diff --git a/src/FlagRenderer.sol b/src/FlagRenderer.sol index 7ba5421..c9c2bc6 100644 --- a/src/FlagRenderer.sol +++ b/src/FlagRenderer.sol @@ -251,7 +251,9 @@ contract FlagRenderer { image = string.concat( image, uint256(uint128(_tokenId)).toString(), // Rank - 'Rank/ ', + uint256(_solves).toString(), // Solvers + 'Rank', _formatTime(_solveTime), // Solve time @@ -294,7 +296,7 @@ contract FlagRenderer { { uint256 seed = uint256(keccak256(abi.encodePacked(_tokenId, _solveMetadata))); // Select the colormap. - bytes32 colormapHash = [ + bytes8 colormapHash = bytes8([ bytes32(0xfd29b65966772202ffdb08f653439b30c849f91409915665d99dbfa5e5dab938), bytes32(0x850ce48e7291439b1e41d21fc3f75dddd97580a4ff94aa9ebdd2bcbd423ea1e8), bytes32(0x4f5e8ea8862eff315c110b682ee070b459ba8983a7575c9a9c4c25007039109d), @@ -313,7 +315,7 @@ contract FlagRenderer { bytes32(0x87970b686eb726750ec792d49da173387a567764d691294d764e53439359c436), bytes32(0xaa6277ab923279cf59d78b9b5b7fb5089c90802c353489571fca3c138056fb1b), bytes32(0xdc1cecffc00e2f3196daaf53c27e53e6052a86dc875adb91607824d62469b2bf) - ][seed % 18]; + ][seed % 18]); // We start at the middle of the board. uint256 index = 210; diff --git a/src/interfaces/IColormapRegistry.sol b/src/interfaces/IColormapRegistry.sol index f19f194..7df040d 100644 --- a/src/interfaces/IColormapRegistry.sol +++ b/src/interfaces/IColormapRegistry.sol @@ -29,12 +29,12 @@ interface IColormapRegistry { // ------------------------------------------------------------------------- /// @notice Emitted when a colormap already exists. - /// @param _colormapHash Hash of the colormap's definition. - error ColormapAlreadyExists(bytes32 _colormapHash); + /// @param _hash Hash of the colormap's definition. + error ColormapAlreadyExists(bytes8 _hash); /// @notice Emitted when a colormap does not exist. - /// @param _colormapHash Hash of the colormap's definition. - error ColormapDoesNotExist(bytes32 _colormapHash); + /// @param _hash Hash of the colormap's definition. + error ColormapDoesNotExist(bytes8 _hash); /// @notice Emitted when a segment data used to define a colormap does not /// follow the representation outlined in {IColormapRegistry}. @@ -69,33 +69,45 @@ interface IColormapRegistry { /// @param _hash Hash of `_paletteGenerator`. /// @param _paletteGenerator Instance of {IPaletteGenerator} for the /// colormap. - event RegisterColormap(bytes32 _hash, IPaletteGenerator _paletteGenerator); + event RegisterColormap(bytes8 _hash, IPaletteGenerator _paletteGenerator); /// @notice Emitted when a colormap is registered via segment data. /// @param _hash Hash of `_segmentData`. /// @param _segmentData Segment data defining the colormap. - event RegisterColormap(bytes32 _hash, SegmentData _segmentData); + event RegisterColormap(bytes8 _hash, SegmentData _segmentData); // ------------------------------------------------------------------------- // Storage // ------------------------------------------------------------------------- - /// @param _colormapHash Hash of the colormap's definition (segment data). + /// @param _hash Hash of the colormap's definition (palette generator). + /// @return IPaletteGenerator Instance of {IPaletteGenerator} for the + /// colormap. + function paletteGenerators(bytes8 _hash) external view returns (IPaletteGenerator); + + /// @param _hash Hash of the colormap's definition (segment data). /// @return uint256 Segment data for red's color value along the colormap. /// @return uint256 Segment data for green's color value along the colormap. /// @return uint256 Segment data for blue's color value along the colormap. - function segments(bytes32 _colormapHash) external view returns (uint256, uint256, uint256); - - /// @param _colormapHash Hash of the colormap's definition (palette - /// generator). - /// @return IPaletteGenerator Instance of {IPaletteGenerator} for the - /// colormap. - function paletteGenerators(bytes32 _colormapHash) external view returns (IPaletteGenerator); + function segments(bytes8 _hash) external view returns (uint256, uint256, uint256); // ------------------------------------------------------------------------- // Actions // ------------------------------------------------------------------------- + /// @notice Batch register colormaps with palette generators. + /// @param _paletteGenerators Array of {IPaletteGenerator} instances for the + /// colormap. + function batchRegister(IPaletteGenerator[] memory _paletteGenerators) external; + + /// @notice Batch register colormaps with segment data that will be read + /// via piece-wise linear interpolation. + /// @dev See {IColormapRegistry} for how the segment data should be + /// structured. + /// @param _segmentDataArray Array of segment data tuples defining the + /// colormap. + function batchRegister(SegmentData[] memory _segmentDataArray) external; + /// @notice Register a colormap with a palette generator. /// @param _paletteGenerator Instance of {IPaletteGenerator} for the /// colormap. @@ -118,7 +130,7 @@ interface IColormapRegistry { /// number in [0, 1]. Note that the function *will not* revert if /// `_position` is an invalid input (i.e. greater than 1e18). This /// responsibility is left to the implementation of {IPaletteGenerator}s. - /// @param _colormapHash Hash of the colormap's definition. + /// @param _hash Hash of the colormap's definition. /// @param _position 18 decimal fixed-point number in [0, 1] representing /// the position in the colormap (i.e. 0 being min, and 1 being max). /// @return uint256 Intensity of red in that color at the position @@ -127,15 +139,26 @@ interface IColormapRegistry { /// `_position`. /// @return uint256 Intensity of blue in that color at the position /// `_position`. - function getValue(bytes32 _colormapHash, uint256 _position) + function getValue(bytes8 _hash, uint256 _position) external view returns (uint256, uint256, uint256); + /// @notice Get the hexstring for a color in a colormap at some position. + /// @param _hash Hash of the colormap's definition. + /// @param _position Position in the colormap (i.e. 0 being min, and 255 + /// being max). + /// @return string Hexstring excluding ``#'' (e.g. `007CFF`) of the color + /// at the position `_position`. + function getValueAsHexString(bytes8 _hash, uint8 _position) + external + view + returns (string memory); + /// @notice Get the red, green, and blue color values of a color in a /// colormap at some position. /// @dev Each color value will be returned as a `uint8` number in [0, 255]. - /// @param _colormapHash Hash of the colormap's definition. + /// @param _hash Hash of the colormap's definition. /// @param _position Position in the colormap (i.e. 0 being min, and 255 /// being max). /// @return uint8 Intensity of red in that color at the position @@ -144,19 +167,8 @@ interface IColormapRegistry { /// `_position`. /// @return uint8 Intensity of blue in that color at the position /// `_position`. - function getValueAsUint8(bytes32 _colormapHash, uint8 _position) + function getValueAsUint8(bytes8 _hash, uint8 _position) external view returns (uint8, uint8, uint8); - - /// @notice Get the hexstring for a color in a colormap at some position. - /// @param _colormapHash Hash of the colormap's definition. - /// @param _position Position in the colormap (i.e. 0 being min, and 255 - /// being max). - /// @return string Hexstring excluding ``#'' (e.g. `007CFF`) of the color - /// at the position `_position`. - function getValueAsHexString(bytes32 _colormapHash, uint8 _position) - external - view - returns (string memory); -} +} \ No newline at end of file