Although I think we should have right and equilateral triangles as terminal shapes, until then I want to try to create a triangle from circles and squares with the smallest shape count.
I throw down a challenge to all CFDG users to generate an equilateral triangle in a 500x500 canvas the uses the smallest number of shapes. I'll start with my entry, with a shape count of 51:
Ok, these aren't all that efficient, but I've got 30, 45 and 60-degree right triangles (using the top angle for naming), and an equilateral, all with a unit length for the longest non-hypoteneuse side.
startshape BLOB
rule BLOB{
r30_triangle{}
r45_triangle{x 1}
r60_triangle{x 2}
eq_triangle{x 3}
}
rule r30_triangle{
SQUARE{s 0.366 x -0.315 y -0.315}
r30_triangle{x 0.05 y -0.3159 s 0.366}
r30_triangle{y 0.183 x -0.1823 s 0.634}
}
rule r45_triangle{
SQUARE{s .5 x -0.25 y -0.25}
r45_triangle{y .25 x -0.25 s 0.5}
r45_triangle{x .25 y -0.25 s 0.5}
}
rule r60_triangle{
SQUARE{s 0.366 x -0.315 y -0.315}
r60_triangle{y 0.05 x -0.3159 s 0.366}
r60_triangle{x 0.183 y -0.1823 s 0.634}
}
rule eq_triangle{
SQUARE{s .4675 y -.26}
r30_triangle{x .4667 y -.26 s .4675}
r60_triangle{x -.4667 y -.26 s .4675 r 90}
eq_triangle{y .2 s .46}
}
startshape tiny
rule tiny {
shape1 { x 0 y 0 }
}
rule shape1 {
SQUARE { x 0 y 3.6 s 8 b 0}
SQUARE { x -5 y 5 s 10 r -120 b 1 }
SQUARE { x 5 y 5 s 10 r 120 b 1 }
}
i know this might be cheating but i made one using 3 shapes.
Well, it isn't just circles. The triangle you designed essentially has two wings of white space which can and will overlap other shapes, as with the circle in the example, and this will typically be undesirable.
hmm... what if there was a way to make a shape transparent to one and opaque to another? like maybe the negative white squares are opaque to the black square that they are subracting from but are transparent to the next group of squares? a.k.a. masking with alpha channels. it might be less intensive than repeating a group of 51 squares that make one triangle to create a more complex pattern.
im not a programmer so dont think i know how to do this. just throwing some ideas out there.
In the upcoming beta of Context Free the little lines between squares will go away. Mark and I have created a compliance test for the platform-specific drawing code to make sure that the primitives look the same on all platforms. We tweaked the anti-aliased drawing code to remove lines between abutted squares. You won't have to put SQUARE {s 1.01} in your rules any more.
Uhm, what did you mean? The versions since 1.0 have had this tweak in them. Is it that you like the way the drawing code currently works and don't want to see it change? If so, all's cool.