Jump to content

Bitmap/Python: Difference between revisions

m
Fixed syntax highlighting.
(→‎Alternative version: since the default background is white, it makes sense to make the default paint color black (this is also required by Bitmap/Bresenham's_line_algorithm#Python))
m (Fixed syntax highlighting.)
 
Line 4:
 
{{works with|python|2.4}}
<langsyntaxhighlight Pythonlang="python">import sys # for stdout
 
class c_color(object):
Line 65:
result = self.pixels[y][x]
assert type(result) is c_color
return result</langsyntaxhighlight>
 
===Alternative version===
Line 71:
 
This makes use of named tuples and may well work with Python 2.6+ too.
<langsyntaxhighlight lang="python">from collections import namedtuple
from copy import copy
 
Line 139:
+--------------------+
 
'''</langsyntaxhighlight>
9,485

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.