Skip to menu

Robotics with Object Pascal

temp

2023.12.14 08:16

me Views:498

https://wiki.lazarus.freepascal.org/BGRABitmap_tutorial_5

 

 

uses Math;


var ctx: TBGRACanvas2D;

img : TBGRABitmap;
img := TBGRABitmap.Create(ExtractFilePath(Application.ExeName)+'auto.png');

procedure TForm1.FormDestroy(Sender: TObject);
begin
  img.Free;
end;

// Test2 from testcanvas2D
var layer: TBGRABitmap;
layer := TBGRABitmap.Create(ctx.width,ctx.height);
layer.Canvas2D.antialiasing:= ctx.antialiasing;
ctx.surface.PutImage(0,0,layer,dmDrawWithTransparency);
layer.Free;

// Rotate
ctx.rotate(angle);            // real angle
ctx.rotate(radangle*PI/180);  // radian angle

// if in collision
if ctx.isPointInPath(mx+0.5,my+0.5) then



procedure TForm1.Test3(ctx: TBGRACanvas2D);
begin
   ctx.fillStyle ('rgb(1000,1000,1000)');
   ctx.fillRect (0, 0, ctx.width, ctx.height);
   // Triangle plein sans bordure
   ctx.beginPath();
   ctx.moveTo(100,100);
   ctx.lineTo(150,30);
   ctx.lineTo(230,150);
   ctx.closePath();
   if ctx.isPointInPath(mx+0.5,my+0.5) then
      ctx.fillStyle ('rgb(1000,192,192)')
   else
      ctx.fillStyle ('rgb(1000,0,0)');
   ctx.fill();
   // Triangle plein avec bordure
   ctx.fillStyle ('rgb(0,1000,0)');
   ctx.strokeStyle ('rgb(0,0,1000)');
   ctx.lineWidth := 8;
   ctx.beginPath();
   ctx.moveTo(50,100);
   ctx.lineTo(50,220);
   ctx.lineTo(210,200);
   ctx.closePath();
   if ctx.isPointInPath(mx+0.5,my+0.5) then
      ctx.fillStyle ('rgb(192,1000,192)')
   else
      ctx.fillStyle ('rgb(0,1000,0)');
   ctx.fill();
   ctx.stroke();
   // Triangle plein avec bordure
   UpdateIn(50);
end;              


 

No. Subject Author Date Views
» temp [1] me 2023.12.14 498
1 CVS's Drift XR from Protocol file me 2023.12.12 197