HEX
Last updated
Last updated
This project is an attempt to visualize the blockchain. NFTs, and cryptocurrency in general rely on hash strings within the transaction ledger. Much like an IP address this specific code is linked to a specific block on the chain. These are typically a string of 66 characters. For Ethereum, it looks something like this:
0x11ac128f8b54949c12d04102cfc01960fc496813cbc3495bf77aeed738579738
Interestingly, hexadecimal code like this can be easily converted into colors. Typical hex colors look like this:
This program is essentially breaking up this initial string of hexadecimal characters into ten groups. Each with six digits. Here’s the example above broken up into the ten groups, with the colors of their corresponding hexadecimal codes:
We can also convert these groups into single numbers. Using their RGB codes we can average their values. The math to do this is a little complex, however you can find a great converter online. Basically we're taking each pair and averaging them:
(R + G + B) / 3 = Averaged RGB Value.
This sequence would now look like this:
Hash - the hashcode used for the output. This should consist of a String of characters starting with “0x”.
Animation - true or false - allows the program to output individual frames instead of single files.
size - this can be any size, however 1000 pixels x 1000 pixels is suitable for most screens.
frameRate(24) - change this number only if animation is set to true. This will dictate the rate of frames.
This is where the program functions, it will loop through the hashcode information provided. Since these keys are deterministic — no two are the same. In a generative art context, this presents us with an amazing variable in which to base our code. In the past, random numbers have been used in everything from divination to modern computation. However, truly random variables are pretty hard to generate in a somewhat predictable way. Based on these supplied values the drawing functions below will generate drawings. In a sense these are digital prints, completely unique and deterministic from one another.
perlinNoise(fill) - In 1983, frustrated with the artificial look of modern computer-generated imagery, Ken Perlin developed the perlin noise algorithm for the Disney movie Tron. It serves, even to this day, as a useful and complex method of generating more realistic random numbers. If rendered two-dimensionally it creates smooth cloud patterns. These cloud patterns form the base layer to the drawing.
flowField(fill) - This will behave a lot like perlin noise. However it uses lines instead of pixel brightness to create this cloud-like look. In this case it uses a supplied number to slightly adjust the angle of this line. Over a larger picture plane it will begin to flow and move in breeze-like movements. This forms the first layer.
flowSlash(fill, seed) - Similar to the previous layer, flowSlash generates a line based perlin noise. However the lines are restricted to vertical, horizontal and 45-degrees. These are then colored based on hash data. Forming the final layer.
displayHash() - This is strictly for diagnostic purposes. It will display the supplied hash string with the ten groups displayed as colored blocks and their greyscale counterparts. I find this helpful for color matching with paint or for a helpful reference. It also shows if the hash code is being processed correctly.
The first of the two equations here parse hexadecimal code into integers. Converting #FFFFFF to 255, 255, 255 for example. This is fundamental for the rest of the code to utilize. The second equation simply averages these integers into a single number. Forming the seeds for generative outputs.
0x1626fddc1ea6ce7f2bfd337269f4f3c18533a4435b1fa95e486b243260d6e5bc
Here’s a few examples of the above hash. Visualized through the Draw functions: