Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drawing 20 planets with graphical commands
#5
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.
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
Reply


Messages In This Thread
RE: Drawing 20 planets with graphical commands - by bplus - 02-07-2026, 05:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  A drawing program Frederick 8 582 02-28-2026, 04:45 PM
Last Post: Frederick
  BallDraw - simple drawing programing using colored balls Dav 2 399 11-11-2025, 08:57 PM
Last Post: Dav
  Improved my small Gradient Ball drawing SUB Dav 22 5,395 07-13-2023, 05:23 PM
Last Post: Dav
  "Slower" Line Drawing Example James D Jarvis 2 1,146 05-13-2023, 03:56 PM
Last Post: James D Jarvis
  Simple drawing that fades to background. Dav 8 1,632 11-05-2022, 03:09 PM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)