Created
January 8, 2024 00:42
-
-
Save 99darwin/943c506bc4cf3e02446d0944a00219bb to your computer and use it in GitHub Desktop.
TorusTest Highlight Generative Art Testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let xRotation = 0; | |
let yRotation = 0; | |
let xRotationSpeed, yRotationSpeed; | |
let torusX, torusY, randomDetailX, randomDetailY; | |
let bgColor; | |
function setup() { | |
createCanvas(windowWidth, windowHeight, WEBGL); | |
// Set random background color once | |
bgColor = [hl.random(0, 255), hl.random(0, 255), hl.random(0, 255)]; | |
// Set random torus color once | |
torusColor = [hl.random(0, 255), hl.random(0, 255), hl.random(0, 255)]; | |
// Set random rotation speeds | |
xRotationSpeed = hl.random(0.001, 0.1); | |
yRotationSpeed = hl.random(0.001, 0.1); | |
// Set up random torus properties | |
torusX = hl.random(15, 50); | |
torusY = hl.random(15, 50); | |
randomDetailX = Math.floor(hl.random(3, 24)); | |
randomDetailY = Math.floor(hl.random(3, 16)); | |
// Set token traits | |
let traits = { | |
"xRotation Speed": xRotationSpeed, | |
"yRotation Speed": yRotationSpeed, | |
"Background Color": bgColor, | |
"Torus Color": torusColor | |
}; | |
hl.token.setTraits(traits); | |
// Set token information | |
hl.token.setName(`TorusTest #${hl.tx.tokenId}`); | |
hl.token.setDescription(`TorusTest #${hl.tx.tokenId} is a torus with a random color and random rotation speed. It is a test for the torus function. Minted by ${hl.tx.walletAddress} at ${hl.tx.timestamp} in transaction ${hl.tx.hash} on block number ${hl.tx.blockNumber}.`); | |
// Capture a preview of the token image | |
hl.token.capturePreview(); | |
} | |
function draw() { | |
// Set the background in each frame | |
background(bgColor); | |
// Update rotation | |
xRotation += xRotationSpeed; | |
yRotation += yRotationSpeed; | |
fill(torusColor); | |
// Draw the torus | |
push(); | |
rotateX(xRotation); | |
rotateY(yRotation); | |
torus(torusX, torusY, randomDetailX, randomDetailY); | |
pop(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment