-
-
Notifications
You must be signed in to change notification settings - Fork 489
clip
TimotheeGreg edited this page Aug 25, 2023
·
20 revisions
clip
Unsets the clipping region (draws to the full screen)
clip(x, y, width, height)
Sets the clipping region
Parameters
- x, y : coordinates of the top left of the clipping region
- width : width of the clipping region in pixels
- height : height of the clipping region in pixels
This function limits drawing to a clipping region or 'viewport' defined by x
,y
, width
, and height
.
Any pixels falling outside of this area will not be drawn.
Calling clip()
with no parameters will reset the drawing area to the entire screen.
-- clip example
-- author: paul59
-- script: lua
t=0
x=96
y=24
local BLACK=0
local BLUE=13
local c=false
function TIC()
if btn(0) then y=y-1 end
if btn(1) then y=y+1 end
if btn(2) then x=x-1 end
if btn(3) then x=x+1 end
cls(BLUE)
if c then
cls(BLACK)
-- limit drawing to a 100 pixel wide/high
-- region, with top left at 60,20
clip(60,20,100,100)
-- cls() is also affected by
-- the clipping region
cls(BLUE)
else
-- reset to entire screen
clip()
end
spr(1+t%60//30*2,x,y,14,3,0,0,2,2)
print("Press 'Up' To",76,84)
print("Toggle Clipping",72,94)
if btnp(0) then c=not c end
t=t+1
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)