-
Notifications
You must be signed in to change notification settings - Fork 1
clip
Kyuchumimo edited this page Jan 6, 2025
·
9 revisions
-
clipUnsets the clipping region (draws to the full screen) -
clip x y width heightSets the clipping region
- 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.
_TIC["PALETTE"] = [[0x14,0x0c,0x1c], [0x44,0x24,0x34], [0x30,0x34,0x6d], [0x4e,0x4a,0x4e], [0x85,0x4c,0x30], [0x34,0x65,0x24], [0xd0,0x46,0x48], [0x75,0x71,0x61], [0x59,0x7d,0xce], [0xd2,0x7d,0x2c], [0x85,0x95,0xa1], [0x6d,0xaa,0x2c], [0xd2,0xaa,0x99], [0x6d,0xc2,0xca], [0xda,0xd4,0x5e], [0xde,0xee,0xd6]] #DB16
# clip example
# author: paul59, edited by Kyuchumimo
# script: python
BLACK=0
BLUE=8
c=False
def TIC():
cls(BLACK)
if c:
# 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()
print("Press 'Up' To Toggle",60,0)
print("Clipping",90,20)
if btnp(0): c=not c