1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
procedure TForm1.RemoveTheRect;
var
R : TRect;
begin
R := NormalizeRect(Rect(MaskRect.TopLeft.X,MaskRect.TopLeft.Y,MaskRect.BottomRight.X,MaskRect.BottomRight.Y)); // Rectangle might be flipped
InflateRect(R,1,1); // Make the rectangle 1 pixel larger
InvalidateRect(Handle,@R,True); // Mark the area as invalid
InflateRect(R,-2,-2); // Now shrink the rectangle 2 pixels
ValidateRect(Handle,@R); // And validate this new rectangle.
// This leaves a 2 pixel band all the way around
// the rectangle that will be erased & redrawn
UpdateWindow(Handle);
end;
procedure TForm1.DrawTheRect;
begin
// Determines starting pixel color of Rect
Counter := CounterStart;
// Use LineDDA to draw each of the 4 edges of the rectangle
LineDDA(MaskRect.TopLeft.X,MaskRect.TopLeft.Y,MaskRect.BottomRight.X,MaskRect.TopLeft.Y,@MovingDots,LongInt(Canvas));
LineDDA(MaskRect.BottomRight.X,MaskRect.TopLeft.Y,MaskRect.BottomRight.X,MaskRect.BottomRight.Y,@MovingDots,LongInt(Canvas));
LineDDA(MaskRect.BottomRight.X,MaskRect.BottomRight.Y,MaskRect.TopLeft.X,MaskRect.BottomRight.Y,@MovingDots,LongInt(Canvas));
LineDDA(MaskRect.TopLeft.X,MaskRect.BottomRight.Y,MaskRect.TopLeft.X,MaskRect.TopLeft.Y,@MovingDots,LongInt(Canvas));
end; |
Partager