Changeset 10 for trunk/UCore.pas
- Timestamp:
- Sep 22, 2014, 3:07:02 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UCore.pas
r9 r10 8 8 Classes, SysUtils, FileUtil, ActnList, UProject, UGraphic, Controls, Graphics; 9 9 10 const 11 ZoomFactor = 1.5; 12 10 13 type 14 TFloatPoint = record 15 X, Y: Double; 16 end; 11 17 12 18 { TCore } 13 19 14 20 TCore = class(TDataModule) 21 AImageGradient: TAction; 15 22 AImageMirror: TAction; 16 23 AImageFlip: TAction; … … 32 39 procedure AImageClearExecute(Sender: TObject); 33 40 procedure AImageFlipExecute(Sender: TObject); 41 procedure AImageGradientExecute(Sender: TObject); 34 42 procedure AImageMirrorExecute(Sender: TObject); 35 43 procedure AImageRandomExecute(Sender: TObject); 36 44 procedure AFileNewExecute(Sender: TObject); 45 procedure AZoomAllExecute(Sender: TObject); 37 46 procedure AZoomInExecute(Sender: TObject); 38 47 procedure AZoomNormalExecute(Sender: TObject); … … 43 52 public 44 53 Project: TProject; 54 procedure Init; 45 55 end; 46 56 … … 53 63 54 64 uses 55 UFormNew, UFormMain, Forms, UColorRGBA8, UColorGray8, UColorGray1; 65 UFormNew, UFormMain, Forms, UColorRGBA8, UColorGray8, UColorGray1, UColorGray4; 66 67 function FloatPoint(AX, AY: Double): TFloatPoint; 68 begin 69 Result.X := AX; 70 Result.Y := AY; 71 end; 56 72 57 73 { TCore } … … 63 79 ColorManager.RegisterFormat(TGColorFormatRGBA8); 64 80 ColorManager.RegisterFormat(TGColorFormatGray8); 81 ColorManager.RegisterFormat(TGColorFormatGray4); 65 82 ColorManager.RegisterFormat(TGColorFormatGray1); 83 end; 66 84 85 procedure TCore.Init; 86 begin 67 87 // Set default 68 88 Project.Bitmap.Size := Point(200, 100); 69 89 if ColorManager.FormatCount > 0 then 70 90 Project.Bitmap.ColorFormat := ColorManager.Formats[0]; 91 Project.View.DestRect := Bounds(0, 0, FormMain.PaintBox1.Width, FormMain.PaintBox1.Height); 92 Core.AZoomAll.Execute; 71 93 end; 72 94 … … 81 103 Project.Bitmap.BackgroundColor.FromTColor(clBlack); 82 104 Project.Bitmap.DPI := FormNew.SpinEditDPI.Value; 83 FormMain.Redraw;105 AZoomAll.Execute;; 84 106 end; 107 end; 108 109 procedure TCore.AZoomAllExecute(Sender: TObject); 110 var 111 Factor: TFloatPoint; 112 begin 113 with Core.Project, View do begin 114 Factor := FloatPoint((DestRect.Right - DestRect.Left) / Bitmap.Size.X, 115 (DestRect.Bottom - DestRect.Top) / Bitmap.Size.Y); 116 if Factor.X < Factor.Y then Zoom := Factor.X 117 else Zoom := Factor.Y; 118 Center(Rect(0, 0, Bitmap.Size.X, Bitmap.Size.Y)); 119 end; 120 FormMain.Redraw; 85 121 end; 86 122 87 123 procedure TCore.AZoomInExecute(Sender: TObject); 88 124 begin 89 Project.View Port.Zoom := Project.ViewPort.Zoom * 1.3;125 Project.View.Zoom := Project.View.Zoom * ZoomFactor; 90 126 FormMain.Redraw; 91 127 end; … … 93 129 procedure TCore.AZoomNormalExecute(Sender: TObject); 94 130 begin 95 Project.View Port.Zoom := 1;131 Project.View.Zoom := 1; 96 132 FormMain.Redraw; 97 133 end; … … 99 135 procedure TCore.AZoomOutExecute(Sender: TObject); 100 136 begin 101 Project.View Port.Zoom := Project.ViewPort.Zoom / 1.3;137 Project.View.Zoom := Project.View.Zoom / ZoomFactor; 102 138 FormMain.Redraw; 103 139 end; … … 124 160 end; 125 161 162 procedure TCore.AImageGradientExecute(Sender: TObject); 163 begin 164 Core.Project.Bitmap.Gradient; 165 FormMain.Redraw; 166 end; 167 126 168 procedure TCore.AImageMirrorExecute(Sender: TObject); 127 169 begin
Note:
See TracChangeset
for help on using the changeset viewer.