-
Notifications
You must be signed in to change notification settings - Fork 2
/
ALG_example01 (original).txt
1 lines (1 loc) · 1.96 KB
/
ALG_example01 (original).txt
1
{"params":"seed:{default:1, min:1, max:100, step:1, class:\"number\"}\n\nnRows:{default:5, min:1, max:100, step:1, class:\"slider\"}\n\npadding:{default:0.75, min:0, max:0.99, step:0.01, class:\"slider\"}\n\nhueCenter:{default:0, min:0, max:255, step:1, class:\"slider-hue\"}\nsatCenter:{default:50, min:0, max:100, step:1, class:\"slider-sat\"}\nlitCenter:{default:50, min:0, max:100, step:1, class:\"slider-lit\"}\ncolorVar:{default:10, min:0, max:100, step:1, class:\"slider\"}\n\nfillMode:{default:0, min:0, max:1, step:1, class:\"on-off\"}\nlineWidthFraction:{default:0.1, min:0.01, max:1, step:0.01, class:\"slider\"}","drawFunction":"\n// constant parameters\nvar alpha = 255;\n\n// code variables\nvar y;\nvar x;\nvar lineWidth;\n\n// the height and width of the cells\nvar width = 1/nRows;\nvar height = 1/nRows;\n\n\n// for each cell (row and column location), draw either a rectangle or a circle in the middle of the cell.\nfor(let i=0; i<nRows; i++) {\n \n y = height * i;\n \n for(let j=0; j<nRows; j++) {\n \n hue = hueCenter;\n sat = vary(satCenter,colorVar);\n lit = vary(litCenter,colorVar);\n \n lineWidth = lineWidthFraction * width;\n \n x = width * j;\n \n // with 50% probability draw a rectangle, otherwise draw a circle instead.\n if( getRandomFloat(0,1) < 0.5 ) { \n \n // some calculations for the rectangle\n var rectWidth = width*padding;\n var rectHeight = height*padding;\n var xTL = x + (width-rectWidth)/2;\n var yTL = y + (height-rectHeight)/2;\n\n // draw a rectangle\n drawRect(ctx, xTL, yTL, rectWidth, rectHeight, lineWidth, hue, sat, lit, alpha, fillMode);\n\n } else {\n \n // some calculations for the circle\n radCirc = width/2 * padding;\n var xCenter = x + width/2;\n var yCenter = y + height/2;\n\n // draw a circle\n drawCircle(xCenter, yCenter, radCirc, lineWidth, hue, sat, lit, alpha, fillMode, ctx);\n \n }\n \n }\n \n}\n"}