Recent

Author Topic: BGRA Simple Fast Triangle  (Read 1000 times)

SandyG

  • Jr. Member
  • **
  • Posts: 92
BGRA Simple Fast Triangle
« on: June 27, 2024, 01:21:19 am »
Found some routines to draw triangles but not sure if the fastest way to draw a simple filled triangle being used as an Analog Gauge Pointer.

I tried these -
    procedure FillTriangleLinearColor(pt1,pt2,pt3: TPointF; c1,c2,c3: TBGRAPixel); override;
    procedure FillTriangleLinearColorAntialias(pt1,pt2,pt3: TPointF; c1,c2,c3: TBGRAPixel); override;

But really just need a simple filled Antialiased Triangle as these are a bit overkill. Whats a light weight way to do this or are these the way to go.

Sandy


jamie

  • Hero Member
  • *****
  • Posts: 6733
Re: BGRA Simple Fast Triangle
« Reply #1 on: June 27, 2024, 02:13:03 am »
if you are dealing with basic direction arrows then using a ImagelIst is much easier and faster.
The only true wisdom is knowing you know nothing

SandyG

  • Jr. Member
  • **
  • Posts: 92
Re: BGRA Simple Fast Triangle
« Reply #2 on: June 27, 2024, 02:43:34 am »
More of a pointer on a gauge, needs to be able to change size, length and a few other parameters.

It may not be worth messing with it as it's a bit tricky to rotate a polygon around a center, more math  :)

Just looking to do some additional styles for the pointer on the updated analog gauge.

Pic of the progress.


circular

  • Hero Member
  • *****
  • Posts: 4356
    • Personal webpage
Re: BGRA Simple Fast Triangle
« Reply #3 on: June 29, 2024, 09:29:29 am »
Found some routines to draw triangles but not sure if the fastest way to draw a simple filled triangle being used as an Analog Gauge Pointer.

I tried these -
    procedure FillTriangleLinearColor(pt1,pt2,pt3: TPointF; c1,c2,c3: TBGRAPixel); override;
    procedure FillTriangleLinearColorAntialias(pt1,pt2,pt3: TPointF; c1,c2,c3: TBGRAPixel); override;

But really just need a simple filled Antialiased Triangle as these are a bit overkill. Whats a light weight way to do this or are these the way to go.

Sandy
Hi Sandy,

These routines provide a trilinear gradient, that's why there are specific versions for triangles. If you're looking for a solid fill, you can use FillPolygon / FillPolygonAntialias functions.

For transformations, there are some tools to make it easier. With BGRATransform, you have affine matrices that can transform TPointF coordinates. Alternatively, you can use Canvas2D to apply transformations to your drawings.

Warm regards
Conscience is the debugger of the mind

SandyG

  • Jr. Member
  • **
  • Posts: 92
Re: BGRA Simple Fast Triangle
« Reply #4 on: July 01, 2024, 08:48:59 pm »
I will have a look. Might be better to use Canvas2D Drawing as it seems easier to draw from points then to find centers of a polygon. I'm almost at the point where I can add some of the fancy looking features, but still have to get some more of the basics done on the Analog Gauage, added a lot of stuff but need to get it organized before I add the fluff :)

Thanks

Sandy

 

TinyPortal © 2005-2018