Skip to content

Instantly share code, notes, and snippets.

@brendanberg
Created February 25, 2019 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brendanberg/a8895b597c6fc8412c9263ebf5ffda54 to your computer and use it in GitHub Desktop.
Save brendanberg/a8895b597c6fc8412c9263ebf5ffda54 to your computer and use it in GitHub Desktop.
Sample DBN programs
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)
}
}
Paper 0
Repeat Y 100 0
{
Repeat X 0 100
{
Set [X Y] ((X + Y) / 2)
}
}
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)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment