Adds LazEyes to the lazarus-ccr

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1753 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat 2011-07-21 15:10:27 +00:00
parent f72e2330a9
commit b2dce13c21
13 changed files with 11678 additions and 0 deletions

View File

@ -0,0 +1,52 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
[Setup]
AppName=LazEyes
AppVerName=LazEyes v2.0
AppPublisherURL=http://wiki.lazarus.freepascal.org/LazEyes
AppSupportURL=http://wiki.lazarus.freepascal.org/LazEyes
AppUpdatesURL=http://wiki.lazarus.freepascal.org/LazEyes
DefaultDirName={pf}\LazEyes
DefaultGroupName=Free Pascal Applications Suite
; LicenseFile=..\license.txt
OutputDir=.\
OutputBaseFilename=LazEyes2.0_install
Compression=lzma
SolidCompression=yes
VersionInfoVersion=2.0
AllowNoIcons=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
Name: "german"; MessagesFile: "compiler:Languages\German.isl"
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "..\lazeyes2.exe"; DestDir: "{app}"; Flags: ignoreversion
; Source: "..\Images\*.png"; DestDir: "{app}\Images"; Flags: ignoreversion
; Source: "..\libraries\pas_overlays\pas_overlays.dll"; DestDir: "{app}"; Flags: ignoreversion
; Source: "..\libraries\videocard_checker\videocard_checker.dll"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\LazEyes"; Filename: "{app}\lazeyes2.exe"
Name: "{group}\{cm:ProgramOnTheWeb,FPChess}"; Filename: "http://wiki.lazarus.freepascal.org/LazEyes"
Name: "{group}\{cm:UninstallProgram,FPChess}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\FPChess"; Filename: "{app}\lazeyes2.exe"; Tasks: desktopicon
[Run]
Filename: "{app}\lazeyes2.exe"; Description: "{cm:LaunchProgram,FPChess}"; Flags: nowait postinstall skipifsilent

View File

@ -0,0 +1,294 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<MainUnit Value="0"/>
<Title Value="lazeyes2"/>
<UseXPManifest Value="True"/>
<ActiveWindowIndexAtStart Value="0"/>
</General>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="2" Active="release">
<Item1 Name="debug" Default="True"/>
<Item2 Name="release">
<CompilerOptions>
<Version Value="10"/>
<PathDelim Value="\"/>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<CStyleOperator Value="False"/>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<UseLineInfoUnit Value="False"/>
<StripSymbols Value="True"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
<UseMsgFile Value="True"/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</Item2>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="13">
<Unit0>
<Filename Value="lazeyes2.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="lazeyes2"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="0"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="3" Y="20"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit0>
<Unit1>
<Filename Value="..\..\..\lazarus\lcl\interfaces\win32\win32winapih.inc"/>
<TopLine Value="42"/>
<CursorPos X="13" Y="56"/>
<UsageCount Value="10"/>
</Unit1>
<Unit2>
<Filename Value="..\..\..\lazarus\lcl\include\winapih.inc"/>
<TopLine Value="49"/>
<CursorPos X="1" Y="64"/>
<UsageCount Value="10"/>
</Unit2>
<Unit3>
<Filename Value="..\..\..\lazarus\lcl\interfaces\win32\win32winapi.inc"/>
<TopLine Value="1796"/>
<CursorPos X="23" Y="1803"/>
<UsageCount Value="10"/>
</Unit3>
<Unit4>
<Filename Value="..\..\..\lazarus\lcl\graphics.pp"/>
<UnitName Value="Graphics"/>
<WindowIndex Value="0"/>
<TopLine Value="1452"/>
<CursorPos X="21" Y="1462"/>
<UsageCount Value="11"/>
<LoadedDesigner Value="True"/>
</Unit4>
<Unit5>
<Filename Value="..\..\..\lazarus\lcl\include\icnsicon.inc"/>
<WindowIndex Value="0"/>
<TopLine Value="224"/>
<CursorPos X="3" Y="243"/>
<UsageCount Value="11"/>
<LoadedDesigner Value="True"/>
</Unit5>
<Unit6>
<Filename Value="..\..\..\lazarus\lcl\include\cursorimage.inc"/>
<WindowIndex Value="0"/>
<TopLine Value="41"/>
<CursorPos X="3" Y="43"/>
<UsageCount Value="11"/>
<LoadedDesigner Value="True"/>
</Unit6>
<Unit7>
<Filename Value="lazeyes2painter.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="lazeyes2painter"/>
<EditorIndex Value="1"/>
<WindowIndex Value="0"/>
<TopLine Value="28"/>
<CursorPos X="25" Y="45"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit7>
<Unit8>
<Filename Value="lazeyes2.lrs"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="1" Y="1"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit8>
<Unit9>
<Filename Value="lazeyes2form.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="lazeyes2form"/>
<EditorIndex Value="2"/>
<WindowIndex Value="0"/>
<TopLine Value="205"/>
<CursorPos X="1" Y="226"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit9>
<Unit10>
<Filename Value="..\..\..\lazarus\lcl\forms.pp"/>
<UnitName Value="Forms"/>
<TopLine Value="33"/>
<CursorPos X="26" Y="40"/>
<UsageCount Value="10"/>
</Unit10>
<Unit11>
<Filename Value="..\..\..\lazarus\lcl\controls.pp"/>
<UnitName Value="Controls"/>
<WindowIndex Value="0"/>
<TopLine Value="1215"/>
<CursorPos X="1" Y="1229"/>
<UsageCount Value="10"/>
<LoadedDesigner Value="True"/>
</Unit11>
<Unit12>
<Filename Value="F:\Jogos\Europa Universalis 2\AGCEEP\Scenarios\1419\1419_AYU_Ayutthaya.inc"/>
<WindowIndex Value="0"/>
<TopLine Value="48"/>
<CursorPos X="13" Y="13"/>
<UsageCount Value="10"/>
<LoadedDesigner Value="True"/>
</Unit12>
</Units>
<JumpHistory Count="18" HistoryIndex="17">
<Position1>
<Filename Value="lazeyes2painter.pas"/>
<Caret Line="11" Column="1" TopLine="1"/>
</Position1>
<Position2>
<Filename Value="lazeyes2painter.pas"/>
<Caret Line="10" Column="29" TopLine="1"/>
</Position2>
<Position3>
<Filename Value="lazeyes2painter.pas"/>
<Caret Line="89" Column="25" TopLine="79"/>
</Position3>
<Position4>
<Filename Value="lazeyes2painter.pas"/>
<Caret Line="40" Column="3" TopLine="38"/>
</Position4>
<Position5>
<Filename Value="lazeyes2painter.pas"/>
<Caret Line="31" Column="15" TopLine="18"/>
</Position5>
<Position6>
<Filename Value="lazeyes2painter.pas"/>
<Caret Line="72" Column="1" TopLine="53"/>
</Position6>
<Position7>
<Filename Value="lazeyes2painter.pas"/>
<Caret Line="157" Column="17" TopLine="144"/>
</Position7>
<Position8>
<Filename Value="lazeyes2.lrs"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position8>
<Position9>
<Filename Value="lazeyes2.lpr"/>
<Caret Line="16" Column="27" TopLine="2"/>
</Position9>
<Position10>
<Filename Value="lazeyes2painter.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position10>
<Position11>
<Filename Value="lazeyes2painter.pas"/>
<Caret Line="67" Column="10" TopLine="54"/>
</Position11>
<Position12>
<Filename Value="lazeyes2form.pas"/>
<Caret Line="83" Column="20" TopLine="77"/>
</Position12>
<Position13>
<Filename Value="lazeyes2form.pas"/>
<Caret Line="70" Column="11" TopLine="48"/>
</Position13>
<Position14>
<Filename Value="lazeyes2form.pas"/>
<Caret Line="59" Column="23" TopLine="56"/>
</Position14>
<Position15>
<Filename Value="lazeyes2painter.pas"/>
<Caret Line="40" Column="33" TopLine="28"/>
</Position15>
<Position16>
<Filename Value="lazeyes2painter.pas"/>
<Caret Line="45" Column="25" TopLine="28"/>
</Position16>
<Position17>
<Filename Value="lazeyes2form.pas"/>
<Caret Line="203" Column="1" TopLine="191"/>
</Position17>
<Position18>
<Filename Value="lazeyes2.lpr"/>
<Caret Line="14" Column="18" TopLine="4"/>
</Position18>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="10"/>
<PathDelim Value="\"/>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<CStyleOperator Value="False"/>
<UseAnsiStrings Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
<UseMsgFile Value="True"/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,29 @@
{
LazEyes2
Fun application which follows the mouse wherever it goes.
The window has the form of the eyes, which are ellipses.
Version 2: Operates with a custom control
}
program lazeyes2;
{$mode objfpc}{$H+}
uses
Interfaces,
Forms,
lazeyes2painter,
lazeyes2form;
//{$IFDEF WINDOWS}{$R lazeyes2.rc}{$ENDIF}
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
#define RT_MANIFEST 24
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
#define ISOLATIONAWARE_MANIFEST_RESOURCE_ID 2
#define ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID 3
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "lazeyes2.manifest"

View File

@ -0,0 +1,230 @@
unit lazeyes2form;
{$mode objfpc}{$H+}
interface
uses
Classes, Math, SysUtils,
Graphics, Forms, LResources, StdCtrls, ExtCtrls,
Controls, LCLType, LCLIntf,
lazeyes2painter;
type
{ TMainForm }
TMainForm = class(TForm)
public
MyTimer: TTimer;
WindowDragMousePos, WindowDragTopLeft: TPoint;
WindowDragStarted: Boolean;
Painter: TLazEye2Painter;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function CalculateEyePosition(
EyeXc, EyeYc: Integer): TPoint;
procedure HandleOnTimer(ASender: TObject);
procedure HandleOnMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
procedure HandleOnMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
procedure HandleOnMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
end;
var
MainForm: TMainForm;
implementation
{ TMainForm }
constructor TMainForm.Create(AOwner: TComponent);
var
Rgn1, Rgn2, TotalRgn: HRGN;
begin
inherited Create(AOwner);
// basic initial data
MousePos := Mouse.CursorPos;
// create child objects
MyTimer := TTimer.Create(Self);
MyTimer.Interval := 1000 div 60;
MyTimer.OnTimer := @HandleOnTimer;
MyTimer.Enabled := True;
Painter := TLazEye2Painter.Create(Self);
Painter.Parent := Self;
Painter.Align := alClient;
Painter.DoubleBuffered := True;
// set events
OnMouseMove := @HandleOnMouseMove;
OnMouseDown := @HandleOnMouseDown;
OnMouseUp := @HandleOnMouseUp;
Painter.OnMouseMove := @HandleOnMouseMove;
Painter.OnMouseDown := @HandleOnMouseDown;
Painter.OnMouseUp := @HandleOnMouseUp;
// set window properties
BorderStyle := bsNone;
Position := poScreenCenter;
// set window transparency
Rgn1 := CreateEllipticRgn(
0, 0,
INT_OUTER_EYE_WIDTH, INT_OUTER_EYE_HEIGHT);
Rgn2 := CreateEllipticRgn(
INT_OUTER_EYE_WIDTH + INT_INTEREYE_SPACE, 0,
2*INT_OUTER_EYE_WIDTH + INT_INTEREYE_SPACE,
INT_OUTER_EYE_HEIGHT);
// The dest region needs to exist before calling
// CombineRgn, so we create it with dummy values
TotalRgn := CreateEllipticRgn(0, 0, 10, 10);
LCLIntf.CombineRgn(TotalRgn, Rgn1, Rgn2, RGN_OR);
LCLIntf.SetWindowRgn(Handle, TotalRgn, True);
end;
destructor TMainForm.Destroy;
begin
// free child object
MyTimer.Free;
inherited Destroy;
end;
{ Calculates where the eye should be painted
EyeXc, EyeYc is the center of the eye ellipse
The size of the ellipse is given by the constants
INT_EYE_WIDTH and INT_EYE_HEIGHT }
function TMainForm.CalculateEyePosition(
EyeXc, EyeYc: Integer): TPoint;
var
RelMousePos: TPoint;
MousePosAngle: Double;
DeltaX, DeltaY: Double;
AbsEyeXc, AbsEyeYc: Integer;
begin
// Get the mouse position relative to the window
RelMousePos.X := MousePos.X - Left;
RelMousePos.Y := MousePos.Y - Top;
// Get the eye center absolute position in the screen
AbsEyeXc := EyeXc + Left;
AbsEyeYc := EyeYc + Top;
// First check if the cursor is inside the eye, in a
// position that it will fall right over the eye pupil
// eye pupil elipse area equation:
// (X - Xc)^2 / A^2 + (Y - Yc)^2 / B^2 <= 1
// (Xc, Yc) is the center of the elipse
// A and B are the half axis of the elipse
if (Sqr(RelMousePos.X - EyeXc) / INT_EYE_HALFWIDTH_SQR)
+ (Sqr(RelMousePos.Y - EyeYc) / INT_EYE_HALFHEIGHT_SQR)
<= 1 then
begin
Result.X := RelMousePos.X;
Result.Y := RelMousePos.Y;
Exit;
end;
// Calculate the position of the eye, by calculating how
// many grads the cursor is forming with the center of
// the eye. The polar equation of the elipse is:
// X = Xc + A * cos(t)
// Y = Yc + B * sen(t)
if MousePos.X - AbsEyeXc = 0 then
MousePosAngle := Pi / 2
else
MousePosAngle := arctan(Abs(MousePos.Y - AbsEyeYc)
/ Abs(MousePos.X - AbsEyeXc));
DeltaX := INT_EYE_HALFWIDTH * Cos(MousePosAngle);
DeltaY := INT_EYE_HALFHEIGHT * Sin(MousePosAngle);
// 1st quadrant
if (MousePos.X >= AbsEyeXc) and
(MousePos.Y <= AbsEyeYc) then
begin
Result.X := Round(EyeXc + DeltaX);
Result.Y := Round(EyeYc - DeltaY);
end
// 2nd quadrant
else if (MousePos.X >= AbsEyeXc) and
(MousePos.Y >= AbsEyeYc) then
begin
Result.X := Round(EyeXc + DeltaX);
Result.Y := Round(EyeYc + DeltaY);
end
// 3rd quadrant
else if (MousePos.X <= AbsEyeXc) and
(MousePos.Y >= AbsEyeYc) then
begin
Result.X := Round(EyeXc - DeltaX);
Result.Y := Round(EyeYc + DeltaY);
end
// 4th quadrant
else
begin
Result.X := Round(EyeXc - DeltaX);
Result.Y := Round(EyeYc - DeltaY);
end;
end;
{ Timer event - Updates the eyes if the mouse moved }
procedure TMainForm.HandleOnTimer(ASender: TObject);
begin
// Check if mouse position changed
if (MousePos.X = Mouse.CursorPos.X) and
(MousePos.Y = Mouse.CursorPos.Y) then Exit;
MousePos := Mouse.CursorPos;
// Calculate the position of the eyes
LeftEyePos := CalculateEyePosition(
INT_EYE_HALFWIDTH + INT_BORDER_WIDTH,
INT_EYE_HALFHEIGHT + INT_BORDER_WIDTH);
RightEyePos := CalculateEyePosition(
INT_OUTER_EYE_WIDTH + INT_INTEREYE_SPACE +
INT_EYE_HALFWIDTH + INT_BORDER_WIDTH,
INT_EYE_HALFHEIGHT + INT_BORDER_WIDTH);
// Redraw the eye
Invalidate;
end;
{ MouseDown - Code to drag the main window using the mouse}
procedure TMainForm.HandleOnMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
WindowDragStarted := True;
WindowDragMousePos := Mouse.CursorPos;
WindowDragTopLeft.X := Left;
WindowDragTopLeft.Y := Top;
end;
{ MouseMove - Code to drag the main window using the mouse}
procedure TMainForm.HandleOnMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
if WindowDragStarted then
begin
Left := WindowDragTopLeft.X +
(Mouse.CursorPos.X - WindowDragMousePos.X);
Top := WindowDragTopLeft.Y +
(Mouse.CursorPos.Y - WindowDragMousePos.Y);
end;
end;
{ MouseUp - Code to drag the main window using the mouse }
procedure TMainForm.HandleOnMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
WindowDragStarted := False;
end;
end.

View File

@ -0,0 +1,118 @@
unit lazeyes2painter;
{$mode objfpc}{$H+}
interface
uses
Classes, Math, SysUtils,
Graphics, Forms, LResources, StdCtrls, ExtCtrls,
Controls, LCLType, LCLIntf;
const
// Sizes for the basic eye ellipse
INT_EYE_WIDTH = 60;
INT_EYE_HALFWIDTH = (INT_EYE_WIDTH div 2);
INT_EYE_HALFWIDTH_SQR = INT_EYE_HALFWIDTH *
INT_EYE_HALFWIDTH;
INT_EYE_HEIGHT = 60;
INT_EYE_HALFHEIGHT = (INT_EYE_HEIGHT div 2);
INT_EYE_HALFHEIGHT_SQR = INT_EYE_HALFHEIGHT *
INT_EYE_HALFHEIGHT;
// This extra border width is the size of the pen,
// and is also used to make the outer ellipse larger
// then the puppil ellipse, to create a better
// visual effect
INT_BORDER_WIDTH = 15;
INT_OUTER_EYE_WIDTH = INT_EYE_WIDTH + 2*INT_BORDER_WIDTH;
INT_OUTER_EYE_HEIGHT = INT_EYE_HEIGHT+2*INT_BORDER_WIDTH;
INT_INTEREYE_SPACE = 20;
INT_WINDOW_WIDTH = 2*INT_OUTER_EYE_WIDTH
+ INT_OUTER_EYE_HEIGHT;
type
{ TLazEye2Painter }
TLazEye2Painter = class(TCustomControl)
public
procedure EraseBackground(DC: HDC); override;
procedure Paint; override;
procedure DrawToCanvas(ACanvas: TCanvas);
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
end;
var
MousePos, LeftEyePos, RightEyePos: TPoint;
implementation
procedure TLazEye2Painter.EraseBackground(DC: HDC);
begin
// Uncomment this to enable default background erasing
//inherited EraseBackground(DC);
end;
procedure TLazEye2Painter.Paint;
var
Bitmap: TBitmap;
begin
Bitmap := TBitmap.Create;
try
// Initializes the Bitmap Size
Bitmap.Height := Height;
Bitmap.Width := Width;
DrawToCanvas(Bitmap.Canvas);
Canvas.Draw(0, 0, Bitmap);
finally
Bitmap.Free;
end;
inherited Paint;
end;
procedure TLazEye2Painter.DrawToCanvas(ACanvas: TCanvas);
begin
// Background
ACanvas.Brush.Color := clWhite;
ACanvas.Pen.Color := clWhite;
ACanvas.FillRect(0, 0, Width, Height);
// Eyes form
ACanvas.Pen.Color := clBlack;
ACanvas.Pen.Width := 5;
ACanvas.Ellipse(
0,
0,
INT_OUTER_EYE_WIDTH,
INT_OUTER_EYE_HEIGHT);
ACanvas.Ellipse(
INT_OUTER_EYE_WIDTH + INT_INTEREYE_SPACE,
0,
2* INT_OUTER_EYE_WIDTH + INT_INTEREYE_SPACE,
INT_OUTER_EYE_HEIGHT);
// Eyes pupils
ACanvas.Brush.Color := clBlack;
ACanvas.Pen.Width := 10;
ACanvas.Ellipse(
LeftEyePos.X - 2,
LeftEyePos.Y - 2,
LeftEyePos.X + 2,
LeftEyePos.Y + 2);
ACanvas.Ellipse(
RightEyePos.X - 2,
RightEyePos.Y - 2,
RightEyePos.X + 2,
RightEyePos.Y + 2);
end;
end.

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -0,0 +1,184 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<Version Value="7"/>
<General>
<Flags>
<AlwaysBuild Value="False"/>
</Flags>
<MainUnit Value="0"/>
<TargetFileExt Value=".exe"/>
<Icon Value="0"/>
<UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="0"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="7">
<Unit0>
<Filename Value="lazeyes.lpr"/>
<IsPartOfProject Value="True"/>
<CursorPos X="1" Y="2"/>
<TopLine Value="1"/>
<EditorIndex Value="0"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="..\..\..\lazarus\lcl\interfaces\win32\win32winapih.inc"/>
<CursorPos X="13" Y="56"/>
<TopLine Value="42"/>
<UsageCount Value="10"/>
</Unit1>
<Unit2>
<Filename Value="..\..\..\lazarus\lcl\include\winapih.inc"/>
<CursorPos X="1" Y="64"/>
<TopLine Value="49"/>
<UsageCount Value="10"/>
</Unit2>
<Unit3>
<Filename Value="..\..\..\lazarus\lcl\interfaces\win32\win32winapi.inc"/>
<CursorPos X="23" Y="1803"/>
<TopLine Value="1796"/>
<UsageCount Value="10"/>
</Unit3>
<Unit4>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\graphics.pp"/>
<UnitName Value="Graphics"/>
<CursorPos X="21" Y="1462"/>
<TopLine Value="1452"/>
<EditorIndex Value="1"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\include\icnsicon.inc"/>
<CursorPos X="3" Y="243"/>
<TopLine Value="224"/>
<EditorIndex Value="3"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit5>
<Unit6>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\include\cursorimage.inc"/>
<CursorPos X="3" Y="43"/>
<TopLine Value="41"/>
<EditorIndex Value="2"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit6>
</Units>
<JumpHistory Count="14" HistoryIndex="13">
<Position1>
<Filename Value="lazeyes.lpr"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position1>
<Position2>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\graphics.pp"/>
<Caret Line="262" Column="1" TopLine="261"/>
</Position2>
<Position3>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\graphics.pp"/>
<Caret Line="421" Column="24" TopLine="404"/>
</Position3>
<Position4>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\graphics.pp"/>
<Caret Line="1620" Column="24" TopLine="1607"/>
</Position4>
<Position5>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\graphics.pp"/>
<Caret Line="1634" Column="38" TopLine="1621"/>
</Position5>
<Position6>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\graphics.pp"/>
<Caret Line="1293" Column="1" TopLine="1281"/>
</Position6>
<Position7>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\graphics.pp"/>
<Caret Line="1671" Column="12" TopLine="1658"/>
</Position7>
<Position8>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\graphics.pp"/>
<Caret Line="1673" Column="10" TopLine="1658"/>
</Position8>
<Position9>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\graphics.pp"/>
<Caret Line="1680" Column="12" TopLine="1658"/>
</Position9>
<Position10>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\graphics.pp"/>
<Caret Line="1681" Column="10" TopLine="1658"/>
</Position10>
<Position11>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\graphics.pp"/>
<Caret Line="1684" Column="23" TopLine="1671"/>
</Position11>
<Position12>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\graphics.pp"/>
<Caret Line="1685" Column="24" TopLine="1671"/>
</Position12>
<Position13>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\graphics.pp"/>
<Caret Line="1696" Column="66" TopLine="1683"/>
</Position13>
<Position14>
<Filename Value="..\..\..\..\..\Programas\lazarus\lcl\graphics.pp"/>
<Caret Line="1900" Column="22" TopLine="1887"/>
</Position14>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="8"/>
<PathDelim Value="\"/>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)\"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<CStyleOperator Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,297 @@
{
LazEyes
Fun application which follows the mouse wherever it goes.
The window has the form of the eyes, which are ellipses.
}
program lazeyes;
{$mode objfpc}{$H+}
uses
Interfaces,
Classes, Math, SysUtils,
Graphics, Forms, LResources, StdCtrls, ExtCtrls,
Controls, LCLType, LCLIntf;
const
// Sizes for the basic eye ellipse
INT_EYE_WIDTH = 60;
INT_EYE_HALFWIDTH = (INT_EYE_WIDTH div 2);
INT_EYE_HALFWIDTH_SQR = INT_EYE_HALFWIDTH *
INT_EYE_HALFWIDTH;
INT_EYE_HEIGHT = 60;
INT_EYE_HALFHEIGHT = (INT_EYE_HEIGHT div 2);
INT_EYE_HALFHEIGHT_SQR = INT_EYE_HALFHEIGHT *
INT_EYE_HALFHEIGHT;
// This extra border width is the size of the pen,
// and is also used to make the outer ellipse larger
// then the puppil ellipse, to create a better
// visual effect
INT_BORDER_WIDTH = 15;
INT_OUTER_EYE_WIDTH = INT_EYE_WIDTH + 2*INT_BORDER_WIDTH;
INT_OUTER_EYE_HEIGHT = INT_EYE_HEIGHT+2*INT_BORDER_WIDTH;
INT_INTEREYE_SPACE = 20;
INT_WINDOW_WIDTH = 2*INT_OUTER_EYE_WIDTH
+ INT_OUTER_EYE_HEIGHT;
type
{ TMainForm }
TMainForm = class(TForm)
public
MyTimer: TTimer;
MousePos, LeftEyePos, RightEyePos: TPoint;
WindowDragMousePos, WindowDragTopLeft: TPoint;
WindowDragStarted: Boolean;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function CalculateEyePosition(
EyeXc, EyeYc: Integer): TPoint;
procedure HandleOnTimer(ASender: TObject);
procedure HandleOnPaint(ASender: TObject);
procedure HandleOnMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
procedure HandleOnMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
procedure HandleOnMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
end;
{ TMainForm }
constructor TMainForm.Create(AOwner: TComponent);
var
Rgn1, Rgn2, TotalRgn: HRGN;
begin
inherited Create(AOwner);
// basic initial data
MousePos := Mouse.CursorPos;
// create child objects
MyTimer := TTimer.Create(Self);
MyTimer.Interval := 1000 div 60;
MyTimer.OnTimer := @HandleOnTimer;
MyTimer.Enabled := True;
// set events
OnPaint := @HandleOnPaint;
OnMouseMove := @HandleOnMouseMove;
OnMouseDown := @HandleOnMouseDown;
OnMouseUp := @HandleOnMouseUp;
// set window properties
BorderStyle := bsNone;
Position := poScreenCenter;
DoubleBuffered := True;
// set window transparency
Rgn1 := CreateEllipticRgn(
0, 0,
INT_OUTER_EYE_WIDTH, INT_OUTER_EYE_HEIGHT);
Rgn2 := CreateEllipticRgn(
INT_OUTER_EYE_WIDTH + INT_INTEREYE_SPACE, 0,
2*INT_OUTER_EYE_WIDTH + INT_INTEREYE_SPACE,
INT_OUTER_EYE_HEIGHT);
// The dest region needs to exist before calling
// CombineRgn, so we create it with dummy values
TotalRgn := CreateEllipticRgn(0, 0, 10, 10);
LCLIntf.CombineRgn(TotalRgn, Rgn1, Rgn2, RGN_OR);
LCLIntf.SetWindowRgn(Handle, TotalRgn, True);
end;
destructor TMainForm.Destroy;
begin
// free child object
MyTimer.Free;
inherited Destroy;
end;
{ Calculates where the eye should be painted
EyeXc, EyeYc is the center of the eye ellipse
The size of the ellipse is given by the constants
INT_EYE_WIDTH and INT_EYE_HEIGHT }
function TMainForm.CalculateEyePosition(
EyeXc, EyeYc: Integer): TPoint;
var
RelMousePos: TPoint;
MousePosAngle: Double;
DeltaX, DeltaY: Double;
AbsEyeXc, AbsEyeYc: Integer;
begin
// Get the mouse position relative to the window
RelMousePos.X := MousePos.X - Left;
RelMousePos.Y := MousePos.Y - Top;
// Get the eye center absolute position in the screen
AbsEyeXc := EyeXc + Left;
AbsEyeYc := EyeYc + Top;
// First check if the cursor is inside the eye, in a
// position that it will fall right over the eye pupil
// eye pupil elipse area equation:
// (X - Xc)^2 / A^2 + (Y - Yc)^2 / B^2 <= 1
// (Xc, Yc) is the center of the elipse
// A and B are the half axis of the elipse
if (Sqr(RelMousePos.X - EyeXc) / INT_EYE_HALFWIDTH_SQR)
+ (Sqr(RelMousePos.Y - EyeYc) / INT_EYE_HALFHEIGHT_SQR)
<= 1 then
begin
Result.X := RelMousePos.X;
Result.Y := RelMousePos.Y;
Exit;
end;
// Calculate the position of the eye, by calculating how
// many grads the cursor is forming with the center of
// the eye. The polar equation of the elipse is:
// X = Xc + A * cos(t)
// Y = Yc + B * sen(t)
if MousePos.X - AbsEyeXc = 0 then
MousePosAngle := Pi / 2
else
MousePosAngle := arctan(Abs(MousePos.Y - AbsEyeYc)
/ Abs(MousePos.X - AbsEyeXc));
DeltaX := INT_EYE_HALFWIDTH * Cos(MousePosAngle);
DeltaY := INT_EYE_HALFHEIGHT * Sin(MousePosAngle);
// 1st quadrant
if (MousePos.X >= AbsEyeXc) and
(MousePos.Y <= AbsEyeYc) then
begin
Result.X := Round(EyeXc + DeltaX);
Result.Y := Round(EyeYc - DeltaY);
end
// 2nd quadrant
else if (MousePos.X >= AbsEyeXc) and
(MousePos.Y >= AbsEyeYc) then
begin
Result.X := Round(EyeXc + DeltaX);
Result.Y := Round(EyeYc + DeltaY);
end
// 3rd quadrant
else if (MousePos.X <= AbsEyeXc) and
(MousePos.Y >= AbsEyeYc) then
begin
Result.X := Round(EyeXc - DeltaX);
Result.Y := Round(EyeYc + DeltaY);
end
// 4th quadrant
else
begin
Result.X := Round(EyeXc - DeltaX);
Result.Y := Round(EyeYc - DeltaY);
end;
end;
{ Timer event - Updates the eyes if the mouse moved }
procedure TMainForm.HandleOnTimer(ASender: TObject);
begin
// Check if mouse position changed
if (MousePos.X = Mouse.CursorPos.X) and
(MousePos.Y = Mouse.CursorPos.Y) then Exit;
MousePos := Mouse.CursorPos;
// Calculate the position of the eyes
LeftEyePos := CalculateEyePosition(
INT_EYE_HALFWIDTH + INT_BORDER_WIDTH,
INT_EYE_HALFHEIGHT + INT_BORDER_WIDTH);
RightEyePos := CalculateEyePosition(
INT_OUTER_EYE_WIDTH + INT_INTEREYE_SPACE +
INT_EYE_HALFWIDTH + INT_BORDER_WIDTH,
INT_EYE_HALFHEIGHT + INT_BORDER_WIDTH);
// Redraw the eye
Invalidate;
end;
{ MouseDown - Code to drag the main window using the mouse}
procedure TMainForm.HandleOnMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
WindowDragStarted := True;
WindowDragMousePos := Mouse.CursorPos;
WindowDragTopLeft.X := Left;
WindowDragTopLeft.Y := Top;
end;
{ MouseMove - Code to drag the main window using the mouse}
procedure TMainForm.HandleOnMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
if WindowDragStarted then
begin
Left := WindowDragTopLeft.X +
(Mouse.CursorPos.X - WindowDragMousePos.X);
Top := WindowDragTopLeft.Y +
(Mouse.CursorPos.Y - WindowDragMousePos.Y);
end;
end;
{ Painting code, activated on OnPaint event }
procedure TMainForm.HandleOnPaint(ASender: TObject);
begin
// Background
Canvas.Brush.Color := clWhite;
Canvas.Pen.Color := clWhite;
Canvas.FillRect(0, 0, Width, Height);
// Eyes form
Canvas.Pen.Color := clBlack;
Canvas.Pen.Width := 5;
Canvas.Ellipse(
0,
0,
INT_OUTER_EYE_WIDTH,
INT_OUTER_EYE_HEIGHT);
Canvas.Ellipse(
INT_OUTER_EYE_WIDTH + INT_INTEREYE_SPACE,
0,
2* INT_OUTER_EYE_WIDTH + INT_INTEREYE_SPACE,
INT_OUTER_EYE_HEIGHT);
// Eyes pupils
Canvas.Brush.Color := clBlack;
Canvas.Pen.Width := 10;
Canvas.Ellipse(
LeftEyePos.X - 2,
LeftEyePos.Y - 2,
LeftEyePos.X + 2,
LeftEyePos.Y + 2);
Canvas.Ellipse(
RightEyePos.X - 2,
RightEyePos.Y - 2,
RightEyePos.X + 2,
RightEyePos.Y + 2);
end;
{ MouseUp - Code to drag the main window using the mouse }
procedure TMainForm.HandleOnMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
WindowDragStarted := False;
end;
var
MainForm: TMainForm;
{$IFDEF WINDOWS}{$R lazeyes.rc}{$ENDIF}
begin
{$I lazeyes.lrs}
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="CompanyName.ProductName.YourApp" type="win32"/>
<description>Your application description here.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -0,0 +1,7 @@
#define RT_MANIFEST 24
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
#define ISOLATIONAWARE_MANIFEST_RESOURCE_ID 2
#define ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID 3
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "lazeyes.manifest"
MAINICON ICON "lazeyes.ico"