Commit 001c428de519d831d8f7151c5c0af32be7f78876
1 parent
ae0e1c6f
Exists in
master
Beginnings of a complete rewrite for the plotting code, neater this time
Showing
3 changed files
with
47 additions
and
0 deletions
Show diff stats
No preview for this file type
| ... | ... | @@ -0,0 +1,42 @@ |
| 1 | +#!/usr/bin/env python | |
| 2 | + | |
| 3 | +import pyglet | |
| 4 | +#import math | |
| 5 | +#import time | |
| 6 | +#import serial | |
| 7 | + | |
| 8 | +from colours import * | |
| 9 | + | |
| 10 | +class Plot: | |
| 11 | + def __init__(self, title="Unknown", size=(640, 480)): | |
| 12 | + self.title = title | |
| 13 | + self.size = size | |
| 14 | + self.font = 'Arkhip' | |
| 15 | + self.window = pyglet.window.Window(self.size[0], self.size[1], resizable=True) | |
| 16 | + self.window.set_caption(title) | |
| 17 | + | |
| 18 | + def draw(self): | |
| 19 | + self.drawBackground() | |
| 20 | + self.drawHeading() | |
| 21 | + | |
| 22 | + def drawBackground(self): | |
| 23 | + pyglet.image.SolidColorImagePattern(WHITE).create_image(self.size[0], self.size[1]).blit(0, 0) | |
| 24 | + | |
| 25 | + def drawHeading(self): | |
| 26 | + heading = pyglet.text.Label(self.title, color=BLACK, | |
| 27 | + font_name=self.font, font_size=self.size[0]/50, x=self.size[0]/2, y=self.size[1], | |
| 28 | + anchor_x='center', anchor_y='top') | |
| 29 | + heading.draw() | |
| 30 | + | |
| 31 | + | |
| 32 | +plots = [] | |
| 33 | +plots.append(Plot("This is a test plot")) | |
| 34 | + | |
| 35 | +def update(foo): | |
| 36 | + for plot in plots: | |
| 37 | + plot.window.clear() | |
| 38 | + plot.draw() | |
| 39 | + | |
| 40 | +pyglet.clock.schedule_interval(update, 0.01) | |
| 41 | + | |
| 42 | +pyglet.app.run() | |
| 0 | 43 | \ No newline at end of file | ... | ... |