Posts: 159
Threads: 10
Joined: Apr 2022
Reputation:
32
03-20-2023, 10:30 PM
(This post was last modified: 03-20-2023, 10:32 PM by dbox.)
I've been working on adding _MapTriangle to QBJS and it's got me curious about usage of this method by the community. _MapTriangle is an interesting and powerful function... it's really two different functions in one. There is a 2D version which takes (x, y) points and a 3d version which takes true 3d (x, y, z) coordinates which are relative to the screen size.
So, do you _MapTriangle?
Posts: 2,700
Threads: 124
Joined: Apr 2022
Reputation:
134
03-20-2023, 11:30 PM
(This post was last modified: 03-20-2023, 11:31 PM by bplus.)
My 2 main uses:
1. Yes for RotoZoom 2D
2. But even before that I used for Filled Triangles
I am not seeing my category.
b = b + ...
Posts: 159
Threads: 10
Joined: Apr 2022
Reputation:
32
Sounds like you are option 2 since you use the 2d version for more than RotoZoom.
Posts: 545
Threads: 116
Joined: Apr 2022
Reputation:
39
It's darn handy in rotozoom but I also use it to fill areas without using paint. It's pretty quick and I don't have to worry about bleeding outside a boundary by accident.
Posts: 159
Threads: 10
Joined: Apr 2022
Reputation:
32
Based on his recent post it looks like Petr would be in the 3d version camp. Nice example Petr!
Posts: 159
Threads: 10
Joined: Apr 2022
Reputation:
32
(03-21-2023, 01:29 PM)James D Jarvis Wrote: It's darn handy in rotozoom but I also use it to fill areas without using paint. It's pretty quick and I don't have to worry about bleeding outside a boundary by accident.
Thanks for the feedback James. Do you have any sample code where you've used it for filling areas instead of Paint?
Posts: 545
Threads: 116
Joined: Apr 2022
Reputation:
39
(03-21-2023, 06:32 PM)dbox Wrote: (03-21-2023, 01:29 PM)James D Jarvis Wrote: It's darn handy in rotozoom but I also use it to fill areas without using paint. It's pretty quick and I don't have to worry about bleeding outside a boundary by accident.
Thanks for the feedback James. Do you have any sample code where you've used it for filling areas instead of Paint?
sure, here's an example:
Code: (Select All) 'imperfect false grid, doesn't work perfectly but it's an example of using _maptriangle to "paint"
Screen _NewImage(800, 500, 32)
'prepare the fill triangle
t& = _NewImage(9, 9, 32)
_Dest t&
Paint (2, 2), _RGB32(200, 200) 'i use paint here because it only gets called once and I wouldn't remember what is going on otherwise
_Dest 0
_DontBlend 0
'get the maze ready
maxx = 61
maxy = 41
Dim grid(0 To maxx + 1, 0 To maxy + 1, 1 To 2)
Dim map(0 To maxx + 1, 0 To maxy + 1)
Do
Cls
'make flasegrid
ybias = 0
trend = Int(-1 + Rnd * 3)
For y = 0 To maxy + 1
trend = Int(-2 + Rnd * 5)
For x = 0 To maxx + 1
ybias = ybias + ((trend * (Rnd * 6)) / 30)
grid(x, y, 1) = x * 10 + Int(Rnd * 4) - Int(Rnd * 4)
grid(x, y, 2) = Int(y * 10 + Int(Rnd * 4) - Int(Rnd * 4) + ybias)
map(x, y) = 1
Next x
Next y
'drunk wandering maze
sx = 4 + Int(Rnd * (maxx - 4))
sy = 4 + Int(Rnd * (maxy - 4))
lastgo = Int(1 + Rnd * 4)
drun = Int(1 + Rnd * 4)
For c = 1 To 1800
dgo = Int(1 + Rnd * 6)
If dgo = 6 Then drun = Int(1 + Rnd * 4)
If dgo > 4 Then dgo = lastgo
Select Case dgo
Case 1
If sy - drun > 1 Then
For ny = sy To sy - drun Step -1
map(sx, ny) = 0
sy = ny
Next ny
End If
c = c + drun
Case 2
If sx + drun < maxx - 1 Then
For nx = sx To sx + drun
map(nx, sy) = 0
sx = nx
Next nx
End If
c = c + drun
Case 3
If sy + drun < maxy - 1 Then
For ny = sy To sy + drun
map(sx, ny) = 0
sy = ny
Next ny
End If
c = c + drun
Case 4
If sx - drun > 1 Then
For nx = sx To sx - drun Step -1
map(nx, sy) = 0
sx = nx
Next nx
End If
c = c + drun
End Select
lastgo = dgo
Next c
'show maze
For y = 0 To maxy - 1
For x = 0 To maxx - 1
If map(x, y) > 0 Then
x1 = grid(x, y, 1)
x2 = grid(x + 1, y, 1)
x3 = grid(x + 1, y + 1, 1)
x4 = grid(x, y + 1, 1)
y1 = grid(x, y, 2)
y2 = grid(x + 1, y, 2)
y3 = grid(x + 1, y + 1, 2)
y4 = grid(x, y + 1, 2)
'filling the irregular cells with _maptriangle instead of paint so there is no need to worry about "leaking"
_MapTriangle (0, 0)-(0, 8)-(8, 8), t& To(x1, y1)-(x2, y2)-(x3, y3)
_MapTriangle (0, 0)-(0, 8)-(8, 0), t& To(x1, y1)-(x3, y3)-(x4, y4)
End If
Next x
Next y
For y = 0 To maxy - 1
For x = 0 To maxx - 1
If map(x, y) = 0 Then
cx = (grid(x, y, 1) + grid(x + 1, y, 1) + grid(x, y + 1, 1) + grid(x + 1, y + 1, 1)) / 4
cy = (grid(x, y, 2) + grid(x + 1, y, 2) + grid(x, y + 1, 2) + grid(x + 1, y + 1, 2)) / 4
' Circle (cx, cy), 1, _RGB32(250, 0, 0)
'not really doing anything right now... it was earlier, it might do so again
End If
Next x
Next y
Do
_Limit 60
kk$ = InKey$
Loop Until kk$ <> ""
Loop Until kk$ = Chr$(27)
Posts: 13
Threads: 0
Joined: Apr 2022
Reputation:
2
I mainly use it for scaling, since it was faster than PUTIMAGE, and for the tiling effect.
Posts: 1,510
Threads: 53
Joined: Jul 2022
Reputation:
47
_MAPTRIANGLE is a command in QB64(PE) that I've never cared about. After coming across some of MasterGy's programs I feel very small having a lot to learn about graphics programming. I just don't have the patience. I could barely fire up GIMP to create the silly-looking avatars that you keep seeing from me on this site, and other things like the "derpface" GIF file.
Posts: 159
Threads: 10
Joined: Apr 2022
Reputation:
32
(03-23-2023, 06:34 PM)Gets Wrote: I mainly use it for scaling, since it was faster than PUTIMAGE, and for the tiling effect.
Thanks for the feedback @Gets! I'm collecting samples for testing purposes. Do you have an example program you could share that uses the tiling effect?
|