-
Notifications
You must be signed in to change notification settings - Fork 1
rectb
Kyuchumimo edited this page Jul 9, 2022
·
6 revisions
rectb x y w h color
- x, y : coordinates of the top left corner of the rectangle
- w : the rectangle's width in pixels
- h : the rectangle's height in pixels
- color : the index of the color in the palette that will be used to color the rectangle's border.
This function draws a one pixel thick rectangle border.
See also:
- rect - draws a filled rectangle
import math
_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
# 'rectb' demo
x=104
y=60
def TIC():
cls()
for s in range(280,0,-4):
s2=s/2
sd=500/s
x=sd*math.sin(time()/1000)
y=sd*math.cos(time()/1000)
rectb(120+x-s2,68+y-(s2/2),s,s2,8)
import math
_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
# 'rectb' demo by Filippo, refactored by Al Rado, edited by Kyuchumimo
HALF_SCR_W = 240/2
HALF_SCR_H = 136/2
DEVIATION = 150
SPEED = 1/500
RECT_COUNT = 70
RECT_STEP = 4
RECT_COLOR = 8
def TIC():
cls()
for i in range(1, RECT_COUNT):
width = i*RECT_STEP
height = width/2
slowedTime = time()*SPEED
x = math.sin(slowedTime) * DEVIATION/i - width/2
y = math.cos(slowedTime) * DEVIATION/i - height/2
rectb(HALF_SCR_W+x, HALF_SCR_H+y, width, height, RECT_COLOR)