From c0c0da966fd157e1611a2671a80859be3d551203 Mon Sep 17 00:00:00 2001 From: Ivan Mahonin Date: Jan 18 2019 17:00:24 +0000 Subject: lazarus: pixel-art --- diff --git a/lazarus/pixel-art/flag/project1.ico b/lazarus/pixel-art/flag/project1.ico new file mode 100644 index 0000000..0341321 Binary files /dev/null and b/lazarus/pixel-art/flag/project1.ico differ diff --git a/lazarus/pixel-art/flag/project1.lpi b/lazarus/pixel-art/flag/project1.lpi new file mode 100644 index 0000000..c490021 --- /dev/null +++ b/lazarus/pixel-art/flag/project1.lpi @@ -0,0 +1,80 @@ + + + + + + + + + <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"/> + <HasResources Value="True"/> + <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/pixel-art/flag/project1.lpr b/lazarus/pixel-art/flag/project1.lpr new file mode 100644 index 0000000..58c35dc --- /dev/null +++ b/lazarus/pixel-art/flag/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/pixel-art/flag/project1.res b/lazarus/pixel-art/flag/project1.res new file mode 100644 index 0000000..e994dfa Binary files /dev/null and b/lazarus/pixel-art/flag/project1.res differ diff --git a/lazarus/pixel-art/flag/unit1.lfm b/lazarus/pixel-art/flag/unit1.lfm new file mode 100644 index 0000000..455d2ea --- /dev/null +++ b/lazarus/pixel-art/flag/unit1.lfm @@ -0,0 +1,16 @@ +object Form1: TForm1 + Left = 192 + Height = 530 + Top = 183 + Width = 860 + Caption = 'Form1' + Color = clBlack + OnPaint = FormPaint + LCLVersion = '1.6.2.0' + object Timer1: TTimer + Interval = 20 + OnTimer = Timer1Timer + left = 24 + top = 14 + end +end diff --git a/lazarus/pixel-art/flag/unit1.pas b/lazarus/pixel-art/flag/unit1.pas new file mode 100644 index 0000000..7aecfce --- /dev/null +++ b/lazarus/pixel-art/flag/unit1.pas @@ -0,0 +1,66 @@ +unit Unit1; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls; + +type + + { TForm1 } + + TForm1 = class(TForm) + Timer1: TTimer; + procedure FormPaint(Sender: TObject); + procedure Timer1Timer(Sender: TObject); + private + { private declarations } + public + { public declarations } + end; + +var + Form1: TForm1; + offset: integer = 0; + +implementation + +{$R *.lfm} + +{ TForm1 } + +procedure TForm1.FormPaint(Sender: TObject); +var + x, y, realX, realY: integer; + c: TColor; +begin + c := clBlack; + + for x := 0 to 250-1 do begin + for y := 0 to 100-1 do begin + if (x mod 50 < 25) = (y mod 30 < 15) then c := clWhite else c := clNavy; + + //realX := 30 + x + y; + //realY := 30 + 200 - y; + + //realX := 30 + 2*x + 2*y; + //realY := 30 + 200 - 2*y; + + realX := 30 + 2*x + 2*y; + realY := 30 + 200 - 2*y - round(10 * cos((x - offset)/10) * cos(y/10)); + + Canvas.Pixels[realX, realY] := c; + end; + end; +end; + +procedure TForm1.Timer1Timer(Sender: TObject); +begin + offset := offset + 1; + Refresh; +end; + +end. + diff --git a/lazarus/pixel-art/stars/project1.ico b/lazarus/pixel-art/stars/project1.ico new file mode 100644 index 0000000..0341321 Binary files /dev/null and b/lazarus/pixel-art/stars/project1.ico differ diff --git a/lazarus/pixel-art/stars/project1.lpi b/lazarus/pixel-art/stars/project1.lpi new file mode 100644 index 0000000..3afe492 --- /dev/null +++ b/lazarus/pixel-art/stars/project1.lpi @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CONFIG> + <ProjectOptions> + <Version Value="9"/> + <General> + <SessionStorage Value="InProjectDir"/> + <MainUnit Value="0"/> + <Title Value="project1"/> + <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/pixel-art/stars/project1.lpr b/lazarus/pixel-art/stars/project1.lpr new file mode 100644 index 0000000..58c35dc --- /dev/null +++ b/lazarus/pixel-art/stars/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/pixel-art/stars/project1.res b/lazarus/pixel-art/stars/project1.res new file mode 100644 index 0000000..e994dfa Binary files /dev/null and b/lazarus/pixel-art/stars/project1.res differ diff --git a/lazarus/pixel-art/stars/unit1.lfm b/lazarus/pixel-art/stars/unit1.lfm new file mode 100644 index 0000000..3739a20 --- /dev/null +++ b/lazarus/pixel-art/stars/unit1.lfm @@ -0,0 +1,17 @@ +object Form1: TForm1 + Left = 125 + Height = 587 + Top = 175 + Width = 903 + Caption = 'Form1' + Color = clBlack + OnCreate = FormCreate + OnPaint = FormPaint + LCLVersion = '1.6.2.0' + object Timer1: TTimer + Interval = 10 + OnTimer = Timer1Timer + left = 24 + top = 20 + end +end diff --git a/lazarus/pixel-art/stars/unit1.pas b/lazarus/pixel-art/stars/unit1.pas new file mode 100644 index 0000000..9c1763e --- /dev/null +++ b/lazarus/pixel-art/stars/unit1.pas @@ -0,0 +1,76 @@ +unit Unit1; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, + Math; + +type + + { TForm1 } + + TForm1 = class(TForm) + Timer1: TTimer; + procedure FormCreate(Sender: TObject); + procedure FormPaint(Sender: TObject); + procedure Timer1Timer(Sender: TObject); + private + { private declarations } + public + { public declarations } + end; + +const + starsCount = 200; + +var + Form1: TForm1; + sx: array [0..starsCount] of integer; + sy: array [0..starsCount] of integer; + sz: array [0..starsCount] of integer; + +implementation + +{$R *.lfm} + +procedure TForm1.FormCreate(Sender: TObject); +var + i : integer; +begin + for i := 0 to starsCount-1 do begin + sx[i] := Random(ClientWidth); + sy[i] := Random(ClientHeight); + sz[i] := RandomRange(1, 10); + end; +end; + +procedure TForm1.Timer1Timer(Sender: TObject); +var + i: integer; +begin + for i := 0 to starsCount-1 do begin + sx[i] := sx[i] - sz[i]; + if sx[i] < 0 then begin + sx[i] := ClientWidth; + sy[i] := Random(ClientHeight); + sz[i] := RandomRange(1, 10); + end; + end; + + Refresh; +end; + +procedure TForm1.FormPaint(Sender: TObject); +var + i: integer; +begin + for i := 0 to starsCount-1 do begin + Canvas.Pixels[ sx[i], sy[i] ] := clWhite; + end; +end; + +end. +