home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
pypil112.zip
/
PIL-1.1.2.zip
/
Lib
/
site-packages
/
PIL
/
ImageDraw.pyc
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2001-12-25
|
7KB
|
177 lines
# Source Generated with Decompyle++
# File: in.pyc (Python 2.2)
import Image
class Draw:
def __init__(self, im):
im.load()
if im.readonly:
im._copy()
self.im = im.im
if im.mode in ('I', 'F'):
self.ink = self.im.draw_ink(1)
else:
self.ink = self.im.draw_ink(-1)
self.fill = 0
self.font = None
def setink(self, ink):
self.ink = self.im.draw_ink(ink)
def setfill(self, onoff):
self.fill = onoff
def setfont(self, font):
self.font = font
def getfont(self):
if not (self.font):
import ImageFont
self.font = ImageFont.load_path('BDF/courR14.pil')
return self.font
def textsize(self, text, font = None):
if font is None:
font = self.getfont()
return font.getsize(text)
def _getink(self, ink, fill = None):
if ink is None and fill is None:
if self.fill:
fill = self.ink
else:
ink = self.ink
elif ink is not None:
ink = self.im.draw_ink(ink)
if fill is not None:
fill = self.im.draw_ink(fill)
return (ink, fill)
def arc(self, xy, start, end, fill = None):
(ink, fill) = self._getink(fill)
if ink is not None:
self.im.draw_arc(xy, start, end, ink)
def bitmap(self, xy, bitmap, fill = None):
bitmap.load()
(ink, fill) = self._getink(fill)
if ink is None:
ink = fill
if ink is not None:
self.im.draw_bitmap(xy, bitmap.im, ink)
def chord(self, xy, start, end, fill = None, outline = None):
(ink, fill) = self._getink(outline, fill)
if fill is not None:
self.im.draw_chord(xy, start, end, fill, 1)
if ink is not None:
self.im.draw_chord(xy, start, end, ink, 0)
def ellipse(self, xy, fill = None, outline = None):
(ink, fill) = self._getink(outline, fill)
if fill is not None:
self.im.draw_ellipse(xy, fill, 1)
if ink is not None:
self.im.draw_ellipse(xy, ink, 0)
def line(self, xy, fill = None):
(ink, fill) = self._getink(fill)
if ink is not None:
self.im.draw_lines(xy, ink)
def shape(self, shape, fill = None, outline = None):
shape.close()
(ink, fill) = self._getink(outline, fill)
if fill is not None:
self.im.draw_outline(shape, fill, 1)
if ink is not None:
self.im.draw_outline(shape, ink, 0)
def pieslice(self, xy, start, end, fill = None, outline = None):
(ink, fill) = self._getink(outline, fill)
if fill is not None:
self.im.draw_pieslice(xy, start, end, fill, 1)
if ink is not None:
self.im.draw_pieslice(xy, start, end, ink, 0)
def point(self, xy, fill = None):
(ink, fill) = self._getink(fill)
if ink is not None:
self.im.draw_points(xy, ink)
def polygon(self, xy, fill = None, outline = None):
(ink, fill) = self._getink(outline, fill)
if fill is not None:
self.im.draw_polygon(xy, fill, 1)
if ink is not None:
self.im.draw_polygon(xy, ink, 0)
def rectangle(self, xy, fill = None, outline = None):
(ink, fill) = self._getink(outline, fill)
if fill is not None:
self.im.draw_rectangle(xy, fill, 1)
if ink is not None:
self.im.draw_rectangle(xy, ink, 0)
def text(self, xy, text, fill = None, font = None, anchor = None):
(ink, fill) = self._getink(fill)
if font is None:
font = self.getfont()
if ink is None:
ink = fill
if ink is not None:
self.im.draw_bitmap(xy, font.getmask(text), ink)
ImageDraw = Draw
try:
Outline = Image.core.outline
except:
Outline = None