How to draw a ring around a planet with just QB64. Basically draw the back half of the ellipse ring draw the planet then draw the front half of the ellipse ring.
If you are not familiar with Radians: to convert Degrees to Radians (ra = radian angle 0 to _Pi(2)) use D2R() function. Radians are just another scale system for angle measures and used for all trig functions as opposed to Degrees.
If you want to draw ellipse rings that are transparent, Steve's recent Ellipse.Arc.Ring stuff might work because he is using scan lines that dont overlap. That's what you need for transparencies without overlap (no stripes and you can see whats under the drawing). https://qb64phoenix.com/forum/showthread...1#pid34131
As OldMoses mentioned, you can tilt the ellipsii with Rotozoom (after putting the image like above into a contianer with an image handle eg Image below) x,y is your planet center, scale just use 1 for no shrink nor expanding and degreesRotation the angle to shift the ellipse to.
Code: (Select All)
Option _Explicit
_Title "Arc of Ellisps" 'b+ 2021-12-25
Dim sw, sh
sw = 600: sh = 600
Screen _NewImage(sw, sh, 32)
_ScreenMove 300, 200
ArcRingOfEllipse sw / 2, sh / 2, 120, 200, _Pi(0), _Pi(1), .25, &HFFAAAAFF
Ring sw / 2, sh / 2, 0, 85, &HFF880088
ArcRingOfEllipse sw / 2, sh / 2, 120, 200, _Pi(1), _Pi(1.999), .25, &HFFAAAAFF
Sub Ring (cx, cy, innerRadius, outerRadius, colr~&) ' wont work well with alpha's < 255
Dim r
For r = innerRadius To outerRadius Step .25
Circle (cx, cy), r, colr~&
Next
End Sub
'ra's here go Counter Clockwise from East
Sub ArcRing (cx, cy, innerRadius, outerRadius, raStart, raEnd, colr~&) ' ra's 0 to <2*pi (almost)
Dim r
For r = innerRadius To outerRadius Step .25
Circle (cx, cy), r, colr~&, raStart, raEnd
Next
End Sub
'ra's here go Counter Clockwise from East
Sub ArcRingOfEllipse (cx, cy, innerRadius, outerRadius, raStart, raEnd, aspect, colr~&) ' ra's 0 to <2*pi (almost)
Dim r
For r = innerRadius To outerRadius Step .25
Circle (cx, cy), r, colr~&, raStart, raEnd, aspect
Next
End Sub
If you are not familiar with Radians: to convert Degrees to Radians (ra = radian angle 0 to _Pi(2)) use D2R() function. Radians are just another scale system for angle measures and used for all trig functions as opposed to Degrees.
If you want to draw ellipse rings that are transparent, Steve's recent Ellipse.Arc.Ring stuff might work because he is using scan lines that dont overlap. That's what you need for transparencies without overlap (no stripes and you can see whats under the drawing). https://qb64phoenix.com/forum/showthread...1#pid34131
As OldMoses mentioned, you can tilt the ellipsii with Rotozoom (after putting the image like above into a contianer with an image handle eg Image below) x,y is your planet center, scale just use 1 for no shrink nor expanding and degreesRotation the angle to shift the ellipse to.
Code: (Select All)
Sub RotoZoom (X As Long, Y As Long, Image As Long, Scale As Single, degreesRotation As Single)
Dim px(3) As Single, py(3) As Single, W&, H&, sinr!, cosr!, i&, x2&, y2&
W& = _Width(Image&): H& = _Height(Image&)
px(0) = -W& / 2: py(0) = -H& / 2: px(1) = -W& / 2: py(1) = H& / 2
px(2) = W& / 2: py(2) = H& / 2: px(3) = W& / 2: py(3) = -H& / 2
sinr! = Sin(-degreesRotation / 57.2957795131): cosr! = Cos(-degreesRotation / 57.2957795131)
For i& = 0 To 3
x2& = (px(i&) * cosr! + sinr! * py(i&)) * Scale + X: y2& = (py(i&) * cosr! - px(i&) * sinr!) * Scale + Y
px(i&) = x2&: py(i&) = y2&
Next
_MapTriangle (0, 0)-(0, H& - 1)-(W& - 1, H& - 1), Image& To(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
_MapTriangle (0, 0)-(W& - 1, 0)-(W& - 1, H& - 1), Image& To(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
End Sub
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever

