Skip to content
John Horigan edited this page Oct 13, 2020 · 2 revisions

Primitive Shapes

Primitive shapes are the shapes that Context Free/CFDG knows how to draw onto a canvas. Whenever Context Free encounters a primitive shape in a shape rule it draws it immediately. There are four primitive shapes that are pre-defined in Context Free: squares, circles, triangles, or fills. Path declarations can be used to teach Context Free how to draw new primitive shapes.

The sizes of these primitive shapes are:

  • Squares are unit squares. If two squares are drawn one unit apart in x or y then that will be drawn edge-to-edge.
SQUARE []
SQUARE [x 1 b 0.5]  // gray square right next to the black square
  • Circles are unit circles. They have the same diameter as the side of a square.
  • Triangles are unit triangles. The have the same side length as squares.
  • Fills draw on the entire canvas with a solid color

Here is what the primitive shapes look like with respect to each other:

shape foo {
    SQUARE []
    CIRCLE [b 1]
 
    SQUARE [x 1.5]
    TRIANGLE [b 0.5 x 1.5]
 
    SQUARE [x 3]
    CIRCLE [b 1 x 3]
    TRIANGLE [b 0.5 x 3]
}

Unicode Ephemera

To facilitate code golf, some Unicode synonyms have been defined for the simple primitive shapes:

  • SQUARE:
    • ⬛ (Black Large Square, U+2B1B)
    • ◼ (Black Medium Square, U+25FC)
    • ◾ (Black Medium Small Square, U+25FE)
    • ■ (Halfwidth Black Square, U+FFED)
  • CIRCLE:
    • ⬤ (Black Large Circle, U+2B24)
    • ⚫ (Medium Black Circle, U+26AB)
    • ● (Black Circle, U+25CF)
  • TRIANGLE:
    • ▲ (Black Up-Pointing Triangle, U+25B2)
    • ▴ (Black Up-Pointing Small Triangle, U+25B4)
Clone this wiki locally