![]() ![]() Procedure PaintAliased ( Canvas : TCanvas x, y : integer const TheText : string ) var w, h, dx, dy : Integer IntfImg : TLazIntfImage Img : TBitmap col : TFPColor FontColor, c : TColor begin w := 0 h := 0 Canvas. The fill color is determined by the color of the canvas's Brush, and the border color is given by the color of the canvas's Pen: You can pass rectangle's edge coordinates to the method either as four separate x/y values, or as a single TRect record. The TCanvas method for painting a rectangle is named very logically: Rectangle(). Never paint in an OnClick handler, because this painting is not persistent and will be erased whenever the operating system requests a repaint. For this purpose we must add code to the OnPaint event of the form. Suppose we want to draw a red rectangle with a 5-pixel-thick blue border in the center of the form, and the the rectangle should be half the size of the form. Let's use TForm as an example to demonstrate how to paint on a canvas. Such controls include TForm, TPanel and TPaintBox. Many controls expose their canvas as a public Canvas property (or via an OnPaint event). In the widgetset LCL-CustomDrawn the native classes are implemented using the non-native ones.Īll of these classes will be better described in the sections below. The non-native classes are guaranteed to perform exactly the same drawing in all platforms with a pixel level precision and they all perform reasonably fast in all platforms. The speed and also the exact final result of the image drawing can have differences. The main difference between the native classes and the non-native ones is that the native ones do not perform exactly the same in all platforms, because the drawing is done by the underlying platform itself. lazcanvas: TLazCanvas is a non-native Canvas which can draw to an image in a TLazIntfImage.intfgraphics: TLazIntfImage is an image which attaches itself to a TRawImage and takes care of converting between TFPColor and the real pixel format of the TRawImage.graphtype: TRawImage is the storage and description of a memory area which contains an image.In Windows it is very fast because Windows allows creating a locally allocated image which can receive drawings from a Windows Canvas.īesides these there are also non-native drawing classes located in the units: TRasterImage (usually used via its descendant TBitmap) is a memory area reserved for drawing graphics, but it is created for maximum compatibility with the native Canvas and therefore in LCL-Gtk2 in X11 it is located in the X11 server, which makes pixel access via the Pixels property extremely slow. ![]() TFont, TBrush and TPen describe how the drawing of various operations will be executed in the Canvas. It cannot exist alone and must either be attached to something visible (or at least which may possibly be visible), such as a visual control descending from TControl, or be attached to an off-screen buffer from a TRasterImage descendent (TBitmap is the most commonly used). TCanvas is a class capable of executing drawings. These classes are: TBitmap, TCanvas, TFont, TBrush, TPen, TPortableNetworkGraphic, etc. The native classes are mostly located in the unit Graphics of the LCL. Native graphics classes are the most traditional way of drawing graphics in the LCL and are also the most important one, while the non-native classes are complementary, but also very important. The Lazarus Component Library (LCL) provides two kinds of drawing class: Native classes and non-native classes. Introduction to the Graphics model of the LCL Graphics libraries - here you can see the main graphic libraries you can use to develop. 15.2 Example 2: Drawing on controls of Form.15.1 Example 1: Drawing on loaded JPEG with TImage.10.3 Create a custom control which draws itself.10.1.3 Painting on the volatile visual area of the TImage.10.1.2 Painting on the bitmap of a TImage.10 Motion Graphics - How to Avoid flickering.9.7 Using the non-native StretchDraw from LazCanvas.9.6 Conversion between TLazIntfImage and TBitmap.9.3 Loading a TLazIntfImage into a TImage.9 Working with TLazIntfImage, TRawImage and TLazCanvas.8.1 Loading/Saving an image from/to the disk.8 Working with TBitmap and other TGraphic descendents.6 Drawing text with sharp edges (non antialiased).5 Drawing text to an exactly fitting width.2 Introduction to the Graphics model of the LCL.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |