diff --git a/lazarus/fractal/project1.ico b/lazarus/fractal/project1.ico new file mode 100644 index 0000000..0341321 Binary files /dev/null and b/lazarus/fractal/project1.ico differ diff --git a/lazarus/fractal/project1.lpi b/lazarus/fractal/project1.lpi new file mode 100644 index 0000000..3afe492 --- /dev/null +++ b/lazarus/fractal/project1.lpi @@ -0,0 +1,79 @@ + + + + + + + + + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <Icon Value="0"/> + </General> + <i18n> + <EnableI18N LFM="False"/> + </i18n> + <VersionInfo> + <StringTable ProductVersion=""/> + </VersionInfo> + <BuildModes Count="1"> + <Item1 Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + </PublishOptions> + <RunParams> + <local> + <FormatVersion Value="1"/> + </local> + </RunParams> + <RequiredPackages Count="1"> + <Item1> + <PackageName Value="LCL"/> + </Item1> + </RequiredPackages> + <Units Count="2"> + <Unit0> + <Filename Value="project1.lpr"/> + <IsPartOfProject Value="True"/> + </Unit0> + <Unit1> + <Filename Value="unit1.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="Form1"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="Unit1"/> + </Unit1> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <Target> + <Filename Value="project1"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/lazarus/fractal/project1.lpr b/lazarus/fractal/project1.lpr new file mode 100644 index 0000000..58c35dc --- /dev/null +++ b/lazarus/fractal/project1.lpr @@ -0,0 +1,21 @@ +program project1; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, Unit1 + { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource:=True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. + diff --git a/lazarus/fractal/project1.res b/lazarus/fractal/project1.res new file mode 100644 index 0000000..e994dfa Binary files /dev/null and b/lazarus/fractal/project1.res differ diff --git a/lazarus/fractal/unit1.lfm b/lazarus/fractal/unit1.lfm new file mode 100644 index 0000000..d0d86bd --- /dev/null +++ b/lazarus/fractal/unit1.lfm @@ -0,0 +1,9 @@ +object Form1: TForm1 + Left = 179 + Height = 550 + Top = 265 + Width = 752 + Caption = 'Form1' + OnPaint = FormPaint + LCLVersion = '1.6.2.0' +end diff --git a/lazarus/fractal/unit1.pas b/lazarus/fractal/unit1.pas new file mode 100644 index 0000000..7d3daac --- /dev/null +++ b/lazarus/fractal/unit1.pas @@ -0,0 +1,66 @@ +unit Unit1; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs; + +type + + { TForm1 } + + TForm1 = class(TForm) + procedure FormPaint(Sender: TObject); + private + { private declarations } + public + { public declarations } + end; + +var + Form1: TForm1; + +implementation + +{$R *.lfm} + +procedure Line(x1, y1, x2, y2: single); +begin + Form1.Canvas.MoveTo(round(x1), round(y1)); + Form1.Canvas.LineTo(round(x2), round(y2)); +end; + +procedure Figure(x1, y1, x2, y2: single; level: integer); +var + ax, ay, bx, by, cx, cy: single; +begin + if level < 10 then begin + ax := (x2 - x1)/3 + x1; + ay := (y2 - y1)/3 + y1; + + cx := (x1 - x2)/3 + x2; + cy := (y1 - y2)/3 + y2; + + bx := (ax + cx)/2 + (cy - ay)*sin(60/180*pi); + by := (ay + cy)/2 - (cx - ax)*sin(60/180*pi); + + Figure(x1, y1, ax, ay, level+1); + Figure(ax, ay, bx, by, level+1); + Figure(bx, by, cx, cy, level+1); + Figure(cx, cy, x2, y2, level+1); + end else begin + Line(x1, y1, x2, y2); + end; +end; + +{ TForm1 } + +procedure TForm1.FormPaint(Sender: TObject); +begin + Figure(100, 400, 500, 400, 0); +end; + +end. +