diff --git a/packages/contracts/src/LucidOrigins.sol b/packages/contracts/src/LucidOrigins.sol
index 0496ec0..f4465f7 100644
--- a/packages/contracts/src/LucidOrigins.sol
+++ b/packages/contracts/src/LucidOrigins.sol
@@ -21,7 +21,7 @@ contract LucidOrigins is Owned, ERC721A, Background, Face, Blob, Blush, Colors {
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
uint16[] memory dna = getDna(uint256(keccak256(abi.encodePacked(tokenId))));
- string memory name = string(abi.encodePacked("LucidOrigins #", tokenId.toString()));
+ string memory name = string.concat("LucidOrigins #", tokenId.toString());
string memory background = background(normalizeToRange(dna[Constants.BACKGROUND_INDEX], 0, 16));
string memory layers = "";
@@ -38,7 +38,7 @@ contract LucidOrigins is Owned, ERC721A, Background, Face, Blob, Blush, Colors {
uint256 edgesNum = normalizeToRange(dna[Constants.EDGES_NUM_INDEX] * i, 10, 15);
string memory path1 = createSvgPath(createPoints(size, 50, 0, minGrowth, edgesNum));
string memory path2 = createSvgPath(createPoints(size + 1, 50, 0, minGrowth, edgesNum));
- layers = string(abi.encodePacked(layers, build(i, colorDefs, fillColor, path1, path2)));
+ layers = string.concat(layers, build(i, colorDefs, fillColor, path1, path2));
unchecked {
size = size - 30;
}
@@ -49,44 +49,37 @@ contract LucidOrigins is Owned, ERC721A, Background, Face, Blob, Blush, Colors {
normalizeToRange(dna[Constants.EYE_PUPIL_RADIUS_INDEX], 0, 6),
fillColor
);
- string memory svgContent = string(abi.encodePacked(layers, face, blush()));
+ string memory svgContent = string.concat(layers, face, blush());
uint256 rotation = normalizeToRange(dna[Constants.SIZE_INDEX], 0, 3);
- string memory svg = string(
- abi.encodePacked(
- '"
- )
+ string memory svg = string.concat(
+ '"
);
- // console2.log(svg);
return metadata(name, svg);
}
function rotationWrapper(uint256 rotation, string memory content) internal pure returns (string memory) {
string memory rotationDegree = rotation == 0 ? "0" : rotation == 1 ? "90" : rotation == 2 ? "180" : "-90";
- return string(
- abi.encodePacked(
- '", content, ""
- )
+ return string.concat(
+ '", content, ""
);
}
function metadata(string memory name, string memory svg) internal pure returns (string memory) {
string memory description = "LucidOrigins, fully on-chain NFT";
- string memory json = string(
- abi.encodePacked(
- '{"name":"',
- name,
- '","description":"',
- description,
- '","image": "data:image/svg+xml;base64,',
- Encoder.base64(bytes(svg)),
- '"}'
- )
+ string memory json = string.concat(
+ '{"name":"',
+ name,
+ '","description":"',
+ description,
+ '","image": "data:image/svg+xml;base64,',
+ Encoder.base64(bytes(svg)),
+ '"}'
);
- return string(abi.encodePacked("data:application/json;base64,", Encoder.base64(bytes(json))));
+ return string.concat("data:application/json;base64,", Encoder.base64(bytes(json)));
}
function getDna(uint256 preDna) internal pure returns (uint16[] memory) {
@@ -139,19 +132,17 @@ contract LucidOrigins is Owned, ERC721A, Background, Face, Blob, Blush, Colors {
bool isPlain = base < 80;
string memory colorDefs = isPlain
? ""
- : string(
- abi.encodePacked(
- "",
- '',
- '',
- '',
- "",
- ""
- )
+ : string.concat(
+ "",
+ '',
+ '',
+ '',
+ "",
+ ""
);
string memory fillColor = isPlain ? colors[color1] : "url(#linear-grad)";
diff --git a/packages/contracts/src/layers/Background.sol b/packages/contracts/src/layers/Background.sol
index ac358bd..760c3fc 100644
--- a/packages/contracts/src/layers/Background.sol
+++ b/packages/contracts/src/layers/Background.sol
@@ -1,35 +1,96 @@
// SPDX-License-Identifier: GNU GPLv3
pragma solidity 0.8.23;
-// import { console2 } from "forge-std/console2.sol";
+import { console2 } from "forge-std/console2.sol";
+import { LibString } from "solmate/utils/LibString.sol";
contract Background {
+ using LibString for int256;
+
string[20] internal bgColors = [
- "#FAF4EF",
- "#EFFAEF",
- "#EFF4FA",
- "#FAEFFA",
- "#EFF4FA",
- "#F4EFFA",
- "#FAFAEF",
- "#FAEFF4",
- "#EFFAFA",
- "#EFF7EB",
- "#DBDBDB",
- "#EDF1F7",
- "#EFF7EB",
- "#F7F7E9",
- "#EFEFEF",
- "#F0E6E6",
- "#E6F0EE",
- "#F0E6F0",
- "#E6E6F0",
- "#F0EEDB"
+ "#F8F8F8",
+ "#F0F0F0",
+ "#E8E8E8",
+ "#E0E0E0",
+ "#D8D8D8",
+ "#D0D0D0",
+ "#C8C8C8",
+ "#C0C0C0",
+ "#B8B8B8",
+ "#B0B0B0",
+ "#A8A8A8",
+ "#A0A0A0",
+ "#989898",
+ "#909090",
+ "#888888",
+ "#808080",
+ "#787878",
+ "#707070",
+ "#686868",
+ "#606060"
];
+ function generatePath(int256 curveVal, int256 pos, int256 index) internal pure returns (string memory) {
+ int256 cVal = curveVal % 100;
+ int256 bigC = 100 - cVal;
+
+ int256 part1x = 33 + pos + 66 * index;
+ int256 part3x = 66 - pos - 66 * index;
+ int256 part5x = 33 + pos + 66 * index;
+
+ return string.concat(
+ "m 50 ",
+ part1x.toString(),
+ " Q ",
+ bigC.toString(),
+ " ",
+ cVal.toString(),
+ " ",
+ part3x.toString(),
+ " 50 Q ",
+ bigC.toString(),
+ " ",
+ bigC.toString(),
+ " 50 ",
+ part3x.toString(),
+ " Q ",
+ cVal.toString(),
+ " ",
+ bigC.toString(),
+ " ",
+ part5x.toString(),
+ " 50 Q ",
+ cVal.toString(),
+ " ",
+ cVal.toString(),
+ " 50 ",
+ part5x.toString(),
+ " z"
+ );
+ }
+
+ function hydrateBlog(string[3] memory paths, string[3] memory colors) internal pure returns (string memory) {
+ return string.concat(
+ ''
+ );
+ }
+
function background(uint256 dnaBgLayer) internal view returns (string memory) {
- return
-
- string(abi.encodePacked('',''));
+ string[3] memory paths = [generatePath(68, 23, 2), generatePath(11, 70, 1), generatePath(38, 67, 0)];
+ string[3] memory colors = ["#27b4f6", "#D84B09", "#F67094"];
+ console2.log(hydrateBlog(paths, colors));
+ return hydrateBlog(paths, colors);
}
}
diff --git a/packages/contracts/src/layers/Blob.sol b/packages/contracts/src/layers/Blob.sol
index 486680b..946dca5 100644
--- a/packages/contracts/src/layers/Blob.sol
+++ b/packages/contracts/src/layers/Blob.sol
@@ -73,29 +73,27 @@ contract Blob {
string memory svgPath;
Point memory mid = Point({ x: (points[0].x + points[1].x) / 2, y: (points[0].y + points[1].y) / 2 });
- svgPath = string(abi.encodePacked("M", mid.x.toString(), ",", mid.y.toString()));
+ svgPath = string.concat("M", mid.x.toString(), ",", mid.y.toString());
for (uint256 i = 0; i < points.length; i++) {
Point memory p1 = points[(i + 1) % points.length];
Point memory p2 = points[(i + 2) % points.length];
Point memory midPoint = Point({ x: (p1.x + p2.x) / 2, y: (p1.y + p2.y) / 2 });
- svgPath = string(
- abi.encodePacked(
- svgPath,
- "Q",
- p1.x.toString(),
- ",",
- p1.y.toString(),
- ",",
- midPoint.x.toString(),
- ",",
- midPoint.y.toString()
- )
+ svgPath = string.concat(
+ svgPath,
+ "Q",
+ p1.x.toString(),
+ ",",
+ p1.y.toString(),
+ ",",
+ midPoint.x.toString(),
+ ",",
+ midPoint.y.toString()
);
}
- return string(abi.encodePacked(svgPath, "Z"));
+ return string.concat(svgPath, "Z");
}
function build(
@@ -109,31 +107,29 @@ contract Blob {
pure
returns (string memory)
{
- return string(
- abi.encodePacked(
- colorDefs,
- '',
- '',
- '',
- ""
- )
+ return string.concat(
+ colorDefs,
+ '',
+ '',
+ '',
+ ""
);
}
}
diff --git a/packages/contracts/src/layers/Blush.sol b/packages/contracts/src/layers/Blush.sol
index 09d11c8..8ce1074 100644
--- a/packages/contracts/src/layers/Blush.sol
+++ b/packages/contracts/src/layers/Blush.sol
@@ -3,13 +3,11 @@ pragma solidity 0.8.23;
contract Blush {
function blush() internal pure returns (string memory) {
- return string(
- abi.encodePacked(
- '',
- ''
- )
+ return string.concat(
+ '',
+ ''
);
}
}
diff --git a/packages/contracts/src/layers/Face.sol b/packages/contracts/src/layers/Face.sol
index f60b23f..6da8335 100644
--- a/packages/contracts/src/layers/Face.sol
+++ b/packages/contracts/src/layers/Face.sol
@@ -18,7 +18,7 @@ contract Face {
returns (string memory)
{
string memory eyes = getEyes(eyeRadius, eyeSeparation, pupilRadius, pupilColor);
- return string(abi.encodePacked('', eyes, ""));
+ return string.concat('', eyes, "");
}
function getEyes(
@@ -31,33 +31,31 @@ contract Face {
pure
returns (string memory)
{
- return string(
- abi.encodePacked(
- '',
- '',
- '' '',
- '' ""
- )
+ return string.concat(
+ '',
+ '',
+ '' '',
+ '' ""
);
}
@@ -71,33 +69,31 @@ contract Face {
pure
returns (string memory)
{
- return string(
- abi.encodePacked(
- '',
- '',
- '',
- ""
- )
+ return string.concat(
+ '',
+ '',
+ '',
+ ""
);
}
@@ -114,45 +110,43 @@ contract Face {
{
uint256 leftEyebrowScale = eyebrowRotation > 10 ? 0 : 1;
uint256 rightEyebrowScale = mouthRotation > 3 ? 0 : 1;
- return string(
- abi.encodePacked(
- '',
- '',
- '',
- ""
- )
+ return string.concat(
+ '',
+ '',
+ '',
+ ""
);
}
@@ -177,30 +171,28 @@ contract Face {
uint256 y2 = eyeSeparation > 25 ? 50 + size : 50 - size;
uint256 y3 = 50 + controlY;
- return string(
- abi.encodePacked(
- '',
- '',
- ""
- )
+ return string.concat(
+ '',
+ '',
+ ""
);
}
}