--- a/hedgewars/uLandGraphics.pas Mon May 28 22:42:59 2012 +0400
+++ b/hedgewars/uLandGraphics.pas Wed May 30 18:00:29 2012 +0400
@@ -39,6 +39,7 @@
procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean);
function LandBackPixel(x, y: LongInt): LongWord;
procedure DrawLine(X1, Y1, X2, Y2: LongInt; Color: Longword);
+procedure DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword);
function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; indestructible: boolean): boolean;
@@ -1056,4 +1057,39 @@
end
end;
+procedure DrawLines(X1, Y1, X2, Y2, dx, dy: LongInt; color: Longword);
+begin
+DrawLine(x1 + dx, y1 + dy, x2 + dx, y2 + dy, color);
+DrawLine(x1 + dx, y1 - dy, x2 + dx, y2 - dy, color);
+DrawLine(x1 - dx, y1 + dy, x2 - dx, y2 + dy, color);
+DrawLine(x1 - dx, y1 - dy, x2 - dx, y2 - dy, color);
+
+DrawLine(x1 + dy, y1 + dx, x2 + dy, y2 + dx, color);
+DrawLine(x1 + dy, y1 - dx, x2 + dy, y2 - dx, color);
+DrawLine(x1 - dy, y1 + dx, x2 - dy, y2 + dx, color);
+DrawLine(x1 - dy, y1 - dx, x2 - dy, y2 - dx, color);
+end;
+
+procedure DrawThickLine(X1, Y1, X2, Y2, radius: LongInt; color: Longword);
+var dx, dy, d: LongInt;
+begin
+ dx:= 0;
+ dy:= Radius;
+ d:= 3 - 2 * Radius;
+ while (dx < dy) do
+ begin
+ DrawLines(x1, y1, x2, y2, dx, dy, color);
+ if (d < 0) then
+ d:= d + 4 * dx + 6
+ else
+ begin
+ d:= d + 4 * (dx - dy) + 10;
+ dec(dy)
+ end;
+ inc(dx)
+ end;
+ if (dx = dy) then
+ DrawLines(x1, y1, x2, y2, dx, dy, color);
+end;
+
end.
--- a/hedgewars/uLandPainted.pas Mon May 28 22:42:59 2012 +0400
+++ b/hedgewars/uLandPainted.pas Wed May 30 18:00:29 2012 +0400
@@ -43,78 +43,6 @@
var pointsListHead, pointsListLast: PPointEntry;
-procedure DrawLineOnLand(X1, Y1, X2, Y2, radius: LongInt; color: Longword);
-var eX, eY, dX, dY: LongInt;
- i, sX, sY, x, y, d: LongInt;
- b: boolean;
- len: LongWord;
-begin
- len:= 0;
- if (X1 = X2) and (Y1 = Y2) then
- begin
- exit
- end;
- eX:= 0;
- eY:= 0;
- dX:= X2 - X1;
- dY:= Y2 - Y1;
-
- if (dX > 0) then
- sX:= 1
- else
- if (dX < 0) then
- begin
- sX:= -1;
- dX:= -dX
- end
- else
- sX:= dX;
-
- if (dY > 0) then
- sY:= 1
- else
- if (dY < 0) then
- begin
- sY:= -1;
- dY:= -dY
- end
- else
- sY:= dY;
-
- if (dX > dY) then
- d:= dX
- else
- d:= dY;
-
- x:= X1;
- y:= Y1;
-
- for i:= 0 to d do
- begin
- inc(eX, dX);
- inc(eY, dY);
- b:= false;
- if (eX > d) then
- begin
- dec(eX, d);
- inc(x, sX);
- b:= true
- end;
- if (eY > d) then
- begin
- dec(eY, d);
- inc(y, sY);
- b:= true
- end;
- if b then
- begin
- inc(len);
- if (len mod 4) = 0 then
- FillRoundInLand(X, Y, radius, color)
- end
- end
-end;
-
procedure chDraw(var s: shortstring);
var rec: PointRec;
prec: ^PointRec;
@@ -173,7 +101,8 @@
else
begin
AddFileLog('[DRAW] Line to: ('+inttostr(pe^.point.X)+','+inttostr(pe^.point.Y)+'), radius = '+inttostr(radius));
- DrawLineOnLand(prevPoint.X, prevPoint.Y, pe^.point.X, pe^.point.Y, radius, color);
+ DrawThickLine(prevPoint.X, prevPoint.Y, pe^.point.X, pe^.point.Y, radius, color);
+ FillRoundInLand(pe^.point.X, pe^.point.Y, radius, color)
end;
prevPoint:= pe^.point;