diff --git a/lib/forge-std b/lib/forge-std index 9825609..27e14b7 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 98256095f37d83653ba1617d06ccd9604cbd7c6d +Subproject commit 27e14b7f2448e5f5ac32719f51fe652aa0b0733e diff --git a/lib/solmate b/lib/solmate index 2979a7a..d155ee8 160000 --- a/lib/solmate +++ b/lib/solmate @@ -1 +1 @@ -Subproject commit 2979a7afe20d3b26bcbe2a278549bd08a88d7f4b +Subproject commit d155ee8d58f96426f57c015b34dee8a410c1eacc diff --git a/src/libraries/Background.sol b/src/libraries/Background.sol index 714986e..73589de 100644 --- a/src/libraries/Background.sol +++ b/src/libraries/Background.sol @@ -5,14 +5,14 @@ import {Palette} from "./Palette.sol"; import {SVG} from "./SVG.sol"; library Background { - function render(bytes32 _seed) internal pure returns (string memory) { + function render(bytes32 _seed, uint256 _tokenId) internal pure returns (string memory) { return SVG.element( "rect", SVG.rectAttributes({ _width: "100%", _height: "100%", - _fill: Palette.backgroundFill(_seed), + _fill: Palette.backgroundFill(_seed, _tokenId), _attributes: "" }) ); diff --git a/src/libraries/Body.sol b/src/libraries/Body.sol index 885ef91..108bc1c 100644 --- a/src/libraries/Body.sol +++ b/src/libraries/Body.sol @@ -12,11 +12,11 @@ library Body { RENDER //////////////////////////////////////////////////////////////*/ - function render(bytes32 _seed) internal pure returns (string memory) { + function render(bytes32 _seed, uint256 _tokenId) internal pure returns (string memory) { string memory bodyGroupChildren; string[7] memory radii = ["64", "64", "64", "56", "48", "32", "24"]; - string memory backgroundFill = Palette.backgroundFill(_seed); + string memory backgroundFill = Palette.backgroundFill(_seed, _tokenId); string memory mixBlendMode = Traits.polarityType(_seed) == PolarityType.POSITIVE ? "lighten" : "multiply"; bodyGroupChildren = string.concat(bodyGroupChildren, _bodyBackground(backgroundFill)); @@ -26,7 +26,13 @@ library Body { for (uint8 i = 0; i < 7; i++) { uint256 bodySeed = uint256(keccak256(abi.encodePacked(_seed, "body", i))); - string memory bodyFill = Palette.bodyFill(_seed, i); + string memory bodyFill = Palette.bodyFill(_seed, i, _tokenId); + string memory bodyFill2 = Palette.bodyFill( + _seed, + i + 7, + _tokenId + ); + string memory radius = radii[i]; string memory dur = Data.shortTimes(bodySeed); @@ -38,9 +44,37 @@ library Body { bool reverse = bodySeed % 2 == 0; bodySeed /= 2; + string memory maybeGenesis = _tokenId == 0 + ? string.concat( + '' + ) + : ""; + bodyGroupChildren = string.concat( bodyGroupChildren, - _bodyCircle(radius, coords, bodyFill, dur, reverse, mixBlendMode) + '', + SVG.element("animateMotion", SVG.animateMotionAttributes(reverse, dur, "linear"), Data.mpathJitterLg()), + maybeGenesis, + "" + // _bodyCircle(radius, coords, bodyFill, bodyFill2, dur, reverse, mixBlendMode) ); } return @@ -51,27 +85,6 @@ library Body { ); } - function _bodyCircle( - string memory _radius, - string[2] memory _coords, - string memory _fill, - string memory _dur, - bool _reverse, - string memory _mixBlendMode - ) internal pure returns (string memory) { - string memory opacity = "1"; - return - SVG.element( - "circle", - SVG.circleAttributes(_radius, _coords, _fill, opacity, _mixBlendMode, ""), - SVG.element( - "animateMotion", - SVG.animateMotionAttributes(_reverse, _dur, "linear"), - Data.mpathJitterLg() - ) - ); - } - function _bodyBackground(string memory _fill) internal pure returns (string memory) { return SVG.element("rect", SVG.rectAttributes({_width: "100%", _height: "100%", _fill: _fill, _attributes: ""})); diff --git a/src/libraries/Misc.sol b/src/libraries/Misc.sol deleted file mode 100644 index d2bbfa1..0000000 --- a/src/libraries/Misc.sol +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: Unlicense -pragma solidity >=0.8.0; - -library Misc { - function render(uint256 _tokenId) internal pure returns (string memory) { - if (_tokenId == 0) return _badge(); - return _empty(); - } - - function _badge() internal pure returns (string memory) { - return - string.concat( - '', - '', - '', - '', - '', - '', - "", - "" - ); - } - - function _empty() internal pure returns (string memory) { - return ""; - } -} diff --git a/src/libraries/Palette.sol b/src/libraries/Palette.sol index 362a6b6..ddb593a 100644 --- a/src/libraries/Palette.sol +++ b/src/libraries/Palette.sol @@ -26,9 +26,15 @@ library Palette { )[_glintSeed % opacityLength]; } - function bodyFill(bytes32 _seed, uint256 _i) internal pure returns (string memory) { + function bodyFill( + bytes32 _seed, + uint256 _i, + uint256 _tokenId + ) internal pure returns (string memory) { uint256 bodyFillValue = uint256(keccak256(abi.encodePacked(_seed, "bodyFill", _i))); + if (_tokenId == 0) return _light(bodyFillValue); + if (Traits.densityType(_seed) == DensityType.HIGH) { if (Traits.polarityType(_seed) == PolarityType.POSITIVE) { return _light(bodyFillValue); @@ -44,9 +50,11 @@ library Palette { } } - function backgroundFill(bytes32 _seed) internal pure returns (string memory) { + function backgroundFill(bytes32 _seed, uint256 _tokenId) internal pure returns (string memory) { uint256 backgroundFillValue = uint256(keccak256(abi.encodePacked(_seed, "backgroundFill"))); + if (_tokenId == 0) return _darkest(backgroundFillValue); + if (Traits.densityType(_seed) == DensityType.HIGH) { if (Traits.polarityType(_seed) == PolarityType.POSITIVE) { return _darkest(backgroundFillValue); diff --git a/src/libraries/Render.sol b/src/libraries/Render.sol index 2ceadfb..6606000 100644 --- a/src/libraries/Render.sol +++ b/src/libraries/Render.sol @@ -13,7 +13,6 @@ import {Motes} from "./Motes.sol"; import {Glints} from "./Glints.sol"; import {Traits} from "./Traits.sol"; import {SVG} from "./SVG.sol"; -import {Misc} from "./Misc.sol"; library Render { string public constant description = "Bibos"; @@ -25,7 +24,7 @@ library Render { _name: _name(_tokenId), _description: description, _attributes: Traits.attributes(_seed), - _backgroundColor: Palette.backgroundFill(_seed), + _backgroundColor: Palette.backgroundFill(_seed, _tokenId), _svg: _svg(_seed, _tokenId) }); } @@ -36,12 +35,11 @@ library Render { "svg", SVG.svgAttributes(), Data.defs(), - Background.render(_seed), - Body.render(_seed), + Background.render(_seed, _tokenId), + Body.render(_seed, _tokenId), Motes.render(_seed), Glints.render(_seed), - Face.render(_seed), - Misc.render(_tokenId) + Face.render(_seed) ); } diff --git a/src/scripts/local_render.sol b/src/scripts/local_render.sol index f449b10..221ff65 100644 --- a/src/scripts/local_render.sol +++ b/src/scripts/local_render.sol @@ -19,15 +19,15 @@ contract local_render is Test { vm.warp(unixTime); // compute a random tokenId - uint256 tokenId = unixTime % 999; + uint256 tokenId = unixTime % 1111; // set the total supply // (in storage slot 7) vm.store(address(bibos), bytes32(uint256(7)), bytes32(tokenId)); // mint - vm.deal(address(this), .111 ether); - bibos.mint{value: .111 ether}(); + vm.deal(address(this), .1 ether); + bibos.mint{value: .1 ether}(); tokenURI = bibos.tokenURI(tokenId); } @@ -41,11 +41,11 @@ contract local_render is Test { tokenURIs = new string[](_amount); - vm.deal(address(this), _amount * .111 ether); + vm.deal(address(this), _amount * .1 ether); uint256 i; for (; i < _amount; ++i) { // mint - bibos.mint{value: .111 ether}(); + bibos.mint{value: .1 ether}(); tokenURIs[i] = bibos.tokenURI(i); } }