0xfbef…2d15

All memos sent from and to 0xfbef…2d15.

let gThreashold = 100; let gNumA = 10; let gNumB = 6; let gRatio = gNumB / gNumA; const WIDTH = 500; function setup() { createCanvas( WIDTH, WIDTH ); colorMode( HSB, 100 ); gNumA = tokenData.hash % 35; gNumB = tokenData.hash % 19; gThreashold = tokenData.hash % 100; } function draw() { background( 100, 0, 100 ); gRatio = gNumB / gNumA; initColorCount(); if( gRatio != 1 ){ divSquare( 0, 0, WIDTH, gRatio, gThreashold ); } if( isEnableCaptureImage() ){ disableCaptureImage(); const namePNG = 'NumA' + gNumA + '_NumB' + gNumB + '_Thr' + gThreashold + '.png'; captureImage( namePNG ); } drawControllerCaptions(); } // Divide a square whose length is squareWidth at ( xPos, yPos ) with some rectangles whose sides have ratio. const divSquare = ( xPos, yPos, squareWidth, ratio, threashold ) => { const xEndPos = squareWidth + xPos; const yEndPos = squareWidth + yPos; let itr = 0; setColor(); rect( xPos, yPos, squareWidth, squareWidth ); while( squareWidth > threashold + 0.1 ){ itr++; if( isOdd( itr ) ){ const nextWidth = squareWidth * ratio; while( xPos + nextWidth < xEndPos + 0.1 ){ divRect( xPos, yPos, nextWidth, ratio, threashold ); xPos += nextWidth; } squareWidth = xEndPos - xPos; }else{ const nextHeight = squareWidth / ratio; while ( yPos + nextHeight < yEndPos + 0.1 ){ divRect( xPos, yPos, squareWidth, ratio, threashold ); yPos += nextHeight; } squareWidth = yEndPos - yPos; } } } // Divide a rectangle with specified ratio whose width is squareWidth at ( xPos, yPos ) with some squares. const divRect = ( xPos, yPos, squareWidth, ratio, threashold ) => { const xEndPos = squareWidth + xPos; const yEndPos = squareWidth / ratio + yPos; let itr = 0; setColor(); rect( xPos, yPos, squareWidth, squareWidth / ratio ); while( squareWidth > threashold + 0.1 ){ itr++; if( isEven( itr ) ){ while( xPos + squareWidth < xEndPos + 0.1 ){ divSquare( xPos, yPos, squareWidth, ratio, threashold ); xPos += squareWidth; } squareWidth = xEndPos - xPos; }else{ while ( yPos + squareWidth < yEndPos + 0.1 ){ divSquare( xPos, yPos, squareWidth, ratio, threashold ); yPos += squareWidth; } squareWidth = yEndPos - yPos; } } } // The number is even or not. const isEven = ( number ) => { return ( number % 2 === 0 ); } // The number is odd or not. const isOdd = ( number ) => { return ( number % 2 === 1 ); } // Get random integer between min and max const getRandomInteger = ( min, max ) => { return Math.floor( random( min, max ) ); } // Capture Image const captureImage = ( namePNG ) => { saveCanvas( namePNG, 'png' ); } let gColorCount = 0; const initColorCount = () => { gColorCount = 0; } const gRandomColorArray = []; // Set Color for each count const setColor = () => { // If new element found, add a random color. if( gRandomColorArray.length <= gColorCount ){ gRandomColorArray.push( random( 100 ) ); } // fill( color( gRandomColorArray[ gColorCount ], 100, 100 ) ); fill( color( gRandomColorArray[ gColorCount ], 40, 100 ) ); gColorCount++; } // Change all colors in the array const changeColor = () => { gRandomColorArray.forEach( ( element, index ) => { gRandomColorArray[ index ] = random( 100 ); }); } let gIsCaptureImage = false; // Is capture image function is ready or not const isEnableCaptureImage = () => { return ( gIsCaptureImage === true ); } // Enable capture image function const enableCaptureImage = () => { gIsCaptureImage = true; } // Disable capture image function const disableCaptureImage = () => { gIsCaptureImage = false; } // Draw controller captions const drawControllerCaptions = () => { textSize(20); // Tentatively, disable stroke. noStroke(); // Draw background fill( color( 'rgba( 0, 0, 0, 0.3 )' ) ); const offset = 10; const width = 200; const height = 160; const cornerRound = 5; rect( offset, offset, width, height, cornerRound ); // Draw captions fill( color( 'white' ) ); text( 'Num A: ' + gNumA, 50, 47 ); text( 'Num B: ' + gNumB, 50, 87 ); text( 'Threashold: ' + gThreashold, 50, 127 ); // Revert stroke stroke( color( 'black' ) ); }