19.04.2017 Views

Learn to Program with Small Basic

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

This program uses the DrawText() method of the GraphicsWindow object <strong>to</strong><br />

display a message. The DrawText() method requires three arguments. The<br />

first two arguments tell <strong>Small</strong> <strong>Basic</strong> the horizontal (x) and vertical (y) positions<br />

of the output message, starting in the upper-left corner of the window.<br />

The third argument tells <strong>Small</strong> <strong>Basic</strong> what text <strong>to</strong> display. The output of this<br />

program is shown in Figure 1-4. As you can see, the message is displayed at<br />

position (100, 50).<br />

100<br />

50<br />

Figure 1-4: The output of Graphic.sb<br />

The GraphicsWindow object contains many other methods that let you<br />

create GUI applications; explore a few of them in Try It Out 1-1.<br />

TRY IT OUT 1-1<br />

Enter the following program in<strong>to</strong> the Edi<strong>to</strong>r, and then run it <strong>to</strong> see what happens:<br />

GraphicsWindow.DrawEllipse(20, 20, 100, 100)<br />

GraphicsWindow.DrawRectangle(140, 20, 100, 100)<br />

GraphicsWindow.FillEllipse(260, 20, 200, 100)<br />

The output of the program is shown in Figure 1-5. The numbers illustrate how<br />

<strong>Small</strong> <strong>Basic</strong> followed your code.<br />

20<br />

20<br />

100<br />

100<br />

100<br />

100<br />

200<br />

Figure 1-5: The output of the program<br />

10 Chapter 1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!