1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
import sys
class AbstractGradientBrush(object):
""" Abstract base class for gradient brushes so they can be detected easily.
"""
def IsOk(self):
return True
def bbox_transform(self, gc, bbox):
""" Apply a transformation to make the bbox a unit square.
"""
x0, y0, w, h = bbox
if sys.platform == 'darwin':
gc.concat_ctm(((w, 0, 0), (0, h, 0), (x0, y0, 1)))
else:
gc.concat_ctm((w,0,0,h,x0,y0))
class NullRenderer(object):
NullBrush = None
NullGraphicsBrush = None
NullPen = None
TransparentPen = None
caps = {
'butt':None,
'round':None,
'square':None
}
joins = {
'miter':None,
'round':None,
'bevel':None
}
fill_rules = {'nonzero':None, 'evenodd': None}
def __init__(self):
pass
@classmethod
def concatTransform(cls, gc, matrix):
raise NotImplemented()
@classmethod
def createAffineMatrix(cls, a,b,c,d,x,y):
raise NotImplemented()
@classmethod
def createBrush(cls, color_tuple):
raise NotImplemented()
@classmethod
def createNativePen(cls, pen):
raise NotImplemented()
@classmethod
def createPen(cls, color_tuple):
raise NotImplemented()
@classmethod
def createLinearGradientBrush(cls, x1,y1,x2,y2, stops, spreadMethod='pad',
transforms=None, units='userSpaceOnUse'):
raise NotImplemented()
@classmethod
def createRadialGradientBrush(cls, cx,cy, r, stops, fx=None,fy=None,
spreadMethod='pad', transforms=None,
units='userSpaceOnUse'):
raise NotImplemented()
@classmethod
def getFont(cls, font_name='Arial'):
raise NotImplemented()
@classmethod
def makeMatrix(cls, *args):
raise NotImplemented()
@classmethod
def makePath(cls):
raise NotImplemented()
@classmethod
def popState(cls, gc):
raise NotImplemented()
@classmethod
def pushState(cls, gc):
raise NotImplemented()
@classmethod
def setFontSize(cls, font, size):
raise NotImplemented()
@classmethod
def setFontStyle(cls, font, style):
raise NotImplemented()
@classmethod
def setFontWeight(cls, font, weight):
raise NotImplemented()
@classmethod
def setFont(cls, gc, font, brush):
raise NotImplemented()
@classmethod
def setBrush(cls, gc, brush):
raise NotImplemented()
@classmethod
def setPenDash(cls, pen, dasharray, offset):
raise NotImplemented()
@classmethod
def setPen(cls, gc, pen):
raise NotImplemented()
@classmethod
def strokePath(cls, gc, path):
raise NotImplemented()
@classmethod
def fillPath(cls, gc, path, mode):
raise NotImplemented()
@classmethod
def gradientPath(cls, gc, path, brush):
raise NotImplemented()
@classmethod
def clipPath(cls, gc, path):
raise NotImplemented()
@classmethod
def translate(cls, gc, *args):
raise NotImplemented()
@classmethod
def rotate(cls, gc, angle):
raise NotImplemented()
@classmethod
def scale(cls, gc, sx, sy):
raise NotImplemented()
@classmethod
def GetTextExtent(cls, gc, text):
raise NotImplemented()
@classmethod
def DrawText(cls, gc, text, x, y, brush, anchor='start'):
""" Draw text at the given x,y position with the color of the
given brush.
"""
raise NotImplemented()
@classmethod
def DrawImage(cls, gc, image, x, y, width, height):
raise NotImplemented()
|