-
Notifications
You must be signed in to change notification settings - Fork 1
clip
Kyuchumimo edited this page Mar 2, 2022
·
9 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.
#####################################
db16=[[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]]
# clip example
# author: paul59, edited by Kyuchumimo
# script: python
BLACK=0
BLUE=8
c=False
while True:
cls(db16[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(db16[BLUE])
else:
# reset to entire screen
clip()
print("Press 'Up' To Toggle",60,0)
print("Clipping",90,20)
if btnp(0): c=not c
#####################################