hedgewars/uLandOutline.pas
branchtransitional_engine
changeset 15900 128ace913837
parent 14025 bb2f4636787f
equal deleted inserted replaced
15899:73cdc306888f 15900:128ace913837
     8               Count: Longword;
     8               Count: Longword;
     9               ar: array[0..Pred(cMaxEdgePoints)] of TPoint;
     9               ar: array[0..Pred(cMaxEdgePoints)] of TPoint;
    10               end;
    10               end;
    11 
    11 
    12 procedure DrawEdge(var pa: TPixAr; value: Word);
    12 procedure DrawEdge(var pa: TPixAr; value: Word);
    13 procedure FillLand(x, y: LongInt; border, value: Word);
       
    14 procedure BezierizeEdge(var pa: TPixAr; Delta: hwFloat);
    13 procedure BezierizeEdge(var pa: TPixAr; Delta: hwFloat);
    15 
    14 
    16 implementation
    15 implementation
    17 
    16 
    18 uses uLandGraphics, uDebug, uVariables, uLandTemplates;
    17 uses uLandGraphics, uDebug, uVariables, uLandTemplates, uLandUtils;
    19 
    18 
    20 
    19 
    21 var Stack: record
    20 var Stack: record
    22            Count: Longword;
    21            Count: Longword;
    23            points: array[0..8192] of record
    22            points: array[0..8192] of record
    50         _xl:= xl;
    49         _xl:= xl;
    51         _xr:= xr;
    50         _xr:= xr;
    52         _y:= y;
    51         _y:= y;
    53         _dir:= dir
    52         _dir:= dir
    54         end
    53         end
    55 end;
       
    56 
       
    57 procedure FillLand(x, y: LongInt; border, value: Word);
       
    58 var xl, xr, dir: LongInt;
       
    59 begin
       
    60     Stack.Count:= 0;
       
    61     xl:= x - 1;
       
    62     xr:= x;
       
    63     Push(xl, xr, y, -1);
       
    64     Push(xl, xr, y,  1);
       
    65     dir:= 0;
       
    66     while Stack.Count > 0 do
       
    67         begin
       
    68         Pop(xl, xr, y, dir);
       
    69         while (xl > 0) and (Land[y, xl] <> border) and (Land[y, xl] <> value) do
       
    70             dec(xl);
       
    71         while (xr < LAND_WIDTH - 1) and (Land[y, xr] <> border) and (Land[y, xr] <> value) do
       
    72             inc(xr);
       
    73         while (xl < xr) do
       
    74             begin
       
    75             while (xl <= xr) and ((Land[y, xl] = border) or (Land[y, xl] = value)) do
       
    76                 inc(xl);
       
    77             x:= xl;
       
    78             while (xl <= xr) and (Land[y, xl] <> border) and (Land[y, xl] <> value) do
       
    79                 begin
       
    80                 Land[y, xl]:= value;
       
    81                 inc(xl)
       
    82                 end;
       
    83             if x < xl then
       
    84                 begin
       
    85                 Push(x, Pred(xl), y, dir);
       
    86                 Push(x, Pred(xl), y,-dir);
       
    87                 end;
       
    88             end;
       
    89         end;
       
    90 end;
    54 end;
    91 
    55 
    92 procedure DrawEdge(var pa: TPixAr; value: Word);
    56 procedure DrawEdge(var pa: TPixAr; value: Word);
    93 var i: LongInt;
    57 var i: LongInt;
    94 begin
    58 begin