Welcome to the REALbasic Developer Magazine Beginner's Corner!
Issue: 1.4 (February/March 2003)
Author: Thomas J. Cunningham
Article Description: No description available.
Article Length (in bytes): 7,967
Starting Page Number: 28
Article Number: 1414
Related Link(s): None
Excerpt of article text...
This month and next month, I will discuss the subject of drawing in REALbasic, commonly known as graphics. Now let me briefly explain what I mean by
drawing. The big picture is that everythingyou see on a computer screen has to be drawn to the screen by your computer. This is accomplished by using the tiny little squares that comprise your computer screen. Launch REALbasic, press Command-1, type in the word "graphics," and look through the properties and methods of this class.
Pixels ' Resolution
The tiny little squares I mentioned above are called pixels. They are laid out in a grid pattern of rows and columns. The number of rows and columns shown on your computer screen are collectively referred to as your monitor's
resolution. My iMac, at the moment, is set at 1024 pixels by 768 pixels. So I have 1024 pixels from left to right and 768 pixels going up and down my screen, for a total of 786,432 pixels. The physical size of my screen is about 12 inches wide by 9 inches high. So at this screen resolution, I have about 85 pixels for every inch horizontally and vertically.
Each of these pixels has a defined location within the screen. In beginning algebra, you were taught to set up a coordinate system that was comprised of a horizontal "X" axis and a vertical "Y" axis. Where these two axes crossed, they were labeled as the origin. And this origin was labeled as zero and zero: positive x values to the right, positive y values moving up.
Computers are laid out using a similar concept, but in a different manner. On a Mac, our origin is at the top, left corner of the screen (or window). The x coordinates are positive moving to the right, but the y coordinates are positive moving
downthe screen. On my monitor, the pixel in the middle of the screen would be described as position 512,384. That's 1024/2 and 768/2.
It's important to understand this way of describing a position in RB. I strongly suggest that you go out and buy yourself a nice notebook of graph paper. I use this graph paper as a way of wrapping my head around positions in my programs a lot. It will save you many hours of frustration when something you draw on screen doesn't look right or isn't placed where you wanted it to be shown. Figure 1 shows a magnified view of an area six pixels wide by six pixels high and how each of the individual pixel boxes are identified. As an exercise, fill in the pixel x and y positions I have left blank.
...End of Excerpt. Please purchase the magazine to read the full article.