Canvas Control 3 Book - Xojo API2 Desktop

Version 3.0 (January 2021) of the book I Wish I Knew How To … Program the Canvas Control 3 with Xojo Desktop has been released with major updates to API2 code and adding GraphicsPath. Thousands of code and description changes have been made, and the original examples have been kept to assist with converting old API1 code to API2. More details and purchasing of the book are available at the following links: https://scispec.ca/index.php/books and http://xojolibrary.com/.

Uses Xojo API2

All examples have been created with native Xojo code with Xojo 2020 r2.1. There are two older books for AP1 (Xojo 2018 r4 – Canvas 2) and legacy code (Xojo 2014 r2 – Canvas).

Specific updates to the book are to numerous to mention, and here is a list of general changes:

New/Updates to Version 3.0 – Jan 2021

  • Remove UseGDIPlus commands as it is deprecated since version 2016r4.
  • Updated performance tips in Chapter 1.
  • Drawline is deprecated in some instances, using GraphicsPath instead
  • DrawPolygon is deprecated, using GraphicsPath instead
  • Graphics is using double instead of integer – updates throughout code
  • Graphics DrawRect is deprecated. Using DrawRectangle instead
  • Graphics DrawRoundRect is deprectated. Using DrawRoundRectangle instead
  • Graphics DrawString is deprectated. Using DrawText instead
  • Added #pragma for unused parameters
  • Example programs to API2 will have the ‘API2’ text added to differentiate the newer examples from previous books
  • Example project have all analysis warnings turned on to provide a more-thorough update
  • ForeColor is deprecated. The newer DrawingColor is used instead.
  • FillPolygon is deprecated. The newer FillPath is used instead.
  • FillRect is deprecated. The newer FillRectangle is used instead.
  • FillRoundRect is deprecated. The newer FillRoundRectangle command is used instead.
  • DoubleBuffer is deprectated and removed
  • EraseBackground is deprecated and removed
  • PenWidth is deprecated. PenSize is used instead.
  • PenHeight is deprecated. PenSize is used instead.
  • Pixel is deprecated. RGBSurface.Pixel is used instead.
  • MsgBox is deprecated, and MessageDialog.Show is used instead
  • Pixel is deprecated, and RGBSurface.Pixel is used instead
  • Mid is deprecated, and String.Middle is used instead
  • OpenDialog is deprecated, OpenFileDialog is used instead
  • EraseBackground is deprectated and removed from the programs
  • OpenAsPicture is deprecated. FolderItem.OpenAsPicture is used instead.
  • Save is deprecated. Using Save Folderitem instead.
  • Updated to newer Picture.Formats picture types
  • TextFont is Deprecated, FontName is used instead
  • TextSize is Deprecated, FontSize is used instead
  • StringShape is Deprecated, TextShape is used instead
  • Text is deprecated, Value is used instead
  • PageSetupDialog is deprecated, using ShowPageSetupDialog instead
  • LiveScroll is deprecated, using AllowLiveScrolling instead
  • StringWidth is deprecated, using TextWidth instead
  • Border is deprecated, using BorderOpacity instead
  • Append is deprecated, use Add instead
  • Ubound is deprecated, LastIndex is used instead
  • Remove is deprecated, using RemoveAt instead
  • Mask is deprecated, using ApplyMask instead
  • AcceptFocus is deprecated, using AllowFocus instead
  • Mode is deprecated, using RunMode instead
  • Using new IconTypes API2 code for MessageDialog
  • Microseconds is deprecated, using System.Microseconds instead
  • Run is deprecated, using Thread.Start instead
  • Kill is deprecated, using Thread.Stop instead
  • Default is deprecated, using IsDefault instead
  • Icon is deprecated, IconType is used instead
  • GraphicStop is Deprecated, using IconTypes.Stop instead
  • SupportsHiDPI is deprecated, using AllowHiDPI instead
  • Added Chapter 14 for GraphicsPath examples
  • Redim is deprecated, using ResizeTo instead

What is included in the purchase of this book:

Fourteen chapters and over 450 pages with over 65 examples that both show and describe the code. This book is in PDF format with example chapter folders containing Xojo source code and running examples.

The free book Table of Contents can be viewed at the authors website at: https://scispec.ca/index.php/books/58-canvas-control-3-with-xojo-desktop.

ISBN: 978-1-927924-28-0

2 Likes

Congratulations @Eugene_Dakin and happy and healthy 2021. Did you also wrote about the new Brushes and Shadow Object in Graphics?

@Martin_T,

I didn’t know about these objects. The book usually gets updates, and I’ll make examples for the next update. Thanks for letting me know :slight_smile:

1 Like

Yeah, there are Graphics.Brush (PictureBrush, LinearGradientBrush and RadialGradientBrush) and Graphics.Shadow (ShadowBrush) now.

Also new Line Properties: Graphics.LineDash, Graphics.LineJoin and Graphics.LineCap.

Also Graphics.DrawLine isn’t deprecated as you wrote. :wink:

1 Like

Thanks for the great suggestions !! :slight_smile:

It seems that picture.Drawline no longer works, and g.Drawline works. I think I mentioned that it doesn’t work in some circumstances, and your right that Drawline still works with the graphics object.