Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.