Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
trouble filling in a closed vector shape
#7
I don't know if I understood correctly, but is it just about coloring the logo? If so, here is a simpler and faster solution. You do need an image, but it can also be easily converted directly into the source code.

In this example, you don't calculate anything at all. You use the image as a mask, according to which you then change the pixel color value with the _Mem command. It's much faster than calculating something and then coloring it.
If is needed coloring those shapes that are created with the Line command as vectors, so you can't use transparency there (for POINT) but this could be solved with the _MapTriangle command, where you map one pixel with transparency to three points. That then works the same as if you were coloring it, but it's much faster. I haven't studied this part of the program... I've already chosen my vacation, sorry.

Code: (Select All)


logo$ = "VHLogo.png"
Dim logo As Long
logo = _LoadImage(logo$, 32)
Const TotalLogos = 50

Dim As _MEM m, n
Dim NewColor As _Unsigned Long, Black As _Unsigned Long
Black = _RGB32(0)
Type LogoPos
    As Integer X, Y
    Handle As Long
    As Single Zoom, Xstep, Ystep
End Type
Dim ColoredLogo(1 To TotalLogos) As LogoPos
W = _Width(logo)
H = _Height(logo)
For EmptyImages = 1 To TotalLogos
    ColoredLogo(EmptyImages).Handle = _NewImage(W, H, 32)
Next
Virtual = _NewImage(W, H, 32)
m = _MemImage(logo)
n = _MemImage(Virtual)

'fill start values and logo colors
For Logos = 1 To TotalLogos
    NewColor = _RGBA32(255 * Rnd, 255 * Rnd, 255 * Rnd, 255 * Rnd)
    Do Until i& = m.SIZE - 4
        If _MemGet(m, m.OFFSET + i&, _Unsigned Long) = Black Then _MemPut n, n.OFFSET + i&, NewColor
        i& = i& + 4
    Loop
    i& = 0
    ColoredLogo(Logos).Handle = _CopyImage(Virtual, 32)
    _MemFill n, n.OFFSET, n.SIZE, 0 As _UNSIGNED LONG
    ColoredLogo(Logos).X = Rnd * 1024
    ColoredLogo(Logos).Y = Rnd * -H
    ColoredLogo(Logos).Zoom = (1 + Rnd * 10) / 15
    If Rnd * 10 > 3 Then o = -1 Else o = 1
    ColoredLogo(Logos).Xstep = (1 + Rnd * 3) / 2 * o
    ColoredLogo(Logos).Ystep = (1 + Rnd * 10) / 1.5

    If ColoredLogo(Logos).Y > -H * ColoredLogo(Logos).Zoom Then ColoredLogo(Logos).Y = -H * ColoredLogo(Logos).Zoom - 200
Next


Screen _NewImage(1024, 768, 32)

L = 0
Do Until _KeyHit
    L = L + 1
    If L > TotalLogos Then
        L = 1
        _Display
        _Limit 20
        Cls
    End If

    ColoredLogo(L).X = ColoredLogo(L).X + ColoredLogo(L).Xstep
    ColoredLogo(L).Y = ColoredLogo(L).Y + ColoredLogo(L).Ystep

    If ColoredLogo(L).Y > 768 + H Or ColoredLogo(L).X > 1024 + W Or ColoredLogo(L).X < -W Then 'restart logo if is out
        i& = 0
        _FreeImage ColoredLogo(L).Handle
        NewColor = _RGBA32(255 * Rnd, 255 * Rnd, 255 * Rnd, 255 * Rnd)
        Do Until i& = m.SIZE - 4
            If _MemGet(m, m.OFFSET + i&, _Unsigned Long) = Black Then _MemPut n, n.OFFSET + i&, NewColor
            i& = i& + 4
        Loop
        i& = 0
        ColoredLogo(L).Handle = _CopyImage(Virtual, 32)
        _MemFill n, n.OFFSET, n.SIZE, 0 As _UNSIGNED LONG
        ColoredLogo(L).X = Rnd * 1024
        ColoredLogo(L).Y = Rnd * -H
        ColoredLogo(L).Zoom = (1 + Rnd * 10) / 15
        If Rnd * 10 > 3 Then o = -1 Else o = 1        
        ColoredLogo(L).Xstep = (1 + Rnd * 3) / 2 * o
        ColoredLogo(L).Ystep = (1 + Rnd * 10) / 1.5
        If ColoredLogo(L).Y > -H * ColoredLogo(L).Zoom Then ColoredLogo(L).Y = -H * ColoredLogo(L).Zoom - 200
    End If
    r = W * ColoredLogo(L).Zoom
    _PutImage (ColoredLogo(L).X, ColoredLogo(L).Y)-(ColoredLogo(L).X + r, ColoredLogo(L).Y + r), ColoredLogo(L).Handle, 0
Loop


[Image: VHLogo.png]


Reply


Messages In This Thread
RE: trouble filling in a closed vector shape - by Petr - 11-08-2025, 05:32 PM

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

Forum Jump:


Users browsing this thread: 1 Guest(s)