Skip to content

Commit

Permalink
chore: swap glints and motes in name + vice versa (#57)
Browse files Browse the repository at this point in the history
* inspector: use babel for m1

* fix: change mouth trait title from eyes to mouth

* chore: swap `glint` for `mote` and vice versa
  • Loading branch information
g-a-v-i-n authored Jul 3, 2022
1 parent 83dc97e commit d7323b2
Show file tree
Hide file tree
Showing 15 changed files with 204 additions and 204 deletions.
2 changes: 1 addition & 1 deletion deployment/get_deployments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ get_address "Cheeks"
get_address "Eyes"
get_address "Face"
get_address "Body"
get_address "Glints"
get_address "Motes"

COMPUTED_ADDRESS_OUTPUT=$(cast compute-address --nonce 1 $DEPLOYER)
BIBOS_ADDRESS=${COMPUTED_ADDRESS_OUTPUT:(-42)}
Expand Down
2 changes: 1 addition & 1 deletion lib/forge-std
2 changes: 1 addition & 1 deletion lib/solmate
6 changes: 3 additions & 3 deletions rarity.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ export const refractivityTypes = [
]

2
export const glintTypes = [
export const moteTypes = [
'None', // 60%
'Floating', // 20%
'Rising', // 15%
'Falling', // 5%
]

export const moteTypes = [
export const glintTypes = [
'Gleam',
]

3
export const moteCountChoices = [
export const glintCountChoices = [
0, // 65%
1, // 30%
2, // 4%
Expand Down
12 changes: 6 additions & 6 deletions src/dev/PointsUncompressed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ library PointsUncompressed {
return bodyPoints[_index % 64];
}

function glint(uint256 _index) external pure returns (string[2] memory) {
string[2][64] memory glintPoints = [
function mote(uint256 _index) external pure returns (string[2] memory) {
string[2][64] memory motePoints = [
["241", "131"],
["238", "108"],
["225", "134"],
Expand Down Expand Up @@ -142,11 +142,11 @@ library PointsUncompressed {
["108", "165"],
["72", "160"]
];
return glintPoints[_index % 64];
return motePoints[_index % 64];
}

function motes(uint256 _index) external pure returns (string[2][3] memory) {
string[2][3][24] memory motePoints = [
function glints(uint256 _index) external pure returns (string[2][3] memory) {
string[2][3][24] memory glintPoints = [
[["173", "94"], ["107", "193"], ["206", "127"]],
[["107", "193"], ["150", "210"], ["193", "193"]],
[["173", "206"], ["94", "127"], ["150", "210"]],
Expand All @@ -172,6 +172,6 @@ library PointsUncompressed {
[["94", "127"], ["127", "94"], ["150", "210"]],
[["210", "150"], ["90", "150"], ["150", "90"]]
];
return motePoints[_index % 24];
return glintPoints[_index % 24];
}
}
8 changes: 4 additions & 4 deletions src/dev/PointsUtil.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ library PointsUtil {
return result;
}

function getGlints() internal pure returns (bytes memory) {
function getMotes() internal pure returns (bytes memory) {
// all in format XXX.XX
// numbers less than 256

bytes memory result;
uint256 i;
for (; i < 64; ) {
string[2] memory pair = PointsUncompressed.glint(i);
string[2] memory pair = PointsUncompressed.mote(i);
result = _concatPair(result, pair[0], pair[1]);
++i;
}
return result;
}

function getMotes() internal pure returns (bytes memory) {
function getGlints() internal pure returns (bytes memory) {
// all in format XXX

uint256 i;
bytes memory result;
for (; i < 64; ) {
string[2][3] memory pair = PointsUncompressed.motes(i);
string[2][3] memory pair = PointsUncompressed.glints(i);
uint256 j;
for (; j < 3; ) {
result = _concatPair(result, pair[j][0], pair[j][1]);
Expand Down
16 changes: 8 additions & 8 deletions src/libraries/Data.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ library Data {
return [x, y];
}

function glintPoints(uint256 _i) external pure returns (string[2] memory) {
function motePoints(uint256 _i) external pure returns (string[2] memory) {
uint256 pos = (_i % length) * 2;
string memory x = Util.bytes1ToString(glintsPointsBytes[pos]);
string memory y = Util.bytes1ToString(glintsPointsBytes[pos + 1]);
string memory x = Util.bytes1ToString(motesPointsBytes[pos]);
string memory y = Util.bytes1ToString(motesPointsBytes[pos + 1]);
return [x, y];
}

function motePoints(uint256 _i) external pure returns (string[2][3] memory) {
function glintPoints(uint256 _i) external pure returns (string[2][3] memory) {
uint256 pos = (_i % length) * 6;
string[2][3] memory result;
uint256 i;
for (; i < 3; ) {
string memory x = Util.bytes1ToString(motePointsBytes[pos + 2 * i]);
string memory y = Util.bytes1ToString(motePointsBytes[pos + 2 * i + 1]);
string memory x = Util.bytes1ToString(glintPointsBytes[pos + 2 * i]);
string memory y = Util.bytes1ToString(glintPointsBytes[pos + 2 * i + 1]);
result[i] = [x, y];
++i;
}
Expand Down Expand Up @@ -102,9 +102,9 @@ library Data {
uint256 constant length = 64;
bytes constant bodyPointsBytes =
hex"75727a8f887c748087736b88906c8a8b7ba397906b7f7a79729488a1829766966faa92846da1a578947983849e6c79af8db891a686b48dafae95a09e9099ad8aa7a49e88a28073887a98b670b77abd84b58eae7ca391b484ad6f7e7278b78bc39ac69ebaa5b483ab85bc9da895ad95bec68eaeabb89aadbebbb1a6c19db1b2b6";
bytes constant glintsPointsBytes =
bytes constant motesPointsBytes =
hex"f183ee6ce186db75f29ae15fdf97d28dc364c680e8add850efc3d4abc69cb54daa67b971aa84b397c753d5c4c5c1b8b2a055957ca19ee4d2cedcbed3b0c0a2b2a3448f469163878e8ea69a90b5e9a1d897c989b97c44786282547e7172967b8287e683d379b46c5069706287579aa3eb71ee73d461b75b5a5a6b507e6ca548a0";
bytes constant motePointsBytes =
bytes constant glintPointsBytes =
hex"ad5e6bc1ce7f6bc196d2c1c1adce5e7f96d25e7fc16b6b6b965ac1c16bc16bc15ead5a96ce7fcead96d2965a5e7fce7fc16b5a9696d2ad5e6b6bc1c17f5e5ead7fcece7f5eadd296d296c1c17f5e6b6b5ead7f5eadcecead5a965a9696d26b6b965aadce5a96ceadadce6b6b965a5a967f5e5e7f7f5ecead7f5ec1c1ce7f7f5e7fce96d25e7f7f5e96d2d2965a96965aad5e6bc1ce7f6bc196d2c1c1adce5e7f96d25e7fc16b6b6b965ac1c16bc16bc15ead5a96ce7fcead96d2965a5e7fce7fc16b5a9696d2ad5e6b6bc1c17f5e5ead7fcece7f5eadd296d296c1c17f5e6b6b5ead7f5eadcecead5a965a9696d26b6b965aadce5a96ceadadce6b6b965a5a967f5e5e7f7f5ecead7f5ec1c1ce7f7f5e7fce96d25e7f7f5e96d2d2965a96965aad5e6bc1ce7f6bc196d2c1c1adce5e7f96d25e7fc16b6b6b965ac1c16bc16bc15ead5a96ce7fcead96d2965a5e7fce7fc16b5a9696d2ad5e6b6bc1c17f5e5ead7fcece7f5eadd296d296c1c17f5e6b6b5ead7f5eadcecead5a965a9696d26b6b";
bytes public constant shortTimesBytes =
hex"59614460553a60493b505f3753543e3a6163343849473e333c325e53483b624d34343e48505c595562364d4f4e5d515d53384457604c5a5b4454534148586063";
Expand Down
137 changes: 45 additions & 92 deletions src/libraries/Glints.sol
Original file line number Diff line number Diff line change
@@ -1,131 +1,84 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;

import {Traits} from "libraries/Traits.sol";
import {Palette} from "./Palette.sol";
import {Data} from "./Data.sol";
import {Util} from "./Util.sol";
import {SVG} from "./SVG.sol";
import {Traits} from "./Traits.sol";

enum GlintType {
NONE,
FLOATING,
RISING,
FALLING
}

library Glints {
uint256 constant GLINT_COUNT = 16;

function render(bytes32 _seed) internal pure returns (string memory) {
string memory result;

string memory mixMode = "lighten";
string memory fill = "white";
string memory result = "";
uint256 glintSeed = uint256(keccak256(abi.encodePacked(_seed, "glint"))) % 100;
string memory reverseRotate = glintSeed % 2 == 0 ? "from='0 0 0' to='360 0 0'" : "from='360 0 0' to='0 0 0'";

GlintType glintType = Traits.getGlintType(_seed);
if (glintType == GlintType.NONE) return "";
uint256 glintCount = Traits.getGlintCount(_seed);

for (uint8 i = 0; i < GLINT_COUNT; i++) {
uint256 glintSeed = uint256(keccak256(abi.encodePacked(_seed, "glint", i)));
string memory opacity = Palette.getOpacity(glintSeed, _seed);
glintSeed /= Palette.opacityLength;
string[2][3] memory coords = Data.glintPoints(glintSeed);
glintSeed /= Data.length;

string memory dur = Data.longTimes(glintSeed);
glintSeed = glintSeed / Data.length;
string[2] memory coords = Data.glintPoints(glintSeed);
glintSeed = glintSeed / Data.length;
string memory radius = glintSeed % 2 == 0 ? "1" : "2";
glintSeed = glintSeed / 2;
string memory opacity = Palette.getOpacity(glintSeed, _seed);
glintSeed /= Palette.opacityLength;
for (uint8 index = 0; index < glintCount; index++) {
string memory reverse = glintSeed % 2 == 0 ? "keyPoints='1;0' keyTimes='0;1'" : "";

if (glintType == GlintType.FLOATING) {
string memory reverse = glintSeed % 2 == 0 ? "keyPoints='1;0' keyTimes='0;1'" : "";
result = addFloatingGlint(result, radius, coords, mixMode, fill, opacity, dur, reverse);
} else if (glintType == GlintType.RISING)
result = addRisingGlint(result, radius, coords, mixMode, fill, opacity, dur);
else if (glintType == GlintType.FALLING) {
result = addFallingGlint(result, radius, coords, mixMode, fill, opacity, dur);
}
}

return string.concat("<g>", result, "</g>");
}

function addRisingGlint(
string memory _result,
string memory _radius,
string[2] memory _coords,
string memory _mixMode,
string memory _fill,
string memory _opacity,
string memory _dur
) internal pure returns (string memory) {
return
string.concat(
_result,
'<g transform="translate(0,25)">',
SVG.circle(_radius, _coords, _mixMode, _fill, _opacity),
animateTransform(_dur, "-100"),
SVG.animate(_dur),
"</circle>",
"</g>"
result = addGlint(
result,
Data.longTimes(glintSeed),
Data.shortTimes(glintSeed),
coords[index],
reverseRotate,
reverse,
opacity
);
}
}

function addFloatingGlint(
string memory _result,
string memory _radius,
string[2] memory _coords,
string memory _mixMode,
string memory _fill,
string memory _opacity,
string memory _dur,
string memory _reverse
) internal pure returns (string memory) {
return
string.concat(
_result,
SVG.circle(_radius, _coords, _mixMode, _fill, _opacity),
SVG.animateMotion(_reverse, _dur, "paced", '<mpath xlink:href="#bibo-jitter-sm"/>'),
"</circle>"
);
return string.concat("<g id='glints'>", result, "</g>");
}

function addFallingGlint(
function addGlint(
string memory _result,
string memory _radius,
string memory _durationLong,
string memory _durationShort,
string[2] memory _coords,
string memory _mixMode,
string memory _fill,
string memory _opacity,
string memory _dur
string memory _reverseRotate,
string memory _reverse,
string memory _opacity
) internal pure returns (string memory) {
return
string.concat(
_result,
'<g transform="translate(0,-25)">',
SVG.circle(_radius, _coords, _mixMode, _fill, _opacity),
animateTransform(_dur, "100"),
SVG.animate(_dur),
'<g transform="translate(',
_coords[0],
",",
_coords[1],
') scale(1)">',
"<g>",
SVG.circleFilter("10", ["0", "0"], "lighten", "white", "1.0", "bibo-blur-sm"),
"</circle>",
"<path fill-opacity=",
Util.quote(_opacity),
'fill="white" style="mix-blend-mode:normal" fill-rule="evenodd" clip-rule="evenodd" d="M2.60676 11.4891C2.49095 12.4964 1.95054 13 0.985526 13C0.580218 13 0.223162 12.8644 -0.0856447 12.5932C-0.39445 12.322 -0.577804 11.9831 -0.635705 11.5763C-0.86731 9.71671 -1.10856 8.28329 -1.35947 7.27603C-1.59107 6.2494 -1.97708 5.47458 -2.51749 4.95157C-3.0386 4.42857 -3.85887 4.02179 -4.97829 3.73123C-6.07841 3.42131 -7.62244 3.05327 -9.61037 2.62712C-10.5368 2.43341 -11 1.89104 -11 0.999999C-11 0.593219 -10.8649 0.234868 -10.5947 -0.0750589C-10.3245 -0.384987 -9.98673 -0.569006 -9.58142 -0.627117C-7.61279 -0.878934 -6.07841 -1.13075 -4.97829 -1.38257C-3.87817 -1.63438 -3.0579 -2.03147 -2.51749 -2.57385C-1.97708 -3.11622 -1.59107 -3.92978 -1.35947 -5.01453C-1.10856 -6.09927 -0.86731 -7.60048 -0.635705 -9.51816C-0.500603 -10.5061 0.0398083 -11 0.985526 -11C1.95054 -11 2.49095 -10.4964 2.60676 -9.4891C2.83836 -7.64891 3.06997 -6.2155 3.30157 -5.18886C3.53317 -4.1816 3.91918 -3.42615 4.45959 -2.92252C5 -2.41889 5.82992 -2.0121 6.94934 -1.70218C8.06876 -1.41162 9.61279 -1.05327 11.5814 -0.627117C12.5271 -0.414042 13 0.128328 13 0.999999C13 1.92978 12.4692 2.47215 11.4077 2.62712C9.47768 2.91767 7.97226 3.19855 6.89144 3.46973C5.81062 3.74092 5 4.1477 4.45959 4.69007C3.91918 5.23244 3.53317 6.03632 3.30157 7.10169C3.06997 8.16707 2.83836 9.62954 2.60676 11.4891Z">',
'<animateTransform attributeName="transform" attributeType="XML" type="scale" additive="sum" beg="0s" dur="1s" values="0.85; 1.25; 0.85" repeatCount="indefinite" />',
"</path>",
animateTransform(_durationShort, _reverseRotate),
"</g>",
SVG.animateMotion(_reverse, _durationLong, "linear", '<mpath href="#jitter-lg" />'),
"</g>"
);
}

function animateTransform(string memory _dur, string memory _to) internal pure returns (string memory) {
function animateTransform(string memory _dur, string memory _reverseRotate) internal pure returns (string memory) {
return
string.concat(
"<animateTransform ",
'attributeName="transform" ',
"dur=",
Util.quote(_dur),
'repeatCount="indefinite" ',
'type="translate" ',
'additive="sum" ',
'from="0 0" ',
'to="0 ',
_to,
'" ',
'type="rotate" ',
_reverseRotate,
"/>"
);
}
Expand Down
Loading

0 comments on commit d7323b2

Please sign in to comment.