Created
June 8, 2014 16:22
-
-
Save jordanorelli/4a32d0b58efda1439e9d to your computer and use it in GitHub Desktop.
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
from walker import Walker | |
import sys | |
walker = Walker(250, 250) | |
def setup(): | |
print sys.version_info | |
size(500, 500) | |
background(255) | |
def draw(): | |
noStroke() | |
fill(255, 5) | |
rect(0, 0, width, height) | |
walker.draw() | |
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
mode.id=jycessing.mode.PythonMode | |
mode=Python |
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
from java.util import Random | |
class Walker(object): | |
"""hi """ | |
def __init__(self, x, y): | |
self._last = PVector(x, y) | |
self._pos = PVector(x, y) | |
self.random_source = Random() | |
def draw(self): | |
stroke(0) | |
self.x = self.x + self.rand() | |
self.y = self.y + self.rand() | |
line(self.x, self.y, self.last_x, self.last_y) | |
@property | |
def x(self): | |
return self._pos.x | |
@x.setter | |
def x(self, value): | |
self._last.x = self._pos.x | |
self._pos.x = value | |
@property | |
def last_x(self): | |
return self._last.x | |
@property | |
def y(self): | |
return self._pos.y | |
@y.setter | |
def y(self, value): | |
self._last.y = self._pos.y | |
self._pos.y = value | |
@property | |
def last_y(self): | |
return self._last.y | |
def rand(self): | |
return 3.0 * self.random_source.nextGaussian() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment