Fractals

double sqrt3 = Math.sqrt(3); float trianglex1 = 0; float triangley1 = (float)(-150 * sqrt3); float trianglex2 = 300; float triangley2 = (float)(150); float trianglex3 = -300; float triangley3 = (float)(150); void setup() { size(1000,1000); frameRate(5); } void draw() { drawShapes(width/2 + trianglex1, height/2 + triangley1, width/2 + trianglex2, height/2 +triangley2, width/2 +trianglex3, height/2 + triangley3); } void drawShapes(float x1, float y1, float x2, float y2, float x3, float y3) { stroke(1); noFill(); triangle(x1, y1, x2, y2, x3, y3); float triangley1place = triangley3; float trianglex2place = trianglex2 * 1/2; float triangley2place; float trianglex3place = trianglex3 * 1/2; float triangley3place; triangley2place = (triangley2+triangley1)/2; triangley3place = (triangley2+triangley1)/2; triangley1 = triangley1place; trianglex2 = trianglex2place; triangley2 = triangley2place; trianglex3 = trianglex3place; triangley3 = triangley3place; if(trianglex3 > 10) { drawShapes(width/2 + trianglex1, height/2 + triangley1, width/2 + trianglex2, height/2 +triangley2, width/2 +trianglex3, height/2 + triangley3); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.