Changeset 5 for trunk/UGraphic.pas
- Timestamp:
- Sep 16, 2014, 1:21:18 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.