diff options
author | John R. Lenton <jlenton@gmail.com> | 2014-01-07 18:01:08 +0000 |
---|---|---|
committer | John R. Lenton <jlenton@gmail.com> | 2014-01-07 18:01:08 +0000 |
commit | 270112f7312f724e46ae34649dfce3ec43b697e0 (patch) | |
tree | d7438ae877350aede062d8ac7e62e52ab35cb018 /examples/mandel.py | |
parent | c06763a0207dde7f2060f7b1670a0b99298a01f8 (diff) | |
parent | fd04bb3bacf5dbc4d79c04a49520e3e81abb7352 (diff) | |
download | micropython-270112f7312f724e46ae34649dfce3ec43b697e0.tar.gz micropython-270112f7312f724e46ae34649dfce3ec43b697e0.zip |
Merge remote-tracking branch 'upstream/master' into listsort. Lots of conflict fun.
Conflicts:
py/obj.h
py/objbool.c
py/objboundmeth.c
py/objcell.c
py/objclass.c
py/objclosure.c
py/objcomplex.c
py/objdict.c
py/objexcept.c
py/objfun.c
py/objgenerator.c
py/objinstance.c
py/objmodule.c
py/objrange.c
py/objset.c
py/objslice.c
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() |