Skip to content

Commit

Permalink
choreasset improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
jpgonzalezra committed Jan 22, 2024
1 parent eba8ee5 commit 8469ba6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 38 deletions.
18 changes: 9 additions & 9 deletions packages/contracts/src/LucidOrigins.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ contract LucidOrigins is Owned, ERC721A, Background, Face, Body, Head, Blush {
string memory linesColor = isColorDark(r, g, b) ? "#FFF" : "#000";
string memory face = face(
normalizeToRange(dna[Constants.EYE_RADIUS_INDEX], 4, 7),
normalizeToRange(dna[Constants.EYE_BROW_LENGHT_INDEX], 1, 4),
normalizeToRange(dna[Constants.EYE_BROW_LENGHT_INDEX], 2, 4),
normalizeToRange(dna[Constants.EYE_SEPARATION_INDEX], 20, 30),
normalizeToRange(dna[Constants.EYE_BROW_ROTATION_INDEX], 0, 20),
normalizeToRange(dna[Constants.MOUNTH_ROTATION], 0, 6),
normalizeToRange(dna[Constants.EYE_BROW_SIZE_INDEX], 1, 5),
linesColor
);

(string memory colorDefs, string memory fillColor) = getColor(r, g, b, r2, g2, b2, dna[Constants.BASE_INDEX]);
(string memory head, string memory stroke) = head(
normalizeToRange(dna[Constants.HEAD_SIZE_INDEX], 85, 88),
normalizeToRange(dna[Constants.HEAD_SIZE_INDEX], 0, 2),
(string memory colorDefs, string memory fillColor) =
getColor(r, g, b, r2, g2, b2, normalizeToRange(dna[Constants.BASE_INDEX], 0, 100));
string memory head = head(
normalizeToRange(dna[Constants.HEAD_SIZE_INDEX], 80, 88),
normalizeToRange(dna[Constants.HEAD_SIZE_INDEX], 1, 3),
normalizeToRange(dna[Constants.HEAD_MIN_GROWTH_INDEX], 6, 9),
normalizeToRange(dna[Constants.HEAD_EDGES_NUM_INDEX], 7, 20),
colorDefs,
fillColor
);

string memory footer = "</svg>";
string memory svg = string(
abi.encodePacked(header, background, body(colorDefs, fillColor), head, stroke, blush(), face, footer)
);
string memory svg =
string(abi.encodePacked(header, background, body(colorDefs, fillColor), head, blush(), face, footer));

return metadata(name, svg);
}
Expand Down Expand Up @@ -131,7 +131,7 @@ contract LucidOrigins is Owned, ERC721A, Background, Face, Body, Head, Blush {
pure
returns (string memory, string memory)
{
bool isPlain = base < 20;
bool isPlain = base < 80;
string memory colorDefs = isPlain
? ""
: string(
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/src/layers/Blush.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ contract Blush {
'<circle id="circle-blush" r="6" fill="rgba(255,255,255,0.4)" />',
'<animateMotion href="#circle-blush" dur="30s" begin="0s" ',
'fill="freeze" repeatCount="indefinite" rotate="auto-reverse" ',
'><mpath href="#body-stroke" /></animateMotion>'
'><mpath href="#head" /></animateMotion>'
)
);
}
Expand Down
32 changes: 4 additions & 28 deletions packages/contracts/src/layers/Head.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ contract Head {
)
internal
view
returns (string memory, string memory)
returns (string memory)
{
Point[] memory points = createPoints(size, minGrowth, edgesNum);
string memory h1 = createSvgPath(points);
string memory h2 = createSvgPath(createPoints(size + animation, minGrowth, edgesNum));
return (buildHead(colorDefs, fillColor, h1, h2), buildStroke(h1, h2));
return buildHead(colorDefs, fillColor, h1, h2);
}

function createPoints(uint256 size, uint256 minGrowth, uint256 edgesNum) internal view returns (Point[] memory) {
Expand Down Expand Up @@ -112,7 +112,7 @@ contract Head {
colorDefs,
'<path id="head" d="',
h1,
'Z" transform-origin="center" fill="',
'Z" stroke-width="2" stroke="black" transform-origin="center" fill="',
fillColor,
'">',
'<animate attributeName="d" values="',
Expand All @@ -125,31 +125,7 @@ contract Head {
' keysplines=".42 0 1 1; 0 0 .59 1; .42 0 1 1; 0 0 .59 1;',
' .42 0 1 1; 0 0 .59 1; .42 0 1 1; 0 0 .59 1;"/>',
'<animateTransform attributeName="transform" type="rotate" ',
'from="0" to="10" dur="1000" repeatCount="indefinite" />',
"</path>"
)
);
}

function buildStroke(string memory h, string memory h2) private pure returns (string memory) {
return string(
abi.encodePacked(
'<path d="',
h,
'Z" id="body-stroke" stroke="',
"black",
'" stroke-width="2" fill="none" transform-origin="center">',
'<animate attributeName="d" values="',
h,
";",
h2,
";",
h,
'" dur="16s" id="stroke-anim" repeatCount="indefinite" ',
'begin="body-anim.begin + 2s" keysplines=".42 0 1 1; 0 0 .59 1; ',
'.42 0 1 1; 0 0 .59 1; .42 0 1 1; 0 0 .59 1; .42 0 1 1; 0 0 .59 1;"/>',
'<animateTransform attributeName="transform" type="rotate" from="0" ',
'to="30" dur="1000" repeatCount="indefinite" />',
'from="0" to="30" dur="1000" repeatCount="indefinite" />',
"</path>"
)
);
Expand Down

0 comments on commit 8469ba6

Please sign in to comment.