mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 10:56:08 +02:00
Examples, updated postscript sample
git-svn-id: trunk@20880 -
This commit is contained in:
parent
8523cdef61
commit
b89ef02ac6
@ -1,12 +1,12 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<CONFIG>
|
<CONFIG>
|
||||||
<ProjectOptions>
|
<ProjectOptions>
|
||||||
<PathDelim Value="/"/>
|
<Version Value="7"/>
|
||||||
<Version Value="6"/>
|
|
||||||
<General>
|
<General>
|
||||||
<Flags>
|
<Flags>
|
||||||
<SaveClosedFiles Value="False"/>
|
<SaveClosedFiles Value="False"/>
|
||||||
<SaveOnlyProjectUnits Value="True"/>
|
<SaveOnlyProjectUnits Value="True"/>
|
||||||
|
<LRSInOutputDirectory Value="False"/>
|
||||||
</Flags>
|
</Flags>
|
||||||
<SessionStorage Value="InProjectDir"/>
|
<SessionStorage Value="InProjectDir"/>
|
||||||
<MainUnit Value="0"/>
|
<MainUnit Value="0"/>
|
||||||
@ -38,10 +38,9 @@
|
|||||||
</Unit0>
|
</Unit0>
|
||||||
<Unit1>
|
<Unit1>
|
||||||
<Filename Value="usamplepostscriptcanvas.pas"/>
|
<Filename Value="usamplepostscriptcanvas.pas"/>
|
||||||
<ComponentName Value="Form1"/>
|
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
|
<ComponentName Value="Form1"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<ResourceFilename Value="usamplepostscriptcanvas.lrs"/>
|
|
||||||
<UnitName Value="uSamplePostScriptCanvas"/>
|
<UnitName Value="uSamplePostScriptCanvas"/>
|
||||||
</Unit1>
|
</Unit1>
|
||||||
</Units>
|
</Units>
|
||||||
|
@ -1,137 +1,93 @@
|
|||||||
object Form1: TForm1
|
object Form1: TForm1
|
||||||
Left = 310
|
Left = 310
|
||||||
Height = 97
|
Height = 118
|
||||||
Top = 163
|
Top = 163
|
||||||
Width = 400
|
Width = 486
|
||||||
HelpContext = 0
|
|
||||||
ActiveControl = Button1
|
ActiveControl = Button1
|
||||||
Align = alNone
|
|
||||||
AllowDropFiles = False
|
|
||||||
AutoScroll = True
|
|
||||||
AutoSize = False
|
|
||||||
BorderIcons = [biSystemMenu, biMinimize, biMaximize]
|
|
||||||
BorderStyle = bsSizeable
|
|
||||||
Caption = 'Form1'
|
Caption = 'Form1'
|
||||||
ClientHeight = 97
|
ClientHeight = 118
|
||||||
ClientWidth = 400
|
ClientWidth = 486
|
||||||
DockSite = False
|
|
||||||
DragKind = dkDrag
|
|
||||||
DragMode = dmManual
|
|
||||||
Enabled = True
|
|
||||||
Font.Height = 0
|
|
||||||
Font.Style = []
|
|
||||||
FormStyle = fsNormal
|
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
ParentBiDiMode = True
|
|
||||||
ParentFont = False
|
|
||||||
Position = poDesigned
|
|
||||||
ShowInTaskBar = stDefault
|
|
||||||
UseDockManager = False
|
|
||||||
LCLVersion = '0.9.27'
|
LCLVersion = '0.9.27'
|
||||||
WindowState = wsNormal
|
|
||||||
object Label1: TLabel
|
object Label1: TLabel
|
||||||
Left = 256
|
Left = 108
|
||||||
Height = 13
|
Height = 16
|
||||||
Top = 23
|
Top = 8
|
||||||
Width = 101
|
Width = 106
|
||||||
HelpContext = 0
|
|
||||||
Align = alNone
|
|
||||||
Alignment = taLeftJustify
|
|
||||||
AutoSize = True
|
|
||||||
Caption = 'Select Paper Size'
|
Caption = 'Select Paper Size'
|
||||||
DragCursor = crDrag
|
|
||||||
DragMode = dmManual
|
|
||||||
Enabled = True
|
|
||||||
Layout = tlTop
|
|
||||||
ParentBidiMode = True
|
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
ParentFont = True
|
end
|
||||||
ParentShowHint = True
|
object Label2: TLabel
|
||||||
ShowAccelChar = True
|
Left = 8
|
||||||
Transparent = True
|
Height = 16
|
||||||
Visible = True
|
Top = 8
|
||||||
WordWrap = False
|
Width = 73
|
||||||
OptimalFill = False
|
Caption = 'Resolution X'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
|
object Label3: TLabel
|
||||||
|
Left = 8
|
||||||
|
Height = 16
|
||||||
|
Top = 64
|
||||||
|
Width = 75
|
||||||
|
Caption = 'Resolution Y'
|
||||||
|
ParentColor = False
|
||||||
end
|
end
|
||||||
object Button1: TButton
|
object Button1: TButton
|
||||||
Left = 24
|
Left = 264
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 23
|
Top = 8
|
||||||
Width = 212
|
Width = 212
|
||||||
HelpContext = 0
|
|
||||||
Align = alNone
|
|
||||||
AutoSize = False
|
|
||||||
BorderSpacing.InnerBorder = 4
|
BorderSpacing.InnerBorder = 4
|
||||||
Cancel = False
|
|
||||||
Caption = 'Generate a PostScript file'
|
Caption = 'Generate a PostScript file'
|
||||||
Default = False
|
|
||||||
DragCursor = crDrag
|
|
||||||
DragMode = dmManual
|
|
||||||
Enabled = True
|
|
||||||
ParentBidiMode = True
|
|
||||||
ModalResult = 0
|
|
||||||
OnClick = Button1Click
|
OnClick = Button1Click
|
||||||
ParentFont = True
|
|
||||||
ParentShowHint = True
|
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
TabStop = True
|
|
||||||
Visible = True
|
|
||||||
end
|
end
|
||||||
object Button2: TButton
|
object Button2: TButton
|
||||||
Left = 24
|
Left = 264
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 56
|
Top = 40
|
||||||
Width = 212
|
Width = 212
|
||||||
HelpContext = 0
|
|
||||||
Align = alNone
|
|
||||||
AutoSize = False
|
|
||||||
BorderSpacing.InnerBorder = 4
|
BorderSpacing.InnerBorder = 4
|
||||||
Cancel = False
|
|
||||||
Caption = 'Show this file (kghostview)'
|
Caption = 'Show this file (kghostview)'
|
||||||
Default = False
|
|
||||||
DragCursor = crDrag
|
|
||||||
DragMode = dmManual
|
|
||||||
Enabled = True
|
|
||||||
ParentBidiMode = True
|
|
||||||
ModalResult = 0
|
|
||||||
OnClick = Button2Click
|
OnClick = Button2Click
|
||||||
ParentFont = True
|
|
||||||
ParentShowHint = True
|
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
TabStop = True
|
|
||||||
Visible = True
|
|
||||||
end
|
end
|
||||||
object ListBox1: TListBox
|
object ListBox1: TListBox
|
||||||
Left = 252
|
Left = 104
|
||||||
Height = 38
|
Height = 79
|
||||||
Top = 43
|
Top = 28
|
||||||
Width = 124
|
Width = 124
|
||||||
HelpContext = 0
|
|
||||||
Align = alNone
|
|
||||||
BorderStyle = bsSingle
|
|
||||||
ClickOnSelChange = True
|
|
||||||
Columns = 0
|
|
||||||
DragCursor = crDrag
|
|
||||||
DragKind = dkDrag
|
|
||||||
DragMode = dmManual
|
|
||||||
ExtendedSelect = True
|
|
||||||
Enabled = True
|
|
||||||
IntegralHeight = False
|
|
||||||
Items.Strings = (
|
Items.Strings = (
|
||||||
'A4'
|
'A4'
|
||||||
'Letter'
|
'Letter'
|
||||||
)
|
)
|
||||||
ItemHeight = 16
|
ItemHeight = 21
|
||||||
MultiSelect = False
|
|
||||||
ParentBidiMode = True
|
|
||||||
ParentColor = False
|
|
||||||
ParentShowHint = True
|
|
||||||
ParentFont = True
|
|
||||||
Sorted = False
|
|
||||||
Style = lbStandard
|
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
TabStop = True
|
end
|
||||||
TopIndex = 0
|
object txtResX: TEdit
|
||||||
Visible = True
|
Left = 8
|
||||||
|
Height = 23
|
||||||
|
Top = 28
|
||||||
|
Width = 80
|
||||||
|
TabOrder = 3
|
||||||
|
Text = '72'
|
||||||
|
end
|
||||||
|
object txtResY: TEdit
|
||||||
|
Left = 8
|
||||||
|
Height = 23
|
||||||
|
Top = 84
|
||||||
|
Width = 80
|
||||||
|
TabOrder = 4
|
||||||
|
Text = '72'
|
||||||
|
end
|
||||||
|
object Button3: TButton
|
||||||
|
Left = 328
|
||||||
|
Height = 25
|
||||||
|
Top = 84
|
||||||
|
Width = 75
|
||||||
|
Caption = 'Button3'
|
||||||
|
OnClick = Button3Click
|
||||||
|
TabOrder = 5
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,40 +1,25 @@
|
|||||||
{ This is an automatically generated lazarus resource file }
|
{ Este es un archivo de recurso de Lazarus generado automáticamente }
|
||||||
|
|
||||||
LazarusResources.Add('TForm1','FORMDATA',[
|
LazarusResources.Add('TForm1','FORMDATA',[
|
||||||
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'6'#1#6'Height'#2'a'#3'Top'#3#163#0#5'Widt'
|
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'6'#1#6'Height'#2'v'#3'Top'#3#163#0#5'Widt'
|
||||||
+'h'#3#144#1#11'HelpContext'#2#0#13'ActiveControl'#7#7'Button1'#5'Align'#7#6
|
+'h'#3#230#1#13'ActiveControl'#7#7'Button1'#7'Caption'#6#5'Form1'#12'ClientHe'
|
||||||
+'alNone'#14'AllowDropFiles'#8#10'AutoScroll'#9#8'AutoSize'#8#11'BorderIcons'
|
+'ight'#2'v'#11'ClientWidth'#3#230#1#8'OnCreate'#7#10'FormCreate'#10'LCLVersi'
|
||||||
+#11#12'biSystemMenu'#10'biMinimize'#10'biMaximize'#0#11'BorderStyle'#7#10'bs'
|
+'on'#6#6'0.9.27'#0#6'TLabel'#6'Label1'#4'Left'#2'l'#6'Height'#2#16#3'Top'#2#8
|
||||||
+'Sizeable'#7'Caption'#6#5'Form1'#12'ClientHeight'#2'a'#11'ClientWidth'#3#144
|
+#5'Width'#2'j'#7'Caption'#6#17'Select Paper Size'#11'ParentColor'#8#0#0#6'TL'
|
||||||
+#1#8'DockSite'#8#8'DragKind'#7#6'dkDrag'#8'DragMode'#7#8'dmManual'#7'Enabled'
|
+'abel'#6'Label2'#4'Left'#2#8#6'Height'#2#16#3'Top'#2#8#5'Width'#2'I'#7'Capti'
|
||||||
+#9#11'Font.Height'#2#0#10'Font.Style'#11#0#9'FormStyle'#7#8'fsNormal'#8'OnCr'
|
+'on'#6#12'Resolution X'#11'ParentColor'#8#0#0#6'TLabel'#6'Label3'#4'Left'#2#8
|
||||||
+'eate'#7#10'FormCreate'#14'ParentBiDiMode'#9#10'ParentFont'#8#8'Position'#7
|
+#6'Height'#2#16#3'Top'#2'@'#5'Width'#2'K'#7'Caption'#6#12'Resolution Y'#11'P'
|
||||||
+#10'poDesigned'#13'ShowInTaskBar'#7#9'stDefault'#14'UseDockManager'#8#10'LCL'
|
+'arentColor'#8#0#0#7'TButton'#7'Button1'#4'Left'#3#8#1#6'Height'#2#25#3'Top'
|
||||||
+'Version'#6#6'0.9.27'#11'WindowState'#7#8'wsNormal'#0#6'TLabel'#6'Label1'#4
|
+#2#8#5'Width'#3#212#0#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#26'Gene'
|
||||||
+'Left'#3#0#1#6'Height'#2#13#3'Top'#2#23#5'Width'#2'e'#11'HelpContext'#2#0#5
|
+'rate a PostScript file'#7'OnClick'#7#12'Button1Click'#8'TabOrder'#2#0#0#0#7
|
||||||
+'Align'#7#6'alNone'#9'Alignment'#7#13'taLeftJustify'#8'AutoSize'#9#7'Caption'
|
+'TButton'#7'Button2'#4'Left'#3#8#1#6'Height'#2#25#3'Top'#2'('#5'Width'#3#212
|
||||||
+#6#17'Select Paper Size'#10'DragCursor'#7#6'crDrag'#8'DragMode'#7#8'dmManual'
|
+#0#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#27'Show this file (kghostv'
|
||||||
+#7'Enabled'#9#6'Layout'#7#5'tlTop'#14'ParentBidiMode'#9#11'ParentColor'#8#10
|
+'iew)'#7'OnClick'#7#12'Button2Click'#8'TabOrder'#2#1#0#0#8'TListBox'#8'ListB'
|
||||||
+'ParentFont'#9#14'ParentShowHint'#9#13'ShowAccelChar'#9#11'Transparent'#9#7
|
+'ox1'#4'Left'#2'h'#6'Height'#2'O'#3'Top'#2#28#5'Width'#2'|'#13'Items.Strings'
|
||||||
+'Visible'#9#8'WordWrap'#8#11'OptimalFill'#8#0#0#7'TButton'#7'Button1'#4'Left'
|
+#1#6#2'A4'#6#6'Letter'#0#10'ItemHeight'#2#21#8'TabOrder'#2#2#0#0#5'TEdit'#7
|
||||||
+#2#24#6'Height'#2#25#3'Top'#2#23#5'Width'#3#212#0#11'HelpContext'#2#0#5'Alig'
|
+'txtResX'#4'Left'#2#8#6'Height'#2#23#3'Top'#2#28#5'Width'#2'P'#8'TabOrder'#2
|
||||||
+'n'#7#6'alNone'#8'AutoSize'#8#25'BorderSpacing.InnerBorder'#2#4#6'Cancel'#8#7
|
+#3#4'Text'#6#2'72'#0#0#5'TEdit'#7'txtResY'#4'Left'#2#8#6'Height'#2#23#3'Top'
|
||||||
+'Caption'#6#26'Generate a PostScript file'#7'Default'#8#10'DragCursor'#7#6'c'
|
+#2'T'#5'Width'#2'P'#8'TabOrder'#2#4#4'Text'#6#2'72'#0#0#7'TButton'#7'Button3'
|
||||||
+'rDrag'#8'DragMode'#7#8'dmManual'#7'Enabled'#9#14'ParentBidiMode'#9#11'Modal'
|
+#4'Left'#3'H'#1#6'Height'#2#25#3'Top'#2'T'#5'Width'#2'K'#7'Caption'#6#7'Butt'
|
||||||
+'Result'#2#0#7'OnClick'#7#12'Button1Click'#10'ParentFont'#9#14'ParentShowHin'
|
+'on3'#7'OnClick'#7#12'Button3Click'#8'TabOrder'#2#5#0#0#0
|
||||||
+'t'#9#8'TabOrder'#2#0#7'TabStop'#9#7'Visible'#9#0#0#7'TButton'#7'Button2'#4
|
|
||||||
+'Left'#2#24#6'Height'#2#25#3'Top'#2'8'#5'Width'#3#212#0#11'HelpContext'#2#0#5
|
|
||||||
+'Align'#7#6'alNone'#8'AutoSize'#8#25'BorderSpacing.InnerBorder'#2#4#6'Cancel'
|
|
||||||
+#8#7'Caption'#6#27'Show this file (kghostview)'#7'Default'#8#10'DragCursor'#7
|
|
||||||
+#6'crDrag'#8'DragMode'#7#8'dmManual'#7'Enabled'#9#14'ParentBidiMode'#9#11'Mo'
|
|
||||||
+'dalResult'#2#0#7'OnClick'#7#12'Button2Click'#10'ParentFont'#9#14'ParentShow'
|
|
||||||
+'Hint'#9#8'TabOrder'#2#1#7'TabStop'#9#7'Visible'#9#0#0#8'TListBox'#8'ListBox'
|
|
||||||
+'1'#4'Left'#3#252#0#6'Height'#2'&'#3'Top'#2'+'#5'Width'#2'|'#11'HelpContext'
|
|
||||||
+#2#0#5'Align'#7#6'alNone'#11'BorderStyle'#7#8'bsSingle'#16'ClickOnSelChange'
|
|
||||||
+#9#7'Columns'#2#0#10'DragCursor'#7#6'crDrag'#8'DragKind'#7#6'dkDrag'#8'DragM'
|
|
||||||
+'ode'#7#8'dmManual'#14'ExtendedSelect'#9#7'Enabled'#9#14'IntegralHeight'#8#13
|
|
||||||
+'Items.Strings'#1#6#2'A4'#6#6'Letter'#0#10'ItemHeight'#2#16#11'MultiSelect'#8
|
|
||||||
+#14'ParentBidiMode'#9#11'ParentColor'#8#14'ParentShowHint'#9#10'ParentFont'#9
|
|
||||||
+#6'Sorted'#8#5'Style'#7#10'lbStandard'#8'TabOrder'#2#2#7'TabStop'#9#8'TopInd'
|
|
||||||
+'ex'#2#0#7'Visible'#9#0#0#0
|
|
||||||
]);
|
]);
|
||||||
|
@ -21,10 +21,16 @@ type
|
|||||||
TForm1 = class(TForm)
|
TForm1 = class(TForm)
|
||||||
Button1: TButton;
|
Button1: TButton;
|
||||||
Button2: TButton;
|
Button2: TButton;
|
||||||
|
Button3: TButton;
|
||||||
|
txtResX: TEdit;
|
||||||
|
txtResY: TEdit;
|
||||||
Label1: TLabel;
|
Label1: TLabel;
|
||||||
|
Label2: TLabel;
|
||||||
|
Label3: TLabel;
|
||||||
ListBox1: TListBox;
|
ListBox1: TListBox;
|
||||||
procedure Button1Click(Sender: TObject);
|
procedure Button1Click(Sender: TObject);
|
||||||
procedure Button2Click(Sender: TObject);
|
procedure Button2Click(Sender: TObject);
|
||||||
|
procedure Button3Click(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
@ -49,25 +55,49 @@ var
|
|||||||
x,y,tmp : Integer;
|
x,y,tmp : Integer;
|
||||||
PsCanvas: TPostscriptCanvas;
|
PsCanvas: TPostscriptCanvas;
|
||||||
|
|
||||||
|
function Sx(AX: Integer): Integer;
|
||||||
|
begin
|
||||||
|
// all values were based on 72 dpi
|
||||||
|
result := round(PsCanvas.XDPI/72*Ax);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Sy(AY: Integer): Integer;
|
||||||
|
begin
|
||||||
|
// all values were based on 72 dpi
|
||||||
|
result := round(PsCanvas.YDPI/72*Ay);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function PointS(Ax,Ay:Integer): TPoint;
|
||||||
|
begin
|
||||||
|
Result.X:= Sx(Ax);
|
||||||
|
Result.Y:= Sy(Ay);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function Pt2Pix(Pt: Integer): Integer;
|
||||||
|
begin
|
||||||
|
result := round(PSCanvas.YDPI/72*Pt);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure LineSample(txt:string);
|
procedure LineSample(txt:string);
|
||||||
begin
|
begin
|
||||||
tmp := PsCanvas.Font.Size div 2;
|
tmp := Pt2Pix(PsCanvas.Font.Size) div 2;
|
||||||
PsCanvas.Line(x+170,y+tmp,x+170+100,y+tmp);
|
//WriteLn('LineSample: Y=',Y,' FontSize=', PsCanvas.Font.Size,' Pix=',tmp*2,' Spc= ',tmp,' Sy=',Sy(Tmp));
|
||||||
|
PsCanvas.Line(x+Sx(170),y+tmp,x+Sx(170+100),y+tmp);
|
||||||
PsCanvas.TextOut(x,y,txt);
|
PsCanvas.TextOut(x,y,txt);
|
||||||
inc(y,tmp*3);
|
inc(y,tmp*3);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure BrushSample(txt:string);
|
procedure BrushSample(txt:string);
|
||||||
begin
|
begin
|
||||||
PsCanvas.Rectangle(x,y,x+50,y+40);
|
PsCanvas.Rectangle(x,y,x+Sx(50),y+Sy(40));
|
||||||
PsCanvas.TextOut(x+55,y+40-PsCanvas.Font.Size,txt);
|
PsCanvas.TextOut(x+Sx(55),y+SY(40)-Pt2Pix(PsCanvas.Font.Size),txt);
|
||||||
inc(y,50);
|
inc(y,Sy(50));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure FontSample(txt:string);
|
procedure FontSample(txt:string);
|
||||||
begin
|
begin
|
||||||
PsCanvas.TextOut(x,y,txt);
|
PsCanvas.TextOut(x,y,txt);
|
||||||
inc(y,PsCanvas.Font.Size+4);
|
inc(y,Pt2Pix(PsCanvas.Font.Size)+Sy(4));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure LineSamples(AX,AY:Integer);
|
procedure LineSamples(AX,AY:Integer);
|
||||||
@ -128,78 +158,78 @@ var
|
|||||||
begin
|
begin
|
||||||
if Sender=nil then ;
|
if Sender=nil then ;
|
||||||
PsCanvas := TPostscriptCanvas.Create;
|
PsCanvas := TPostscriptCanvas.Create;
|
||||||
PsCanvas.XDPI:=72;
|
psCanvas.XDPI := StrToIntDef(txtResX.Text,300);
|
||||||
PsCanvas.YDPI:=72;
|
psCanvas.YDPI := StrToIntDef(txtResY.Text,300);
|
||||||
With PsCanvas do
|
With PsCanvas do
|
||||||
try
|
try
|
||||||
if ListBox1.ItemIndex=1 then begin
|
if ListBox1.ItemIndex=1 then begin
|
||||||
PageHeight:=792;
|
PaperHeight:=Sx(792);
|
||||||
PageWidth:=612;
|
PaperWidth:=Sy(612);
|
||||||
end else begin
|
end else begin
|
||||||
PageHeight:=842;
|
PaperHeight:=Sy(842);
|
||||||
PageWidth:=595;
|
PaperWidth:=Sx(595);
|
||||||
end;
|
end;
|
||||||
TopMargin:=40;
|
TopMargin:=Sy(40);
|
||||||
LeftMargin:=20;
|
LeftMargin:=Sx(20);
|
||||||
|
|
||||||
BeginDoc;
|
BeginDoc;
|
||||||
|
|
||||||
// title
|
// title
|
||||||
Font.Size:=24;
|
Font.Size:=24;
|
||||||
Font.Style:=[fsBold,fsItalic,fsUnderline];
|
Font.Style:=[fsBold,fsItalic,fsUnderline];
|
||||||
TextOut(100,-10,'PostScript Canvas Lazarus sample');
|
TextOut(Sx(100),Sy(10),'PostScript Canvas Lazarus sample');
|
||||||
|
|
||||||
Font.Size:=12;
|
Font.Size:=12;
|
||||||
Brush.Color:=clRed;
|
Brush.Color:=clRed;
|
||||||
Pen.Width:=1;
|
Pen.Width:=1;
|
||||||
RoundRect(10,60,60,110,8,8);
|
RoundRect(Sx(10),Sy(60),Sx(60),Sy(110),Sx(8),Sy(8));
|
||||||
Brush.Color:=clMaroon;
|
Brush.Color:=clMaroon;
|
||||||
Rectangle(70,60,170,110);
|
Rectangle(Sx(70),Sy(60),Sx(170),Sy(110));
|
||||||
|
|
||||||
FontSamples(200, 60);
|
FontSamples(Sx(200), Sy(60));
|
||||||
|
|
||||||
// green ellipse
|
// green ellipse
|
||||||
Pen.Style:=psSolid;
|
Pen.Style:=psSolid;
|
||||||
Brush.Color:=clGreen;
|
Brush.Color:=clGreen;
|
||||||
Ellipse(10,260,60,310);
|
Ellipse(Sx(10),Sy(260),Sx(60),Sy(310));
|
||||||
|
|
||||||
// pie
|
// pie
|
||||||
Brush.Color:=clTeal;
|
Brush.Color:=clTeal;
|
||||||
Brush.Style:=bsSolid;
|
Brush.Style:=bsSolid;
|
||||||
RadialPie(10,360,90,440,0,60*16);
|
RadialPie(Sx(10),Sy(360),Sx(90),Sy(440),0,60*16);
|
||||||
|
|
||||||
// polygon: triangle
|
// polygon: triangle
|
||||||
Pen.Style:=psSolid;
|
Pen.Style:=psSolid;
|
||||||
Brush.Color:=clGray;
|
Brush.Color:=clGray;
|
||||||
Pt[0]:=Point(10,140);
|
Pt[0]:=PointS(10,140);
|
||||||
Pt[1]:=Point(10,240);
|
Pt[1]:=PointS(10,240);
|
||||||
Pt[2]:=Point(140,140);
|
Pt[2]:=PointS(140,140);
|
||||||
Polygon(@Pt,3,True);
|
Polygon(@Pt,3,True);
|
||||||
|
|
||||||
// polyline: angle
|
// polyline: angle
|
||||||
Pen.Style:=psDot;
|
Pen.Style:=psDot;
|
||||||
Pt1[0]:=Point(10,400);
|
Pt1[0]:=PointS(10,400);
|
||||||
Pt1[1]:=Point(50,390);
|
Pt1[1]:=PointS(50,390);
|
||||||
Pt1[2]:=Point(120,410);
|
Pt1[2]:=PointS(120,410);
|
||||||
Pt1[3]:=Point(180,425);
|
Pt1[3]:=PointS(180,425);
|
||||||
Polyline(@Pt1,4);
|
Polyline(@Pt1,4);
|
||||||
|
|
||||||
// bezier
|
// bezier
|
||||||
Brush.Color:=clAqua;
|
Brush.Color:=clAqua;
|
||||||
Pen.Style:=psSolid;
|
Pen.Style:=psSolid;
|
||||||
Pt1[0]:=Point(10,430);
|
Pt1[0]:=PointS(10,430);
|
||||||
PolyBezier(@Pt1,4,true,True);
|
PolyBezier(@Pt1,4,true,True);
|
||||||
|
|
||||||
// line samples
|
// line samples
|
||||||
|
|
||||||
LineSamples(200,165);
|
LineSamples(Sx(200),Sy(165));
|
||||||
|
|
||||||
BrushSamples(240,280);
|
BrushSamples(Sx(240),Sy(280));
|
||||||
|
|
||||||
Bmp:=TBitMap.Create;
|
Bmp:=TBitMap.Create;
|
||||||
try
|
try
|
||||||
Bmp.LoadFromFile(ExpandFileNameUTF8('../../images/LazarusForm.bmp'));
|
Bmp.LoadFromFile(ExpandFileNameUTF8('../../images/LazarusForm.bmp'));
|
||||||
DRaw(10,450,BMP);
|
DRaw(Sx(10),SY(450),BMP);
|
||||||
finally
|
finally
|
||||||
Bmp.Free;
|
Bmp.Free;
|
||||||
end;
|
end;
|
||||||
@ -207,7 +237,7 @@ begin
|
|||||||
xpm:=TPixMap.Create;
|
xpm:=TPixMap.Create;
|
||||||
try
|
try
|
||||||
xpm.LoadFromFile(ExpandFileNameUTF8('../../images/vase_trans.xpm'));
|
xpm.LoadFromFile(ExpandFileNameUTF8('../../images/vase_trans.xpm'));
|
||||||
StretchDraw(bounds(10, 590, round(xpm.Width*0.60),round(xpm.height*0.60)),xpm);
|
StretchDraw(bounds(Sx(10), Sy(590), Sx(round(xpm.Width*0.60)),Sy(round(xpm.height*0.60))),xpm);
|
||||||
finally
|
finally
|
||||||
xpm.Free;
|
xpm.Free;
|
||||||
end;
|
end;
|
||||||
@ -215,7 +245,7 @@ begin
|
|||||||
png := TPortableNetworkGraphic.Create;
|
png := TPortableNetworkGraphic.Create;
|
||||||
try
|
try
|
||||||
png.LoadFromFile('../../images/splash_logo.png');
|
png.LoadFromFile('../../images/splash_logo.png');
|
||||||
StretchDraw(bounds(190, 590, round(png.Width*0.60),round(png.height*0.60)),png);
|
StretchDraw(bounds(Sx(190), Sy(590), Sx(round(png.Width*0.60)),Sy(round(png.height*0.60))),png);
|
||||||
finally
|
finally
|
||||||
png.Free;
|
png.Free;
|
||||||
end;
|
end;
|
||||||
@ -225,9 +255,9 @@ begin
|
|||||||
Pen.Color:=clBlack;
|
Pen.Color:=clBlack;
|
||||||
Brush.Color:=clTeal;
|
Brush.Color:=clTeal;
|
||||||
Brush.Style:=bsSolid;
|
Brush.Style:=bsSolid;
|
||||||
Chord(10,360,90,440,0,60*16);
|
Chord(Sx(10),Sy(360),Sx(90),Sy(440),0,60*16);
|
||||||
|
|
||||||
BrushSamples(100,100);
|
BrushSamples(Sx(100),Sy(100));
|
||||||
|
|
||||||
EndDoc;
|
EndDoc;
|
||||||
SaveToFile('test1.ps');
|
SaveToFile('test1.ps');
|
||||||
@ -248,11 +278,39 @@ begin
|
|||||||
ShellExecute(Handle, 'open', PChar(FName), nil, nil, SW_SHOWNORMAL)
|
ShellExecute(Handle, 'open', PChar(FName), nil, nil, SW_SHOWNORMAL)
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$IFDEF UNIX}
|
{$IFDEF UNIX}
|
||||||
Shell(format('kghostview %s',[ExpandFileNameUTF8('./test1.ps')]));
|
Shell(format('gv %s',[ExpandFileNameUTF8('./test1.ps')]));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.Button3Click(Sender: TObject);
|
||||||
|
var
|
||||||
|
png : TPortableNetworkGraphic;
|
||||||
|
x,y,tmp : Integer;
|
||||||
|
PsCanvas: TPostscriptCanvas;
|
||||||
|
begin
|
||||||
|
psCanvas := TPostscriptCanvas.Create;
|
||||||
|
psCanvas.XDPI := 72;
|
||||||
|
psCanvas.YDPI := 72;
|
||||||
|
psCanvas.PaperHeight:=842;
|
||||||
|
psCanvas.PaperWidth:=595;
|
||||||
|
psCanvas.TopMargin:=40;
|
||||||
|
psCanvas.LeftMargin:=20;
|
||||||
|
psCanvas.BeginDoc;
|
||||||
|
|
||||||
|
png := TPortableNetworkGraphic.Create;
|
||||||
|
try
|
||||||
|
png.LoadFromFile('small.png');
|
||||||
|
psCanvas.StretchDraw(Bounds(50,500,50,50),png);
|
||||||
|
finally
|
||||||
|
png.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
psCanvas.EndDoc;
|
||||||
|
psCanvas.SaveToFile('small.ps');
|
||||||
|
psCanvas.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.FormCreate(Sender: TObject);
|
procedure TForm1.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
ListBox1.ItemIndex:=0;
|
ListBox1.ItemIndex:=0;
|
||||||
|
Loading…
Reference in New Issue
Block a user