Created
August 15, 2012 17:02
-
-
Save GrAndSE/3361621 to your computer and use it in GitHub Desktop.
soy.widgets.Canvas example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| from random import randint, random | |
| from time import sleep | |
| import soy | |
| client = soy.Client() | |
| tex = soy.textures.Texture() | |
| tex.size = soy.atoms.Size((16, 16)) | |
| tex.smooth = False | |
| can = soy.widgets.Canvas(client.window, tex) | |
| colors = ( | |
| soy.atoms.Color('blue'), | |
| soy.atoms.Color('cyan'), | |
| soy.atoms.Color('green'), | |
| soy.atoms.Color('white'), | |
| soy.atoms.Color('yellow'), | |
| soy.atoms.Color('red'), | |
| soy.atoms.Color('pink'), | |
| soy.atoms.Color('grey') | |
| ) | |
| for i in range(256): | |
| tex[i] = colors[randint(0, len(colors) - 1)] | |
| while True: | |
| colors[randint(0, len(colors) - 1)].red += int(random() * 2) + 1 | |
| colors[randint(0, len(colors) - 1)].green += int(random() * 2) + 1 | |
| colors[randint(0, len(colors) - 1)].blue += int(random() * 2) + 1 | |
| pos = randint(0, 255) | |
| tex[pos] = colors[randint(0, len(colors) - 1)] | |
| print(tex[pos]) | |
| can = soy.widgets.Canvas(client.window, tex) | |
| sleep(.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment