source: trunk/Packages/Common/MetaCanvas.pas

Last change on this file was 2, checked in by chronos, 16 months ago
  • Added: Initial development version.
File size: 18.2 KB
Line 
1unit MetaCanvas;
2
3interface
4
5uses
6 Classes, SysUtils, Graphics, Types, Generics.Collections;
7
8type
9 TArrayOfPoint = array of TPoint;
10
11 { TCanvasObject }
12
13 TCanvasObject = class
14 procedure Paint(Canvas: TCanvas); virtual;
15 procedure Zoom(Factor: Double); virtual;
16 procedure Move(Delta: TPoint); virtual;
17 end;
18
19 TCanvasObjects = class(TObjectList<TCanvasObject>)
20 end;
21
22 { TCanvasText }
23
24 TCanvasText = class(TCanvasObject)
25 Brush: TBrush;
26 Font: TFont;
27 Position: TPoint;
28 Text: string;
29 procedure Paint(Canvas: TCanvas); override;
30 procedure Zoom(Factor: Double); override;
31 procedure Move(Delta: TPoint); override;
32 constructor Create;
33 destructor Destroy; override;
34 end;
35
36 { TCanvasRectangle }
37
38 TCanvasRectangle = class(TCanvasObject)
39 Pen: TPen;
40 Brush: TBrush;
41 BoundingRect: TRect;
42 Rounded: TPoint;
43 procedure Paint(Canvas: TCanvas); override;
44 procedure Zoom(Factor: Double); override;
45 procedure Move(Delta: TPoint); override;
46 constructor Create;
47 destructor Destroy; override;
48 end;
49
50 { TCanvasLine }
51
52 TCanvasLine = class(TCanvasObject)
53 Pen: TPen;
54 P1, P2: TPoint;
55 procedure Paint(Canvas: TCanvas); override;
56 procedure Zoom(Factor: Double); override;
57 procedure Move(Delta: TPoint); override;
58 constructor Create;
59 destructor Destroy; override;
60 end;
61
62 { TCanvasPolygon }
63
64 TCanvasPolygon = class(TCanvasObject)
65 Pen: TPen;
66 Brush: TBrush;
67 Points: array of TPoint;
68 procedure Paint(Canvas: TCanvas); override;
69 procedure Zoom(Factor: Double); override;
70 procedure Move(Delta: TPoint); override;
71 constructor Create;
72 destructor Destroy; override;
73 end;
74
75 { TCanvasPolyline }
76
77 TCanvasPolyline = class(TCanvasObject)
78 Pen: TPen;
79 Brush: TBrush;
80 Points: array of TPoint;
81 procedure Paint(Canvas: TCanvas); override;
82 procedure Zoom(Factor: Double); override;
83 procedure Move(Delta: TPoint); override;
84 constructor Create;
85 destructor Destroy; override;
86 end;
87
88 { TCanvasPolyBezier }
89
90 TCanvasPolyBezier = class(TCanvasObject)
91 Pen: TPen;
92 Brush: TBrush;
93 Points: array of TPoint;
94 procedure Paint(Canvas: TCanvas); override;
95 procedure Zoom(Factor: Double); override;
96 procedure Move(Delta: TPoint); override;
97 constructor Create;
98 destructor Destroy; override;
99 end;
100
101 { TCanvasEllipse }
102
103 TCanvasEllipse = class(TCanvasObject)
104 Pen: TPen;
105 Brush: TBrush;
106 BoundingRect: TRect;
107 procedure Paint(Canvas: TCanvas); override;
108 procedure Zoom(Factor: Double); override;
109 procedure Move(Delta: TPoint); override;
110 constructor Create;
111 destructor Destroy; override;
112 end;
113
114 { TCanvasPie }
115
116 TCanvasPie = class(TCanvasObject)
117 Pen: TPen;
118 Brush: TBrush;
119 BoundingRect: TRect;
120 StartPoint: TPoint;
121 EndPoint: TPoint;
122 procedure Paint(Canvas: TCanvas); override;
123 procedure Zoom(Factor: Double); override;
124 procedure Move(Delta: TPoint); override;
125 constructor Create;
126 destructor Destroy; override;
127 end;
128
129 { TCanvasStretchDraw }
130
131 TCanvasStretchDraw = class(TCanvasObject)
132 SrcGraphic: TGraphic;
133 DestRect: TRect;
134 procedure Paint(Canvas: TCanvas); override;
135 procedure Zoom(Factor: Double); override;
136 procedure Move(Delta: TPoint); override;
137 constructor Create;
138 destructor Destroy; override;
139 end;
140
141 { TMetaCanvas }
142
143 TMetaCanvas = class(TCanvas)
144 private
145 FSize: TPoint;
146 FPenPos: TPoint;
147 protected
148 procedure SetHeight(AValue: Integer); override;
149 function GetHeight: Integer; override;
150 procedure SetWidth(AValue: Integer); override;
151 function GetWidth: Integer; override;
152 procedure DoLine (x1,y1,x2,y2:integer); override;
153 procedure DoTextOut(X, Y: Integer; Text: string); override;
154 procedure DoRectangle(const Bounds: TRect); override;
155 procedure DoRectangleFill(const Bounds: TRect); override;
156 procedure DoPolygon(const Points: array of TPoint); override;
157 procedure CreateHandle; override;
158 procedure DoEllipse(const Bounds: TRect); override;
159 procedure DoMoveTo(X, Y: Integer); override;
160 procedure DoLineTo(X, Y: Integer); override;
161 procedure DoPolyline(const Points: array of TPoint); override;
162 procedure DoPolyBezier(Points: PPoint; NumPts: Integer;
163 Filled: Boolean = False; Continuous: Boolean = False); override;
164 public
165 Objects: TCanvasObjects;
166 procedure FillRect(const ARect: TRect); overload; override;
167 procedure FillRect(X1,Y1,X2,Y2: Integer); overload;
168 procedure RoundRect(X1, Y1, X2, Y2: Integer; RX,RY: Integer); overload; override;
169 procedure RoundRect(const Rect: TRect; RX,RY: Integer); overload;
170 procedure TextOut(X,Y: Integer; const Text: String); override;
171 procedure Polygon(Points: PPoint; NumPts: Integer; Winding: Boolean = False); override;
172 procedure Polyline(Points: PPoint; NumPts: Integer); override;
173 procedure PolyBezier(Points: PPoint; NumPts: Integer;
174 Filled: Boolean = False; Continuous: Boolean = True); override;
175 procedure Ellipse(x1, y1, x2, y2: Integer); override;
176 procedure StretchDraw(const DestRect: TRect; SrcGraphic: TGraphic); override;
177 function TextExtent(const Text: string): TSize; override;
178 procedure Pie(EllipseX1, EllipseY1, EllipseX2, EllipseY2,
179 StartX, StartY, EndX, EndY: Integer); override;
180 procedure Reset;
181 procedure DrawTo(Canvas: TCanvas);
182 procedure Zoom(Factor: Double);
183 procedure Move(Delta: TPoint);
184 constructor Create;
185 destructor Destroy; override;
186 property Size: TPoint read FSize write FSize;
187 end;
188
189
190implementation
191
192uses
193 Geometric, LCLIntf;
194
195{ TCanvasPolyBezier }
196
197procedure TCanvasPolyBezier.Paint(Canvas: TCanvas);
198begin
199 Canvas.Pen.Assign(Pen);
200 Canvas.Brush.Assign(Brush);
201 Canvas.PolyBezier(Points);
202end;
203
204procedure TCanvasPolyBezier.Zoom(Factor: Double);
205var
206 I: Integer;
207begin
208 for I := 0 to High(Points) do
209 Points[I] := Point(Trunc(Points[I].X * Factor),
210 Trunc(Points[I].Y * Factor));
211 Pen.Width := Trunc(Pen.Width * Factor);
212end;
213
214procedure TCanvasPolyBezier.Move(Delta: TPoint);
215var
216 I: Integer;
217begin
218 for I := 0 to High(Points) do
219 Points[I] := AddPoint(Points[I], Delta);
220end;
221
222constructor TCanvasPolyBezier.Create;
223begin
224 Pen := TPen.Create;
225 Brush := TBrush.Create;
226end;
227
228destructor TCanvasPolyBezier.Destroy;
229begin
230 FreeAndNil(Brush);
231 FreeAndNil(Pen);
232 inherited;
233end;
234
235{ TCanvasPolyline }
236
237procedure TCanvasPolyline.Paint(Canvas: TCanvas);
238begin
239 Canvas.Pen.Assign(Pen);
240 Canvas.Brush.Assign(Brush);
241 Canvas.Polyline(Points);
242end;
243
244procedure TCanvasPolyline.Zoom(Factor: Double);
245var
246 I: Integer;
247begin
248 for I := 0 to High(Points) do
249 Points[I] := Point(Trunc(Points[I].X * Factor),
250 Trunc(Points[I].Y * Factor));
251 Pen.Width := Trunc(Pen.Width * Factor);
252end;
253
254procedure TCanvasPolyline.Move(Delta: TPoint);
255var
256 I: Integer;
257begin
258 for I := 0 to High(Points) do
259 Points[I] := AddPoint(Points[I], Delta);
260end;
261
262constructor TCanvasPolyline.Create;
263begin
264 Pen := TPen.Create;
265 Brush := TBrush.Create;
266end;
267
268destructor TCanvasPolyline.Destroy;
269begin
270 FreeAndNil(Brush);
271 FreeAndNil(Pen);
272 inherited;
273end;
274
275{ TCanvasPie }
276
277procedure TCanvasPie.Paint(Canvas: TCanvas);
278begin
279 Canvas.Brush.Assign(Brush);
280 Canvas.Pen.Assign(Pen);
281 Canvas.Pie(BoundingRect.Left, BoundingRect.Top,
282 BoundingRect.Right, BoundingRect.Bottom, StartPoint.X, StartPoint.Y,
283 EndPoint.X, EndPoint.Y);
284end;
285
286procedure TCanvasPie.Zoom(Factor: Double);
287begin
288 BoundingRect := Rect(Trunc(BoundingRect.Left * Factor),
289 Trunc(BoundingRect.Top * Factor),
290 Trunc(BoundingRect.Right * Factor),
291 Trunc(BoundingRect.Bottom * Factor));
292 Pen.Width := Trunc(Pen.Width * Factor);
293 StartPoint := Point(Trunc(StartPoint.X * Factor), Trunc(StartPoint.Y * Factor));
294 EndPoint := Point(Trunc(EndPoint.X * Factor), Trunc(EndPoint.Y * Factor));
295end;
296
297procedure TCanvasPie.Move(Delta: TPoint);
298begin
299 BoundingRect := ShiftRect(BoundingRect, Delta);
300 StartPoint := AddPoint(StartPoint, Delta);
301 EndPoint := AddPoint(EndPoint, Delta);
302end;
303
304constructor TCanvasPie.Create;
305begin
306 Pen := TPen.Create;
307 Brush := TBrush.Create;
308end;
309
310destructor TCanvasPie.Destroy;
311begin
312 Pen.Free;
313 Brush.Free;
314 inherited;
315end;
316
317{ TCanvasStretchDraw }
318
319procedure TCanvasStretchDraw.Paint(Canvas: TCanvas);
320begin
321 Canvas.StretchDraw(DestRect, SrcGraphic);
322end;
323
324procedure TCanvasStretchDraw.Zoom(Factor: Double);
325begin
326 DestRect := Rect(Trunc(DestRect.Left * Factor),
327 Trunc(DestRect.Top * Factor),
328 Trunc(DestRect.Right * Factor),
329 Trunc(DestRect.Bottom * Factor));
330end;
331
332procedure TCanvasStretchDraw.Move(Delta: TPoint);
333begin
334 DestRect := ShiftRect(DestRect, Delta);
335end;
336
337constructor TCanvasStretchDraw.Create;
338begin
339 SrcGraphic := nil;
340end;
341
342destructor TCanvasStretchDraw.Destroy;
343begin
344 inherited;
345end;
346
347{ TCanvasEllipse }
348
349procedure TCanvasEllipse.Paint(Canvas: TCanvas);
350begin
351 Canvas.Pen.Assign(Pen);
352 Canvas.Brush.Assign(Brush);
353 Canvas.Ellipse(BoundingRect);
354end;
355
356procedure TCanvasEllipse.Zoom(Factor: Double);
357begin
358 BoundingRect := Rect(Trunc(BoundingRect.Left * Factor),
359 Trunc(BoundingRect.Top * Factor),
360 Trunc(BoundingRect.Right * Factor),
361 Trunc(BoundingRect.Bottom * Factor));
362 Pen.Width := Trunc(Pen.Width * Factor);
363end;
364
365procedure TCanvasEllipse.Move(Delta: TPoint);
366begin
367 BoundingRect := ShiftRect(BoundingRect, Delta);
368end;
369
370constructor TCanvasEllipse.Create;
371begin
372 Pen := TPen.Create;
373 Brush := TBrush.Create;
374end;
375
376destructor TCanvasEllipse.Destroy;
377begin
378 Pen.Free;
379 Brush.Free;
380 inherited;
381end;
382
383{ TCanvasPolygon }
384
385procedure TCanvasPolygon.Paint(Canvas: TCanvas);
386begin
387 Canvas.Pen.Assign(Pen);
388 Canvas.Brush.Assign(Brush);
389 Canvas.Polygon(Points);
390end;
391
392procedure TCanvasPolygon.Zoom(Factor: Double);
393var
394 I: Integer;
395begin
396 for I := 0 to High(Points) do
397 Points[I] := Point(Trunc(Points[I].X * Factor),
398 Trunc(Points[I].Y * Factor));
399 Pen.Width := Trunc(Pen.Width * Factor);
400end;
401
402procedure TCanvasPolygon.Move(Delta: TPoint);
403var
404 I: Integer;
405begin
406 for I := 0 to High(Points) do
407 Points[I] := AddPoint(Points[I], Delta);
408end;
409
410constructor TCanvasPolygon.Create;
411begin
412 Pen := TPen.Create;
413 Brush := TBrush.Create;
414end;
415
416destructor TCanvasPolygon.Destroy;
417begin
418 FreeAndNil(Brush);
419 FreeAndNil(Pen);
420 inherited;
421end;
422
423{ TCanvasLine }
424
425procedure TCanvasLine.Paint(Canvas: TCanvas);
426begin
427 Canvas.Pen.Assign(Pen);
428 Canvas.Line(P1, P2);
429end;
430
431procedure TCanvasLine.Zoom(Factor: Double);
432begin
433 P1 := Point(Trunc(P1.X * Factor), Trunc(P1.Y * Factor));
434 P2 := Point(Trunc(P2.X * Factor), Trunc(P2.Y * Factor));
435 Pen.Width := Trunc(Pen.Width * Factor);
436end;
437
438procedure TCanvasLine.Move(Delta: TPoint);
439begin
440 P1 := AddPoint(P1, Delta);
441 P2 := AddPoint(P2, Delta);
442end;
443
444constructor TCanvasLine.Create;
445begin
446 Pen := TPen.Create;
447end;
448
449destructor TCanvasLine.Destroy;
450begin
451 Pen.Free;
452 inherited;
453end;
454
455{ TCanvasRectangle }
456
457procedure TCanvasRectangle.Paint(Canvas: TCanvas);
458begin
459 Canvas.Pen.Assign(Pen);
460 Canvas.Brush.Assign(Brush);
461
462 if Rounded <> Point(0, 0) then Canvas.RoundRect(BoundingRect, Rounded.X, Rounded.Y)
463 else Canvas.Rectangle(BoundingRect);
464end;
465
466procedure TCanvasRectangle.Zoom(Factor: Double);
467begin
468 BoundingRect := Rect(Trunc(BoundingRect.Left * Factor),
469 Trunc(BoundingRect.Top * Factor),
470 Trunc(BoundingRect.Right * Factor),
471 Trunc(BoundingRect.Bottom * Factor));
472 Pen.Width := Trunc(Pen.Width * Factor);
473end;
474
475procedure TCanvasRectangle.Move(Delta: TPoint);
476begin
477 BoundingRect := ShiftRect(BoundingRect, Delta);
478end;
479
480constructor TCanvasRectangle.Create;
481begin
482 Pen := TPen.Create;
483 Brush := TBrush.Create;
484 Rounded := Point(0, 0);
485end;
486
487destructor TCanvasRectangle.Destroy;
488begin
489 Pen.Free;
490 Brush.Free;
491 inherited;
492end;
493
494{ TCanvasText }
495
496procedure TCanvasText.Paint(Canvas: TCanvas);
497begin
498 Canvas.Brush.Assign(Brush);
499 Canvas.Font.Assign(Font);
500 Canvas.TextOut(Position.X, Position.Y, Text);
501end;
502
503procedure TCanvasText.Zoom(Factor: Double);
504begin
505 Position := Point(Trunc(Position.X * Factor), Trunc(Position.Y * Factor));
506 Font.Size := Trunc(Font.Size * Factor);
507end;
508
509procedure TCanvasText.Move(Delta: TPoint);
510begin
511 Position := AddPoint(Position, Delta);
512end;
513
514constructor TCanvasText.Create;
515begin
516 Font := TFont.Create;
517 Brush := TBrush.Create;
518end;
519
520destructor TCanvasText.Destroy;
521begin
522 Brush.Free;
523 Font.Free;
524 inherited;
525end;
526
527{ TCanvasObject }
528
529procedure TCanvasObject.Paint(Canvas: TCanvas);
530begin
531
532end;
533
534procedure TCanvasObject.Zoom(Factor: Double);
535begin
536
537end;
538
539procedure TCanvasObject.Move(Delta: TPoint);
540begin
541end;
542
543{ TMetaCanvas }
544
545procedure TMetaCanvas.SetHeight(AValue: Integer);
546begin
547 FSize.Y := AValue;
548end;
549
550function TMetaCanvas.GetHeight: Integer;
551begin
552 Result := FSize.Y;
553end;
554
555procedure TMetaCanvas.SetWidth(AValue: Integer);
556begin
557 FSize.X := AValue;
558end;
559
560function TMetaCanvas.GetWidth: Integer;
561begin
562 Result := FSize.X;
563end;
564
565procedure TMetaCanvas.DoLine(x1, y1, x2, y2: integer);
566var
567 NewObj: TCanvasLine;
568begin
569 NewObj := TCanvasLine.Create;
570 NewObj.Pen.Assign(Pen);
571 NewObj.P1 := Point(X1, Y1);
572 NewObj.P2 := Point(X2, Y2);
573 Objects.Add(NewObj);
574end;
575
576procedure TMetaCanvas.DoTextOut(X, Y: Integer; Text: string);
577var
578 NewObj: TCanvasText;
579begin
580 NewObj := TCanvasText.Create;
581 NewObj.Font.Assign(Font);
582 NewObj.Brush.Assign(Brush);
583 NewObj.Position := Point(X, Y);
584 NewObj.Text := Text;
585 Objects.Add(NewObj);
586end;
587
588procedure TMetaCanvas.TextOut(X, Y: Integer; const Text: String);
589begin
590 DoTextOut(X, Y, Text);
591end;
592
593procedure TMetaCanvas.DoRectangle(const Bounds: TRect);
594var
595 NewObj: TCanvasRectangle;
596begin
597 NewObj := TCanvasRectangle.Create;
598 NewObj.Pen.Assign(Pen);
599 NewObj.BoundingRect := Bounds;
600 Objects.Add(NewObj);
601end;
602
603procedure TMetaCanvas.DoRectangleFill(const Bounds: TRect);
604var
605 NewObj: TCanvasRectangle;
606begin
607 NewObj := TCanvasRectangle.Create;
608 NewObj.Brush.Assign(Brush);
609 NewObj.Pen.Assign(Pen);
610 NewObj.BoundingRect := Bounds;
611 Objects.Add(NewObj);
612end;
613
614procedure TMetaCanvas.Polygon(Points: PPoint; NumPts: Integer; Winding: Boolean
615 );
616var
617 APoints: array of TPoint;
618 I: Integer;
619begin
620 APoints := nil;
621 SetLength(APoints, NumPts);
622 for I := 0 to High(APoints) do
623 APoints[I] := Points[I];
624 DoPolygon(APoints);
625end;
626
627procedure TMetaCanvas.Polyline(Points: PPoint; NumPts: Integer);
628var
629 APoints: array of TPoint;
630 I: Integer;
631begin
632 APoints := nil;
633 SetLength(APoints, NumPts);
634 for I := 0 to High(APoints) do
635 APoints[I] := Points[I];
636 DoPolyline(APoints);
637end;
638
639procedure TMetaCanvas.PolyBezier(Points: PPoint; NumPts: Integer;
640 Filled: Boolean; Continuous: Boolean);
641begin
642 DoPolyBezier(Points, NumPts, Filled, Continuous);
643end;
644
645procedure TMetaCanvas.DoPolygon(const Points: array of TPoint);
646var
647 NewObj: TCanvasPolygon;
648 I: Integer;
649begin
650 NewObj := TCanvasPolygon.Create;
651 NewObj.Brush.Assign(Brush);
652 NewObj.Pen.Assign(Pen);
653 SetLength(NewObj.Points, Length(Points));
654 for I := 0 to High(Points) do
655 NewObj.Points[I] := Points[I];
656 Objects.Add(NewObj);
657end;
658
659procedure TMetaCanvas.CreateHandle;
660begin
661end;
662
663procedure TMetaCanvas.Ellipse(x1, y1, x2, y2: Integer);
664begin
665 DoEllipse(Rect(X1, Y1, X2, Y2));
666end;
667
668procedure TMetaCanvas.DoEllipse(const Bounds: TRect);
669var
670 NewObj: TCanvasEllipse;
671begin
672 NewObj := TCanvasEllipse.Create;
673 NewObj.Brush.Assign(Brush);
674 NewObj.Pen.Assign(Pen);
675 NewObj.BoundingRect := Bounds;
676 Objects.Add(NewObj);
677end;
678
679procedure TMetaCanvas.StretchDraw(const DestRect: TRect; SrcGraphic: TGraphic);
680var
681 NewObj: TCanvasStretchDraw;
682begin
683 NewObj := TCanvasStretchDraw.Create;
684 NewObj.SrcGraphic := SrcGraphic;
685 NewObj.DestRect := DestRect;
686 Objects.Add(NewObj);
687end;
688
689function TMetaCanvas.TextExtent(const Text: string): TSize;
690var
691 Canvas: TCanvas;
692begin
693 Canvas := TCanvas.Create;
694 Canvas.Handle := CreateCompatibleDC(0);
695 Canvas.Font.Assign(Font);
696 Result := Canvas.TextExtent(Text);
697 DeleteDC(Canvas.Handle);
698 Canvas.Free;
699end;
700
701procedure TMetaCanvas.DoMoveTo(X, Y: Integer);
702begin
703 FPenPos := Point(X, Y);
704end;
705
706procedure TMetaCanvas.DoLineTo(X, Y: Integer);
707begin
708 DoLine(FPenPos.X, FPenPos.Y, X, Y);
709 DoMoveTo(X, Y);
710end;
711
712procedure TMetaCanvas.DoPolyline(const Points: array of TPoint);
713var
714 NewObj: TCanvasPolyline;
715 I: Integer;
716begin
717 NewObj := TCanvasPolyline.Create;
718 NewObj.Brush.Assign(Brush);
719 NewObj.Pen.Assign(Pen);
720 SetLength(NewObj.Points, Length(Points));
721 for I := 0 to High(Points) do
722 NewObj.Points[I] := Points[I];
723 Objects.Add(NewObj);
724end;
725
726procedure TMetaCanvas.DoPolyBezier(Points: PPoint; NumPts: Integer;
727 Filled: Boolean; Continuous: Boolean);
728var
729 NewObj: TCanvasPolyBezier;
730 I: Integer;
731begin
732 NewObj := TCanvasPolyBezier.Create;
733 NewObj.Brush.Assign(Brush);
734 NewObj.Pen.Assign(Pen);
735 SetLength(NewObj.Points, NumPts);
736 for I := 0 to High(NewObj.Points) do
737 NewObj.Points[I] := Points[I];
738 Objects.Add(NewObj);
739end;
740
741procedure TMetaCanvas.FillRect(const ARect: TRect);
742begin
743 DoRectangleFill(ARect);
744end;
745
746procedure TMetaCanvas.FillRect(X1, Y1, X2, Y2: Integer);
747begin
748 FillRect(Rect(X1, Y1, X2, Y2));
749end;
750
751procedure TMetaCanvas.RoundRect(X1, Y1, X2, Y2: Integer; RX, RY: Integer);
752begin
753 RoundRect(Rect(X1, Y1, X2, Y2), RX, RY);
754end;
755
756procedure TMetaCanvas.RoundRect(const Rect: TRect; RX, RY: Integer);
757var
758 NewObj: TCanvasRectangle;
759begin
760 NewObj := TCanvasRectangle.Create;
761 NewObj.Brush.Assign(Brush);
762 NewObj.Pen.Assign(Pen);
763 NewObj.BoundingRect := Rect;
764 NewObj.Rounded := Point(RX, RY);
765 Objects.Add(NewObj);
766end;
767
768procedure TMetaCanvas.Pie(EllipseX1, EllipseY1, EllipseX2, EllipseY2, StartX,
769 StartY, EndX, EndY: Integer);
770var
771 NewObj: TCanvasPie;
772begin
773 NewObj := TCanvasPie.Create;
774 NewObj.Brush.Assign(Brush);
775 NewObj.Pen.Assign(Pen);
776 NewObj.BoundingRect := Rect(EllipseX1, EllipseY1, EllipseX2, EllipseY2);
777 NewObj.StartPoint := Point(StartX, StartY);
778 NewObj.EndPoint := Point(EndX, EndY);
779 Objects.Add(NewObj);
780end;
781
782procedure TMetaCanvas.Reset;
783begin
784 Objects.Count := 0;
785end;
786
787procedure TMetaCanvas.DrawTo(Canvas: TCanvas);
788var
789 I: Integer;
790begin
791 for I := 0 to Objects.Count - 1 do
792 Objects[I].Paint(Canvas);
793end;
794
795procedure TMetaCanvas.Zoom(Factor: Double);
796var
797 I: Integer;
798begin
799 for I := 0 to Objects.Count - 1 do
800 Objects[I].Zoom(Factor);
801end;
802
803procedure TMetaCanvas.Move(Delta: TPoint);
804var
805 I: Integer;
806begin
807 for I := 0 to Objects.Count - 1 do
808 Objects[I].Move(Delta);
809end;
810
811constructor TMetaCanvas.Create;
812begin
813 inherited;
814 FPenPos := Point(0, 0);
815 Objects := TCanvasObjects.Create;
816end;
817
818destructor TMetaCanvas.Destroy;
819begin
820 Objects.Free;
821 inherited;
822end;
823
824end.
Note: See TracBrowser for help on using the repository browser.