-
-
Notifications
You must be signed in to change notification settings - Fork 492
textri
textri x1 y1 x2 y2 x3 y3 u1 v1 u2 v2 u3 v3 [use_map=false] [colorkey=-1]
- x1 : the x coordinate of the first triangle corner
- y1 : the y coordinate of the first triangle corner
- x2 : the x coordinate of the second triangle corner
- y2 : the y coordinate of the second triangle corner
- x3 : the x coordinate of the third triangle corner
- y3 : the y coordinate of the third triangle corner
These can be thought of as the window inside image ram (sprite sheet), or map ram. Note that the sprite sheet or map in this case is treated as a single large image, with U and V addressing its pixels directly, rather than by sprite ID. So for example the top left corner of sprite #2 would be located at u=16, v=0.
-
u1 : the U coordinate of the first triangle corner
-
v1 : the V coordinate of the first triangle corner
-
u2 : the U coordinate of the second triangle corner
-
v2 : the V coordinate of the second triangle corner
-
u3 : the U coordinate of the third triangle corner
-
v3 : the V coordinate of the third triangle corner
-
use_map : if false (default), the triangle's texture is read from the image vram (sprite sheet). If true, the texture comes from the map ram.
-
colorkey : index (or array of indexes) of the color that will be used as transparent color.
It renders a triangle filled with texture from image ram or map ram
This function does not perform perspective correction, so it is not generally suitable for 3D graphics (except in some constrained scenarios). In particular, if the vertices in the triangle have different 3D depth, you may see some distortion.
-- title: triangle demo
-- author: MonstersGoBoom
-- desc: wiki demo for textri
-- script: lua
-- input: gamepad
usize = 32
vsize = 32
function TIC()
cls(1)
if btn(0) then usize=usize-1 end
if btn(1) then usize=usize+1 end
if btn(2) then vsize=vsize-1 end
if btn(3) then vsize=vsize+1 end
-- draw a scaling view into the map ram
textri(0,0,
64,0,
0,64,
0,0,
usize,0,
0,vsize,
true,
14)
textri(64,0,
0,64,
64,64,
usize,0,
0,vsize,
usize,vsize,
true,
14)
end
TIC-80 tiny computer https://tic80.com | Twitter | Telegram | Terms
Built-in Editors
Console
Platform
RAM & VRAM | Display | Palette | Bits per Pixel (BPP) |
.tic
Format | Supported Languages
Other
Tutorials | Code Snippets | Libraries | External Tools | FFT
API
- BDR (0.90)
- BOOT (1.0)
- MENU
- OVR (deprecated)
- SCN (deprecated)
- TIC
- btn & btnp
- circ & circb
- clip
- cls
- elli & ellib (0.90)
- exit
- fget & fset (0.80)
- font
- key & keyp
- line
- map
- memcpy & memset
- mget & mset
- mouse
- music
- peek, peek4
- peek1, peek2 (1.0)
- pix
- pmem
- poke, poke4
- poke1, poke2 (1.0)
- rect & rectb
- reset
- sfx
- spr
- sync
- ttri (1.0)
- time
- trace
- tri & trib (0.90)
- tstamp (0.80)
- vbank (1.0)