Posts: 19
Threads: 0
Joined: Apr 2022
Reputation:
4
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
Posts: 248
Threads: 44
Joined: May 2022
Reputation:
28
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
Posts: 248
Threads: 44
Joined: May 2022
Reputation:
28
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
Posts: 272
Threads: 24
Joined: Apr 2022
Reputation:
59
Excellent, thanks for the examples! I’ll add them to the test cases.
Posts: 3,974
Threads: 177
Joined: Apr 2022
Reputation:
219
03-25-2023, 07:57 PM
Cool! That checkered thing surprised me! I was expecting a Full Screen 4 checkers image.
b = b + ...
Posts: 272
Threads: 24
Joined: Apr 2022
Reputation:
59
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:
- Most people don't answer surveys.
This not an effective way to measure utilization of a particular feature.
- _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.
- People who use the 3D version of _MapTriangle operate on a plane beyond surveys.
Posts: 248
Threads: 44
Joined: May 2022
Reputation:
28
The option was missing - I use both, always as needed.
|