From 36ad6ffe35cec2d15a40b82923971e0663a035b8 Mon Sep 17 00:00:00 2001 From: Ivan Mahonin Date: Jan 18 2019 18:49:16 +0000 Subject: lazarus: live-ink --- diff --git a/lazarus/live-ink/project1.ico b/lazarus/live-ink/project1.ico new file mode 100644 index 0000000..0341321 Binary files /dev/null and b/lazarus/live-ink/project1.ico differ diff --git a/lazarus/live-ink/project1.lpi b/lazarus/live-ink/project1.lpi new file mode 100644 index 0000000..3afe492 --- /dev/null +++ b/lazarus/live-ink/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/live-ink/project1.lpr b/lazarus/live-ink/project1.lpr new file mode 100644 index 0000000..58c35dc --- /dev/null +++ b/lazarus/live-ink/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/live-ink/project1.res b/lazarus/live-ink/project1.res new file mode 100644 index 0000000..e994dfa Binary files /dev/null and b/lazarus/live-ink/project1.res differ diff --git a/lazarus/live-ink/unit1.lfm b/lazarus/live-ink/unit1.lfm new file mode 100644 index 0000000..6a7a799 --- /dev/null +++ b/lazarus/live-ink/unit1.lfm @@ -0,0 +1,17 @@ +object Form1: TForm1 + Cursor = crNone + Left = 188 + Height = 517 + Top = 214 + Width = 737 + Caption = 'Form1' + OnMouseMove = FormMouseMove + OnPaint = FormPaint + LCLVersion = '1.6.2.0' + object Timer1: TTimer + Interval = 100 + OnTimer = Timer1Timer + left = 16 + top = 16 + end +end diff --git a/lazarus/live-ink/unit1.pas b/lazarus/live-ink/unit1.pas new file mode 100644 index 0000000..a1ac079 --- /dev/null +++ b/lazarus/live-ink/unit1.pas @@ -0,0 +1,71 @@ +unit Unit1; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls; + +type + + { TForm1 } + + TForm1 = class(TForm) + Timer1: TTimer; + procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); + procedure FormPaint(Sender: TObject); + procedure Timer1Timer(Sender: TObject); + private + { private declarations } + public + { public declarations } + end; + +const + maxLen = 50; + +var + Form1: TForm1; + pos: integer = 0; + len: integer = 0; + px: array[0..maxLen] of integer; + py: array[0..maxLen] of integer; + +implementation + +{$R *.lfm} + +procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, + Y: Integer); +begin + pos := pos + 1; + len := len + 1; + if pos >= maxLen then pos := 0; + if len > maxLen then len := maxLen; + + px[pos] := x; + py[pos] := y; +end; + +procedure TForm1.Timer1Timer(Sender: TObject); +begin + Refresh; + len := len - 1; + if len < 0 then len := 0; +end; + +procedure TForm1.FormPaint(Sender: TObject); +var + i, p: Integer; +begin + Canvas.MoveTo(px[pos], py[pos]); + for i := 0 to len-1 do begin + p := (maxLen + pos - i) mod maxLen; + Canvas.Pen.Width := len - i; + Canvas.LineTo(px[p], py[p]); + end; +end; + +end. +