Changeset 5
- Timestamp:
- Sep 16, 2014, 1:21:18 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.lfm
r4 r5 1 1 object FormMain: TFormMain 2 Left = 5 942 Left = 514 3 3 Height = 640 4 Top = 3274 Top = 299 5 5 Width = 920 6 6 Caption = 'LibrePaint' -
trunk/LibrePaint.lpi
r4 r5 33 33 </Item1> 34 34 </RequiredPackages> 35 <Units Count=" 7">35 <Units Count="8"> 36 36 <Unit0> 37 37 <Filename Value="LibrePaint.lpr"/> … … 75 75 <UnitName Value="UFormMain"/> 76 76 </Unit6> 77 <Unit7> 78 <Filename Value="ColorFormats/UColorGray8.pas"/> 79 <IsPartOfProject Value="True"/> 80 <UnitName Value="UColorGray8"/> 81 </Unit7> 77 82 </Units> 78 83 </ProjectOptions> -
trunk/LibrePaint.lpr
r3 r5 8 8 {$ENDIF}{$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, UCore, UGraphic, UProject, UFormNew, UFormMain, UColorRGBA8 10 Forms, UCore, UGraphic, UProject, UFormNew, UFormMain, UColorRGBA8, 11 UColorGray8 11 12 { you can add units after this }; 12 13 -
trunk/UCore.pas
r4 r5 37 37 38 38 uses 39 UFormNew, UFormMain, UColorRGBA8, Forms;39 UFormNew, UFormMain, Forms, UColorRGBA8, UColorGray8; 40 40 41 41 { TCore } … … 46 46 47 47 ColorManager.RegisterFormat(TGColorFormatRGBA8); 48 ColorManager.RegisterFormat(TGColorFormatGray8); 48 49 49 50 // Set default … … 74 75 begin 75 76 Project.Bitmap.Clear; 77 Project.Bitmap.Canvas.Pen.Color.Format := Project.Bitmap.ColorFormat; 78 Project.Bitmap.Canvas.Pen.Color.FromTColor(clWhite); 79 Project.Bitmap.Canvas.Pen.MoveTo(Point(100, 100)); 80 Project.Bitmap.Canvas.Pen.LineTo(Point(700, 500)); 76 81 FormMain.Redraw; 77 82 end; -
trunk/UGraphic.pas
r4 r5 12 12 13 13 TGColor = class; 14 TGCanvas = class; 14 15 15 16 TGColorClass = class of TGColor; … … 45 46 procedure FromTColor(Color: TColor); 46 47 procedure Assign(Source: TGColor); virtual; 48 constructor Create; 47 49 property Channels[Channel: TGColorChannel]: TGColor read GetChannel; 48 50 property Data: PByte read FData; … … 56 58 private 57 59 FBackgroundColor: TGColor; 60 FCanvas: TGCanvas; 58 61 FColorFormat: TGColorFormatClass; 59 62 FDPI: Integer; … … 79 82 property Size: TPoint read FSize write SetSize; 80 83 property Pixels[X, Y: Integer]: TGColor read GetPixel write SetPixel; 84 property Canvas: TGCanvas read FCanvas write FCanvas; 81 85 published 82 86 end; … … 96 100 end; 97 101 102 { TGPen } 103 104 TGPen = class 105 Canvas: TGCanvas; 106 Color: TGColor; 107 Position: TPoint; 108 procedure MoveTo(Pos: TPoint); 109 procedure LineTo(Pos: TPoint); 110 constructor Create; virtual; 111 destructor Destroy; override; 112 end; 113 114 { TGBrush } 115 116 TGBrush = class 117 Canvas: TGCanvas; 118 Color: TGColor; 119 constructor Create; virtual; 120 destructor Destroy; override; 121 end; 122 123 { TGCanvas } 124 125 TGCanvas = class 126 Brush: TGBrush; 127 Pen: TGPen; 128 Bitmap: TGBitmap; 129 constructor Create; virtual; 130 destructor Destroy; override; 131 end; 132 133 98 134 var 99 135 ColorManager: TGColorManager; 100 136 101 137 implementation 138 139 { TGBrush } 140 141 constructor TGBrush.Create; 142 begin 143 Color := TGColor.Create; 144 end; 145 146 destructor TGBrush.Destroy; 147 begin 148 Color.Free; 149 inherited Destroy; 150 end; 151 152 { TGPen } 153 154 procedure TGPen.MoveTo(Pos: TPoint); 155 begin 156 Position := Pos; 157 end; 158 159 procedure TGPen.LineTo(Pos: TPoint); 160 var 161 I: Integer; 162 Len: Integer; 163 begin 164 Len := Trunc(Sqrt(Sqr(Position.X - Pos.X) + Sqr(Position.Y - Pos.Y))); 165 for I := 0 to Len - 1 do 166 Canvas.Bitmap.Pixels[Trunc(Position.X + I * (Pos.X - Position.X) / Len), 167 Trunc(Position.Y + I * (Pos.Y - Position.Y) / Len)] := Color; 168 end; 169 170 constructor TGPen.Create; 171 begin 172 Color := TGColor.Create; 173 end; 174 175 destructor TGPen.Destroy; 176 begin 177 Color.Free; 178 inherited Destroy; 179 end; 180 181 { TGCanvas } 182 183 constructor TGCanvas.Create; 184 begin 185 Pen := TGPen.Create; 186 Pen.Canvas := Self; 187 Brush := TGBrush.Create; 188 Brush.Canvas := Self; 189 end; 190 191 destructor TGCanvas.Destroy; 192 begin 193 Pen.Free; 194 Brush.Free; 195 inherited Destroy; 196 end; 102 197 103 198 { TGColorManager } … … 233 328 procedure TGColor.Assign(Source: TGColor); 234 329 begin 330 end; 331 332 constructor TGColor.Create; 333 begin 334 Format := TGColorFormat; 235 335 end; 236 336 … … 343 443 ColorFormat := TGColorFormat; 344 444 FBackgroundColor.Format := ColorFormat; 445 FBackgroundColor.FromTColor(clBlack); 446 Canvas := TGCanvas.Create; 447 Canvas.Bitmap := Self; 345 448 end; 346 449
Note:
See TracChangeset
for help on using the changeset viewer.