A test on how to influence opacity with an array of bales of turtles.
A group of turtles is known as a bale.[49] - WikiPedia
Log in to post a comment.
let grid = 5; // You can find the Turtle API reference here: https://turtletoy.net/syntax var fullOpacity = 100 Canvas.setpenopacity(1 / fullOpacity); var size = 200 / grid; // Global code will be evaluated once. const bales = []; for(var j = 0; j < grid * grid; j++) { bales[j] = []; for(var i = 0; i < getBaleSize(j); i++) { bales[j][i] = new Turtle(); bales[j][i].penup(); bales[j][i].goto( ((((j % grid) + .5) * size) - 100) - (75 / grid) , ((((j / grid | 0) + .5) * size) - 100) - (20 / grid) ) bales[j][i].pendown(); } } // The walk function will be called until it returns false. function walk(i) { for(var k = 0; k < bales.length; k++) { for(var j = 0; j < bales[k].length; j++) { bales[k][j].forward(150 / grid); bales[k][j].right(144); } } return i < 4; } function getBaleSize(j) { var max = grid * grid; return fullOpacity * (Math.cos( Math.PI + ((j / max) * (Math.PI / 2)) ) + 1); }