image ResEx Logo
ResExcellence www : Powered by Google
Cell Phone Themes Icons Mighty Mouse Cursors Software Reviews Widgets & Widgets

Articles
   3D
   Audio
   Custom Controls
   General RB
   Graphics
   Hacks
   Mac OS X
   Menus
   Novelty
   Printing
   REALbasic 2005
   REALbasic 2006
   Registration
   Resources
   Reviews
   Serial
   Speech
   Sockets
   XML
   Video
Resource Links
News
   Current News
   February 2006
   January 2006
   December 2005
   November 2005
   October 2005
   September 2005
   August 2005
   July 2005
   June 2005
   May 2005
   April 2005
   March 2005









REALbasic for Dummies
by Erick Tejkowski


Learning REALbasic through Applications
by Clayton E., Crooks II


REALbasic for Macintosh
by Michael Swaine


REALbasic Cross-Platform Application Development
by Mark S. Choate





Older files are in Stuffit 5 or greater format. Newer files are ".Zip". Download StuffIt Expander
Tell us about a bad link. Thank You!

Cropping Graphics Part 4 by Erick Tejkowsi
03-28-03

Printer Version




Today we'll look at last part of this tutorial (Part 4). These tutorials cover the basics of how to implement click-and-drag graphics selection and cropping, like you'll find in many popular applications (e.g.Photoshop, iPhoto, and the Finder). This week we'll add a lasso selection and offer live feedback.

The tutorial emulates a Cocoa project available from Apple. Go check out the original code and come back here ready for some REALbasic coding. NOTE: This demo is made with OS X in mind.

Augment the Interface
Launch REALbasic and open a copy of the last project. To the Window1 interface, add a checkbox labeled . Then, add another entry to PopupMenu2 property: Lasso. The result will look something like this (when tested with Debug-Run):

03-28-02_img1.jpg (25k)

If you're following along from the last tutorial, you may have to resize the window a bit to accommodate the new checkbox. Now, let's move on to the code.

Add the Code
Double-click the Window Editor of Window1 to open the Code Editor. Choose Edit-New Property to add a property to the window: polyPoints(0) as integer. This array will store a list of points that will make up the outline of the lasso selection.

Next, change the code in the MouseDrag event of Canvas1 to read:

Then, navigate to the MouseUp event of Canvas1. Remove the code that you have there in favor of the new code. The code in the MouseDrag and MouseUp events closely matches earlier code with the addition of the lasso selection.

Finally, create a new method named AutoDraw by choosing Edit-New Method. Navigate to this new AutoDraw method and add the following code. This method takes care of continuously updating the display when the new checkbox is selected.

Select Debug-Run to test your work. Click and drag in the image on the left side of the window to view a cropped version on the right side. Select the new Lasso selection feature to see it in action.

03-28-02_img2.jpg (21k)

Conclusion
You can download the completed project for this week here. That's it for this multi-part tutorial. Hopefully you learned a trick or two along the way. Next time we'll move on to a new topic. See you then!




Cell Phone Themes Icons Mighty Mouse Cursors Software Reviews Widgets & Widgets

Maintained by the Staff of ResExcellence. This entire site ©1997-2006 ResExcellence
Privacy Statement? Sure we gotta Privacy Statement. [an error occurred while processing this directive]