QB64 Phoenix Edition
Do you _MAPTRIANGLE? - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1)
+--- Forum: QBJS, BAM, and Other BASICs (https://staging.qb64phoenix.com/forumdisplay.php?fid=50)
+--- Thread: Do you _MAPTRIANGLE? (/showthread.php?tid=1564)

Pages: 1 2


RE: Do you _MAPTRIANGLE? - Gets - 03-25-2023

If you have a 100x100 image, you can treat it like a 1000x100 image and draw it 10 times with one command... or two commands since you need two triangles. I checked the wiki to see if the feature was described, and I think a comment about achieving a  "tiling effect" was the only reference to it.

I mainly use it for scrolling backgrounds, but here's an example of how it works:

Code: (Select All)
scr = _NewImage(1000, 600, 32)

Screen scr


'DRAW SINGLE SMALL TILE

'---------------------

img = _NewImage(40, 100, 32)

_Dest img

Line (0, 0)-(20, 50), _RGB32(128, 0, 0), BF
Line (21, 0)-(40, 50), _RGB32(255, 0, 0), BF
Line (21, 51)-(40, 100), _RGB32(128, 0, 0), BF
Line (0, 51)-(20, 100), _RGB32(255, 0, 0), BF

'----------------------


'FILL ENTIRE SCREEN WITH MAPTRIANGLE

_MapTriangle (0, 0)-(1000, 0)-(0, 600), img To(0, 0)-(1000, 0)-(0, 600), scr
_MapTriangle (0, 600)-(1000, 600)-(1000, 0), img To(0, 600)-(1000, 600)-(1000, 0), scr



RE: Do you _MAPTRIANGLE? - Petr - 03-25-2023

How about a round magnifying glass effect?

Code: (Select All)
i& = _ScreenImage

_Delay .5
Screen _NewImage(_DesktopWidth, _DesktopHeight, 32)

stp = _Pi(2) / 30

While i$ <> Chr$(27)
    While _MouseInput: Wend
    mx = _MouseX
    my = _MouseY
    i$ = InKey$
    _PutImage , i&
    For c = 0 To _Pi(2) Step stp
        sx = mx + Cos(c) * 30
        sy = my + Sin(c) * 30
        sx2 = mx + Cos(c + stp) * 30
        sy2 = my + Sin(c + stp) * 30

        dx = mx + Cos(c) * 90
        dy = my + Sin(c) * 90
        dx2 = mx + Cos(c + stp) * 90
        dy2 = my + Sin(c + stp) * 90

        _MapTriangle (mx, my)-(sx, sy)-(sx2, sy2), i& To(mx, my)-(dx, dy)-(dx2, dy2), 0, _Smooth
    Next c
    _Display
Wend



RE: Do you _MAPTRIANGLE? - Petr - 03-25-2023

You can do different effects with it...

Code: (Select All)
i& = _ScreenImage

_Delay .5
Screen _NewImage(_DesktopWidth, _DesktopHeight, 32)

stp = _Pi(2) / 30
ir = 4
vr = 7



While i$ <> Chr$(27)
    i$ = InKey$
    _PutImage , i&
    mx = _DesktopWidth / 2
    my = _DesktopHeight / 2
    For c = 0 To _Pi(2) Step stp
        sx = mx + Cos(c) * ir
        sy = my + Sin(c) * ir
        sx2 = mx + Cos(c + stp) * ir
        sy2 = my + Sin(c + stp) * ir

        dx = mx + Cos(c) * vr
        dy = my + Sin(c) * vr
        dx2 = mx + Cos(c + stp) * vr
        dy2 = my + Sin(c + stp) * vr

        _MapTriangle (mx, my)-(sx, sy)-(sx2, sy2), i& To(mx, my)-(dx, dy)-(dx2, dy2), 0, _Smooth
    Next c
    ir = ir + 3
    vr = vr + 2
    _FreeImage i&
    i& = _CopyImage(0, 32)
    _Display
    _Limit 20
Wend



RE: Do you _MAPTRIANGLE? - dbox - 03-25-2023

Excellent, thanks for the examples!  I’ll add them to the test cases.


RE: Do you _MAPTRIANGLE? - bplus - 03-25-2023

Cool! That checkered thing surprised me! I was expecting a Full Screen 4 checkers image.


RE: Do you _MAPTRIANGLE? - dbox - 03-27-2023

Thank you to everyone that participated in this survey and provided examples!  Based on the feedback that's been received I've learned the following:
  1. Most people don't answer surveys.
    This not an effective way to measure utilization of a particular feature.

  2. _MapTriangle is used a lot for doing higher level 2D graphics functions that there are not specific QB64 functions for (e.g. RotoZoom, FillTriangle).
    I'm looking at adding an extended 2D graphics library for QBJS that will provide native support for these and a few other high-level graphics methods.

  3. People who use the 3D version of _MapTriangle operate on a plane beyond surveys.

   


RE: Do you _MAPTRIANGLE? - Petr - 03-27-2023

The option was missing - I use both, always as needed.