Skip to content

Commit

Permalink
Ga/genesis fix (#89)
Browse files Browse the repository at this point in the history
* fix: cheek color

* fix animation reversal

* fix: ensure genesis bibo is always positive, high density
  • Loading branch information
g-a-v-i-n authored Aug 4, 2022
1 parent 12f2473 commit e8aab94
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
4 changes: 3 additions & 1 deletion src/libraries/Body.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ library Body {
string[7] memory radii = ["64", "64", "64", "56", "48", "32", "24"];

string memory backgroundFill = Palette.backgroundFill(_seed, _tokenId);
string memory mixBlendMode = Traits.polarityType(_seed) == PolarityType.POSITIVE ? "lighten" : "multiply";
string memory mixBlendMode = Traits.polarityType(_seed, _tokenId) == PolarityType.POSITIVE
? "lighten"
: "multiply";

string memory bodyGroupChildren = _bodyBackground(backgroundFill);

Expand Down
4 changes: 2 additions & 2 deletions src/libraries/Motes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ library Motes {
RENDER
//////////////////////////////////////////////////////////////*/

function render(bytes32 _seed) internal pure returns (string memory) {
function render(bytes32 _seed, uint256 _tokenId) internal pure returns (string memory) {
string memory motesChildren;

MoteType moteType = Traits.moteType(_seed);
Expand All @@ -35,7 +35,7 @@ library Motes {
string memory delay = Data.shorterTimes(moteSeed /= Data.length);
string[2] memory coords = Data.motePoints(moteSeed /= Data.length);
string memory radius = (moteSeed /= 2) % 2 == 0 ? "1" : "2";
string memory opacity = Palette.opacity(moteSeed /= Palette.opacityLength, _seed);
string memory opacity = Palette.opacity(moteSeed /= Palette.opacityLength, _seed, _tokenId);
bool reverse = moteSeed % 2 == 0;

if (moteType == MoteType.FLOATING)
Expand Down
24 changes: 12 additions & 12 deletions src/libraries/Palette.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,23 @@ library Palette {
) 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);
if (Traits.densityType(_seed, _tokenId) == DensityType.HIGH) {
if (Traits.polarityType(_seed, _tokenId) == PolarityType.POSITIVE) return _light(bodyFillValue);
else return _invertedLight(bodyFillValue);
} else {
if (Traits.polarityType(_seed) == PolarityType.POSITIVE) return _lightest(bodyFillValue);
if (Traits.polarityType(_seed, _tokenId) == PolarityType.POSITIVE) return _lightest(bodyFillValue);
else return _invertedLightest(bodyFillValue);
}
}

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);
if (Traits.densityType(_seed, _tokenId) == DensityType.HIGH) {
if (Traits.polarityType(_seed, _tokenId) == PolarityType.POSITIVE) return _darkest(backgroundFillValue);
else return _invertedDarkest(backgroundFillValue);
} else {
if (Traits.polarityType(_seed) == PolarityType.POSITIVE) return _darkest(backgroundFillValue);
if (Traits.polarityType(_seed, _tokenId) == PolarityType.POSITIVE) return _darkest(backgroundFillValue);
else return _invertedDarkest(backgroundFillValue);
}
}
Expand All @@ -57,10 +53,14 @@ library Palette {
OPACITY
//////////////////////////////////////////////////////////////*/

function opacity(uint256 _glintSeed, bytes32 _seed) internal pure returns (string memory) {
function opacity(
uint256 _glintSeed,
bytes32 _seed,
uint256 _tokenId
) internal pure returns (string memory) {
return
(
Traits.densityType(_seed) == DensityType.HIGH
Traits.densityType(_seed, _tokenId) == DensityType.HIGH
? ["0.3", "0.4", "0.5", "0.6", "0.7"]
: ["0.6", "0.7", "0.8", "0.9", "1.0"]
)[_glintSeed % opacityLength];
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/Render.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ library Render {
_tokenId: _tokenId,
_name: _name(_tokenId),
_description: description,
_attributes: Traits.attributes(_seed),
_attributes: Traits.attributes(_seed, _tokenId),
_backgroundColor: Palette.backgroundFill(_seed, _tokenId),
_svg: _svg(_seed, _tokenId)
});
Expand All @@ -46,7 +46,7 @@ library Render {
Data.defs(),
Background.render(_seed, _tokenId),
Body.render(_seed, _tokenId),
Motes.render(_seed),
Motes.render(_seed, _tokenId),
Glints.render(_seed),
Face.render(_seed)
);
Expand Down
20 changes: 11 additions & 9 deletions src/libraries/Traits.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ library Traits {
TRAITS
//////////////////////////////////////////////////////////////*/

function attributes(bytes32 _seed) internal pure returns (string memory) {
function attributes(bytes32 _seed, uint256 _tokenId) internal pure returns (string memory) {
string memory result = "[";
result = string.concat(result, _attribute("Density", densityTrait(_seed)));
result = string.concat(result, ",", _attribute("Polarity", polarityTrait(_seed)));
result = string.concat(result, _attribute("Density", densityTrait(_seed, _tokenId)));
result = string.concat(result, ",", _attribute("Polarity", polarityTrait(_seed, _tokenId)));
result = string.concat(result, ",", _attribute("Glints", glintTrait(_seed)));
result = string.concat(result, ",", _attribute("Motes", moteTrait(_seed)));
result = string.concat(result, ",", _attribute("Eyes", eyeTrait(_seed)));
Expand All @@ -43,14 +43,15 @@ library Traits {
DENSITY
//////////////////////////////////////////////////////////////*/

function densityTrait(bytes32 _seed) internal pure returns (string memory) {
DensityType type_ = densityType(_seed);
function densityTrait(bytes32 _seed, uint256 _tokenId) internal pure returns (string memory) {
DensityType type_ = densityType(_seed, _tokenId);
return type_ == DensityType.HIGH ? "High" : "Low";
}

function densityType(bytes32 _seed) internal pure returns (DensityType) {
function densityType(bytes32 _seed, uint256 _tokenId) internal pure returns (DensityType) {
uint256 densityRarity = _rarity(_seed, "density");

if (_tokenId == 0) return DensityType.HIGH;
if (densityRarity < 80) return DensityType.HIGH;
return DensityType.LOW;
}
Expand All @@ -59,14 +60,15 @@ library Traits {
POLARITY
//////////////////////////////////////////////////////////////*/

function polarityTrait(bytes32 _seed) internal pure returns (string memory) {
PolarityType type_ = polarityType(_seed);
function polarityTrait(bytes32 _seed, uint256 _tokenId) internal pure returns (string memory) {
PolarityType type_ = polarityType(_seed, _tokenId);
return type_ == PolarityType.POSITIVE ? "Positive" : "Negative";
}

function polarityType(bytes32 _seed) internal pure returns (PolarityType) {
function polarityType(bytes32 _seed, uint256 _tokenId) internal pure returns (PolarityType) {
uint256 polarityRarity = _rarity(_seed, "polarity");

if (_tokenId == 0) return PolarityType.POSITIVE;
if (polarityRarity < 80) return PolarityType.POSITIVE;
return PolarityType.NEGATIVE;
}
Expand Down

0 comments on commit e8aab94

Please sign in to comment.