Code Blocks is in Beta!
Random change the color of a text 3D spot
Preview
Code
var textSpot = Space.getSpot('Text3D'); var colorR; var colorG; var colorB; var colorRGB; textSpot.text = 'Click for random color'; // Generate a random number between 1 and 256 function getRandom(min, max) { return Math.random() * (257- 1) + 1; } // Sets a new color to colorRGB function colorSwap() { colorRGB = Color(colorR/256, colorG/256 , colorB/256); } // if the clicked spot is text3D, then get a random number for R,G and B
// swap the color and set the new color to text3D
function onClick(event) { if (event.spot.name == textSpot.name) { colorR = getRandom(); colorG = getRandom(); colorB = getRandom(); colorSwap(); textSpot.color = colorRGB; } }
Spot layout
