|
REALbasic Magnifying Glass 10-11-01
|
 |
One fun trick that many programmers use is the magnifying lens. You've probably seen it. Move the cursor around the screen and watch a magnified version of the area around the cursor appear onscreen. This is helpful for calculating HTML colors as well as viewing icons up close.
Add Some Code
The first step in this week's project is to create a custom class. Select File->New Class to create a new class. Name the class "flickerFreeCanvas" and change its Super property to "Canvas".
Next, create a new Method by choosing Edit->New Method. Name the Method Draw with a parameter of g as graphics. Enter the following code:
Then, create a Method named Redraw by selecting Edit->New Method.
To this new method, add the following code:
Finally, add a property by choosing Edit->New Property (pic as Picture)
Create an Interface
This week's interface is simple to create. Add a Canvas control (with default settings and "flickerFreeCanvas" as the Super property) and a Timer (with Period set to 10).
Double click Canvas1 and enter the following code into its Paint event:

Next, create two integer properties by selecting Edit->New Properties. Name the two properties xx and yy.
Finally, add the following code to the Action event of Timer1.
Conclusion
If you'd like to download this week's example instead of typing it in, you can get it here. See you next week!