Skip to content

Instantly share code, notes, and snippets.

@brendanberg
Created February 25, 2019 18:53
Show Gist options
  • Select an option

  • Save brendanberg/a8895b597c6fc8412c9263ebf5ffda54 to your computer and use it in GitHub Desktop.

Select an option

Save brendanberg/a8895b597c6fc8412c9263ebf5ffda54 to your computer and use it in GitHub Desktop.

Revisions

  1. brendanberg created this gist Feb 25, 2019.
    44 changes: 44 additions & 0 deletions circles.dbn
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    Command Circlepixels cx cy dx dy v
    {
    Set [(cx+dx) (cy+dy)] v
    Set [(cx+dx) (cy-dy)] v
    Set [(cx-dx) (cy+dy)] v
    Set [(cx-dx) (cy-dy)] v
    Set [(cx+dy) (cy+dx)] v
    Set [(cx+dy) (cy-dx)] v
    Set [(cx-dy) (cy+dx)] v
    Set [(cx-dy) (cy-dx)] v
    }

    Command Circle cx cy radius v
    {
    Set x 0
    Set y radius
    Set d (1-radius)

    // 707/1000 approximates square root of 0.5 = cos(45)
    Repeat x 0 (radius*707/1000)
    {
    Set tempd d
    Smaller? tempd 0
    {
    Set d (d+(2*x)+3)
    }
    Notsmaller? tempd 0
    {
    Set d (d+(2*(x-y))+5)
    Set y (y-1)
    }
    Circlepixels cx cy x y v
    }
    }

    Paper 25

    Repeat X 0 3
    {
    Repeat Y 0 3
    {
    Circle (X * 20 + 20) (Y * 20 + 20) 20 (X * 10 + Y * 10)
    }
    }
    9 changes: 9 additions & 0 deletions gradient.dbn
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    Paper 0

    Repeat Y 100 0
    {
    Repeat X 0 100
    {
    Set [X Y] ((X + Y) / 2)
    }
    }
    24 changes: 24 additions & 0 deletions squares.dbn
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    Command Square x y w color
    {
    Pen color
    Line x y (x + w) y
    Line x y x (y + w)
    Line x (y + w) (x + w) (y + w)
    Line (x + w) y (x + w) (y + w)
    }

    Paper 0

    Repeat Y 0 100
    {
    Pen (Y / 5 + 50)
    Line Y 0 Y 100
    }

    Repeat X 0 9
    {
    Repeat Y 0 9
    {
    Square (X * 10 + 3) (Y * 10 + 3) 4 (X * 6 + Y * 6)
    }
    }