Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
trouble filling in a closed vector shape
#21
Quote:Didn't really rewrite it, just renamed vars and minor tweaks to match my program.
 
If its working differently then something is different in the tweaks, thats just logic.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#22
@madscijr the reason the Colors are pale is that you are resetting plasma at every drawing frame! No, ResetPlasma once before you start the drawing down the screen. That sets a new pallet of colors called by formula instead of by an array of colors. Then ResetPlasma for another color set when the thing goes offscreen and you reset the other variables.

And you solved the problem of the FreeImage varaible.

OK onto next challnge with the lines I think...
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#23
(11-10-2025, 06:54 PM)madscijr Wrote:
(11-08-2025, 07:30 PM)bplus Wrote: @Petr you inspired me!
I have another question BPlus. My prog (see attached) uses Sub RotoLine (which uses Sub RotoZoom23d , or now Sub RotoZoom23d3  which I based on the updated RotoZoom in your vh logo program). 

Anyway, either way, I'm wondering how we might modify RotoLine and/or RotoZoom to get the stripes to extend all the way off the screen, so you don't see those corners at the end? 

I have tried messing with the variables but haven't found anything that worked. 

[Image: Roto-Line-question.png]

Any help or guidance much appreciated!

Sure! just isolate the code that draws the stripes so I don't have to wade through 4616 lines of BS.

I hope you are using Thickline and not rotozoom of any form. I think for that the image has to fit inside the screen. Thickline shouln't mind one bit drawing outside the screen border.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#24
Random ThickLines Across the Screen
Code: (Select All)
_Title "Random ThickLines crossing the screen" 'b+ 2025-11-10
Const SW = 1200, SH = 700
Dim Shared cN, pR, pG, pB, pA
Screen _NewImage(SW, SH, 32)
_ScreenMove 60, 20
Randomize Timer
Do Until _KeyDown(27)
    Color , &HFFFFFFFF
    Cls
    ResetPal
    For L = 1 To 40
        thick = Rnd * 40 + 10
        r = Int(Rnd * 6)
        Select Case r
            Case 0: x1 = -50: y1 = 25 + Rnd * (SH - 50): x2 = 25 + Rnd * (SW - 50): y2 = -50
            Case 1: x1 = 25 + Rnd * (SW - 50): y1 = -50: x2 = SW + 50: y2 = 25 + Rnd * (SH - 50)
            Case 2: x1 = SW + 50: y1 = 25 + Rnd * (SH - 50): x2 = 25 + Rnd * (SW - 50): y2 = SH + 50
            Case 3: x1 = 25 + Rnd * (SW - 50): y1 = SH + 50: x2 = -50: y2 = 25 + Rnd * (SH - 50)
            Case 4: x1 = -50: y1 = 25 + Rnd * (SH - 50): x2 = SW + 50: y2 = 25 + Rnd * (SH - 50)
            Case 5: x1 = 25 + Rnd * (SW - 50): y1 = -50: x2 = 25 + Rnd * (SW - 50): y2 = SH + 50
        End Select
        thic x1, y1, x2, y2, thick, Pal~&
    Next
    _Display
    _Limit 1
Loop

'update 2020-01-24 to include PD2 inside the sub
Sub thic (x1, y1, x2, y2, thick, K As _Unsigned Long)
    Dim PD2 As Double, t2 As Single, a As Single, x3 As Single, y3 As Single, x4 As Single, y4 As Single
    Dim x5 As Single, y5 As Single, x6 As Single, y6 As Single
    PD2 = 1.570796326794897
    t2 = thick / 2
    If t2 < 1 Then t2 = 1
    a = _Atan2(y2 - y1, x2 - x1)
    x3 = x1 + t2 * Cos(a + PD2)
    y3 = y1 + t2 * Sin(a + PD2)
    x4 = x1 + t2 * Cos(a - PD2)
    y4 = y1 + t2 * Sin(a - PD2)
    x5 = x2 + t2 * Cos(a + PD2)
    y5 = y2 + t2 * Sin(a + PD2)
    x6 = x2 + t2 * Cos(a - PD2)
    y6 = y2 + t2 * Sin(a - PD2)
    ftri x6, y6, x4, y4, x3, y3, K
    ftri x3, y3, x5, y5, x6, y6, K
End Sub

''   BEST saves dest and optimized with Static a& and alpha colors work better
'2019-12-16 fix by Steve saves some time with STATIC and saves and restores last dest
Sub ftri (x1, y1, x2, y2, x3, y3, K As _Unsigned Long)
    Dim D As Long
    Static a&
    D = _Dest
    If a& = 0 Then a& = _NewImage(1, 1, 32)
    _Dest a&
    _DontBlend a& '  '<<<< new 2019-12-16 fix
    PSet (0, 0), K
    _Blend a& '<<<< new 2019-12-16 fix
    _Dest D
    _MapTriangle _Seamless(0, 0)-(0, 0)-(0, 0), a& To(x1, y1)-(x2, y2)-(x3, y3)
End Sub

Function Pal~& ()
    cN = cN + 1 ''Dim Shared cN, pR, pG, pB, pA
    Pal~& = _RGB32(127 + 127 * Sin(pR * cN), 127 + 127 * Sin(pG * cN), 127 + 127 * Sin(pB * cN), 127 + 127 * Sin(pA * cN))
End Function

Sub ResetPal ()
    ''Dim Shared cN, pR, pG, pB, pA
    pR = Rnd ^ 2: pG = Rnd ^ 2: pB = Rnd ^ 2: pA = Rnd: cN = 0
End Sub

I tried Steves Thickline routine that madscijr was using but it left lines where the traingles intersect sometimes when using transparent colors, so back to my version because I was also trying Petr's suggestion to try Alpha Coloring with the Coloring set that I use to call Plasma but now call Pal~&, pal as in short for palette.

   
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#25
Thanks - that's very nice! 
I was actually using RotoLine and not ThickLine (just never deleted the routine from my code, but never called it). 
I will give your code a look when back at PC and try not to ask any dumb questions, LoLz
Reply
#26
(11-10-2025, 09:48 PM)bplus Wrote: @madscijr the reason the Colors are pale is that you are resetting plasma at every drawing frame! No, ResetPlasma once before you start the drawing down the screen. That sets a new pallet of colors called by formula instead of by an array of colors. Then ResetPlasma for another color set when the thing goes offscreen and you reset the other variables.
Ah... OK that was definitely my mistake. Thanks for explaining, B!
Reply
#27
(11-11-2025, 12:51 AM)bplus Wrote:
Code: (Select All)
''   BEST saves dest and optimized with Static a& and alpha colors work better
'2019-12-16 fix by Steve saves some time with STATIC and saves and restores last dest
Sub ftri (x1, y1, x2, y2, x3, y3, K As _Unsigned Long)
    Dim D As Long
    Static a&
    D = _Dest
    If a& = 0 Then a& = _NewImage(1, 1, 32)
    _Dest a&
    _DontBlend a& '  '<<<< new 2019-12-16 fix
    PSet (0, 0), K
    _Blend a& '<<<< new 2019-12-16 fix
    _Dest D
    _MapTriangle _Seamless(0, 0)-(0, 0)-(0, 0), a& To(x1, y1)-(x2, y2)-(x3, y3)
End Sub
I do have a question about this - so it creates a new image in the static variable a& - where is that image ever freed? 
Does QB64PE do that automatically when the program ends?
Reply
#28
Yes, a& is preserved throughout the program until program ends to save time with each call to ftri (= fill triangle).
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#29
(11-11-2025, 01:01 PM)bplus Wrote: Yes, a& is preserved throughout the program until program ends to save time with each call to ftri (= fill triangle).
That's fine - and thanks. Just one general QB64PE question - should I free image for a& when the program ends, or is that kind of cleanup done automatically?
Reply
#30
Honestly I don't know what the official way would be. I never worried about it and just assumed its all cleaned up when the program ends. I have been using it for years and ha e nev r ha  a pr ble   ith i . Wink


BTW that was Steve's idea (along with the blend, dont blend) so blame him if it ain't right though he never said one way or other about cleanup of that routine at the end of the program. Come to think of it, how would you do that? Originally I was freeing the image before exiting the routine and that worked fine too, so if you are truely worried you could go back to that if only for peace of mind.

BTW #2 using _MapTriangle was someone else suggestion at old .net whom I'd like to thank because this is one of the most useful tricks I've ever run across. What a neat way to get filled triangles! My old version was hairy as hell trying to get all the lines in without overlap for nice transparent colored triangle.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  simple 3d starfield & wireframe or vector graphics revisited madscijr 5 263 01-31-2026, 09:41 PM
Last Post: Pete
  trouble building ansiprint by a740g hsiangch_ong 2 578 01-09-2025, 12:57 AM
Last Post: hsiangch_ong
  Having trouble Windows command line SORT via SHELL GTC 19 4,367 08-26-2023, 04:19 AM
Last Post: GTC
  How do I paint a shape? PhilOfPerth 21 3,921 06-28-2023, 10:09 PM
Last Post: TempodiBasic
Photo Ellipse trouble james2464 14 2,998 08-25-2022, 10:52 PM
Last Post: james2464

Forum Jump:


Users browsing this thread: 1 Guest(s)