2
Ported to FPC by Nikolay Nikolov (nickysn@users.sourceforge.net)
6
Clip example for OpenPTC 1.0 C++ Implementation
7
Copyright (c) Glenn Fiedler (ptc@gaffer.org)
8
This source code is in the public domain
19
console : TPTCConsole;
20
surface : TPTCSurface;
23
x1, y1, x2, y2 : Integer;
25
width, height : Integer;
27
x, y, r, g, b : Integer;
36
console := TPTCConsole.Create;
39
format := TPTCFormat.Create(32, $00FF0000, $0000FF00, $000000FF);
42
console.open('Clip example', format);
44
{ create surface matching console dimensions }
45
surface := TPTCSurface.Create(console.width, console.height, format);
47
{ calculate clip coordinates }
48
x1 := console.width Div 4;
49
y1 := console.height Div 4;
50
x2 := console.width - x1;
51
y2 := console.height - y1;
54
area := TPTCArea.Create(x1, y1, x2, y2);
62
{ loop until a key is pressed }
63
While Not console.KeyPressed Do
66
pixels := surface.lock;
68
{ get surface dimensions }
69
width := surface.width;
70
height := surface.height;
72
{ draw random pixels }
75
{ get random position }
84
{ draw color [r,g,b] at position [x,y] }
85
pixels[x + y * width] := (r Shl 16) + (g Shl 8) + b;
93
surface.copy(console);
105
On error : TPTCError Do