hedgewars/uLand.pas
changeset 429 7f69c7ac2e97
parent 393 db01cc79f278
child 430 57d05fb13ea7
equal deleted inserted replaced
428:1052ef2f7863 429:7f69c7ac2e97
   398                FillPoints^[i].y:= 1023 - FillPoints^[i].y;
   398                FillPoints^[i].y:= 1023 - FillPoints^[i].y;
   399            end;
   399            end;
   400      end
   400      end
   401 end;
   401 end;
   402 
   402 
   403 procedure RandomizePoints(var pa: TPixAr; MaxRad: LongInt);
   403 procedure RandomizePoints(var pa: TPixAr);
   404 const cEdge = 55;
   404 const cEdge = 55;
   405       cMinDist = 0;
   405       cMinDist = 0;
   406 var radz: array[0..Pred(cMaxEdgePoints)] of LongInt;
   406 var radz: array[0..Pred(cMaxEdgePoints)] of LongInt;
   407     i, k, dist: LongInt;
   407     i, k, dist: LongInt;
   408 begin
   408 begin
   414       radz[i]:= Min(Max(x - cEdge, 0), Max(2048 - cEdge - x, 0));
   414       radz[i]:= Min(Max(x - cEdge, 0), Max(2048 - cEdge - x, 0));
   415       radz[i]:= Min(radz[i], Min(Max(y - cEdge, 0), Max(1024 - cEdge - y, 0)));
   415       radz[i]:= Min(radz[i], Min(Max(y - cEdge, 0), Max(1024 - cEdge - y, 0)));
   416       if radz[i] > 0 then
   416       if radz[i] > 0 then
   417         for k:= 0 to Pred(i) do
   417         for k:= 0 to Pred(i) do
   418           begin
   418           begin
   419           dist:= Min(Max(abs(x - pa.ar[k].x), abs(y - pa.ar[k].y)), MaxRad);
   419           dist:= Max(abs(x - pa.ar[k].x), abs(y - pa.ar[k].y));
   420           radz[k]:= Max(0, Min((dist - cMinDist) div 2, radz[k]));
   420           radz[k]:= Max(0, Min((dist - cMinDist) div 2, radz[k]));
   421           radz[i]:= Max(0, Min(dist - radz[k] - cMinDist, radz[i]))
   421           radz[i]:= Max(0, Min(dist - radz[k] - cMinDist, radz[i]))
   422         end
   422         end
   423       end;
   423       end;
   424 
   424 
   440 for y:= 0 to 1023 do
   440 for y:= 0 to 1023 do
   441     for x:= 0 to 2047 do
   441     for x:= 0 to 2047 do
   442         Land[y, x]:= COLOR_LAND;
   442         Land[y, x]:= COLOR_LAND;
   443 
   443 
   444 SetPoints(Template, pa);
   444 SetPoints(Template, pa);
   445 BezierizeEdge(pa, _1div3);
   445 for i:= 1 to Template.BezierizeCount do
   446 for i:= 0 to Pred(Template.RandPassesCount) do RandomizePoints(pa, 1000);
   446     begin
   447 BezierizeEdge(pa, _1div3);
   447     BezierizeEdge(pa, _1div3);
   448 RandomizePoints(pa, 1000);
   448     RandomizePoints(pa)
       
   449     end;
       
   450 for i:= 1 to Template.RandPassesCount do RandomizePoints(pa);
   449 BezierizeEdge(pa, _0_1);
   451 BezierizeEdge(pa, _0_1);
   450 
   452 
   451 DrawEdge(pa, 0);
   453 DrawEdge(pa, 0);
   452 
   454 
   453 with Template do
   455 with Template do