polyFT in QBJS - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: QBJS, BAM, and Other BASICs (https://qb64phoenix.com/forum/forumdisplay.php?fid=50) +--- Thread: polyFT in QBJS (/showthread.php?tid=1983) Pages:
1
2
|
polyFT in QBJS - James D Jarvis - 09-09-2023 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] RE: polyFT in QBJS - bplus - 09-09-2023 I added fTri routine and put the 100 polys in a loop: Jarvis polyFT demo QBJS tags not working This won't work in QB64 but is code for above: Code: (Select All) Randomize Timer RE: polyFT in QBJS - James D Jarvis - 09-09-2023 neat. my older QB64 version uses _maptriangle . I haven't seen ftri yet. RE: polyFT in QBJS - grymmjack - 09-10-2023 (09-09-2023, 11:16 PM)James D Jarvis Wrote: 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. Gotta use qb tag for pasting literal code not qbjs for qbjs share. For qbjs use share link from qbjs.org and then qbjs bbcode. Like @bplus did. Looks cool so far! RE: polyFT in QBJS - bplus - 09-10-2023 (09-09-2023, 11:51 PM)James D Jarvis Wrote: neat. my older QB64 version uses _maptriangle . I haven't seen ftri yet. Yes I have fTri (Fill Triangle) in my drawing tools https://qb64phoenix.com/forum/showthread.php?tid=272&pid=1204#pid1204 (as filltri because several versions of fill triangle in there.) I have been using it for filling triangles for the pumpkin in my Fall Banner code. I also showed it to Charlie for his polygon fill because he doesn't have _MapTriangle either. Very handy for Basics without _MapTriangle. @grymmjack this is 2nd instance where a link to my mini-mod board thread takes me to bottom of page of that thread and inside forum editor when I am logged in. But works correctly when I am logged out. RE: polyFT in QBJS - dbox - 09-10-2023 James, I thought your original version looked great that used G2D.FillTriange: What was the issue? If you want to adjust the line width you can use the G2D.LineWidth method. I added it to your program, you can uncomment it to play with different line widths. RE: polyFT in QBJS - James D Jarvis - 09-10-2023 (09-10-2023, 04:21 AM)dbox Wrote: James, I thought your original version looked great that used G2D.FillTriange: Thanks. If you crank up the line width to just say 4 or 5 pixels you'll notice a gap in the line segments on the outline with the routine I used. When I did this in QB64 I used a custom fat-line routine that used filled circles to draw lines and as such there was always overlap at endpoints due to how the line segments were drawn. There may be fancier ways to draw those line with the graphics library in QBJS that I am just unaware of at this point. Is there a continuous line plot I just didn't notice yet, how's the end-cap work on line segments? RE: polyFT in QBJS - bplus - 09-10-2023 Oh Fill triangle was available in QBJS G2D. library, missed it. Here is link to QBJS keywords to bookmark: https://github.com/boxgaming/qbjs/wiki/Supported-Keywords#qbjs-standard-modules RE: polyFT in QBJS - dbox - 09-10-2023 Ah, there are a couple of additional line cap styles you can use with the G2D.LineCap method. Here it is with the round cap style: RE: polyFT in QBJS - grymmjack - 09-10-2023 (09-10-2023, 03:11 AM)bplus Wrote:(09-09-2023, 11:51 PM)James D Jarvis Wrote: neat. my older QB64 version uses _maptriangle . I haven't seen ftri yet. Turn off the editor at the bottom. It’ll stop. I posted the solution in another thread. Press the little switch on the bottom of the editor. It will hide it. Then you won’t autofocus to it. This only seems to happen when the default editor is source mode. |