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!

Image Spinner by Erick Tejkowsi
04-11-03

Printer Version




One of the most frequently asked questions among REALbasic lists is "How do I rotate an image?" This week we'll show you how to quickly and easily rotate an image in realtime. The REALbasic Group2D class simplifies matters significantly for us. By dragging a few items to your interface and adding a bit of code, you'll be spinning in no time.

Build the Interface
Launch REALbasic and add a Canvas, a PushButton, and a Slider control to the Window1 interface. Set the maximum value of the slider to 6283. Since one complete rotation around a circle is approximately 6.283 radians, we'll use the larger value of 6283 to insure fine resolution upon rotation. Next, click on the slider to select it and uncheck its Enabled property in the Properties window. Then, add an image file to your project. I snagged a photo of Michael Coyle, ResEx' own top dog. His image accompanies the source code download at the end of this tutorial. The final interface looks like this:

4-11-03_img1.jpg (18k)

Add the Code
Double-click PushButton1 and add the following code to its Action event.

  Dim px as PixmapShape
  Dim p as Picture
  
  px=New PixmapShape(coyle)
  p=New Picture(coyle.width,coyle.height,32)
  d=New Group2D
  d.append(px)
  Canvas1.Backdrop=p
  Canvas1.backdrop.Objects=d
  canvas1.Refresh 
  slider1.enabled = TRUE

Next, add this code to the Paint event of Canvas1.

  g.clearRect 0,0,me.width,me.height
  g.drawobject d,47,60

With the Window1 code editor opened, create a new property of that window, by choosing Edit-New Property. Name the property like this: d as Group2D

4-11-03_img2.jpg (18k)

Conclusion
Choose Debug-Run to see your work. By drawing an image using a Group2D object, you can a number of important image operations. The speed isn't as fast as an RGBSurface, but for many tasks its perfectly suitable. You can download the completed project for this week here. See you next week!




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]