-
Notifications
You must be signed in to change notification settings - Fork 1
Drawing some shapes
Ryan G edited this page Sep 9, 2017
·
3 revisions
Now that we have a window, we should populate it with something.
import dgt;
void main()
{
Window window = Window("Your First Window", 800, 600, WindowConfig());
while(window.isOpen)
{
window.begin(Color.white);
window.draw(Color.blue, Circlei(400, 300, 40));
window.draw(Color.red, Rectanglei(100, 0, 32, 32));
window.end();
}
}
The window should now have a blue circle and a red square. The blue circle should be exactly centered, and the red square should be at the top of the window offset 100 pixels from the left.
window.draw(Color.blue, Circlei(400, 300, 40)); draws a blue Circle. 400 gives the x, 300 gives the y, and 40 gives the radius. (Like Rectanglei, Circlei is an alias for Circle!int)
window.draw(Color.red, Rectanglei(100, 0, 32, 32)); draws a red Rectangle. It is constructed much the same way as the camera.