summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2022-01-18 22:43:20 +0100
committerErich Eckner <git@eckner.net>2022-01-18 22:43:20 +0100
commit3fac7d25a157b0ee3d2299be7493e09dac607be2 (patch)
tree90b2e8f9daada888999546eb9b8408c1927dfb15
parentc187e6817f07151c6a074bbe68a0787c5024f323 (diff)
downloadPenrose-master.tar.xz
Farben gehen so la-laHEADmaster
-rwxr-xr-xpenrosebin26443368 -> 26443376 bytes
-rw-r--r--penroseunit.pas29
2 files changed, 18 insertions, 11 deletions
diff --git a/penrose b/penrose
index c4d8278..9f7e2be 100755
--- a/penrose
+++ b/penrose
Binary files differ
diff --git a/penroseunit.pas b/penroseunit.pas
index eac0a69..7aee2ba 100644
--- a/penroseunit.pas
+++ b/penroseunit.pas
@@ -19,7 +19,7 @@ type
private
teile: array of tTeil;
function teilEcken(i: longint): tExtPointArray;
- function id2color(id: int64): tColor;
+ function id2color(id,mx: int64): tColor;
public
constructor create(level: longint);
procedure Zeichnen(breite, hoehe: longint; Canvas: TCanvas);
@@ -96,29 +96,33 @@ begin
result[j]:=teile[i].Groesze * rotationsMatrix(teile[i].Richtung) * result[j] + teile[i].Ursprung;
end;
-function tPenrose.id2color(id: int64): tColor;
+function tPenrose.id2color(id,mx: int64): tColor;
const
- steps = 256;
+ fLen = 6;//2;
var
- farben: array[0..6] of tExt3dPoint;
+ farben: tExt3dPointArray;
r: tExt3dPoint;
-var
i: integer;
+ x: extended;
begin
+ setLength(farben,fLen+1);
for i:=0 to 2 do
- farben[2*i]:=ext3dPoint($ff*byte(i=2),$ff*byte(i=1),$ff*byte(i=0));
+ farben[2*i]:=ext3dPoint($ff*byte(i=0),$ff*byte(i=1),$ff*byte(i=2));
for i:=0 to 2 do
farben[7-2*i]:=ext3dPoint($ff,$ff,$ff)-farben[2*i];
- farben[6]:=farben[0];
- id:=id mod (steps*(length(farben)-1));
- i:=id div steps;
- r:=(id/steps - i) * farben[i+1] + (1+i-id/steps) * farben[i];
+(* for i:=0 to 1 do
+ farben[i]:=i*ext3dPoint($ff,$ff,$ff); *)
+ farben[fLen]:=farben[0];
+ x:=(id mod mx)/mx*fLen;
+ i:=floor(x/fLen);
+ r:=(x - i) * farben[i+1] + (1+i-x) * farben[i];
result:=round(r['x']) + (round(r['y']) shl 8) + (round(r['z']) shl 16)
end;
procedure tPenrose.Zeichnen(breite, hoehe: longint; Canvas: TCanvas);
var
lo,ru: tExtPoint;
+ mx: int64;
ecken: tExtPointArray;
i,j: longint;
c: char;
@@ -128,6 +132,7 @@ var
begin
lo:=extPoint(0,0);
ru:=lo;
+ mx:=0;
for i:=0 to length(teile)-1 do begin
ecken:=teilEcken(i);
for j:=0 to length(ecken)-1 do
@@ -135,12 +140,14 @@ begin
lo[c]:=min(lo[c],ecken[j][c]);
ru[c]:=max(ru[c],ecken[j][c]);
end;
+ mx:=max(mx,teile[i].id);
end;
Groesze:=min(
(breite-1) / (ru['x']-lo['x']),
(hoehe-1) / (ru['y']-lo['y'])
);
Verschiebung:=-Groesze * lo;
+ mx:=max(1,mx div 4);
canvas.brush.Color:=$ffffff;
canvas.rectangle(-10,-10,breite+10,hoehe+10);
@@ -151,7 +158,7 @@ begin
ecken[j]:=Verschiebung + Groesze * ecken[j];
points[j]:=point(round(ecken[j]['x']),round(ecken[j]['y']));
end;
- canvas.brush.Color:=id2color(teile[i].id);
+ canvas.brush.Color:=id2color(teile[i].id,mx);
canvas.pen.Color:=canvas.brush.Color;
canvas.Polygon(points);
end;