diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-07 17:14:05 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-07 17:14:05 +0000 |
commit | fd04bb3bacf5dbc4d79c04a49520e3e81abb7352 (patch) | |
tree | 17df5d5e31e738fa5bed33e08824ad4e8e125160 /examples/mandel.py | |
parent | 7b21c2d8f01b33b35463cb22487b1235aa7446a4 (diff) | |
download | micropython-fd04bb3bacf5dbc4d79c04a49520e3e81abb7352.tar.gz micropython-fd04bb3bacf5dbc4d79c04a49520e3e81abb7352.zip |
Add some example scripts for pyboard (some can run on PC).
Diffstat (limited to 'examples/mandel.py')
-rw-r--r-- | examples/mandel.py | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/examples/mandel.py b/examples/mandel.py index b13b7d87f8..996132a915 100644 --- a/examples/mandel.py +++ b/examples/mandel.py @@ -1,14 +1,22 @@ -@micropython.native -def in_set(c): - z = 0 - for i in range(40): - z = z*z + c - if abs(z) > 60: - return False - return True +def mandelbrot(): + # returns True if c, complex, is in the Mandelbrot set + @micropython.native + def in_set(c): + z = 0 + for i in range(40): + z = z*z + c + if abs(z) > 60: + return False + return True -for v in range(31): - line = [] + lcd.clear() for u in range(91): - line.append('*' if in_set((u / 30 - 2) + (v / 15 - 1) * 1j) else ' ') - print(''.join(line)) + for v in range(31): + if in_set((u / 30 - 2) + (v / 15 - 1) * 1j): + lcd.set(u, v) + lcd.show() + +# PC testing +import lcd +lcd = lcd.LCD(128, 32) +mandelbrot() |