Page 160 - Demo
P. 160

TI Python BootCamp VIRTUELE STEM-EXPERIMENTEN
¨¨def top_off(self):
¨¨¨¨set_color(217,214,187)
¨¨¨¨use_buffer()
¨¨¨¨for i in range(8): ¨¨¨¨¨¨fill_circle(self.toplist[i][0],self.toplist[i][1],self.rad) ¨¨¨¨set_color(0,0,0)
¨¨¨¨for i in range(8): ¨¨¨¨¨¨fill_circle(self.topoff[i][0],self.topoff[i][1],1) ¨¨¨¨paint_buffer()
¨¨def base_off(self):
¨¨¨¨set_color(217,214,187)
¨¨¨¨use_buffer()
¨¨¨¨for i in range(8): ¨¨¨¨¨¨fill_circle(self.baselist[i][0],self.baselist[i][1],self.rad) ¨¨¨¨set_color(0,0,0)
¨¨¨¨for i in range(8): ¨¨¨¨¨¨fill_circle(self.baseoff[i][0],self.baseoff[i][1],1) ¨¨¨¨paint_buffer()
We eindigen met de onderstaande at random kleurenanimatie.
from vir_rgb import * from ti_system import * from random import *
background() strip=Array()
use_buffer()
while get_key() != "esc":
¨¨r=randint(0,255)
¨¨g=randint(0,255)
¨¨b=randint(0,255)
¨¨set_color(r,g,b)
¨¨strip.set_all(r,g,b)
¨¨fill_rect(225,160,40,40) ¨¨set_color(255,255,255) ¨¨fill_rect(50,160,150,50)
¨¨set_color(0,0,0)
¨¨draw_text(50,180,"RGB ({},{},{})".format(r,g,b)) ¨¨draw_text(50,200,"ESC = STOP") ¨¨paint_buffer()
¨¨sleep(2)
Python OOP
  strip.top_off(0,255,0)
 strip.base_off(0,255,0)
  © 2020 T3 Nederland – T3 Vlaanderen 6
www.t3nederland.nl – www.t3vlaanderen.be





































































   158   159   160   161   162