def draw(self): try: scene.push_matrix() self.transform() scene.translate(*self.trans) scene.rotate(self.rot) scene.scale(*self.scl) self.main() scene.pop_matrix() except AttributeError: pass
def draw(self): scene.push_matrix() scene.translate(self.frame.x, self.frame.y) scene.no_stroke() scene.fill(0.90, 0.90, 0.90) for i in self.shapes: scene.ellipse(i[0], i[1] - 5, i[2], i[2]) scene.fill(1.00, 1.00, 1.00) for i in self.shapes: scene.ellipse(i[0], i[1] + 5, i[2], i[2]) scene.pop_matrix()
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 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 = 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) # 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 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])