Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure TForm1.Button4Click(Sender: TObject);
- var
- bit: TBitMap;
- z: TXXXL;
- i: Integer;
- aa: Integer;
- xGraphics: IGPGraphics;
- xLayer: TPNGGraphic;
- xBack: TPNGGraphic;
- {$DEFINE USEGDIP}
- procedure add(a: Word; c: TColor);
- var
- d: integer;
- begin
- d:=Length(z);
- SetLength(z, d+1);
- z[d].A:=Round(360*(a / 100));
- z[d].C:=c;
- end;
- procedure DrawSector(x1, y1, x2, y2: Integer; Color: TColor);
- begin
- bit.Canvas.Brush.Color:=Color;
- bit.Canvas.Pen.Color:=Color;
- bit.Canvas.Pie(0, 0, 200, 200, x1, y1, x2, y2);
- end;
- procedure DrawSector2(x0, y0, r: Integer; a1, a2: Real; Color: TColor);
- var
- x1, y1, x2, y2: Integer;
- rx1, ry1, rx2, ry2: Integer;
- function IntToStr2(v: Integer): WideString;
- var
- vs: WideString;
- l, lx, i: Integer;
- begin
- vs:=IntToStr(v);
- l:=length(vs);
- Result:='';
- lx:=6-l;
- for I := 0 to lx do
- Result:=Result+' ';
- Result:=Result+vs;
- end;
- begin
- rx1:=round(r*cos(a1));
- x1:=x0+rx1;
- ry1:=round(r*sin(a1));
- y1:=y0-ry1;
- rx2:=round(r*cos(a2));
- x2:=x0+rx2;
- ry2:=round(r*sin(a2));
- y2:=y0-ry2;
- sRichEdit1.Lines.Add('['+FloatToStr(a1)+'/'+FloatToStr(a2)+']'+sLineBreak+IntToStr2(rx1)+' '+IntToStr2(ry1)+' '+IntToStr2(rx2)+' '+IntToStr2(ry2)+' '+IntToStr2(x1)+' '+IntToStr2(y1)+' '+IntToStr2(x2)+' '+IntToStr2(y2));
- DrawSector(x1, y1, x2, y2, Color);
- end;
- procedure DrawSector3(x0, y0, r: Integer; a1, a2: Integer; Color: TColor);
- var
- ar1, ar2: Real;
- begin
- ar1:=a1 * (PI / 180);
- ar2:=a2 * (PI / 180);
- DrawSector2(x0, y0, r, ar1, ar2, Color);
- end;
- {$IFDEF USEGDIP}
- procedure DrawSector4(x0, y0, r: Integer; sa, da: Integer; Color: TColor);
- begin
- xGraphics.FillPie(TGPSolidBrush.Create(TGPColor.CreateFromColorRef(Color)), 0, 0, 200, 200, sa, da);
- end;
- {$ELSE}
- procedure DrawSector4(x0, y0, r: Integer; sa, da: Integer; Color: TColor);
- begin
- DrawSector3(x0, y0, r, sa, sa+da, Color);
- end;
- {$ENDIF}
- begin
- bit:=TBitmap.Create;
- bit.Width:=400;
- bit.Height:=400;
- bit.TransparentMode:=tmFixed;
- bit.TransparentColor:=clLime;
- bit.Transparent:=False;
- bit.Canvas.Brush.Color:=clLime;
- bit.Canvas.FillRect(Rect(0, 0, 400, 400));
- xGraphics:=bit.Canvas.ToGPGraphics;
- xGraphics.SmoothingMode:=SmoothingModeHighQuality;
- add(5, clRed);
- add(10, $FFA500);
- add(15, clYellow);
- add(25, clGreen);
- add(35, clBlue);
- add(10, clPurple);
- //add(100, clGray);
- aa:=0;
- for I := 0 to length(z)-1 do
- begin
- DrawSector4(100, 100, 100, aa, z[i].A, z[i].C);
- aa:=aa + z[i].A;
- end;
- {$IFNDEF USEGDIP}
- bit.Canvas.Brush.Color:=clLime;
- bit.Canvas.Pen.Color:=clLime;
- bit.Canvas.Ellipse(50, 50, 150, 150);
- {$ELSE}
- xGraphics.FillEllipse(TGPSolidBrush.Create(TGPColor.CreateFromColorRef(clLime)), 50, 50, 100, 100);
- {$ENDIF}
- xBack:=TPNGGraphic.Create;
- xBack.Width:=400;
- xBack.Height:=400;
- xBack.Canvas.Draw(0,0, bit);
- xLayer:=TPNGGraphic.Create;
- xLayer.LoadFromFile('Layer.png');
- xBack.Canvas.Draw(0, 0, xLayer);
- Image1.Picture.Graphic:=xBack;
- //Image1.Transparent:=True;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement