CreatePattern Method
Class THtml5Canvas2D
function CreatePattern(Node: TDOM_Node; Pattern: TCanvasPatternMode): TCanvasPattern;
The CreatePattern method creates a pattern object used to repeat an element in a specified direction. The element can be an image, video, or another canvas element. The repeated element can be used to draw/fill rectangles, circles, lines etc.
Parameter Values
Handle to the image, canvas, or video element of the pattern to use.
cpaRepeat
The pattern repeats both horizontally and vertically.
cpaRepeatX
The pattern repeats only horizontally.
cpaRepeatY
The pattern repeats only vertically.
cpaNoRepeat
The pattern will be displayed only once (no repeat).
Example:
Repeat an image both horizontally and vertically:
Image to Use:
Use an image to fill the drawing pattern:
Add this code to your image update or image load event:
Canvas.Rect(250, 30, 150, 100);
Canvas.FillStyle := Canvas.CreatePattern(ImgLamp.DomHandle, cpaRepeat);
Canvas.Fill;