Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi GDI+ Zeichenfehler bei ARC (https://www.delphipraxis.net/215937-gdi-zeichenfehler-bei-arc.html)

DaCoda 28. Sep 2024 18:17

GDI+ Zeichenfehler bei ARC
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo,
ich habe mal versucht ein Testprogramm auf GDI+ umzustellen, aber ich scheiter natürlich wieder an den Bögen :-(

Ich bin für jeden Tipp dankbar...

DaCoda 30. Sep 2024 02:17

AW: GDI+ Zeichenfehler bei ARC
 
Sollte ich eventuell doch mit Direct3D oder OpenGL machen, da ich später dann auch besser Skalieren und um XYZ rotieren könnte.

Was meint Ihr ? OpenGL oder Direct3D ?

himitsu 30. Sep 2024 03:10

AW: GDI+ Zeichenfehler bei ARC
 
Zitat:

Zitat von himitsu (Beitrag 1541217)
Vielleicht wird es aber "einfacher", wenn du SVG im Skia (TSkSvg/TSkPaintBox/TSkAnimatedPaintBox/TSkAnimatedImage) anstatt GDI (TCanvas/TBitmap/TImage/...) verwendets?

:roll:

Kas Ob. 30. Sep 2024 11:54

AW: GDI+ Zeichenfehler bei ARC
 
Hi,
@DacCoda why not using TGPGraphicsPath ?

TGPGraphicsPath should simplify your code, like a lot, as it is literally what you need and what you are simulating.

Is there something i am missing with it ?

DaCoda 30. Sep 2024 12:46

AW: GDI+ Zeichenfehler bei ARC
 
@Kas Ob,

Hi Kas, in this moment i have a full project with drawing on a TPaintBox.
Everything is ok, but i want to have AntiAliasing for the Lines. So i tried to make a changeover to GDI+
The Normal Lines (procedure DrawLine) is easy to chnage over.

but i'am struggeling on procedure DrawArc. The changeover is not working.
You can see it in the attached Source in the first Post.

For this moment i'am not ready to make it in 3D. I have to study first the Tutorials and so on...

But i need the Program now with functional GDI+ and i have no idea whats going wrong in the attached Test-App.

If the GDI+ Version works well, i will start to make 3D Stuff :-)

Kas Ob. 30. Sep 2024 13:15

AW: GDI+ Zeichenfehler bei ARC
 
Zitat:

Zitat von DaCoda (Beitrag 1541675)
@Kas Ob,

Hi Kas, in this moment i have a full project with drawing on a TPaintBox.
Everything is ok, but i want to have AntiAliasing for the Lines. So i tried to make a changeover to GDI+
The Normal Lines (procedure DrawLine) is easy to chnage over.

but i'am struggeling on procedure DrawArc. The changeover is not working.
You can see it in the attached Source in the first Post.

For this moment i'am not ready to make it in 3D. I have to study first the Tutorials and so on...

But i need the Program now with functional GDI+ and i have no idea whats going wrong in the attached Test-App.

If the GDI+ Version works well, i will start to make 3D Stuff :-)

I was talking about DrawArc and its problem !

Here some thoughts:
1) You can use TGPGraphicsPath then add it to your mixed (what ever) it is called, adding it is simple as
Delphi-Quellcode:
  Pen := TGPPen.Create(ColorRefToARGB(Color), 1.0);
  try
    Path := TGPGraphicsPath.Create;
    try  
      Path.AddArc(StartX, StartY, FScale * Cos(EndAngle), FScale * Sin(EndAngle), StartAngle, EndAngle); ///  THIS IS WRONG CALCULATION !!! JUST AN EXAMPLE
      Graphics.DrawPath(Pen, Path);
    finally
      Path.Free;
    end;
  finally
    Pen.Free;
  end;
The above is wrong and missing a lot it is just to show the ability to mixing directional arc into Graphics.

2) You don't need 3D to switch to GDI(+) in full, i might be missing or misunderstand your point here, but drawing in 2d is fine, and on top of that Path drawing is more consistent with what you are simulating, see.. DrawArc doesn't have a direction vector !, while AddArc from GraphicsPath::AddArc https://learn.microsoft.com/en-us/wi...real_real_real)
This what i meant by switching or using GraphicsPath, you remove the need for Counter/ClockWise handling.

3) AddArc and your DrawArc both need the Bounding Box, aka the rectangle for the the arc (width and height or rect), this a little bit complicated, as it need more calculation, explaining it is way easier by showing some formulas, so i tried to search and found a nice answer for this on StackOverflow, and it is well written and easy to understand, so read the answer here and adjust as you don't have the third point, but you will find these if..then..esle are crucial for your rect finding, of course after calculating the center of the circle of the arc :
https://stackoverflow.com/questions/...-box-of-an-arc

And good luck !

DaCoda 30. Sep 2024 14:02

AW: GDI+ Zeichenfehler bei ARC
 
Liste der Anhänge anzeigen (Anzahl: 1)
@Kas,

thank you for the info's. But at the end it will not the right solution with GDI+

Because i have a 2D Solution now, but i can't rotate it to see the steps (Deep) in the Z-Axis now.

So i have to Draw with all 3-Parameters (X, Y, and Z) with Scaling and rotation.
I think Spending time in 2Dis wasting of time...

But there is no way to make this in a Easy-Way for Dummies (Me) :lol:

Kas Ob. 30. Sep 2024 14:10

AW: GDI+ Zeichenfehler bei ARC
 
Liste der Anhänge anzeigen (Anzahl: 1)
I am sorry, i think i am completely in loss and misunderstood the question, as thought the problem in drawing arcs in GDI

I ran you test and this is screenshot of the result
Anhang 57162

So i was talking about fixing this arcs and their directional drawing :oops:

Sorry again !

DaCoda 30. Sep 2024 14:21

AW: GDI+ Zeichenfehler bei ARC
 
Dear Kas,

Zitat:

Zitat von Kas Ob. (Beitrag 1541681)
I am sorry, i think i am completely in loss and misunderstood the question, as thought the problem in drawing arcs in GDI

Yes you are right, the first post was based on GDI+ and your Answers where absolutely good for this Question.

But in the meantime i have realisized that i have to change over to Real-3D to have the functionality in future Steps.

However, your answers were completely correct and I am very grateful for your help.
But I think my own requirements, or my new thoughts for the future display with Z-coordinates, require real 3D.

DaCoda 30. Sep 2024 14:24

AW: GDI+ Zeichenfehler bei ARC
 
Somit ist dann dieser Thread erst einmal abgeschlossen und ich muss schauen wie ich das Projekt aus dem ersten Posting umändere zu echten 3D inklusive Z-Koordinaten.

Vielen Dank an Euch Alle, es hat mir sehr geholfen und ich habe dabei eben festgestellt, das ich mit 2D auf dem Holzweg bin... :-)


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:28 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz