diff options
author | Erich Eckner <git@eckner.net> | 2023-07-10 21:48:00 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2023-07-10 21:48:00 +0200 |
commit | 9bdbb88d2d4a79da872d62b2091fbf7e824d6d60 (patch) | |
tree | b77535c0edf193f5020a7ce45ecd982c0c536d53 | |
parent | fb3f9ff8b3e34d4084230b72a21595599c250f07 (diff) | |
download | spectre-master.tar.xz |
-rw-r--r-- | spectre.lps | 99 | ||||
-rw-r--r-- | spectreunit.pas | 47 | ||||
-rw-r--r-- | unit1.pas | 2 |
3 files changed, 94 insertions, 54 deletions
diff --git a/spectre.lps b/spectre.lps index 975dbf5..9168810 100644 --- a/spectre.lps +++ b/spectre.lps @@ -20,9 +20,8 @@ <HasResources Value="True"/> <ResourceBaseClass Value="Form"/> <UnitName Value="Unit1"/> - <IsVisibleTab Value="True"/> - <TopLine Value="32"/> - <CursorPos X="40" Y="62"/> + <TopLine Value="33"/> + <CursorPos Y="47"/> <UsageCount Value="20"/> <Loaded Value="True"/> <LoadedDesigner Value="True"/> @@ -30,9 +29,10 @@ <Unit> <Filename Value="spectreunit.pas"/> <IsPartOfProject Value="True"/> + <IsVisibleTab Value="True"/> <EditorIndex Value="1"/> - <TopLine Value="19"/> - <CursorPos Y="49"/> + <TopLine Value="42"/> + <CursorPos X="41" Y="70"/> <UsageCount Value="20"/> <Loaded Value="True"/> </Unit> @@ -47,14 +47,15 @@ <Unit> <Filename Value="/usr/lib/lazarus/lcl/graphics.pp"/> <UnitName Value="Graphics"/> - <EditorIndex Value="-1"/> - <TopLine Value="952"/> - <CursorPos X="3" Y="969"/> + <EditorIndex Value="2"/> + <TopLine Value="183"/> + <CursorPos X="3" Y="201"/> <UsageCount Value="10"/> + <Loaded Value="True"/> </Unit> <Unit> <Filename Value="../units/lowlevelunit.pas"/> - <EditorIndex Value="3"/> + <EditorIndex Value="5"/> <TopLine Value="1036"/> <CursorPos Y="1063"/> <UsageCount Value="10"/> @@ -77,45 +78,23 @@ </Unit> <Unit> <Filename Value="../units/matheunit.pas"/> - <EditorIndex Value="2"/> + <EditorIndex Value="4"/> <TopLine Value="1235"/> <CursorPos X="5" Y="1268"/> <UsageCount Value="10"/> <Loaded Value="True"/> </Unit> + <Unit> + <Filename Value="/usr/lib/lazarus/components/lazutils/graphtype.pp"/> + <UnitName Value="GraphType"/> + <EditorIndex Value="3"/> + <TopLine Value="26"/> + <CursorPos X="3" Y="43"/> + <UsageCount Value="10"/> + <Loaded Value="True"/> + </Unit> </Units> - <JumpHistory HistoryIndex="28"> - <Position> - <Filename Value="../units/lowlevelunit.pas"/> - </Position> - <Position> - <Filename Value="../units/lowlevelunit.pas"/> - <Caret Line="29" Column="12"/> - </Position> - <Position> - <Filename Value="../units/lowlevelunit.pas"/> - <Caret Line="35" Column="19" TopLine="7"/> - </Position> - <Position> - <Filename Value="../units/lowlevelunit.pas"/> - <Caret Line="37" Column="47" TopLine="9"/> - </Position> - <Position> - <Filename Value="../units/lowlevelunit.pas"/> - <Caret Line="69" Column="29" TopLine="41"/> - </Position> - <Position> - <Filename Value="../units/lowlevelunit.pas"/> - <Caret Line="74" Column="41" TopLine="46"/> - </Position> - <Position> - <Filename Value="../units/lowlevelunit.pas"/> - <Caret Line="78" Column="41" TopLine="50"/> - </Position> - <Position> - <Filename Value="../units/lowlevelunit.pas"/> - <Caret Line="82" Column="52" TopLine="54"/> - </Position> + <JumpHistory HistoryIndex="29"> <Position> <Filename Value="../units/lowlevelunit.pas"/> <Caret Line="84" Column="50" TopLine="56"/> @@ -200,6 +179,42 @@ <Filename Value="../units/matheunit.pas"/> <Caret Line="1268" Column="5" TopLine="1235"/> </Position> + <Position> + <Filename Value="spectreunit.pas"/> + <Caret Line="63" Column="24" TopLine="33"/> + </Position> + <Position> + <Filename Value="/usr/lib/lazarus/lcl/graphics.pp"/> + <Caret Line="1093" Column="15" TopLine="1078"/> + </Position> + <Position> + <Filename Value="/usr/lib/lazarus/lcl/graphics.pp"/> + <Caret Line="201" Column="3" TopLine="183"/> + </Position> + <Position> + <Filename Value="spectreunit.pas"/> + <Caret Line="63" Column="75" TopLine="34"/> + </Position> + <Position> + <Filename Value="spectreunit.pas"/> + <Caret Line="65" Column="40" TopLine="33"/> + </Position> + <Position> + <Filename Value="spectreunit.pas"/> + <Caret Line="64" Column="16" TopLine="36"/> + </Position> + <Position> + <Filename Value="spectreunit.pas"/> + <Caret Line="59" Column="12" TopLine="36"/> + </Position> + <Position> + <Filename Value="spectreunit.pas"/> + <Caret Line="64" Column="81" TopLine="34"/> + </Position> + <Position> + <Filename Value="spectreunit.pas"/> + <Caret Line="70" Column="62" TopLine="44"/> + </Position> </JumpHistory> <RunParams> <FormatVersion Value="2"/> diff --git a/spectreunit.pas b/spectreunit.pas index f84fb98..7b258e3 100644 --- a/spectreunit.pas +++ b/spectreunit.pas @@ -12,6 +12,9 @@ type private _o: tExtPoint; _alpha,_size: extended; + _ecken: array of tExtPoint; + _winkel: array of extended; + procedure berechneEckenUndWinkel; public constructor create(x,y,alpha,size: extended); procedure draw(c: tCanvas); @@ -19,8 +22,10 @@ type implementation +// https://www.chiark.greenend.org.uk/~sgtatham/quasiblog/aperiodic-spectre/ + uses - matheunit; + matheunit, graphType; constructor tSpectre.create(x,y,alpha,size: extended); begin @@ -28,23 +33,43 @@ begin _o:=extPoint(x,y); _alpha:=alpha; _size:=size; + berechneEckenUndWinkel; end; -procedure tSpectre.draw(c: tCanvas); +procedure tSpectre.berechneEckenUndWinkel; var - r: tExtPoint; - a: extended; i: longint; const winkel: array of extended = (90,-60,90,-60,90,60,-90,60,90,60,-90,60,0,60); begin - r:=_o; - a:=_alpha; - c.moveTo(point(round(r))); - for i:=0 to length(winkel)-1 do begin - r:=r + _size * einheitsVektor(a); - c.lineTo(point(round(r))); - a:=a - winkel[i]/180*pi; + setLength(_winkel,length(winkel)); + setLength(_ecken,length(winkel)+1); + _winkel[0]:=_alpha; + _ecken[0]:=_o; + for i:=0 to length(winkel)-2 do begin + _ecken[i+1]:=_ecken[i] + _size * einheitsVektor(_winkel[i]); + _winkel[i+1]:=_winkel[i] - winkel[i]/180*pi; + end; + _ecken[length(_ecken)-1]:=_ecken[0]; +end; + +procedure tSpectre.draw(c: tCanvas); +var + i: longint; + p: tInt64Point; + s: string; + a,b,m: tExtPoint; +begin + s:='lorem ipsum'; + p:=round(0.5*(_ecken[0]+_ecken[6]-extPoint(c.textWidth(s),c.textHeight(s)))); + c.TextOut(p['x'],p['y'],s); + for i:=0 to length(_ecken)-2 do begin + a:=_ecken[i+byte(odd(i))]; + b:=_ecken[i+1-byte(odd(i))]; + m:=a + rotationsMatrix(pi/3)*(b-a); + c.Arc( + round(m['x']-_size),round(m['y']-_size)+1,round(m['x']+_size),round(m['y']+_size)+1, + round(b['x']),round(b['y']),round(a['x']),round(a['y'])); end; end; @@ -59,7 +59,7 @@ end; procedure TForm1.FormCreate(Sender: TObject); begin setLength(spectres,1); - spectres[0]:=tSpectre.create(100,100,pi/4,30); + spectres[0]:=tSpectre.create(100,150,pi/4,30); end; end. |