Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
polyFT in QBJS
#1
polyFT almost working in QBJS.  I just haven't figured out how to make it look good with thicker lines using the 2d graphic library functions yet but it is working with lines of one pixel thick.

[qbjs]'polyFT in QBjs
'v 0.5
'haven't quite figure out how to make the this look good with thicker lines but it works fine at one pixel wide
Import G2D From "lib/graphics/2d.bas"

Randomize Timer
For i = 0 to 100
polyFT Rnd * 640, Rnd * 400,rnd*30+30,int(3+rnd*12),int(rnd*360),_rgb32(int(rnd*256),int(rnd*256),int(rnd*256)),_rgb32(int(rnd*256),int(rnd*256),int(rnd*256))
_Limit 200
Next i


Sub polyFT (cx As Long, cy As Long, rad As Long, sides As Integer, rang As Long, klr As _Unsigned Long, lineyes As _Unsigned Long)
    'draw an equilateral polygon using filled triangle for each segment
    'centered at cx,cy to radius rad of sides # of face rotated to angle rang of color klr and lineyes if there is an outline, a value 0 would create no outline
    Dim px(sides)
    Dim py(sides)
    pang = 360 / sides
    ang = 0
    For p = 1 To sides
        px(p) = cx + (rad * Cos(0.01745329 * (ang + rang)))
        py(p) = cy + (rad * Sin(0.01745329 * (ang + rang)))
        ang = ang + pang
    Next p
    For p = 1 To sides - 1
    line (cx,cy)-(px(p),py(p)),klr
    G2D.FillTriangle cx,cy,px(p),py(p),px(p+1),py(p+1),klr
    Next p
    line (cx,cy)-(px(sides),py(sides)),klr
    G2D.FillTriangle cx,cy,px(sides),py(sides),px(1),py(1),klr
  if lineyes>0 then
  for p =1 to sides-1
    Line (px(p), py(p))-(px(p + 1), py(p + 1)), lineyes
  next
  Line (px(sides), py(sides))-(px(1), py(1)), lineyes
  end if
End Sub[/qbjs]
Reply


Messages In This Thread
polyFT in QBJS - by James D Jarvis - 09-09-2023, 11:16 PM
RE: polyFT in QBJS - by bplus - 09-09-2023, 11:31 PM
RE: polyFT in QBJS - by James D Jarvis - 09-09-2023, 11:51 PM
RE: polyFT in QBJS - by grymmjack - 09-10-2023, 12:33 AM
RE: polyFT in QBJS - by bplus - 09-10-2023, 03:11 AM
RE: polyFT in QBJS - by grymmjack - 09-10-2023, 05:11 PM
RE: polyFT in QBJS - by dbox - 09-10-2023, 04:21 AM
RE: polyFT in QBJS - by James D Jarvis - 09-10-2023, 01:55 PM
RE: polyFT in QBJS - by bplus - 09-10-2023, 02:17 PM
RE: polyFT in QBJS - by dbox - 09-10-2023, 02:21 PM
RE: polyFT in QBJS - by James D Jarvis - 09-10-2023, 06:27 PM
RE: polyFT in QBJS - by bplus - 09-10-2023, 05:18 PM



Users browsing this thread: 3 Guest(s)