Everything else that doesn't fall into one of the other PB categories.
Ollivier
Enthusiast
Posts: 281 Joined: Mon Jul 23, 2007 8:30 pm
Location: FR
Post
by Ollivier » Sat Sep 01, 2007 10:26 am
Code: Select all
xCenter FLOAT (pixel)
yCenter FLOAT (pixel)
xRadius FLOAT (pixel)
yRadius FLOAT (pixel)
zRotation FLOAT (rad)
StartAngle FLOAT (rad)
FinishAngle FLOAT (rad)
Code: Select all
Procedure EllipseWithRotation(xCenter.F, yCenter.F, xRadius.F, yRadius.F, zRotation.F, StartAngle.F, FinishAngle.F, Color.L)
Protected Angle.F
Protected AngleStep.F
Protected X.F
Protected Y.F
Protected DisplayX.F
Protected DisplayY.F
Protected GreatestRadius.F
If xRadius > yRadius
GreatestRadius.F = xRadius
Else
GreatestRadius = yRadius
EndIf
AngleStep.F = #PI / GreatestRadius
NewList DrawX.POINT()
Angle = StartAngle
Repeat
X.F = Cos(Angle) * xRadius ; Draw an ellipse...
Y.F = -Sin(Angle) * yRadius
DisplayX.F = X * Cos(zRotation) - Y * Sin(zRotation) ; Rotation...
DisplayY.F = X * Sin(zRotation) + Y * Cos(zRotation)
AddElement(DrawX() ) ; Record...
DrawX()\X = xCenter + DisplayX
DrawX()\Y = yCenter + DisplayY
Angle + AngleStep
Until Angle > FinishAngle
ResetList(DrawX() ) ; Draw...
For i = 1 To CountList(DrawX() ) - 1
SelectElement(DrawX(), i - 1)
x1 = DrawX()\X
y1 = DrawX()\Y
SelectElement(DrawX(), i)
x2 = DrawX()\X
y2 = DrawX()\Y
LineXY(x1, y1, x2, y2, Color)
Next
ClearList(DrawX() )
EndProcedure
Nice day!
dell_jockey
Enthusiast
Posts: 767 Joined: Sat Jan 24, 2004 6:56 pm
Post
by dell_jockey » Sat Sep 01, 2007 11:29 am
Look Ma! No API....
Well done, thanks a lot Ollivier! Your usage of lists forces me to re-think parts of an application that I'm currently developing. Thanks again.
Ollivier
Enthusiast
Posts: 281 Joined: Mon Jul 23, 2007 8:30 pm
Location: FR
Post
by Ollivier » Sat Sep 01, 2007 11:44 am
Indeed, lists offer many possibilities
Ollivier
Enthusiast
Posts: 281 Joined: Mon Jul 23, 2007 8:30 pm
Location: FR
Post
by Ollivier » Sat Sep 01, 2007 12:00 pm
2 Xombie (or somebody who knows the answer)
What is 'anti-aliased' ???
Ollivier
Enthusiast
Posts: 281 Joined: Mon Jul 23, 2007 8:30 pm
Location: FR
Post
by Ollivier » Sat Sep 01, 2007 12:57 pm
So, reading the wikipedia's article, I think I answer Xombie enough correctly... With a list! He'll have just to manage the 2 lines 'NewList' and 'ClearList' to recuperate coordonates x and y arcs...
Thanks
Xombie
Addict
Posts: 898 Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:
Post
by Xombie » Sat Sep 01, 2007 8:11 pm
Thanks, everyone! I'm excited to try this out tonight and see what kind of damage I can do.
So, yes, thanks again for being patient with me even though I'm quite slow at stuff like this :p
Thanks again, Ollivier, Helle and Kaeru Gaman!
Trond
Always Here
Posts: 7446 Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway
Post
by Trond » Sun Sep 02, 2007 9:05 am
Is there any reason you don't use the API function Arc_()?
Xombie
Addict
Posts: 898 Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:
Post
by Xombie » Sun Sep 02, 2007 9:38 pm
@Trond - because GDI+ and the Arc_() command are both bound by a rectangle which means the ellipse is either elongated on the x or y axis. I need to set the elongated edge around the z axis, if that makes sense. It's for a silly little program that I'm working on on the side ^_^
@Ollivier - it works although I had to scare up a quick old memory on coordinate systems to vaguely remember something about degrees and radians
I especially like being able to have points available as I was hoping to color different parts different colors.
Thanks so much!
Trond
Always Here
Posts: 7446 Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway
Post
by Trond » Sun Sep 02, 2007 9:43 pm
Xombie wrote: @Trond - because GDI+ and the Arc_() command are both bound by a rectangle which means the ellipse is either elongated on the x or y axis. I need to set the elongated edge around the z axis, if that makes sense. It's for a silly little program that I'm working on on the side ^_^
Did you try RotateDC_()?
Xombie
Addict
Posts: 898 Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:
Post
by Xombie » Tue Sep 04, 2007 1:14 am
I haven't heard of RotateDC_() and it doesn't seem to show up on MSDN.
Do you have links to any more information?
Thanks!
Trond
Always Here
Posts: 7446 Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway
Post
by Trond » Tue Sep 04, 2007 4:51 pm
Sorry, RotateDC() was I function I had written myself. I meant SetWorldTransform_().
Code: Select all
Procedure RotateDC(hDC.l, x0.l, y0.l, Degrees.d)
Static XFORM.XFORM
Protected Radians.d = Degrees*(#PI/180)
With XFORM
\eM11 = Cos(Radians)
\eM12 = Sin(Radians)
\eM21 = -\eM12
\eM22 = \eM11
\ex = x0 - Cos(Radians)*x0 + Sin(Radians)*y0
\ey = y0 - Cos(Radians)*y0 - Sin(Radians)*x0
EndWith
SetGraphicsMode_(hDC, #GM_ADVANCED)
SetWorldTransform_(hDC, XFORM)
EndProcedure
Ollivier
Enthusiast
Posts: 281 Joined: Mon Jul 23, 2007 8:30 pm
Location: FR
Post
by Ollivier » Tue Sep 04, 2007 5:30 pm
2Trond
Have you got an example of using RotateDC() ?
What is XFORM structure?
Trond
Always Here
Posts: 7446 Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway
Post
by Trond » Tue Sep 04, 2007 6:32 pm
Code: Select all
Procedure RotateDC(hDC.l, x0.l, y0.l, Degrees.d)
Static XFORM.XFORM
Protected Radians.d = Degrees*(#PI/180)
With XFORM
\eM11 = Cos(Radians)
\eM12 = Sin(Radians)
\eM21 = -\eM12
\eM22 = \eM11
\eDx = x0 - Cos(Radians)*x0 + Sin(Radians)*y0
\eDy = y0 - Cos(Radians)*y0 - Sin(Radians)*x0
EndWith
SetGraphicsMode_(hDC, #GM_ADVANCED)
SetWorldTransform_(hDC, XFORM)
EndProcedure
OpenWindow(0, 0, 0, 384, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
Repeat
Select WaitWindowEvent()
Case #PB_Event_Repaint
hDC = StartDrawing(WindowOutput(0))
Line(100, 100, 200, 0, #Red)
RotateDC(hDC, WindowWidth(0)/2, WindowHeight(0)/2, 90)
Line(100, 100, 200, 0, #Blue)
RotateDC(hDC, WindowWidth(0)/2, WindowHeight(0)/2, 180)
Line(100, 100, 200, 0, #Green)
StopDrawing()
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
Ollivier
Enthusiast
Posts: 281 Joined: Mon Jul 23, 2007 8:30 pm
Location: FR
Post
by Ollivier » Tue Sep 04, 2007 8:15 pm
To run your code, I replaced the 2 lines
Code: Select all
\eDx = x0 - Cos(Radians)*x0 + Sin(Radians)*y0
\eDy = y0 - Cos(Radians)*y0 - Sin(Radians)*x0
with
Code: Select all
\ex = x0 - Cos(Radians)*x0 + Sin(Radians)*y0
\ey = y0 - Cos(Radians)*y0 - Sin(Radians)*x0
It's exactly what Xombie could use with the API Ellipse drawing function!
But I ignore the XFORM structure. Has it other variables. Its variables are they in function of the functions using it, or do they have a independant mean?