diff --git a/lazarus/kaleidoscope/project1.ico b/lazarus/kaleidoscope/project1.ico new file mode 100644 index 0000000..0341321 Binary files /dev/null and b/lazarus/kaleidoscope/project1.ico differ diff --git a/lazarus/kaleidoscope/project1.lpi b/lazarus/kaleidoscope/project1.lpi new file mode 100644 index 0000000..3afe492 --- /dev/null +++ b/lazarus/kaleidoscope/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/kaleidoscope/project1.lpr b/lazarus/kaleidoscope/project1.lpr new file mode 100644 index 0000000..58c35dc --- /dev/null +++ b/lazarus/kaleidoscope/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/kaleidoscope/project1.res b/lazarus/kaleidoscope/project1.res new file mode 100644 index 0000000..e994dfa Binary files /dev/null and b/lazarus/kaleidoscope/project1.res differ diff --git a/lazarus/kaleidoscope/unit1.lfm b/lazarus/kaleidoscope/unit1.lfm new file mode 100644 index 0000000..c663ec4 --- /dev/null +++ b/lazarus/kaleidoscope/unit1.lfm @@ -0,0 +1,9 @@ +object Form1: TForm1 + Left = 101 + Height = 572 + Top = 210 + Width = 750 + Caption = 'Form1' + OnMouseMove = FormMouseMove + LCLVersion = '1.6.2.0' +end diff --git a/lazarus/kaleidoscope/unit1.pas b/lazarus/kaleidoscope/unit1.pas new file mode 100644 index 0000000..47009d3 --- /dev/null +++ b/lazarus/kaleidoscope/unit1.pas @@ -0,0 +1,75 @@ +unit Unit1; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Math; + +type + + { TForm1 } + + TForm1 = class(TForm) + procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); + private + { private declarations } + public + { public declarations } + end; + +const + sectors = 16; + +var + Form1: TForm1; + px: integer = 0; + py: integer = 0; + +implementation + +{$R *.lfm} + +procedure LinePolar(x1, y1, x2, y2: single); +var + sector: integer; + a1, r1, a2, r2, cx ,cy: single; + +begin + cx := Form1.ClientWidth/2; + cy := Form1.ClientHeight/2; + + x1 := x1 - cx; + y1 := y1 - cy; + x2 := x2 - cx; + y2 := y2 - cy; + + a1 := arctan2(y1, x1); + r1 := sqrt(x1*x1 + y1*y1); + a2 := arctan2(y2, x2); + r2 := sqrt(x2*x2 + y2*y2); + + for sector := 0 to sectors-1 do begin + x1 := r1 * cos(a1 + sector*2*pi/sectors) + cx; + y1 := r1 * sin(a1 + sector*2*pi/sectors) + cy; + x2 := r2 * cos(a2 + sector*2*pi/sectors) + cx; + y2 := r2 * sin(a2 + sector*2*pi/sectors) + cy; + + Form1.Canvas.MoveTo(round(x1), round(y1)); + Form1.Canvas.LineTo(round(x2), round(y2)); + end; +end; + +procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, + Y: Integer); +begin + canvas.pen.width := 3; + if ssRight in Shift then Form1.Refresh; + if ssLeft in Shift then LinePolar(px, py, x, y); + px := x; + py := y; +end; + +end. +