I Wish I Knew How To… Program the Canvas Control 2 with Xojo Desktop will provide you with the ability to learn how to modify pictures, graphics, make animation, and how to make two games.
*Uses Xojo API1
The focus of this book is to work with topics related to the Canvas Control. All of these examples are created with native Xojo code and does not use any third party programs. The examples have been tested on Windows 10, OS X Mojave 10.14.3, and Ubuntu 18.04 Operating Systems.
By the time you finish the book you will be able to apply skills from these examples to create your own programs!
Examples were tested on Xojo 2018 r4. There is an older book that has legacy code for Xojo 2014 r2 that works without the changes in the Xojo Language.
Goals of the newer updated Canvas 2 book:
- Most drawings are drawn in the Paint event with the Graphics property
- Drawing speed has been increased
- Windows calls the paint event with Invalidate(False) to improve speed and prevent erasing the canvas
- Most examples have been converted to double data-types for drawing locations on the canvas
- Faster RGBSurface.Pixel drawing has been updated from the older graphics.Pixel method (deprecated since 2016 r1)
- Added basic sound in the Space Ship Shooter game
- Removed most PBuffer picture properties and replaced with algorithms to draw in the Paint event (some examples required this property to exist)
- Removed GDIPlus from Windows examples
- Added a couple HiDPI/Retina Examples
- Increased resolution of example screen grabs
- Used the more popular TargetWindows instead of TargetWin32 command
- Added PDF bookmarks for easier reference
- Attempts were made to maintain the same output of the original examples from the first Canvas book to the second Canvas book
Topics included in the book:
- Text
- Chart Fundamentals
- Objects
- 2D Objects
- Graphics
- Blurring
- Cropping
- Gaussian Blur
- Building basic controls
- Animation
- Sprites
Two simple games with step-by-step code explanations provide an understanding to help you build your own and more...
Learn animation basics:
What is included with the purchase of this book:
Thirteen chapters and over 450 pages of code to build 60 example programs. Create realistic 2D game motion. It also includes example images and the ways to use them in programs. The book is in PDF format with example chapter folders containing Xojo source code and running examples.
New/Updates to Version 2.0 – April 2019
This version has the following material added:
1) Added common settings in Canvas Open Event in Appendix A.
2) Remove UseGDIPlus commands as it is deprecated since version 2016r4.
3) Updated performance tips in Chapter 1.
4) Added Example 2-7, save a picture from a canvas control.
5) Updated Example 3-1 to use Paint Graphics instead of picture graphics
6) Update Example 3-2 to use Paint Graphics instead of picture graphics
7) Update Example 3-3 to use Paint Graphics instead of picture graphics
8) Update Example 3-4 to use Paint Graphics instead of picture graphics
9) Update Example 3-5 to use Paint Graphics instead of picture graphics
10) Update Example 4-1 to use RGBSurface.Pixel Instead of Picture.Pixel
11) Updated Open Event in Example 4-2 for Windows, Mac, and Linux code
12) Updated Open Event in Example 4-3 for Windows, Mac, and Linux code
13) Rewrite code in Example 7-1 to change from Picture buffering to paint graphics buffering
14) Rewrite code in Example 7-2 to change from Picture buffering to paint graphics buffering
15) Rewrite code in Example 7-3 to change from Picture buffering to paint graphics buffering
16) Rewrite code in Example 7-4 to change from Picture buffering to paint graphics buffering
17) Rewrite code in Example 8-1 to change from Picture buffering to paint graphics buffering
18) Rewrite code in Example 8-2 to change from Picture buffering to paint graphics buffering and also change to RGBSurface for pixel drawing
19) Rewrite code in Examples 8-3, 8-4, 8-5, 8-6, 8-7, 8-8, 8-9, 8-10, and 8-11, 8-12, 8-13, 8-14, 8-15, 8-16, and 8-17 to change from Picture buffering to paint graphics buffering, added RefreshCanvas Boolean property.
20) Update code in Examples 9-1, 9-2, 9-3, and 9-4. Remove PBuffer and update with graphics code. Get all examples working. Add RefreshCanvas property to allow user interaction.
21) Update code in Examples 10-1, 10-2, and 10-3. Remove PBuffer and update with graphics code.
22) Update code in Examples 11-1, 11-2, 11-3, 11-4 and 11-5. Added AcceptFocus in 11-2 to allow the KeyDown event to fire in the CanvasAnimation Event.
23) Added Sound to Space Ship Shooter for shooting, and for rock collisions (Example 12-2h).
24) Update code in Examples 12-1, and 12-2. Change from Picture buffering to paint graphics buffering.
25) Updated Example 1-6 to use RGBSurface outside of the Paint event since the colour value cannot be read inside the paint event.
26) Rewrite code in Examples 6-1, 6-2, 6-3, 6-4, 6-5 to change from Picture buffering to paint graphics buffering, added RefreshCanvas Boolean property.
27) Added HiDPI and Retina examples in Chapter 12.
This version has the following material added:
1) Added common settings in Canvas Open Event in Appendix A.
2) Remove UseGDIPlus commands as it is deprecated since version 2016r4.
3) Updated performance tips in Chapter 1.
4) Added Example 2-7, save a picture from a canvas control.
5) Updated Example 3-1 to use Paint Graphics instead of picture graphics
6) Update Example 3-2 to use Paint Graphics instead of picture graphics
7) Update Example 3-3 to use Paint Graphics instead of picture graphics
8) Update Example 3-4 to use Paint Graphics instead of picture graphics
9) Update Example 3-5 to use Paint Graphics instead of picture graphics
10) Update Example 4-1 to use RGBSurface.Pixel Instead of Picture.Pixel
11) Updated Open Event in Example 4-2 for Windows, Mac, and Linux code
12) Updated Open Event in Example 4-3 for Windows, Mac, and Linux code
13) Rewrite code in Example 7-1 to change from Picture buffering to paint graphics buffering
14) Rewrite code in Example 7-2 to change from Picture buffering to paint graphics buffering
15) Rewrite code in Example 7-3 to change from Picture buffering to paint graphics buffering
16) Rewrite code in Example 7-4 to change from Picture buffering to paint graphics buffering
17) Rewrite code in Example 8-1 to change from Picture buffering to paint graphics buffering
18) Rewrite code in Example 8-2 to change from Picture buffering to paint graphics buffering and also change to RGBSurface for pixel drawing
19) Rewrite code in Examples 8-3, 8-4, 8-5, 8-6, 8-7, 8-8, 8-9, 8-10, and 8-11, 8-12, 8-13, 8-14, 8-15, 8-16, and 8-17 to change from Picture buffering to paint graphics buffering, added RefreshCanvas Boolean property.
20) Update code in Examples 9-1, 9-2, 9-3, and 9-4. Remove PBuffer and update with graphics code. Get all examples working. Add RefreshCanvas property to allow user interaction.
21) Update code in Examples 10-1, 10-2, and 10-3. Remove PBuffer and update with graphics code.
22) Update code in Examples 11-1, 11-2, 11-3, 11-4 and 11-5. Added AcceptFocus in 11-2 to allow the KeyDown event to fire in the CanvasAnimation Event.
23) Added Sound to Space Ship Shooter for shooting, and for rock collisions (Example 12-2h).
24) Update code in Examples 12-1, and 12-2. Change from Picture buffering to paint graphics buffering.
25) Updated Example 1-6 to use RGBSurface outside of the Paint event since the colour value cannot be read inside the paint event.
26) Rewrite code in Examples 6-1, 6-2, 6-3, 6-4, 6-5 to change from Picture buffering to paint graphics buffering, added RefreshCanvas Boolean property.
27) Added HiDPI and Retina examples in Chapter 12.
Eugene Dakin is the author of many Xojo reference materials and has many years experience creating technical programs.
Click to download the latest version of the Table Of Contents.
This is one of many books at XojoLibrary. This book can be purchased at Xojo Library here many great Xojo resources are available.
ISBN: 978-1-927924-24-2