Shapes

A lot of low-level drawing code can be avoided by using different controls from the Shape category on the Tool Palette. There are lines, circles, ellipses, rectangles, pies, paths, and more. They just encapsulate drawing on the canvas, so you need not write so much code.

Let's try to recreate our sun visualisation with shapes to better compare these two possible approaches to drawing. Add a new Form HD to the project. Drop the TRectangle component on the form and align it to Client. Change its Name property to rectSky. Expand its Fill property and change Color to Skyblue. Drop the TCircle component on the form and name it circleSun. Change its Width and Height properties to 100 to make it bigger, and its Position.X and Position.Y

Get Expert Delphi now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.