|
Using
SiMPLE
To Create Your Own Computer Art (Part 2)
|
Welcome to Part 2 of our introductory discussion about creating your own computer art.
In Part 1, we showed you how to tell your computer to draw colored circles. Now, let's use our knowledge of circles to make the computer create an image of a small multi-colored "target" (a set of concentric circular rings, each of a different color). And let's have it place the center of that image at row 240, column 150, on the screen.
Just as you did before, first create a "New Text Document" on your desktop (or anywhere that you choose). Then type in the following list of instructions:
|
Ultra-SiMPLE solid color (8) solid circle (150, 240, 70) solid color (4) solid circle (150, 240, 60) solid color (5) solid circle (150, 240, 50) solid color (9) solid circle (150, 240, 40) solid color (10) solid circle (150, 240, 30) solid color (14) solid circle (150, 240, 20) solid color (12) solid circle (150, 240, 10) |
[Notice the order in which we are having the circles drawn (the larger ones first
When you have finished typing, close the document and drop its icon onto the "Drop SiMPLE Listing Here" icon. In a few moments, you should see the following image near the left side of your screen:
Let's Change the Location of the Image
Our previous list of instructions told the computer to draw seven different circles, each at the same fixed location on the screen (row 240, column 150). But suppose that we later change our mind and decide that our little target image would look better if it were to be drawn several hundred pixels farther to the right (let's say: at column 500), instead of at column 150.
We could just go back to our list of instructions, find all the "150" numbers, and change them to "500". But then, what if we rerun that new list of instructions, and we're still not satisfied with the location of the image? What if we want to keep trying different numbers until we get the image exactly where we want it? How can we avoid having to make lots of changes everywhere in our listing whenever we want to try a new value?
One way to deal with this problem is to simply parameterize the values that you use: Instead of always using fixed numbers when specifying things (such as row values, column values, etc.), use words whose values have been previously defined in your list of instructions. It doesn't matter what particular words you use; you can even invent meaningless words (like "qdytzj") if you so choose. But, to make your listings easier for you to read, it is generally a good idea to use words that are descriptive of their intended purpose.
For example, our original instructions for drawing the little target could have been written this way:
|
Ultra-SiMPLE row = 240 col = 150 solid color (8) solid circle (col, row, 70) solid color (4) solid circle (col, row, 60) solid color (5) solid circle (col, row, 50) solid color (9) solid circle (col, row, 40) solid color (10) solid circle (col, row, 30) solid color (14) solid circle (col, row, 20) solid color (12) solid circle (col, row, 10) |
We've first defined the word "row" to mean "240", and the word "col" to mean "150". We then used the word "row" instead of the number "240" (and the word "col" instead of the number "150") whenever those values were needed later in the listing.
Now, we can easily change the horizontal location to "500" (or anywhere else) by changing just one number at just one place in the listing:
|
Ultra-SiMPLE row = 240 col = 500 solid color (8) solid circle (col, row, 70) solid color (4) solid circle (col, row, 60) solid color (5) solid circle (col, row, 50) solid color (9) solid circle (col, row, 40) solid color (10) solid circle (col, row, 30) solid color (14) solid circle (col, row, 20) solid color (12) solid circle (col, row, 10) |
Go ahead and try placing the image anywhere you like (by changing the values that are assigned to "row" and "col" at the beginning of the listing).
This concludes the second part of our discussion.![]() Click here to read Part 3. |

[ Webmaster
| FAQ's
| Home Page
| Contact Us ]
© Copyright 2010 SiMPLE CodeWorks, Inc. All rights reserved.