def draw(self): scene.background(0, 0, 1) # 0,0,1 = blue scene.stroke(1, 0, 0) # 1,0,0 = red scene.stroke_weight(5) scene.line(50, 50, 100, 50) scene.line(100, 50, 75, 75) scene.line(75, 75, 50, 50)
def draw(self): scene.background(0,0,0) scene.stroke_weight(4) for colored_line in self.colored_lines: scene.stroke(*colored_line.color) scene.line(*colored_line.line)
def draw(self): scene.background(0, 0, 0) for c in self.cells.values(): if c.alive: c.draw() scene.stroke(1, 1, 1) scene.stroke_weight(1) scene.image(self.grid_img, 0, 0)
def draw(self): scene.background(0, 0, 0) for c in self.cells.values(): if c.alive: c.draw() scene.stroke(1,1,1) scene.stroke_weight(1) scene.image(self.grid_img, 0, 0)
def draw(self): scene.background(0, 0, 0) self.root_layer.update(self.dt) self.root_layer.draw() scene.fill(1, 1, 1) scene.stroke(*self.stroke_color) scene.stroke_weight(4) scene.rect(0, 180, 320, 15) scene.rect(0, 290, 320, 15) scene.rect(92, 87, 15, 310) scene.rect(208, 87, 15, 310) for l in self.lines: scene.line(*l)
def scene_draw(self): if self.touch: if (self.magnitude < 0.99 * self.max_length): scene.stroke_weight(self.color['normal']['weight']) scene.stroke(*self.color['normal']['stroke']) scene.fill(*self.color['normal']['fill']) else: scene.stroke_weight(self.color['highlight']['weight']) scene.stroke(*self.color['highlight']['stroke']) scene.fill(*self.color['highlight']['fill']) scene.ellipse(self.boundary['left'], self.boundary['lower'], 2.0 * self.max_length, 2.0 * self.max_length) scene.line(self.ref_x, self.ref_y, self.clamp_x, self.clamp_y) scene.text(self.label, x=self.ref_x, y=self.ref_y)
def draw(self): if self.xy_velocity and not self.cur_touch: #self.dx += self.xy_velocity[0] * self.dt self.dy += self.xy_velocity[1] * self.dt decay = exp( - self.dt / self.velocity_decay_timescale_seconds ) self.xy_velocity = (self.xy_velocity[0] * decay, self.xy_velocity[1] * decay) if ((abs(self.xy_velocity[0]) <= self.min_velocity_points_per_second) and (abs(self.xy_velocity[1]) <= self.min_velocity_points_per_second)): self.xy_velocity = None # Get day of week...Monday=1, etc day = datetime.datetime.today().isoweekday() # Rotate a color for each day in week r,g,b = get_background_color(day) scene.background(r,g,b) scene.translate(self.dx, self.dy) scene.fill(1, 1, 1) scene.stroke(1, 1, 1) # Line thickness scene.stroke_weight(1) # Vertical lines scene.line(-150,-931,-150,255) scene.line(150,-931,150,255) # Horizontal lines scene.line(-150,255,150,255) scene.line(-150,230,150,230) scene.line(-150,60,150,60) scene.line(-150,35,150,35) scene.line(-150,-104,150,-104) scene.line(-150,-241,150,-241) scene.line(-150,-379,150,-379) scene.line(-150,-517,150,-517) scene.line(-150,-655,150,-655) scene.line(-150,-794,150,-794) scene.line(-150,-931,150,-931) ''' Text will be white by default and images drawn in their natural colors unless tint(r,g,b,a) function is used ''' scene.text(weather_now,font_size=12,x=-140,y=250, alignment=3) scene.text(forecast,font_size=12,x=-140,y=55, alignment=3) # Insert icons into scene for i, image in enumerate(self.images): scene.image(image,75,y[i])
def scene_draw(self): if self.touch: if not (int(self.x) or int(self.y)): scene.stroke_weight(self.color['normal']['weight']) scene.stroke(*self.color['normal']['stroke']) scene.fill(*self.color['normal']['fill']) else: scene.stroke_weight(self.color['highlight']['weight']) scene.stroke(*self.color['highlight']['stroke']) scene.fill(*self.color['highlight']['fill']) scene.rect(self.boundary['left'], self.boundary['lower'], 2.0 * self.max_length, 2.0 * self.max_length) scene.line(self.clamp_x, self.boundary['upper'], self.clamp_x, self.boundary['lower']) scene.line(self.boundary['left'], self.clamp_y, self.boundary['right'], self.clamp_y) scene.text(self.label, x=self.ref_x, y=self.ref_y)
def scene_draw(self): if self.touch: scene.stroke_weight(self.color['highlight']['weight']) scene.stroke(*self.color['highlight']['stroke']) scene.fill(*self.color['highlight']['fill']) scene.line(self.touch.location.x, self.respond_area['y1'], self.touch.location.x, self.respond_area['y2']) scene.line(self.respond_area['x1'], self.touch.location.y, self.respond_area['x2'], self.touch.location.y) else: scene.stroke_weight(self.color['normal']['weight']) scene.stroke(*self.color['normal']['stroke']) scene.fill(*self.color['normal']['fill']) scene.rect(self.respond_area['x1'], self.respond_area['y1'], self.respond_area['x2'], self.respond_area['y2']) scene.text(self.label, x=self.respond_area['x1'], y=self.respond_area['y1'])
def draw(self): self.prevmode = self.mode self.mode = 'off' for touch in touches: if touch.location in scene.Rect(*self.rect): self.mode = 'on' elif self.prevmode == 'on': self.mode = 'up' if self.mode == 'on': scene.fill(*self.altcolor) scene.tint(*self.alttxtcolor) scene.stroke(*self.altbordrcolor) else: scene.fill(*self.color) scene.tint(*self.txtcolor) scene.stroke(*self.bordrcolor) scene.stroke_weight(self.bordrw) scene.rect(*self.rect) scene.text(self.text, self.font, self.fontsize, self.rect[0] + self.rect[2] / 2, self.rect[1] + self.rect[3] / 2)
def scene_draw(self): if not (self.touch or (self.toggle)): scene.stroke_weight(self.color['normal']['weight']) scene.stroke(*self.color['normal']['stroke']) scene.fill(*self.color['normal']['fill']) else: scene.stroke_weight(self.color['highlight']['weight']) scene.stroke(*self.color['highlight']['stroke']) scene.fill(*self.color['highlight']['fill']) scene.rect(self.respond_area['x1'] * self.scrnWdth, self.respond_area['y1'] * self.scrnHght, (self.respond_area['x2'] - self.respond_area['x1']) * self.scrnWdth, (self.respond_area['y2'] - self.respond_area['y1']) * self.scrnHght) scene.text( self.label, x=0.5 * (self.respond_area['x1'] + self.respond_area['x2']) * self.scrnWdth, y=0.5 * (self.respond_area['y1'] + self.respond_area['y2']) * self.scrnHght, )
def draw(self): self.update() scene.stroke(0, 0, 0) scene.fill(*self.color) scene.rect(*self.frame)
def draw(self): if self.xy_velocity and not self.cur_touch: #self.dx += self.xy_velocity[0] * self.dt self.dy += self.xy_velocity[1] * self.dt decay = exp( - self.dt / self.velocity_decay_timescale_seconds ) self.xy_velocity = (self.xy_velocity[0] * decay, self.xy_velocity[1] * decay) if ((abs(self.xy_velocity[0]) <= self.min_velocity_points_per_second) and (abs(self.xy_velocity[1]) <= self.min_velocity_points_per_second)): self.xy_velocity = None # Save battery life #scene.frame_interval = 3 scene.translate(self.dx, self.dy) scene.stroke(1, 1, 1) # Line thickness scene.stroke_weight(1) # Get day of week...Monday=1, etc day = datetime.datetime.today().isoweekday() # Rotate a color for each day of week r, g, b = get_background_color(day) scene.background(r, g, b) # Vertical lines for sides of main border scene.line(-155, y1_y2[7], -155, 240) scene.line(155, y1_y2[7], 155, 240) # Horizontal line constants x1 = -155 x2 = 155 ''' Set text size for best mix of space & apperance...all text defaults to white unless tint() is used. ''' font_sz = 10 # Display city header and info scene.line(x1, 240, x2, 240) scene.text(city_name, font_size = font_sz * 2, x = 0, y = 220, alignment = 5) scene.text(conditions, font_size = font_sz + 4, x = 0, y = 195, alignment = 5) scene.text(temp_now, font_size = font_sz + 4, x = 0, y = 172, alignment = 5) # Display header box and current conditions scene.line(x1, 155, x2, 155) scene.line(x1, 130, x2, 130) scene.text(w, font_size = font_sz, x = -150, y = 150, alignment = 3) # Display header box for 24 hr forecast scene.line(x1, -40, x2, -40) scene.text('Next 24 Hours:', font_size = font_sz, x = -150, y = -45, alignment = 3) # Division lines for 24 hr forecast y = -65 for i in range(4): scene.line(x1, y, x2, y) y = y - 80 # Divide 24 hrs into 4 rows of 6 hrs each x = -205 y = -70 count = 0 the_x = [] the_y = [] for i in range(24): # Display six hours per row if count%6 == 0 and count <> 0: x = -205 y = y - 80 x = x + 55 # Get coordinates for icon placement the_x.append(x - 4) the_y.append(y - 55) count += 1 # Percent of precip...no zeros if the_pops[i] == '0%': the_pops[i] = '' # Display hour, pop, & temp in grid msg = '{}\n{}\n\n\n\n{}'.format(the_hours[i], the_pops[i], the_temps[i]) scene.text(msg, font_size = font_sz, x = x, y = y, alignment = 3) # Insert icons into 24 hour forecast for i, image in enumerate(self.images): if i <= 23: # Reduce icon size for space scene.image(image, the_x[i], the_y[i], 30, 30) # Display header box for extended forecast scene.line(x1, -385, x2, -385) scene.text('Next 7 Days:', font_size = font_sz, x = -150, y = -390, alignment = 3) # Display extended forecast scene.line(x1, -410, x2, -410) scene.text(txt_wrapped_f, font_size = font_sz, x = -150, y = -402, alignment = 3) # Insert icons into extended forecast for i, image in enumerate(self.images): if i >= 24: # Tweak icon placement a bit more for best appearance scene.image(image, 113, icon_y[i-24], 40, 40) # Division lines for days of week for i in range(len(y1_y2)): if i > 0: scene.line(x1, y1_y2[i], x2, y1_y2[i])
def rect(rectangle, borderw=0, borderclr=(0, 0, 0)): scene.stroke(*borderclr) scene.stroke_weight(borderw) scene.rect(*rectangle)
def ellipse(rectangle, borderw=0, borderclr=(0, 0, 0)): scene.stroke(*borderclr) scene.stroke_weight(borderw) scene.ellipse(*rectangle)
def draw(self): scene.background(0,0,1) # 0,0,1 = blue scene.stroke(1,0,0) # 1,0,0 = red scene.stroke_weight(5) scene.line(50,50,100,50) scene.line(100,50,75,75)
def draw(self): if self.xy_velocity and not self.cur_touch: #self.dx += self.xy_velocity[0] * self.dt self.dy += self.xy_velocity[1] * self.dt decay = exp(-self.dt / self.velocity_decay_timescale_seconds) self.xy_velocity = (self.xy_velocity[0] * decay, self.xy_velocity[1] * decay) if ((abs(self.xy_velocity[0]) <= self.min_velocity_points_per_second) and (abs(self.xy_velocity[1]) <= self.min_velocity_points_per_second)): self.xy_velocity = None # Save battery life #scene.frame_interval = 3 scene.translate(self.dx, self.dy) scene.stroke(1, 1, 1) # Line thickness scene.stroke_weight(1) scene.line(1, 25, 20, 25) # Get day of week...Monday=1, etc day = datetime.datetime.today().isoweekday() # Rotate a color for each day of week r, g, b = get_background_color(day) scene.background(r, g, b) # Vertical lines for sides of main border scene.line(-155, y1_y2[7], -155, 240) scene.line(155, y1_y2[7], 155, 240) # Horizontal line constants x1 = -155 x2 = 155 ''' Set text size for best mix of space & apperance...all text defaults to white unless tint() is used. ''' font_sz = 10 # Display city header and info scene.line(x1, 240, x2, 240) scene.text(city_name, font_size=font_sz * 2, x=0, y=220, alignment=5) scene.text(conditions, font_size=font_sz + 4, x=0, y=195, alignment=5) scene.text(temp_now, font_size=font_sz + 4, x=0, y=172, alignment=5) # Display header box and current conditions scene.line(x1, 155, x2, 155) scene.line(x1, 130, x2, 130) scene.text(w, font_size=font_sz, x=-150, y=150, alignment=3) # Display header box for 24 hr forecast scene.line(x1, -40, x2, -40) scene.text('Next 24 Hours:', font_size=font_sz, x=-150, y=-45, alignment=3) # Division lines for 24 hr forecast y = -65 for i in range(4): scene.line(x1, y, x2, y) y = y - 80 # Divide 24 hrs into 4 rows of 6 hrs each x = -205 y = -70 count = 0 the_x = [] the_y = [] for i in range(24): # Display six hours per row if count % 6 == 0 and count <> 0: x = -205 y = y - 80 x = x + 55 # Get coordinates for icon placement the_x.append(x - 4) the_y.append(y - 55) count += 1 # Percent of precip...no zeros if the_pops[i] == '0%': the_pops[i] = '' # Display hour, pop, & temp in grid scene.text('{}\n{}\n\n\n\n{}'.format(the_hours[i], the_pops[i], the_temps[i]), font_size=font_sz, x=x, y=y, alignment=3) # Insert icons into 24 hour forecast for i, image in enumerate(self.images): if i <= 23: # Reduce icon size for space scene.image(image, the_x[i], the_y[i], 30, 30) # Display header box for extended forecast scene.line(x1, -385, x2, -385) scene.text('Next 7 Days:', font_size=font_sz, x=-150, y=-390, alignment=3) # Display extended forecast scene.line(x1, -410, x2, -410) scene.text(txt_wrapped_f, font_size=font_sz, x=-150, y=-402, alignment=3) # Insert icons into extended forecast for i, image in enumerate(self.images): if i >= 24: # Tweak icon placement a bit more for best appearance scene.image(image, 113, icon_y[i - 24], 40, 40) # Division lines for days of week for i in range(len(y1_y2)): if i > 0: scene.line(x1, y1_y2[i], x2, y1_y2[i])
def draw(self): if self.xy_velocity and not self.cur_touch: #self.dx += self.xy_velocity[0] * self.dt self.dy += self.xy_velocity[1] * self.dt decay = exp(-self.dt / self.velocity_decay_timescale_seconds) self.xy_velocity = (self.xy_velocity[0] * decay, self.xy_velocity[1] * decay) if ((abs(self.xy_velocity[0]) <= self.min_velocity_points_per_second) and (abs(self.xy_velocity[1]) <= self.min_velocity_points_per_second)): self.xy_velocity = None # Save battery life #scene.frame_interval = 3 scene.translate(self.dx, self.dy) scene.stroke(1, 1, 1) # Line thickness scene.stroke_weight(1) scene.line(1, 25, 20, 25) # Get day of week...Monday=1, etc day = datetime.datetime.today().isoweekday() # Rotate a color for each day of week r, g, b = self.get_background_color(day) scene.background(r, g, b) ''' Set text size for best mix of space & apperance...all text defaults to white unless tint() is used. ''' font_sz = 10 x1 = -((self.size.w / 2) - 2) # -205 for iP6p, -158 for iP5 x2 = (self.size.w / 2) - 2 # 205 for iP6p, 158 for iP5 # If Pythonista 2 & iPhone 6+ or larger... if py_ver == '2' and is_P6: y_anchor = 325 l_margin = x1 + 10 # 24 hour temps in a 3x8 matrix rows = 3 hrs_per_row = 8 else: y_anchor = 240 l_margin = x1 + 8 # 24 hour temps in a 4x6 matrix rows = 4 hrs_per_row = 6 # Vertical lines for sides of main border scene.line(x1, y1_y2[7], x1, y_anchor) scene.line(x2, y1_y2[7], x2, y_anchor) # Display city header and info scene.line(x1, y_anchor, x2, y_anchor) scene.text(city_name, font_size=font_sz * 2, x=0, y=y_anchor - 20, alignment=5) scene.text(conditions, font_size=font_sz + 4, x=0, y=y_anchor - 45, alignment=5) scene.text(temp_now, font_size=font_sz + 4, x=0, y=y_anchor - 68, alignment=5) # Display header box and current conditions scene.line(x1, y_anchor - 85, x2, y_anchor - 85) scene.line(x1, y_anchor - 110, x2, y_anchor - 110) l_margin = x1 + 10 scene.text(w, font_size=font_sz, x=l_margin, y=y_anchor - 90, alignment=3) # Display header box for 24 hr forecast scene.line(x1, y_anchor - 280, x2, y_anchor - 280) scene.text('Next 24 Hours:', font_size=font_sz, x=l_margin, y=y_anchor - 285, alignment=3) # Division lines for 24 hr forecast # Divide 24 hrs into 'rows' rows of 'hrs_per_row' hrs each y = y_anchor - 305 for i in range(int(rows)): scene.line(x1, y, x2, y) y = y - 80 x = x1 - 45 y = y_anchor - 310 count = 0 the_x = [] the_y = [] for i in range(24): # Display 'hrs_per_row' hours per row if count % int(hrs_per_row) == 0 and count <> 0: x = x1 - 45 y = y - 80 x = x + 53 # Get coordinates for icon placement the_x.append(x - 4) the_y.append(y - 55) count += 1 # Percent of precip...no zeros if the_pops[i] == '0%': the_pops[i] = '' # Display hour, pop, & temp in grid scene.text('{}\n{}\n\n\n\n{}'.format(the_hours[i], the_pops[i], the_temps[i]), font_size=font_sz, x=x, y=y, alignment=3) # Insert icons into 24 hour forecast for i, image in enumerate(self.images): if i <= 23: # Reduce icon size for space scene.image(image, the_x[i], the_y[i], 30, 30) if py_ver == '2' and is_P6: # Display header box for extended forecast scene.line(x1, y_anchor - 545, x2, y_anchor - 545) scene.text('Next 7 Days:', font_size=font_sz, x=l_margin, y=y_anchor - 550, alignment=3) # Display extended forecast scene.line(x1, y_anchor - 570, x2, y_anchor - 570) scene.text(txt_wrapped_f, font_size=font_sz, x=l_margin, y=y_anchor - 563, alignment=3) else: # Display header box for extended forecast scene.line(x1, y_anchor - 625, x2, y_anchor - 625) scene.text('Next 7 Days:', font_size=font_sz, x=l_margin, y=y_anchor - 630, alignment=3) # Display extended forecast scene.line(x1, y_anchor - 650, x2, y_anchor - 650) scene.text(txt_wrapped_f, font_size=font_sz, x=l_margin, y=y_anchor - 643, alignment=3) # Insert icons into extended forecast for i, image in enumerate(self.images): if i >= 24: # Tweak icon placement a bit more for best appearance if wa.pythonista_version()[:1] == '2' and wa.is_iP6p(): scene.image(image, 160, icon_y[i - 24], 40, 40) else: scene.image(image, 113, icon_y[i - 24], 40, 40) # Division lines for days of week for i in range(len(y1_y2)): if i > 0: scene.line(x1, y1_y2[i], x2, y1_y2[i])
def draw(self): if self.xy_velocity and not self.cur_touch: #self.dx += self.xy_velocity[0] * self.dt self.dy += self.xy_velocity[1] * self.dt decay = exp( - self.dt / self.velocity_decay_timescale_seconds ) self.xy_velocity = (self.xy_velocity[0] * decay, self.xy_velocity[1] * decay) if ((abs(self.xy_velocity[0]) <= self.min_velocity_points_per_second) and (abs(self.xy_velocity[1]) <= self.min_velocity_points_per_second)): self.xy_velocity = None # Save battery life #scene.frame_interval = 3 scene.translate(self.dx, self.dy) scene.stroke(1, 1, 1) # Line thickness scene.stroke_weight(1) scene.line(1, 25, 20, 25) # Get day of week...Monday=1, etc day = datetime.datetime.today().isoweekday() # Rotate a color for each day of week r, g, b = self.get_background_color(day) scene.background(r, g, b) ''' Set text size for best mix of space & apperance...all text defaults to white unless tint() is used. ''' font_sz = 10 x1 = - ((self.size.w / 2) -2) # -205 for iP6p, -158 for iP5 x2 = (self.size.w / 2) -2 # 205 for iP6p, 158 for iP5 # If Pythonista 2 & iPhone 6+ or larger... if py_ver == '2' and is_P6: y_anchor = 325 l_margin = x1 + 10 # 24 hour temps in a 3x8 matrix rows = 3 hrs_per_row = 8 else: y_anchor = 240 l_margin = x1 + 8 # 24 hour temps in a 4x6 matrix rows = 4 hrs_per_row = 6 # Vertical lines for sides of main border scene.line(x1, y1_y2[7], x1, y_anchor) scene.line(x2, y1_y2[7], x2, y_anchor) # Display city header and info scene.line(x1, y_anchor, x2, y_anchor) scene.text(city_name, font_size = font_sz * 2, x = 0, y = y_anchor - 20, alignment = 5) scene.text(conditions, font_size = font_sz + 4, x = 0, y = y_anchor - 45, alignment = 5) scene.text(temp_now, font_size = font_sz + 4, x = 0, y = y_anchor - 68, alignment = 5) # Display header box and current conditions scene.line(x1, y_anchor - 85, x2, y_anchor - 85) scene.line(x1, y_anchor - 110, x2, y_anchor - 110) l_margin = x1 + 10 scene.text(w, font_size = font_sz, x = l_margin, y = y_anchor - 90, alignment = 3) # Display header box for 24 hr forecast scene.line(x1, y_anchor - 280, x2, y_anchor - 280) scene.text('Next 24 Hours:', font_size = font_sz, x = l_margin, y = y_anchor - 285, alignment = 3) # Division lines for 24 hr forecast # Divide 24 hrs into 'rows' rows of 'hrs_per_row' hrs each y = y_anchor - 305 for i in range(int(rows)): scene.line(x1, y, x2, y) y = y - 80 x = x1 - 45 y = y_anchor - 310 count = 0 the_x = [] the_y = [] for i in range(24): # Display 'hrs_per_row' hours per row if count%int(hrs_per_row) == 0 and count <> 0: x = x1 - 45 y = y - 80 x = x + 53 # Get coordinates for icon placement the_x.append(x - 4) the_y.append(y - 55) count += 1 # Percent of precip...no zeros if the_pops[i] == '0%': the_pops[i] = '' # Display hour, pop, & temp in grid scene.text('{}\n{}\n\n\n\n{}'.format(the_hours[i], the_pops[i], the_temps[i]), font_size = font_sz, x = x, y = y, alignment = 3) # Insert icons into 24 hour forecast for i, image in enumerate(self.images): if i <= 23: # Reduce icon size for space scene.image(image, the_x[i], the_y[i], 30, 30) if py_ver == '2' and is_P6: # Display header box for extended forecast scene.line(x1, y_anchor - 545, x2, y_anchor - 545) scene.text('Next 7 Days:', font_size = font_sz, x = l_margin, y = y_anchor - 550, alignment = 3) # Display extended forecast scene.line(x1, y_anchor - 570, x2, y_anchor - 570) scene.text(txt_wrapped_f, font_size = font_sz, x = l_margin, y = y_anchor - 563, alignment = 3) else: # Display header box for extended forecast scene.line(x1, y_anchor - 625, x2, y_anchor - 625) scene.text('Next 7 Days:', font_size = font_sz, x = l_margin, y = y_anchor - 630, alignment = 3) # Display extended forecast scene.line(x1, y_anchor - 650, x2, y_anchor - 650) scene.text(txt_wrapped_f, font_size = font_sz, x = l_margin, y = y_anchor - 643, alignment = 3) # Insert icons into extended forecast for i, image in enumerate(self.images): if i >= 24: # Tweak icon placement a bit more for best appearance if wa.pythonista_version()[:1] == '2' and wa.is_iP6p(): scene.image(image, 160, icon_y[i - 24], 40, 40) else: scene.image(image, 113, icon_y[i - 24], 40, 40) # Division lines for days of week for i in range(len(y1_y2)): if i > 0: scene.line(x1, y1_y2[i], x2, y1_y2[i])