enthought-chaco2-4.5.1.orig/0000755000175000017500000000000012516137726014704 5ustar varunvarunenthought-chaco2-4.5.1.orig/MANIFEST.in0000644000175000017500000000015512516137326016437 0ustar varunvaruninclude kiva/agg/agg.i include chaco/tests/data/PngSuite/*.png include chaco/tests/data/PngSuite/LICENSE.txt enthought-chaco2-4.5.1.orig/kiva/0000755000175000017500000000000012516137725015635 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/pdfmetrics.py0000644000175000017500000005143112516137326020350 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2005, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # # Author: Enthought, Inc. # Description: #------------------------------------------------------------------------------ #copyright ReportLab Inc. 2001 #see license.txt for license details #history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/pdfbase/pdfmetrics.py?cvsroot=reportlab # MODIFIED from reportlab's version for the sake of easier integration in Kiva -- David Ascher #$Header $ __version__=''' $Id: pdfmetrics.py,v 1.1 2002/12/03 08:06:29 da Exp $ ''' __doc__=""" This provides a database of font metric information and efines Font, Encoding and TypeFace classes aimed at end users. There are counterparts to some of these in pdfbase/pdfdoc.py, but the latter focus on constructing the right PDF objects. These classes are declarative and focus on letting the user construct and query font objects. The module maintains a registry of font objects at run time. It is independent of the canvas or any particular context. It keeps a registry of Font, TypeFace and Encoding objects. Ideally these would be pre-loaded, but due to a nasty circularity problem we trap attempts to access them and do it on first access. """ import string, os from types import ListType, TupleType # XXX Kiva specific changes defaultEncoding = 'WinAnsiEncoding' # 'WinAnsi' or 'MacRoman' import _fontdata standardFonts = _fontdata.standardFonts standardEncodings = _fontdata.standardEncodings _dummyEncoding=' _not an encoding_ ' # XXX Kiva-specific changes _stringWidth = None _typefaces = {} _encodings = {} _fonts = {} class FontError(Exception): pass class FontNotFoundError(Exception): pass def parseAFMFile(afmFileName): """Quick and dirty - gives back a top-level dictionary with top-level items, and a 'widths' key containing a dictionary of glyph names and widths. Just enough needed for embedding. A better parser would accept options for what data you wwanted, and preserve the order.""" lines = open(afmFileName, 'r').readlines() if len(lines)<=1: #likely to be a MAC file lines = string.split(lines,'\r') if len(lines)<=1: raise ValueError, 'AFM file %s hasn\'t enough data' % afmFileName topLevel = {} glyphLevel = [] lines = map(string.strip, lines) #pass 1 - get the widths inMetrics = 0 # os 'TOP', or 'CHARMETRICS' for line in lines: if line[0:16] == 'StartCharMetrics': inMetrics = 1 elif line[0:14] == 'EndCharMetrics': inMetrics = 0 elif inMetrics: chunks = string.split(line, ';') chunks = map(string.strip, chunks) cidChunk, widthChunk, nameChunk = chunks[0:3] # character ID l, r = string.split(cidChunk) assert l == 'C', 'bad line in font file %s' % line cid = string.atoi(r) # width l, r = string.split(widthChunk) assert l == 'WX', 'bad line in font file %s' % line width = string.atoi(r) # name l, r = string.split(nameChunk) assert l == 'N', 'bad line in font file %s' % line name = r glyphLevel.append((cid, width, name)) # pass 2 font info inHeader = 0 for line in lines: if line[0:16] == 'StartFontMetrics': inHeader = 1 if line[0:16] == 'StartCharMetrics': inHeader = 0 elif inHeader: if line[0:7] == 'Comment': pass try: left, right = string.split(line,' ',1) except: raise ValueError, "Header information error in afm %s: line='%s'" % (afmFileName, line) try: right = string.atoi(right) except: pass topLevel[left] = right return (topLevel, glyphLevel) class TypeFace: def __init__(self, name): self.name = name self.glyphNames = [] self.glyphWidths = {} self.ascent = 0 self.descent = 0 if name == 'ZapfDingbats': self.requiredEncoding = 'ZapfDingbatsEncoding' elif name == 'Symbol': self.requiredEncoding = 'SymbolEncoding' else: self.requiredEncoding = None if name in standardFonts: self.builtIn = 1 self._loadBuiltInData(name) else: self.builtIn = 0 def _loadBuiltInData(self, name): """Called for the built in 14 fonts. Gets their glyph data. We presume they never change so this can be a shared reference.""" self.glyphWidths = _fontdata.widthsByFontGlyph[name] self.glyphNames = self.glyphWidths.keys() self.ascent,self.descent = _fontdata.ascent_descent[name] def findT1File(self, ext='.pfb'): possible_exts = (string.lower(ext), string.upper(ext)) if hasattr(self,'pfbFileName'): r_basename = os.path.splitext(self.pfbFileName)[0] for e in possible_exts: if os.path.isfile(r_basename + e): return r_basename + e try: r = _fontdata.findT1File(self.name) except: afm = bruteForceSearchForAFM(self.name) if afm: if string.lower(ext) == '.pfb': for e in possible_exts: pfb = os.path.splitext(afm)[0] + e if os.path.isfile(pfb): r = pfb else: r = None elif string.lower(ext) == '.afm': r = afm else: r = None if r is None: warnOnce("Can't find %s for face '%s'" % (ext, self.name)) return r def bruteForceSearchForAFM(faceName): """Looks in all AFM files on path for face with given name. Returns AFM file name or None. Ouch!""" import glob # XXX Kiva-specific changes T1SearchPath = [] # XXX should be modified if Kiva wants to support T1 fonts for dirname in T1SearchPath: if not os.path.isdir(dirname): continue possibles = glob.glob(dirname + os.sep + '*.[aA][fF][mM]') for possible in possibles: (topDict, glyphDict) = parseAFMFile(possible) if topDict['FontName'] == faceName: return possible return None #for faceName in standardFonts: # registerTypeFace(TypeFace(faceName)) class Encoding: """Object to help you create and refer to encodings.""" def __init__(self, name, base=None): self.name = name self.frozen = 0 if name in standardEncodings: assert base is None, "Can't have a base encoding for a standard encoding" self.baseEncodingName = name self.vector = _fontdata.encodings[name] elif base == None: # assume based on the usual one self.baseEncodingName = defaultEncoding self.vector = _fontdata.encodings[defaultEncoding] elif isinstance(base, basestring): baseEnc = getEncoding(base) self.baseEncodingName = baseEnc.name self.vector = baseEnc.vector[:] elif type(base) in (ListType, TupleType): self.baseEncodingName = defaultEncoding self.vector = base[:] elif isinstance(base, Encoding): # accept a vector self.baseEncodingName = base.name self.vector = base.vector[:] def __getitem__(self, index): "Return glyph name for that code point, or None" # THIS SHOULD BE INLINED FOR SPEED return self.vector[index] def __setitem__(self, index, value): # should fail if they are frozen assert self.frozen == 0, 'Cannot modify a frozen encoding' if self.vector[index]!=value: L = list(self.vector) L[index] = value self.vector = tuple(L) def freeze(self): self.vector = tuple(self.vector) self.frozen = 1 def isEqual(self, other): return ((enc.name == other.name) and (enc.vector == other.vector)) def modifyRange(self, base, newNames): """Sets a group of character names starting at the code point 'base'.""" assert self.frozen == 0, 'Cannot modify a frozen encoding' idx = base for name in newNames: self.vector[idx] = name idx = idx + 1 def getDifferences(self, otherEnc): """Returns a compact list of the code points differing between two encodings This is in the Adobe format, a list of:: [[b1, name1, name2, name3], [b2, name4]] where b1...bn is the starting code point, and the glyph names following are assigned consecutive code points.""" ranges = [] curRange = None for i in xrange(len(self.vector)): glyph = self.vector[i] if glyph==otherEnc.vector[i]: if curRange: ranges.append(curRange) curRange = [] else: if curRange: curRange.append(glyph) elif glyph: curRange = [i, glyph] if curRange: ranges.append(curRange) return ranges def makePDFObject(self): # XXX Kiva specific change raise NotImplementedError #for encName in standardEncodings: # registerEncoding(Encoding(encName)) class Font: """Represents a font (i.e., combination of face and encoding). Defines suitable machinery for single byte fonts. This is a concrete class which can handle the basic built-in fonts; not clear yet if embedded ones need a new font class or just a new typeface class (which would do the job through composition)""" def __init__(self, name, faceName, encName): self.fontName = name self.face = getTypeFace(faceName) self.encoding= getEncoding(encName) self._calcWidths() # multi byte fonts do their own stringwidth calculations. # signal this here. self._multiByte = 0 def _calcWidths(self): """Vector of widths for stringWidth function""" #synthesize on first request w = [0] * 256 gw = self.face.glyphWidths vec = self.encoding.vector for i in range(256): glyphName = vec[i] if glyphName is not None: try: width = gw[glyphName] w[i] = width except KeyError: # XXX Kiva specific change print 'typeface "%s" does not have a glyph "%s", bad font!' % (self.face.name, glyphName) self.widths = w if not _stringWidth: def stringWidth(self, text, size): """This is the "purist" approach to width. The practical one is to use the stringWidth one which may be optimized in C.""" w = 0 widths = self.widths for ch in text: w = w + widths[ord(ch)] return w * 0.001 * size def _formatWidths(self): "returns a pretty block in PDF Array format to aid inspection" text = '[' for i in range(256): text = text + ' ' + str(self.widths[i]) if i == 255: text = text + ' ]' if i % 16 == 15: text = text + '\n' return text def addObjects(self, doc): # XXX Kiva specific change raise NotImplementedError PFB_MARKER=chr(0x80) PFB_ASCII=chr(1) PFB_BINARY=chr(2) PFB_EOF=chr(3) def _pfbSegLen(p,d): '''compute a pfb style length from the first 4 bytes of string d''' return ((((ord(d[p+3])<<8)|ord(d[p+2])<<8)|ord(d[p+1]))<<8)|ord(d[p]) def _pfbCheck(p,d,m,fn): if d[p]!=PFB_MARKER or d[p+1]!=m: raise ValueError, 'Bad pfb file\'%s\' expected chr(%d)chr(%d) at char %d, got chr(%d)chr(%d)' % (fn,ord(PFB_MARKER),ord(m),p,ord(d[p]),ord(d[p+1])) if m==PFB_EOF: return p = p + 2 l = _pfbSegLen(p,d) p = p + 4 if p+l>len(d): raise ValueError, 'Bad pfb file\'%s\' needed %d+%d bytes have only %d!' % (fn,p,l,len(d)) return p, p+l class EmbeddedType1Face(TypeFace): """A Type 1 font other than one of the basic 14. Its glyph data will be embedded in the PDF file.""" def __init__(self, afmFileName, pfbFileName): # ignore afm file for now self.afmFileName = os.path.abspath(afmFileName) self.pfbFileName = os.path.abspath(pfbFileName) self.requiredEncoding = None self._loadGlyphs(pfbFileName) self._loadMetrics(afmFileName) def _loadGlyphs(self, pfbFileName): """Loads in binary glyph data, and finds the four length measurements needed for the font descriptor.""" assert os.path.isfile(pfbFileName), 'file %s not found' % pfbFileName d = open(pfbFileName, 'rb').read() s1, l1 = _pfbCheck(0,d,PFB_ASCII,pfbFileName) s2, l2 = _pfbCheck(l1,d,PFB_BINARY,pfbFileName) s3, l3 = _pfbCheck(l2,d,PFB_ASCII,pfbFileName) _pfbCheck(l3,d,PFB_EOF,pfbFileName) self._binaryData = d[s1:l1]+d[s2:l2]+d[s3:l3] self._length = len(self._binaryData) self._length1 = l1-s1 self._length2 = l2-s2 self._length3 = l3-s3 def _loadMetrics(self, afmFileName): """Loads in and parses font metrics.""" #assert os.path.isfile(afmFileName), "AFM file %s not found" % afmFileName (topLevel, glyphData) = parseAFMFile(afmFileName) self.name = topLevel['FontName'] self.ascent = topLevel.get('Ascender', 1000) self.descent = topLevel.get('Descender', 0) self.capHeight = topLevel.get('CapHeight', 1000) self.italicAngle = topLevel.get('ItalicAngle', 0) self.stemV = topLevel.get('stemV', 0) self.xHeight = topLevel.get('XHeight', 1000) strBbox = topLevel.get('FontBBox', [0,0,1000,1000]) tokens = string.split(strBbox) self.bbox = [] for tok in tokens: self.bbox.append(string.atoi(tok)) glyphWidths = {} for (cid, width, name) in glyphData: glyphWidths[name] = width self.glyphWidths = glyphWidths self.glyphNames = glyphWidths.keys() self.glyphNames.sort() # for font-specific encodings like Symbol, Dingbats, Carta we # need to make a new encoding as well.... if topLevel.get('EncodingScheme', None) == 'FontSpecific': names = [None] * 256 for (code, width, name) in glyphData: if code >=0 and code <=255: names[code] = name encName = self.name + 'Encoding' self.requiredEncoding = encName enc = Encoding(encName, names) registerEncoding(enc) def addObjects(self, doc): # XXX Kiva specific changes raise NotImplementedError def registerTypeFace(face): assert isinstance(face, TypeFace), 'Not a TypeFace: %s' % face _typefaces[face.name] = face # XXX Kiva specific changes def registerEncoding(enc): assert isinstance(enc, Encoding), 'Not an Encoding: %s' % enc if _encodings.has_key(enc.name): # already got one, complain if they are not the same if enc.isEqual(_encodings[enc.name]): enc.freeze() else: raise FontError('Encoding "%s" already registered with a different name vector!' % enc.Name) else: _encodings[enc.name] = enc enc.freeze() # have not yet dealt with immutability! def registerFont(font): "Registers a font, including setting up info for accelerated stringWidth" #assert isinstance(font, Font), 'Not a Font: %s' % font fontName = font.fontName _fonts[fontName] = font if not font._multiByte: if _stringWidth: _rl_accel.setFontInfo(string.lower(fontName), _dummyEncoding, font.face.ascent, font.face.descent, font.widths) def getTypeFace(faceName): """Lazily constructs known typefaces if not found.""" try: return _typefaces[faceName] except KeyError: # not found, construct it if known if faceName in standardFonts: face = TypeFace(faceName) registerTypeFace(face) #print 'auto-constructing type face %s' % face.name return face else: #try a brute force search afm = bruteForceSearchForAFM(faceName) if afm: for e in ('.pfb', '.PFB'): pfb = os.path.splitext(afm)[0] + e if os.path.isfile(pfb): break assert os.path.isfile(pfb), 'file %s not found!' % pfb face = EmbeddedType1Face(afm, pfb) registerTypeFace(face) return face else: raise def getEncoding(encName): """Lazily constructs known encodings if not found.""" try: return _encodings[encName] except KeyError: if encName in standardEncodings: enc = Encoding(encName) registerEncoding(enc) #print 'auto-constructing encoding %s' % encName return enc else: raise def getFont(fontName): """Lazily constructs known fonts if not found. Names of the form 'face-encoding' will be built if face and encoding are known. Also if the name is just one of the standard 14, it will make up a font in the default encoding.""" try: return _fonts[fontName] except KeyError: #it might have a font-specific encoding e.g. Symbol # or Dingbats. If not, take the default. face = getTypeFace(fontName) if face.requiredEncoding: font = Font(fontName, fontName, face.requiredEncoding) else: font = Font(fontName, fontName, defaultEncoding) registerFont(font) return font def _slowStringWidth(text, fontName, fontSize): """Define this anyway so it can be tested, but whether it is used or not depends on _rl_accel""" font = getFont(fontName) return font.stringWidth(text, fontSize) #this is faster, but will need more special-casing for multi-byte fonts. #wid = getFont(fontName).widths #w = 0 #for ch in text: # w = w + wid[ord(ch)] #return 0.001 * w * fontSize # XXX Kiva specific changes stringWidth = _slowStringWidth def dumpFontData(): print 'Registered Encodings:' keys = _encodings.keys() keys.sort() for encName in keys: print ' ',encName print print 'Registered Typefaces:' faces = _typefaces.keys() faces.sort() for faceName in faces: print ' ',faceName print print 'Registered Fonts:' k = _fonts.keys() k.sort() for key in k: font = _fonts[key] print ' %s (%s/%s)' % (font.fontName, font.face.name, font.encoding.name) def test3widths(texts): # checks all 3 algorithms give same answer, note speed import time for fontName in standardFonts[0:1]: t0 = time.time() for text in texts: l1 = _stringWidth(text, fontName, 10) t1 = time.time() print 'fast stringWidth took %0.4f' % (t1 - t0) t0 = time.time() w = getFont(fontName).widths for text in texts: l2 = 0 for ch in text: l2 = l2 + w[ord(ch)] t1 = time.time() print 'slow stringWidth took %0.4f' % (t1 - t0) t0 = time.time() for text in texts: l3 = getFont(fontName).stringWidth(text, 10) t1 = time.time() print 'class lookup and stringWidth took %0.4f' % (t1 - t0) print def testStringWidthAlgorithms(): rawdata = open('../../rlextra/rml2pdf/doc/rml_user_guide.prep').read() print 'rawdata length %d' % len(rawdata) print 'test one huge string...' test3widths([rawdata]) print words = string.split(rawdata) print 'test %d shorter strings (average length %0.2f chars)...' % (len(words), 1.0*len(rawdata)/len(words)) test3widths(words) def test(): helv = TypeFace('Helvetica') registerTypeFace(helv) print helv.glyphNames[0:30] wombat = TypeFace('Wombat') print wombat.glyphNames registerTypeFace(wombat) dumpFontData() if __name__=='__main__': test() testStringWidthAlgorithms() enthought-chaco2-4.5.1.orig/kiva/agg/0000755000175000017500000000000012564247427016377 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg.i0000644000175000017500000000053512516137326017303 0ustar varunvarun/* -*- c++ -*- */ /* File : example.i */ %module agg #if (SWIG_VERSION > 0x010322) %feature("compactdefaultargs"); #endif // (SWIG_VERSION > 0x010322) %include "constants.i" %include "rgba.i" %include "font_type.i" %include "affine_matrix.i" %include "compiled_path.i" //%include "image.i" %include "graphics_context.i" %include "hit_test.i" enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/0000755000175000017500000000000012516137725017354 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/font_win32_tt/0000755000175000017500000000000012516137725022053 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/font_win32_tt/agg_font_win32_tt.cpp0000644000175000017500000010767412516137326026110 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #include #include "agg_font_win32_tt.h" #include "agg_bitset_iterator.h" #include "agg_renderer_scanline.h" #ifdef AGG_WIN9X_COMPLIANT #define GetGlyphOutlineX GetGlyphOutline #else #define GetGlyphOutlineX GetGlyphOutlineW #endif namespace agg24 { //------------------------------------------------------------------------------ // // This code implements the AUTODIN II polynomial // The variable corresponding to the macro argument "crc" should // be an unsigned long. // Oroginal code by Spencer Garrett // // generated using the AUTODIN II polynomial // x^32 + x^26 + x^23 + x^22 + x^16 + // x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + 1 // //------------------------------------------------------------------------------ static const unsigned crc32tab[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, }; //------------------------------------------------------------------------------ static unsigned calc_crc32(const unsigned char* buf, unsigned size) { unsigned crc = (unsigned)~0; const unsigned char* p; unsigned len = 0; unsigned nr = size; for (len += nr, p = buf; nr--; ++p) { crc = (crc >> 8) ^ crc32tab[(crc ^ *p) & 0xff]; } return ~crc; } //------------------------------------------------------------------------ static inline FIXED dbl_to_fx(double d) { int l; l = int(d * 65536.0); return *(FIXED*)&l; } //------------------------------------------------------------------------ static inline int dbl_to_plain_fx(double d) { return int(d * 65536.0); } //------------------------------------------------------------------------ static inline FIXED negate_fx(const FIXED& fx) { int l = -(*(int*)(&fx)); return *(FIXED*)&l; } //------------------------------------------------------------------------ static inline double fx_to_dbl(const FIXED& p) { return double(p.value) + double(p.fract) * (1.0 / 65536.0); } //------------------------------------------------------------------------ static inline int fx_to_plain_int(const FIXED& fx) { return *(int*)(&fx); } //------------------------------------------------------------------------ static inline int fx_to_int26p6(const FIXED& p) { return (int(p.value) << 6) + (int(p.fract) >> 10); } //------------------------------------------------------------------------ static inline int dbl_to_int26p6(double p) { return int(p * 64.0 + 0.5); } //------------------------------------------------------------------------ template void decompose_win32_glyph_bitmap_mono(const char* gbuf, int w, int h, int x, int y, bool flip_y, Scanline& sl, ScanlineStorage& storage) { int i; int pitch = ((w + 31) >> 5) << 2; const int8u* buf = (const int8u*)gbuf; sl.reset(x, x + w); storage.prepare(); if(flip_y) { buf += pitch * (h - 1); y += h; pitch = -pitch; } for(i = 0; i < h; i++) { sl.reset_spans(); bitset_iterator bits(buf, 0); int j; for(j = 0; j < w; j++) { if(bits.bit()) sl.add_cell(x + j, cover_full); ++bits; } buf += pitch; if(sl.num_spans()) { sl.finalize(y - i - 1); storage.render(sl); } } } //------------------------------------------------------------------------ template void decompose_win32_glyph_bitmap_gray8(const char* gbuf, int w, int h, int x, int y, bool flip_y, Rasterizer& ras, Scanline& sl, ScanlineStorage& storage) { int i, j; int pitch = ((w + 3) >> 2) << 2; const int8u* buf = (const int8u*)gbuf; sl.reset(x, x + w); storage.prepare(); if(flip_y) { buf += pitch * (h - 1); y += h; pitch = -pitch; } for(i = 0; i < h; i++) { sl.reset_spans(); const int8u* p = buf; for(j = 0; j < w; j++) { if(*p) { unsigned v = *p; if(v == 64) v = 255; else v <<= 2; sl.add_cell(x + j, ras.apply_gamma(v)); } ++p; } buf += pitch; if(sl.num_spans()) { sl.finalize(y - i - 1); storage.render(sl); } } } //------------------------------------------------------------------------ template bool decompose_win32_glyph_outline(const char* gbuf, unsigned total_size, bool flip_y, const trans_affine& mtx, PathStorage& path) { const char* cur_glyph = gbuf; const char* end_glyph = gbuf + total_size; double x, y; typedef typename PathStorage::value_type value_type; while(cur_glyph < end_glyph) { const TTPOLYGONHEADER* th = (TTPOLYGONHEADER*)cur_glyph; const char* end_poly = cur_glyph + th->cb; const char* cur_poly = cur_glyph + sizeof(TTPOLYGONHEADER); x = fx_to_dbl(th->pfxStart.x); y = fx_to_dbl(th->pfxStart.y); if(flip_y) y = -y; mtx.transform(&x, &y); path.move_to(value_type(dbl_to_int26p6(x)), value_type(dbl_to_int26p6(y))); while(cur_poly < end_poly) { const TTPOLYCURVE* pc = (const TTPOLYCURVE*)cur_poly; if (pc->wType == TT_PRIM_LINE) { int i; for (i = 0; i < pc->cpfx; i++) { x = fx_to_dbl(pc->apfx[i].x); y = fx_to_dbl(pc->apfx[i].y); if(flip_y) y = -y; mtx.transform(&x, &y); path.line_to(value_type(dbl_to_int26p6(x)), value_type(dbl_to_int26p6(y))); } } if (pc->wType == TT_PRIM_QSPLINE) { int u; for (u = 0; u < pc->cpfx - 1; u++) // Walk through points in spline { POINTFX pnt_b = pc->apfx[u]; // B is always the current point POINTFX pnt_c = pc->apfx[u+1]; if (u < pc->cpfx - 2) // If not on last spline, compute C { // midpoint (x,y) *(int*)&pnt_c.x = (*(int*)&pnt_b.x + *(int*)&pnt_c.x) / 2; *(int*)&pnt_c.y = (*(int*)&pnt_b.y + *(int*)&pnt_c.y) / 2; } double x2, y2; x = fx_to_dbl(pnt_b.x); y = fx_to_dbl(pnt_b.y); x2 = fx_to_dbl(pnt_c.x); y2 = fx_to_dbl(pnt_c.y); if(flip_y) { y = -y; y2 = -y2; } mtx.transform(&x, &y); mtx.transform(&x2, &y2); path.curve3(value_type(dbl_to_int26p6(x)), value_type(dbl_to_int26p6(y)), value_type(dbl_to_int26p6(x2)), value_type(dbl_to_int26p6(y2))); } } cur_poly += sizeof(WORD) * 2 + sizeof(POINTFX) * pc->cpfx; } cur_glyph += th->cb; } return true; } //------------------------------------------------------------------------ font_engine_win32_tt_base::~font_engine_win32_tt_base() { delete [] m_kerning_pairs; delete [] m_gbuf; delete [] m_signature; delete [] m_typeface; if(m_dc && m_old_font) ::SelectObject(m_dc, m_old_font); unsigned i; for(i = 0; i < m_num_fonts; ++i) { delete [] m_font_names[i]; ::DeleteObject(m_fonts[i]); } delete [] m_font_names; delete [] m_fonts; } //------------------------------------------------------------------------ font_engine_win32_tt_base::font_engine_win32_tt_base(bool flag32, HDC dc, unsigned max_fonts) : m_flag32(flag32), m_dc(dc), m_old_font(m_dc ? (HFONT)::GetCurrentObject(m_dc, OBJ_FONT) : 0), m_fonts(new HFONT [max_fonts]), m_num_fonts(0), m_max_fonts(max_fonts), m_font_names(new char* [max_fonts]), m_cur_font(0), m_change_stamp(0), m_typeface(new char [256-16]), m_typeface_len(256-16-1), m_signature(new char [256+256-16]), m_height(0), m_width(0), m_weight(FW_REGULAR), m_italic(false), m_char_set(DEFAULT_CHARSET), m_pitch_and_family(FF_DONTCARE), m_hinting(true), m_flip_y(false), m_font_created(false), m_resolution(0), m_glyph_rendering(glyph_ren_native_gray8), m_glyph_index(0), m_data_size(0), m_data_type(glyph_data_invalid), m_bounds(1,1,0,0), m_advance_x(0.0), m_advance_y(0.0), m_gbuf(new char [buf_size]), m_kerning_pairs(0), m_num_kerning_pairs(0), m_max_kerning_pairs(0), m_path16(), m_path32(), m_curves16(m_path16), m_curves32(m_path32), m_scanline_aa(), m_scanline_bin(), m_scanlines_aa(), m_scanlines_bin(), m_rasterizer() { m_curves16.approximation_scale(4.0); m_curves32.approximation_scale(4.0); memset(&m_matrix, 0, sizeof(m_matrix)); m_matrix.eM11.value = 1; m_matrix.eM22.value = 1; } //------------------------------------------------------------------------ int font_engine_win32_tt_base::find_font(const char* name) const { unsigned i; for(i = 0; i < m_num_fonts; ++i) { if(strcmp(name, m_font_names[i]) == 0) return i; } return -1; } //------------------------------------------------------------------------ bool font_engine_win32_tt_base::create_font(const char* typeface_, glyph_rendering ren_type) { if(m_dc) { unsigned len = strlen(typeface_); if(len > m_typeface_len) { delete [] m_signature; delete [] m_typeface; m_typeface = new char [len + 32]; m_signature = new char [len + 32 + 256]; m_typeface_len = len + 32 - 1; } strcpy(m_typeface, typeface_); int h = m_height; int w = m_width; if(m_resolution) { h = ::MulDiv(m_height, m_resolution, 72); w = ::MulDiv(m_width, m_resolution, 72); } m_glyph_rendering = ren_type; update_signature(); int idx = find_font(m_signature); if(idx >= 0) { m_cur_font = m_fonts[idx]; ::SelectObject(m_dc, m_cur_font); m_num_kerning_pairs = 0; return true; } else { m_cur_font = ::CreateFont(-h, // height of font w, // average character width 0, // angle of escapement 0, // base-line orientation angle m_weight, // font weight m_italic, // italic attribute option 0, // underline attribute option 0, // strikeout attribute option m_char_set, // character set identifier OUT_DEFAULT_PRECIS, // output precision CLIP_DEFAULT_PRECIS, // clipping precision ANTIALIASED_QUALITY, // output quality m_pitch_and_family, // pitch and family m_typeface); // typeface name if(m_cur_font) { if(m_num_fonts >= m_max_fonts) { delete [] m_font_names[0]; if(m_old_font) ::SelectObject(m_dc, m_old_font); ::DeleteObject(m_fonts[0]); memcpy(m_fonts, m_fonts + 1, (m_max_fonts - 1) * sizeof(HFONT)); memcpy(m_font_names, m_font_names + 1, (m_max_fonts - 1) * sizeof(char*)); m_num_fonts = m_max_fonts - 1; } update_signature(); m_font_names[m_num_fonts] = new char[strlen(m_signature) + 1]; strcpy(m_font_names[m_num_fonts], m_signature); m_fonts[m_num_fonts] = m_cur_font; ++m_num_fonts; ::SelectObject(m_dc, m_cur_font); m_num_kerning_pairs = 0; return true; } } } return false; } //------------------------------------------------------------------------ bool font_engine_win32_tt_base::create_font(const char* typeface_, glyph_rendering ren_type, double height_, double width_, int weight_, bool italic_, DWORD char_set_, DWORD pitch_and_family_) { height(height_); width(width_); weight(weight_); italic(italic_); char_set(char_set_); pitch_and_family(pitch_and_family_); return create_font(typeface_, ren_type); } //------------------------------------------------------------------------ void font_engine_win32_tt_base::update_signature() { m_signature[0] = 0; if(m_dc && m_cur_font) { unsigned gamma_hash = 0; if(m_glyph_rendering == glyph_ren_native_gray8 || m_glyph_rendering == glyph_ren_agg_mono || m_glyph_rendering == glyph_ren_agg_gray8) { unsigned char gamma_table[rasterizer_scanline_aa<>::aa_scale]; unsigned i; for(i = 0; i < rasterizer_scanline_aa<>::aa_scale; ++i) { gamma_table[i] = m_rasterizer.apply_gamma(i); } gamma_hash = calc_crc32(gamma_table, sizeof(gamma_table)); } sprintf(m_signature, "%s,%u,%d,%d:%dx%d,%d,%d,%d,%d,%d,%08X", m_typeface, m_char_set, int(m_glyph_rendering), m_resolution, m_height, m_width, m_weight, int(m_italic), int(m_hinting), int(m_flip_y), int(m_pitch_and_family), gamma_hash); if(m_glyph_rendering == glyph_ren_outline || m_glyph_rendering == glyph_ren_agg_mono || m_glyph_rendering == glyph_ren_agg_gray8) { double mtx[6]; char buf[100]; m_affine.store_to(mtx); sprintf(buf, ",%08X%08X%08X%08X%08X%08X", dbl_to_plain_fx(mtx[0]), dbl_to_plain_fx(mtx[1]), dbl_to_plain_fx(mtx[2]), dbl_to_plain_fx(mtx[3]), dbl_to_plain_fx(mtx[4]), dbl_to_plain_fx(mtx[5])); strcat(m_signature, buf); } ++m_change_stamp; } } //------------------------------------------------------------------------ bool font_engine_win32_tt_base::prepare_glyph(unsigned glyph_code) { if(m_dc && m_cur_font) { int format = GGO_BITMAP; switch(m_glyph_rendering) { case glyph_ren_native_gray8: format = GGO_GRAY8_BITMAP; break; case glyph_ren_outline: case glyph_ren_agg_mono: case glyph_ren_agg_gray8: format = GGO_NATIVE; break; } #ifndef GGO_UNHINTED // For compatibility with old SDKs. #define GGO_UNHINTED 0x0100 #endif if(!m_hinting) format |= GGO_UNHINTED; GLYPHMETRICS gm; int total_size = GetGlyphOutlineX(m_dc, glyph_code, format, &gm, buf_size, (void*)m_gbuf, &m_matrix); if(total_size < 0) { // GetGlyphOutline() fails when being called for // GGO_GRAY8_BITMAP and white space (stupid Microsoft). // It doesn't even initialize the glyph metrics // structure. So, we have to query the metrics // separately (basically we need gmCellIncX). int total_size = GetGlyphOutlineX(m_dc, glyph_code, GGO_METRICS, &gm, buf_size, (void*)m_gbuf, &m_matrix); if(total_size < 0) return false; gm.gmBlackBoxX = gm.gmBlackBoxY = 0; total_size = 0; } m_glyph_index = glyph_code; m_advance_x = gm.gmCellIncX; m_advance_y = -gm.gmCellIncY; switch(m_glyph_rendering) { case glyph_ren_native_mono: decompose_win32_glyph_bitmap_mono(m_gbuf, gm.gmBlackBoxX, gm.gmBlackBoxY, gm.gmptGlyphOrigin.x, m_flip_y ? -gm.gmptGlyphOrigin.y : gm.gmptGlyphOrigin.y, m_flip_y, m_scanline_bin, m_scanlines_bin); m_bounds.x1 = m_scanlines_bin.min_x(); m_bounds.y1 = m_scanlines_bin.min_y(); m_bounds.x2 = m_scanlines_bin.max_x() + 1; m_bounds.y2 = m_scanlines_bin.max_y() + 1; m_data_size = m_scanlines_bin.byte_size(); m_data_type = glyph_data_mono; return true; case glyph_ren_native_gray8: decompose_win32_glyph_bitmap_gray8(m_gbuf, gm.gmBlackBoxX, gm.gmBlackBoxY, gm.gmptGlyphOrigin.x, m_flip_y ? -gm.gmptGlyphOrigin.y : gm.gmptGlyphOrigin.y, m_flip_y, m_rasterizer, m_scanline_aa, m_scanlines_aa); m_bounds.x1 = m_scanlines_aa.min_x(); m_bounds.y1 = m_scanlines_aa.min_y(); m_bounds.x2 = m_scanlines_aa.max_x() + 1; m_bounds.y2 = m_scanlines_aa.max_y() + 1; m_data_size = m_scanlines_aa.byte_size(); m_data_type = glyph_data_gray8; return true; case glyph_ren_outline: m_affine.transform(&m_advance_x, &m_advance_y); if(m_flag32) { m_path32.remove_all(); if(decompose_win32_glyph_outline(m_gbuf, total_size, m_flip_y, m_affine, m_path32)) { rect_d bnd = m_path32.bounding_rect(); m_data_size = m_path32.byte_size(); m_data_type = glyph_data_outline; m_bounds.x1 = int(floor(bnd.x1)); m_bounds.y1 = int(floor(bnd.y1)); m_bounds.x2 = int(ceil(bnd.x2)); m_bounds.y2 = int(ceil(bnd.y2)); return true; } } else { m_path16.remove_all(); if(decompose_win32_glyph_outline(m_gbuf, total_size, m_flip_y, m_affine, m_path16)) { rect_d bnd = m_path16.bounding_rect(); m_data_size = m_path16.byte_size(); m_data_type = glyph_data_outline; m_bounds.x1 = int(floor(bnd.x1)); m_bounds.y1 = int(floor(bnd.y1)); m_bounds.x2 = int(ceil(bnd.x2)); m_bounds.y2 = int(ceil(bnd.y2)); return true; } } break; case glyph_ren_agg_mono: m_rasterizer.reset(); m_affine.transform(&m_advance_x, &m_advance_y); if(m_flag32) { m_path32.remove_all(); decompose_win32_glyph_outline(m_gbuf, total_size, m_flip_y, m_affine, m_path32); m_rasterizer.add_path(m_curves32); } else { m_path16.remove_all(); decompose_win32_glyph_outline(m_gbuf, total_size, m_flip_y, m_affine, m_path16); m_rasterizer.add_path(m_curves16); } m_scanlines_bin.prepare(); // Remove all render_scanlines(m_rasterizer, m_scanline_bin, m_scanlines_bin); m_bounds.x1 = m_scanlines_bin.min_x(); m_bounds.y1 = m_scanlines_bin.min_y(); m_bounds.x2 = m_scanlines_bin.max_x() + 1; m_bounds.y2 = m_scanlines_bin.max_y() + 1; m_data_size = m_scanlines_bin.byte_size(); m_data_type = glyph_data_mono; return true; case glyph_ren_agg_gray8: m_rasterizer.reset(); m_affine.transform(&m_advance_x, &m_advance_y); if(m_flag32) { m_path32.remove_all(); decompose_win32_glyph_outline(m_gbuf, total_size, m_flip_y, m_affine, m_path32); m_rasterizer.add_path(m_curves32); } else { m_path16.remove_all(); decompose_win32_glyph_outline(m_gbuf, total_size, m_flip_y, m_affine, m_path16); m_rasterizer.add_path(m_curves16); } m_scanlines_aa.prepare(); // Remove all render_scanlines(m_rasterizer, m_scanline_aa, m_scanlines_aa); m_bounds.x1 = m_scanlines_aa.min_x(); m_bounds.y1 = m_scanlines_aa.min_y(); m_bounds.x2 = m_scanlines_aa.max_x() + 1; m_bounds.y2 = m_scanlines_aa.max_y() + 1; m_data_size = m_scanlines_aa.byte_size(); m_data_type = glyph_data_gray8; return true; } } return false; } //------------------------------------------------------------------------ void font_engine_win32_tt_base::write_glyph_to(int8u* data) const { if(data && m_data_size) { switch(m_data_type) { case glyph_data_mono: m_scanlines_bin.serialize(data); break; case glyph_data_gray8: m_scanlines_aa.serialize(data); break; case glyph_data_outline: if(m_flag32) { m_path32.serialize(data); } else { m_path16.serialize(data); } break; } } } //------------------------------------------------------------------------ static bool pair_less(const KERNINGPAIR& v1, const KERNINGPAIR& v2) { if(v1.wFirst != v2.wFirst) return v1.wFirst < v2.wFirst; return v1.wSecond < v2.wSecond; } //------------------------------------------------------------------------ void font_engine_win32_tt_base::sort_kerning_pairs() { pod_array_adaptor pairs(m_kerning_pairs, m_num_kerning_pairs); quick_sort(pairs, pair_less); } //------------------------------------------------------------------------ void font_engine_win32_tt_base::load_kerning_pairs() { if(m_dc && m_cur_font) { if(m_kerning_pairs == 0) { m_kerning_pairs = new KERNINGPAIR [16384-16]; m_max_kerning_pairs = 16384-16; } m_num_kerning_pairs = ::GetKerningPairs(m_dc, m_max_kerning_pairs, m_kerning_pairs); if(m_num_kerning_pairs) { // Check to see if the kerning pairs are sorted and // sort them if they are not. //---------------- unsigned i; for(i = 1; i < m_num_kerning_pairs; ++i) { if(!pair_less(m_kerning_pairs[i - 1], m_kerning_pairs[i])) { sort_kerning_pairs(); break; } } } } } //------------------------------------------------------------------------ bool font_engine_win32_tt_base::add_kerning(unsigned first, unsigned second, double* x, double* y) { if(m_dc && m_cur_font) { if(m_num_kerning_pairs == 0) { load_kerning_pairs(); } int end = m_num_kerning_pairs - 1; int beg = 0; KERNINGPAIR t; t.wFirst = (WORD)first; t.wSecond = (WORD)second; while(beg <= end) { int mid = (end + beg) / 2; if(m_kerning_pairs[mid].wFirst == t.wFirst && m_kerning_pairs[mid].wSecond == t.wSecond) { double dx = m_kerning_pairs[mid].iKernAmount; double dy = 0.0; if(m_glyph_rendering == glyph_ren_outline || m_glyph_rendering == glyph_ren_agg_mono || m_glyph_rendering == glyph_ren_agg_gray8) { m_affine.transform_2x2(&dx, &dy); } *x += dx; *y += dy; return true; } else if(pair_less(t, m_kerning_pairs[mid])) { end = mid - 1; } else { beg = mid + 1; } } return false; } return false; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/font_win32_tt/Makefile.am0000644000175000017500000000077712516137326024117 0ustar varunvarun## this needs more work, and is intended to work in a unix cross ## compilation toolchain, or in something like msys if ENABLE_WIN32_TT aggincludedir = $(includedir)/agg2 agginclude_HEADERS = agg_font_win32_tt.h lib_LTLIBRARIES = libaggfontwin32tt.la libaggfontwin32tt_la_LDFLAGS = -no-undefined -version-info @AGG_LIB_VERSION@ @WINDOWS_LIBS@ ../src/libagg.la libaggfontwin32tt_la_SOURCES = agg_font_win32_tt.cpp libaggfontwin32tt_la_CXXFLAGS = -I$(top_srcdir)/include @WINDOWS_CFLAGS@ endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/font_win32_tt/agg_font_win32_tt.h0000644000175000017500000002236512516137326025546 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_FONT_WIN32_TT_INCLUDED #define AGG_FONT_WIN32_TT_INCLUDED #include #include "agg_scanline_storage_aa.h" #include "agg_scanline_storage_bin.h" #include "agg_scanline_u.h" #include "agg_scanline_bin.h" #include "agg_path_storage_integer.h" #include "agg_rasterizer_scanline_aa.h" #include "agg_conv_curve.h" #include "agg_trans_affine.h" #include "agg_font_cache_manager.h" namespace agg24 { //-----------------------------------------------font_engine_win32_tt_base class font_engine_win32_tt_base { enum { buf_size = 32768-32 }; public: //-------------------------------------------------------------------- typedef serialized_scanlines_adaptor_aa gray8_adaptor_type; typedef serialized_scanlines_adaptor_bin mono_adaptor_type; typedef scanline_storage_aa8 scanlines_aa_type; typedef scanline_storage_bin scanlines_bin_type; //-------------------------------------------------------------------- ~font_engine_win32_tt_base(); font_engine_win32_tt_base(bool flag32, HDC dc, unsigned max_fonts = 32); // Set font parameters //-------------------------------------------------------------------- void resolution(unsigned dpi) { m_resolution = unsigned(dpi); } void height(double h) { m_height = unsigned(h); } void width(double w) { m_width = unsigned(w); } void weight(int w) { m_weight = w; } void italic(bool it) { m_italic = it; } void char_set(DWORD c) { m_char_set = c; } void pitch_and_family(DWORD p){ m_pitch_and_family = p; } void flip_y(bool flip) { m_flip_y = flip; } void hinting(bool h) { m_hinting = h; } bool create_font(const char* typeface_, glyph_rendering ren_type); bool create_font(const char* typeface_, glyph_rendering ren_type, double height_, double width_=0.0, int weight_=FW_REGULAR, bool italic_=false, DWORD char_set_=ANSI_CHARSET, DWORD pitch_and_family_=FF_DONTCARE); // Set Gamma //-------------------------------------------------------------------- template void gamma(const GammaF& f) { m_rasterizer.gamma(f); } //-------------------------------------------------------------------- void transform(const agg24::trans_affine& mtx) { m_affine = mtx; } // Accessors //-------------------------------------------------------------------- unsigned resolution() const { return m_resolution; } const char* typeface() const { return m_typeface; } double height() const { return m_height; } double width() const { return m_width; } int weight() const { return m_weight; } bool italic() const { return m_italic; } DWORD char_set() const { return m_char_set; } DWORD pitch_and_family() const { return m_pitch_and_family; } bool hinting() const { return m_hinting; } bool flip_y() const { return m_flip_y; } // Interface mandatory to implement for font_cache_manager //-------------------------------------------------------------------- const char* font_signature() const { return m_signature; } int change_stamp() const { return m_change_stamp; } bool prepare_glyph(unsigned glyph_code); unsigned glyph_index() const { return m_glyph_index; } unsigned data_size() const { return m_data_size; } glyph_data_type data_type() const { return m_data_type; } const rect_i& bounds() const { return m_bounds; } double advance_x() const { return m_advance_x; } double advance_y() const { return m_advance_y; } void write_glyph_to(int8u* data) const; bool add_kerning(unsigned first, unsigned second, double* x, double* y); private: font_engine_win32_tt_base(const font_engine_win32_tt_base&); const font_engine_win32_tt_base& operator = (const font_engine_win32_tt_base&); void update_signature(); void load_kerning_pairs(); void sort_kerning_pairs(); int find_font(const char* name) const; bool m_flag32; HDC m_dc; HFONT m_old_font; HFONT* m_fonts; unsigned m_num_fonts; unsigned m_max_fonts; char** m_font_names; HFONT m_cur_font; int m_change_stamp; char* m_typeface; unsigned m_typeface_len; char* m_signature; unsigned m_height; unsigned m_width; int m_weight; bool m_italic; DWORD m_char_set; DWORD m_pitch_and_family; bool m_hinting; bool m_flip_y; bool m_font_created; unsigned m_resolution; glyph_rendering m_glyph_rendering; unsigned m_glyph_index; unsigned m_data_size; glyph_data_type m_data_type; rect_i m_bounds; double m_advance_x; double m_advance_y; MAT2 m_matrix; char* m_gbuf; KERNINGPAIR* m_kerning_pairs; unsigned m_num_kerning_pairs; unsigned m_max_kerning_pairs; trans_affine m_affine; path_storage_integer m_path16; path_storage_integer m_path32; conv_curve > m_curves16; conv_curve > m_curves32; scanline_u8 m_scanline_aa; scanline_bin m_scanline_bin; scanlines_aa_type m_scanlines_aa; scanlines_bin_type m_scanlines_bin; rasterizer_scanline_aa<> m_rasterizer; }; //------------------------------------------------font_engine_win32_tt_int16 // This class uses values of type int16 (10.6 format) for the vector cache. // The vector cache is compact, but when rendering glyphs of height // more that 200 there integer overflow can occur. // class font_engine_win32_tt_int16 : public font_engine_win32_tt_base { public: typedef serialized_integer_path_adaptor path_adaptor_type; typedef font_engine_win32_tt_base::gray8_adaptor_type gray8_adaptor_type; typedef font_engine_win32_tt_base::mono_adaptor_type mono_adaptor_type; typedef font_engine_win32_tt_base::scanlines_aa_type scanlines_aa_type; typedef font_engine_win32_tt_base::scanlines_bin_type scanlines_bin_type; font_engine_win32_tt_int16(HDC dc, unsigned max_fonts = 32) : font_engine_win32_tt_base(false, dc, max_fonts) {} }; //------------------------------------------------font_engine_win32_tt_int32 // This class uses values of type int32 (26.6 format) for the vector cache. // The vector cache is twice larger than in font_engine_win32_tt_int16, // but it allows you to render glyphs of very large sizes. // class font_engine_win32_tt_int32 : public font_engine_win32_tt_base { public: typedef serialized_integer_path_adaptor path_adaptor_type; typedef font_engine_win32_tt_base::gray8_adaptor_type gray8_adaptor_type; typedef font_engine_win32_tt_base::mono_adaptor_type mono_adaptor_type; typedef font_engine_win32_tt_base::scanlines_aa_type scanlines_aa_type; typedef font_engine_win32_tt_base::scanlines_bin_type scanlines_bin_type; font_engine_win32_tt_int32(HDC dc, unsigned max_fonts = 32) : font_engine_win32_tt_base(true, dc, max_fonts) {} }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/Makefile0000644000175000017500000000013612516137326021011 0ustar varunvarunall: lib src/libagg.a: cd src; make lib: src/libagg.a clean: cd src; make clean enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/libagg.m40000644000175000017500000000165512516137326021047 0ustar varunvarun# Configure paths for libagg # Kirill Smelkov 2005-10-23, based on freetype2.m4 by Marcelo Magallon # AC_CHECK_LIBAGG([MINIMUM-VERSION [, ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]]) # Test for libagg, and define LIBAGG_CFLAGS and LIBAGG_LIBS # AC_DEFUN([AC_CHECK_LIBAGG], [ # Get the cflags and libraries from pkg-config libagg ... AC_ARG_WITH([libagg], AS_HELP_STRING([--with-libagg=PREFIX], [Prefix where libagg is installed (optional)]), [libagg_prefix="$withval"], [libagg_prefix=""]) libagg_name=libagg if test "x$libagg_prefix" != "x"; then libagg_name="$libagg_prefix/lib/pkgconfig/libagg.pc" fi PKG_CHECK_MODULES([LIBAGG], "$libagg_name", success=yes, success=no) if test "x$success" = xyes; then ifelse([$2], , :, [$2]) AC_SUBST([LIBAGG_CFLAGS]) AC_SUBST([LIBAGG_LIBS]) else ifelse([$3], , :, [$3]) fi ]) # end of libagg.m4 enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/Makefile.in.Darwin.SDL0000644000175000017500000000033612516137326023264 0ustar varunvarunAGGLIBS= -lagg -L/usr/local/lib -lSDLmain -lSDL -framework Cocoa -framework OpenGL AGGCXXFLAGS = -O3 -I/Library/Frameworks/SDL.framework/Headers -L/usr/lib CXX = g++ C = gcc #CXX = icc LIB = ar cr .PHONY : clean enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/readme0000644000175000017500000000402012516137326020525 0ustar varunvarunThe Anti-Grain Geometry Project A high quality rendering engine for C++ http://antigrain.com Anti-Grain Geometry - Version 2.4 Copyright (C) 2002-2005 Maxim Shemanarev (McSeem) Permission to copy, use, modify, sell and distribute this software is granted provided this copyright notice appears in all copies. This software is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose. --------------------------------- Use automake to build the library. If automake is not available you still can use the old make. There is a very simple Makefile that can be used. Note that if you use automake it will overwrite Makefile. --------------------------------- If building on AmigaOS 4.0 or higher type the following for instructions on what targets are available. make -f Makefile.AmigaOS To just build and install AGG into the standard AmigaOS SDK ready for use type: make -f Makefile.AmigaOS install If you just want to build one demo (e.g. lion) use: make -f Makefile.AmigaOS bin/lion If you have any questions about the AmigaOS port please contact Steven Solie (ssolie@telus.net) for help. --------------------------------- To build all examples using SDL (Mac or Linux) just type: cd /examples/sdl make Individual examples can be built with make aa_test In the same way the native Carbon examples can be built with cd /examples/macosx_carbon make In both cases the static library will be built (if it was not already) from the existing global Makefile in /src/. The Makefiles for both SDL and Carbon will also attempt to download the required .bmp files if they are not found in the system for a given example. If the files could not be fetched (wget) the user will receive a message explaining where to download the samples from (sphere.bmp, etc.) Since all programs reside in the same directory there is no need to duplicate the .bmp files for each program that needs to use them. --------------------------------- enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/libagg.pc.in0000644000175000017500000000042512516137326021530 0ustar varunvarunprefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@/agg2 Name: libagg Description: Anti Grain Geometry - A High Quality Rendering Engine for C++ Version: 2.3 Libs: -L${libdir} -Wl,-rpath,${exec_prefix}/lib -lagg Cflags: -I${includedir} enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/configure.in0000644000175000017500000001175312516137326021671 0ustar varunvarunAC_INIT(src/agg_arc.cpp) # give me a source file, any source file... AC_CANONICAL_TARGET AC_CONFIG_HEADERS(include/config.h) AM_INIT_AUTOMAKE(agg, 2.4.0) dnl Checks for programs. AC_PROG_CC AC_PROG_CXX AC_ISC_POSIX AM_C_PROTOTYPES if test "x$U" != "x"; then AC_MSG_ERROR(Compiler not ANSI compliant) fi AM_PROG_LIBTOOL AC_PROG_INSTALL dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_ARG_ENABLE(examples, AC_HELP_STRING([--enable-examples],[Antigrain examples])) AM_CONDITIONAL(ENABLE_EXAMPLES,test x$enable_examples != xno) AC_ARG_ENABLE(ctrl, AC_HELP_STRING([--enable-ctrl],[a gui libray used in examples])) AC_ARG_ENABLE(platform, AC_HELP_STRING([--enable-platform],[portable platform layers])) if test x$enable_examples != xno ; then enable_platform="yes" fi if test x$enable_platform != xno ; then enable_ctrl="yes" fi AM_CONDITIONAL(ENABLE_CTRL,test x$enable_ctrl != xno) # used as platform library in examples: # todo, make the PREFERED_PLATFORM selectable, after the set of possible # Platforms to link the examples have been evaluated. PREFERED_PLATFORM=X11 case "$host" in *darwin* ) OSX_LIBS="-framework Carbon -framework QuickTime" OSX_CFLAGS="-I/System/Library/Frameworks/Carbon.framework/Headers -I/System/Library/Frameworks/QuickTime.framework/Headers " AC_SUBST(OSX_CFLAGS) AC_SUBST(OSX_LIBS) osx_host=yes PREFERED_PLATFORM=mac ;; dnl #### Check if we are compiling for win32 ##### *mingw*) win32_host=yes WINDOWS_LIBS=-lgdi32 WINDOWS_CFLAGS= AC_SUBST(WINDOWS_CFLAGS) AC_SUBST(WINDOWS_LIBS) PREFERED_PLATFORM=win32 ;; esac AM_CONDITIONAL(ENABLE_WIN32,[test x$win32_host = xyes -a x$enable_platform != xno ]) AM_CONDITIONAL(ENABLE_OSX,[test x$osx_host = xyes -a x$enable_platform != xno ]) dnl then enable font_win32tt AC_ARG_ENABLE(win32tt, AC_HELP_STRING([--enable-win32tt],[Win32 TrueType font support library]), enable_tt=$enable_win32tt, enable_tt=$win32_host) AM_CONDITIONAL(ENABLE_WIN32_TT, test x$enable_tt = xyes ) dnl ######### Check for FT2: ##################### ft_enabled="" PKG_CHECK_MODULES([FREETYPE], freetype2, [ft_enabled="yes"], AC_MSG_WARN([*** Freetype2 not found! Building without font library.]) ) AC_ARG_ENABLE(freetype, AC_HELP_STRING([--enable-freetype],[freetype font support library]), ft_enabled=$enable_freetype) AM_CONDITIONAL(ENABLE_FT,[test xyes = x$ft_enabled]) dnl ############################################### dnl ######### Ask for GPC: ####################### AC_ARG_ENABLE(gpc, AC_HELP_STRING([--enable-gpc],[gpc polygon clipper library]) ) AM_CONDITIONAL(ENABLE_GPC,[test xyes = x$enable_gpc]) dnl ############################################### dnl ######### Check for SDL: ##################### dnl the sdl script pollutes our global values: temp_LIBS="$LIBS" temp_CFLAGS="$CFLAGS" temp_CXXFLAGS="$CXXFLAGS" sdl_enabled="" SDL_VERSION=1.2.0 AM_PATH_SDL($SDL_VERSION, [sdl_enabled="yes"], AC_MSG_WARN([*** SDL version $SDL_VERSION not found! Omitting sdl layer.]) ) dnl ### Restore old values CFLAGS=$temp_CFLAGS CXXFLAGS=$temp_CXXFLAGS LIBS=$temp_LIBS dnl ### the sdl script already does that: dnl AC_SUBST(SDL_CFLAGS) dnl AC_SUBST(SDL_LIBS) AM_CONDITIONAL(ENABLE_SDL,[test xyes = x$sdl_enabled -a xno != x$enable_platform -a x$win32_host != xyes]) dnl ############################################### dnl ######### Checking for X11: ################## AC_PATH_X if test "$no_x" = "yes"; then AC_MSG_WARN([*** X11 not found! Omitting X11 layer.]) fi AM_CONDITIONAL(ENABLE_X11,[test x$no_x = x -a xno != x$enable_platform -a x$win32_host != xyes]) AC_SUBST(x_includes) AC_SUBST(x_libraries) dnl ############################################### dnl Settung up library version AGG_LIB_VERSION="2:4:0" dnl current-´ / / dnl revision--´ / dnl age---´ dnl Update the version information only immediately before a public release of antigrain dnl If the library source code has changed, increment revision (c:r:a becomes c:r+1:a). dnl If any interfaces have been added, removed, or changed since the last update, dnl increment current, and set revision to 0. dnl If any interfaces have been added since the last public release, then increment age. dnl If any interfaces have been removed since the last public release, then set age to 0. AC_SUBST(AGG_LIB_VERSION) AC_SUBST(PREFERED_PLATFORM) AC_OUTPUT( Makefile libagg.pc gpc/Makefile font_freetype/Makefile font_win32_tt/Makefile src/Makefile src/ctrl/Makefile src/platform/Makefile src/platform/X11/Makefile src/platform/sdl/Makefile src/platform/mac/Makefile src/platform/win32/Makefile src/platform/BeOS/Makefile src/platform/AmigaOS/Makefile include/Makefile include/ctrl/Makefile include/util/Makefile include/platform/Makefile examples/Makefile ) enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/Makefile.in.Linux.SDL0000644000175000017500000000020612516137326023133 0ustar varunvarunAGGLIBS= -lagg -lSDL AGGCXXFLAGS = -O3 -I/usr/include/SDL -L/usr/lib CXX = g++ C = gcc #CXX = icc LIB = ar cr .PHONY : clean enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/copying0000644000175000017500000000505512516137326020751 0ustar varunvarunThe Anti-Grain Geometry Project A high quality rendering engine for C++ http://antigrain.com Anti-Grain Geometry has dual licensing model. The Modified BSD License was first added in version v2.4 just for convenience. It is a simple, permissive non-copyleft free software license, compatible with the GNU GPL. It's well proven and recognizable. See http://www.fsf.org/licensing/licenses/index_html#ModifiedBSD for details. Note that the Modified BSD license DOES NOT restrict your rights if you choose the Anti-Grain Geometry Public License. Anti-Grain Geometry Public License ==================================================== Anti-Grain Geometry - Version 2.4 Copyright (C) 2002-2005 Maxim Shemanarev (McSeem) Permission to copy, use, modify, sell and distribute this software is granted provided this copyright notice appears in all copies. This software is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose. Modified BSD License ==================================================== Anti-Grain Geometry - Version 2.4 Copyright (C) 2002-2005 Maxim Shemanarev (McSeem) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/authors0000644000175000017500000000012712516137326020761 0ustar varunvarunAnti-Grain Geometry - Version 2.4 Copyright (C) 2002-2005 Maxim Shemanarev (McSeem) enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/Makefile.in.IRIX640000644000175000017500000000012512516137326022340 0ustar varunvarunAGGLIBS= -lagg AGGCXXFLAGS = CXX = CC C = cc LIB = CC -ar -o .PHONY : clean enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/Makefile.in.Darwin0000644000175000017500000000021112516137326022633 0ustar varunvarunAGGLIBS= -lagg AGGCXXFLAGS = -O3 -I/usr/X11R6/include -L/usr/X11R6/lib CXX = g++ C = gcc #CXX = icc LIB = ar cr .PHONY : clean enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/Makefile.AmigaOS0000644000175000017500000002722012516137326022273 0ustar varunvarun# # Makefile for AmigaOS 4.0 # .PHONY : help all setup lib examples svg freetype clean install wget CXX = g++ CXXFLAGS = -mcrt=clib2 -O3 -Iinclude -Igpc -Ifont_freetype CXXLIBS = -Llib -lagg CC = gcc CFLAGS = -mcrt=clib2 -O3 AR = ar ARFLAGS = cr STRIP = strip -R.comment AGGLIBNAME = lib/libagg.a SVGNAME = bin/svg_test EXAMPLES =\ bin/aa_demo \ bin/aa_test \ bin/alpha_gradient \ bin/alpha_mask \ bin/alpha_mask2 \ bin/alpha_mask3 \ bin/bezier_div \ bin/bspline \ bin/circles \ bin/component_rendering \ bin/compositing \ bin/compositing2 \ bin/conv_contour \ bin/conv_dash_marker \ bin/conv_stroke \ bin/distortions \ bin/flash_rasterizer \ bin/flash_rasterizer2 \ bin/gamma_correction \ bin/gamma_ctrl \ bin/gamma_tuner \ bin/gouraud \ bin/gouraud_mesh \ bin/gpc_test \ bin/gradients \ bin/graph_test \ bin/idea \ bin/image_alpha \ bin/image_filters \ bin/image_filters2 \ bin/image_fltr_graph \ bin/image_perspective \ bin/image_resample \ bin/image_transforms \ bin/image1 \ bin/line_patterns_clip \ bin/line_patterns \ bin/lion \ bin/lion_lens \ bin/lion_outline \ bin/mol_view \ bin/multi_clip \ bin/pattern_fill \ bin/pattern_perspective \ bin/pattern_resample \ bin/perspective \ bin/polymorphic_renderer \ bin/raster_text \ bin/rasterizers \ bin/rasterizers2 \ bin/rounded_rect \ bin/scanline_boolean \ bin/scanline_boolean2 \ bin/simple_blur \ bin/trans_polar FREETYPE_EXAMPLES=\ bin/freetype_test \ bin/trans_curve1_ft \ bin/trans_curve2_ft PLATFORM_SRC=\ src/platform/AmigaOS/agg_platform_support.cpp FREETYPE_SRC=\ font_freetype/agg_font_freetype.cpp LIB_CXXSRC=\ src/agg_arc.cpp \ src/agg_arrowhead.cpp \ src/agg_bezier_arc.cpp \ src/agg_bspline.cpp \ src/agg_curves.cpp \ src/agg_embedded_raster_fonts.cpp \ src/agg_gsv_text.cpp \ src/agg_image_filters.cpp \ src/agg_line_aa_basics.cpp \ src/agg_line_profile_aa.cpp \ src/agg_rounded_rect.cpp \ src/agg_sqrt_tables.cpp \ src/agg_trans_affine.cpp \ src/agg_trans_double_path.cpp \ src/agg_trans_single_path.cpp \ src/agg_trans_warp_magnifier.cpp \ src/agg_vcgen_bspline.cpp \ src/agg_vcgen_contour.cpp \ src/agg_vcgen_dash.cpp \ src/agg_vcgen_markers_term.cpp \ src/agg_vcgen_smooth_poly1.cpp \ src/agg_vcgen_stroke.cpp \ src/agg_vpgen_clip_polygon.cpp \ src/agg_vpgen_clip_polyline.cpp \ src/agg_vpgen_segmentator.cpp \ src/ctrl/agg_bezier_ctrl.cpp \ src/ctrl/agg_cbox_ctrl.cpp \ src/ctrl/agg_gamma_ctrl.cpp \ src/ctrl/agg_gamma_spline.cpp \ src/ctrl/agg_polygon_ctrl.cpp \ src/ctrl/agg_rbox_ctrl.cpp \ src/ctrl/agg_scale_ctrl.cpp \ src/ctrl/agg_slider_ctrl.cpp \ src/ctrl/agg_spline_ctrl.cpp LIB_CSRC=\ gpc/gpc.c SVG_SRC=\ examples/svg_viewer/agg_svg_parser.cpp \ examples/svg_viewer/agg_svg_path_renderer.cpp \ examples/svg_viewer/agg_svg_path_tokenizer.cpp \ examples/svg_viewer/svg_test.cpp \ $(PLATFORM_SRC) PLATFORM_OBJ = $(PLATFORM_SRC:.cpp=.o) FREETYPE_OBJ = $(FREETYPE_SRC:.cpp=.o) LIB_OBJ = $(LIB_CXXSRC:.cpp=.o) $(LIB_CSRC:.c=.o) SVG_OBJ = $(SVG_SRC:.cpp=.o) # # Targets # help: @Echo Requirements: @Echo - AmigaOS 4.0 @Echo - SDK 51.15 @Echo - GCC 4.0.2 @Echo - clib2 1.198 @Echo - optional: libexpat.a for SVG viewer @Echo - optional: libfreetype.a for FreeType examples @Echo '""' @Echo Targets: @Echo all - build AGG library and all tests/examples @Echo lib - build AGG library only @Echo examples - build AGG library and examples @Echo svg - build AGG library and SVG viewer @Echo freetype - build AGG library and FreeType examples @Echo clean - clean all build files @Echo install - build AGG library and install into SDK @Echo wget - download and install example test files with wget all: setup lib examples svg freetype $(STRIP) $(EXAMPLES) $(SVGNAME) $(FREETYPE_EXAMPLES) setup: -@MakeDir >NIL: lib bin lib: setup $(AGGLIBNAME) examples: lib $(EXAMPLES) svg: lib $(SVGNAME) freetype: lib $(FREETYPE_EXAMPLES) clean: -@Delete >NIL: FORCE QUIET examples/#?.o -@Delete >NIL: FORCE QUIET $(PLATFORM_OBJ) $(FREETYPE_OBJ) $(LIB_OBJ) $(SVG_OBJ) -@Delete >NIL: FORCE QUIET ALL lib bin install: lib -@Copy CLONE $(AGGLIBNAME) SDK:Local/clib2/lib -@Copy CLONE ALL include/#?.h SDK:Local/clib2/include/agg -@Copy CLONE ALL gpc/#?.h SDK:Local/clib2/include/gpc $(AGGLIBNAME): $(LIB_OBJ) $(AR) $(ARFLAGS) $(AGGLIBNAME) $^ $(SVGNAME): $(SVG_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) -lexpat # # Examples binaries # bin/aa_test: examples/aa_test.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/aa_demo: examples/aa_demo.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/alpha_gradient: examples/alpha_gradient.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/alpha_mask: examples/alpha_mask.o examples/parse_lion.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/alpha_mask2: examples/alpha_mask2.o examples/parse_lion.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/alpha_mask3: examples/alpha_mask3.o examples/make_arrows.o examples/make_gb_poly.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/bezier_div: examples/bezier_div.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/bspline: examples/bspline.o examples/interactive_polygon.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/circles: examples/circles.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/component_rendering: examples/component_rendering.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/compositing: examples/compositing.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/compositing2: examples/compositing2.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/conv_contour: examples/conv_contour.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/conv_dash_marker: examples/conv_dash_marker.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/conv_stroke: examples/conv_stroke.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/distortions: examples/distortions.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/flash_rasterizer: examples/flash_rasterizer.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/flash_rasterizer2: examples/flash_rasterizer2.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/gamma_correction: examples/gamma_correction.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/gamma_ctrl: examples/gamma_ctrl.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/gamma_tuner: examples/gamma_tuner.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/gouraud: examples/gouraud.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/gouraud_mesh: examples/gouraud_mesh.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/gpc_test: examples/gpc_test.o examples/make_arrows.o examples/make_gb_poly.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/gradients: examples/gradients.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/graph_test: examples/graph_test.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/idea: examples/idea.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/image1: examples/image1.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/image_alpha: examples/image_alpha.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/image_filters: examples/image_filters.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/image_filters2: examples/image_filters2.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/image_fltr_graph: examples/image_fltr_graph.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/image_perspective: examples/image_perspective.o examples/interactive_polygon.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/image_resample: examples/image_resample.o examples/interactive_polygon.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/image_transforms: examples/image_transforms.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/line_patterns: examples/line_patterns.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/line_patterns_clip: examples/line_patterns_clip.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/lion: examples/lion.o examples/parse_lion.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/lion_lens: examples/lion_lens.o examples/parse_lion.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/lion_outline: examples/lion_outline.o examples/parse_lion.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/mol_view: examples/mol_view.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/multi_clip: examples/multi_clip.o examples/parse_lion.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/pattern_fill: examples/pattern_fill.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/pattern_perspective: examples/pattern_perspective.o examples/interactive_polygon.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/pattern_resample: examples/pattern_resample.o examples/interactive_polygon.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/perspective: examples/perspective.o examples/interactive_polygon.o examples/parse_lion.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/polymorphic_renderer: examples/polymorphic_renderer.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/rasterizers: examples/rasterizers.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/rasterizers2: examples/rasterizers2.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/raster_text: examples/raster_text.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/rounded_rect: examples/rounded_rect.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/scanline_boolean: examples/scanline_boolean.o examples/interactive_polygon.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/scanline_boolean2: examples/scanline_boolean2.o examples/make_arrows.o examples/make_gb_poly.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/simple_blur: examples/simple_blur.o examples/parse_lion.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/trans_polar: examples/trans_polar.o $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) bin/freetype_test: examples/freetype_test.o $(FREETYPE_OBJ) $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) -lfreetype -lz bin/trans_curve1_ft: examples/trans_curve1_ft.o examples/interactive_polygon.o $(FREETYPE_OBJ) $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) -lfreetype -lz bin/trans_curve2_ft: examples/trans_curve2_ft.o examples/interactive_polygon.o $(FREETYPE_OBJ) $(PLATFORM_OBJ) $(CXX) $(CXXFLAGS) $^ -o $@ $(CXXLIBS) -lfreetype -lz # # Examples files # wget: wget http://www.antigrain.com/svg/tiger.svg move tiger.svg bin wget http://www.antigrain.com/agg.bmp move agg.bmp bin wget http://www.antigrain.com/compositing.bmp move compositing.bmp bin wget http://www.antigrain.com/spheres.bmp move spheres.bmp bin wget http://www.antigrain.com/shapes.txt move shapes.txt bin wget http://www.antigrain.com/1.sdf move 1.sdf bin wget http://www.antigrain.com/line_patterns.bmp.zip xadunfile line_patterns.bmp.zip bin overwrite delete line_patterns.bmp.zip wget http://www.antigrain.com/timesi.zip xadunfile timesi.zip bin overwrite delete timesi.zip # # Pattern Rules # %.o: %.cpp $(CXX) -c $(CXXFLAGS) $*.cpp -o $@ %.o: %.c $(CC) -c $(CFLAGS) $*.c -o $@ enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/0000755000175000017500000000000012516137725020777 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_interpolator_persp.h0000644000175000017500000003741612516137326026752 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_SPAN_INTERPOLATOR_PERSP_INCLUDED #define AGG_SPAN_INTERPOLATOR_PERSP_INCLUDED #include "agg_trans_perspective.h" #include "agg_dda_line.h" namespace agg24 { //===========================================span_interpolator_persp_exact template class span_interpolator_persp_exact { public: typedef trans_perspective trans_type; typedef trans_perspective::iterator_x iterator_type; enum subpixel_scale_e { subpixel_shift = SubpixelShift, subpixel_scale = 1 << subpixel_shift }; //-------------------------------------------------------------------- span_interpolator_persp_exact() {} //-------------------------------------------------------------------- // Arbitrary quadrangle transformations span_interpolator_persp_exact(const double* src, const double* dst) { quad_to_quad(src, dst); } //-------------------------------------------------------------------- // Direct transformations span_interpolator_persp_exact(double x1, double y1, double x2, double y2, const double* quad) { rect_to_quad(x1, y1, x2, y2, quad); } //-------------------------------------------------------------------- // Reverse transformations span_interpolator_persp_exact(const double* quad, double x1, double y1, double x2, double y2) { quad_to_rect(quad, x1, y1, x2, y2); } //-------------------------------------------------------------------- // Set the transformations using two arbitrary quadrangles. void quad_to_quad(const double* src, const double* dst) { m_trans_dir.quad_to_quad(src, dst); m_trans_inv.quad_to_quad(dst, src); } //-------------------------------------------------------------------- // Set the direct transformations, i.e., rectangle -> quadrangle void rect_to_quad(double x1, double y1, double x2, double y2, const double* quad) { double src[8]; src[0] = src[6] = x1; src[2] = src[4] = x2; src[1] = src[3] = y1; src[5] = src[7] = y2; quad_to_quad(src, quad); } //-------------------------------------------------------------------- // Set the reverse transformations, i.e., quadrangle -> rectangle void quad_to_rect(const double* quad, double x1, double y1, double x2, double y2) { double dst[8]; dst[0] = dst[6] = x1; dst[2] = dst[4] = x2; dst[1] = dst[3] = y1; dst[5] = dst[7] = y2; quad_to_quad(quad, dst); } //-------------------------------------------------------------------- // Check if the equations were solved successfully bool is_valid() const { return m_trans_dir.is_valid(); } //---------------------------------------------------------------- void begin(double x, double y, unsigned len) { m_iterator = m_trans_dir.begin(x, y, 1.0); double xt = m_iterator.x; double yt = m_iterator.y; double dx; double dy; const double delta = 1/double(subpixel_scale); dx = xt + delta; dy = yt; m_trans_inv.transform(&dx, &dy); dx -= x; dy -= y; int sx1 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; dx = xt; dy = yt + delta; m_trans_inv.transform(&dx, &dy); dx -= x; dy -= y; int sy1 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; x += len; xt = x; yt = y; m_trans_dir.transform(&xt, &yt); dx = xt + delta; dy = yt; m_trans_inv.transform(&dx, &dy); dx -= x; dy -= y; int sx2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; dx = xt; dy = yt + delta; m_trans_inv.transform(&dx, &dy); dx -= x; dy -= y; int sy2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; m_scale_x = dda2_line_interpolator(sx1, sx2, len); m_scale_y = dda2_line_interpolator(sy1, sy2, len); } //---------------------------------------------------------------- void resynchronize(double xe, double ye, unsigned len) { // Assume x1,y1 are equal to the ones at the previous end point int sx1 = m_scale_x.y(); int sy1 = m_scale_y.y(); // Calculate transformed coordinates at x2,y2 double xt = xe; double yt = ye; m_trans_dir.transform(&xt, &yt); const double delta = 1/double(subpixel_scale); double dx; double dy; // Calculate scale by X at x2,y2 dx = xt + delta; dy = yt; m_trans_inv.transform(&dx, &dy); dx -= xe; dy -= ye; int sx2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; // Calculate scale by Y at x2,y2 dx = xt; dy = yt + delta; m_trans_inv.transform(&dx, &dy); dx -= xe; dy -= ye; int sy2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; // Initialize the interpolators m_scale_x = dda2_line_interpolator(sx1, sx2, len); m_scale_y = dda2_line_interpolator(sy1, sy2, len); } //---------------------------------------------------------------- void operator++() { ++m_iterator; ++m_scale_x; ++m_scale_y; } //---------------------------------------------------------------- void coordinates(int* x, int* y) const { *x = iround(m_iterator.x * subpixel_scale); *y = iround(m_iterator.y * subpixel_scale); } //---------------------------------------------------------------- void local_scale(int* x, int* y) { *x = m_scale_x.y(); *y = m_scale_y.y(); } //---------------------------------------------------------------- void transform(double* x, double* y) const { m_trans_dir.transform(x, y); } private: trans_type m_trans_dir; trans_type m_trans_inv; iterator_type m_iterator; dda2_line_interpolator m_scale_x; dda2_line_interpolator m_scale_y; }; //============================================span_interpolator_persp_lerp template class span_interpolator_persp_lerp { public: typedef trans_perspective trans_type; enum subpixel_scale_e { subpixel_shift = SubpixelShift, subpixel_scale = 1 << subpixel_shift }; //-------------------------------------------------------------------- span_interpolator_persp_lerp() {} //-------------------------------------------------------------------- // Arbitrary quadrangle transformations span_interpolator_persp_lerp(const double* src, const double* dst) { quad_to_quad(src, dst); } //-------------------------------------------------------------------- // Direct transformations span_interpolator_persp_lerp(double x1, double y1, double x2, double y2, const double* quad) { rect_to_quad(x1, y1, x2, y2, quad); } //-------------------------------------------------------------------- // Reverse transformations span_interpolator_persp_lerp(const double* quad, double x1, double y1, double x2, double y2) { quad_to_rect(quad, x1, y1, x2, y2); } //-------------------------------------------------------------------- // Set the transformations using two arbitrary quadrangles. void quad_to_quad(const double* src, const double* dst) { m_trans_dir.quad_to_quad(src, dst); m_trans_inv.quad_to_quad(dst, src); } //-------------------------------------------------------------------- // Set the direct transformations, i.e., rectangle -> quadrangle void rect_to_quad(double x1, double y1, double x2, double y2, const double* quad) { double src[8]; src[0] = src[6] = x1; src[2] = src[4] = x2; src[1] = src[3] = y1; src[5] = src[7] = y2; quad_to_quad(src, quad); } //-------------------------------------------------------------------- // Set the reverse transformations, i.e., quadrangle -> rectangle void quad_to_rect(const double* quad, double x1, double y1, double x2, double y2) { double dst[8]; dst[0] = dst[6] = x1; dst[2] = dst[4] = x2; dst[1] = dst[3] = y1; dst[5] = dst[7] = y2; quad_to_quad(quad, dst); } //-------------------------------------------------------------------- // Check if the equations were solved successfully bool is_valid() const { return m_trans_dir.is_valid(); } //---------------------------------------------------------------- void begin(double x, double y, unsigned len) { // Calculate transformed coordinates at x1,y1 double xt = x; double yt = y; m_trans_dir.transform(&xt, &yt); int x1 = iround(xt * subpixel_scale); int y1 = iround(yt * subpixel_scale); double dx; double dy; const double delta = 1/double(subpixel_scale); // Calculate scale by X at x1,y1 dx = xt + delta; dy = yt; m_trans_inv.transform(&dx, &dy); dx -= x; dy -= y; int sx1 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; // Calculate scale by Y at x1,y1 dx = xt; dy = yt + delta; m_trans_inv.transform(&dx, &dy); dx -= x; dy -= y; int sy1 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; // Calculate transformed coordinates at x2,y2 x += len; xt = x; yt = y; m_trans_dir.transform(&xt, &yt); int x2 = iround(xt * subpixel_scale); int y2 = iround(yt * subpixel_scale); // Calculate scale by X at x2,y2 dx = xt + delta; dy = yt; m_trans_inv.transform(&dx, &dy); dx -= x; dy -= y; int sx2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; // Calculate scale by Y at x2,y2 dx = xt; dy = yt + delta; m_trans_inv.transform(&dx, &dy); dx -= x; dy -= y; int sy2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; // Initialize the interpolators m_coord_x = dda2_line_interpolator(x1, x2, len); m_coord_y = dda2_line_interpolator(y1, y2, len); m_scale_x = dda2_line_interpolator(sx1, sx2, len); m_scale_y = dda2_line_interpolator(sy1, sy2, len); } //---------------------------------------------------------------- void resynchronize(double xe, double ye, unsigned len) { // Assume x1,y1 are equal to the ones at the previous end point int x1 = m_coord_x.y(); int y1 = m_coord_y.y(); int sx1 = m_scale_x.y(); int sy1 = m_scale_y.y(); // Calculate transformed coordinates at x2,y2 double xt = xe; double yt = ye; m_trans_dir.transform(&xt, &yt); int x2 = iround(xt * subpixel_scale); int y2 = iround(yt * subpixel_scale); const double delta = 1/double(subpixel_scale); double dx; double dy; // Calculate scale by X at x2,y2 dx = xt + delta; dy = yt; m_trans_inv.transform(&dx, &dy); dx -= xe; dy -= ye; int sx2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; // Calculate scale by Y at x2,y2 dx = xt; dy = yt + delta; m_trans_inv.transform(&dx, &dy); dx -= xe; dy -= ye; int sy2 = uround(subpixel_scale/sqrt(dx*dx + dy*dy)) >> subpixel_shift; // Initialize the interpolators m_coord_x = dda2_line_interpolator(x1, x2, len); m_coord_y = dda2_line_interpolator(y1, y2, len); m_scale_x = dda2_line_interpolator(sx1, sx2, len); m_scale_y = dda2_line_interpolator(sy1, sy2, len); } //---------------------------------------------------------------- void operator++() { ++m_coord_x; ++m_coord_y; ++m_scale_x; ++m_scale_y; } //---------------------------------------------------------------- void coordinates(int* x, int* y) const { *x = m_coord_x.y(); *y = m_coord_y.y(); } //---------------------------------------------------------------- void local_scale(int* x, int* y) { *x = m_scale_x.y(); *y = m_scale_y.y(); } //---------------------------------------------------------------- void transform(double* x, double* y) const { m_trans_dir.transform(x, y); } private: trans_type m_trans_dir; trans_type m_trans_inv; dda2_line_interpolator m_coord_x; dda2_line_interpolator m_coord_y; dda2_line_interpolator m_scale_x; dda2_line_interpolator m_scale_y; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_image_filter.h0000644000175000017500000002122312516137326025433 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Image transformations with filtering. Span generator base class // //---------------------------------------------------------------------------- #ifndef AGG_SPAN_IMAGE_FILTER_INCLUDED #define AGG_SPAN_IMAGE_FILTER_INCLUDED #include "agg_basics.h" #include "agg_image_filters.h" #include "agg_span_interpolator_linear.h" namespace agg24 { //-------------------------------------------------------span_image_filter template class span_image_filter { public: typedef Source source_type; typedef Interpolator interpolator_type; //-------------------------------------------------------------------- span_image_filter() {} span_image_filter(source_type& src, interpolator_type& interpolator, const image_filter_lut* filter) : m_src(&src), m_interpolator(&interpolator), m_filter(filter), m_dx_dbl(0.5), m_dy_dbl(0.5), m_dx_int(image_subpixel_scale / 2), m_dy_int(image_subpixel_scale / 2) {} void attach(source_type& v) { m_src = &v; } //-------------------------------------------------------------------- source_type& source() { return *m_src; } const source_type& source() const { return *m_src; } const image_filter_lut& filter() const { return *m_filter; } int filter_dx_int() const { return m_dx_int; } int filter_dy_int() const { return m_dy_int; } double filter_dx_dbl() const { return m_dx_dbl; } double filter_dy_dbl() const { return m_dy_dbl; } //-------------------------------------------------------------------- void interpolator(interpolator_type& v) { m_interpolator = &v; } void filter(const image_filter_lut& v) { m_filter = &v; } void filter_offset(double dx, double dy) { m_dx_dbl = dx; m_dy_dbl = dy; m_dx_int = iround(dx * image_subpixel_scale); m_dy_int = iround(dy * image_subpixel_scale); } void filter_offset(double d) { filter_offset(d, d); } //-------------------------------------------------------------------- interpolator_type& interpolator() { return *m_interpolator; } //-------------------------------------------------------------------- void prepare() {} //-------------------------------------------------------------------- private: source_type* m_src; interpolator_type* m_interpolator; const image_filter_lut* m_filter; double m_dx_dbl; double m_dy_dbl; unsigned m_dx_int; unsigned m_dy_int; }; //==============================================span_image_resample_affine template class span_image_resample_affine : public span_image_filter > { public: typedef Source source_type; typedef span_interpolator_linear interpolator_type; typedef span_image_filter base_type; //-------------------------------------------------------------------- span_image_resample_affine() : m_scale_limit(200.0), m_blur_x(1.0), m_blur_y(1.0) {} //-------------------------------------------------------------------- span_image_resample_affine(source_type& src, interpolator_type& inter, const image_filter_lut& filter) : base_type(src, inter, &filter), m_scale_limit(200.0), m_blur_x(1.0), m_blur_y(1.0) {} //-------------------------------------------------------------------- int scale_limit() const { return uround(m_scale_limit); } void scale_limit(int v) { m_scale_limit = v; } //-------------------------------------------------------------------- double blur_x() const { return m_blur_x; } double blur_y() const { return m_blur_y; } void blur_x(double v) { m_blur_x = v; } void blur_y(double v) { m_blur_y = v; } void blur(double v) { m_blur_x = m_blur_y = v; } //-------------------------------------------------------------------- void prepare() { double scale_x; double scale_y; base_type::interpolator().transformer().scaling_abs(&scale_x, &scale_y); m_rx = image_subpixel_scale; m_ry = image_subpixel_scale; m_rx_inv = image_subpixel_scale; m_ry_inv = image_subpixel_scale; scale_x *= m_blur_x; scale_y *= m_blur_y; if(scale_x * scale_y > m_scale_limit) { scale_x = scale_x * m_scale_limit / (scale_x * scale_y); scale_y = scale_y * m_scale_limit / (scale_x * scale_y); } if(scale_x > 1.0001) { if(scale_x > m_scale_limit) scale_x = m_scale_limit; m_rx = uround( scale_x * double(image_subpixel_scale)); m_rx_inv = uround(1.0/scale_x * double(image_subpixel_scale)); } if(scale_y > 1.0001) { if(scale_y > m_scale_limit) scale_y = m_scale_limit; m_ry = uround( scale_y * double(image_subpixel_scale)); m_ry_inv = uround(1.0/scale_y * double(image_subpixel_scale)); } } protected: int m_rx; int m_ry; int m_rx_inv; int m_ry_inv; private: double m_scale_limit; double m_blur_x; double m_blur_y; }; //=====================================================span_image_resample template class span_image_resample : public span_image_filter { public: typedef Source source_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; //-------------------------------------------------------------------- span_image_resample() : m_scale_limit(20), m_blur_x(image_subpixel_scale), m_blur_y(image_subpixel_scale) {} //-------------------------------------------------------------------- span_image_resample(source_type& src, interpolator_type& inter, const image_filter_lut& filter) : base_type(src, inter, &filter), m_scale_limit(20), m_blur_x(image_subpixel_scale), m_blur_y(image_subpixel_scale) {} //-------------------------------------------------------------------- int scale_limit() const { return m_scale_limit; } void scale_limit(int v) { m_scale_limit = v; } //-------------------------------------------------------------------- double blur_x() const { return double(m_blur_x) / double(image_subpixel_scale); } double blur_y() const { return double(m_blur_y) / double(image_subpixel_scale); } void blur_x(double v) { m_blur_x = uround(v * double(image_subpixel_scale)); } void blur_y(double v) { m_blur_y = uround(v * double(image_subpixel_scale)); } void blur(double v) { m_blur_x = m_blur_y = uround(v * double(image_subpixel_scale)); } protected: int m_scale_limit; int m_blur_x; int m_blur_y; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_vpgen_segmentator.h0000644000175000017500000000351012516137326025511 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_VPGEN_SEGMENTATOR_INCLUDED #define AGG_VPGEN_SEGMENTATOR_INCLUDED #include #include "agg_basics.h" namespace agg24 { //=======================================================vpgen_segmentator // // See Implementation agg_vpgen_segmentator.cpp // class vpgen_segmentator { public: vpgen_segmentator() : m_approximation_scale(1.0) {} void approximation_scale(double s) { m_approximation_scale = s; } double approximation_scale() const { return m_approximation_scale; } static bool auto_close() { return false; } static bool auto_unclose() { return false; } void reset() { m_cmd = path_cmd_stop; } void move_to(double x, double y); void line_to(double x, double y); unsigned vertex(double* x, double* y); private: double m_approximation_scale; double m_x1; double m_y1; double m_dx; double m_dy; double m_dl; double m_ddl; unsigned m_cmd; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_vertex_sequence.h0000644000175000017500000001235212516137326025173 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // vertex_sequence container and vertex_dist struct // //---------------------------------------------------------------------------- #ifndef AGG_VERTEX_SEQUENCE_INCLUDED #define AGG_VERTEX_SEQUENCE_INCLUDED #include "agg_basics.h" #include "agg_array.h" #include "agg_math.h" namespace agg24 { //----------------------------------------------------------vertex_sequence // Modified agg24::pod_bvector. The data is interpreted as a sequence // of vertices. It means that the type T must expose: // // bool T::operator() (const T& val) // // that is called every time new vertex is being added. The main purpose // of this operator is the possibility to calculate some values during // adding and to return true if the vertex fits some criteria or false if // it doesn't. In the last case the new vertex is not added. // // The simple example is filtering coinciding vertices with calculation // of the distance between the current and previous ones: // // struct vertex_dist // { // double x; // double y; // double dist; // // vertex_dist() {} // vertex_dist(double x_, double y_) : // x(x_), // y(y_), // dist(0.0) // { // } // // bool operator () (const vertex_dist& val) // { // return (dist = calc_distance(x, y, val.x, val.y)) > EPSILON; // } // }; // // Function close() calls this operator and removes the last vertex if // necessary. //------------------------------------------------------------------------ template class vertex_sequence : public pod_bvector { public: typedef pod_bvector base_type; void add(const T& val); void modify_last(const T& val); void close(bool remove_flag); }; //------------------------------------------------------------------------ template void vertex_sequence::add(const T& val) { if(base_type::size() > 1) { if(!(*this)[base_type::size() - 2]((*this)[base_type::size() - 1])) { base_type::remove_last(); } } base_type::add(val); } //------------------------------------------------------------------------ template void vertex_sequence::modify_last(const T& val) { base_type::remove_last(); add(val); } //------------------------------------------------------------------------ template void vertex_sequence::close(bool closed) { while(base_type::size() > 1) { if((*this)[base_type::size() - 2]((*this)[base_type::size() - 1])) break; T t = (*this)[base_type::size() - 1]; base_type::remove_last(); modify_last(t); } if(closed) { while(base_type::size() > 1) { if((*this)[base_type::size() - 1]((*this)[0])) break; base_type::remove_last(); } } } //-------------------------------------------------------------vertex_dist // Vertex (x, y) with the distance to the next one. The last vertex has // distance between the last and the first points if the polygon is closed // and 0.0 if it's a polyline. struct vertex_dist { double x; double y; double dist; vertex_dist() {} vertex_dist(double x_, double y_) : x(x_), y(y_), dist(0.0) { } bool operator () (const vertex_dist& val) { bool ret = (dist = calc_distance(x, y, val.x, val.y)) > vertex_dist_epsilon; if(!ret) dist = 1.0 / vertex_dist_epsilon; return ret; } }; //--------------------------------------------------------vertex_dist_cmd // Save as the above but with additional "command" value struct vertex_dist_cmd : public vertex_dist { unsigned cmd; vertex_dist_cmd() {} vertex_dist_cmd(double x_, double y_, unsigned cmd_) : vertex_dist(x_, y_), cmd(cmd_) { } }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_adaptor_vcgen.h0000644000175000017500000001177612516137326025640 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_CONV_ADAPTOR_VCGEN_INCLUDED #define AGG_CONV_ADAPTOR_VCGEN_INCLUDED #include "agg_basics.h" namespace agg24 { //------------------------------------------------------------null_markers struct null_markers { void remove_all() {} void add_vertex(double, double, unsigned) {} void prepare_src() {} void rewind(unsigned) {} unsigned vertex(double*, double*) { return path_cmd_stop; } }; //------------------------------------------------------conv_adaptor_vcgen template class conv_adaptor_vcgen { enum status { initial, accumulate, generate }; public: conv_adaptor_vcgen(VertexSource& source) : m_source(&source), m_status(initial) {} void attach(VertexSource& source) { m_source = &source; } Generator& generator() { return m_generator; } const Generator& generator() const { return m_generator; } Markers& markers() { return m_markers; } const Markers& markers() const { return m_markers; } void rewind(unsigned path_id) { m_source->rewind(path_id); m_status = initial; } unsigned vertex(double* x, double* y); private: // Prohibit copying conv_adaptor_vcgen(const conv_adaptor_vcgen&); const conv_adaptor_vcgen& operator = (const conv_adaptor_vcgen&); VertexSource* m_source; Generator m_generator; Markers m_markers; status m_status; unsigned m_last_cmd; double m_start_x; double m_start_y; }; //------------------------------------------------------------------------ template unsigned conv_adaptor_vcgen::vertex(double* x, double* y) { unsigned cmd = path_cmd_stop; bool done = false; while(!done) { switch(m_status) { case initial: m_markers.remove_all(); m_last_cmd = m_source->vertex(&m_start_x, &m_start_y); m_status = accumulate; case accumulate: if(is_stop(m_last_cmd)) return path_cmd_stop; m_generator.remove_all(); m_generator.add_vertex(m_start_x, m_start_y, path_cmd_move_to); m_markers.add_vertex(m_start_x, m_start_y, path_cmd_move_to); for(;;) { cmd = m_source->vertex(x, y); if(is_vertex(cmd)) { m_last_cmd = cmd; if(is_move_to(cmd)) { m_start_x = *x; m_start_y = *y; break; } m_generator.add_vertex(*x, *y, cmd); m_markers.add_vertex(*x, *y, path_cmd_line_to); } else { if(is_stop(cmd)) { m_last_cmd = path_cmd_stop; break; } if(is_end_poly(cmd)) { m_generator.add_vertex(*x, *y, cmd); break; } } } m_generator.rewind(0); m_status = generate; case generate: cmd = m_generator.vertex(x, y); if(is_stop(cmd)) { m_status = accumulate; break; } done = true; break; } } return cmd; } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_image_filter_rgba.h0000644000175000017500000011455112516137326026435 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for high precision colors has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_SPAN_IMAGE_FILTER_RGBA_INCLUDED #define AGG_SPAN_IMAGE_FILTER_RGBA_INCLUDED #include "agg_basics.h" #include "agg_color_rgba.h" #include "agg_span_image_filter.h" namespace agg24 { //==============================================span_image_filter_rgba_nn template class span_image_filter_rgba_nn : public span_image_filter { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- span_image_filter_rgba_nn() {} span_image_filter_rgba_nn(source_type& src, interpolator_type& inter) : base_type(src, inter, 0) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); do { base_type::interpolator().coordinates(&x, &y); const value_type* fg_ptr = (const value_type*) base_type::source().span(x >> image_subpixel_shift, y >> image_subpixel_shift, 1); span->r = fg_ptr[order_type::R]; span->g = fg_ptr[order_type::G]; span->b = fg_ptr[order_type::B]; span->a = fg_ptr[order_type::A]; ++span; ++base_type::interpolator(); } while(--len); } }; //=========================================span_image_filter_rgba_bilinear template class span_image_filter_rgba_bilinear : public span_image_filter { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- span_image_filter_rgba_bilinear() {} span_image_filter_rgba_bilinear(source_type& src, interpolator_type& inter) : base_type(src, inter, 0) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); calc_type fg[4]; const value_type *fg_ptr; do { int x_hr; int y_hr; base_type::interpolator().coordinates(&x_hr, &y_hr); x_hr -= base_type::filter_dx_int(); y_hr -= base_type::filter_dy_int(); int x_lr = x_hr >> image_subpixel_shift; int y_lr = y_hr >> image_subpixel_shift; unsigned weight; fg[0] = fg[1] = fg[2] = fg[3] = image_subpixel_scale * image_subpixel_scale / 2; x_hr &= image_subpixel_mask; y_hr &= image_subpixel_mask; fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); weight = (image_subpixel_scale - x_hr) * (image_subpixel_scale - y_hr); fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr; fg_ptr = (const value_type*)base_type::source().next_x(); weight = x_hr * (image_subpixel_scale - y_hr); fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr; fg_ptr = (const value_type*)base_type::source().next_y(); weight = (image_subpixel_scale - x_hr) * y_hr; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr; fg_ptr = (const value_type*)base_type::source().next_x(); weight = x_hr * y_hr; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr; span->r = value_type(fg[order_type::R] >> (image_subpixel_shift * 2)); span->g = value_type(fg[order_type::G] >> (image_subpixel_shift * 2)); span->b = value_type(fg[order_type::B] >> (image_subpixel_shift * 2)); span->a = value_type(fg[order_type::A] >> (image_subpixel_shift * 2)); ++span; ++base_type::interpolator(); } while(--len); } }; //====================================span_image_filter_rgba_bilinear_clip template class span_image_filter_rgba_bilinear_clip : public span_image_filter { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- span_image_filter_rgba_bilinear_clip() {} span_image_filter_rgba_bilinear_clip(source_type& src, const color_type& back_color, interpolator_type& inter) : base_type(src, inter, 0), m_back_color(back_color) {} const color_type& background_color() const { return m_back_color; } void background_color(const color_type& v) { m_back_color = v; } //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); calc_type fg[4]; value_type back_r = m_back_color.r; value_type back_g = m_back_color.g; value_type back_b = m_back_color.b; value_type back_a = m_back_color.a; const value_type *fg_ptr; int maxx = base_type::source().width() - 1; int maxy = base_type::source().height() - 1; do { int x_hr; int y_hr; base_type::interpolator().coordinates(&x_hr, &y_hr); x_hr -= base_type::filter_dx_int(); y_hr -= base_type::filter_dy_int(); int x_lr = x_hr >> image_subpixel_shift; int y_lr = y_hr >> image_subpixel_shift; unsigned weight; if(x_lr >= 0 && y_lr >= 0 && x_lr < maxx && y_lr < maxy) { fg[0] = fg[1] = fg[2] = fg[3] = image_subpixel_scale * image_subpixel_scale / 2; x_hr &= image_subpixel_mask; y_hr &= image_subpixel_mask; fg_ptr = (const value_type*) base_type::source().row_ptr(y_lr) + (x_lr << 2); weight = (image_subpixel_scale - x_hr) * (image_subpixel_scale - y_hr); fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr++; weight = x_hr * (image_subpixel_scale - y_hr); fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr++; ++y_lr; fg_ptr = (const value_type*) base_type::source().row_ptr(y_lr) + (x_lr << 2); weight = (image_subpixel_scale - x_hr) * y_hr; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr++; weight = x_hr * y_hr; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr++; fg[0] >>= image_subpixel_shift * 2; fg[1] >>= image_subpixel_shift * 2; fg[2] >>= image_subpixel_shift * 2; fg[3] >>= image_subpixel_shift * 2; } else { if(x_lr < -1 || y_lr < -1 || x_lr > maxx || y_lr > maxy) { fg[order_type::R] = back_r; fg[order_type::G] = back_g; fg[order_type::B] = back_b; fg[order_type::A] = back_a; } else { fg[0] = fg[1] = fg[2] = fg[3] = image_subpixel_scale * image_subpixel_scale / 2; x_hr &= image_subpixel_mask; y_hr &= image_subpixel_mask; weight = (image_subpixel_scale - x_hr) * (image_subpixel_scale - y_hr); if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) { fg_ptr = (const value_type*) base_type::source().row_ptr(y_lr) + (x_lr << 2); fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr++; } else { fg[order_type::R] += back_r * weight; fg[order_type::G] += back_g * weight; fg[order_type::B] += back_b * weight; fg[order_type::A] += back_a * weight; } x_lr++; weight = x_hr * (image_subpixel_scale - y_hr); if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) { fg_ptr = (const value_type*) base_type::source().row_ptr(y_lr) + (x_lr << 2); fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr++; } else { fg[order_type::R] += back_r * weight; fg[order_type::G] += back_g * weight; fg[order_type::B] += back_b * weight; fg[order_type::A] += back_a * weight; } x_lr--; y_lr++; weight = (image_subpixel_scale - x_hr) * y_hr; if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) { fg_ptr = (const value_type*) base_type::source().row_ptr(y_lr) + (x_lr << 2); fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr++; } else { fg[order_type::R] += back_r * weight; fg[order_type::G] += back_g * weight; fg[order_type::B] += back_b * weight; fg[order_type::A] += back_a * weight; } x_lr++; weight = x_hr * y_hr; if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) { fg_ptr = (const value_type*) base_type::source().row_ptr(y_lr) + (x_lr << 2); fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr++; } else { fg[order_type::R] += back_r * weight; fg[order_type::G] += back_g * weight; fg[order_type::B] += back_b * weight; fg[order_type::A] += back_a * weight; } fg[0] >>= image_subpixel_shift * 2; fg[1] >>= image_subpixel_shift * 2; fg[2] >>= image_subpixel_shift * 2; fg[3] >>= image_subpixel_shift * 2; } } span->r = (value_type)fg[order_type::R]; span->g = (value_type)fg[order_type::G]; span->b = (value_type)fg[order_type::B]; span->a = (value_type)fg[order_type::A]; ++span; ++base_type::interpolator(); } while(--len); } private: color_type m_back_color; }; //==============================================span_image_filter_rgba_2x2 template class span_image_filter_rgba_2x2 : public span_image_filter { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- span_image_filter_rgba_2x2() {} span_image_filter_rgba_2x2(source_type& src, interpolator_type& inter, const image_filter_lut& filter) : base_type(src, inter, &filter) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); calc_type fg[4]; const value_type *fg_ptr; const int16* weight_array = base_type::filter().weight_array() + ((base_type::filter().diameter()/2 - 1) << image_subpixel_shift); do { int x_hr; int y_hr; base_type::interpolator().coordinates(&x_hr, &y_hr); x_hr -= base_type::filter_dx_int(); y_hr -= base_type::filter_dy_int(); int x_lr = x_hr >> image_subpixel_shift; int y_lr = y_hr >> image_subpixel_shift; unsigned weight; fg[0] = fg[1] = fg[2] = fg[3] = image_filter_scale / 2; x_hr &= image_subpixel_mask; y_hr &= image_subpixel_mask; fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); weight = (weight_array[x_hr + image_subpixel_scale] * weight_array[y_hr + image_subpixel_scale] + image_filter_scale / 2) >> image_filter_shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr; fg_ptr = (const value_type*)base_type::source().next_x(); weight = (weight_array[x_hr] * weight_array[y_hr + image_subpixel_scale] + image_filter_scale / 2) >> image_filter_shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr; fg_ptr = (const value_type*)base_type::source().next_y(); weight = (weight_array[x_hr + image_subpixel_scale] * weight_array[y_hr] + image_filter_scale / 2) >> image_filter_shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr; fg_ptr = (const value_type*)base_type::source().next_x(); weight = (weight_array[x_hr] * weight_array[y_hr] + image_filter_scale / 2) >> image_filter_shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr; fg[0] >>= image_filter_shift; fg[1] >>= image_filter_shift; fg[2] >>= image_filter_shift; fg[3] >>= image_filter_shift; if(fg[order_type::A] > base_mask) fg[order_type::A] = base_mask; if(fg[order_type::R] > fg[order_type::A]) fg[order_type::R] = fg[order_type::A]; if(fg[order_type::G] > fg[order_type::A]) fg[order_type::G] = fg[order_type::A]; if(fg[order_type::B] > fg[order_type::A]) fg[order_type::B] = fg[order_type::A]; span->r = (value_type)fg[order_type::R]; span->g = (value_type)fg[order_type::G]; span->b = (value_type)fg[order_type::B]; span->a = (value_type)fg[order_type::A]; ++span; ++base_type::interpolator(); } while(--len); } }; //==================================================span_image_filter_rgba template class span_image_filter_rgba : public span_image_filter { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- span_image_filter_rgba() {} span_image_filter_rgba(source_type& src, interpolator_type& inter, const image_filter_lut& filter) : base_type(src, inter, &filter) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); int fg[4]; const value_type *fg_ptr; unsigned diameter = base_type::filter().diameter(); int start = base_type::filter().start(); const int16* weight_array = base_type::filter().weight_array(); int x_count; int weight_y; do { base_type::interpolator().coordinates(&x, &y); x -= base_type::filter_dx_int(); y -= base_type::filter_dy_int(); int x_hr = x; int y_hr = y; int x_lr = x_hr >> image_subpixel_shift; int y_lr = y_hr >> image_subpixel_shift; fg[0] = fg[1] = fg[2] = fg[3] = image_filter_scale / 2; int x_fract = x_hr & image_subpixel_mask; unsigned y_count = diameter; y_hr = image_subpixel_mask - (y_hr & image_subpixel_mask); fg_ptr = (const value_type*)base_type::source().span(x_lr + start, y_lr + start, diameter); for(;;) { x_count = diameter; weight_y = weight_array[y_hr]; x_hr = image_subpixel_mask - x_fract; for(;;) { int weight = (weight_y * weight_array[x_hr] + image_filter_scale / 2) >> image_filter_shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[3] += weight * *fg_ptr; if(--x_count == 0) break; x_hr += image_subpixel_scale; fg_ptr = (const value_type*)base_type::source().next_x(); } if(--y_count == 0) break; y_hr += image_subpixel_scale; fg_ptr = (const value_type*)base_type::source().next_y(); } fg[0] >>= image_filter_shift; fg[1] >>= image_filter_shift; fg[2] >>= image_filter_shift; fg[3] >>= image_filter_shift; if(fg[0] < 0) fg[0] = 0; if(fg[1] < 0) fg[1] = 0; if(fg[2] < 0) fg[2] = 0; if(fg[3] < 0) fg[3] = 0; if(fg[order_type::A] > base_mask) fg[order_type::A] = base_mask; if(fg[order_type::R] > fg[order_type::A]) fg[order_type::R] = fg[order_type::A]; if(fg[order_type::G] > fg[order_type::A]) fg[order_type::G] = fg[order_type::A]; if(fg[order_type::B] > fg[order_type::A]) fg[order_type::B] = fg[order_type::A]; span->r = (value_type)fg[order_type::R]; span->g = (value_type)fg[order_type::G]; span->b = (value_type)fg[order_type::B]; span->a = (value_type)fg[order_type::A]; ++span; ++base_type::interpolator(); } while(--len); } }; //========================================span_image_resample_rgba_affine template class span_image_resample_rgba_affine : public span_image_resample_affine { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef span_image_resample_affine base_type; typedef typename base_type::interpolator_type interpolator_type; typedef typename color_type::value_type value_type; typedef typename color_type::long_type long_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask, downscale_shift = image_filter_shift }; //-------------------------------------------------------------------- span_image_resample_rgba_affine() {} span_image_resample_rgba_affine(source_type& src, interpolator_type& inter, const image_filter_lut& filter) : base_type(src, inter, filter) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); long_type fg[4]; int diameter = base_type::filter().diameter(); int filter_scale = diameter << image_subpixel_shift; int radius_x = (diameter * base_type::m_rx) >> 1; int radius_y = (diameter * base_type::m_ry) >> 1; int len_x_lr = (diameter * base_type::m_rx + image_subpixel_mask) >> image_subpixel_shift; const int16* weight_array = base_type::filter().weight_array(); do { base_type::interpolator().coordinates(&x, &y); x += base_type::filter_dx_int() - radius_x; y += base_type::filter_dy_int() - radius_y; fg[0] = fg[1] = fg[2] = fg[3] = image_filter_scale / 2; int y_lr = y >> image_subpixel_shift; int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * base_type::m_ry_inv) >> image_subpixel_shift; int total_weight = 0; int x_lr = x >> image_subpixel_shift; int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * base_type::m_rx_inv) >> image_subpixel_shift; int x_hr2 = x_hr; const value_type* fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); for(;;) { int weight_y = weight_array[y_hr]; x_hr = x_hr2; for(;;) { int weight = (weight_y * weight_array[x_hr] + image_filter_scale / 2) >> downscale_shift; fg[0] += *fg_ptr++ * weight; fg[1] += *fg_ptr++ * weight; fg[2] += *fg_ptr++ * weight; fg[3] += *fg_ptr++ * weight; total_weight += weight; x_hr += base_type::m_rx_inv; if(x_hr >= filter_scale) break; fg_ptr = (const value_type*)base_type::source().next_x(); } y_hr += base_type::m_ry_inv; if(y_hr >= filter_scale) break; fg_ptr = (const value_type*)base_type::source().next_y(); } fg[0] /= total_weight; fg[1] /= total_weight; fg[2] /= total_weight; fg[3] /= total_weight; if(fg[0] < 0) fg[0] = 0; if(fg[1] < 0) fg[1] = 0; if(fg[2] < 0) fg[2] = 0; if(fg[3] < 0) fg[3] = 0; if(fg[order_type::A] > base_mask) fg[order_type::A] = base_mask; if(fg[order_type::R] > fg[order_type::A]) fg[order_type::R] = fg[order_type::A]; if(fg[order_type::G] > fg[order_type::A]) fg[order_type::G] = fg[order_type::A]; if(fg[order_type::B] > fg[order_type::A]) fg[order_type::B] = fg[order_type::A]; span->r = (value_type)fg[order_type::R]; span->g = (value_type)fg[order_type::G]; span->b = (value_type)fg[order_type::B]; span->a = (value_type)fg[order_type::A]; ++span; ++base_type::interpolator(); } while(--len); } }; //==============================================span_image_resample_rgba template class span_image_resample_rgba : public span_image_resample { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef Interpolator interpolator_type; typedef span_image_resample base_type; typedef typename color_type::value_type value_type; typedef typename color_type::long_type long_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask, downscale_shift = image_filter_shift }; //-------------------------------------------------------------------- span_image_resample_rgba() {} span_image_resample_rgba(source_type& src, interpolator_type& inter, const image_filter_lut& filter) : base_type(src, inter, filter) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); long_type fg[4]; int diameter = base_type::filter().diameter(); int filter_scale = diameter << image_subpixel_shift; const int16* weight_array = base_type::filter().weight_array(); do { int rx; int ry; int rx_inv = image_subpixel_scale; int ry_inv = image_subpixel_scale; base_type::interpolator().coordinates(&x, &y); base_type::interpolator().local_scale(&rx, &ry); rx = (rx * base_type::m_blur_x) >> image_subpixel_shift; ry = (ry * base_type::m_blur_y) >> image_subpixel_shift; if(rx < image_subpixel_scale) { rx = image_subpixel_scale; } else { if(rx > image_subpixel_scale * base_type::m_scale_limit) { rx = image_subpixel_scale * base_type::m_scale_limit; } rx_inv = image_subpixel_scale * image_subpixel_scale / rx; } if(ry < image_subpixel_scale) { ry = image_subpixel_scale; } else { if(ry > image_subpixel_scale * base_type::m_scale_limit) { ry = image_subpixel_scale * base_type::m_scale_limit; } ry_inv = image_subpixel_scale * image_subpixel_scale / ry; } int radius_x = (diameter * rx) >> 1; int radius_y = (diameter * ry) >> 1; int len_x_lr = (diameter * rx + image_subpixel_mask) >> image_subpixel_shift; x += base_type::filter_dx_int() - radius_x; y += base_type::filter_dy_int() - radius_y; fg[0] = fg[1] = fg[2] = fg[3] = image_filter_scale / 2; int y_lr = y >> image_subpixel_shift; int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * ry_inv) >> image_subpixel_shift; int total_weight = 0; int x_lr = x >> image_subpixel_shift; int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * rx_inv) >> image_subpixel_shift; int x_hr2 = x_hr; const value_type* fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); for(;;) { int weight_y = weight_array[y_hr]; x_hr = x_hr2; for(;;) { int weight = (weight_y * weight_array[x_hr] + image_filter_scale / 2) >> downscale_shift; fg[0] += *fg_ptr++ * weight; fg[1] += *fg_ptr++ * weight; fg[2] += *fg_ptr++ * weight; fg[3] += *fg_ptr++ * weight; total_weight += weight; x_hr += rx_inv; if(x_hr >= filter_scale) break; fg_ptr = (const value_type*)base_type::source().next_x(); } y_hr += ry_inv; if(y_hr >= filter_scale) break; fg_ptr = (const value_type*)base_type::source().next_y(); } fg[0] /= total_weight; fg[1] /= total_weight; fg[2] /= total_weight; fg[3] /= total_weight; if(fg[0] < 0) fg[0] = 0; if(fg[1] < 0) fg[1] = 0; if(fg[2] < 0) fg[2] = 0; if(fg[3] < 0) fg[3] = 0; if(fg[order_type::A] > base_mask) fg[order_type::A] = base_mask; if(fg[order_type::R] > fg[order_type::R]) fg[order_type::R] = fg[order_type::R]; if(fg[order_type::G] > fg[order_type::G]) fg[order_type::G] = fg[order_type::G]; if(fg[order_type::B] > fg[order_type::B]) fg[order_type::B] = fg[order_type::B]; span->r = (value_type)fg[order_type::R]; span->g = (value_type)fg[order_type::G]; span->b = (value_type)fg[order_type::B]; span->a = (value_type)fg[order_type::A]; ++span; ++base_type::interpolator(); } while(--len); } }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_close_polygon.h0000644000175000017500000000720612516137326025671 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_CONV_CLOSE_POLYGON_INCLUDED #define AGG_CONV_CLOSE_POLYGON_INCLUDED #include "agg_basics.h" namespace agg24 { //======================================================conv_close_polygon template class conv_close_polygon { public: conv_close_polygon(VertexSource& vs) : m_source(&vs) {} void attach(VertexSource& source) { m_source = &source; } void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: conv_close_polygon(const conv_close_polygon&); const conv_close_polygon& operator = (const conv_close_polygon&); VertexSource* m_source; unsigned m_cmd[2]; double m_x[2]; double m_y[2]; unsigned m_vertex; bool m_line_to; }; //------------------------------------------------------------------------ template void conv_close_polygon::rewind(unsigned path_id) { m_source->rewind(path_id); m_vertex = 2; m_line_to = false; } //------------------------------------------------------------------------ template unsigned conv_close_polygon::vertex(double* x, double* y) { unsigned cmd = path_cmd_stop; for(;;) { if(m_vertex < 2) { *x = m_x[m_vertex]; *y = m_y[m_vertex]; cmd = m_cmd[m_vertex]; ++m_vertex; break; } cmd = m_source->vertex(x, y); if(is_end_poly(cmd)) { cmd |= path_flags_close; break; } if(is_stop(cmd)) { if(m_line_to) { m_cmd[0] = path_cmd_end_poly | path_flags_close; m_cmd[1] = path_cmd_stop; m_vertex = 0; m_line_to = false; continue; } break; } if(is_move_to(cmd)) { if(m_line_to) { m_x[0] = 0.0; m_y[0] = 0.0; m_cmd[0] = path_cmd_end_poly | path_flags_close; m_x[1] = *x; m_y[1] = *y; m_cmd[1] = cmd; m_vertex = 0; m_line_to = false; continue; } break; } if(is_vertex(cmd)) { m_line_to = true; break; } } return cmd; } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_converter.h0000644000175000017500000000373012516137326025016 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_SPAN_CONVERTER_INCLUDED #define AGG_SPAN_CONVERTER_INCLUDED #include "agg_basics.h" namespace agg24 { //----------------------------------------------------------span_converter template class span_converter { public: typedef typename SpanGenerator::color_type color_type; span_converter(SpanGenerator& span_gen, SpanConverter& span_cnv) : m_span_gen(&span_gen), m_span_cnv(&span_cnv) {} void attach_generator(SpanGenerator& span_gen) { m_span_gen = &span_gen; } void attach_converter(SpanConverter& span_cnv) { m_span_cnv = &span_cnv; } //-------------------------------------------------------------------- void prepare() { m_span_gen->prepare(); m_span_cnv->prepare(); } //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { m_span_gen->generate(span, x, y, len); m_span_cnv->generate(span, x, y, len); } private: SpanGenerator* m_span_gen; SpanConverter* m_span_cnv; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_pixfmt_rgb.h0000644000175000017500000006654212516137326024141 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for high precision colors has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_PIXFMT_RGB_INCLUDED #define AGG_PIXFMT_RGB_INCLUDED #include #include "agg_basics.h" #include "agg_color_rgba.h" #include "agg_rendering_buffer.h" namespace agg24 { //=====================================================apply_gamma_dir_rgb template class apply_gamma_dir_rgb { public: typedef typename ColorT::value_type value_type; apply_gamma_dir_rgb(const GammaLut& gamma) : m_gamma(gamma) {} AGG_INLINE void operator () (value_type* p) { p[Order::R] = m_gamma.dir(p[Order::R]); p[Order::G] = m_gamma.dir(p[Order::G]); p[Order::B] = m_gamma.dir(p[Order::B]); } private: const GammaLut& m_gamma; }; //=====================================================apply_gamma_inv_rgb template class apply_gamma_inv_rgb { public: typedef typename ColorT::value_type value_type; apply_gamma_inv_rgb(const GammaLut& gamma) : m_gamma(gamma) {} AGG_INLINE void operator () (value_type* p) { p[Order::R] = m_gamma.inv(p[Order::R]); p[Order::G] = m_gamma.inv(p[Order::G]); p[Order::B] = m_gamma.inv(p[Order::B]); } private: const GammaLut& m_gamma; }; //=========================================================blender_rgb template struct blender_rgb { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift }; //-------------------------------------------------------------------- static AGG_INLINE void blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover=0) { p[Order::R] += (value_type)(((cr - p[Order::R]) * alpha) >> base_shift); p[Order::G] += (value_type)(((cg - p[Order::G]) * alpha) >> base_shift); p[Order::B] += (value_type)(((cb - p[Order::B]) * alpha) >> base_shift); } }; //======================================================blender_rgb_pre template struct blender_rgb_pre { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift }; //-------------------------------------------------------------------- static AGG_INLINE void blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover) { alpha = color_type::base_mask - alpha; cover = (cover + 1) << (base_shift - 8); p[Order::R] = (value_type)((p[Order::R] * alpha + cr * cover) >> base_shift); p[Order::G] = (value_type)((p[Order::G] * alpha + cg * cover) >> base_shift); p[Order::B] = (value_type)((p[Order::B] * alpha + cb * cover) >> base_shift); } //-------------------------------------------------------------------- static AGG_INLINE void blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha) { alpha = color_type::base_mask - alpha; p[Order::R] = (value_type)(((p[Order::R] * alpha) >> base_shift) + cr); p[Order::G] = (value_type)(((p[Order::G] * alpha) >> base_shift) + cg); p[Order::B] = (value_type)(((p[Order::B] * alpha) >> base_shift) + cb); } }; //===================================================blender_rgb_gamma template class blender_rgb_gamma { public: typedef ColorT color_type; typedef Order order_type; typedef Gamma gamma_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift }; //-------------------------------------------------------------------- blender_rgb_gamma() : m_gamma(0) {} void gamma(const gamma_type& g) { m_gamma = &g; } //-------------------------------------------------------------------- AGG_INLINE void blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover=0) { calc_type r = m_gamma->dir(p[Order::R]); calc_type g = m_gamma->dir(p[Order::G]); calc_type b = m_gamma->dir(p[Order::B]); p[Order::R] = m_gamma->inv((((m_gamma->dir(cr) - r) * alpha) >> base_shift) + r); p[Order::G] = m_gamma->inv((((m_gamma->dir(cg) - g) * alpha) >> base_shift) + g); p[Order::B] = m_gamma->inv((((m_gamma->dir(cb) - b) * alpha) >> base_shift) + b); } private: const gamma_type* m_gamma; }; //==================================================pixfmt_alpha_blend_rgb template class pixfmt_alpha_blend_rgb { public: typedef RenBuf rbuf_type; typedef typename rbuf_type::row_data row_data; typedef Blender blender_type; typedef typename blender_type::color_type color_type; typedef typename blender_type::order_type order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_scale = color_type::base_scale, base_mask = color_type::base_mask, pix_width = sizeof(value_type) * 3 }; private: //-------------------------------------------------------------------- AGG_INLINE void copy_or_blend_pix(value_type* p, const color_type& c, unsigned cover) { if (c.a) { calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; if(alpha == base_mask) { p[order_type::R] = c.r; p[order_type::G] = c.g; p[order_type::B] = c.b; } else { m_blender.blend_pix(p, c.r, c.g, c.b, alpha, cover); } } } //-------------------------------------------------------------------- AGG_INLINE void copy_or_blend_pix(value_type* p, const color_type& c) { if (c.a) { if(c.a == base_mask) { p[order_type::R] = c.r; p[order_type::G] = c.g; p[order_type::B] = c.b; } else { m_blender.blend_pix(p, c.r, c.g, c.b, c.a); } } } public: //-------------------------------------------------------------------- pixfmt_alpha_blend_rgb(rbuf_type& rb) : m_rbuf(&rb) {} void attach(rbuf_type& rb) { m_rbuf = &rb; } //-------------------------------------------------------------------- Blender& blender() { return m_blender; } //-------------------------------------------------------------------- AGG_INLINE unsigned width() const { return m_rbuf->width(); } AGG_INLINE unsigned height() const { return m_rbuf->height(); } //-------------------------------------------------------------------- const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); } //-------------------------------------------------------------------- const int8u* pix_ptr(int x, int y) const { return m_rbuf->row_ptr(y) + x * pix_width; } //-------------------------------------------------------------------- row_data row(int y) const { return m_rbuf->row(y); } //-------------------------------------------------------------------- AGG_INLINE static void make_pix(int8u* p, const color_type& c) { ((value_type*)p)[order_type::R] = c.r; ((value_type*)p)[order_type::G] = c.g; ((value_type*)p)[order_type::B] = c.b; } //-------------------------------------------------------------------- AGG_INLINE color_type pixel(int x, int y) const { value_type* p = (value_type*)m_rbuf->row_ptr(y) + x + x + x; return color_type(p[order_type::R], p[order_type::G], p[order_type::B]); } //-------------------------------------------------------------------- AGG_INLINE void copy_pixel(int x, int y, const color_type& c) { value_type* p = (value_type*)m_rbuf->row_ptr(x, y, 1) + x + x + x; p[order_type::R] = c.r; p[order_type::G] = c.g; p[order_type::B] = c.b; } //-------------------------------------------------------------------- AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover) { copy_or_blend_pix((value_type*)m_rbuf->row_ptr(x, y, 1) + x + x + x, c, cover); } //-------------------------------------------------------------------- AGG_INLINE void copy_hline(int x, int y, unsigned len, const color_type& c) { value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + x + x + x; do { p[order_type::R] = c.r; p[order_type::G] = c.g; p[order_type::B] = c.b; p += 3; } while(--len); } //-------------------------------------------------------------------- AGG_INLINE void copy_vline(int x, int y, unsigned len, const color_type& c) { do { value_type* p = (value_type*) m_rbuf->row_ptr(x, y++, 1) + x + x + x; p[order_type::R] = c.r; p[order_type::G] = c.g; p[order_type::B] = c.b; } while(--len); } //-------------------------------------------------------------------- void blend_hline(int x, int y, unsigned len, const color_type& c, int8u cover) { if (c.a) { value_type* p = (value_type*) m_rbuf->row_ptr(x, y, len) + x + x + x; calc_type alpha = (calc_type(c.a) * (calc_type(cover) + 1)) >> 8; if(alpha == base_mask) { do { p[order_type::R] = c.r; p[order_type::G] = c.g; p[order_type::B] = c.b; p += 3; } while(--len); } else { do { m_blender.blend_pix(p, c.r, c.g, c.b, alpha, cover); p += 3; } while(--len); } } } //-------------------------------------------------------------------- void blend_vline(int x, int y, unsigned len, const color_type& c, int8u cover) { if (c.a) { value_type* p; calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; if(alpha == base_mask) { do { p = (value_type*) m_rbuf->row_ptr(x, y++, 1) + x + x + x; p[order_type::R] = c.r; p[order_type::G] = c.g; p[order_type::B] = c.b; } while(--len); } else { do { p = (value_type*) m_rbuf->row_ptr(x, y++, 1) + x + x + x; m_blender.blend_pix(p, c.r, c.g, c.b, alpha, cover); } while(--len); } } } //-------------------------------------------------------------------- void blend_solid_hspan(int x, int y, unsigned len, const color_type& c, const int8u* covers) { if (c.a) { value_type* p = (value_type*) m_rbuf->row_ptr(x, y, len) + x + x + x; do { calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8; if(alpha == base_mask) { p[order_type::R] = c.r; p[order_type::G] = c.g; p[order_type::B] = c.b; } else { m_blender.blend_pix(p, c.r, c.g, c.b, alpha, *covers); } p += 3; ++covers; } while(--len); } } //-------------------------------------------------------------------- void blend_solid_vspan(int x, int y, unsigned len, const color_type& c, const int8u* covers) { if (c.a) { do { value_type* p = (value_type*) m_rbuf->row_ptr(x, y++, 1) + x + x + x; calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8; if(alpha == base_mask) { p[order_type::R] = c.r; p[order_type::G] = c.g; p[order_type::B] = c.b; } else { m_blender.blend_pix(p, c.r, c.g, c.b, alpha, *covers); } ++covers; } while(--len); } } //-------------------------------------------------------------------- void copy_color_hspan(int x, int y, unsigned len, const color_type* colors) { value_type* p = (value_type*) m_rbuf->row_ptr(x, y, len) + x + x + x; do { p[order_type::R] = colors->r; p[order_type::G] = colors->g; p[order_type::B] = colors->b; ++colors; p += 3; } while(--len); } //-------------------------------------------------------------------- void blend_color_hspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover) { value_type* p = (value_type*) m_rbuf->row_ptr(x, y, len) + x + x + x; if(covers) { do { copy_or_blend_pix(p, *colors++, *covers++); p += 3; } while(--len); } else { if(cover == 255) { do { copy_or_blend_pix(p, *colors++); p += 3; } while(--len); } else { do { copy_or_blend_pix(p, *colors++, cover); p += 3; } while(--len); } } } //-------------------------------------------------------------------- void blend_color_vspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover) { value_type* p; if(covers) { do { p = (value_type*) m_rbuf->row_ptr(x, y++, 1) + x + x + x; copy_or_blend_pix(p, *colors++, *covers++); } while(--len); } else { if(cover == 255) { do { p = (value_type*) m_rbuf->row_ptr(x, y++, 1) + x + x + x; copy_or_blend_pix(p, *colors++); } while(--len); } else { do { p = (value_type*) m_rbuf->row_ptr(x, y++, 1) + x + x + x; copy_or_blend_pix(p, *colors++, cover); } while(--len); } } } //-------------------------------------------------------------------- template void for_each_pixel(Function f) { unsigned y; for(y = 0; y < height(); ++y) { row_data r = m_rbuf->row(y); if(r.ptr) { unsigned len = r.x2 - r.x1 + 1; value_type* p = (value_type*) m_rbuf->row_ptr(r.x1, y, len) + r.x1 * 3; do { f(p); p += 3; } while(--len); } } } //-------------------------------------------------------------------- template void apply_gamma_dir(const GammaLut& g) { for_each_pixel(apply_gamma_dir_rgb(g)); } //-------------------------------------------------------------------- template void apply_gamma_inv(const GammaLut& g) { for_each_pixel(apply_gamma_inv_rgb(g)); } //-------------------------------------------------------------------- template void copy_from(const RenBuf2& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len) { const int8u* p = from.row_ptr(ysrc); if(p) { memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, p + xsrc * pix_width, len * pix_width); } } //-------------------------------------------------------------------- template void blend_from(const SrcPixelFormatRenderer& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len, int8u cover) { typedef typename SrcPixelFormatRenderer::order_type src_order; const value_type* psrc = (const value_type*)from.row_ptr(ysrc); if(psrc) { psrc += xsrc * 4; value_type* pdst = (value_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst * 3; if(cover == 255) { do { value_type alpha = psrc[src_order::A]; if(alpha) { if(alpha == base_mask) { pdst[order_type::R] = psrc[src_order::R]; pdst[order_type::G] = psrc[src_order::G]; pdst[order_type::B] = psrc[src_order::B]; } else { m_blender.blend_pix(pdst, psrc[src_order::R], psrc[src_order::G], psrc[src_order::B], alpha); } } psrc += 4; pdst += 3; } while(--len); } else { color_type color; do { color.r = psrc[src_order::R]; color.g = psrc[src_order::G]; color.b = psrc[src_order::B]; color.a = psrc[src_order::A]; copy_or_blend_pix(pdst, color, cover); psrc += 4; pdst += 3; } while(--len); } } } private: rbuf_type* m_rbuf; Blender m_blender; }; typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_rgb24; //----pixfmt_rgb24 typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_bgr24; //----pixfmt_bgr24 typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_rgb48; //----pixfmt_rgb48 typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_bgr48; //----pixfmt_bgr48 typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_rgb24_pre; //----pixfmt_rgb24_pre typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_bgr24_pre; //----pixfmt_bgr24_pre typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_rgb48_pre; //----pixfmt_rgb48_pre typedef pixfmt_alpha_blend_rgb, rendering_buffer> pixfmt_bgr48_pre; //----pixfmt_bgr48_pre //-----------------------------------------------------pixfmt_rgb24_gamma template class pixfmt_rgb24_gamma : public pixfmt_alpha_blend_rgb, rendering_buffer> { public: pixfmt_rgb24_gamma(rendering_buffer& rb, const Gamma& g) : pixfmt_alpha_blend_rgb, rendering_buffer>(rb) { this->blender().gamma(g); } }; //-----------------------------------------------------pixfmt_bgr24_gamma template class pixfmt_bgr24_gamma : public pixfmt_alpha_blend_rgb, rendering_buffer> { public: pixfmt_bgr24_gamma(rendering_buffer& rb, const Gamma& g) : pixfmt_alpha_blend_rgb, rendering_buffer>(rb) { this->blender().gamma(g); } }; //-----------------------------------------------------pixfmt_rgb48_gamma template class pixfmt_rgb48_gamma : public pixfmt_alpha_blend_rgb, rendering_buffer> { public: pixfmt_rgb48_gamma(rendering_buffer& rb, const Gamma& g) : pixfmt_alpha_blend_rgb, rendering_buffer>(rb) { this->blender().gamma(g); } }; //-----------------------------------------------------pixfmt_bgr48_gamma template class pixfmt_bgr48_gamma : public pixfmt_alpha_blend_rgb, rendering_buffer> { public: pixfmt_bgr48_gamma(rendering_buffer& rb, const Gamma& g) : pixfmt_alpha_blend_rgb, rendering_buffer>(rb) { this->blender().gamma(g); } }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_gradient.h0000644000175000017500000003425312516137326024610 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_SPAN_GRADIENT_INCLUDED #define AGG_SPAN_GRADIENT_INCLUDED #include #include #include #include "agg_basics.h" #include "agg_math.h" #include "agg_array.h" namespace agg24 { enum gradient_subpixel_scale_e { gradient_subpixel_shift = 4, //-----gradient_subpixel_shift gradient_subpixel_scale = 1 << gradient_subpixel_shift, //-----gradient_subpixel_scale gradient_subpixel_mask = gradient_subpixel_scale - 1 //-----gradient_subpixel_mask }; //==========================================================span_gradient template class span_gradient { public: typedef Interpolator interpolator_type; typedef ColorT color_type; enum downscale_shift_e { downscale_shift = interpolator_type::subpixel_shift - gradient_subpixel_shift }; //-------------------------------------------------------------------- span_gradient() {} //-------------------------------------------------------------------- span_gradient(interpolator_type& inter, const GradientF& gradient_function, const ColorF& color_function, double d1, double d2) : m_interpolator(&inter), m_gradient_function(&gradient_function), m_color_function(&color_function), m_d1(iround(d1 * gradient_subpixel_scale)), m_d2(iround(d2 * gradient_subpixel_scale)) {} //-------------------------------------------------------------------- interpolator_type& interpolator() { return *m_interpolator; } const GradientF& gradient_function() const { return *m_gradient_function; } const ColorF& color_function() const { return *m_color_function; } double d1() const { return double(m_d1) / gradient_subpixel_scale; } double d2() const { return double(m_d2) / gradient_subpixel_scale; } //-------------------------------------------------------------------- void interpolator(interpolator_type& i) { m_interpolator = &i; } void gradient_function(const GradientF& gf) { m_gradient_function = &gf; } void color_function(const ColorF& cf) { m_color_function = &cf; } void d1(double v) { m_d1 = iround(v * gradient_subpixel_scale); } void d2(double v) { m_d2 = iround(v * gradient_subpixel_scale); } //-------------------------------------------------------------------- void prepare() {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { int dd = m_d2 - m_d1; if(dd < 1) dd = 1; m_interpolator->begin(x+0.5, y+0.5, len); do { m_interpolator->coordinates(&x, &y); int d = m_gradient_function->calculate(x >> downscale_shift, y >> downscale_shift, m_d2); d = ((d - m_d1) * (int)m_color_function->size()) / dd; if(d < 0) d = 0; if(d >= (int)m_color_function->size()) d = m_color_function->size() - 1; *span++ = (*m_color_function)[d]; ++(*m_interpolator); } while(--len); } private: interpolator_type* m_interpolator; const GradientF* m_gradient_function; const ColorF* m_color_function; int m_d1; int m_d2; }; //=====================================================gradient_linear_color template struct gradient_linear_color { typedef ColorT color_type; gradient_linear_color() {} gradient_linear_color(const color_type& c1, const color_type& c2, unsigned size = 256) : m_c1(c1), m_c2(c2), m_size(size) {} unsigned size() const { return m_size; } color_type operator [] (unsigned v) const { return m_c1.gradient(m_c2, double(v) / double(m_size - 1)); } void colors(const color_type& c1, const color_type& c2, unsigned size = 256) { m_c1 = c1; m_c2 = c2; m_size = size; } color_type m_c1; color_type m_c2; unsigned m_size; }; //==========================================================gradient_circle class gradient_circle { // Actually the same as radial. Just for compatibility public: static AGG_INLINE int calculate(int x, int y, int) { return int(fast_sqrt(x*x + y*y)); } }; //==========================================================gradient_radial class gradient_radial { public: static AGG_INLINE int calculate(int x, int y, int) { return int(fast_sqrt(x*x + y*y)); } }; //========================================================gradient_radial_d class gradient_radial_d { public: static AGG_INLINE int calculate(int x, int y, int) { return uround(sqrt(double(x)*double(x) + double(y)*double(y))); } }; //====================================================gradient_radial_focus class gradient_radial_focus { public: //--------------------------------------------------------------------- gradient_radial_focus() : m_radius(100 * gradient_subpixel_scale), m_focus_x(0), m_focus_y(0) { update_values(); } //--------------------------------------------------------------------- gradient_radial_focus(double r, double fx, double fy) : m_radius (iround(r * gradient_subpixel_scale)), m_focus_x(iround(fx * gradient_subpixel_scale)), m_focus_y(iround(fy * gradient_subpixel_scale)) { update_values(); } //--------------------------------------------------------------------- void init(double r, double fx, double fy) { m_radius = iround(r * gradient_subpixel_scale); m_focus_x = iround(fx * gradient_subpixel_scale); m_focus_y = iround(fy * gradient_subpixel_scale); update_values(); } //--------------------------------------------------------------------- double radius() const { return double(m_radius) / gradient_subpixel_scale; } double focus_x() const { return double(m_focus_x) / gradient_subpixel_scale; } double focus_y() const { return double(m_focus_y) / gradient_subpixel_scale; } //--------------------------------------------------------------------- int calculate(int x, int y, int) const { double solution_x; double solution_y; // Special case to avoid divide by zero or very near zero //--------------------------------- if(x == iround(m_focus_x)) { solution_x = m_focus_x; solution_y = 0.0; solution_y += (y > m_focus_y) ? m_trivial : -m_trivial; } else { // Slope of the focus-current line //------------------------------- double slope = double(y - m_focus_y) / double(x - m_focus_x); // y-intercept of that same line //-------------------------------- double yint = double(y) - (slope * x); // Use the classical quadratic formula to calculate // the intersection point //-------------------------------- double a = (slope * slope) + 1; double b = 2 * slope * yint; double c = yint * yint - m_radius2; double det = sqrt((b * b) - (4.0 * a * c)); solution_x = -b; // Choose the positive or negative root depending // on where the X coord lies with respect to the focus. solution_x += (x < m_focus_x) ? -det : det; solution_x /= 2.0 * a; // Calculating of Y is trivial solution_y = (slope * solution_x) + yint; } // Calculate the percentage (0...1) of the current point along the // focus-circumference line and return the normalized (0...d) value //------------------------------- solution_x -= double(m_focus_x); solution_y -= double(m_focus_y); double int_to_focus = solution_x * solution_x + solution_y * solution_y; double cur_to_focus = double(x - m_focus_x) * double(x - m_focus_x) + double(y - m_focus_y) * double(y - m_focus_y); return iround(sqrt(cur_to_focus / int_to_focus) * m_radius); } private: //--------------------------------------------------------------------- void update_values() { // For use in the quadratic equation //------------------------------- m_radius2 = double(m_radius) * double(m_radius); double dist = sqrt(double(m_focus_x) * double(m_focus_x) + double(m_focus_y) * double(m_focus_y)); // Test if distance from focus to center is greater than the radius // For the sake of assurance factor restrict the point to be // no further than 99% of the radius. //------------------------------- double r = m_radius * 0.99; if(dist > r) { // clamp focus to radius // x = r cos theta, y = r sin theta //------------------------ double a = atan2(double(m_focus_y), double(m_focus_x)); m_focus_x = iround(r * cos(a)); m_focus_y = iround(r * sin(a)); } // Calculate the solution to be used in the case where x == focus_x //------------------------------ m_trivial = sqrt(m_radius2 - (m_focus_x * m_focus_x)); } int m_radius; int m_focus_x; int m_focus_y; double m_radius2; double m_trivial; }; //==============================================================gradient_x class gradient_x { public: static int calculate(int x, int, int) { return x; } }; //==============================================================gradient_y class gradient_y { public: static int calculate(int, int y, int) { return y; } }; //========================================================gradient_diamond class gradient_diamond { public: static AGG_INLINE int calculate(int x, int y, int) { int ax = abs(x); int ay = abs(y); return ax > ay ? ax : ay; } }; //=============================================================gradient_xy class gradient_xy { public: static AGG_INLINE int calculate(int x, int y, int d) { return abs(x) * abs(y) / d; } }; //========================================================gradient_sqrt_xy class gradient_sqrt_xy { public: static AGG_INLINE int calculate(int x, int y, int) { return fast_sqrt(abs(x) * abs(y)); } }; //==========================================================gradient_conic class gradient_conic { public: static AGG_INLINE int calculate(int x, int y, int d) { return uround(fabs(atan2(double(y), double(x))) * double(d) / pi); } }; //=================================================gradient_repeat_adaptor template class gradient_repeat_adaptor { public: gradient_repeat_adaptor(const GradientF& gradient) : m_gradient(&gradient) {} AGG_INLINE int calculate(int x, int y, int d) const { int ret = m_gradient->calculate(x, y, d) % d; if(ret < 0) ret += d; return ret; } private: const GradientF* m_gradient; }; //================================================gradient_reflect_adaptor template class gradient_reflect_adaptor { public: gradient_reflect_adaptor(const GradientF& gradient) : m_gradient(&gradient) {} AGG_INLINE int calculate(int x, int y, int d) const { int d2 = d << 1; int ret = m_gradient->calculate(x, y, d) % d2; if(ret < 0) ret += d2; if(ret >= d) ret = d2 - ret; return ret; } private: const GradientF* m_gradient; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_gamma_functions.h0000644000175000017500000000646112516137326025144 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_GAMMA_FUNCTIONS_INCLUDED #define AGG_GAMMA_FUNCTIONS_INCLUDED #include #include "agg_basics.h" namespace agg24 { //===============================================================gamma_none struct gamma_none { double operator()(double x) const { return x; } }; //==============================================================gamma_power class gamma_power { public: gamma_power() : m_gamma(1.0) {} gamma_power(double g) : m_gamma(g) {} void gamma(double g) { m_gamma = g; } double gamma() const { return m_gamma; } double operator() (double x) const { return pow(x, m_gamma); } private: double m_gamma; }; //==========================================================gamma_threshold class gamma_threshold { public: gamma_threshold() : m_threshold(0.5) {} gamma_threshold(double t) : m_threshold(t) {} void threshold(double t) { m_threshold = t; } double threshold() const { return m_threshold; } double operator() (double x) const { return (x < m_threshold) ? 0.0 : 1.0; } private: double m_threshold; }; //============================================================gamma_linear class gamma_linear { public: gamma_linear() : m_start(0.0), m_end(1.0) {} gamma_linear(double s, double e) : m_start(s), m_end(e) {} void set(double s, double e) { m_start = s; m_end = e; } void start(double s) { m_start = s; } void end(double e) { m_end = e; } double start() const { return m_start; } double end() const { return m_end; } double operator() (double x) const { if(x < m_start) return 0.0; if(x > m_end) return 1.0; return (x - m_start) / (m_end - m_start); } private: double m_start; double m_end; }; //==========================================================gamma_multiply class gamma_multiply { public: gamma_multiply() : m_mul(1.0) {} gamma_multiply(double v) : m_mul(v) {} void value(double v) { m_mul = v; } double value() const { return m_mul; } double operator() (double x) const { double y = x * m_mul; if(y > 1.0) y = 1.0; return y; } private: double m_mul; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_gouraud.h0000644000175000017500000001341512516137326024456 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_SPAN_GOURAUD_INCLUDED #define AGG_SPAN_GOURAUD_INCLUDED #include "agg_basics.h" #include "agg_math.h" namespace agg24 { //============================================================span_gouraud template class span_gouraud { public: typedef ColorT color_type; struct coord_type { double x; double y; color_type color; }; //-------------------------------------------------------------------- span_gouraud() : m_vertex(0) { m_cmd[0] = path_cmd_stop; } //-------------------------------------------------------------------- span_gouraud(const color_type& c1, const color_type& c2, const color_type& c3, double x1, double y1, double x2, double y2, double x3, double y3, double d) : m_vertex(0) { colors(c1, c2, c3); triangle(x1, y1, x2, y2, x3, y3, d); } //-------------------------------------------------------------------- void colors(ColorT c1, ColorT c2, ColorT c3) { m_coord[0].color = c1; m_coord[1].color = c2; m_coord[2].color = c3; } //-------------------------------------------------------------------- // Sets the triangle and dilates it if needed. // The trick here is to calculate beveled joins in the vertices of the // triangle and render it as a 6-vertex polygon. // It's necessary to achieve numerical stability. // However, the coordinates to interpolate colors are calculated // as miter joins (calc_intersection). void triangle(double x1, double y1, double x2, double y2, double x3, double y3, double d) { m_coord[0].x = m_x[0] = x1; m_coord[0].y = m_y[0] = y1; m_coord[1].x = m_x[1] = x2; m_coord[1].y = m_y[1] = y2; m_coord[2].x = m_x[2] = x3; m_coord[2].y = m_y[2] = y3; m_cmd[0] = path_cmd_move_to; m_cmd[1] = path_cmd_line_to; m_cmd[2] = path_cmd_line_to; m_cmd[3] = path_cmd_stop; if(d != 0.0) { dilate_triangle(m_coord[0].x, m_coord[0].y, m_coord[1].x, m_coord[1].y, m_coord[2].x, m_coord[2].y, m_x, m_y, d); calc_intersection(m_x[4], m_y[4], m_x[5], m_y[5], m_x[0], m_y[0], m_x[1], m_y[1], &m_coord[0].x, &m_coord[0].y); calc_intersection(m_x[0], m_y[0], m_x[1], m_y[1], m_x[2], m_y[2], m_x[3], m_y[3], &m_coord[1].x, &m_coord[1].y); calc_intersection(m_x[2], m_y[2], m_x[3], m_y[3], m_x[4], m_y[4], m_x[5], m_y[5], &m_coord[2].x, &m_coord[2].y); m_cmd[3] = path_cmd_line_to; m_cmd[4] = path_cmd_line_to; m_cmd[5] = path_cmd_line_to; m_cmd[6] = path_cmd_stop; } } //-------------------------------------------------------------------- // Vertex Source Interface to feed the coordinates to the rasterizer void rewind(unsigned) { m_vertex = 0; } //-------------------------------------------------------------------- unsigned vertex(double* x, double* y) { *x = m_x[m_vertex]; *y = m_y[m_vertex]; return m_cmd[m_vertex++]; } protected: //-------------------------------------------------------------------- void arrange_vertices(coord_type* coord) const { coord[0] = m_coord[0]; coord[1] = m_coord[1]; coord[2] = m_coord[2]; if(m_coord[0].y > m_coord[2].y) { coord[0] = m_coord[2]; coord[2] = m_coord[0]; } coord_type tmp; if(coord[0].y > coord[1].y) { tmp = coord[1]; coord[1] = coord[0]; coord[0] = tmp; } if(coord[1].y > coord[2].y) { tmp = coord[2]; coord[2] = coord[1]; coord[1] = tmp; } } private: //-------------------------------------------------------------------- coord_type m_coord[3]; double m_x[8]; double m_y[8]; unsigned m_cmd[8]; unsigned m_vertex; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_math.h0000644000175000017500000003177012516137326022724 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // Bessel function (besj) was adapted for use in AGG library by Andy Wilk // Contact: castor.vulgaris@gmail.com //---------------------------------------------------------------------------- #ifndef AGG_MATH_INCLUDED #define AGG_MATH_INCLUDED #include #include "agg_basics.h" namespace agg24 { //------------------------------------------------------vertex_dist_epsilon // Coinciding points maximal distance (Epsilon) const double vertex_dist_epsilon = 1e-14; //-----------------------------------------------------intersection_epsilon // See calc_intersection const double intersection_epsilon = 1.0e-30; //------------------------------------------------------------cross_product AGG_INLINE double cross_product(double x1, double y1, double x2, double y2, double x, double y) { return (x - x2) * (y2 - y1) - (y - y2) * (x2 - x1); } //--------------------------------------------------------point_in_triangle AGG_INLINE bool point_in_triangle(double x1, double y1, double x2, double y2, double x3, double y3, double x, double y) { bool cp1 = cross_product(x1, y1, x2, y2, x, y) < 0.0; bool cp2 = cross_product(x2, y2, x3, y3, x, y) < 0.0; bool cp3 = cross_product(x3, y3, x1, y1, x, y) < 0.0; return cp1 == cp2 && cp2 == cp3 && cp3 == cp1; } //-----------------------------------------------------------calc_distance AGG_INLINE double calc_distance(double x1, double y1, double x2, double y2) { double dx = x2-x1; double dy = y2-y1; return sqrt(dx * dx + dy * dy); } //------------------------------------------------calc_line_point_distance AGG_INLINE double calc_line_point_distance(double x1, double y1, double x2, double y2, double x, double y) { double dx = x2-x1; double dy = y2-y1; double d = sqrt(dx * dx + dy * dy); if(d < vertex_dist_epsilon) { return calc_distance(x1, y1, x, y); } return ((x - x2) * dy - (y - y2) * dx) / d; } //-------------------------------------------------------calc_intersection AGG_INLINE bool calc_intersection(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy, double* x, double* y) { double num = (ay-cy) * (dx-cx) - (ax-cx) * (dy-cy); double den = (bx-ax) * (dy-cy) - (by-ay) * (dx-cx); if(fabs(den) < intersection_epsilon) return false; double r = num / den; *x = ax + r * (bx-ax); *y = ay + r * (by-ay); return true; } //-----------------------------------------------------intersection_exists AGG_INLINE bool intersection_exists(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { // It's less expensive but you can't control the // boundary conditions: Less or LessEqual double dx1 = x2 - x1; double dy1 = y2 - y1; double dx2 = x4 - x3; double dy2 = y4 - y3; return ((x3 - x2) * dy1 - (y3 - y2) * dx1 < 0.0) != ((x4 - x2) * dy1 - (y4 - y2) * dx1 < 0.0) && ((x1 - x4) * dy2 - (y1 - y4) * dx2 < 0.0) != ((x2 - x4) * dy2 - (y2 - y4) * dx2 < 0.0); // It's is more expensive but more flexible // in terms of boundary conditions. //-------------------- //double den = (x2-x1) * (y4-y3) - (y2-y1) * (x4-x3); //if(fabs(den) < intersection_epsilon) return false; //double nom1 = (x4-x3) * (y1-y3) - (y4-y3) * (x1-x3); //double nom2 = (x2-x1) * (y1-y3) - (y2-y1) * (x1-x3); //double ua = nom1 / den; //double ub = nom2 / den; //return ua >= 0.0 && ua <= 1.0 && ub >= 0.0 && ub <= 1.0; } //--------------------------------------------------------calc_orthogonal AGG_INLINE void calc_orthogonal(double thickness, double x1, double y1, double x2, double y2, double* x, double* y) { double dx = x2 - x1; double dy = y2 - y1; double d = sqrt(dx*dx + dy*dy); *x = thickness * dy / d; *y = thickness * dx / d; } //--------------------------------------------------------dilate_triangle AGG_INLINE void dilate_triangle(double x1, double y1, double x2, double y2, double x3, double y3, double *x, double* y, double d) { double dx1=0.0; double dy1=0.0; double dx2=0.0; double dy2=0.0; double dx3=0.0; double dy3=0.0; double loc = cross_product(x1, y1, x2, y2, x3, y3); if(fabs(loc) > intersection_epsilon) { if(cross_product(x1, y1, x2, y2, x3, y3) > 0.0) { d = -d; } calc_orthogonal(d, x1, y1, x2, y2, &dx1, &dy1); calc_orthogonal(d, x2, y2, x3, y3, &dx2, &dy2); calc_orthogonal(d, x3, y3, x1, y1, &dx3, &dy3); } *x++ = x1 + dx1; *y++ = y1 - dy1; *x++ = x2 + dx1; *y++ = y2 - dy1; *x++ = x2 + dx2; *y++ = y2 - dy2; *x++ = x3 + dx2; *y++ = y3 - dy2; *x++ = x3 + dx3; *y++ = y3 - dy3; *x++ = x1 + dx3; *y++ = y1 - dy3; } //------------------------------------------------------calc_triangle_area AGG_INLINE double calc_triangle_area(double x1, double y1, double x2, double y2, double x3, double y3) { return (x1*y2 - x2*y1 + x2*y3 - x3*y2 + x3*y1 - x1*y3) * 0.5; } //-------------------------------------------------------calc_polygon_area template double calc_polygon_area(const Storage& st) { unsigned i; double sum = 0.0; double x = st[0].x; double y = st[0].y; double xs = x; double ys = y; for(i = 1; i < st.size(); i++) { const typename Storage::value_type& v = st[i]; sum += x * v.y - y * v.x; x = v.x; y = v.y; } return (sum + x * ys - y * xs) * 0.5; } //------------------------------------------------------------------------ // Tables for fast sqrt extern int16u g_sqrt_table[1024]; extern int8 g_elder_bit_table[256]; //---------------------------------------------------------------fast_sqrt //Fast integer Sqrt - really fast: no cycles, divisions or multiplications #if defined(_MSC_VER) #pragma warning(push) #pragma warning(disable : 4035) //Disable warning "no return value" #endif AGG_INLINE unsigned fast_sqrt(unsigned val) { #if defined(_M_IX86) && defined(_MSC_VER) && !defined(AGG_NO_ASM) //For Ix86 family processors this assembler code is used. //The key command here is bsr - determination the number of the most //significant bit of the value. For other processors //(and maybe compilers) the pure C "#else" section is used. __asm { mov ebx, val mov edx, 11 bsr ecx, ebx sub ecx, 9 jle less_than_9_bits shr ecx, 1 adc ecx, 0 sub edx, ecx shl ecx, 1 shr ebx, cl less_than_9_bits: xor eax, eax mov ax, g_sqrt_table[ebx*2] mov ecx, edx shr eax, cl } #else //This code is actually pure C and portable to most //arcitectures including 64bit ones. unsigned t = val; int bit=0; unsigned shift = 11; //The following piece of code is just an emulation of the //Ix86 assembler command "bsr" (see above). However on old //Intels (like Intel MMX 233MHz) this code is about twice //faster (sic!) then just one "bsr". On PIII and PIV the //bsr is optimized quite well. bit = t >> 24; if(bit) { bit = g_elder_bit_table[bit] + 24; } else { bit = (t >> 16) & 0xFF; if(bit) { bit = g_elder_bit_table[bit] + 16; } else { bit = (t >> 8) & 0xFF; if(bit) { bit = g_elder_bit_table[bit] + 8; } else { bit = g_elder_bit_table[t]; } } } //This is calculation sqrt itself. bit -= 9; if(bit > 0) { bit = (bit >> 1) + (bit & 1); shift -= bit; val >>= (bit << 1); } return g_sqrt_table[val] >> shift; #endif } #if defined(_MSC_VER) #pragma warning(pop) #endif //--------------------------------------------------------------------besj // Function BESJ calculates Bessel function of first kind of order n // Arguments: // n - an integer (>=0), the order // x - value at which the Bessel function is required //-------------------- // C++ Mathematical Library // Convereted from equivalent FORTRAN library // Converetd by Gareth Walker for use by course 392 computational project // All functions tested and yield the same results as the corresponding // FORTRAN versions. // // If you have any problems using these functions please report them to // M.Muldoon@UMIST.ac.uk // // Documentation available on the web // http://www.ma.umist.ac.uk/mrm/Teaching/392/libs/392.html // Version 1.0 8/98 // 29 October, 1999 //-------------------- // Adapted for use in AGG library by Andy Wilk (castor.vulgaris@gmail.com) //------------------------------------------------------------------------ inline double besj(double x, int n) { if(n < 0) { return 0; } double d = 1E-6; double b = 0; if(fabs(x) <= d) { if(n != 0) return 0; return 1; } double b1 = 0; // b1 is the value from the previous iteration // Set up a starting order for recurrence int m1 = (int)fabs(x) + 6; if(fabs(x) > 5) { m1 = (int)(fabs(1.4 * x + 60 / x)); } int m2 = (int)(n + 2 + fabs(x) / 4); if (m1 > m2) { m2 = m1; } // Apply recurrence down from curent max order for(;;) { double c3 = 0; double c2 = 1E-30; double c4 = 0; int m8 = 1; if (m2 / 2 * 2 == m2) { m8 = -1; } int imax = m2 - 2; for (int i = 1; i <= imax; i++) { double c6 = 2 * (m2 - i) * c2 / x - c3; c3 = c2; c2 = c6; if(m2 - i - 1 == n) { b = c6; } m8 = -1 * m8; if (m8 > 0) { c4 = c4 + 2 * c6; } } double c6 = 2 * c2 / x - c3; if(n == 0) { b = c6; } c4 += c6; b /= c4; if(fabs(b - b1) < d) { return b; } b1 = b; m2 += 3; } } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_gamma_lut.h0000644000175000017500000000676012516137326023742 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_GAMMA_LUT_INCLUDED #define AGG_GAMMA_LUT_INCLUDED #include #include "agg_basics.h" namespace agg24 { template class gamma_lut { public: typedef gamma_lut self_type; enum gamma_scale_e { gamma_shift = GammaShift, gamma_size = 1 << gamma_shift, gamma_mask = gamma_size - 1 }; enum hi_res_scale_e { hi_res_shift = HiResShift, hi_res_size = 1 << hi_res_shift, hi_res_mask = hi_res_size - 1 }; ~gamma_lut() { pod_allocator::deallocate(m_inv_gamma, hi_res_size); pod_allocator::deallocate(m_dir_gamma, gamma_size); } gamma_lut() : m_gamma(1.0), m_dir_gamma(pod_allocator::allocate(gamma_size)), m_inv_gamma(pod_allocator::allocate(hi_res_size)) { unsigned i; for(i = 0; i < gamma_size; i++) { m_dir_gamma[i] = HiResT(i << (hi_res_shift - gamma_shift)); } for(i = 0; i < hi_res_size; i++) { m_inv_gamma[i] = LoResT(i >> (hi_res_shift - gamma_shift)); } } gamma_lut(double g) : m_gamma(1.0), m_dir_gamma(pod_allocator::allocate(gamma_size)), m_inv_gamma(pod_allocator::allocate(hi_res_size)) { gamma(g); } void gamma(double g) { m_gamma = g; unsigned i; for(i = 0; i < gamma_size; i++) { m_dir_gamma[i] = (HiResT) uround(pow(i / double(gamma_mask), m_gamma) * double(hi_res_mask)); } double inv_g = 1.0 / g; for(i = 0; i < hi_res_size; i++) { m_inv_gamma[i] = (LoResT) uround(pow(i / double(hi_res_mask), inv_g) * double(gamma_mask)); } } double gamma() const { return m_gamma; } HiResT dir(LoResT v) const { return m_dir_gamma[unsigned(v)]; } LoResT inv(HiResT v) const { return m_inv_gamma[unsigned(v)]; } private: gamma_lut(const self_type&); const self_type& operator = (const self_type&); double m_gamma; HiResT* m_dir_gamma; LoResT* m_inv_gamma; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_rasterizer_cells_aa.h0000644000175000017500000005321512516137326026006 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // // The author gratefully acknowleges the support of David Turner, // Robert Wilhelm, and Werner Lemberg - the authors of the FreeType // libray - in producing this work. See http://www.freetype.org for details. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for 32-bit screen coordinates has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_RASTERIZER_CELLS_AA_INCLUDED #define AGG_RASTERIZER_CELLS_AA_INCLUDED #include #include #include "agg_math.h" #include "agg_array.h" namespace agg24 { //-----------------------------------------------------rasterizer_cells_aa // An internal class that implements the main rasterization algorithm. // Used in the rasterizer. Should not be used direcly. template class rasterizer_cells_aa { enum cell_block_scale_e { cell_block_shift = 12, cell_block_size = 1 << cell_block_shift, cell_block_mask = cell_block_size - 1, cell_block_pool = 256, cell_block_limit = 1024 }; struct sorted_y { unsigned start; unsigned num; }; public: typedef Cell cell_type; typedef rasterizer_cells_aa self_type; ~rasterizer_cells_aa(); rasterizer_cells_aa(); void reset(); void style(const cell_type& style_cell); void line(int x1, int y1, int x2, int y2); int min_x() const { return m_min_x; } int min_y() const { return m_min_y; } int max_x() const { return m_max_x; } int max_y() const { return m_max_y; } void sort_cells(); unsigned total_cells() const { return m_num_cells; } unsigned scanline_num_cells(unsigned y) const { return m_sorted_y[y - m_min_y].num; } const cell_type* const* scanline_cells(unsigned y) const { return m_sorted_cells.data() + m_sorted_y[y - m_min_y].start; } bool sorted() const { return m_sorted; } private: rasterizer_cells_aa(const self_type&); const self_type& operator = (const self_type&); void set_curr_cell(int x, int y); void add_curr_cell(); void render_hline(int ey, int x1, int y1, int x2, int y2); void allocate_block(); private: unsigned m_num_blocks; unsigned m_max_blocks; unsigned m_curr_block; unsigned m_num_cells; cell_type** m_cells; cell_type* m_curr_cell_ptr; pod_vector m_sorted_cells; pod_vector m_sorted_y; cell_type m_curr_cell; cell_type m_style_cell; int m_min_x; int m_min_y; int m_max_x; int m_max_y; bool m_sorted; }; //------------------------------------------------------------------------ template rasterizer_cells_aa::~rasterizer_cells_aa() { if(m_num_blocks) { cell_type** ptr = m_cells + m_num_blocks - 1; while(m_num_blocks--) { pod_allocator::deallocate(*ptr, cell_block_size); ptr--; } pod_allocator::deallocate(m_cells, m_max_blocks); } } //------------------------------------------------------------------------ template rasterizer_cells_aa::rasterizer_cells_aa() : m_num_blocks(0), m_max_blocks(0), m_curr_block(0), m_num_cells(0), m_cells(0), m_curr_cell_ptr(0), m_sorted_cells(), m_sorted_y(), m_min_x(0x7FFFFFFF), m_min_y(0x7FFFFFFF), m_max_x(-0x7FFFFFFF), m_max_y(-0x7FFFFFFF), m_sorted(false) { m_style_cell.initial(); m_curr_cell.initial(); } //------------------------------------------------------------------------ template void rasterizer_cells_aa::reset() { m_num_cells = 0; m_curr_block = 0; m_curr_cell.initial(); m_style_cell.initial(); m_sorted = false; m_min_x = 0x7FFFFFFF; m_min_y = 0x7FFFFFFF; m_max_x = -0x7FFFFFFF; m_max_y = -0x7FFFFFFF; } //------------------------------------------------------------------------ template AGG_INLINE void rasterizer_cells_aa::add_curr_cell() { if(m_curr_cell.area | m_curr_cell.cover) { if((m_num_cells & cell_block_mask) == 0) { if(m_num_blocks >= cell_block_limit) return; allocate_block(); } *m_curr_cell_ptr++ = m_curr_cell; ++m_num_cells; } } //------------------------------------------------------------------------ template AGG_INLINE void rasterizer_cells_aa::set_curr_cell(int x, int y) { if(m_curr_cell.not_equal(x, y, m_style_cell)) { add_curr_cell(); m_curr_cell.style(m_style_cell); m_curr_cell.x = x; m_curr_cell.y = y; m_curr_cell.cover = 0; m_curr_cell.area = 0; } } //------------------------------------------------------------------------ template AGG_INLINE void rasterizer_cells_aa::render_hline(int ey, int x1, int y1, int x2, int y2) { int ex1 = x1 >> poly_subpixel_shift; int ex2 = x2 >> poly_subpixel_shift; int fx1 = x1 & poly_subpixel_mask; int fx2 = x2 & poly_subpixel_mask; int delta, p, first, dx; int incr, lift, mod, rem; //trivial case. Happens often if(y1 == y2) { set_curr_cell(ex2, ey); return; } //everything is located in a single cell. That is easy! if(ex1 == ex2) { delta = y2 - y1; m_curr_cell.cover += delta; m_curr_cell.area += (fx1 + fx2) * delta; return; } //ok, we'll have to render a run of adjacent cells on the same //hline... p = (poly_subpixel_scale - fx1) * (y2 - y1); first = poly_subpixel_scale; incr = 1; dx = x2 - x1; if(dx < 0) { p = fx1 * (y2 - y1); first = 0; incr = -1; dx = -dx; } delta = p / dx; mod = p % dx; if(mod < 0) { delta--; mod += dx; } m_curr_cell.cover += delta; m_curr_cell.area += (fx1 + first) * delta; ex1 += incr; set_curr_cell(ex1, ey); y1 += delta; if(ex1 != ex2) { p = poly_subpixel_scale * (y2 - y1 + delta); lift = p / dx; rem = p % dx; if (rem < 0) { lift--; rem += dx; } mod -= dx; while (ex1 != ex2) { delta = lift; mod += rem; if(mod >= 0) { mod -= dx; delta++; } m_curr_cell.cover += delta; m_curr_cell.area += poly_subpixel_scale * delta; y1 += delta; ex1 += incr; set_curr_cell(ex1, ey); } } delta = y2 - y1; m_curr_cell.cover += delta; m_curr_cell.area += (fx2 + poly_subpixel_scale - first) * delta; } //------------------------------------------------------------------------ template AGG_INLINE void rasterizer_cells_aa::style(const cell_type& style_cell) { m_style_cell.style(style_cell); } //------------------------------------------------------------------------ template void rasterizer_cells_aa::line(int x1, int y1, int x2, int y2) { enum dx_limit_e { dx_limit = 16384 << poly_subpixel_shift }; int dx = x2 - x1; if(dx >= dx_limit || dx <= -dx_limit) { int cx = (x1 + x2) >> 1; int cy = (y1 + y2) >> 1; line(x1, y1, cx, cy); line(cx, cy, x2, y2); } int dy = y2 - y1; int ex1 = x1 >> poly_subpixel_shift; int ex2 = x2 >> poly_subpixel_shift; int ey1 = y1 >> poly_subpixel_shift; int ey2 = y2 >> poly_subpixel_shift; int fy1 = y1 & poly_subpixel_mask; int fy2 = y2 & poly_subpixel_mask; int x_from, x_to; int p, rem, mod, lift, delta, first, incr; if(ex1 < m_min_x) m_min_x = ex1; if(ex1 > m_max_x) m_max_x = ex1; if(ey1 < m_min_y) m_min_y = ey1; if(ey1 > m_max_y) m_max_y = ey1; if(ex2 < m_min_x) m_min_x = ex2; if(ex2 > m_max_x) m_max_x = ex2; if(ey2 < m_min_y) m_min_y = ey2; if(ey2 > m_max_y) m_max_y = ey2; set_curr_cell(ex1, ey1); //everything is on a single hline if(ey1 == ey2) { render_hline(ey1, x1, fy1, x2, fy2); return; } //Vertical line - we have to calculate start and end cells, //and then - the common values of the area and coverage for //all cells of the line. We know exactly there's only one //cell, so, we don't have to call render_hline(). incr = 1; if(dx == 0) { int ex = x1 >> poly_subpixel_shift; int two_fx = (x1 - (ex << poly_subpixel_shift)) << 1; int area; first = poly_subpixel_scale; if(dy < 0) { first = 0; incr = -1; } x_from = x1; //render_hline(ey1, x_from, fy1, x_from, first); delta = first - fy1; m_curr_cell.cover += delta; m_curr_cell.area += two_fx * delta; ey1 += incr; set_curr_cell(ex, ey1); delta = first + first - poly_subpixel_scale; area = two_fx * delta; while(ey1 != ey2) { //render_hline(ey1, x_from, poly_subpixel_scale - first, x_from, first); m_curr_cell.cover = delta; m_curr_cell.area = area; ey1 += incr; set_curr_cell(ex, ey1); } //render_hline(ey1, x_from, poly_subpixel_scale - first, x_from, fy2); delta = fy2 - poly_subpixel_scale + first; m_curr_cell.cover += delta; m_curr_cell.area += two_fx * delta; return; } //ok, we have to render several hlines p = (poly_subpixel_scale - fy1) * dx; first = poly_subpixel_scale; if(dy < 0) { p = fy1 * dx; first = 0; incr = -1; dy = -dy; } delta = p / dy; mod = p % dy; if(mod < 0) { delta--; mod += dy; } x_from = x1 + delta; render_hline(ey1, x1, fy1, x_from, first); ey1 += incr; set_curr_cell(x_from >> poly_subpixel_shift, ey1); if(ey1 != ey2) { p = poly_subpixel_scale * dx; lift = p / dy; rem = p % dy; if(rem < 0) { lift--; rem += dy; } mod -= dy; while(ey1 != ey2) { delta = lift; mod += rem; if (mod >= 0) { mod -= dy; delta++; } x_to = x_from + delta; render_hline(ey1, x_from, poly_subpixel_scale - first, x_to, first); x_from = x_to; ey1 += incr; set_curr_cell(x_from >> poly_subpixel_shift, ey1); } } render_hline(ey1, x_from, poly_subpixel_scale - first, x2, fy2); } //------------------------------------------------------------------------ template void rasterizer_cells_aa::allocate_block() { if(m_curr_block >= m_num_blocks) { if(m_num_blocks >= m_max_blocks) { cell_type** new_cells = pod_allocator::allocate(m_max_blocks + cell_block_pool); if(m_cells) { memcpy(new_cells, m_cells, m_max_blocks * sizeof(cell_type*)); pod_allocator::deallocate(m_cells, m_max_blocks); } m_cells = new_cells; m_max_blocks += cell_block_pool; } m_cells[m_num_blocks++] = pod_allocator::allocate(cell_block_size); } m_curr_cell_ptr = m_cells[m_curr_block++]; } //------------------------------------------------------------------------ template static AGG_INLINE void swap_cells(T* a, T* b) { T temp = *a; *a = *b; *b = temp; } //------------------------------------------------------------------------ enum { qsort_threshold = 9 }; //------------------------------------------------------------------------ template void qsort_cells(Cell** start, unsigned num) { Cell** stack[80]; Cell*** top; Cell** limit; Cell** base; limit = start + num; base = start; top = stack; for (;;) { int len = int(limit - base); Cell** i; Cell** j; Cell** pivot; if(len > qsort_threshold) { // we use base + len/2 as the pivot pivot = base + len / 2; swap_cells(base, pivot); i = base + 1; j = limit - 1; // now ensure that *i <= *base <= *j if((*j)->x < (*i)->x) { swap_cells(i, j); } if((*base)->x < (*i)->x) { swap_cells(base, i); } if((*j)->x < (*base)->x) { swap_cells(base, j); } for(;;) { int x = (*base)->x; do i++; while( (*i)->x < x ); do j--; while( x < (*j)->x ); if(i > j) { break; } swap_cells(i, j); } swap_cells(base, j); // now, push the largest sub-array if(j - base > limit - i) { top[0] = base; top[1] = j; base = i; } else { top[0] = i; top[1] = limit; limit = j; } top += 2; } else { // the sub-array is small, perform insertion sort j = base; i = j + 1; for(; i < limit; j = i, i++) { for(; j[1]->x < (*j)->x; j--) { swap_cells(j + 1, j); if (j == base) { break; } } } if(top > stack) { top -= 2; base = top[0]; limit = top[1]; } else { break; } } } } //------------------------------------------------------------------------ template void rasterizer_cells_aa::sort_cells() { if(m_sorted) return; //Perform sort only the first time. add_curr_cell(); m_curr_cell.x = 0x7FFFFFFF; m_curr_cell.y = 0x7FFFFFFF; m_curr_cell.cover = 0; m_curr_cell.area = 0; if(m_num_cells == 0) return; // DBG: Check to see if min/max works well. //for(unsigned nc = 0; nc < m_num_cells; nc++) //{ // cell_type* cell = m_cells[nc >> cell_block_shift] + (nc & cell_block_mask); // if(cell->x < m_min_x || // cell->y < m_min_y || // cell->x > m_max_x || // cell->y > m_max_y) // { // cell = cell; // Breakpoint here // } //} // Allocate the array of cell pointers m_sorted_cells.allocate(m_num_cells, 16); // Allocate and zero the Y array m_sorted_y.allocate(m_max_y - m_min_y + 1, 16); m_sorted_y.zero(); // Create the Y-histogram (count the numbers of cells for each Y) cell_type** block_ptr = m_cells; cell_type* cell_ptr; unsigned nb = m_num_cells >> cell_block_shift; unsigned i; while(nb--) { cell_ptr = *block_ptr++; i = cell_block_size; while(i--) { m_sorted_y[cell_ptr->y - m_min_y].start++; ++cell_ptr; } } cell_ptr = *block_ptr++; i = m_num_cells & cell_block_mask; while(i--) { m_sorted_y[cell_ptr->y - m_min_y].start++; ++cell_ptr; } // Convert the Y-histogram into the array of starting indexes unsigned start = 0; for(i = 0; i < m_sorted_y.size(); i++) { unsigned v = m_sorted_y[i].start; m_sorted_y[i].start = start; start += v; } // Fill the cell pointer array sorted by Y block_ptr = m_cells; nb = m_num_cells >> cell_block_shift; while(nb--) { cell_ptr = *block_ptr++; i = cell_block_size; while(i--) { sorted_y& curr_y = m_sorted_y[cell_ptr->y - m_min_y]; m_sorted_cells[curr_y.start + curr_y.num] = cell_ptr; ++curr_y.num; ++cell_ptr; } } cell_ptr = *block_ptr++; i = m_num_cells & cell_block_mask; while(i--) { sorted_y& curr_y = m_sorted_y[cell_ptr->y - m_min_y]; m_sorted_cells[curr_y.start + curr_y.num] = cell_ptr; ++curr_y.num; ++cell_ptr; } // Finally arrange the X-arrays for(i = 0; i < m_sorted_y.size(); i++) { const sorted_y& curr_y = m_sorted_y[i]; if(curr_y.num) { qsort_cells(m_sorted_cells.data() + curr_y.start, curr_y.num); } } m_sorted = true; } //------------------------------------------------------scanline_hit_test class scanline_hit_test { public: scanline_hit_test(int x) : m_x(x), m_hit(false) {} void reset_spans() {} void finalize(int) {} void add_cell(int x, int) { if(m_x == x) m_hit = true; } void add_span(int x, int len, int) { if(m_x >= x && m_x < x+len) m_hit = true; } unsigned num_spans() const { return 1; } bool hit() const { return m_hit; } private: int m_x; bool m_hit; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_color_rgba.h0000644000175000017500000006204412516137326024102 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // // Adaptation for high precision colors has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_COLOR_RGBA_INCLUDED #define AGG_COLOR_RGBA_INCLUDED #include #include "agg_basics.h" namespace agg24 { // Supported byte orders for RGB and RGBA pixel formats //======================================================================= struct order_rgb { enum rgb_e { R=0, G=1, B=2, rgb_tag }; }; //----order_rgb struct order_bgr { enum bgr_e { B=0, G=1, R=2, rgb_tag }; }; //----order_bgr struct order_rgba { enum rgba_e { R=0, G=1, B=2, A=3, rgba_tag }; }; //----order_rgba struct order_argb { enum argb_e { A=0, R=1, G=2, B=3, rgba_tag }; }; //----order_argb struct order_abgr { enum abgr_e { A=0, B=1, G=2, R=3, rgba_tag }; }; //----order_abgr struct order_bgra { enum bgra_e { B=0, G=1, R=2, A=3, rgba_tag }; }; //----order_bgra //====================================================================rgba struct rgba { typedef double value_type; double r; double g; double b; double a; //-------------------------------------------------------------------- rgba() {} //-------------------------------------------------------------------- rgba(double r_, double g_, double b_, double a_=1.0) : r(r_), g(g_), b(b_), a(a_) {} //-------------------------------------------------------------------- rgba(const rgba& c, double a_) : r(c.r), g(c.g), b(c.b), a(a_) {} //-------------------------------------------------------------------- void clear() { r = g = b = a = 0; } //-------------------------------------------------------------------- const rgba& transparent() { a = 0.0; return *this; } //-------------------------------------------------------------------- const rgba& opacity(double a_) { if(a_ < 0.0) a_ = 0.0; if(a_ > 1.0) a_ = 1.0; a = a_; return *this; } //-------------------------------------------------------------------- double opacity() const { return a; } //-------------------------------------------------------------------- const rgba& premultiply() { r *= a; g *= a; b *= a; return *this; } //-------------------------------------------------------------------- const rgba& premultiply(double a_) { if(a <= 0.0 || a_ <= 0.0) { r = g = b = a = 0.0; return *this; } a_ /= a; r *= a_; g *= a_; b *= a_; a = a_; return *this; } //-------------------------------------------------------------------- const rgba& demultiply() { if(a == 0) { r = g = b = 0; return *this; } double a_ = 1.0 / a; r *= a_; g *= a_; b *= a_; return *this; } //-------------------------------------------------------------------- rgba gradient(rgba c, double k) const { rgba ret; ret.r = r + (c.r - r) * k; ret.g = g + (c.g - g) * k; ret.b = b + (c.b - b) * k; ret.a = a + (c.a - a) * k; return ret; } //-------------------------------------------------------------------- static rgba no_color() { return rgba(0,0,0,0); } //-------------------------------------------------------------------- static rgba from_wavelength(double wl, double gamma = 1.0); //-------------------------------------------------------------------- explicit rgba(double wavelen, double gamma=1.0) { *this = from_wavelength(wavelen, gamma); } }; //----------------------------------------------------------------rgba_pre inline rgba rgba_pre(double r, double g, double b, double a=1.0) { return rgba(r, g, b, a).premultiply(); } inline rgba rgba_pre(const rgba& c) { return rgba(c).premultiply(); } inline rgba rgba_pre(const rgba& c, double a) { return rgba(c, a).premultiply(); } //------------------------------------------------------------------------ inline rgba rgba::from_wavelength(double wl, double gamma) { rgba t(0.0, 0.0, 0.0); if(wl >= 380.0 && wl <= 440.0) { t.r = -1.0 * (wl - 440.0) / (440.0 - 380.0); t.b = 1.0; } else if(wl >= 440.0 && wl <= 490.0) { t.g = (wl - 440.0) / (490.0 - 440.0); t.b = 1.0; } else if(wl >= 490.0 && wl <= 510.0) { t.g = 1.0; t.b = -1.0 * (wl - 510.0) / (510.0 - 490.0); } else if(wl >= 510.0 && wl <= 580.0) { t.r = (wl - 510.0) / (580.0 - 510.0); t.g = 1.0; } else if(wl >= 580.0 && wl <= 645.0) { t.r = 1.0; t.g = -1.0 * (wl - 645.0) / (645.0 - 580.0); } else if(wl >= 645.0 && wl <= 780.0) { t.r = 1.0; } double s = 1.0; if(wl > 700.0) s = 0.3 + 0.7 * (780.0 - wl) / (780.0 - 700.0); else if(wl < 420.0) s = 0.3 + 0.7 * (wl - 380.0) / (420.0 - 380.0); t.r = pow(t.r * s, gamma); t.g = pow(t.g * s, gamma); t.b = pow(t.b * s, gamma); return t; } //===================================================================rgba8 struct rgba8 { typedef int8u value_type; typedef int32u calc_type; typedef int32 long_type; enum base_scale_e { base_shift = 8, base_scale = 1 << base_shift, base_mask = base_scale - 1 }; typedef rgba8 self_type; value_type r; value_type g; value_type b; value_type a; //-------------------------------------------------------------------- rgba8() {} //-------------------------------------------------------------------- rgba8(unsigned r_, unsigned g_, unsigned b_, unsigned a_=base_mask) : r(value_type(r_)), g(value_type(g_)), b(value_type(b_)), a(value_type(a_)) {} //-------------------------------------------------------------------- rgba8(const rgba& c, double a_) : r((value_type)uround(c.r * double(base_mask))), g((value_type)uround(c.g * double(base_mask))), b((value_type)uround(c.b * double(base_mask))), a((value_type)uround(a_ * double(base_mask))) {} //-------------------------------------------------------------------- rgba8(const self_type& c, unsigned a_) : r(c.r), g(c.g), b(c.b), a(value_type(a_)) {} //-------------------------------------------------------------------- rgba8(const rgba& c) : r((value_type)uround(c.r * double(base_mask))), g((value_type)uround(c.g * double(base_mask))), b((value_type)uround(c.b * double(base_mask))), a((value_type)uround(c.a * double(base_mask))) {} //-------------------------------------------------------------------- void clear() { r = g = b = a = 0; } //-------------------------------------------------------------------- const self_type& transparent() { a = 0; return *this; } //-------------------------------------------------------------------- const self_type& opacity(double a_) { if(a_ < 0.0) a_ = 0.0; if(a_ > 1.0) a_ = 1.0; a = (value_type)uround(a_ * double(base_mask)); return *this; } //-------------------------------------------------------------------- double opacity() const { return double(a) / double(base_mask); } //-------------------------------------------------------------------- AGG_INLINE const self_type& premultiply() { if(a == base_mask) return *this; if(a == 0) { r = g = b = 0; return *this; } r = value_type((calc_type(r) * a) >> base_shift); g = value_type((calc_type(g) * a) >> base_shift); b = value_type((calc_type(b) * a) >> base_shift); return *this; } //-------------------------------------------------------------------- AGG_INLINE const self_type& premultiply(unsigned a_) { if(a == base_mask && a_ >= base_mask) return *this; if(a == 0 || a_ == 0) { r = g = b = a = 0; return *this; } calc_type r_ = (calc_type(r) * a_) / a; calc_type g_ = (calc_type(g) * a_) / a; calc_type b_ = (calc_type(b) * a_) / a; r = value_type((r_ > a_) ? a_ : r_); g = value_type((g_ > a_) ? a_ : g_); b = value_type((b_ > a_) ? a_ : b_); a = value_type(a_); return *this; } //-------------------------------------------------------------------- AGG_INLINE const self_type& demultiply() { if(a == base_mask) return *this; if(a == 0) { r = g = b = 0; return *this; } calc_type r_ = (calc_type(r) * base_mask) / a; calc_type g_ = (calc_type(g) * base_mask) / a; calc_type b_ = (calc_type(b) * base_mask) / a; r = value_type((r_ > calc_type(base_mask)) ? calc_type(base_mask) : r_); g = value_type((g_ > calc_type(base_mask)) ? calc_type(base_mask) : g_); b = value_type((b_ > calc_type(base_mask)) ? calc_type(base_mask) : b_); return *this; } //-------------------------------------------------------------------- AGG_INLINE self_type gradient(const self_type& c, double k) const { self_type ret; calc_type ik = uround(k * base_scale); ret.r = value_type(calc_type(r) + (((calc_type(c.r) - r) * ik) >> base_shift)); ret.g = value_type(calc_type(g) + (((calc_type(c.g) - g) * ik) >> base_shift)); ret.b = value_type(calc_type(b) + (((calc_type(c.b) - b) * ik) >> base_shift)); ret.a = value_type(calc_type(a) + (((calc_type(c.a) - a) * ik) >> base_shift)); return ret; } //-------------------------------------------------------------------- AGG_INLINE void add(const self_type& c, unsigned cover) { calc_type cr, cg, cb, ca; if(cover == cover_mask) { if(c.a == base_mask) { *this = c; } else { cr = r + c.r; r = (cr > calc_type(base_mask)) ? calc_type(base_mask) : cr; cg = g + c.g; g = (cg > calc_type(base_mask)) ? calc_type(base_mask) : cg; cb = b + c.b; b = (cb > calc_type(base_mask)) ? calc_type(base_mask) : cb; ca = a + c.a; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca; } } else { cr = r + ((c.r * cover + cover_mask/2) >> cover_shift); cg = g + ((c.g * cover + cover_mask/2) >> cover_shift); cb = b + ((c.b * cover + cover_mask/2) >> cover_shift); ca = a + ((c.a * cover + cover_mask/2) >> cover_shift); r = (cr > calc_type(base_mask)) ? calc_type(base_mask) : cr; g = (cg > calc_type(base_mask)) ? calc_type(base_mask) : cg; b = (cb > calc_type(base_mask)) ? calc_type(base_mask) : cb; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca; } } //-------------------------------------------------------------------- template AGG_INLINE void apply_gamma_dir(const GammaLUT& gamma) { r = gamma.dir(r); g = gamma.dir(g); b = gamma.dir(b); } //-------------------------------------------------------------------- template AGG_INLINE void apply_gamma_inv(const GammaLUT& gamma) { r = gamma.inv(r); g = gamma.inv(g); b = gamma.inv(b); } //-------------------------------------------------------------------- static self_type no_color() { return self_type(0,0,0,0); } //-------------------------------------------------------------------- static self_type from_wavelength(double wl, double gamma = 1.0) { return self_type(rgba::from_wavelength(wl, gamma)); } }; //-------------------------------------------------------------rgba8_pre inline rgba8 rgba8_pre(unsigned r, unsigned g, unsigned b, unsigned a = rgba8::base_mask) { return rgba8(r,g,b,a).premultiply(); } inline rgba8 rgba8_pre(const rgba8& c) { return rgba8(c).premultiply(); } inline rgba8 rgba8_pre(const rgba8& c, unsigned a) { return rgba8(c,a).premultiply(); } inline rgba8 rgba8_pre(const rgba& c) { return rgba8(c).premultiply(); } inline rgba8 rgba8_pre(const rgba& c, double a) { return rgba8(c,a).premultiply(); } //-----------------------------------------------------------rgb8_packed inline rgba8 rgb8_packed(unsigned v) { return rgba8((v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF); } //-----------------------------------------------------------bgr8_packed inline rgba8 bgr8_packed(unsigned v) { return rgba8(v & 0xFF, (v >> 8) & 0xFF, (v >> 16) & 0xFF); } //----------------------------------------------------------argb8_packed inline rgba8 argb8_packed(unsigned v) { return rgba8((v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF, v >> 24); } //=================================================================rgba16 struct rgba16 { typedef int16u value_type; typedef int32u calc_type; typedef int64 long_type; enum base_scale_e { base_shift = 16, base_scale = 1 << base_shift, base_mask = base_scale - 1 }; typedef rgba16 self_type; value_type r; value_type g; value_type b; value_type a; //-------------------------------------------------------------------- rgba16() {} //-------------------------------------------------------------------- rgba16(unsigned r_, unsigned g_, unsigned b_, unsigned a_=base_mask) : r(value_type(r_)), g(value_type(g_)), b(value_type(b_)), a(value_type(a_)) {} //-------------------------------------------------------------------- rgba16(const self_type& c, unsigned a_) : r(c.r), g(c.g), b(c.b), a(value_type(a_)) {} //-------------------------------------------------------------------- rgba16(const rgba& c) : r((value_type)uround(c.r * double(base_mask))), g((value_type)uround(c.g * double(base_mask))), b((value_type)uround(c.b * double(base_mask))), a((value_type)uround(c.a * double(base_mask))) {} //-------------------------------------------------------------------- rgba16(const rgba& c, double a_) : r((value_type)uround(c.r * double(base_mask))), g((value_type)uround(c.g * double(base_mask))), b((value_type)uround(c.b * double(base_mask))), a((value_type)uround(a_ * double(base_mask))) {} //-------------------------------------------------------------------- rgba16(const rgba8& c) : r(value_type((value_type(c.r) << 8) | c.r)), g(value_type((value_type(c.g) << 8) | c.g)), b(value_type((value_type(c.b) << 8) | c.b)), a(value_type((value_type(c.a) << 8) | c.a)) {} //-------------------------------------------------------------------- rgba16(const rgba8& c, unsigned a_) : r(value_type((value_type(c.r) << 8) | c.r)), g(value_type((value_type(c.g) << 8) | c.g)), b(value_type((value_type(c.b) << 8) | c.b)), a(value_type(( a_ << 8) | c.a)) {} //-------------------------------------------------------------------- void clear() { r = g = b = a = 0; } //-------------------------------------------------------------------- const self_type& transparent() { a = 0; return *this; } //-------------------------------------------------------------------- AGG_INLINE const self_type& opacity(double a_) { if(a_ < 0.0) a_ = 0.0; if(a_ > 1.0) a_ = 1.0; a = (value_type)uround(a_ * double(base_mask)); return *this; } //-------------------------------------------------------------------- double opacity() const { return double(a) / double(base_mask); } //-------------------------------------------------------------------- AGG_INLINE const self_type& premultiply() { if(a == base_mask) return *this; if(a == 0) { r = g = b = 0; return *this; } r = value_type((calc_type(r) * a) >> base_shift); g = value_type((calc_type(g) * a) >> base_shift); b = value_type((calc_type(b) * a) >> base_shift); return *this; } //-------------------------------------------------------------------- AGG_INLINE const self_type& premultiply(unsigned a_) { if(a == base_mask && a_ >= base_mask) return *this; if(a == 0 || a_ == 0) { r = g = b = a = 0; return *this; } calc_type r_ = (calc_type(r) * a_) / a; calc_type g_ = (calc_type(g) * a_) / a; calc_type b_ = (calc_type(b) * a_) / a; r = value_type((r_ > a_) ? a_ : r_); g = value_type((g_ > a_) ? a_ : g_); b = value_type((b_ > a_) ? a_ : b_); a = value_type(a_); return *this; } //-------------------------------------------------------------------- AGG_INLINE const self_type& demultiply() { if(a == base_mask) return *this; if(a == 0) { r = g = b = 0; return *this; } calc_type r_ = (calc_type(r) * base_mask) / a; calc_type g_ = (calc_type(g) * base_mask) / a; calc_type b_ = (calc_type(b) * base_mask) / a; r = value_type((r_ > calc_type(base_mask)) ? calc_type(base_mask) : r_); g = value_type((g_ > calc_type(base_mask)) ? calc_type(base_mask) : g_); b = value_type((b_ > calc_type(base_mask)) ? calc_type(base_mask) : b_); return *this; } //-------------------------------------------------------------------- AGG_INLINE self_type gradient(const self_type& c, double k) const { self_type ret; calc_type ik = uround(k * base_scale); ret.r = value_type(calc_type(r) + (((calc_type(c.r) - r) * ik) >> base_shift)); ret.g = value_type(calc_type(g) + (((calc_type(c.g) - g) * ik) >> base_shift)); ret.b = value_type(calc_type(b) + (((calc_type(c.b) - b) * ik) >> base_shift)); ret.a = value_type(calc_type(a) + (((calc_type(c.a) - a) * ik) >> base_shift)); return ret; } //-------------------------------------------------------------------- AGG_INLINE void add(const self_type& c, unsigned cover) { calc_type cr, cg, cb, ca; if(cover == cover_mask) { if(c.a == base_mask) { *this = c; } else { cr = r + c.r; r = (cr > calc_type(base_mask)) ? calc_type(base_mask) : cr; cg = g + c.g; g = (cg > calc_type(base_mask)) ? calc_type(base_mask) : cg; cb = b + c.b; b = (cb > calc_type(base_mask)) ? calc_type(base_mask) : cb; ca = a + c.a; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca; } } else { cr = r + ((c.r * cover + cover_mask) >> cover_shift); cg = g + ((c.g * cover + cover_mask) >> cover_shift); cb = b + ((c.b * cover + cover_mask) >> cover_shift); ca = a + ((c.a * cover + cover_mask) >> cover_shift); r = (cr > calc_type(base_mask)) ? calc_type(base_mask) : cr; g = (cg > calc_type(base_mask)) ? calc_type(base_mask) : cg; b = (cb > calc_type(base_mask)) ? calc_type(base_mask) : cb; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca; } } //-------------------------------------------------------------------- template AGG_INLINE void apply_gamma_dir(const GammaLUT& gamma) { r = gamma.dir(r); g = gamma.dir(g); b = gamma.dir(b); } //-------------------------------------------------------------------- template AGG_INLINE void apply_gamma_inv(const GammaLUT& gamma) { r = gamma.inv(r); g = gamma.inv(g); b = gamma.inv(b); } //-------------------------------------------------------------------- static self_type no_color() { return self_type(0,0,0,0); } //-------------------------------------------------------------------- static self_type from_wavelength(double wl, double gamma = 1.0) { return self_type(rgba::from_wavelength(wl, gamma)); } }; //--------------------------------------------------------------rgba16_pre inline rgba16 rgba16_pre(unsigned r, unsigned g, unsigned b, unsigned a = rgba16::base_mask) { return rgba16(r,g,b,a).premultiply(); } inline rgba16 rgba16_pre(const rgba16& c, unsigned a) { return rgba16(c,a).premultiply(); } inline rgba16 rgba16_pre(const rgba& c) { return rgba16(c).premultiply(); } inline rgba16 rgba16_pre(const rgba& c, double a) { return rgba16(c,a).premultiply(); } inline rgba16 rgba16_pre(const rgba8& c) { return rgba16(c).premultiply(); } inline rgba16 rgba16_pre(const rgba8& c, unsigned a) { return rgba16(c,a).premultiply(); } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_unclose_polygon.h0000644000175000017500000000333112516137326026227 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_CONV_UNCLOSE_POLYGON_INCLUDED #define AGG_CONV_UNCLOSE_POLYGON_INCLUDED #include "agg_basics.h" namespace agg24 { //====================================================conv_unclose_polygon template class conv_unclose_polygon { public: conv_unclose_polygon(VertexSource& vs) : m_source(&vs) {} void attach(VertexSource& source) { m_source = &source; } void rewind(unsigned path_id) { m_source->rewind(path_id); } unsigned vertex(double* x, double* y) { unsigned cmd = m_source->vertex(x, y); if(is_end_poly(cmd)) cmd &= ~path_flags_close; return cmd; } private: conv_unclose_polygon(const conv_unclose_polygon&); const conv_unclose_polygon& operator = (const conv_unclose_polygon&); VertexSource* m_source; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_vcgen_stroke.h0000644000175000017500000000714412516137326024462 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_VCGEN_STROKE_INCLUDED #define AGG_VCGEN_STROKE_INCLUDED #include "agg_math_stroke.h" namespace agg24 { //============================================================vcgen_stroke // // See Implementation agg_vcgen_stroke.cpp // Stroke generator // //------------------------------------------------------------------------ class vcgen_stroke { enum status_e { initial, ready, cap1, cap2, outline1, close_first, outline2, out_vertices, end_poly1, end_poly2, stop }; public: typedef vertex_sequence vertex_storage; typedef pod_bvector coord_storage; vcgen_stroke(); void line_cap(line_cap_e lc) { m_stroker.line_cap(lc); } void line_join(line_join_e lj) { m_stroker.line_join(lj); } void inner_join(inner_join_e ij) { m_stroker.inner_join(ij); } line_cap_e line_cap() const { return m_stroker.line_cap(); } line_join_e line_join() const { return m_stroker.line_join(); } inner_join_e inner_join() const { return m_stroker.inner_join(); } void width(double w) { m_stroker.width(w); } void miter_limit(double ml) { m_stroker.miter_limit(ml); } void miter_limit_theta(double t) { m_stroker.miter_limit_theta(t); } void inner_miter_limit(double ml) { m_stroker.inner_miter_limit(ml); } void approximation_scale(double as) { m_stroker.approximation_scale(as); } double width() const { return m_stroker.width(); } double miter_limit() const { return m_stroker.miter_limit(); } double inner_miter_limit() const { return m_stroker.inner_miter_limit(); } double approximation_scale() const { return m_stroker.approximation_scale(); } void shorten(double s) { m_shorten = s; } double shorten() const { return m_shorten; } // Vertex Generator Interface void remove_all(); void add_vertex(double x, double y, unsigned cmd); // Vertex Source Interface void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: vcgen_stroke(const vcgen_stroke&); const vcgen_stroke& operator = (const vcgen_stroke&); math_stroke m_stroker; vertex_storage m_src_vertices; coord_storage m_out_vertices; double m_shorten; unsigned m_closed; status_e m_status; status_e m_prev_status; unsigned m_src_vertex; unsigned m_out_vertex; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_pixfmt_gray.h0000644000175000017500000004603612516137326024325 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for high precision colors has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_PIXFMT_GRAY_INCLUDED #define AGG_PIXFMT_GRAY_INCLUDED #include #include "agg_basics.h" #include "agg_color_gray.h" #include "agg_rendering_buffer.h" namespace agg24 { //============================================================blender_gray template struct blender_gray { typedef ColorT color_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift }; static AGG_INLINE void blend_pix(value_type* p, unsigned cv, unsigned alpha, unsigned cover=0) { *p = (value_type)((((cv - calc_type(*p)) * alpha) + (calc_type(*p) << base_shift)) >> base_shift); } }; //======================================================blender_gray_pre template struct blender_gray_pre { typedef ColorT color_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift }; static AGG_INLINE void blend_pix(value_type* p, unsigned cv, unsigned alpha, unsigned cover) { alpha = color_type::base_mask - alpha; cover = (cover + 1) << (base_shift - 8); *p = (value_type)((*p * alpha + cv * cover) >> base_shift); } static AGG_INLINE void blend_pix(value_type* p, unsigned cv, unsigned alpha) { *p = (value_type)(((*p * (color_type::base_mask - alpha)) >> base_shift) + cv); } }; //=====================================================apply_gamma_dir_gray template class apply_gamma_dir_gray { public: typedef typename ColorT::value_type value_type; apply_gamma_dir_gray(const GammaLut& gamma) : m_gamma(gamma) {} AGG_INLINE void operator () (value_type* p) { *p = m_gamma.dir(*p); } private: const GammaLut& m_gamma; }; //=====================================================apply_gamma_inv_gray template class apply_gamma_inv_gray { public: typedef typename ColorT::value_type value_type; apply_gamma_inv_gray(const GammaLut& gamma) : m_gamma(gamma) {} AGG_INLINE void operator () (value_type* p) { *p = m_gamma.inv(*p); } private: const GammaLut& m_gamma; }; //=================================================pixfmt_alpha_blend_gray template class pixfmt_alpha_blend_gray { public: typedef RenBuf rbuf_type; typedef typename rbuf_type::row_data row_data; typedef Blender blender_type; typedef typename blender_type::color_type color_type; typedef int order_type; // A fake one typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_scale = color_type::base_scale, base_mask = color_type::base_mask, pix_width = sizeof(value_type) }; private: //-------------------------------------------------------------------- static AGG_INLINE void copy_or_blend_pix(value_type* p, const color_type& c, unsigned cover) { if (c.a) { calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; if(alpha == base_mask) { *p = c.v; } else { Blender::blend_pix(p, c.v, alpha, cover); } } } static AGG_INLINE void copy_or_blend_pix(value_type* p, const color_type& c) { if (c.a) { if(c.a == base_mask) { *p = c.v; } else { Blender::blend_pix(p, c.v, c.a); } } } public: //-------------------------------------------------------------------- pixfmt_alpha_blend_gray(rbuf_type& rb) : m_rbuf(&rb) {} void attach(rbuf_type& rb) { m_rbuf = &rb; } //-------------------------------------------------------------------- AGG_INLINE unsigned width() const { return m_rbuf->width(); } AGG_INLINE unsigned height() const { return m_rbuf->height(); } //-------------------------------------------------------------------- const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); } //-------------------------------------------------------------------- const int8u* pix_ptr(int x, int y) const { return m_rbuf->row_ptr(y) + x * pix_width; } //-------------------------------------------------------------------- row_data row(int y) const { return m_rbuf->row(y); } //-------------------------------------------------------------------- AGG_INLINE static void make_pix(int8u* p, const color_type& c) { *(value_type*)p = c.v; } //-------------------------------------------------------------------- AGG_INLINE color_type pixel(int x, int y) const { value_type* p = (value_type*)m_rbuf->row(y) + x * Step + Offset; return color_type(*p); } //-------------------------------------------------------------------- AGG_INLINE void copy_pixel(int x, int y, const color_type& c) { *((value_type*)m_rbuf->row_ptr(x, y, 1) + x * Step + Offset) = c.v; } //-------------------------------------------------------------------- AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover) { copy_or_blend_pix((value_type*) m_rbuf->row_ptr(x, y, 1) + x * Step + Offset, c, cover); } //-------------------------------------------------------------------- AGG_INLINE void copy_hline(int x, int y, unsigned len, const color_type& c) { value_type* p = (value_type*) m_rbuf->row_ptr(x, y, len) + x * Step + Offset; do { *p = c.v; p += Step; } while(--len); } //-------------------------------------------------------------------- AGG_INLINE void copy_vline(int x, int y, unsigned len, const color_type& c) { do { value_type* p = (value_type*) m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset; *p = c.v; } while(--len); } //-------------------------------------------------------------------- void blend_hline(int x, int y, unsigned len, const color_type& c, int8u cover) { if (c.a) { value_type* p = (value_type*) m_rbuf->row_ptr(x, y, len) + x * Step + Offset; calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; if(alpha == base_mask) { do { *p = c.v; p += Step; } while(--len); } else { do { Blender::blend_pix(p, c.v, alpha, cover); p += Step; } while(--len); } } } //-------------------------------------------------------------------- void blend_vline(int x, int y, unsigned len, const color_type& c, int8u cover) { if (c.a) { value_type* p; calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; if(alpha == base_mask) { do { p = (value_type*) m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset; *p = c.v; } while(--len); } else { do { p = (value_type*) m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset; Blender::blend_pix(p, c.v, alpha, cover); } while(--len); } } } //-------------------------------------------------------------------- void blend_solid_hspan(int x, int y, unsigned len, const color_type& c, const int8u* covers) { if (c.a) { value_type* p = (value_type*) m_rbuf->row_ptr(x, y, len) + x * Step + Offset; do { calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8; if(alpha == base_mask) { *p = c.v; } else { Blender::blend_pix(p, c.v, alpha, *covers); } p += Step; ++covers; } while(--len); } } //-------------------------------------------------------------------- void blend_solid_vspan(int x, int y, unsigned len, const color_type& c, const int8u* covers) { if (c.a) { do { calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8; value_type* p = (value_type*) m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset; if(alpha == base_mask) { *p = c.v; } else { Blender::blend_pix(p, c.v, alpha, *covers); } ++covers; } while(--len); } } //-------------------------------------------------------------------- void copy_color_hspan(int x, int y, unsigned len, const color_type* colors) { value_type* p = (value_type*) m_rbuf->row_ptr(x, y, len) + x * Step + Offset; do { *p++ = colors->v; ++colors; } while(--len); } //-------------------------------------------------------------------- void blend_color_hspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover) { value_type* p = (value_type*) m_rbuf->row_ptr(x, y, len) + x * Step + Offset; if(covers) { do { copy_or_blend_pix(p, *colors++, *covers++); p += Step; } while(--len); } else { if(cover == 255) { do { if(colors->a == base_mask) { *p = colors->v; } else { copy_or_blend_pix(p, *colors); } p += Step; ++colors; } while(--len); } else { do { copy_or_blend_pix(p, *colors++, cover); p += Step; } while(--len); } } } //-------------------------------------------------------------------- void blend_color_vspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover) { value_type* p; if(covers) { do { p = (value_type*) m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset; copy_or_blend_pix(p, *colors++, *covers++); } while(--len); } else { if(cover == 255) { do { p = (value_type*) m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset; if(colors->a == base_mask) { *p = colors->v; } else { copy_or_blend_pix(p, *colors); } ++colors; } while(--len); } else { do { p = (value_type*) m_rbuf->row_ptr(x, y++, 1) + x * Step + Offset; copy_or_blend_pix(p, *colors++, cover); } while(--len); } } } //-------------------------------------------------------------------- template void for_each_pixel(Function f) { unsigned y; for(y = 0; y < height(); ++y) { row_data r = m_rbuf->row(y); if(r.ptr) { unsigned len = r.x2 - r.x1 + 1; value_type* p = (value_type*) m_rbuf->row_ptr(r.x1, y, len) + r.x1 * Step + Offset; do { f(p); p += Step; } while(--len); } } } //-------------------------------------------------------------------- template void apply_gamma_dir(const GammaLut& g) { for_each_pixel(apply_gamma_dir_gray(g)); } //-------------------------------------------------------------------- template void apply_gamma_inv(const GammaLut& g) { for_each_pixel(apply_gamma_inv_gray(g)); } //-------------------------------------------------------------------- template void copy_from(const RenBuf2& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len) { const int8u* p = from.row_ptr(ysrc); if(p) { memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, p + xsrc * pix_width, len * pix_width); } } private: rbuf_type* m_rbuf; }; typedef blender_gray blender_gray8; typedef blender_gray_pre blender_gray8_pre; typedef blender_gray blender_gray16; typedef blender_gray_pre blender_gray16_pre; typedef pixfmt_alpha_blend_gray pixfmt_gray8; //----pixfmt_gray8 typedef pixfmt_alpha_blend_gray pixfmt_gray8_pre; //----pixfmt_gray8_pre typedef pixfmt_alpha_blend_gray pixfmt_gray16; //----pixfmt_gray16 typedef pixfmt_alpha_blend_gray pixfmt_gray16_pre; //----pixfmt_gray16_pre } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_renderer_outline_image.h0000644000175000017500000010641512516137326026501 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_RENDERER_OUTLINE_IMAGE_INCLUDED #define AGG_RENDERER_OUTLINE_IMAGE_INCLUDED #include "agg_array.h" #include "agg_math.h" #include "agg_line_aa_basics.h" #include "agg_dda_line.h" #include "agg_rendering_buffer.h" #include "agg_clip_liang_barsky.h" namespace agg24 { //========================================================line_image_scale template class line_image_scale { public: typedef typename Source::color_type color_type; line_image_scale(const Source& src, double height) : m_source(src), m_height(height), m_scale(src.height() / height) { } double width() const { return m_source.width(); } double height() const { return m_height; } color_type pixel(int x, int y) const { double src_y = (y + 0.5) * m_scale - 0.5; int h = m_source.height() - 1; int y1 = ufloor(src_y); int y2 = y1 + 1; color_type pix1 = (y1 < 0) ? color_type::no_color() : m_source.pixel(x, y1); color_type pix2 = (y2 > h) ? color_type::no_color() : m_source.pixel(x, y2); return pix1.gradient(pix2, src_y - y1); } private: line_image_scale(const line_image_scale&); const line_image_scale& operator = (const line_image_scale&); const Source& m_source; double m_height; double m_scale; }; //======================================================line_image_pattern template class line_image_pattern { public: typedef Filter filter_type; typedef typename filter_type::color_type color_type; //-------------------------------------------------------------------- line_image_pattern(const Filter& filter) : m_filter(&filter), m_dilation(filter.dilation() + 1), m_dilation_hr(m_dilation << line_subpixel_shift), m_data(), m_width(0), m_height(0), m_width_hr(0), m_half_height_hr(0), m_offset_y_hr(0) { } // Create //-------------------------------------------------------------------- template line_image_pattern(const Filter& filter, const Source& src) : m_filter(&filter), m_dilation(filter.dilation() + 1), m_dilation_hr(m_dilation << line_subpixel_shift), m_data(), m_width(0), m_height(0), m_width_hr(0), m_half_height_hr(0), m_offset_y_hr(0) { create(src); } // Create //-------------------------------------------------------------------- template void create(const Source& src) { m_height = uceil(src.height()); m_width = uceil(src.width()); m_width_hr = uround(src.width() * line_subpixel_scale); m_half_height_hr = uround(src.height() * line_subpixel_scale/2); m_offset_y_hr = m_dilation_hr + m_half_height_hr - line_subpixel_scale/2; m_half_height_hr += line_subpixel_scale/2; m_data.resize((m_width + m_dilation * 2) * (m_height + m_dilation * 2)); m_buf.attach(&m_data[0], m_width + m_dilation * 2, m_height + m_dilation * 2, m_width + m_dilation * 2); unsigned x, y; color_type* d1; color_type* d2; for(y = 0; y < m_height; y++) { d1 = m_buf.row_ptr(y + m_dilation) + m_dilation; for(x = 0; x < m_width; x++) { *d1++ = src.pixel(x, y); } } const color_type* s1; const color_type* s2; for(y = 0; y < m_dilation; y++) { //s1 = m_buf.row_ptr(m_height + m_dilation - 1) + m_dilation; //s2 = m_buf.row_ptr(m_dilation) + m_dilation; d1 = m_buf.row_ptr(m_dilation + m_height + y) + m_dilation; d2 = m_buf.row_ptr(m_dilation - y - 1) + m_dilation; for(x = 0; x < m_width; x++) { //*d1++ = color_type(*s1++, 0); //*d2++ = color_type(*s2++, 0); *d1++ = color_type::no_color(); *d2++ = color_type::no_color(); } } unsigned h = m_height + m_dilation * 2; for(y = 0; y < h; y++) { s1 = m_buf.row_ptr(y) + m_dilation; s2 = m_buf.row_ptr(y) + m_dilation + m_width; d1 = m_buf.row_ptr(y) + m_dilation + m_width; d2 = m_buf.row_ptr(y) + m_dilation; for(x = 0; x < m_dilation; x++) { *d1++ = *s1++; *--d2 = *--s2; } } } //-------------------------------------------------------------------- int pattern_width() const { return m_width_hr; } int line_width() const { return m_half_height_hr; } double width() const { return m_height; } //-------------------------------------------------------------------- void pixel(color_type* p, int x, int y) const { m_filter->pixel_high_res(m_buf.rows(), p, x % m_width_hr + m_dilation_hr, y + m_offset_y_hr); } //-------------------------------------------------------------------- const filter_type& filter() const { return *m_filter; } private: line_image_pattern(const line_image_pattern&); const line_image_pattern& operator = (const line_image_pattern&); protected: row_ptr_cache m_buf; const filter_type* m_filter; unsigned m_dilation; int m_dilation_hr; pod_array m_data; unsigned m_width; unsigned m_height; int m_width_hr; int m_half_height_hr; int m_offset_y_hr; }; //=================================================line_image_pattern_pow2 template class line_image_pattern_pow2 : public line_image_pattern { public: typedef Filter filter_type; typedef typename filter_type::color_type color_type; typedef line_image_pattern base_type; //-------------------------------------------------------------------- line_image_pattern_pow2(const Filter& filter) : line_image_pattern(filter), m_mask(line_subpixel_mask) {} //-------------------------------------------------------------------- template line_image_pattern_pow2(const Filter& filter, const Source& src) : line_image_pattern(filter), m_mask(line_subpixel_mask) { create(src); } //-------------------------------------------------------------------- template void create(const Source& src) { line_image_pattern::create(src); m_mask = 1; while(m_mask < base_type::m_width) { m_mask <<= 1; m_mask |= 1; } m_mask <<= line_subpixel_shift - 1; m_mask |= line_subpixel_mask; base_type::m_width_hr = m_mask + 1; } //-------------------------------------------------------------------- void pixel(color_type* p, int x, int y) const { base_type::m_filter->pixel_high_res( base_type::m_buf.rows(), p, (x & m_mask) + base_type::m_dilation_hr, y + base_type::m_offset_y_hr); } private: unsigned m_mask; }; //===================================================distance_interpolator4 class distance_interpolator4 { public: //--------------------------------------------------------------------- distance_interpolator4() {} distance_interpolator4(int x1, int y1, int x2, int y2, int sx, int sy, int ex, int ey, int len, double scale, int x, int y) : m_dx(x2 - x1), m_dy(y2 - y1), m_dx_start(line_mr(sx) - line_mr(x1)), m_dy_start(line_mr(sy) - line_mr(y1)), m_dx_end(line_mr(ex) - line_mr(x2)), m_dy_end(line_mr(ey) - line_mr(y2)), m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - double(y + line_subpixel_scale/2 - y2) * double(m_dx))), m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start - (line_mr(y + line_subpixel_scale/2) - line_mr(sy)) * m_dx_start), m_dist_end((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_end - (line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_end), m_len(uround(len / scale)) { double d = len * scale; int dx = iround(((x2 - x1) << line_subpixel_shift) / d); int dy = iround(((y2 - y1) << line_subpixel_shift) / d); m_dx_pict = -dy; m_dy_pict = dx; m_dist_pict = ((x + line_subpixel_scale/2 - (x1 - dy)) * m_dy_pict - (y + line_subpixel_scale/2 - (y1 + dx)) * m_dx_pict) >> line_subpixel_shift; m_dx <<= line_subpixel_shift; m_dy <<= line_subpixel_shift; m_dx_start <<= line_mr_subpixel_shift; m_dy_start <<= line_mr_subpixel_shift; m_dx_end <<= line_mr_subpixel_shift; m_dy_end <<= line_mr_subpixel_shift; } //--------------------------------------------------------------------- void inc_x() { m_dist += m_dy; m_dist_start += m_dy_start; m_dist_pict += m_dy_pict; m_dist_end += m_dy_end; } //--------------------------------------------------------------------- void dec_x() { m_dist -= m_dy; m_dist_start -= m_dy_start; m_dist_pict -= m_dy_pict; m_dist_end -= m_dy_end; } //--------------------------------------------------------------------- void inc_y() { m_dist -= m_dx; m_dist_start -= m_dx_start; m_dist_pict -= m_dx_pict; m_dist_end -= m_dx_end; } //--------------------------------------------------------------------- void dec_y() { m_dist += m_dx; m_dist_start += m_dx_start; m_dist_pict += m_dx_pict; m_dist_end += m_dx_end; } //--------------------------------------------------------------------- void inc_x(int dy) { m_dist += m_dy; m_dist_start += m_dy_start; m_dist_pict += m_dy_pict; m_dist_end += m_dy_end; if(dy > 0) { m_dist -= m_dx; m_dist_start -= m_dx_start; m_dist_pict -= m_dx_pict; m_dist_end -= m_dx_end; } if(dy < 0) { m_dist += m_dx; m_dist_start += m_dx_start; m_dist_pict += m_dx_pict; m_dist_end += m_dx_end; } } //--------------------------------------------------------------------- void dec_x(int dy) { m_dist -= m_dy; m_dist_start -= m_dy_start; m_dist_pict -= m_dy_pict; m_dist_end -= m_dy_end; if(dy > 0) { m_dist -= m_dx; m_dist_start -= m_dx_start; m_dist_pict -= m_dx_pict; m_dist_end -= m_dx_end; } if(dy < 0) { m_dist += m_dx; m_dist_start += m_dx_start; m_dist_pict += m_dx_pict; m_dist_end += m_dx_end; } } //--------------------------------------------------------------------- void inc_y(int dx) { m_dist -= m_dx; m_dist_start -= m_dx_start; m_dist_pict -= m_dx_pict; m_dist_end -= m_dx_end; if(dx > 0) { m_dist += m_dy; m_dist_start += m_dy_start; m_dist_pict += m_dy_pict; m_dist_end += m_dy_end; } if(dx < 0) { m_dist -= m_dy; m_dist_start -= m_dy_start; m_dist_pict -= m_dy_pict; m_dist_end -= m_dy_end; } } //--------------------------------------------------------------------- void dec_y(int dx) { m_dist += m_dx; m_dist_start += m_dx_start; m_dist_pict += m_dx_pict; m_dist_end += m_dx_end; if(dx > 0) { m_dist += m_dy; m_dist_start += m_dy_start; m_dist_pict += m_dy_pict; m_dist_end += m_dy_end; } if(dx < 0) { m_dist -= m_dy; m_dist_start -= m_dy_start; m_dist_pict -= m_dy_pict; m_dist_end -= m_dy_end; } } //--------------------------------------------------------------------- int dist() const { return m_dist; } int dist_start() const { return m_dist_start; } int dist_pict() const { return m_dist_pict; } int dist_end() const { return m_dist_end; } //--------------------------------------------------------------------- int dx() const { return m_dx; } int dy() const { return m_dy; } int dx_start() const { return m_dx_start; } int dy_start() const { return m_dy_start; } int dx_pict() const { return m_dx_pict; } int dy_pict() const { return m_dy_pict; } int dx_end() const { return m_dx_end; } int dy_end() const { return m_dy_end; } int len() const { return m_len; } private: //--------------------------------------------------------------------- int m_dx; int m_dy; int m_dx_start; int m_dy_start; int m_dx_pict; int m_dy_pict; int m_dx_end; int m_dy_end; int m_dist; int m_dist_start; int m_dist_pict; int m_dist_end; int m_len; }; //==================================================line_interpolator_image template class line_interpolator_image { public: typedef Renderer renderer_type; typedef typename Renderer::color_type color_type; //--------------------------------------------------------------------- enum max_half_width_e { max_half_width = 64 }; //--------------------------------------------------------------------- line_interpolator_image(renderer_type& ren, const line_parameters& lp, int sx, int sy, int ex, int ey, int pattern_start, double scale_x) : m_lp(lp), m_li(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) : line_dbl_hr(lp.y2 - lp.y1), lp.vertical ? abs(lp.y2 - lp.y1) : abs(lp.x2 - lp.x1) + 1), m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey, lp.len, scale_x, lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask), m_ren(ren), m_x(lp.x1 >> line_subpixel_shift), m_y(lp.y1 >> line_subpixel_shift), m_old_x(m_x), m_old_y(m_y), m_count((lp.vertical ? abs((lp.y2 >> line_subpixel_shift) - m_y) : abs((lp.x2 >> line_subpixel_shift) - m_x))), m_width(ren.subpixel_width()), //m_max_extent(m_width >> (line_subpixel_shift - 2)), m_max_extent((m_width + line_subpixel_scale) >> line_subpixel_shift), m_start(pattern_start + (m_max_extent + 2) * ren.pattern_width()), m_step(0) { agg24::dda2_line_interpolator li(0, lp.vertical ? (lp.dy << agg24::line_subpixel_shift) : (lp.dx << agg24::line_subpixel_shift), lp.len); unsigned i; int stop = m_width + line_subpixel_scale * 2; for(i = 0; i < max_half_width; ++i) { m_dist_pos[i] = li.y(); if(m_dist_pos[i] >= stop) break; ++li; } m_dist_pos[i] = 0x7FFF0000; int dist1_start; int dist2_start; int npix = 1; if(lp.vertical) { do { --m_li; m_y -= lp.inc; m_x = (m_lp.x1 + m_li.y()) >> line_subpixel_shift; if(lp.inc > 0) m_di.dec_y(m_x - m_old_x); else m_di.inc_y(m_x - m_old_x); m_old_x = m_x; dist1_start = dist2_start = m_di.dist_start(); int dx = 0; if(dist1_start < 0) ++npix; do { dist1_start += m_di.dy_start(); dist2_start -= m_di.dy_start(); if(dist1_start < 0) ++npix; if(dist2_start < 0) ++npix; ++dx; } while(m_dist_pos[dx] <= m_width); if(npix == 0) break; npix = 0; } while(--m_step >= -m_max_extent); } else { do { --m_li; m_x -= lp.inc; m_y = (m_lp.y1 + m_li.y()) >> line_subpixel_shift; if(lp.inc > 0) m_di.dec_x(m_y - m_old_y); else m_di.inc_x(m_y - m_old_y); m_old_y = m_y; dist1_start = dist2_start = m_di.dist_start(); int dy = 0; if(dist1_start < 0) ++npix; do { dist1_start -= m_di.dx_start(); dist2_start += m_di.dx_start(); if(dist1_start < 0) ++npix; if(dist2_start < 0) ++npix; ++dy; } while(m_dist_pos[dy] <= m_width); if(npix == 0) break; npix = 0; } while(--m_step >= -m_max_extent); } m_li.adjust_forward(); m_step -= m_max_extent; } //--------------------------------------------------------------------- bool step_hor() { ++m_li; m_x += m_lp.inc; m_y = (m_lp.y1 + m_li.y()) >> line_subpixel_shift; if(m_lp.inc > 0) m_di.inc_x(m_y - m_old_y); else m_di.dec_x(m_y - m_old_y); m_old_y = m_y; int s1 = m_di.dist() / m_lp.len; int s2 = -s1; if(m_lp.inc < 0) s1 = -s1; int dist_start; int dist_pict; int dist_end; int dy; int dist; dist_start = m_di.dist_start(); dist_pict = m_di.dist_pict() + m_start; dist_end = m_di.dist_end(); color_type* p0 = m_colors + max_half_width + 2; color_type* p1 = p0; int npix = 0; p1->clear(); if(dist_end > 0) { if(dist_start <= 0) { m_ren.pixel(p1, dist_pict, s2); } ++npix; } ++p1; dy = 1; while((dist = m_dist_pos[dy]) - s1 <= m_width) { dist_start -= m_di.dx_start(); dist_pict -= m_di.dx_pict(); dist_end -= m_di.dx_end(); p1->clear(); if(dist_end > 0 && dist_start <= 0) { if(m_lp.inc > 0) dist = -dist; m_ren.pixel(p1, dist_pict, s2 - dist); ++npix; } ++p1; ++dy; } dy = 1; dist_start = m_di.dist_start(); dist_pict = m_di.dist_pict() + m_start; dist_end = m_di.dist_end(); while((dist = m_dist_pos[dy]) + s1 <= m_width) { dist_start += m_di.dx_start(); dist_pict += m_di.dx_pict(); dist_end += m_di.dx_end(); --p0; p0->clear(); if(dist_end > 0 && dist_start <= 0) { if(m_lp.inc > 0) dist = -dist; m_ren.pixel(p0, dist_pict, s2 + dist); ++npix; } ++dy; } m_ren.blend_color_vspan(m_x, m_y - dy + 1, unsigned(p1 - p0), p0); return npix && ++m_step < m_count; } //--------------------------------------------------------------------- bool step_ver() { ++m_li; m_y += m_lp.inc; m_x = (m_lp.x1 + m_li.y()) >> line_subpixel_shift; if(m_lp.inc > 0) m_di.inc_y(m_x - m_old_x); else m_di.dec_y(m_x - m_old_x); m_old_x = m_x; int s1 = m_di.dist() / m_lp.len; int s2 = -s1; if(m_lp.inc > 0) s1 = -s1; int dist_start; int dist_pict; int dist_end; int dist; int dx; dist_start = m_di.dist_start(); dist_pict = m_di.dist_pict() + m_start; dist_end = m_di.dist_end(); color_type* p0 = m_colors + max_half_width + 2; color_type* p1 = p0; int npix = 0; p1->clear(); if(dist_end > 0) { if(dist_start <= 0) { m_ren.pixel(p1, dist_pict, s2); } ++npix; } ++p1; dx = 1; while((dist = m_dist_pos[dx]) - s1 <= m_width) { dist_start += m_di.dy_start(); dist_pict += m_di.dy_pict(); dist_end += m_di.dy_end(); p1->clear(); if(dist_end > 0 && dist_start <= 0) { if(m_lp.inc > 0) dist = -dist; m_ren.pixel(p1, dist_pict, s2 + dist); ++npix; } ++p1; ++dx; } dx = 1; dist_start = m_di.dist_start(); dist_pict = m_di.dist_pict() + m_start; dist_end = m_di.dist_end(); while((dist = m_dist_pos[dx]) + s1 <= m_width) { dist_start -= m_di.dy_start(); dist_pict -= m_di.dy_pict(); dist_end -= m_di.dy_end(); --p0; p0->clear(); if(dist_end > 0 && dist_start <= 0) { if(m_lp.inc > 0) dist = -dist; m_ren.pixel(p0, dist_pict, s2 - dist); ++npix; } ++dx; } m_ren.blend_color_hspan(m_x - dx + 1, m_y, unsigned(p1 - p0), p0); return npix && ++m_step < m_count; } //--------------------------------------------------------------------- int pattern_end() const { return m_start + m_di.len(); } //--------------------------------------------------------------------- bool vertical() const { return m_lp.vertical; } int width() const { return m_width; } int count() const { return m_count; } private: line_interpolator_image(const line_interpolator_image&); const line_interpolator_image& operator = (const line_interpolator_image&); protected: const line_parameters& m_lp; dda2_line_interpolator m_li; distance_interpolator4 m_di; renderer_type& m_ren; int m_plen; int m_x; int m_y; int m_old_x; int m_old_y; int m_count; int m_width; int m_max_extent; int m_start; int m_step; int m_dist_pos[max_half_width + 1]; color_type m_colors[max_half_width * 2 + 4]; }; //===================================================renderer_outline_image template class renderer_outline_image { public: //--------------------------------------------------------------------- typedef BaseRenderer base_ren_type; typedef renderer_outline_image self_type; typedef typename base_ren_type::color_type color_type; typedef ImagePattern pattern_type; //--------------------------------------------------------------------- renderer_outline_image(base_ren_type& ren, const pattern_type& patt) : m_ren(&ren), m_pattern(&patt), m_start(0), m_scale_x(1.0), m_clip_box(0,0,0,0), m_clipping(false) {} void attach(base_ren_type& ren) { m_ren = &ren; } //--------------------------------------------------------------------- void pattern(const pattern_type& p) { m_pattern = &p; } const pattern_type& pattern() const { return *m_pattern; } //--------------------------------------------------------------------- void reset_clipping() { m_clipping = false; } void clip_box(double x1, double y1, double x2, double y2) { m_clip_box.x1 = line_coord_sat::conv(x1); m_clip_box.y1 = line_coord_sat::conv(y1); m_clip_box.x2 = line_coord_sat::conv(x2); m_clip_box.y2 = line_coord_sat::conv(y2); m_clipping = true; } //--------------------------------------------------------------------- void scale_x(double s) { m_scale_x = s; } double scale_x() const { return m_scale_x; } //--------------------------------------------------------------------- void start_x(double s) { m_start = iround(s * line_subpixel_scale); } double start_x() const { return double(m_start) / line_subpixel_scale; } //--------------------------------------------------------------------- int subpixel_width() const { return m_pattern->line_width(); } int pattern_width() const { return m_pattern->pattern_width(); } double width() const { return double(subpixel_width()) / line_subpixel_scale; } //------------------------------------------------------------------------- void pixel(color_type* p, int x, int y) const { m_pattern->pixel(p, x, y); } //------------------------------------------------------------------------- void blend_color_hspan(int x, int y, unsigned len, const color_type* colors) { m_ren->blend_color_hspan(x, y, len, colors, 0); } //------------------------------------------------------------------------- void blend_color_vspan(int x, int y, unsigned len, const color_type* colors) { m_ren->blend_color_vspan(x, y, len, colors, 0); } //------------------------------------------------------------------------- static bool accurate_join_only() { return true; } //------------------------------------------------------------------------- template void semidot(Cmp, int, int, int, int) { } //------------------------------------------------------------------------- void pie(int, int, int, int, int, int) { } //------------------------------------------------------------------------- void line0(const line_parameters&) { } //------------------------------------------------------------------------- void line1(const line_parameters&, int, int) { } //------------------------------------------------------------------------- void line2(const line_parameters&, int, int) { } //------------------------------------------------------------------------- void line3_no_clip(const line_parameters& lp, int sx, int sy, int ex, int ey) { if(lp.len > line_max_length) { line_parameters lp1, lp2; lp.divide(lp1, lp2); int mx = lp1.x2 + (lp1.y2 - lp1.y1); int my = lp1.y2 - (lp1.x2 - lp1.x1); line3_no_clip(lp1, (lp.x1 + sx) >> 1, (lp.y1 + sy) >> 1, mx, my); line3_no_clip(lp2, mx, my, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1); return; } fix_degenerate_bisectrix_start(lp, &sx, &sy); fix_degenerate_bisectrix_end(lp, &ex, &ey); line_interpolator_image li(*this, lp, sx, sy, ex, ey, m_start, m_scale_x); if(li.vertical()) { while(li.step_ver()); } else { while(li.step_hor()); } m_start += uround(lp.len / m_scale_x); } //------------------------------------------------------------------------- void line3(const line_parameters& lp, int sx, int sy, int ex, int ey) { if(m_clipping) { int x1 = lp.x1; int y1 = lp.y1; int x2 = lp.x2; int y2 = lp.y2; unsigned flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box); int start = m_start; if((flags & 4) == 0) { if(flags) { line_parameters lp2(x1, y1, x2, y2, uround(calc_distance(x1, y1, x2, y2))); if(flags & 1) { m_start += uround(calc_distance(lp.x1, lp.y1, x1, y1) / m_scale_x); sx = x1 + (y2 - y1); sy = y1 - (x2 - x1); } else { while(abs(sx - lp.x1) + abs(sy - lp.y1) > lp2.len) { sx = (lp.x1 + sx) >> 1; sy = (lp.y1 + sy) >> 1; } } if(flags & 2) { ex = x2 + (y2 - y1); ey = y2 - (x2 - x1); } else { while(abs(ex - lp.x2) + abs(ey - lp.y2) > lp2.len) { ex = (lp.x2 + ex) >> 1; ey = (lp.y2 + ey) >> 1; } } line3_no_clip(lp2, sx, sy, ex, ey); } else { line3_no_clip(lp, sx, sy, ex, ey); } } m_start = start + uround(lp.len / m_scale_x); } else { line3_no_clip(lp, sx, sy, ex, ey); } } private: base_ren_type* m_ren; const pattern_type* m_pattern; int m_start; double m_scale_x; rect_i m_clip_box; bool m_clipping; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_scanline_p.h0000644000175000017500000002506612516137326024107 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Class scanline_p - a general purpose scanline container with packed spans. // //---------------------------------------------------------------------------- // // Adaptation for 32-bit screen coordinates (scanline32_p) has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_SCANLINE_P_INCLUDED #define AGG_SCANLINE_P_INCLUDED #include "agg_array.h" namespace agg24 { //=============================================================scanline_p8 // // This is a general purpose scaline container which supports the interface // used in the rasterizer::render(). See description of scanline_u8 // for details. // //------------------------------------------------------------------------ class scanline_p8 { public: typedef scanline_p8 self_type; typedef int8u cover_type; typedef int16 coord_type; //-------------------------------------------------------------------- struct span { coord_type x; coord_type len; // If negative, it's a solid span, covers is valid const cover_type* covers; }; typedef span* iterator; typedef const span* const_iterator; scanline_p8() : m_last_x(0x7FFFFFF0), m_covers(), m_cover_ptr(0), m_spans(), m_cur_span(0) { } //-------------------------------------------------------------------- void reset(int min_x, int max_x) { unsigned max_len = max_x - min_x + 3; if(max_len > m_spans.size()) { m_spans.resize(max_len); m_covers.resize(max_len); } m_last_x = 0x7FFFFFF0; m_cover_ptr = &m_covers[0]; m_cur_span = &m_spans[0]; m_cur_span->len = 0; } //-------------------------------------------------------------------- void add_cell(int x, unsigned cover) { *m_cover_ptr = (cover_type)cover; if(x == m_last_x+1 && m_cur_span->len > 0) { m_cur_span->len++; } else { m_cur_span++; m_cur_span->covers = m_cover_ptr; m_cur_span->x = (int16)x; m_cur_span->len = 1; } m_last_x = x; m_cover_ptr++; } //-------------------------------------------------------------------- void add_cells(int x, unsigned len, const cover_type* covers) { memcpy(m_cover_ptr, covers, len * sizeof(cover_type)); if(x == m_last_x+1 && m_cur_span->len > 0) { m_cur_span->len += (int16)len; } else { m_cur_span++; m_cur_span->covers = m_cover_ptr; m_cur_span->x = (int16)x; m_cur_span->len = (int16)len; } m_cover_ptr += len; m_last_x = x + len - 1; } //-------------------------------------------------------------------- void add_span(int x, unsigned len, unsigned cover) { if(x == m_last_x+1 && m_cur_span->len < 0 && cover == *m_cur_span->covers) { m_cur_span->len -= (int16)len; } else { *m_cover_ptr = (cover_type)cover; m_cur_span++; m_cur_span->covers = m_cover_ptr++; m_cur_span->x = (int16)x; m_cur_span->len = (int16)(-int(len)); } m_last_x = x + len - 1; } //-------------------------------------------------------------------- void finalize(int y) { m_y = y; } //-------------------------------------------------------------------- void reset_spans() { m_last_x = 0x7FFFFFF0; m_cover_ptr = &m_covers[0]; m_cur_span = &m_spans[0]; m_cur_span->len = 0; } //-------------------------------------------------------------------- int y() const { return m_y; } unsigned num_spans() const { return unsigned(m_cur_span - &m_spans[0]); } const_iterator begin() const { return &m_spans[1]; } private: scanline_p8(const self_type&); const self_type& operator = (const self_type&); int m_last_x; int m_y; pod_array m_covers; cover_type* m_cover_ptr; pod_array m_spans; span* m_cur_span; }; //==========================================================scanline32_p8 class scanline32_p8 { public: typedef scanline32_p8 self_type; typedef int8u cover_type; typedef int32 coord_type; struct span { span() {} span(coord_type x_, coord_type len_, const cover_type* covers_) : x(x_), len(len_), covers(covers_) {} coord_type x; coord_type len; // If negative, it's a solid span, covers is valid const cover_type* covers; }; typedef pod_bvector span_array_type; //-------------------------------------------------------------------- class const_iterator { public: const_iterator(const span_array_type& spans) : m_spans(spans), m_span_idx(0) {} const span& operator*() const { return m_spans[m_span_idx]; } const span* operator->() const { return &m_spans[m_span_idx]; } void operator ++ () { ++m_span_idx; } private: const span_array_type& m_spans; unsigned m_span_idx; }; //-------------------------------------------------------------------- scanline32_p8() : m_max_len(0), m_last_x(0x7FFFFFF0), m_covers(), m_cover_ptr(0) { } //-------------------------------------------------------------------- void reset(int min_x, int max_x) { unsigned max_len = max_x - min_x + 3; if(max_len > m_covers.size()) { m_covers.resize(max_len); } m_last_x = 0x7FFFFFF0; m_cover_ptr = &m_covers[0]; m_spans.remove_all(); } //-------------------------------------------------------------------- void add_cell(int x, unsigned cover) { *m_cover_ptr = cover_type(cover); if(x == m_last_x+1 && m_spans.size() && m_spans.last().len > 0) { m_spans.last().len++; } else { m_spans.add(span(coord_type(x), 1, m_cover_ptr)); } m_last_x = x; m_cover_ptr++; } //-------------------------------------------------------------------- void add_cells(int x, unsigned len, const cover_type* covers) { memcpy(m_cover_ptr, covers, len * sizeof(cover_type)); if(x == m_last_x+1 && m_spans.size() && m_spans.last().len > 0) { m_spans.last().len += coord_type(len); } else { m_spans.add(span(coord_type(x), coord_type(len), m_cover_ptr)); } m_cover_ptr += len; m_last_x = x + len - 1; } //-------------------------------------------------------------------- void add_span(int x, unsigned len, unsigned cover) { if(x == m_last_x+1 && m_spans.size() && m_spans.last().len < 0 && cover == *m_spans.last().covers) { m_spans.last().len -= coord_type(len); } else { *m_cover_ptr = cover_type(cover); m_spans.add(span(coord_type(x), -coord_type(len), m_cover_ptr++)); } m_last_x = x + len - 1; } //-------------------------------------------------------------------- void finalize(int y) { m_y = y; } //-------------------------------------------------------------------- void reset_spans() { m_last_x = 0x7FFFFFF0; m_cover_ptr = &m_covers[0]; m_spans.remove_all(); } //-------------------------------------------------------------------- int y() const { return m_y; } unsigned num_spans() const { return m_spans.size(); } const_iterator begin() const { return const_iterator(m_spans); } private: scanline32_p8(const self_type&); const self_type& operator = (const self_type&); unsigned m_max_len; int m_last_x; int m_y; pod_array m_covers; cover_type* m_cover_ptr; span_array_type m_spans; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_vcgen_contour.h0000644000175000017500000000673412516137326024650 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_VCGEN_CONTOUR_INCLUDED #define AGG_VCGEN_CONTOUR_INCLUDED #include "agg_math_stroke.h" namespace agg24 { //----------------------------------------------------------vcgen_contour // // See Implementation agg_vcgen_contour.cpp // class vcgen_contour { enum status_e { initial, ready, outline, out_vertices, end_poly, stop }; public: typedef vertex_sequence vertex_storage; typedef pod_bvector coord_storage; vcgen_contour(); void line_cap(line_cap_e lc) { m_stroker.line_cap(lc); } void line_join(line_join_e lj) { m_stroker.line_join(lj); } void inner_join(inner_join_e ij) { m_stroker.inner_join(ij); } line_cap_e line_cap() const { return m_stroker.line_cap(); } line_join_e line_join() const { return m_stroker.line_join(); } inner_join_e inner_join() const { return m_stroker.inner_join(); } void width(double w) { m_stroker.width(m_width = w); } void miter_limit(double ml) { m_stroker.miter_limit(ml); } void miter_limit_theta(double t) { m_stroker.miter_limit_theta(t); } void inner_miter_limit(double ml) { m_stroker.inner_miter_limit(ml); } void approximation_scale(double as) { m_stroker.approximation_scale(as); } double width() const { return m_width; } double miter_limit() const { return m_stroker.miter_limit(); } double inner_miter_limit() const { return m_stroker.inner_miter_limit(); } double approximation_scale() const { return m_stroker.approximation_scale(); } void auto_detect_orientation(bool v) { m_auto_detect = v; } bool auto_detect_orientation() const { return m_auto_detect; } // Generator interface void remove_all(); void add_vertex(double x, double y, unsigned cmd); // Vertex Source Interface void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: vcgen_contour(const vcgen_contour&); const vcgen_contour& operator = (const vcgen_contour&); math_stroke m_stroker; double m_width; vertex_storage m_src_vertices; coord_storage m_out_vertices; status_e m_status; unsigned m_src_vertex; unsigned m_out_vertex; unsigned m_closed; unsigned m_orientation; bool m_auto_detect; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_embedded_raster_fonts.h0000644000175000017500000000424012516137326026305 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_EMBEDDED_RASTER_FONTS_INCLUDED #define AGG_EMBEDDED_RASTER_FONTS_INCLUDED #include "agg_basics.h" namespace agg24 { extern const int8u gse4x6[]; extern const int8u gse4x8[]; extern const int8u gse5x7[]; extern const int8u gse5x9[]; extern const int8u gse6x12[]; extern const int8u gse6x9[]; extern const int8u gse7x11[]; extern const int8u gse7x11_bold[]; extern const int8u gse7x15[]; extern const int8u gse7x15_bold[]; extern const int8u gse8x16[]; extern const int8u gse8x16_bold[]; extern const int8u mcs11_prop[]; extern const int8u mcs11_prop_condensed[]; extern const int8u mcs12_prop[]; extern const int8u mcs13_prop[]; extern const int8u mcs5x10_mono[]; extern const int8u mcs5x11_mono[]; extern const int8u mcs6x10_mono[]; extern const int8u mcs6x11_mono[]; extern const int8u mcs7x12_mono_high[]; extern const int8u mcs7x12_mono_low[]; extern const int8u verdana12[]; extern const int8u verdana12_bold[]; extern const int8u verdana13[]; extern const int8u verdana13_bold[]; extern const int8u verdana14[]; extern const int8u verdana14_bold[]; extern const int8u verdana16[]; extern const int8u verdana16_bold[]; extern const int8u verdana17[]; extern const int8u verdana17_bold[]; extern const int8u verdana18[]; extern const int8u verdana18_bold[]; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_bspline.h0000644000175000017500000000327512516137326024453 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_CONV_BSPLINE_INCLUDED #define AGG_CONV_BSPLINE_INCLUDED #include "agg_basics.h" #include "agg_vcgen_bspline.h" #include "agg_conv_adaptor_vcgen.h" namespace agg24 { //---------------------------------------------------------conv_bspline template struct conv_bspline : public conv_adaptor_vcgen { typedef conv_adaptor_vcgen base_type; conv_bspline(VertexSource& vs) : conv_adaptor_vcgen(vs) {} void interpolation_step(double v) { base_type::generator().interpolation_step(v); } double interpolation_step() const { return base_type::generator().interpolation_step(); } private: conv_bspline(const conv_bspline&); const conv_bspline& operator = (const conv_bspline&); }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_shorten_path.h0000644000175000017500000000406412516137326024465 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_SHORTEN_PATH_INCLUDED #define AGG_SHORTEN_PATH_INCLUDED #include "agg_basics.h" #include "agg_vertex_sequence.h" namespace agg24 { //===========================================================shorten_path template void shorten_path(VertexSequence& vs, double s, unsigned closed = 0) { typedef typename VertexSequence::value_type vertex_type; if(s > 0.0 && vs.size() > 1) { double d; int n = int(vs.size() - 2); while(n) { d = vs[n].dist; if(d > s) break; vs.remove_last(); s -= d; --n; } if(vs.size() < 2) { vs.remove_all(); } else { n = vs.size() - 1; vertex_type& prev = vs[n-1]; vertex_type& last = vs[n]; d = (prev.dist - s) / prev.dist; double x = prev.x + (last.x - prev.x) * d; double y = prev.y + (last.y - prev.y) * d; last.x = x; last.y = y; if(!prev(last)) vs.remove_last(); vs.close(closed != 0); } } } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_clip_polyline.h0000644000175000017500000000504512516137326025656 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // polyline clipping converter // There an optimized Liang-Basky algorithm is used. // The algorithm doesn't optimize the degenerate edges, i.e. it will never // break a closed polyline into two or more ones, instead, there will be // degenerate edges coinciding with the respective clipping boundaries. // This is a sub-optimal solution, because that optimization would require // extra, rather expensive math while the rasterizer tolerates it quite well, // without any considerable overhead. // //---------------------------------------------------------------------------- #ifndef AGG_CONV_CLIP_polyline_INCLUDED #define AGG_CONV_CLIP_polyline_INCLUDED #include "agg_basics.h" #include "agg_conv_adaptor_vpgen.h" #include "agg_vpgen_clip_polyline.h" namespace agg24 { //=======================================================conv_clip_polyline template struct conv_clip_polyline : public conv_adaptor_vpgen { typedef conv_adaptor_vpgen base_type; conv_clip_polyline(VertexSource& vs) : conv_adaptor_vpgen(vs) {} void clip_box(double x1, double y1, double x2, double y2) { base_type::vpgen().clip_box(x1, y1, x2, y2); } double x1() const { return base_type::vpgen().x1(); } double y1() const { return base_type::vpgen().y1(); } double x2() const { return base_type::vpgen().x2(); } double y2() const { return base_type::vpgen().y2(); } private: conv_clip_polyline(const conv_clip_polyline&); const conv_clip_polyline& operator = (const conv_clip_polyline&); }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_adaptor_vpgen.h0000644000175000017500000001206712516137326025647 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_CONV_ADAPTOR_VPGEN_INCLUDED #define AGG_CONV_ADAPTOR_VPGEN_INCLUDED #include "agg_basics.h" namespace agg24 { //======================================================conv_adaptor_vpgen template class conv_adaptor_vpgen { public: conv_adaptor_vpgen(VertexSource& source) : m_source(&source) {} void attach(VertexSource& source) { m_source = &source; } VPGen& vpgen() { return m_vpgen; } const VPGen& vpgen() const { return m_vpgen; } void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: conv_adaptor_vpgen(const conv_adaptor_vpgen&); const conv_adaptor_vpgen& operator = (const conv_adaptor_vpgen&); VertexSource* m_source; VPGen m_vpgen; double m_start_x; double m_start_y; unsigned m_poly_flags; int m_vertices; }; //------------------------------------------------------------------------ template void conv_adaptor_vpgen::rewind(unsigned path_id) { m_source->rewind(path_id); m_vpgen.reset(); m_start_x = 0; m_start_y = 0; m_poly_flags = 0; m_vertices = 0; } //------------------------------------------------------------------------ template unsigned conv_adaptor_vpgen::vertex(double* x, double* y) { unsigned cmd = path_cmd_stop; for(;;) { cmd = m_vpgen.vertex(x, y); if(!is_stop(cmd)) break; if(m_poly_flags && !m_vpgen.auto_unclose()) { *x = 0.0; *y = 0.0; cmd = m_poly_flags; m_poly_flags = 0; break; } if(m_vertices < 0) { if(m_vertices < -1) { m_vertices = 0; return path_cmd_stop; } m_vpgen.move_to(m_start_x, m_start_y); m_vertices = 1; continue; } double tx, ty; cmd = m_source->vertex(&tx, &ty); if(is_vertex(cmd)) { if(is_move_to(cmd)) { if(m_vpgen.auto_close() && m_vertices > 2) { m_vpgen.line_to(m_start_x, m_start_y); m_poly_flags = path_cmd_end_poly | path_flags_close; m_start_x = tx; m_start_y = ty; m_vertices = -1; continue; } m_vpgen.move_to(tx, ty); m_start_x = tx; m_start_y = ty; m_vertices = 1; } else { m_vpgen.line_to(tx, ty); ++m_vertices; } } else { if(is_end_poly(cmd)) { m_poly_flags = cmd; if(is_closed(cmd) || m_vpgen.auto_close()) { if(m_vpgen.auto_close()) m_poly_flags |= path_flags_close; if(m_vertices > 2) { m_vpgen.line_to(m_start_x, m_start_y); } m_vertices = 0; } } else { // path_cmd_stop if(m_vpgen.auto_close() && m_vertices > 2) { m_vpgen.line_to(m_start_x, m_start_y); m_poly_flags = path_cmd_end_poly | path_flags_close; m_vertices = -2; continue; } break; } } } return cmd; } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_ellipse.h0000644000175000017500000000727512516137326023433 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class ellipse // //---------------------------------------------------------------------------- #ifndef AGG_ELLIPSE_INCLUDED #define AGG_ELLIPSE_INCLUDED #include "agg_basics.h" #include namespace agg24 { //----------------------------------------------------------------ellipse class ellipse { public: ellipse() : m_x(0.0), m_y(0.0), m_rx(1.0), m_ry(1.0), m_scale(1.0), m_num(4), m_step(0), m_cw(false) {} ellipse(double x, double y, double rx, double ry, unsigned num_steps=0, bool cw=false) : m_x(x), m_y(y), m_rx(rx), m_ry(ry), m_scale(1.0), m_num(num_steps), m_step(0), m_cw(cw) { if(m_num == 0) calc_num_steps(); } void init(double x, double y, double rx, double ry, unsigned num_steps=0, bool cw=false); void approximation_scale(double scale); void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: void calc_num_steps(); double m_x; double m_y; double m_rx; double m_ry; double m_scale; unsigned m_num; unsigned m_step; bool m_cw; }; //------------------------------------------------------------------------ inline void ellipse::init(double x, double y, double rx, double ry, unsigned num_steps, bool cw) { m_x = x; m_y = y; m_rx = rx; m_ry = ry; m_num = num_steps; m_step = 0; m_cw = cw; if(m_num == 0) calc_num_steps(); } //------------------------------------------------------------------------ inline void ellipse::approximation_scale(double scale) { m_scale = scale; calc_num_steps(); } //------------------------------------------------------------------------ inline void ellipse::calc_num_steps() { double ra = (fabs(m_rx) + fabs(m_ry)) / 2; double da = acos(ra / (ra + 0.125 / m_scale)) * 2; m_num = uround(2*pi / da); } //------------------------------------------------------------------------ inline void ellipse::rewind(unsigned) { m_step = 0; } //------------------------------------------------------------------------ inline unsigned ellipse::vertex(double* x, double* y) { if(m_step == m_num) { ++m_step; return path_cmd_end_poly | path_flags_close | path_flags_ccw; } if(m_step > m_num) return path_cmd_stop; double angle = double(m_step) / double(m_num) * 2.0 * pi; if(m_cw) angle = 2.0 * pi - angle; *x = m_x + cos(angle) * m_rx; *y = m_y + sin(angle) * m_ry; m_step++; return ((m_step == 1) ? path_cmd_move_to : path_cmd_line_to); } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_contour.h0000644000175000017500000000565312516137326024512 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // conv_stroke // //---------------------------------------------------------------------------- #ifndef AGG_CONV_CONTOUR_INCLUDED #define AGG_CONV_CONTOUR_INCLUDED #include "agg_basics.h" #include "agg_vcgen_contour.h" #include "agg_conv_adaptor_vcgen.h" namespace agg24 { //-----------------------------------------------------------conv_contour template struct conv_contour : public conv_adaptor_vcgen { typedef conv_adaptor_vcgen base_type; conv_contour(VertexSource& vs) : conv_adaptor_vcgen(vs) { } void line_join(line_join_e lj) { base_type::generator().line_join(lj); } void inner_join(inner_join_e ij) { base_type::generator().inner_join(ij); } void width(double w) { base_type::generator().width(w); } void miter_limit(double ml) { base_type::generator().miter_limit(ml); } void miter_limit_theta(double t) { base_type::generator().miter_limit_theta(t); } void inner_miter_limit(double ml) { base_type::generator().inner_miter_limit(ml); } void approximation_scale(double as) { base_type::generator().approximation_scale(as); } void auto_detect_orientation(bool v) { base_type::generator().auto_detect_orientation(v); } line_join_e line_join() const { return base_type::generator().line_join(); } inner_join_e inner_join() const { return base_type::generator().inner_join(); } double width() const { return base_type::generator().width(); } double miter_limit() const { return base_type::generator().miter_limit(); } double inner_miter_limit() const { return base_type::generator().inner_miter_limit(); } double approximation_scale() const { return base_type::generator().approximation_scale(); } bool auto_detect_orientation() const { return base_type::generator().auto_detect_orientation(); } private: conv_contour(const conv_contour&); const conv_contour& operator = (const conv_contour&); }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_renderer_outline_aa.h0000644000175000017500000017771412516137326026012 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_RENDERER_OUTLINE_AA_INCLUDED #define AGG_RENDERER_OUTLINE_AA_INCLUDED #include "agg_array.h" #include "agg_math.h" #include "agg_line_aa_basics.h" #include "agg_dda_line.h" #include "agg_ellipse_bresenham.h" #include "agg_renderer_base.h" #include "agg_gamma_functions.h" #include "agg_clip_liang_barsky.h" namespace agg24 { //===================================================distance_interpolator0 class distance_interpolator0 { public: //--------------------------------------------------------------------- distance_interpolator0() {} distance_interpolator0(int x1, int y1, int x2, int y2, int x, int y) : m_dx(line_mr(x2) - line_mr(x1)), m_dy(line_mr(y2) - line_mr(y1)), m_dist((line_mr(x + line_subpixel_scale/2) - line_mr(x2)) * m_dy - (line_mr(y + line_subpixel_scale/2) - line_mr(y2)) * m_dx) { m_dx <<= line_mr_subpixel_shift; m_dy <<= line_mr_subpixel_shift; } //--------------------------------------------------------------------- void inc_x() { m_dist += m_dy; } int dist() const { return m_dist; } private: //--------------------------------------------------------------------- int m_dx; int m_dy; int m_dist; }; //==================================================distance_interpolator00 class distance_interpolator00 { public: //--------------------------------------------------------------------- distance_interpolator00() {} distance_interpolator00(int xc, int yc, int x1, int y1, int x2, int y2, int x, int y) : m_dx1(line_mr(x1) - line_mr(xc)), m_dy1(line_mr(y1) - line_mr(yc)), m_dx2(line_mr(x2) - line_mr(xc)), m_dy2(line_mr(y2) - line_mr(yc)), m_dist1((line_mr(x + line_subpixel_scale/2) - line_mr(x1)) * m_dy1 - (line_mr(y + line_subpixel_scale/2) - line_mr(y1)) * m_dx1), m_dist2((line_mr(x + line_subpixel_scale/2) - line_mr(x2)) * m_dy2 - (line_mr(y + line_subpixel_scale/2) - line_mr(y2)) * m_dx2) { m_dx1 <<= line_mr_subpixel_shift; m_dy1 <<= line_mr_subpixel_shift; m_dx2 <<= line_mr_subpixel_shift; m_dy2 <<= line_mr_subpixel_shift; } //--------------------------------------------------------------------- void inc_x() { m_dist1 += m_dy1; m_dist2 += m_dy2; } int dist1() const { return m_dist1; } int dist2() const { return m_dist2; } private: //--------------------------------------------------------------------- int m_dx1; int m_dy1; int m_dx2; int m_dy2; int m_dist1; int m_dist2; }; //===================================================distance_interpolator1 class distance_interpolator1 { public: //--------------------------------------------------------------------- distance_interpolator1() {} distance_interpolator1(int x1, int y1, int x2, int y2, int x, int y) : m_dx(x2 - x1), m_dy(y2 - y1), m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - double(y + line_subpixel_scale/2 - y2) * double(m_dx))) { m_dx <<= line_subpixel_shift; m_dy <<= line_subpixel_shift; } //--------------------------------------------------------------------- void inc_x() { m_dist += m_dy; } void dec_x() { m_dist -= m_dy; } void inc_y() { m_dist -= m_dx; } void dec_y() { m_dist += m_dx; } //--------------------------------------------------------------------- void inc_x(int dy) { m_dist += m_dy; if(dy > 0) m_dist -= m_dx; if(dy < 0) m_dist += m_dx; } //--------------------------------------------------------------------- void dec_x(int dy) { m_dist -= m_dy; if(dy > 0) m_dist -= m_dx; if(dy < 0) m_dist += m_dx; } //--------------------------------------------------------------------- void inc_y(int dx) { m_dist -= m_dx; if(dx > 0) m_dist += m_dy; if(dx < 0) m_dist -= m_dy; } void dec_y(int dx) //--------------------------------------------------------------------- { m_dist += m_dx; if(dx > 0) m_dist += m_dy; if(dx < 0) m_dist -= m_dy; } //--------------------------------------------------------------------- int dist() const { return m_dist; } int dx() const { return m_dx; } int dy() const { return m_dy; } private: //--------------------------------------------------------------------- int m_dx; int m_dy; int m_dist; }; //===================================================distance_interpolator2 class distance_interpolator2 { public: //--------------------------------------------------------------------- distance_interpolator2() {} distance_interpolator2(int x1, int y1, int x2, int y2, int sx, int sy, int x, int y) : m_dx(x2 - x1), m_dy(y2 - y1), m_dx_start(line_mr(sx) - line_mr(x1)), m_dy_start(line_mr(sy) - line_mr(y1)), m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - double(y + line_subpixel_scale/2 - y2) * double(m_dx))), m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start - (line_mr(y + line_subpixel_scale/2) - line_mr(sy)) * m_dx_start) { m_dx <<= line_subpixel_shift; m_dy <<= line_subpixel_shift; m_dx_start <<= line_mr_subpixel_shift; m_dy_start <<= line_mr_subpixel_shift; } distance_interpolator2(int x1, int y1, int x2, int y2, int ex, int ey, int x, int y, int) : m_dx(x2 - x1), m_dy(y2 - y1), m_dx_start(line_mr(ex) - line_mr(x2)), m_dy_start(line_mr(ey) - line_mr(y2)), m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - double(y + line_subpixel_scale/2 - y2) * double(m_dx))), m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_start - (line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_start) { m_dx <<= line_subpixel_shift; m_dy <<= line_subpixel_shift; m_dx_start <<= line_mr_subpixel_shift; m_dy_start <<= line_mr_subpixel_shift; } //--------------------------------------------------------------------- void inc_x() { m_dist += m_dy; m_dist_start += m_dy_start; } void dec_x() { m_dist -= m_dy; m_dist_start -= m_dy_start; } void inc_y() { m_dist -= m_dx; m_dist_start -= m_dx_start; } void dec_y() { m_dist += m_dx; m_dist_start += m_dx_start; } //--------------------------------------------------------------------- void inc_x(int dy) { m_dist += m_dy; m_dist_start += m_dy_start; if(dy > 0) { m_dist -= m_dx; m_dist_start -= m_dx_start; } if(dy < 0) { m_dist += m_dx; m_dist_start += m_dx_start; } } //--------------------------------------------------------------------- void dec_x(int dy) { m_dist -= m_dy; m_dist_start -= m_dy_start; if(dy > 0) { m_dist -= m_dx; m_dist_start -= m_dx_start; } if(dy < 0) { m_dist += m_dx; m_dist_start += m_dx_start; } } //--------------------------------------------------------------------- void inc_y(int dx) { m_dist -= m_dx; m_dist_start -= m_dx_start; if(dx > 0) { m_dist += m_dy; m_dist_start += m_dy_start; } if(dx < 0) { m_dist -= m_dy; m_dist_start -= m_dy_start; } } //--------------------------------------------------------------------- void dec_y(int dx) { m_dist += m_dx; m_dist_start += m_dx_start; if(dx > 0) { m_dist += m_dy; m_dist_start += m_dy_start; } if(dx < 0) { m_dist -= m_dy; m_dist_start -= m_dy_start; } } //--------------------------------------------------------------------- int dist() const { return m_dist; } int dist_start() const { return m_dist_start; } int dist_end() const { return m_dist_start; } //--------------------------------------------------------------------- int dx() const { return m_dx; } int dy() const { return m_dy; } int dx_start() const { return m_dx_start; } int dy_start() const { return m_dy_start; } int dx_end() const { return m_dx_start; } int dy_end() const { return m_dy_start; } private: //--------------------------------------------------------------------- int m_dx; int m_dy; int m_dx_start; int m_dy_start; int m_dist; int m_dist_start; }; //===================================================distance_interpolator3 class distance_interpolator3 { public: //--------------------------------------------------------------------- distance_interpolator3() {} distance_interpolator3(int x1, int y1, int x2, int y2, int sx, int sy, int ex, int ey, int x, int y) : m_dx(x2 - x1), m_dy(y2 - y1), m_dx_start(line_mr(sx) - line_mr(x1)), m_dy_start(line_mr(sy) - line_mr(y1)), m_dx_end(line_mr(ex) - line_mr(x2)), m_dy_end(line_mr(ey) - line_mr(y2)), m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - double(y + line_subpixel_scale/2 - y2) * double(m_dx))), m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start - (line_mr(y + line_subpixel_scale/2) - line_mr(sy)) * m_dx_start), m_dist_end((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_end - (line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_end) { m_dx <<= line_subpixel_shift; m_dy <<= line_subpixel_shift; m_dx_start <<= line_mr_subpixel_shift; m_dy_start <<= line_mr_subpixel_shift; m_dx_end <<= line_mr_subpixel_shift; m_dy_end <<= line_mr_subpixel_shift; } //--------------------------------------------------------------------- void inc_x() { m_dist += m_dy; m_dist_start += m_dy_start; m_dist_end += m_dy_end; } void dec_x() { m_dist -= m_dy; m_dist_start -= m_dy_start; m_dist_end -= m_dy_end; } void inc_y() { m_dist -= m_dx; m_dist_start -= m_dx_start; m_dist_end -= m_dx_end; } void dec_y() { m_dist += m_dx; m_dist_start += m_dx_start; m_dist_end += m_dx_end; } //--------------------------------------------------------------------- void inc_x(int dy) { m_dist += m_dy; m_dist_start += m_dy_start; m_dist_end += m_dy_end; if(dy > 0) { m_dist -= m_dx; m_dist_start -= m_dx_start; m_dist_end -= m_dx_end; } if(dy < 0) { m_dist += m_dx; m_dist_start += m_dx_start; m_dist_end += m_dx_end; } } //--------------------------------------------------------------------- void dec_x(int dy) { m_dist -= m_dy; m_dist_start -= m_dy_start; m_dist_end -= m_dy_end; if(dy > 0) { m_dist -= m_dx; m_dist_start -= m_dx_start; m_dist_end -= m_dx_end; } if(dy < 0) { m_dist += m_dx; m_dist_start += m_dx_start; m_dist_end += m_dx_end; } } //--------------------------------------------------------------------- void inc_y(int dx) { m_dist -= m_dx; m_dist_start -= m_dx_start; m_dist_end -= m_dx_end; if(dx > 0) { m_dist += m_dy; m_dist_start += m_dy_start; m_dist_end += m_dy_end; } if(dx < 0) { m_dist -= m_dy; m_dist_start -= m_dy_start; m_dist_end -= m_dy_end; } } //--------------------------------------------------------------------- void dec_y(int dx) { m_dist += m_dx; m_dist_start += m_dx_start; m_dist_end += m_dx_end; if(dx > 0) { m_dist += m_dy; m_dist_start += m_dy_start; m_dist_end += m_dy_end; } if(dx < 0) { m_dist -= m_dy; m_dist_start -= m_dy_start; m_dist_end -= m_dy_end; } } //--------------------------------------------------------------------- int dist() const { return m_dist; } int dist_start() const { return m_dist_start; } int dist_end() const { return m_dist_end; } //--------------------------------------------------------------------- int dx() const { return m_dx; } int dy() const { return m_dy; } int dx_start() const { return m_dx_start; } int dy_start() const { return m_dy_start; } int dx_end() const { return m_dx_end; } int dy_end() const { return m_dy_end; } private: //--------------------------------------------------------------------- int m_dx; int m_dy; int m_dx_start; int m_dy_start; int m_dx_end; int m_dy_end; int m_dist; int m_dist_start; int m_dist_end; }; //================================================line_interpolator_aa_base template class line_interpolator_aa_base { public: typedef Renderer renderer_type; typedef typename Renderer::color_type color_type; //--------------------------------------------------------------------- enum max_half_width_e { max_half_width = 64 }; //--------------------------------------------------------------------- line_interpolator_aa_base(renderer_type& ren, const line_parameters& lp) : m_lp(&lp), m_li(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) : line_dbl_hr(lp.y2 - lp.y1), lp.vertical ? abs(lp.y2 - lp.y1) : abs(lp.x2 - lp.x1) + 1), m_ren(ren), m_len((lp.vertical == (lp.inc > 0)) ? -lp.len : lp.len), m_x(lp.x1 >> line_subpixel_shift), m_y(lp.y1 >> line_subpixel_shift), m_old_x(m_x), m_old_y(m_y), m_count((lp.vertical ? abs((lp.y2 >> line_subpixel_shift) - m_y) : abs((lp.x2 >> line_subpixel_shift) - m_x))), m_width(ren.subpixel_width()), //m_max_extent(m_width >> (line_subpixel_shift - 2)), m_max_extent((m_width + line_subpixel_mask) >> line_subpixel_shift), m_step(0) { agg24::dda2_line_interpolator li(0, lp.vertical ? (lp.dy << agg24::line_subpixel_shift) : (lp.dx << agg24::line_subpixel_shift), lp.len); unsigned i; int stop = m_width + line_subpixel_scale * 2; for(i = 0; i < max_half_width; ++i) { m_dist[i] = li.y(); if(m_dist[i] >= stop) break; ++li; } m_dist[i++] = 0x7FFF0000; } //--------------------------------------------------------------------- template int step_hor_base(DI& di) { ++m_li; m_x += m_lp->inc; m_y = (m_lp->y1 + m_li.y()) >> line_subpixel_shift; if(m_lp->inc > 0) di.inc_x(m_y - m_old_y); else di.dec_x(m_y - m_old_y); m_old_y = m_y; return di.dist() / m_len; } //--------------------------------------------------------------------- template int step_ver_base(DI& di) { ++m_li; m_y += m_lp->inc; m_x = (m_lp->x1 + m_li.y()) >> line_subpixel_shift; if(m_lp->inc > 0) di.inc_y(m_x - m_old_x); else di.dec_y(m_x - m_old_x); m_old_x = m_x; return di.dist() / m_len; } //--------------------------------------------------------------------- bool vertical() const { return m_lp->vertical; } int width() const { return m_width; } int count() const { return m_count; } private: line_interpolator_aa_base(const line_interpolator_aa_base&); const line_interpolator_aa_base& operator = (const line_interpolator_aa_base&); protected: const line_parameters* m_lp; dda2_line_interpolator m_li; renderer_type& m_ren; int m_len; int m_x; int m_y; int m_old_x; int m_old_y; int m_count; int m_width; int m_max_extent; int m_step; int m_dist[max_half_width + 1]; cover_type m_covers[max_half_width * 2 + 4]; }; //====================================================line_interpolator_aa0 template class line_interpolator_aa0 : public line_interpolator_aa_base { public: typedef Renderer renderer_type; typedef typename Renderer::color_type color_type; typedef line_interpolator_aa_base base_type; //--------------------------------------------------------------------- line_interpolator_aa0(renderer_type& ren, const line_parameters& lp) : line_interpolator_aa_base(ren, lp), m_di(lp.x1, lp.y1, lp.x2, lp.y2, lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask) { base_type::m_li.adjust_forward(); } //--------------------------------------------------------------------- bool step_hor() { int dist; int dy; int s1 = base_type::step_hor_base(m_di); cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; cover_type* p1 = p0; *p1++ = (cover_type)base_type::m_ren.cover(s1); dy = 1; while((dist = base_type::m_dist[dy] - s1) <= base_type::m_width) { *p1++ = (cover_type)base_type::m_ren.cover(dist); ++dy; } dy = 1; while((dist = base_type::m_dist[dy] + s1) <= base_type::m_width) { *--p0 = (cover_type)base_type::m_ren.cover(dist); ++dy; } base_type::m_ren.blend_solid_vspan(base_type::m_x, base_type::m_y - dy + 1, unsigned(p1 - p0), p0); return ++base_type::m_step < base_type::m_count; } //--------------------------------------------------------------------- bool step_ver() { int dist; int dx; int s1 = base_type::step_ver_base(m_di); cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; cover_type* p1 = p0; *p1++ = (cover_type)base_type::m_ren.cover(s1); dx = 1; while((dist = base_type::m_dist[dx] - s1) <= base_type::m_width) { *p1++ = (cover_type)base_type::m_ren.cover(dist); ++dx; } dx = 1; while((dist = base_type::m_dist[dx] + s1) <= base_type::m_width) { *--p0 = (cover_type)base_type::m_ren.cover(dist); ++dx; } base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, base_type::m_y, unsigned(p1 - p0), p0); return ++base_type::m_step < base_type::m_count; } private: line_interpolator_aa0(const line_interpolator_aa0&); const line_interpolator_aa0& operator = (const line_interpolator_aa0&); //--------------------------------------------------------------------- distance_interpolator1 m_di; }; //====================================================line_interpolator_aa1 template class line_interpolator_aa1 : public line_interpolator_aa_base { public: typedef Renderer renderer_type; typedef typename Renderer::color_type color_type; typedef line_interpolator_aa_base base_type; //--------------------------------------------------------------------- line_interpolator_aa1(renderer_type& ren, const line_parameters& lp, int sx, int sy) : line_interpolator_aa_base(ren, lp), m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask) { int dist1_start; int dist2_start; int npix = 1; if(lp.vertical) { do { --base_type::m_li; base_type::m_y -= lp.inc; base_type::m_x = (base_type::m_lp->x1 + base_type::m_li.y()) >> line_subpixel_shift; if(lp.inc > 0) m_di.dec_y(base_type::m_x - base_type::m_old_x); else m_di.inc_y(base_type::m_x - base_type::m_old_x); base_type::m_old_x = base_type::m_x; dist1_start = dist2_start = m_di.dist_start(); int dx = 0; if(dist1_start < 0) ++npix; do { dist1_start += m_di.dy_start(); dist2_start -= m_di.dy_start(); if(dist1_start < 0) ++npix; if(dist2_start < 0) ++npix; ++dx; } while(base_type::m_dist[dx] <= base_type::m_width); --base_type::m_step; if(npix == 0) break; npix = 0; } while(base_type::m_step >= -base_type::m_max_extent); } else { do { --base_type::m_li; base_type::m_x -= lp.inc; base_type::m_y = (base_type::m_lp->y1 + base_type::m_li.y()) >> line_subpixel_shift; if(lp.inc > 0) m_di.dec_x(base_type::m_y - base_type::m_old_y); else m_di.inc_x(base_type::m_y - base_type::m_old_y); base_type::m_old_y = base_type::m_y; dist1_start = dist2_start = m_di.dist_start(); int dy = 0; if(dist1_start < 0) ++npix; do { dist1_start -= m_di.dx_start(); dist2_start += m_di.dx_start(); if(dist1_start < 0) ++npix; if(dist2_start < 0) ++npix; ++dy; } while(base_type::m_dist[dy] <= base_type::m_width); --base_type::m_step; if(npix == 0) break; npix = 0; } while(base_type::m_step >= -base_type::m_max_extent); } base_type::m_li.adjust_forward(); } //--------------------------------------------------------------------- bool step_hor() { int dist_start; int dist; int dy; int s1 = base_type::step_hor_base(m_di); dist_start = m_di.dist_start(); cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; cover_type* p1 = p0; *p1 = 0; if(dist_start <= 0) { *p1 = (cover_type)base_type::m_ren.cover(s1); } ++p1; dy = 1; while((dist = base_type::m_dist[dy] - s1) <= base_type::m_width) { dist_start -= m_di.dx_start(); *p1 = 0; if(dist_start <= 0) { *p1 = (cover_type)base_type::m_ren.cover(dist); } ++p1; ++dy; } dy = 1; dist_start = m_di.dist_start(); while((dist = base_type::m_dist[dy] + s1) <= base_type::m_width) { dist_start += m_di.dx_start(); *--p0 = 0; if(dist_start <= 0) { *p0 = (cover_type)base_type::m_ren.cover(dist); } ++dy; } base_type::m_ren.blend_solid_vspan(base_type::m_x, base_type::m_y - dy + 1, unsigned(p1 - p0), p0); return ++base_type::m_step < base_type::m_count; } //--------------------------------------------------------------------- bool step_ver() { int dist_start; int dist; int dx; int s1 = base_type::step_ver_base(m_di); cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; cover_type* p1 = p0; dist_start = m_di.dist_start(); *p1 = 0; if(dist_start <= 0) { *p1 = (cover_type)base_type::m_ren.cover(s1); } ++p1; dx = 1; while((dist = base_type::m_dist[dx] - s1) <= base_type::m_width) { dist_start += m_di.dy_start(); *p1 = 0; if(dist_start <= 0) { *p1 = (cover_type)base_type::m_ren.cover(dist); } ++p1; ++dx; } dx = 1; dist_start = m_di.dist_start(); while((dist = base_type::m_dist[dx] + s1) <= base_type::m_width) { dist_start -= m_di.dy_start(); *--p0 = 0; if(dist_start <= 0) { *p0 = (cover_type)base_type::m_ren.cover(dist); } ++dx; } base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, base_type::m_y, unsigned(p1 - p0), p0); return ++base_type::m_step < base_type::m_count; } private: line_interpolator_aa1(const line_interpolator_aa1&); const line_interpolator_aa1& operator = (const line_interpolator_aa1&); //--------------------------------------------------------------------- distance_interpolator2 m_di; }; //====================================================line_interpolator_aa2 template class line_interpolator_aa2 : public line_interpolator_aa_base { public: typedef Renderer renderer_type; typedef typename Renderer::color_type color_type; typedef line_interpolator_aa_base base_type; //--------------------------------------------------------------------- line_interpolator_aa2(renderer_type& ren, const line_parameters& lp, int ex, int ey) : line_interpolator_aa_base(ren, lp), m_di(lp.x1, lp.y1, lp.x2, lp.y2, ex, ey, lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask, 0) { base_type::m_li.adjust_forward(); base_type::m_step -= base_type::m_max_extent; } //--------------------------------------------------------------------- bool step_hor() { int dist_end; int dist; int dy; int s1 = base_type::step_hor_base(m_di); cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; cover_type* p1 = p0; dist_end = m_di.dist_end(); int npix = 0; *p1 = 0; if(dist_end > 0) { *p1 = (cover_type)base_type::m_ren.cover(s1); ++npix; } ++p1; dy = 1; while((dist = base_type::m_dist[dy] - s1) <= base_type::m_width) { dist_end -= m_di.dx_end(); *p1 = 0; if(dist_end > 0) { *p1 = (cover_type)base_type::m_ren.cover(dist); ++npix; } ++p1; ++dy; } dy = 1; dist_end = m_di.dist_end(); while((dist = base_type::m_dist[dy] + s1) <= base_type::m_width) { dist_end += m_di.dx_end(); *--p0 = 0; if(dist_end > 0) { *p0 = (cover_type)base_type::m_ren.cover(dist); ++npix; } ++dy; } base_type::m_ren.blend_solid_vspan(base_type::m_x, base_type::m_y - dy + 1, unsigned(p1 - p0), p0); return npix && ++base_type::m_step < base_type::m_count; } //--------------------------------------------------------------------- bool step_ver() { int dist_end; int dist; int dx; int s1 = base_type::step_ver_base(m_di); cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; cover_type* p1 = p0; dist_end = m_di.dist_end(); int npix = 0; *p1 = 0; if(dist_end > 0) { *p1 = (cover_type)base_type::m_ren.cover(s1); ++npix; } ++p1; dx = 1; while((dist = base_type::m_dist[dx] - s1) <= base_type::m_width) { dist_end += m_di.dy_end(); *p1 = 0; if(dist_end > 0) { *p1 = (cover_type)base_type::m_ren.cover(dist); ++npix; } ++p1; ++dx; } dx = 1; dist_end = m_di.dist_end(); while((dist = base_type::m_dist[dx] + s1) <= base_type::m_width) { dist_end -= m_di.dy_end(); *--p0 = 0; if(dist_end > 0) { *p0 = (cover_type)base_type::m_ren.cover(dist); ++npix; } ++dx; } base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, base_type::m_y, unsigned(p1 - p0), p0); return npix && ++base_type::m_step < base_type::m_count; } private: line_interpolator_aa2(const line_interpolator_aa2&); const line_interpolator_aa2& operator = (const line_interpolator_aa2&); //--------------------------------------------------------------------- distance_interpolator2 m_di; }; //====================================================line_interpolator_aa3 template class line_interpolator_aa3 : public line_interpolator_aa_base { public: typedef Renderer renderer_type; typedef typename Renderer::color_type color_type; typedef line_interpolator_aa_base base_type; //--------------------------------------------------------------------- line_interpolator_aa3(renderer_type& ren, const line_parameters& lp, int sx, int sy, int ex, int ey) : line_interpolator_aa_base(ren, lp), m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey, lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask) { int dist1_start; int dist2_start; int npix = 1; if(lp.vertical) { do { --base_type::m_li; base_type::m_y -= lp.inc; base_type::m_x = (base_type::m_lp->x1 + base_type::m_li.y()) >> line_subpixel_shift; if(lp.inc > 0) m_di.dec_y(base_type::m_x - base_type::m_old_x); else m_di.inc_y(base_type::m_x - base_type::m_old_x); base_type::m_old_x = base_type::m_x; dist1_start = dist2_start = m_di.dist_start(); int dx = 0; if(dist1_start < 0) ++npix; do { dist1_start += m_di.dy_start(); dist2_start -= m_di.dy_start(); if(dist1_start < 0) ++npix; if(dist2_start < 0) ++npix; ++dx; } while(base_type::m_dist[dx] <= base_type::m_width); if(npix == 0) break; npix = 0; } while(--base_type::m_step >= -base_type::m_max_extent); } else { do { --base_type::m_li; base_type::m_x -= lp.inc; base_type::m_y = (base_type::m_lp->y1 + base_type::m_li.y()) >> line_subpixel_shift; if(lp.inc > 0) m_di.dec_x(base_type::m_y - base_type::m_old_y); else m_di.inc_x(base_type::m_y - base_type::m_old_y); base_type::m_old_y = base_type::m_y; dist1_start = dist2_start = m_di.dist_start(); int dy = 0; if(dist1_start < 0) ++npix; do { dist1_start -= m_di.dx_start(); dist2_start += m_di.dx_start(); if(dist1_start < 0) ++npix; if(dist2_start < 0) ++npix; ++dy; } while(base_type::m_dist[dy] <= base_type::m_width); if(npix == 0) break; npix = 0; } while(--base_type::m_step >= -base_type::m_max_extent); } base_type::m_li.adjust_forward(); base_type::m_step -= base_type::m_max_extent; } //--------------------------------------------------------------------- bool step_hor() { int dist_start; int dist_end; int dist; int dy; int s1 = base_type::step_hor_base(m_di); cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; cover_type* p1 = p0; dist_start = m_di.dist_start(); dist_end = m_di.dist_end(); int npix = 0; *p1 = 0; if(dist_end > 0) { if(dist_start <= 0) { *p1 = (cover_type)base_type::m_ren.cover(s1); } ++npix; } ++p1; dy = 1; while((dist = base_type::m_dist[dy] - s1) <= base_type::m_width) { dist_start -= m_di.dx_start(); dist_end -= m_di.dx_end(); *p1 = 0; if(dist_end > 0 && dist_start <= 0) { *p1 = (cover_type)base_type::m_ren.cover(dist); ++npix; } ++p1; ++dy; } dy = 1; dist_start = m_di.dist_start(); dist_end = m_di.dist_end(); while((dist = base_type::m_dist[dy] + s1) <= base_type::m_width) { dist_start += m_di.dx_start(); dist_end += m_di.dx_end(); *--p0 = 0; if(dist_end > 0 && dist_start <= 0) { *p0 = (cover_type)base_type::m_ren.cover(dist); ++npix; } ++dy; } base_type::m_ren.blend_solid_vspan(base_type::m_x, base_type::m_y - dy + 1, unsigned(p1 - p0), p0); return npix && ++base_type::m_step < base_type::m_count; } //--------------------------------------------------------------------- bool step_ver() { int dist_start; int dist_end; int dist; int dx; int s1 = base_type::step_ver_base(m_di); cover_type* p0 = base_type::m_covers + base_type::max_half_width + 2; cover_type* p1 = p0; dist_start = m_di.dist_start(); dist_end = m_di.dist_end(); int npix = 0; *p1 = 0; if(dist_end > 0) { if(dist_start <= 0) { *p1 = (cover_type)base_type::m_ren.cover(s1); } ++npix; } ++p1; dx = 1; while((dist = base_type::m_dist[dx] - s1) <= base_type::m_width) { dist_start += m_di.dy_start(); dist_end += m_di.dy_end(); *p1 = 0; if(dist_end > 0 && dist_start <= 0) { *p1 = (cover_type)base_type::m_ren.cover(dist); ++npix; } ++p1; ++dx; } dx = 1; dist_start = m_di.dist_start(); dist_end = m_di.dist_end(); while((dist = base_type::m_dist[dx] + s1) <= base_type::m_width) { dist_start -= m_di.dy_start(); dist_end -= m_di.dy_end(); *--p0 = 0; if(dist_end > 0 && dist_start <= 0) { *p0 = (cover_type)base_type::m_ren.cover(dist); ++npix; } ++dx; } base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, base_type::m_y, unsigned(p1 - p0), p0); return npix && ++base_type::m_step < base_type::m_count; } private: line_interpolator_aa3(const line_interpolator_aa3&); const line_interpolator_aa3& operator = (const line_interpolator_aa3&); //--------------------------------------------------------------------- distance_interpolator3 m_di; }; //==========================================================line_profile_aa // // See Implementation agg_line_profile_aa.cpp // class line_profile_aa { public: //--------------------------------------------------------------------- typedef int8u value_type; enum subpixel_scale_e { subpixel_shift = line_subpixel_shift, subpixel_scale = 1 << subpixel_shift, subpixel_mask = subpixel_scale - 1 }; enum aa_scale_e { aa_shift = 8, aa_scale = 1 << aa_shift, aa_mask = aa_scale - 1 }; //--------------------------------------------------------------------- line_profile_aa() : m_subpixel_width(0), m_min_width(1.0), m_smoother_width(1.0) { int i; for(i = 0; i < aa_scale; i++) m_gamma[i] = (value_type)i; } //--------------------------------------------------------------------- template line_profile_aa(double w, const GammaF& gamma_function) : m_subpixel_width(0), m_min_width(1.0), m_smoother_width(1.0) { gamma(gamma_function); width(w); } //--------------------------------------------------------------------- void min_width(double w) { m_min_width = w; } void smoother_width(double w) { m_smoother_width = w; } //--------------------------------------------------------------------- template void gamma(const GammaF& gamma_function) { int i; for(i = 0; i < aa_scale; i++) { m_gamma[i] = value_type( uround(gamma_function(double(i) / aa_mask) * aa_mask)); } } void width(double w); unsigned profile_size() const { return m_profile.size(); } int subpixel_width() const { return m_subpixel_width; } //--------------------------------------------------------------------- double min_width() const { return m_min_width; } double smoother_width() const { return m_smoother_width; } //--------------------------------------------------------------------- value_type value(int dist) const { return m_profile[dist + subpixel_scale*2]; } private: line_profile_aa(const line_profile_aa&); const line_profile_aa& operator = (const line_profile_aa&); value_type* profile(double w); void set(double center_width, double smoother_width); //--------------------------------------------------------------------- pod_array m_profile; value_type m_gamma[aa_scale]; int m_subpixel_width; double m_min_width; double m_smoother_width; }; //======================================================renderer_outline_aa template class renderer_outline_aa { public: //--------------------------------------------------------------------- typedef BaseRenderer base_ren_type; typedef renderer_outline_aa self_type; typedef typename base_ren_type::color_type color_type; //--------------------------------------------------------------------- renderer_outline_aa(base_ren_type& ren, const line_profile_aa& prof) : m_ren(&ren), m_profile(&prof), m_clip_box(0,0,0,0), m_clipping(false) {} void attach(base_ren_type& ren) { m_ren = &ren; } //--------------------------------------------------------------------- void color(const color_type& c) { m_color = c; } const color_type& color() const { return m_color; } //--------------------------------------------------------------------- void profile(const line_profile_aa& prof) { m_profile = &prof; } const line_profile_aa& profile() const { return *m_profile; } const line_profile_aa& profile() { return *m_profile; } //--------------------------------------------------------------------- int subpixel_width() const { return m_profile->subpixel_width(); } //--------------------------------------------------------------------- void reset_clipping() { m_clipping = false; } void clip_box(double x1, double y1, double x2, double y2) { m_clip_box.x1 = line_coord_sat::conv(x1); m_clip_box.y1 = line_coord_sat::conv(y1); m_clip_box.x2 = line_coord_sat::conv(x2); m_clip_box.y2 = line_coord_sat::conv(y2); m_clipping = true; } //--------------------------------------------------------------------- int cover(int d) const { return m_profile->value(d); } //------------------------------------------------------------------------- void blend_solid_hspan(int x, int y, unsigned len, const cover_type* covers) { m_ren->blend_solid_hspan(x, y, len, m_color, covers); } //------------------------------------------------------------------------- void blend_solid_vspan(int x, int y, unsigned len, const cover_type* covers) { m_ren->blend_solid_vspan(x, y, len, m_color, covers); } //------------------------------------------------------------------------- static bool accurate_join_only() { return false; } //------------------------------------------------------------------------- template void semidot_hline(Cmp cmp, int xc1, int yc1, int xc2, int yc2, int x1, int y1, int x2) { cover_type covers[line_interpolator_aa_base::max_half_width * 2 + 4]; cover_type* p0 = covers; cover_type* p1 = covers; int x = x1 << line_subpixel_shift; int y = y1 << line_subpixel_shift; int w = subpixel_width(); distance_interpolator0 di(xc1, yc1, xc2, yc2, x, y); x += line_subpixel_scale/2; y += line_subpixel_scale/2; int x0 = x1; int dx = x - xc1; int dy = y - yc1; do { int d = int(fast_sqrt(dx*dx + dy*dy)); *p1 = 0; if(cmp(di.dist()) && d <= w) { *p1 = (cover_type)cover(d); } ++p1; dx += line_subpixel_scale; di.inc_x(); } while(++x1 <= x2); m_ren->blend_solid_hspan(x0, y1, unsigned(p1 - p0), color(), p0); } //------------------------------------------------------------------------- template void semidot(Cmp cmp, int xc1, int yc1, int xc2, int yc2) { if(m_clipping && clipping_flags(xc1, yc1, m_clip_box)) return; int r = ((subpixel_width() + line_subpixel_mask) >> line_subpixel_shift); if(r < 1) r = 1; ellipse_bresenham_interpolator ei(r, r); int dx = 0; int dy = -r; int dy0 = dy; int dx0 = dx; int x = xc1 >> line_subpixel_shift; int y = yc1 >> line_subpixel_shift; do { dx += ei.dx(); dy += ei.dy(); if(dy != dy0) { semidot_hline(cmp, xc1, yc1, xc2, yc2, x-dx0, y+dy0, x+dx0); semidot_hline(cmp, xc1, yc1, xc2, yc2, x-dx0, y-dy0, x+dx0); } dx0 = dx; dy0 = dy; ++ei; } while(dy < 0); semidot_hline(cmp, xc1, yc1, xc2, yc2, x-dx0, y+dy0, x+dx0); } //------------------------------------------------------------------------- void pie_hline(int xc, int yc, int xp1, int yp1, int xp2, int yp2, int xh1, int yh1, int xh2) { if(m_clipping && clipping_flags(xc, yc, m_clip_box)) return; cover_type covers[line_interpolator_aa_base::max_half_width * 2 + 4]; cover_type* p0 = covers; cover_type* p1 = covers; int x = xh1 << line_subpixel_shift; int y = yh1 << line_subpixel_shift; int w = subpixel_width(); distance_interpolator00 di(xc, yc, xp1, yp1, xp2, yp2, x, y); x += line_subpixel_scale/2; y += line_subpixel_scale/2; int xh0 = xh1; int dx = x - xc; int dy = y - yc; do { int d = int(fast_sqrt(dx*dx + dy*dy)); *p1 = 0; if(di.dist1() <= 0 && di.dist2() > 0 && d <= w) { *p1 = (cover_type)cover(d); } ++p1; dx += line_subpixel_scale; di.inc_x(); } while(++xh1 <= xh2); m_ren->blend_solid_hspan(xh0, yh1, unsigned(p1 - p0), color(), p0); } //------------------------------------------------------------------------- void pie(int xc, int yc, int x1, int y1, int x2, int y2) { int r = ((subpixel_width() + line_subpixel_mask) >> line_subpixel_shift); if(r < 1) r = 1; ellipse_bresenham_interpolator ei(r, r); int dx = 0; int dy = -r; int dy0 = dy; int dx0 = dx; int x = xc >> line_subpixel_shift; int y = yc >> line_subpixel_shift; do { dx += ei.dx(); dy += ei.dy(); if(dy != dy0) { pie_hline(xc, yc, x1, y1, x2, y2, x-dx0, y+dy0, x+dx0); pie_hline(xc, yc, x1, y1, x2, y2, x-dx0, y-dy0, x+dx0); } dx0 = dx; dy0 = dy; ++ei; } while(dy < 0); pie_hline(xc, yc, x1, y1, x2, y2, x-dx0, y+dy0, x+dx0); } //------------------------------------------------------------------------- void line0_no_clip(const line_parameters& lp) { if(lp.len > line_max_length) { line_parameters lp1, lp2; lp.divide(lp1, lp2); line0_no_clip(lp1); line0_no_clip(lp2); return; } line_interpolator_aa0 li(*this, lp); if(li.count()) { if(li.vertical()) { while(li.step_ver()); } else { while(li.step_hor()); } } } //------------------------------------------------------------------------- void line0(const line_parameters& lp) { if(m_clipping) { int x1 = lp.x1; int y1 = lp.y1; int x2 = lp.x2; int y2 = lp.y2; unsigned flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box); if((flags & 4) == 0) { if(flags) { line_parameters lp2(x1, y1, x2, y2, uround(calc_distance(x1, y1, x2, y2))); line0_no_clip(lp2); } else { line0_no_clip(lp); } } } else { line0_no_clip(lp); } } //------------------------------------------------------------------------- void line1_no_clip(const line_parameters& lp, int sx, int sy) { if(lp.len > line_max_length) { line_parameters lp1, lp2; lp.divide(lp1, lp2); line1_no_clip(lp1, (lp.x1 + sx) >> 1, (lp.y1 + sy) >> 1); line1_no_clip(lp2, lp1.x2 + (lp1.y2 - lp1.y1), lp1.y2 - (lp1.x2 - lp1.x1)); return; } fix_degenerate_bisectrix_start(lp, &sx, &sy); line_interpolator_aa1 li(*this, lp, sx, sy); if(li.vertical()) { while(li.step_ver()); } else { while(li.step_hor()); } } //------------------------------------------------------------------------- void line1(const line_parameters& lp, int sx, int sy) { if(m_clipping) { int x1 = lp.x1; int y1 = lp.y1; int x2 = lp.x2; int y2 = lp.y2; unsigned flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box); if((flags & 4) == 0) { if(flags) { line_parameters lp2(x1, y1, x2, y2, uround(calc_distance(x1, y1, x2, y2))); if(flags & 1) { sx = x1 + (y2 - y1); sy = y1 - (x2 - x1); } else { while(abs(sx - lp.x1) + abs(sy - lp.y1) > lp2.len) { sx = (lp.x1 + sx) >> 1; sy = (lp.y1 + sy) >> 1; } } line1_no_clip(lp2, sx, sy); } else { line1_no_clip(lp, sx, sy); } } } else { line1_no_clip(lp, sx, sy); } } //------------------------------------------------------------------------- void line2_no_clip(const line_parameters& lp, int ex, int ey) { if(lp.len > line_max_length) { line_parameters lp1, lp2; lp.divide(lp1, lp2); line2_no_clip(lp1, lp1.x2 + (lp1.y2 - lp1.y1), lp1.y2 - (lp1.x2 - lp1.x1)); line2_no_clip(lp2, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1); return; } fix_degenerate_bisectrix_end(lp, &ex, &ey); line_interpolator_aa2 li(*this, lp, ex, ey); if(li.vertical()) { while(li.step_ver()); } else { while(li.step_hor()); } } //------------------------------------------------------------------------- void line2(const line_parameters& lp, int ex, int ey) { if(m_clipping) { int x1 = lp.x1; int y1 = lp.y1; int x2 = lp.x2; int y2 = lp.y2; unsigned flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box); if((flags & 4) == 0) { if(flags) { line_parameters lp2(x1, y1, x2, y2, uround(calc_distance(x1, y1, x2, y2))); if(flags & 2) { ex = x2 + (y2 - y1); ey = y2 - (x2 - x1); } else { while(abs(ex - lp.x2) + abs(ey - lp.y2) > lp2.len) { ex = (lp.x2 + ex) >> 1; ey = (lp.y2 + ey) >> 1; } } line2_no_clip(lp2, ex, ey); } else { line2_no_clip(lp, ex, ey); } } } else { line2_no_clip(lp, ex, ey); } } //------------------------------------------------------------------------- void line3_no_clip(const line_parameters& lp, int sx, int sy, int ex, int ey) { if(lp.len > line_max_length) { line_parameters lp1, lp2; lp.divide(lp1, lp2); int mx = lp1.x2 + (lp1.y2 - lp1.y1); int my = lp1.y2 - (lp1.x2 - lp1.x1); line3_no_clip(lp1, (lp.x1 + sx) >> 1, (lp.y1 + sy) >> 1, mx, my); line3_no_clip(lp2, mx, my, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1); return; } fix_degenerate_bisectrix_start(lp, &sx, &sy); fix_degenerate_bisectrix_end(lp, &ex, &ey); line_interpolator_aa3 li(*this, lp, sx, sy, ex, ey); if(li.vertical()) { while(li.step_ver()); } else { while(li.step_hor()); } } //------------------------------------------------------------------------- void line3(const line_parameters& lp, int sx, int sy, int ex, int ey) { if(m_clipping) { int x1 = lp.x1; int y1 = lp.y1; int x2 = lp.x2; int y2 = lp.y2; unsigned flags = clip_line_segment(&x1, &y1, &x2, &y2, m_clip_box); if((flags & 4) == 0) { if(flags) { line_parameters lp2(x1, y1, x2, y2, uround(calc_distance(x1, y1, x2, y2))); if(flags & 1) { sx = x1 + (y2 - y1); sy = y1 - (x2 - x1); } else { while(abs(sx - lp.x1) + abs(sy - lp.y1) > lp2.len) { sx = (lp.x1 + sx) >> 1; sy = (lp.y1 + sy) >> 1; } } if(flags & 2) { ex = x2 + (y2 - y1); ey = y2 - (x2 - x1); } else { while(abs(ex - lp.x2) + abs(ey - lp.y2) > lp2.len) { ex = (lp.x2 + ex) >> 1; ey = (lp.y2 + ey) >> 1; } } line3_no_clip(lp2, sx, sy, ex, ey); } else { line3_no_clip(lp, sx, sy, ex, ey); } } } else { line3_no_clip(lp, sx, sy, ex, ey); } } private: base_ren_type* m_ren; const line_profile_aa* m_profile; color_type m_color; rect_i m_clip_box; bool m_clipping; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_rasterizer_sl_clip.h0000644000175000017500000003171212516137326025666 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_RASTERIZER_SL_CLIP_INCLUDED #define AGG_RASTERIZER_SL_CLIP_INCLUDED #include "agg_clip_liang_barsky.h" namespace agg24 { //--------------------------------------------------------poly_max_coord_e enum poly_max_coord_e { poly_max_coord = (1 << 30) - 1 //----poly_max_coord }; //------------------------------------------------------------ras_conv_int struct ras_conv_int { typedef int coord_type; static AGG_INLINE int mul_div(double a, double b, double c) { return iround(a * b / c); } static int xi(int v) { return v; } static int yi(int v) { return v; } static int upscale(double v) { return iround(v * poly_subpixel_scale); } static int downscale(int v) { return v; } }; //--------------------------------------------------------ras_conv_int_sat struct ras_conv_int_sat { typedef int coord_type; static AGG_INLINE int mul_div(double a, double b, double c) { return saturation::iround(a * b / c); } static int xi(int v) { return v; } static int yi(int v) { return v; } static int upscale(double v) { return saturation::iround(v * poly_subpixel_scale); } static int downscale(int v) { return v; } }; //---------------------------------------------------------ras_conv_int_3x struct ras_conv_int_3x { typedef int coord_type; static AGG_INLINE int mul_div(double a, double b, double c) { return iround(a * b / c); } static int xi(int v) { return v * 3; } static int yi(int v) { return v; } static int upscale(double v) { return iround(v * poly_subpixel_scale); } static int downscale(int v) { return v; } }; //-----------------------------------------------------------ras_conv_dbl struct ras_conv_dbl { typedef double coord_type; static AGG_INLINE double mul_div(double a, double b, double c) { return a * b / c; } static int xi(double v) { return iround(v * poly_subpixel_scale); } static int yi(double v) { return iround(v * poly_subpixel_scale); } static double upscale(double v) { return v; } static double downscale(int v) { return v / double(poly_subpixel_scale); } }; //--------------------------------------------------------ras_conv_dbl_3x struct ras_conv_dbl_3x { typedef double coord_type; static AGG_INLINE double mul_div(double a, double b, double c) { return a * b / c; } static int xi(double v) { return iround(v * poly_subpixel_scale * 3); } static int yi(double v) { return iround(v * poly_subpixel_scale); } static double upscale(double v) { return v; } static double downscale(int v) { return v / double(poly_subpixel_scale); } }; //------------------------------------------------------rasterizer_sl_clip template class rasterizer_sl_clip { public: typedef Conv conv_type; typedef typename Conv::coord_type coord_type; typedef rect_base rect_type; //-------------------------------------------------------------------- rasterizer_sl_clip() : m_clip_box(0,0,0,0), m_x1(0), m_y1(0), m_f1(0), m_clipping(false) {} //-------------------------------------------------------------------- void reset_clipping() { m_clipping = false; } //-------------------------------------------------------------------- void clip_box(coord_type x1, coord_type y1, coord_type x2, coord_type y2) { m_clip_box = rect_type(x1, y1, x2, y2); m_clip_box.normalize(); m_clipping = true; } //-------------------------------------------------------------------- void move_to(coord_type x1, coord_type y1) { m_x1 = x1; m_y1 = y1; if(m_clipping) m_f1 = clipping_flags(x1, y1, m_clip_box); } private: //------------------------------------------------------------------------ template AGG_INLINE void line_clip_y(Rasterizer& ras, coord_type x1, coord_type y1, coord_type x2, coord_type y2, unsigned f1, unsigned f2) const { f1 &= 10; f2 &= 10; if((f1 | f2) == 0) { // Fully visible ras.line(Conv::xi(x1), Conv::yi(y1), Conv::xi(x2), Conv::yi(y2)); } else { if(f1 == f2) { // Invisible by Y return; } coord_type tx1 = x1; coord_type ty1 = y1; coord_type tx2 = x2; coord_type ty2 = y2; if(f1 & 8) // y1 < clip.y1 { tx1 = x1 + Conv::mul_div(m_clip_box.y1-y1, x2-x1, y2-y1); ty1 = m_clip_box.y1; } if(f1 & 2) // y1 > clip.y2 { tx1 = x1 + Conv::mul_div(m_clip_box.y2-y1, x2-x1, y2-y1); ty1 = m_clip_box.y2; } if(f2 & 8) // y2 < clip.y1 { tx2 = x1 + Conv::mul_div(m_clip_box.y1-y1, x2-x1, y2-y1); ty2 = m_clip_box.y1; } if(f2 & 2) // y2 > clip.y2 { tx2 = x1 + Conv::mul_div(m_clip_box.y2-y1, x2-x1, y2-y1); ty2 = m_clip_box.y2; } ras.line(Conv::xi(tx1), Conv::yi(ty1), Conv::xi(tx2), Conv::yi(ty2)); } } public: //-------------------------------------------------------------------- template void line_to(Rasterizer& ras, coord_type x2, coord_type y2) { if(m_clipping) { unsigned f2 = clipping_flags(x2, y2, m_clip_box); if((m_f1 & 10) == (f2 & 10) && (m_f1 & 10) != 0) { // Invisible by Y m_x1 = x2; m_y1 = y2; m_f1 = f2; return; } coord_type x1 = m_x1; coord_type y1 = m_y1; unsigned f1 = m_f1; coord_type y3, y4; unsigned f3, f4; switch(((f1 & 5) << 1) | (f2 & 5)) { case 0: // Visible by X line_clip_y(ras, x1, y1, x2, y2, f1, f2); break; case 1: // x2 > clip.x2 y3 = y1 + Conv::mul_div(m_clip_box.x2-x1, y2-y1, x2-x1); f3 = clipping_flags_y(y3, m_clip_box); line_clip_y(ras, x1, y1, m_clip_box.x2, y3, f1, f3); line_clip_y(ras, m_clip_box.x2, y3, m_clip_box.x2, y2, f3, f2); break; case 2: // x1 > clip.x2 y3 = y1 + Conv::mul_div(m_clip_box.x2-x1, y2-y1, x2-x1); f3 = clipping_flags_y(y3, m_clip_box); line_clip_y(ras, m_clip_box.x2, y1, m_clip_box.x2, y3, f1, f3); line_clip_y(ras, m_clip_box.x2, y3, x2, y2, f3, f2); break; case 3: // x1 > clip.x2 && x2 > clip.x2 line_clip_y(ras, m_clip_box.x2, y1, m_clip_box.x2, y2, f1, f2); break; case 4: // x2 < clip.x1 y3 = y1 + Conv::mul_div(m_clip_box.x1-x1, y2-y1, x2-x1); f3 = clipping_flags_y(y3, m_clip_box); line_clip_y(ras, x1, y1, m_clip_box.x1, y3, f1, f3); line_clip_y(ras, m_clip_box.x1, y3, m_clip_box.x1, y2, f3, f2); break; case 6: // x1 > clip.x2 && x2 < clip.x1 y3 = y1 + Conv::mul_div(m_clip_box.x2-x1, y2-y1, x2-x1); y4 = y1 + Conv::mul_div(m_clip_box.x1-x1, y2-y1, x2-x1); f3 = clipping_flags_y(y3, m_clip_box); f4 = clipping_flags_y(y4, m_clip_box); line_clip_y(ras, m_clip_box.x2, y1, m_clip_box.x2, y3, f1, f3); line_clip_y(ras, m_clip_box.x2, y3, m_clip_box.x1, y4, f3, f4); line_clip_y(ras, m_clip_box.x1, y4, m_clip_box.x1, y2, f4, f2); break; case 8: // x1 < clip.x1 y3 = y1 + Conv::mul_div(m_clip_box.x1-x1, y2-y1, x2-x1); f3 = clipping_flags_y(y3, m_clip_box); line_clip_y(ras, m_clip_box.x1, y1, m_clip_box.x1, y3, f1, f3); line_clip_y(ras, m_clip_box.x1, y3, x2, y2, f3, f2); break; case 9: // x1 < clip.x1 && x2 > clip.x2 y3 = y1 + Conv::mul_div(m_clip_box.x1-x1, y2-y1, x2-x1); y4 = y1 + Conv::mul_div(m_clip_box.x2-x1, y2-y1, x2-x1); f3 = clipping_flags_y(y3, m_clip_box); f4 = clipping_flags_y(y4, m_clip_box); line_clip_y(ras, m_clip_box.x1, y1, m_clip_box.x1, y3, f1, f3); line_clip_y(ras, m_clip_box.x1, y3, m_clip_box.x2, y4, f3, f4); line_clip_y(ras, m_clip_box.x2, y4, m_clip_box.x2, y2, f4, f2); break; case 12: // x1 < clip.x1 && x2 < clip.x1 line_clip_y(ras, m_clip_box.x1, y1, m_clip_box.x1, y2, f1, f2); break; } m_f1 = f2; } else { ras.line(Conv::xi(m_x1), Conv::yi(m_y1), Conv::xi(x2), Conv::yi(y2)); } m_x1 = x2; m_y1 = y2; } private: rect_type m_clip_box; coord_type m_x1; coord_type m_y1; unsigned m_f1; bool m_clipping; }; //---------------------------------------------------rasterizer_sl_no_clip class rasterizer_sl_no_clip { public: typedef ras_conv_int conv_type; typedef int coord_type; rasterizer_sl_no_clip() : m_x1(0), m_y1(0) {} void reset_clipping() {} void clip_box(coord_type x1, coord_type y1, coord_type x2, coord_type y2) {} void move_to(coord_type x1, coord_type y1) { m_x1 = x1; m_y1 = y1; } template void line_to(Rasterizer& ras, coord_type x2, coord_type y2) { ras.line(m_x1, m_y1, x2, y2); m_x1 = x2; m_y1 = y2; } private: int m_x1, m_y1; }; // -----rasterizer_sl_clip_int // -----rasterizer_sl_clip_int_sat // -----rasterizer_sl_clip_int_3x // -----rasterizer_sl_clip_dbl // -----rasterizer_sl_clip_dbl_3x //------------------------------------------------------------------------ typedef rasterizer_sl_clip rasterizer_sl_clip_int; typedef rasterizer_sl_clip rasterizer_sl_clip_int_sat; typedef rasterizer_sl_clip rasterizer_sl_clip_int_3x; typedef rasterizer_sl_clip rasterizer_sl_clip_dbl; typedef rasterizer_sl_clip rasterizer_sl_clip_dbl_3x; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_shorten_path.h0000644000175000017500000000337012516137326025511 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_CONV_SHORTEN_PATH_INCLUDED #define AGG_CONV_SHORTEN_PATH_INCLUDED #include "agg_basics.h" #include "agg_conv_adaptor_vcgen.h" #include "agg_vcgen_vertex_sequence.h" namespace agg24 { //=======================================================conv_shorten_path template class conv_shorten_path : public conv_adaptor_vcgen { public: typedef conv_adaptor_vcgen base_type; conv_shorten_path(VertexSource& vs) : conv_adaptor_vcgen(vs) { } void shorten(double s) { base_type::generator().shorten(s); } double shorten() const { return base_type::generator().shorten(); } private: conv_shorten_path(const conv_shorten_path&); const conv_shorten_path& operator = (const conv_shorten_path&); }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_rasterizer_compound_aa.h0000644000175000017500000004740612516137326026535 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // // The author gratefully acknowleges the support of David Turner, // Robert Wilhelm, and Werner Lemberg - the authors of the FreeType // libray - in producing this work. See http://www.freetype.org for details. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for 32-bit screen coordinates has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_RASTERIZER_COMPOUND_AA_INCLUDED #define AGG_RASTERIZER_COMPOUND_AA_INCLUDED #include "agg_rasterizer_cells_aa.h" #include "agg_rasterizer_sl_clip.h" namespace agg24 { //-----------------------------------------------------------cell_style_aa // A pixel cell. There're no constructors defined and it was done // intentionally in order to avoid extra overhead when allocating an // array of cells. struct cell_style_aa { int x; int y; int cover; int area; int16 left, right; void initial() { x = 0x7FFFFFFF; y = 0x7FFFFFFF; cover = 0; area = 0; left = -1; right = -1; } void style(const cell_style_aa& c) { left = c.left; right = c.right; } int not_equal(int ex, int ey, const cell_style_aa& c) const { return (ex - x) | (ey - y) | (left - c.left) | (right - c.right); } }; //==================================================rasterizer_compound_aa template class rasterizer_compound_aa { struct style_info { unsigned start_cell; unsigned num_cells; int last_x; }; struct cell_info { int x, area, cover; }; public: typedef Clip clip_type; typedef typename Clip::conv_type conv_type; enum aa_scale_e { aa_shift = 8, aa_scale = 1 << aa_shift, aa_mask = aa_scale - 1, aa_scale2 = aa_scale * 2, aa_mask2 = aa_scale2 - 1 }; //-------------------------------------------------------------------- rasterizer_compound_aa() : m_outline(), m_clipper(), m_filling_rule(fill_non_zero), m_styles(), // Active Styles m_ast(), // Active Style Table (unique values) m_asm(), // Active Style Mask m_cells(), m_min_style(0x7FFFFFFF), m_max_style(-0x7FFFFFFF), m_scan_y(0x7FFFFFFF) {} //-------------------------------------------------------------------- void reset(); void reset_clipping(); void clip_box(double x1, double y1, double x2, double y2); void filling_rule(filling_rule_e filling_rule); //-------------------------------------------------------------------- void styles(int left, int right); void move_to(int x, int y); void line_to(int x, int y); void move_to_d(double x, double y); void line_to_d(double x, double y); void add_vertex(double x, double y, unsigned cmd); void edge(int x1, int y1, int x2, int y2); void edge_d(double x1, double y1, double x2, double y2); //------------------------------------------------------------------- template void add_path(VertexSource& vs, unsigned path_id=0) { double x; double y; unsigned cmd; vs.rewind(path_id); if(m_outline.sorted()) reset(); while(!is_stop(cmd = vs.vertex(&x, &y))) { add_vertex(x, y, cmd); } } //-------------------------------------------------------------------- int min_x() const { return m_outline.min_x(); } int min_y() const { return m_outline.min_y(); } int max_x() const { return m_outline.max_x(); } int max_y() const { return m_outline.max_y(); } int min_style() const { return m_min_style; } int max_style() const { return m_max_style; } //-------------------------------------------------------------------- void sort(); bool rewind_scanlines(); unsigned sweep_styles(); unsigned style(unsigned style_idx) const; //-------------------------------------------------------------------- bool navigate_scanline(int y); bool hit_test(int tx, int ty); //-------------------------------------------------------------------- AGG_INLINE unsigned calculate_alpha(int area) const { int cover = area >> (poly_subpixel_shift*2 + 1 - aa_shift); if(cover < 0) cover = -cover; if(m_filling_rule == fill_even_odd) { cover &= aa_mask2; if(cover > aa_scale) { cover = aa_scale2 - cover; } } if(cover > aa_mask) cover = aa_mask; return cover; } //-------------------------------------------------------------------- // Sweeps one scanline with one style index. The style ID can be // determined by calling style(). template bool sweep_scanline(Scanline& sl, int style_idx) { int scan_y = m_scan_y - 1; if(scan_y > m_outline.max_y()) return false; sl.reset_spans(); if(style_idx < 0) style_idx = 0; else style_idx++; const style_info& st = m_styles[m_ast[style_idx]]; unsigned num_cells = st.num_cells; cell_info* cell = &m_cells[st.start_cell]; int cover = 0; while(num_cells--) { unsigned alpha; int x = cell->x; int area = cell->area; cover += cell->cover; ++cell; if(area) { alpha = calculate_alpha((cover << (poly_subpixel_shift + 1)) - area); sl.add_cell(x, alpha); x++; } if(num_cells && cell->x > x) { alpha = calculate_alpha(cover << (poly_subpixel_shift + 1)); if(alpha) { sl.add_span(x, cell->x - x, alpha); } } } if(sl.num_spans() == 0) return false; sl.finalize(scan_y); return true; } private: void add_style(int style_id); //-------------------------------------------------------------------- // Disable copying rasterizer_compound_aa(const rasterizer_compound_aa&); const rasterizer_compound_aa& operator = (const rasterizer_compound_aa&); private: rasterizer_cells_aa m_outline; clip_type m_clipper; filling_rule_e m_filling_rule; pod_vector m_styles; // Active Styles pod_vector m_ast; // Active Style Table (unique values) pod_vector m_asm; // Active Style Mask pod_vector m_cells; int m_min_style; int m_max_style; int m_scan_y; }; //------------------------------------------------------------------------ template void rasterizer_compound_aa::reset() { m_outline.reset(); m_min_style = 0x7FFFFFFF; m_max_style = -0x7FFFFFFF; m_scan_y = 0x7FFFFFFF; } //------------------------------------------------------------------------ template void rasterizer_compound_aa::filling_rule(filling_rule_e filling_rule) { m_filling_rule = filling_rule; } //------------------------------------------------------------------------ template void rasterizer_compound_aa::clip_box(double x1, double y1, double x2, double y2) { reset(); m_clipper.clip_box(conv_type::upscale(x1), conv_type::upscale(y1), conv_type::upscale(x2), conv_type::upscale(y2)); } //------------------------------------------------------------------------ template void rasterizer_compound_aa::reset_clipping() { reset(); m_clipper.reset_clipping(); } //------------------------------------------------------------------------ template void rasterizer_compound_aa::styles(int left, int right) { cell_style_aa cell; cell.initial(); cell.left = (int16)left; cell.right = (int16)right; m_outline.style(cell); if(left >= 0 && left < m_min_style) m_min_style = left; if(left >= 0 && left > m_max_style) m_max_style = left; if(right >= 0 && right < m_min_style) m_min_style = right; if(right >= 0 && right > m_max_style) m_max_style = right; } //------------------------------------------------------------------------ template void rasterizer_compound_aa::move_to(int x, int y) { if(m_outline.sorted()) reset(); m_clipper.move_to(conv_type::downscale(x), conv_type::downscale(y)); } //------------------------------------------------------------------------ template void rasterizer_compound_aa::line_to(int x, int y) { m_clipper.line_to(m_outline, conv_type::downscale(x), conv_type::downscale(y)); } //------------------------------------------------------------------------ template void rasterizer_compound_aa::move_to_d(double x, double y) { if(m_outline.sorted()) reset(); m_clipper.move_to(conv_type::upscale(x), conv_type::upscale(y)); } //------------------------------------------------------------------------ template void rasterizer_compound_aa::line_to_d(double x, double y) { m_clipper.line_to(m_outline, conv_type::upscale(x), conv_type::upscale(y)); } //------------------------------------------------------------------------ template void rasterizer_compound_aa::add_vertex(double x, double y, unsigned cmd) { if(is_move_to(cmd)) { move_to_d(x, y); } else { if(is_vertex(cmd)) { line_to_d(x, y); } } } //------------------------------------------------------------------------ template void rasterizer_compound_aa::edge(int x1, int y1, int x2, int y2) { if(m_outline.sorted()) reset(); m_clipper.move_to(conv_type::downscale(x1), conv_type::downscale(y1)); m_clipper.line_to(m_outline, conv_type::downscale(x2), conv_type::downscale(y2)); } //------------------------------------------------------------------------ template void rasterizer_compound_aa::edge_d(double x1, double y1, double x2, double y2) { if(m_outline.sorted()) reset(); m_clipper.move_to(conv_type::upscale(x1), conv_type::upscale(y1)); m_clipper.line_to(m_outline, conv_type::upscale(x2), conv_type::upscale(y2)); } //------------------------------------------------------------------------ template AGG_INLINE void rasterizer_compound_aa::sort() { m_outline.sort_cells(); } //------------------------------------------------------------------------ template AGG_INLINE bool rasterizer_compound_aa::rewind_scanlines() { m_outline.sort_cells(); if(m_outline.total_cells() == 0) { return false; } if(m_max_style < m_min_style) { return false; } m_scan_y = m_outline.min_y(); m_styles.allocate(m_max_style - m_min_style + 2, 128); return true; } //------------------------------------------------------------------------ template AGG_INLINE void rasterizer_compound_aa::add_style(int style_id) { if(style_id < 0) style_id = 0; else style_id -= m_min_style - 1; unsigned nbyte = style_id >> 3; unsigned mask = 1 << (style_id & 7); style_info* style = &m_styles[style_id]; if((m_asm[nbyte] & mask) == 0) { m_ast.add(style_id); m_asm[nbyte] |= mask; style->start_cell = 0; style->num_cells = 0; style->last_x = -0x7FFFFFFF; } ++style->start_cell; } //------------------------------------------------------------------------ // Returns the number of styles template unsigned rasterizer_compound_aa::sweep_styles() { for(;;) { if(m_scan_y > m_outline.max_y()) return 0; unsigned num_cells = m_outline.scanline_num_cells(m_scan_y); const cell_style_aa* const* cells = m_outline.scanline_cells(m_scan_y); unsigned num_styles = m_max_style - m_min_style + 2; const cell_style_aa* curr_cell; unsigned style_id; style_info* style; cell_info* cell; m_cells.allocate(num_cells * 2, 256); // Each cell can have two styles m_ast.capacity(num_styles, 64); m_asm.allocate((num_styles + 7) >> 3, 8); m_asm.zero(); // Pre-add zero (for no-fill style, that is, -1). // We need that to ensure that the "-1 style" would go first. m_asm[0] |= 1; m_ast.add(0); style = &m_styles[0]; style->start_cell = 0; style->num_cells = 0; style->last_x = -0x7FFFFFFF; while(num_cells--) { curr_cell = *cells++; add_style(curr_cell->left); add_style(curr_cell->right); } // Convert the Y-histogram into the array of starting indexes unsigned i; unsigned start_cell = 0; for(i = 0; i < m_ast.size(); i++) { style_info& st = m_styles[m_ast[i]]; unsigned v = st.start_cell; st.start_cell = start_cell; start_cell += v; } cells = m_outline.scanline_cells(m_scan_y); num_cells = m_outline.scanline_num_cells(m_scan_y); while(num_cells--) { curr_cell = *cells++; style_id = (curr_cell->left < 0) ? 0 : curr_cell->left - m_min_style + 1; style = &m_styles[style_id]; if(curr_cell->x == style->last_x) { cell = &m_cells[style->start_cell + style->num_cells - 1]; cell->area += curr_cell->area; cell->cover += curr_cell->cover; } else { cell = &m_cells[style->start_cell + style->num_cells]; cell->x = curr_cell->x; cell->area = curr_cell->area; cell->cover = curr_cell->cover; style->last_x = curr_cell->x; style->num_cells++; } style_id = (curr_cell->right < 0) ? 0 : curr_cell->right - m_min_style + 1; style = &m_styles[style_id]; if(curr_cell->x == style->last_x) { cell = &m_cells[style->start_cell + style->num_cells - 1]; cell->area -= curr_cell->area; cell->cover -= curr_cell->cover; } else { cell = &m_cells[style->start_cell + style->num_cells]; cell->x = curr_cell->x; cell->area = -curr_cell->area; cell->cover = -curr_cell->cover; style->last_x = curr_cell->x; style->num_cells++; } } if(m_ast.size() > 1) break; ++m_scan_y; } ++m_scan_y; return m_ast.size() - 1; } //------------------------------------------------------------------------ // Returns style ID depending of the existing style index template AGG_INLINE unsigned rasterizer_compound_aa::style(unsigned style_idx) const { return m_ast[style_idx + 1] + m_min_style - 1; } //------------------------------------------------------------------------ template AGG_INLINE bool rasterizer_compound_aa::navigate_scanline(int y) { m_outline.sort_cells(); if(m_outline.total_cells() == 0) { return false; } if(m_max_style < m_min_style) { return false; } if(y < m_outline.min_y() || y > m_outline.max_y()) { return false; } m_scan_y = y; m_styles.allocate(m_max_style - m_min_style + 2, 128); return true; } //------------------------------------------------------------------------ template bool rasterizer_compound_aa::hit_test(int tx, int ty) { if(!navigate_scanline(ty)) { return false; } unsigned num_styles = sweep_styles(); if(num_styles <= 0) { return false; } scanline_hit_test sl(tx); sweep_scanline(sl, -1); return sl.hit(); } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_scanline_storage_bin.h0000644000175000017500000004460012516137326026137 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for 32-bit screen coordinates has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_SCANLINE_STORAGE_BIN_INCLUDED #define AGG_SCANLINE_STORAGE_BIN_INCLUDED #include #include #include #include "agg_array.h" namespace agg24 { //-----------------------------------------------scanline_storage_bin class scanline_storage_bin { public: //--------------------------------------------------------------- struct span_data { int32 x; int32 len; }; //--------------------------------------------------------------- struct scanline_data { int y; unsigned num_spans; unsigned start_span; }; //--------------------------------------------------------------- class embedded_scanline { public: //----------------------------------------------------------- class const_iterator { public: const_iterator() : m_storage(0) {} const_iterator(const embedded_scanline& sl) : m_storage(sl.m_storage), m_span_idx(sl.m_scanline.start_span) { m_span = m_storage->span_by_index(m_span_idx); } const span_data& operator*() const { return m_span; } const span_data* operator->() const { return &m_span; } void operator ++ () { ++m_span_idx; m_span = m_storage->span_by_index(m_span_idx); } private: const scanline_storage_bin* m_storage; unsigned m_span_idx; span_data m_span; }; friend class const_iterator; //----------------------------------------------------------- embedded_scanline(const scanline_storage_bin& storage) : m_storage(&storage) { setup(0); } //----------------------------------------------------------- void reset(int, int) {} unsigned num_spans() const { return m_scanline.num_spans; } int y() const { return m_scanline.y; } const_iterator begin() const { return const_iterator(*this); } //----------------------------------------------------------- void setup(unsigned scanline_idx) { m_scanline_idx = scanline_idx; m_scanline = m_storage->scanline_by_index(m_scanline_idx); } private: const scanline_storage_bin* m_storage; scanline_data m_scanline; unsigned m_scanline_idx; }; //--------------------------------------------------------------- scanline_storage_bin() : m_spans(256-2), // Block increment size m_scanlines(), m_min_x( 0x7FFFFFFF), m_min_y( 0x7FFFFFFF), m_max_x(-0x7FFFFFFF), m_max_y(-0x7FFFFFFF), m_cur_scanline(0) { m_fake_scanline.y = 0; m_fake_scanline.num_spans = 0; m_fake_scanline.start_span = 0; m_fake_span.x = 0; m_fake_span.len = 0; } // Renderer Interface //--------------------------------------------------------------- void prepare() { m_scanlines.remove_all(); m_spans.remove_all(); m_min_x = 0x7FFFFFFF; m_min_y = 0x7FFFFFFF; m_max_x = -0x7FFFFFFF; m_max_y = -0x7FFFFFFF; m_cur_scanline = 0; } //--------------------------------------------------------------- template void render(const Scanline& sl) { scanline_data sl_this; int y = sl.y(); if(y < m_min_y) m_min_y = y; if(y > m_max_y) m_max_y = y; sl_this.y = y; sl_this.num_spans = sl.num_spans(); sl_this.start_span = m_spans.size(); typename Scanline::const_iterator span_iterator = sl.begin(); unsigned num_spans = sl_this.num_spans; for(;;) { span_data sp; sp.x = span_iterator->x; sp.len = (int32)abs((int)(span_iterator->len)); m_spans.add(sp); int x1 = sp.x; int x2 = sp.x + sp.len - 1; if(x1 < m_min_x) m_min_x = x1; if(x2 > m_max_x) m_max_x = x2; if(--num_spans == 0) break; ++span_iterator; } m_scanlines.add(sl_this); } //--------------------------------------------------------------- // Iterate scanlines interface int min_x() const { return m_min_x; } int min_y() const { return m_min_y; } int max_x() const { return m_max_x; } int max_y() const { return m_max_y; } //--------------------------------------------------------------- bool rewind_scanlines() { m_cur_scanline = 0; return m_scanlines.size() > 0; } //--------------------------------------------------------------- template bool sweep_scanline(Scanline& sl) { sl.reset_spans(); for(;;) { if(m_cur_scanline >= m_scanlines.size()) return false; const scanline_data& sl_this = m_scanlines[m_cur_scanline]; unsigned num_spans = sl_this.num_spans; unsigned span_idx = sl_this.start_span; do { const span_data& sp = m_spans[span_idx++]; sl.add_span(sp.x, sp.len, cover_full); } while(--num_spans); ++m_cur_scanline; if(sl.num_spans()) { sl.finalize(sl_this.y); break; } } return true; } //--------------------------------------------------------------- // Specialization for embedded_scanline bool sweep_scanline(embedded_scanline& sl) { do { if(m_cur_scanline >= m_scanlines.size()) return false; sl.setup(m_cur_scanline); ++m_cur_scanline; } while(sl.num_spans() == 0); return true; } //--------------------------------------------------------------- unsigned byte_size() const { unsigned i; unsigned size = sizeof(int32) * 4; // min_x, min_y, max_x, max_y for(i = 0; i < m_scanlines.size(); ++i) { size += sizeof(int32) * 2 + // Y, num_spans unsigned(m_scanlines[i].num_spans) * sizeof(int32) * 2; // X, span_len } return size; } //--------------------------------------------------------------- static void write_int32(int8u* dst, int32 val) { dst[0] = ((const int8u*)&val)[0]; dst[1] = ((const int8u*)&val)[1]; dst[2] = ((const int8u*)&val)[2]; dst[3] = ((const int8u*)&val)[3]; } //--------------------------------------------------------------- void serialize(int8u* data) const { unsigned i; write_int32(data, min_x()); // min_x data += sizeof(int32); write_int32(data, min_y()); // min_y data += sizeof(int32); write_int32(data, max_x()); // max_x data += sizeof(int32); write_int32(data, max_y()); // max_y data += sizeof(int32); for(i = 0; i < m_scanlines.size(); ++i) { const scanline_data& sl_this = m_scanlines[i]; write_int32(data, sl_this.y); // Y data += sizeof(int32); write_int32(data, sl_this.num_spans); // num_spans data += sizeof(int32); unsigned num_spans = sl_this.num_spans; unsigned span_idx = sl_this.start_span; do { const span_data& sp = m_spans[span_idx++]; write_int32(data, sp.x); // X data += sizeof(int32); write_int32(data, sp.len); // len data += sizeof(int32); } while(--num_spans); } } //--------------------------------------------------------------- const scanline_data& scanline_by_index(unsigned i) const { return (i < m_scanlines.size()) ? m_scanlines[i] : m_fake_scanline; } //--------------------------------------------------------------- const span_data& span_by_index(unsigned i) const { return (i < m_spans.size()) ? m_spans[i] : m_fake_span; } private: pod_bvector m_spans; pod_bvector m_scanlines; span_data m_fake_span; scanline_data m_fake_scanline; int m_min_x; int m_min_y; int m_max_x; int m_max_y; unsigned m_cur_scanline; }; //---------------------------------------serialized_scanlines_adaptor_bin class serialized_scanlines_adaptor_bin { public: typedef bool cover_type; //-------------------------------------------------------------------- class embedded_scanline { public: //---------------------------------------------------------------- class const_iterator { public: struct span { int32 x; int32 len; }; const_iterator() : m_ptr(0) {} const_iterator(const embedded_scanline& sl) : m_ptr(sl.m_ptr), m_dx(sl.m_dx) { m_span.x = read_int32() + m_dx; m_span.len = read_int32(); } const span& operator*() const { return m_span; } const span* operator->() const { return &m_span; } void operator ++ () { m_span.x = read_int32() + m_dx; m_span.len = read_int32(); } private: int read_int32() { int32 val; ((int8u*)&val)[0] = *m_ptr++; ((int8u*)&val)[1] = *m_ptr++; ((int8u*)&val)[2] = *m_ptr++; ((int8u*)&val)[3] = *m_ptr++; return val; } const int8u* m_ptr; span m_span; int m_dx; }; friend class const_iterator; //---------------------------------------------------------------- embedded_scanline() : m_ptr(0), m_y(0), m_num_spans(0) {} //---------------------------------------------------------------- void reset(int, int) {} unsigned num_spans() const { return m_num_spans; } int y() const { return m_y; } const_iterator begin() const { return const_iterator(*this); } private: //---------------------------------------------------------------- int read_int32() { int32 val; ((int8u*)&val)[0] = *m_ptr++; ((int8u*)&val)[1] = *m_ptr++; ((int8u*)&val)[2] = *m_ptr++; ((int8u*)&val)[3] = *m_ptr++; return val; } public: //---------------------------------------------------------------- void init(const int8u* ptr, int dx, int dy) { m_ptr = ptr; m_y = read_int32() + dy; m_num_spans = unsigned(read_int32()); m_dx = dx; } private: const int8u* m_ptr; int m_y; unsigned m_num_spans; int m_dx; }; public: //-------------------------------------------------------------------- serialized_scanlines_adaptor_bin() : m_data(0), m_end(0), m_ptr(0), m_dx(0), m_dy(0), m_min_x(0x7FFFFFFF), m_min_y(0x7FFFFFFF), m_max_x(-0x7FFFFFFF), m_max_y(-0x7FFFFFFF) {} //-------------------------------------------------------------------- serialized_scanlines_adaptor_bin(const int8u* data, unsigned size, double dx, double dy) : m_data(data), m_end(data + size), m_ptr(data), m_dx(iround(dx)), m_dy(iround(dy)), m_min_x(0x7FFFFFFF), m_min_y(0x7FFFFFFF), m_max_x(-0x7FFFFFFF), m_max_y(-0x7FFFFFFF) {} //-------------------------------------------------------------------- void init(const int8u* data, unsigned size, double dx, double dy) { m_data = data; m_end = data + size; m_ptr = data; m_dx = iround(dx); m_dy = iround(dy); m_min_x = 0x7FFFFFFF; m_min_y = 0x7FFFFFFF; m_max_x = -0x7FFFFFFF; m_max_y = -0x7FFFFFFF; } private: //-------------------------------------------------------------------- int read_int32() { int32 val; ((int8u*)&val)[0] = *m_ptr++; ((int8u*)&val)[1] = *m_ptr++; ((int8u*)&val)[2] = *m_ptr++; ((int8u*)&val)[3] = *m_ptr++; return val; } public: // Iterate scanlines interface //-------------------------------------------------------------------- bool rewind_scanlines() { m_ptr = m_data; if(m_ptr < m_end) { m_min_x = read_int32() + m_dx; m_min_y = read_int32() + m_dy; m_max_x = read_int32() + m_dx; m_max_y = read_int32() + m_dy; } return m_ptr < m_end; } //-------------------------------------------------------------------- int min_x() const { return m_min_x; } int min_y() const { return m_min_y; } int max_x() const { return m_max_x; } int max_y() const { return m_max_y; } //-------------------------------------------------------------------- template bool sweep_scanline(Scanline& sl) { sl.reset_spans(); for(;;) { if(m_ptr >= m_end) return false; int y = read_int32() + m_dy; unsigned num_spans = read_int32(); do { int x = read_int32() + m_dx; int len = read_int32(); if(len < 0) len = -len; sl.add_span(x, unsigned(len), cover_full); } while(--num_spans); if(sl.num_spans()) { sl.finalize(y); break; } } return true; } //-------------------------------------------------------------------- // Specialization for embedded_scanline bool sweep_scanline(embedded_scanline& sl) { do { if(m_ptr >= m_end) return false; sl.init(m_ptr, m_dx, m_dy); // Jump to the next scanline //-------------------------- read_int32(); // Y int num_spans = read_int32(); // num_spans m_ptr += num_spans * sizeof(int32) * 2; } while(sl.num_spans() == 0); return true; } private: const int8u* m_data; const int8u* m_end; const int8u* m_ptr; int m_dx; int m_dy; int m_min_x; int m_min_y; int m_max_x; int m_max_y; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_rendering_buffer_dynarow.h0000644000175000017500000001230112516137326027031 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class rendering_buffer_dynarow // //---------------------------------------------------------------------------- #ifndef AGG_RENDERING_BUFFER_DYNAROW_INCLUDED #define AGG_RENDERING_BUFFER_DYNAROW_INCLUDED #include "agg_array.h" namespace agg24 { //===============================================rendering_buffer_dynarow // Rendering buffer class with dynamic allocation of the rows. // The rows are allocated as needed when requesting for span_ptr(). // The class automatically calculates min_x and max_x for each row. // Generally it's more efficient to use this class as a temporary buffer // for rendering a few lines and then to blend it with another buffer. // class rendering_buffer_dynarow { public: //---------------------------------------------------------------------- struct row_data { int x1, x2; const int8u* ptr; }; //------------------------------------------------------------------- ~rendering_buffer_dynarow() { init(0,0,0); } //------------------------------------------------------------------- rendering_buffer_dynarow() : m_rows(), m_width(0), m_height(0), m_byte_width(0) { } // Allocate and clear the buffer //-------------------------------------------------------------------- rendering_buffer_dynarow(unsigned width, unsigned height, unsigned byte_width) : m_rows(height), m_width(width), m_height(height), m_byte_width(byte_width) { memset(&m_rows[0], 0, sizeof(row_data) * height); } // Allocate and clear the buffer //-------------------------------------------------------------------- void init(unsigned width, unsigned height, unsigned byte_width) { unsigned i; for(i = 0; i < m_height; ++i) { pod_allocator::deallocate((int8u*)m_rows[i].ptr, m_byte_width); } if(width && height) { m_width = width; m_height = height; m_byte_width = byte_width; m_rows.resize(height); memset(&m_rows[0], 0, sizeof(row_data) * height); } } //-------------------------------------------------------------------- unsigned width() const { return m_width; } unsigned height() const { return m_height; } unsigned byte_width() const { return m_byte_width; } // The main function used for rendering. Returns pointer to the // pre-allocated span. Memory for the row is allocated as needed. //-------------------------------------------------------------------- int8u* row_ptr(int x, int y, unsigned len) { row_data* r = &m_rows[y]; int x2 = x + len - 1; if(r->ptr) { if(x < r->x1) { r->x1 = x; } if(x2 > r->x2) { r->x2 = x2; } } else { int8u* p = pod_allocator::allocate(m_byte_width); r->ptr = p; r->x1 = x; r->x2 = x2; memset(p, 0, m_byte_width); } return (int8u*)r->ptr; } //-------------------------------------------------------------------- const int8u* row_ptr(int y) const { return m_rows[y].ptr; } int8u* row_ptr(int y) { return row_ptr(0, y, m_width); } row_data row (int y) const { return m_rows[y]; } private: //-------------------------------------------------------------------- // Prohibit copying rendering_buffer_dynarow(const rendering_buffer_dynarow&); const rendering_buffer_dynarow& operator = (const rendering_buffer_dynarow&); private: //-------------------------------------------------------------------- pod_array m_rows; // Pointers to each row of the buffer unsigned m_width; // Width in pixels unsigned m_height; // Height in pixels unsigned m_byte_width; // Width in bytes }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_vpgen_clip_polyline.h0000644000175000017500000000453312516137326026031 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_VPGEN_CLIP_POLYLINE_INCLUDED #define AGG_VPGEN_CLIP_POLYLINE_INCLUDED #include "agg_basics.h" namespace agg24 { //======================================================vpgen_clip_polyline // // See Implementation agg_vpgen_clip_polyline.cpp // class vpgen_clip_polyline { public: vpgen_clip_polyline() : m_clip_box(0, 0, 1, 1), m_x1(0), m_y1(0), m_num_vertices(0), m_vertex(0), m_move_to(false) { } void clip_box(double x1, double y1, double x2, double y2) { m_clip_box.x1 = x1; m_clip_box.y1 = y1; m_clip_box.x2 = x2; m_clip_box.y2 = y2; m_clip_box.normalize(); } double x1() const { return m_clip_box.x1; } double y1() const { return m_clip_box.y1; } double x2() const { return m_clip_box.x2; } double y2() const { return m_clip_box.y2; } static bool auto_close() { return false; } static bool auto_unclose() { return true; } void reset(); void move_to(double x, double y); void line_to(double x, double y); unsigned vertex(double* x, double* y); private: rect_d m_clip_box; double m_x1; double m_y1; double m_x[2]; double m_y[2]; unsigned m_cmd[2]; unsigned m_num_vertices; unsigned m_vertex; bool m_move_to; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_vcgen_dash.h0000644000175000017500000000526212516137326024071 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Line dash generator // //---------------------------------------------------------------------------- #ifndef AGG_VCGEN_DASH_INCLUDED #define AGG_VCGEN_DASH_INCLUDED #include "agg_basics.h" #include "agg_vertex_sequence.h" namespace agg24 { //---------------------------------------------------------------vcgen_dash // // See Implementation agg_vcgen_dash.cpp // class vcgen_dash { enum max_dashes_e { max_dashes = 32 }; enum status_e { initial, ready, polyline, stop }; public: typedef vertex_sequence vertex_storage; vcgen_dash(); void remove_all_dashes(); void add_dash(double dash_len, double gap_len); void dash_start(double ds); void shorten(double s) { m_shorten = s; } double shorten() const { return m_shorten; } // Vertex Generator Interface void remove_all(); void add_vertex(double x, double y, unsigned cmd); // Vertex Source Interface void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: vcgen_dash(const vcgen_dash&); const vcgen_dash& operator = (const vcgen_dash&); void calc_dash_start(double ds); double m_dashes[max_dashes]; double m_total_dash_len; unsigned m_num_dashes; double m_dash_start; double m_shorten; double m_curr_dash_start; unsigned m_curr_dash; double m_curr_rest; const vertex_dist* m_v1; const vertex_dist* m_v2; vertex_storage m_src_vertices; unsigned m_closed; status_e m_status; unsigned m_src_vertex; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_basics.h0000644000175000017500000003744412516137326023243 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_BASICS_INCLUDED #define AGG_BASICS_INCLUDED #include #include "agg_config.h" #ifdef AGG_CUSTOM_ALLOCATOR #include "agg_allocator.h" #else namespace agg24 { // The policy of all AGG containers and memory allocation strategy // in general is that no allocated data requires explicit construction. // It means that the allocator can be really simple; you can even // replace new/delete to malloc/free. The constructors and destructors // won't be called in this case, however everything will remain working. // The second argument of deallocate() is the size of the allocated // block. You can use this information if you wish. //------------------------------------------------------------pod_allocator template struct pod_allocator { static T* allocate(unsigned num) { return new T [num]; } static void deallocate(T* ptr, unsigned) { delete [] ptr; } }; // Single object allocator. It's also can be replaced with your custom // allocator. The difference is that it can only allocate a single // object and the constructor and destructor must be called. // In AGG there is no need to allocate an array of objects with // calling their constructors (only single ones). So that, if you // replace these new/delete to malloc/free make sure that the in-place // new is called and take care of calling the destructor too. //------------------------------------------------------------obj_allocator template struct obj_allocator { static T* allocate() { return new T; } static void deallocate(T* ptr) { delete ptr; } }; } #endif //-------------------------------------------------------- Default basic types // // If the compiler has different capacity of the basic types you can redefine // them via the compiler command line or by generating agg_config.h that is // empty by default. // #ifndef AGG_INT8 #define AGG_INT8 signed char #endif #ifndef AGG_INT8U #define AGG_INT8U unsigned char #endif #ifndef AGG_INT16 #define AGG_INT16 short #endif #ifndef AGG_INT16U #define AGG_INT16U unsigned short #endif #ifndef AGG_INT32 #define AGG_INT32 int #endif #ifndef AGG_INT32U #define AGG_INT32U unsigned #endif #ifndef AGG_INT64 #if defined(_MSC_VER) || defined(__BORLANDC__) #define AGG_INT64 signed __int64 #else #define AGG_INT64 signed long long #endif #endif #ifndef AGG_INT64U #if defined(_MSC_VER) || defined(__BORLANDC__) #define AGG_INT64U unsigned __int64 #else #define AGG_INT64U unsigned long long #endif #endif //------------------------------------------------ Some fixes for MS Visual C++ #if defined(_MSC_VER) #pragma warning(disable:4786) // Identifier was truncated... #endif #if defined(_MSC_VER) #define AGG_INLINE __forceinline #else #define AGG_INLINE inline #endif namespace agg24 { //------------------------------------------------------------------------- typedef AGG_INT8 int8; //----int8 typedef AGG_INT8U int8u; //----int8u typedef AGG_INT16 int16; //----int16 typedef AGG_INT16U int16u; //----int16u typedef AGG_INT32 int32; //----int32 typedef AGG_INT32U int32u; //----int32u typedef AGG_INT64 int64; //----int64 typedef AGG_INT64U int64u; //----int64u #if defined(AGG_FISTP) #pragma warning(push) #pragma warning(disable : 4035) //Disable warning "no return value" AGG_INLINE int iround(double v) //-------iround { __asm fld qword ptr [v] __asm fistp dword ptr [ebp-8] __asm mov eax, dword ptr [ebp-8] } AGG_INLINE unsigned uround(double v) //-------uround { __asm fld qword ptr [v] __asm fistp dword ptr [ebp-8] __asm mov eax, dword ptr [ebp-8] } #pragma warning(pop) AGG_INLINE unsigned ufloor(double v) //-------ufloor { return unsigned(floor(v)); } AGG_INLINE unsigned uceil(double v) //--------uceil { return unsigned(ceil(v)); } #elif defined(AGG_QIFIST) AGG_INLINE int iround(double v) { return int(v); } AGG_INLINE int uround(double v) { return unsigned(v); } AGG_INLINE unsigned ufloor(double v) { return unsigned(floor(v)); } AGG_INLINE unsigned uceil(double v) { return unsigned(ceil(v)); } #else AGG_INLINE int iround(double v) { return int((v < 0.0) ? v - 0.5 : v + 0.5); } AGG_INLINE int uround(double v) { return unsigned(v + 0.5); } AGG_INLINE unsigned ufloor(double v) { return unsigned(v); } AGG_INLINE unsigned uceil(double v) { return unsigned(ceil(v)); } #endif //---------------------------------------------------------------saturation template struct saturation { AGG_INLINE static int iround(double v) { if(v < double(-Limit)) return -Limit; if(v > double( Limit)) return Limit; return agg24::iround(v); } }; //------------------------------------------------------------------mul_one template struct mul_one { AGG_INLINE static unsigned mul(unsigned a, unsigned b) { register unsigned q = a * b + (1 << (Shift-1)); return (q + (q >> Shift)) >> Shift; } }; //------------------------------------------------------------------------- typedef unsigned char cover_type; //----cover_type enum cover_scale_e { cover_shift = 8, //----cover_shift cover_size = 1 << cover_shift, //----cover_size cover_mask = cover_size - 1, //----cover_mask cover_none = 0, //----cover_none cover_full = cover_mask //----cover_full }; //----------------------------------------------------poly_subpixel_scale_e // These constants determine the subpixel accuracy, to be more precise, // the number of bits of the fractional part of the coordinates. // The possible coordinate capacity in bits can be calculated by formula: // sizeof(int) * 8 - poly_subpixel_shift, i.e, for 32-bit integers and // 8-bits fractional part the capacity is 24 bits. enum poly_subpixel_scale_e { poly_subpixel_shift = 8, //----poly_subpixel_shift poly_subpixel_scale = 1< struct rect_base { typedef rect_base self_type; T x1; T y1; T x2; T y2; rect_base() {} rect_base(T x1_, T y1_, T x2_, T y2_) : x1(x1_), y1(y1_), x2(x2_), y2(y2_) {} const self_type& normalize() { T t; if(x1 > x2) { t = x1; x1 = x2; x2 = t; } if(y1 > y2) { t = y1; y1 = y2; y2 = t; } return *this; } bool clip(const self_type& r) { if(x2 > r.x2) x2 = r.x2; if(y2 > r.y2) y2 = r.y2; if(x1 < r.x1) x1 = r.x1; if(y1 < r.y1) y1 = r.y1; return x1 <= x2 && y1 <= y2; } bool is_valid() const { return x1 <= x2 && y1 <= y2; } }; //-----------------------------------------------------intersect_rectangles template inline Rect intersect_rectangles(const Rect& r1, const Rect& r2) { Rect r = r1; // First process x2,y2 because the other order // results in Internal Compiler Error under // Microsoft Visual C++ .NET 2003 69462-335-0000007-18038 in // case of "Maximize Speed" optimization option. //----------------- if(r.x2 > r2.x2) r.x2 = r2.x2; if(r.y2 > r2.y2) r.y2 = r2.y2; if(r.x1 < r2.x1) r.x1 = r2.x1; if(r.y1 < r2.y1) r.y1 = r2.y1; return r; } //---------------------------------------------------------unite_rectangles template inline Rect unite_rectangles(const Rect& r1, const Rect& r2) { Rect r = r1; if(r.x2 < r2.x2) r.x2 = r2.x2; if(r.y2 < r2.y2) r.y2 = r2.y2; if(r.x1 > r2.x1) r.x1 = r2.x1; if(r.y1 > r2.y1) r.y1 = r2.y1; return r; } typedef rect_base rect_i; //----rect_i typedef rect_base rect_f; //----rect_f typedef rect_base rect_d; //----rect_d //---------------------------------------------------------path_commands_e enum path_commands_e { path_cmd_stop = 0, //----path_cmd_stop path_cmd_move_to = 1, //----path_cmd_move_to path_cmd_line_to = 2, //----path_cmd_line_to path_cmd_curve3 = 3, //----path_cmd_curve3 path_cmd_curve4 = 4, //----path_cmd_curve4 path_cmd_curveN = 5, //----path_cmd_curveN path_cmd_catrom = 6, //----path_cmd_catrom path_cmd_ubspline = 7, //----path_cmd_ubspline path_cmd_end_poly = 0x0F, //----path_cmd_end_poly path_cmd_mask = 0x0F //----path_cmd_mask }; //------------------------------------------------------------path_flags_e enum path_flags_e { path_flags_none = 0, //----path_flags_none path_flags_ccw = 0x10, //----path_flags_ccw path_flags_cw = 0x20, //----path_flags_cw path_flags_close = 0x40, //----path_flags_close path_flags_mask = 0xF0 //----path_flags_mask }; //---------------------------------------------------------------is_vertex inline bool is_vertex(unsigned c) { return c >= path_cmd_move_to && c < path_cmd_end_poly; } //--------------------------------------------------------------is_drawing inline bool is_drawing(unsigned c) { return c >= path_cmd_line_to && c < path_cmd_end_poly; } //-----------------------------------------------------------------is_stop inline bool is_stop(unsigned c) { return c == path_cmd_stop; } //--------------------------------------------------------------is_move_to inline bool is_move_to(unsigned c) { return c == path_cmd_move_to; } //--------------------------------------------------------------is_line_to inline bool is_line_to(unsigned c) { return c == path_cmd_line_to; } //----------------------------------------------------------------is_curve inline bool is_curve(unsigned c) { return c == path_cmd_curve3 || c == path_cmd_curve4; } //---------------------------------------------------------------is_curve3 inline bool is_curve3(unsigned c) { return c == path_cmd_curve3; } //---------------------------------------------------------------is_curve4 inline bool is_curve4(unsigned c) { return c == path_cmd_curve4; } //-------------------------------------------------------------is_end_poly inline bool is_end_poly(unsigned c) { return (c & path_cmd_mask) == path_cmd_end_poly; } //----------------------------------------------------------------is_close inline bool is_close(unsigned c) { return (c & ~(path_flags_cw | path_flags_ccw)) == (path_cmd_end_poly | path_flags_close); } //------------------------------------------------------------is_next_poly inline bool is_next_poly(unsigned c) { return is_stop(c) || is_move_to(c) || is_end_poly(c); } //-------------------------------------------------------------------is_cw inline bool is_cw(unsigned c) { return (c & path_flags_cw) != 0; } //------------------------------------------------------------------is_ccw inline bool is_ccw(unsigned c) { return (c & path_flags_ccw) != 0; } //-------------------------------------------------------------is_oriented inline bool is_oriented(unsigned c) { return (c & (path_flags_cw | path_flags_ccw)) != 0; } //---------------------------------------------------------------is_closed inline bool is_closed(unsigned c) { return (c & path_flags_close) != 0; } //----------------------------------------------------------get_close_flag inline unsigned get_close_flag(unsigned c) { return c & path_flags_close; } //-------------------------------------------------------clear_orientation inline unsigned clear_orientation(unsigned c) { return c & ~(path_flags_cw | path_flags_ccw); } //---------------------------------------------------------get_orientation inline unsigned get_orientation(unsigned c) { return c & (path_flags_cw | path_flags_ccw); } //---------------------------------------------------------set_orientation inline unsigned set_orientation(unsigned c, unsigned o) { return clear_orientation(c) | o; } //--------------------------------------------------------------point_base template struct point_base { typedef T value_type; T x,y; point_base() {} point_base(T x_, T y_) : x(x_), y(y_) {} }; typedef point_base point_i; //-----point_i typedef point_base point_f; //-----point_f typedef point_base point_d; //-----point_d //-------------------------------------------------------------vertex_base template struct vertex_base { typedef T value_type; T x,y; unsigned cmd; vertex_base() {} vertex_base(T x_, T y_, unsigned cmd_) : x(x_), y(y_), cmd(cmd_) {} }; typedef vertex_base vertex_i; //-----vertex_i typedef vertex_base vertex_f; //-----vertex_f typedef vertex_base vertex_d; //-----vertex_d } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_scanline_u.h0000644000175000017500000004223012516137326024104 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for 32-bit screen coordinates (scanline32_u) has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_SCANLINE_U_INCLUDED #define AGG_SCANLINE_U_INCLUDED #include "agg_array.h" namespace agg24 { //=============================================================scanline_u8 // // Unpacked scanline container class // // This class is used to transfer data from a scanline rasterizer // to the rendering buffer. It's organized very simple. The class stores // information of horizontal spans to render it into a pixel-map buffer. // Each span has staring X, length, and an array of bytes that determine the // cover-values for each pixel. // Before using this class you should know the minimal and maximal pixel // coordinates of your scanline. The protocol of using is: // 1. reset(min_x, max_x) // 2. add_cell() / add_span() - accumulate scanline. // When forming one scanline the next X coordinate must be always greater // than the last stored one, i.e. it works only with ordered coordinates. // 3. Call finalize(y) and render the scanline. // 3. Call reset_spans() to prepare for the new scanline. // // 4. Rendering: // // Scanline provides an iterator class that allows you to extract // the spans and the cover values for each pixel. Be aware that clipping // has not been done yet, so you should perform it yourself. // Use scanline_u8::iterator to render spans: //------------------------------------------------------------------------- // // int y = sl.y(); // Y-coordinate of the scanline // // ************************************ // ...Perform vertical clipping here... // ************************************ // // scanline_u8::const_iterator span = sl.begin(); // // unsigned char* row = m_rbuf->row(y); // The the address of the beginning // // of the current row // // unsigned num_spans = sl.num_spans(); // Number of spans. It's guaranteed that // // num_spans is always greater than 0. // // do // { // const scanline_u8::cover_type* covers = // span->covers; // The array of the cover values // // int num_pix = span->len; // Number of pixels of the span. // // Always greater than 0, still it's // // better to use "int" instead of // // "unsigned" because it's more // // convenient for clipping // int x = span->x; // // ************************************** // ...Perform horizontal clipping here... // ...you have x, covers, and pix_count.. // ************************************** // // unsigned char* dst = row + x; // Calculate the start address of the row. // // In this case we assume a simple // // grayscale image 1-byte per pixel. // do // { // *dst++ = *covers++; // Hypotetical rendering. // } // while(--num_pix); // // ++span; // } // while(--num_spans); // num_spans cannot be 0, so this loop is quite safe //------------------------------------------------------------------------ // // The question is: why should we accumulate the whole scanline when we // could render just separate spans when they're ready? // That's because using the scanline is generally faster. When is consists // of more than one span the conditions for the processor cash system // are better, because switching between two different areas of memory // (that can be very large) occurs less frequently. //------------------------------------------------------------------------ class scanline_u8 { public: typedef scanline_u8 self_type; typedef int8u cover_type; typedef int16 coord_type; //-------------------------------------------------------------------- struct span { coord_type x; coord_type len; cover_type* covers; }; typedef span* iterator; typedef const span* const_iterator; //-------------------------------------------------------------------- scanline_u8() : m_min_x(0), m_last_x(0x7FFFFFF0), m_cur_span(0) {} //-------------------------------------------------------------------- void reset(int min_x, int max_x) { unsigned max_len = max_x - min_x + 2; if(max_len > m_spans.size()) { m_spans.resize(max_len); m_covers.resize(max_len); } m_last_x = 0x7FFFFFF0; m_min_x = min_x; m_cur_span = &m_spans[0]; } //-------------------------------------------------------------------- void add_cell(int x, unsigned cover) { x -= m_min_x; m_covers[x] = (cover_type)cover; if(x == m_last_x+1) { m_cur_span->len++; } else { m_cur_span++; m_cur_span->x = (coord_type)(x + m_min_x); m_cur_span->len = 1; m_cur_span->covers = &m_covers[x]; } m_last_x = x; } //-------------------------------------------------------------------- void add_cells(int x, unsigned len, const cover_type* covers) { x -= m_min_x; memcpy(&m_covers[x], covers, len * sizeof(cover_type)); if(x == m_last_x+1) { m_cur_span->len += (coord_type)len; } else { m_cur_span++; m_cur_span->x = (coord_type)(x + m_min_x); m_cur_span->len = (coord_type)len; m_cur_span->covers = &m_covers[x]; } m_last_x = x + len - 1; } //-------------------------------------------------------------------- void add_span(int x, unsigned len, unsigned cover) { x -= m_min_x; memset(&m_covers[x], cover, len); if(x == m_last_x+1) { m_cur_span->len += (coord_type)len; } else { m_cur_span++; m_cur_span->x = (coord_type)(x + m_min_x); m_cur_span->len = (coord_type)len; m_cur_span->covers = &m_covers[x]; } m_last_x = x + len - 1; } //-------------------------------------------------------------------- void finalize(int y) { m_y = y; } //-------------------------------------------------------------------- void reset_spans() { m_last_x = 0x7FFFFFF0; m_cur_span = &m_spans[0]; } //-------------------------------------------------------------------- int y() const { return m_y; } unsigned num_spans() const { return unsigned(m_cur_span - &m_spans[0]); } const_iterator begin() const { return &m_spans[1]; } iterator begin() { return &m_spans[1]; } private: scanline_u8(const self_type&); const self_type& operator = (const self_type&); private: int m_min_x; int m_last_x; int m_y; pod_array m_covers; pod_array m_spans; span* m_cur_span; }; //==========================================================scanline_u8_am // // The scanline container with alpha-masking // //------------------------------------------------------------------------ template class scanline_u8_am : public scanline_u8 { public: typedef scanline_u8 base_type; typedef AlphaMask alpha_mask_type; typedef base_type::cover_type cover_type; typedef base_type::coord_type coord_type; scanline_u8_am() : base_type(), m_alpha_mask(0) {} scanline_u8_am(const AlphaMask& am) : base_type(), m_alpha_mask(&am) {} //-------------------------------------------------------------------- void finalize(int span_y) { base_type::finalize(span_y); if(m_alpha_mask) { typename base_type::iterator span = base_type::begin(); unsigned count = base_type::num_spans(); do { m_alpha_mask->combine_hspan(span->x, base_type::y(), span->covers, span->len); ++span; } while(--count); } } private: const AlphaMask* m_alpha_mask; }; //===========================================================scanline32_u8 class scanline32_u8 { public: typedef scanline32_u8 self_type; typedef int8u cover_type; typedef int32 coord_type; //-------------------------------------------------------------------- struct span { span() {} span(coord_type x_, coord_type len_, cover_type* covers_) : x(x_), len(len_), covers(covers_) {} coord_type x; coord_type len; cover_type* covers; }; typedef pod_bvector span_array_type; //-------------------------------------------------------------------- class const_iterator { public: const_iterator(const span_array_type& spans) : m_spans(spans), m_span_idx(0) {} const span& operator*() const { return m_spans[m_span_idx]; } const span* operator->() const { return &m_spans[m_span_idx]; } void operator ++ () { ++m_span_idx; } private: const span_array_type& m_spans; unsigned m_span_idx; }; //-------------------------------------------------------------------- class iterator { public: iterator(span_array_type& spans) : m_spans(spans), m_span_idx(0) {} span& operator*() { return m_spans[m_span_idx]; } span* operator->() { return &m_spans[m_span_idx]; } void operator ++ () { ++m_span_idx; } private: span_array_type& m_spans; unsigned m_span_idx; }; //-------------------------------------------------------------------- scanline32_u8() : m_min_x(0), m_last_x(0x7FFFFFF0), m_covers() {} //-------------------------------------------------------------------- void reset(int min_x, int max_x) { unsigned max_len = max_x - min_x + 2; if(max_len > m_covers.size()) { m_covers.resize(max_len); } m_last_x = 0x7FFFFFF0; m_min_x = min_x; m_spans.remove_all(); } //-------------------------------------------------------------------- void add_cell(int x, unsigned cover) { x -= m_min_x; m_covers[x] = cover_type(cover); if(x == m_last_x+1) { m_spans.last().len++; } else { m_spans.add(span(coord_type(x + m_min_x), 1, &m_covers[x])); } m_last_x = x; } //-------------------------------------------------------------------- void add_cells(int x, unsigned len, const cover_type* covers) { x -= m_min_x; memcpy(&m_covers[x], covers, len * sizeof(cover_type)); if(x == m_last_x+1) { m_spans.last().len += coord_type(len); } else { m_spans.add(span(coord_type(x + m_min_x), coord_type(len), &m_covers[x])); } m_last_x = x + len - 1; } //-------------------------------------------------------------------- void add_span(int x, unsigned len, unsigned cover) { x -= m_min_x; memset(&m_covers[x], cover, len); if(x == m_last_x+1) { m_spans.last().len += coord_type(len); } else { m_spans.add(span(coord_type(x + m_min_x), coord_type(len), &m_covers[x])); } m_last_x = x + len - 1; } //-------------------------------------------------------------------- void finalize(int y) { m_y = y; } //-------------------------------------------------------------------- void reset_spans() { m_last_x = 0x7FFFFFF0; m_spans.remove_all(); } //-------------------------------------------------------------------- int y() const { return m_y; } unsigned num_spans() const { return m_spans.size(); } const_iterator begin() const { return const_iterator(m_spans); } iterator begin() { return iterator(m_spans); } private: scanline32_u8(const self_type&); const self_type& operator = (const self_type&); private: int m_min_x; int m_last_x; int m_y; pod_array m_covers; span_array_type m_spans; }; //========================================================scanline32_u8_am // // The scanline container with alpha-masking // //------------------------------------------------------------------------ template class scanline32_u8_am : public scanline32_u8 { public: typedef scanline32_u8 base_type; typedef AlphaMask alpha_mask_type; typedef base_type::cover_type cover_type; typedef base_type::coord_type coord_type; scanline32_u8_am() : base_type(), m_alpha_mask(0) {} scanline32_u8_am(const AlphaMask& am) : base_type(), m_alpha_mask(&am) {} //-------------------------------------------------------------------- void finalize(int span_y) { base_type::finalize(span_y); if(m_alpha_mask) { typename base_type::iterator span = base_type::begin(); unsigned count = base_type::num_spans(); do { m_alpha_mask->combine_hspan(span->x, base_type::y(), span->covers, span->len); ++span; } while(--count); } } private: const AlphaMask* m_alpha_mask; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_solid.h0000644000175000017500000000333512516137326024122 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // span_solid_rgba8 // //---------------------------------------------------------------------------- #ifndef AGG_SPAN_SOLID_INCLUDED #define AGG_SPAN_SOLID_INCLUDED #include "agg_basics.h" namespace agg24 { //--------------------------------------------------------------span_solid template class span_solid { public: typedef ColorT color_type; //-------------------------------------------------------------------- void color(const color_type& c) { m_color = c; } const color_type& color() const { return m_color; } //-------------------------------------------------------------------- void prepare() {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { do { *span++ = m_color; } while(--len); } private: color_type m_color; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_image_filter_rgb.h0000644000175000017500000011123612516137326026271 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for high precision colors has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_SPAN_IMAGE_FILTER_RGB_INCLUDED #define AGG_SPAN_IMAGE_FILTER_RGB_INCLUDED #include "agg_basics.h" #include "agg_color_rgba.h" #include "agg_span_image_filter.h" namespace agg24 { //===============================================span_image_filter_rgb_nn template class span_image_filter_rgb_nn : public span_image_filter { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- span_image_filter_rgb_nn() {} span_image_filter_rgb_nn(source_type& src, interpolator_type& inter) : base_type(src, inter, 0) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); do { base_type::interpolator().coordinates(&x, &y); const value_type* fg_ptr = (const value_type*) base_type::source().span(x >> image_subpixel_shift, y >> image_subpixel_shift, 1); span->r = fg_ptr[order_type::R]; span->g = fg_ptr[order_type::G]; span->b = fg_ptr[order_type::B]; span->a = base_mask; ++span; ++base_type::interpolator(); } while(--len); } }; //==========================================span_image_filter_rgb_bilinear template class span_image_filter_rgb_bilinear : public span_image_filter { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- span_image_filter_rgb_bilinear() {} span_image_filter_rgb_bilinear(source_type& src, interpolator_type& inter) : base_type(src, inter, 0) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); calc_type fg[3]; const value_type *fg_ptr; do { int x_hr; int y_hr; base_type::interpolator().coordinates(&x_hr, &y_hr); x_hr -= base_type::filter_dx_int(); y_hr -= base_type::filter_dy_int(); int x_lr = x_hr >> image_subpixel_shift; int y_lr = y_hr >> image_subpixel_shift; unsigned weight; fg[0] = fg[1] = fg[2] = image_subpixel_scale * image_subpixel_scale / 2; x_hr &= image_subpixel_mask; y_hr &= image_subpixel_mask; fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); weight = (image_subpixel_scale - x_hr) * (image_subpixel_scale - y_hr); fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr; fg_ptr = (const value_type*)base_type::source().next_x(); weight = x_hr * (image_subpixel_scale - y_hr); fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr; fg_ptr = (const value_type*)base_type::source().next_y(); weight = (image_subpixel_scale - x_hr) * y_hr; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr; fg_ptr = (const value_type*)base_type::source().next_x(); weight = x_hr * y_hr; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr; span->r = value_type(fg[order_type::R] >> (image_subpixel_shift * 2)); span->g = value_type(fg[order_type::G] >> (image_subpixel_shift * 2)); span->b = value_type(fg[order_type::B] >> (image_subpixel_shift * 2)); span->a = base_mask; ++span; ++base_type::interpolator(); } while(--len); } }; //=====================================span_image_filter_rgb_bilinear_clip template class span_image_filter_rgb_bilinear_clip : public span_image_filter { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- span_image_filter_rgb_bilinear_clip() {} span_image_filter_rgb_bilinear_clip(source_type& src, const color_type& back_color, interpolator_type& inter) : base_type(src, inter, 0), m_back_color(back_color) {} const color_type& background_color() const { return m_back_color; } void background_color(const color_type& v) { m_back_color = v; } //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); calc_type fg[3]; calc_type src_alpha; value_type back_r = m_back_color.r; value_type back_g = m_back_color.g; value_type back_b = m_back_color.b; value_type back_a = m_back_color.a; const value_type *fg_ptr; int maxx = base_type::source().width() - 1; int maxy = base_type::source().height() - 1; do { int x_hr; int y_hr; base_type::interpolator().coordinates(&x_hr, &y_hr); x_hr -= base_type::filter_dx_int(); y_hr -= base_type::filter_dy_int(); int x_lr = x_hr >> image_subpixel_shift; int y_lr = y_hr >> image_subpixel_shift; unsigned weight; if(x_lr >= 0 && y_lr >= 0 && x_lr < maxx && y_lr < maxy) { fg[0] = fg[1] = fg[2] = image_subpixel_scale * image_subpixel_scale / 2; x_hr &= image_subpixel_mask; y_hr &= image_subpixel_mask; fg_ptr = (const value_type*) base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; weight = (image_subpixel_scale - x_hr) * (image_subpixel_scale - y_hr); fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; weight = x_hr * (image_subpixel_scale - y_hr); fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; ++y_lr; fg_ptr = (const value_type*) base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; weight = (image_subpixel_scale - x_hr) * y_hr; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; weight = x_hr * y_hr; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; fg[0] >>= image_subpixel_shift * 2; fg[1] >>= image_subpixel_shift * 2; fg[2] >>= image_subpixel_shift * 2; src_alpha = base_mask; } else { if(x_lr < -1 || y_lr < -1 || x_lr > maxx || y_lr > maxy) { fg[order_type::R] = back_r; fg[order_type::G] = back_g; fg[order_type::B] = back_b; src_alpha = back_a; } else { fg[0] = fg[1] = fg[2] = src_alpha = image_subpixel_scale * image_subpixel_scale / 2; x_hr &= image_subpixel_mask; y_hr &= image_subpixel_mask; weight = (image_subpixel_scale - x_hr) * (image_subpixel_scale - y_hr); if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) { fg_ptr = (const value_type*) base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; src_alpha += weight * base_mask; } else { fg[order_type::R] += back_r * weight; fg[order_type::G] += back_g * weight; fg[order_type::B] += back_b * weight; src_alpha += back_a * weight; } x_lr++; weight = x_hr * (image_subpixel_scale - y_hr); if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) { fg_ptr = (const value_type*) base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; src_alpha += weight * base_mask; } else { fg[order_type::R] += back_r * weight; fg[order_type::G] += back_g * weight; fg[order_type::B] += back_b * weight; src_alpha += back_a * weight; } x_lr--; y_lr++; weight = (image_subpixel_scale - x_hr) * y_hr; if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) { fg_ptr = (const value_type*) base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; src_alpha += weight * base_mask; } else { fg[order_type::R] += back_r * weight; fg[order_type::G] += back_g * weight; fg[order_type::B] += back_b * weight; src_alpha += back_a * weight; } x_lr++; weight = x_hr * y_hr; if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) { fg_ptr = (const value_type*) base_type::source().row_ptr(y_lr) + x_lr + x_lr + x_lr; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr++; src_alpha += weight * base_mask; } else { fg[order_type::R] += back_r * weight; fg[order_type::G] += back_g * weight; fg[order_type::B] += back_b * weight; src_alpha += back_a * weight; } fg[0] >>= image_subpixel_shift * 2; fg[1] >>= image_subpixel_shift * 2; fg[2] >>= image_subpixel_shift * 2; src_alpha >>= image_subpixel_shift * 2; } } span->r = (value_type)fg[order_type::R]; span->g = (value_type)fg[order_type::G]; span->b = (value_type)fg[order_type::B]; span->a = (value_type)src_alpha; ++span; ++base_type::interpolator(); } while(--len); } private: color_type m_back_color; }; //===============================================span_image_filter_rgb_2x2 template class span_image_filter_rgb_2x2 : public span_image_filter { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- span_image_filter_rgb_2x2() {} span_image_filter_rgb_2x2(source_type& src, interpolator_type& inter, const image_filter_lut& filter) : base_type(src, inter, &filter) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); calc_type fg[3]; const value_type *fg_ptr; const int16* weight_array = base_type::filter().weight_array() + ((base_type::filter().diameter()/2 - 1) << image_subpixel_shift); do { int x_hr; int y_hr; base_type::interpolator().coordinates(&x_hr, &y_hr); x_hr -= base_type::filter_dx_int(); y_hr -= base_type::filter_dy_int(); int x_lr = x_hr >> image_subpixel_shift; int y_lr = y_hr >> image_subpixel_shift; unsigned weight; fg[0] = fg[1] = fg[2] = image_filter_scale / 2; x_hr &= image_subpixel_mask; y_hr &= image_subpixel_mask; fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); weight = (weight_array[x_hr + image_subpixel_scale] * weight_array[y_hr + image_subpixel_scale] + image_filter_scale / 2) >> image_filter_shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr; fg_ptr = (const value_type*)base_type::source().next_x(); weight = (weight_array[x_hr] * weight_array[y_hr + image_subpixel_scale] + image_filter_scale / 2) >> image_filter_shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr; fg_ptr = (const value_type*)base_type::source().next_y(); weight = (weight_array[x_hr + image_subpixel_scale] * weight_array[y_hr] + image_filter_scale / 2) >> image_filter_shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr; fg_ptr = (const value_type*)base_type::source().next_x(); weight = (weight_array[x_hr] * weight_array[y_hr] + image_filter_scale / 2) >> image_filter_shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr; fg[0] >>= image_filter_shift; fg[1] >>= image_filter_shift; fg[2] >>= image_filter_shift; if(fg[order_type::R] > base_mask) fg[order_type::R] = base_mask; if(fg[order_type::G] > base_mask) fg[order_type::G] = base_mask; if(fg[order_type::B] > base_mask) fg[order_type::B] = base_mask; span->r = (value_type)fg[order_type::R]; span->g = (value_type)fg[order_type::G]; span->b = (value_type)fg[order_type::B]; span->a = base_mask; ++span; ++base_type::interpolator(); } while(--len); } }; //===================================================span_image_filter_rgb template class span_image_filter_rgb : public span_image_filter { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- span_image_filter_rgb() {} span_image_filter_rgb(source_type& src, interpolator_type& inter, const image_filter_lut& filter) : base_type(src, inter, &filter) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); int fg[3]; const value_type *fg_ptr; unsigned diameter = base_type::filter().diameter(); int start = base_type::filter().start(); const int16* weight_array = base_type::filter().weight_array(); int x_count; int weight_y; do { base_type::interpolator().coordinates(&x, &y); x -= base_type::filter_dx_int(); y -= base_type::filter_dy_int(); int x_hr = x; int y_hr = y; int x_lr = x_hr >> image_subpixel_shift; int y_lr = y_hr >> image_subpixel_shift; fg[0] = fg[1] = fg[2] = image_filter_scale / 2; int x_fract = x_hr & image_subpixel_mask; unsigned y_count = diameter; y_hr = image_subpixel_mask - (y_hr & image_subpixel_mask); fg_ptr = (const value_type*)base_type::source().span(x_lr + start, y_lr + start, diameter); for(;;) { x_count = diameter; weight_y = weight_array[y_hr]; x_hr = image_subpixel_mask - x_fract; for(;;) { int weight = (weight_y * weight_array[x_hr] + image_filter_scale / 2) >> image_filter_shift; fg[0] += weight * *fg_ptr++; fg[1] += weight * *fg_ptr++; fg[2] += weight * *fg_ptr; if(--x_count == 0) break; x_hr += image_subpixel_scale; fg_ptr = (const value_type*)base_type::source().next_x(); } if(--y_count == 0) break; y_hr += image_subpixel_scale; fg_ptr = (const value_type*)base_type::source().next_y(); } fg[0] >>= image_filter_shift; fg[1] >>= image_filter_shift; fg[2] >>= image_filter_shift; if(fg[0] < 0) fg[0] = 0; if(fg[1] < 0) fg[1] = 0; if(fg[2] < 0) fg[2] = 0; if(fg[order_type::R] > base_mask) fg[order_type::R] = base_mask; if(fg[order_type::G] > base_mask) fg[order_type::G] = base_mask; if(fg[order_type::B] > base_mask) fg[order_type::B] = base_mask; span->r = (value_type)fg[order_type::R]; span->g = (value_type)fg[order_type::G]; span->b = (value_type)fg[order_type::B]; span->a = base_mask; ++span; ++base_type::interpolator(); } while(--len); } }; //==========================================span_image_resample_rgb_affine template class span_image_resample_rgb_affine : public span_image_resample_affine { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef span_image_resample_affine base_type; typedef typename base_type::interpolator_type interpolator_type; typedef typename color_type::value_type value_type; typedef typename color_type::long_type long_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask, downscale_shift = image_filter_shift }; //-------------------------------------------------------------------- span_image_resample_rgb_affine() {} span_image_resample_rgb_affine(source_type& src, interpolator_type& inter, const image_filter_lut& filter) : base_type(src, inter, filter) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); long_type fg[3]; int diameter = base_type::filter().diameter(); int filter_scale = diameter << image_subpixel_shift; int radius_x = (diameter * base_type::m_rx) >> 1; int radius_y = (diameter * base_type::m_ry) >> 1; int len_x_lr = (diameter * base_type::m_rx + image_subpixel_mask) >> image_subpixel_shift; const int16* weight_array = base_type::filter().weight_array(); do { base_type::interpolator().coordinates(&x, &y); x += base_type::filter_dx_int() - radius_x; y += base_type::filter_dy_int() - radius_y; fg[0] = fg[1] = fg[2] = image_filter_scale / 2; int y_lr = y >> image_subpixel_shift; int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * base_type::m_ry_inv) >> image_subpixel_shift; int total_weight = 0; int x_lr = x >> image_subpixel_shift; int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * base_type::m_rx_inv) >> image_subpixel_shift; int x_hr2 = x_hr; const value_type* fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); for(;;) { int weight_y = weight_array[y_hr]; x_hr = x_hr2; for(;;) { int weight = (weight_y * weight_array[x_hr] + image_filter_scale / 2) >> downscale_shift; fg[0] += *fg_ptr++ * weight; fg[1] += *fg_ptr++ * weight; fg[2] += *fg_ptr * weight; total_weight += weight; x_hr += base_type::m_rx_inv; if(x_hr >= filter_scale) break; fg_ptr = (const value_type*)base_type::source().next_x(); } y_hr += base_type::m_ry_inv; if(y_hr >= filter_scale) break; fg_ptr = (const value_type*)base_type::source().next_y(); } fg[0] /= total_weight; fg[1] /= total_weight; fg[2] /= total_weight; if(fg[0] < 0) fg[0] = 0; if(fg[1] < 0) fg[1] = 0; if(fg[2] < 0) fg[2] = 0; if(fg[order_type::R] > base_mask) fg[order_type::R] = base_mask; if(fg[order_type::G] > base_mask) fg[order_type::G] = base_mask; if(fg[order_type::B] > base_mask) fg[order_type::B] = base_mask; span->r = (value_type)fg[order_type::R]; span->g = (value_type)fg[order_type::G]; span->b = (value_type)fg[order_type::B]; span->a = base_mask; ++span; ++base_type::interpolator(); } while(--len); } }; //=================================================span_image_resample_rgb template class span_image_resample_rgb : public span_image_resample { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef Interpolator interpolator_type; typedef span_image_resample base_type; typedef typename color_type::value_type value_type; typedef typename color_type::long_type long_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask, downscale_shift = image_filter_shift }; //-------------------------------------------------------------------- span_image_resample_rgb() {} span_image_resample_rgb(source_type& src, interpolator_type& inter, const image_filter_lut& filter) : base_type(src, inter, filter) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); long_type fg[3]; int diameter = base_type::filter().diameter(); int filter_scale = diameter << image_subpixel_shift; const int16* weight_array = base_type::filter().weight_array(); do { int rx; int ry; int rx_inv = image_subpixel_scale; int ry_inv = image_subpixel_scale; base_type::interpolator().coordinates(&x, &y); base_type::interpolator().local_scale(&rx, &ry); rx = (rx * base_type::m_blur_x) >> image_subpixel_shift; ry = (ry * base_type::m_blur_y) >> image_subpixel_shift; if(rx < image_subpixel_scale) { rx = image_subpixel_scale; } else { if(rx > image_subpixel_scale * base_type::m_scale_limit) { rx = image_subpixel_scale * base_type::m_scale_limit; } rx_inv = image_subpixel_scale * image_subpixel_scale / rx; } if(ry < image_subpixel_scale) { ry = image_subpixel_scale; } else { if(ry > image_subpixel_scale * base_type::m_scale_limit) { ry = image_subpixel_scale * base_type::m_scale_limit; } ry_inv = image_subpixel_scale * image_subpixel_scale / ry; } int radius_x = (diameter * rx) >> 1; int radius_y = (diameter * ry) >> 1; int len_x_lr = (diameter * rx + image_subpixel_mask) >> image_subpixel_shift; x += base_type::filter_dx_int() - radius_x; y += base_type::filter_dy_int() - radius_y; fg[0] = fg[1] = fg[2] = image_filter_scale / 2; int y_lr = y >> image_subpixel_shift; int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * ry_inv) >> image_subpixel_shift; int total_weight = 0; int x_lr = x >> image_subpixel_shift; int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * rx_inv) >> image_subpixel_shift; int x_hr2 = x_hr; const value_type* fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); for(;;) { int weight_y = weight_array[y_hr]; x_hr = x_hr2; for(;;) { int weight = (weight_y * weight_array[x_hr] + image_filter_scale / 2) >> downscale_shift; fg[0] += *fg_ptr++ * weight; fg[1] += *fg_ptr++ * weight; fg[2] += *fg_ptr * weight; total_weight += weight; x_hr += rx_inv; if(x_hr >= filter_scale) break; fg_ptr = (const value_type*)base_type::source().next_x(); } y_hr += ry_inv; if(y_hr >= filter_scale) break; fg_ptr = (const value_type*)base_type::source().next_y(); } fg[0] /= total_weight; fg[1] /= total_weight; fg[2] /= total_weight; if(fg[0] < 0) fg[0] = 0; if(fg[1] < 0) fg[1] = 0; if(fg[2] < 0) fg[2] = 0; if(fg[order_type::R] > base_mask) fg[order_type::R] = base_mask; if(fg[order_type::G] > base_mask) fg[order_type::G] = base_mask; if(fg[order_type::B] > base_mask) fg[order_type::B] = base_mask; span->r = (value_type)fg[order_type::R]; span->g = (value_type)fg[order_type::G]; span->b = (value_type)fg[order_type::B]; span->a = base_mask; ++span; ++base_type::interpolator(); } while(--len); } }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_concat.h0000644000175000017500000000441012516137326024256 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_CONV_CONCAT_INCLUDED #define AGG_CONV_CONCAT_INCLUDED #include "agg_basics.h" namespace agg24 { //=============================================================conv_concat // Concatenation of two paths. Usually used to combine lines or curves // with markers such as arrowheads template class conv_concat { public: conv_concat(VS1& source1, VS2& source2) : m_source1(&source1), m_source2(&source2), m_status(2) {} void attach1(VS1& source) { m_source1 = &source; } void attach2(VS2& source) { m_source2 = &source; } void rewind(unsigned path_id) { m_source1->rewind(path_id); m_source2->rewind(0); m_status = 0; } unsigned vertex(double* x, double* y) { unsigned cmd; if(m_status == 0) { cmd = m_source1->vertex(x, y); if(!is_stop(cmd)) return cmd; m_status = 1; } if(m_status == 1) { cmd = m_source2->vertex(x, y); if(!is_stop(cmd)) return cmd; m_status = 2; } return path_cmd_stop; } private: conv_concat(const conv_concat&); const conv_concat& operator = (const conv_concat&); VS1* m_source1; VS2* m_source2; int m_status; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_image_filters.h0000644000175000017500000003574212516137326024610 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Image transformation filters, // Filtering classes (image_filter_lut, image_filter), // Basic filter shape classes //---------------------------------------------------------------------------- #ifndef AGG_IMAGE_FILTERS_INCLUDED #define AGG_IMAGE_FILTERS_INCLUDED #include "agg_array.h" #include "agg_math.h" namespace agg24 { // See Implementation agg_image_filters.cpp enum image_filter_scale_e { image_filter_shift = 14, //----image_filter_shift image_filter_scale = 1 << image_filter_shift, //----image_filter_scale image_filter_mask = image_filter_scale - 1 //----image_filter_mask }; enum image_subpixel_scale_e { image_subpixel_shift = 8, //----image_subpixel_shift image_subpixel_scale = 1 << image_subpixel_shift, //----image_subpixel_scale image_subpixel_mask = image_subpixel_scale - 1 //----image_subpixel_mask }; //-----------------------------------------------------image_filter_lut class image_filter_lut { public: template void calculate(const FilterF& filter, bool normalization=true) { double r = filter.radius(); realloc_lut(r); unsigned i; unsigned pivot = diameter() << (image_subpixel_shift - 1); for(i = 0; i < pivot; i++) { double x = double(i) / double(image_subpixel_scale); double y = filter.calc_weight(x); m_weight_array[pivot + i] = m_weight_array[pivot - i] = (int16)iround(y * image_filter_scale); } unsigned end = (diameter() << image_subpixel_shift) - 1; m_weight_array[0] = m_weight_array[end]; if(normalization) { normalize(); } } image_filter_lut() : m_radius(0), m_diameter(0), m_start(0) {} template image_filter_lut(const FilterF& filter, bool normalization=true) { calculate(filter, normalization); } double radius() const { return m_radius; } unsigned diameter() const { return m_diameter; } int start() const { return m_start; } const int16* weight_array() const { return &m_weight_array[0]; } void normalize(); private: void realloc_lut(double radius); image_filter_lut(const image_filter_lut&); const image_filter_lut& operator = (const image_filter_lut&); double m_radius; unsigned m_diameter; int m_start; pod_array m_weight_array; }; //--------------------------------------------------------image_filter template class image_filter : public image_filter_lut { public: image_filter() { calculate(m_filter_function); } private: FilterF m_filter_function; }; //-----------------------------------------------image_filter_bilinear struct image_filter_bilinear { static double radius() { return 1.0; } static double calc_weight(double x) { return 1.0 - x; } }; //-----------------------------------------------image_filter_hanning struct image_filter_hanning { static double radius() { return 1.0; } static double calc_weight(double x) { return 0.5 + 0.5 * cos(pi * x); } }; //-----------------------------------------------image_filter_hamming struct image_filter_hamming { static double radius() { return 1.0; } static double calc_weight(double x) { return 0.54 + 0.46 * cos(pi * x); } }; //-----------------------------------------------image_filter_hermite struct image_filter_hermite { static double radius() { return 1.0; } static double calc_weight(double x) { return (2.0 * x - 3.0) * x * x + 1.0; } }; //------------------------------------------------image_filter_quadric struct image_filter_quadric { static double radius() { return 1.5; } static double calc_weight(double x) { double t; if(x < 0.5) return 0.75 - x * x; if(x < 1.5) {t = x - 1.5; return 0.5 * t * t;} return 0.0; } }; //------------------------------------------------image_filter_bicubic class image_filter_bicubic { static double pow3(double x) { return (x <= 0.0) ? 0.0 : x * x * x; } public: static double radius() { return 2.0; } static double calc_weight(double x) { return (1.0/6.0) * (pow3(x + 2) - 4 * pow3(x + 1) + 6 * pow3(x) - 4 * pow3(x - 1)); } }; //-------------------------------------------------image_filter_kaiser class image_filter_kaiser { double a; double i0a; double epsilon; public: image_filter_kaiser(double b = 6.33) : a(b), epsilon(1e-12) { i0a = 1.0 / bessel_i0(b); } static double radius() { return 1.0; } double calc_weight(double x) const { return bessel_i0(a * sqrt(1. - x * x)) * i0a; } private: double bessel_i0(double x) const { int i; double sum, y, t; sum = 1.; y = x * x / 4.; t = y; for(i = 2; t > epsilon; i++) { sum += t; t *= (double)y / (i * i); } return sum; } }; //----------------------------------------------image_filter_catrom struct image_filter_catrom { static double radius() { return 2.0; } static double calc_weight(double x) { if(x < 1.0) return 0.5 * (2.0 + x * x * (-5.0 + x * 3.0)); if(x < 2.0) return 0.5 * (4.0 + x * (-8.0 + x * (5.0 - x))); return 0.; } }; //---------------------------------------------image_filter_mitchell class image_filter_mitchell { double p0, p2, p3; double q0, q1, q2, q3; public: image_filter_mitchell(double b = 1.0/3.0, double c = 1.0/3.0) : p0((6.0 - 2.0 * b) / 6.0), p2((-18.0 + 12.0 * b + 6.0 * c) / 6.0), p3((12.0 - 9.0 * b - 6.0 * c) / 6.0), q0((8.0 * b + 24.0 * c) / 6.0), q1((-12.0 * b - 48.0 * c) / 6.0), q2((6.0 * b + 30.0 * c) / 6.0), q3((-b - 6.0 * c) / 6.0) {} static double radius() { return 2.0; } double calc_weight(double x) const { if(x < 1.0) return p0 + x * x * (p2 + x * p3); if(x < 2.0) return q0 + x * (q1 + x * (q2 + x * q3)); return 0.0; } }; //----------------------------------------------image_filter_spline16 struct image_filter_spline16 { static double radius() { return 2.0; } static double calc_weight(double x) { if(x < 1.0) { return ((x - 9.0/5.0 ) * x - 1.0/5.0 ) * x + 1.0; } return ((-1.0/3.0 * (x-1) + 4.0/5.0) * (x-1) - 7.0/15.0 ) * (x-1); } }; //---------------------------------------------image_filter_spline36 struct image_filter_spline36 { static double radius() { return 3.0; } static double calc_weight(double x) { if(x < 1.0) { return ((13.0/11.0 * x - 453.0/209.0) * x - 3.0/209.0) * x + 1.0; } if(x < 2.0) { return ((-6.0/11.0 * (x-1) + 270.0/209.0) * (x-1) - 156.0/ 209.0) * (x-1); } return ((1.0/11.0 * (x-2) - 45.0/209.0) * (x-2) + 26.0/209.0) * (x-2); } }; //----------------------------------------------image_filter_gaussian struct image_filter_gaussian { static double radius() { return 2.0; } static double calc_weight(double x) { return exp(-2.0 * x * x) * sqrt(2.0 / pi); } }; //------------------------------------------------image_filter_bessel struct image_filter_bessel { static double radius() { return 3.2383; } static double calc_weight(double x) { return (x == 0.0) ? pi / 4.0 : besj(pi * x, 1) / (2.0 * x); } }; //-------------------------------------------------image_filter_sinc class image_filter_sinc { public: image_filter_sinc(double r) : m_radius(r < 2.0 ? 2.0 : r) {} double radius() const { return m_radius; } double calc_weight(double x) const { if(x == 0.0) return 1.0; x *= pi; return sin(x) / x; } private: double m_radius; }; //-----------------------------------------------image_filter_lanczos class image_filter_lanczos { public: image_filter_lanczos(double r) : m_radius(r < 2.0 ? 2.0 : r) {} double radius() const { return m_radius; } double calc_weight(double x) const { if(x == 0.0) return 1.0; if(x > m_radius) return 0.0; x *= pi; double xr = x / m_radius; return (sin(x) / x) * (sin(xr) / xr); } private: double m_radius; }; //----------------------------------------------image_filter_blackman class image_filter_blackman { public: image_filter_blackman(double r) : m_radius(r < 2.0 ? 2.0 : r) {} double radius() const { return m_radius; } double calc_weight(double x) const { if(x == 0.0) return 1.0; if(x > m_radius) return 0.0; x *= pi; double xr = x / m_radius; return (sin(x) / x) * (0.42 + 0.5*cos(xr) + 0.08*cos(2*xr)); } private: double m_radius; }; //------------------------------------------------image_filter_sinc36 class image_filter_sinc36 : public image_filter_sinc { public: image_filter_sinc36() : image_filter_sinc(3.0){} }; //------------------------------------------------image_filter_sinc64 class image_filter_sinc64 : public image_filter_sinc { public: image_filter_sinc64() : image_filter_sinc(4.0){} }; //-----------------------------------------------image_filter_sinc100 class image_filter_sinc100 : public image_filter_sinc { public: image_filter_sinc100() : image_filter_sinc(5.0){} }; //-----------------------------------------------image_filter_sinc144 class image_filter_sinc144 : public image_filter_sinc { public: image_filter_sinc144() : image_filter_sinc(6.0){} }; //-----------------------------------------------image_filter_sinc196 class image_filter_sinc196 : public image_filter_sinc { public: image_filter_sinc196() : image_filter_sinc(7.0){} }; //-----------------------------------------------image_filter_sinc256 class image_filter_sinc256 : public image_filter_sinc { public: image_filter_sinc256() : image_filter_sinc(8.0){} }; //---------------------------------------------image_filter_lanczos36 class image_filter_lanczos36 : public image_filter_lanczos { public: image_filter_lanczos36() : image_filter_lanczos(3.0){} }; //---------------------------------------------image_filter_lanczos64 class image_filter_lanczos64 : public image_filter_lanczos { public: image_filter_lanczos64() : image_filter_lanczos(4.0){} }; //--------------------------------------------image_filter_lanczos100 class image_filter_lanczos100 : public image_filter_lanczos { public: image_filter_lanczos100() : image_filter_lanczos(5.0){} }; //--------------------------------------------image_filter_lanczos144 class image_filter_lanczos144 : public image_filter_lanczos { public: image_filter_lanczos144() : image_filter_lanczos(6.0){} }; //--------------------------------------------image_filter_lanczos196 class image_filter_lanczos196 : public image_filter_lanczos { public: image_filter_lanczos196() : image_filter_lanczos(7.0){} }; //--------------------------------------------image_filter_lanczos256 class image_filter_lanczos256 : public image_filter_lanczos { public: image_filter_lanczos256() : image_filter_lanczos(8.0){} }; //--------------------------------------------image_filter_blackman36 class image_filter_blackman36 : public image_filter_blackman { public: image_filter_blackman36() : image_filter_blackman(3.0){} }; //--------------------------------------------image_filter_blackman64 class image_filter_blackman64 : public image_filter_blackman { public: image_filter_blackman64() : image_filter_blackman(4.0){} }; //-------------------------------------------image_filter_blackman100 class image_filter_blackman100 : public image_filter_blackman { public: image_filter_blackman100() : image_filter_blackman(5.0){} }; //-------------------------------------------image_filter_blackman144 class image_filter_blackman144 : public image_filter_blackman { public: image_filter_blackman144() : image_filter_blackman(6.0){} }; //-------------------------------------------image_filter_blackman196 class image_filter_blackman196 : public image_filter_blackman { public: image_filter_blackman196() : image_filter_blackman(7.0){} }; //-------------------------------------------image_filter_blackman256 class image_filter_blackman256 : public image_filter_blackman { public: image_filter_blackman256() : image_filter_blackman(8.0){} }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_trans_bilinear.h0000644000175000017500000001275212516137326024766 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Bilinear 2D transformations // //---------------------------------------------------------------------------- #ifndef AGG_TRANS_BILINEAR_INCLUDED #define AGG_TRANS_BILINEAR_INCLUDED #include "agg_basics.h" #include "agg_simul_eq.h" namespace agg24 { //==========================================================trans_bilinear class trans_bilinear { public: //-------------------------------------------------------------------- trans_bilinear() : m_valid(false) {} //-------------------------------------------------------------------- // Arbitrary quadrangle transformations trans_bilinear(const double* src, const double* dst) { quad_to_quad(src, dst); } //-------------------------------------------------------------------- // Direct transformations trans_bilinear(double x1, double y1, double x2, double y2, const double* quad) { rect_to_quad(x1, y1, x2, y2, quad); } //-------------------------------------------------------------------- // Reverse transformations trans_bilinear(const double* quad, double x1, double y1, double x2, double y2) { quad_to_rect(quad, x1, y1, x2, y2); } //-------------------------------------------------------------------- // Set the transformations using two arbitrary quadrangles. void quad_to_quad(const double* src, const double* dst) { double left[4][4]; double right[4][2]; unsigned i; for(i = 0; i < 4; i++) { unsigned ix = i * 2; unsigned iy = ix + 1; left[i][0] = 1.0; left[i][1] = src[ix] * src[iy]; left[i][2] = src[ix]; left[i][3] = src[iy]; right[i][0] = dst[ix]; right[i][1] = dst[iy]; } m_valid = simul_eq<4, 2>::solve(left, right, m_mtx); } //-------------------------------------------------------------------- // Set the direct transformations, i.e., rectangle -> quadrangle void rect_to_quad(double x1, double y1, double x2, double y2, const double* quad) { double src[8]; src[0] = src[6] = x1; src[2] = src[4] = x2; src[1] = src[3] = y1; src[5] = src[7] = y2; quad_to_quad(src, quad); } //-------------------------------------------------------------------- // Set the reverse transformations, i.e., quadrangle -> rectangle void quad_to_rect(const double* quad, double x1, double y1, double x2, double y2) { double dst[8]; dst[0] = dst[6] = x1; dst[2] = dst[4] = x2; dst[1] = dst[3] = y1; dst[5] = dst[7] = y2; quad_to_quad(quad, dst); } //-------------------------------------------------------------------- // Check if the equations were solved successfully bool is_valid() const { return m_valid; } //-------------------------------------------------------------------- // Transform a point (x, y) void transform(double* x, double* y) const { double tx = *x; double ty = *y; double xy = tx * ty; *x = m_mtx[0][0] + m_mtx[1][0] * xy + m_mtx[2][0] * tx + m_mtx[3][0] * ty; *y = m_mtx[0][1] + m_mtx[1][1] * xy + m_mtx[2][1] * tx + m_mtx[3][1] * ty; } //-------------------------------------------------------------------- class iterator_x { double inc_x; double inc_y; public: double x; double y; iterator_x() {} iterator_x(double tx, double ty, double step, const double m[4][2]) : inc_x(m[1][0] * step * ty + m[2][0] * step), inc_y(m[1][1] * step * ty + m[2][1] * step), x(m[0][0] + m[1][0] * tx * ty + m[2][0] * tx + m[3][0] * ty), y(m[0][1] + m[1][1] * tx * ty + m[2][1] * tx + m[3][1] * ty) { } void operator ++ () { x += inc_x; y += inc_y; } }; iterator_x begin(double x, double y, double step) const { return iterator_x(x, y, step, m_mtx); } private: double m_mtx[4][2]; bool m_valid; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_scanline_storage_aa.h0000644000175000017500000006511312516137326025752 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for 32-bit screen coordinates has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_SCANLINE_STORAGE_AA_INCLUDED #define AGG_SCANLINE_STORAGE_AA_INCLUDED #include #include #include #include "agg_array.h" namespace agg24 { //----------------------------------------------scanline_cell_storage template class scanline_cell_storage { struct extra_span { unsigned len; T* ptr; }; public: typedef T value_type; //--------------------------------------------------------------- ~scanline_cell_storage() { remove_all(); } //--------------------------------------------------------------- scanline_cell_storage() : m_cells(128-2), m_extra_storage() {} // Copying //--------------------------------------------------------------- scanline_cell_storage(const scanline_cell_storage& v) : m_cells(v.m_cells), m_extra_storage() { copy_extra_storage(v); } //--------------------------------------------------------------- const scanline_cell_storage& operator = (const scanline_cell_storage& v) { remove_all(); m_cells = v.m_cells; copy_extra_storage(v); return *this; } //--------------------------------------------------------------- void remove_all() { int i; for(i = m_extra_storage.size()-1; i >= 0; --i) { pod_allocator::deallocate(m_extra_storage[i].ptr, m_extra_storage[i].len); } m_extra_storage.remove_all(); m_cells.remove_all(); } //--------------------------------------------------------------- int add_cells(const T* cells, unsigned num_cells) { int idx = m_cells.allocate_continuous_block(num_cells); if(idx >= 0) { T* ptr = &m_cells[idx]; memcpy(ptr, cells, sizeof(T) * num_cells); return idx; } extra_span s; s.len = num_cells; s.ptr = pod_allocator::allocate(num_cells); memcpy(s.ptr, cells, sizeof(T) * num_cells); m_extra_storage.add(s); return -int(m_extra_storage.size()); } //--------------------------------------------------------------- const T* operator [] (int idx) const { if(idx >= 0) { if((unsigned)idx >= m_cells.size()) return 0; return &m_cells[(unsigned)idx]; } unsigned i = unsigned(-idx - 1); if(i >= m_extra_storage.size()) return 0; return m_extra_storage[i].ptr; } //--------------------------------------------------------------- T* operator [] (int idx) { if(idx >= 0) { if((unsigned)idx >= m_cells.size()) return 0; return &m_cells[(unsigned)idx]; } unsigned i = unsigned(-idx - 1); if(i >= m_extra_storage.size()) return 0; return m_extra_storage[i].ptr; } private: void copy_extra_storage(const scanline_cell_storage& v) { unsigned i; for(i = 0; i < v.m_extra_storage.size(); ++i) { const extra_span& src = v.m_extra_storage[i]; extra_span dst; dst.len = src.len; dst.ptr = pod_allocator::allocate(dst.len); memcpy(dst.ptr, src.ptr, dst.len * sizeof(T)); m_extra_storage.add(dst); } } pod_bvector m_cells; pod_bvector m_extra_storage; }; //-----------------------------------------------scanline_storage_aa template class scanline_storage_aa { public: typedef T cover_type; //--------------------------------------------------------------- struct span_data { int32 x; int32 len; // If negative, it's a solid span, covers is valid int covers_id; // The index of the cells in the scanline_cell_storage }; //--------------------------------------------------------------- struct scanline_data { int y; unsigned num_spans; unsigned start_span; }; //--------------------------------------------------------------- class embedded_scanline { public: //----------------------------------------------------------- class const_iterator { public: struct span { int32 x; int32 len; // If negative, it's a solid span, covers is valid const T* covers; }; const_iterator() : m_storage(0) {} const_iterator(const embedded_scanline& sl) : m_storage(sl.m_storage), m_span_idx(sl.m_scanline.start_span) { init_span(); } const span& operator*() const { return m_span; } const span* operator->() const { return &m_span; } void operator ++ () { ++m_span_idx; init_span(); } private: void init_span() { const span_data& s = m_storage->span_by_index(m_span_idx); m_span.x = s.x; m_span.len = s.len; m_span.covers = m_storage->covers_by_index(s.covers_id); } const scanline_storage_aa* m_storage; unsigned m_span_idx; span m_span; }; friend class const_iterator; //----------------------------------------------------------- embedded_scanline(const scanline_storage_aa& storage) : m_storage(&storage) { init(0); } //----------------------------------------------------------- void reset(int, int) {} unsigned num_spans() const { return m_scanline.num_spans; } int y() const { return m_scanline.y; } const_iterator begin() const { return const_iterator(*this); } //----------------------------------------------------------- void init(unsigned scanline_idx) { m_scanline_idx = scanline_idx; m_scanline = m_storage->scanline_by_index(m_scanline_idx); } private: const scanline_storage_aa* m_storage; scanline_data m_scanline; unsigned m_scanline_idx; }; //--------------------------------------------------------------- scanline_storage_aa() : m_covers(), m_spans(256-2), // Block increment size m_scanlines(), m_min_x( 0x7FFFFFFF), m_min_y( 0x7FFFFFFF), m_max_x(-0x7FFFFFFF), m_max_y(-0x7FFFFFFF), m_cur_scanline(0) { m_fake_scanline.y = 0; m_fake_scanline.num_spans = 0; m_fake_scanline.start_span = 0; m_fake_span.x = 0; m_fake_span.len = 0; m_fake_span.covers_id = 0; } // Renderer Interface //--------------------------------------------------------------- void prepare() { m_covers.remove_all(); m_scanlines.remove_all(); m_spans.remove_all(); m_min_x = 0x7FFFFFFF; m_min_y = 0x7FFFFFFF; m_max_x = -0x7FFFFFFF; m_max_y = -0x7FFFFFFF; m_cur_scanline = 0; } //--------------------------------------------------------------- template void render(const Scanline& sl) { scanline_data sl_this; int y = sl.y(); if(y < m_min_y) m_min_y = y; if(y > m_max_y) m_max_y = y; sl_this.y = y; sl_this.num_spans = sl.num_spans(); sl_this.start_span = m_spans.size(); typename Scanline::const_iterator span_iterator = sl.begin(); unsigned num_spans = sl_this.num_spans; for(;;) { span_data sp; sp.x = span_iterator->x; sp.len = span_iterator->len; int len = abs(int(sp.len)); sp.covers_id = m_covers.add_cells(span_iterator->covers, unsigned(len)); m_spans.add(sp); int x1 = sp.x; int x2 = sp.x + len - 1; if(x1 < m_min_x) m_min_x = x1; if(x2 > m_max_x) m_max_x = x2; if(--num_spans == 0) break; ++span_iterator; } m_scanlines.add(sl_this); } //--------------------------------------------------------------- // Iterate scanlines interface int min_x() const { return m_min_x; } int min_y() const { return m_min_y; } int max_x() const { return m_max_x; } int max_y() const { return m_max_y; } //--------------------------------------------------------------- bool rewind_scanlines() { m_cur_scanline = 0; return m_scanlines.size() > 0; } //--------------------------------------------------------------- template bool sweep_scanline(Scanline& sl) { sl.reset_spans(); for(;;) { if(m_cur_scanline >= m_scanlines.size()) return false; const scanline_data& sl_this = m_scanlines[m_cur_scanline]; unsigned num_spans = sl_this.num_spans; unsigned span_idx = sl_this.start_span; do { const span_data& sp = m_spans[span_idx++]; const T* covers = covers_by_index(sp.covers_id); if(sp.len < 0) { sl.add_span(sp.x, unsigned(-sp.len), *covers); } else { sl.add_cells(sp.x, sp.len, covers); } } while(--num_spans); ++m_cur_scanline; if(sl.num_spans()) { sl.finalize(sl_this.y); break; } } return true; } //--------------------------------------------------------------- // Specialization for embedded_scanline bool sweep_scanline(embedded_scanline& sl) { do { if(m_cur_scanline >= m_scanlines.size()) return false; sl.init(m_cur_scanline); ++m_cur_scanline; } while(sl.num_spans() == 0); return true; } //--------------------------------------------------------------- unsigned byte_size() const { unsigned i; unsigned size = sizeof(int32) * 4; // min_x, min_y, max_x, max_y for(i = 0; i < m_scanlines.size(); ++i) { size += sizeof(int32) * 3; // scanline size in bytes, Y, num_spans const scanline_data& sl_this = m_scanlines[i]; unsigned num_spans = sl_this.num_spans; unsigned span_idx = sl_this.start_span; do { const span_data& sp = m_spans[span_idx++]; size += sizeof(int32) * 2; // X, span_len if(sp.len < 0) { size += sizeof(T); // cover } else { size += sizeof(T) * unsigned(sp.len); // covers } } while(--num_spans); } return size; } //--------------------------------------------------------------- static void write_int32(int8u* dst, int32 val) { dst[0] = ((const int8u*)&val)[0]; dst[1] = ((const int8u*)&val)[1]; dst[2] = ((const int8u*)&val)[2]; dst[3] = ((const int8u*)&val)[3]; } //--------------------------------------------------------------- void serialize(int8u* data) const { unsigned i; write_int32(data, min_x()); // min_x data += sizeof(int32); write_int32(data, min_y()); // min_y data += sizeof(int32); write_int32(data, max_x()); // max_x data += sizeof(int32); write_int32(data, max_y()); // max_y data += sizeof(int32); for(i = 0; i < m_scanlines.size(); ++i) { const scanline_data& sl_this = m_scanlines[i]; int8u* size_ptr = data; data += sizeof(int32); // Reserve space for scanline size in bytes write_int32(data, sl_this.y); // Y data += sizeof(int32); write_int32(data, sl_this.num_spans); // num_spans data += sizeof(int32); unsigned num_spans = sl_this.num_spans; unsigned span_idx = sl_this.start_span; do { const span_data& sp = m_spans[span_idx++]; const T* covers = covers_by_index(sp.covers_id); write_int32(data, sp.x); // X data += sizeof(int32); write_int32(data, sp.len); // span_len data += sizeof(int32); if(sp.len < 0) { memcpy(data, covers, sizeof(T)); data += sizeof(T); } else { memcpy(data, covers, unsigned(sp.len) * sizeof(T)); data += sizeof(T) * unsigned(sp.len); } } while(--num_spans); write_int32(size_ptr, int32(unsigned(data - size_ptr))); } } //--------------------------------------------------------------- const scanline_data& scanline_by_index(unsigned i) const { return (i < m_scanlines.size()) ? m_scanlines[i] : m_fake_scanline; } //--------------------------------------------------------------- const span_data& span_by_index(unsigned i) const { return (i < m_spans.size()) ? m_spans[i] : m_fake_span; } //--------------------------------------------------------------- const T* covers_by_index(int i) const { return m_covers[i]; } private: scanline_cell_storage m_covers; pod_bvector m_spans; pod_bvector m_scanlines; span_data m_fake_span; scanline_data m_fake_scanline; int m_min_x; int m_min_y; int m_max_x; int m_max_y; unsigned m_cur_scanline; }; typedef scanline_storage_aa scanline_storage_aa8; //--------scanline_storage_aa8 typedef scanline_storage_aa scanline_storage_aa16; //--------scanline_storage_aa16 typedef scanline_storage_aa scanline_storage_aa32; //--------scanline_storage_aa32 //------------------------------------------serialized_scanlines_adaptor_aa template class serialized_scanlines_adaptor_aa { public: typedef T cover_type; //--------------------------------------------------------------------- class embedded_scanline { public: typedef T cover_type; //----------------------------------------------------------------- class const_iterator { public: struct span { int32 x; int32 len; // If negative, it's a solid span, "covers" is valid const T* covers; }; const_iterator() : m_ptr(0) {} const_iterator(const embedded_scanline& sl) : m_ptr(sl.m_ptr), m_dx(sl.m_dx) { init_span(); } const span& operator*() const { return m_span; } const span* operator->() const { return &m_span; } void operator ++ () { if(m_span.len < 0) { m_ptr += sizeof(T); } else { m_ptr += m_span.len * sizeof(T); } init_span(); } private: int read_int32() { int32 val; ((int8u*)&val)[0] = *m_ptr++; ((int8u*)&val)[1] = *m_ptr++; ((int8u*)&val)[2] = *m_ptr++; ((int8u*)&val)[3] = *m_ptr++; return val; } void init_span() { m_span.x = read_int32() + m_dx; m_span.len = read_int32(); m_span.covers = m_ptr; } const int8u* m_ptr; span m_span; int m_dx; }; friend class const_iterator; //----------------------------------------------------------------- embedded_scanline() : m_ptr(0), m_y(0), m_num_spans(0) {} //----------------------------------------------------------------- void reset(int, int) {} unsigned num_spans() const { return m_num_spans; } int y() const { return m_y; } const_iterator begin() const { return const_iterator(*this); } private: //----------------------------------------------------------------- int read_int32() { int32 val; ((int8u*)&val)[0] = *m_ptr++; ((int8u*)&val)[1] = *m_ptr++; ((int8u*)&val)[2] = *m_ptr++; ((int8u*)&val)[3] = *m_ptr++; return val; } public: //----------------------------------------------------------------- void init(const int8u* ptr, int dx, int dy) { m_ptr = ptr; m_y = read_int32() + dy; m_num_spans = unsigned(read_int32()); m_dx = dx; } private: const int8u* m_ptr; int m_y; unsigned m_num_spans; int m_dx; }; public: //-------------------------------------------------------------------- serialized_scanlines_adaptor_aa() : m_data(0), m_end(0), m_ptr(0), m_dx(0), m_dy(0), m_min_x(0x7FFFFFFF), m_min_y(0x7FFFFFFF), m_max_x(-0x7FFFFFFF), m_max_y(-0x7FFFFFFF) {} //-------------------------------------------------------------------- serialized_scanlines_adaptor_aa(const int8u* data, unsigned size, double dx, double dy) : m_data(data), m_end(data + size), m_ptr(data), m_dx(iround(dx)), m_dy(iround(dy)), m_min_x(0x7FFFFFFF), m_min_y(0x7FFFFFFF), m_max_x(-0x7FFFFFFF), m_max_y(-0x7FFFFFFF) {} //-------------------------------------------------------------------- void init(const int8u* data, unsigned size, double dx, double dy) { m_data = data; m_end = data + size; m_ptr = data; m_dx = iround(dx); m_dy = iround(dy); m_min_x = 0x7FFFFFFF; m_min_y = 0x7FFFFFFF; m_max_x = -0x7FFFFFFF; m_max_y = -0x7FFFFFFF; } private: //-------------------------------------------------------------------- int read_int32() { int32 val; ((int8u*)&val)[0] = *m_ptr++; ((int8u*)&val)[1] = *m_ptr++; ((int8u*)&val)[2] = *m_ptr++; ((int8u*)&val)[3] = *m_ptr++; return val; } //-------------------------------------------------------------------- unsigned read_int32u() { int32u val; ((int8u*)&val)[0] = *m_ptr++; ((int8u*)&val)[1] = *m_ptr++; ((int8u*)&val)[2] = *m_ptr++; ((int8u*)&val)[3] = *m_ptr++; return val; } public: // Iterate scanlines interface //-------------------------------------------------------------------- bool rewind_scanlines() { m_ptr = m_data; if(m_ptr < m_end) { m_min_x = read_int32() + m_dx; m_min_y = read_int32() + m_dy; m_max_x = read_int32() + m_dx; m_max_y = read_int32() + m_dy; } return m_ptr < m_end; } //-------------------------------------------------------------------- int min_x() const { return m_min_x; } int min_y() const { return m_min_y; } int max_x() const { return m_max_x; } int max_y() const { return m_max_y; } //-------------------------------------------------------------------- template bool sweep_scanline(Scanline& sl) { sl.reset_spans(); for(;;) { if(m_ptr >= m_end) return false; read_int32(); // Skip scanline size in bytes int y = read_int32() + m_dy; unsigned num_spans = read_int32(); do { int x = read_int32() + m_dx; int len = read_int32(); if(len < 0) { sl.add_span(x, unsigned(-len), *m_ptr); m_ptr += sizeof(T); } else { sl.add_cells(x, len, m_ptr); m_ptr += len * sizeof(T); } } while(--num_spans); if(sl.num_spans()) { sl.finalize(y); break; } } return true; } //-------------------------------------------------------------------- // Specialization for embedded_scanline bool sweep_scanline(embedded_scanline& sl) { do { if(m_ptr >= m_end) return false; unsigned byte_size = read_int32u(); sl.init(m_ptr, m_dx, m_dy); m_ptr += byte_size - sizeof(int32); } while(sl.num_spans() == 0); return true; } private: const int8u* m_data; const int8u* m_end; const int8u* m_ptr; int m_dx; int m_dy; int m_min_x; int m_min_y; int m_max_x; int m_max_y; }; typedef serialized_scanlines_adaptor_aa serialized_scanlines_adaptor_aa8; //----serialized_scanlines_adaptor_aa8 typedef serialized_scanlines_adaptor_aa serialized_scanlines_adaptor_aa16; //----serialized_scanlines_adaptor_aa16 typedef serialized_scanlines_adaptor_aa serialized_scanlines_adaptor_aa32; //----serialized_scanlines_adaptor_aa32 } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_renderer_raster_text.h0000644000175000017500000002143712516137326026224 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_RENDERER_RASTER_TEXT_INCLUDED #define AGG_RENDERER_RASTER_TEXT_INCLUDED #include "agg_basics.h" namespace agg24 { //==============================================renderer_raster_htext_solid template class renderer_raster_htext_solid { public: typedef BaseRenderer ren_type; typedef GlyphGenerator glyph_gen_type; typedef typename glyph_gen_type::glyph_rect glyph_rect; typedef typename ren_type::color_type color_type; renderer_raster_htext_solid(ren_type& ren, glyph_gen_type& glyph) : m_ren(&ren), m_glyph(&glyph) {} void attach(ren_type& ren) { m_ren = &ren; } //-------------------------------------------------------------------- void color(const color_type& c) { m_color = c; } const color_type& color() const { return m_color; } //-------------------------------------------------------------------- template void render_text(double x, double y, const CharT* str, bool flip=false) { glyph_rect r; while(*str) { m_glyph->prepare(&r, x, y, *str, flip); if(r.x2 >= r.x1) { int i; if(flip) { for(i = r.y1; i <= r.y2; i++) { m_ren->blend_solid_hspan(r.x1, i, (r.x2 - r.x1 + 1), m_color, m_glyph->span(r.y2 - i)); } } else { for(i = r.y1; i <= r.y2; i++) { m_ren->blend_solid_hspan(r.x1, i, (r.x2 - r.x1 + 1), m_color, m_glyph->span(i - r.y1)); } } } x += r.dx; y += r.dy; ++str; } } private: ren_type* m_ren; glyph_gen_type* m_glyph; color_type m_color; }; //=============================================renderer_raster_vtext_solid template class renderer_raster_vtext_solid { public: typedef BaseRenderer ren_type; typedef GlyphGenerator glyph_gen_type; typedef typename glyph_gen_type::glyph_rect glyph_rect; typedef typename ren_type::color_type color_type; renderer_raster_vtext_solid(ren_type& ren, glyph_gen_type& glyph) : m_ren(&ren), m_glyph(&glyph) { } //-------------------------------------------------------------------- void color(const color_type& c) { m_color = c; } const color_type& color() const { return m_color; } //-------------------------------------------------------------------- template void render_text(double x, double y, const CharT* str, bool flip=false) { glyph_rect r; while(*str) { m_glyph->prepare(&r, x, y, *str, !flip); if(r.x2 >= r.x1) { int i; if(flip) { for(i = r.y1; i <= r.y2; i++) { m_ren->blend_solid_vspan(i, r.x1, (r.x2 - r.x1 + 1), m_color, m_glyph->span(i - r.y1)); } } else { for(i = r.y1; i <= r.y2; i++) { m_ren->blend_solid_vspan(i, r.x1, (r.x2 - r.x1 + 1), m_color, m_glyph->span(r.y2 - i)); } } } x += r.dx; y += r.dy; ++str; } } private: ren_type* m_ren; glyph_gen_type* m_glyph; color_type m_color; }; //===================================================renderer_raster_htext template class renderer_raster_htext { public: typedef ScanlineRenderer ren_type; typedef GlyphGenerator glyph_gen_type; typedef typename glyph_gen_type::glyph_rect glyph_rect; class scanline_single_span { public: typedef agg24::cover_type cover_type; //---------------------------------------------------------------- struct const_span { int x; unsigned len; const cover_type* covers; const_span() {} const_span(int x_, unsigned len_, const cover_type* covers_) : x(x_), len(len_), covers(covers_) {} }; typedef const const_span* const_iterator; //---------------------------------------------------------------- scanline_single_span(int x, int y, unsigned len, const cover_type* covers) : m_y(y), m_span(x, len, covers) {} //---------------------------------------------------------------- int y() const { return m_y; } unsigned num_spans() const { return 1; } const_iterator begin() const { return &m_span; } private: //---------------------------------------------------------------- int m_y; const_span m_span; }; //-------------------------------------------------------------------- renderer_raster_htext(ren_type& ren, glyph_gen_type& glyph) : m_ren(&ren), m_glyph(&glyph) { } //-------------------------------------------------------------------- template void render_text(double x, double y, const CharT* str, bool flip=false) { glyph_rect r; while(*str) { m_glyph->prepare(&r, x, y, *str, flip); if(r.x2 >= r.x1) { m_ren->prepare(); int i; if(flip) { for(i = r.y1; i <= r.y2; i++) { m_ren->render( scanline_single_span(r.x1, i, (r.x2 - r.x1 + 1), m_glyph->span(r.y2 - i))); } } else { for(i = r.y1; i <= r.y2; i++) { m_ren->render( scanline_single_span(r.x1, i, (r.x2 - r.x1 + 1), m_glyph->span(i - r.y1))); } } } x += r.dx; y += r.dy; ++str; } } private: ren_type* m_ren; glyph_gen_type* m_glyph; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_renderer_primitives.h0000644000175000017500000001752612516137326026057 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class renderer_primitives // //---------------------------------------------------------------------------- #ifndef AGG_RENDERER_PRIMITIVES_INCLUDED #define AGG_RENDERER_PRIMITIVES_INCLUDED #include "agg_basics.h" #include "agg_renderer_base.h" #include "agg_dda_line.h" #include "agg_ellipse_bresenham.h" namespace agg24 { //-----------------------------------------------------renderer_primitives template class renderer_primitives { public: typedef BaseRenderer base_ren_type; typedef typename base_ren_type::color_type color_type; //-------------------------------------------------------------------- renderer_primitives(base_ren_type& ren) : m_ren(&ren), m_fill_color(), m_line_color(), m_curr_x(0), m_curr_y(0) {} void attach(base_ren_type& ren) { m_ren = &ren; } //-------------------------------------------------------------------- static int coord(double c) { return iround(c * line_bresenham_interpolator::subpixel_scale); } //-------------------------------------------------------------------- void fill_color(const color_type& c) { m_fill_color = c; } void line_color(const color_type& c) { m_line_color = c; } const color_type& fill_color() const { return m_fill_color; } const color_type& line_color() const { return m_line_color; } //-------------------------------------------------------------------- void rectangle(int x1, int y1, int x2, int y2) { m_ren->blend_hline(x1, y1, x2-1, m_line_color, cover_full); m_ren->blend_vline(x2, y1, y2-1, m_line_color, cover_full); m_ren->blend_hline(x1+1, y2, x2, m_line_color, cover_full); m_ren->blend_vline(x1, y1+1, y2, m_line_color, cover_full); } //-------------------------------------------------------------------- void solid_rectangle(int x1, int y1, int x2, int y2) { m_ren->blend_bar(x1, y1, x2, y2, m_fill_color, cover_full); } //-------------------------------------------------------------------- void outlined_rectangle(int x1, int y1, int x2, int y2) { rectangle(x1, y1, x2, y2); m_ren->blend_bar(x1+1, y1+1, x2-1, y2-1, m_fill_color, cover_full); } //-------------------------------------------------------------------- void ellipse(int x, int y, int rx, int ry) { ellipse_bresenham_interpolator ei(rx, ry); int dx = 0; int dy = -ry; do { dx += ei.dx(); dy += ei.dy(); m_ren->blend_pixel(x + dx, y + dy, m_line_color, cover_full); m_ren->blend_pixel(x + dx, y - dy, m_line_color, cover_full); m_ren->blend_pixel(x - dx, y - dy, m_line_color, cover_full); m_ren->blend_pixel(x - dx, y + dy, m_line_color, cover_full); ++ei; } while(dy < 0); } //-------------------------------------------------------------------- void solid_ellipse(int x, int y, int rx, int ry) { ellipse_bresenham_interpolator ei(rx, ry); int dx = 0; int dy = -ry; int dy0 = dy; int dx0 = dx; do { dx += ei.dx(); dy += ei.dy(); if(dy != dy0) { m_ren->blend_hline(x-dx0, y+dy0, x+dx0, m_fill_color, cover_full); m_ren->blend_hline(x-dx0, y-dy0, x+dx0, m_fill_color, cover_full); } dx0 = dx; dy0 = dy; ++ei; } while(dy < 0); m_ren->blend_hline(x-dx0, y+dy0, x+dx0, m_fill_color, cover_full); } //-------------------------------------------------------------------- void outlined_ellipse(int x, int y, int rx, int ry) { ellipse_bresenham_interpolator ei(rx, ry); int dx = 0; int dy = -ry; do { dx += ei.dx(); dy += ei.dy(); m_ren->blend_pixel(x + dx, y + dy, m_line_color, cover_full); m_ren->blend_pixel(x + dx, y - dy, m_line_color, cover_full); m_ren->blend_pixel(x - dx, y - dy, m_line_color, cover_full); m_ren->blend_pixel(x - dx, y + dy, m_line_color, cover_full); if(ei.dy() && dx) { m_ren->blend_hline(x-dx+1, y+dy, x+dx-1, m_fill_color, cover_full); m_ren->blend_hline(x-dx+1, y-dy, x+dx-1, m_fill_color, cover_full); } ++ei; } while(dy < 0); } //-------------------------------------------------------------------- void line(int x1, int y1, int x2, int y2, bool last=false) { line_bresenham_interpolator li(x1, y1, x2, y2); unsigned len = li.len(); if(len == 0) { if(last) { m_ren->blend_pixel(li.line_lr(x1), li.line_lr(y1), m_line_color, cover_full); } return; } if(last) ++len; if(li.is_ver()) { do { m_ren->blend_pixel(li.x2(), li.y1(), m_line_color, cover_full); li.vstep(); } while(--len); } else { do { m_ren->blend_pixel(li.x1(), li.y2(), m_line_color, cover_full); li.hstep(); } while(--len); } } //-------------------------------------------------------------------- void move_to(int x, int y) { m_curr_x = x; m_curr_y = y; } //-------------------------------------------------------------------- void line_to(int x, int y, bool last=false) { line(m_curr_x, m_curr_y, x, y, last); m_curr_x = x; m_curr_y = y; } //-------------------------------------------------------------------- const base_ren_type& ren() const { return *m_ren; } base_ren_type& ren() { return *m_ren; } //-------------------------------------------------------------------- const rendering_buffer& rbuf() const { return m_ren->rbuf(); } rendering_buffer& rbuf() { return m_ren->rbuf(); } private: base_ren_type* m_ren; color_type m_fill_color; color_type m_line_color; int m_curr_x; int m_curr_y; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_ellipse_bresenham.h0000644000175000017500000000560612516137326025453 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Simple Bresenham interpolator for ellipsees // //---------------------------------------------------------------------------- #ifndef AGG_ELLIPSE_BRESENHAM_INCLUDED #define AGG_ELLIPSE_BRESENHAM_INCLUDED #include "agg_basics.h" namespace agg24 { //------------------------------------------ellipse_bresenham_interpolator class ellipse_bresenham_interpolator { public: ellipse_bresenham_interpolator(int rx, int ry) : m_rx2(rx * rx), m_ry2(ry * ry), m_two_rx2(m_rx2 << 1), m_two_ry2(m_ry2 << 1), m_dx(0), m_dy(0), m_inc_x(0), m_inc_y(-ry * m_two_rx2), m_cur_f(0) {} int dx() const { return m_dx; } int dy() const { return m_dy; } void operator++ () { int mx, my, mxy, min_m; int fx, fy, fxy; mx = fx = m_cur_f + m_inc_x + m_ry2; if(mx < 0) mx = -mx; my = fy = m_cur_f + m_inc_y + m_rx2; if(my < 0) my = -my; mxy = fxy = m_cur_f + m_inc_x + m_ry2 + m_inc_y + m_rx2; if(mxy < 0) mxy = -mxy; min_m = mx; bool flag = true; if(min_m > my) { min_m = my; flag = false; } m_dx = m_dy = 0; if(min_m > mxy) { m_inc_x += m_two_ry2; m_inc_y += m_two_rx2; m_cur_f = fxy; m_dx = 1; m_dy = 1; return; } if(flag) { m_inc_x += m_two_ry2; m_cur_f = fx; m_dx = 1; return; } m_inc_y += m_two_rx2; m_cur_f = fy; m_dy = 1; } private: int m_rx2; int m_ry2; int m_two_rx2; int m_two_ry2; int m_dx; int m_dy; int m_inc_x; int m_inc_y; int m_cur_f; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_color_gray.h0000644000175000017500000003336512516137326024135 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for high precision colors has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- // // color types gray8, gray16 // //---------------------------------------------------------------------------- #ifndef AGG_COLOR_GRAY_INCLUDED #define AGG_COLOR_GRAY_INCLUDED #include "agg_basics.h" #include "agg_color_rgba.h" namespace agg24 { //===================================================================gray8 struct gray8 { typedef int8u value_type; typedef int32u calc_type; typedef int32 long_type; enum base_scale_e { base_shift = 8, base_scale = 1 << base_shift, base_mask = base_scale - 1 }; typedef gray8 self_type; value_type v; value_type a; //-------------------------------------------------------------------- gray8() {} //-------------------------------------------------------------------- gray8(unsigned v_, unsigned a_=base_mask) : v(int8u(v_)), a(int8u(a_)) {} //-------------------------------------------------------------------- gray8(const self_type& c, unsigned a_) : v(c.v), a(value_type(a_)) {} //-------------------------------------------------------------------- gray8(const rgba& c) : v((value_type)uround((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask))), a((value_type)uround(c.a * double(base_mask))) {} //-------------------------------------------------------------------- gray8(const rgba& c, double a_) : v((value_type)uround((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask))), a((value_type)uround(a_ * double(base_mask))) {} //-------------------------------------------------------------------- gray8(const rgba8& c) : v((c.r*77 + c.g*150 + c.b*29) >> 8), a(c.a) {} //-------------------------------------------------------------------- gray8(const rgba8& c, unsigned a_) : v((c.r*77 + c.g*150 + c.b*29) >> 8), a(a_) {} //-------------------------------------------------------------------- void clear() { v = a = 0; } //-------------------------------------------------------------------- const self_type& transparent() { a = 0; return *this; } //-------------------------------------------------------------------- void opacity(double a_) { if(a_ < 0.0) a_ = 0.0; if(a_ > 1.0) a_ = 1.0; a = (value_type)uround(a_ * double(base_mask)); } //-------------------------------------------------------------------- double opacity() const { return double(a) / double(base_mask); } //-------------------------------------------------------------------- const self_type& premultiply() { if(a == base_mask) return *this; if(a == 0) { v = 0; return *this; } v = value_type((calc_type(v) * a) >> base_shift); return *this; } //-------------------------------------------------------------------- const self_type& premultiply(unsigned a_) { if(a == base_mask && a_ >= base_mask) return *this; if(a == 0 || a_ == 0) { v = a = 0; return *this; } calc_type v_ = (calc_type(v) * a_) / a; v = value_type((v_ > a_) ? a_ : v_); a = value_type(a_); return *this; } //-------------------------------------------------------------------- const self_type& demultiply() { if(a == base_mask) return *this; if(a == 0) { v = 0; return *this; } calc_type v_ = (calc_type(v) * base_mask) / a; v = value_type((v_ > base_mask) ? base_mask : v_); return *this; } //-------------------------------------------------------------------- self_type gradient(self_type c, double k) const { self_type ret; calc_type ik = uround(k * base_scale); ret.v = value_type(calc_type(v) + (((calc_type(c.v) - v) * ik) >> base_shift)); ret.a = value_type(calc_type(a) + (((calc_type(c.a) - a) * ik) >> base_shift)); return ret; } //-------------------------------------------------------------------- AGG_INLINE void add(const self_type& c, unsigned cover) { calc_type cv, ca; if(cover == cover_mask) { if(c.a == base_mask) { *this = c; } else { cv = v + c.v; v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv; ca = a + c.a; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca; } } else { cv = v + ((c.v * cover + cover_mask/2) >> cover_shift); ca = a + ((c.a * cover + cover_mask/2) >> cover_shift); v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca; } } //-------------------------------------------------------------------- static self_type no_color() { return self_type(0,0); } }; //-------------------------------------------------------------gray8_pre inline gray8 gray8_pre(unsigned v, unsigned a = gray8::base_mask) { return gray8(v,a).premultiply(); } inline gray8 gray8_pre(const gray8& c, unsigned a) { return gray8(c,a).premultiply(); } inline gray8 gray8_pre(const rgba& c) { return gray8(c).premultiply(); } inline gray8 gray8_pre(const rgba& c, double a) { return gray8(c,a).premultiply(); } inline gray8 gray8_pre(const rgba8& c) { return gray8(c).premultiply(); } inline gray8 gray8_pre(const rgba8& c, unsigned a) { return gray8(c,a).premultiply(); } //==================================================================gray16 struct gray16 { typedef int16u value_type; typedef int32u calc_type; typedef int64 long_type; enum base_scale_e { base_shift = 16, base_scale = 1 << base_shift, base_mask = base_scale - 1 }; typedef gray16 self_type; value_type v; value_type a; //-------------------------------------------------------------------- gray16() {} //-------------------------------------------------------------------- gray16(unsigned v_, unsigned a_=base_mask) : v(int16u(v_)), a(int16u(a_)) {} //-------------------------------------------------------------------- gray16(const self_type& c, unsigned a_) : v(c.v), a(value_type(a_)) {} //-------------------------------------------------------------------- gray16(const rgba& c) : v((value_type)uround((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask))), a((value_type)uround(c.a * double(base_mask))) {} //-------------------------------------------------------------------- gray16(const rgba& c, double a_) : v((value_type)uround((0.299*c.r + 0.587*c.g + 0.114*c.b) * double(base_mask))), a((value_type)uround(a_ * double(base_mask))) {} //-------------------------------------------------------------------- gray16(const rgba8& c) : v(c.r*77 + c.g*150 + c.b*29), a((value_type(c.a) << 8) | c.a) {} //-------------------------------------------------------------------- gray16(const rgba8& c, unsigned a_) : v(c.r*77 + c.g*150 + c.b*29), a((value_type(a_) << 8) | c.a) {} //-------------------------------------------------------------------- void clear() { v = a = 0; } //-------------------------------------------------------------------- const self_type& transparent() { a = 0; return *this; } //-------------------------------------------------------------------- void opacity(double a_) { if(a_ < 0.0) a_ = 0.0; if(a_ > 1.0) a_ = 1.0; a = (value_type)uround(a_ * double(base_mask)); } //-------------------------------------------------------------------- double opacity() const { return double(a) / double(base_mask); } //-------------------------------------------------------------------- const self_type& premultiply() { if(a == base_mask) return *this; if(a == 0) { v = 0; return *this; } v = value_type((calc_type(v) * a) >> base_shift); return *this; } //-------------------------------------------------------------------- const self_type& premultiply(unsigned a_) { if(a == base_mask && a_ >= base_mask) return *this; if(a == 0 || a_ == 0) { v = a = 0; return *this; } calc_type v_ = (calc_type(v) * a_) / a; v = value_type((v_ > a_) ? a_ : v_); a = value_type(a_); return *this; } //-------------------------------------------------------------------- const self_type& demultiply() { if(a == base_mask) return *this; if(a == 0) { v = 0; return *this; } calc_type v_ = (calc_type(v) * base_mask) / a; v = value_type((v_ > base_mask) ? base_mask : v_); return *this; } //-------------------------------------------------------------------- self_type gradient(self_type c, double k) const { self_type ret; calc_type ik = uround(k * base_scale); ret.v = value_type(calc_type(v) + (((calc_type(c.v) - v) * ik) >> base_shift)); ret.a = value_type(calc_type(a) + (((calc_type(c.a) - a) * ik) >> base_shift)); return ret; } //-------------------------------------------------------------------- AGG_INLINE void add(const self_type& c, unsigned cover) { calc_type cv, ca; if(cover == cover_mask) { if(c.a == base_mask) { *this = c; } else { cv = v + c.v; v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv; ca = a + c.a; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca; } } else { cv = v + ((c.v * cover + cover_mask/2) >> cover_shift); ca = a + ((c.a * cover + cover_mask/2) >> cover_shift); v = (cv > calc_type(base_mask)) ? calc_type(base_mask) : cv; a = (ca > calc_type(base_mask)) ? calc_type(base_mask) : ca; } } //-------------------------------------------------------------------- static self_type no_color() { return self_type(0,0); } }; //------------------------------------------------------------gray16_pre inline gray16 gray16_pre(unsigned v, unsigned a = gray16::base_mask) { return gray16(v,a).premultiply(); } inline gray16 gray16_pre(const gray16& c, unsigned a) { return gray16(c,a).premultiply(); } inline gray16 gray16_pre(const rgba& c) { return gray16(c).premultiply(); } inline gray16 gray16_pre(const rgba& c, double a) { return gray16(c,a).premultiply(); } inline gray16 gray16_pre(const rgba8& c) { return gray16(c).premultiply(); } inline gray16 gray16_pre(const rgba8& c, unsigned a) { return gray16(c,a).premultiply(); } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_renderer_markers.h0000644000175000017500000010766212516137326025331 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class renderer_markers // //---------------------------------------------------------------------------- #ifndef AGG_RENDERER_MARKERS_INCLUDED #define AGG_RENDERER_MARKERS_INCLUDED #include "agg_basics.h" #include "agg_renderer_primitives.h" namespace agg24 { //---------------------------------------------------------------marker_e enum marker_e { marker_square, marker_diamond, marker_circle, marker_crossed_circle, marker_semiellipse_left, marker_semiellipse_right, marker_semiellipse_up, marker_semiellipse_down, marker_triangle_left, marker_triangle_right, marker_triangle_up, marker_triangle_down, marker_four_rays, marker_cross, marker_x, marker_dash, marker_dot, marker_pixel, end_of_markers }; //--------------------------------------------------------renderer_markers template class renderer_markers : public renderer_primitives { public: typedef renderer_primitives base_type; typedef BaseRenderer base_ren_type; typedef typename base_ren_type::color_type color_type; //-------------------------------------------------------------------- renderer_markers(base_ren_type& rbuf) : base_type(rbuf) {} //-------------------------------------------------------------------- bool visible(int x, int y, int r) const { rect_i rc(x-r, y-r, x+y, y+r); return rc.clip(base_type::ren().bounding_clip_box()); } //-------------------------------------------------------------------- void square(int x, int y, int r) { if(visible(x, y, r)) { if(r) base_type::outlined_rectangle(x-r, y-r, x+r, y+r); else base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } //-------------------------------------------------------------------- void diamond(int x, int y, int r) { if(visible(x, y, r)) { if(r) { int dy = -r; int dx = 0; do { base_type::ren().blend_pixel(x - dx, y + dy, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x + dx, y + dy, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x - dx, y - dy, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x + dx, y - dy, base_type::line_color(), cover_full); if(dx) { base_type::ren().blend_hline(x-dx+1, y+dy, x+dx-1, base_type::fill_color(), cover_full); base_type::ren().blend_hline(x-dx+1, y-dy, x+dx-1, base_type::fill_color(), cover_full); } ++dy; ++dx; } while(dy <= 0); } else { base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } } //-------------------------------------------------------------------- void circle(int x, int y, int r) { if(visible(x, y, r)) { if(r) base_type::outlined_ellipse(x, y, r, r); else base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } //-------------------------------------------------------------------- void crossed_circle(int x, int y, int r) { if(visible(x, y, r)) { if(r) { base_type::outlined_ellipse(x, y, r, r); int r6 = r + (r >> 1); if(r <= 2) r6++; r >>= 1; base_type::ren().blend_hline(x-r6, y, x-r, base_type::line_color(), cover_full); base_type::ren().blend_hline(x+r, y, x+r6, base_type::line_color(), cover_full); base_type::ren().blend_vline(x, y-r6, y-r, base_type::line_color(), cover_full); base_type::ren().blend_vline(x, y+r, y+r6, base_type::line_color(), cover_full); } else { base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } } //------------------------------------------------------------------------ void semiellipse_left(int x, int y, int r) { if(visible(x, y, r)) { if(r) { int r8 = r * 4 / 5; int dy = -r; int dx = 0; ellipse_bresenham_interpolator ei(r * 3 / 5, r+r8); do { dx += ei.dx(); dy += ei.dy(); base_type::ren().blend_pixel(x + dy, y + dx, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x + dy, y - dx, base_type::line_color(), cover_full); if(ei.dy() && dx) { base_type::ren().blend_vline(x+dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); } ++ei; } while(dy < r8); base_type::ren().blend_vline(x+dy, y-dx, y+dx, base_type::line_color(), cover_full); } else { base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } } //-------------------------------------------------------------------- void semiellipse_right(int x, int y, int r) { if(visible(x, y, r)) { if(r) { int r8 = r * 4 / 5; int dy = -r; int dx = 0; ellipse_bresenham_interpolator ei(r * 3 / 5, r+r8); do { dx += ei.dx(); dy += ei.dy(); base_type::ren().blend_pixel(x - dy, y + dx, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x - dy, y - dx, base_type::line_color(), cover_full); if(ei.dy() && dx) { base_type::ren().blend_vline(x-dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); } ++ei; } while(dy < r8); base_type::ren().blend_vline(x-dy, y-dx, y+dx, base_type::line_color(), cover_full); } else { base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } } //-------------------------------------------------------------------- void semiellipse_up(int x, int y, int r) { if(visible(x, y, r)) { if(r) { int r8 = r * 4 / 5; int dy = -r; int dx = 0; ellipse_bresenham_interpolator ei(r * 3 / 5, r+r8); do { dx += ei.dx(); dy += ei.dy(); base_type::ren().blend_pixel(x + dx, y - dy, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x - dx, y - dy, base_type::line_color(), cover_full); if(ei.dy() && dx) { base_type::ren().blend_hline(x-dx+1, y-dy, x+dx-1, base_type::fill_color(), cover_full); } ++ei; } while(dy < r8); base_type::ren().blend_hline(x-dx, y-dy-1, x+dx, base_type::line_color(), cover_full); } else { base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } } //-------------------------------------------------------------------- void semiellipse_down(int x, int y, int r) { if(visible(x, y, r)) { if(r) { int r8 = r * 4 / 5; int dy = -r; int dx = 0; ellipse_bresenham_interpolator ei(r * 3 / 5, r+r8); do { dx += ei.dx(); dy += ei.dy(); base_type::ren().blend_pixel(x + dx, y + dy, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x - dx, y + dy, base_type::line_color(), cover_full); if(ei.dy() && dx) { base_type::ren().blend_hline(x-dx+1, y+dy, x+dx-1, base_type::fill_color(), cover_full); } ++ei; } while(dy < r8); base_type::ren().blend_hline(x-dx, y+dy+1, x+dx, base_type::line_color(), cover_full); } else { base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } } //-------------------------------------------------------------------- void triangle_left(int x, int y, int r) { if(visible(x, y, r)) { if(r) { int dy = -r; int dx = 0; int flip = 0; int r6 = r * 3 / 5; do { base_type::ren().blend_pixel(x + dy, y - dx, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x + dy, y + dx, base_type::line_color(), cover_full); if(dx) { base_type::ren().blend_vline(x+dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); } ++dy; dx += flip; flip ^= 1; } while(dy < r6); base_type::ren().blend_vline(x+dy, y-dx, y+dx, base_type::line_color(), cover_full); } else { base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } } //-------------------------------------------------------------------- void triangle_right(int x, int y, int r) { if(visible(x, y, r)) { if(r) { int dy = -r; int dx = 0; int flip = 0; int r6 = r * 3 / 5; do { base_type::ren().blend_pixel(x - dy, y - dx, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x - dy, y + dx, base_type::line_color(), cover_full); if(dx) { base_type::ren().blend_vline(x-dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); } ++dy; dx += flip; flip ^= 1; } while(dy < r6); base_type::ren().blend_vline(x-dy, y-dx, y+dx, base_type::line_color(), cover_full); } else { base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } } //-------------------------------------------------------------------- void triangle_up(int x, int y, int r) { if(visible(x, y, r)) { if(r) { int dy = -r; int dx = 0; int flip = 0; int r6 = r * 3 / 5; do { base_type::ren().blend_pixel(x - dx, y - dy, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x + dx, y - dy, base_type::line_color(), cover_full); if(dx) { base_type::ren().blend_hline(x-dx+1, y-dy, x+dx-1, base_type::fill_color(), cover_full); } ++dy; dx += flip; flip ^= 1; } while(dy < r6); base_type::ren().blend_hline(x-dx, y-dy, x+dx, base_type::line_color(), cover_full); } else { base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } } //-------------------------------------------------------------------- void triangle_down(int x, int y, int r) { if(visible(x, y, r)) { if(r) { int dy = -r; int dx = 0; int flip = 0; int r6 = r * 3 / 5; do { base_type::ren().blend_pixel(x - dx, y + dy, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x + dx, y + dy, base_type::line_color(), cover_full); if(dx) { base_type::ren().blend_hline(x-dx+1, y+dy, x+dx-1, base_type::fill_color(), cover_full); } ++dy; dx += flip; flip ^= 1; } while(dy < r6); base_type::ren().blend_hline(x-dx, y+dy, x+dx, base_type::line_color(), cover_full); } else { base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } } //-------------------------------------------------------------------- void four_rays(int x, int y, int r) { if(visible(x, y, r)) { if(r) { int dy = -r; int dx = 0; int flip = 0; int r3 = -(r / 3); do { base_type::ren().blend_pixel(x - dx, y + dy, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x + dx, y + dy, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x - dx, y - dy, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x + dx, y - dy, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x + dy, y - dx, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x + dy, y + dx, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x - dy, y - dx, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x - dy, y + dx, base_type::line_color(), cover_full); if(dx) { base_type::ren().blend_hline(x-dx+1, y+dy, x+dx-1, base_type::fill_color(), cover_full); base_type::ren().blend_hline(x-dx+1, y-dy, x+dx-1, base_type::fill_color(), cover_full); base_type::ren().blend_vline(x+dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); base_type::ren().blend_vline(x-dy, y-dx+1, y+dx-1, base_type::fill_color(), cover_full); } ++dy; dx += flip; flip ^= 1; } while(dy <= r3); base_type::solid_rectangle(x+r3+1, y+r3+1, x-r3-1, y-r3-1); } else { base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } } //-------------------------------------------------------------------- void cross(int x, int y, int r) { if(visible(x, y, r)) { if(r) { base_type::ren().blend_vline(x, y-r, y+r, base_type::line_color(), cover_full); base_type::ren().blend_hline(x-r, y, x+r, base_type::line_color(), cover_full); } else { base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } } //-------------------------------------------------------------------- void xing(int x, int y, int r) { if(visible(x, y, r)) { if(r) { int dy = -r * 7 / 10; do { base_type::ren().blend_pixel(x + dy, y + dy, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x - dy, y + dy, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x + dy, y - dy, base_type::line_color(), cover_full); base_type::ren().blend_pixel(x - dy, y - dy, base_type::line_color(), cover_full); ++dy; } while(dy < 0); } base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } //-------------------------------------------------------------------- void dash(int x, int y, int r) { if(visible(x, y, r)) { if(r) base_type::ren().blend_hline(x-r, y, x+r, base_type::line_color(), cover_full); else base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } //-------------------------------------------------------------------- void dot(int x, int y, int r) { if(visible(x, y, r)) { if(r) base_type::solid_ellipse(x, y, r, r); else base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } } //-------------------------------------------------------------------- void pixel(int x, int y, int) { base_type::ren().blend_pixel(x, y, base_type::fill_color(), cover_full); } //-------------------------------------------------------------------- void marker(int x, int y, int r, marker_e type) { switch(type) { case marker_square: square(x, y, r); break; case marker_diamond: diamond(x, y, r); break; case marker_circle: circle(x, y, r); break; case marker_crossed_circle: crossed_circle(x, y, r); break; case marker_semiellipse_left: semiellipse_left(x, y, r); break; case marker_semiellipse_right: semiellipse_right(x, y, r); break; case marker_semiellipse_up: semiellipse_up(x, y, r); break; case marker_semiellipse_down: semiellipse_down(x, y, r); break; case marker_triangle_left: triangle_left(x, y, r); break; case marker_triangle_right: triangle_right(x, y, r); break; case marker_triangle_up: triangle_up(x, y, r); break; case marker_triangle_down: triangle_down(x, y, r); break; case marker_four_rays: four_rays(x, y, r); break; case marker_cross: cross(x, y, r); break; case marker_x: xing(x, y, r); break; case marker_dash: dash(x, y, r); break; case marker_dot: dot(x, y, r); break; case marker_pixel: pixel(x, y, r); break; case end_of_markers: break; } } //-------------------------------------------------------------------- template void markers(int n, const T* x, const T* y, T r, marker_e type) { if(n <= 0) return; if(r == 0) { do { base_type::ren().blend_pixel(int(*x), int(*y), base_type::fill_color(), cover_full); ++x; ++y; } while(--n); return; } switch(type) { case marker_square: do { square (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_diamond: do { diamond (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_circle: do { circle (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_crossed_circle: do { crossed_circle (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_semiellipse_left: do { semiellipse_left (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_semiellipse_right: do { semiellipse_right(int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_semiellipse_up: do { semiellipse_up (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_semiellipse_down: do { semiellipse_down (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_triangle_left: do { triangle_left (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_triangle_right: do { triangle_right (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_triangle_up: do { triangle_up (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_triangle_down: do { triangle_down (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_four_rays: do { four_rays (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_cross: do { cross (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_x: do { xing (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_dash: do { dash (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_dot: do { dot (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; case marker_pixel: do { pixel (int(*x), int(*y), int(r)); ++x; ++y; } while(--n); break; } } //-------------------------------------------------------------------- template void markers(int n, const T* x, const T* y, const T* r, marker_e type) { if(n <= 0) return; switch(type) { case marker_square: do { square (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_diamond: do { diamond (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_circle: do { circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_crossed_circle: do { crossed_circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_semiellipse_left: do { semiellipse_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_semiellipse_right: do { semiellipse_right(int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_semiellipse_up: do { semiellipse_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_semiellipse_down: do { semiellipse_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_triangle_left: do { triangle_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_triangle_right: do { triangle_right (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_triangle_up: do { triangle_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_triangle_down: do { triangle_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_four_rays: do { four_rays (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_cross: do { cross (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_x: do { xing (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_dash: do { dash (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_dot: do { dot (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; case marker_pixel: do { pixel (int(*x), int(*y), int(*r)); ++x; ++y; ++r; } while(--n); break; } } //-------------------------------------------------------------------- template void markers(int n, const T* x, const T* y, const T* r, const color_type* fc, marker_e type) { if(n <= 0) return; switch(type) { case marker_square: do { base_type::fill_color(*fc); square (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_diamond: do { base_type::fill_color(*fc); diamond (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_circle: do { base_type::fill_color(*fc); circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_crossed_circle: do { base_type::fill_color(*fc); crossed_circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_semiellipse_left: do { base_type::fill_color(*fc); semiellipse_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_semiellipse_right: do { base_type::fill_color(*fc); semiellipse_right(int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_semiellipse_up: do { base_type::fill_color(*fc); semiellipse_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_semiellipse_down: do { base_type::fill_color(*fc); semiellipse_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_triangle_left: do { base_type::fill_color(*fc); triangle_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_triangle_right: do { base_type::fill_color(*fc); triangle_right (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_triangle_up: do { base_type::fill_color(*fc); triangle_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_triangle_down: do { base_type::fill_color(*fc); triangle_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_four_rays: do { base_type::fill_color(*fc); four_rays (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_cross: do { base_type::fill_color(*fc); cross (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_x: do { base_type::fill_color(*fc); xing (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_dash: do { base_type::fill_color(*fc); dash (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_dot: do { base_type::fill_color(*fc); dot (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; case marker_pixel: do { base_type::fill_color(*fc); pixel (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; } while(--n); break; } } //-------------------------------------------------------------------- template void markers(int n, const T* x, const T* y, const T* r, const color_type* fc, const color_type* lc, marker_e type) { if(n <= 0) return; switch(type) { case marker_square: do { base_type::fill_color(*fc); base_type::line_color(*lc); square (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_diamond: do { base_type::fill_color(*fc); base_type::line_color(*lc); diamond (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_circle: do { base_type::fill_color(*fc); base_type::line_color(*lc); circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_crossed_circle: do { base_type::fill_color(*fc); base_type::line_color(*lc); crossed_circle (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_semiellipse_left: do { base_type::fill_color(*fc); base_type::line_color(*lc); semiellipse_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_semiellipse_right: do { base_type::fill_color(*fc); base_type::line_color(*lc); semiellipse_right(int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_semiellipse_up: do { base_type::fill_color(*fc); base_type::line_color(*lc); semiellipse_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_semiellipse_down: do { base_type::fill_color(*fc); base_type::line_color(*lc); semiellipse_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_triangle_left: do { base_type::fill_color(*fc); base_type::line_color(*lc); triangle_left (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_triangle_right: do { base_type::fill_color(*fc); base_type::line_color(*lc); triangle_right (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_triangle_up: do { base_type::fill_color(*fc); base_type::line_color(*lc); triangle_up (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_triangle_down: do { base_type::fill_color(*fc); base_type::line_color(*lc); triangle_down (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_four_rays: do { base_type::fill_color(*fc); base_type::line_color(*lc); four_rays (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_cross: do { base_type::fill_color(*fc); base_type::line_color(*lc); cross (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_x: do { base_type::fill_color(*fc); base_type::line_color(*lc); xing (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_dash: do { base_type::fill_color(*fc); base_type::line_color(*lc); dash (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_dot: do { base_type::fill_color(*fc); base_type::line_color(*lc); dot (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; case marker_pixel: do { base_type::fill_color(*fc); base_type::line_color(*lc); pixel (int(*x), int(*y), int(*r)); ++x; ++y; ++r; ++fc; ++lc; } while(--n); break; } } }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/ctrl/0000755000175000017500000000000012516137725021743 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/ctrl/agg_bezier_ctrl.h0000644000175000017500000001453112516137326025237 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes bezier_ctrl_impl, bezier_ctrl // //---------------------------------------------------------------------------- #ifndef AGG_BEZIER_CTRL_INCLUDED #define AGG_BEZIER_CTRL_INCLUDED #include "agg_math.h" #include "agg_ellipse.h" #include "agg_trans_affine.h" #include "agg_color_rgba.h" #include "agg_conv_stroke.h" #include "agg_conv_curve.h" #include "agg_polygon_ctrl.h" namespace agg24 { //--------------------------------------------------------bezier_ctrl_impl class bezier_ctrl_impl : public ctrl { public: bezier_ctrl_impl(); void curve(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4); curve4& curve(); double x1() const { return m_poly.xn(0); } double y1() const { return m_poly.yn(0); } double x2() const { return m_poly.xn(1); } double y2() const { return m_poly.yn(1); } double x3() const { return m_poly.xn(2); } double y3() const { return m_poly.yn(2); } double x4() const { return m_poly.xn(3); } double y4() const { return m_poly.yn(3); } void x1(double x) { m_poly.xn(0) = x; } void y1(double y) { m_poly.yn(0) = y; } void x2(double x) { m_poly.xn(1) = x; } void y2(double y) { m_poly.yn(1) = y; } void x3(double x) { m_poly.xn(2) = x; } void y3(double y) { m_poly.yn(2) = y; } void x4(double x) { m_poly.xn(3) = x; } void y4(double y) { m_poly.yn(3) = y; } void line_width(double w) { m_stroke.width(w); } double line_width() const { return m_stroke.width(); } void point_radius(double r) { m_poly.point_radius(r); } double point_radius() const { return m_poly.point_radius(); } virtual bool in_rect(double x, double y) const; virtual bool on_mouse_button_down(double x, double y); virtual bool on_mouse_button_up(double x, double y); virtual bool on_mouse_move(double x, double y, bool button_flag); virtual bool on_arrow_keys(bool left, bool right, bool down, bool up); // Vertex source interface unsigned num_paths() { return 7; }; void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: curve4 m_curve; ellipse m_ellipse; conv_stroke m_stroke; polygon_ctrl_impl m_poly; unsigned m_idx; }; //----------------------------------------------------------bezier_ctrl template class bezier_ctrl : public bezier_ctrl_impl { public: bezier_ctrl() : m_color(rgba(0.0, 0.0, 0.0)) { } void line_color(const ColorT& c) { m_color = c; } const ColorT& color(unsigned i) const { return m_color; } private: bezier_ctrl(const bezier_ctrl&); const bezier_ctrl& operator = (const bezier_ctrl&); ColorT m_color; }; //--------------------------------------------------------curve3_ctrl_impl class curve3_ctrl_impl : public ctrl { public: curve3_ctrl_impl(); void curve(double x1, double y1, double x2, double y2, double x3, double y3); curve3& curve(); double x1() const { return m_poly.xn(0); } double y1() const { return m_poly.yn(0); } double x2() const { return m_poly.xn(1); } double y2() const { return m_poly.yn(1); } double x3() const { return m_poly.xn(2); } double y3() const { return m_poly.yn(2); } void x1(double x) { m_poly.xn(0) = x; } void y1(double y) { m_poly.yn(0) = y; } void x2(double x) { m_poly.xn(1) = x; } void y2(double y) { m_poly.yn(1) = y; } void x3(double x) { m_poly.xn(2) = x; } void y3(double y) { m_poly.yn(2) = y; } void line_width(double w) { m_stroke.width(w); } double line_width() const { return m_stroke.width(); } void point_radius(double r) { m_poly.point_radius(r); } double point_radius() const { return m_poly.point_radius(); } virtual bool in_rect(double x, double y) const; virtual bool on_mouse_button_down(double x, double y); virtual bool on_mouse_button_up(double x, double y); virtual bool on_mouse_move(double x, double y, bool button_flag); virtual bool on_arrow_keys(bool left, bool right, bool down, bool up); // Vertex source interface unsigned num_paths() { return 6; }; void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: curve3 m_curve; ellipse m_ellipse; conv_stroke m_stroke; polygon_ctrl_impl m_poly; unsigned m_idx; }; //----------------------------------------------------------curve3_ctrl template class curve3_ctrl : public curve3_ctrl_impl { public: curve3_ctrl() : m_color(rgba(0.0, 0.0, 0.0)) { } void line_color(const ColorT& c) { m_color = c; } const ColorT& color(unsigned i) const { return m_color; } private: curve3_ctrl(const curve3_ctrl&); const curve3_ctrl& operator = (const curve3_ctrl&); ColorT m_color; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/ctrl/agg_ctrl.h0000644000175000017500000000760112516137326023677 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Function render_ctrl // //---------------------------------------------------------------------------- #ifndef AGG_CTRL_INCLUDED #define AGG_CTRL_INCLUDED #include "agg_trans_affine.h" #include "agg_renderer_scanline.h" namespace agg24 { //--------------------------------------------------------------------ctrl class ctrl { public: //-------------------------------------------------------------------- virtual ~ctrl() {} ctrl(double x1, double y1, double x2, double y2, bool flip_y) : m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2), m_flip_y(flip_y), m_mtx(0) { } //-------------------------------------------------------------------- virtual bool in_rect(double x, double y) const = 0; virtual bool on_mouse_button_down(double x, double y) = 0; virtual bool on_mouse_button_up(double x, double y) = 0; virtual bool on_mouse_move(double x, double y, bool button_flag) = 0; virtual bool on_arrow_keys(bool left, bool right, bool down, bool up) = 0; //-------------------------------------------------------------------- void transform(const trans_affine& mtx) { m_mtx = &mtx; } void no_transform() { m_mtx = 0; } //-------------------------------------------------------------------- void transform_xy(double* x, double* y) const { if(m_flip_y) *y = m_y1 + m_y2 - *y; if(m_mtx) m_mtx->transform(x, y); } //-------------------------------------------------------------------- void inverse_transform_xy(double* x, double* y) const { if(m_mtx) m_mtx->inverse_transform(x, y); if(m_flip_y) *y = m_y1 + m_y2 - *y; } //-------------------------------------------------------------------- double scale() const { return m_mtx ? m_mtx->scale() : 1.0; } private: ctrl(const ctrl&); const ctrl& operator = (const ctrl&); protected: double m_x1; double m_y1; double m_x2; double m_y2; private: bool m_flip_y; const trans_affine* m_mtx; }; //-------------------------------------------------------------------- template void render_ctrl(Rasterizer& ras, Scanline& sl, Renderer& r, Ctrl& c) { unsigned i; for(i = 0; i < c.num_paths(); i++) { ras.reset(); ras.add_path(c, i); render_scanlines_aa_solid(ras, sl, r, c.color(i)); } } //-------------------------------------------------------------------- template void render_ctrl_rs(Rasterizer& ras, Scanline& sl, Renderer& r, Ctrl& c) { unsigned i; for(i = 0; i < c.num_paths(); i++) { ras.reset(); ras.add_path(c, i); r.color(c.color(i)); render_scanlines(ras, sl, r); } } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/ctrl/agg_gamma_ctrl.h0000644000175000017500000001437012516137326025042 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class gamma_ctrl // //---------------------------------------------------------------------------- #ifndef AGG_GAMMA_CTRL_INCLUDED #define AGG_GAMMA_CTRL_INCLUDED #include "agg_basics.h" #include "agg_gamma_spline.h" #include "agg_ellipse.h" #include "agg_conv_stroke.h" #include "agg_gsv_text.h" #include "agg_trans_affine.h" #include "agg_color_rgba.h" #include "agg_ctrl.h" namespace agg24 { //------------------------------------------------------------------------ // Class that can be used to create an interactive control to set up // gamma arrays. //------------------------------------------------------------------------ class gamma_ctrl_impl : public ctrl { public: gamma_ctrl_impl(double x1, double y1, double x2, double y2, bool flip_y=false); // Set other parameters void border_width(double t, double extra=0.0); void curve_width(double t) { m_curve_width = t; } void grid_width(double t) { m_grid_width = t; } void text_thickness(double t) { m_text_thickness = t; } void text_size(double h, double w=0.0); void point_size(double s) { m_point_size = s; } // Event handlers. Just call them if the respective events // in your system occure. The functions return true if redrawing // is required. virtual bool in_rect(double x, double y) const; virtual bool on_mouse_button_down(double x, double y); virtual bool on_mouse_button_up(double x, double y); virtual bool on_mouse_move(double x, double y, bool button_flag); virtual bool on_arrow_keys(bool left, bool right, bool down, bool up); void change_active_point(); // A copy of agg24::gamma_spline interface void values(double kx1, double ky1, double kx2, double ky2); void values(double* kx1, double* ky1, double* kx2, double* ky2) const; const unsigned char* gamma() const { return m_gamma_spline.gamma(); } double y(double x) const { return m_gamma_spline.y(x); } double operator() (double x) const { return m_gamma_spline.y(x); } const gamma_spline& get_gamma_spline() const { return m_gamma_spline; } // Vertex soutce interface unsigned num_paths() { return 7; } void rewind(unsigned idx); unsigned vertex(double* x, double* y); private: void calc_spline_box(); void calc_points(); void calc_values(); gamma_spline m_gamma_spline; double m_border_width; double m_border_extra; double m_curve_width; double m_grid_width; double m_text_thickness; double m_point_size; double m_text_height; double m_text_width; double m_xc1; double m_yc1; double m_xc2; double m_yc2; double m_xs1; double m_ys1; double m_xs2; double m_ys2; double m_xt1; double m_yt1; double m_xt2; double m_yt2; conv_stroke m_curve_poly; ellipse m_ellipse; gsv_text m_text; conv_stroke m_text_poly; unsigned m_idx; unsigned m_vertex; double m_vx[32]; double m_vy[32]; double m_xp1; double m_yp1; double m_xp2; double m_yp2; bool m_p1_active; unsigned m_mouse_point; double m_pdx; double m_pdy; }; template class gamma_ctrl : public gamma_ctrl_impl { public: gamma_ctrl(double x1, double y1, double x2, double y2, bool flip_y=false) : gamma_ctrl_impl(x1, y1, x2, y2, flip_y), m_background_color(rgba(1.0, 1.0, 0.9)), m_border_color(rgba(0.0, 0.0, 0.0)), m_curve_color(rgba(0.0, 0.0, 0.0)), m_grid_color(rgba(0.2, 0.2, 0.0)), m_inactive_pnt_color(rgba(0.0, 0.0, 0.0)), m_active_pnt_color(rgba(1.0, 0.0, 0.0)), m_text_color(rgba(0.0, 0.0, 0.0)) { m_colors[0] = &m_background_color; m_colors[1] = &m_border_color; m_colors[2] = &m_curve_color; m_colors[3] = &m_grid_color; m_colors[4] = &m_inactive_pnt_color; m_colors[5] = &m_active_pnt_color; m_colors[6] = &m_text_color; } // Set colors void background_color(const ColorT& c) { m_background_color = c; } void border_color(const ColorT& c) { m_border_color = c; } void curve_color(const ColorT& c) { m_curve_color = c; } void grid_color(const ColorT& c) { m_grid_color = c; } void inactive_pnt_color(const ColorT& c) { m_inactive_pnt_color = c; } void active_pnt_color(const ColorT& c) { m_active_pnt_color = c; } void text_color(const ColorT& c) { m_text_color = c; } const ColorT& color(unsigned i) const { return *m_colors[i]; } private: gamma_ctrl(const gamma_ctrl&); const gamma_ctrl& operator = (const gamma_ctrl&); ColorT m_background_color; ColorT m_border_color; ColorT m_curve_color; ColorT m_grid_color; ColorT m_inactive_pnt_color; ColorT m_active_pnt_color; ColorT m_text_color; ColorT* m_colors[7]; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/ctrl/agg_polygon_ctrl.h0000644000175000017500000001237012516137326025445 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes polygon_ctrl_impl, polygon_ctrl // //---------------------------------------------------------------------------- #ifndef POLYGON_CTRL_INCLUDED #define POLYGON_CTRL_INCLUDED #include "agg_array.h" #include "agg_conv_stroke.h" #include "agg_ellipse.h" #include "agg_color_rgba.h" #include "agg_ctrl.h" namespace agg24 { class simple_polygon_vertex_source { public: simple_polygon_vertex_source(const double* polygon, unsigned np, bool roundoff = false, bool close = true) : m_polygon(polygon), m_num_points(np), m_vertex(0), m_roundoff(roundoff), m_close(close) { } void close(bool f) { m_close = f; } bool close() const { return m_close; } void rewind(unsigned) { m_vertex = 0; } unsigned vertex(double* x, double* y) { if(m_vertex > m_num_points) return path_cmd_stop; if(m_vertex == m_num_points) { ++m_vertex; return path_cmd_end_poly | (m_close ? path_flags_close : 0); } *x = m_polygon[m_vertex * 2]; *y = m_polygon[m_vertex * 2 + 1]; if(m_roundoff) { *x = floor(*x) + 0.5; *y = floor(*y) + 0.5; } ++m_vertex; return (m_vertex == 1) ? path_cmd_move_to : path_cmd_line_to; } private: const double* m_polygon; unsigned m_num_points; unsigned m_vertex; bool m_roundoff; bool m_close; }; class polygon_ctrl_impl : public ctrl { public: polygon_ctrl_impl(unsigned np, double point_radius=5); unsigned num_points() const { return m_num_points; } double xn(unsigned n) const { return m_polygon[n * 2]; } double yn(unsigned n) const { return m_polygon[n * 2 + 1]; } double& xn(unsigned n) { return m_polygon[n * 2]; } double& yn(unsigned n) { return m_polygon[n * 2 + 1]; } const double* polygon() const { return &m_polygon[0]; } void line_width(double w) { m_stroke.width(w); } double line_width() const { return m_stroke.width(); } void point_radius(double r) { m_point_radius = r; } double point_radius() const { return m_point_radius; } void in_polygon_check(bool f) { m_in_polygon_check = f; } bool in_polygon_check() const { return m_in_polygon_check; } void close(bool f) { m_vs.close(f); } bool close() const { return m_vs.close(); } // Vertex source interface unsigned num_paths() { return 1; } void rewind(unsigned path_id); unsigned vertex(double* x, double* y); virtual bool in_rect(double x, double y) const; virtual bool on_mouse_button_down(double x, double y); virtual bool on_mouse_button_up(double x, double y); virtual bool on_mouse_move(double x, double y, bool button_flag); virtual bool on_arrow_keys(bool left, bool right, bool down, bool up); private: bool check_edge(unsigned i, double x, double y) const; bool point_in_polygon(double x, double y) const; pod_array m_polygon; unsigned m_num_points; int m_node; int m_edge; simple_polygon_vertex_source m_vs; conv_stroke m_stroke; ellipse m_ellipse; double m_point_radius; unsigned m_status; double m_dx; double m_dy; bool m_in_polygon_check; }; //----------------------------------------------------------polygon_ctrl template class polygon_ctrl : public polygon_ctrl_impl { public: polygon_ctrl(unsigned np, double point_radius=5) : polygon_ctrl_impl(np, point_radius), m_color(rgba(0.0, 0.0, 0.0)) { } void line_color(const ColorT& c) { m_color = c; } const ColorT& color(unsigned i) const { return m_color; } private: polygon_ctrl(const polygon_ctrl&); const polygon_ctrl& operator = (const polygon_ctrl&); ColorT m_color; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/ctrl/agg_cbox_ctrl.h0000644000175000017500000000722712516137326024716 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes cbox_ctrl_impl, cbox_ctrl // //---------------------------------------------------------------------------- #ifndef AGG_CBOX_CTRL_INCLUDED #define AGG_CBOX_CTRL_INCLUDED #include "agg_basics.h" #include "agg_conv_stroke.h" #include "agg_gsv_text.h" #include "agg_trans_affine.h" #include "agg_color_rgba.h" #include "agg_ctrl.h" namespace agg24 { //----------------------------------------------------------cbox_ctrl_impl class cbox_ctrl_impl : public ctrl { public: cbox_ctrl_impl(double x, double y, const char* label, bool flip_y=false); void text_thickness(double t) { m_text_thickness = t; } void text_size(double h, double w=0.0); const char* label() { return m_label; } void label(const char* l); bool status() const { return m_status; } void status(bool st) { m_status = st; } virtual bool in_rect(double x, double y) const; virtual bool on_mouse_button_down(double x, double y); virtual bool on_mouse_button_up(double x, double y); virtual bool on_mouse_move(double x, double y, bool button_flag); virtual bool on_arrow_keys(bool left, bool right, bool down, bool up); // Vertex soutce interface unsigned num_paths() { return 3; }; void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: double m_text_thickness; double m_text_height; double m_text_width; char m_label[128]; bool m_status; double m_vx[32]; double m_vy[32]; gsv_text m_text; conv_stroke m_text_poly; unsigned m_idx; unsigned m_vertex; }; //----------------------------------------------------------cbox_ctrl_impl template class cbox_ctrl : public cbox_ctrl_impl { public: cbox_ctrl(double x, double y, const char* label, bool flip_y=false) : cbox_ctrl_impl(x, y, label, flip_y), m_text_color(rgba(0.0, 0.0, 0.0)), m_inactive_color(rgba(0.0, 0.0, 0.0)), m_active_color(rgba(0.4, 0.0, 0.0)) { m_colors[0] = &m_inactive_color; m_colors[1] = &m_text_color; m_colors[2] = &m_active_color; } void text_color(const ColorT& c) { m_text_color = c; } void inactive_color(const ColorT& c) { m_inactive_color = c; } void active_color(const ColorT& c) { m_active_color = c; } const ColorT& color(unsigned i) const { return *m_colors[i]; } private: cbox_ctrl(const cbox_ctrl&); const cbox_ctrl& operator = (const cbox_ctrl&); ColorT m_text_color; ColorT m_inactive_color; ColorT m_active_color; ColorT* m_colors[3]; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/ctrl/agg_spline_ctrl.h0000644000175000017500000001336712516137326025257 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes spline_ctrl_impl, spline_ctrl // //---------------------------------------------------------------------------- #ifndef AGG_SPLINE_CTRL_INCLUDED #define AGG_SPLINE_CTRL_INCLUDED #include "agg_basics.h" #include "agg_ellipse.h" #include "agg_bspline.h" #include "agg_conv_stroke.h" #include "agg_path_storage.h" #include "agg_trans_affine.h" #include "agg_color_rgba.h" #include "agg_ctrl.h" namespace agg24 { //------------------------------------------------------------------------ // Class that can be used to create an interactive control to set up // gamma arrays. //------------------------------------------------------------------------ class spline_ctrl_impl : public ctrl { public: spline_ctrl_impl(double x1, double y1, double x2, double y2, unsigned num_pnt, bool flip_y=false); // Set other parameters void border_width(double t, double extra=0.0); void curve_width(double t) { m_curve_width = t; } void point_size(double s) { m_point_size = s; } // Event handlers. Just call them if the respective events // in your system occure. The functions return true if redrawing // is required. virtual bool in_rect(double x, double y) const; virtual bool on_mouse_button_down(double x, double y); virtual bool on_mouse_button_up(double x, double y); virtual bool on_mouse_move(double x, double y, bool button_flag); virtual bool on_arrow_keys(bool left, bool right, bool down, bool up); void active_point(int i); const double* spline() const { return m_spline_values; } const int8u* spline8() const { return m_spline_values8; } double value(double x) const; void value(unsigned idx, double y); void point(unsigned idx, double x, double y); void x(unsigned idx, double x) { m_xp[idx] = x; } void y(unsigned idx, double y) { m_yp[idx] = y; } double x(unsigned idx) const { return m_xp[idx]; } double y(unsigned idx) const { return m_yp[idx]; } void update_spline(); // Vertex soutce interface unsigned num_paths() { return 5; } void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: void calc_spline_box(); void calc_curve(); double calc_xp(unsigned idx); double calc_yp(unsigned idx); void set_xp(unsigned idx, double val); void set_yp(unsigned idx, double val); unsigned m_num_pnt; double m_xp[32]; double m_yp[32]; bspline m_spline; double m_spline_values[256]; int8u m_spline_values8[256]; double m_border_width; double m_border_extra; double m_curve_width; double m_point_size; double m_xs1; double m_ys1; double m_xs2; double m_ys2; path_storage m_curve_pnt; conv_stroke m_curve_poly; ellipse m_ellipse; unsigned m_idx; unsigned m_vertex; double m_vx[32]; double m_vy[32]; int m_active_pnt; int m_move_pnt; double m_pdx; double m_pdy; const trans_affine* m_mtx; }; template class spline_ctrl : public spline_ctrl_impl { public: spline_ctrl(double x1, double y1, double x2, double y2, unsigned num_pnt, bool flip_y=false) : spline_ctrl_impl(x1, y1, x2, y2, num_pnt, flip_y), m_background_color(rgba(1.0, 1.0, 0.9)), m_border_color(rgba(0.0, 0.0, 0.0)), m_curve_color(rgba(0.0, 0.0, 0.0)), m_inactive_pnt_color(rgba(0.0, 0.0, 0.0)), m_active_pnt_color(rgba(1.0, 0.0, 0.0)) { m_colors[0] = &m_background_color; m_colors[1] = &m_border_color; m_colors[2] = &m_curve_color; m_colors[3] = &m_inactive_pnt_color; m_colors[4] = &m_active_pnt_color; } // Set colors void background_color(const ColorT& c) { m_background_color = c; } void border_color(const ColorT& c) { m_border_color = c; } void curve_color(const ColorT& c) { m_curve_color = c; } void inactive_pnt_color(const ColorT& c) { m_inactive_pnt_color = c; } void active_pnt_color(const ColorT& c) { m_active_pnt_color = c; } const ColorT& color(unsigned i) const { return *m_colors[i]; } private: spline_ctrl(const spline_ctrl&); const spline_ctrl& operator = (const spline_ctrl&); ColorT m_background_color; ColorT m_border_color; ColorT m_curve_color; ColorT m_inactive_pnt_color; ColorT m_active_pnt_color; ColorT* m_colors[5]; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/ctrl/Makefile.am0000644000175000017500000000037112516137326023775 0ustar varunvarunaggincludedir = $(includedir)/agg2/ctrl agginclude_HEADERS = agg_ctrl.h agg_gamma_spline.h agg_scale_ctrl.h agg_spline_ctrl.h \ agg_cbox_ctrl.h agg_gamma_ctrl.h agg_rbox_ctrl.h agg_slider_ctrl.h \ agg_bezier_ctrl.h agg_polygon_ctrl.h enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/ctrl/agg_gamma_spline.h0000644000175000017500000000742112516137326025367 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class gamma_spline // //---------------------------------------------------------------------------- #ifndef AGG_GAMMA_SPLINE_INCLUDED #define AGG_GAMMA_SPLINE_INCLUDED #include "agg_basics.h" #include "agg_bspline.h" namespace agg24 { //------------------------------------------------------------------------ // Class-helper for calculation gamma-correction arrays. A gamma-correction // array is an array of 256 unsigned chars that determine the actual values // of Anti-Aliasing for each pixel coverage value from 0 to 255. If all the // values in the array are equal to its index, i.e. 0,1,2,3,... there's // no gamma-correction. Class agg24::polyfill allows you to use custom // gamma-correction arrays. You can calculate it using any approach, and // class gamma_spline allows you to calculate almost any reasonable shape // of the gamma-curve with using only 4 values - kx1, ky1, kx2, ky2. // // kx2 // +----------------------------------+ // | | | . | // | | | . | ky2 // | | . ------| // | | . | // | | . | // |----------------.|----------------| // | . | | // | . | | // |-------. | | // ky1 | . | | | // | . | | | // +----------------------------------+ // kx1 // // Each value can be in range [0...2]. Value 1.0 means one quarter of the // bounding rectangle. Function values() calculates the curve by these // 4 values. After calling it one can get the gamma-array with call gamma(). // Class also supports the vertex source interface, i.e rewind() and // vertex(). It's made for convinience and used in class gamma_ctrl. // Before calling rewind/vertex one must set the bounding box // box() using pixel coordinates. //------------------------------------------------------------------------ class gamma_spline { public: gamma_spline(); void values(double kx1, double ky1, double kx2, double ky2); const unsigned char* gamma() const { return m_gamma; } double y(double x) const; void values(double* kx1, double* ky1, double* kx2, double* ky2) const; void box(double x1, double y1, double x2, double y2); void rewind(unsigned); unsigned vertex(double* x, double* y); private: unsigned char m_gamma[256]; double m_x[4]; double m_y[4]; bspline m_spline; double m_x1; double m_y1; double m_x2; double m_y2; double m_cur_x; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/ctrl/agg_scale_ctrl.h0000644000175000017500000001064512516137326025050 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes scale_ctrl_impl, scale_ctrl // //---------------------------------------------------------------------------- #ifndef AGG_SCALE_CTRL_INCLUDED #define AGG_SCALE_CTRL_INCLUDED #include "agg_basics.h" #include "agg_math.h" #include "agg_ellipse.h" #include "agg_trans_affine.h" #include "agg_color_rgba.h" #include "agg_ctrl.h" namespace agg24 { //------------------------------------------------------------------------ class scale_ctrl_impl : public ctrl { enum move_e { move_nothing, move_value1, move_value2, move_slider }; public: scale_ctrl_impl(double x1, double y1, double x2, double y2, bool flip_y=false); void border_thickness(double t, double extra=0.0); void resize(double x1, double y1, double x2, double y2); double min_delta() const { return m_min_d; } void min_delta(double d) { m_min_d = d; } double value1() const { return m_value1; } void value1(double value); double value2() const { return m_value2; } void value2(double value); void move(double d); virtual bool in_rect(double x, double y) const; virtual bool on_mouse_button_down(double x, double y); virtual bool on_mouse_button_up(double x, double y); virtual bool on_mouse_move(double x, double y, bool button_flag); virtual bool on_arrow_keys(bool left, bool right, bool down, bool up); // Vertex soutce interface unsigned num_paths() { return 5; }; void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: void calc_box(); double m_border_thickness; double m_border_extra; double m_value1; double m_value2; double m_min_d; double m_xs1; double m_ys1; double m_xs2; double m_ys2; double m_pdx; double m_pdy; move_e m_move_what; double m_vx[32]; double m_vy[32]; ellipse m_ellipse; unsigned m_idx; unsigned m_vertex; }; //------------------------------------------------------------------------ template class scale_ctrl : public scale_ctrl_impl { public: scale_ctrl(double x1, double y1, double x2, double y2, bool flip_y=false) : scale_ctrl_impl(x1, y1, x2, y2, flip_y), m_background_color(rgba(1.0, 0.9, 0.8)), m_border_color(rgba(0.0, 0.0, 0.0)), m_pointers_color(rgba(0.8, 0.0, 0.0, 0.8)), m_slider_color(rgba(0.2, 0.1, 0.0, 0.6)) { m_colors[0] = &m_background_color; m_colors[1] = &m_border_color; m_colors[2] = &m_pointers_color; m_colors[3] = &m_pointers_color; m_colors[4] = &m_slider_color; } void background_color(const ColorT& c) { m_background_color = c; } void border_color(const ColorT& c) { m_border_color = c; } void pointers_color(const ColorT& c) { m_pointers_color = c; } void slider_color(const ColorT& c) { m_slider_color = c; } const ColorT& color(unsigned i) const { return *m_colors[i]; } private: scale_ctrl(const scale_ctrl&); const scale_ctrl& operator = (const scale_ctrl&); ColorT m_background_color; ColorT m_border_color; ColorT m_pointers_color; ColorT m_slider_color; ColorT* m_colors[5]; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/ctrl/agg_rbox_ctrl.h0000644000175000017500000001105112516137326024723 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes rbox_ctrl_impl, rbox_ctrl // //---------------------------------------------------------------------------- #ifndef AGG_RBOX_CTRL_INCLUDED #define AGG_RBOX_CTRL_INCLUDED #include "agg_array.h" #include "agg_ellipse.h" #include "agg_conv_stroke.h" #include "agg_gsv_text.h" #include "agg_trans_affine.h" #include "agg_color_rgba.h" #include "agg_ctrl.h" namespace agg24 { //------------------------------------------------------------------------ class rbox_ctrl_impl : public ctrl { public: rbox_ctrl_impl(double x1, double y1, double x2, double y2, bool flip_y=false); void border_width(double t, double extra=0.0); void text_thickness(double t) { m_text_thickness = t; } void text_size(double h, double w=0.0); void add_item(const char* text); int cur_item() const { return m_cur_item; } void cur_item(int i) { m_cur_item = i; } virtual bool in_rect(double x, double y) const; virtual bool on_mouse_button_down(double x, double y); virtual bool on_mouse_button_up(double x, double y); virtual bool on_mouse_move(double x, double y, bool button_flag); virtual bool on_arrow_keys(bool left, bool right, bool down, bool up); // Vertex soutce interface unsigned num_paths() { return 5; }; void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: void calc_rbox(); double m_border_width; double m_border_extra; double m_text_thickness; double m_text_height; double m_text_width; pod_array m_items[32]; unsigned m_num_items; int m_cur_item; double m_xs1; double m_ys1; double m_xs2; double m_ys2; double m_vx[32]; double m_vy[32]; unsigned m_draw_item; double m_dy; ellipse m_ellipse; conv_stroke m_ellipse_poly; gsv_text m_text; conv_stroke m_text_poly; unsigned m_idx; unsigned m_vertex; }; //------------------------------------------------------------------------ template class rbox_ctrl : public rbox_ctrl_impl { public: rbox_ctrl(double x1, double y1, double x2, double y2, bool flip_y=false) : rbox_ctrl_impl(x1, y1, x2, y2, flip_y), m_background_color(rgba(1.0, 1.0, 0.9)), m_border_color(rgba(0.0, 0.0, 0.0)), m_text_color(rgba(0.0, 0.0, 0.0)), m_inactive_color(rgba(0.0, 0.0, 0.0)), m_active_color(rgba(0.4, 0.0, 0.0)) { m_colors[0] = &m_background_color; m_colors[1] = &m_border_color; m_colors[2] = &m_text_color; m_colors[3] = &m_inactive_color; m_colors[4] = &m_active_color; } void background_color(const ColorT& c) { m_background_color = c; } void border_color(const ColorT& c) { m_border_color = c; } void text_color(const ColorT& c) { m_text_color = c; } void inactive_color(const ColorT& c) { m_inactive_color = c; } void active_color(const ColorT& c) { m_active_color = c; } const ColorT& color(unsigned i) const { return *m_colors[i]; } private: rbox_ctrl(const rbox_ctrl&); const rbox_ctrl& operator = (const rbox_ctrl&); ColorT m_background_color; ColorT m_border_color; ColorT m_text_color; ColorT m_inactive_color; ColorT m_active_color; ColorT* m_colors[5]; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/ctrl/agg_slider_ctrl.h0000644000175000017500000001135112516137326025236 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes slider_ctrl_impl, slider_ctrl // //---------------------------------------------------------------------------- #ifndef AGG_SLIDER_CTRL_INCLUDED #define AGG_SLIDER_CTRL_INCLUDED #include "agg_basics.h" #include "agg_math.h" #include "agg_ellipse.h" #include "agg_trans_affine.h" #include "agg_color_rgba.h" #include "agg_gsv_text.h" #include "agg_conv_stroke.h" #include "agg_path_storage.h" #include "agg_ctrl.h" namespace agg24 { //--------------------------------------------------------slider_ctrl_impl class slider_ctrl_impl : public ctrl { public: slider_ctrl_impl(double x1, double y1, double x2, double y2, bool flip_y=false); void border_width(double t, double extra=0.0); void range(double min, double max) { m_min = min; m_max = max; } void num_steps(unsigned num) { m_num_steps = num; } void label(const char* fmt); void text_thickness(double t) { m_text_thickness = t; } bool descending() const { return m_descending; } void descending(bool v) { m_descending = v; } double value() const { return m_value * (m_max - m_min) + m_min; } void value(double value); virtual bool in_rect(double x, double y) const; virtual bool on_mouse_button_down(double x, double y); virtual bool on_mouse_button_up(double x, double y); virtual bool on_mouse_move(double x, double y, bool button_flag); virtual bool on_arrow_keys(bool left, bool right, bool down, bool up); // Vertex source interface unsigned num_paths() { return 6; }; void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: void calc_box(); bool normalize_value(bool preview_value_flag); double m_border_width; double m_border_extra; double m_text_thickness; double m_value; double m_preview_value; double m_min; double m_max; unsigned m_num_steps; bool m_descending; char m_label[64]; double m_xs1; double m_ys1; double m_xs2; double m_ys2; double m_pdx; bool m_mouse_move; double m_vx[32]; double m_vy[32]; ellipse m_ellipse; unsigned m_idx; unsigned m_vertex; gsv_text m_text; conv_stroke m_text_poly; path_storage m_storage; }; //----------------------------------------------------------slider_ctrl template class slider_ctrl : public slider_ctrl_impl { public: slider_ctrl(double x1, double y1, double x2, double y2, bool flip_y=false) : slider_ctrl_impl(x1, y1, x2, y2, flip_y), m_background_color(rgba(1.0, 0.9, 0.8)), m_triangle_color(rgba(0.7, 0.6, 0.6)), m_text_color(rgba(0.0, 0.0, 0.0)), m_pointer_preview_color(rgba(0.6, 0.4, 0.4, 0.4)), m_pointer_color(rgba(0.8, 0.0, 0.0, 0.6)) { m_colors[0] = &m_background_color; m_colors[1] = &m_triangle_color; m_colors[2] = &m_text_color; m_colors[3] = &m_pointer_preview_color; m_colors[4] = &m_pointer_color; m_colors[5] = &m_text_color; } void background_color(const ColorT& c) { m_background_color = c; } void pointer_color(const ColorT& c) { m_pointer_color = c; } const ColorT& color(unsigned i) const { return *m_colors[i]; } private: slider_ctrl(const slider_ctrl&); const slider_ctrl& operator = (const slider_ctrl&); ColorT m_background_color; ColorT m_triangle_color; ColorT m_text_color; ColorT m_pointer_preview_color; ColorT m_pointer_color; ColorT* m_colors[6]; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_simul_eq.h0000644000175000017500000001006612516137326023604 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Solving simultaneous equations // //---------------------------------------------------------------------------- #ifndef AGG_SIMUL_EQ_INCLUDED #define AGG_SIMUL_EQ_INCLUDED #include #include "agg_basics.h" namespace agg24 { //=============================================================swap_arrays template void swap_arrays(T* a1, T* a2, unsigned n) { unsigned i; for(i = 0; i < n; i++) { T tmp = *a1; *a1++ = *a2; *a2++ = tmp; } } //============================================================matrix_pivot template struct matrix_pivot { static int pivot(double m[Rows][Cols], unsigned row) { int k = int(row); double max_val, tmp; max_val = -1.0; unsigned i; for(i = row; i < Rows; i++) { if((tmp = fabs(m[i][row])) > max_val && tmp != 0.0) { max_val = tmp; k = i; } } if(m[k][row] == 0.0) { return -1; } if(k != int(row)) { swap_arrays(m[k], m[row], Cols); return k; } return 0; } }; //===============================================================simul_eq template struct simul_eq { static bool solve(const double left[Size][Size], const double right[Size][RightCols], double result[Size][RightCols]) { unsigned i, j, k; double a1; double tmp[Size][Size + RightCols]; for(i = 0; i < Size; i++) { for(j = 0; j < Size; j++) { tmp[i][j] = left[i][j]; } for(j = 0; j < RightCols; j++) { tmp[i][Size + j] = right[i][j]; } } for(k = 0; k < Size; k++) { if(matrix_pivot::pivot(tmp, k) < 0) { return false; // Singularity.... } a1 = tmp[k][k]; for(j = k; j < Size + RightCols; j++) { tmp[k][j] /= a1; } for(i = k + 1; i < Size; i++) { a1 = tmp[i][k]; for (j = k; j < Size + RightCols; j++) { tmp[i][j] -= a1 * tmp[k][j]; } } } for(k = 0; k < RightCols; k++) { int m; for(m = int(Size - 1); m >= 0; m--) { result[m][k] = tmp[m][Size + k]; for(j = m + 1; j < Size; j++) { result[m][k] -= tmp[m][j] * result[j][k]; } } } return true; } }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_vpgen_clip_polygon.h0000644000175000017500000000470312516137326025664 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_VPGEN_CLIP_POLYGON_INCLUDED #define AGG_VPGEN_CLIP_POLYGON_INCLUDED #include "agg_basics.h" namespace agg24 { //======================================================vpgen_clip_polygon // // See Implementation agg_vpgen_clip_polygon.cpp // class vpgen_clip_polygon { public: vpgen_clip_polygon() : m_clip_box(0, 0, 1, 1), m_x1(0), m_y1(0), m_clip_flags(0), m_num_vertices(0), m_vertex(0), m_cmd(path_cmd_move_to) { } void clip_box(double x1, double y1, double x2, double y2) { m_clip_box.x1 = x1; m_clip_box.y1 = y1; m_clip_box.x2 = x2; m_clip_box.y2 = y2; m_clip_box.normalize(); } double x1() const { return m_clip_box.x1; } double y1() const { return m_clip_box.y1; } double x2() const { return m_clip_box.x2; } double y2() const { return m_clip_box.y2; } static bool auto_close() { return true; } static bool auto_unclose() { return false; } void reset(); void move_to(double x, double y); void line_to(double x, double y); unsigned vertex(double* x, double* y); private: unsigned clipping_flags(double x, double y); private: rect_d m_clip_box; double m_x1; double m_y1; unsigned m_clip_flags; double m_x[4]; double m_y[4]; unsigned m_num_vertices; unsigned m_vertex; unsigned m_cmd; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_glyph_raster_bin.h0000644000175000017500000001165412516137326025325 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_GLYPH_RASTER_BIN_INCLUDED #define AGG_GLYPH_RASTER_BIN_INCLUDED #include #include "agg_basics.h" namespace agg24 { //========================================================glyph_raster_bin template class glyph_raster_bin { public: typedef ColorT color_type; //-------------------------------------------------------------------- struct glyph_rect { int x1,y1,x2,y2; double dx, dy; }; //-------------------------------------------------------------------- glyph_raster_bin(const int8u* font) : m_font(font), m_big_endian(false) { int t = 1; if(*(char*)&t == 0) m_big_endian = true; memset(m_span, 0, sizeof(m_span)); } //-------------------------------------------------------------------- const int8u* font() const { return m_font; } void font(const int8u* f) { m_font = f; } //-------------------------------------------------------------------- double height() const { return m_font[0]; } double base_line() const { return m_font[1]; } //-------------------------------------------------------------------- template double width(const CharT* str) const { unsigned start_char = m_font[2]; unsigned num_chars = m_font[3]; unsigned w = 0; while(*str) { unsigned glyph = *str; const int8u* bits = m_font + 4 + num_chars * 2 + value(m_font + 4 + (glyph - start_char) * 2); w += *bits; ++str; } return w; } //-------------------------------------------------------------------- void prepare(glyph_rect* r, double x, double y, unsigned glyph, bool flip) { unsigned start_char = m_font[2]; unsigned num_chars = m_font[3]; m_bits = m_font + 4 + num_chars * 2 + value(m_font + 4 + (glyph - start_char) * 2); m_glyph_width = *m_bits++; m_glyph_byte_width = (m_glyph_width + 7) >> 3; r->x1 = int(x); r->x2 = r->x1 + m_glyph_width - 1; if(flip) { r->y1 = int(y) - m_font[0] + m_font[1]; r->y2 = r->y1 + m_font[0] - 1; } else { r->y1 = int(y) - m_font[1] + 1; r->y2 = r->y1 + m_font[0] - 1; } r->dx = m_glyph_width; r->dy = 0; } //-------------------------------------------------------------------- const cover_type* span(unsigned i) { i = m_font[0] - i - 1; const int8u* bits = m_bits + i * m_glyph_byte_width; unsigned j; unsigned val = *bits; unsigned nb = 0; for(j = 0; j < m_glyph_width; ++j) { m_span[j] = (cover_type)((val & 0x80) ? cover_full : cover_none); val <<= 1; if(++nb >= 8) { val = *++bits; nb = 0; } } return m_span; } private: //-------------------------------------------------------------------- int16u value(const int8u* p) const { int16u v; if(m_big_endian) { *(int8u*)&v = p[1]; *((int8u*)&v + 1) = p[0]; } else { *(int8u*)&v = p[0]; *((int8u*)&v + 1) = p[1]; } return v; } //-------------------------------------------------------------------- const int8u* m_font; bool m_big_endian; cover_type m_span[32]; const int8u* m_bits; unsigned m_glyph_width; unsigned m_glyph_byte_width; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_bezier_arc.h0000644000175000017500000001346012516137326024074 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Arc generator. Produces at most 4 consecutive cubic bezier curves, i.e., // 4, 7, 10, or 13 vertices. // //---------------------------------------------------------------------------- #ifndef AGG_BEZIER_ARC_INCLUDED #define AGG_BEZIER_ARC_INCLUDED #include "agg_conv_transform.h" namespace agg24 { //----------------------------------------------------------------------- void arc_to_bezier(double cx, double cy, double rx, double ry, double start_angle, double sweep_angle, double* curve); //==============================================================bezier_arc // // See implemantaion agg_bezier_arc.cpp // class bezier_arc { public: //-------------------------------------------------------------------- bezier_arc() : m_vertex(26), m_num_vertices(0), m_cmd(path_cmd_line_to) {} bezier_arc(double x, double y, double rx, double ry, double start_angle, double sweep_angle) { init(x, y, rx, ry, start_angle, sweep_angle); } //-------------------------------------------------------------------- void init(double x, double y, double rx, double ry, double start_angle, double sweep_angle); //-------------------------------------------------------------------- void rewind(unsigned) { m_vertex = 0; } //-------------------------------------------------------------------- unsigned vertex(double* x, double* y) { if(m_vertex >= m_num_vertices) return path_cmd_stop; *x = m_vertices[m_vertex]; *y = m_vertices[m_vertex + 1]; m_vertex += 2; return (m_vertex == 2) ? path_cmd_move_to : m_cmd; } // Supplemantary functions. num_vertices() actually returns doubled // number of vertices. That is, for 1 vertex it returns 2. //-------------------------------------------------------------------- unsigned num_vertices() const { return m_num_vertices; } const double* vertices() const { return m_vertices; } double* vertices() { return m_vertices; } private: unsigned m_vertex; unsigned m_num_vertices; double m_vertices[26]; unsigned m_cmd; }; //==========================================================bezier_arc_svg // Compute an SVG-style bezier arc. // // Computes an elliptical arc from (x1, y1) to (x2, y2). The size and // orientation of the ellipse are defined by two radii (rx, ry) // and an x-axis-rotation, which indicates how the ellipse as a whole // is rotated relative to the current coordinate system. The center // (cx, cy) of the ellipse is calculated automatically to satisfy the // constraints imposed by the other parameters. // large-arc-flag and sweep-flag contribute to the automatic calculations // and help determine how the arc is drawn. class bezier_arc_svg { public: //-------------------------------------------------------------------- bezier_arc_svg() : m_arc(), m_radii_ok(false) {} bezier_arc_svg(double x1, double y1, double rx, double ry, double angle, bool large_arc_flag, bool sweep_flag, double x2, double y2) : m_arc(), m_radii_ok(false) { init(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2); } //-------------------------------------------------------------------- void init(double x1, double y1, double rx, double ry, double angle, bool large_arc_flag, bool sweep_flag, double x2, double y2); //-------------------------------------------------------------------- bool radii_ok() const { return m_radii_ok; } //-------------------------------------------------------------------- void rewind(unsigned) { m_arc.rewind(0); } //-------------------------------------------------------------------- unsigned vertex(double* x, double* y) { return m_arc.vertex(x, y); } // Supplemantary functions. num_vertices() actually returns doubled // number of vertices. That is, for 1 vertex it returns 2. //-------------------------------------------------------------------- unsigned num_vertices() const { return m_arc.num_vertices(); } const double* vertices() const { return m_arc.vertices(); } double* vertices() { return m_arc.vertices(); } private: bezier_arc m_arc; bool m_radii_ok; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_dash.h0000644000175000017500000000433012516137326023727 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // conv_dash // //---------------------------------------------------------------------------- #ifndef AGG_CONV_DASH_INCLUDED #define AGG_CONV_DASH_INCLUDED #include "agg_basics.h" #include "agg_vcgen_dash.h" #include "agg_conv_adaptor_vcgen.h" namespace agg24 { //---------------------------------------------------------------conv_dash template struct conv_dash : public conv_adaptor_vcgen { typedef Markers marker_type; typedef conv_adaptor_vcgen base_type; conv_dash(VertexSource& vs) : conv_adaptor_vcgen(vs) { } void remove_all_dashes() { base_type::generator().remove_all_dashes(); } void add_dash(double dash_len, double gap_len) { base_type::generator().add_dash(dash_len, gap_len); } void dash_start(double ds) { base_type::generator().dash_start(ds); } void shorten(double s) { base_type::generator().shorten(s); } double shorten() const { return base_type::generator().shorten(); } private: conv_dash(const conv_dash&); const conv_dash& operator = (const conv_dash&); }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_gouraud_rgba.h0000644000175000017500000002354512516137326025456 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for high precision colors has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_SPAN_GOURAUD_RGBA_INCLUDED #define AGG_SPAN_GOURAUD_RGBA_INCLUDED #include "agg_basics.h" #include "agg_color_rgba.h" #include "agg_dda_line.h" #include "agg_span_gouraud.h" namespace agg24 { //=======================================================span_gouraud_rgba template class span_gouraud_rgba : public span_gouraud { public: typedef ColorT color_type; typedef typename ColorT::value_type value_type; typedef span_gouraud base_type; typedef typename base_type::coord_type coord_type; enum subpixel_scale_e { subpixel_shift = 4, subpixel_scale = 1 << subpixel_shift }; private: //-------------------------------------------------------------------- struct rgba_calc { void init(const coord_type& c1, const coord_type& c2) { m_x1 = c1.x - 0.5; m_y1 = c1.y - 0.5; m_dx = c2.x - c1.x; double dy = c2.y - c1.y; m_1dy = (dy < 1e-5) ? 1e5 : 1.0 / dy; m_r1 = c1.color.r; m_g1 = c1.color.g; m_b1 = c1.color.b; m_a1 = c1.color.a; m_dr = c2.color.r - m_r1; m_dg = c2.color.g - m_g1; m_db = c2.color.b - m_b1; m_da = c2.color.a - m_a1; } void calc(double y) { double k = (y - m_y1) * m_1dy; if(k < 0.0) k = 0.0; if(k > 1.0) k = 1.0; m_r = m_r1 + iround(m_dr * k); m_g = m_g1 + iround(m_dg * k); m_b = m_b1 + iround(m_db * k); m_a = m_a1 + iround(m_da * k); m_x = iround((m_x1 + m_dx * k) * subpixel_scale); } double m_x1; double m_y1; double m_dx; double m_1dy; int m_r1; int m_g1; int m_b1; int m_a1; int m_dr; int m_dg; int m_db; int m_da; int m_r; int m_g; int m_b; int m_a; int m_x; }; public: //-------------------------------------------------------------------- span_gouraud_rgba() {} span_gouraud_rgba(const color_type& c1, const color_type& c2, const color_type& c3, double x1, double y1, double x2, double y2, double x3, double y3, double d = 0) : base_type(c1, c2, c3, x1, y1, x2, y2, x3, y3, d) {} //-------------------------------------------------------------------- void prepare() { coord_type coord[3]; base_type::arrange_vertices(coord); m_y2 = int(coord[1].y); m_swap = cross_product(coord[0].x, coord[0].y, coord[2].x, coord[2].y, coord[1].x, coord[1].y) < 0.0; m_rgba1.init(coord[0], coord[2]); m_rgba2.init(coord[0], coord[1]); m_rgba3.init(coord[1], coord[2]); } //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { m_rgba1.calc(y);//(m_rgba1.m_1dy > 2) ? m_rgba1.m_y1 : y); const rgba_calc* pc1 = &m_rgba1; const rgba_calc* pc2 = &m_rgba2; if(y <= m_y2) { // Bottom part of the triangle (first subtriangle) //------------------------- m_rgba2.calc(y + m_rgba2.m_1dy); } else { // Upper part (second subtriangle) m_rgba3.calc(y - m_rgba3.m_1dy); //------------------------- pc2 = &m_rgba3; } if(m_swap) { // It means that the triangle is oriented clockwise, // so that we need to swap the controlling structures //------------------------- const rgba_calc* t = pc2; pc2 = pc1; pc1 = t; } // Get the horizontal length with subpixel accuracy // and protect it from division by zero //------------------------- int nlen = abs(pc2->m_x - pc1->m_x); if(nlen <= 0) nlen = 1; dda_line_interpolator<14> r(pc1->m_r, pc2->m_r, nlen); dda_line_interpolator<14> g(pc1->m_g, pc2->m_g, nlen); dda_line_interpolator<14> b(pc1->m_b, pc2->m_b, nlen); dda_line_interpolator<14> a(pc1->m_a, pc2->m_a, nlen); // Calculate the starting point of the gradient with subpixel // accuracy and correct (roll back) the interpolators. // This operation will also clip the beginning of the span // if necessary. //------------------------- int start = pc1->m_x - (x << subpixel_shift); r -= start; g -= start; b -= start; a -= start; nlen += start; int vr, vg, vb, va; enum lim_e { lim = color_type::base_mask }; // Beginning part of the span. Since we rolled back the // interpolators, the color values may have overflow. // So that, we render the beginning part with checking // for overflow. It lasts until "start" is positive; // typically it's 1-2 pixels, but may be more in some cases. //------------------------- while(len && start > 0) { vr = r.y(); vg = g.y(); vb = b.y(); va = a.y(); if(vr < 0) vr = 0; if(vr > lim) vr = lim; if(vg < 0) vg = 0; if(vg > lim) vg = lim; if(vb < 0) vb = 0; if(vb > lim) vb = lim; if(va < 0) va = 0; if(va > lim) va = lim; span->r = (value_type)vr; span->g = (value_type)vg; span->b = (value_type)vb; span->a = (value_type)va; r += subpixel_scale; g += subpixel_scale; b += subpixel_scale; a += subpixel_scale; nlen -= subpixel_scale; start -= subpixel_scale; ++span; --len; } // Middle part, no checking for overflow. // Actual spans can be longer than the calculated length // because of anti-aliasing, thus, the interpolators can // overflow. But while "nlen" is positive we are safe. //------------------------- while(len && nlen > 0) { span->r = (value_type)r.y(); span->g = (value_type)g.y(); span->b = (value_type)b.y(); span->a = (value_type)a.y(); r += subpixel_scale; g += subpixel_scale; b += subpixel_scale; a += subpixel_scale; nlen -= subpixel_scale; ++span; --len; } // Ending part; checking for overflow. // Typically it's 1-2 pixels, but may be more in some cases. //------------------------- while(len) { vr = r.y(); vg = g.y(); vb = b.y(); va = a.y(); if(vr < 0) vr = 0; if(vr > lim) vr = lim; if(vg < 0) vg = 0; if(vg > lim) vg = lim; if(vb < 0) vb = 0; if(vb > lim) vb = lim; if(va < 0) va = 0; if(va > lim) va = lim; span->r = (value_type)vr; span->g = (value_type)vg; span->b = (value_type)vb; span->a = (value_type)va; r += subpixel_scale; g += subpixel_scale; b += subpixel_scale; a += subpixel_scale; ++span; --len; } } private: bool m_swap; int m_y2; rgba_calc m_rgba1; rgba_calc m_rgba2; rgba_calc m_rgba3; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/platform/0000755000175000017500000000000012516137725022623 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/platform/mac/0000755000175000017500000000000012516137725023363 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/platform/mac/agg_mac_pmap.h0000644000175000017500000000532112516137326026125 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (McSeem) // Copyright (C) 2002 Hansruedi Baer (MacOS support) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com // baer@karto.baug.eth.ch //---------------------------------------------------------------------------- // // class pixel_map // //---------------------------------------------------------------------------- #ifndef AGG_MAC_PMAP_INCLUDED #define AGG_MAC_PMAP_INCLUDED #include #include namespace agg24 { enum org_e { org_mono8 = 8, org_color16 = 16, org_color24 = 24, org_color32 = 32 }; class pixel_map { public: ~pixel_map(); pixel_map(); public: void destroy(); void create(unsigned width, unsigned height, org_e org, unsigned clear_val=255); void clear(unsigned clear_val=255); bool load_from_qt(const char* filename); bool save_as_qt(const char* filename) const; void draw(WindowRef window, const Rect* device_rect=0, const Rect* bmp_rect=0) const; void draw(WindowRef window, int x, int y, double scale=1.0) const; void blend(WindowRef window, const Rect* device_rect=0, const Rect* bmp_rect=0) const; void blend(WindowRef window, int x, int y, double scale=1.0) const; unsigned char* buf(); unsigned width() const; unsigned height() const; int row_bytes() const; unsigned bpp() const { return m_bpp; } //Auxiliary static functions static unsigned calc_row_len(unsigned width, unsigned bits_per_pixel); private: pixel_map(const pixel_map&); const pixel_map& operator = (const pixel_map&); private: GWorldPtr m_pmap; unsigned char* m_buf; unsigned m_bpp; unsigned m_img_size; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/platform/agg_platform_support.h0000644000175000017500000007240412516137326027236 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class platform_support // // It's not a part of the AGG library, it's just a helper class to create // interactive demo examples. Since the examples should not be too complex // this class is provided to support some very basic interactive graphical // funtionality, such as putting the rendered image to the window, simple // keyboard and mouse input, window resizing, setting the window title, // and catching the "idle" events. // // The idea is to have a single header file that does not depend on any // platform (I hate these endless #ifdef/#elif/#elif.../#endif) and a number // of different implementations depending on the concrete platform. // The most popular platforms are: // // Windows-32 API // X-Window API // SDL library (see http://www.libsdl.org/) // MacOS C/C++ API // // This file does not include any system dependent .h files such as // windows.h or X11.h, so, your demo applications do not depend on the // platform. The only file that can #include system dependend headers // is the implementation file agg_platform_support.cpp. Different // implementations are placed in different directories, such as // ~/agg/src/platform/win32 // ~/agg/src/platform/sdl // ~/agg/src/platform/X11 // and so on. // // All the system dependent stuff sits in the platform_specific // class which is forward-declared here but not defined. // The platform_support class has just a pointer to it and it's // the responsibility of the implementation to create/delete it. // This class being defined in the implementation file can have // any platform dependent stuff such as HWND, X11 Window and so on. // //---------------------------------------------------------------------------- #ifndef AGG_PLATFORM_SUPPORT_INCLUDED #define AGG_PLATFORM_SUPPORT_INCLUDED #include "agg_basics.h" #include "agg_rendering_buffer.h" #include "agg_trans_viewport.h" #include "ctrl/agg_ctrl.h" namespace agg24 { //----------------------------------------------------------window_flag_e // These are flags used in method init(). Not all of them are // applicable on different platforms, for example the win32_api // cannot use a hardware buffer (window_hw_buffer). // The implementation should simply ignore unsupported flags. enum window_flag_e { window_resize = 1, window_hw_buffer = 2, window_keep_aspect_ratio = 4, window_process_all_keys = 8 }; //-----------------------------------------------------------pix_format_e // Possible formats of the rendering buffer. Initially I thought that it's // reasonable to create the buffer and the rendering functions in // accordance with the native pixel format of the system because it // would have no overhead for pixel format conersion. // But eventually I came to a conclusion that having a possibility to // convert pixel formats on demand is a good idea. First, it was X11 where // there lots of different formats and visuals and it would be great to // render everything in, say, RGB-24 and display it automatically without // any additional efforts. The second reason is to have a possibility to // debug renderers for different pixel formats and colorspaces having only // one computer and one system. // // This stuff is not included into the basic AGG functionality because the // number of supported pixel formats (and/or colorspaces) can be great and // if one needs to add new format it would be good only to add new // rendering files without having to modify any existing ones (a general // principle of incapsulation and isolation). // // Using a particular pixel format doesn't obligatory mean the necessity // of software conversion. For example, win32 API can natively display // gray8, 15-bit RGB, 24-bit BGR, and 32-bit BGRA formats. // This list can be (and will be!) extended in future. enum pix_format_e { pix_format_undefined = 0, // By default. No conversions are applied pix_format_bw, // 1 bit per color B/W pix_format_gray8, // Simple 256 level grayscale pix_format_gray16, // Simple 65535 level grayscale pix_format_rgb555, // 15 bit rgb. Depends on the byte ordering! pix_format_rgb565, // 16 bit rgb. Depends on the byte ordering! pix_format_rgbAAA, // 30 bit rgb. Depends on the byte ordering! pix_format_rgbBBA, // 32 bit rgb. Depends on the byte ordering! pix_format_bgrAAA, // 30 bit bgr. Depends on the byte ordering! pix_format_bgrABB, // 32 bit bgr. Depends on the byte ordering! pix_format_rgb24, // R-G-B, one byte per color component pix_format_bgr24, // B-G-R, native win32 BMP format. pix_format_rgba32, // R-G-B-A, one byte per color component pix_format_argb32, // A-R-G-B, native MAC format pix_format_abgr32, // A-B-G-R, one byte per color component pix_format_bgra32, // B-G-R-A, native win32 BMP format pix_format_rgb48, // R-G-B, 16 bits per color component pix_format_bgr48, // B-G-R, native win32 BMP format. pix_format_rgba64, // R-G-B-A, 16 bits byte per color component pix_format_argb64, // A-R-G-B, native MAC format pix_format_abgr64, // A-B-G-R, one byte per color component pix_format_bgra64, // B-G-R-A, native win32 BMP format end_of_pix_formats }; //-------------------------------------------------------------input_flag_e // Mouse and keyboard flags. They can be different on different platforms // and the ways they are obtained are also different. But in any case // the system dependent flags should be mapped into these ones. The meaning // of that is as follows. For example, if kbd_ctrl is set it means that the // ctrl key is pressed and being held at the moment. They are also used in // the overridden methods such as on_mouse_move(), on_mouse_button_down(), // on_mouse_button_dbl_click(), on_mouse_button_up(), on_key(). // In the method on_mouse_button_up() the mouse flags have different // meaning. They mean that the respective button is being released, but // the meaning of the keyboard flags remains the same. // There's absolut minimal set of flags is used because they'll be most // probably supported on different platforms. Even the mouse_right flag // is restricted because Mac's mice have only one button, but AFAIK // it can be simulated with holding a special key on the keydoard. enum input_flag_e { mouse_left = 1, mouse_right = 2, kbd_shift = 4, kbd_ctrl = 8 }; //--------------------------------------------------------------key_code_e // Keyboard codes. There's also a restricted set of codes that are most // probably supported on different platforms. Any platform dependent codes // should be converted into these ones. There're only those codes are // defined that cannot be represented as printable ASCII-characters. // All printable ASCII-set can be used in a regular C/C++ manner: // ' ', 'A', '0' '+' and so on. // Since the class is used for creating very simple demo-applications // we don't need very rich possibilities here, just basic ones. // Actually the numeric key codes are taken from the SDL library, so, // the implementation of the SDL support does not require any mapping. enum key_code_e { // ASCII set. Should be supported everywhere key_backspace = 8, key_tab = 9, key_clear = 12, key_return = 13, key_pause = 19, key_escape = 27, // Keypad key_delete = 127, key_kp0 = 256, key_kp1 = 257, key_kp2 = 258, key_kp3 = 259, key_kp4 = 260, key_kp5 = 261, key_kp6 = 262, key_kp7 = 263, key_kp8 = 264, key_kp9 = 265, key_kp_period = 266, key_kp_divide = 267, key_kp_multiply = 268, key_kp_minus = 269, key_kp_plus = 270, key_kp_enter = 271, key_kp_equals = 272, // Arrow-keys and stuff key_up = 273, key_down = 274, key_right = 275, key_left = 276, key_insert = 277, key_home = 278, key_end = 279, key_page_up = 280, key_page_down = 281, // Functional keys. You'd better avoid using // f11...f15 in your applications if you want // the applications to be portable key_f1 = 282, key_f2 = 283, key_f3 = 284, key_f4 = 285, key_f5 = 286, key_f6 = 287, key_f7 = 288, key_f8 = 289, key_f9 = 290, key_f10 = 291, key_f11 = 292, key_f12 = 293, key_f13 = 294, key_f14 = 295, key_f15 = 296, // The possibility of using these keys is // very restricted. Actually it's guaranteed // only in win32_api and win32_sdl implementations key_numlock = 300, key_capslock = 301, key_scrollock = 302, // Phew! end_of_key_codes }; //------------------------------------------------------------------------ // A predeclaration of the platform dependent class. Since we do not // know anything here the only we can have is just a pointer to this // class as a data member. It should be created and destroyed explicitly // in the constructor/destructor of the platform_support class. // Although the pointer to platform_specific is public the application // cannot have access to its members or methods since it does not know // anything about them and it's a perfect incapsulation :-) class platform_specific; //----------------------------------------------------------ctrl_container // A helper class that contains pointers to a number of controls. // This class is used to ease the event handling with controls. // The implementation should simply call the appropriate methods // of this class when appropriate events occur. class ctrl_container { enum max_ctrl_e { max_ctrl = 64 }; public: //-------------------------------------------------------------------- ctrl_container() : m_num_ctrl(0), m_cur_ctrl(-1) {} //-------------------------------------------------------------------- void add(ctrl& c) { if(m_num_ctrl < max_ctrl) { m_ctrl[m_num_ctrl++] = &c; } } //-------------------------------------------------------------------- bool in_rect(double x, double y) { unsigned i; for(i = 0; i < m_num_ctrl; i++) { if(m_ctrl[i]->in_rect(x, y)) return true; } return false; } //-------------------------------------------------------------------- bool on_mouse_button_down(double x, double y) { unsigned i; for(i = 0; i < m_num_ctrl; i++) { if(m_ctrl[i]->on_mouse_button_down(x, y)) return true; } return false; } //-------------------------------------------------------------------- bool on_mouse_button_up(double x, double y) { unsigned i; bool flag = false; for(i = 0; i < m_num_ctrl; i++) { if(m_ctrl[i]->on_mouse_button_up(x, y)) flag = true; } return flag; } //-------------------------------------------------------------------- bool on_mouse_move(double x, double y, bool button_flag) { unsigned i; for(i = 0; i < m_num_ctrl; i++) { if(m_ctrl[i]->on_mouse_move(x, y, button_flag)) return true; } return false; } //-------------------------------------------------------------------- bool on_arrow_keys(bool left, bool right, bool down, bool up) { if(m_cur_ctrl >= 0) { return m_ctrl[m_cur_ctrl]->on_arrow_keys(left, right, down, up); } return false; } //-------------------------------------------------------------------- bool set_cur(double x, double y) { unsigned i; for(i = 0; i < m_num_ctrl; i++) { if(m_ctrl[i]->in_rect(x, y)) { if(m_cur_ctrl != int(i)) { m_cur_ctrl = i; return true; } return false; } } if(m_cur_ctrl != -1) { m_cur_ctrl = -1; return true; } return false; } private: ctrl* m_ctrl[max_ctrl]; unsigned m_num_ctrl; int m_cur_ctrl; }; //---------------------------------------------------------platform_support // This class is a base one to the apllication classes. It can be used // as follows: // // class the_application : public agg24::platform_support // { // public: // the_application(unsigned bpp, bool flip_y) : // platform_support(bpp, flip_y) // . . . // // //override stuff . . . // virtual void on_init() // { // . . . // } // // virtual void on_draw() // { // . . . // } // // virtual void on_resize(int sx, int sy) // { // . . . // } // // . . . and so on, see virtual functions // // // //any your own stuff . . . // }; // // // int agg_main(int argc, char* argv[]) // { // the_application app(pix_format_rgb24, true); // app.caption("AGG Example. Lion"); // // if(app.init(500, 400, agg24::window_resize)) // { // return app.run(); // } // return 1; // } // // The reason to have agg_main() instead of just main() is that SDL // for Windows requires including SDL.h if you define main(). Since // the demo applications cannot rely on any platform/library specific // stuff it's impossible to include SDL.h into the application files. // The demo applications are simple and their use is restricted, so, // this approach is quite reasonable. // class platform_support { public: enum max_images_e { max_images = 16 }; // format - see enum pix_format_e {}; // flip_y - true if you want to have the Y-axis flipped vertically. platform_support(pix_format_e format, bool flip_y); virtual ~platform_support(); // Setting the windows caption (title). Should be able // to be called at least before calling init(). // It's perfect if they can be called anytime. void caption(const char* cap); const char* caption() const { return m_caption; } //-------------------------------------------------------------------- // These 3 methods handle working with images. The image // formats are the simplest ones, such as .BMP in Windows or // .ppm in Linux. In the applications the names of the files // should not have any file extensions. Method load_img() can // be called before init(), so, the application could be able // to determine the initial size of the window depending on // the size of the loaded image. // The argument "idx" is the number of the image 0...max_images-1 bool load_img(unsigned idx, const char* file); bool save_img(unsigned idx, const char* file); bool create_img(unsigned idx, unsigned width=0, unsigned height=0); //-------------------------------------------------------------------- // init() and run(). See description before the class for details. // The necessity of calling init() after creation is that it's // impossible to call the overridden virtual function (on_init()) // from the constructor. On the other hand it's very useful to have // some on_init() event handler when the window is created but // not yet displayed. The rbuf_window() method (see below) is // accessible from on_init(). bool init(unsigned width, unsigned height, unsigned flags); int run(); //-------------------------------------------------------------------- // The very same parameters that were used in the constructor pix_format_e format() const { return m_format; } bool flip_y() const { return m_flip_y; } unsigned bpp() const { return m_bpp; } //-------------------------------------------------------------------- // The following provides a very simple mechanism of doing someting // in background. It's not multithreading. When wait_mode is true // the class waits for the events and it does not ever call on_idle(). // When it's false it calls on_idle() when the event queue is empty. // The mode can be changed anytime. This mechanism is satisfactory // to create very simple animations. bool wait_mode() const { return m_wait_mode; } void wait_mode(bool wait_mode) { m_wait_mode = wait_mode; } //-------------------------------------------------------------------- // These two functions control updating of the window. // force_redraw() is an analog of the Win32 InvalidateRect() function. // Being called it sets a flag (or sends a message) which results // in calling on_draw() and updating the content of the window // when the next event cycle comes. // update_window() results in just putting immediately the content // of the currently rendered buffer to the window without calling // on_draw(). void force_redraw(); void update_window(); //-------------------------------------------------------------------- // So, finally, how to draw anythig with AGG? Very simple. // rbuf_window() returns a reference to the main rendering // buffer which can be attached to any rendering class. // rbuf_img() returns a reference to the previously created // or loaded image buffer (see load_img()). The image buffers // are not displayed directly, they should be copied to or // combined somehow with the rbuf_window(). rbuf_window() is // the only buffer that can be actually displayed. rendering_buffer& rbuf_window() { return m_rbuf_window; } rendering_buffer& rbuf_img(unsigned idx) { return m_rbuf_img[idx]; } //-------------------------------------------------------------------- // Returns file extension used in the implementation for the particular // system. const char* img_ext() const; //-------------------------------------------------------------------- void copy_img_to_window(unsigned idx) { if(idx < max_images && rbuf_img(idx).buf()) { rbuf_window().copy_from(rbuf_img(idx)); } } //-------------------------------------------------------------------- void copy_window_to_img(unsigned idx) { if(idx < max_images) { create_img(idx, rbuf_window().width(), rbuf_window().height()); rbuf_img(idx).copy_from(rbuf_window()); } } //-------------------------------------------------------------------- void copy_img_to_img(unsigned idx_to, unsigned idx_from) { if(idx_from < max_images && idx_to < max_images && rbuf_img(idx_from).buf()) { create_img(idx_to, rbuf_img(idx_from).width(), rbuf_img(idx_from).height()); rbuf_img(idx_to).copy_from(rbuf_img(idx_from)); } } //-------------------------------------------------------------------- // Event handlers. They are not pure functions, so you don't have // to override them all. // In my demo applications these functions are defined inside // the the_application class (implicit inlining) which is in general // very bad practice, I mean vitual inline methods. At least it does // not make sense. // But in this case it's quite appropriate bacause we have the only // instance of the the_application class and it is in the same file // where this class is defined. virtual void on_init(); virtual void on_resize(int sx, int sy); virtual void on_idle(); virtual void on_mouse_move(int x, int y, unsigned flags); virtual void on_mouse_button_down(int x, int y, unsigned flags); virtual void on_mouse_button_up(int x, int y, unsigned flags); virtual void on_key(int x, int y, unsigned key, unsigned flags); virtual void on_ctrl_change(); virtual void on_draw(); virtual void on_post_draw(void* raw_handler); //-------------------------------------------------------------------- // Adding control elements. A control element once added will be // working and reacting to the mouse and keyboard events. Still, you // will have to render them in the on_draw() using function // render_ctrl() because platform_support doesn't know anything about // renderers you use. The controls will be also scaled automatically // if they provide a proper scaling mechanism (all the controls // included into the basic AGG package do). // If you don't need a particular control to be scaled automatically // call ctrl::no_transform() after adding. void add_ctrl(ctrl& c) { m_ctrls.add(c); c.transform(m_resize_mtx); } //-------------------------------------------------------------------- // Auxiliary functions. trans_affine_resizing() modifier sets up the resizing // matrix on the basis of the given width and height and the initial // width and height of the window. The implementation should simply // call this function every time when it catches the resizing event // passing in the new values of width and height of the window. // Nothing prevents you from "cheating" the scaling matrix if you // call this function from somewhere with wrong arguments. // trans_affine_resizing() accessor simply returns current resizing matrix // which can be used to apply additional scaling of any of your // stuff when the window is being resized. // width(), height(), initial_width(), and initial_height() must be // clear to understand with no comments :-) void trans_affine_resizing(int width, int height) { if(m_window_flags & window_keep_aspect_ratio) { //double sx = double(width) / double(m_initial_width); //double sy = double(height) / double(m_initial_height); //if(sy < sx) sx = sy; //m_resize_mtx = trans_affine_scaling(sx, sx); trans_viewport vp; vp.preserve_aspect_ratio(0.5, 0.5, aspect_ratio_meet); vp.device_viewport(0, 0, width, height); vp.world_viewport(0, 0, m_initial_width, m_initial_height); m_resize_mtx = vp.to_affine(); } else { m_resize_mtx = trans_affine_scaling( double(width) / double(m_initial_width), double(height) / double(m_initial_height)); } } const trans_affine& trans_affine_resizing() const { return m_resize_mtx; } double width() const { return m_rbuf_window.width(); } double height() const { return m_rbuf_window.height(); } double initial_width() const { return m_initial_width; } double initial_height() const { return m_initial_height; } unsigned window_flags() const { return m_window_flags; } //-------------------------------------------------------------------- // Get raw display handler depending on the system. // For win32 its an HDC, for other systems it can be a pointer to some // structure. See the implementation files for detals. // It's provided "as is", so, first you should check if it's not null. // If it's null the raw_display_handler is not supported. Also, there's // no guarantee that this function is implemented, so, in some // implementations you may have simply an unresolved symbol when linking. void* raw_display_handler(); //-------------------------------------------------------------------- // display message box or print the message to the console // (depending on implementation) void message(const char* msg); //-------------------------------------------------------------------- // Stopwatch functions. Function elapsed_time() returns time elapsed // since the latest start_timer() invocation in millisecods. // The resolutoin depends on the implementation. // In Win32 it uses QueryPerformanceFrequency() / QueryPerformanceCounter(). void start_timer(); double elapsed_time() const; //-------------------------------------------------------------------- // Get the full file name. In most cases it simply returns // file_name. As it's appropriate in many systems if you open // a file by its name without specifying the path, it tries to // open it in the current directory. The demos usually expect // all the supplementary files to be placed in the current // directory, that is usually coincides with the directory where // the the executable is. However, in some systems (BeOS) it's not so. // For those kinds of systems full_file_name() can help access files // preserving commonly used policy. // So, it's a good idea to use in the demos the following: // FILE* fd = fopen(full_file_name("some.file"), "r"); // instead of // FILE* fd = fopen("some.file", "r"); const char* full_file_name(const char* file_name); public: platform_specific* m_specific; ctrl_container m_ctrls; // Sorry, I'm too tired to describe the private // data membders. See the implementations for different // platforms for details. private: platform_support(const platform_support&); const platform_support& operator = (const platform_support&); pix_format_e m_format; unsigned m_bpp; rendering_buffer m_rbuf_window; rendering_buffer m_rbuf_img[max_images]; unsigned m_window_flags; bool m_wait_mode; bool m_flip_y; char m_caption[256]; int m_initial_width; int m_initial_height; trans_affine m_resize_mtx; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/platform/win32/0000755000175000017500000000000012516137725023565 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/platform/win32/agg_win32_bmp.h0000644000175000017500000001024112516137326026347 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class pixel_map // //---------------------------------------------------------------------------- #ifndef AGG_WIN32_BMP_INCLUDED #define AGG_WIN32_BMP_INCLUDED #include #include namespace agg24 { enum org_e { org_mono8 = 8, org_color16 = 16, org_color24 = 24, org_color32 = 32, org_color48 = 48, org_color64 = 64 }; class pixel_map { public: ~pixel_map(); pixel_map(); public: void destroy(); void create(unsigned width, unsigned height, org_e org, unsigned clear_val=256); HBITMAP create_dib_section(HDC h_dc, unsigned width, unsigned height, org_e org, unsigned clear_val=256); void clear(unsigned clear_val=256); void attach_to_bmp(BITMAPINFO* bmp); BITMAPINFO* bitmap_info() { return m_bmp; } bool load_from_bmp(FILE* fd); bool save_as_bmp(FILE* fd) const; bool load_from_bmp(const char* filename); bool save_as_bmp(const char* filename) const; void draw(HDC h_dc, const RECT* device_rect=0, const RECT* bmp_rect=0) const; void draw(HDC h_dc, int x, int y, double scale=1.0) const; void blend(HDC h_dc, const RECT* device_rect=0, const RECT* bmp_rect=0) const; void blend(HDC h_dc, int x, int y, double scale=1.0) const; unsigned char* buf(); unsigned width() const; unsigned height() const; int stride() const; unsigned bpp() const { return m_bpp; } //Auxiliary static functions static unsigned calc_full_size(BITMAPINFO *bmp); static unsigned calc_header_size(BITMAPINFO *bmp); static unsigned calc_palette_size(unsigned clr_used, unsigned bits_per_pixel); static unsigned calc_palette_size(BITMAPINFO *bmp); static unsigned char* calc_img_ptr(BITMAPINFO *bmp); static BITMAPINFO* create_bitmap_info(unsigned width, unsigned height, unsigned bits_per_pixel); static void create_gray_scale_palette(BITMAPINFO *bmp); static unsigned calc_row_len(unsigned width, unsigned bits_per_pixel); private: pixel_map(const pixel_map&); const pixel_map& operator = (const pixel_map&); void create_from_bmp(BITMAPINFO *bmp); HBITMAP create_dib_section_from_args(HDC h_dc, unsigned width, unsigned height, unsigned bits_per_pixel); private: BITMAPINFO* m_bmp; unsigned char* m_buf; unsigned m_bpp; bool m_is_internal; unsigned m_img_size; unsigned m_full_size; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/platform/Makefile.am0000644000175000017500000000022612516137326024654 0ustar varunvarunEXTRA_DIST=win32/agg_win32_bmp.h \ mac/agg_mac_pmap.h myincludedir = $(includedir)/agg2/platform myinclude_HEADERS = agg_platform_support.h enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_trans_lens.h0000644000175000017500000000433212516137326024135 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.1 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_WARP_MAGNIFIER_INCLUDED #define AGG_WARP_MAGNIFIER_INCLUDED #include #include "agg_basics.h" namespace agg24 { class trans_warp_magnifier { public: trans_warp_magnifier() : m_xc(0.0), m_yc(0.0), m_magn(1.0), m_radius(1.0), m_warp(false) {} void center(double x, double y) { m_xc = x; m_yc = y; } void magnification(double m) { m_magn = m; } void radius(double r) { m_radius = r; } void warp(bool w) { m_warp = w; } void transform(double* x, double* y) const { double dx = *x - m_xc; double dy = *y - m_yc; double r = sqrt(dx * dx + dy * dy); double rm = m_radius / m_magn; if(r < rm) { *x = m_xc + dx * m_magn; *y = m_yc + dy * m_magn; return; } if(m_warp) { double m = (r + rm * (m_magn - 1.0)) / r; *x = m_xc + dx * m; *y = m_yc + dy * m; return; } if(r < m_radius) { double m = m_radius / r; *x = m_xc + dx * m; *y = m_yc + dy * m; } } private: double m_xc; double m_yc; double m_magn; double m_radius; bool m_warp; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_curve.h0000644000175000017500000001534412516137326024143 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes conv_curve // //---------------------------------------------------------------------------- #ifndef AGG_CONV_CURVE_INCLUDED #define AGG_CONV_CURVE_INCLUDED #include "agg_basics.h" #include "agg_curves.h" namespace agg24 { //---------------------------------------------------------------conv_curve // Curve converter class. Any path storage can have Bezier curves defined // by their control points. There're two types of curves supported: curve3 // and curve4. Curve3 is a conic Bezier curve with 2 endpoints and 1 control // point. Curve4 has 2 control points (4 points in total) and can be used // to interpolate more complicated curves. Curve4, unlike curve3 can be used // to approximate arcs, both circular and elliptical. Curves are approximated // with straight lines and one of the approaches is just to store the whole // sequence of vertices that approximate our curve. It takes additional // memory, and at the same time the consecutive vertices can be calculated // on demand. // // Initially, path storages are not suppose to keep all the vertices of the // curves (although, nothing prevents us from doing so). Instead, path_storage // keeps only vertices, needed to calculate a curve on demand. Those vertices // are marked with special commands. So, if the path_storage contains curves // (which are not real curves yet), and we render this storage directly, // all we will see is only 2 or 3 straight line segments (for curve3 and // curve4 respectively). If we need to see real curves drawn we need to // include this class into the conversion pipeline. // // Class conv_curve recognizes commands path_cmd_curve3 and path_cmd_curve4 // and converts these vertices into a move_to/line_to sequence. //----------------------------------------------------------------------- template class conv_curve { public: typedef Curve3 curve3_type; typedef Curve4 curve4_type; typedef conv_curve self_type; conv_curve(VertexSource& source) : m_source(&source), m_last_x(0.0), m_last_y(0.0) {} void attach(VertexSource& source) { m_source = &source; } void approximation_method(curve_approximation_method_e v) { m_curve3.approximation_method(v); m_curve4.approximation_method(v); } curve_approximation_method_e approximation_method() const { return m_curve4.approximation_method(); } void approximation_scale(double s) { m_curve3.approximation_scale(s); m_curve4.approximation_scale(s); } double approximation_scale() const { return m_curve4.approximation_scale(); } void angle_tolerance(double v) { m_curve3.angle_tolerance(v); m_curve4.angle_tolerance(v); } double angle_tolerance() const { return m_curve4.angle_tolerance(); } void cusp_limit(double v) { m_curve3.cusp_limit(v); m_curve4.cusp_limit(v); } double cusp_limit() const { return m_curve4.cusp_limit(); } void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: conv_curve(const self_type&); const self_type& operator = (const self_type&); VertexSource* m_source; double m_last_x; double m_last_y; curve3_type m_curve3; curve4_type m_curve4; }; //------------------------------------------------------------------------ template void conv_curve::rewind(unsigned path_id) { m_source->rewind(path_id); m_last_x = 0.0; m_last_y = 0.0; m_curve3.reset(); m_curve4.reset(); } //------------------------------------------------------------------------ template unsigned conv_curve::vertex(double* x, double* y) { if(!is_stop(m_curve3.vertex(x, y))) { m_last_x = *x; m_last_y = *y; return path_cmd_line_to; } if(!is_stop(m_curve4.vertex(x, y))) { m_last_x = *x; m_last_y = *y; return path_cmd_line_to; } double ct2_x = 0.0; double ct2_y = 0.0; double end_x = 0.0; double end_y = 0.0; unsigned cmd = m_source->vertex(x, y); switch(cmd) { case path_cmd_curve3: m_source->vertex(&end_x, &end_y); m_curve3.init(m_last_x, m_last_y, *x, *y, end_x, end_y); m_curve3.vertex(x, y); // First call returns path_cmd_move_to m_curve3.vertex(x, y); // This is the first vertex of the curve cmd = path_cmd_line_to; break; case path_cmd_curve4: m_source->vertex(&ct2_x, &ct2_y); m_source->vertex(&end_x, &end_y); m_curve4.init(m_last_x, m_last_y, *x, *y, ct2_x, ct2_y, end_x, end_y); m_curve4.vertex(x, y); // First call returns path_cmd_move_to m_curve4.vertex(x, y); // This is the first vertex of the curve cmd = path_cmd_line_to; break; } m_last_x = *x; m_last_y = *y; return cmd; } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_font_cache_manager.h0000644000175000017500000003506012516137326025552 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_FONT_CACHE_MANAGER_INCLUDED #define AGG_FONT_CACHE_MANAGER_INCLUDED #include #include "agg_array.h" namespace agg24 { //---------------------------------------------------------glyph_data_type enum glyph_data_type { glyph_data_invalid = 0, glyph_data_mono = 1, glyph_data_gray8 = 2, glyph_data_outline = 3 }; //-------------------------------------------------------------glyph_cache struct glyph_cache { unsigned glyph_index; int8u* data; unsigned data_size; glyph_data_type data_type; rect_i bounds; double advance_x; double advance_y; }; //--------------------------------------------------------------font_cache class font_cache { public: enum block_size_e { block_size = 16384-16 }; //-------------------------------------------------------------------- font_cache() : m_allocator(block_size), m_font_signature(0) {} //-------------------------------------------------------------------- void signature(const char* font_signature) { m_font_signature = (char*)m_allocator.allocate(strlen(font_signature) + 1); strcpy(m_font_signature, font_signature); memset(m_glyphs, 0, sizeof(m_glyphs)); } //-------------------------------------------------------------------- bool font_is(const char* font_signature) const { return strcmp(font_signature, m_font_signature) == 0; } //-------------------------------------------------------------------- const glyph_cache* find_glyph(unsigned glyph_code) const { unsigned msb = (glyph_code >> 8) & 0xFF; if(m_glyphs[msb]) { return m_glyphs[msb][glyph_code & 0xFF]; } return 0; } //-------------------------------------------------------------------- glyph_cache* cache_glyph(unsigned glyph_code, unsigned glyph_index, unsigned data_size, glyph_data_type data_type, const rect_i& bounds, double advance_x, double advance_y) { unsigned msb = (glyph_code >> 8) & 0xFF; if(m_glyphs[msb] == 0) { m_glyphs[msb] = (glyph_cache**)m_allocator.allocate(sizeof(glyph_cache*) * 256, sizeof(glyph_cache*)); memset(m_glyphs[msb], 0, sizeof(glyph_cache*) * 256); } unsigned lsb = glyph_code & 0xFF; if(m_glyphs[msb][lsb]) return 0; // Already exists, do not overwrite glyph_cache* glyph = (glyph_cache*)m_allocator.allocate(sizeof(glyph_cache), sizeof(double)); glyph->glyph_index = glyph_index; glyph->data = m_allocator.allocate(data_size); glyph->data_size = data_size; glyph->data_type = data_type; glyph->bounds = bounds; glyph->advance_x = advance_x; glyph->advance_y = advance_y; return m_glyphs[msb][lsb] = glyph; } private: block_allocator m_allocator; glyph_cache** m_glyphs[256]; char* m_font_signature; }; //---------------------------------------------------------font_cache_pool class font_cache_pool { public: //-------------------------------------------------------------------- ~font_cache_pool() { unsigned i; for(i = 0; i < m_num_fonts; ++i) { obj_allocator::deallocate(m_fonts[i]); } pod_allocator::deallocate(m_fonts, m_max_fonts); } //-------------------------------------------------------------------- font_cache_pool(unsigned max_fonts=32) : m_fonts(pod_allocator::allocate(max_fonts)), m_max_fonts(max_fonts), m_num_fonts(0), m_cur_font(0) {} //-------------------------------------------------------------------- void font(const char* font_signature, bool reset_cache = false) { int idx = find_font(font_signature); if(idx >= 0) { if(reset_cache) { obj_allocator::deallocate(m_fonts[idx]); m_fonts[idx] = obj_allocator::allocate(); m_fonts[idx]->signature(font_signature); } m_cur_font = m_fonts[idx]; } else { if(m_num_fonts >= m_max_fonts) { obj_allocator::deallocate(m_fonts[0]); memcpy(m_fonts, m_fonts + 1, (m_max_fonts - 1) * sizeof(font_cache*)); m_num_fonts = m_max_fonts - 1; } m_fonts[m_num_fonts] = obj_allocator::allocate(); m_fonts[m_num_fonts]->signature(font_signature); m_cur_font = m_fonts[m_num_fonts]; ++m_num_fonts; } } //-------------------------------------------------------------------- const font_cache* font() const { return m_cur_font; } //-------------------------------------------------------------------- const glyph_cache* find_glyph(unsigned glyph_code) const { if(m_cur_font) return m_cur_font->find_glyph(glyph_code); return 0; } //-------------------------------------------------------------------- glyph_cache* cache_glyph(unsigned glyph_code, unsigned glyph_index, unsigned data_size, glyph_data_type data_type, const rect_i& bounds, double advance_x, double advance_y) { if(m_cur_font) { return m_cur_font->cache_glyph(glyph_code, glyph_index, data_size, data_type, bounds, advance_x, advance_y); } return 0; } //-------------------------------------------------------------------- int find_font(const char* font_signature) { unsigned i; for(i = 0; i < m_num_fonts; i++) { if(m_fonts[i]->font_is(font_signature)) return int(i); } return -1; } private: font_cache** m_fonts; unsigned m_max_fonts; unsigned m_num_fonts; font_cache* m_cur_font; }; //------------------------------------------------------------------------ enum glyph_rendering { glyph_ren_native_mono, glyph_ren_native_gray8, glyph_ren_outline, glyph_ren_agg_mono, glyph_ren_agg_gray8 }; //------------------------------------------------------font_cache_manager template class font_cache_manager { public: typedef FontEngine font_engine_type; typedef font_cache_manager self_type; typedef typename font_engine_type::path_adaptor_type path_adaptor_type; typedef typename font_engine_type::gray8_adaptor_type gray8_adaptor_type; typedef typename gray8_adaptor_type::embedded_scanline gray8_scanline_type; typedef typename font_engine_type::mono_adaptor_type mono_adaptor_type; typedef typename mono_adaptor_type::embedded_scanline mono_scanline_type; //-------------------------------------------------------------------- font_cache_manager(font_engine_type& engine, unsigned max_fonts=32) : m_fonts(max_fonts), m_engine(engine), m_change_stamp(-1), m_prev_glyph(0), m_last_glyph(0) {} //-------------------------------------------------------------------- const glyph_cache* glyph(unsigned glyph_code) { synchronize(); const glyph_cache* gl = m_fonts.find_glyph(glyph_code); if(gl) { m_prev_glyph = m_last_glyph; return m_last_glyph = gl; } else { if(m_engine.prepare_glyph(glyph_code)) { m_prev_glyph = m_last_glyph; m_last_glyph = m_fonts.cache_glyph(glyph_code, m_engine.glyph_index(), m_engine.data_size(), m_engine.data_type(), m_engine.bounds(), m_engine.advance_x(), m_engine.advance_y()); m_engine.write_glyph_to(m_last_glyph->data); return m_last_glyph; } } return 0; } //-------------------------------------------------------------------- void init_embedded_adaptors(const glyph_cache* gl, double x, double y, double scale=1.0) { if(gl) { switch(gl->data_type) { default: return; case glyph_data_mono: m_mono_adaptor.init(gl->data, gl->data_size, x, y); break; case glyph_data_gray8: m_gray8_adaptor.init(gl->data, gl->data_size, x, y); break; case glyph_data_outline: m_path_adaptor.init(gl->data, gl->data_size, x, y, scale); break; } } } //-------------------------------------------------------------------- path_adaptor_type& path_adaptor() { return m_path_adaptor; } gray8_adaptor_type& gray8_adaptor() { return m_gray8_adaptor; } gray8_scanline_type& gray8_scanline() { return m_gray8_scanline; } mono_adaptor_type& mono_adaptor() { return m_mono_adaptor; } mono_scanline_type& mono_scanline() { return m_mono_scanline; } //-------------------------------------------------------------------- const glyph_cache* perv_glyph() const { return m_prev_glyph; } const glyph_cache* last_glyph() const { return m_last_glyph; } //-------------------------------------------------------------------- bool add_kerning(double* x, double* y) { if(m_prev_glyph && m_last_glyph) { return m_engine.add_kerning(m_prev_glyph->glyph_index, m_last_glyph->glyph_index, x, y); } return false; } //-------------------------------------------------------------------- void precache(unsigned from, unsigned to) { for(; from <= to; ++from) glyph(from); } //-------------------------------------------------------------------- void reset_cache() { m_fonts.font(m_engine.font_signature(), true); m_change_stamp = m_engine.change_stamp(); m_prev_glyph = m_last_glyph = 0; } private: //-------------------------------------------------------------------- font_cache_manager(const self_type&); const self_type& operator = (const self_type&); //-------------------------------------------------------------------- void synchronize() { if(m_change_stamp != m_engine.change_stamp()) { m_fonts.font(m_engine.font_signature()); m_change_stamp = m_engine.change_stamp(); m_prev_glyph = m_last_glyph = 0; } } font_cache_pool m_fonts; font_engine_type& m_engine; int m_change_stamp; double m_dx; double m_dy; const glyph_cache* m_prev_glyph; const glyph_cache* m_last_glyph; path_adaptor_type m_path_adaptor; gray8_adaptor_type m_gray8_adaptor; gray8_scanline_type m_gray8_scanline; mono_adaptor_type m_mono_adaptor; mono_scanline_type m_mono_scanline; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_interpolator_adaptor.h0000644000175000017500000000527112516137326027245 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_SPAN_INTERPOLATOR_ADAPTOR_INCLUDED #define AGG_SPAN_INTERPOLATOR_ADAPTOR_INCLUDED #include "agg_basics.h" namespace agg24 { //===============================================span_interpolator_adaptor template class span_interpolator_adaptor : public Interpolator { public: typedef Interpolator base_type; typedef typename base_type::trans_type trans_type; typedef Distortion distortion_type; //-------------------------------------------------------------------- span_interpolator_adaptor() {} span_interpolator_adaptor(const trans_type& trans, const distortion_type& dist) : base_type(trans), m_distortion(&dist) { } //-------------------------------------------------------------------- span_interpolator_adaptor(const trans_type& trans, const distortion_type& dist, double x, double y, unsigned len) : base_type(trans, x, y, len), m_distortion(&dist) { } //-------------------------------------------------------------------- const distortion_type& distortion() const { return *m_distortion; } //-------------------------------------------------------------------- void distortion(const distortion_type& dist) { m_distortion = dist; } //-------------------------------------------------------------------- void coordinates(int* x, int* y) const { base_type::coordinates(x, y); m_distortion->calculate(x, y); } private: //-------------------------------------------------------------------- const distortion_type* m_distortion; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_path_storage.h0000644000175000017500000014020512516137326024445 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_PATH_STORAGE_INCLUDED #define AGG_PATH_STORAGE_INCLUDED #include #include #include "agg_math.h" #include "agg_array.h" #include "agg_bezier_arc.h" namespace agg24 { //----------------------------------------------------vertex_block_storage template class vertex_block_storage { public: // Allocation parameters enum block_scale_e { block_shift = BlockShift, block_size = 1 << block_shift, block_mask = block_size - 1, block_pool = BlockPool }; typedef T value_type; typedef vertex_block_storage self_type; ~vertex_block_storage(); vertex_block_storage(); vertex_block_storage(const self_type& v); const self_type& operator = (const self_type& ps); void remove_all(); void free_all(); void add_vertex(double x, double y, unsigned cmd); void modify_vertex(unsigned idx, double x, double y); void modify_vertex(unsigned idx, double x, double y, unsigned cmd); void modify_command(unsigned idx, unsigned cmd); void swap_vertices(unsigned v1, unsigned v2); unsigned last_command() const; unsigned last_vertex(double* x, double* y) const; unsigned prev_vertex(double* x, double* y) const; double last_x() const; double last_y() const; unsigned total_vertices() const; unsigned vertex(unsigned idx, double* x, double* y) const; unsigned command(unsigned idx) const; private: void allocate_block(unsigned nb); int8u* storage_ptrs(T** xy_ptr); private: unsigned m_total_vertices; unsigned m_total_blocks; unsigned m_max_blocks; T** m_coord_blocks; int8u** m_cmd_blocks; }; //------------------------------------------------------------------------ template void vertex_block_storage::free_all() { if(m_total_blocks) { T** coord_blk = m_coord_blocks + m_total_blocks - 1; while(m_total_blocks--) { pod_allocator::deallocate( *coord_blk, block_size * 2 + block_size / (sizeof(T) / sizeof(unsigned char))); --coord_blk; } pod_allocator::deallocate(m_coord_blocks, m_max_blocks * 2); m_total_blocks = 0; m_max_blocks = 0; m_coord_blocks = 0; m_cmd_blocks = 0; m_total_vertices = 0; } } //------------------------------------------------------------------------ template vertex_block_storage::~vertex_block_storage() { free_all(); } //------------------------------------------------------------------------ template vertex_block_storage::vertex_block_storage() : m_total_vertices(0), m_total_blocks(0), m_max_blocks(0), m_coord_blocks(0), m_cmd_blocks(0) { } //------------------------------------------------------------------------ template vertex_block_storage::vertex_block_storage(const vertex_block_storage& v) : m_total_vertices(0), m_total_blocks(0), m_max_blocks(0), m_coord_blocks(0), m_cmd_blocks(0) { *this = v; } //------------------------------------------------------------------------ template const vertex_block_storage& vertex_block_storage::operator = (const vertex_block_storage& v) { remove_all(); unsigned i; for(i = 0; i < v.total_vertices(); i++) { double x, y; unsigned cmd = v.vertex(i, &x, &y); add_vertex(x, y, cmd); } return *this; } //------------------------------------------------------------------------ template inline void vertex_block_storage::remove_all() { m_total_vertices = 0; } //------------------------------------------------------------------------ template inline void vertex_block_storage::add_vertex(double x, double y, unsigned cmd) { T* coord_ptr = 0; *storage_ptrs(&coord_ptr) = (int8u)cmd; coord_ptr[0] = T(x); coord_ptr[1] = T(y); m_total_vertices++; } //------------------------------------------------------------------------ template inline void vertex_block_storage::modify_vertex(unsigned idx, double x, double y) { T* pv = m_coord_blocks[idx >> block_shift] + ((idx & block_mask) << 1); pv[0] = T(x); pv[1] = T(y); } //------------------------------------------------------------------------ template inline void vertex_block_storage::modify_vertex(unsigned idx, double x, double y, unsigned cmd) { unsigned block = idx >> block_shift; unsigned offset = idx & block_mask; T* pv = m_coord_blocks[block] + (offset << 1); pv[0] = T(x); pv[1] = T(y); m_cmd_blocks[block][offset] = (int8u)cmd; } //------------------------------------------------------------------------ template inline void vertex_block_storage::modify_command(unsigned idx, unsigned cmd) { m_cmd_blocks[idx >> block_shift][idx & block_mask] = (int8u)cmd; } //------------------------------------------------------------------------ template inline void vertex_block_storage::swap_vertices(unsigned v1, unsigned v2) { unsigned b1 = v1 >> block_shift; unsigned b2 = v2 >> block_shift; unsigned o1 = v1 & block_mask; unsigned o2 = v2 & block_mask; T* pv1 = m_coord_blocks[b1] + (o1 << 1); T* pv2 = m_coord_blocks[b2] + (o2 << 1); T val; val = pv1[0]; pv1[0] = pv2[0]; pv2[0] = val; val = pv1[1]; pv1[1] = pv2[1]; pv2[1] = val; int8u cmd = m_cmd_blocks[b1][o1]; m_cmd_blocks[b1][o1] = m_cmd_blocks[b2][o2]; m_cmd_blocks[b2][o2] = cmd; } //------------------------------------------------------------------------ template inline unsigned vertex_block_storage::last_command() const { if(m_total_vertices) return command(m_total_vertices - 1); return path_cmd_stop; } //------------------------------------------------------------------------ template inline unsigned vertex_block_storage::last_vertex(double* x, double* y) const { if(m_total_vertices) return vertex(m_total_vertices - 1, x, y); return path_cmd_stop; } //------------------------------------------------------------------------ template inline unsigned vertex_block_storage::prev_vertex(double* x, double* y) const { if(m_total_vertices > 1) return vertex(m_total_vertices - 2, x, y); return path_cmd_stop; } //------------------------------------------------------------------------ template inline double vertex_block_storage::last_x() const { if(m_total_vertices) { unsigned idx = m_total_vertices - 1; return m_coord_blocks[idx >> block_shift][(idx & block_mask) << 1]; } return 0.0; } //------------------------------------------------------------------------ template inline double vertex_block_storage::last_y() const { if(m_total_vertices) { unsigned idx = m_total_vertices - 1; return m_coord_blocks[idx >> block_shift][((idx & block_mask) << 1) + 1]; } return 0.0; } //------------------------------------------------------------------------ template inline unsigned vertex_block_storage::total_vertices() const { return m_total_vertices; } //------------------------------------------------------------------------ template inline unsigned vertex_block_storage::vertex(unsigned idx, double* x, double* y) const { unsigned nb = idx >> block_shift; const T* pv = m_coord_blocks[nb] + ((idx & block_mask) << 1); *x = pv[0]; *y = pv[1]; return m_cmd_blocks[nb][idx & block_mask]; } //------------------------------------------------------------------------ template inline unsigned vertex_block_storage::command(unsigned idx) const { return m_cmd_blocks[idx >> block_shift][idx & block_mask]; } //------------------------------------------------------------------------ template void vertex_block_storage::allocate_block(unsigned nb) { if(nb >= m_max_blocks) { T** new_coords = pod_allocator::allocate((m_max_blocks + block_pool) * 2); unsigned char** new_cmds = (unsigned char**)(new_coords + m_max_blocks + block_pool); if(m_coord_blocks) { memcpy(new_coords, m_coord_blocks, m_max_blocks * sizeof(T*)); memcpy(new_cmds, m_cmd_blocks, m_max_blocks * sizeof(unsigned char*)); pod_allocator::deallocate(m_coord_blocks, m_max_blocks * 2); } m_coord_blocks = new_coords; m_cmd_blocks = new_cmds; m_max_blocks += block_pool; } m_coord_blocks[nb] = pod_allocator::allocate(block_size * 2 + block_size / (sizeof(T) / sizeof(unsigned char))); m_cmd_blocks[nb] = (unsigned char*)(m_coord_blocks[nb] + block_size * 2); m_total_blocks++; } //------------------------------------------------------------------------ template int8u* vertex_block_storage::storage_ptrs(T** xy_ptr) { unsigned nb = m_total_vertices >> block_shift; if(nb >= m_total_blocks) { allocate_block(nb); } *xy_ptr = m_coord_blocks[nb] + ((m_total_vertices & block_mask) << 1); return m_cmd_blocks[nb] + (m_total_vertices & block_mask); } //-----------------------------------------------------poly_plain_adaptor template class poly_plain_adaptor { public: typedef T value_type; poly_plain_adaptor() : m_data(0), m_ptr(0), m_end(0), m_closed(false), m_stop(false) {} poly_plain_adaptor(const T* data, unsigned num_points, bool closed) : m_data(data), m_ptr(data), m_end(data + num_points * 2), m_closed(closed), m_stop(false) {} void init(const T* data, unsigned num_points, bool closed) { m_data = data; m_ptr = data; m_end = data + num_points * 2; m_closed = closed; m_stop = false; } void rewind(unsigned) { m_ptr = m_data; m_stop = false; } unsigned vertex(double* x, double* y) { if(m_ptr < m_end) { bool first = m_ptr == m_data; *x = *m_ptr++; *y = *m_ptr++; return first ? path_cmd_move_to : path_cmd_line_to; } *x = *y = 0.0; if(m_closed && !m_stop) { m_stop = true; return path_cmd_end_poly | path_flags_close; } return path_cmd_stop; } private: const T* m_data; const T* m_ptr; const T* m_end; bool m_closed; bool m_stop; }; //-------------------------------------------------poly_container_adaptor template class poly_container_adaptor { public: typedef typename Container::value_type vertex_type; poly_container_adaptor() : m_container(0), m_index(0), m_closed(false), m_stop(false) {} poly_container_adaptor(const Container& data, bool closed) : m_container(&data), m_index(0), m_closed(closed), m_stop(false) {} void init(const Container& data, bool closed) { m_container = &data; m_index = 0; m_closed = closed; m_stop = false; } void rewind(unsigned) { m_index = 0; m_stop = false; } unsigned vertex(double* x, double* y) { if(m_index < m_container->size()) { bool first = m_index == 0; const vertex_type& v = (*m_container)[m_index++]; *x = v.x; *y = v.y; return first ? path_cmd_move_to : path_cmd_line_to; } *x = *y = 0.0; if(m_closed && !m_stop) { m_stop = true; return path_cmd_end_poly | path_flags_close; } return path_cmd_stop; } private: const Container* m_container; unsigned m_index; bool m_closed; bool m_stop; }; //-----------------------------------------poly_container_reverse_adaptor template class poly_container_reverse_adaptor { public: typedef typename Container::value_type vertex_type; poly_container_reverse_adaptor() : m_container(0), m_index(-1), m_closed(false), m_stop(false) {} poly_container_reverse_adaptor(const Container& data, bool closed) : m_container(&data), m_index(-1), m_closed(closed), m_stop(false) {} void init(const Container& data, bool closed) { m_container = &data; m_index = m_container->size() - 1; m_closed = closed; m_stop = false; } void rewind(unsigned) { m_index = m_container->size() - 1; m_stop = false; } unsigned vertex(double* x, double* y) { if(m_index >= 0) { bool first = m_index == int(m_container->size() - 1); const vertex_type& v = (*m_container)[m_index--]; *x = v.x; *y = v.y; return first ? path_cmd_move_to : path_cmd_line_to; } *x = *y = 0.0; if(m_closed && !m_stop) { m_stop = true; return path_cmd_end_poly | path_flags_close; } return path_cmd_stop; } private: const Container* m_container; int m_index; bool m_closed; bool m_stop; }; //--------------------------------------------------------line_adaptor class line_adaptor { public: typedef double value_type; line_adaptor() : m_line(m_coord, 2, false) {} line_adaptor(double x1, double y1, double x2, double y2) : m_line(m_coord, 2, false) { m_coord[0] = x1; m_coord[1] = y1; m_coord[2] = x2; m_coord[3] = y2; } void init(double x1, double y1, double x2, double y2) { m_coord[0] = x1; m_coord[1] = y1; m_coord[2] = x2; m_coord[3] = y2; m_line.rewind(0); } void rewind(unsigned) { m_line.rewind(0); } unsigned vertex(double* x, double* y) { return m_line.vertex(x, y); } private: double m_coord[4]; poly_plain_adaptor m_line; }; //---------------------------------------------------------------path_base // A container to store vertices with their flags. // A path consists of a number of contours separated with "move_to" // commands. The path storage can keep and maintain more than one // path. // To navigate to the beginning of a particular path, use rewind(path_id); // Where path_id is what start_new_path() returns. So, when you call // start_new_path() you need to store its return value somewhere else // to navigate to the path afterwards. // // See also: vertex_source concept //------------------------------------------------------------------------ template class path_base { public: typedef VertexContainer container_type; typedef path_base self_type; //-------------------------------------------------------------------- path_base() : m_vertices(), m_iterator(0) {} void remove_all() { m_vertices.remove_all(); m_iterator = 0; } void free_all() { m_vertices.free_all(); m_iterator = 0; } // Make path functions //-------------------------------------------------------------------- unsigned start_new_path(); void move_to(double x, double y); void move_rel(double dx, double dy); void line_to(double x, double y); void line_rel(double dx, double dy); void hline_to(double x); void hline_rel(double dx); void vline_to(double y); void vline_rel(double dy); void arc_to(double rx, double ry, double angle, bool large_arc_flag, bool sweep_flag, double x, double y); void arc_rel(double rx, double ry, double angle, bool large_arc_flag, bool sweep_flag, double dx, double dy); void curve3(double x_ctrl, double y_ctrl, double x_to, double y_to); void curve3_rel(double dx_ctrl, double dy_ctrl, double dx_to, double dy_to); void curve3(double x_to, double y_to); void curve3_rel(double dx_to, double dy_to); void curve4(double x_ctrl1, double y_ctrl1, double x_ctrl2, double y_ctrl2, double x_to, double y_to); void curve4_rel(double dx_ctrl1, double dy_ctrl1, double dx_ctrl2, double dy_ctrl2, double dx_to, double dy_to); void curve4(double x_ctrl2, double y_ctrl2, double x_to, double y_to); void curve4_rel(double x_ctrl2, double y_ctrl2, double x_to, double y_to); void end_poly(unsigned flags = path_flags_close); void close_polygon(unsigned flags = path_flags_none); // Accessors //-------------------------------------------------------------------- const container_type& vertices() const { return m_vertices; } container_type& vertices() { return m_vertices; } unsigned total_vertices() const; void rel_to_abs(double* x, double* y) const; unsigned last_vertex(double* x, double* y) const; unsigned prev_vertex(double* x, double* y) const; double last_x() const; double last_y() const; unsigned vertex(unsigned idx, double* x, double* y) const; unsigned command(unsigned idx) const; void modify_vertex(unsigned idx, double x, double y); void modify_vertex(unsigned idx, double x, double y, unsigned cmd); void modify_command(unsigned idx, unsigned cmd); // VertexSource interface //-------------------------------------------------------------------- void rewind(unsigned path_id); unsigned vertex(double* x, double* y); // Arrange the orientation of a polygon, all polygons in a path, // or in all paths. After calling arrange_orientations() or // arrange_orientations_all_paths(), all the polygons will have // the same orientation, i.e. path_flags_cw or path_flags_ccw //-------------------------------------------------------------------- unsigned arrange_polygon_orientation(unsigned start, path_flags_e orientation); unsigned arrange_orientations(unsigned path_id, path_flags_e orientation); void arrange_orientations_all_paths(path_flags_e orientation); void invert_polygon(unsigned start); // Flip all vertices horizontally or vertically, // between x1 and x2, or between y1 and y2 respectively //-------------------------------------------------------------------- void flip_x(double x1, double x2); void flip_y(double y1, double y2); // Concatenate path. The path is added as is. //-------------------------------------------------------------------- template void concat_path(VertexSource& vs, unsigned path_id = 0) { double x, y; unsigned cmd; vs.rewind(path_id); while(!is_stop(cmd = vs.vertex(&x, &y))) { m_vertices.add_vertex(x, y, cmd); } } //-------------------------------------------------------------------- // Join path. The path is joined with the existing one, that is, // it behaves as if the pen of a plotter was always down (drawing) template void join_path(VertexSource& vs, unsigned path_id = 0) { double x, y; unsigned cmd; vs.rewind(path_id); cmd = vs.vertex(&x, &y); if(!is_stop(cmd)) { if(is_vertex(cmd)) { double x0, y0; unsigned cmd0 = last_vertex(&x0, &y0); if(is_vertex(cmd0)) { if(calc_distance(x, y, x0, y0) > vertex_dist_epsilon) { if(is_move_to(cmd)) cmd = path_cmd_line_to; m_vertices.add_vertex(x, y, cmd); } } else { if(is_stop(cmd0)) { cmd = path_cmd_move_to; } else { if(is_move_to(cmd)) cmd = path_cmd_line_to; } m_vertices.add_vertex(x, y, cmd); } } while(!is_stop(cmd = vs.vertex(&x, &y))) { m_vertices.add_vertex(x, y, is_move_to(cmd) ? path_cmd_line_to : cmd); } } } // Concatenate polygon/polyline. //-------------------------------------------------------------------- template void concat_poly(const T* data, unsigned num_points, bool closed) { poly_plain_adaptor poly(data, num_points, closed); concat_path(poly); } // Join polygon/polyline continuously. //-------------------------------------------------------------------- template void join_poly(const T* data, unsigned num_points, bool closed) { poly_plain_adaptor poly(data, num_points, closed); join_path(poly); } private: unsigned perceive_polygon_orientation(unsigned start, unsigned end); void invert_polygon(unsigned start, unsigned end); VertexContainer m_vertices; unsigned m_iterator; }; //------------------------------------------------------------------------ template unsigned path_base::start_new_path() { if(!is_stop(m_vertices.last_command())) { m_vertices.add_vertex(0.0, 0.0, path_cmd_stop); } return m_vertices.total_vertices(); } //------------------------------------------------------------------------ template inline void path_base::rel_to_abs(double* x, double* y) const { if(m_vertices.total_vertices()) { double x2; double y2; if(is_vertex(m_vertices.last_vertex(&x2, &y2))) { *x += x2; *y += y2; } } } //------------------------------------------------------------------------ template inline void path_base::move_to(double x, double y) { m_vertices.add_vertex(x, y, path_cmd_move_to); } //------------------------------------------------------------------------ template inline void path_base::move_rel(double dx, double dy) { rel_to_abs(&dx, &dy); m_vertices.add_vertex(dx, dy, path_cmd_move_to); } //------------------------------------------------------------------------ template inline void path_base::line_to(double x, double y) { m_vertices.add_vertex(x, y, path_cmd_line_to); } //------------------------------------------------------------------------ template inline void path_base::line_rel(double dx, double dy) { rel_to_abs(&dx, &dy); m_vertices.add_vertex(dx, dy, path_cmd_line_to); } //------------------------------------------------------------------------ template inline void path_base::hline_to(double x) { m_vertices.add_vertex(x, last_y(), path_cmd_line_to); } //------------------------------------------------------------------------ template inline void path_base::hline_rel(double dx) { double dy = 0; rel_to_abs(&dx, &dy); m_vertices.add_vertex(dx, dy, path_cmd_line_to); } //------------------------------------------------------------------------ template inline void path_base::vline_to(double y) { m_vertices.add_vertex(last_x(), y, path_cmd_line_to); } //------------------------------------------------------------------------ template inline void path_base::vline_rel(double dy) { double dx = 0; rel_to_abs(&dx, &dy); m_vertices.add_vertex(dx, dy, path_cmd_line_to); } //------------------------------------------------------------------------ template void path_base::arc_to(double rx, double ry, double angle, bool large_arc_flag, bool sweep_flag, double x, double y) { if(m_vertices.total_vertices() && is_vertex(m_vertices.last_command())) { const double epsilon = 1e-30; double x0 = 0.0; double y0 = 0.0; m_vertices.last_vertex(&x0, &y0); rx = fabs(rx); ry = fabs(ry); // Ensure radii are valid //------------------------- if(rx < epsilon || ry < epsilon) { line_to(x, y); return; } if(calc_distance(x0, y0, x, y) < epsilon) { // If the endpoints (x, y) and (x0, y0) are identical, then this // is equivalent to omitting the elliptical arc segment entirely. return; } bezier_arc_svg a(x0, y0, rx, ry, angle, large_arc_flag, sweep_flag, x, y); if(a.radii_ok()) { join_path(a); } else { line_to(x, y); } } else { move_to(x, y); } } //------------------------------------------------------------------------ template void path_base::arc_rel(double rx, double ry, double angle, bool large_arc_flag, bool sweep_flag, double dx, double dy) { rel_to_abs(&dx, &dy); arc_to(rx, ry, angle, large_arc_flag, sweep_flag, dx, dy); } //------------------------------------------------------------------------ template void path_base::curve3(double x_ctrl, double y_ctrl, double x_to, double y_to) { m_vertices.add_vertex(x_ctrl, y_ctrl, path_cmd_curve3); m_vertices.add_vertex(x_to, y_to, path_cmd_curve3); } //------------------------------------------------------------------------ template void path_base::curve3_rel(double dx_ctrl, double dy_ctrl, double dx_to, double dy_to) { rel_to_abs(&dx_ctrl, &dy_ctrl); rel_to_abs(&dx_to, &dy_to); m_vertices.add_vertex(dx_ctrl, dy_ctrl, path_cmd_curve3); m_vertices.add_vertex(dx_to, dy_to, path_cmd_curve3); } //------------------------------------------------------------------------ template void path_base::curve3(double x_to, double y_to) { double x0; double y0; if(is_vertex(m_vertices.last_vertex(&x0, &y0))) { double x_ctrl; double y_ctrl; unsigned cmd = m_vertices.prev_vertex(&x_ctrl, &y_ctrl); if(is_curve(cmd)) { x_ctrl = x0 + x0 - x_ctrl; y_ctrl = y0 + y0 - y_ctrl; } else { x_ctrl = x0; y_ctrl = y0; } curve3(x_ctrl, y_ctrl, x_to, y_to); } } //------------------------------------------------------------------------ template void path_base::curve3_rel(double dx_to, double dy_to) { rel_to_abs(&dx_to, &dy_to); curve3(dx_to, dy_to); } //------------------------------------------------------------------------ template void path_base::curve4(double x_ctrl1, double y_ctrl1, double x_ctrl2, double y_ctrl2, double x_to, double y_to) { m_vertices.add_vertex(x_ctrl1, y_ctrl1, path_cmd_curve4); m_vertices.add_vertex(x_ctrl2, y_ctrl2, path_cmd_curve4); m_vertices.add_vertex(x_to, y_to, path_cmd_curve4); } //------------------------------------------------------------------------ template void path_base::curve4_rel(double dx_ctrl1, double dy_ctrl1, double dx_ctrl2, double dy_ctrl2, double dx_to, double dy_to) { rel_to_abs(&dx_ctrl1, &dy_ctrl1); rel_to_abs(&dx_ctrl2, &dy_ctrl2); rel_to_abs(&dx_to, &dy_to); m_vertices.add_vertex(dx_ctrl1, dy_ctrl1, path_cmd_curve4); m_vertices.add_vertex(dx_ctrl2, dy_ctrl2, path_cmd_curve4); m_vertices.add_vertex(dx_to, dy_to, path_cmd_curve4); } //------------------------------------------------------------------------ template void path_base::curve4(double x_ctrl2, double y_ctrl2, double x_to, double y_to) { double x0; double y0; if(is_vertex(last_vertex(&x0, &y0))) { double x_ctrl1; double y_ctrl1; unsigned cmd = prev_vertex(&x_ctrl1, &y_ctrl1); if(is_curve(cmd)) { x_ctrl1 = x0 + x0 - x_ctrl1; y_ctrl1 = y0 + y0 - y_ctrl1; } else { x_ctrl1 = x0; y_ctrl1 = y0; } curve4(x_ctrl1, y_ctrl1, x_ctrl2, y_ctrl2, x_to, y_to); } } //------------------------------------------------------------------------ template void path_base::curve4_rel(double dx_ctrl2, double dy_ctrl2, double dx_to, double dy_to) { rel_to_abs(&dx_ctrl2, &dy_ctrl2); rel_to_abs(&dx_to, &dy_to); curve4(dx_ctrl2, dy_ctrl2, dx_to, dy_to); } //------------------------------------------------------------------------ template inline void path_base::end_poly(unsigned flags) { if(is_vertex(m_vertices.last_command())) { m_vertices.add_vertex(0.0, 0.0, path_cmd_end_poly | flags); } } //------------------------------------------------------------------------ template inline void path_base::close_polygon(unsigned flags) { end_poly(path_flags_close | flags); } //------------------------------------------------------------------------ template inline unsigned path_base::total_vertices() const { return m_vertices.total_vertices(); } //------------------------------------------------------------------------ template inline unsigned path_base::last_vertex(double* x, double* y) const { return m_vertices.last_vertex(x, y); } //------------------------------------------------------------------------ template inline unsigned path_base::prev_vertex(double* x, double* y) const { return m_vertices.prev_vertex(x, y); } //------------------------------------------------------------------------ template inline double path_base::last_x() const { return m_vertices.last_x(); } //------------------------------------------------------------------------ template inline double path_base::last_y() const { return m_vertices.last_y(); } //------------------------------------------------------------------------ template inline unsigned path_base::vertex(unsigned idx, double* x, double* y) const { return m_vertices.vertex(idx, x, y); } //------------------------------------------------------------------------ template inline unsigned path_base::command(unsigned idx) const { return m_vertices.command(idx); } //------------------------------------------------------------------------ template void path_base::modify_vertex(unsigned idx, double x, double y) { m_vertices.modify_vertex(idx, x, y); } //------------------------------------------------------------------------ template void path_base::modify_vertex(unsigned idx, double x, double y, unsigned cmd) { m_vertices.modify_vertex(idx, x, y, cmd); } //------------------------------------------------------------------------ template void path_base::modify_command(unsigned idx, unsigned cmd) { m_vertices.modify_command(idx, cmd); } //------------------------------------------------------------------------ template inline void path_base::rewind(unsigned path_id) { m_iterator = path_id; } //------------------------------------------------------------------------ template inline unsigned path_base::vertex(double* x, double* y) { if(m_iterator >= m_vertices.total_vertices()) return path_cmd_stop; return m_vertices.vertex(m_iterator++, x, y); } //------------------------------------------------------------------------ template unsigned path_base::perceive_polygon_orientation(unsigned start, unsigned end) { // Calculate signed area (double area to be exact) //--------------------- unsigned np = end - start; double area = 0.0; unsigned i; for(i = 0; i < np; i++) { double x1, y1, x2, y2; m_vertices.vertex(start + i, &x1, &y1); m_vertices.vertex(start + (i + 1) % np, &x2, &y2); area += x1 * y2 - y1 * x2; } return (area < 0.0) ? path_flags_cw : path_flags_ccw; } //------------------------------------------------------------------------ template void path_base::invert_polygon(unsigned start, unsigned end) { unsigned i; unsigned tmp_cmd = m_vertices.command(start); --end; // Make "end" inclusive // Shift all commands to one position for(i = start; i < end; i++) { m_vertices.modify_command(i, m_vertices.command(i + 1)); } // Assign starting command to the ending command m_vertices.modify_command(end, tmp_cmd); // Reverse the polygon while(end > start) { m_vertices.swap_vertices(start++, end--); } } //------------------------------------------------------------------------ template void path_base::invert_polygon(unsigned start) { // Skip all non-vertices at the beginning while(start < m_vertices.total_vertices() && !is_vertex(m_vertices.command(start))) ++start; // Skip all insignificant move_to while(start+1 < m_vertices.total_vertices() && is_move_to(m_vertices.command(start)) && is_move_to(m_vertices.command(start+1))) ++start; // Find the last vertex unsigned end = start + 1; while(end < m_vertices.total_vertices() && !is_next_poly(m_vertices.command(end))) ++end; if(end - start > 2) { invert_polygon(start, end); } } //------------------------------------------------------------------------ template unsigned path_base::arrange_polygon_orientation(unsigned start, path_flags_e orientation) { if(orientation == path_flags_none) return start; // Skip all non-vertices at the beginning while(start < m_vertices.total_vertices() && !is_vertex(m_vertices.command(start))) ++start; // Skip all insignificant move_to while(start+1 < m_vertices.total_vertices() && is_move_to(m_vertices.command(start)) && is_move_to(m_vertices.command(start+1))) ++start; // Find the last vertex unsigned end = start + 1; while(end < m_vertices.total_vertices() && !is_next_poly(m_vertices.command(end))) ++end; if(end - start > 2) { if(perceive_polygon_orientation(start, end) != unsigned(orientation)) { // Invert polygon, set orientation flag, and skip all end_poly invert_polygon(start, end); unsigned cmd; while(end < m_vertices.total_vertices() && is_end_poly(cmd = m_vertices.command(end))) { m_vertices.modify_command(end++, set_orientation(cmd, orientation)); } } } return end; } //------------------------------------------------------------------------ template unsigned path_base::arrange_orientations(unsigned start, path_flags_e orientation) { if(orientation != path_flags_none) { while(start < m_vertices.total_vertices()) { start = arrange_polygon_orientation(start, orientation); if(is_stop(m_vertices.command(start))) { ++start; break; } } } return start; } //------------------------------------------------------------------------ template void path_base::arrange_orientations_all_paths(path_flags_e orientation) { if(orientation != path_flags_none) { unsigned start = 0; while(start < m_vertices.total_vertices()) { start = arrange_orientations(start, orientation); } } } //------------------------------------------------------------------------ template void path_base::flip_x(double x1, double x2) { unsigned i; double x, y; for(i = 0; i < m_vertices.total_vertices(); i++) { unsigned cmd = m_vertices.vertex(i, &x, &y); if(is_vertex(cmd)) { m_vertices.modify_vertex(i, x2 - x + x1, y); } } } //------------------------------------------------------------------------ template void path_base::flip_y(double y1, double y2) { unsigned i; double x, y; for(i = 0; i < m_vertices.total_vertices(); i++) { unsigned cmd = m_vertices.vertex(i, &x, &y); if(is_vertex(cmd)) { m_vertices.modify_vertex(i, x, y2 - y + y1); } } } //-----------------------------------------------------vertex_stl_storage template class vertex_stl_storage { public: typedef typename Container::value_type vertex_type; typedef typename vertex_type::value_type value_type; void remove_all() { m_vertices.clear(); } void free_all() { m_vertices.clear(); } void add_vertex(double x, double y, unsigned cmd) { m_vertices.push_back(vertex_type(value_type(x), value_type(y), int8u(cmd))); } void modify_vertex(unsigned idx, double x, double y) { vertex_type& v = m_vertices[idx]; v.x = value_type(x); v.y = value_type(y); } void modify_vertex(unsigned idx, double x, double y, unsigned cmd) { vertex_type& v = m_vertices[idx]; v.x = value_type(x); v.y = value_type(y); v.cmd = int8u(cmd); } void modify_command(unsigned idx, unsigned cmd) { m_vertices[idx].cmd = int8u(cmd); } void swap_vertices(unsigned v1, unsigned v2) { vertex_type t = m_vertices[v1]; m_vertices[v1] = m_vertices[v2]; m_vertices[v2] = t; } unsigned last_command() const { return m_vertices.size() ? m_vertices[m_vertices.size() - 1].cmd : path_cmd_stop; } unsigned last_vertex(double* x, double* y) const { if(m_vertices.size() == 0) { *x = *y = 0.0; return path_cmd_stop; } return vertex(m_vertices.size() - 1, x, y); } unsigned prev_vertex(double* x, double* y) const { if(m_vertices.size() < 2) { *x = *y = 0.0; return path_cmd_stop; } return vertex(m_vertices.size() - 2, x, y); } double last_x() const { return m_vertices.size() ? m_vertices[m_vertices.size() - 1].x : 0.0; } double last_y() const { return m_vertices.size() ? m_vertices[m_vertices.size() - 1].y : 0.0; } unsigned total_vertices() const { return m_vertices.size(); } unsigned vertex(unsigned idx, double* x, double* y) const { const vertex_type& v = m_vertices[idx]; *x = v.x; *y = v.y; return v.cmd; } unsigned command(unsigned idx) const { return m_vertices[idx].cmd; } private: Container m_vertices; }; //-----------------------------------------------------------path_storage typedef path_base > path_storage; // Example of declarations path_storage with pod_bvector as a container //----------------------------------------------------------------------- //typedef path_base > > path_storage; } // Example of declarations path_storage with std::vector as a container //--------------------------------------------------------------------------- //#include //namespace agg24 //{ // typedef path_base > > stl_path_storage; //} #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_rounded_rect.h0000644000175000017500000000441712516137326024446 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Rounded rectangle vertex generator // //---------------------------------------------------------------------------- #ifndef AGG_ROUNDED_RECT_INCLUDED #define AGG_ROUNDED_RECT_INCLUDED #include "agg_basics.h" #include "agg_arc.h" namespace agg24 { //------------------------------------------------------------rounded_rect // // See Implemantation agg_rounded_rect.cpp // class rounded_rect { public: rounded_rect() {} rounded_rect(double x1, double y1, double x2, double y2, double r); void rect(double x1, double y1, double x2, double y2); void radius(double r); void radius(double rx, double ry); void radius(double rx_bottom, double ry_bottom, double rx_top, double ry_top); void radius(double rx1, double ry1, double rx2, double ry2, double rx3, double ry3, double rx4, double ry4); void normalize_radius(); void approximation_scale(double s) { m_arc.approximation_scale(s); } double approximation_scale() const { return m_arc.approximation_scale(); } void rewind(unsigned); unsigned vertex(double* x, double* y); private: double m_x1; double m_y1; double m_x2; double m_y2; double m_rx1; double m_ry1; double m_rx2; double m_ry2; double m_rx3; double m_ry3; double m_rx4; double m_ry4; unsigned m_status; arc m_arc; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_math_stroke.h0000644000175000017500000004274312516137326024315 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Stroke math // //---------------------------------------------------------------------------- #ifndef AGG_STROKE_MATH_INCLUDED #define AGG_STROKE_MATH_INCLUDED #include "agg_math.h" #include "agg_vertex_sequence.h" namespace agg24 { //-------------------------------------------------------------line_cap_e enum line_cap_e { butt_cap, square_cap, round_cap }; //------------------------------------------------------------line_join_e enum line_join_e { miter_join = 0, miter_join_revert = 1, round_join = 2, bevel_join = 3, miter_join_round = 4 }; //-----------------------------------------------------------inner_join_e enum inner_join_e { inner_bevel, inner_miter, inner_jag, inner_round }; //------------------------------------------------------------math_stroke template class math_stroke { public: typedef typename VertexConsumer::value_type coord_type; math_stroke(); void line_cap(line_cap_e lc) { m_line_cap = lc; } void line_join(line_join_e lj) { m_line_join = lj; } void inner_join(inner_join_e ij) { m_inner_join = ij; } line_cap_e line_cap() const { return m_line_cap; } line_join_e line_join() const { return m_line_join; } inner_join_e inner_join() const { return m_inner_join; } void width(double w); void miter_limit(double ml) { m_miter_limit = ml; } void miter_limit_theta(double t); void inner_miter_limit(double ml) { m_inner_miter_limit = ml; } void approximation_scale(double as) { m_approx_scale = as; } double width() const { return m_width * 2.0; } double miter_limit() const { return m_miter_limit; } double inner_miter_limit() const { return m_inner_miter_limit; } double approximation_scale() const { return m_approx_scale; } void calc_cap(VertexConsumer& out_vertices, const vertex_dist& v0, const vertex_dist& v1, double len); void calc_join(VertexConsumer& out_vertices, const vertex_dist& v0, const vertex_dist& v1, const vertex_dist& v2, double len1, double len2); private: void calc_arc(VertexConsumer& out_vertices, double x, double y, double dx1, double dy1, double dx2, double dy2); void calc_miter(VertexConsumer& out_vertices, const vertex_dist& v0, const vertex_dist& v1, const vertex_dist& v2, double dx1, double dy1, double dx2, double dy2, line_join_e lj, double ml); double m_width; double m_width_abs; int m_width_sign; double m_miter_limit; double m_inner_miter_limit; double m_approx_scale; line_cap_e m_line_cap; line_join_e m_line_join; inner_join_e m_inner_join; }; //----------------------------------------------------------------------- template math_stroke::math_stroke() : m_width(0.5), m_width_abs(0.5), m_width_sign(1), m_miter_limit(4.0), m_inner_miter_limit(1.01), m_approx_scale(1.0), m_line_cap(butt_cap), m_line_join(miter_join), m_inner_join(inner_miter) { } //----------------------------------------------------------------------- template void math_stroke::width(double w) { m_width = w * 0.5; if(m_width < 0) { m_width_abs = -m_width; m_width_sign = -1; } else { m_width_abs = m_width; m_width_sign = 1; } } //----------------------------------------------------------------------- template void math_stroke::miter_limit_theta(double t) { m_miter_limit = 1.0 / sin(t * 0.5) ; } //----------------------------------------------------------------------- template void math_stroke::calc_arc(VC& out_vertices, double x, double y, double dx1, double dy1, double dx2, double dy2) { double a1 = atan2(dy1 * m_width_sign, dx1 * m_width_sign); double a2 = atan2(dy2 * m_width_sign, dx2 * m_width_sign); double da = a1 - a2; int i, n; da = acos(m_width_abs / (m_width_abs + 0.125 / m_approx_scale)) * 2; out_vertices.add(coord_type(x + dx1, y + dy1)); if(m_width_sign > 0) { if(a1 > a2) a2 += 2 * pi; n = int((a2 - a1) / da); da = (a2 - a1) / (n + 1); a1 += da; for(i = 0; i < n; i++) { out_vertices.add(coord_type(x + cos(a1) * m_width, y + sin(a1) * m_width)); a1 += da; } } else { if(a1 < a2) a2 -= 2 * pi; n = int((a1 - a2) / da); da = (a1 - a2) / (n + 1); a1 -= da; for(i = 0; i < n; i++) { out_vertices.add(coord_type(x + cos(a1) * m_width, y + sin(a1) * m_width)); a1 -= da; } } out_vertices.add(coord_type(x + dx2, y + dy2)); } //----------------------------------------------------------------------- template void math_stroke::calc_miter(VC& out_vertices, const vertex_dist& v0, const vertex_dist& v1, const vertex_dist& v2, double dx1, double dy1, double dx2, double dy2, line_join_e lj, double ml) { double xi = v1.x; double yi = v1.y; bool miter_limit_exceeded = true; // Assume the worst if(calc_intersection(v0.x + dx1, v0.y - dy1, v1.x + dx1, v1.y - dy1, v1.x + dx2, v1.y - dy2, v2.x + dx2, v2.y - dy2, &xi, &yi)) { // Calculation of the intersection succeeded //--------------------- double d1 = calc_distance(v1.x, v1.y, xi, yi); double lim = m_width_abs * ml; if(d1 <= lim) { // Inside the miter limit //--------------------- out_vertices.add(coord_type(xi, yi)); miter_limit_exceeded = false; } } else { // Calculation of the intersection failed, most probably // the three points lie one straight line. // First check if v0 and v2 lie on the opposite sides of vector: // (v1.x, v1.y) -> (v1.x+dx1, v1.y-dy1), that is, the perpendicular // to the line determined by vertices v0 and v1. // This condition determines whether the next line segments continues // the previous one or goes back. //---------------- double x2 = v1.x + dx1; double y2 = v1.y - dy1; if(((x2 - v0.x)*dy1 - (v0.y - y2)*dx1 < 0.0) != ((x2 - v2.x)*dy1 - (v2.y - y2)*dx1 < 0.0)) { // This case means that the next segment continues // the previous one (straight line) //----------------- out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1)); miter_limit_exceeded = false; } } if(miter_limit_exceeded) { // Miter limit exceeded //------------------------ switch(lj) { case miter_join_revert: // For the compatibility with SVG, PDF, etc, // we use a simple bevel join instead of // "smart" bevel //------------------- out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1)); out_vertices.add(coord_type(v1.x + dx2, v1.y - dy2)); break; case miter_join_round: calc_arc(out_vertices, v1.x, v1.y, dx1, -dy1, dx2, -dy2); break; default: // If no miter-revert, calculate new dx1, dy1, dx2, dy2 //---------------- ml *= m_width_sign; out_vertices.add(coord_type(v1.x + dx1 + dy1 * ml, v1.y - dy1 + dx1 * ml)); out_vertices.add(coord_type(v1.x + dx2 - dy2 * ml, v1.y - dy2 - dx2 * ml)); break; } } } //--------------------------------------------------------stroke_calc_cap template void math_stroke::calc_cap(VC& out_vertices, const vertex_dist& v0, const vertex_dist& v1, double len) { out_vertices.remove_all(); double dx1 = (v1.y - v0.y) / len; double dy1 = (v1.x - v0.x) / len; double dx2 = 0; double dy2 = 0; dx1 *= m_width; dy1 *= m_width; if(m_line_cap != round_cap) { if(m_line_cap == square_cap) { dx2 = dy1 * m_width_sign; dy2 = dx1 * m_width_sign; } out_vertices.add(coord_type(v0.x - dx1 - dx2, v0.y + dy1 - dy2)); out_vertices.add(coord_type(v0.x + dx1 - dx2, v0.y - dy1 - dy2)); } else { double da = acos(m_width_abs / (m_width_abs + 0.125 / m_approx_scale)) * 2; double a1; int i; int n = int(pi / da); da = pi / (n + 1); out_vertices.add(coord_type(v0.x - dx1, v0.y + dy1)); if(m_width_sign > 0) { a1 = atan2(dy1, -dx1); a1 += da; for(i = 0; i < n; i++) { out_vertices.add(coord_type(v0.x + cos(a1) * m_width, v0.y + sin(a1) * m_width)); a1 += da; } } else { a1 = atan2(-dy1, dx1); a1 -= da; for(i = 0; i < n; i++) { out_vertices.add(coord_type(v0.x + cos(a1) * m_width, v0.y + sin(a1) * m_width)); a1 -= da; } } out_vertices.add(coord_type(v0.x + dx1, v0.y - dy1)); } } //----------------------------------------------------------------------- template void math_stroke::calc_join(VC& out_vertices, const vertex_dist& v0, const vertex_dist& v1, const vertex_dist& v2, double len1, double len2) { double dx1, dy1, dx2, dy2; double d; dx1 = m_width * (v1.y - v0.y) / len1; dy1 = m_width * (v1.x - v0.x) / len1; dx2 = m_width * (v2.y - v1.y) / len2; dy2 = m_width * (v2.x - v1.x) / len2; out_vertices.remove_all(); double cp = cross_product(v0.x, v0.y, v1.x, v1.y, v2.x, v2.y); if(cp != 0 && (cp > 0) == (m_width > 0)) { // Inner join //--------------- switch(m_inner_join) { default: // inner_bevel out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1)); out_vertices.add(coord_type(v1.x + dx2, v1.y - dy2)); break; case inner_miter: calc_miter(out_vertices, v0, v1, v2, dx1, dy1, dx2, dy2, miter_join_revert, m_inner_miter_limit); break; case inner_jag: case inner_round: { d = (dx1-dx2) * (dx1-dx2) + (dy1-dy2) * (dy1-dy2); if(d < len1 * len1 && d < len2 * len2) { calc_miter(out_vertices, v0, v1, v2, dx1, dy1, dx2, dy2, miter_join_revert, m_inner_miter_limit); } else { if(m_inner_join == inner_jag) { out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1)); out_vertices.add(coord_type(v1.x, v1.y )); out_vertices.add(coord_type(v1.x + dx2, v1.y - dy2)); } else { out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1)); out_vertices.add(coord_type(v1.x, v1.y )); calc_arc(out_vertices, v1.x, v1.y, dx2, -dy2, dx1, -dy1); out_vertices.add(coord_type(v1.x, v1.y )); out_vertices.add(coord_type(v1.x + dx2, v1.y - dy2)); } } } break; } } else { // Outer join //--------------- line_join_e lj = m_line_join; if(m_line_join == round_join || m_line_join == bevel_join) { // This is an optimization that reduces the number of points // in cases of almost collonear segments. If there's no // visible difference between bevel and miter joins we'd rather // use miter join because it adds only one point instead of two. // // Here we calculate the middle point between the bevel points // and then, the distance between v1 and this middle point. // At outer joins this distance always less than stroke width, // because it's actually the height of an isosceles triangle of // v1 and its two bevel points. If the difference between this // width and this value is small (no visible bevel) we can switch // to the miter join. // // The constant in the expression makes the result approximately // the same as in round joins and caps. One can safely comment // out this "if". //------------------- double dx = (dx1 + dx2) / 2; double dy = (dy1 + dy2) / 2; d = m_width_abs - sqrt(dx * dx + dy * dy); if(d < 0.0625 / m_approx_scale) { lj = miter_join; } } switch(lj) { case miter_join: case miter_join_revert: case miter_join_round: calc_miter(out_vertices, v0, v1, v2, dx1, dy1, dx2, dy2, lj, m_miter_limit); break; case round_join: calc_arc(out_vertices, v1.x, v1.y, dx1, -dy1, dx2, -dy2); break; default: // Bevel join out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1)); out_vertices.add(coord_type(v1.x + dx2, v1.y - dy2)); break; } } } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_pixfmt_rgb_packed.h0000644000175000017500000013352212516137326025441 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for high precision colors has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_PIXFMT_RGB_PACKED_INCLUDED #define AGG_PIXFMT_RGB_PACKED_INCLUDED #include #include "agg_basics.h" #include "agg_color_rgba.h" #include "agg_rendering_buffer.h" namespace agg24 { //=========================================================blender_rgb555 struct blender_rgb555 { typedef rgba8 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int16u pixel_type; static AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned) { pixel_type rgb = *p; calc_type r = (rgb >> 7) & 0xF8; calc_type g = (rgb >> 2) & 0xF8; calc_type b = (rgb << 3) & 0xF8; *p = (pixel_type) (((((cr - r) * alpha + (r << 8)) >> 1) & 0x7C00) | ((((cg - g) * alpha + (g << 8)) >> 6) & 0x03E0) | (((cb - b) * alpha + (b << 8)) >> 11) | 0x8000); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((r & 0xF8) << 7) | ((g & 0xF8) << 2) | (b >> 3) | 0x8000); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p >> 7) & 0xF8, (p >> 2) & 0xF8, (p << 3) & 0xF8); } }; //=====================================================blender_rgb555_pre struct blender_rgb555_pre { typedef rgba8 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int16u pixel_type; static AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover) { alpha = color_type::base_mask - alpha; pixel_type rgb = *p; calc_type r = (rgb >> 7) & 0xF8; calc_type g = (rgb >> 2) & 0xF8; calc_type b = (rgb << 3) & 0xF8; *p = (pixel_type) ((((r * alpha + cr * cover) >> 1) & 0x7C00) | (((g * alpha + cg * cover) >> 6) & 0x03E0) | ((b * alpha + cb * cover) >> 11) | 0x8000); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((r & 0xF8) << 7) | ((g & 0xF8) << 2) | (b >> 3) | 0x8000); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p >> 7) & 0xF8, (p >> 2) & 0xF8, (p << 3) & 0xF8); } }; //=====================================================blender_rgb555_gamma template class blender_rgb555_gamma { public: typedef rgba8 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int16u pixel_type; typedef Gamma gamma_type; blender_rgb555_gamma() : m_gamma(0) {} void gamma(const gamma_type& g) { m_gamma = &g; } AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned) { pixel_type rgb = *p; calc_type r = m_gamma->dir((rgb >> 7) & 0xF8); calc_type g = m_gamma->dir((rgb >> 2) & 0xF8); calc_type b = m_gamma->dir((rgb << 3) & 0xF8); *p = (pixel_type) (((m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 8)) >> 8) << 7) & 0x7C00) | ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 8)) >> 8) << 2) & 0x03E0) | (m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 8)) >> 8) >> 3) | 0x8000); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((r & 0xF8) << 7) | ((g & 0xF8) << 2) | (b >> 3) | 0x8000); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p >> 7) & 0xF8, (p >> 2) & 0xF8, (p << 3) & 0xF8); } private: const Gamma* m_gamma; }; //=========================================================blender_rgb565 struct blender_rgb565 { typedef rgba8 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int16u pixel_type; static AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned) { pixel_type rgb = *p; calc_type r = (rgb >> 8) & 0xF8; calc_type g = (rgb >> 3) & 0xFC; calc_type b = (rgb << 3) & 0xF8; *p = (pixel_type) (((((cr - r) * alpha + (r << 8)) ) & 0xF800) | ((((cg - g) * alpha + (g << 8)) >> 5) & 0x07E0) | (((cb - b) * alpha + (b << 8)) >> 11)); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p >> 8) & 0xF8, (p >> 3) & 0xFC, (p << 3) & 0xF8); } }; //=====================================================blender_rgb565_pre struct blender_rgb565_pre { typedef rgba8 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int16u pixel_type; static AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover) { alpha = color_type::base_mask - alpha; pixel_type rgb = *p; calc_type r = (rgb >> 8) & 0xF8; calc_type g = (rgb >> 3) & 0xFC; calc_type b = (rgb << 3) & 0xF8; *p = (pixel_type) ((((r * alpha + cr * cover) ) & 0xF800) | (((g * alpha + cg * cover) >> 5 ) & 0x07E0) | ((b * alpha + cb * cover) >> 11)); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p >> 8) & 0xF8, (p >> 3) & 0xFC, (p << 3) & 0xF8); } }; //=====================================================blender_rgb565_gamma template class blender_rgb565_gamma { public: typedef rgba8 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int16u pixel_type; typedef Gamma gamma_type; blender_rgb565_gamma() : m_gamma(0) {} void gamma(const gamma_type& g) { m_gamma = &g; } AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned) { pixel_type rgb = *p; calc_type r = m_gamma->dir((rgb >> 8) & 0xF8); calc_type g = m_gamma->dir((rgb >> 3) & 0xFC); calc_type b = m_gamma->dir((rgb << 3) & 0xF8); *p = (pixel_type) (((m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 8)) >> 8) << 8) & 0xF800) | ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 8)) >> 8) << 3) & 0x07E0) | (m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 8)) >> 8) >> 3)); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p >> 8) & 0xF8, (p >> 3) & 0xFC, (p << 3) & 0xF8); } private: const Gamma* m_gamma; }; //=====================================================blender_rgbAAA struct blender_rgbAAA { typedef rgba16 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int32u pixel_type; static AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned) { pixel_type rgb = *p; calc_type r = (rgb >> 14) & 0xFFC0; calc_type g = (rgb >> 4) & 0xFFC0; calc_type b = (rgb << 6) & 0xFFC0; *p = (pixel_type) (((((cr - r) * alpha + (r << 16)) >> 2) & 0x3FF00000) | ((((cg - g) * alpha + (g << 16)) >> 12) & 0x000FFC00) | (((cb - b) * alpha + (b << 16)) >> 22) | 0xC0000000); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((r & 0xFFC0) << 14) | ((g & 0xFFC0) << 4) | (b >> 6) | 0xC0000000); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p >> 14) & 0xFFC0, (p >> 4) & 0xFFC0, (p << 6) & 0xFFC0); } }; //==================================================blender_rgbAAA_pre struct blender_rgbAAA_pre { typedef rgba16 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int32u pixel_type; static AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover) { alpha = color_type::base_mask - alpha; cover = (cover + 1) << (color_type::base_shift - 8); pixel_type rgb = *p; calc_type r = (rgb >> 14) & 0xFFC0; calc_type g = (rgb >> 4) & 0xFFC0; calc_type b = (rgb << 6) & 0xFFC0; *p = (pixel_type) ((((r * alpha + cr * cover) >> 2) & 0x3FF00000) | (((g * alpha + cg * cover) >> 12) & 0x000FFC00) | ((b * alpha + cb * cover) >> 22) | 0xC0000000); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((r & 0xFFC0) << 14) | ((g & 0xFFC0) << 4) | (b >> 6) | 0xC0000000); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p >> 14) & 0xFFC0, (p >> 4) & 0xFFC0, (p << 6) & 0xFFC0); } }; //=================================================blender_rgbAAA_gamma template class blender_rgbAAA_gamma { public: typedef rgba16 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int32u pixel_type; typedef Gamma gamma_type; blender_rgbAAA_gamma() : m_gamma(0) {} void gamma(const gamma_type& g) { m_gamma = &g; } AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned) { pixel_type rgb = *p; calc_type r = m_gamma->dir((rgb >> 14) & 0xFFC0); calc_type g = m_gamma->dir((rgb >> 4) & 0xFFC0); calc_type b = m_gamma->dir((rgb << 6) & 0xFFC0); *p = (pixel_type) (((m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 16)) >> 16) << 14) & 0x3FF00000) | ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 16)) >> 16) << 4 ) & 0x000FFC00) | (m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 16)) >> 16) >> 6 ) | 0xC0000000); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((r & 0xFFC0) << 14) | ((g & 0xFFC0) << 4) | (b >> 6) | 0xC0000000); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p >> 14) & 0xFFC0, (p >> 4) & 0xFFC0, (p << 6) & 0xFFC0); } private: const Gamma* m_gamma; }; //=====================================================blender_bgrAAA struct blender_bgrAAA { typedef rgba16 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int32u pixel_type; static AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned) { pixel_type bgr = *p; calc_type b = (bgr >> 14) & 0xFFC0; calc_type g = (bgr >> 4) & 0xFFC0; calc_type r = (bgr << 6) & 0xFFC0; *p = (pixel_type) (((((cb - b) * alpha + (b << 16)) >> 2) & 0x3FF00000) | ((((cg - g) * alpha + (g << 16)) >> 12) & 0x000FFC00) | (((cr - r) * alpha + (r << 16)) >> 22) | 0xC0000000); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((b & 0xFFC0) << 14) | ((g & 0xFFC0) << 4) | (r >> 6) | 0xC0000000); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p << 6) & 0xFFC0, (p >> 4) & 0xFFC0, (p >> 14) & 0xFFC0); } }; //=================================================blender_bgrAAA_pre struct blender_bgrAAA_pre { typedef rgba16 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int32u pixel_type; static AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover) { alpha = color_type::base_mask - alpha; cover = (cover + 1) << (color_type::base_shift - 8); pixel_type bgr = *p; calc_type b = (bgr >> 14) & 0xFFC0; calc_type g = (bgr >> 4) & 0xFFC0; calc_type r = (bgr << 6) & 0xFFC0; *p = (pixel_type) ((((b * alpha + cb * cover) >> 2) & 0x3FF00000) | (((g * alpha + cg * cover) >> 12) & 0x000FFC00) | ((r * alpha + cr * cover) >> 22) | 0xC0000000); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((b & 0xFFC0) << 14) | ((g & 0xFFC0) << 4) | (r >> 6) | 0xC0000000); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p << 6) & 0xFFC0, (p >> 4) & 0xFFC0, (p >> 14) & 0xFFC0); } }; //=================================================blender_bgrAAA_gamma template class blender_bgrAAA_gamma { public: typedef rgba16 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int32u pixel_type; typedef Gamma gamma_type; blender_bgrAAA_gamma() : m_gamma(0) {} void gamma(const gamma_type& g) { m_gamma = &g; } AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned) { pixel_type bgr = *p; calc_type b = m_gamma->dir((bgr >> 14) & 0xFFC0); calc_type g = m_gamma->dir((bgr >> 4) & 0xFFC0); calc_type r = m_gamma->dir((bgr << 6) & 0xFFC0); *p = (pixel_type) (((m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 16)) >> 16) << 14) & 0x3FF00000) | ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 16)) >> 16) << 4 ) & 0x000FFC00) | (m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 16)) >> 16) >> 6 ) | 0xC0000000); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((b & 0xFFC0) << 14) | ((g & 0xFFC0) << 4) | (r >> 6) | 0xC0000000); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p << 6) & 0xFFC0, (p >> 4) & 0xFFC0, (p >> 14) & 0xFFC0); } private: const Gamma* m_gamma; }; //=====================================================blender_rgbBBA struct blender_rgbBBA { typedef rgba16 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int32u pixel_type; static AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned) { pixel_type rgb = *p; calc_type r = (rgb >> 16) & 0xFFE0; calc_type g = (rgb >> 5) & 0xFFE0; calc_type b = (rgb << 6) & 0xFFC0; *p = (pixel_type) (((((cr - r) * alpha + (r << 16)) ) & 0xFFE00000) | ((((cg - g) * alpha + (g << 16)) >> 11) & 0x001FFC00) | (((cb - b) * alpha + (b << 16)) >> 22)); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((r & 0xFFE0) << 16) | ((g & 0xFFE0) << 5) | (b >> 6)); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p >> 16) & 0xFFE0, (p >> 5) & 0xFFE0, (p << 6) & 0xFFC0); } }; //=================================================blender_rgbBBA_pre struct blender_rgbBBA_pre { typedef rgba16 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int32u pixel_type; static AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover) { alpha = color_type::base_mask - alpha; cover = (cover + 1) << (color_type::base_shift - 8); pixel_type rgb = *p; calc_type r = (rgb >> 16) & 0xFFE0; calc_type g = (rgb >> 5) & 0xFFE0; calc_type b = (rgb << 6) & 0xFFC0; *p = (pixel_type) ((((r * alpha + cr * cover) ) & 0xFFE00000) | (((g * alpha + cg * cover) >> 11) & 0x001FFC00) | ((b * alpha + cb * cover) >> 22)); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((r & 0xFFE0) << 16) | ((g & 0xFFE0) << 5) | (b >> 6)); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p >> 16) & 0xFFE0, (p >> 5) & 0xFFE0, (p << 6) & 0xFFC0); } }; //=================================================blender_rgbBBA_gamma template class blender_rgbBBA_gamma { public: typedef rgba16 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int32u pixel_type; typedef Gamma gamma_type; blender_rgbBBA_gamma() : m_gamma(0) {} void gamma(const gamma_type& g) { m_gamma = &g; } AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned) { pixel_type rgb = *p; calc_type r = m_gamma->dir((rgb >> 16) & 0xFFE0); calc_type g = m_gamma->dir((rgb >> 5) & 0xFFE0); calc_type b = m_gamma->dir((rgb << 6) & 0xFFC0); *p = (pixel_type) (((m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 16)) >> 16) << 16) & 0xFFE00000) | ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 16)) >> 16) << 5 ) & 0x001FFC00) | (m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 16)) >> 16) >> 6 )); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((r & 0xFFE0) << 16) | ((g & 0xFFE0) << 5) | (b >> 6)); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p >> 16) & 0xFFE0, (p >> 5) & 0xFFE0, (p << 6) & 0xFFC0); } private: const Gamma* m_gamma; }; //=====================================================blender_bgrABB struct blender_bgrABB { typedef rgba16 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int32u pixel_type; static AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned) { pixel_type bgr = *p; calc_type b = (bgr >> 16) & 0xFFC0; calc_type g = (bgr >> 6) & 0xFFE0; calc_type r = (bgr << 5) & 0xFFE0; *p = (pixel_type) (((((cb - b) * alpha + (b << 16)) ) & 0xFFC00000) | ((((cg - g) * alpha + (g << 16)) >> 10) & 0x003FF800) | (((cr - r) * alpha + (r << 16)) >> 21)); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((b & 0xFFC0) << 16) | ((g & 0xFFE0) << 6) | (r >> 5)); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p << 5) & 0xFFE0, (p >> 6) & 0xFFE0, (p >> 16) & 0xFFC0); } }; //=================================================blender_bgrABB_pre struct blender_bgrABB_pre { typedef rgba16 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int32u pixel_type; static AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover) { alpha = color_type::base_mask - alpha; cover = (cover + 1) << (color_type::base_shift - 8); pixel_type bgr = *p; calc_type b = (bgr >> 16) & 0xFFC0; calc_type g = (bgr >> 6) & 0xFFE0; calc_type r = (bgr << 5) & 0xFFE0; *p = (pixel_type) ((((b * alpha + cb * cover) ) & 0xFFC00000) | (((g * alpha + cg * cover) >> 10) & 0x003FF800) | ((r * alpha + cr * cover) >> 21)); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((b & 0xFFC0) << 16) | ((g & 0xFFE0) << 6) | (r >> 5)); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p << 5) & 0xFFE0, (p >> 6) & 0xFFE0, (p >> 16) & 0xFFC0); } }; //=================================================blender_bgrABB_gamma template class blender_bgrABB_gamma { public: typedef rgba16 color_type; typedef color_type::value_type value_type; typedef color_type::calc_type calc_type; typedef int32u pixel_type; typedef Gamma gamma_type; blender_bgrABB_gamma() : m_gamma(0) {} void gamma(const gamma_type& g) { m_gamma = &g; } AGG_INLINE void blend_pix(pixel_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned) { pixel_type bgr = *p; calc_type b = m_gamma->dir((bgr >> 16) & 0xFFC0); calc_type g = m_gamma->dir((bgr >> 6) & 0xFFE0); calc_type r = m_gamma->dir((bgr << 5) & 0xFFE0); *p = (pixel_type) (((m_gamma->inv(((m_gamma->dir(cb) - b) * alpha + (b << 16)) >> 16) << 16) & 0xFFC00000) | ((m_gamma->inv(((m_gamma->dir(cg) - g) * alpha + (g << 16)) >> 16) << 6 ) & 0x003FF800) | (m_gamma->inv(((m_gamma->dir(cr) - r) * alpha + (r << 16)) >> 16) >> 5 )); } static AGG_INLINE pixel_type make_pix(unsigned r, unsigned g, unsigned b) { return (pixel_type)(((b & 0xFFC0) << 16) | ((g & 0xFFE0) << 6) | (r >> 5)); } static AGG_INLINE color_type make_color(pixel_type p) { return color_type((p << 5) & 0xFFE0, (p >> 6) & 0xFFE0, (p >> 16) & 0xFFC0); } private: const Gamma* m_gamma; }; //===========================================pixfmt_alpha_blend_rgb_packed template class pixfmt_alpha_blend_rgb_packed { public: typedef RenBuf rbuf_type; typedef typename rbuf_type::row_data row_data; typedef Blender blender_type; typedef typename blender_type::color_type color_type; typedef typename blender_type::pixel_type pixel_type; typedef int order_type; // A fake one typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_scale = color_type::base_scale, base_mask = color_type::base_mask, pix_width = sizeof(pixel_type) }; private: //-------------------------------------------------------------------- AGG_INLINE void copy_or_blend_pix(pixel_type* p, const color_type& c, unsigned cover) { if (c.a) { calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; if(alpha == base_mask) { *p = m_blender.make_pix(c.r, c.g, c.b); } else { m_blender.blend_pix(p, c.r, c.g, c.b, alpha, cover); } } } public: //-------------------------------------------------------------------- pixfmt_alpha_blend_rgb_packed(rbuf_type& rb) : m_rbuf(&rb) {} void attach(rbuf_type& rb) { m_rbuf = &rb; } Blender& blender() { return m_blender; } //-------------------------------------------------------------------- AGG_INLINE unsigned width() const { return m_rbuf->width(); } AGG_INLINE unsigned height() const { return m_rbuf->height(); } //-------------------------------------------------------------------- const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); } //-------------------------------------------------------------------- const int8u* pix_ptr(int x, int y) const { return m_rbuf->row_ptr(y) + x * pix_width; } //-------------------------------------------------------------------- row_data row(int y) const { return m_rbuf->row(y); } //-------------------------------------------------------------------- AGG_INLINE void make_pix(int8u* p, const color_type& c) { *(pixel_type*)p = m_blender.make_pix(c.r, c.g, c.b); } //-------------------------------------------------------------------- AGG_INLINE color_type pixel(int x, int y) const { return m_blender.make_color(((pixel_type*)m_rbuf->row_ptr(y))[x]); } //-------------------------------------------------------------------- AGG_INLINE void copy_pixel(int x, int y, const color_type& c) { ((pixel_type*) m_rbuf->row_ptr(x, y, 1))[x] = m_blender.make_pix(c.r, c.g, c.b); } //-------------------------------------------------------------------- AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover) { copy_or_blend_pix((pixel_type*)m_rbuf->row_ptr(x, y, 1) + x, c, cover); } //-------------------------------------------------------------------- AGG_INLINE void copy_hline(int x, int y, unsigned len, const color_type& c) { pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y, len) + x; pixel_type v = m_blender.make_pix(c.r, c.g, c.b); do { *p++ = v; } while(--len); } //-------------------------------------------------------------------- AGG_INLINE void copy_vline(int x, int y, unsigned len, const color_type& c) { pixel_type v = m_blender.make_pix(c.r, c.g, c.b); do { pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y++, 1) + x; *p = v; } while(--len); } //-------------------------------------------------------------------- void blend_hline(int x, int y, unsigned len, const color_type& c, int8u cover) { if (c.a) { pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y, len) + x; calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; if(alpha == base_mask) { pixel_type v = m_blender.make_pix(c.r, c.g, c.b); do { *p++ = v; } while(--len); } else { do { m_blender.blend_pix(p, c.r, c.g, c.b, alpha, cover); ++p; } while(--len); } } } //-------------------------------------------------------------------- void blend_vline(int x, int y, unsigned len, const color_type& c, int8u cover) { if (c.a) { calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; if(alpha == base_mask) { pixel_type v = m_blender.make_pix(c.r, c.g, c.b); do { ((pixel_type*)m_rbuf->row_ptr(x, y++, 1))[x] = v; } while(--len); } else { do { m_blender.blend_pix( (pixel_type*)m_rbuf->row_ptr(x, y++, 1), c.r, c.g, c.b, alpha, cover); } while(--len); } } } //-------------------------------------------------------------------- void blend_solid_hspan(int x, int y, unsigned len, const color_type& c, const int8u* covers) { pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y, len) + x; do { copy_or_blend_pix(p, c, *covers++); ++p; } while(--len); } //-------------------------------------------------------------------- void blend_solid_vspan(int x, int y, unsigned len, const color_type& c, const int8u* covers) { do { copy_or_blend_pix((pixel_type*)m_rbuf->row_ptr(x, y++, 1) + x, c, *covers++); } while(--len); } //-------------------------------------------------------------------- void copy_color_hspan(int x, int y, unsigned len, const color_type* colors) { pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y, len) + x; do { *p++ = m_blender.make_pix(colors->r, colors->g, colors->b); ++colors; } while(--len); } //-------------------------------------------------------------------- void blend_color_hspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover) { pixel_type* p = (pixel_type*)m_rbuf->row_ptr(x, y, len) + x; do { copy_or_blend_pix(p++, *colors++, covers ? *covers++ : cover); } while(--len); } //-------------------------------------------------------------------- void blend_color_vspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover) { do { copy_or_blend_pix((pixel_type*)m_rbuf->row_ptr(x, y++, 1) + x, *colors++, covers ? *covers++ : cover); } while(--len); } //-------------------------------------------------------------------- template void copy_from(const RenBuf2& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len) { const int8u* p = from.row_ptr(ysrc); if(p) { memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, p + xsrc * pix_width, len * pix_width); } } //-------------------------------------------------------------------- template void blend_from(const SrcPixelFormatRenderer& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len, int8u cover) { typedef typename SrcPixelFormatRenderer::order_type src_order; const value_type* psrc = (const value_type*)from.row_ptr(ysrc); if(psrc) { psrc += xsrc * 4; pixel_type* pdst = (pixel_type*)m_rbuf->row_ptr(xdst, ydst, len) + xdst; do { value_type alpha = psrc[src_order::A]; if(alpha) { if(alpha == base_mask && cover == 255) { *pdst = m_blender.make_pix(psrc[src_order::R], psrc[src_order::G], psrc[src_order::B]); } else { m_blender.blend_pix(pdst, psrc[src_order::R], psrc[src_order::G], psrc[src_order::B], alpha, cover); } } psrc += 4; ++pdst; } while(--len); } } private: rbuf_type* m_rbuf; Blender m_blender; }; typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgb555; //----pixfmt_rgb555 typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgb565; //----pixfmt_rgb565 typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgb555_pre; //----pixfmt_rgb555_pre typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgb565_pre; //----pixfmt_rgb565_pre typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgbAAA; //----pixfmt_rgbAAA typedef pixfmt_alpha_blend_rgb_packed pixfmt_bgrAAA; //----pixfmt_bgrAAA typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgbBBA; //----pixfmt_rgbBBA typedef pixfmt_alpha_blend_rgb_packed pixfmt_bgrABB; //----pixfmt_bgrABB typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgbAAA_pre; //----pixfmt_rgbAAA_pre typedef pixfmt_alpha_blend_rgb_packed pixfmt_bgrAAA_pre; //----pixfmt_bgrAAA_pre typedef pixfmt_alpha_blend_rgb_packed pixfmt_rgbBBA_pre; //----pixfmt_rgbBBA_pre typedef pixfmt_alpha_blend_rgb_packed pixfmt_bgrABB_pre; //----pixfmt_bgrABB_pre //-----------------------------------------------------pixfmt_rgb555_gamma template class pixfmt_rgb555_gamma : public pixfmt_alpha_blend_rgb_packed, rendering_buffer> { public: pixfmt_rgb555_gamma(rendering_buffer& rb, const Gamma& g) : pixfmt_alpha_blend_rgb_packed, rendering_buffer>(rb) { this->blender().gamma(g); } }; //-----------------------------------------------------pixfmt_rgb565_gamma template class pixfmt_rgb565_gamma : public pixfmt_alpha_blend_rgb_packed, rendering_buffer> { public: pixfmt_rgb565_gamma(rendering_buffer& rb, const Gamma& g) : pixfmt_alpha_blend_rgb_packed, rendering_buffer>(rb) { this->blender().gamma(g); } }; //-----------------------------------------------------pixfmt_rgbAAA_gamma template class pixfmt_rgbAAA_gamma : public pixfmt_alpha_blend_rgb_packed, rendering_buffer> { public: pixfmt_rgbAAA_gamma(rendering_buffer& rb, const Gamma& g) : pixfmt_alpha_blend_rgb_packed, rendering_buffer>(rb) { this->blender().gamma(g); } }; //-----------------------------------------------------pixfmt_bgrAAA_gamma template class pixfmt_bgrAAA_gamma : public pixfmt_alpha_blend_rgb_packed, rendering_buffer> { public: pixfmt_bgrAAA_gamma(rendering_buffer& rb, const Gamma& g) : pixfmt_alpha_blend_rgb_packed, rendering_buffer>(rb) { this->blender().gamma(g); } }; //-----------------------------------------------------pixfmt_rgbBBA_gamma template class pixfmt_rgbBBA_gamma : public pixfmt_alpha_blend_rgb_packed, rendering_buffer> { public: pixfmt_rgbBBA_gamma(rendering_buffer& rb, const Gamma& g) : pixfmt_alpha_blend_rgb_packed, rendering_buffer>(rb) { this->blender().gamma(g); } }; //-----------------------------------------------------pixfmt_bgrABB_gamma template class pixfmt_bgrABB_gamma : public pixfmt_alpha_blend_rgb_packed, rendering_buffer> { public: pixfmt_bgrABB_gamma(rendering_buffer& rb, const Gamma& g) : pixfmt_alpha_blend_rgb_packed, rendering_buffer>(rb) { this->blender().gamma(g); } }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_pattern_gray.h0000644000175000017500000000646312516137326025514 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for high precision colors has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_SPAN_PATTERN_GRAY_INCLUDED #define AGG_SPAN_PATTERN_GRAY_INCLUDED #include "agg_basics.h" namespace agg24 { //=======================================================span_pattern_gray template class span_pattern_gray { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; //-------------------------------------------------------------------- span_pattern_gray() {} span_pattern_gray(source_type& src, unsigned offset_x, unsigned offset_y) : m_src(&src), m_offset_x(offset_x), m_offset_y(offset_y), m_alpha(color_type::base_mask) {} //-------------------------------------------------------------------- void attach(source_type& v) { m_src = &v; } source_type& source() { return *m_src; } const source_type& source() const { return *m_src; } //-------------------------------------------------------------------- void offset_x(unsigned v) { m_offset_x = v; } void offset_y(unsigned v) { m_offset_y = v; } unsigned offset_x() const { return m_offset_x; } unsigned offset_y() const { return m_offset_y; } void alpha(value_type v) { m_alpha = v; } value_type alpha() const { return m_alpha; } //-------------------------------------------------------------------- void prepare() {} void generate(color_type* span, int x, int y, unsigned len) { x += m_offset_x; y += m_offset_y; const value_type* p = (const value_type*)m_src->span(x, y, len); do { span->v = *p; span->a = m_alpha; p = m_src->next_x(); ++span; } while(--len); } private: source_type* m_src; unsigned m_offset_x; unsigned m_offset_y; value_type m_alpha; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/util/0000755000175000017500000000000012516137725021754 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/util/agg_color_conv.h0000644000175000017500000000471112516137326025106 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Conversion from one colorspace/pixel format to another // //---------------------------------------------------------------------------- #ifndef AGG_COLOR_CONV_INCLUDED #define AGG_COLOR_CONV_INCLUDED #include #include "agg_basics.h" #include "agg_rendering_buffer.h" namespace agg24 { //--------------------------------------------------------------color_conv template void color_conv(RenBuf* dst, const RenBuf* src, CopyRow copy_row_functor) { unsigned width = src->width(); unsigned height = src->height(); if(dst->width() < width) width = dst->width(); if(dst->height() < height) height = dst->height(); if(width) { unsigned y; for(y = 0; y < height; y++) { copy_row_functor(dst->row_ptr(0, y, width), src->row_ptr(y), width); } } } //---------------------------------------------------------color_conv_row template void color_conv_row(int8u* dst, const int8u* src, unsigned width, CopyRow copy_row_functor) { copy_row_functor(dst, src, width); } //---------------------------------------------------------color_conv_same template class color_conv_same { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { memmove(dst, src, width*BPP); } }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/util/agg_color_conv_rgb16.h0000644000175000017500000002536012516137326026112 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // This part of the library has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- // // A set of functors used with color_conv(). See file agg_color_conv.h // These functors can convert images with up to 8 bits per component. // Use convertors in the following way: // // agg24::color_conv(dst, src, agg24::color_conv_XXXX_to_YYYY()); //---------------------------------------------------------------------------- #ifndef AGG_COLOR_CONV_RGB16_INCLUDED #define AGG_COLOR_CONV_RGB16_INCLUDED #include "agg_basics.h" #include "agg_color_conv.h" namespace agg24 { //-------------------------------------------------color_conv_gray16_to_gray8 class color_conv_gray16_to_gray8 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { int16u* s = (int16u*)src; do { *dst++ = *s++ >> 8; } while(--width); } }; //-----------------------------------------------------color_conv_rgb24_rgb48 template class color_conv_rgb24_rgb48 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { int16u* d = (int16u*)dst; do { *d++ = (src[I1] << 8) | src[I1]; *d++ = (src[1] << 8) | src[1] ; *d++ = (src[I3] << 8) | src[I3]; src += 3; } while(--width); } }; typedef color_conv_rgb24_rgb48<0,2> color_conv_rgb24_to_rgb48; typedef color_conv_rgb24_rgb48<0,2> color_conv_bgr24_to_bgr48; typedef color_conv_rgb24_rgb48<2,0> color_conv_rgb24_to_bgr48; typedef color_conv_rgb24_rgb48<2,0> color_conv_bgr24_to_rgb48; //-----------------------------------------------------color_conv_rgb24_rgb48 template class color_conv_rgb48_rgb24 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { const int16u* s = (const int16u*)src; do { *dst++ = s[I1] >> 8; *dst++ = s[1] >> 8; *dst++ = s[I3] >> 8; s += 3; } while(--width); } }; typedef color_conv_rgb48_rgb24<0,2> color_conv_rgb48_to_rgb24; typedef color_conv_rgb48_rgb24<0,2> color_conv_bgr48_to_bgr24; typedef color_conv_rgb48_rgb24<2,0> color_conv_rgb48_to_bgr24; typedef color_conv_rgb48_rgb24<2,0> color_conv_bgr48_to_rgb24; //----------------------------------------------color_conv_rgbAAA_rgb24 template class color_conv_rgbAAA_rgb24 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { int32u rgb = *(int32u*)src; dst[R] = int8u(rgb >> 22); dst[1] = int8u(rgb >> 12); dst[B] = int8u(rgb >> 2); src += 4; dst += 3; } while(--width); } }; typedef color_conv_rgbAAA_rgb24<0,2> color_conv_rgbAAA_to_rgb24; typedef color_conv_rgbAAA_rgb24<2,0> color_conv_rgbAAA_to_bgr24; typedef color_conv_rgbAAA_rgb24<2,0> color_conv_bgrAAA_to_rgb24; typedef color_conv_rgbAAA_rgb24<0,2> color_conv_bgrAAA_to_bgr24; //----------------------------------------------color_conv_rgbBBA_rgb24 template class color_conv_rgbBBA_rgb24 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { int32u rgb = *(int32u*)src; dst[R] = int8u(rgb >> 24); dst[1] = int8u(rgb >> 13); dst[B] = int8u(rgb >> 2); src += 4; dst += 3; } while(--width); } }; typedef color_conv_rgbBBA_rgb24<0,2> color_conv_rgbBBA_to_rgb24; typedef color_conv_rgbBBA_rgb24<2,0> color_conv_rgbBBA_to_bgr24; //----------------------------------------------color_conv_bgrABB_rgb24 template class color_conv_bgrABB_rgb24 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { int32u bgr = *(int32u*)src; dst[R] = int8u(bgr >> 3); dst[1] = int8u(bgr >> 14); dst[B] = int8u(bgr >> 24); src += 4; dst += 3; } while(--width); } }; typedef color_conv_bgrABB_rgb24<2,0> color_conv_bgrABB_to_rgb24; typedef color_conv_bgrABB_rgb24<0,2> color_conv_bgrABB_to_bgr24; //-------------------------------------------------color_conv_rgba64_rgba32 template class color_conv_rgba64_rgba32 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { *dst++ = int8u(((int16u*)src)[I1] >> 8); *dst++ = int8u(((int16u*)src)[I2] >> 8); *dst++ = int8u(((int16u*)src)[I3] >> 8); *dst++ = int8u(((int16u*)src)[I4] >> 8); src += 8; } while(--width); } }; //------------------------------------------------------------------------ typedef color_conv_rgba64_rgba32<0,1,2,3> color_conv_rgba64_to_rgba32; //----color_conv_rgba64_to_rgba32 typedef color_conv_rgba64_rgba32<0,1,2,3> color_conv_argb64_to_argb32; //----color_conv_argb64_to_argb32 typedef color_conv_rgba64_rgba32<0,1,2,3> color_conv_bgra64_to_bgra32; //----color_conv_bgra64_to_bgra32 typedef color_conv_rgba64_rgba32<0,1,2,3> color_conv_abgr64_to_abgr32; //----color_conv_abgr64_to_abgr32 typedef color_conv_rgba64_rgba32<0,3,2,1> color_conv_argb64_to_abgr32; //----color_conv_argb64_to_abgr32 typedef color_conv_rgba64_rgba32<3,2,1,0> color_conv_argb64_to_bgra32; //----color_conv_argb64_to_bgra32 typedef color_conv_rgba64_rgba32<1,2,3,0> color_conv_argb64_to_rgba32; //----color_conv_argb64_to_rgba32 typedef color_conv_rgba64_rgba32<3,0,1,2> color_conv_bgra64_to_abgr32; //----color_conv_bgra64_to_abgr32 typedef color_conv_rgba64_rgba32<3,2,1,0> color_conv_bgra64_to_argb32; //----color_conv_bgra64_to_argb32 typedef color_conv_rgba64_rgba32<2,1,0,3> color_conv_bgra64_to_rgba32; //----color_conv_bgra64_to_rgba32 typedef color_conv_rgba64_rgba32<3,2,1,0> color_conv_rgba64_to_abgr32; //----color_conv_rgba64_to_abgr32 typedef color_conv_rgba64_rgba32<3,0,1,2> color_conv_rgba64_to_argb32; //----color_conv_rgba64_to_argb32 typedef color_conv_rgba64_rgba32<2,1,0,3> color_conv_rgba64_to_bgra32; //----color_conv_rgba64_to_bgra32 typedef color_conv_rgba64_rgba32<0,3,2,1> color_conv_abgr64_to_argb32; //----color_conv_abgr64_to_argb32 typedef color_conv_rgba64_rgba32<1,2,3,0> color_conv_abgr64_to_bgra32; //----color_conv_abgr64_to_bgra32 typedef color_conv_rgba64_rgba32<3,2,1,0> color_conv_abgr64_to_rgba32; //----color_conv_abgr64_to_rgba32 //--------------------------------------------color_conv_rgb24_rgba64 template class color_conv_rgb24_rgba64 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { int16u* d = (int16u*)dst; do { d[I1] = (src[0] << 8) | src[0]; d[I2] = (src[1] << 8) | src[1]; d[I3] = (src[2] << 8) | src[2]; d[A] = 65535; d += 4; src += 3; } while(--width); } }; //------------------------------------------------------------------------ typedef color_conv_rgb24_rgba64<1,2,3,0> color_conv_rgb24_to_argb64; //----color_conv_rgb24_to_argb64 typedef color_conv_rgb24_rgba64<3,2,1,0> color_conv_rgb24_to_abgr64; //----color_conv_rgb24_to_abgr64 typedef color_conv_rgb24_rgba64<2,1,0,3> color_conv_rgb24_to_bgra64; //----color_conv_rgb24_to_bgra64 typedef color_conv_rgb24_rgba64<0,1,2,3> color_conv_rgb24_to_rgba64; //----color_conv_rgb24_to_rgba64 typedef color_conv_rgb24_rgba64<3,2,1,0> color_conv_bgr24_to_argb64; //----color_conv_bgr24_to_argb64 typedef color_conv_rgb24_rgba64<1,2,3,0> color_conv_bgr24_to_abgr64; //----color_conv_bgr24_to_abgr64 typedef color_conv_rgb24_rgba64<0,1,2,3> color_conv_bgr24_to_bgra64; //----color_conv_bgr24_to_bgra64 typedef color_conv_rgb24_rgba64<2,1,0,3> color_conv_bgr24_to_rgba64; //----color_conv_bgr24_to_rgba64 template class color_conv_rgb24_gray16 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { int16u* d = (int16u*)dst; do { *d++ = src[R]*77 + src[1]*150 + src[B]*29; src += 3; } while(--width); } }; typedef color_conv_rgb24_gray16<0,2> color_conv_rgb24_to_gray16; typedef color_conv_rgb24_gray16<2,0> color_conv_bgr24_to_gray16; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/util/Makefile.am0000644000175000017500000000017312516137326024006 0ustar varunvarunmyincludedir = $(includedir)/agg2/util myinclude_HEADERS = agg_color_conv.h agg_color_conv_rgb8.h agg_color_conv_rgb16.h enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/util/agg_color_conv_rgb8.h0000644000175000017500000004356212516137326026037 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // A set of functors used with color_conv(). See file agg_color_conv.h // These functors can convert images with up to 8 bits per component. // Use convertors in the following way: // // agg24::color_conv(dst, src, agg24::color_conv_XXXX_to_YYYY()); // whare XXXX and YYYY can be any of: // rgb24 // bgr24 // rgba32 // abgr32 // argb32 // bgra32 // rgb555 // rgb565 //---------------------------------------------------------------------------- #ifndef AGG_COLOR_CONV_RGB8_INCLUDED #define AGG_COLOR_CONV_RGB8_INCLUDED #include "agg_basics.h" #include "agg_color_conv.h" namespace agg24 { //-----------------------------------------------------color_conv_rgb24 class color_conv_rgb24 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { *dst++ = src[2]; *dst++ = src[1]; *dst++ = src[0]; src += 3; } while(--width); } }; typedef color_conv_rgb24 color_conv_rgb24_to_bgr24; typedef color_conv_rgb24 color_conv_bgr24_to_rgb24; typedef color_conv_same<3> color_conv_bgr24_to_bgr24; typedef color_conv_same<3> color_conv_rgb24_to_rgb24; //------------------------------------------------------color_conv_rgba32 template class color_conv_rgba32 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { *dst++ = src[I1]; *dst++ = src[I2]; *dst++ = src[I3]; *dst++ = src[I4]; src += 4; } while(--width); } }; //------------------------------------------------------------------------ typedef color_conv_rgba32<0,3,2,1> color_conv_argb32_to_abgr32; //----color_conv_argb32_to_abgr32 typedef color_conv_rgba32<3,2,1,0> color_conv_argb32_to_bgra32; //----color_conv_argb32_to_bgra32 typedef color_conv_rgba32<1,2,3,0> color_conv_argb32_to_rgba32; //----color_conv_argb32_to_rgba32 typedef color_conv_rgba32<3,0,1,2> color_conv_bgra32_to_abgr32; //----color_conv_bgra32_to_abgr32 typedef color_conv_rgba32<3,2,1,0> color_conv_bgra32_to_argb32; //----color_conv_bgra32_to_argb32 typedef color_conv_rgba32<2,1,0,3> color_conv_bgra32_to_rgba32; //----color_conv_bgra32_to_rgba32 typedef color_conv_rgba32<3,2,1,0> color_conv_rgba32_to_abgr32; //----color_conv_rgba32_to_abgr32 typedef color_conv_rgba32<3,0,1,2> color_conv_rgba32_to_argb32; //----color_conv_rgba32_to_argb32 typedef color_conv_rgba32<2,1,0,3> color_conv_rgba32_to_bgra32; //----color_conv_rgba32_to_bgra32 typedef color_conv_rgba32<0,3,2,1> color_conv_abgr32_to_argb32; //----color_conv_abgr32_to_argb32 typedef color_conv_rgba32<1,2,3,0> color_conv_abgr32_to_bgra32; //----color_conv_abgr32_to_bgra32 typedef color_conv_rgba32<3,2,1,0> color_conv_abgr32_to_rgba32; //----color_conv_abgr32_to_rgba32 //------------------------------------------------------------------------ typedef color_conv_same<4> color_conv_rgba32_to_rgba32; //----color_conv_rgba32_to_rgba32 typedef color_conv_same<4> color_conv_argb32_to_argb32; //----color_conv_argb32_to_argb32 typedef color_conv_same<4> color_conv_bgra32_to_bgra32; //----color_conv_bgra32_to_bgra32 typedef color_conv_same<4> color_conv_abgr32_to_abgr32; //----color_conv_abgr32_to_abgr32 //--------------------------------------------color_conv_rgb24_rgba32 template class color_conv_rgb24_rgba32 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { dst[I1] = *src++; dst[I2] = *src++; dst[I3] = *src++; dst[A] = 255; dst += 4; } while(--width); } }; //------------------------------------------------------------------------ typedef color_conv_rgb24_rgba32<1,2,3,0> color_conv_rgb24_to_argb32; //----color_conv_rgb24_to_argb32 typedef color_conv_rgb24_rgba32<3,2,1,0> color_conv_rgb24_to_abgr32; //----color_conv_rgb24_to_abgr32 typedef color_conv_rgb24_rgba32<2,1,0,3> color_conv_rgb24_to_bgra32; //----color_conv_rgb24_to_bgra32 typedef color_conv_rgb24_rgba32<0,1,2,3> color_conv_rgb24_to_rgba32; //----color_conv_rgb24_to_rgba32 typedef color_conv_rgb24_rgba32<3,2,1,0> color_conv_bgr24_to_argb32; //----color_conv_bgr24_to_argb32 typedef color_conv_rgb24_rgba32<1,2,3,0> color_conv_bgr24_to_abgr32; //----color_conv_bgr24_to_abgr32 typedef color_conv_rgb24_rgba32<0,1,2,3> color_conv_bgr24_to_bgra32; //----color_conv_bgr24_to_bgra32 typedef color_conv_rgb24_rgba32<2,1,0,3> color_conv_bgr24_to_rgba32; //----color_conv_bgr24_to_rgba32 //-------------------------------------------------color_conv_rgba32_rgb24 template class color_conv_rgba32_rgb24 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { *dst++ = src[I1]; *dst++ = src[I2]; *dst++ = src[I3]; src += 4; } while(--width); } }; //------------------------------------------------------------------------ typedef color_conv_rgba32_rgb24<1,2,3> color_conv_argb32_to_rgb24; //----color_conv_argb32_to_rgb24 typedef color_conv_rgba32_rgb24<3,2,1> color_conv_abgr32_to_rgb24; //----color_conv_abgr32_to_rgb24 typedef color_conv_rgba32_rgb24<2,1,0> color_conv_bgra32_to_rgb24; //----color_conv_bgra32_to_rgb24 typedef color_conv_rgba32_rgb24<0,1,2> color_conv_rgba32_to_rgb24; //----color_conv_rgba32_to_rgb24 typedef color_conv_rgba32_rgb24<3,2,1> color_conv_argb32_to_bgr24; //----color_conv_argb32_to_bgr24 typedef color_conv_rgba32_rgb24<1,2,3> color_conv_abgr32_to_bgr24; //----color_conv_abgr32_to_bgr24 typedef color_conv_rgba32_rgb24<0,1,2> color_conv_bgra32_to_bgr24; //----color_conv_bgra32_to_bgr24 typedef color_conv_rgba32_rgb24<2,1,0> color_conv_rgba32_to_bgr24; //----color_conv_rgba32_to_bgr24 //------------------------------------------------color_conv_rgb555_rgb24 template class color_conv_rgb555_rgb24 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { unsigned rgb = *(int16u*)src; dst[R] = (int8u)((rgb >> 7) & 0xF8); dst[1] = (int8u)((rgb >> 2) & 0xF8); dst[B] = (int8u)((rgb << 3) & 0xF8); src += 2; dst += 3; } while(--width); } }; //------------------------------------------------------------------------ typedef color_conv_rgb555_rgb24<2,0> color_conv_rgb555_to_bgr24; //----color_conv_rgb555_to_bgr24 typedef color_conv_rgb555_rgb24<0,2> color_conv_rgb555_to_rgb24; //----color_conv_rgb555_to_rgb24 //-------------------------------------------------color_conv_rgb24_rgb555 template class color_conv_rgb24_rgb555 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { *(int16u*)dst = (int16u)(((unsigned(src[R]) << 7) & 0x7C00) | ((unsigned(src[1]) << 2) & 0x3E0) | ((unsigned(src[B]) >> 3))); src += 3; dst += 2; } while(--width); } }; //------------------------------------------------------------------------ typedef color_conv_rgb24_rgb555<2,0> color_conv_bgr24_to_rgb555; //----color_conv_bgr24_to_rgb555 typedef color_conv_rgb24_rgb555<0,2> color_conv_rgb24_to_rgb555; //----color_conv_rgb24_to_rgb555 //-------------------------------------------------color_conv_rgb565_rgb24 template class color_conv_rgb565_rgb24 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { unsigned rgb = *(int16u*)src; dst[R] = (rgb >> 8) & 0xF8; dst[1] = (rgb >> 3) & 0xFC; dst[B] = (rgb << 3) & 0xF8; src += 2; dst += 3; } while(--width); } }; //------------------------------------------------------------------------ typedef color_conv_rgb565_rgb24<2,0> color_conv_rgb565_to_bgr24; //----color_conv_rgb565_to_bgr24 typedef color_conv_rgb565_rgb24<0,2> color_conv_rgb565_to_rgb24; //----color_conv_rgb565_to_rgb24 //-------------------------------------------------color_conv_rgb24_rgb565 template class color_conv_rgb24_rgb565 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { *(int16u*)dst = (int16u)(((unsigned(src[R]) << 8) & 0xF800) | ((unsigned(src[1]) << 3) & 0x7E0) | ((unsigned(src[B]) >> 3))); src += 3; dst += 2; } while(--width); } }; //------------------------------------------------------------------------ typedef color_conv_rgb24_rgb565<2,0> color_conv_bgr24_to_rgb565; //----color_conv_bgr24_to_rgb565 typedef color_conv_rgb24_rgb565<0,2> color_conv_rgb24_to_rgb565; //----color_conv_rgb24_to_rgb565 //-------------------------------------------------color_conv_rgb555_rgba32 template class color_conv_rgb555_rgba32 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { int rgb = *(int16*)src; dst[R] = (int8u)((rgb >> 7) & 0xF8); dst[G] = (int8u)((rgb >> 2) & 0xF8); dst[B] = (int8u)((rgb << 3) & 0xF8); dst[A] = (int8u)(rgb >> 15); src += 2; dst += 4; } while(--width); } }; //------------------------------------------------------------------------ typedef color_conv_rgb555_rgba32<1,2,3,0> color_conv_rgb555_to_argb32; //----color_conv_rgb555_to_argb32 typedef color_conv_rgb555_rgba32<3,2,1,0> color_conv_rgb555_to_abgr32; //----color_conv_rgb555_to_abgr32 typedef color_conv_rgb555_rgba32<2,1,0,3> color_conv_rgb555_to_bgra32; //----color_conv_rgb555_to_bgra32 typedef color_conv_rgb555_rgba32<0,1,2,3> color_conv_rgb555_to_rgba32; //----color_conv_rgb555_to_rgba32 //------------------------------------------------color_conv_rgba32_rgb555 template class color_conv_rgba32_rgb555 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { *(int16u*)dst = (int16u)(((unsigned(src[R]) << 7) & 0x7C00) | ((unsigned(src[G]) << 2) & 0x3E0) | ((unsigned(src[B]) >> 3)) | ((unsigned(src[A]) << 8) & 0x8000)); src += 4; dst += 2; } while(--width); } }; //------------------------------------------------------------------------ typedef color_conv_rgba32_rgb555<1,2,3,0> color_conv_argb32_to_rgb555; //----color_conv_argb32_to_rgb555 typedef color_conv_rgba32_rgb555<3,2,1,0> color_conv_abgr32_to_rgb555; //----color_conv_abgr32_to_rgb555 typedef color_conv_rgba32_rgb555<2,1,0,3> color_conv_bgra32_to_rgb555; //----color_conv_bgra32_to_rgb555 typedef color_conv_rgba32_rgb555<0,1,2,3> color_conv_rgba32_to_rgb555; //----color_conv_rgba32_to_rgb555 //------------------------------------------------color_conv_rgb565_rgba32 template class color_conv_rgb565_rgba32 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { int rgb = *(int16*)src; dst[R] = (rgb >> 8) & 0xF8; dst[G] = (rgb >> 3) & 0xFC; dst[B] = (rgb << 3) & 0xF8; dst[A] = 255; src += 2; dst += 4; } while(--width); } }; //------------------------------------------------------------------------ typedef color_conv_rgb565_rgba32<1,2,3,0> color_conv_rgb565_to_argb32; //----color_conv_rgb565_to_argb32 typedef color_conv_rgb565_rgba32<3,2,1,0> color_conv_rgb565_to_abgr32; //----color_conv_rgb565_to_abgr32 typedef color_conv_rgb565_rgba32<2,1,0,3> color_conv_rgb565_to_bgra32; //----color_conv_rgb565_to_bgra32 typedef color_conv_rgb565_rgba32<0,1,2,3> color_conv_rgb565_to_rgba32; //----color_conv_rgb565_to_rgba32 //------------------------------------------------color_conv_rgba32_rgb565 template class color_conv_rgba32_rgb565 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { *(int16u*)dst = (int16u)(((unsigned(src[R]) << 8) & 0xF800) | ((unsigned(src[G]) << 3) & 0x7E0) | ((unsigned(src[B]) >> 3))); src += 4; dst += 2; } while(--width); } }; //------------------------------------------------------------------------ typedef color_conv_rgba32_rgb565<1,2,3> color_conv_argb32_to_rgb565; //----color_conv_argb32_to_rgb565 typedef color_conv_rgba32_rgb565<3,2,1> color_conv_abgr32_to_rgb565; //----color_conv_abgr32_to_rgb565 typedef color_conv_rgba32_rgb565<2,1,0> color_conv_bgra32_to_rgb565; //----color_conv_bgra32_to_rgb565 typedef color_conv_rgba32_rgb565<0,1,2> color_conv_rgba32_to_rgb565; //----color_conv_rgba32_to_rgb565 //---------------------------------------------color_conv_rgb555_to_rgb565 class color_conv_rgb555_to_rgb565 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { unsigned rgb = *(int16u*)src; *(int16u*)dst = (int16u)(((rgb << 1) & 0xFFC0) | (rgb & 0x1F)); src += 2; dst += 2; } while(--width); } }; //----------------------------------------------color_conv_rgb565_to_rgb555 class color_conv_rgb565_to_rgb555 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { unsigned rgb = *(int16u*)src; *(int16u*)dst = (int16u)(((rgb >> 1) & 0x7FE0) | (rgb & 0x1F)); src += 2; dst += 2; } while(--width); } }; //------------------------------------------------------------------------ typedef color_conv_same<2> color_conv_rgb555_to_rgb555; //----color_conv_rgb555_to_rgb555 typedef color_conv_same<2> color_conv_rgb565_to_rgb565; //----color_conv_rgb565_to_rgb565 template class color_conv_rgb24_gray8 { public: void operator () (int8u* dst, const int8u* src, unsigned width) const { do { *dst++ = (src[R]*77 + src[1]*150 + src[B]*29) >> 8; src += 3; } while(--width); } }; typedef color_conv_rgb24_gray8<0,2> color_conv_rgb24_to_gray8; //----color_conv_rgb24_to_gray8 typedef color_conv_rgb24_gray8<2,0> color_conv_bgr24_to_gray8; //----color_conv_bgr24_to_gray8 } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_vcgen_bspline.h0000644000175000017500000000421612516137326024604 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_VCGEN_BSPLINE_INCLUDED #define AGG_VCGEN_BSPLINE_INCLUDED #include "agg_basics.h" #include "agg_array.h" #include "agg_bspline.h" namespace agg24 { //==========================================================vcgen_bspline class vcgen_bspline { enum status_e { initial, ready, polygon, end_poly, stop }; public: typedef pod_bvector vertex_storage; vcgen_bspline(); void interpolation_step(double v) { m_interpolation_step = v; } double interpolation_step() const { return m_interpolation_step; } // Vertex Generator Interface void remove_all(); void add_vertex(double x, double y, unsigned cmd); // Vertex Source Interface void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: vcgen_bspline(const vcgen_bspline&); const vcgen_bspline& operator = (const vcgen_bspline&); vertex_storage m_src_vertices; bspline m_spline_x; bspline m_spline_y; double m_interpolation_step; unsigned m_closed; status_e m_status; unsigned m_src_vertex; double m_cur_abscissa; double m_max_abscissa; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_bounding_rect.h0000644000175000017500000000717012516137326024612 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // bounding_rect function template // //---------------------------------------------------------------------------- #ifndef AGG_BOUNDING_RECT_INCLUDED #define AGG_BOUNDING_RECT_INCLUDED #include "agg_basics.h" namespace agg24 { //-----------------------------------------------------------bounding_rect template bool bounding_rect(VertexSource& vs, GetId& gi, unsigned start, unsigned num, CoordT* x1, CoordT* y1, CoordT* x2, CoordT* y2) { unsigned i; double x; double y; bool first = true; *x1 = CoordT(1); *y1 = CoordT(1); *x2 = CoordT(0); *y2 = CoordT(0); for(i = 0; i < num; i++) { vs.rewind(gi[start + i]); unsigned cmd; while(!is_stop(cmd = vs.vertex(&x, &y))) { if(is_vertex(cmd)) { if(first) { *x1 = CoordT(x); *y1 = CoordT(y); *x2 = CoordT(x); *y2 = CoordT(y); first = false; } else { if(CoordT(x) < *x1) *x1 = CoordT(x); if(CoordT(y) < *y1) *y1 = CoordT(y); if(CoordT(x) > *x2) *x2 = CoordT(x); if(CoordT(y) > *y2) *y2 = CoordT(y); } } } } return *x1 <= *x2 && *y1 <= *y2; } //-----------------------------------------------------bounding_rect_single template bool bounding_rect_single(VertexSource& vs, unsigned path_id, CoordT* x1, CoordT* y1, CoordT* x2, CoordT* y2) { double x; double y; bool first = true; *x1 = CoordT(1); *y1 = CoordT(1); *x2 = CoordT(0); *y2 = CoordT(0); vs.rewind(path_id); unsigned cmd; while(!is_stop(cmd = vs.vertex(&x, &y))) { if(is_vertex(cmd)) { if(first) { *x1 = CoordT(x); *y1 = CoordT(y); *x2 = CoordT(x); *y2 = CoordT(y); first = false; } else { if(CoordT(x) < *x1) *x1 = CoordT(x); if(CoordT(y) < *y1) *y1 = CoordT(y); if(CoordT(x) > *x2) *x2 = CoordT(x); if(CoordT(y) > *y2) *y2 = CoordT(y); } } } return *x1 <= *x2 && *y1 <= *y2; } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_scanline_boolean_algebra.h0000644000175000017500000015522612516137326026746 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_SCANLINE_BOOLEAN_ALGEBRA_INCLUDED #define AGG_SCANLINE_BOOLEAN_ALGEBRA_INCLUDED #include #include #include "agg_basics.h" namespace agg24 { //-----------------------------------------------sbool_combine_spans_bin // Functor. // Combine two binary encoded spans, i.e., when we don't have any // anti-aliasing information, but only X and Length. The function // is compatible with any type of scanlines. //---------------- template struct sbool_combine_spans_bin { void operator () (const typename Scanline1::const_iterator&, const typename Scanline2::const_iterator&, int x, unsigned len, Scanline& sl) const { sl.add_span(x, len, cover_full); } }; //---------------------------------------------sbool_combine_spans_empty // Functor. // Combine two spans as empty ones. The functor does nothing // and is used to XOR binary spans. //---------------- template struct sbool_combine_spans_empty { void operator () (const typename Scanline1::const_iterator&, const typename Scanline2::const_iterator&, int, unsigned, Scanline&) const {} }; //--------------------------------------------------sbool_add_span_empty // Functor. // Add nothing. Used in conbine_shapes_sub //---------------- template struct sbool_add_span_empty { void operator () (const typename Scanline1::const_iterator&, int, unsigned, Scanline&) const {} }; //----------------------------------------------------sbool_add_span_bin // Functor. // Add a binary span //---------------- template struct sbool_add_span_bin { void operator () (const typename Scanline1::const_iterator&, int x, unsigned len, Scanline& sl) const { sl.add_span(x, len, cover_full); } }; //-----------------------------------------------------sbool_add_span_aa // Functor. // Add an anti-aliased span // anti-aliasing information, but only X and Length. The function // is compatible with any type of scanlines. //---------------- template struct sbool_add_span_aa { void operator () (const typename Scanline1::const_iterator& span, int x, unsigned len, Scanline& sl) const { if(span->len < 0) { sl.add_span(x, len, *span->covers); } else if(span->len > 0) { const typename Scanline1::cover_type* covers = span->covers; if(span->x < x) covers += x - span->x; sl.add_cells(x, len, covers); } } }; //----------------------------------------------sbool_intersect_spans_aa // Functor. // Intersect two spans preserving the anti-aliasing information. // The result is added to the "sl" scanline. //------------------ template struct sbool_intersect_spans_aa { enum cover_scale_e { cover_shift = CoverShift, cover_size = 1 << cover_shift, cover_mask = cover_size - 1, cover_full = cover_mask }; void operator () (const typename Scanline1::const_iterator& span1, const typename Scanline2::const_iterator& span2, int x, unsigned len, Scanline& sl) const { unsigned cover; const typename Scanline1::cover_type* covers1; const typename Scanline2::cover_type* covers2; // Calculate the operation code and choose the // proper combination algorithm. // 0 = Both spans are of AA type // 1 = span1 is solid, span2 is AA // 2 = span1 is AA, span2 is solid // 3 = Both spans are of solid type //----------------- switch((span1->len < 0) | ((span2->len < 0) << 1)) { case 0: // Both are AA spans covers1 = span1->covers; covers2 = span2->covers; if(span1->x < x) covers1 += x - span1->x; if(span2->x < x) covers2 += x - span2->x; do { cover = *covers1++ * *covers2++; sl.add_cell(x++, (cover == cover_full * cover_full) ? cover_full : (cover >> cover_shift)); } while(--len); break; case 1: // span1 is solid, span2 is AA covers2 = span2->covers; if(span2->x < x) covers2 += x - span2->x; if(*(span1->covers) == cover_full) { sl.add_cells(x, len, covers2); } else { do { cover = *(span1->covers) * *covers2++; sl.add_cell(x++, (cover == cover_full * cover_full) ? cover_full : (cover >> cover_shift)); } while(--len); } break; case 2: // span1 is AA, span2 is solid covers1 = span1->covers; if(span1->x < x) covers1 += x - span1->x; if(*(span2->covers) == cover_full) { sl.add_cells(x, len, covers1); } else { do { cover = *covers1++ * *(span2->covers); sl.add_cell(x++, (cover == cover_full * cover_full) ? cover_full : (cover >> cover_shift)); } while(--len); } break; case 3: // Both are solid spans cover = *(span1->covers) * *(span2->covers); sl.add_span(x, len, (cover == cover_full * cover_full) ? cover_full : (cover >> cover_shift)); break; } } }; //--------------------------------------------------sbool_unite_spans_aa // Functor. // Unite two spans preserving the anti-aliasing information. // The result is added to the "sl" scanline. //------------------ template struct sbool_unite_spans_aa { enum cover_scale_e { cover_shift = CoverShift, cover_size = 1 << cover_shift, cover_mask = cover_size - 1, cover_full = cover_mask }; void operator () (const typename Scanline1::const_iterator& span1, const typename Scanline2::const_iterator& span2, int x, unsigned len, Scanline& sl) const { unsigned cover; const typename Scanline1::cover_type* covers1; const typename Scanline2::cover_type* covers2; // Calculate the operation code and choose the // proper combination algorithm. // 0 = Both spans are of AA type // 1 = span1 is solid, span2 is AA // 2 = span1 is AA, span2 is solid // 3 = Both spans are of solid type //----------------- switch((span1->len < 0) | ((span2->len < 0) << 1)) { case 0: // Both are AA spans covers1 = span1->covers; covers2 = span2->covers; if(span1->x < x) covers1 += x - span1->x; if(span2->x < x) covers2 += x - span2->x; do { cover = cover_mask * cover_mask - (cover_mask - *covers1++) * (cover_mask - *covers2++); sl.add_cell(x++, (cover == cover_full * cover_full) ? cover_full : (cover >> cover_shift)); } while(--len); break; case 1: // span1 is solid, span2 is AA covers2 = span2->covers; if(span2->x < x) covers2 += x - span2->x; if(*(span1->covers) == cover_full) { sl.add_span(x, len, cover_full); } else { do { cover = cover_mask * cover_mask - (cover_mask - *(span1->covers)) * (cover_mask - *covers2++); sl.add_cell(x++, (cover == cover_full * cover_full) ? cover_full : (cover >> cover_shift)); } while(--len); } break; case 2: // span1 is AA, span2 is solid covers1 = span1->covers; if(span1->x < x) covers1 += x - span1->x; if(*(span2->covers) == cover_full) { sl.add_span(x, len, cover_full); } else { do { cover = cover_mask * cover_mask - (cover_mask - *covers1++) * (cover_mask - *(span2->covers)); sl.add_cell(x++, (cover == cover_full * cover_full) ? cover_full : (cover >> cover_shift)); } while(--len); } break; case 3: // Both are solid spans cover = cover_mask * cover_mask - (cover_mask - *(span1->covers)) * (cover_mask - *(span2->covers)); sl.add_span(x, len, (cover == cover_full * cover_full) ? cover_full : (cover >> cover_shift)); break; } } }; //---------------------------------------------sbool_xor_formula_linear template struct sbool_xor_formula_linear { enum cover_scale_e { cover_shift = CoverShift, cover_size = 1 << cover_shift, cover_mask = cover_size - 1 }; static AGG_INLINE unsigned calculate(unsigned a, unsigned b) { unsigned cover = a + b; if(cover > cover_mask) cover = cover_mask + cover_mask - cover; return cover; } }; //---------------------------------------------sbool_xor_formula_saddle template struct sbool_xor_formula_saddle { enum cover_scale_e { cover_shift = CoverShift, cover_size = 1 << cover_shift, cover_mask = cover_size - 1 }; static AGG_INLINE unsigned calculate(unsigned a, unsigned b) { unsigned k = a * b; if(k == cover_mask * cover_mask) return 0; a = (cover_mask * cover_mask - (a << cover_shift) + k) >> cover_shift; b = (cover_mask * cover_mask - (b << cover_shift) + k) >> cover_shift; return cover_mask - ((a * b) >> cover_shift); } }; //-------------------------------------------sbool_xor_formula_abs_diff struct sbool_xor_formula_abs_diff { static AGG_INLINE unsigned calculate(unsigned a, unsigned b) { return unsigned(abs(int(a) - int(b))); } }; //----------------------------------------------------sbool_xor_spans_aa // Functor. // XOR two spans preserving the anti-aliasing information. // The result is added to the "sl" scanline. //------------------ template struct sbool_xor_spans_aa { enum cover_scale_e { cover_shift = CoverShift, cover_size = 1 << cover_shift, cover_mask = cover_size - 1, cover_full = cover_mask }; void operator () (const typename Scanline1::const_iterator& span1, const typename Scanline2::const_iterator& span2, int x, unsigned len, Scanline& sl) const { unsigned cover; const typename Scanline1::cover_type* covers1; const typename Scanline2::cover_type* covers2; // Calculate the operation code and choose the // proper combination algorithm. // 0 = Both spans are of AA type // 1 = span1 is solid, span2 is AA // 2 = span1 is AA, span2 is solid // 3 = Both spans are of solid type //----------------- switch((span1->len < 0) | ((span2->len < 0) << 1)) { case 0: // Both are AA spans covers1 = span1->covers; covers2 = span2->covers; if(span1->x < x) covers1 += x - span1->x; if(span2->x < x) covers2 += x - span2->x; do { cover = XorFormula::calculate(*covers1++, *covers2++); if(cover) sl.add_cell(x, cover); ++x; } while(--len); break; case 1: // span1 is solid, span2 is AA covers2 = span2->covers; if(span2->x < x) covers2 += x - span2->x; do { cover = XorFormula::calculate(*(span1->covers), *covers2++); if(cover) sl.add_cell(x, cover); ++x; } while(--len); break; case 2: // span1 is AA, span2 is solid covers1 = span1->covers; if(span1->x < x) covers1 += x - span1->x; do { cover = XorFormula::calculate(*covers1++, *(span2->covers)); if(cover) sl.add_cell(x, cover); ++x; } while(--len); break; case 3: // Both are solid spans cover = XorFormula::calculate(*(span1->covers), *(span2->covers)); if(cover) sl.add_span(x, len, cover); break; } } }; //-----------------------------------------------sbool_subtract_spans_aa // Functor. // Unite two spans preserving the anti-aliasing information. // The result is added to the "sl" scanline. //------------------ template struct sbool_subtract_spans_aa { enum cover_scale_e { cover_shift = CoverShift, cover_size = 1 << cover_shift, cover_mask = cover_size - 1, cover_full = cover_mask }; void operator () (const typename Scanline1::const_iterator& span1, const typename Scanline2::const_iterator& span2, int x, unsigned len, Scanline& sl) const { unsigned cover; const typename Scanline1::cover_type* covers1; const typename Scanline2::cover_type* covers2; // Calculate the operation code and choose the // proper combination algorithm. // 0 = Both spans are of AA type // 1 = span1 is solid, span2 is AA // 2 = span1 is AA, span2 is solid // 3 = Both spans are of solid type //----------------- switch((span1->len < 0) | ((span2->len < 0) << 1)) { case 0: // Both are AA spans covers1 = span1->covers; covers2 = span2->covers; if(span1->x < x) covers1 += x - span1->x; if(span2->x < x) covers2 += x - span2->x; do { cover = *covers1++ * (cover_mask - *covers2++); if(cover) { sl.add_cell(x, (cover == cover_full * cover_full) ? cover_full : (cover >> cover_shift)); } ++x; } while(--len); break; case 1: // span1 is solid, span2 is AA covers2 = span2->covers; if(span2->x < x) covers2 += x - span2->x; do { cover = *(span1->covers) * (cover_mask - *covers2++); if(cover) { sl.add_cell(x, (cover == cover_full * cover_full) ? cover_full : (cover >> cover_shift)); } ++x; } while(--len); break; case 2: // span1 is AA, span2 is solid covers1 = span1->covers; if(span1->x < x) covers1 += x - span1->x; if(*(span2->covers) != cover_full) { do { cover = *covers1++ * (cover_mask - *(span2->covers)); if(cover) { sl.add_cell(x, (cover == cover_full * cover_full) ? cover_full : (cover >> cover_shift)); } ++x; } while(--len); } break; case 3: // Both are solid spans cover = *(span1->covers) * (cover_mask - *(span2->covers)); if(cover) { sl.add_span(x, len, (cover == cover_full * cover_full) ? cover_full : (cover >> cover_shift)); } break; } } }; //--------------------------------------------sbool_add_spans_and_render template void sbool_add_spans_and_render(const Scanline1& sl1, Scanline& sl, Renderer& ren, AddSpanFunctor add_span) { sl.reset_spans(); typename Scanline1::const_iterator span = sl1.begin(); unsigned num_spans = sl1.num_spans(); for(;;) { add_span(span, span->x, abs((int)span->len), sl); if(--num_spans == 0) break; ++span; } sl.finalize(sl1.y()); ren.render(sl); } //---------------------------------------------sbool_intersect_scanlines // Intersect two scanlines, "sl1" and "sl2" and generate a new "sl" one. // The combine_spans functor can be of type sbool_combine_spans_bin or // sbool_intersect_spans_aa. First is a general functor to combine // two spans without Anti-Aliasing, the second preserves the AA // information, but works slower // template void sbool_intersect_scanlines(const Scanline1& sl1, const Scanline2& sl2, Scanline& sl, CombineSpansFunctor combine_spans) { sl.reset_spans(); unsigned num1 = sl1.num_spans(); if(num1 == 0) return; unsigned num2 = sl2.num_spans(); if(num2 == 0) return; typename Scanline1::const_iterator span1 = sl1.begin(); typename Scanline2::const_iterator span2 = sl2.begin(); while(num1 && num2) { int xb1 = span1->x; int xb2 = span2->x; int xe1 = xb1 + abs((int)span1->len) - 1; int xe2 = xb2 + abs((int)span2->len) - 1; // Determine what spans we should advance in the next step // The span with the least ending X should be advanced // advance_both is just an optimization when we ending // coordinates are the same and we can advance both //-------------- bool advance_span1 = xe1 < xe2; bool advance_both = xe1 == xe2; // Find the intersection of the spans // and check if they intersect //-------------- if(xb1 < xb2) xb1 = xb2; if(xe1 > xe2) xe1 = xe2; if(xb1 <= xe1) { combine_spans(span1, span2, xb1, xe1 - xb1 + 1, sl); } // Advance the spans //-------------- if(advance_both) { --num1; --num2; if(num1) ++span1; if(num2) ++span2; } else { if(advance_span1) { --num1; if(num1) ++span1; } else { --num2; if(num2) ++span2; } } } } //------------------------------------------------sbool_intersect_shapes // Intersect the scanline shapes. Here the "Scanline Generator" // abstraction is used. ScanlineGen1 and ScanlineGen2 are // the generators, and can be of type rasterizer_scanline_aa<>. // There function requires three scanline containers that can be of // different types. // "sl1" and "sl2" are used to retrieve scanlines from the generators, // "sl" is ised as the resulting scanline to render it. // The external "sl1" and "sl2" are used only for the sake of // optimization and reusing of the scanline objects. // the function calls sbool_intersect_scanlines with CombineSpansFunctor // as the last argument. See sbool_intersect_scanlines for details. //---------- template void sbool_intersect_shapes(ScanlineGen1& sg1, ScanlineGen2& sg2, Scanline1& sl1, Scanline2& sl2, Scanline& sl, Renderer& ren, CombineSpansFunctor combine_spans) { // Prepare the scanline generators. // If anyone of them doesn't contain // any scanlines, then return. //----------------- if(!sg1.rewind_scanlines()) return; if(!sg2.rewind_scanlines()) return; // Get the bounding boxes //---------------- rect_i r1(sg1.min_x(), sg1.min_y(), sg1.max_x(), sg1.max_y()); rect_i r2(sg2.min_x(), sg2.min_y(), sg2.max_x(), sg2.max_y()); // Calculate the intersection of the bounding // boxes and return if they don't intersect. //----------------- rect_i ir = intersect_rectangles(r1, r2); if(!ir.is_valid()) return; // Reset the scanlines and get two first ones //----------------- sl.reset(ir.x1, ir.x2); sl1.reset(sg1.min_x(), sg1.max_x()); sl2.reset(sg2.min_x(), sg2.max_x()); if(!sg1.sweep_scanline(sl1)) return; if(!sg2.sweep_scanline(sl2)) return; ren.prepare(); // The main loop // Here we synchronize the scanlines with // the same Y coordinate, ignoring all other ones. // Only scanlines having the same Y-coordinate // are to be combined. //----------------- for(;;) { while(sl1.y() < sl2.y()) { if(!sg1.sweep_scanline(sl1)) return; } while(sl2.y() < sl1.y()) { if(!sg2.sweep_scanline(sl2)) return; } if(sl1.y() == sl2.y()) { // The Y coordinates are the same. // Combine the scanlines, render if they contain any spans, // and advance both generators to the next scanlines //---------------------- sbool_intersect_scanlines(sl1, sl2, sl, combine_spans); if(sl.num_spans()) { sl.finalize(sl1.y()); ren.render(sl); } if(!sg1.sweep_scanline(sl1)) return; if(!sg2.sweep_scanline(sl2)) return; } } } //-------------------------------------------------sbool_unite_scanlines // Unite two scanlines, "sl1" and "sl2" and generate a new "sl" one. // The combine_spans functor can be of type sbool_combine_spans_bin or // sbool_intersect_spans_aa. First is a general functor to combine // two spans without Anti-Aliasing, the second preserves the AA // information, but works slower // template void sbool_unite_scanlines(const Scanline1& sl1, const Scanline2& sl2, Scanline& sl, AddSpanFunctor1 add_span1, AddSpanFunctor2 add_span2, CombineSpansFunctor combine_spans) { sl.reset_spans(); unsigned num1 = sl1.num_spans(); unsigned num2 = sl2.num_spans(); typename Scanline1::const_iterator span1;// = sl1.begin(); typename Scanline2::const_iterator span2;// = sl2.begin(); enum invalidation_e { invalid_b = 0xFFFFFFF, invalid_e = invalid_b - 1 }; // Initialize the spans as invalid //--------------- int xb1 = invalid_b; int xb2 = invalid_b; int xe1 = invalid_e; int xe2 = invalid_e; // Initialize span1 if there are spans //--------------- if(num1) { span1 = sl1.begin(); xb1 = span1->x; xe1 = xb1 + abs((int)span1->len) - 1; --num1; } // Initialize span2 if there are spans //--------------- if(num2) { span2 = sl2.begin(); xb2 = span2->x; xe2 = xb2 + abs((int)span2->len) - 1; --num2; } for(;;) { // Retrieve a new span1 if it's invalid //---------------- if(num1 && xb1 > xe1) { --num1; ++span1; xb1 = span1->x; xe1 = xb1 + abs((int)span1->len) - 1; } // Retrieve a new span2 if it's invalid //---------------- if(num2 && xb2 > xe2) { --num2; ++span2; xb2 = span2->x; xe2 = xb2 + abs((int)span2->len) - 1; } if(xb1 > xe1 && xb2 > xe2) break; // Calculate the intersection //---------------- int xb = xb1; int xe = xe1; if(xb < xb2) xb = xb2; if(xe > xe2) xe = xe2; int len = xe - xb + 1; // The length of the intersection if(len > 0) { // The spans intersect, // add the beginning of the span //---------------- if(xb1 < xb2) { add_span1(span1, xb1, xb2 - xb1, sl); xb1 = xb2; } else if(xb2 < xb1) { add_span2(span2, xb2, xb1 - xb2, sl); xb2 = xb1; } // Add the combination part of the spans //---------------- combine_spans(span1, span2, xb, len, sl); // Invalidate the fully processed span or both //---------------- if(xe1 < xe2) { // Invalidate span1 and eat // the processed part of span2 //-------------- xb1 = invalid_b; xe1 = invalid_e; xb2 += len; } else if(xe2 < xe1) { // Invalidate span2 and eat // the processed part of span1 //-------------- xb2 = invalid_b; xe2 = invalid_e; xb1 += len; } else { xb1 = invalid_b; // Invalidate both xb2 = invalid_b; xe1 = invalid_e; xe2 = invalid_e; } } else { // The spans do not intersect //-------------- if(xb1 < xb2) { // Advance span1 //--------------- if(xb1 <= xe1) { add_span1(span1, xb1, xe1 - xb1 + 1, sl); } xb1 = invalid_b; // Invalidate xe1 = invalid_e; } else { // Advance span2 //--------------- if(xb2 <= xe2) { add_span2(span2, xb2, xe2 - xb2 + 1, sl); } xb2 = invalid_b; // Invalidate xe2 = invalid_e; } } } } //----------------------------------------------------sbool_unite_shapes // Unite the scanline shapes. Here the "Scanline Generator" // abstraction is used. ScanlineGen1 and ScanlineGen2 are // the generators, and can be of type rasterizer_scanline_aa<>. // There function requires three scanline containers that can be // of different type. // "sl1" and "sl2" are used to retrieve scanlines from the generators, // "sl" is ised as the resulting scanline to render it. // The external "sl1" and "sl2" are used only for the sake of // optimization and reusing of the scanline objects. // the function calls sbool_unite_scanlines with CombineSpansFunctor // as the last argument. See sbool_unite_scanlines for details. //---------- template void sbool_unite_shapes(ScanlineGen1& sg1, ScanlineGen2& sg2, Scanline1& sl1, Scanline2& sl2, Scanline& sl, Renderer& ren, AddSpanFunctor1 add_span1, AddSpanFunctor2 add_span2, CombineSpansFunctor combine_spans) { // Prepare the scanline generators. // If anyone of them doesn't contain // any scanlines, then return. //----------------- bool flag1 = sg1.rewind_scanlines(); bool flag2 = sg2.rewind_scanlines(); if(!flag1 && !flag2) return; // Get the bounding boxes //---------------- rect_i r1(sg1.min_x(), sg1.min_y(), sg1.max_x(), sg1.max_y()); rect_i r2(sg2.min_x(), sg2.min_y(), sg2.max_x(), sg2.max_y()); // Calculate the union of the bounding boxes //----------------- rect_i ur(1,1,0,0); if(flag1 && flag2) ur = unite_rectangles(r1, r2); else if(flag1) ur = r1; else if(flag2) ur = r2; if(!ur.is_valid()) return; ren.prepare(); // Reset the scanlines and get two first ones //----------------- sl.reset(ur.x1, ur.x2); if(flag1) { sl1.reset(sg1.min_x(), sg1.max_x()); flag1 = sg1.sweep_scanline(sl1); } if(flag2) { sl2.reset(sg2.min_x(), sg2.max_x()); flag2 = sg2.sweep_scanline(sl2); } // The main loop // Here we synchronize the scanlines with // the same Y coordinate. //----------------- while(flag1 || flag2) { if(flag1 && flag2) { if(sl1.y() == sl2.y()) { // The Y coordinates are the same. // Combine the scanlines, render if they contain any spans, // and advance both generators to the next scanlines //---------------------- sbool_unite_scanlines(sl1, sl2, sl, add_span1, add_span2, combine_spans); if(sl.num_spans()) { sl.finalize(sl1.y()); ren.render(sl); } flag1 = sg1.sweep_scanline(sl1); flag2 = sg2.sweep_scanline(sl2); } else { if(sl1.y() < sl2.y()) { sbool_add_spans_and_render(sl1, sl, ren, add_span1); flag1 = sg1.sweep_scanline(sl1); } else { sbool_add_spans_and_render(sl2, sl, ren, add_span2); flag2 = sg2.sweep_scanline(sl2); } } } else { if(flag1) { sbool_add_spans_and_render(sl1, sl, ren, add_span1); flag1 = sg1.sweep_scanline(sl1); } if(flag2) { sbool_add_spans_and_render(sl2, sl, ren, add_span2); flag2 = sg2.sweep_scanline(sl2); } } } } //-------------------------------------------------sbool_subtract_shapes // Subtract the scanline shapes, "sg1-sg2". Here the "Scanline Generator" // abstraction is used. ScanlineGen1 and ScanlineGen2 are // the generators, and can be of type rasterizer_scanline_aa<>. // There function requires three scanline containers that can be of // different types. // "sl1" and "sl2" are used to retrieve scanlines from the generators, // "sl" is ised as the resulting scanline to render it. // The external "sl1" and "sl2" are used only for the sake of // optimization and reusing of the scanline objects. // the function calls sbool_intersect_scanlines with CombineSpansFunctor // as the last argument. See combine_scanlines_sub for details. //---------- template void sbool_subtract_shapes(ScanlineGen1& sg1, ScanlineGen2& sg2, Scanline1& sl1, Scanline2& sl2, Scanline& sl, Renderer& ren, AddSpanFunctor1 add_span1, CombineSpansFunctor combine_spans) { // Prepare the scanline generators. // Here "sg1" is master, "sg2" is slave. //----------------- if(!sg1.rewind_scanlines()) return; bool flag2 = sg2.rewind_scanlines(); // Get the bounding box //---------------- rect_i r1(sg1.min_x(), sg1.min_y(), sg1.max_x(), sg1.max_y()); // Reset the scanlines and get two first ones //----------------- sl.reset(sg1.min_x(), sg1.max_x()); sl1.reset(sg1.min_x(), sg1.max_x()); sl2.reset(sg2.min_x(), sg2.max_x()); if(!sg1.sweep_scanline(sl1)) return; if(flag2) flag2 = sg2.sweep_scanline(sl2); ren.prepare(); // A fake span2 processor sbool_add_span_empty add_span2; // The main loop // Here we synchronize the scanlines with // the same Y coordinate, ignoring all other ones. // Only scanlines having the same Y-coordinate // are to be combined. //----------------- bool flag1 = true; do { // Synchronize "slave" with "master" //----------------- while(flag2 && sl2.y() < sl1.y()) { flag2 = sg2.sweep_scanline(sl2); } if(flag2 && sl2.y() == sl1.y()) { // The Y coordinates are the same. // Combine the scanlines and render if they contain any spans. //---------------------- sbool_unite_scanlines(sl1, sl2, sl, add_span1, add_span2, combine_spans); if(sl.num_spans()) { sl.finalize(sl1.y()); ren.render(sl); } } else { sbool_add_spans_and_render(sl1, sl, ren, add_span1); } // Advance the "master" flag1 = sg1.sweep_scanline(sl1); } while(flag1); } //---------------------------------------------sbool_intersect_shapes_aa // Intersect two anti-aliased scanline shapes. // Here the "Scanline Generator" abstraction is used. // ScanlineGen1 and ScanlineGen2 are the generators, and can be of // type rasterizer_scanline_aa<>. There function requires three // scanline containers that can be of different types. // "sl1" and "sl2" are used to retrieve scanlines from the generators, // "sl" is ised as the resulting scanline to render it. // The external "sl1" and "sl2" are used only for the sake of // optimization and reusing of the scanline objects. //---------- template void sbool_intersect_shapes_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, Scanline1& sl1, Scanline2& sl2, Scanline& sl, Renderer& ren) { sbool_intersect_spans_aa combine_functor; sbool_intersect_shapes(sg1, sg2, sl1, sl2, sl, ren, combine_functor); } //--------------------------------------------sbool_intersect_shapes_bin // Intersect two binary scanline shapes (without anti-aliasing). // See intersect_shapes_aa for more comments //---------- template void sbool_intersect_shapes_bin(ScanlineGen1& sg1, ScanlineGen2& sg2, Scanline1& sl1, Scanline2& sl2, Scanline& sl, Renderer& ren) { sbool_combine_spans_bin combine_functor; sbool_intersect_shapes(sg1, sg2, sl1, sl2, sl, ren, combine_functor); } //-------------------------------------------------sbool_unite_shapes_aa // Unite two anti-aliased scanline shapes // See intersect_shapes_aa for more comments //---------- template void sbool_unite_shapes_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, Scanline1& sl1, Scanline2& sl2, Scanline& sl, Renderer& ren) { sbool_add_span_aa add_functor1; sbool_add_span_aa add_functor2; sbool_unite_spans_aa combine_functor; sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, add_functor1, add_functor2, combine_functor); } //------------------------------------------------sbool_unite_shapes_bin // Unite two binary scanline shapes (without anti-aliasing). // See intersect_shapes_aa for more comments //---------- template void sbool_unite_shapes_bin(ScanlineGen1& sg1, ScanlineGen2& sg2, Scanline1& sl1, Scanline2& sl2, Scanline& sl, Renderer& ren) { sbool_add_span_bin add_functor1; sbool_add_span_bin add_functor2; sbool_combine_spans_bin combine_functor; sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, add_functor1, add_functor2, combine_functor); } //---------------------------------------------------sbool_xor_shapes_aa // Apply eXclusive OR to two anti-aliased scanline shapes. There's // a modified "Linear" XOR used instead of classical "Saddle" one. // The reason is to have the result absolutely conststent with what // the scanline rasterizer produces. // See intersect_shapes_aa for more comments //---------- template void sbool_xor_shapes_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, Scanline1& sl1, Scanline2& sl2, Scanline& sl, Renderer& ren) { sbool_add_span_aa add_functor1; sbool_add_span_aa add_functor2; sbool_xor_spans_aa > combine_functor; sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, add_functor1, add_functor2, combine_functor); } //------------------------------------------sbool_xor_shapes_saddle_aa // Apply eXclusive OR to two anti-aliased scanline shapes. // There's the classical "Saddle" used to calculate the // Anti-Aliasing values, that is: // a XOR b : 1-((1-a+a*b)*(1-b+a*b)) // See intersect_shapes_aa for more comments //---------- template void sbool_xor_shapes_saddle_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, Scanline1& sl1, Scanline2& sl2, Scanline& sl, Renderer& ren) { sbool_add_span_aa add_functor1; sbool_add_span_aa add_functor2; sbool_xor_spans_aa > combine_functor; sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, add_functor1, add_functor2, combine_functor); } //--------------------------------------sbool_xor_shapes_abs_diff_aa // Apply eXclusive OR to two anti-aliased scanline shapes. // There's the absolute difference used to calculate // Anti-Aliasing values, that is: // a XOR b : abs(a-b) // See intersect_shapes_aa for more comments //---------- template void sbool_xor_shapes_abs_diff_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, Scanline1& sl1, Scanline2& sl2, Scanline& sl, Renderer& ren) { sbool_add_span_aa add_functor1; sbool_add_span_aa add_functor2; sbool_xor_spans_aa combine_functor; sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, add_functor1, add_functor2, combine_functor); } //--------------------------------------------------sbool_xor_shapes_bin // Apply eXclusive OR to two binary scanline shapes (without anti-aliasing). // See intersect_shapes_aa for more comments //---------- template void sbool_xor_shapes_bin(ScanlineGen1& sg1, ScanlineGen2& sg2, Scanline1& sl1, Scanline2& sl2, Scanline& sl, Renderer& ren) { sbool_add_span_bin add_functor1; sbool_add_span_bin add_functor2; sbool_combine_spans_empty combine_functor; sbool_unite_shapes(sg1, sg2, sl1, sl2, sl, ren, add_functor1, add_functor2, combine_functor); } //----------------------------------------------sbool_subtract_shapes_aa // Subtract shapes "sg1-sg2" with anti-aliasing // See intersect_shapes_aa for more comments //---------- template void sbool_subtract_shapes_aa(ScanlineGen1& sg1, ScanlineGen2& sg2, Scanline1& sl1, Scanline2& sl2, Scanline& sl, Renderer& ren) { sbool_add_span_aa add_functor; sbool_subtract_spans_aa combine_functor; sbool_subtract_shapes(sg1, sg2, sl1, sl2, sl, ren, add_functor, combine_functor); } //---------------------------------------------sbool_subtract_shapes_bin // Subtract binary shapes "sg1-sg2" without anti-aliasing // See intersect_shapes_aa for more comments //---------- template void sbool_subtract_shapes_bin(ScanlineGen1& sg1, ScanlineGen2& sg2, Scanline1& sl1, Scanline2& sl2, Scanline& sl, Renderer& ren) { sbool_add_span_bin add_functor; sbool_combine_spans_empty combine_functor; sbool_subtract_shapes(sg1, sg2, sl1, sl2, sl, ren, add_functor, combine_functor); } //------------------------------------------------------------sbool_op_e enum sbool_op_e { sbool_or, //----sbool_or sbool_and, //----sbool_and sbool_xor, //----sbool_xor sbool_xor_saddle, //----sbool_xor_saddle sbool_xor_abs_diff, //----sbool_xor_abs_diff sbool_a_minus_b, //----sbool_a_minus_b sbool_b_minus_a //----sbool_b_minus_a }; //----------------------------------------------sbool_combine_shapes_bin template void sbool_combine_shapes_bin(sbool_op_e op, ScanlineGen1& sg1, ScanlineGen2& sg2, Scanline1& sl1, Scanline2& sl2, Scanline& sl, Renderer& ren) { switch(op) { case sbool_or : sbool_unite_shapes_bin (sg1, sg2, sl1, sl2, sl, ren); break; case sbool_and : sbool_intersect_shapes_bin(sg1, sg2, sl1, sl2, sl, ren); break; case sbool_xor : case sbool_xor_saddle : case sbool_xor_abs_diff: sbool_xor_shapes_bin (sg1, sg2, sl1, sl2, sl, ren); break; case sbool_a_minus_b : sbool_subtract_shapes_bin (sg1, sg2, sl1, sl2, sl, ren); break; case sbool_b_minus_a : sbool_subtract_shapes_bin (sg2, sg1, sl2, sl1, sl, ren); break; } } //-----------------------------------------------sbool_combine_shapes_aa template void sbool_combine_shapes_aa(sbool_op_e op, ScanlineGen1& sg1, ScanlineGen2& sg2, Scanline1& sl1, Scanline2& sl2, Scanline& sl, Renderer& ren) { switch(op) { case sbool_or : sbool_unite_shapes_aa (sg1, sg2, sl1, sl2, sl, ren); break; case sbool_and : sbool_intersect_shapes_aa (sg1, sg2, sl1, sl2, sl, ren); break; case sbool_xor : sbool_xor_shapes_aa (sg1, sg2, sl1, sl2, sl, ren); break; case sbool_xor_saddle : sbool_xor_shapes_saddle_aa (sg1, sg2, sl1, sl2, sl, ren); break; case sbool_xor_abs_diff: sbool_xor_shapes_abs_diff_aa(sg1, sg2, sl1, sl2, sl, ren); break; case sbool_a_minus_b : sbool_subtract_shapes_aa (sg1, sg2, sl1, sl2, sl, ren); break; case sbool_b_minus_a : sbool_subtract_shapes_aa (sg2, sg1, sl2, sl1, sl, ren); break; } } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_alpha_mask_u8.h0000644000175000017500000004505612516137326024511 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // scanline_u8 class // //---------------------------------------------------------------------------- #ifndef AGG_ALPHA_MASK_U8_INCLUDED #define AGG_ALPHA_MASK_U8_INCLUDED #include #include "agg_basics.h" #include "agg_rendering_buffer.h" namespace agg24 { //===================================================one_component_mask_u8 struct one_component_mask_u8 { static unsigned calculate(const int8u* p) { return *p; } }; //=====================================================rgb_to_gray_mask_u8 template struct rgb_to_gray_mask_u8 { static unsigned calculate(const int8u* p) { return (p[R]*77 + p[G]*150 + p[B]*29) >> 8; } }; //==========================================================alpha_mask_u8 template class alpha_mask_u8 { public: typedef int8u cover_type; typedef alpha_mask_u8 self_type; enum cover_scale_e { cover_shift = 8, cover_none = 0, cover_full = 255 }; alpha_mask_u8() : m_rbuf(0) {} alpha_mask_u8(rendering_buffer& rbuf) : m_rbuf(&rbuf) {} void attach(rendering_buffer& rbuf) { m_rbuf = &rbuf; } MaskF& mask_function() { return m_mask_function; } const MaskF& mask_function() const { return m_mask_function; } //-------------------------------------------------------------------- cover_type pixel(int x, int y) const { if(x >= 0 && y >= 0 && x < (int)m_rbuf->width() && y <= (int)m_rbuf->height()) { return (cover_type)m_mask_function.calculate( m_rbuf->row_ptr(y) + x * Step + Offset); } return 0; } //-------------------------------------------------------------------- cover_type combine_pixel(int x, int y, cover_type val) const { if(x >= 0 && y >= 0 && x < (int)m_rbuf->width() && y <= (int)m_rbuf->height()) { return (cover_type)((cover_full + val * m_mask_function.calculate( m_rbuf->row_ptr(y) + x * Step + Offset)) >> cover_shift); } return 0; } //-------------------------------------------------------------------- void fill_hspan(int x, int y, cover_type* dst, int num_pix) const { int xmax = m_rbuf->width() - 1; int ymax = m_rbuf->height() - 1; int count = num_pix; cover_type* covers = dst; if(y < 0 || y > ymax) { memset(dst, 0, num_pix * sizeof(cover_type)); return; } if(x < 0) { count += x; if(count <= 0) { memset(dst, 0, num_pix * sizeof(cover_type)); return; } memset(covers, 0, -x * sizeof(cover_type)); covers -= x; x = 0; } if(x + count > xmax) { int rest = x + count - xmax - 1; count -= rest; if(count <= 0) { memset(dst, 0, num_pix * sizeof(cover_type)); return; } memset(covers + count, 0, rest * sizeof(cover_type)); } const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; do { *covers++ = (cover_type)m_mask_function.calculate(mask); mask += Step; } while(--count); } //-------------------------------------------------------------------- void combine_hspan(int x, int y, cover_type* dst, int num_pix) const { int xmax = m_rbuf->width() - 1; int ymax = m_rbuf->height() - 1; int count = num_pix; cover_type* covers = dst; if(y < 0 || y > ymax) { memset(dst, 0, num_pix * sizeof(cover_type)); return; } if(x < 0) { count += x; if(count <= 0) { memset(dst, 0, num_pix * sizeof(cover_type)); return; } memset(covers, 0, -x * sizeof(cover_type)); covers -= x; x = 0; } if(x + count > xmax) { int rest = x + count - xmax - 1; count -= rest; if(count <= 0) { memset(dst, 0, num_pix * sizeof(cover_type)); return; } memset(covers + count, 0, rest * sizeof(cover_type)); } const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; do { *covers = (cover_type)((cover_full + (*covers) * m_mask_function.calculate(mask)) >> cover_shift); ++covers; mask += Step; } while(--count); } //-------------------------------------------------------------------- void fill_vspan(int x, int y, cover_type* dst, int num_pix) const { int xmax = m_rbuf->width() - 1; int ymax = m_rbuf->height() - 1; int count = num_pix; cover_type* covers = dst; if(x < 0 || x > xmax) { memset(dst, 0, num_pix * sizeof(cover_type)); return; } if(y < 0) { count += y; if(count <= 0) { memset(dst, 0, num_pix * sizeof(cover_type)); return; } memset(covers, 0, -y * sizeof(cover_type)); covers -= y; y = 0; } if(y + count > ymax) { int rest = y + count - ymax - 1; count -= rest; if(count <= 0) { memset(dst, 0, num_pix * sizeof(cover_type)); return; } memset(covers + count, 0, rest * sizeof(cover_type)); } const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; do { *covers++ = (cover_type)m_mask_function.calculate(mask); mask += m_rbuf->stride(); } while(--count); } //-------------------------------------------------------------------- void combine_vspan(int x, int y, cover_type* dst, int num_pix) const { int xmax = m_rbuf->width() - 1; int ymax = m_rbuf->height() - 1; int count = num_pix; cover_type* covers = dst; if(x < 0 || x > xmax) { memset(dst, 0, num_pix * sizeof(cover_type)); return; } if(y < 0) { count += y; if(count <= 0) { memset(dst, 0, num_pix * sizeof(cover_type)); return; } memset(covers, 0, -y * sizeof(cover_type)); covers -= y; y = 0; } if(y + count > ymax) { int rest = y + count - ymax - 1; count -= rest; if(count <= 0) { memset(dst, 0, num_pix * sizeof(cover_type)); return; } memset(covers + count, 0, rest * sizeof(cover_type)); } const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; do { *covers = (cover_type)((cover_full + (*covers) * m_mask_function.calculate(mask)) >> cover_shift); ++covers; mask += m_rbuf->stride(); } while(--count); } private: alpha_mask_u8(const self_type&); const self_type& operator = (const self_type&); rendering_buffer* m_rbuf; MaskF m_mask_function; }; typedef alpha_mask_u8<1, 0> alpha_mask_gray8; //----alpha_mask_gray8 typedef alpha_mask_u8<3, 0> alpha_mask_rgb24r; //----alpha_mask_rgb24r typedef alpha_mask_u8<3, 1> alpha_mask_rgb24g; //----alpha_mask_rgb24g typedef alpha_mask_u8<3, 2> alpha_mask_rgb24b; //----alpha_mask_rgb24b typedef alpha_mask_u8<3, 2> alpha_mask_bgr24r; //----alpha_mask_bgr24r typedef alpha_mask_u8<3, 1> alpha_mask_bgr24g; //----alpha_mask_bgr24g typedef alpha_mask_u8<3, 0> alpha_mask_bgr24b; //----alpha_mask_bgr24b typedef alpha_mask_u8<4, 0> alpha_mask_rgba32r; //----alpha_mask_rgba32r typedef alpha_mask_u8<4, 1> alpha_mask_rgba32g; //----alpha_mask_rgba32g typedef alpha_mask_u8<4, 2> alpha_mask_rgba32b; //----alpha_mask_rgba32b typedef alpha_mask_u8<4, 3> alpha_mask_rgba32a; //----alpha_mask_rgba32a typedef alpha_mask_u8<4, 1> alpha_mask_argb32r; //----alpha_mask_argb32r typedef alpha_mask_u8<4, 2> alpha_mask_argb32g; //----alpha_mask_argb32g typedef alpha_mask_u8<4, 3> alpha_mask_argb32b; //----alpha_mask_argb32b typedef alpha_mask_u8<4, 0> alpha_mask_argb32a; //----alpha_mask_argb32a typedef alpha_mask_u8<4, 2> alpha_mask_bgra32r; //----alpha_mask_bgra32r typedef alpha_mask_u8<4, 1> alpha_mask_bgra32g; //----alpha_mask_bgra32g typedef alpha_mask_u8<4, 0> alpha_mask_bgra32b; //----alpha_mask_bgra32b typedef alpha_mask_u8<4, 3> alpha_mask_bgra32a; //----alpha_mask_bgra32a typedef alpha_mask_u8<4, 3> alpha_mask_abgr32r; //----alpha_mask_abgr32r typedef alpha_mask_u8<4, 2> alpha_mask_abgr32g; //----alpha_mask_abgr32g typedef alpha_mask_u8<4, 1> alpha_mask_abgr32b; //----alpha_mask_abgr32b typedef alpha_mask_u8<4, 0> alpha_mask_abgr32a; //----alpha_mask_abgr32a typedef alpha_mask_u8<3, 0, rgb_to_gray_mask_u8<0, 1, 2> > alpha_mask_rgb24gray; //----alpha_mask_rgb24gray typedef alpha_mask_u8<3, 0, rgb_to_gray_mask_u8<2, 1, 0> > alpha_mask_bgr24gray; //----alpha_mask_bgr24gray typedef alpha_mask_u8<4, 0, rgb_to_gray_mask_u8<0, 1, 2> > alpha_mask_rgba32gray; //----alpha_mask_rgba32gray typedef alpha_mask_u8<4, 1, rgb_to_gray_mask_u8<0, 1, 2> > alpha_mask_argb32gray; //----alpha_mask_argb32gray typedef alpha_mask_u8<4, 0, rgb_to_gray_mask_u8<2, 1, 0> > alpha_mask_bgra32gray; //----alpha_mask_bgra32gray typedef alpha_mask_u8<4, 1, rgb_to_gray_mask_u8<2, 1, 0> > alpha_mask_abgr32gray; //----alpha_mask_abgr32gray //==========================================================amask_no_clip_u8 template class amask_no_clip_u8 { public: typedef int8u cover_type; typedef amask_no_clip_u8 self_type; enum cover_scale_e { cover_shift = 8, cover_none = 0, cover_full = 255 }; amask_no_clip_u8() : m_rbuf(0) {} amask_no_clip_u8(rendering_buffer& rbuf) : m_rbuf(&rbuf) {} void attach(rendering_buffer& rbuf) { m_rbuf = &rbuf; } MaskF& mask_function() { return m_mask_function; } const MaskF& mask_function() const { return m_mask_function; } //-------------------------------------------------------------------- cover_type pixel(int x, int y) const { return (cover_type)m_mask_function.calculate( m_rbuf->row_ptr(y) + x * Step + Offset); } //-------------------------------------------------------------------- cover_type combine_pixel(int x, int y, cover_type val) const { return (cover_type)((cover_full + val * m_mask_function.calculate( m_rbuf->row_ptr(y) + x * Step + Offset)) >> cover_shift); } //-------------------------------------------------------------------- void fill_hspan(int x, int y, cover_type* dst, int num_pix) const { const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; do { *dst++ = (cover_type)m_mask_function.calculate(mask); mask += Step; } while(--num_pix); } //-------------------------------------------------------------------- void combine_hspan(int x, int y, cover_type* dst, int num_pix) const { const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; do { *dst = (cover_type)((cover_full + (*dst) * m_mask_function.calculate(mask)) >> cover_shift); ++dst; mask += Step; } while(--num_pix); } //-------------------------------------------------------------------- void fill_vspan(int x, int y, cover_type* dst, int num_pix) const { const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; do { *dst++ = (cover_type)m_mask_function.calculate(mask); mask += m_rbuf->stride(); } while(--num_pix); } //-------------------------------------------------------------------- void combine_vspan(int x, int y, cover_type* dst, int num_pix) const { const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; do { *dst = (cover_type)((cover_full + (*dst) * m_mask_function.calculate(mask)) >> cover_shift); ++dst; mask += m_rbuf->stride(); } while(--num_pix); } private: amask_no_clip_u8(const self_type&); const self_type& operator = (const self_type&); rendering_buffer* m_rbuf; MaskF m_mask_function; }; typedef amask_no_clip_u8<1, 0> amask_no_clip_gray8; //----amask_no_clip_gray8 typedef amask_no_clip_u8<3, 0> amask_no_clip_rgb24r; //----amask_no_clip_rgb24r typedef amask_no_clip_u8<3, 1> amask_no_clip_rgb24g; //----amask_no_clip_rgb24g typedef amask_no_clip_u8<3, 2> amask_no_clip_rgb24b; //----amask_no_clip_rgb24b typedef amask_no_clip_u8<3, 2> amask_no_clip_bgr24r; //----amask_no_clip_bgr24r typedef amask_no_clip_u8<3, 1> amask_no_clip_bgr24g; //----amask_no_clip_bgr24g typedef amask_no_clip_u8<3, 0> amask_no_clip_bgr24b; //----amask_no_clip_bgr24b typedef amask_no_clip_u8<4, 0> amask_no_clip_rgba32r; //----amask_no_clip_rgba32r typedef amask_no_clip_u8<4, 1> amask_no_clip_rgba32g; //----amask_no_clip_rgba32g typedef amask_no_clip_u8<4, 2> amask_no_clip_rgba32b; //----amask_no_clip_rgba32b typedef amask_no_clip_u8<4, 3> amask_no_clip_rgba32a; //----amask_no_clip_rgba32a typedef amask_no_clip_u8<4, 1> amask_no_clip_argb32r; //----amask_no_clip_argb32r typedef amask_no_clip_u8<4, 2> amask_no_clip_argb32g; //----amask_no_clip_argb32g typedef amask_no_clip_u8<4, 3> amask_no_clip_argb32b; //----amask_no_clip_argb32b typedef amask_no_clip_u8<4, 0> amask_no_clip_argb32a; //----amask_no_clip_argb32a typedef amask_no_clip_u8<4, 2> amask_no_clip_bgra32r; //----amask_no_clip_bgra32r typedef amask_no_clip_u8<4, 1> amask_no_clip_bgra32g; //----amask_no_clip_bgra32g typedef amask_no_clip_u8<4, 0> amask_no_clip_bgra32b; //----amask_no_clip_bgra32b typedef amask_no_clip_u8<4, 3> amask_no_clip_bgra32a; //----amask_no_clip_bgra32a typedef amask_no_clip_u8<4, 3> amask_no_clip_abgr32r; //----amask_no_clip_abgr32r typedef amask_no_clip_u8<4, 2> amask_no_clip_abgr32g; //----amask_no_clip_abgr32g typedef amask_no_clip_u8<4, 1> amask_no_clip_abgr32b; //----amask_no_clip_abgr32b typedef amask_no_clip_u8<4, 0> amask_no_clip_abgr32a; //----amask_no_clip_abgr32a typedef amask_no_clip_u8<3, 0, rgb_to_gray_mask_u8<0, 1, 2> > amask_no_clip_rgb24gray; //----amask_no_clip_rgb24gray typedef amask_no_clip_u8<3, 0, rgb_to_gray_mask_u8<2, 1, 0> > amask_no_clip_bgr24gray; //----amask_no_clip_bgr24gray typedef amask_no_clip_u8<4, 0, rgb_to_gray_mask_u8<0, 1, 2> > amask_no_clip_rgba32gray; //----amask_no_clip_rgba32gray typedef amask_no_clip_u8<4, 1, rgb_to_gray_mask_u8<0, 1, 2> > amask_no_clip_argb32gray; //----amask_no_clip_argb32gray typedef amask_no_clip_u8<4, 0, rgb_to_gray_mask_u8<2, 1, 0> > amask_no_clip_bgra32gray; //----amask_no_clip_bgra32gray typedef amask_no_clip_u8<4, 1, rgb_to_gray_mask_u8<2, 1, 0> > amask_no_clip_abgr32gray; //----amask_no_clip_abgr32gray } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_segmentator.h0000644000175000017500000000336212516137326025344 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_CONV_SEGMENTATOR_INCLUDED #define AGG_CONV_SEGMENTATOR_INCLUDED #include "agg_basics.h" #include "agg_conv_adaptor_vpgen.h" #include "agg_vpgen_segmentator.h" namespace agg24 { //========================================================conv_segmentator template struct conv_segmentator : public conv_adaptor_vpgen { typedef conv_adaptor_vpgen base_type; conv_segmentator(VertexSource& vs) : conv_adaptor_vpgen(vs) {} void approximation_scale(double s) { base_type::vpgen().approximation_scale(s); } double approximation_scale() const { return base_type::vpgen().approximation_scale(); } private: conv_segmentator(const conv_segmentator&); const conv_segmentator& operator = (const conv_segmentator&); }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_pattern_filters_rgba.h0000644000175000017500000001022712516137326026165 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_PATTERN_FILTERS_RGBA8_INCLUDED #define AGG_PATTERN_FILTERS_RGBA8_INCLUDED #include "agg_basics.h" #include "agg_line_aa_basics.h" #include "agg_color_rgba.h" namespace agg24 { //=======================================================pattern_filter_nn template struct pattern_filter_nn { typedef ColorT color_type; static unsigned dilation() { return 0; } static void AGG_INLINE pixel_low_res(color_type const* const* buf, color_type* p, int x, int y) { *p = buf[y][x]; } static void AGG_INLINE pixel_high_res(color_type const* const* buf, color_type* p, int x, int y) { *p = buf[y >> line_subpixel_shift] [x >> line_subpixel_shift]; } }; typedef pattern_filter_nn pattern_filter_nn_rgba8; typedef pattern_filter_nn pattern_filter_nn_rgba16; //===========================================pattern_filter_bilinear_rgba template struct pattern_filter_bilinear_rgba { typedef ColorT color_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; static unsigned dilation() { return 1; } static AGG_INLINE void pixel_low_res(color_type const* const* buf, color_type* p, int x, int y) { *p = buf[y][x]; } static AGG_INLINE void pixel_high_res(color_type const* const* buf, color_type* p, int x, int y) { calc_type r, g, b, a; r = g = b = a = line_subpixel_scale * line_subpixel_scale / 2; calc_type weight; int x_lr = x >> line_subpixel_shift; int y_lr = y >> line_subpixel_shift; x &= line_subpixel_mask; y &= line_subpixel_mask; const color_type* ptr = buf[y_lr] + x_lr; weight = (line_subpixel_scale - x) * (line_subpixel_scale - y); r += weight * ptr->r; g += weight * ptr->g; b += weight * ptr->b; a += weight * ptr->a; ++ptr; weight = x * (line_subpixel_scale - y); r += weight * ptr->r; g += weight * ptr->g; b += weight * ptr->b; a += weight * ptr->a; ptr = buf[y_lr + 1] + x_lr; weight = (line_subpixel_scale - x) * y; r += weight * ptr->r; g += weight * ptr->g; b += weight * ptr->b; a += weight * ptr->a; ++ptr; weight = x * y; r += weight * ptr->r; g += weight * ptr->g; b += weight * ptr->b; a += weight * ptr->a; p->r = (value_type)(r >> line_subpixel_shift * 2); p->g = (value_type)(g >> line_subpixel_shift * 2); p->b = (value_type)(b >> line_subpixel_shift * 2); p->a = (value_type)(a >> line_subpixel_shift * 2); } }; typedef pattern_filter_bilinear_rgba pattern_filter_bilinear_rgba8; typedef pattern_filter_bilinear_rgba pattern_filter_bilinear_rgba16; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_image_filter_gray.h0000644000175000017500000007364712516137326026476 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for high precision colors has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_SPAN_IMAGE_FILTER_GRAY_INCLUDED #define AGG_SPAN_IMAGE_FILTER_GRAY_INCLUDED #include "agg_basics.h" #include "agg_color_gray.h" #include "agg_span_image_filter.h" namespace agg24 { //==============================================span_image_filter_gray_nn template class span_image_filter_gray_nn : public span_image_filter { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- span_image_filter_gray_nn() {} span_image_filter_gray_nn(source_type& src, interpolator_type& inter) : base_type(src, inter, 0) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); do { base_type::interpolator().coordinates(&x, &y); span->v = *(const value_type*) base_type::source().span(x >> image_subpixel_shift, y >> image_subpixel_shift, 1); span->a = base_mask; ++span; ++base_type::interpolator(); } while(--len); } }; //=========================================span_image_filter_gray_bilinear template class span_image_filter_gray_bilinear : public span_image_filter { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- span_image_filter_gray_bilinear() {} span_image_filter_gray_bilinear(source_type& src, interpolator_type& inter) : base_type(src, inter, 0) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); calc_type fg; const value_type *fg_ptr; do { int x_hr; int y_hr; base_type::interpolator().coordinates(&x_hr, &y_hr); x_hr -= base_type::filter_dx_int(); y_hr -= base_type::filter_dy_int(); int x_lr = x_hr >> image_subpixel_shift; int y_lr = y_hr >> image_subpixel_shift; fg = image_subpixel_scale * image_subpixel_scale / 2; x_hr &= image_subpixel_mask; y_hr &= image_subpixel_mask; fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); fg += *fg_ptr * (image_subpixel_scale - x_hr) * (image_subpixel_scale - y_hr); fg_ptr = (const value_type*)base_type::source().next_x(); fg += *fg_ptr * x_hr * (image_subpixel_scale - y_hr); fg_ptr = (const value_type*)base_type::source().next_y(); fg += *fg_ptr * (image_subpixel_scale - x_hr) * y_hr; fg_ptr = (const value_type*)base_type::source().next_x(); fg += *fg_ptr * x_hr * y_hr; span->v = value_type(fg >> (image_subpixel_shift * 2)); span->a = base_mask; ++span; ++base_type::interpolator(); } while(--len); } }; //====================================span_image_filter_gray_bilinear_clip template class span_image_filter_gray_bilinear_clip : public span_image_filter { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- span_image_filter_gray_bilinear_clip() {} span_image_filter_gray_bilinear_clip(source_type& src, const color_type& back_color, interpolator_type& inter) : base_type(src, inter, 0), m_back_color(back_color) {} const color_type& background_color() const { return m_back_color; } void background_color(const color_type& v) { m_back_color = v; } //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); calc_type fg; calc_type src_alpha; value_type back_v = m_back_color.v; value_type back_a = m_back_color.a; const value_type *fg_ptr; int maxx = base_type::source().width() - 1; int maxy = base_type::source().height() - 1; do { int x_hr; int y_hr; base_type::interpolator().coordinates(&x_hr, &y_hr); x_hr -= base_type::filter_dx_int(); y_hr -= base_type::filter_dy_int(); int x_lr = x_hr >> image_subpixel_shift; int y_lr = y_hr >> image_subpixel_shift; if(x_lr >= 0 && y_lr >= 0 && x_lr < maxx && y_lr < maxy) { fg = image_subpixel_scale * image_subpixel_scale / 2; x_hr &= image_subpixel_mask; y_hr &= image_subpixel_mask; fg_ptr = (const value_type*)base_type::source().row_ptr(y_lr) + x_lr; fg += *fg_ptr++ * (image_subpixel_scale - x_hr) * (image_subpixel_scale - y_hr); fg += *fg_ptr++ * (image_subpixel_scale - y_hr) * x_hr; ++y_lr; fg_ptr = (const value_type*)base_type::source().row_ptr(y_lr) + x_lr; fg += *fg_ptr++ * (image_subpixel_scale - x_hr) * y_hr; fg += *fg_ptr++ * x_hr * y_hr; fg >>= image_subpixel_shift * 2; src_alpha = base_mask; } else { unsigned weight; if(x_lr < -1 || y_lr < -1 || x_lr > maxx || y_lr > maxy) { fg = back_v; src_alpha = back_a; } else { fg = src_alpha = image_subpixel_scale * image_subpixel_scale / 2; x_hr &= image_subpixel_mask; y_hr &= image_subpixel_mask; weight = (image_subpixel_scale - x_hr) * (image_subpixel_scale - y_hr); if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) { fg += weight * *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr); src_alpha += weight * base_mask; } else { fg += back_v * weight; src_alpha += back_a * weight; } x_lr++; weight = x_hr * (image_subpixel_scale - y_hr); if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) { fg += weight * *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr); src_alpha += weight * base_mask; } else { fg += back_v * weight; src_alpha += back_a * weight; } x_lr--; y_lr++; weight = (image_subpixel_scale - x_hr) * y_hr; if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) { fg += weight * *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr); src_alpha += weight * base_mask; } else { fg += back_v * weight; src_alpha += back_a * weight; } x_lr++; weight = x_hr * y_hr; if(x_lr >= 0 && y_lr >= 0 && x_lr <= maxx && y_lr <= maxy) { fg += weight * *((const value_type*)base_type::source().row_ptr(y_lr) + x_lr); src_alpha += weight * base_mask; } else { fg += back_v * weight; src_alpha += back_a * weight; } fg >>= image_subpixel_shift * 2; src_alpha >>= image_subpixel_shift * 2; } } span->v = (value_type)fg; span->a = (value_type)src_alpha; ++span; ++base_type::interpolator(); } while(--len); } private: color_type m_back_color; }; //==============================================span_image_filter_gray_2x2 template class span_image_filter_gray_2x2 : public span_image_filter { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- span_image_filter_gray_2x2() {} span_image_filter_gray_2x2(source_type& src, interpolator_type& inter, const image_filter_lut& filter) : base_type(src, inter, &filter) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); calc_type fg; const value_type *fg_ptr; const int16* weight_array = base_type::filter().weight_array() + ((base_type::filter().diameter()/2 - 1) << image_subpixel_shift); do { int x_hr; int y_hr; base_type::interpolator().coordinates(&x_hr, &y_hr); x_hr -= base_type::filter_dx_int(); y_hr -= base_type::filter_dy_int(); int x_lr = x_hr >> image_subpixel_shift; int y_lr = y_hr >> image_subpixel_shift; unsigned weight; fg = image_filter_scale / 2; x_hr &= image_subpixel_mask; y_hr &= image_subpixel_mask; fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, 2); weight = (weight_array[x_hr + image_subpixel_scale] * weight_array[y_hr + image_subpixel_scale] + image_filter_scale / 2) >> image_filter_shift; fg += weight * *fg_ptr; fg_ptr = (const value_type*)base_type::source().next_x(); weight = (weight_array[x_hr] * weight_array[y_hr + image_subpixel_scale] + image_filter_scale / 2) >> image_filter_shift; fg += weight * *fg_ptr; fg_ptr = (const value_type*)base_type::source().next_y(); weight = (weight_array[x_hr + image_subpixel_scale] * weight_array[y_hr] + image_filter_scale / 2) >> image_filter_shift; fg += weight * *fg_ptr; fg_ptr = (const value_type*)base_type::source().next_x(); weight = (weight_array[x_hr] * weight_array[y_hr] + image_filter_scale / 2) >> image_filter_shift; fg += weight * *fg_ptr; fg >>= image_filter_shift; if(fg > base_mask) fg = base_mask; span->v = (value_type)fg; span->a = base_mask; ++span; ++base_type::interpolator(); } while(--len); } }; //==================================================span_image_filter_gray template class span_image_filter_gray : public span_image_filter { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef Interpolator interpolator_type; typedef span_image_filter base_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- span_image_filter_gray() {} span_image_filter_gray(source_type& src, interpolator_type& inter, const image_filter_lut& filter) : base_type(src, inter, &filter) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); int fg; const value_type *fg_ptr; unsigned diameter = base_type::filter().diameter(); int start = base_type::filter().start(); const int16* weight_array = base_type::filter().weight_array(); int x_count; int weight_y; do { base_type::interpolator().coordinates(&x, &y); x -= base_type::filter_dx_int(); y -= base_type::filter_dy_int(); int x_hr = x; int y_hr = y; int x_lr = x_hr >> image_subpixel_shift; int y_lr = y_hr >> image_subpixel_shift; fg = image_filter_scale / 2; int x_fract = x_hr & image_subpixel_mask; unsigned y_count = diameter; y_hr = image_subpixel_mask - (y_hr & image_subpixel_mask); fg_ptr = (const value_type*)base_type::source().span(x_lr + start, y_lr + start, diameter); for(;;) { x_count = diameter; weight_y = weight_array[y_hr]; x_hr = image_subpixel_mask - x_fract; for(;;) { fg += *fg_ptr * ((weight_y * weight_array[x_hr] + image_filter_scale / 2) >> image_filter_shift); if(--x_count == 0) break; x_hr += image_subpixel_scale; fg_ptr = (const value_type*)base_type::source().next_x(); } if(--y_count == 0) break; y_hr += image_subpixel_scale; fg_ptr = (const value_type*)base_type::source().next_y(); } fg >>= image_filter_shift; if(fg < 0) fg = 0; if(fg > base_mask) fg = base_mask; span->v = (value_type)fg; span->a = base_mask; ++span; ++base_type::interpolator(); } while(--len); } }; //=========================================span_image_resample_gray_affine template class span_image_resample_gray_affine : public span_image_resample_affine { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef span_image_resample_affine base_type; typedef typename base_type::interpolator_type interpolator_type; typedef typename color_type::value_type value_type; typedef typename color_type::long_type long_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask, downscale_shift = image_filter_shift }; //-------------------------------------------------------------------- span_image_resample_gray_affine() {} span_image_resample_gray_affine(source_type& src, interpolator_type& inter, const image_filter_lut& filter) : base_type(src, inter, filter) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); long_type fg; int diameter = base_type::filter().diameter(); int filter_scale = diameter << image_subpixel_shift; int radius_x = (diameter * base_type::m_rx) >> 1; int radius_y = (diameter * base_type::m_ry) >> 1; int len_x_lr = (diameter * base_type::m_rx + image_subpixel_mask) >> image_subpixel_shift; const int16* weight_array = base_type::filter().weight_array(); do { base_type::interpolator().coordinates(&x, &y); x += base_type::filter_dx_int() - radius_x; y += base_type::filter_dy_int() - radius_y; fg = image_filter_scale / 2; int y_lr = y >> image_subpixel_shift; int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * base_type::m_ry_inv) >> image_subpixel_shift; int total_weight = 0; int x_lr = x >> image_subpixel_shift; int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * base_type::m_rx_inv) >> image_subpixel_shift; int x_hr2 = x_hr; const value_type* fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); for(;;) { int weight_y = weight_array[y_hr]; x_hr = x_hr2; for(;;) { int weight = (weight_y * weight_array[x_hr] + image_filter_scale / 2) >> downscale_shift; fg += *fg_ptr * weight; total_weight += weight; x_hr += base_type::m_rx_inv; if(x_hr >= filter_scale) break; fg_ptr = (const value_type*)base_type::source().next_x(); } y_hr += base_type::m_ry_inv; if(y_hr >= filter_scale) break; fg_ptr = (const value_type*)base_type::source().next_y(); } fg /= total_weight; if(fg < 0) fg = 0; if(fg > base_mask) fg = base_mask; span->v = (value_type)fg; span->a = base_mask; ++span; ++base_type::interpolator(); } while(--len); } }; //================================================span_image_resample_gray template class span_image_resample_gray : public span_image_resample { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef Interpolator interpolator_type; typedef span_image_resample base_type; typedef typename color_type::value_type value_type; typedef typename color_type::long_type long_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask, downscale_shift = image_filter_shift }; //-------------------------------------------------------------------- span_image_resample_gray() {} span_image_resample_gray(source_type& src, interpolator_type& inter, const image_filter_lut& filter) : base_type(src, inter, filter) {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { base_type::interpolator().begin(x + base_type::filter_dx_dbl(), y + base_type::filter_dy_dbl(), len); long_type fg; int diameter = base_type::filter().diameter(); int filter_scale = diameter << image_subpixel_shift; const int16* weight_array = base_type::filter().weight_array(); do { int rx; int ry; int rx_inv = image_subpixel_scale; int ry_inv = image_subpixel_scale; base_type::interpolator().coordinates(&x, &y); base_type::interpolator().local_scale(&rx, &ry); rx = (rx * base_type::m_blur_x) >> image_subpixel_shift; ry = (ry * base_type::m_blur_y) >> image_subpixel_shift; if(rx < image_subpixel_scale) { rx = image_subpixel_scale; } else { if(rx > image_subpixel_scale * base_type::m_scale_limit) { rx = image_subpixel_scale * base_type::m_scale_limit; } rx_inv = image_subpixel_scale * image_subpixel_scale / rx; } if(ry < image_subpixel_scale) { ry = image_subpixel_scale; } else { if(ry > image_subpixel_scale * base_type::m_scale_limit) { ry = image_subpixel_scale * base_type::m_scale_limit; } ry_inv = image_subpixel_scale * image_subpixel_scale / ry; } int radius_x = (diameter * rx) >> 1; int radius_y = (diameter * ry) >> 1; int len_x_lr = (diameter * rx + image_subpixel_mask) >> image_subpixel_shift; x += base_type::filter_dx_int() - radius_x; y += base_type::filter_dy_int() - radius_y; fg = image_filter_scale / 2; int y_lr = y >> image_subpixel_shift; int y_hr = ((image_subpixel_mask - (y & image_subpixel_mask)) * ry_inv) >> image_subpixel_shift; int total_weight = 0; int x_lr = x >> image_subpixel_shift; int x_hr = ((image_subpixel_mask - (x & image_subpixel_mask)) * rx_inv) >> image_subpixel_shift; int x_hr2 = x_hr; const value_type* fg_ptr = (const value_type*)base_type::source().span(x_lr, y_lr, len_x_lr); for(;;) { int weight_y = weight_array[y_hr]; x_hr = x_hr2; for(;;) { int weight = (weight_y * weight_array[x_hr] + image_filter_scale / 2) >> downscale_shift; fg += *fg_ptr * weight; total_weight += weight; x_hr += rx_inv; if(x_hr >= filter_scale) break; fg_ptr = (const value_type*)base_type::source().next_x(); } y_hr += ry_inv; if(y_hr >= filter_scale) break; fg_ptr = (const value_type*)base_type::source().next_y(); } fg /= total_weight; if(fg < 0) fg = 0; if(fg > base_mask) fg = base_mask; span->v = (value_type)fg; span->a = base_mask; ++span; ++base_type::interpolator(); } while(--len); } }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_interpolator_trans.h0000644000175000017500000000620612516137326026741 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Horizontal span interpolator for use with an arbitrary transformer // The efficiency highly depends on the operations done in the transformer // //---------------------------------------------------------------------------- #ifndef AGG_SPAN_INTERPOLATOR_TRANS_INCLUDED #define AGG_SPAN_INTERPOLATOR_TRANS_INCLUDED #include "agg_basics.h" namespace agg24 { //=================================================span_interpolator_trans template class span_interpolator_trans { public: typedef Transformer trans_type; enum subpixel_scale_e { subpixel_shift = SubpixelShift, subpixel_scale = 1 << subpixel_shift }; //-------------------------------------------------------------------- span_interpolator_trans() {} span_interpolator_trans(const trans_type& trans) : m_trans(&trans) {} span_interpolator_trans(const trans_type& trans, double x, double y, unsigned) : m_trans(&trans) { begin(x, y, 0); } //---------------------------------------------------------------- const trans_type& transformer() const { return *m_trans; } void transformer(const trans_type& trans) { m_trans = &trans; } //---------------------------------------------------------------- void begin(double x, double y, unsigned) { m_x = x; m_y = y; m_trans->transform(&x, &y); m_ix = iround(x * subpixel_scale); m_iy = iround(y * subpixel_scale); } //---------------------------------------------------------------- void operator++() { m_x += 1.0; double x = m_x; double y = m_y; m_trans->transform(&x, &y); m_ix = iround(x * subpixel_scale); m_iy = iround(y * subpixel_scale); } //---------------------------------------------------------------- void coordinates(int* x, int* y) const { *x = m_ix; *y = m_iy; } private: const trans_type* m_trans; double m_x; double m_y; int m_ix; int m_iy; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/Makefile.am0000644000175000017500000000705312516137326023035 0ustar varunvarunSUBDIRS = ctrl util platform aggincludedir = $(includedir)/agg2 agginclude_HEADERS = \ agg_alpha_mask_u8.h agg_glyph_raster_bin.h agg_span_allocator.h \ agg_arc.h agg_gsv_text.h agg_span_converter.h \ agg_array.h agg_image_accessors.h agg_span_gouraud.h \ agg_arrowhead.h agg_image_filters.h agg_span_gouraud_gray.h \ agg_basics.h agg_line_aa_basics.h agg_span_gouraud_rgba.h \ agg_bezier_arc.h agg_math.h agg_span_gradient.h \ agg_bitset_iterator.h agg_math_stroke.h agg_span_gradient_alpha.h \ agg_bounding_rect.h agg_path_length.h agg_span_image_filter.h \ agg_bspline.h agg_path_storage.h agg_span_image_filter_gray.h \ agg_clip_liang_barsky.h agg_path_storage_integer.h agg_span_image_filter_rgb.h \ agg_color_gray.h agg_pattern_filters_rgba.h agg_span_image_filter_rgba.h \ agg_color_rgba.h agg_pixfmt_amask_adaptor.h agg_span_interpolator_adaptor.h \ agg_config.h agg_pixfmt_gray.h agg_span_interpolator_linear.h \ agg_conv_adaptor_vcgen.h agg_pixfmt_rgb.h agg_span_interpolator_persp.h \ agg_conv_adaptor_vpgen.h agg_pixfmt_rgb_packed.h agg_span_interpolator_trans.h \ agg_conv_bspline.h agg_pixfmt_rgba.h agg_span_pattern_gray.h \ agg_conv_clip_polygon.h agg_rasterizer_cells_aa.h agg_span_pattern_rgb.h \ agg_conv_clip_polyline.h agg_rasterizer_compound_aa.h agg_span_pattern_rgba.h \ agg_conv_close_polygon.h agg_rasterizer_outline.h agg_span_solid.h \ agg_conv_concat.h agg_rasterizer_outline_aa.h agg_span_subdiv_adaptor.h \ agg_conv_contour.h agg_rasterizer_scanline_aa.h agg_trans_affine.h \ agg_conv_curve.h agg_rasterizer_sl_clip.h agg_trans_bilinear.h \ agg_conv_dash.h agg_renderer_base.h agg_trans_double_path.h \ agg_renderer_markers.h agg_trans_lens.h \ agg_conv_marker.h agg_renderer_mclip.h agg_trans_perspective.h \ agg_conv_marker_adaptor.h agg_renderer_outline_aa.h agg_trans_single_path.h \ agg_conv_segmentator.h agg_renderer_outline_image.h agg_trans_viewport.h \ agg_conv_shorten_path.h agg_renderer_primitives.h agg_trans_warp_magnifier.h \ agg_conv_smooth_poly1.h agg_renderer_raster_text.h agg_vcgen_bspline.h \ agg_conv_stroke.h agg_renderer_scanline.h agg_vcgen_contour.h \ agg_conv_transform.h agg_rendering_buffer.h agg_vcgen_dash.h \ agg_conv_unclose_polygon.h agg_rendering_buffer_dynarow.h agg_vcgen_markers_term.h \ agg_curves.h agg_rounded_rect.h agg_vcgen_smooth_poly1.h \ agg_scanline_bin.h agg_vcgen_stroke.h \ agg_dda_line.h agg_scanline_boolean_algebra.h agg_vcgen_vertex_sequence.h \ agg_ellipse.h agg_scanline_p.h agg_vertex_sequence.h \ agg_ellipse_bresenham.h agg_scanline_storage_aa.h agg_vpgen_clip_polygon.h \ agg_embedded_raster_fonts.h agg_scanline_storage_bin.h agg_vpgen_clip_polyline.h \ agg_font_cache_manager.h agg_scanline_u.h agg_vpgen_segmentator.h \ agg_gamma_functions.h agg_shorten_path.h \ agg_gamma_lut.h agg_simul_eq.h enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_clip_liang_barsky.h0000644000175000017500000002335112516137326025443 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Liang-Barsky clipping // //---------------------------------------------------------------------------- #ifndef AGG_CLIP_LIANG_BARSKY_INCLUDED #define AGG_CLIP_LIANG_BARSKY_INCLUDED #include "agg_basics.h" namespace agg24 { //------------------------------------------------------------------------ enum clipping_flags_e { clipping_flags_x1_clipped = 4, clipping_flags_x2_clipped = 1, clipping_flags_y1_clipped = 8, clipping_flags_y2_clipped = 2, clipping_flags_x_clipped = clipping_flags_x1_clipped | clipping_flags_x2_clipped, clipping_flags_y_clipped = clipping_flags_y1_clipped | clipping_flags_y2_clipped }; //----------------------------------------------------------clipping_flags // Determine the clipping code of the vertex according to the // Cyrus-Beck line clipping algorithm // // | | // 0110 | 0010 | 0011 // | | // -------+--------+-------- clip_box.y2 // | | // 0100 | 0000 | 0001 // | | // -------+--------+-------- clip_box.y1 // | | // 1100 | 1000 | 1001 // | | // clip_box.x1 clip_box.x2 // // template inline unsigned clipping_flags(T x, T y, const rect_base& clip_box) { return (x > clip_box.x2) | ((y > clip_box.y2) << 1) | ((x < clip_box.x1) << 2) | ((y < clip_box.y1) << 3); } //--------------------------------------------------------clipping_flags_x template inline unsigned clipping_flags_x(T x, const rect_base& clip_box) { return (x > clip_box.x2) | ((x < clip_box.x1) << 2); } //--------------------------------------------------------clipping_flags_y template inline unsigned clipping_flags_y(T y, const rect_base& clip_box) { return ((y > clip_box.y2) << 1) | ((y < clip_box.y1) << 3); } //-------------------------------------------------------clip_liang_barsky template inline unsigned clip_liang_barsky(T x1, T y1, T x2, T y2, const rect_base& clip_box, T* x, T* y) { const double nearzero = 1e-30; double deltax = x2 - x1; double deltay = y2 - y1; double xin; double xout; double yin; double yout; double tinx; double tiny; double toutx; double touty; double tin1; double tin2; double tout1; unsigned np = 0; if(deltax == 0.0) { // bump off of the vertical deltax = (x1 > clip_box.x1) ? -nearzero : nearzero; } if(deltay == 0.0) { // bump off of the horizontal deltay = (y1 > clip_box.y1) ? -nearzero : nearzero; } if(deltax > 0.0) { // points to right xin = clip_box.x1; xout = clip_box.x2; } else { xin = clip_box.x2; xout = clip_box.x1; } if(deltay > 0.0) { // points up yin = clip_box.y1; yout = clip_box.y2; } else { yin = clip_box.y2; yout = clip_box.y1; } tinx = (xin - x1) / deltax; tiny = (yin - y1) / deltay; if (tinx < tiny) { // hits x first tin1 = tinx; tin2 = tiny; } else { // hits y first tin1 = tiny; tin2 = tinx; } if(tin1 <= 1.0) { if(0.0 < tin1) { *x++ = (T)xin; *y++ = (T)yin; ++np; } if(tin2 <= 1.0) { toutx = (xout - x1) / deltax; touty = (yout - y1) / deltay; tout1 = (toutx < touty) ? toutx : touty; if(tin2 > 0.0 || tout1 > 0.0) { if(tin2 <= tout1) { if(tin2 > 0.0) { if(tinx > tiny) { *x++ = (T)xin; *y++ = (T)(y1 + tinx * deltay); } else { *x++ = (T)(x1 + tiny * deltax); *y++ = (T)yin; } ++np; } if(tout1 < 1.0) { if(toutx < touty) { *x++ = (T)xout; *y++ = (T)(y1 + toutx * deltay); } else { *x++ = (T)(x1 + touty * deltax); *y++ = (T)yout; } } else { *x++ = x2; *y++ = y2; } ++np; } else { if(tinx > tiny) { *x++ = (T)xin; *y++ = (T)yout; } else { *x++ = (T)xout; *y++ = (T)yin; } ++np; } } } } return np; } //---------------------------------------------------------------------------- template bool clip_move_point(T x1, T y1, T x2, T y2, const rect_base& clip_box, T* x, T* y, unsigned flags) { T bound; if(flags & clipping_flags_x_clipped) { if(x1 == x2) { return false; } bound = (flags & clipping_flags_x1_clipped) ? clip_box.x1 : clip_box.x2; *y = (T)(double(bound - x1) * (y2 - y1) / (x2 - x1) + y1); *x = bound; } flags = clipping_flags_y(*y, clip_box); if(flags & clipping_flags_y_clipped) { if(y1 == y2) { return false; } bound = (flags & clipping_flags_y1_clipped) ? clip_box.y1 : clip_box.y2; *x = (T)(double(bound - y1) * (x2 - x1) / (y2 - y1) + x1); *y = bound; } return true; } //-------------------------------------------------------clip_line_segment // Returns: ret >= 4 - Fully clipped // (ret & 1) != 0 - First point has been moved // (ret & 2) != 0 - Second point has been moved // template unsigned clip_line_segment(T* x1, T* y1, T* x2, T* y2, const rect_base& clip_box) { unsigned f1 = clipping_flags(*x1, *y1, clip_box); unsigned f2 = clipping_flags(*x2, *y2, clip_box); unsigned ret = 0; if((f2 | f1) == 0) { // Fully visible return 0; } if((f1 & clipping_flags_x_clipped) != 0 && (f1 & clipping_flags_x_clipped) == (f2 & clipping_flags_x_clipped)) { // Fully clipped return 4; } if((f1 & clipping_flags_y_clipped) != 0 && (f1 & clipping_flags_y_clipped) == (f2 & clipping_flags_y_clipped)) { // Fully clipped return 4; } T tx1 = *x1; T ty1 = *y1; T tx2 = *x2; T ty2 = *y2; if(f1) { if(!clip_move_point(tx1, ty1, tx2, ty2, clip_box, x1, y1, f1)) { return 4; } if(*x1 == *x2 && *y1 == *y2) { return 4; } ret |= 1; } if(f2) { if(!clip_move_point(tx1, ty1, tx2, ty2, clip_box, x2, y2, f2)) { return 4; } if(*x1 == *x2 && *y1 == *y2) { return 4; } ret |= 2; } return ret; } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_rendering_buffer.h0000644000175000017500000001257612516137326025304 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class rendering_buffer // //---------------------------------------------------------------------------- #ifndef AGG_RENDERING_BUFFER_INCLUDED #define AGG_RENDERING_BUFFER_INCLUDED #include "agg_array.h" namespace agg24 { //==========================================================row_ptr_cache template class row_ptr_cache { public: //-------------------------------------------------------------------- struct row_data { int x1, x2; const int8u* ptr; row_data() {} row_data(int x1_, int x2_, const int8u* ptr_) : x1(x1_), x2(x2_), ptr(ptr_) {} }; //------------------------------------------------------------------- row_ptr_cache() : m_buf(0), m_rows(), m_width(0), m_height(0), m_stride(0) { } //-------------------------------------------------------------------- row_ptr_cache(T* buf, unsigned width, unsigned height, int stride) : m_buf(0), m_rows(), m_width(0), m_height(0), m_stride(0) { attach(buf, width, height, stride); } //-------------------------------------------------------------------- void attach(T* buf, unsigned width, unsigned height, int stride) { m_buf = buf; m_width = width; m_height = height; m_stride = stride; if(height > m_rows.size()) { m_rows.resize(height); } T* row_ptr = m_buf; if(stride < 0) { row_ptr = m_buf - int(height - 1) * (stride); } T** rows = &m_rows[0]; while(height--) { *rows++ = row_ptr; row_ptr += stride; } } //-------------------------------------------------------------------- T* buf() { return m_buf; } const T* buf() const { return m_buf; } unsigned width() const { return m_width; } unsigned height() const { return m_height; } int stride() const { return m_stride; } unsigned stride_abs() const { return (m_stride < 0) ? unsigned(-m_stride) : unsigned(m_stride); } //-------------------------------------------------------------------- T* row_ptr(int, int y, unsigned) { return m_rows[y]; } T* row_ptr(int y) { return m_rows[y]; } const T* row_ptr(int y) const { return m_rows[y]; } row_data row (int y) const { return row_data(0, m_width-1, m_rows[y]); } //-------------------------------------------------------------------- T const* const* rows() const { return &m_rows[0]; } //-------------------------------------------------------------------- template void copy_from(const RenBuf& src) { unsigned h = height(); if(src.height() < h) h = src.height(); unsigned l = stride_abs(); if(src.stride_abs() < l) l = src.stride_abs(); l *= sizeof(T); unsigned y; unsigned w = width(); for (y = 0; y < h; y++) { memcpy(row_ptr(0, y, w), src.row_ptr(y), l); } } //-------------------------------------------------------------------- void clear(T value) { unsigned y; unsigned w = width(); unsigned stride = stride_abs(); for(y = 0; y < height(); y++) { T* p = row_ptr(0, y, w); unsigned x; for(x = 0; x < stride; x++) { *p++ = value; } } } private: //-------------------------------------------------------------------- T* m_buf; // Pointer to renrdering buffer pod_array m_rows; // Pointers to each row of the buffer unsigned m_width; // Width in pixels unsigned m_height; // Height in pixels int m_stride; // Number of bytes per row. Can be < 0 }; //========================================================rendering_buffer typedef row_ptr_cache rendering_buffer; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_trans_perspective.h0000644000175000017500000001475412516137326025536 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Perspective 2D transformations // //---------------------------------------------------------------------------- #ifndef AGG_TRANS_PERSPECTIVE_INCLUDED #define AGG_TRANS_PERSPECTIVE_INCLUDED #include "agg_basics.h" #include "agg_simul_eq.h" namespace agg24 { //=======================================================trans_perspective class trans_perspective { public: //-------------------------------------------------------------------- trans_perspective() : m_valid(false) {} //-------------------------------------------------------------------- // Arbitrary quadrangle transformations trans_perspective(const double* src, const double* dst) { quad_to_quad(src, dst); } //-------------------------------------------------------------------- // Direct transformations trans_perspective(double x1, double y1, double x2, double y2, const double* quad) { rect_to_quad(x1, y1, x2, y2, quad); } //-------------------------------------------------------------------- // Reverse transformations trans_perspective(const double* quad, double x1, double y1, double x2, double y2) { quad_to_rect(quad, x1, y1, x2, y2); } //-------------------------------------------------------------------- // Set the transformations using two arbitrary quadrangles. void quad_to_quad(const double* src, const double* dst) { double left[8][8]; double right[8][1]; unsigned i; for (i = 0; i < 4; i++) { unsigned ix = i * 2; unsigned iy = ix + 1; left[ix][0] = 1.0; left[ix][1] = src[ix]; left[ix][2] = src[iy]; left[ix][3] = 0.0; left[ix][4] = 0.0; left[ix][5] = 0.0; left[ix][6] = -src[ix] * dst[ix]; left[ix][7] = -src[iy] * dst[ix]; right[ix][0] = dst[ix]; left[iy][0] = 0.0; left[iy][1] = 0.0; left[iy][2] = 0.0; left[iy][3] = 1.0; left[iy][4] = src[ix]; left[iy][5] = src[iy]; left[iy][6] = -src[ix] * dst[iy]; left[iy][7] = -src[iy] * dst[iy]; right[iy][0] = dst[iy]; } m_valid = simul_eq<8, 1>::solve(left, right, m_mtx); } //-------------------------------------------------------------------- // Set the direct transformations, i.e., rectangle -> quadrangle void rect_to_quad(double x1, double y1, double x2, double y2, const double* quad) { double src[8]; src[0] = src[6] = x1; src[2] = src[4] = x2; src[1] = src[3] = y1; src[5] = src[7] = y2; quad_to_quad(src, quad); } //-------------------------------------------------------------------- // Set the reverse transformations, i.e., quadrangle -> rectangle void quad_to_rect(const double* quad, double x1, double y1, double x2, double y2) { double dst[8]; dst[0] = dst[6] = x1; dst[2] = dst[4] = x2; dst[1] = dst[3] = y1; dst[5] = dst[7] = y2; quad_to_quad(quad, dst); } //-------------------------------------------------------------------- // Check if the equations were solved successfully bool is_valid() const { return m_valid; } //-------------------------------------------------------------------- // Transform a point (x, y) void transform(double* x, double* y) const { double tx = *x; double ty = *y; double d = 1.0 / (m_mtx[6][0] * tx + m_mtx[7][0] * ty + 1.0); *x = (m_mtx[0][0] + m_mtx[1][0] * tx + m_mtx[2][0] * ty) * d; *y = (m_mtx[3][0] + m_mtx[4][0] * tx + m_mtx[5][0] * ty) * d; } //-------------------------------------------------------------------- class iterator_x { double den; double den_step; double nom_x; double nom_x_step; double nom_y; double nom_y_step; public: double x; double y; iterator_x() {} iterator_x(double tx, double ty, double step, const double m[8][1]) : den(m[6][0] * tx + m[7][0] * ty + 1.0), den_step(m[6][0] * step), nom_x(m[0][0] + m[1][0] * tx + m[2][0] * ty), nom_x_step(m[1][0] * step), nom_y(m[3][0] + m[4][0] * tx + m[5][0] * ty), nom_y_step(m[4][0] * step), x(nom_x / den), y(nom_y / den) { } void operator ++ () { den += den_step; nom_x += nom_x_step; nom_y += nom_y_step; double d = 1.0 / den; x = nom_x * d; y = nom_y * d; } }; //-------------------------------------------------------------------- iterator_x begin(double x, double y, double step) const { return iterator_x(x, y, step, m_mtx); } private: double m_mtx[8][1]; bool m_valid; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_renderer_mclip.h0000644000175000017500000002753112516137326024765 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class renderer_mclip // //---------------------------------------------------------------------------- #ifndef AGG_RENDERER_MCLIP_INCLUDED #define AGG_RENDERER_MCLIP_INCLUDED #include "agg_basics.h" #include "agg_array.h" #include "agg_renderer_base.h" namespace agg24 { //----------------------------------------------------------renderer_mclip template class renderer_mclip { public: typedef PixelFormat pixfmt_type; typedef typename pixfmt_type::color_type color_type; typedef typename pixfmt_type::row_data row_data; typedef renderer_base base_ren_type; //-------------------------------------------------------------------- renderer_mclip(pixfmt_type& pixf) : m_ren(pixf), m_curr_cb(0), m_bounds(m_ren.xmin(), m_ren.ymin(), m_ren.xmax(), m_ren.ymax()) {} void attach(pixfmt_type& pixf) { m_ren.attach(pixf); reset_clipping(true); } //-------------------------------------------------------------------- const pixfmt_type& ren() const { return m_ren.ren(); } pixfmt_type& ren() { return m_ren.ren(); } //-------------------------------------------------------------------- unsigned width() const { return m_ren.width(); } unsigned height() const { return m_ren.height(); } //-------------------------------------------------------------------- const rect_i& clip_box() const { return m_ren.clip_box(); } int xmin() const { return m_ren.xmin(); } int ymin() const { return m_ren.ymin(); } int xmax() const { return m_ren.xmax(); } int ymax() const { return m_ren.ymax(); } //-------------------------------------------------------------------- const rect_i& bounding_clip_box() const { return m_bounds; } int bounding_xmin() const { return m_bounds.x1; } int bounding_ymin() const { return m_bounds.y1; } int bounding_xmax() const { return m_bounds.x2; } int bounding_ymax() const { return m_bounds.y2; } //-------------------------------------------------------------------- void first_clip_box() { m_curr_cb = 0; if(m_clip.size()) { const rect_i& cb = m_clip[0]; m_ren.clip_box_naked(cb.x1, cb.y1, cb.x2, cb.y2); } } //-------------------------------------------------------------------- bool next_clip_box() { if(++m_curr_cb < m_clip.size()) { const rect_i& cb = m_clip[m_curr_cb]; m_ren.clip_box_naked(cb.x1, cb.y1, cb.x2, cb.y2); return true; } return false; } //-------------------------------------------------------------------- void reset_clipping(bool visibility) { m_ren.reset_clipping(visibility); m_clip.remove_all(); m_curr_cb = 0; m_bounds = m_ren.clip_box(); } //-------------------------------------------------------------------- void add_clip_box(int x1, int y1, int x2, int y2) { rect_i cb(x1, y1, x2, y2); cb.normalize(); if(cb.clip(rect_i(0, 0, width() - 1, height() - 1))) { m_clip.add(cb); if(cb.x1 < m_bounds.x1) m_bounds.x1 = cb.x1; if(cb.y1 < m_bounds.y1) m_bounds.y1 = cb.y1; if(cb.x2 > m_bounds.x2) m_bounds.x2 = cb.x2; if(cb.y2 > m_bounds.y2) m_bounds.y2 = cb.y2; } } //-------------------------------------------------------------------- void clear(const color_type& c) { m_ren.clear(c); } //-------------------------------------------------------------------- void copy_pixel(int x, int y, const color_type& c) { first_clip_box(); do { if(m_ren.inbox(x, y)) { m_ren.ren().copy_pixel(x, y, c); break; } } while(next_clip_box()); } //-------------------------------------------------------------------- void blend_pixel(int x, int y, const color_type& c, cover_type cover) { first_clip_box(); do { if(m_ren.inbox(x, y)) { m_ren.ren().blend_pixel(x, y, c, cover); break; } } while(next_clip_box()); } //-------------------------------------------------------------------- color_type pixel(int x, int y) const { first_clip_box(); do { if(m_ren.inbox(x, y)) { return m_ren.ren().pixel(x, y); } } while(next_clip_box()); return color_type::no_color(); } //-------------------------------------------------------------------- void copy_hline(int x1, int y, int x2, const color_type& c) { first_clip_box(); do { m_ren.copy_hline(x1, y, x2, c); } while(next_clip_box()); } //-------------------------------------------------------------------- void copy_vline(int x, int y1, int y2, const color_type& c) { first_clip_box(); do { m_ren.copy_vline(x, y1, y2, c); } while(next_clip_box()); } //-------------------------------------------------------------------- void blend_hline(int x1, int y, int x2, const color_type& c, cover_type cover) { first_clip_box(); do { m_ren.blend_hline(x1, y, x2, c, cover); } while(next_clip_box()); } //-------------------------------------------------------------------- void blend_vline(int x, int y1, int y2, const color_type& c, cover_type cover) { first_clip_box(); do { m_ren.blend_vline(x, y1, y2, c, cover); } while(next_clip_box()); } //-------------------------------------------------------------------- void copy_bar(int x1, int y1, int x2, int y2, const color_type& c) { first_clip_box(); do { m_ren.copy_bar(x1, y1, x2, y2, c); } while(next_clip_box()); } //-------------------------------------------------------------------- void blend_bar(int x1, int y1, int x2, int y2, const color_type& c, cover_type cover) { first_clip_box(); do { m_ren.blend_bar(x1, y1, x2, y2, c, cover); } while(next_clip_box()); } //-------------------------------------------------------------------- void blend_solid_hspan(int x, int y, int len, const color_type& c, const cover_type* covers) { first_clip_box(); do { m_ren.blend_solid_hspan(x, y, len, c, covers); } while(next_clip_box()); } //-------------------------------------------------------------------- void blend_solid_vspan(int x, int y, int len, const color_type& c, const cover_type* covers) { first_clip_box(); do { m_ren.blend_solid_vspan(x, y, len, c, covers); } while(next_clip_box()); } //-------------------------------------------------------------------- void copy_color_hspan(int x, int y, int len, const color_type* colors) { first_clip_box(); do { m_ren.copy_color_hspan(x, y, len, colors); } while(next_clip_box()); } //-------------------------------------------------------------------- void blend_color_hspan(int x, int y, int len, const color_type* colors, const cover_type* covers, cover_type cover = cover_full) { first_clip_box(); do { m_ren.blend_color_hspan(x, y, len, colors, covers, cover); } while(next_clip_box()); } //-------------------------------------------------------------------- void blend_color_vspan(int x, int y, int len, const color_type* colors, const cover_type* covers, cover_type cover = cover_full) { first_clip_box(); do { m_ren.blend_color_vspan(x, y, len, colors, covers, cover); } while(next_clip_box()); } //-------------------------------------------------------------------- void copy_from(const rendering_buffer& from, const rect_i* rc=0, int x_to=0, int y_to=0) { first_clip_box(); do { m_ren.copy_from(from, rc, x_to, y_to); } while(next_clip_box()); } //-------------------------------------------------------------------- template void blend_from(const SrcPixelFormatRenderer& src, const rect_i* rect_src_ptr = 0, int dx = 0, int dy = 0, cover_type cover = cover_full) { first_clip_box(); do { m_ren.blend_from(src, rect_src_ptr, dx, dy, cover); } while(next_clip_box()); } private: renderer_mclip(const renderer_mclip&); const renderer_mclip& operator = (const renderer_mclip&); base_ren_type m_ren; pod_bvector m_clip; unsigned m_curr_cb; rect_i m_bounds; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_dda_line.h0000644000175000017500000002104612516137326023525 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes dda_line_interpolator, dda2_line_interpolator // //---------------------------------------------------------------------------- #ifndef AGG_DDA_LINE_INCLUDED #define AGG_DDA_LINE_INCLUDED #include #include "agg_basics.h" namespace agg24 { //===================================================dda_line_interpolator template class dda_line_interpolator { public: //-------------------------------------------------------------------- dda_line_interpolator() {} //-------------------------------------------------------------------- dda_line_interpolator(int y1, int y2, unsigned count) : m_y(y1), m_inc(((y2 - y1) << FractionShift) / int(count)), m_dy(0) { } //-------------------------------------------------------------------- void operator ++ () { m_dy += m_inc; } //-------------------------------------------------------------------- void operator -- () { m_dy -= m_inc; } //-------------------------------------------------------------------- void operator += (unsigned n) { m_dy += m_inc * n; } //-------------------------------------------------------------------- void operator -= (unsigned n) { m_dy -= m_inc * n; } //-------------------------------------------------------------------- int y() const { return m_y + (m_dy >> (FractionShift-YShift)); } int dy() const { return m_dy; } private: int m_y; int m_inc; int m_dy; }; //=================================================dda2_line_interpolator class dda2_line_interpolator { public: typedef int save_data_type; enum save_size_e { save_size = 2 }; //-------------------------------------------------------------------- dda2_line_interpolator() {} //-------------------------------------------- Forward-adjusted line dda2_line_interpolator(int y1, int y2, int count) : m_cnt(count <= 0 ? 1 : count), m_lft((y2 - y1) / m_cnt), m_rem((y2 - y1) % m_cnt), m_mod(m_rem), m_y(y1) { if(m_mod <= 0) { m_mod += count; m_rem += count; m_lft--; } m_mod -= count; } //-------------------------------------------- Backward-adjusted line dda2_line_interpolator(int y1, int y2, int count, int) : m_cnt(count <= 0 ? 1 : count), m_lft((y2 - y1) / m_cnt), m_rem((y2 - y1) % m_cnt), m_mod(m_rem), m_y(y1) { if(m_mod <= 0) { m_mod += count; m_rem += count; m_lft--; } } //-------------------------------------------- Backward-adjusted line dda2_line_interpolator(int y, int count) : m_cnt(count <= 0 ? 1 : count), m_lft(y / m_cnt), m_rem(y % m_cnt), m_mod(m_rem), m_y(0) { if(m_mod <= 0) { m_mod += count; m_rem += count; m_lft--; } } //-------------------------------------------------------------------- void save(save_data_type* data) const { data[0] = m_mod; data[1] = m_y; } //-------------------------------------------------------------------- void load(const save_data_type* data) { m_mod = data[0]; m_y = data[1]; } //-------------------------------------------------------------------- void operator++() { m_mod += m_rem; m_y += m_lft; if(m_mod > 0) { m_mod -= m_cnt; m_y++; } } //-------------------------------------------------------------------- void operator--() { if(m_mod <= m_rem) { m_mod += m_cnt; m_y--; } m_mod -= m_rem; m_y -= m_lft; } //-------------------------------------------------------------------- void adjust_forward() { m_mod -= m_cnt; } //-------------------------------------------------------------------- void adjust_backward() { m_mod += m_cnt; } //-------------------------------------------------------------------- int mod() const { return m_mod; } int rem() const { return m_rem; } int lft() const { return m_lft; } //-------------------------------------------------------------------- int y() const { return m_y; } private: int m_cnt; int m_lft; int m_rem; int m_mod; int m_y; }; //---------------------------------------------line_bresenham_interpolator class line_bresenham_interpolator { public: enum subpixel_scale_e { subpixel_shift = 8, subpixel_scale = 1 << subpixel_shift, subpixel_mask = subpixel_scale - 1 }; //-------------------------------------------------------------------- static int line_lr(int v) { return v >> subpixel_shift; } //-------------------------------------------------------------------- line_bresenham_interpolator(int x1, int y1, int x2, int y2) : m_x1_lr(line_lr(x1)), m_y1_lr(line_lr(y1)), m_x2_lr(line_lr(x2)), m_y2_lr(line_lr(y2)), m_ver(abs(m_x2_lr - m_x1_lr) < abs(m_y2_lr - m_y1_lr)), m_len(m_ver ? abs(m_y2_lr - m_y1_lr) : abs(m_x2_lr - m_x1_lr)), m_inc(m_ver ? ((y2 > y1) ? 1 : -1) : ((x2 > x1) ? 1 : -1)), m_interpolator(m_ver ? x1 : y1, m_ver ? x2 : y2, m_len) { } //-------------------------------------------------------------------- bool is_ver() const { return m_ver; } unsigned len() const { return m_len; } int inc() const { return m_inc; } //-------------------------------------------------------------------- void hstep() { ++m_interpolator; m_x1_lr += m_inc; } //-------------------------------------------------------------------- void vstep() { ++m_interpolator; m_y1_lr += m_inc; } //-------------------------------------------------------------------- int x1() const { return m_x1_lr; } int y1() const { return m_y1_lr; } int x2() const { return line_lr(m_interpolator.y()); } int y2() const { return line_lr(m_interpolator.y()); } int x2_hr() const { return m_interpolator.y(); } int y2_hr() const { return m_interpolator.y(); } private: int m_x1_lr; int m_y1_lr; int m_x2_lr; int m_y2_lr; bool m_ver; unsigned m_len; int m_inc; dda2_line_interpolator m_interpolator; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_pattern_rgba.h0000644000175000017500000000657712516137326025473 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for high precision colors has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_SPAN_PATTERN_RGBA_INCLUDED #define AGG_SPAN_PATTERN_RGBA_INCLUDED #include "agg_basics.h" namespace agg24 { //======================================================span_pattern_rgba template class span_pattern_rgba { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; //-------------------------------------------------------------------- span_pattern_rgba() {} span_pattern_rgba(source_type& src, unsigned offset_x, unsigned offset_y) : m_src(&src), m_offset_x(offset_x), m_offset_y(offset_y) {} //-------------------------------------------------------------------- void attach(source_type& v) { m_src = &v; } source_type& source() { return *m_src; } const source_type& source() const { return *m_src; } //-------------------------------------------------------------------- void offset_x(unsigned v) { m_offset_x = v; } void offset_y(unsigned v) { m_offset_y = v; } unsigned offset_x() const { return m_offset_x; } unsigned offset_y() const { return m_offset_y; } void alpha(value_type) {} value_type alpha() const { return 0; } //-------------------------------------------------------------------- void prepare() {} void generate(color_type* span, int x, int y, unsigned len) { x += m_offset_x; y += m_offset_y; const value_type* p = (const value_type*)m_src->span(x, y, len); do { span->r = p[order_type::R]; span->g = p[order_type::G]; span->b = p[order_type::B]; span->a = p[order_type::A]; p = m_src->next_x(); ++span; } while(--len); } private: source_type* m_src; unsigned m_offset_x; unsigned m_offset_y; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_pattern_rgb.h0000644000175000017500000000672312516137326025323 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for high precision colors has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_SPAN_PATTERN_RGB_INCLUDED #define AGG_SPAN_PATTERN_RGB_INCLUDED #include "agg_basics.h" namespace agg24 { //========================================================span_pattern_rgb template class span_pattern_rgb { public: typedef Source source_type; typedef typename source_type::color_type color_type; typedef typename source_type::order_type order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; //-------------------------------------------------------------------- span_pattern_rgb() {} span_pattern_rgb(source_type& src, unsigned offset_x, unsigned offset_y) : m_src(&src), m_offset_x(offset_x), m_offset_y(offset_y), m_alpha(color_type::base_mask) {} //-------------------------------------------------------------------- void attach(source_type& v) { m_src = &v; } source_type& source() { return *m_src; } const source_type& source() const { return *m_src; } //-------------------------------------------------------------------- void offset_x(unsigned v) { m_offset_x = v; } void offset_y(unsigned v) { m_offset_y = v; } unsigned offset_x() const { return m_offset_x; } unsigned offset_y() const { return m_offset_y; } void alpha(value_type v) { m_alpha = v; } value_type alpha() const { return m_alpha; } //-------------------------------------------------------------------- void prepare() {} void generate(color_type* span, int x, int y, unsigned len) { x += m_offset_x; y += m_offset_y; const value_type* p = (const value_type*)m_src->span(x, y, len); do { span->r = p[order_type::R]; span->g = p[order_type::G]; span->b = p[order_type::B]; span->a = m_alpha; p = m_src->next_x(); ++span; } while(--len); } private: source_type* m_src; unsigned m_offset_x; unsigned m_offset_y; value_type m_alpha; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_subdiv_adaptor.h0000644000175000017500000001154312516137326026016 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_SPAN_SUBDIV_ADAPTOR_INCLUDED #define AGG_SPAN_SUBDIV_ADAPTOR_INCLUDED #include "agg_basics.h" namespace agg24 { //=================================================span_subdiv_adaptor template class span_subdiv_adaptor { public: typedef Interpolator interpolator_type; typedef typename interpolator_type::trans_type trans_type; enum sublixel_scale_e { subpixel_shift = SubpixelShift, subpixel_scale = 1 << subpixel_shift }; //---------------------------------------------------------------- span_subdiv_adaptor() : m_subdiv_shift(4), m_subdiv_size(1 << m_subdiv_shift), m_subdiv_mask(m_subdiv_size - 1) {} span_subdiv_adaptor(interpolator_type& interpolator, unsigned subdiv_shift = 4) : m_subdiv_shift(subdiv_shift), m_subdiv_size(1 << m_subdiv_shift), m_subdiv_mask(m_subdiv_size - 1), m_interpolator(&interpolator) {} span_subdiv_adaptor(interpolator_type& interpolator, double x, double y, unsigned len, unsigned subdiv_shift = 4) : m_subdiv_shift(subdiv_shift), m_subdiv_size(1 << m_subdiv_shift), m_subdiv_mask(m_subdiv_size - 1), m_interpolator(&interpolator) { begin(x, y, len); } //---------------------------------------------------------------- const interpolator_type& interpolator() const { return *m_interpolator; } void interpolator(interpolator_type& intr) { m_interpolator = &intr; } //---------------------------------------------------------------- const trans_type& transformer() const { return *m_interpolator->transformer(); } void transformer(const trans_type& trans) { m_interpolator->transformer(trans); } //---------------------------------------------------------------- unsigned subdiv_shift() const { return m_subdiv_shift; } void subdiv_shift(unsigned shift) { m_subdiv_shift = shift; m_subdiv_size = 1 << m_subdiv_shift; m_subdiv_mask = m_subdiv_size - 1; } //---------------------------------------------------------------- void begin(double x, double y, unsigned len) { m_pos = 1; m_src_x = iround(x * subpixel_scale) + subpixel_scale; m_src_y = y; m_len = len; if(len > m_subdiv_size) len = m_subdiv_size; m_interpolator->begin(x, y, len); } //---------------------------------------------------------------- void operator++() { ++(*m_interpolator); if(m_pos >= m_subdiv_size) { unsigned len = m_len; if(len > m_subdiv_size) len = m_subdiv_size; m_interpolator->resynchronize(double(m_src_x) / double(subpixel_scale) + len, m_src_y, len); m_pos = 0; } m_src_x += subpixel_scale; ++m_pos; --m_len; } //---------------------------------------------------------------- void coordinates(int* x, int* y) const { m_interpolator->coordinates(x, y); } //---------------------------------------------------------------- void local_scale(int* x, int* y) const { m_interpolator->local_scale(x, y); } private: unsigned m_subdiv_shift; unsigned m_subdiv_size; unsigned m_subdiv_mask; interpolator_type* m_interpolator; int m_src_x; double m_src_y; unsigned m_pos; unsigned m_len; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_vcgen_markers_term.h0000644000175000017500000000403512516137326025642 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_VCGEN_MARKERS_TERM_INCLUDED #define AGG_VCGEN_MARKERS_TERM_INCLUDED #include "agg_basics.h" #include "agg_vertex_sequence.h" namespace agg24 { //======================================================vcgen_markers_term // // See Implemantation agg_vcgen_markers_term.cpp // Terminal markers generator (arrowhead/arrowtail) // //------------------------------------------------------------------------ class vcgen_markers_term { public: vcgen_markers_term() : m_curr_id(0), m_curr_idx(0) {} // Vertex Generator Interface void remove_all(); void add_vertex(double x, double y, unsigned cmd); // Vertex Source Interface void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: vcgen_markers_term(const vcgen_markers_term&); const vcgen_markers_term& operator = (const vcgen_markers_term&); struct coord_type { double x, y; coord_type() {} coord_type(double x_, double y_) : x(x_), y(y_) {} }; typedef pod_bvector coord_storage; coord_storage m_markers; unsigned m_curr_id; unsigned m_curr_idx; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_bspline.h0000644000175000017500000000523612516137326023425 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class bspline // //---------------------------------------------------------------------------- #ifndef AGG_BSPLINE_INCLUDED #define AGG_BSPLINE_INCLUDED #include "agg_array.h" namespace agg24 { //----------------------------------------------------------------bspline // A very simple class of Bi-cubic Spline interpolation. // First call init(num, x[], y[]) where num - number of source points, // x, y - arrays of X and Y values respectively. Here Y must be a function // of X. It means that all the X-coordinates must be arranged in the ascending // order. // Then call get(x) that calculates a value Y for the respective X. // The class supports extrapolation, i.e. you can call get(x) where x is // outside the given with init() X-range. Extrapolation is a simple linear // function. // // See Implementation agg_bspline.cpp //------------------------------------------------------------------------ class bspline { public: bspline(); bspline(int num); bspline(int num, const double* x, const double* y); void init(int num); void add_point(double x, double y); void prepare(); void init(int num, const double* x, const double* y); double get(double x) const; double get_stateful(double x) const; private: bspline(const bspline&); const bspline& operator = (const bspline&); static void bsearch(int n, const double *x, double x0, int *i); double extrapolation_left(double x) const; double extrapolation_right(double x) const; double interpolation(double x, int i) const; int m_max; int m_num; double* m_x; double* m_y; pod_array m_am; mutable int m_last_idx; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_marker_adaptor.h0000644000175000017500000000357012516137326026010 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_CONV_MARKER_ADAPTOR_INCLUDED #define AGG_CONV_MARKER_ADAPTOR_INCLUDED #include "agg_basics.h" #include "agg_conv_adaptor_vcgen.h" #include "agg_vcgen_vertex_sequence.h" namespace agg24 { //=====================================================conv_marker_adaptor template struct conv_marker_adaptor : public conv_adaptor_vcgen { typedef Markers marker_type; typedef conv_adaptor_vcgen base_type; conv_marker_adaptor(VertexSource& vs) : conv_adaptor_vcgen(vs) { } void shorten(double s) { base_type::generator().shorten(s); } double shorten() const { return base_type::generator().shorten(); } private: conv_marker_adaptor(const conv_marker_adaptor&); const conv_marker_adaptor& operator = (const conv_marker_adaptor&); }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_gouraud_gray.h0000644000175000017500000002050712516137326025500 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for high precision colors has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_SPAN_GOURAUD_GRAY_INCLUDED #define AGG_SPAN_GOURAUD_GRAY_INCLUDED #include "agg_basics.h" #include "agg_color_gray.h" #include "agg_dda_line.h" #include "agg_span_gouraud.h" namespace agg24 { //=======================================================span_gouraud_gray template class span_gouraud_gray : public span_gouraud { public: typedef ColorT color_type; typedef typename color_type::value_type value_type; typedef span_gouraud base_type; typedef typename base_type::coord_type coord_type; enum subpixel_scale_e { subpixel_shift = 4, subpixel_scale = 1 << subpixel_shift }; private: //-------------------------------------------------------------------- struct gray_calc { void init(const coord_type& c1, const coord_type& c2) { m_x1 = c1.x - 0.5; m_y1 = c1.y - 0.5; m_dx = c2.x - c1.x; double dy = c2.y - c1.y; m_1dy = (fabs(dy) < 1e-10) ? 1e10 : 1.0 / dy; m_v1 = c1.color.v; m_a1 = c1.color.a; m_dv = c2.color.v - m_v1; m_da = c2.color.a - m_a1; } void calc(double y) { double k = (y - m_y1) * m_1dy; if(k < 0.0) k = 0.0; if(k > 1.0) k = 1.0; m_v = m_v1 + iround(m_dv * k); m_a = m_a1 + iround(m_da * k); m_x = iround((m_x1 + m_dx * k) * subpixel_scale); } double m_x1; double m_y1; double m_dx; double m_1dy; int m_v1; int m_a1; int m_dv; int m_da; int m_v; int m_a; int m_x; }; public: //-------------------------------------------------------------------- span_gouraud_gray() {} span_gouraud_gray(const color_type& c1, const color_type& c2, const color_type& c3, double x1, double y1, double x2, double y2, double x3, double y3, double d = 0) : base_type(c1, c2, c3, x1, y1, x2, y2, x3, y3, d) {} //-------------------------------------------------------------------- void prepare() { coord_type coord[3]; base_type::arrange_vertices(coord); m_y2 = int(coord[1].y); m_swap = cross_product(coord[0].x, coord[0].y, coord[2].x, coord[2].y, coord[1].x, coord[1].y) < 0.0; m_c1.init(coord[0], coord[2]); m_c2.init(coord[0], coord[1]); m_c3.init(coord[1], coord[2]); } //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { m_c1.calc(y); const gray_calc* pc1 = &m_c1; const gray_calc* pc2 = &m_c2; if(y < m_y2) { // Bottom part of the triangle (first subtriangle) //------------------------- m_c2.calc(y + m_c2.m_1dy); } else { // Upper part (second subtriangle) //------------------------- m_c3.calc(y - m_c3.m_1dy); pc2 = &m_c3; } if(m_swap) { // It means that the triangle is oriented clockwise, // so that we need to swap the controlling structures //------------------------- const gray_calc* t = pc2; pc2 = pc1; pc1 = t; } // Get the horizontal length with subpixel accuracy // and protect it from division by zero //------------------------- int nlen = abs(pc2->m_x - pc1->m_x); if(nlen <= 0) nlen = 1; dda_line_interpolator<14> v(pc1->m_v, pc2->m_v, nlen); dda_line_interpolator<14> a(pc1->m_a, pc2->m_a, nlen); // Calculate the starting point of the gradient with subpixel // accuracy and correct (roll back) the interpolators. // This operation will also clip the beginning of the span // if necessary. //------------------------- int start = pc1->m_x - (x << subpixel_shift); v -= start; a -= start; nlen += start; int vv, va; enum lim_e { lim = color_type::base_mask }; // Beginning part of the span. Since we rolled back the // interpolators, the color values may have overflow. // So that, we render the beginning part with checking // for overflow. It lasts until "start" is positive; // typically it's 1-2 pixels, but may be more in some cases. //------------------------- while(len && start > 0) { vv = v.y(); va = a.y(); if(vv < 0) vv = 0; if(vv > lim) vv = lim; if(va < 0) va = 0; if(va > lim) va = lim; span->v = (value_type)vv; span->a = (value_type)va; v += subpixel_scale; a += subpixel_scale; nlen -= subpixel_scale; start -= subpixel_scale; ++span; --len; } // Middle part, no checking for overflow. // Actual spans can be longer than the calculated length // because of anti-aliasing, thus, the interpolators can // overflow. But while "nlen" is positive we are safe. //------------------------- while(len && nlen > 0) { span->v = (value_type)v.y(); span->a = (value_type)a.y(); v += subpixel_scale; a += subpixel_scale; nlen -= subpixel_scale; ++span; --len; } // Ending part; checking for overflow. // Typically it's 1-2 pixels, but may be more in some cases. //------------------------- while(len) { vv = v.y(); va = a.y(); if(vv < 0) vv = 0; if(vv > lim) vv = lim; if(va < 0) va = 0; if(va > lim) va = lim; span->v = (value_type)vv; span->a = (value_type)va; v += subpixel_scale; a += subpixel_scale; ++span; --len; } } private: bool m_swap; int m_y2; gray_calc m_c1; gray_calc m_c2; gray_calc m_c3; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_vcgen_smooth_poly1.h0000644000175000017500000000513612516137326025607 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_VCGEN_SMOOTH_POLY1_INCLUDED #define AGG_VCGEN_SMOOTH_POLY1_INCLUDED #include "agg_basics.h" #include "agg_vertex_sequence.h" namespace agg24 { //======================================================vcgen_smooth_poly1 // // See Implementation agg_vcgen_smooth_poly1.cpp // Smooth polygon generator // //------------------------------------------------------------------------ class vcgen_smooth_poly1 { enum status_e { initial, ready, polygon, ctrl_b, ctrl_e, ctrl1, ctrl2, end_poly, stop }; public: typedef vertex_sequence vertex_storage; vcgen_smooth_poly1(); void smooth_value(double v) { m_smooth_value = v * 0.5; } double smooth_value() const { return m_smooth_value * 2.0; } // Vertex Generator Interface void remove_all(); void add_vertex(double x, double y, unsigned cmd); // Vertex Source Interface void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: vcgen_smooth_poly1(const vcgen_smooth_poly1&); const vcgen_smooth_poly1& operator = (const vcgen_smooth_poly1&); void calculate(const vertex_dist& v0, const vertex_dist& v1, const vertex_dist& v2, const vertex_dist& v3); vertex_storage m_src_vertices; double m_smooth_value; unsigned m_closed; status_e m_status; unsigned m_src_vertex; double m_ctrl1_x; double m_ctrl1_y; double m_ctrl2_x; double m_ctrl2_y; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_trans_single_path.h0000644000175000017500000000601112516137326025465 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_TRANS_SINGLE_PATH_INCLUDED #define AGG_TRANS_SINGLE_PATH_INCLUDED #include "agg_basics.h" #include "agg_vertex_sequence.h" namespace agg24 { // See also: agg_trans_single_path.cpp // //-------------------------------------------------------trans_single_path class trans_single_path { enum status_e { initial, making_path, ready }; public: typedef vertex_sequence vertex_storage; trans_single_path(); //-------------------------------------------------------------------- void base_length(double v) { m_base_length = v; } double base_length() const { return m_base_length; } //-------------------------------------------------------------------- void preserve_x_scale(bool f) { m_preserve_x_scale = f; } bool preserve_x_scale() const { return m_preserve_x_scale; } //-------------------------------------------------------------------- void reset(); void move_to(double x, double y); void line_to(double x, double y); void finalize_path(); //-------------------------------------------------------------------- template void add_path(VertexSource& vs, unsigned path_id=0) { double x; double y; unsigned cmd; vs.rewind(path_id); while(!is_stop(cmd = vs.vertex(&x, &y))) { if(is_move_to(cmd)) { move_to(x, y); } else { if(is_vertex(cmd)) { line_to(x, y); } } } finalize_path(); } //-------------------------------------------------------------------- double total_length() const; void transform(double *x, double *y) const; private: vertex_storage m_src_vertices; double m_base_length; double m_kindex; status_e m_status; bool m_preserve_x_scale; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_vcgen_vertex_sequence.h0000644000175000017500000000760112516137326026356 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_VCGEN_VERTEX_SEQUENCE_INCLUDED #define AGG_VCGEN_VERTEX_SEQUENCE_INCLUDED #include "agg_basics.h" #include "agg_vertex_sequence.h" #include "agg_shorten_path.h" namespace agg24 { //===================================================vcgen_vertex_sequence class vcgen_vertex_sequence { public: typedef vertex_dist_cmd vertex_type; typedef vertex_sequence vertex_storage; vcgen_vertex_sequence() : m_flags(0), m_cur_vertex(0), m_shorten(0.0), m_ready(false) { } // Vertex Generator Interface void remove_all(); void add_vertex(double x, double y, unsigned cmd); // Vertex Source Interface void rewind(unsigned path_id); unsigned vertex(double* x, double* y); void shorten(double s) { m_shorten = s; } double shorten() const { return m_shorten; } private: vcgen_vertex_sequence(const vcgen_vertex_sequence&); const vcgen_vertex_sequence& operator = (const vcgen_vertex_sequence&); vertex_storage m_src_vertices; unsigned m_flags; unsigned m_cur_vertex; double m_shorten; bool m_ready; }; //------------------------------------------------------------------------ inline void vcgen_vertex_sequence::remove_all() { m_ready = false; m_src_vertices.remove_all(); m_cur_vertex = 0; m_flags = 0; } //------------------------------------------------------------------------ inline void vcgen_vertex_sequence::add_vertex(double x, double y, unsigned cmd) { m_ready = false; if(is_move_to(cmd)) { m_src_vertices.modify_last(vertex_dist_cmd(x, y, cmd)); } else { if(is_vertex(cmd)) { m_src_vertices.add(vertex_dist_cmd(x, y, cmd)); } else { m_flags = cmd & path_flags_mask; } } } //------------------------------------------------------------------------ inline void vcgen_vertex_sequence::rewind(unsigned) { if(!m_ready) { m_src_vertices.close(is_closed(m_flags)); shorten_path(m_src_vertices, m_shorten, get_close_flag(m_flags)); } m_ready = true; m_cur_vertex = 0; } //------------------------------------------------------------------------ inline unsigned vcgen_vertex_sequence::vertex(double* x, double* y) { if(!m_ready) { rewind(0); } if(m_cur_vertex == m_src_vertices.size()) { ++m_cur_vertex; return path_cmd_end_poly | m_flags; } if(m_cur_vertex > m_src_vertices.size()) { return path_cmd_stop; } vertex_type& v = m_src_vertices[m_cur_vertex++]; *x = v.x; *y = v.y; return v.cmd; } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_curves.h0000644000175000017500000005035012516137326023275 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // Copyright (C) 2005 Tony Juricic (tonygeek@yahoo.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_CURVES_INCLUDED #define AGG_CURVES_INCLUDED #include "agg_array.h" namespace agg24 { // See Implementation agg_curves.cpp //--------------------------------------------curve_approximation_method_e enum curve_approximation_method_e { curve_inc, curve_div }; //--------------------------------------------------------------curve3_inc class curve3_inc { public: curve3_inc() : m_num_steps(0), m_step(0), m_scale(1.0) { } curve3_inc(double x1, double y1, double x2, double y2, double x3, double y3) : m_num_steps(0), m_step(0), m_scale(1.0) { init(x1, y1, x2, y2, x3, y3); } void reset() { m_num_steps = 0; m_step = -1; } void init(double x1, double y1, double x2, double y2, double x3, double y3); void approximation_method(curve_approximation_method_e) {} curve_approximation_method_e approximation_method() const { return curve_inc; } void approximation_scale(double s); double approximation_scale() const; void angle_tolerance(double) {} double angle_tolerance() const { return 0.0; } void cusp_limit(double) {} double cusp_limit() const { return 0.0; } void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: int m_num_steps; int m_step; double m_scale; double m_start_x; double m_start_y; double m_end_x; double m_end_y; double m_fx; double m_fy; double m_dfx; double m_dfy; double m_ddfx; double m_ddfy; double m_saved_fx; double m_saved_fy; double m_saved_dfx; double m_saved_dfy; }; //-------------------------------------------------------------curve3_div class curve3_div { public: curve3_div() : m_approximation_scale(1.0), m_angle_tolerance(0.0), m_count(0) {} curve3_div(double x1, double y1, double x2, double y2, double x3, double y3) : m_approximation_scale(1.0), m_angle_tolerance(0.0), m_count(0) { init(x1, y1, x2, y2, x3, y3); } void reset() { m_points.remove_all(); m_count = 0; } void init(double x1, double y1, double x2, double y2, double x3, double y3); void approximation_method(curve_approximation_method_e) {} curve_approximation_method_e approximation_method() const { return curve_div; } void approximation_scale(double s) { m_approximation_scale = s; } double approximation_scale() const { return m_approximation_scale; } void angle_tolerance(double a) { m_angle_tolerance = a; } double angle_tolerance() const { return m_angle_tolerance; } void cusp_limit(double) {} double cusp_limit() const { return 0.0; } void rewind(unsigned) { m_count = 0; } unsigned vertex(double* x, double* y) { if(m_count >= m_points.size()) return path_cmd_stop; const point_d& p = m_points[m_count++]; *x = p.x; *y = p.y; return (m_count == 1) ? path_cmd_move_to : path_cmd_line_to; } private: void bezier(double x1, double y1, double x2, double y2, double x3, double y3); void recursive_bezier(double x1, double y1, double x2, double y2, double x3, double y3, unsigned level); double m_approximation_scale; double m_distance_tolerance_square; double m_distance_tolerance_manhattan; double m_angle_tolerance; unsigned m_count; pod_bvector m_points; }; //-------------------------------------------------------------curve4_points struct curve4_points { double cp[8]; curve4_points() {} curve4_points(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { cp[0] = x1; cp[1] = y1; cp[2] = x2; cp[3] = y2; cp[4] = x3; cp[5] = y3; cp[6] = x4; cp[7] = y4; } void init(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { cp[0] = x1; cp[1] = y1; cp[2] = x2; cp[3] = y2; cp[4] = x3; cp[5] = y3; cp[6] = x4; cp[7] = y4; } double operator [] (unsigned i) const { return cp[i]; } double& operator [] (unsigned i) { return cp[i]; } }; //-------------------------------------------------------------curve4_inc class curve4_inc { public: curve4_inc() : m_num_steps(0), m_step(0), m_scale(1.0) { } curve4_inc(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) : m_num_steps(0), m_step(0), m_scale(1.0) { init(x1, y1, x2, y2, x3, y3, x4, y4); } curve4_inc(const curve4_points& cp) : m_num_steps(0), m_step(0), m_scale(1.0) { init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); } void reset() { m_num_steps = 0; m_step = -1; } void init(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4); void init(const curve4_points& cp) { init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); } void approximation_method(curve_approximation_method_e) {} curve_approximation_method_e approximation_method() const { return curve_inc; } void approximation_scale(double s); double approximation_scale() const; void angle_tolerance(double) {} double angle_tolerance() const { return 0.0; } void cusp_limit(double) {} double cusp_limit() const { return 0.0; } void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: int m_num_steps; int m_step; double m_scale; double m_start_x; double m_start_y; double m_end_x; double m_end_y; double m_fx; double m_fy; double m_dfx; double m_dfy; double m_ddfx; double m_ddfy; double m_dddfx; double m_dddfy; double m_saved_fx; double m_saved_fy; double m_saved_dfx; double m_saved_dfy; double m_saved_ddfx; double m_saved_ddfy; }; //-------------------------------------------------------catrom_to_bezier inline curve4_points catrom_to_bezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { // Trans. matrix Catmull-Rom to Bezier // // 0 1 0 0 // -1/6 1 1/6 0 // 0 1/6 1 -1/6 // 0 0 1 0 // return curve4_points( x2, y2, (-x1 + 6*x2 + x3) / 6, (-y1 + 6*y2 + y3) / 6, ( x2 + 6*x3 - x4) / 6, ( y2 + 6*y3 - y4) / 6, x3, y3); } //----------------------------------------------------------------------- inline curve4_points catrom_to_bezier(const curve4_points& cp) { return catrom_to_bezier(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); } //-----------------------------------------------------ubspline_to_bezier inline curve4_points ubspline_to_bezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { // Trans. matrix Uniform BSpline to Bezier // // 1/6 4/6 1/6 0 // 0 4/6 2/6 0 // 0 2/6 4/6 0 // 0 1/6 4/6 1/6 // return curve4_points( (x1 + 4*x2 + x3) / 6, (y1 + 4*y2 + y3) / 6, (4*x2 + 2*x3) / 6, (4*y2 + 2*y3) / 6, (2*x2 + 4*x3) / 6, (2*y2 + 4*y3) / 6, (x2 + 4*x3 + x4) / 6, (y2 + 4*y3 + y4) / 6); } //----------------------------------------------------------------------- inline curve4_points ubspline_to_bezier(const curve4_points& cp) { return ubspline_to_bezier(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); } //------------------------------------------------------hermite_to_bezier inline curve4_points hermite_to_bezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { // Trans. matrix Hermite to Bezier // // 1 0 0 0 // 1 0 1/3 0 // 0 1 0 -1/3 // 0 1 0 0 // return curve4_points( x1, y1, (3*x1 + x3) / 3, (3*y1 + y3) / 3, (3*x2 - x4) / 3, (3*y2 - y4) / 3, x2, y2); } //----------------------------------------------------------------------- inline curve4_points hermite_to_bezier(const curve4_points& cp) { return hermite_to_bezier(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); } //-------------------------------------------------------------curve4_div class curve4_div { public: curve4_div() : m_approximation_scale(1.0), m_angle_tolerance(0.0), m_cusp_limit(0.0), m_count(0) {} curve4_div(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) : m_approximation_scale(1.0), m_angle_tolerance(0.0), m_cusp_limit(0.0), m_count(0) { init(x1, y1, x2, y2, x3, y3, x4, y4); } curve4_div(const curve4_points& cp) : m_approximation_scale(1.0), m_angle_tolerance(0.0), m_count(0) { init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); } void reset() { m_points.remove_all(); m_count = 0; } void init(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4); void init(const curve4_points& cp) { init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); } void approximation_method(curve_approximation_method_e) {} curve_approximation_method_e approximation_method() const { return curve_div; } void approximation_scale(double s) { m_approximation_scale = s; } double approximation_scale() const { return m_approximation_scale; } void angle_tolerance(double a) { m_angle_tolerance = a; } double angle_tolerance() const { return m_angle_tolerance; } void cusp_limit(double v) { m_cusp_limit = (v == 0.0) ? 0.0 : pi - v; } double cusp_limit() const { return (m_cusp_limit == 0.0) ? 0.0 : pi - m_cusp_limit; } void rewind(unsigned) { m_count = 0; } unsigned vertex(double* x, double* y) { if(m_count >= m_points.size()) return path_cmd_stop; const point_d& p = m_points[m_count++]; *x = p.x; *y = p.y; return (m_count == 1) ? path_cmd_move_to : path_cmd_line_to; } private: void bezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4); void recursive_bezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, unsigned level); double m_approximation_scale; double m_distance_tolerance_square; double m_distance_tolerance_manhattan; double m_angle_tolerance; double m_cusp_limit; unsigned m_count; pod_bvector m_points; }; //-----------------------------------------------------------------curve3 class curve3 { public: curve3() : m_approximation_method(curve_div) {} curve3(double x1, double y1, double x2, double y2, double x3, double y3) : m_approximation_method(curve_div) { init(x1, y1, x2, y2, x3, y3); } void reset() { m_curve_inc.reset(); m_curve_div.reset(); } void init(double x1, double y1, double x2, double y2, double x3, double y3) { if(m_approximation_method == curve_inc) { m_curve_inc.init(x1, y1, x2, y2, x3, y3); } else { m_curve_div.init(x1, y1, x2, y2, x3, y3); } } void approximation_method(curve_approximation_method_e v) { m_approximation_method = v; } curve_approximation_method_e approximation_method() const { return m_approximation_method; } void approximation_scale(double s) { m_curve_inc.approximation_scale(s); m_curve_div.approximation_scale(s); } double approximation_scale() const { return m_curve_inc.approximation_scale(); } void angle_tolerance(double a) { m_curve_div.angle_tolerance(a); } double angle_tolerance() const { return m_curve_div.angle_tolerance(); } void cusp_limit(double v) { m_curve_div.cusp_limit(v); } double cusp_limit() const { return m_curve_div.cusp_limit(); } void rewind(unsigned path_id) { if(m_approximation_method == curve_inc) { m_curve_inc.rewind(path_id); } else { m_curve_div.rewind(path_id); } } unsigned vertex(double* x, double* y) { if(m_approximation_method == curve_inc) { return m_curve_inc.vertex(x, y); } return m_curve_div.vertex(x, y); } private: curve3_inc m_curve_inc; curve3_div m_curve_div; curve_approximation_method_e m_approximation_method; }; //-----------------------------------------------------------------curve4 class curve4 { public: curve4() : m_approximation_method(curve_div) {} curve4(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) : m_approximation_method(curve_div) { init(x1, y1, x2, y2, x3, y3, x4, y4); } curve4(const curve4_points& cp) : m_approximation_method(curve_div) { init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); } void reset() { m_curve_inc.reset(); m_curve_div.reset(); } void init(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { if(m_approximation_method == curve_inc) { m_curve_inc.init(x1, y1, x2, y2, x3, y3, x4, y4); } else { m_curve_div.init(x1, y1, x2, y2, x3, y3, x4, y4); } } void init(const curve4_points& cp) { init(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5], cp[6], cp[7]); } void approximation_method(curve_approximation_method_e v) { m_approximation_method = v; } curve_approximation_method_e approximation_method() const { return m_approximation_method; } void approximation_scale(double s) { m_curve_inc.approximation_scale(s); m_curve_div.approximation_scale(s); } double approximation_scale() const { return m_curve_inc.approximation_scale(); } void angle_tolerance(double v) { m_curve_div.angle_tolerance(v); } double angle_tolerance() const { return m_curve_div.angle_tolerance(); } void cusp_limit(double v) { m_curve_div.cusp_limit(v); } double cusp_limit() const { return m_curve_div.cusp_limit(); } void rewind(unsigned path_id) { if(m_approximation_method == curve_inc) { m_curve_inc.rewind(path_id); } else { m_curve_div.rewind(path_id); } } unsigned vertex(double* x, double* y) { if(m_approximation_method == curve_inc) { return m_curve_inc.vertex(x, y); } return m_curve_div.vertex(x, y); } private: curve4_inc m_curve_inc; curve4_div m_curve_div; curve_approximation_method_e m_approximation_method; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_path_storage_integer.h0000644000175000017500000002355712516137326026174 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_PATH_STORAGE_INTEGER_INCLUDED #define AGG_PATH_STORAGE_INTEGER_INCLUDED #include #include "agg_array.h" namespace agg24 { //---------------------------------------------------------vertex_integer template struct vertex_integer { enum path_cmd { cmd_move_to = 0, cmd_line_to = 1, cmd_curve3 = 2, cmd_curve4 = 3 }; enum coord_scale_e { coord_shift = CoordShift, coord_scale = 1 << coord_shift }; T x,y; vertex_integer() {} vertex_integer(T x_, T y_, unsigned flag) : x(((x_ << 1) & ~1) | (flag & 1)), y(((y_ << 1) & ~1) | (flag >> 1)) {} unsigned vertex(double* x_, double* y_, double dx=0, double dy=0, double scale=1.0) const { *x_ = dx + (double(x >> 1) / coord_scale) * scale; *y_ = dy + (double(y >> 1) / coord_scale) * scale; switch(((y & 1) << 1) | (x & 1)) { case cmd_move_to: return path_cmd_move_to; case cmd_line_to: return path_cmd_line_to; case cmd_curve3: return path_cmd_curve3; case cmd_curve4: return path_cmd_curve4; } return path_cmd_stop; } }; //---------------------------------------------------path_storage_integer template class path_storage_integer { public: typedef T value_type; typedef vertex_integer vertex_integer_type; //-------------------------------------------------------------------- path_storage_integer() : m_storage(), m_vertex_idx(0), m_closed(true) {} //-------------------------------------------------------------------- void remove_all() { m_storage.remove_all(); } //-------------------------------------------------------------------- void move_to(T x, T y) { m_storage.add(vertex_integer_type(x, y, vertex_integer_type::cmd_move_to)); } //-------------------------------------------------------------------- void line_to(T x, T y) { m_storage.add(vertex_integer_type(x, y, vertex_integer_type::cmd_line_to)); } //-------------------------------------------------------------------- void curve3(T x_ctrl, T y_ctrl, T x_to, T y_to) { m_storage.add(vertex_integer_type(x_ctrl, y_ctrl, vertex_integer_type::cmd_curve3)); m_storage.add(vertex_integer_type(x_to, y_to, vertex_integer_type::cmd_curve3)); } //-------------------------------------------------------------------- void curve4(T x_ctrl1, T y_ctrl1, T x_ctrl2, T y_ctrl2, T x_to, T y_to) { m_storage.add(vertex_integer_type(x_ctrl1, y_ctrl1, vertex_integer_type::cmd_curve4)); m_storage.add(vertex_integer_type(x_ctrl2, y_ctrl2, vertex_integer_type::cmd_curve4)); m_storage.add(vertex_integer_type(x_to, y_to, vertex_integer_type::cmd_curve4)); } //-------------------------------------------------------------------- void close_polygon() {} //-------------------------------------------------------------------- unsigned size() const { return m_storage.size(); } unsigned vertex(unsigned idx, double* x, double* y) const { return m_storage[idx].vertex(x, y); } //-------------------------------------------------------------------- unsigned byte_size() const { return m_storage.size() * sizeof(vertex_integer_type); } void serialize(int8u* ptr) const { unsigned i; for(i = 0; i < m_storage.size(); i++) { memcpy(ptr, &m_storage[i], sizeof(vertex_integer_type)); ptr += sizeof(vertex_integer_type); } } //-------------------------------------------------------------------- void rewind(unsigned) { m_vertex_idx = 0; m_closed = true; } //-------------------------------------------------------------------- unsigned vertex(double* x, double* y) { if(m_storage.size() < 2 || m_vertex_idx > m_storage.size()) { *x = 0; *y = 0; return path_cmd_stop; } if(m_vertex_idx == m_storage.size()) { *x = 0; *y = 0; ++m_vertex_idx; return path_cmd_end_poly | path_flags_close; } unsigned cmd = m_storage[m_vertex_idx].vertex(x, y); if(is_move_to(cmd) && !m_closed) { *x = 0; *y = 0; m_closed = true; return path_cmd_end_poly | path_flags_close; } m_closed = false; ++m_vertex_idx; return cmd; } //-------------------------------------------------------------------- rect_d bounding_rect() const { rect_d bounds(1e100, 1e100, -1e100, -1e100); if(m_storage.size() == 0) { bounds.x1 = bounds.y1 = bounds.x2 = bounds.y2 = 0.0; } else { unsigned i; for(i = 0; i < m_storage.size(); i++) { double x, y; m_storage[i].vertex(&x, &y); if(x < bounds.x1) bounds.x1 = x; if(y < bounds.y1) bounds.y1 = y; if(x > bounds.x2) bounds.x2 = x; if(y > bounds.y2) bounds.y2 = y; } } return bounds; } private: pod_bvector m_storage; unsigned m_vertex_idx; bool m_closed; }; //-----------------------------------------serialized_integer_path_adaptor template class serialized_integer_path_adaptor { public: typedef vertex_integer vertex_integer_type; //-------------------------------------------------------------------- serialized_integer_path_adaptor() : m_data(0), m_end(0), m_ptr(0), m_dx(0.0), m_dy(0.0), m_scale(1.0), m_vertices(0) {} //-------------------------------------------------------------------- serialized_integer_path_adaptor(const int8u* data, unsigned size, double dx, double dy) : m_data(data), m_end(data + size), m_ptr(data), m_dx(dx), m_dy(dy), m_vertices(0) {} //-------------------------------------------------------------------- void init(const int8u* data, unsigned size, double dx, double dy, double scale=1.0) { m_data = data; m_end = data + size; m_ptr = data; m_dx = dx; m_dy = dy; m_scale = scale; m_vertices = 0; } //-------------------------------------------------------------------- void rewind(unsigned) { m_ptr = m_data; m_vertices = 0; } //-------------------------------------------------------------------- unsigned vertex(double* x, double* y) { if(m_data == 0 || m_ptr > m_end) { *x = 0; *y = 0; return path_cmd_stop; } if(m_ptr == m_end) { *x = 0; *y = 0; m_ptr += sizeof(vertex_integer_type); return path_cmd_end_poly | path_flags_close; } vertex_integer_type v; memcpy(&v, m_ptr, sizeof(vertex_integer_type)); unsigned cmd = v.vertex(x, y, m_dx, m_dy, m_scale); if(is_move_to(cmd) && m_vertices > 2) { *x = 0; *y = 0; m_vertices = 0; return path_cmd_end_poly | path_flags_close; } ++m_vertices; m_ptr += sizeof(vertex_integer_type); return cmd; } private: const int8u* m_data; const int8u* m_end; const int8u* m_ptr; double m_dx; double m_dy; double m_scale; unsigned m_vertices; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_marker.h0000644000175000017500000001106412516137326024273 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // conv_marker // //---------------------------------------------------------------------------- #ifndef AGG_CONV_MARKER_INCLUDED #define AGG_CONV_MARKER_INCLUDED #include "agg_basics.h" #include "agg_trans_affine.h" namespace agg24 { //-------------------------------------------------------------conv_marker template class conv_marker { public: conv_marker(MarkerLocator& ml, MarkerShapes& ms); trans_affine& transform() { return m_transform; } const trans_affine& transform() const { return m_transform; } void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: conv_marker(const conv_marker&); const conv_marker& operator = (const conv_marker&); enum status_e { initial, markers, polygon, stop }; MarkerLocator* m_marker_locator; MarkerShapes* m_marker_shapes; trans_affine m_transform; trans_affine m_mtx; status_e m_status; unsigned m_marker; unsigned m_num_markers; }; //------------------------------------------------------------------------ template conv_marker::conv_marker(MarkerLocator& ml, MarkerShapes& ms) : m_marker_locator(&ml), m_marker_shapes(&ms), m_status(initial), m_marker(0), m_num_markers(1) { } //------------------------------------------------------------------------ template void conv_marker::rewind(unsigned) { m_status = initial; m_marker = 0; m_num_markers = 1; } //------------------------------------------------------------------------ template unsigned conv_marker::vertex(double* x, double* y) { unsigned cmd = path_cmd_move_to; double x1, y1, x2, y2; while(!is_stop(cmd)) { switch(m_status) { case initial: if(m_num_markers == 0) { cmd = path_cmd_stop; break; } m_marker_locator->rewind(m_marker); ++m_marker; m_num_markers = 0; m_status = markers; case markers: if(is_stop(m_marker_locator->vertex(&x1, &y1))) { m_status = initial; break; } if(is_stop(m_marker_locator->vertex(&x2, &y2))) { m_status = initial; break; } ++m_num_markers; m_mtx = m_transform; m_mtx *= trans_affine_rotation(atan2(y2 - y1, x2 - x1)); m_mtx *= trans_affine_translation(x1, y1); m_marker_shapes->rewind(m_marker - 1); m_status = polygon; case polygon: cmd = m_marker_shapes->vertex(x, y); if(is_stop(cmd)) { cmd = path_cmd_move_to; m_status = markers; break; } m_mtx.transform(x, y); return cmd; case stop: cmd = path_cmd_stop; break; } } return cmd; } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_trans_viewport.h0000644000175000017500000002326312516137326025057 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Viewport transformer - simple orthogonal conversions from world coordinates // to screen (device) ones. // //---------------------------------------------------------------------------- #ifndef AGG_TRANS_VIEWPORT_INCLUDED #define AGG_TRANS_VIEWPORT_INCLUDED #include #include "agg_trans_affine.h" namespace agg24 { enum aspect_ratio_e { aspect_ratio_stretch, aspect_ratio_meet, aspect_ratio_slice }; //----------------------------------------------------------trans_viewport class trans_viewport { public: //------------------------------------------------------------------- trans_viewport() : m_world_x1(0.0), m_world_y1(0.0), m_world_x2(1.0), m_world_y2(1.0), m_device_x1(0.0), m_device_y1(0.0), m_device_x2(1.0), m_device_y2(1.0), m_aspect(aspect_ratio_stretch), m_is_valid(true), m_align_x(0.5), m_align_y(0.5), m_wx1(0.0), m_wy1(0.0), m_wx2(1.0), m_wy2(1.0), m_dx1(0.0), m_dy1(0.0), m_kx(1.0), m_ky(1.0) {} //------------------------------------------------------------------- void preserve_aspect_ratio(double alignx, double aligny, aspect_ratio_e aspect) { m_align_x = alignx; m_align_y = aligny; m_aspect = aspect; update(); } //------------------------------------------------------------------- void device_viewport(double x1, double y1, double x2, double y2) { m_device_x1 = x1; m_device_y1 = y1; m_device_x2 = x2; m_device_y2 = y2; update(); } //------------------------------------------------------------------- void world_viewport(double x1, double y1, double x2, double y2) { m_world_x1 = x1; m_world_y1 = y1; m_world_x2 = x2; m_world_y2 = y2; update(); } //------------------------------------------------------------------- void device_viewport(double* x1, double* y1, double* x2, double* y2) const { *x1 = m_device_x1; *y1 = m_device_y1; *x2 = m_device_x2; *y2 = m_device_y2; } //------------------------------------------------------------------- void world_viewport(double* x1, double* y1, double* x2, double* y2) const { *x1 = m_world_x1; *y1 = m_world_y1; *x2 = m_world_x2; *y2 = m_world_y2; } //------------------------------------------------------------------- void world_viewport_actual(double* x1, double* y1, double* x2, double* y2) const { *x1 = m_wx1; *y1 = m_wy1; *x2 = m_wx2; *y2 = m_wy2; } //------------------------------------------------------------------- bool is_valid() const { return m_is_valid; } double align_x() const { return m_align_x; } double align_y() const { return m_align_y; } aspect_ratio_e aspect_ratio() const { return m_aspect; } //------------------------------------------------------------------- void transform(double* x, double* y) const { *x = (*x - m_wx1) * m_kx + m_dx1; *y = (*y - m_wy1) * m_ky + m_dy1; } //------------------------------------------------------------------- void transform_scale_only(double* x, double* y) const { *x *= m_kx; *y *= m_ky; } //------------------------------------------------------------------- void inverse_transform(double* x, double* y) const { *x = (*x - m_dx1) / m_kx + m_wx1; *y = (*y - m_dy1) / m_ky + m_wy1; } //------------------------------------------------------------------- void inverse_transform_scale_only(double* x, double* y) const { *x /= m_kx; *y /= m_ky; } //------------------------------------------------------------------- double device_dx() const { return m_dx1 - m_wx1 * m_kx; } double device_dy() const { return m_dy1 - m_wy1 * m_ky; } //------------------------------------------------------------------- double scale_x() const { return m_kx; } //------------------------------------------------------------------- double scale_y() const { return m_ky; } //------------------------------------------------------------------- double scale() const { return (m_kx + m_ky) * 0.5; } //------------------------------------------------------------------- trans_affine to_affine() const { trans_affine mtx = trans_affine_translation(-m_wx1, -m_wy1); mtx *= trans_affine_scaling(m_kx, m_ky); mtx *= trans_affine_translation(m_dx1, m_dy1); return mtx; } //------------------------------------------------------------------- trans_affine to_affine_scale_only() const { return trans_affine_scaling(m_kx, m_ky); } //------------------------------------------------------------------- unsigned byte_size() const { return sizeof(*this); } void serialize(int8u* ptr) const { memcpy(ptr, this, sizeof(*this)); } void deserialize(const int8u* ptr) { memcpy(this, ptr, sizeof(*this)); } private: void update(); double m_world_x1; double m_world_y1; double m_world_x2; double m_world_y2; double m_device_x1; double m_device_y1; double m_device_x2; double m_device_y2; aspect_ratio_e m_aspect; bool m_is_valid; double m_align_x; double m_align_y; double m_wx1; double m_wy1; double m_wx2; double m_wy2; double m_dx1; double m_dy1; double m_kx; double m_ky; }; //----------------------------------------------------------------------- inline void trans_viewport::update() { const double epsilon = 1e-30; if(fabs(m_world_x1 - m_world_x2) < epsilon || fabs(m_world_y1 - m_world_y2) < epsilon || fabs(m_device_x1 - m_device_x2) < epsilon || fabs(m_device_y1 - m_device_y2) < epsilon) { m_wx1 = m_world_x1; m_wy1 = m_world_y1; m_wx2 = m_world_x1 + 1.0; m_wy2 = m_world_y2 + 1.0; m_dx1 = m_device_x1; m_dy1 = m_device_y1; m_kx = 1.0; m_ky = 1.0; m_is_valid = false; return; } double world_x1 = m_world_x1; double world_y1 = m_world_y1; double world_x2 = m_world_x2; double world_y2 = m_world_y2; double device_x1 = m_device_x1; double device_y1 = m_device_y1; double device_x2 = m_device_x2; double device_y2 = m_device_y2; if(m_aspect != aspect_ratio_stretch) { double d; m_kx = (device_x2 - device_x1) / (world_x2 - world_x1); m_ky = (device_y2 - device_y1) / (world_y2 - world_y1); if((m_aspect == aspect_ratio_meet) == (m_kx < m_ky)) { d = (world_y2 - world_y1) * m_ky / m_kx; world_y1 += (world_y2 - world_y1 - d) * m_align_y; world_y2 = world_y1 + d; } else { d = (world_x2 - world_x1) * m_kx / m_ky; world_x1 += (world_x2 - world_x1 - d) * m_align_x; world_x2 = world_x1 + d; } } m_wx1 = world_x1; m_wy1 = world_y1; m_wx2 = world_x2; m_wy2 = world_y2; m_dx1 = device_x1; m_dy1 = device_y1; m_kx = (device_x2 - device_x1) / (world_x2 - world_x1); m_ky = (device_y2 - device_y1) / (world_y2 - world_y1); m_is_valid = true; } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_trans_warp_magnifier.h0000644000175000017500000000306312516137326026166 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_WARP_MAGNIFIER_INCLUDED #define AGG_WARP_MAGNIFIER_INCLUDED namespace agg24 { //----------------------------------------------------trans_warp_magnifier // // See Inmplementation agg_trans_warp_magnifier.cpp // class trans_warp_magnifier { public: trans_warp_magnifier() : m_xc(0.0), m_yc(0.0), m_magn(1.0), m_radius(1.0) {} void center(double x, double y) { m_xc = x; m_yc = y; } void magnification(double m) { m_magn = m; } void radius(double r) { m_radius = r; } void transform(double* x, double* y) const; void inverse_transform(double* x, double* y) const; private: double m_xc; double m_yc; double m_magn; double m_radius; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_arc.h0000644000175000017500000000407612516137326022537 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Arc vertex generator // //---------------------------------------------------------------------------- #ifndef AGG_ARC_INCLUDED #define AGG_ARC_INCLUDED #include #include "agg_basics.h" namespace agg24 { //=====================================================================arc // // See Implementation agg_arc.cpp // class arc { public: arc() : m_scale(1.0), m_initialized(false) {} arc(double x, double y, double rx, double ry, double a1, double a2, bool ccw=true); void init(double x, double y, double rx, double ry, double a1, double a2, bool ccw=true); void approximation_scale(double s); double approximation_scale() const { return m_scale; } void rewind(unsigned); unsigned vertex(double* x, double* y); private: void normalize(double a1, double a2, bool ccw); double m_x; double m_y; double m_rx; double m_ry; double m_angle; double m_start; double m_end; double m_scale; double m_da; bool m_ccw; bool m_initialized; unsigned m_path_cmd; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_pixfmt_rgba.h0000644000175000017500000032206212516137326024272 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for high precision colors has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_PIXFMT_RGBA_INCLUDED #define AGG_PIXFMT_RGBA_INCLUDED #include #include #include "agg_basics.h" #include "agg_color_rgba.h" #include "agg_rendering_buffer.h" namespace agg24 { //=========================================================multiplier_rgba template struct multiplier_rgba { typedef typename ColorT::value_type value_type; typedef typename ColorT::calc_type calc_type; //-------------------------------------------------------------------- static AGG_INLINE void premultiply(value_type* p) { calc_type a = p[Order::A]; if(a < ColorT::base_mask) { if(a == 0) { p[Order::R] = p[Order::G] = p[Order::B] = 0; return; } p[Order::R] = value_type((p[Order::R] * a + ColorT::base_mask) >> ColorT::base_shift); p[Order::G] = value_type((p[Order::G] * a + ColorT::base_mask) >> ColorT::base_shift); p[Order::B] = value_type((p[Order::B] * a + ColorT::base_mask) >> ColorT::base_shift); } } //-------------------------------------------------------------------- static AGG_INLINE void demultiply(value_type* p) { calc_type a = p[Order::A]; if(a < ColorT::base_mask) { if(a == 0) { p[Order::R] = p[Order::G] = p[Order::B] = 0; return; } calc_type r = (calc_type(p[Order::R]) * ColorT::base_mask) / a; calc_type g = (calc_type(p[Order::G]) * ColorT::base_mask) / a; calc_type b = (calc_type(p[Order::B]) * ColorT::base_mask) / a; p[Order::R] = value_type((r > ColorT::base_mask) ? ColorT::base_mask : r); p[Order::G] = value_type((g > ColorT::base_mask) ? ColorT::base_mask : g); p[Order::B] = value_type((b > ColorT::base_mask) ? ColorT::base_mask : b); } } }; //=====================================================apply_gamma_dir_rgba template class apply_gamma_dir_rgba { public: typedef typename ColorT::value_type value_type; apply_gamma_dir_rgba(const GammaLut& gamma) : m_gamma(gamma) {} AGG_INLINE void operator () (value_type* p) { p[Order::R] = m_gamma.dir(p[Order::R]); p[Order::G] = m_gamma.dir(p[Order::G]); p[Order::B] = m_gamma.dir(p[Order::B]); } private: const GammaLut& m_gamma; }; //=====================================================apply_gamma_inv_rgba template class apply_gamma_inv_rgba { public: typedef typename ColorT::value_type value_type; apply_gamma_inv_rgba(const GammaLut& gamma) : m_gamma(gamma) {} AGG_INLINE void operator () (value_type* p) { p[Order::R] = m_gamma.inv(p[Order::R]); p[Order::G] = m_gamma.inv(p[Order::G]); p[Order::B] = m_gamma.inv(p[Order::B]); } private: const GammaLut& m_gamma; }; //=============================================================blender_rgba template struct blender_rgba { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- static AGG_INLINE void blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover=0) { calc_type r = p[Order::R]; calc_type g = p[Order::G]; calc_type b = p[Order::B]; calc_type a = p[Order::A]; p[Order::R] = (value_type)(((cr - r) * alpha + (r << base_shift)) >> base_shift); p[Order::G] = (value_type)(((cg - g) * alpha + (g << base_shift)) >> base_shift); p[Order::B] = (value_type)(((cb - b) * alpha + (b << base_shift)) >> base_shift); p[Order::A] = (value_type)((alpha + a) - ((alpha * a + base_mask) >> base_shift)); } }; //=========================================================blender_rgba_pre template struct blender_rgba_pre { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- static AGG_INLINE void blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover) { alpha = color_type::base_mask - alpha; cover = (cover + 1) << (base_shift - 8); p[Order::R] = (value_type)((p[Order::R] * alpha + cr * cover) >> base_shift); p[Order::G] = (value_type)((p[Order::G] * alpha + cg * cover) >> base_shift); p[Order::B] = (value_type)((p[Order::B] * alpha + cb * cover) >> base_shift); p[Order::A] = (value_type)(base_mask - ((alpha * (base_mask - p[Order::A])) >> base_shift)); } //-------------------------------------------------------------------- static AGG_INLINE void blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha) { alpha = color_type::base_mask - alpha; p[Order::R] = (value_type)(((p[Order::R] * alpha) >> base_shift) + cr); p[Order::G] = (value_type)(((p[Order::G] * alpha) >> base_shift) + cg); p[Order::B] = (value_type)(((p[Order::B] * alpha) >> base_shift) + cb); p[Order::A] = (value_type)(base_mask - ((alpha * (base_mask - p[Order::A])) >> base_shift)); } }; //======================================================blender_rgba_plain template struct blender_rgba_plain { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift }; //-------------------------------------------------------------------- static AGG_INLINE void blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover=0) { if(alpha == 0) return; calc_type a = p[Order::A]; calc_type r = p[Order::R] * a; calc_type g = p[Order::G] * a; calc_type b = p[Order::B] * a; a = ((alpha + a) << base_shift) - alpha * a; p[Order::A] = (value_type)(a >> base_shift); p[Order::R] = (value_type)((((cr << base_shift) - r) * alpha + (r << base_shift)) / a); p[Order::G] = (value_type)((((cg << base_shift) - g) * alpha + (g << base_shift)) / a); p[Order::B] = (value_type)((((cb << base_shift) - b) * alpha + (b << base_shift)) / a); } }; //=========================================================comp_op_rgba_clear template struct comp_op_rgba_clear { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; static AGG_INLINE void blend_pix(value_type* p, unsigned, unsigned, unsigned, unsigned, unsigned cover) { if(cover < 255) { cover = 255 - cover; p[Order::R] = (value_type)((p[Order::R] * cover + 255) >> 8); p[Order::G] = (value_type)((p[Order::G] * cover + 255) >> 8); p[Order::B] = (value_type)((p[Order::B] * cover + 255) >> 8); p[Order::A] = (value_type)((p[Order::A] * cover + 255) >> 8); } else { p[0] = p[1] = p[2] = p[3] = 0; } } }; //===========================================================comp_op_rgba_src template struct comp_op_rgba_src { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { unsigned alpha = 255 - cover; p[Order::R] = (value_type)(((p[Order::R] * alpha + 255) >> 8) + ((sr * cover + 255) >> 8)); p[Order::G] = (value_type)(((p[Order::G] * alpha + 255) >> 8) + ((sg * cover + 255) >> 8)); p[Order::B] = (value_type)(((p[Order::B] * alpha + 255) >> 8) + ((sb * cover + 255) >> 8)); p[Order::A] = (value_type)(((p[Order::A] * alpha + 255) >> 8) + ((sa * cover + 255) >> 8)); } else { p[Order::R] = sr; p[Order::G] = sg; p[Order::B] = sb; p[Order::A] = sa; } } }; //===========================================================comp_op_rgba_dst template struct comp_op_rgba_dst { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; static AGG_INLINE void blend_pix(value_type*, unsigned, unsigned, unsigned, unsigned, unsigned) { } }; //======================================================comp_op_rgba_src_over template struct comp_op_rgba_src_over { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = Sca + Dca.(1 - Sa) // Da' = Sa + Da - Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type s1a = base_mask - sa; p[Order::R] = (value_type)(sr + ((p[Order::R] * s1a + base_mask) >> base_shift)); p[Order::G] = (value_type)(sg + ((p[Order::G] * s1a + base_mask) >> base_shift)); p[Order::B] = (value_type)(sb + ((p[Order::B] * s1a + base_mask) >> base_shift)); p[Order::A] = (value_type)(sa + p[Order::A] - ((sa * p[Order::A] + base_mask) >> base_shift)); } }; //======================================================comp_op_rgba_dst_over template struct comp_op_rgba_dst_over { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = Dca + Sca.(1 - Da) // Da' = Sa + Da - Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type d1a = base_mask - p[Order::A]; p[Order::R] = (value_type)(p[Order::R] + ((sr * d1a + base_mask) >> base_shift)); p[Order::G] = (value_type)(p[Order::G] + ((sg * d1a + base_mask) >> base_shift)); p[Order::B] = (value_type)(p[Order::B] + ((sb * d1a + base_mask) >> base_shift)); p[Order::A] = (value_type)(sa + p[Order::A] - ((sa * p[Order::A] + base_mask) >> base_shift)); } }; //======================================================comp_op_rgba_src_in template struct comp_op_rgba_src_in { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = Sca.Da // Da' = Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { calc_type da = p[Order::A]; if(cover < 255) { unsigned alpha = 255 - cover; p[Order::R] = (value_type)(((p[Order::R] * alpha + 255) >> 8) + ((((sr * da + base_mask) >> base_shift) * cover + 255) >> 8)); p[Order::G] = (value_type)(((p[Order::G] * alpha + 255) >> 8) + ((((sg * da + base_mask) >> base_shift) * cover + 255) >> 8)); p[Order::B] = (value_type)(((p[Order::B] * alpha + 255) >> 8) + ((((sb * da + base_mask) >> base_shift) * cover + 255) >> 8)); p[Order::A] = (value_type)(((p[Order::A] * alpha + 255) >> 8) + ((((sa * da + base_mask) >> base_shift) * cover + 255) >> 8)); } else { p[Order::R] = (value_type)((sr * da + base_mask) >> base_shift); p[Order::G] = (value_type)((sg * da + base_mask) >> base_shift); p[Order::B] = (value_type)((sb * da + base_mask) >> base_shift); p[Order::A] = (value_type)((sa * da + base_mask) >> base_shift); } } }; //======================================================comp_op_rgba_dst_in template struct comp_op_rgba_dst_in { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = Dca.Sa // Da' = Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned, unsigned, unsigned, unsigned sa, unsigned cover) { if(cover < 255) { sa = base_mask - ((cover * (base_mask - sa) + 255) >> 8); } p[Order::R] = (value_type)((p[Order::R] * sa + base_mask) >> base_shift); p[Order::G] = (value_type)((p[Order::G] * sa + base_mask) >> base_shift); p[Order::B] = (value_type)((p[Order::B] * sa + base_mask) >> base_shift); p[Order::A] = (value_type)((p[Order::A] * sa + base_mask) >> base_shift); } }; //======================================================comp_op_rgba_src_out template struct comp_op_rgba_src_out { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = Sca.(1 - Da) // Da' = Sa.(1 - Da) static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { calc_type da = base_mask - p[Order::A]; if(cover < 255) { unsigned alpha = 255 - cover; p[Order::R] = (value_type)(((p[Order::R] * alpha + 255) >> 8) + ((((sr * da + base_mask) >> base_shift) * cover + 255) >> 8)); p[Order::G] = (value_type)(((p[Order::G] * alpha + 255) >> 8) + ((((sg * da + base_mask) >> base_shift) * cover + 255) >> 8)); p[Order::B] = (value_type)(((p[Order::B] * alpha + 255) >> 8) + ((((sb * da + base_mask) >> base_shift) * cover + 255) >> 8)); p[Order::A] = (value_type)(((p[Order::A] * alpha + 255) >> 8) + ((((sa * da + base_mask) >> base_shift) * cover + 255) >> 8)); } else { p[Order::R] = (value_type)((sr * da + base_mask) >> base_shift); p[Order::G] = (value_type)((sg * da + base_mask) >> base_shift); p[Order::B] = (value_type)((sb * da + base_mask) >> base_shift); p[Order::A] = (value_type)((sa * da + base_mask) >> base_shift); } } }; //======================================================comp_op_rgba_dst_out template struct comp_op_rgba_dst_out { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = Dca.(1 - Sa) // Da' = Da.(1 - Sa) static AGG_INLINE void blend_pix(value_type* p, unsigned, unsigned, unsigned, unsigned sa, unsigned cover) { if(cover < 255) { sa = (sa * cover + 255) >> 8; } sa = base_mask - sa; p[Order::R] = (value_type)((p[Order::R] * sa + base_shift) >> base_shift); p[Order::G] = (value_type)((p[Order::G] * sa + base_shift) >> base_shift); p[Order::B] = (value_type)((p[Order::B] * sa + base_shift) >> base_shift); p[Order::A] = (value_type)((p[Order::A] * sa + base_shift) >> base_shift); } }; //=====================================================comp_op_rgba_src_atop template struct comp_op_rgba_src_atop { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = Sca.Da + Dca.(1 - Sa) // Da' = Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type da = p[Order::A]; sa = base_mask - sa; p[Order::R] = (value_type)((sr * da + p[Order::R] * sa + base_mask) >> base_shift); p[Order::G] = (value_type)((sg * da + p[Order::G] * sa + base_mask) >> base_shift); p[Order::B] = (value_type)((sb * da + p[Order::B] * sa + base_mask) >> base_shift); } }; //=====================================================comp_op_rgba_dst_atop template struct comp_op_rgba_dst_atop { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = Dca.Sa + Sca.(1 - Da) // Da' = Sa static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { calc_type da = base_mask - p[Order::A]; if(cover < 255) { unsigned alpha = 255 - cover; sr = (p[Order::R] * sa + sr * da + base_mask) >> base_shift; sg = (p[Order::G] * sa + sg * da + base_mask) >> base_shift; sb = (p[Order::B] * sa + sb * da + base_mask) >> base_shift; p[Order::R] = (value_type)(((p[Order::R] * alpha + 255) >> 8) + ((sr * cover + 255) >> 8)); p[Order::G] = (value_type)(((p[Order::G] * alpha + 255) >> 8) + ((sg * cover + 255) >> 8)); p[Order::B] = (value_type)(((p[Order::B] * alpha + 255) >> 8) + ((sb * cover + 255) >> 8)); p[Order::A] = (value_type)(((p[Order::A] * alpha + 255) >> 8) + ((sa * cover + 255) >> 8)); } else { p[Order::R] = (value_type)((p[Order::R] * sa + sr * da + base_mask) >> base_shift); p[Order::G] = (value_type)((p[Order::G] * sa + sg * da + base_mask) >> base_shift); p[Order::B] = (value_type)((p[Order::B] * sa + sb * da + base_mask) >> base_shift); p[Order::A] = (value_type)sa; } } }; //=========================================================comp_op_rgba_xor template struct comp_op_rgba_xor { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = Sca.(1 - Da) + Dca.(1 - Sa) // Da' = Sa + Da - 2.Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type s1a = base_mask - sa; calc_type d1a = base_mask - p[Order::A]; p[Order::R] = (value_type)((p[Order::R] * s1a + sr * d1a + base_mask) >> base_shift); p[Order::G] = (value_type)((p[Order::G] * s1a + sg * d1a + base_mask) >> base_shift); p[Order::B] = (value_type)((p[Order::B] * s1a + sb * d1a + base_mask) >> base_shift); p[Order::A] = (value_type)(sa + p[Order::A] - ((sa * p[Order::A] + base_mask/2) >> (base_shift - 1))); } }; //=========================================================comp_op_rgba_plus template struct comp_op_rgba_plus { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = Sca + Dca // Da' = Sa + Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type dr = p[Order::R] + sr; calc_type dg = p[Order::G] + sg; calc_type db = p[Order::B] + sb; calc_type da = p[Order::A] + sa; p[Order::R] = (dr > base_mask) ? base_mask : dr; p[Order::G] = (dg > base_mask) ? base_mask : dg; p[Order::B] = (db > base_mask) ? base_mask : db; p[Order::A] = (da > base_mask) ? base_mask : da; } }; //========================================================comp_op_rgba_minus template struct comp_op_rgba_minus { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = Dca - Sca // Da' = 1 - (1 - Sa).(1 - Da) static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type dr = p[Order::R] - sr; calc_type dg = p[Order::G] - sg; calc_type db = p[Order::B] - sb; p[Order::R] = (dr > base_mask) ? 0 : dr; p[Order::G] = (dg > base_mask) ? 0 : dg; p[Order::B] = (db > base_mask) ? 0 : db; p[Order::A] = (value_type)(base_mask - (((base_mask - sa) * (base_mask - p[Order::A]) + base_mask) >> base_shift)); } }; //=====================================================comp_op_rgba_multiply template struct comp_op_rgba_multiply { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) // Da' = Sa + Da - Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type s1a = base_mask - sa; calc_type d1a = base_mask - p[Order::A]; calc_type dr = p[Order::R]; calc_type dg = p[Order::G]; calc_type db = p[Order::B]; p[Order::R] = (value_type)((sr * dr + sr * d1a + dr * s1a + base_mask) >> base_shift); p[Order::G] = (value_type)((sg * dg + sg * d1a + dg * s1a + base_mask) >> base_shift); p[Order::B] = (value_type)((sb * db + sb * d1a + db * s1a + base_mask) >> base_shift); p[Order::A] = (value_type)(sa + p[Order::A] - ((sa * p[Order::A] + base_mask) >> base_shift)); } }; //=====================================================comp_op_rgba_screen template struct comp_op_rgba_screen { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = Sca + Dca - Sca.Dca // Da' = Sa + Da - Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type dr = p[Order::R]; calc_type dg = p[Order::G]; calc_type db = p[Order::B]; calc_type da = p[Order::A]; p[Order::R] = (value_type)(sr + dr - ((sr * dr + base_mask) >> base_shift)); p[Order::G] = (value_type)(sg + dg - ((sg * dg + base_mask) >> base_shift)); p[Order::B] = (value_type)(sb + db - ((sb * db + base_mask) >> base_shift)); p[Order::A] = (value_type)(sa + da - ((sa * da + base_mask) >> base_shift)); } }; //=====================================================comp_op_rgba_overlay template struct comp_op_rgba_overlay { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // if 2.Dca < Da // Dca' = 2.Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) // otherwise // Dca' = Sa.Da - 2.(Da - Dca).(Sa - Sca) + Sca.(1 - Da) + Dca.(1 - Sa) // // Da' = Sa + Da - Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type d1a = base_mask - p[Order::A]; calc_type s1a = base_mask - sa; calc_type dr = p[Order::R]; calc_type dg = p[Order::G]; calc_type db = p[Order::B]; calc_type da = p[Order::A]; calc_type sada = sa * p[Order::A]; p[Order::R] = (value_type)(((2*dr < da) ? 2*sr*dr + sr*d1a + dr*s1a : sada - 2*(da - dr)*(sa - sr) + sr*d1a + dr*s1a) >> base_shift); p[Order::G] = (value_type)(((2*dg < da) ? 2*sg*dg + sg*d1a + dg*s1a : sada - 2*(da - dg)*(sa - sg) + sg*d1a + dg*s1a) >> base_shift); p[Order::B] = (value_type)(((2*db < da) ? 2*sb*db + sb*d1a + db*s1a : sada - 2*(da - db)*(sa - sb) + sb*d1a + db*s1a) >> base_shift); p[Order::A] = (value_type)(sa + da - ((sa * da + base_mask) >> base_shift)); } }; template inline T sd_min(T a, T b) { return (a < b) ? a : b; } template inline T sd_max(T a, T b) { return (a > b) ? a : b; } //=====================================================comp_op_rgba_darken template struct comp_op_rgba_darken { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = min(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) // Da' = Sa + Da - Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type d1a = base_mask - p[Order::A]; calc_type s1a = base_mask - sa; calc_type dr = p[Order::R]; calc_type dg = p[Order::G]; calc_type db = p[Order::B]; calc_type da = p[Order::A]; p[Order::R] = (value_type)((sd_min(sr * da, dr * sa) + sr * d1a + dr * s1a) >> base_shift); p[Order::G] = (value_type)((sd_min(sg * da, dg * sa) + sg * d1a + dg * s1a) >> base_shift); p[Order::B] = (value_type)((sd_min(sb * da, db * sa) + sb * d1a + db * s1a) >> base_shift); p[Order::A] = (value_type)(sa + da - ((sa * da + base_mask) >> base_shift)); } }; //=====================================================comp_op_rgba_lighten template struct comp_op_rgba_lighten { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = max(Sca.Da, Dca.Sa) + Sca.(1 - Da) + Dca.(1 - Sa) // Da' = Sa + Da - Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type d1a = base_mask - p[Order::A]; calc_type s1a = base_mask - sa; calc_type dr = p[Order::R]; calc_type dg = p[Order::G]; calc_type db = p[Order::B]; calc_type da = p[Order::A]; p[Order::R] = (value_type)((sd_max(sr * da, dr * sa) + sr * d1a + dr * s1a) >> base_shift); p[Order::G] = (value_type)((sd_max(sg * da, dg * sa) + sg * d1a + dg * s1a) >> base_shift); p[Order::B] = (value_type)((sd_max(sb * da, db * sa) + sb * d1a + db * s1a) >> base_shift); p[Order::A] = (value_type)(sa + da - ((sa * da + base_mask) >> base_shift)); } }; //=====================================================comp_op_rgba_color_dodge template struct comp_op_rgba_color_dodge { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; typedef typename color_type::long_type long_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // if Sca.Da + Dca.Sa >= Sa.Da // Dca' = Sa.Da + Sca.(1 - Da) + Dca.(1 - Sa) // otherwise // Dca' = Dca.Sa/(1-Sca/Sa) + Sca.(1 - Da) + Dca.(1 - Sa) // // Da' = Sa + Da - Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type d1a = base_mask - p[Order::A]; calc_type s1a = base_mask - sa; calc_type dr = p[Order::R]; calc_type dg = p[Order::G]; calc_type db = p[Order::B]; calc_type da = p[Order::A]; long_type drsa = dr * sa; long_type dgsa = dg * sa; long_type dbsa = db * sa; long_type srda = sr * da; long_type sgda = sg * da; long_type sbda = sb * da; long_type sada = sa * da; p[Order::R] = (value_type)((srda + drsa >= sada) ? (sada + sr * d1a + dr * s1a) >> base_shift : drsa / (base_mask - (sr << base_shift) / sa) + ((sr * d1a + dr * s1a) >> base_shift)); p[Order::G] = (value_type)((sgda + dgsa >= sada) ? (sada + sg * d1a + dg * s1a) >> base_shift : dgsa / (base_mask - (sg << base_shift) / sa) + ((sg * d1a + dg * s1a) >> base_shift)); p[Order::B] = (value_type)((sbda + dbsa >= sada) ? (sada + sb * d1a + db * s1a) >> base_shift : dbsa / (base_mask - (sb << base_shift) / sa) + ((sb * d1a + db * s1a) >> base_shift)); p[Order::A] = (value_type)(sa + da - ((sa * da + base_mask) >> base_shift)); } }; //=====================================================comp_op_rgba_color_burn template struct comp_op_rgba_color_burn { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; typedef typename color_type::long_type long_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // if Sca.Da + Dca.Sa <= Sa.Da // Dca' = Sca.(1 - Da) + Dca.(1 - Sa) // otherwise // Dca' = Sa.(Sca.Da + Dca.Sa - Sa.Da)/Sca + Sca.(1 - Da) + Dca.(1 - Sa) // // Da' = Sa + Da - Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type d1a = base_mask - p[Order::A]; calc_type s1a = base_mask - sa; calc_type dr = p[Order::R]; calc_type dg = p[Order::G]; calc_type db = p[Order::B]; calc_type da = p[Order::A]; long_type drsa = dr * sa; long_type dgsa = dg * sa; long_type dbsa = db * sa; long_type srda = sr * da; long_type sgda = sg * da; long_type sbda = sb * da; long_type sada = sa * da; p[Order::R] = (value_type)(((srda + drsa <= sada) ? sr * d1a + dr * s1a : sa * (srda + drsa - sada) / sr + sr * d1a + dr * s1a) >> base_shift); p[Order::G] = (value_type)(((sgda + dgsa <= sada) ? sg * d1a + dg * s1a : sa * (sgda + dgsa - sada) / sg + sg * d1a + dg * s1a) >> base_shift); p[Order::B] = (value_type)(((sbda + dbsa <= sada) ? sb * d1a + db * s1a : sa * (sbda + dbsa - sada) / sb + sb * d1a + db * s1a) >> base_shift); p[Order::A] = (value_type)(sa + da - ((sa * da + base_mask) >> base_shift)); } }; //=====================================================comp_op_rgba_hard_light template struct comp_op_rgba_hard_light { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; typedef typename color_type::long_type long_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // if 2.Sca < Sa // Dca' = 2.Sca.Dca + Sca.(1 - Da) + Dca.(1 - Sa) // otherwise // Dca' = Sa.Da - 2.(Da - Dca).(Sa - Sca) + Sca.(1 - Da) + Dca.(1 - Sa) // // Da' = Sa + Da - Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type d1a = base_mask - p[Order::A]; calc_type s1a = base_mask - sa; calc_type dr = p[Order::R]; calc_type dg = p[Order::G]; calc_type db = p[Order::B]; calc_type da = p[Order::A]; calc_type sada = sa * da; p[Order::R] = (value_type)(((2*sr < sa) ? 2*sr*dr + sr*d1a + dr*s1a : sada - 2*(da - dr)*(sa - sr) + sr*d1a + dr*s1a) >> base_shift); p[Order::G] = (value_type)(((2*sg < sa) ? 2*sg*dg + sg*d1a + dg*s1a : sada - 2*(da - dg)*(sa - sg) + sg*d1a + dg*s1a) >> base_shift); p[Order::B] = (value_type)(((2*sb < sa) ? 2*sb*db + sb*d1a + db*s1a : sada - 2*(da - db)*(sa - sb) + sb*d1a + db*s1a) >> base_shift); p[Order::A] = (value_type)(sa + da - ((sa * da + base_mask) >> base_shift)); } }; //=====================================================comp_op_rgba_soft_light template struct comp_op_rgba_soft_light { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; typedef typename color_type::long_type long_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // if 2.Sca < Sa // Dca' = Dca.(Sa + (1 - Dca/Da).(2.Sca - Sa)) + Sca.(1 - Da) + Dca.(1 - Sa) // otherwise if 8.Dca <= Da // Dca' = Dca.(Sa + (1 - Dca/Da).(2.Sca - Sa).(3 - 8.Dca/Da)) + Sca.(1 - Da) + Dca.(1 - Sa) // otherwise // Dca' = (Dca.Sa + ((Dca/Da)^(0.5).Da - Dca).(2.Sca - Sa)) + Sca.(1 - Da) + Dca.(1 - Sa) // // Da' = Sa + Da - Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned r, unsigned g, unsigned b, unsigned a, unsigned cover) { double sr = double(r * cover) / (base_mask * 255); double sg = double(g * cover) / (base_mask * 255); double sb = double(b * cover) / (base_mask * 255); double sa = double(a * cover) / (base_mask * 255); double dr = double(p[Order::R]) / base_mask; double dg = double(p[Order::G]) / base_mask; double db = double(p[Order::B]) / base_mask; double da = double(p[Order::A] ? p[Order::A] : 1) / base_mask; if(cover < 255) { a = (a * cover + 255) >> 8; } if(2*sr < sa) dr = dr*(sa + (1 - dr/da)*(2*sr - sa)) + sr*(1 - da) + dr*(1 - sa); else if(8*dr <= da) dr = dr*(sa + (1 - dr/da)*(2*sr - sa)*(3 - 8*dr/da)) + sr*(1 - da) + dr*(1 - sa); else dr = (dr*sa + (sqrt(dr/da)*da - dr)*(2*sr - sa)) + sr*(1 - da) + dr*(1 - sa); if(2*sg < sa) dg = dg*(sa + (1 - dg/da)*(2*sg - sa)) + sg*(1 - da) + dg*(1 - sa); else if(8*dg <= da) dg = dg*(sa + (1 - dg/da)*(2*sg - sa)*(3 - 8*dg/da)) + sg*(1 - da) + dg*(1 - sa); else dg = (dg*sa + (sqrt(dg/da)*da - dg)*(2*sg - sa)) + sg*(1 - da) + dg*(1 - sa); if(2*sb < sa) db = db*(sa + (1 - db/da)*(2*sb - sa)) + sb*(1 - da) + db*(1 - sa); else if(8*db <= da) db = db*(sa + (1 - db/da)*(2*sb - sa)*(3 - 8*db/da)) + sb*(1 - da) + db*(1 - sa); else db = (db*sa + (sqrt(db/da)*da - db)*(2*sb - sa)) + sb*(1 - da) + db*(1 - sa); p[Order::R] = (value_type)uround(dr * base_mask); p[Order::G] = (value_type)uround(dg * base_mask); p[Order::B] = (value_type)uround(db * base_mask); p[Order::A] = (value_type)(a + p[Order::A] - ((a * p[Order::A] + base_mask) >> base_shift)); } }; //=====================================================comp_op_rgba_difference template struct comp_op_rgba_difference { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; typedef typename color_type::long_type long_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = Sca + Dca - 2.min(Sca.Da, Dca.Sa) // Da' = Sa + Da - Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type dr = p[Order::R]; calc_type dg = p[Order::G]; calc_type db = p[Order::B]; calc_type da = p[Order::A]; p[Order::R] = (value_type)(sr + dr - ((2 * sd_min(sr*da, dr*sa)) >> base_shift)); p[Order::G] = (value_type)(sg + dg - ((2 * sd_min(sg*da, dg*sa)) >> base_shift)); p[Order::B] = (value_type)(sb + db - ((2 * sd_min(sb*da, db*sa)) >> base_shift)); p[Order::A] = (value_type)(sa + da - ((sa * da + base_mask) >> base_shift)); } }; //=====================================================comp_op_rgba_exclusion template struct comp_op_rgba_exclusion { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; typedef typename color_type::long_type long_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; // Dca' = (Sca.Da + Dca.Sa - 2.Sca.Dca) + Sca.(1 - Da) + Dca.(1 - Sa) // Da' = Sa + Da - Sa.Da static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } calc_type d1a = base_mask - p[Order::A]; calc_type s1a = base_mask - sa; calc_type dr = p[Order::R]; calc_type dg = p[Order::G]; calc_type db = p[Order::B]; calc_type da = p[Order::A]; p[Order::R] = (value_type)((sr*da + dr*sa - 2*sr*dr + sr*d1a + dr*s1a) >> base_shift); p[Order::G] = (value_type)((sg*da + dg*sa - 2*sg*dg + sg*d1a + dg*s1a) >> base_shift); p[Order::B] = (value_type)((sb*da + db*sa - 2*sb*db + sb*d1a + db*s1a) >> base_shift); p[Order::A] = (value_type)(sa + da - ((sa * da + base_mask) >> base_shift)); } }; //=====================================================comp_op_rgba_contrast template struct comp_op_rgba_contrast { typedef ColorT color_type; typedef Order order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; typedef typename color_type::long_type long_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; static AGG_INLINE void blend_pix(value_type* p, unsigned sr, unsigned sg, unsigned sb, unsigned sa, unsigned cover) { if(cover < 255) { sr = (sr * cover + 255) >> 8; sg = (sg * cover + 255) >> 8; sb = (sb * cover + 255) >> 8; sa = (sa * cover + 255) >> 8; } long_type dr = p[Order::R]; long_type dg = p[Order::G]; long_type db = p[Order::B]; int da = p[Order::A]; long_type d2a = da >> 1; unsigned s2a = sa >> 1; int r = (int)((((dr - d2a) * int((sr - s2a)*2 + base_mask)) >> base_shift) + d2a); int g = (int)((((dg - d2a) * int((sg - s2a)*2 + base_mask)) >> base_shift) + d2a); int b = (int)((((db - d2a) * int((sb - s2a)*2 + base_mask)) >> base_shift) + d2a); r = (r < 0) ? 0 : r; g = (g < 0) ? 0 : g; b = (b < 0) ? 0 : b; p[Order::R] = (value_type)((r > da) ? da : r); p[Order::G] = (value_type)((g > da) ? da : g); p[Order::B] = (value_type)((b > da) ? da : b); } }; //======================================================comp_op_table_rgba template struct comp_op_table_rgba { typedef typename ColorT::value_type value_type; typedef void (*comp_op_func_type)(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned ca, unsigned cover); static comp_op_func_type g_comp_op_func[]; }; //==========================================================g_comp_op_func template typename comp_op_table_rgba::comp_op_func_type comp_op_table_rgba::g_comp_op_func[] = { comp_op_rgba_clear ::blend_pix, comp_op_rgba_src ::blend_pix, comp_op_rgba_dst ::blend_pix, comp_op_rgba_src_over ::blend_pix, comp_op_rgba_dst_over ::blend_pix, comp_op_rgba_src_in ::blend_pix, comp_op_rgba_dst_in ::blend_pix, comp_op_rgba_src_out ::blend_pix, comp_op_rgba_dst_out ::blend_pix, comp_op_rgba_src_atop ::blend_pix, comp_op_rgba_dst_atop ::blend_pix, comp_op_rgba_xor ::blend_pix, comp_op_rgba_plus ::blend_pix, comp_op_rgba_minus ::blend_pix, comp_op_rgba_multiply ::blend_pix, comp_op_rgba_screen ::blend_pix, comp_op_rgba_overlay ::blend_pix, comp_op_rgba_darken ::blend_pix, comp_op_rgba_lighten ::blend_pix, comp_op_rgba_color_dodge::blend_pix, comp_op_rgba_color_burn ::blend_pix, comp_op_rgba_hard_light ::blend_pix, comp_op_rgba_soft_light ::blend_pix, comp_op_rgba_difference ::blend_pix, comp_op_rgba_exclusion ::blend_pix, comp_op_rgba_contrast ::blend_pix, 0 }; //==============================================================comp_op_e enum comp_op_e { comp_op_clear, //----comp_op_clear comp_op_src, //----comp_op_src comp_op_dst, //----comp_op_dst comp_op_src_over, //----comp_op_src_over comp_op_dst_over, //----comp_op_dst_over comp_op_src_in, //----comp_op_src_in comp_op_dst_in, //----comp_op_dst_in comp_op_src_out, //----comp_op_src_out comp_op_dst_out, //----comp_op_dst_out comp_op_src_atop, //----comp_op_src_atop comp_op_dst_atop, //----comp_op_dst_atop comp_op_xor, //----comp_op_xor comp_op_plus, //----comp_op_plus comp_op_minus, //----comp_op_minus comp_op_multiply, //----comp_op_multiply comp_op_screen, //----comp_op_screen comp_op_overlay, //----comp_op_overlay comp_op_darken, //----comp_op_darken comp_op_lighten, //----comp_op_lighten comp_op_color_dodge, //----comp_op_color_dodge comp_op_color_burn, //----comp_op_color_burn comp_op_hard_light, //----comp_op_hard_light comp_op_soft_light, //----comp_op_soft_light comp_op_difference, //----comp_op_difference comp_op_exclusion, //----comp_op_exclusion comp_op_contrast, //----comp_op_contrast end_of_comp_op_e }; //====================================================comp_op_adaptor_rgba template struct comp_op_adaptor_rgba { typedef Order order_type; typedef ColorT color_type; typedef typename color_type::value_type value_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; static AGG_INLINE void blend_pix(unsigned op, value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned ca, unsigned cover) { comp_op_table_rgba::g_comp_op_func[op] (p, (cr * ca + base_mask) >> base_shift, (cg * ca + base_mask) >> base_shift, (cb * ca + base_mask) >> base_shift, ca, cover); } }; //=========================================comp_op_adaptor_clip_to_dst_rgba template struct comp_op_adaptor_clip_to_dst_rgba { typedef Order order_type; typedef ColorT color_type; typedef typename color_type::value_type value_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; static AGG_INLINE void blend_pix(unsigned op, value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned ca, unsigned cover) { cr = (cr * ca + base_mask) >> base_shift; cg = (cg * ca + base_mask) >> base_shift; cb = (cb * ca + base_mask) >> base_shift; unsigned da = p[Order::A]; comp_op_table_rgba::g_comp_op_func[op] (p, (cr * da + base_mask) >> base_shift, (cg * da + base_mask) >> base_shift, (cb * da + base_mask) >> base_shift, (ca * da + base_mask) >> base_shift, cover); } }; //================================================comp_op_adaptor_rgba_pre template struct comp_op_adaptor_rgba_pre { typedef Order order_type; typedef ColorT color_type; typedef typename color_type::value_type value_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; static AGG_INLINE void blend_pix(unsigned op, value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned ca, unsigned cover) { comp_op_table_rgba::g_comp_op_func[op](p, cr, cg, cb, ca, cover); } }; //=====================================comp_op_adaptor_clip_to_dst_rgba_pre template struct comp_op_adaptor_clip_to_dst_rgba_pre { typedef Order order_type; typedef ColorT color_type; typedef typename color_type::value_type value_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; static AGG_INLINE void blend_pix(unsigned op, value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned ca, unsigned cover) { unsigned da = p[Order::A]; comp_op_table_rgba::g_comp_op_func[op] (p, (cr * da + base_mask) >> base_shift, (cg * da + base_mask) >> base_shift, (cb * da + base_mask) >> base_shift, (ca * da + base_mask) >> base_shift, cover); } }; //=======================================================comp_adaptor_rgba template struct comp_adaptor_rgba { typedef typename BlenderPre::order_type order_type; typedef typename BlenderPre::color_type color_type; typedef typename color_type::value_type value_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; static AGG_INLINE void blend_pix(unsigned op, value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned ca, unsigned cover) { BlenderPre::blend_pix(p, (cr * ca + base_mask) >> base_shift, (cg * ca + base_mask) >> base_shift, (cb * ca + base_mask) >> base_shift, ca, cover); } }; //==========================================comp_adaptor_clip_to_dst_rgba template struct comp_adaptor_clip_to_dst_rgba { typedef typename BlenderPre::order_type order_type; typedef typename BlenderPre::color_type color_type; typedef typename color_type::value_type value_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; static AGG_INLINE void blend_pix(unsigned op, value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned ca, unsigned cover) { cr = (cr * ca + base_mask) >> base_shift; cg = (cg * ca + base_mask) >> base_shift; cb = (cb * ca + base_mask) >> base_shift; unsigned da = p[order_type::A]; BlenderPre::blend_pix(p, (cr * da + base_mask) >> base_shift, (cg * da + base_mask) >> base_shift, (cb * da + base_mask) >> base_shift, (ca * da + base_mask) >> base_shift, cover); } }; //======================================comp_adaptor_clip_to_dst_rgba_pre template struct comp_adaptor_clip_to_dst_rgba_pre { typedef typename BlenderPre::order_type order_type; typedef typename BlenderPre::color_type color_type; typedef typename color_type::value_type value_type; enum base_scale_e { base_shift = color_type::base_shift, base_mask = color_type::base_mask }; static AGG_INLINE void blend_pix(unsigned op, value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned ca, unsigned cover) { unsigned da = p[order_type::A]; BlenderPre::blend_pix(p, (cr * da + base_mask) >> base_shift, (cg * da + base_mask) >> base_shift, (cb * da + base_mask) >> base_shift, (ca * da + base_mask) >> base_shift, cover); } }; //===============================================copy_or_blend_rgba_wrapper template struct copy_or_blend_rgba_wrapper { typedef typename Blender::color_type color_type; typedef typename Blender::order_type order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_scale = color_type::base_scale, base_mask = color_type::base_mask }; //-------------------------------------------------------------------- static AGG_INLINE void copy_or_blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha) { if(alpha) { if(alpha == base_mask) { p[order_type::R] = cr; p[order_type::G] = cg; p[order_type::B] = cb; p[order_type::A] = base_mask; } else { Blender::blend_pix(p, cr, cg, cb, alpha); } } } //-------------------------------------------------------------------- static AGG_INLINE void copy_or_blend_pix(value_type* p, unsigned cr, unsigned cg, unsigned cb, unsigned alpha, unsigned cover) { if(cover == 255) { copy_or_blend_pix(p, cr, cg, cb, alpha); } else { if(alpha) { alpha = (alpha * (cover + 1)) >> 8; if(alpha == base_mask) { p[order_type::R] = cr; p[order_type::G] = cg; p[order_type::B] = cb; p[order_type::A] = base_mask; } else { Blender::blend_pix(p, cr, cg, cb, alpha, cover); } } } } }; //=================================================pixfmt_alpha_blend_rgba template class pixfmt_alpha_blend_rgba { public: typedef RenBuf rbuf_type; typedef typename rbuf_type::row_data row_data; typedef PixelT pixel_type; typedef Blender blender_type; typedef typename blender_type::color_type color_type; typedef typename blender_type::order_type order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; typedef copy_or_blend_rgba_wrapper cob_type; enum base_scale_e { base_shift = color_type::base_shift, base_scale = color_type::base_scale, base_mask = color_type::base_mask, pix_width = sizeof(pixel_type) }; //-------------------------------------------------------------------- pixfmt_alpha_blend_rgba() : m_rbuf(0) {} pixfmt_alpha_blend_rgba(rbuf_type& rb) : m_rbuf(&rb) {} void attach(rbuf_type& rb) { m_rbuf = &rb; } //-------------------------------------------------------------------- AGG_INLINE unsigned width() const { return m_rbuf->width(); } AGG_INLINE unsigned height() const { return m_rbuf->height(); } //-------------------------------------------------------------------- const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); } //-------------------------------------------------------------------- const int8u* pix_ptr(int x, int y) const { return m_rbuf->row_ptr(y) + x * pix_width; } //-------------------------------------------------------------------- row_data row(int y) const { return m_rbuf->row(y); } //-------------------------------------------------------------------- AGG_INLINE static void make_pix(int8u* p, const color_type& c) { ((value_type*)p)[order_type::R] = c.r; ((value_type*)p)[order_type::G] = c.g; ((value_type*)p)[order_type::B] = c.b; ((value_type*)p)[order_type::A] = c.a; } //-------------------------------------------------------------------- AGG_INLINE color_type pixel(int x, int y) const { const value_type* p = (const value_type*)m_rbuf->row_ptr(y); if(p) { p += x << 2; return color_type(p[order_type::R], p[order_type::G], p[order_type::B], p[order_type::A]); } return color_type::no_color(); } //-------------------------------------------------------------------- AGG_INLINE void copy_pixel(int x, int y, const color_type& c) { value_type* p = (value_type*)m_rbuf->row_ptr(x, y, 1) + (x << 2); p[order_type::R] = c.r; p[order_type::G] = c.g; p[order_type::B] = c.b; p[order_type::A] = c.a; } //-------------------------------------------------------------------- AGG_INLINE void blend_pixel(int x, int y, const color_type& c, int8u cover) { cob_type::copy_or_blend_pix( (value_type*)m_rbuf->row_ptr(x, y, 1) + (x << 2), c.r, c.g, c.b, c.a, cover); } //-------------------------------------------------------------------- AGG_INLINE void copy_hline(int x, int y, unsigned len, const color_type& c) { value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + (x << 2); pixel_type v; ((value_type*)&v)[order_type::R] = c.r; ((value_type*)&v)[order_type::G] = c.g; ((value_type*)&v)[order_type::B] = c.b; ((value_type*)&v)[order_type::A] = c.a; do { *(pixel_type*)p = v; p += 4; } while(--len); } //-------------------------------------------------------------------- AGG_INLINE void copy_vline(int x, int y, unsigned len, const color_type& c) { pixel_type v; ((value_type*)&v)[order_type::R] = c.r; ((value_type*)&v)[order_type::G] = c.g; ((value_type*)&v)[order_type::B] = c.b; ((value_type*)&v)[order_type::A] = c.a; do { value_type* p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + (x << 2); *(pixel_type*)p = v; } while(--len); } //-------------------------------------------------------------------- void blend_hline(int x, int y, unsigned len, const color_type& c, int8u cover) { if (c.a) { value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + (x << 2); calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; if(alpha == base_mask) { pixel_type v; ((value_type*)&v)[order_type::R] = c.r; ((value_type*)&v)[order_type::G] = c.g; ((value_type*)&v)[order_type::B] = c.b; ((value_type*)&v)[order_type::A] = c.a; do { *(pixel_type*)p = v; p += 4; } while(--len); } else { if(cover == 255) { do { blender_type::blend_pix(p, c.r, c.g, c.b, alpha); p += 4; } while(--len); } else { do { blender_type::blend_pix(p, c.r, c.g, c.b, alpha, cover); p += 4; } while(--len); } } } } //-------------------------------------------------------------------- void blend_vline(int x, int y, unsigned len, const color_type& c, int8u cover) { if (c.a) { value_type* p; calc_type alpha = (calc_type(c.a) * (cover + 1)) >> 8; if(alpha == base_mask) { pixel_type v; ((value_type*)&v)[order_type::R] = c.r; ((value_type*)&v)[order_type::G] = c.g; ((value_type*)&v)[order_type::B] = c.b; ((value_type*)&v)[order_type::A] = c.a; do { p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + (x << 2); *(pixel_type*)p = v; } while(--len); } else { if(cover == 255) { do { p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + (x << 2); blender_type::blend_pix(p, c.r, c.g, c.b, alpha); } while(--len); } else { do { p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + (x << 2); blender_type::blend_pix(p, c.r, c.g, c.b, alpha, cover); } while(--len); } } } } //-------------------------------------------------------------------- void blend_solid_hspan(int x, int y, unsigned len, const color_type& c, const int8u* covers) { if (c.a) { value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + (x << 2); do { calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8; if(alpha == base_mask) { p[order_type::R] = c.r; p[order_type::G] = c.g; p[order_type::B] = c.b; p[order_type::A] = base_mask; } else { blender_type::blend_pix(p, c.r, c.g, c.b, alpha, *covers); } p += 4; ++covers; } while(--len); } } //-------------------------------------------------------------------- void blend_solid_vspan(int x, int y, unsigned len, const color_type& c, const int8u* covers) { if (c.a) { do { value_type* p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + (x << 2); calc_type alpha = (calc_type(c.a) * (calc_type(*covers) + 1)) >> 8; if(alpha == base_mask) { p[order_type::R] = c.r; p[order_type::G] = c.g; p[order_type::B] = c.b; p[order_type::A] = base_mask; } else { blender_type::blend_pix(p, c.r, c.g, c.b, alpha, *covers); } ++covers; } while(--len); } } //-------------------------------------------------------------------- void copy_color_hspan(int x, int y, unsigned len, const color_type* colors) { value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + (x << 2); do { p[order_type::R] = colors->r; p[order_type::G] = colors->g; p[order_type::B] = colors->b; p[order_type::A] = colors->a; ++colors; p += 4; } while(--len); } //-------------------------------------------------------------------- void blend_color_hspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover) { value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + (x << 2); if(covers) { do { cob_type::copy_or_blend_pix(p, colors->r, colors->g, colors->b, colors->a, *covers++); p += 4; ++colors; } while(--len); } else { if(cover == 255) { do { cob_type::copy_or_blend_pix(p, colors->r, colors->g, colors->b, colors->a); p += 4; ++colors; } while(--len); } else { do { cob_type::copy_or_blend_pix(p, colors->r, colors->g, colors->b, colors->a, cover); p += 4; ++colors; } while(--len); } } } //-------------------------------------------------------------------- void blend_color_vspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover) { value_type* p; if(covers) { do { p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + (x << 2); cob_type::copy_or_blend_pix(p, colors->r, colors->g, colors->b, colors->a, *covers++); ++colors; } while(--len); } else { if(cover == 255) { do { p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + (x << 2); cob_type::copy_or_blend_pix(p, colors->r, colors->g, colors->b, colors->a); ++colors; } while(--len); } else { do { p = (value_type*)m_rbuf->row_ptr(x, y++, 1) + (x << 2); cob_type::copy_or_blend_pix(p, colors->r, colors->g, colors->b, colors->a, cover); ++colors; } while(--len); } } } //-------------------------------------------------------------------- template void for_each_pixel(Function f) { unsigned y; for(y = 0; y < height(); ++y) { row_data r = m_rbuf->row(y); if(r.ptr) { unsigned len = r.x2 - r.x1 + 1; value_type* p = (value_type*)m_rbuf->row_ptr(r.x1, y, len) + (r.x1 << 2); do { f(p); p += 4; } while(--len); } } } //-------------------------------------------------------------------- void premultiply() { for_each_pixel(multiplier_rgba::premultiply); } //-------------------------------------------------------------------- void demultiply() { for_each_pixel(multiplier_rgba::demultiply); } //-------------------------------------------------------------------- template void apply_gamma_dir(const GammaLut& g) { for_each_pixel(apply_gamma_dir_rgba(g)); } //-------------------------------------------------------------------- template void apply_gamma_inv(const GammaLut& g) { for_each_pixel(apply_gamma_inv_rgba(g)); } //-------------------------------------------------------------------- template void copy_from(const RenBuf2& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len) { const int8u* p = from.row_ptr(ysrc); if(p) { memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, p + xsrc * pix_width, len * pix_width); } } //-------------------------------------------------------------------- template void blend_from(const SrcPixelFormatRenderer& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len, int8u cover) { typedef typename SrcPixelFormatRenderer::order_type src_order; const value_type* psrc = (value_type*)from.row_ptr(ysrc); if(psrc) { psrc += xsrc << 2; value_type* pdst = (value_type*)m_rbuf->row_ptr(xdst, ydst, len) + (xdst << 2); int incp = 4; if(xdst > xsrc) { psrc += (len-1) << 2; pdst += (len-1) << 2; incp = -4; } if(cover == 255) { do { cob_type::copy_or_blend_pix(pdst, psrc[src_order::R], psrc[src_order::G], psrc[src_order::B], psrc[src_order::A]); psrc += incp; pdst += incp; } while(--len); } else { do { cob_type::copy_or_blend_pix(pdst, psrc[src_order::R], psrc[src_order::G], psrc[src_order::B], psrc[src_order::A], cover); psrc += incp; pdst += incp; } while(--len); } } } private: rbuf_type* m_rbuf; }; //================================================pixfmt_custom_blend_rgba template class pixfmt_custom_blend_rgba { public: typedef RenBuf rbuf_type; typedef typename rbuf_type::row_data row_data; typedef Blender blender_type; typedef typename blender_type::color_type color_type; typedef typename blender_type::order_type order_type; typedef typename color_type::value_type value_type; typedef typename color_type::calc_type calc_type; enum base_scale_e { base_shift = color_type::base_shift, base_scale = color_type::base_scale, base_mask = color_type::base_mask, pix_width = sizeof(value_type) * 4 }; //-------------------------------------------------------------------- pixfmt_custom_blend_rgba() : m_rbuf(0), m_comp_op(3) {} pixfmt_custom_blend_rgba(rbuf_type& rb, unsigned comp_op=3) : m_rbuf(&rb), m_comp_op(comp_op) {} void attach(rbuf_type& rb) { m_rbuf = &rb; } //-------------------------------------------------------------------- unsigned width() const { return m_rbuf->width(); } unsigned height() const { return m_rbuf->height(); } //-------------------------------------------------------------------- void comp_op(unsigned op) { m_comp_op = op; } unsigned comp_op() const { return m_comp_op; } //-------------------------------------------------------------------- const int8u* row_ptr(int y) const { return m_rbuf->row_ptr(y); } //-------------------------------------------------------------------- const int8u* pix_ptr(int x, int y) const { return m_rbuf->row_ptr(y) + x * pix_width; } //-------------------------------------------------------------------- row_data row(int y) const { return m_rbuf->row(y); } //-------------------------------------------------------------------- AGG_INLINE static void make_pix(int8u* p, const color_type& c) { ((value_type*)p)[order_type::R] = c.r; ((value_type*)p)[order_type::G] = c.g; ((value_type*)p)[order_type::B] = c.b; ((value_type*)p)[order_type::A] = c.a; } //-------------------------------------------------------------------- color_type pixel(int x, int y) const { const value_type* p = (value_type*)m_rbuf->row_ptr(y) + (x << 2); return color_type(p[order_type::R], p[order_type::G], p[order_type::B], p[order_type::A]); } //-------------------------------------------------------------------- void copy_pixel(int x, int y, const color_type& c) { blender_type::blend_pix( m_comp_op, (value_type*)m_rbuf->row_ptr(x, y, 1) + (x << 2), c.r, c.g, c.b, c.a, 255); } //-------------------------------------------------------------------- void blend_pixel(int x, int y, const color_type& c, int8u cover) { blender_type::blend_pix( m_comp_op, (value_type*)m_rbuf->row_ptr(x, y, 1) + (x << 2), c.r, c.g, c.b, c.a, cover); } //-------------------------------------------------------------------- void copy_hline(int x, int y, unsigned len, const color_type& c) { value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + (x << 2);; do { blender_type::blend_pix(m_comp_op, p, c.r, c.g, c.b, c.a, 255); p += 4; } while(--len); } //-------------------------------------------------------------------- void copy_vline(int x, int y, unsigned len, const color_type& c) { do { blender_type::blend_pix( m_comp_op, (value_type*)m_rbuf->row_ptr(x, y++, 1) + (x << 2), c.r, c.g, c.b, c.a, 255); } while(--len); } //-------------------------------------------------------------------- void blend_hline(int x, int y, unsigned len, const color_type& c, int8u cover) { value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + (x << 2); do { blender_type::blend_pix(m_comp_op, p, c.r, c.g, c.b, c.a, cover); p += 4; } while(--len); } //-------------------------------------------------------------------- void blend_vline(int x, int y, unsigned len, const color_type& c, int8u cover) { do { blender_type::blend_pix( m_comp_op, (value_type*)m_rbuf->row_ptr(x, y++, 1) + (x << 2), c.r, c.g, c.b, c.a, cover); } while(--len); } //-------------------------------------------------------------------- void blend_solid_hspan(int x, int y, unsigned len, const color_type& c, const int8u* covers) { value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + (x << 2); do { blender_type::blend_pix(m_comp_op, p, c.r, c.g, c.b, c.a, *covers++); p += 4; } while(--len); } //-------------------------------------------------------------------- void blend_solid_vspan(int x, int y, unsigned len, const color_type& c, const int8u* covers) { do { blender_type::blend_pix( m_comp_op, (value_type*)m_rbuf->row_ptr(x, y++, 1) + (x << 2), c.r, c.g, c.b, c.a, *covers++); } while(--len); } //-------------------------------------------------------------------- void copy_color_hspan(int x, int y, unsigned len, const color_type* colors) { value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + (x << 2); do { p[order_type::R] = colors->r; p[order_type::G] = colors->g; p[order_type::B] = colors->b; p[order_type::A] = colors->a; ++colors; p += 4; } while(--len); } //-------------------------------------------------------------------- void blend_color_hspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover) { value_type* p = (value_type*)m_rbuf->row_ptr(x, y, len) + (x << 2); do { blender_type::blend_pix(m_comp_op, p, colors->r, colors->g, colors->b, colors->a, covers ? *covers++ : cover); p += 4; ++colors; } while(--len); } //-------------------------------------------------------------------- void blend_color_vspan(int x, int y, unsigned len, const color_type* colors, const int8u* covers, int8u cover) { do { blender_type::blend_pix( m_comp_op, (value_type*)m_rbuf->row_ptr(x, y++, 1) + (x << 2), colors->r, colors->g, colors->b, colors->a, covers ? *covers++ : cover); ++colors; } while(--len); } //-------------------------------------------------------------------- template void for_each_pixel(Function f) { unsigned y; for(y = 0; y < height(); ++y) { row_data r = m_rbuf->row(y); if(r.ptr) { unsigned len = r.x2 - r.x1 + 1; value_type* p = (value_type*)m_rbuf->row_ptr(r.x1, y, len) + (r.x1 << 2); do { f(p); p += 4; } while(--len); } } } //-------------------------------------------------------------------- void premultiply() { for_each_pixel(multiplier_rgba::premultiply); } //-------------------------------------------------------------------- void demultiply() { for_each_pixel(multiplier_rgba::demultiply); } //-------------------------------------------------------------------- template void apply_gamma_dir(const GammaLut& g) { for_each_pixel(apply_gamma_dir_rgba(g)); } //-------------------------------------------------------------------- template void apply_gamma_inv(const GammaLut& g) { for_each_pixel(apply_gamma_inv_rgba(g)); } //-------------------------------------------------------------------- template void copy_from(const RenBuf2& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len) { const int8u* p = from.row_ptr(ysrc); if(p) { memmove(m_rbuf->row_ptr(xdst, ydst, len) + xdst * pix_width, p + xsrc * pix_width, len * pix_width); } } //-------------------------------------------------------------------- template void blend_from(const SrcPixelFormatRenderer& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len, int8u cover) { typedef typename SrcPixelFormatRenderer::order_type src_order; const value_type* psrc = (const value_type*)from.row_ptr(ysrc); if(psrc) { psrc += xsrc << 2; value_type* pdst = (value_type*)m_rbuf->row_ptr(xdst, ydst, len) + (xdst << 2); int incp = 4; if(xdst > xsrc) { psrc += (len-1) << 2; pdst += (len-1) << 2; incp = -4; } do { blender_type::blend_pix(m_comp_op, pdst, psrc[src_order::R], psrc[src_order::G], psrc[src_order::B], psrc[src_order::A], cover); psrc += incp; pdst += incp; } while(--len); } } private: rbuf_type* m_rbuf; unsigned m_comp_op; }; //----------------------------------------------------------------------- typedef blender_rgba blender_rgba32; //----blender_rgba32 typedef blender_rgba blender_argb32; //----blender_argb32 typedef blender_rgba blender_abgr32; //----blender_abgr32 typedef blender_rgba blender_bgra32; //----blender_bgra32 typedef blender_rgba_pre blender_rgba32_pre; //----blender_rgba32_pre typedef blender_rgba_pre blender_argb32_pre; //----blender_argb32_pre typedef blender_rgba_pre blender_abgr32_pre; //----blender_abgr32_pre typedef blender_rgba_pre blender_bgra32_pre; //----blender_bgra32_pre typedef blender_rgba_plain blender_rgba32_plain; //----blender_rgba32_plain typedef blender_rgba_plain blender_argb32_plain; //----blender_argb32_plain typedef blender_rgba_plain blender_abgr32_plain; //----blender_abgr32_plain typedef blender_rgba_plain blender_bgra32_plain; //----blender_bgra32_plain typedef blender_rgba blender_rgba64; //----blender_rgba64 typedef blender_rgba blender_argb64; //----blender_argb64 typedef blender_rgba blender_abgr64; //----blender_abgr64 typedef blender_rgba blender_bgra64; //----blender_bgra64 typedef blender_rgba_pre blender_rgba64_pre; //----blender_rgba64_pre typedef blender_rgba_pre blender_argb64_pre; //----blender_argb64_pre typedef blender_rgba_pre blender_abgr64_pre; //----blender_abgr64_pre typedef blender_rgba_pre blender_bgra64_pre; //----blender_bgra64_pre //----------------------------------------------------------------------- typedef int32u pixel32_type; typedef pixfmt_alpha_blend_rgba pixfmt_rgba32; //----pixfmt_rgba32 typedef pixfmt_alpha_blend_rgba pixfmt_argb32; //----pixfmt_argb32 typedef pixfmt_alpha_blend_rgba pixfmt_abgr32; //----pixfmt_abgr32 typedef pixfmt_alpha_blend_rgba pixfmt_bgra32; //----pixfmt_bgra32 typedef pixfmt_alpha_blend_rgba pixfmt_rgba32_pre; //----pixfmt_rgba32_pre typedef pixfmt_alpha_blend_rgba pixfmt_argb32_pre; //----pixfmt_argb32_pre typedef pixfmt_alpha_blend_rgba pixfmt_abgr32_pre; //----pixfmt_abgr32_pre typedef pixfmt_alpha_blend_rgba pixfmt_bgra32_pre; //----pixfmt_bgra32_pre typedef pixfmt_alpha_blend_rgba pixfmt_rgba32_plain; //----pixfmt_rgba32_plain typedef pixfmt_alpha_blend_rgba pixfmt_argb32_plain; //----pixfmt_argb32_plain typedef pixfmt_alpha_blend_rgba pixfmt_abgr32_plain; //----pixfmt_abgr32_plain typedef pixfmt_alpha_blend_rgba pixfmt_bgra32_plain; //----pixfmt_bgra32_plain struct pixel64_type { int16u c[4]; }; typedef pixfmt_alpha_blend_rgba pixfmt_rgba64; //----pixfmt_rgba64 typedef pixfmt_alpha_blend_rgba pixfmt_argb64; //----pixfmt_argb64 typedef pixfmt_alpha_blend_rgba pixfmt_abgr64; //----pixfmt_abgr64 typedef pixfmt_alpha_blend_rgba pixfmt_bgra64; //----pixfmt_bgra64 typedef pixfmt_alpha_blend_rgba pixfmt_rgba64_pre; //----pixfmt_rgba64_pre typedef pixfmt_alpha_blend_rgba pixfmt_argb64_pre; //----pixfmt_argb64_pre typedef pixfmt_alpha_blend_rgba pixfmt_abgr64_pre; //----pixfmt_abgr64_pre typedef pixfmt_alpha_blend_rgba pixfmt_bgra64_pre; //----pixfmt_bgra64_pre } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_bitset_iterator.h0000644000175000017500000000270412516137326025171 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_BITSET_ITERATOR_INCLUDED #define AGG_BITSET_ITERATOR_INCLUDED #include "agg_basics.h" namespace agg24 { class bitset_iterator { public: bitset_iterator(const int8u* bits, unsigned offset = 0) : m_bits(bits + (offset >> 3)), m_mask(0x80 >> (offset & 7)) {} void operator ++ () { m_mask >>= 1; if(m_mask == 0) { ++m_bits; m_mask = 0x80; } } unsigned bit() const { return (*m_bits) & m_mask; } private: const int8u* m_bits; int8u m_mask; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_clip_polygon.h0000644000175000017500000000502612516137326025511 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Polygon clipping converter // There an optimized Liang-Basky algorithm is used. // The algorithm doesn't optimize the degenerate edges, i.e. it will never // break a closed polygon into two or more ones, instead, there will be // degenerate edges coinciding with the respective clipping boundaries. // This is a sub-optimal solution, because that optimization would require // extra, rather expensive math while the rasterizer tolerates it quite well, // without any considerable overhead. // //---------------------------------------------------------------------------- #ifndef AGG_CONV_CLIP_POLYGON_INCLUDED #define AGG_CONV_CLIP_POLYGON_INCLUDED #include "agg_basics.h" #include "agg_conv_adaptor_vpgen.h" #include "agg_vpgen_clip_polygon.h" namespace agg24 { //=======================================================conv_clip_polygon template struct conv_clip_polygon : public conv_adaptor_vpgen { typedef conv_adaptor_vpgen base_type; conv_clip_polygon(VertexSource& vs) : conv_adaptor_vpgen(vs) {} void clip_box(double x1, double y1, double x2, double y2) { base_type::vpgen().clip_box(x1, y1, x2, y2); } double x1() const { return base_type::vpgen().x1(); } double y1() const { return base_type::vpgen().y1(); } double x2() const { return base_type::vpgen().x2(); } double y2() const { return base_type::vpgen().y2(); } private: conv_clip_polygon(const conv_clip_polygon&); const conv_clip_polygon& operator = (const conv_clip_polygon&); }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_interpolator_linear.h0000644000175000017500000001723412516137326027067 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_SPAN_INTERPOLATOR_LINEAR_INCLUDED #define AGG_SPAN_INTERPOLATOR_LINEAR_INCLUDED #include "agg_basics.h" #include "agg_dda_line.h" #include "agg_trans_affine.h" namespace agg24 { //================================================span_interpolator_linear template class span_interpolator_linear { public: typedef Transformer trans_type; enum subpixel_scale_e { subpixel_shift = SubpixelShift, subpixel_scale = 1 << subpixel_shift }; //-------------------------------------------------------------------- span_interpolator_linear() {} span_interpolator_linear(const trans_type& trans) : m_trans(&trans) {} span_interpolator_linear(const trans_type& trans, double x, double y, unsigned len) : m_trans(&trans) { begin(x, y, len); } //---------------------------------------------------------------- const trans_type& transformer() const { return *m_trans; } void transformer(const trans_type& trans) { m_trans = &trans; } //---------------------------------------------------------------- void begin(double x, double y, unsigned len) { double tx; double ty; tx = x; ty = y; m_trans->transform(&tx, &ty); int x1 = iround(tx * subpixel_scale); int y1 = iround(ty * subpixel_scale); tx = x + len; ty = y; m_trans->transform(&tx, &ty); int x2 = iround(tx * subpixel_scale); int y2 = iround(ty * subpixel_scale); m_li_x = dda2_line_interpolator(x1, x2, len); m_li_y = dda2_line_interpolator(y1, y2, len); } //---------------------------------------------------------------- void resynchronize(double xe, double ye, unsigned len) { m_trans->transform(&xe, &ye); m_li_x = dda2_line_interpolator(m_li_x.y(), iround(xe * subpixel_scale), len); m_li_y = dda2_line_interpolator(m_li_y.y(), iround(ye * subpixel_scale), len); } //---------------------------------------------------------------- void operator++() { ++m_li_x; ++m_li_y; } //---------------------------------------------------------------- void coordinates(int* x, int* y) const { *x = m_li_x.y(); *y = m_li_y.y(); } private: const trans_type* m_trans; dda2_line_interpolator m_li_x; dda2_line_interpolator m_li_y; }; //=====================================span_interpolator_linear_subdiv template class span_interpolator_linear_subdiv { public: typedef Transformer trans_type; enum subpixel_scale_e { subpixel_shift = SubpixelShift, subpixel_scale = 1 << subpixel_shift }; //---------------------------------------------------------------- span_interpolator_linear_subdiv() : m_subdiv_shift(4), m_subdiv_size(1 << m_subdiv_shift), m_subdiv_mask(m_subdiv_size - 1) {} span_interpolator_linear_subdiv(const trans_type& trans, unsigned subdiv_shift = 4) : m_subdiv_shift(subdiv_shift), m_subdiv_size(1 << m_subdiv_shift), m_subdiv_mask(m_subdiv_size - 1), m_trans(&trans) {} span_interpolator_linear_subdiv(const trans_type& trans, double x, double y, unsigned len, unsigned subdiv_shift = 4) : m_subdiv_shift(subdiv_shift), m_subdiv_size(1 << m_subdiv_shift), m_subdiv_mask(m_subdiv_size - 1), m_trans(&trans) { begin(x, y, len); } //---------------------------------------------------------------- const trans_type& transformer() const { return *m_trans; } void transformer(const trans_type& trans) { m_trans = &trans; } //---------------------------------------------------------------- unsigned subdiv_shift() const { return m_subdiv_shift; } void subdiv_shift(unsigned shift) { m_subdiv_shift = shift; m_subdiv_size = 1 << m_subdiv_shift; m_subdiv_mask = m_subdiv_size - 1; } //---------------------------------------------------------------- void begin(double x, double y, unsigned len) { double tx; double ty; m_pos = 1; m_src_x = iround(x * subpixel_scale) + subpixel_scale; m_src_y = y; m_len = len; if(len > m_subdiv_size) len = m_subdiv_size; tx = x; ty = y; m_trans->transform(&tx, &ty); int x1 = iround(tx * subpixel_scale); int y1 = iround(ty * subpixel_scale); tx = x + len; ty = y; m_trans->transform(&tx, &ty); m_li_x = dda2_line_interpolator(x1, iround(tx * subpixel_scale), len); m_li_y = dda2_line_interpolator(y1, iround(ty * subpixel_scale), len); } //---------------------------------------------------------------- void operator++() { ++m_li_x; ++m_li_y; if(m_pos >= m_subdiv_size) { unsigned len = m_len; if(len > m_subdiv_size) len = m_subdiv_size; double tx = double(m_src_x) / double(subpixel_scale) + len; double ty = m_src_y; m_trans->transform(&tx, &ty); m_li_x = dda2_line_interpolator(m_li_x.y(), iround(tx * subpixel_scale), len); m_li_y = dda2_line_interpolator(m_li_y.y(), iround(ty * subpixel_scale), len); m_pos = 0; } m_src_x += subpixel_scale; ++m_pos; --m_len; } //---------------------------------------------------------------- void coordinates(int* x, int* y) const { *x = m_li_x.y(); *y = m_li_y.y(); } private: unsigned m_subdiv_shift; unsigned m_subdiv_size; unsigned m_subdiv_mask; const trans_type* m_trans; dda2_line_interpolator m_li_x; dda2_line_interpolator m_li_y; int m_src_x; double m_src_y; unsigned m_pos; unsigned m_len; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_renderer_base.h0000644000175000017500000004531312516137326024571 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class renderer_base // //---------------------------------------------------------------------------- #ifndef AGG_RENDERER_BASE_INCLUDED #define AGG_RENDERER_BASE_INCLUDED #include "agg_basics.h" #include "agg_rendering_buffer.h" namespace agg24 { //-----------------------------------------------------------renderer_base template class renderer_base { public: typedef PixelFormat pixfmt_type; typedef typename pixfmt_type::color_type color_type; typedef typename pixfmt_type::row_data row_data; //-------------------------------------------------------------------- renderer_base() : m_ren(0), m_clip_box(1, 1, 0, 0) {} renderer_base(pixfmt_type& ren) : m_ren(&ren), m_clip_box(0, 0, ren.width() - 1, ren.height() - 1) {} void attach(pixfmt_type& ren) { m_ren = &ren; m_clip_box = rect_i(0, 0, ren.width() - 1, ren.height() - 1); } //-------------------------------------------------------------------- const pixfmt_type& ren() const { return *m_ren; } pixfmt_type& ren() { return *m_ren; } //-------------------------------------------------------------------- unsigned width() const { return m_ren->width(); } unsigned height() const { return m_ren->height(); } //-------------------------------------------------------------------- bool clip_box(int x1, int y1, int x2, int y2) { rect_i cb(x1, y1, x2, y2); cb.normalize(); if(cb.clip(rect_i(0, 0, width() - 1, height() - 1))) { m_clip_box = cb; return true; } m_clip_box.x1 = 1; m_clip_box.y1 = 1; m_clip_box.x2 = 0; m_clip_box.y2 = 0; return false; } //-------------------------------------------------------------------- void reset_clipping(bool visibility) { if(visibility) { m_clip_box.x1 = 0; m_clip_box.y1 = 0; m_clip_box.x2 = width() - 1; m_clip_box.y2 = height() - 1; } else { m_clip_box.x1 = 1; m_clip_box.y1 = 1; m_clip_box.x2 = 0; m_clip_box.y2 = 0; } } //-------------------------------------------------------------------- void clip_box_naked(int x1, int y1, int x2, int y2) { m_clip_box.x1 = x1; m_clip_box.y1 = y1; m_clip_box.x2 = x2; m_clip_box.y2 = y2; } //-------------------------------------------------------------------- bool inbox(int x, int y) const { return x >= m_clip_box.x1 && y >= m_clip_box.y1 && x <= m_clip_box.x2 && y <= m_clip_box.y2; } //-------------------------------------------------------------------- const rect_i& clip_box() const { return m_clip_box; } int xmin() const { return m_clip_box.x1; } int ymin() const { return m_clip_box.y1; } int xmax() const { return m_clip_box.x2; } int ymax() const { return m_clip_box.y2; } //-------------------------------------------------------------------- const rect_i& bounding_clip_box() const { return m_clip_box; } int bounding_xmin() const { return m_clip_box.x1; } int bounding_ymin() const { return m_clip_box.y1; } int bounding_xmax() const { return m_clip_box.x2; } int bounding_ymax() const { return m_clip_box.y2; } //-------------------------------------------------------------------- void clear(const color_type& c) { unsigned y; if(width()) { for(y = 0; y < height(); y++) { m_ren->copy_hline(0, y, width(), c); } } } //-------------------------------------------------------------------- void copy_pixel(int x, int y, const color_type& c) { if(inbox(x, y)) { m_ren->copy_pixel(x, y, c); } } //-------------------------------------------------------------------- void blend_pixel(int x, int y, const color_type& c, cover_type cover) { if(inbox(x, y)) { m_ren->blend_pixel(x, y, c, cover); } } //-------------------------------------------------------------------- color_type pixel(int x, int y) const { return inbox(x, y) ? m_ren->pixel(x, y) : color_type::no_color(); } //-------------------------------------------------------------------- void copy_hline(int x1, int y, int x2, const color_type& c) { if(x1 > x2) { int t = x2; x2 = x1; x1 = t; } if(y > ymax()) return; if(y < ymin()) return; if(x1 > xmax()) return; if(x2 < xmin()) return; if(x1 < xmin()) x1 = xmin(); if(x2 > xmax()) x2 = xmax(); m_ren->copy_hline(x1, y, x2 - x1 + 1, c); } //-------------------------------------------------------------------- void copy_vline(int x, int y1, int y2, const color_type& c) { if(y1 > y2) { int t = y2; y2 = y1; y1 = t; } if(x > xmax()) return; if(x < xmin()) return; if(y1 > ymax()) return; if(y2 < ymin()) return; if(y1 < ymin()) y1 = ymin(); if(y2 > ymax()) y2 = ymax(); m_ren->copy_vline(x, y1, y2 - y1 + 1, c); } //-------------------------------------------------------------------- void blend_hline(int x1, int y, int x2, const color_type& c, cover_type cover) { if(x1 > x2) { int t = x2; x2 = x1; x1 = t; } if(y > ymax()) return; if(y < ymin()) return; if(x1 > xmax()) return; if(x2 < xmin()) return; if(x1 < xmin()) x1 = xmin(); if(x2 > xmax()) x2 = xmax(); m_ren->blend_hline(x1, y, x2 - x1 + 1, c, cover); } //-------------------------------------------------------------------- void blend_vline(int x, int y1, int y2, const color_type& c, cover_type cover) { if(y1 > y2) { int t = y2; y2 = y1; y1 = t; } if(x > xmax()) return; if(x < xmin()) return; if(y1 > ymax()) return; if(y2 < ymin()) return; if(y1 < ymin()) y1 = ymin(); if(y2 > ymax()) y2 = ymax(); m_ren->blend_vline(x, y1, y2 - y1 + 1, c, cover); } //-------------------------------------------------------------------- void copy_bar(int x1, int y1, int x2, int y2, const color_type& c) { rect_i rc(x1, y1, x2, y2); rc.normalize(); if(rc.clip(clip_box())) { int y; for(y = rc.y1; y <= rc.y2; y++) { m_ren->copy_hline(rc.x1, y, unsigned(rc.x2 - rc.x1 + 1), c); } } } //-------------------------------------------------------------------- void blend_bar(int x1, int y1, int x2, int y2, const color_type& c, cover_type cover) { rect_i rc(x1, y1, x2, y2); rc.normalize(); if(rc.clip(clip_box())) { int y; for(y = rc.y1; y <= rc.y2; y++) { m_ren->blend_hline(rc.x1, y, unsigned(rc.x2 - rc.x1 + 1), c, cover); } } } //-------------------------------------------------------------------- void blend_solid_hspan(int x, int y, int len, const color_type& c, const cover_type* covers) { if(y > ymax()) return; if(y < ymin()) return; if(x < xmin()) { len -= xmin() - x; if(len <= 0) return; covers += xmin() - x; x = xmin(); } if(x + len > xmax()) { len = xmax() - x + 1; if(len <= 0) return; } m_ren->blend_solid_hspan(x, y, len, c, covers); } //-------------------------------------------------------------------- void blend_solid_vspan(int x, int y, int len, const color_type& c, const cover_type* covers) { if(x > xmax()) return; if(x < xmin()) return; if(y < ymin()) { len -= ymin() - y; if(len <= 0) return; covers += ymin() - y; y = ymin(); } if(y + len > ymax()) { len = ymax() - y + 1; if(len <= 0) return; } m_ren->blend_solid_vspan(x, y, len, c, covers); } //-------------------------------------------------------------------- void copy_color_hspan(int x, int y, int len, const color_type* colors) { if(y > ymax()) return; if(y < ymin()) return; if(x < xmin()) { int d = xmin() - x; len -= d; if(len <= 0) return; colors += d; x = xmin(); } if(x + len > xmax()) { len = xmax() - x + 1; if(len <= 0) return; } m_ren->copy_color_hspan(x, y, len, colors); } //-------------------------------------------------------------------- void blend_color_hspan(int x, int y, int len, const color_type* colors, const cover_type* covers, cover_type cover = agg24::cover_full) { if(y > ymax()) return; if(y < ymin()) return; if(x < xmin()) { int d = xmin() - x; len -= d; if(len <= 0) return; if(covers) covers += d; colors += d; x = xmin(); } if(x + len > xmax()) { len = xmax() - x + 1; if(len <= 0) return; } m_ren->blend_color_hspan(x, y, len, colors, covers, cover); } //-------------------------------------------------------------------- void blend_color_vspan(int x, int y, int len, const color_type* colors, const cover_type* covers, cover_type cover = agg24::cover_full) { if(x > xmax()) return; if(x < xmin()) return; if(y < ymin()) { int d = ymin() - y; len -= d; if(len <= 0) return; if(covers) covers += d; colors += d; y = ymin(); } if(y + len > ymax()) { len = ymax() - y + 1; if(len <= 0) return; } m_ren->blend_color_vspan(x, y, len, colors, covers, cover); } //-------------------------------------------------------------------- rect_i clip_rect_area(rect_i& dst, rect_i& src, int wsrc, int hsrc) const { rect_i rc(0,0,0,0); rect_i cb = clip_box(); ++cb.x2; ++cb.y2; if(src.x1 < 0) { dst.x1 -= src.x1; src.x1 = 0; } if(src.y1 < 0) { dst.y1 -= src.y1; src.y1 = 0; } if(src.x2 > wsrc) src.x2 = wsrc; if(src.y2 > hsrc) src.y2 = hsrc; if(dst.x1 < cb.x1) { src.x1 += cb.x1 - dst.x1; dst.x1 = cb.x1; } if(dst.y1 < cb.y1) { src.y1 += cb.y1 - dst.y1; dst.y1 = cb.y1; } if(dst.x2 > cb.x2) dst.x2 = cb.x2; if(dst.y2 > cb.y2) dst.y2 = cb.y2; rc.x2 = dst.x2 - dst.x1; rc.y2 = dst.y2 - dst.y1; if(rc.x2 > src.x2 - src.x1) rc.x2 = src.x2 - src.x1; if(rc.y2 > src.y2 - src.y1) rc.y2 = src.y2 - src.y1; return rc; } //-------------------------------------------------------------------- template void copy_from(const RenBuf& src, const rect_i* rect_src_ptr = 0, int dx = 0, int dy = 0) { rect_i rsrc(0, 0, src.width(), src.height()); if(rect_src_ptr) { rsrc.x1 = rect_src_ptr->x1; rsrc.y1 = rect_src_ptr->y1; rsrc.x2 = rect_src_ptr->x2 + 1; rsrc.y2 = rect_src_ptr->y2 + 1; } // Version with xdst, ydst (absolute positioning) //rect_i rdst(xdst, ydst, xdst + rsrc.x2 - rsrc.x1, ydst + rsrc.y2 - rsrc.y1); // Version with dx, dy (relative positioning) rect_i rdst(rsrc.x1 + dx, rsrc.y1 + dy, rsrc.x2 + dx, rsrc.y2 + dy); rect_i rc = clip_rect_area(rdst, rsrc, src.width(), src.height()); if(rc.x2 > 0) { int incy = 1; if(rdst.y1 > rsrc.y1) { rsrc.y1 += rc.y2 - 1; rdst.y1 += rc.y2 - 1; incy = -1; } while(rc.y2 > 0) { m_ren->copy_from(src, rdst.x1, rdst.y1, rsrc.x1, rsrc.y1, rc.x2); rdst.y1 += incy; rsrc.y1 += incy; --rc.y2; } } } //-------------------------------------------------------------------- template void blend_from(const SrcPixelFormatRenderer& src, const rect_i* rect_src_ptr = 0, int dx = 0, int dy = 0, cover_type cover = agg24::cover_full) { rect_i rsrc(0, 0, src.width(), src.height()); if(rect_src_ptr) { rsrc.x1 = rect_src_ptr->x1; rsrc.y1 = rect_src_ptr->y1; rsrc.x2 = rect_src_ptr->x2 + 1; rsrc.y2 = rect_src_ptr->y2 + 1; } // Version with xdst, ydst (absolute positioning) //rect_i rdst(xdst, ydst, xdst + rsrc.x2 - rsrc.x1, ydst + rsrc.y2 - rsrc.y1); // Version with dx, dy (relative positioning) rect_i rdst(rsrc.x1 + dx, rsrc.y1 + dy, rsrc.x2 + dx, rsrc.y2 + dy); rect_i rc = clip_rect_area(rdst, rsrc, src.width(), src.height()); if(rc.x2 > 0) { int incy = 1; if(rdst.y1 > rsrc.y1) { rsrc.y1 += rc.y2 - 1; rdst.y1 += rc.y2 - 1; incy = -1; } while(rc.y2 > 0) { typename SrcPixelFormatRenderer::row_data rw = src.row(rsrc.y1); if(rw.ptr) { int x1src = rsrc.x1; int x1dst = rdst.x1; int len = rc.x2; if(rw.x1 > x1src) { x1dst += rw.x1 - x1src; len -= rw.x1 - x1src; x1src = rw.x1; } if(len > 0) { if(x1src + len-1 > rw.x2) { len -= x1src + len - rw.x2 - 1; } if(len > 0) { m_ren->blend_from(src, x1dst, rdst.y1, x1src, rsrc.y1, len, cover); } } } rdst.y1 += incy; rsrc.y1 += incy; --rc.y2; } } } private: pixfmt_type* m_ren; rect_i m_clip_box; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_scanline_bin.h0000644000175000017500000001751612516137326024421 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Class scanline_bin - binary scanline. // //---------------------------------------------------------------------------- // // Adaptation for 32-bit screen coordinates (scanline32_bin) has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_SCANLINE_BIN_INCLUDED #define AGG_SCANLINE_BIN_INCLUDED #include "agg_array.h" namespace agg24 { //=============================================================scanline_bin // // This is binary scaline container which supports the interface // used in the rasterizer::render(). See description of agg_scanline_u8 // for details. // //------------------------------------------------------------------------ class scanline_bin { public: typedef int32 coord_type; struct span { int16 x; int16 len; }; typedef const span* const_iterator; //-------------------------------------------------------------------- scanline_bin() : m_last_x(0x7FFFFFF0), m_spans(), m_cur_span(0) { } //-------------------------------------------------------------------- void reset(int min_x, int max_x) { unsigned max_len = max_x - min_x + 3; if(max_len > m_spans.size()) { m_spans.resize(max_len); } m_last_x = 0x7FFFFFF0; m_cur_span = &m_spans[0]; } //-------------------------------------------------------------------- void add_cell(int x, unsigned) { if(x == m_last_x+1) { m_cur_span->len++; } else { ++m_cur_span; m_cur_span->x = (int16)x; m_cur_span->len = 1; } m_last_x = x; } //-------------------------------------------------------------------- void add_span(int x, unsigned len, unsigned) { if(x == m_last_x+1) { m_cur_span->len = (int16)(m_cur_span->len + len); } else { ++m_cur_span; m_cur_span->x = (int16)x; m_cur_span->len = (int16)len; } m_last_x = x + len - 1; } //-------------------------------------------------------------------- void add_cells(int x, unsigned len, const void*) { add_span(x, len, 0); } //-------------------------------------------------------------------- void finalize(int y) { m_y = y; } //-------------------------------------------------------------------- void reset_spans() { m_last_x = 0x7FFFFFF0; m_cur_span = &m_spans[0]; } //-------------------------------------------------------------------- int y() const { return m_y; } unsigned num_spans() const { return unsigned(m_cur_span - &m_spans[0]); } const_iterator begin() const { return &m_spans[1]; } private: scanline_bin(const scanline_bin&); const scanline_bin operator = (const scanline_bin&); int m_last_x; int m_y; pod_array m_spans; span* m_cur_span; }; //===========================================================scanline32_bin class scanline32_bin { public: typedef int32 coord_type; //-------------------------------------------------------------------- struct span { span() {} span(coord_type x_, coord_type len_) : x(x_), len(len_) {} coord_type x; coord_type len; }; typedef pod_bvector span_array_type; //-------------------------------------------------------------------- class const_iterator { public: const_iterator(const span_array_type& spans) : m_spans(spans), m_span_idx(0) {} const span& operator*() const { return m_spans[m_span_idx]; } const span* operator->() const { return &m_spans[m_span_idx]; } void operator ++ () { ++m_span_idx; } private: const span_array_type& m_spans; unsigned m_span_idx; }; //-------------------------------------------------------------------- scanline32_bin() : m_max_len(0), m_last_x(0x7FFFFFF0) {} //-------------------------------------------------------------------- void reset(int min_x, int max_x) { m_last_x = 0x7FFFFFF0; m_spans.remove_all(); } //-------------------------------------------------------------------- void add_cell(int x, unsigned) { if(x == m_last_x+1) { m_spans.last().len++; } else { m_spans.add(span(coord_type(x), 1)); } m_last_x = x; } //-------------------------------------------------------------------- void add_span(int x, unsigned len, unsigned) { if(x == m_last_x+1) { m_spans.last().len += coord_type(len); } else { m_spans.add(span(coord_type(x), coord_type(len))); } m_last_x = x + len - 1; } //-------------------------------------------------------------------- void add_cells(int x, unsigned len, const void*) { add_span(x, len, 0); } //-------------------------------------------------------------------- void finalize(int y) { m_y = y; } //-------------------------------------------------------------------- void reset_spans() { m_last_x = 0x7FFFFFF0; m_spans.remove_all(); } //-------------------------------------------------------------------- int y() const { return m_y; } unsigned num_spans() const { return m_spans.size(); } const_iterator begin() const { return const_iterator(m_spans); } private: scanline32_bin(const scanline32_bin&); const scanline32_bin operator = (const scanline32_bin&); unsigned m_max_len; int m_last_x; int m_y; span_array_type m_spans; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_trans_affine.h0000644000175000017500000003637512516137326024440 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Affine transformation classes. // //---------------------------------------------------------------------------- #ifndef AGG_TRANS_AFFINE_INCLUDED #define AGG_TRANS_AFFINE_INCLUDED #include #include "agg_basics.h" namespace agg24 { const double affine_epsilon = 1e-14; // About of precision of doubles //============================================================trans_affine // // See Implementation agg_trans_affine.cpp // // Affine transformation are linear transformations in Cartesian coordinates // (strictly speaking not only in Cartesian, but for the beginning we will // think so). They are rotation, scaling, translation and skewing. // After any affine transformation a line segment remains a line segment // and it will never become a curve. // // There will be no math about matrix calculations, since it has been // described many times. Ask yourself a very simple question: // "why do we need to understand and use some matrix stuff instead of just // rotating, scaling and so on". The answers are: // // 1. Any combination of transformations can be done by only 4 multiplications // and 4 additions in floating point. // 2. One matrix transformation is equivalent to the number of consecutive // discrete transformations, i.e. the matrix "accumulates" all transformations // in the order of their settings. Suppose we have 4 transformations: // * rotate by 30 degrees, // * scale X to 2.0, // * scale Y to 1.5, // * move to (100, 100). // The result will depend on the order of these transformations, // and the advantage of matrix is that the sequence of discret calls: // rotate(30), scaleX(2.0), scaleY(1.5), move(100,100) // will have exactly the same result as the following matrix transformations: // // affine_matrix m; // m *= rotate_matrix(30); // m *= scaleX_matrix(2.0); // m *= scaleY_matrix(1.5); // m *= move_matrix(100,100); // // m.transform_my_point_at_last(x, y); // // What is the good of it? In real life we will set-up the matrix only once // and then transform many points, let alone the convenience to set any // combination of transformations. // // So, how to use it? Very easy - literally as it's shown above. Not quite, // let us write a correct example: // // agg24::trans_affine m; // m *= agg24::trans_affine_rotation(30.0 * 3.1415926 / 180.0); // m *= agg24::trans_affine_scaling(2.0, 1.5); // m *= agg24::trans_affine_translation(100.0, 100.0); // m.transform(&x, &y); // // The affine matrix is all you need to perform any linear transformation, // but all transformations have origin point (0,0). It means that we need to // use 2 translations if we want to rotate someting around (100,100): // // m *= agg24::trans_affine_translation(-100.0, -100.0); // move to (0,0) // m *= agg24::trans_affine_rotation(30.0 * 3.1415926 / 180.0); // rotate // m *= agg24::trans_affine_translation(100.0, 100.0); // move back to (100,100) //---------------------------------------------------------------------- class trans_affine { public: //------------------------------------------ Construction // Construct an identity matrix - it does not transform anything trans_affine() : m0(1.0), m1(0.0), m2(0.0), m3(1.0), m4(0.0), m5(0.0) {} // Construct a custom matrix. Usually used in derived classes trans_affine(double v0, double v1, double v2, double v3, double v4, double v5) : m0(v0), m1(v1), m2(v2), m3(v3), m4(v4), m5(v5) {} // Construct a matrix to transform a parallelogram to another one. trans_affine(const double* rect, const double* parl) { parl_to_parl(rect, parl); } // Construct a matrix to transform a rectangle to a parallelogram. trans_affine(double x1, double y1, double x2, double y2, const double* parl) { rect_to_parl(x1, y1, x2, y2, parl); } // Construct a matrix to transform a parallelogram to a rectangle. trans_affine(const double* parl, double x1, double y1, double x2, double y2) { parl_to_rect(parl, x1, y1, x2, y2); } //---------------------------------- Parellelogram transformations // Calculate a matrix to transform a parallelogram to another one. // src and dst are pointers to arrays of three points // (double[6], x,y,...) that identify three corners of the // parallelograms assuming implicit fourth points. // There are also transformations rectangtle to parallelogram and // parellelogram to rectangle const trans_affine& parl_to_parl(const double* src, const double* dst); const trans_affine& rect_to_parl(double x1, double y1, double x2, double y2, const double* parl); const trans_affine& parl_to_rect(const double* parl, double x1, double y1, double x2, double y2); //------------------------------------------ Operations // Reset - actually load an identity matrix const trans_affine& reset(); // Multiply matrix to another one const trans_affine& multiply(const trans_affine& m); // Multiply "m" to "this" and assign the result to "this" const trans_affine& premultiply(const trans_affine& m); // Multiply matrix to inverse of another one const trans_affine& multiply_inv(const trans_affine& m); // Multiply inverse of "m" to "this" and assign the result to "this" const trans_affine& premultiply_inv(const trans_affine& m); // Invert matrix. Do not try to invert degenerate matrices, // there's no check for validity. If you set scale to 0 and // then try to invert matrix, expect unpredictable result. const trans_affine& invert(); // Mirroring around X const trans_affine& flip_x(); // Mirroring around Y const trans_affine& flip_y(); //------------------------------------------- Load/Store // Store matrix to an array [6] of double void store_to(double* m) const { *m++ = m0; *m++ = m1; *m++ = m2; *m++ = m3; *m++ = m4; *m++ = m5; } // Load matrix from an array [6] of double const trans_affine& load_from(const double* m) { m0 = *m++; m1 = *m++; m2 = *m++; m3 = *m++; m4 = *m++; m5 = *m++; return *this; } //------------------------------------------- Operators // Multiply current matrix to another one const trans_affine& operator *= (const trans_affine& m) { return multiply(m); } // Multiply current matrix to inverse of another one const trans_affine& operator /= (const trans_affine& m) { return multiply_inv(m); } // Multiply current matrix to another one and return // the result in a separete matrix. trans_affine operator * (const trans_affine& m) { return trans_affine(*this).multiply(m); } // Multiply current matrix to inverse of another one // and return the result in a separete matrix. trans_affine operator / (const trans_affine& m) { return trans_affine(*this).multiply_inv(m); } // Calculate and return the inverse matrix trans_affine operator ~ () const { trans_affine ret = *this; return ret.invert(); } // Equal operator with default epsilon bool operator == (const trans_affine& m) const { return is_equal(m, affine_epsilon); } // Not Equal operator with default epsilon bool operator != (const trans_affine& m) const { return !is_equal(m, affine_epsilon); } //-------------------------------------------- Transformations // Direct transformation x and y void transform(double* x, double* y) const; // Direct transformation x and y, 2x2 matrix only, no translation void transform_2x2(double* x, double* y) const; // Inverse transformation x and y. It works slower than the // direct transformation, so if the performance is critical // it's better to invert() the matrix and then use transform() void inverse_transform(double* x, double* y) const; //-------------------------------------------- Auxiliary // Calculate the determinant of matrix double determinant() const { return 1.0 / (m0 * m3 - m1 * m2); } // Get the average scale (by X and Y). // Basically used to calculate the approximation_scale when // decomposinting curves into line segments. double scale() const; // Check to see if it's an identity matrix bool is_identity(double epsilon = affine_epsilon) const; // Check to see if two matrices are equal bool is_equal(const trans_affine& m, double epsilon = affine_epsilon) const; // Determine the major parameters. Use carefully considering degenerate matrices double rotation() const; void translation(double* dx, double* dy) const; void scaling(double* sx, double* sy) const; void scaling_abs(double* sx, double* sy) const { *sx = sqrt(m0*m0 + m2*m2); *sy = sqrt(m1*m1 + m3*m3); } public: double m0; double m1; double m2; double m3; double m4; double m5; }; //------------------------------------------------------------------------ inline void trans_affine::transform(double* x, double* y) const { register double tx = *x; *x = tx * m0 + *y * m2 + m4; *y = tx * m1 + *y * m3 + m5; } //------------------------------------------------------------------------ inline void trans_affine::transform_2x2(double* x, double* y) const { register double tx = *x; *x = tx * m0 + *y * m2; *y = tx * m1 + *y * m3; } //------------------------------------------------------------------------ inline void trans_affine::inverse_transform(double* x, double* y) const { register double d = determinant(); register double a = (*x - m4) * d; register double b = (*y - m5) * d; *x = a * m3 - b * m2; *y = b * m0 - a * m1; } //------------------------------------------------------------------------ inline double trans_affine::scale() const { double x = 0.707106781 * m0 + 0.707106781 * m2; double y = 0.707106781 * m1 + 0.707106781 * m3; return sqrt(x*x + y*y); } //------------------------------------------------------------------------ inline const trans_affine& trans_affine::premultiply(const trans_affine& m) { trans_affine t = m; return *this = t.multiply(*this); } //------------------------------------------------------------------------ inline const trans_affine& trans_affine::multiply_inv(const trans_affine& m) { trans_affine t = m; t.invert(); multiply(t); return *this; } //------------------------------------------------------------------------ inline const trans_affine& trans_affine::premultiply_inv(const trans_affine& m) { trans_affine t = m; t.invert(); return *this = t.multiply(*this); } //====================================================trans_affine_rotation // Rotation matrix. sin() and cos() are calculated twice for the same angle. // There's no harm because the performance of sin()/cos() is very good on all // modern processors. Besides, this operation is not going to be invoked too // often. class trans_affine_rotation : public trans_affine { public: trans_affine_rotation(double a) : trans_affine(cos(a), sin(a), -sin(a), cos(a), 0.0, 0.0) {} }; //====================================================trans_affine_scaling // Scaling matrix. sx, sy - scale coefficients by X and Y respectively class trans_affine_scaling : public trans_affine { public: trans_affine_scaling(double sx, double sy) : trans_affine(sx, 0.0, 0.0, sy, 0.0, 0.0) {} trans_affine_scaling(double s) : trans_affine(s, 0.0, 0.0, s, 0.0, 0.0) {} }; //================================================trans_affine_translation // Translation matrix class trans_affine_translation : public trans_affine { public: trans_affine_translation(double tx, double ty) : trans_affine(1.0, 0.0, 0.0, 1.0, tx, ty) {} }; //====================================================trans_affine_skewing // Sckewing (shear) matrix class trans_affine_skewing : public trans_affine { public: trans_affine_skewing(double sx, double sy) : trans_affine(1.0, tan(sy), tan(sx), 1.0, 0.0, 0.0) {} }; //===============================================trans_affine_line_segment // Rotate, Scale and Translate, associating 0...dist with line segment // x1,y1,x2,y2 class trans_affine_line_segment : public trans_affine { public: trans_affine_line_segment(double x1, double y1, double x2, double y2, double dist) { double dx = x2 - x1; double dy = y2 - y1; if(dist > 0.0) { multiply(trans_affine_scaling(sqrt(dx * dx + dy * dy) / dist)); } multiply(trans_affine_rotation(atan2(dy, dx))); multiply(trans_affine_translation(x1, y1)); } }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_rasterizer_outline_aa.h0000644000175000017500000005151012516137326026357 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_RASTERIZER_OUTLINE_AA_INCLUDED #define AGG_RASTERIZER_OUTLINE_AA_INCLUDED #include "agg_basics.h" #include "agg_line_aa_basics.h" #include "agg_vertex_sequence.h" namespace agg24 { //------------------------------------------------------------------------- inline bool cmp_dist_start(int d) { return d > 0; } inline bool cmp_dist_end(int d) { return d <= 0; } //-----------------------------------------------------------line_aa_vertex // Vertex (x, y) with the distance to the next one. The last vertex has // the distance between the last and the first points struct line_aa_vertex { int x; int y; int len; line_aa_vertex() {} line_aa_vertex(int x_, int y_) : x(x_), y(y_), len(0) { } bool operator () (const line_aa_vertex& val) { double dx = val.x - x; double dy = val.y - y; return (len = uround(sqrt(dx * dx + dy * dy))) > (line_subpixel_scale + line_subpixel_scale / 2); } }; //----------------------------------------------------------outline_aa_join_e enum outline_aa_join_e { outline_no_join, //-----outline_no_join outline_miter_join, //-----outline_miter_join outline_round_join, //-----outline_round_join outline_miter_accurate_join //-----outline_accurate_join }; //=======================================================rasterizer_outline_aa template class rasterizer_outline_aa { private: //------------------------------------------------------------------------ struct draw_vars { unsigned idx; int x1, y1, x2, y2; line_parameters curr, next; int lcurr, lnext; int xb1, yb1, xb2, yb2; unsigned flags; }; void draw(draw_vars& dv, unsigned start, unsigned end); public: typedef line_aa_vertex vertex_type; typedef vertex_sequence vertex_storage_type; rasterizer_outline_aa(Renderer& ren) : m_ren(&ren), m_line_join(ren.accurate_join_only() ? outline_miter_accurate_join : outline_round_join), m_round_cap(false), m_start_x(0), m_start_y(0) {} void attach(Renderer& ren) { m_ren = &ren; } //------------------------------------------------------------------------ void line_join(outline_aa_join_e join) { m_line_join = m_ren->accurate_join_only() ? outline_miter_accurate_join : join; } bool line_join() const { return m_line_join; } //------------------------------------------------------------------------ void round_cap(bool v) { m_round_cap = v; } bool round_cap() const { return m_round_cap; } //------------------------------------------------------------------------ void move_to(int x, int y) { m_src_vertices.modify_last(vertex_type(m_start_x = x, m_start_y = y)); } //------------------------------------------------------------------------ void line_to(int x, int y) { m_src_vertices.add(vertex_type(x, y)); } //------------------------------------------------------------------------ void move_to_d(double x, double y) { move_to(Coord::conv(x), Coord::conv(y)); } //------------------------------------------------------------------------ void line_to_d(double x, double y) { line_to(Coord::conv(x), Coord::conv(y)); } //------------------------------------------------------------------------ void render(bool close_polygon); //------------------------------------------------------------------------ void add_vertex(double x, double y, unsigned cmd) { if(is_move_to(cmd)) { render(false); move_to_d(x, y); } else { if(is_end_poly(cmd)) { render(is_closed(cmd)); if(is_closed(cmd)) { move_to(m_start_x, m_start_y); } } else { line_to_d(x, y); } } } //------------------------------------------------------------------------ template void add_path(VertexSource& vs, unsigned path_id=0) { double x; double y; unsigned cmd; vs.rewind(path_id); while(!is_stop(cmd = vs.vertex(&x, &y))) { add_vertex(x, y, cmd); } render(false); } //------------------------------------------------------------------------ template void render_all_paths(VertexSource& vs, const ColorStorage& colors, const PathId& path_id, unsigned num_paths) { for(unsigned i = 0; i < num_paths; i++) { m_ren->color(colors[i]); add_path(vs, path_id[i]); } } //------------------------------------------------------------------------ template void render_ctrl(Ctrl& c) { unsigned i; for(i = 0; i < c.num_paths(); i++) { m_ren->color(c.color(i)); add_path(c, i); } } private: rasterizer_outline_aa(const rasterizer_outline_aa&); const rasterizer_outline_aa& operator = (const rasterizer_outline_aa&); Renderer* m_ren; vertex_storage_type m_src_vertices; outline_aa_join_e m_line_join; bool m_round_cap; int m_start_x; int m_start_y; }; //---------------------------------------------------------------------------- template void rasterizer_outline_aa::draw(draw_vars& dv, unsigned start, unsigned end) { unsigned i; const vertex_storage_type::value_type* v; for(i = start; i < end; i++) { if(m_line_join == outline_round_join) { dv.xb1 = dv.curr.x1 + (dv.curr.y2 - dv.curr.y1); dv.yb1 = dv.curr.y1 - (dv.curr.x2 - dv.curr.x1); dv.xb2 = dv.curr.x2 + (dv.curr.y2 - dv.curr.y1); dv.yb2 = dv.curr.y2 - (dv.curr.x2 - dv.curr.x1); } switch(dv.flags) { case 0: m_ren->line3(dv.curr, dv.xb1, dv.yb1, dv.xb2, dv.yb2); break; case 1: m_ren->line2(dv.curr, dv.xb2, dv.yb2); break; case 2: m_ren->line1(dv.curr, dv.xb1, dv.yb1); break; case 3: m_ren->line0(dv.curr); break; } if(m_line_join == outline_round_join && (dv.flags & 2) == 0) { m_ren->pie(dv.curr.x2, dv.curr.y2, dv.curr.x2 + (dv.curr.y2 - dv.curr.y1), dv.curr.y2 - (dv.curr.x2 - dv.curr.x1), dv.curr.x2 + (dv.next.y2 - dv.next.y1), dv.curr.y2 - (dv.next.x2 - dv.next.x1)); } dv.x1 = dv.x2; dv.y1 = dv.y2; dv.lcurr = dv.lnext; dv.lnext = m_src_vertices[dv.idx].len; ++dv.idx; if(dv.idx >= m_src_vertices.size()) dv.idx = 0; v = &m_src_vertices[dv.idx]; dv.x2 = v->x; dv.y2 = v->y; dv.curr = dv.next; dv.next = line_parameters(dv.x1, dv.y1, dv.x2, dv.y2, dv.lnext); dv.xb1 = dv.xb2; dv.yb1 = dv.yb2; switch(m_line_join) { case outline_no_join: dv.flags = 3; break; case outline_miter_join: dv.flags >>= 1; dv.flags |= ((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1); if((dv.flags & 2) == 0) { bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2); } break; case outline_round_join: dv.flags >>= 1; dv.flags |= ((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1); break; case outline_miter_accurate_join: dv.flags = 0; bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2); break; } } } //---------------------------------------------------------------------------- template void rasterizer_outline_aa::render(bool close_polygon) { m_src_vertices.close(close_polygon); draw_vars dv; const vertex_storage_type::value_type* v; int x1; int y1; int x2; int y2; int lprev; if(close_polygon) { if(m_src_vertices.size() >= 3) { dv.idx = 2; v = &m_src_vertices[m_src_vertices.size() - 1]; x1 = v->x; y1 = v->y; lprev = v->len; v = &m_src_vertices[0]; x2 = v->x; y2 = v->y; dv.lcurr = v->len; line_parameters prev(x1, y1, x2, y2, lprev); v = &m_src_vertices[1]; dv.x1 = v->x; dv.y1 = v->y; dv.lnext = v->len; dv.curr = line_parameters(x2, y2, dv.x1, dv.y1, dv.lcurr); v = &m_src_vertices[dv.idx]; dv.x2 = v->x; dv.y2 = v->y; dv.next = line_parameters(dv.x1, dv.y1, dv.x2, dv.y2, dv.lnext); dv.xb1 = 0; dv.yb1 = 0; dv.xb2 = 0; dv.yb2 = 0; switch(m_line_join) { case outline_no_join: dv.flags = 3; break; case outline_miter_join: case outline_round_join: dv.flags = (prev.diagonal_quadrant() == dv.curr.diagonal_quadrant()) | ((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1); break; case outline_miter_accurate_join: dv.flags = 0; break; } if((dv.flags & 1) == 0 && m_line_join != outline_round_join) { bisectrix(prev, dv.curr, &dv.xb1, &dv.yb1); } if((dv.flags & 2) == 0 && m_line_join != outline_round_join) { bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2); } draw(dv, 0, m_src_vertices.size()); } } else { switch(m_src_vertices.size()) { case 0: case 1: break; case 2: { v = &m_src_vertices[0]; x1 = v->x; y1 = v->y; lprev = v->len; v = &m_src_vertices[1]; x2 = v->x; y2 = v->y; line_parameters lp(x1, y1, x2, y2, lprev); if(m_round_cap) { m_ren->semidot(cmp_dist_start, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1)); } m_ren->line3(lp, x1 + (y2 - y1), y1 - (x2 - x1), x2 + (y2 - y1), y2 - (x2 - x1)); if(m_round_cap) { m_ren->semidot(cmp_dist_end, x2, y2, x2 + (y2 - y1), y2 - (x2 - x1)); } } break; case 3: { int x3, y3; int lnext; v = &m_src_vertices[0]; x1 = v->x; y1 = v->y; lprev = v->len; v = &m_src_vertices[1]; x2 = v->x; y2 = v->y; lnext = v->len; v = &m_src_vertices[2]; x3 = v->x; y3 = v->y; line_parameters lp1(x1, y1, x2, y2, lprev); line_parameters lp2(x2, y2, x3, y3, lnext); if(m_round_cap) { m_ren->semidot(cmp_dist_start, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1)); } if(m_line_join == outline_round_join) { m_ren->line3(lp1, x1 + (y2 - y1), y1 - (x2 - x1), x2 + (y2 - y1), y2 - (x2 - x1)); m_ren->pie(x2, y2, x2 + (y2 - y1), y2 - (x2 - x1), x2 + (y3 - y2), y2 - (x3 - x2)); m_ren->line3(lp2, x2 + (y3 - y2), y2 - (x3 - x2), x3 + (y3 - y2), y3 - (x3 - x2)); } else { bisectrix(lp1, lp2, &dv.xb1, &dv.yb1); m_ren->line3(lp1, x1 + (y2 - y1), y1 - (x2 - x1), dv.xb1, dv.yb1); m_ren->line3(lp2, dv.xb1, dv.yb1, x3 + (y3 - y2), y3 - (x3 - x2)); } if(m_round_cap) { m_ren->semidot(cmp_dist_end, x3, y3, x3 + (y3 - y2), y3 - (x3 - x2)); } } break; default: { dv.idx = 3; v = &m_src_vertices[0]; x1 = v->x; y1 = v->y; lprev = v->len; v = &m_src_vertices[1]; x2 = v->x; y2 = v->y; dv.lcurr = v->len; line_parameters prev(x1, y1, x2, y2, lprev); v = &m_src_vertices[2]; dv.x1 = v->x; dv.y1 = v->y; dv.lnext = v->len; dv.curr = line_parameters(x2, y2, dv.x1, dv.y1, dv.lcurr); v = &m_src_vertices[dv.idx]; dv.x2 = v->x; dv.y2 = v->y; dv.next = line_parameters(dv.x1, dv.y1, dv.x2, dv.y2, dv.lnext); dv.xb1 = 0; dv.yb1 = 0; dv.xb2 = 0; dv.yb2 = 0; switch(m_line_join) { case outline_no_join: dv.flags = 3; break; case outline_miter_join: case outline_round_join: dv.flags = (prev.diagonal_quadrant() == dv.curr.diagonal_quadrant()) | ((dv.curr.diagonal_quadrant() == dv.next.diagonal_quadrant()) << 1); break; case outline_miter_accurate_join: dv.flags = 0; break; } if(m_round_cap) { m_ren->semidot(cmp_dist_start, x1, y1, x1 + (y2 - y1), y1 - (x2 - x1)); } if((dv.flags & 1) == 0) { if(m_line_join == outline_round_join) { m_ren->line3(prev, x1 + (y2 - y1), y1 - (x2 - x1), x2 + (y2 - y1), y2 - (x2 - x1)); m_ren->pie(prev.x2, prev.y2, x2 + (y2 - y1), y2 - (x2 - x1), dv.curr.x1 + (dv.curr.y2 - dv.curr.y1), dv.curr.y1 - (dv.curr.x2 - dv.curr.x1)); } else { bisectrix(prev, dv.curr, &dv.xb1, &dv.yb1); m_ren->line3(prev, x1 + (y2 - y1), y1 - (x2 - x1), dv.xb1, dv.yb1); } } else { m_ren->line1(prev, x1 + (y2 - y1), y1 - (x2 - x1)); } if((dv.flags & 2) == 0 && m_line_join != outline_round_join) { bisectrix(dv.curr, dv.next, &dv.xb2, &dv.yb2); } draw(dv, 1, m_src_vertices.size() - 2); if((dv.flags & 1) == 0) { if(m_line_join == outline_round_join) { m_ren->line3(dv.curr, dv.curr.x1 + (dv.curr.y2 - dv.curr.y1), dv.curr.y1 - (dv.curr.x2 - dv.curr.x1), dv.curr.x2 + (dv.curr.y2 - dv.curr.y1), dv.curr.y2 - (dv.curr.x2 - dv.curr.x1)); } else { m_ren->line3(dv.curr, dv.xb1, dv.yb1, dv.curr.x2 + (dv.curr.y2 - dv.curr.y1), dv.curr.y2 - (dv.curr.x2 - dv.curr.x1)); } } else { m_ren->line2(dv.curr, dv.curr.x2 + (dv.curr.y2 - dv.curr.y1), dv.curr.y2 - (dv.curr.x2 - dv.curr.x1)); } if(m_round_cap) { m_ren->semidot(cmp_dist_end, dv.curr.x2, dv.curr.y2, dv.curr.x2 + (dv.curr.y2 - dv.curr.y1), dv.curr.y2 - (dv.curr.x2 - dv.curr.x1)); } } break; } } m_src_vertices.remove_all(); } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_line_aa_basics.h0000644000175000017500000001541612516137326024706 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_LINE_AA_BASICS_INCLUDED #define AGG_LINE_AA_BASICS_INCLUDED #include #include "agg_basics.h" namespace agg24 { // See Implementation agg_line_aa_basics.cpp //------------------------------------------------------------------------- enum line_subpixel_scale_e { line_subpixel_shift = 8, //----line_subpixel_shift line_subpixel_scale = 1 << line_subpixel_shift, //----line_subpixel_scale line_subpixel_mask = line_subpixel_scale - 1, //----line_subpixel_mask line_max_coord = (1 << 28) - 1, //----line_max_coord line_max_length = 1 << (line_subpixel_shift + 10) //----line_max_length }; //------------------------------------------------------------------------- enum line_mr_subpixel_scale_e { line_mr_subpixel_shift = 4, //----line_mr_subpixel_shift line_mr_subpixel_scale = 1 << line_mr_subpixel_shift, //----line_mr_subpixel_scale line_mr_subpixel_mask = line_mr_subpixel_scale - 1 //----line_mr_subpixel_mask }; //------------------------------------------------------------------line_mr AGG_INLINE int line_mr(int x) { return x >> (line_subpixel_shift - line_mr_subpixel_shift); } //-------------------------------------------------------------------line_hr AGG_INLINE int line_hr(int x) { return x << (line_subpixel_shift - line_mr_subpixel_shift); } //---------------------------------------------------------------line_dbl_hr AGG_INLINE int line_dbl_hr(int x) { return x << line_subpixel_shift; } //---------------------------------------------------------------line_coord struct line_coord { AGG_INLINE static int conv(double x) { return iround(x * line_subpixel_scale); } }; //-----------------------------------------------------------line_coord_sat struct line_coord_sat { AGG_INLINE static int conv(double x) { return saturation::iround(x * line_subpixel_scale); } }; //==========================================================line_parameters struct line_parameters { //--------------------------------------------------------------------- line_parameters() {} line_parameters(int x1_, int y1_, int x2_, int y2_, int len_) : x1(x1_), y1(y1_), x2(x2_), y2(y2_), dx(abs(x2_ - x1_)), dy(abs(y2_ - y1_)), sx((x2_ > x1_) ? 1 : -1), sy((y2_ > y1_) ? 1 : -1), vertical(dy >= dx), inc(vertical ? sy : sx), len(len_), octant((sy & 4) | (sx & 2) | int(vertical)) { } //--------------------------------------------------------------------- unsigned orthogonal_quadrant() const { return s_orthogonal_quadrant[octant]; } unsigned diagonal_quadrant() const { return s_diagonal_quadrant[octant]; } //--------------------------------------------------------------------- bool same_orthogonal_quadrant(const line_parameters& lp) const { return s_orthogonal_quadrant[octant] == s_orthogonal_quadrant[lp.octant]; } //--------------------------------------------------------------------- bool same_diagonal_quadrant(const line_parameters& lp) const { return s_diagonal_quadrant[octant] == s_diagonal_quadrant[lp.octant]; } //--------------------------------------------------------------------- void divide(line_parameters& lp1, line_parameters& lp2) const { int xmid = (x1 + x2) >> 1; int ymid = (y1 + y2) >> 1; int len2 = len >> 1; lp1 = *this; lp2 = *this; lp1.x2 = xmid; lp1.y2 = ymid; lp1.len = len2; lp1.dx = abs(lp1.x2 - lp1.x1); lp1.dy = abs(lp1.y2 - lp1.y1); lp2.x1 = xmid; lp2.y1 = ymid; lp2.len = len2; lp2.dx = abs(lp2.x2 - lp2.x1); lp2.dy = abs(lp2.y2 - lp2.y1); } //--------------------------------------------------------------------- int x1, y1, x2, y2, dx, dy, sx, sy; bool vertical; int inc; int len; int octant; //--------------------------------------------------------------------- static const int8u s_orthogonal_quadrant[8]; static const int8u s_diagonal_quadrant[8]; }; // See Implementation agg_line_aa_basics.cpp //----------------------------------------------------------------bisectrix void bisectrix(const line_parameters& l1, const line_parameters& l2, int* x, int* y); //-------------------------------------------fix_degenerate_bisectrix_start void inline fix_degenerate_bisectrix_start(const line_parameters& lp, int* x, int* y) { int d = iround((double(*x - lp.x2) * double(lp.y2 - lp.y1) - double(*y - lp.y2) * double(lp.x2 - lp.x1)) / lp.len); if(d < line_subpixel_scale/2) { *x = lp.x1 + (lp.y2 - lp.y1); *y = lp.y1 - (lp.x2 - lp.x1); } } //---------------------------------------------fix_degenerate_bisectrix_end void inline fix_degenerate_bisectrix_end(const line_parameters& lp, int* x, int* y) { int d = iround((double(*x - lp.x2) * double(lp.y2 - lp.y1) - double(*y - lp.y2) * double(lp.x2 - lp.x1)) / lp.len); if(d < line_subpixel_scale/2) { *x = lp.x2 + (lp.y2 - lp.y1); *y = lp.y2 - (lp.x2 - lp.x1); } } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_rasterizer_outline.h0000644000175000017500000001046012516137326025715 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_RASTERIZER_OUTLINE_INCLUDED #define AGG_RASTERIZER_OUTLINE_INCLUDED #include "agg_basics.h" namespace agg24 { //======================================================rasterizer_outline template class rasterizer_outline { public: rasterizer_outline(Renderer& ren) : m_ren(&ren), m_start_x(0), m_start_y(0), m_vertices(0) {} void attach(Renderer& ren) { m_ren = &ren; } //-------------------------------------------------------------------- void move_to(int x, int y) { m_vertices = 1; m_ren->move_to(m_start_x = x, m_start_y = y); } //-------------------------------------------------------------------- void line_to(int x, int y) { ++m_vertices; m_ren->line_to(x, y); } //-------------------------------------------------------------------- void move_to_d(double x, double y) { move_to(m_ren->coord(x), m_ren->coord(y)); } //-------------------------------------------------------------------- void line_to_d(double x, double y) { line_to(m_ren->coord(x), m_ren->coord(y)); } //-------------------------------------------------------------------- void close() { if(m_vertices > 2) { line_to(m_start_x, m_start_y); } m_vertices = 0; } //-------------------------------------------------------------------- void add_vertex(double x, double y, unsigned cmd) { if(is_move_to(cmd)) { move_to_d(x, y); } else { if(is_end_poly(cmd)) { if(is_closed(cmd)) close(); } else { line_to_d(x, y); } } } //-------------------------------------------------------------------- template void add_path(VertexSource& vs, unsigned path_id=0) { double x; double y; unsigned cmd; vs.rewind(path_id); while(!is_stop(cmd = vs.vertex(&x, &y))) { add_vertex(x, y, cmd); } } //-------------------------------------------------------------------- template void render_all_paths(VertexSource& vs, const ColorStorage& colors, const PathId& path_id, unsigned num_paths) { for(unsigned i = 0; i < num_paths; i++) { m_ren->line_color(colors[i]); add_path(vs, path_id[i]); } } //-------------------------------------------------------------------- template void render_ctrl(Ctrl& c) { unsigned i; for(i = 0; i < c.num_paths(); i++) { m_ren->line_color(c.color(i)); add_path(c, i); } } private: Renderer* m_ren; int m_start_x; int m_start_y; unsigned m_vertices; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_gsv_text.h0000644000175000017500000001006212516137326023625 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Class gsv_text // //---------------------------------------------------------------------------- #ifndef AGG_GSV_TEXT_INCLUDED #define AGG_GSV_TEXT_INCLUDED #include "agg_array.h" #include "agg_conv_stroke.h" #include "agg_conv_transform.h" namespace agg24 { //---------------------------------------------------------------gsv_text // // See Implementation agg_gsv_text.cpp // class gsv_text { enum status { initial, next_char, start_glyph, glyph }; public: gsv_text(); void font(const void* font); void flip(bool flip_y) { m_flip = flip_y; } void load_font(const char* file); void size(double height, double width=0.0); void space(double space); void line_space(double line_space); void start_point(double x, double y); void text(const char* text); void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: // not supposed to be copied gsv_text(const gsv_text&); const gsv_text& operator = (const gsv_text&); int16u value(const int8u* p) const { int16u v; if(m_big_endian) { *(int8u*)&v = p[1]; *((int8u*)&v + 1) = p[0]; } else { *(int8u*)&v = p[0]; *((int8u*)&v + 1) = p[1]; } return v; } private: double m_x; double m_y; double m_start_x; double m_width; double m_height; double m_space; double m_line_space; char m_chr[2]; char* m_text; pod_array m_text_buf; char* m_cur_chr; const void* m_font; pod_array m_loaded_font; status m_status; bool m_big_endian; bool m_flip; int8u* m_indices; int8* m_glyphs; int8* m_bglyph; int8* m_eglyph; double m_w; double m_h; }; //--------------------------------------------------------gsv_text_outline template class gsv_text_outline { public: gsv_text_outline(gsv_text& text, const Transformer& trans) : m_polyline(text), m_trans(m_polyline, trans) { } void width(double w) { m_polyline.width(w); } void transformer(const Transformer* trans) { m_trans->transformer(trans); } void rewind(unsigned path_id) { m_trans.rewind(path_id); m_polyline.line_join(round_join); m_polyline.line_cap(round_cap); } unsigned vertex(double* x, double* y) { return m_trans.vertex(x, y); } private: conv_stroke m_polyline; conv_transform, Transformer> m_trans; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_path_length.h0000644000175000017500000000366312516137326024270 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_PATH_LENGTH_INCLUDED #define AGG_PATH_LENGTH_INCLUDED #include "agg_math.h" namespace agg24 { template double path_length(VertexSource& vs, unsigned path_id = 0) { double len = 0.0; double start_x = 0.0; double start_y = 0.0; double x1 = 0.0; double y1 = 0.0; double x2 = 0.0; double y2 = 0.0; bool first = true; unsigned cmd; vs.rewind(path_id); while(!is_stop(cmd = vs.vertex(&x2, &y2))) { if(is_vertex(cmd)) { if(first || is_move_to(cmd)) { start_x = x2; start_y = y2; } else { len += calc_distance(x1, y1, x2, y2); } x1 = x2; y1 = y2; first = false; } else { if(is_close(cmd) && !first) { len += calc_distance(x1, y1, start_x, start_y); } } } return len; } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_trans_double_path.h0000644000175000017500000001034012516137326025456 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_TRANS_DOUBLE_PATH_INCLUDED #define AGG_TRANS_DOUBLE_PATH_INCLUDED #include "agg_basics.h" #include "agg_vertex_sequence.h" namespace agg24 { // See also: agg_trans_double_path.cpp // //-------------------------------------------------------trans_double_path class trans_double_path { enum status_e { initial, making_path, ready }; public: typedef vertex_sequence vertex_storage; trans_double_path(); //-------------------------------------------------------------------- void base_length(double v) { m_base_length = v; } double base_length() const { return m_base_length; } //-------------------------------------------------------------------- void base_height(double v) { m_base_height = v; } double base_height() const { return m_base_height; } //-------------------------------------------------------------------- void preserve_x_scale(bool f) { m_preserve_x_scale = f; } bool preserve_x_scale() const { return m_preserve_x_scale; } //-------------------------------------------------------------------- void reset(); void move_to1(double x, double y); void line_to1(double x, double y); void move_to2(double x, double y); void line_to2(double x, double y); void finalize_paths(); //-------------------------------------------------------------------- template void add_paths(VertexSource1& vs1, VertexSource2& vs2, unsigned path1_id=0, unsigned path2_id=0) { double x; double y; unsigned cmd; vs1.rewind(path1_id); while(!is_stop(cmd = vs1.vertex(&x, &y))) { if(is_move_to(cmd)) { move_to1(x, y); } else { if(is_vertex(cmd)) { line_to1(x, y); } } } vs2.rewind(path2_id); while(!is_stop(cmd = vs2.vertex(&x, &y))) { if(is_move_to(cmd)) { move_to2(x, y); } else { if(is_vertex(cmd)) { line_to2(x, y); } } } finalize_paths(); } //-------------------------------------------------------------------- double total_length1() const; double total_length2() const; void transform(double *x, double *y) const; private: double finalize_path(vertex_storage& vertices); void transform1(const vertex_storage& vertices, double kindex, double kx, double *x, double* y) const; vertex_storage m_src_vertices1; vertex_storage m_src_vertices2; double m_base_length; double m_base_height; double m_kindex1; double m_kindex2; status_e m_status1; status_e m_status2; bool m_preserve_x_scale; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_array.h0000644000175000017500000010211312516137326023077 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_ARRAY_INCLUDED #define AGG_ARRAY_INCLUDED #include #include #include "agg_basics.h" namespace agg24 { //-------------------------------------------------------pod_array_adaptor template class pod_array_adaptor { public: typedef T value_type; pod_array_adaptor(T* array, unsigned size) : m_array(array), m_size(size) {} unsigned size() const { return m_size; } const T& operator [] (unsigned i) const { return m_array[i]; } T& operator [] (unsigned i) { return m_array[i]; } const T& at(unsigned i) const { return m_array[i]; } T& at(unsigned i) { return m_array[i]; } T value_at(unsigned i) const { return m_array[i]; } private: T* m_array; unsigned m_size; }; //---------------------------------------------------------pod_auto_array template class pod_auto_array { public: typedef T value_type; typedef pod_auto_array self_type; pod_auto_array() {} explicit pod_auto_array(const T* c) { memcpy(m_array, c, sizeof(T) * Size); } const self_type& operator = (const T* c) { memcpy(m_array, c, sizeof(T) * Size); return *this; } static unsigned size() { return Size; } const T& operator [] (unsigned i) const { return m_array[i]; } T& operator [] (unsigned i) { return m_array[i]; } const T& at(unsigned i) const { return m_array[i]; } T& at(unsigned i) { return m_array[i]; } T value_at(unsigned i) const { return m_array[i]; } private: T m_array[Size]; }; //--------------------------------------------------------pod_auto_vector template class pod_auto_vector { public: typedef T value_type; typedef pod_auto_vector self_type; pod_auto_vector() : m_size(0) {} void remove_all() { m_size = 0; } void clear() { m_size = 0; } void add(const T& v) { m_array[m_size++] = v; } void push_back(const T& v) { m_array[m_size++] = v; } void inc_size(unsigned size) { m_size += size; } unsigned size() const { return m_size; } const T& operator [] (unsigned i) const { return m_array[i]; } T& operator [] (unsigned i) { return m_array[i]; } const T& at(unsigned i) const { return m_array[i]; } T& at(unsigned i) { return m_array[i]; } T value_at(unsigned i) const { return m_array[i]; } private: T m_array[Size]; unsigned m_size; }; //---------------------------------------------------------------pod_array template class pod_array { public: typedef T value_type; typedef pod_array self_type; ~pod_array() { pod_allocator::deallocate(m_array, m_size); } pod_array() : m_array(0), m_size(0) {} pod_array(unsigned size) : m_array(pod_allocator::allocate(size)), m_size(size) {} pod_array(const self_type& v) : m_array(pod_allocator::allocate(v.m_size)), m_size(v.m_size) { memcpy(m_array, v.m_array, sizeof(T) * m_size); } void resize(unsigned size) { if(size != m_size) { pod_allocator::deallocate(m_array, m_size); m_array = pod_allocator::allocate(m_size = size); } } const self_type& operator = (const self_type& v) { resize(v.size()); memcpy(m_array, v.m_array, sizeof(T) * m_size); return *this; } unsigned size() const { return m_size; } const T& operator [] (unsigned i) const { return m_array[i]; } T& operator [] (unsigned i) { return m_array[i]; } const T& at(unsigned i) const { return m_array[i]; } T& at(unsigned i) { return m_array[i]; } T value_at(unsigned i) const { return m_array[i]; } const T* data() const { return m_array; } T* data() { return m_array; } private: T* m_array; unsigned m_size; }; //--------------------------------------------------------------pod_vector // A simple class template to store Plain Old Data, a vector // of a fixed size. The data is continous in memory //------------------------------------------------------------------------ template class pod_vector { public: typedef T value_type; ~pod_vector() { pod_allocator::deallocate(m_array, m_capacity); } pod_vector() : m_size(0), m_capacity(0), m_array(0) {} pod_vector(unsigned cap, unsigned extra_tail=0); // Copying pod_vector(const pod_vector&); const pod_vector& operator = (const pod_vector&); // Set new capacity. All data is lost, size is set to zero. void capacity(unsigned cap, unsigned extra_tail=0); unsigned capacity() const { return m_capacity; } // Allocate n elements. All data is lost, // but elements can be accessed in range 0...size-1. void allocate(unsigned size, unsigned extra_tail=0); // Resize keeping the content. void resize(unsigned new_size); void zero() { memset(m_array, 0, sizeof(T) * m_size); } void add(const T& v) { m_array[m_size++] = v; } void push_back(const T& v) { m_array[m_size++] = v; } void insert_at(unsigned pos, const T& val); void inc_size(unsigned size) { m_size += size; } unsigned size() const { return m_size; } unsigned byte_size() const { return m_size * sizeof(T); } void serialize(int8u* ptr) const; void deserialize(const int8u* data, unsigned byte_size); const T& operator [] (unsigned i) const { return m_array[i]; } T& operator [] (unsigned i) { return m_array[i]; } const T& at(unsigned i) const { return m_array[i]; } T& at(unsigned i) { return m_array[i]; } T value_at(unsigned i) const { return m_array[i]; } const T* data() const { return m_array; } T* data() { return m_array; } void remove_all() { m_size = 0; } void clear() { m_size = 0; } void cut_at(unsigned num) { if(num < m_size) m_size = num; } private: unsigned m_size; unsigned m_capacity; T* m_array; }; //------------------------------------------------------------------------ template void pod_vector::capacity(unsigned cap, unsigned extra_tail) { m_size = 0; if(cap > m_capacity) { pod_allocator::deallocate(m_array, m_capacity); m_capacity = cap + extra_tail; m_array = m_capacity ? pod_allocator::allocate(m_capacity) : 0; } } //------------------------------------------------------------------------ template void pod_vector::allocate(unsigned size, unsigned extra_tail) { capacity(size, extra_tail); m_size = size; } //------------------------------------------------------------------------ template void pod_vector::resize(unsigned new_size) { if(new_size > m_size) { if(new_size > m_capacity) { T* data = pod_allocator::allocate(new_size); memcpy(data, m_array, m_size * sizeof(T)); pod_allocator::deallocate(m_array, m_capacity); m_array = data; } } else { m_size = new_size; } } //------------------------------------------------------------------------ template pod_vector::pod_vector(unsigned cap, unsigned extra_tail) : m_size(0), m_capacity(cap + extra_tail), m_array(pod_allocator::allocate(m_capacity)) {} //------------------------------------------------------------------------ template pod_vector::pod_vector(const pod_vector& v) : m_size(v.m_size), m_capacity(v.m_capacity), m_array(v.m_capacity ? pod_allocator::allocate(v.m_capacity) : 0) { memcpy(m_array, v.m_array, sizeof(T) * v.m_size); } //------------------------------------------------------------------------ template const pod_vector& pod_vector::operator = (const pod_vector&v) { allocate(v.m_size); if(v.m_size) memcpy(m_array, v.m_array, sizeof(T) * v.m_size); return *this; } //------------------------------------------------------------------------ template void pod_vector::serialize(int8u* ptr) const { if(m_size) memcpy(ptr, m_array, m_size * sizeof(T)); } //------------------------------------------------------------------------ template void pod_vector::deserialize(const int8u* data, unsigned byte_size) { byte_size /= sizeof(T); allocate(byte_size); if(byte_size) memcpy(m_array, data, byte_size * sizeof(T)); } //------------------------------------------------------------------------ template void pod_vector::insert_at(unsigned pos, const T& val) { if(pos >= m_size) { m_array[m_size] = val; } else { memmove(m_array + pos + 1, m_array + pos, (m_size - pos) * sizeof(T)); m_array[pos] = val; } ++m_size; } //---------------------------------------------------------------pod_bvector // A simple class template to store Plain Old Data, similar to std::deque // It doesn't reallocate memory but instead, uses blocks of data of size // of (1 << S), that is, power of two. The data is NOT contiguous in memory, // so the only valid access method is operator [] or curr(), prev(), next() // // There reallocs occure only when the pool of pointers to blocks needs // to be extended (it happens very rarely). You can control the value // of increment to reallocate the pointer buffer. See the second constructor. // By default, the incremeent value equals (1 << S), i.e., the block size. //------------------------------------------------------------------------ template class pod_bvector { public: enum block_scale_e { block_shift = S, block_size = 1 << block_shift, block_mask = block_size - 1 }; typedef T value_type; ~pod_bvector(); pod_bvector(); pod_bvector(unsigned block_ptr_inc); // Copying pod_bvector(const pod_bvector& v); const pod_bvector& operator = (const pod_bvector& v); void remove_all() { m_size = 0; } void clear() { m_size = 0; } void free_all() { free_tail(0); } void free_tail(unsigned size); void add(const T& val); void push_back(const T& val) { add(val); } void modify_last(const T& val); void remove_last(); int allocate_continuous_block(unsigned num_elements); void add_array(const T* ptr, unsigned num_elem) { while(num_elem--) { add(*ptr++); } } template void add_data(DataAccessor& data) { while(data.size()) { add(*data); ++data; } } void cut_at(unsigned size) { if(size < m_size) m_size = size; } unsigned size() const { return m_size; } const T& operator [] (unsigned i) const { return m_blocks[i >> block_shift][i & block_mask]; } T& operator [] (unsigned i) { return m_blocks[i >> block_shift][i & block_mask]; } const T& at(unsigned i) const { return m_blocks[i >> block_shift][i & block_mask]; } T& at(unsigned i) { return m_blocks[i >> block_shift][i & block_mask]; } T value_at(unsigned i) const { return m_blocks[i >> block_shift][i & block_mask]; } const T& curr(unsigned idx) const { return (*this)[idx]; } T& curr(unsigned idx) { return (*this)[idx]; } const T& prev(unsigned idx) const { return (*this)[(idx + m_size - 1) % m_size]; } T& prev(unsigned idx) { return (*this)[(idx + m_size - 1) % m_size]; } const T& next(unsigned idx) const { return (*this)[(idx + 1) % m_size]; } T& next(unsigned idx) { return (*this)[(idx + 1) % m_size]; } const T& last() const { return (*this)[m_size - 1]; } T& last() { return (*this)[m_size - 1]; } unsigned byte_size() const; void serialize(int8u* ptr) const; void deserialize(const int8u* data, unsigned byte_size); void deserialize(unsigned start, const T& empty_val, const int8u* data, unsigned byte_size); template void deserialize(ByteAccessor data) { remove_all(); unsigned elem_size = data.size() / sizeof(T); for(unsigned i = 0; i < elem_size; ++i) { int8u* ptr = (int8u*)data_ptr(); for(unsigned j = 0; j < sizeof(T); ++j) { *ptr++ = *data; ++data; } ++m_size; } } template void deserialize(unsigned start, const T& empty_val, ByteAccessor data) { while(m_size < start) { add(empty_val); } unsigned elem_size = data.size() / sizeof(T); for(unsigned i = 0; i < elem_size; ++i) { int8u* ptr; if(start + i < m_size) { ptr = (int8u*)(&((*this)[start + i])); } else { ptr = (int8u*)data_ptr(); ++m_size; } for(unsigned j = 0; j < sizeof(T); ++j) { *ptr++ = *data; ++data; } } } const T* block(unsigned nb) const { return m_blocks[nb]; } private: void allocate_block(unsigned nb); T* data_ptr(); unsigned m_size; unsigned m_num_blocks; unsigned m_max_blocks; T** m_blocks; unsigned m_block_ptr_inc; }; //------------------------------------------------------------------------ template pod_bvector::~pod_bvector() { if(m_num_blocks) { T** blk = m_blocks + m_num_blocks - 1; while(m_num_blocks--) { pod_allocator::deallocate(*blk, block_size); --blk; } } pod_allocator::deallocate(m_blocks, m_max_blocks); } //------------------------------------------------------------------------ template void pod_bvector::free_tail(unsigned size) { if(size < m_size) { unsigned nb = (size + block_mask) >> block_shift; while(m_num_blocks > nb) { pod_allocator::deallocate(m_blocks[--m_num_blocks], block_size); } if(m_num_blocks == 0) { pod_allocator::deallocate(m_blocks, m_max_blocks); m_blocks = 0; m_max_blocks = 0; } m_size = size; } } //------------------------------------------------------------------------ template pod_bvector::pod_bvector() : m_size(0), m_num_blocks(0), m_max_blocks(0), m_blocks(0), m_block_ptr_inc(block_size) { } //------------------------------------------------------------------------ template pod_bvector::pod_bvector(unsigned block_ptr_inc) : m_size(0), m_num_blocks(0), m_max_blocks(0), m_blocks(0), m_block_ptr_inc(block_ptr_inc) { } //------------------------------------------------------------------------ template pod_bvector::pod_bvector(const pod_bvector& v) : m_size(v.m_size), m_num_blocks(v.m_num_blocks), m_max_blocks(v.m_max_blocks), m_blocks(v.m_max_blocks ? pod_allocator::allocate(v.m_max_blocks) : 0), m_block_ptr_inc(v.m_block_ptr_inc) { unsigned i; for(i = 0; i < v.m_num_blocks; ++i) { m_blocks[i] = pod_allocator::allocate(block_size); memcpy(m_blocks[i], v.m_blocks[i], block_size * sizeof(T)); } } //------------------------------------------------------------------------ template const pod_bvector& pod_bvector::operator = (const pod_bvector& v) { unsigned i; for(i = m_num_blocks; i < v.m_num_blocks; ++i) { allocate_block(i); } for(i = 0; i < v.m_num_blocks; ++i) { memcpy(m_blocks[i], v.m_blocks[i], block_size * sizeof(T)); } m_size = v.m_size; return *this; } //------------------------------------------------------------------------ template void pod_bvector::allocate_block(unsigned nb) { if(nb >= m_max_blocks) { T** new_blocks = pod_allocator::allocate(m_max_blocks + m_block_ptr_inc); if(m_blocks) { memcpy(new_blocks, m_blocks, m_num_blocks * sizeof(T*)); pod_allocator::deallocate(m_blocks, m_max_blocks); } m_blocks = new_blocks; m_max_blocks += m_block_ptr_inc; } m_blocks[nb] = pod_allocator::allocate(block_size); m_num_blocks++; } //------------------------------------------------------------------------ template inline T* pod_bvector::data_ptr() { unsigned nb = m_size >> block_shift; if(nb >= m_num_blocks) { allocate_block(nb); } return m_blocks[nb] + (m_size & block_mask); } //------------------------------------------------------------------------ template inline void pod_bvector::add(const T& val) { *data_ptr() = val; ++m_size; } //------------------------------------------------------------------------ template inline void pod_bvector::remove_last() { if(m_size) --m_size; } //------------------------------------------------------------------------ template void pod_bvector::modify_last(const T& val) { remove_last(); add(val); } //------------------------------------------------------------------------ template int pod_bvector::allocate_continuous_block(unsigned num_elements) { if(num_elements < block_size) { data_ptr(); // Allocate initial block if necessary unsigned rest = block_size - (m_size & block_mask); unsigned index; if(num_elements <= rest) { // The rest of the block is good, we can use it //----------------- index = m_size; m_size += num_elements; return index; } // New block //--------------- m_size += rest; data_ptr(); index = m_size; m_size += num_elements; return index; } return -1; // Impossible to allocate } //------------------------------------------------------------------------ template unsigned pod_bvector::byte_size() const { return m_size * sizeof(T); } //------------------------------------------------------------------------ template void pod_bvector::serialize(int8u* ptr) const { unsigned i; for(i = 0; i < m_size; i++) { memcpy(ptr, &(*this)[i], sizeof(T)); ptr += sizeof(T); } } //------------------------------------------------------------------------ template void pod_bvector::deserialize(const int8u* data, unsigned byte_size) { remove_all(); byte_size /= sizeof(T); for(unsigned i = 0; i < byte_size; ++i) { T* ptr = data_ptr(); memcpy(ptr, data, sizeof(T)); ++m_size; data += sizeof(T); } } // Replace or add a number of elements starting from "start" position //------------------------------------------------------------------------ template void pod_bvector::deserialize(unsigned start, const T& empty_val, const int8u* data, unsigned byte_size) { while(m_size < start) { add(empty_val); } byte_size /= sizeof(T); for(unsigned i = 0; i < byte_size; ++i) { if(start + i < m_size) { memcpy(&((*this)[start + i]), data, sizeof(T)); } else { T* ptr = data_ptr(); memcpy(ptr, data, sizeof(T)); ++m_size; } data += sizeof(T); } } //---------------------------------------------------------block_allocator // Allocator for arbitrary POD data. Most usable in different cache // systems for efficient memory allocations. // Memory is allocated with blocks of fixed size ("block_size" in // the constructor). If required size exceeds the block size the allocator // creates a new block of the required size. However, the most efficient // use is when the average reqired size is much less than the block size. //------------------------------------------------------------------------ class block_allocator { struct block_type { int8u* data; unsigned size; }; public: void remove_all() { if(m_num_blocks) { block_type* blk = m_blocks + m_num_blocks - 1; while(m_num_blocks--) { pod_allocator::deallocate(blk->data, blk->size); --blk; } pod_allocator::deallocate(m_blocks, m_max_blocks); } m_num_blocks = 0; m_max_blocks = 0; m_blocks = 0; m_buf_ptr = 0; m_rest = 0; } ~block_allocator() { remove_all(); } block_allocator(unsigned block_size, unsigned block_ptr_inc=256-8) : m_block_size(block_size), m_block_ptr_inc(block_ptr_inc), m_num_blocks(0), m_max_blocks(0), m_blocks(0), m_buf_ptr(0), m_rest(0) { } int8u* allocate(unsigned size, unsigned alignment=1) { if(size == 0) return 0; if(size <= m_rest) { int8u* ptr = m_buf_ptr; if(alignment > 1) { unsigned align = (alignment - unsigned((size_t)ptr) % alignment) % alignment; size += align; ptr += align; if(size <= m_rest) { m_rest -= size; m_buf_ptr += size; return ptr; } allocate_block(size); return allocate(size - align, alignment); } m_rest -= size; m_buf_ptr += size; return ptr; } allocate_block(size + alignment - 1); return allocate(size, alignment); } private: void allocate_block(unsigned size) { if(size < m_block_size) size = m_block_size; if(m_num_blocks >= m_max_blocks) { block_type* new_blocks = pod_allocator::allocate(m_max_blocks + m_block_ptr_inc); if(m_blocks) { memcpy(new_blocks, m_blocks, m_num_blocks * sizeof(block_type)); pod_allocator::deallocate(m_blocks, m_max_blocks); } m_blocks = new_blocks; m_max_blocks += m_block_ptr_inc; } m_blocks[m_num_blocks].size = size; m_blocks[m_num_blocks].data = m_buf_ptr = pod_allocator::allocate(size); m_num_blocks++; m_rest = size; } unsigned m_block_size; unsigned m_block_ptr_inc; unsigned m_num_blocks; unsigned m_max_blocks; block_type* m_blocks; int8u* m_buf_ptr; unsigned m_rest; }; //------------------------------------------------------------------------ enum quick_sort_threshold_e { quick_sort_threshold = 9 }; //-----------------------------------------------------------swap_elements template inline void swap_elements(T& a, T& b) { T temp = a; a = b; b = temp; } //--------------------------------------------------------------quick_sort template void quick_sort(Array& arr, Less less) { if(arr.size() < 2) return; typename Array::value_type* e1; typename Array::value_type* e2; int stack[80]; int* top = stack; int limit = arr.size(); int base = 0; for(;;) { int len = limit - base; int i; int j; int pivot; if(len > quick_sort_threshold) { // we use base + len/2 as the pivot pivot = base + len / 2; swap_elements(arr[base], arr[pivot]); i = base + 1; j = limit - 1; // now ensure that *i <= *base <= *j e1 = &(arr[j]); e2 = &(arr[i]); if(less(*e1, *e2)) swap_elements(*e1, *e2); e1 = &(arr[base]); e2 = &(arr[i]); if(less(*e1, *e2)) swap_elements(*e1, *e2); e1 = &(arr[j]); e2 = &(arr[base]); if(less(*e1, *e2)) swap_elements(*e1, *e2); for(;;) { do i++; while( less(arr[i], arr[base]) ); do j--; while( less(arr[base], arr[j]) ); if( i > j ) { break; } swap_elements(arr[i], arr[j]); } swap_elements(arr[base], arr[j]); // now, push the largest sub-array if(j - base > limit - i) { top[0] = base; top[1] = j; base = i; } else { top[0] = i; top[1] = limit; limit = j; } top += 2; } else { // the sub-array is small, perform insertion sort j = base; i = j + 1; for(; i < limit; j = i, i++) { for(; less(*(e1 = &(arr[j + 1])), *(e2 = &(arr[j]))); j--) { swap_elements(*e1, *e2); if(j == base) { break; } } } if(top > stack) { top -= 2; base = top[0]; limit = top[1]; } else { break; } } } } //------------------------------------------------------remove_duplicates // Remove duplicates from a sorted array. It doesn't cut the // tail of the array, it just returns the number of remaining elements. //----------------------------------------------------------------------- template unsigned remove_duplicates(Array& arr, Equal equal) { if(arr.size() < 2) return arr.size(); unsigned i, j; for(i = 1, j = 1; i < arr.size(); i++) { typename Array::value_type& e = arr[i]; if(!equal(e, arr[i - 1])) { arr[j++] = e; } } return j; } //--------------------------------------------------------invert_container template void invert_container(Array& arr) { int i = 0; int j = arr.size() - 1; while(i < j) { swap_elements(arr[i++], arr[j--]); } } //------------------------------------------------------binary_search_pos template unsigned binary_search_pos(const Array& arr, const Value& val, Less less) { if(arr.size() == 0) return 0; unsigned beg = 0; unsigned end = arr.size() - 1; if(less(val, arr[0])) return 0; if(less(arr[end], val)) return end + 1; while(end - beg > 1) { unsigned mid = (end + beg) >> 1; if(less(val, arr[mid])) end = mid; else beg = mid; } //if(beg <= 0 && less(val, arr[0])) return 0; //if(end >= arr.size() - 1 && less(arr[end], val)) ++end; return end; } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_pixfmt_amask_adaptor.h0000644000175000017500000001771612516137326026174 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_PIXFMT_AMASK_ADAPTOR_INCLUDED #define AGG_PIXFMT_AMASK_ADAPTOR_INCLUDED #include #include "agg_array.h" #include "agg_rendering_buffer.h" namespace agg24 { //==================================================pixfmt_amask_adaptor template class pixfmt_amask_adaptor { public: typedef PixFmt pixfmt_type; typedef typename pixfmt_type::color_type color_type; typedef typename pixfmt_type::row_data row_data; typedef AlphaMask amask_type; typedef typename amask_type::cover_type cover_type; private: enum span_extra_tail_e { span_extra_tail = 256 }; void realloc_span(unsigned len) { if(len > m_span.size()) { m_span.resize(len + span_extra_tail); } } void init_span(unsigned len) { realloc_span(len); memset(&m_span[0], amask_type::cover_full, len * sizeof(cover_type)); } void init_span(unsigned len, const cover_type* covers) { realloc_span(len); memcpy(&m_span[0], covers, len * sizeof(cover_type)); } public: pixfmt_amask_adaptor(pixfmt_type& pixf, const amask_type& mask) : m_pixf(&pixf), m_mask(&mask), m_span() {} void attach_pixfmt(pixfmt_type& pixf) { m_pixf = &pixf; } void attach_alpha_mask(const amask_type& mask) { m_mask = &mask; } //-------------------------------------------------------------------- unsigned width() const { return m_pixf->width(); } unsigned height() const { return m_pixf->height(); } //-------------------------------------------------------------------- color_type pixel(int x, int y) { return m_pixf->pixel(x, y); } //-------------------------------------------------------------------- void copy_pixel(int x, int y, const color_type& c) { m_pixf->blend_pixel(x, y, c, m_mask->pixel(x, y)); } //-------------------------------------------------------------------- void blend_pixel(int x, int y, const color_type& c, cover_type cover) { m_pixf->blend_pixel(x, y, c, m_mask->combine_pixel(x, y, cover)); } //-------------------------------------------------------------------- void copy_hline(int x, int y, unsigned len, const color_type& c) { realloc_span(len); m_mask->fill_hspan(x, y, &m_span[0], len); m_pixf->blend_solid_hspan(x, y, len, c, &m_span[0]); } //-------------------------------------------------------------------- void blend_hline(int x, int y, unsigned len, const color_type& c, cover_type cover) { init_span(len); m_mask->combine_hspan(x, y, &m_span[0], len); m_pixf->blend_solid_hspan(x, y, len, c, &m_span[0]); } //-------------------------------------------------------------------- void copy_vline(int x, int y, unsigned len, const color_type& c) { realloc_span(len); m_mask->fill_vspan(x, y, &m_span[0], len); m_pixf->blend_solid_vspan(x, y, len, c, &m_span[0]); } //-------------------------------------------------------------------- void blend_vline(int x, int y, unsigned len, const color_type& c, cover_type cover) { init_span(len); m_mask->combine_vspan(x, y, &m_span[0], len); m_pixf->blend_solid_vspan(x, y, len, c, &m_span[0]); } //-------------------------------------------------------------------- void copy_from(const rendering_buffer& from, int xdst, int ydst, int xsrc, int ysrc, unsigned len) { m_pixf->copy_from(from, xdst, ydst, xsrc, ysrc, len); } //-------------------------------------------------------------------- void blend_solid_hspan(int x, int y, unsigned len, const color_type& c, const cover_type* covers) { init_span(len, covers); m_mask->combine_hspan(x, y, &m_span[0], len); m_pixf->blend_solid_hspan(x, y, len, c, &m_span[0]); } //-------------------------------------------------------------------- void blend_solid_vspan(int x, int y, unsigned len, const color_type& c, const cover_type* covers) { init_span(len, covers); m_mask->combine_vspan(x, y, &m_span[0], len); m_pixf->blend_solid_vspan(x, y, len, c, &m_span[0]); } //-------------------------------------------------------------------- void copy_color_hspan(int x, int y, unsigned len, const color_type* colors) { realloc_span(len); m_mask->fill_hspan(x, y, &m_span[0], len); m_pixf->blend_color_hspan(x, y, len, colors, &m_span[0], cover_full); } //-------------------------------------------------------------------- void blend_color_hspan(int x, int y, unsigned len, const color_type* colors, const cover_type* covers, cover_type cover = cover_full) { if(covers) { init_span(len, covers); m_mask->combine_hspan(x, y, &m_span[0], len); } else { realloc_span(len); m_mask->fill_hspan(x, y, &m_span[0], len); } m_pixf->blend_color_hspan(x, y, len, colors, &m_span[0], cover); } //-------------------------------------------------------------------- void blend_color_vspan(int x, int y, unsigned len, const color_type* colors, const cover_type* covers, cover_type cover = cover_full) { if(covers) { init_span(len, covers); m_mask->combine_vspan(x, y, &m_span[0], len); } else { realloc_span(len); m_mask->fill_vspan(x, y, &m_span[0], len); } m_pixf->blend_color_vspan(x, y, len, colors, &m_span[0], cover); } private: pixfmt_type* m_pixf; const amask_type* m_mask; pod_array m_span; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_transform.h0000644000175000017500000000412412516137326025024 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class conv_transform // //---------------------------------------------------------------------------- #ifndef AGG_CONV_TRANSFORM_INCLUDED #define AGG_CONV_TRANSFORM_INCLUDED #include "agg_basics.h" #include "agg_trans_affine.h" namespace agg24 { //----------------------------------------------------------conv_transform template class conv_transform { public: conv_transform(VertexSource& source, const Transformer& tr) : m_source(&source), m_trans(&tr) {} void attach(VertexSource& source) { m_source = &source; } void rewind(unsigned path_id) { m_source->rewind(path_id); } unsigned vertex(double* x, double* y) { unsigned cmd = m_source->vertex(x, y); if(is_vertex(cmd)) { m_trans->transform(x, y); } return cmd; } void transformer(const Transformer& tr) { m_trans = &tr; } private: conv_transform(const conv_transform&); const conv_transform& operator = (const conv_transform&); VertexSource* m_source; const Transformer* m_trans; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_renderer_scanline.h0000644000175000017500000006055712516137326025462 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_RENDERER_SCANLINE_INCLUDED #define AGG_RENDERER_SCANLINE_INCLUDED #include "agg_basics.h" #include "agg_renderer_base.h" namespace agg24 { //================================================render_scanline_aa_solid template void render_scanline_aa_solid(const Scanline& sl, BaseRenderer& ren, const ColorT& color) { int y = sl.y(); unsigned num_spans = sl.num_spans(); typename Scanline::const_iterator span = sl.begin(); for(;;) { int x = span->x; if(span->len > 0) { ren.blend_solid_hspan(x, y, (unsigned)span->len, color, span->covers); } else { ren.blend_hline(x, y, (unsigned)(x - span->len - 1), color, *(span->covers)); } if(--num_spans == 0) break; ++span; } } //===============================================render_scanlines_aa_solid template void render_scanlines_aa_solid(Rasterizer& ras, Scanline& sl, BaseRenderer& ren, const ColorT& color) { if(ras.rewind_scanlines()) { // Explicitly convert "color" to the BaseRenderer color type. // For example, it can be called with color type "rgba", while // "rgba8" is needed. Otherwise it will be implicitly // converted in the loop many times. //---------------------- typename BaseRenderer::color_type ren_color(color); sl.reset(ras.min_x(), ras.max_x()); while(ras.sweep_scanline(sl)) { //render_scanline_aa_solid(sl, ren, ren_color); // This code is equivalent to the above call (copy/paste). // It's just a "manual" optimization for old compilers, // like Microsoft Visual C++ v6.0 //------------------------------- int y = sl.y(); unsigned num_spans = sl.num_spans(); typename Scanline::const_iterator span = sl.begin(); for(;;) { int x = span->x; if(span->len > 0) { ren.blend_solid_hspan(x, y, (unsigned)span->len, ren_color, span->covers); } else { ren.blend_hline(x, y, (unsigned)(x - span->len - 1), ren_color, *(span->covers)); } if(--num_spans == 0) break; ++span; } } } } //==============================================renderer_scanline_aa_solid template class renderer_scanline_aa_solid { public: typedef BaseRenderer base_ren_type; typedef typename base_ren_type::color_type color_type; //-------------------------------------------------------------------- renderer_scanline_aa_solid() : m_ren(0) {} renderer_scanline_aa_solid(base_ren_type& ren) : m_ren(&ren) {} void attach(base_ren_type& ren) { m_ren = &ren; } //-------------------------------------------------------------------- void color(const color_type& c) { m_color = c; } const color_type& color() const { return m_color; } //-------------------------------------------------------------------- void prepare() {} //-------------------------------------------------------------------- template void render(const Scanline& sl) { render_scanline_aa_solid(sl, *m_ren, m_color); } private: base_ren_type* m_ren; color_type m_color; }; //======================================================render_scanline_aa template void render_scanline_aa(const Scanline& sl, BaseRenderer& ren, SpanAllocator& alloc, SpanGenerator& span_gen) { int y = sl.y(); unsigned num_spans = sl.num_spans(); typename Scanline::const_iterator span = sl.begin(); for(;;) { int x = span->x; int len = span->len; const typename Scanline::cover_type* covers = span->covers; if(len < 0) len = -len; typename BaseRenderer::color_type* colors = alloc.allocate(len); span_gen.generate(colors, x, y, len); ren.blend_color_hspan(x, y, len, colors, (span->len < 0) ? 0 : covers, *covers); if(--num_spans == 0) break; ++span; } } //=====================================================render_scanlines_aa template void render_scanlines_aa(Rasterizer& ras, Scanline& sl, BaseRenderer& ren, SpanAllocator& alloc, SpanGenerator& span_gen) { if(ras.rewind_scanlines()) { sl.reset(ras.min_x(), ras.max_x()); span_gen.prepare(); while(ras.sweep_scanline(sl)) { render_scanline_aa(sl, ren, alloc, span_gen); } } } //====================================================renderer_scanline_aa template class renderer_scanline_aa { public: typedef BaseRenderer base_ren_type; typedef SpanAllocator alloc_type; typedef SpanGenerator span_gen_type; //-------------------------------------------------------------------- renderer_scanline_aa() : m_ren(0), m_alloc(0), m_span_gen(0) {} renderer_scanline_aa(base_ren_type& ren, alloc_type& alloc, span_gen_type& span_gen) : m_ren(&ren), m_alloc(&alloc), m_span_gen(&span_gen) {} void attach(base_ren_type& ren, alloc_type& alloc, span_gen_type& span_gen) { m_ren = &ren; m_alloc = &alloc; m_span_gen = &span_gen; } //-------------------------------------------------------------------- void prepare() { m_span_gen->prepare(); } //-------------------------------------------------------------------- template void render(const Scanline& sl) { render_scanline_aa(sl, *m_ren, *m_alloc, *m_span_gen); } private: base_ren_type* m_ren; alloc_type* m_alloc; span_gen_type* m_span_gen; }; //===============================================render_scanline_bin_solid template void render_scanline_bin_solid(const Scanline& sl, BaseRenderer& ren, const ColorT& color) { unsigned num_spans = sl.num_spans(); typename Scanline::const_iterator span = sl.begin(); for(;;) { ren.blend_hline(span->x, sl.y(), span->x - 1 + ((span->len < 0) ? -span->len : span->len), color, cover_full); if(--num_spans == 0) break; ++span; } } //==============================================render_scanlines_bin_solid template void render_scanlines_bin_solid(Rasterizer& ras, Scanline& sl, BaseRenderer& ren, const ColorT& color) { if(ras.rewind_scanlines()) { // Explicitly convert "color" to the BaseRenderer color type. // For example, it can be called with color type "rgba", while // "rgba8" is needed. Otherwise it will be implicitly // converted in the loop many times. //---------------------- typename BaseRenderer::color_type ren_color(color); sl.reset(ras.min_x(), ras.max_x()); while(ras.sweep_scanline(sl)) { //render_scanline_bin_solid(sl, ren, ren_color); // This code is equivalent to the above call (copy/paste). // It's just a "manual" optimization for old compilers, // like Microsoft Visual C++ v6.0 //------------------------------- unsigned num_spans = sl.num_spans(); typename Scanline::const_iterator span = sl.begin(); for(;;) { ren.blend_hline(span->x, sl.y(), span->x - 1 + ((span->len < 0) ? -span->len : span->len), ren_color, cover_full); if(--num_spans == 0) break; ++span; } } } } //=============================================renderer_scanline_bin_solid template class renderer_scanline_bin_solid { public: typedef BaseRenderer base_ren_type; typedef typename base_ren_type::color_type color_type; //-------------------------------------------------------------------- renderer_scanline_bin_solid() : m_ren(0) {} renderer_scanline_bin_solid(base_ren_type& ren) : m_ren(&ren) {} void attach(base_ren_type& ren) { m_ren = &ren; } //-------------------------------------------------------------------- void color(const color_type& c) { m_color = c; } const color_type& color() const { return m_color; } //-------------------------------------------------------------------- void prepare() {} //-------------------------------------------------------------------- template void render(const Scanline& sl) { render_scanline_bin_solid(sl, *m_ren, m_color); } private: base_ren_type* m_ren; color_type m_color; }; //======================================================render_scanline_bin template void render_scanline_bin(const Scanline& sl, BaseRenderer& ren, SpanAllocator& alloc, SpanGenerator& span_gen) { int y = sl.y(); unsigned num_spans = sl.num_spans(); typename Scanline::const_iterator span = sl.begin(); for(;;) { int x = span->x; int len = span->len; if(len < 0) len = -len; typename BaseRenderer::color_type* colors = alloc.allocate(len); span_gen.generate(colors, x, y, len); ren.blend_color_hspan(x, y, len, colors, 0, cover_full); if(--num_spans == 0) break; ++span; } } //=====================================================render_scanlines_bin template void render_scanlines_bin(Rasterizer& ras, Scanline& sl, BaseRenderer& ren, SpanAllocator& alloc, SpanGenerator& span_gen) { if(ras.rewind_scanlines()) { sl.reset(ras.min_x(), ras.max_x()); span_gen.prepare(); while(ras.sweep_scanline(sl)) { render_scanline_bin(sl, ren, alloc, span_gen); } } } //====================================================renderer_scanline_bin template class renderer_scanline_bin { public: typedef BaseRenderer base_ren_type; typedef SpanAllocator alloc_type; typedef SpanGenerator span_gen_type; //-------------------------------------------------------------------- renderer_scanline_bin() : m_ren(0), m_alloc(0), m_span_gen(0) {} renderer_scanline_bin(base_ren_type& ren, alloc_type& alloc, span_gen_type& span_gen) : m_ren(&ren), m_alloc(&alloc), m_span_gen(&span_gen) {} void attach(base_ren_type& ren, alloc_type& alloc, span_gen_type& span_gen) { m_ren = &ren; m_alloc = &alloc; m_span_gen = &span_gen; } //-------------------------------------------------------------------- void prepare() { m_span_gen->prepare(); } //-------------------------------------------------------------------- template void render(const Scanline& sl) { render_scanline_bin(sl, *m_ren, *m_alloc, *m_span_gen); } private: base_ren_type* m_ren; alloc_type* m_alloc; span_gen_type* m_span_gen; }; //========================================================render_scanlines template void render_scanlines(Rasterizer& ras, Scanline& sl, Renderer& ren) { if(ras.rewind_scanlines()) { sl.reset(ras.min_x(), ras.max_x()); ren.prepare(); while(ras.sweep_scanline(sl)) { ren.render(sl); } } } //========================================================render_all_paths template void render_all_paths(Rasterizer& ras, Scanline& sl, Renderer& r, VertexSource& vs, const ColorStorage& as, const PathId& path_id, unsigned num_paths) { for(unsigned i = 0; i < num_paths; i++) { ras.reset(); ras.add_path(vs, path_id[i]); r.color(as[i]); render_scanlines(ras, sl, r); } } //=============================================render_scanlines_compound template void render_scanlines_compound(Rasterizer& ras, ScanlineAA& sl_aa, ScanlineBin& sl_bin, BaseRenderer& ren, SpanAllocator& alloc, StyleHandler& sh) { if(ras.rewind_scanlines()) { int min_x = ras.min_x(); int len = ras.max_x() - min_x + 2; sl_aa.reset(min_x, ras.max_x()); sl_bin.reset(min_x, ras.max_x()); typedef typename BaseRenderer::color_type color_type; color_type* color_span = alloc.allocate(len * 2); color_type* mix_buffer = color_span + len; unsigned num_spans; unsigned num_styles; unsigned style; bool solid; while((num_styles = ras.sweep_styles()) > 0) { typename ScanlineAA::const_iterator span_aa; if(num_styles == 1) { // Optimization for a single style. Happens often //------------------------- if(ras.sweep_scanline(sl_aa, 0)) { style = ras.style(0); if(sh.is_solid(style)) { // Just solid fill //----------------------- render_scanline_aa_solid(sl_aa, ren, sh.color(style)); } else { // Arbitrary span generator //----------------------- span_aa = sl_aa.begin(); num_spans = sl_aa.num_spans(); for(;;) { len = span_aa->len; sh.generate_span(color_span, span_aa->x, sl_aa.y(), len, style); ren.blend_color_hspan(span_aa->x, sl_aa.y(), span_aa->len, color_span, span_aa->covers); if(--num_spans == 0) break; ++span_aa; } } } } else { if(ras.sweep_scanline(sl_bin, -1)) { // Clear the spans of the mix_buffer //-------------------- typename ScanlineBin::const_iterator span_bin = sl_bin.begin(); num_spans = sl_bin.num_spans(); for(;;) { memset(mix_buffer + span_bin->x - min_x, 0, span_bin->len * sizeof(color_type)); if(--num_spans == 0) break; ++span_bin; } unsigned i; for(i = 0; i < num_styles; i++) { style = ras.style(i); solid = sh.is_solid(style); if(ras.sweep_scanline(sl_aa, i)) { color_type* colors; color_type* cspan; typename ScanlineAA::cover_type* covers; span_aa = sl_aa.begin(); num_spans = sl_aa.num_spans(); if(solid) { // Just solid fill //----------------------- for(;;) { color_type c = sh.color(style); len = span_aa->len; colors = mix_buffer + span_aa->x - min_x; covers = span_aa->covers; do { colors->add(c, *covers); ++colors; ++covers; } while(--len); if(--num_spans == 0) break; ++span_aa; } } else { // Arbitrary span generator //----------------------- for(;;) { len = span_aa->len; colors = mix_buffer + span_aa->x - min_x; cspan = color_span; sh.generate_span(cspan, span_aa->x, sl_aa.y(), len, style); covers = span_aa->covers; do { colors->add(*cspan, *covers); ++cspan; ++colors; ++covers; } while(--len); if(--num_spans == 0) break; ++span_aa; } } } } // Emit the blended result as a color hspan //------------------------- span_bin = sl_bin.begin(); num_spans = sl_bin.num_spans(); for(;;) { ren.blend_color_hspan(span_bin->x, sl_bin.y(), span_bin->len, mix_buffer + span_bin->x - min_x, 0, cover_full); if(--num_spans == 0) break; ++span_bin; } } } } } } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_gradient_alpha.h0000644000175000017500000001171212516137326025750 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_SPAN_GRADIENT_ALPHA_INCLUDED #define AGG_SPAN_GRADIENT_ALPHA_INCLUDED #include "agg_span_gradient.h" namespace agg24 { //======================================================span_gradient_alpha template class span_gradient_alpha { public: typedef Interpolator interpolator_type; typedef ColorT color_type; typedef typename color_type::value_type alpha_type; enum downscale_shift_e { downscale_shift = interpolator_type::subpixel_shift - gradient_subpixel_shift }; //-------------------------------------------------------------------- span_gradient_alpha() {} //-------------------------------------------------------------------- span_gradient_alpha(interpolator_type& inter, const GradientF& gradient_function, const AlphaF& alpha_function, double d1, double d2) : m_interpolator(&inter), m_gradient_function(&gradient_function), m_alpha_function(&alpha_function), m_d1(iround(d1 * gradient_subpixel_scale)), m_d2(iround(d2 * gradient_subpixel_scale)) {} //-------------------------------------------------------------------- interpolator_type& interpolator() { return *m_interpolator; } const GradientF& gradient_function() const { return *m_gradient_function; } const AlphaF& alpha_function() const { return *m_alpha_function; } double d1() const { return double(m_d1) / gradient_subpixel_scale; } double d2() const { return double(m_d2) / gradient_subpixel_scale; } //-------------------------------------------------------------------- void interpolator(interpolator_type& i) { m_interpolator = &i; } void gradient_function(const GradientF& gf) { m_gradient_function = &gf; } void alpha_function(const AlphaF& af) { m_alpha_function = ⁡ } void d1(double v) { m_d1 = iround(v * gradient_subpixel_scale); } void d2(double v) { m_d2 = iround(v * gradient_subpixel_scale); } //-------------------------------------------------------------------- void prepare() {} //-------------------------------------------------------------------- void generate(color_type* span, int x, int y, unsigned len) { int dd = m_d2 - m_d1; if(dd < 1) dd = 1; m_interpolator->begin(x+0.5, y+0.5, len); do { m_interpolator->coordinates(&x, &y); int d = m_gradient_function->calculate(x >> downscale_shift, y >> downscale_shift, m_d2); d = ((d - m_d1) * (int)m_alpha_function->size()) / dd; if(d < 0) d = 0; if(d >= (int)m_alpha_function->size()) d = m_alpha_function->size() - 1; span->a = (*m_alpha_function)[d]; ++span; ++(*m_interpolator); } while(--len); } private: interpolator_type* m_interpolator; const GradientF* m_gradient_function; const AlphaF* m_alpha_function; int m_d1; int m_d2; }; //=======================================================gradient_alpha_x template struct gradient_alpha_x { typedef typename ColorT::value_type alpha_type; alpha_type operator [] (alpha_type x) const { return x; } }; //====================================================gradient_alpha_x_u8 struct gradient_alpha_x_u8 { typedef int8u alpha_type; alpha_type operator [] (alpha_type x) const { return x; } }; //==========================================gradient_alpha_one_munus_x_u8 struct gradient_alpha_one_munus_x_u8 { typedef int8u alpha_type; alpha_type operator [] (alpha_type x) const { return 255-x; } }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_span_allocator.h0000644000175000017500000000350112516137326024763 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_SPAN_ALLOCATOR_INCLUDED #define AGG_SPAN_ALLOCATOR_INCLUDED #include "agg_array.h" namespace agg24 { //----------------------------------------------------------span_allocator template class span_allocator { public: typedef ColorT color_type; //-------------------------------------------------------------------- AGG_INLINE color_type* allocate(unsigned span_len) { if(span_len > m_span.size()) { // To reduce the number of reallocs we align the // span_len to 256 color elements. // Well, I just like this number and it looks reasonable. //----------------------- m_span.resize(((span_len + 255) >> 8) << 8); } return &m_span[0]; } AGG_INLINE color_type* span() { return &m_span[0]; } AGG_INLINE unsigned max_span_len() const { return m_span.size(); } private: pod_array m_span; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_smooth_poly1.h0000644000175000017500000000533512516137326025453 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Smooth polygon generator // //---------------------------------------------------------------------------- #ifndef AGG_CONV_SMOOTH_POLY1_INCLUDED #define AGG_CONV_SMOOTH_POLY1_INCLUDED #include "agg_basics.h" #include "agg_vcgen_smooth_poly1.h" #include "agg_conv_adaptor_vcgen.h" #include "agg_conv_curve.h" namespace agg24 { //-------------------------------------------------------conv_smooth_poly1 template struct conv_smooth_poly1 : public conv_adaptor_vcgen { typedef conv_adaptor_vcgen base_type; conv_smooth_poly1(VertexSource& vs) : conv_adaptor_vcgen(vs) { } void smooth_value(double v) { base_type::generator().smooth_value(v); } double smooth_value() const { return base_type::generator().smooth_value(); } private: conv_smooth_poly1(const conv_smooth_poly1&); const conv_smooth_poly1& operator = (const conv_smooth_poly1&); }; //-------------------------------------------------conv_smooth_poly1_curve template struct conv_smooth_poly1_curve : public conv_curve > { conv_smooth_poly1_curve(VertexSource& vs) : conv_curve >(m_smooth), m_smooth(vs) { } void smooth_value(double v) { m_smooth.generator().smooth_value(v); } double smooth_value() const { return m_smooth.generator().smooth_value(); } private: conv_smooth_poly1_curve(const conv_smooth_poly1_curve&); const conv_smooth_poly1_curve& operator = (const conv_smooth_poly1_curve&); conv_smooth_poly1 m_smooth; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_rasterizer_scanline_aa.h0000644000175000017500000004220312516137326026473 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // // The author gratefully acknowleges the support of David Turner, // Robert Wilhelm, and Werner Lemberg - the authors of the FreeType // libray - in producing this work. See http://www.freetype.org for details. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Adaptation for 32-bit screen coordinates has been sponsored by // Liberty Technology Systems, Inc., visit http://lib-sys.com // // Liberty Technology Systems, Inc. is the provider of // PostScript and PDF technology for software developers. // //---------------------------------------------------------------------------- #ifndef AGG_RASTERIZER_SCANLINE_AA_INCLUDED #define AGG_RASTERIZER_SCANLINE_AA_INCLUDED #include "agg_rasterizer_cells_aa.h" #include "agg_rasterizer_sl_clip.h" #include "agg_gamma_functions.h" namespace agg24 { //-----------------------------------------------------------------cell_aa // A pixel cell. There're no constructors defined and it was done // intentionally in order to avoid extra overhead when allocating an // array of cells. struct cell_aa { int x; int y; int cover; int area; void initial() { x = 0x7FFFFFFF; y = 0x7FFFFFFF; cover = 0; area = 0; } void style(const cell_aa&) {} int not_equal(int ex, int ey, const cell_aa&) const { return (ex - x) | (ey - y); } }; //==================================================rasterizer_scanline_aa // Polygon rasterizer that is used to render filled polygons with // high-quality Anti-Aliasing. Internally, by default, the class uses // integer coordinates in format 24.8, i.e. 24 bits for integer part // and 8 bits for fractional - see poly_subpixel_shift. This class can be // used in the following way: // // 1. filling_rule(filling_rule_e ft) - optional. // // 2. gamma() - optional. // // 3. reset() // // 4. move_to(x, y) / line_to(x, y) - make the polygon. One can create // more than one contour, but each contour must consist of at least 3 // vertices, i.e. move_to(x1, y1); line_to(x2, y2); line_to(x3, y3); // is the absolute minimum of vertices that define a triangle. // The algorithm does not check either the number of vertices nor // coincidence of their coordinates, but in the worst case it just // won't draw anything. // The orger of the vertices (clockwise or counterclockwise) // is important when using the non-zero filling rule (fill_non_zero). // In this case the vertex order of all the contours must be the same // if you want your intersecting polygons to be without "holes". // You actually can use different vertices order. If the contours do not // intersect each other the order is not important anyway. If they do, // contours with the same vertex order will be rendered without "holes" // while the intersecting contours with different orders will have "holes". // // filling_rule() and gamma() can be called anytime before "sweeping". //------------------------------------------------------------------------ template class rasterizer_scanline_aa { enum status { status_initial, status_move_to, status_line_to, status_closed }; public: typedef Clip clip_type; typedef typename Clip::conv_type conv_type; typedef typename Clip::coord_type coord_type; enum aa_scale_e { aa_shift = 8, aa_scale = 1 << aa_shift, aa_mask = aa_scale - 1, aa_scale2 = aa_scale * 2, aa_mask2 = aa_scale2 - 1 }; //-------------------------------------------------------------------- rasterizer_scanline_aa() : m_outline(), m_clipper(), m_filling_rule(fill_non_zero), m_auto_close(true), m_start_x(0), m_start_y(0), m_status(status_initial) { int i; for(i = 0; i < aa_scale; i++) m_gamma[i] = i; } //-------------------------------------------------------------------- template rasterizer_scanline_aa(const GammaF& gamma_function) : m_outline(), m_clipper(m_outline), m_filling_rule(fill_non_zero), m_auto_close(true), m_start_x(0), m_start_y(0), m_status(status_initial) { gamma(gamma_function); } //-------------------------------------------------------------------- void reset(); void reset_clipping(); void clip_box(double x1, double y1, double x2, double y2); void filling_rule(filling_rule_e filling_rule); void auto_close(bool flag) { m_auto_close = flag; } //-------------------------------------------------------------------- template void gamma(const GammaF& gamma_function) { int i; for(i = 0; i < aa_scale; i++) { m_gamma[i] = uround(gamma_function(double(i) / aa_mask) * aa_mask); } } //-------------------------------------------------------------------- unsigned apply_gamma(unsigned cover) const { return m_gamma[cover]; } //-------------------------------------------------------------------- void move_to(int x, int y); void line_to(int x, int y); void move_to_d(double x, double y); void line_to_d(double x, double y); void close_polygon(); void add_vertex(double x, double y, unsigned cmd); void edge(int x1, int y1, int x2, int y2); void edge_d(double x1, double y1, double x2, double y2); //------------------------------------------------------------------- template void add_path(VertexSource& vs, unsigned path_id=0) { double x; double y; unsigned cmd; vs.rewind(path_id); if(m_outline.sorted()) reset(); while(!is_stop(cmd = vs.vertex(&x, &y))) { add_vertex(x, y, cmd); } } //-------------------------------------------------------------------- int min_x() const { return m_outline.min_x(); } int min_y() const { return m_outline.min_y(); } int max_x() const { return m_outline.max_x(); } int max_y() const { return m_outline.max_y(); } //-------------------------------------------------------------------- void sort(); bool rewind_scanlines(); bool navigate_scanline(int y); //-------------------------------------------------------------------- AGG_INLINE unsigned calculate_alpha(int area) const { int cover = area >> (poly_subpixel_shift*2 + 1 - aa_shift); if(cover < 0) cover = -cover; if(m_filling_rule == fill_even_odd) { cover &= aa_mask2; if(cover > aa_scale) { cover = aa_scale2 - cover; } } if(cover > aa_mask) cover = aa_mask; return m_gamma[cover]; } //-------------------------------------------------------------------- template bool sweep_scanline(Scanline& sl) { for(;;) { if(m_scan_y > m_outline.max_y()) return false; sl.reset_spans(); unsigned num_cells = m_outline.scanline_num_cells(m_scan_y); const cell_aa* const* cells = m_outline.scanline_cells(m_scan_y); int cover = 0; while(num_cells) { const cell_aa* cur_cell = *cells; int x = cur_cell->x; int area = cur_cell->area; unsigned alpha; cover += cur_cell->cover; //accumulate all cells with the same X while(--num_cells) { cur_cell = *++cells; if(cur_cell->x != x) break; area += cur_cell->area; cover += cur_cell->cover; } if(area) { alpha = calculate_alpha((cover << (poly_subpixel_shift + 1)) - area); if(alpha) { sl.add_cell(x, alpha); } x++; } if(num_cells && cur_cell->x > x) { alpha = calculate_alpha(cover << (poly_subpixel_shift + 1)); if(alpha) { sl.add_span(x, cur_cell->x - x, alpha); } } } if(sl.num_spans()) break; ++m_scan_y; } sl.finalize(m_scan_y); ++m_scan_y; return true; } //-------------------------------------------------------------------- bool hit_test(int tx, int ty); private: //-------------------------------------------------------------------- // Disable copying rasterizer_scanline_aa(const rasterizer_scanline_aa&); const rasterizer_scanline_aa& operator = (const rasterizer_scanline_aa&); private: rasterizer_cells_aa m_outline; clip_type m_clipper; int m_gamma[aa_scale]; filling_rule_e m_filling_rule; bool m_auto_close; coord_type m_start_x; coord_type m_start_y; unsigned m_status; int m_scan_y; }; //------------------------------------------------------------------------ template void rasterizer_scanline_aa::reset() { m_outline.reset(); m_status = status_initial; } //------------------------------------------------------------------------ template void rasterizer_scanline_aa::filling_rule(filling_rule_e filling_rule) { m_filling_rule = filling_rule; } //------------------------------------------------------------------------ template void rasterizer_scanline_aa::clip_box(double x1, double y1, double x2, double y2) { reset(); m_clipper.clip_box(conv_type::upscale(x1), conv_type::upscale(y1), conv_type::upscale(x2), conv_type::upscale(y2)); } //------------------------------------------------------------------------ template void rasterizer_scanline_aa::reset_clipping() { reset(); m_clipper.reset_clipping(); } //------------------------------------------------------------------------ template void rasterizer_scanline_aa::close_polygon() { if(m_auto_close && m_status == status_line_to) { m_clipper.line_to(m_outline, m_start_x, m_start_y); m_status = status_closed; } } //------------------------------------------------------------------------ template void rasterizer_scanline_aa::move_to(int x, int y) { if(m_outline.sorted()) reset(); if(m_status == status_line_to) close_polygon(); m_clipper.move_to(m_start_x = conv_type::downscale(x), m_start_y = conv_type::downscale(y)); m_status = status_move_to; } //------------------------------------------------------------------------ template void rasterizer_scanline_aa::line_to(int x, int y) { m_clipper.line_to(m_outline, conv_type::downscale(x), conv_type::downscale(y)); m_status = status_line_to; } //------------------------------------------------------------------------ template void rasterizer_scanline_aa::move_to_d(double x, double y) { if(m_outline.sorted()) reset(); if(m_status == status_line_to) close_polygon(); m_clipper.move_to(m_start_x = conv_type::upscale(x), m_start_y = conv_type::upscale(y)); m_status = status_move_to; } //------------------------------------------------------------------------ template void rasterizer_scanline_aa::line_to_d(double x, double y) { m_clipper.line_to(m_outline, conv_type::upscale(x), conv_type::upscale(y)); m_status = status_line_to; } //------------------------------------------------------------------------ template void rasterizer_scanline_aa::add_vertex(double x, double y, unsigned cmd) { if(is_move_to(cmd)) { move_to_d(x, y); } else { if(is_vertex(cmd)) { line_to_d(x, y); } } } //------------------------------------------------------------------------ template void rasterizer_scanline_aa::edge(int x1, int y1, int x2, int y2) { if(m_outline.sorted()) reset(); m_clipper.move_to(conv_type::downscale(x1), conv_type::downscale(y1)); m_clipper.line_to(m_outline, conv_type::downscale(x2), conv_type::downscale(y2)); m_status = status_move_to; } //------------------------------------------------------------------------ template void rasterizer_scanline_aa::edge_d(double x1, double y1, double x2, double y2) { if(m_outline.sorted()) reset(); m_clipper.move_to(conv_type::upscale(x1), conv_type::upscale(y1)); m_clipper.line_to(m_outline, conv_type::upscale(x2), conv_type::upscale(y2)); m_status = status_move_to; } //------------------------------------------------------------------------ template void rasterizer_scanline_aa::sort() { m_outline.sort_cells(); } //------------------------------------------------------------------------ template AGG_INLINE bool rasterizer_scanline_aa::rewind_scanlines() { close_polygon(); m_outline.sort_cells(); if(m_outline.total_cells() == 0) { return false; } m_scan_y = m_outline.min_y(); return true; } //------------------------------------------------------------------------ template AGG_INLINE bool rasterizer_scanline_aa::navigate_scanline(int y) { close_polygon(); m_outline.sort_cells(); if(m_outline.total_cells() == 0 || y < m_outline.min_y() || y > m_outline.max_y()) { return false; } m_scan_y = y; return true; } //------------------------------------------------------------------------ template bool rasterizer_scanline_aa::hit_test(int tx, int ty) { if(!navigate_scanline(ty)) return false; scanline_hit_test sl(tx); sweep_scanline(sl); return sl.hit(); } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_config.h0000644000175000017500000000126112516137326023230 0ustar varunvarun#ifndef AGG_CONFIG_INCLUDED #define AGG_CONFIG_INCLUDED // This file can be used to redefine the default basic types such as: // // AGG_INT8 // AGG_INT8U // AGG_INT16 // AGG_INT16U // AGG_INT32 // AGG_INT32U // AGG_INT64 // AGG_INT64U // // Just replace this file with new defines if necessary. // For example, if your compiler doesn't have a 64 bit integer type // you can still use AGG if you define the follows: // // #define AGG_INT64 int // #define AGG_INT64U unsigned // // It will result in overflow in 16 bit-per-component image/pattern resampling // but it won't result any crash and the rest of the library will remain // fully functional. #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_image_accessors.h0000644000175000017500000003243412516137326025120 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #ifndef AGG_IMAGE_ACCESSORS_INCLUDED #define AGG_IMAGE_ACCESSORS_INCLUDED #include "agg_basics.h" namespace agg24 { //-----------------------------------------------------image_accessor_clip template class image_accessor_clip { public: typedef PixFmt pixfmt_type; typedef typename pixfmt_type::color_type color_type; typedef typename pixfmt_type::order_type order_type; typedef typename pixfmt_type::value_type value_type; enum pix_width_e { pix_width = pixfmt_type::pix_width }; image_accessor_clip() {} image_accessor_clip(const pixfmt_type& pixf, const color_type& bk) : m_pixf(&pixf) { pixfmt_type::make_pix(m_bk_buf, bk); } void attach(const pixfmt_type& pixf) { m_pixf = &pixf; } void background_color(const color_type& bk) { pixfmt_type::make_pix(m_bk_buf, bk); } private: AGG_INLINE const int8u* pixel() const { if(m_y >= 0 && m_y < (int)m_pixf->height() && m_x >= 0 && m_x < (int)m_pixf->width()) { return m_pixf->pix_ptr(m_x, m_y); } return m_bk_buf; } public: AGG_INLINE const int8u* span(int x, int y, unsigned len) { m_x = m_x0 = x; m_y = y; // comparison between signed and unsigned if(y >= 0 && y < (int)m_pixf->height() && x >= 0 && (int)(x+len) <= (int)m_pixf->width()) { return m_pix_ptr = m_pixf->pix_ptr(x, y); } m_pix_ptr = 0; return pixel(); } AGG_INLINE const int8u* next_x() { if(m_pix_ptr) return m_pix_ptr += pix_width; ++m_x; return pixel(); } AGG_INLINE const int8u* next_y() { ++m_y; m_x = m_x0; if(m_pix_ptr && m_y >= 0 && m_y < (int)m_pixf->height()) { return m_pix_ptr = m_pixf->pix_ptr(m_x, m_y); } m_pix_ptr = 0; return pixel(); } private: const pixfmt_type* m_pixf; int8u m_bk_buf[4]; int m_x, m_x0, m_y; const int8u* m_pix_ptr; }; //--------------------------------------------------image_accessor_no_clip template class image_accessor_no_clip { public: typedef PixFmt pixfmt_type; typedef typename pixfmt_type::color_type color_type; typedef typename pixfmt_type::order_type order_type; typedef typename pixfmt_type::value_type value_type; enum pix_width_e { pix_width = pixfmt_type::pix_width }; image_accessor_no_clip() {} image_accessor_no_clip(const pixfmt_type& pixf) : m_pixf(&pixf) {} void attach(const pixfmt_type& pixf) { m_pixf = &pixf; } AGG_INLINE const int8u* span(int x, int y, unsigned) { m_x = x; m_y = y; return m_pix_ptr = m_pixf->pix_ptr(x, y); } AGG_INLINE const int8u* next_x() { return m_pix_ptr += pix_width; } AGG_INLINE const int8u* next_y() { ++m_y; return m_pix_ptr = m_pixf->pix_ptr(m_x, m_y); } private: const pixfmt_type* m_pixf; int m_x, m_y; const int8u* m_pix_ptr; }; //----------------------------------------------------image_accessor_clone template class image_accessor_clone { public: typedef PixFmt pixfmt_type; typedef typename pixfmt_type::color_type color_type; typedef typename pixfmt_type::order_type order_type; typedef typename pixfmt_type::value_type value_type; enum pix_width_e { pix_width = pixfmt_type::pix_width }; image_accessor_clone() {} image_accessor_clone(const pixfmt_type& pixf) : m_pixf(&pixf) {} void attach(const pixfmt_type& pixf) { m_pixf = &pixf; } private: AGG_INLINE const int8u* pixel() const { register int x = m_x; register int y = m_y; if(x < 0) x = 0; if(y < 0) y = 0; if(x >= (int)m_pixf->width()) x = m_pixf->width() - 1; if(y >= (int)m_pixf->height()) y = m_pixf->height() - 1; return m_pixf->pix_ptr(x, y); } public: AGG_INLINE const int8u* span(int x, int y, unsigned len) { m_x = m_x0 = x; m_y = y; if(y >= 0 && y < (int)m_pixf->height() && x >= 0 && x+len <= (int)m_pixf->width()) { return m_pix_ptr = m_pixf->pix_ptr(x, y); } m_pix_ptr = 0; return pixel(); } AGG_INLINE const int8u* next_x() { if(m_pix_ptr) return m_pix_ptr += pix_width; ++m_x; return pixel(); } AGG_INLINE const int8u* next_y() { ++m_y; m_x = m_x0; if(m_pix_ptr && m_y >= 0 && m_y < (int)m_pixf->height()) { return m_pix_ptr = m_pixf->pix_ptr(m_x, m_y); } m_pix_ptr = 0; return pixel(); } private: const pixfmt_type* m_pixf; int m_x, m_x0, m_y; const int8u* m_pix_ptr; }; //-----------------------------------------------------image_accessor_wrap template class image_accessor_wrap { public: typedef PixFmt pixfmt_type; typedef typename pixfmt_type::color_type color_type; typedef typename pixfmt_type::order_type order_type; typedef typename pixfmt_type::value_type value_type; enum pix_width_e { pix_width = pixfmt_type::pix_width }; image_accessor_wrap() {} image_accessor_wrap(const pixfmt_type& pixf) : m_pixf(&pixf), m_wrap_x(pixf.width()), m_wrap_y(pixf.height()) {} void attach(const pixfmt_type& pixf) { m_pixf = &pixf; } AGG_INLINE const int8u* span(int x, int y, unsigned) { m_x = x; m_row_ptr = m_pixf->row_ptr(m_wrap_y(y)); return m_row_ptr + m_wrap_x(x) * pix_width; } AGG_INLINE const int8u* next_x() { int x = ++m_wrap_x; return m_row_ptr + x * pix_width; } AGG_INLINE const int8u* next_y() { m_row_ptr = m_pixf->row_ptr(++m_wrap_y); return m_row_ptr + m_wrap_x(m_x) * pix_width; } private: const pixfmt_type* m_pixf; const int8u* m_row_ptr; int m_x; WrapX m_wrap_x; WrapY m_wrap_y; }; //--------------------------------------------------------wrap_mode_repeat class wrap_mode_repeat { public: wrap_mode_repeat() {} wrap_mode_repeat(unsigned size) : m_size(size), m_add(size * (0x3FFFFFFF / size)), m_value(0) {} AGG_INLINE unsigned operator() (int v) { return m_value = (unsigned(v) + m_add) % m_size; } AGG_INLINE unsigned operator++ () { ++m_value; if(m_value >= m_size) m_value = 0; return m_value; } private: unsigned m_size; unsigned m_add; unsigned m_value; }; //---------------------------------------------------wrap_mode_repeat_pow2 class wrap_mode_repeat_pow2 { public: wrap_mode_repeat_pow2() {} wrap_mode_repeat_pow2(unsigned size) : m_value(0) { m_mask = 1; while(m_mask < size) m_mask = (m_mask << 1) | 1; m_mask >>= 1; } AGG_INLINE unsigned operator() (int v) { return m_value = unsigned(v) & m_mask; } AGG_INLINE unsigned operator++ () { ++m_value; if(m_value > m_mask) m_value = 0; return m_value; } private: unsigned m_mask; unsigned m_value; }; //----------------------------------------------wrap_mode_repeat_auto_pow2 class wrap_mode_repeat_auto_pow2 { public: wrap_mode_repeat_auto_pow2() {} wrap_mode_repeat_auto_pow2(unsigned size) : m_size(size), m_add(size * (0x3FFFFFFF / size)), m_mask((m_size & (m_size-1)) ? 0 : m_size-1), m_value(0) {} AGG_INLINE unsigned operator() (int v) { if(m_mask) return m_value = unsigned(v) & m_mask; return m_value = (unsigned(v) + m_add) % m_size; } AGG_INLINE unsigned operator++ () { ++m_value; if(m_value >= m_size) m_value = 0; return m_value; } private: unsigned m_size; unsigned m_add; unsigned m_mask; unsigned m_value; }; //-------------------------------------------------------wrap_mode_reflect class wrap_mode_reflect { public: wrap_mode_reflect() {} wrap_mode_reflect(unsigned size) : m_size(size), m_size2(size * 2), m_add(m_size2 * (0x3FFFFFFF / m_size2)), m_value(0) {} AGG_INLINE unsigned operator() (int v) { m_value = (unsigned(v) + m_add) % m_size2; if(m_value >= m_size) return m_size2 - m_value - 1; return m_value; } AGG_INLINE unsigned operator++ () { ++m_value; if(m_value >= m_size2) m_value = 0; if(m_value >= m_size) return m_size2 - m_value - 1; return m_value; } private: unsigned m_size; unsigned m_size2; unsigned m_add; unsigned m_value; }; //--------------------------------------------------wrap_mode_reflect_pow2 class wrap_mode_reflect_pow2 { public: wrap_mode_reflect_pow2() {} wrap_mode_reflect_pow2(unsigned size) : m_value(0) { m_mask = 1; m_size = 1; while(m_mask < size) { m_mask = (m_mask << 1) | 1; m_size <<= 1; } } AGG_INLINE unsigned operator() (int v) { m_value = unsigned(v) & m_mask; if(m_value >= m_size) return m_mask - m_value; return m_value; } AGG_INLINE unsigned operator++ () { ++m_value; m_value &= m_mask; if(m_value >= m_size) return m_mask - m_value; return m_value; } private: unsigned m_size; unsigned m_mask; unsigned m_value; }; //---------------------------------------------wrap_mode_reflect_auto_pow2 class wrap_mode_reflect_auto_pow2 { public: wrap_mode_reflect_auto_pow2() {} wrap_mode_reflect_auto_pow2(unsigned size) : m_size(size), m_size2(size * 2), m_add(m_size2 * (0x3FFFFFFF / m_size2)), m_mask((m_size2 & (m_size2-1)) ? 0 : m_size2-1), m_value(0) {} AGG_INLINE unsigned operator() (int v) { m_value = m_mask ? unsigned(v) & m_mask : (unsigned(v) + m_add) % m_size2; if(m_value >= m_size) return m_size2 - m_value - 1; return m_value; } AGG_INLINE unsigned operator++ () { ++m_value; if(m_value >= m_size2) m_value = 0; if(m_value >= m_size) return m_size2 - m_value - 1; return m_value; } private: unsigned m_size; unsigned m_size2; unsigned m_add; unsigned m_mask; unsigned m_value; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_conv_stroke.h0000644000175000017500000000622712516137326024326 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // conv_stroke // //---------------------------------------------------------------------------- #ifndef AGG_CONV_STROKE_INCLUDED #define AGG_CONV_STROKE_INCLUDED #include "agg_basics.h" #include "agg_vcgen_stroke.h" #include "agg_conv_adaptor_vcgen.h" namespace agg24 { //-------------------------------------------------------------conv_stroke template struct conv_stroke : public conv_adaptor_vcgen { typedef Markers marker_type; typedef conv_adaptor_vcgen base_type; conv_stroke(VertexSource& vs) : conv_adaptor_vcgen(vs) { } void line_cap(line_cap_e lc) { base_type::generator().line_cap(lc); } void line_join(line_join_e lj) { base_type::generator().line_join(lj); } void inner_join(inner_join_e ij) { base_type::generator().inner_join(ij); } line_cap_e line_cap() const { return base_type::generator().line_cap(); } line_join_e line_join() const { return base_type::generator().line_join(); } inner_join_e inner_join() const { return base_type::generator().inner_join(); } void width(double w) { base_type::generator().width(w); } void miter_limit(double ml) { base_type::generator().miter_limit(ml); } void miter_limit_theta(double t) { base_type::generator().miter_limit_theta(t); } void inner_miter_limit(double ml) { base_type::generator().inner_miter_limit(ml); } void approximation_scale(double as) { base_type::generator().approximation_scale(as); } double width() const { return base_type::generator().width(); } double miter_limit() const { return base_type::generator().miter_limit(); } double inner_miter_limit() const { return base_type::generator().inner_miter_limit(); } double approximation_scale() const { return base_type::generator().approximation_scale(); } void shorten(double s) { base_type::generator().shorten(s); } double shorten() const { return base_type::generator().shorten(); } private: conv_stroke(const conv_stroke&); const conv_stroke& operator = (const conv_stroke&); }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/include/agg_arrowhead.h0000644000175000017500000000454512516137326023747 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Simple arrowhead/arrowtail generator // //---------------------------------------------------------------------------- #ifndef AGG_ARROWHEAD_INCLUDED #define AGG_ARROWHEAD_INCLUDED #include "agg_basics.h" namespace agg24 { //===============================================================arrowhead // // See implementation agg_arrowhead.cpp // class arrowhead { public: arrowhead(); void head(double d1, double d2, double d3, double d4) { m_head_d1 = d1; m_head_d2 = d2; m_head_d3 = d3; m_head_d4 = d4; m_head_flag = true; } void head() { m_head_flag = true; } void no_head() { m_head_flag = false; } void tail(double d1, double d2, double d3, double d4) { m_tail_d1 = d1; m_tail_d2 = d2; m_tail_d3 = d3; m_tail_d4 = d4; m_tail_flag = true; } void tail() { m_tail_flag = true; } void no_tail() { m_tail_flag = false; } void rewind(unsigned path_id); unsigned vertex(double* x, double* y); private: double m_head_d1; double m_head_d2; double m_head_d3; double m_head_d4; double m_tail_d1; double m_tail_d2; double m_tail_d3; double m_tail_d4; bool m_head_flag; bool m_tail_flag; double m_coord[16]; unsigned m_cmd[8]; unsigned m_curr_id; unsigned m_curr_coord; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/Makefile.in.CYGWIN_NT-5.00000644000175000017500000000021112516137326023310 0ustar varunvarunAGGLIBS= -lagg AGGCXXFLAGS = -O3 -I/usr/X11R6/include -L/usr/X11R6/lib CXX = g++ C = gcc #CXX = icc LIB = ar cr .PHONY : clean enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/Makefile.in.BeOS0000644000175000017500000000013012516137326022177 0ustar varunvarunAGGLIBS= -lagg AGGCXXFLAGS = -O1 CXX = g++ C = cc LIB = ar -cru .PHONY : clean enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/font_freetype/0000755000175000017500000000000012516137725022225 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/font_freetype/agg_font_freetype.h0000644000175000017500000002053712516137326026071 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // See implementation agg_font_freetype.cpp // //---------------------------------------------------------------------------- #ifndef AGG_FONT_FREETYPE_INCLUDED #define AGG_FONT_FREETYPE_INCLUDED #include #include FT_FREETYPE_H #include "agg_scanline_storage_aa.h" #include "agg_scanline_storage_bin.h" #include "agg_scanline_u.h" #include "agg_scanline_bin.h" #include "agg_path_storage_integer.h" #include "agg_rasterizer_scanline_aa.h" #include "agg_conv_curve.h" #include "agg_font_cache_manager.h" #include "agg_trans_affine.h" namespace agg24 { //-----------------------------------------------font_engine_freetype_base class font_engine_freetype_base { public: //-------------------------------------------------------------------- typedef serialized_scanlines_adaptor_aa gray8_adaptor_type; typedef serialized_scanlines_adaptor_bin mono_adaptor_type; typedef scanline_storage_aa8 scanlines_aa_type; typedef scanline_storage_bin scanlines_bin_type; //-------------------------------------------------------------------- ~font_engine_freetype_base(); font_engine_freetype_base(bool flag32, unsigned max_faces = 32); // Set font parameters //-------------------------------------------------------------------- void resolution(unsigned dpi); bool load_font(const char* font_name, unsigned face_index, glyph_rendering ren_type, const char* font_mem = 0, const long font_mem_size = 0); bool attach(const char* file_name); bool char_map(FT_Encoding map); bool height(double h); bool width(double w); void hinting(bool h); void flip_y(bool f); void transform(const trans_affine& affine); // Set Gamma //-------------------------------------------------------------------- template void gamma(const GammaF& f) { m_rasterizer.gamma(f); } // Accessors //-------------------------------------------------------------------- int last_error() const { return m_last_error; } unsigned resolution() const { return m_resolution; } const char* name() const { return m_name; } unsigned num_faces() const; FT_Encoding char_map() const { return m_char_map; } double height() const { return double(m_height) / 64.0; } double width() const { return double(m_width) / 64.0; } double ascender() const; double descender() const; bool hinting() const { return m_hinting; } bool flip_y() const { return m_flip_y; } // Interface mandatory to implement for font_cache_manager //-------------------------------------------------------------------- const char* font_signature() const { return m_signature; } int change_stamp() const { return m_change_stamp; } bool prepare_glyph(unsigned glyph_code); unsigned glyph_index() const { return m_glyph_index; } unsigned data_size() const { return m_data_size; } glyph_data_type data_type() const { return m_data_type; } const rect_i& bounds() const { return m_bounds; } double advance_x() const { return m_advance_x; } double advance_y() const { return m_advance_y; } void write_glyph_to(int8u* data) const; bool add_kerning(unsigned first, unsigned second, double* x, double* y); private: font_engine_freetype_base(const font_engine_freetype_base&); const font_engine_freetype_base& operator = (const font_engine_freetype_base&); void update_char_size(); void update_signature(); int find_face(const char* face_name) const; bool m_flag32; int m_change_stamp; int m_last_error; char* m_name; unsigned m_name_len; unsigned m_face_index; FT_Encoding m_char_map; char* m_signature; unsigned m_height; unsigned m_width; bool m_hinting; bool m_flip_y; bool m_library_initialized; FT_Library m_library; // handle to library FT_Face* m_faces; // A pool of font faces char** m_face_names; unsigned m_num_faces; unsigned m_max_faces; FT_Face m_cur_face; // handle to the current face object int m_resolution; glyph_rendering m_glyph_rendering; unsigned m_glyph_index; unsigned m_data_size; glyph_data_type m_data_type; rect_i m_bounds; double m_advance_x; double m_advance_y; trans_affine m_affine; path_storage_integer m_path16; path_storage_integer m_path32; conv_curve > m_curves16; conv_curve > m_curves32; scanline_u8 m_scanline_aa; scanline_bin m_scanline_bin; scanlines_aa_type m_scanlines_aa; scanlines_bin_type m_scanlines_bin; rasterizer_scanline_aa<> m_rasterizer; }; //------------------------------------------------font_engine_freetype_int16 // This class uses values of type int16 (10.6 format) for the vector cache. // The vector cache is compact, but when rendering glyphs of height // more that 200 there integer overflow can occur. // class font_engine_freetype_int16 : public font_engine_freetype_base { public: typedef serialized_integer_path_adaptor path_adaptor_type; typedef font_engine_freetype_base::gray8_adaptor_type gray8_adaptor_type; typedef font_engine_freetype_base::mono_adaptor_type mono_adaptor_type; typedef font_engine_freetype_base::scanlines_aa_type scanlines_aa_type; typedef font_engine_freetype_base::scanlines_bin_type scanlines_bin_type; font_engine_freetype_int16(unsigned max_faces = 32) : font_engine_freetype_base(false, max_faces) {} }; //------------------------------------------------font_engine_freetype_int32 // This class uses values of type int32 (26.6 format) for the vector cache. // The vector cache is twice larger than in font_engine_freetype_int16, // but it allows you to render glyphs of very large sizes. // class font_engine_freetype_int32 : public font_engine_freetype_base { public: typedef serialized_integer_path_adaptor path_adaptor_type; typedef font_engine_freetype_base::gray8_adaptor_type gray8_adaptor_type; typedef font_engine_freetype_base::mono_adaptor_type mono_adaptor_type; typedef font_engine_freetype_base::scanlines_aa_type scanlines_aa_type; typedef font_engine_freetype_base::scanlines_bin_type scanlines_bin_type; font_engine_freetype_int32(unsigned max_faces = 32) : font_engine_freetype_base(true, max_faces) {} }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/font_freetype/Makefile.am0000644000175000017500000000055012516137326024256 0ustar varunvarun if ENABLE_FT aggincludedir = $(includedir)/agg2 agginclude_HEADERS = agg_font_freetype.h lib_LTLIBRARIES = libaggfontfreetype.la libaggfontfreetype_la_LDFLAGS = -version-info @AGG_LIB_VERSION@ @FREETYPE_LIBS@ libaggfontfreetype_la_SOURCES = agg_font_freetype.cpp libaggfontfreetype_la_CXXFLAGS = -I$(top_srcdir)/include @FREETYPE_CFLAGS@ endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/font_freetype/agg_font_freetype.cpp0000644000175000017500000012632212516137326026423 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #include #include "agg_font_freetype.h" #include "agg_bitset_iterator.h" #include "agg_renderer_scanline.h" namespace agg24 { //------------------------------------------------------------------------------ // // This code implements the AUTODIN II polynomial // The variable corresponding to the macro argument "crc" should // be an unsigned long. // Oroginal code by Spencer Garrett // // generated using the AUTODIN II polynomial // x^32 + x^26 + x^23 + x^22 + x^16 + // x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + 1 // //------------------------------------------------------------------------------ static const unsigned crc32tab[256] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d, }; //------------------------------------------------------------------------------ static unsigned calc_crc32(const unsigned char* buf, unsigned size) { unsigned crc = (unsigned)~0; const unsigned char* p; unsigned len = 0; unsigned nr = size; for (len += nr, p = buf; nr--; ++p) { crc = (crc >> 8) ^ crc32tab[(crc ^ *p) & 0xff]; } return ~crc; } //------------------------------------------------------------------------ static inline int dbl_to_plain_fx(double d) { return int(d * 65536.0); } //------------------------------------------------------------------------ static inline double int26p6_to_dbl(int p) { return double(p) / 64.0; } //------------------------------------------------------------------------ static inline int dbl_to_int26p6(double p) { return int(p * 64.0 + 0.5); } //------------------------------------------------------------------------ template bool decompose_ft_outline(const FT_Outline& outline, bool flip_y, const trans_affine& mtx, PathStorage& path) { typedef typename PathStorage::value_type value_type; FT_Vector v_last; FT_Vector v_control; FT_Vector v_start; double x1, y1, x2, y2, x3, y3; FT_Vector* point; FT_Vector* limit; char* tags; int n; // index of contour in outline int first; // index of first point in contour char tag; // current point's state first = 0; for(n = 0; n < outline.n_contours; n++) { int last; // index of last point in contour last = outline.contours[n]; limit = outline.points + last; v_start = outline.points[first]; v_last = outline.points[last]; v_control = v_start; point = outline.points + first; tags = outline.tags + first; tag = FT_CURVE_TAG(tags[0]); // A contour cannot start with a cubic control point! if(tag == FT_CURVE_TAG_CUBIC) return false; // check first point to determine origin if( tag == FT_CURVE_TAG_CONIC) { // first point is conic control. Yes, this happens. if(FT_CURVE_TAG(outline.tags[last]) == FT_CURVE_TAG_ON) { // start at last point if it is on the curve v_start = v_last; limit--; } else { // if both first and last points are conic, // start at their middle and record its position // for closure v_start.x = (v_start.x + v_last.x) / 2; v_start.y = (v_start.y + v_last.y) / 2; v_last = v_start; } point--; tags--; } x1 = int26p6_to_dbl(v_start.x); y1 = int26p6_to_dbl(v_start.y); if(flip_y) y1 = -y1; mtx.transform(&x1, &y1); path.move_to(value_type(dbl_to_int26p6(x1)), value_type(dbl_to_int26p6(y1))); while(point < limit) { point++; tags++; tag = FT_CURVE_TAG(tags[0]); switch(tag) { case FT_CURVE_TAG_ON: // emit a single line_to { x1 = int26p6_to_dbl(point->x); y1 = int26p6_to_dbl(point->y); if(flip_y) y1 = -y1; mtx.transform(&x1, &y1); path.line_to(value_type(dbl_to_int26p6(x1)), value_type(dbl_to_int26p6(y1))); //path.line_to(conv(point->x), flip_y ? -conv(point->y) : conv(point->y)); continue; } case FT_CURVE_TAG_CONIC: // consume conic arcs { v_control.x = point->x; v_control.y = point->y; Do_Conic: if(point < limit) { FT_Vector vec; FT_Vector v_middle; point++; tags++; tag = FT_CURVE_TAG(tags[0]); vec.x = point->x; vec.y = point->y; if(tag == FT_CURVE_TAG_ON) { x1 = int26p6_to_dbl(v_control.x); y1 = int26p6_to_dbl(v_control.y); x2 = int26p6_to_dbl(vec.x); y2 = int26p6_to_dbl(vec.y); if(flip_y) { y1 = -y1; y2 = -y2; } mtx.transform(&x1, &y1); mtx.transform(&x2, &y2); path.curve3(value_type(dbl_to_int26p6(x1)), value_type(dbl_to_int26p6(y1)), value_type(dbl_to_int26p6(x2)), value_type(dbl_to_int26p6(y2))); continue; } if(tag != FT_CURVE_TAG_CONIC) return false; v_middle.x = (v_control.x + vec.x) / 2; v_middle.y = (v_control.y + vec.y) / 2; x1 = int26p6_to_dbl(v_control.x); y1 = int26p6_to_dbl(v_control.y); x2 = int26p6_to_dbl(v_middle.x); y2 = int26p6_to_dbl(v_middle.y); if(flip_y) { y1 = -y1; y2 = -y2; } mtx.transform(&x1, &y1); mtx.transform(&x2, &y2); path.curve3(value_type(dbl_to_int26p6(x1)), value_type(dbl_to_int26p6(y1)), value_type(dbl_to_int26p6(x2)), value_type(dbl_to_int26p6(y2))); //path.curve3(conv(v_control.x), // flip_y ? -conv(v_control.y) : conv(v_control.y), // conv(v_middle.x), // flip_y ? -conv(v_middle.y) : conv(v_middle.y)); v_control = vec; goto Do_Conic; } x1 = int26p6_to_dbl(v_control.x); y1 = int26p6_to_dbl(v_control.y); x2 = int26p6_to_dbl(v_start.x); y2 = int26p6_to_dbl(v_start.y); if(flip_y) { y1 = -y1; y2 = -y2; } mtx.transform(&x1, &y1); mtx.transform(&x2, &y2); path.curve3(value_type(dbl_to_int26p6(x1)), value_type(dbl_to_int26p6(y1)), value_type(dbl_to_int26p6(x2)), value_type(dbl_to_int26p6(y2))); //path.curve3(conv(v_control.x), // flip_y ? -conv(v_control.y) : conv(v_control.y), // conv(v_start.x), // flip_y ? -conv(v_start.y) : conv(v_start.y)); goto Close; } default: // FT_CURVE_TAG_CUBIC { FT_Vector vec1, vec2; if(point + 1 > limit || FT_CURVE_TAG(tags[1]) != FT_CURVE_TAG_CUBIC) { return false; } vec1.x = point[0].x; vec1.y = point[0].y; vec2.x = point[1].x; vec2.y = point[1].y; point += 2; tags += 2; if(point <= limit) { FT_Vector vec; vec.x = point->x; vec.y = point->y; x1 = int26p6_to_dbl(vec1.x); y1 = int26p6_to_dbl(vec1.y); x2 = int26p6_to_dbl(vec2.x); y2 = int26p6_to_dbl(vec2.y); x3 = int26p6_to_dbl(vec.x); y3 = int26p6_to_dbl(vec.y); if(flip_y) { y1 = -y1; y2 = -y2; y3 = -y3; } mtx.transform(&x1, &y1); mtx.transform(&x2, &y2); mtx.transform(&x3, &y3); path.curve4(value_type(dbl_to_int26p6(x1)), value_type(dbl_to_int26p6(y1)), value_type(dbl_to_int26p6(x2)), value_type(dbl_to_int26p6(y2)), value_type(dbl_to_int26p6(x3)), value_type(dbl_to_int26p6(y3))); //path.curve4(conv(vec1.x), // flip_y ? -conv(vec1.y) : conv(vec1.y), // conv(vec2.x), // flip_y ? -conv(vec2.y) : conv(vec2.y), // conv(vec.x), // flip_y ? -conv(vec.y) : conv(vec.y)); continue; } x1 = int26p6_to_dbl(vec1.x); y1 = int26p6_to_dbl(vec1.y); x2 = int26p6_to_dbl(vec2.x); y2 = int26p6_to_dbl(vec2.y); x3 = int26p6_to_dbl(v_start.x); y3 = int26p6_to_dbl(v_start.y); if(flip_y) { y1 = -y1; y2 = -y2; y3 = -y3; } mtx.transform(&x1, &y1); mtx.transform(&x2, &y2); mtx.transform(&x3, &y3); path.curve4(value_type(dbl_to_int26p6(x1)), value_type(dbl_to_int26p6(y1)), value_type(dbl_to_int26p6(x2)), value_type(dbl_to_int26p6(y2)), value_type(dbl_to_int26p6(x3)), value_type(dbl_to_int26p6(y3))); //path.curve4(conv(vec1.x), // flip_y ? -conv(vec1.y) : conv(vec1.y), // conv(vec2.x), // flip_y ? -conv(vec2.y) : conv(vec2.y), // conv(v_start.x), // flip_y ? -conv(v_start.y) : conv(v_start.y)); goto Close; } } } path.close_polygon(); Close: first = last + 1; } return true; } //------------------------------------------------------------------------ template void decompose_ft_bitmap_mono(const FT_Bitmap& bitmap, int x, int y, bool flip_y, Scanline& sl, ScanlineStorage& storage) { int i; const int8u* buf = (const int8u*)bitmap.buffer; int pitch = bitmap.pitch; sl.reset(x, x + bitmap.width); storage.prepare(); if(flip_y) { buf += bitmap.pitch * (bitmap.rows - 1); y += bitmap.rows; pitch = -pitch; } for(i = 0; i < bitmap.rows; i++) { sl.reset_spans(); bitset_iterator bits(buf, 0); int j; for(j = 0; j < bitmap.width; j++) { if(bits.bit()) sl.add_cell(x + j, cover_full); ++bits; } buf += pitch; if(sl.num_spans()) { sl.finalize(y - i - 1); storage.render(sl); } } } //------------------------------------------------------------------------ template void decompose_ft_bitmap_gray8(const FT_Bitmap& bitmap, int x, int y, bool flip_y, Rasterizer& ras, Scanline& sl, ScanlineStorage& storage) { int i, j; const int8u* buf = (const int8u*)bitmap.buffer; int pitch = bitmap.pitch; sl.reset(x, x + bitmap.width); storage.prepare(); if(flip_y) { buf += bitmap.pitch * (bitmap.rows - 1); y += bitmap.rows; pitch = -pitch; } for(i = 0; i < bitmap.rows; i++) { sl.reset_spans(); const int8u* p = buf; for(j = 0; j < bitmap.width; j++) { if(*p) sl.add_cell(x + j, ras.apply_gamma(*p)); ++p; } buf += pitch; if(sl.num_spans()) { sl.finalize(y - i - 1); storage.render(sl); } } } //------------------------------------------------------------------------ font_engine_freetype_base::~font_engine_freetype_base() { unsigned i; for(i = 0; i < m_num_faces; ++i) { delete [] m_face_names[i]; FT_Done_Face(m_faces[i]); } delete [] m_face_names; delete [] m_faces; delete [] m_signature; if(m_library_initialized) FT_Done_FreeType(m_library); } //------------------------------------------------------------------------ font_engine_freetype_base::font_engine_freetype_base(bool flag32, unsigned max_faces) : m_flag32(flag32), m_change_stamp(0), m_last_error(0), m_name(0), m_name_len(256-16-1), m_face_index(0), m_char_map(FT_ENCODING_NONE), m_signature(new char [256+256-16]), m_height(0), m_width(0), m_hinting(true), m_flip_y(false), m_library_initialized(false), m_library(0), m_faces(new FT_Face [max_faces]), m_face_names(new char* [max_faces]), m_num_faces(0), m_max_faces(max_faces), m_cur_face(0), m_resolution(0), m_glyph_rendering(glyph_ren_native_gray8), m_glyph_index(0), m_data_size(0), m_data_type(glyph_data_invalid), m_bounds(1,1,0,0), m_advance_x(0.0), m_advance_y(0.0), m_path16(), m_path32(), m_curves16(m_path16), m_curves32(m_path32), m_scanline_aa(), m_scanline_bin(), m_scanlines_aa(), m_scanlines_bin(), m_rasterizer() { m_curves16.approximation_scale(4.0); m_curves32.approximation_scale(4.0); m_last_error = FT_Init_FreeType(&m_library); if(m_last_error == 0) m_library_initialized = true; } //------------------------------------------------------------------------ void font_engine_freetype_base::resolution(unsigned dpi) { m_resolution = dpi; update_char_size(); } //------------------------------------------------------------------------ int font_engine_freetype_base::find_face(const char* face_name) const { unsigned i; for(i = 0; i < m_num_faces; ++i) { if(strcmp(face_name, m_face_names[i]) == 0) return i; } return -1; } //------------------------------------------------------------------------ double font_engine_freetype_base::ascender() const { if(m_cur_face) { return m_cur_face->ascender * height() / m_cur_face->height; } return 0.0; } //------------------------------------------------------------------------ double font_engine_freetype_base::descender() const { if(m_cur_face) { return m_cur_face->descender * height() / m_cur_face->height; } return 0.0; } //------------------------------------------------------------------------ bool font_engine_freetype_base::load_font(const char* font_name, unsigned face_index, glyph_rendering ren_type, const char* font_mem, const long font_mem_size) { bool ret = false; if(m_library_initialized) { m_last_error = 0; int idx = find_face(font_name); if(idx >= 0) { m_cur_face = m_faces[idx]; m_name = m_face_names[idx]; } else { if(m_num_faces >= m_max_faces) { delete [] m_face_names[0]; FT_Done_Face(m_faces[0]); memcpy(m_faces, m_faces + 1, (m_max_faces - 1) * sizeof(FT_Face)); memcpy(m_face_names, m_face_names + 1, (m_max_faces - 1) * sizeof(char*)); m_num_faces = m_max_faces - 1; } if (font_mem && font_mem_size) { m_last_error = FT_New_Memory_Face(m_library, (const FT_Byte*)font_mem, font_mem_size, face_index, &m_faces[m_num_faces]); } else { m_last_error = FT_New_Face(m_library, font_name, face_index, &m_faces[m_num_faces]); } if(m_last_error == 0) { m_face_names[m_num_faces] = new char [strlen(font_name) + 1]; strcpy(m_face_names[m_num_faces], font_name); m_cur_face = m_faces[m_num_faces]; m_name = m_face_names[m_num_faces]; ++m_num_faces; } else { m_face_names[m_num_faces] = 0; m_cur_face = 0; m_name = 0; } } if(m_last_error == 0) { ret = true; switch(ren_type) { case glyph_ren_native_mono: m_glyph_rendering = glyph_ren_native_mono; break; case glyph_ren_native_gray8: m_glyph_rendering = glyph_ren_native_gray8; break; case glyph_ren_outline: if(FT_IS_SCALABLE(m_cur_face)) { m_glyph_rendering = glyph_ren_outline; } else { m_glyph_rendering = glyph_ren_native_gray8; } break; case glyph_ren_agg_mono: if(FT_IS_SCALABLE(m_cur_face)) { m_glyph_rendering = glyph_ren_agg_mono; } else { m_glyph_rendering = glyph_ren_native_mono; } break; case glyph_ren_agg_gray8: if(FT_IS_SCALABLE(m_cur_face)) { m_glyph_rendering = glyph_ren_agg_gray8; } else { m_glyph_rendering = glyph_ren_native_gray8; } break; } update_signature(); } } return ret; } //------------------------------------------------------------------------ bool font_engine_freetype_base::attach(const char* file_name) { if(m_cur_face) { m_last_error = FT_Attach_File(m_cur_face, file_name); return m_last_error == 0; } return false; } //------------------------------------------------------------------------ unsigned font_engine_freetype_base::num_faces() const { if(m_cur_face) { return m_cur_face->num_faces; } return 0; } //------------------------------------------------------------------------ bool font_engine_freetype_base::char_map(FT_Encoding char_map) { if(m_cur_face) { m_last_error = FT_Select_Charmap(m_cur_face, m_char_map); if(m_last_error == 0) { update_signature(); return true; } } return false; } //------------------------------------------------------------------------ bool font_engine_freetype_base::height(double h) { m_height = int(h * 64.0); if(m_cur_face) { update_char_size(); return true; } return false; } //------------------------------------------------------------------------ bool font_engine_freetype_base::width(double w) { m_width = int(w * 64.0); if(m_cur_face) { update_char_size(); return true; } return false; } //------------------------------------------------------------------------ void font_engine_freetype_base::hinting(bool h) { m_hinting = h; if(m_cur_face) { update_signature(); } } //------------------------------------------------------------------------ void font_engine_freetype_base::flip_y(bool f) { m_flip_y = f; if(m_cur_face) { update_signature(); } } //------------------------------------------------------------------------ void font_engine_freetype_base::transform(const trans_affine& affine) { m_affine = affine; if(m_cur_face) { update_signature(); } } //------------------------------------------------------------------------ void font_engine_freetype_base::update_signature() { if(m_cur_face && m_name) { unsigned name_len = strlen(m_name); if(name_len > m_name_len) { delete [] m_signature; m_signature = new char [name_len + 32 + 256]; m_name_len = name_len + 32 - 1; } unsigned gamma_hash = 0; if(m_glyph_rendering == glyph_ren_native_gray8 || m_glyph_rendering == glyph_ren_agg_mono || m_glyph_rendering == glyph_ren_agg_gray8) { unsigned char gamma_table[rasterizer_scanline_aa<>::aa_scale]; unsigned i; for(i = 0; i < rasterizer_scanline_aa<>::aa_scale; ++i) { gamma_table[i] = m_rasterizer.apply_gamma(i); } gamma_hash = calc_crc32(gamma_table, sizeof(gamma_table)); } sprintf(m_signature, "%s,%u,%d,%d,%d:%dx%d,%d,%d,%08X", m_name, m_char_map, m_face_index, int(m_glyph_rendering), m_resolution, m_height, m_width, int(m_hinting), int(m_flip_y), gamma_hash); if(m_glyph_rendering == glyph_ren_outline || m_glyph_rendering == glyph_ren_agg_mono || m_glyph_rendering == glyph_ren_agg_gray8) { double mtx[6]; char buf[100]; m_affine.store_to(mtx); sprintf(buf, ",%08X%08X%08X%08X%08X%08X", dbl_to_plain_fx(mtx[0]), dbl_to_plain_fx(mtx[1]), dbl_to_plain_fx(mtx[2]), dbl_to_plain_fx(mtx[3]), dbl_to_plain_fx(mtx[4]), dbl_to_plain_fx(mtx[5])); strcat(m_signature, buf); } ++m_change_stamp; } } //------------------------------------------------------------------------ void font_engine_freetype_base::update_char_size() { if(m_cur_face) { if(m_resolution) { FT_Set_Char_Size(m_cur_face, m_width, // char_width in 1/64th of points m_height, // char_height in 1/64th of points m_resolution, // horizontal device resolution m_resolution); // vertical device resolution } else { FT_Set_Pixel_Sizes(m_cur_face, m_width >> 6, // pixel_width m_height >> 6); // pixel_height } update_signature(); } } //------------------------------------------------------------------------ bool font_engine_freetype_base::prepare_glyph(unsigned glyph_code) { m_glyph_index = FT_Get_Char_Index(m_cur_face, glyph_code); m_last_error = FT_Load_Glyph(m_cur_face, m_glyph_index, m_hinting ? FT_LOAD_DEFAULT : FT_LOAD_NO_HINTING); // m_hinting ? FT_LOAD_FORCE_AUTOHINT : FT_LOAD_NO_HINTING); if(m_last_error == 0) { switch(m_glyph_rendering) { case glyph_ren_native_mono: m_last_error = FT_Render_Glyph(m_cur_face->glyph, FT_RENDER_MODE_MONO); if(m_last_error == 0) { decompose_ft_bitmap_mono(m_cur_face->glyph->bitmap, m_cur_face->glyph->bitmap_left, m_flip_y ? -m_cur_face->glyph->bitmap_top : m_cur_face->glyph->bitmap_top, m_flip_y, m_scanline_bin, m_scanlines_bin); m_bounds.x1 = m_scanlines_bin.min_x(); m_bounds.y1 = m_scanlines_bin.min_y(); m_bounds.x2 = m_scanlines_bin.max_x() + 1; m_bounds.y2 = m_scanlines_bin.max_y() + 1; m_data_size = m_scanlines_bin.byte_size(); m_data_type = glyph_data_mono; m_advance_x = int26p6_to_dbl(m_cur_face->glyph->advance.x); m_advance_y = int26p6_to_dbl(m_cur_face->glyph->advance.y); return true; } break; case glyph_ren_native_gray8: m_last_error = FT_Render_Glyph(m_cur_face->glyph, FT_RENDER_MODE_NORMAL); if(m_last_error == 0) { decompose_ft_bitmap_gray8(m_cur_face->glyph->bitmap, m_cur_face->glyph->bitmap_left, m_flip_y ? -m_cur_face->glyph->bitmap_top : m_cur_face->glyph->bitmap_top, m_flip_y, m_rasterizer, m_scanline_aa, m_scanlines_aa); m_bounds.x1 = m_scanlines_aa.min_x(); m_bounds.y1 = m_scanlines_aa.min_y(); m_bounds.x2 = m_scanlines_aa.max_x() + 1; m_bounds.y2 = m_scanlines_aa.max_y() + 1; m_data_size = m_scanlines_aa.byte_size(); m_data_type = glyph_data_gray8; m_advance_x = int26p6_to_dbl(m_cur_face->glyph->advance.x); m_advance_y = int26p6_to_dbl(m_cur_face->glyph->advance.y); return true; } break; case glyph_ren_outline: if(m_last_error == 0) { if(m_flag32) { m_path32.remove_all(); if(decompose_ft_outline(m_cur_face->glyph->outline, m_flip_y, m_affine, m_path32)) { rect_d bnd = m_path32.bounding_rect(); m_data_size = m_path32.byte_size(); m_data_type = glyph_data_outline; m_bounds.x1 = int(floor(bnd.x1)); m_bounds.y1 = int(floor(bnd.y1)); m_bounds.x2 = int(ceil(bnd.x2)); m_bounds.y2 = int(ceil(bnd.y2)); m_advance_x = int26p6_to_dbl(m_cur_face->glyph->advance.x); m_advance_y = int26p6_to_dbl(m_cur_face->glyph->advance.y); m_affine.transform(&m_advance_x, &m_advance_y); return true; } } else { m_path16.remove_all(); if(decompose_ft_outline(m_cur_face->glyph->outline, m_flip_y, m_affine, m_path16)) { rect_d bnd = m_path16.bounding_rect(); m_data_size = m_path16.byte_size(); m_data_type = glyph_data_outline; m_bounds.x1 = int(floor(bnd.x1)); m_bounds.y1 = int(floor(bnd.y1)); m_bounds.x2 = int(ceil(bnd.x2)); m_bounds.y2 = int(ceil(bnd.y2)); m_advance_x = int26p6_to_dbl(m_cur_face->glyph->advance.x); m_advance_y = int26p6_to_dbl(m_cur_face->glyph->advance.y); m_affine.transform(&m_advance_x, &m_advance_y); return true; } } } return false; case glyph_ren_agg_mono: if(m_last_error == 0) { m_rasterizer.reset(); if(m_flag32) { m_path32.remove_all(); decompose_ft_outline(m_cur_face->glyph->outline, m_flip_y, m_affine, m_path32); m_rasterizer.add_path(m_curves32); } else { m_path16.remove_all(); decompose_ft_outline(m_cur_face->glyph->outline, m_flip_y, m_affine, m_path16); m_rasterizer.add_path(m_curves16); } m_scanlines_bin.prepare(); // Remove all render_scanlines(m_rasterizer, m_scanline_bin, m_scanlines_bin); m_bounds.x1 = m_scanlines_bin.min_x(); m_bounds.y1 = m_scanlines_bin.min_y(); m_bounds.x2 = m_scanlines_bin.max_x() + 1; m_bounds.y2 = m_scanlines_bin.max_y() + 1; m_data_size = m_scanlines_bin.byte_size(); m_data_type = glyph_data_mono; m_advance_x = int26p6_to_dbl(m_cur_face->glyph->advance.x); m_advance_y = int26p6_to_dbl(m_cur_face->glyph->advance.y); m_affine.transform(&m_advance_x, &m_advance_y); return true; } return false; case glyph_ren_agg_gray8: if(m_last_error == 0) { m_rasterizer.reset(); if(m_flag32) { m_path32.remove_all(); decompose_ft_outline(m_cur_face->glyph->outline, m_flip_y, m_affine, m_path32); m_rasterizer.add_path(m_curves32); } else { m_path16.remove_all(); decompose_ft_outline(m_cur_face->glyph->outline, m_flip_y, m_affine, m_path16); m_rasterizer.add_path(m_curves16); } m_scanlines_aa.prepare(); // Remove all render_scanlines(m_rasterizer, m_scanline_aa, m_scanlines_aa); m_bounds.x1 = m_scanlines_aa.min_x(); m_bounds.y1 = m_scanlines_aa.min_y(); m_bounds.x2 = m_scanlines_aa.max_x() + 1; m_bounds.y2 = m_scanlines_aa.max_y() + 1; m_data_size = m_scanlines_aa.byte_size(); m_data_type = glyph_data_gray8; m_advance_x = int26p6_to_dbl(m_cur_face->glyph->advance.x); m_advance_y = int26p6_to_dbl(m_cur_face->glyph->advance.y); m_affine.transform(&m_advance_x, &m_advance_y); return true; } return false; } } return false; } //------------------------------------------------------------------------ void font_engine_freetype_base::write_glyph_to(int8u* data) const { if(data && m_data_size) { switch(m_data_type) { default: return; case glyph_data_mono: m_scanlines_bin.serialize(data); break; case glyph_data_gray8: m_scanlines_aa.serialize(data); break; case glyph_data_outline: if(m_flag32) { m_path32.serialize(data); } else { m_path16.serialize(data); } break; case glyph_data_invalid: break; } } } //------------------------------------------------------------------------ bool font_engine_freetype_base::add_kerning(unsigned first, unsigned second, double* x, double* y) { if(m_cur_face && first && second && FT_HAS_KERNING(m_cur_face)) { FT_Vector delta; FT_Get_Kerning(m_cur_face, first, second, FT_KERNING_DEFAULT, &delta); double dx = int26p6_to_dbl(delta.x); double dy = int26p6_to_dbl(delta.y); if(m_glyph_rendering == glyph_ren_outline || m_glyph_rendering == glyph_ren_agg_mono || m_glyph_rendering == glyph_ren_agg_gray8) { m_affine.transform_2x2(&dx, &dy); } *x += dx; *y += dy; return true; } return false; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/Makefile.am0000644000175000017500000000115412516137326021406 0ustar varunvarunSUBDIRS = gpc src font_freetype font_win32_tt include examples pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libagg.pc EXTRA_DIST = Makefile.AmigaOS \ Makefile.in.BeOS \ Makefile.in.CYGWIN_NT-5.0 \ Makefile.in.CYGWIN_NT-5.1 \ Makefile.in.Darwin \ Makefile.in.Darwin.SDL \ Makefile.in.IRIX64 \ Makefile.in.Linux \ Makefile.in.Linux.SDL \ Makefile.in.MINGW32_NT-5.0 \ Makefile.in.MINGW32_NT-5.1 \ Makefile.in.SunOS # M4 macro file for inclusion with autoconf m4datadir = $(datadir)/aclocal m4data_DATA = libagg.m4 enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/Makefile.in.MINGW32_NT-5.10000644000175000017500000000014312516137326023343 0ustar varunvarunAGGLIBS= -lagg AGGCXXFLAGS = -O3 CXX = g++ C = gcc #CXX = icc LIB = ar cr .PHONY : clean enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/distclean0000644000175000017500000000155012516137326021243 0ustar varunvarun#! /bin/sh find . -iname '*.[oa]' -exec \rm -f {} \; find . -iname '*.ppm' -exec \rm -f {} \; find . -iname '*~' -exec \rm -f {} \; find . -iname 'gamma.*' -exec \rm -f {} \; find . -iname Debug -exec \rm -rf {} \; find . -iname Release -exec \rm -rf {} \; find . -iname '*.exe' -exec \rm -rf {} \; find . -iname '*.lib' -exec \rm -rf {} \; find . -iname '*.dll' -exec \rm -rf {} \; find . -iname '*.obj' -exec \rm -rf {} \; find . -iname '*.aps' -exec \rm -rf {} \; find . -iname '*.clw' -exec \rm -rf {} \; find . -iname '*.ilk' -exec \rm -rf {} \; find . -iname '*.ncb' -exec \rm -rf {} \; find . -iname '*.opt' -exec \rm -rf {} \; find . -iname '*.plg' -exec \rm -rf {} \; find . -iname '*.pch' -exec \rm -rf {} \; find . -iname '*.idb' -exec \rm -rf {} \; find . -iname '*.pdb' -exec \rm -rf {} \; find . -iname '*.res' -exec \rm -rf {} \; enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/Makefile.in.SunOS0000644000175000017500000000020412516137326022420 0ustar varunvarunAGGLIBS= -lagg AGGCXXFLAGS = -O3 -I/usr/openwin/include -L/usr/openwin/lib CXX = CC C = cc LIB = CC -xar -o .PHONY : clean enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/news0000644000175000017500000000003712516137326020250 0ustar varunvarunVisit http://antigrain.com/newsenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/autogen.sh0000644000175000017500000000055512516137326021354 0ustar varunvarun# autogen.sh # # invoke the auto* tools to create the configuration/build system # build aclocal.m4 aclocal # build config.h autoheader # build the configure script autoconf # set up libtool libtoolize --force # invoke automake automake --foreign --add-missing --ignore-deps # and finally invoke our new configure ./configure $* # end enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/Makefile.in.MINGW32_NT-5.00000644000175000017500000000014312516137326023342 0ustar varunvarunAGGLIBS= -lagg AGGCXXFLAGS = -O3 CXX = g++ C = gcc #CXX = icc LIB = ar cr .PHONY : clean enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/ChangeLog0000644000175000017500000000003712516137326021123 0ustar varunvarunVisit http://antigrain.com/newsenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/install0000644000175000017500000000342312516137326020744 0ustar varunvarunAnti-Grain Geometry is a C++ library distributed in sources and does not require any installation procedure. The source code is platform independent and does not have any dependencies on system APIs (except for very standard C runtime library). You just take source files and include them into your project. The sources are maintained to be highly compatible with most popular C++ compilers, including poor ones, like Microsoft Visual C++ V6.0. On Unix/Linux/MacOS/BeOS/AmigaOS systems you can type "make" to build src/libagg.a There must be GNU Make utility installed. Makefiles are very simple, so that if something goes wrong you could easily fix it. There are no "include files" dependency suppoeted. Also note that there's no "make install" option either; basically the original Makefiles are needed only to build the examples. After building the library you do "cd examples/" and build the examples in a similar way. On most Linux platforms the "automake" environment should work. It's generously provided by Nikolas Zimmermann, aka WildFox, who is a key developer of KDE and KSVG. This process will replace the original Makefiles. On Windows there's no library or a DLL created at all. You just add source files into your project or create a preoject to build a LIB/DLL if you wish. The problem is that it's very tedious to maintain building environments for all possible configurations. I'm sorry for not automating it, but the compensation is that AGG compiles fine without any hidden problems, nor the neccesity to configure. All examples have building environments for Microsoft Visual C++ 6.0 (.dsp/.dsw) and they are self-sufficient. The newer versions of the studio can easily convert the projects. Also, see "readme" for more details.enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/Makefile.in.Linux0000644000175000017500000000021112516137326022506 0ustar varunvarunAGGLIBS= -lagg AGGCXXFLAGS = -O3 -I/usr/X11R6/include -L/usr/X11R6/lib CXX = g++ C = gcc #CXX = icc LIB = ar cr .PHONY : clean enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/Makefile.in.CYGWIN_NT-5.10000644000175000017500000000021112516137326023311 0ustar varunvarunAGGLIBS= -lagg AGGCXXFLAGS = -O3 -I/usr/X11R6/include -L/usr/X11R6/lib CXX = g++ C = gcc #CXX = icc LIB = ar cr .PHONY : clean enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/0000755000175000017500000000000012516137725020143 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_arc.cpp0000644000175000017500000000626512516137326022240 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Arc vertex generator // //---------------------------------------------------------------------------- #include #include "agg_arc.h" namespace agg24 { //------------------------------------------------------------------------ arc::arc(double x, double y, double rx, double ry, double a1, double a2, bool ccw) : m_x(x), m_y(y), m_rx(rx), m_ry(ry), m_scale(1.0) { normalize(a1, a2, ccw); } //------------------------------------------------------------------------ void arc::init(double x, double y, double rx, double ry, double a1, double a2, bool ccw) { m_x = x; m_y = y; m_rx = rx; m_ry = ry; normalize(a1, a2, ccw); } //------------------------------------------------------------------------ void arc::approximation_scale(double s) { m_scale = s; if(m_initialized) { normalize(m_start, m_end, m_ccw); } } //------------------------------------------------------------------------ void arc::rewind(unsigned) { m_path_cmd = path_cmd_move_to; m_angle = m_start; } //------------------------------------------------------------------------ unsigned arc::vertex(double* x, double* y) { if(is_stop(m_path_cmd)) return path_cmd_stop; if((m_angle < m_end - m_da/4) != m_ccw) { *x = m_x + cos(m_end) * m_rx; *y = m_y + sin(m_end) * m_ry; m_path_cmd = path_cmd_stop; return path_cmd_line_to; } *x = m_x + cos(m_angle) * m_rx; *y = m_y + sin(m_angle) * m_ry; m_angle += m_da; unsigned pf = m_path_cmd; m_path_cmd = path_cmd_line_to; return pf; } //------------------------------------------------------------------------ void arc::normalize(double a1, double a2, bool ccw) { double ra = (fabs(m_rx) + fabs(m_ry)) / 2; m_da = acos(ra / (ra + 0.125 / m_scale)) * 2; if(ccw) { while(a2 < a1) a2 += pi * 2.0; } else { while(a1 < a2) a1 += pi * 2.0; m_da = -m_da; } m_ccw = ccw; m_start = a1; m_end = a2; m_initialized = true; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/Makefile0000644000175000017500000000237312516137326021605 0ustar varunvaruninclude ../Makefile.in.$(shell uname) CXXFLAGS= $(AGGCXXFLAGS) -I../include -L./ SRC_CXX=\ agg_arc.cpp \ agg_arrowhead.cpp \ agg_bezier_arc.cpp \ agg_bspline.cpp \ agg_curves.cpp \ agg_vcgen_contour.cpp \ agg_vcgen_dash.cpp \ agg_vcgen_markers_term.cpp \ agg_vcgen_smooth_poly1.cpp \ agg_vcgen_stroke.cpp \ agg_vcgen_bspline.cpp \ agg_gsv_text.cpp \ agg_image_filters.cpp \ agg_line_aa_basics.cpp \ agg_line_profile_aa.cpp \ agg_rounded_rect.cpp \ agg_sqrt_tables.cpp \ agg_embedded_raster_fonts.cpp \ agg_trans_affine.cpp \ agg_trans_warp_magnifier.cpp \ agg_trans_single_path.cpp \ agg_trans_double_path.cpp \ agg_vpgen_clip_polygon.cpp \ agg_vpgen_clip_polyline.cpp \ agg_vpgen_segmentator.cpp \ ctrl/agg_cbox_ctrl.cpp \ ctrl/agg_gamma_ctrl.cpp \ ctrl/agg_gamma_spline.cpp \ ctrl/agg_rbox_ctrl.cpp \ ctrl/agg_slider_ctrl.cpp \ ctrl/agg_spline_ctrl.cpp \ ctrl/agg_scale_ctrl.cpp \ ctrl/agg_polygon_ctrl.cpp \ ctrl/agg_bezier_ctrl.cpp SRC_C=\ ../gpc/gpc.c OBJ=$(SRC_CXX:.cpp=.o) $(SRC_C:.c=.o) all: $(OBJ) $(LIB) libagg.a $(OBJ) clean: rm -f *.o *.a ctrl/*.o ../gpc/*.o rm -rf SunWS_cache rm -rf ctrl/SunWS_cache %.o: %.cpp $(CXX) -c $(CXXFLAGS) $*.cpp -o $@ %.o: %.c $(C) -c $(CXXFLAGS) $*.c -o $@ enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_line_profile_aa.cpp0000644000175000017500000000711212516137326024573 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #include "agg_renderer_outline_aa.h" namespace agg24 { //--------------------------------------------------------------------- void line_profile_aa::width(double w) { if(w < 0.0) w = 0.0; if(w < m_smoother_width) w += w; else w += m_smoother_width; w *= 0.5; w -= m_smoother_width; double s = m_smoother_width; if(w < 0.0) { s += w; w = 0.0; } set(w, s); } //--------------------------------------------------------------------- line_profile_aa::value_type* line_profile_aa::profile(double w) { m_subpixel_width = uround(w * subpixel_scale); unsigned size = m_subpixel_width + subpixel_scale * 6; if(size > m_profile.size()) { m_profile.resize(size); } return &m_profile[0]; } //--------------------------------------------------------------------- void line_profile_aa::set(double center_width, double smoother_width) { double base_val = 1.0; if(center_width == 0.0) center_width = 1.0 / subpixel_scale; if(smoother_width == 0.0) smoother_width = 1.0 / subpixel_scale; double width = center_width + smoother_width; if(width < m_min_width) { double k = width / m_min_width; base_val *= k; center_width /= k; smoother_width /= k; } value_type* ch = profile(center_width + smoother_width); unsigned subpixel_center_width = unsigned(center_width * subpixel_scale); unsigned subpixel_smoother_width = unsigned(smoother_width * subpixel_scale); value_type* ch_center = ch + subpixel_scale*2; value_type* ch_smoother = ch_center + subpixel_center_width; unsigned i; unsigned val = m_gamma[unsigned(base_val * aa_mask)]; ch = ch_center; for(i = 0; i < subpixel_center_width; i++) { *ch++ = (value_type)val; } for(i = 0; i < subpixel_smoother_width; i++) { *ch_smoother++ = m_gamma[unsigned((base_val - base_val * (double(i) / subpixel_smoother_width)) * aa_mask)]; } unsigned n_smoother = profile_size() - subpixel_smoother_width - subpixel_center_width - subpixel_scale*2; val = m_gamma[0]; for(i = 0; i < n_smoother; i++) { *ch_smoother++ = (value_type)val; } ch = ch_center; for(i = 0; i < subpixel_scale*2; i++) { *--ch = *ch_center++; } } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_vpgen_clip_polygon.cpp0000644000175000017500000000745212516137326025367 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #include "agg_vpgen_clip_polygon.h" #include "agg_clip_liang_barsky.h" namespace agg24 { //------------------------------------------------------------------------ // Determine the clipping code of the vertex according to the // Cyrus-Beck line clipping algorithm // // | | // 0110 | 0010 | 0011 // | | // -------+--------+-------- clip_box.y2 // | | // 0100 | 0000 | 0001 // | | // -------+--------+-------- clip_box.y1 // | | // 1100 | 1000 | 1001 // | | // clip_box.x1 clip_box.x2 // // unsigned vpgen_clip_polygon::clipping_flags(double x, double y) { if(x < m_clip_box.x1) { if(y > m_clip_box.y2) return 6; if(y < m_clip_box.y1) return 12; return 4; } if(x > m_clip_box.x2) { if(y > m_clip_box.y2) return 3; if(y < m_clip_box.y1) return 9; return 1; } if(y > m_clip_box.y2) return 2; if(y < m_clip_box.y1) return 8; return 0; } //---------------------------------------------------------------------------- void vpgen_clip_polygon::reset() { m_vertex = 0; m_num_vertices = 0; } //---------------------------------------------------------------------------- void vpgen_clip_polygon::move_to(double x, double y) { m_vertex = 0; m_num_vertices = 0; m_clip_flags = clipping_flags(x, y); if(m_clip_flags == 0) { m_x[0] = x; m_y[0] = y; m_num_vertices = 1; } m_x1 = x; m_y1 = y; m_cmd = path_cmd_move_to; } //---------------------------------------------------------------------------- void vpgen_clip_polygon::line_to(double x, double y) { m_vertex = 0; m_num_vertices = 0; unsigned flags = clipping_flags(x, y); if(m_clip_flags == flags) { if(flags == 0) { m_x[0] = x; m_y[0] = y; m_num_vertices = 1; } } else { m_num_vertices = clip_liang_barsky(m_x1, m_y1, x, y, m_clip_box, m_x, m_y); } m_clip_flags = flags; m_x1 = x; m_y1 = y; } //---------------------------------------------------------------------------- unsigned vpgen_clip_polygon::vertex(double* x, double* y) { if(m_vertex < m_num_vertices) { *x = m_x[m_vertex]; *y = m_y[m_vertex]; ++m_vertex; unsigned cmd = m_cmd; m_cmd = path_cmd_line_to; return cmd; } return path_cmd_stop; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_trans_affine.cpp0000644000175000017500000001436612516137326024133 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Affine transformations // //---------------------------------------------------------------------------- #include "agg_trans_affine.h" namespace agg24 { //------------------------------------------------------------------------ const trans_affine& trans_affine::parl_to_parl(const double* src, const double* dst) { m0 = src[2] - src[0]; m1 = src[3] - src[1]; m2 = src[4] - src[0]; m3 = src[5] - src[1]; m4 = src[0]; m5 = src[1]; invert(); multiply(trans_affine(dst[2] - dst[0], dst[3] - dst[1], dst[4] - dst[0], dst[5] - dst[1], dst[0], dst[1])); return *this; } //------------------------------------------------------------------------ const trans_affine& trans_affine::rect_to_parl(double x1, double y1, double x2, double y2, const double* parl) { double src[6]; src[0] = x1; src[1] = y1; src[2] = x2; src[3] = y1; src[4] = x2; src[5] = y2; parl_to_parl(src, parl); return *this; } //------------------------------------------------------------------------ const trans_affine& trans_affine::parl_to_rect(const double* parl, double x1, double y1, double x2, double y2) { double dst[6]; dst[0] = x1; dst[1] = y1; dst[2] = x2; dst[3] = y1; dst[4] = x2; dst[5] = y2; parl_to_parl(parl, dst); return *this; } //------------------------------------------------------------------------ const trans_affine& trans_affine::multiply(const trans_affine& m) { double t0 = m0 * m.m0 + m1 * m.m2; double t2 = m2 * m.m0 + m3 * m.m2; double t4 = m4 * m.m0 + m5 * m.m2 + m.m4; m1 = m0 * m.m1 + m1 * m.m3; m3 = m2 * m.m1 + m3 * m.m3; m5 = m4 * m.m1 + m5 * m.m3 + m.m5; m0 = t0; m2 = t2; m4 = t4; return *this; } //------------------------------------------------------------------------ const trans_affine& trans_affine::invert() { double d = determinant(); double t0 = m3 * d; m3 = m0 * d; m1 = -m1 * d; m2 = -m2 * d; double t4 = -m4 * t0 - m5 * m2; m5 = -m4 * m1 - m5 * m3; m0 = t0; m4 = t4; return *this; } //------------------------------------------------------------------------ const trans_affine& trans_affine::flip_x() { m0 = -m0; m1 = -m1; m4 = -m4; return *this; } //------------------------------------------------------------------------ const trans_affine& trans_affine::flip_y() { m2 = -m2; m3 = -m3; m5 = -m5; return *this; } //------------------------------------------------------------------------ const trans_affine& trans_affine::reset() { m0 = m3 = 1.0; m1 = m2 = m4 = m5 = 0.0; return *this; } //------------------------------------------------------------------------ inline bool is_equal_eps(double v1, double v2, double epsilon) { return fabs(v1 - v2) < epsilon; } //------------------------------------------------------------------------ bool trans_affine::is_identity(double epsilon) const { return is_equal_eps(m0, 1.0, epsilon) && is_equal_eps(m1, 0.0, epsilon) && is_equal_eps(m2, 0.0, epsilon) && is_equal_eps(m3, 1.0, epsilon) && is_equal_eps(m4, 0.0, epsilon) && is_equal_eps(m5, 0.0, epsilon); } //------------------------------------------------------------------------ bool trans_affine::is_equal(const trans_affine& m, double epsilon) const { return is_equal_eps(m0, m.m0, epsilon) && is_equal_eps(m1, m.m1, epsilon) && is_equal_eps(m2, m.m2, epsilon) && is_equal_eps(m3, m.m3, epsilon) && is_equal_eps(m4, m.m4, epsilon) && is_equal_eps(m5, m.m5, epsilon); } //------------------------------------------------------------------------ double trans_affine::rotation() const { double x1 = 0.0; double y1 = 0.0; double x2 = 1.0; double y2 = 0.0; transform(&x1, &y1); transform(&x2, &y2); return atan2(y2-y1, x2-x1); } //------------------------------------------------------------------------ void trans_affine::translation(double* dx, double* dy) const { trans_affine t(*this); t *= trans_affine_rotation(-rotation()); t.transform(dx, dy); } //------------------------------------------------------------------------ void trans_affine::scaling(double* sx, double* sy) const { double x1 = 0.0; double y1 = 0.0; double x2 = 1.0; double y2 = 1.0; trans_affine t(*this); t *= trans_affine_rotation(-rotation()); t.transform(&x1, &y1); t.transform(&x2, &y2); *sx = x2 - x1; *sy = y2 - y1; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_image_filters.cpp0000644000175000017500000000713112516137326024276 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Filtering class image_filter_lut implemantation // //---------------------------------------------------------------------------- #include "agg_image_filters.h" namespace agg24 { //-------------------------------------------------------------------- void image_filter_lut::realloc_lut(double radius) { m_radius = radius; m_diameter = uceil(radius) * 2; m_start = -int(m_diameter / 2 - 1); unsigned size = m_diameter << image_subpixel_shift; if(size > m_weight_array.size()) { m_weight_array.resize(size); } } //-------------------------------------------------------------------- // This function normalizes integer values and corrects the rounding // errors. It doesn't do anything with the source floating point values // (m_weight_array_dbl), it corrects only integers according to the rule // of 1.0 which means that any sum of pixel weights must be equal to 1.0. // So, the filter function must produce a graph of the proper shape. //-------------------------------------------------------------------- void image_filter_lut::normalize() { unsigned i; int flip = 1; for(i = 0; i < image_subpixel_scale; i++) { for(;;) { int sum = 0; unsigned j; for(j = 0; j < m_diameter; j++) { sum += m_weight_array[j * image_subpixel_scale + i]; } if(sum == image_filter_scale) break; double k = double(image_filter_scale) / double(sum); sum = 0; for(j = 0; j < m_diameter; j++) { sum += m_weight_array[j * image_subpixel_scale + i] = iround(m_weight_array[j * image_subpixel_scale + i] * k); } sum -= image_filter_scale; int inc = (sum > 0) ? -1 : 1; for(j = 0; j < m_diameter && sum; j++) { flip ^= 1; unsigned idx = flip ? m_diameter/2 + j/2 : m_diameter/2 - j/2; int v = m_weight_array[idx * image_subpixel_scale + i]; if(v < image_filter_scale) { m_weight_array[idx * image_subpixel_scale + i] += inc; sum += inc; } } } } unsigned pivot = m_diameter << (image_subpixel_shift - 1); for(i = 0; i < pivot; i++) { m_weight_array[pivot + i] = m_weight_array[pivot - i]; } unsigned end = (diameter() << image_subpixel_shift) - 1; m_weight_array[0] = m_weight_array[end]; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/readme0000644000175000017500000000032412516137326021317 0ustar varunvarunUse automake to build the library. If automake is not available you still can use the old make. There is a very simple Makefile that can be used. Note that if you use automake it will overwrite Makefile. enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/configure.in0000644000175000017500000000040312516137326022446 0ustar varunvarunAC_INIT(src/agg_arc.cpp) # give me a source file, any source file... AM_INIT_AUTOMAKE(agg, 2.0.0) AC_PROG_LN_S AC_PROG_CC AC_PROG_CPP AC_PROG_CXX AC_PROG_LIBTOOL AC_OUTPUT( Makefile gpc/Makefile src/Makefile src/ctrl/Makefile ) enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/copying0000644000175000017500000000070612516137326021536 0ustar varunvarunThe Anti-Grain Geometry Project A high quality rendering engine for C++ http://antigrain.com Anti-Grain Geometry - Version 2.4 Copyright (C) 2002-2005 Maxim Shemanarev (McSeem) Permission to copy, use, modify, sell and distribute this software is granted provided this copyright notice appears in all copies. This software is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose. enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/authors0000644000175000017500000000000012516137326021536 0ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/ctrl/0000755000175000017500000000000012516137725021107 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/ctrl/agg_gamma_spline.cpp0000644000175000017500000000722212516137326025065 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class gamma_spline // //---------------------------------------------------------------------------- #include "ctrl/agg_gamma_spline.h" namespace agg24 { //------------------------------------------------------------------------ gamma_spline::gamma_spline() : m_x1(0), m_y1(0), m_x2(10), m_y2(10), m_cur_x(0.0) { values(1.0, 1.0, 1.0, 1.0); } //------------------------------------------------------------------------ double gamma_spline::y(double x) const { if(x < 0.0) x = 0.0; if(x > 1.0) x = 1.0; double val = m_spline.get(x); if(val < 0.0) val = 0.0; if(val > 1.0) val = 1.0; return val; } //------------------------------------------------------------------------ void gamma_spline::values(double kx1, double ky1, double kx2, double ky2) { if(kx1 < 0.001) kx1 = 0.001; if(kx1 > 1.999) kx1 = 1.999; if(ky1 < 0.001) ky1 = 0.001; if(ky1 > 1.999) ky1 = 1.999; if(kx2 < 0.001) kx2 = 0.001; if(kx2 > 1.999) kx2 = 1.999; if(ky2 < 0.001) ky2 = 0.001; if(ky2 > 1.999) ky2 = 1.999; m_x[0] = 0.0; m_y[0] = 0.0; m_x[1] = kx1 * 0.25; m_y[1] = ky1 * 0.25; m_x[2] = 1.0 - kx2 * 0.25; m_y[2] = 1.0 - ky2 * 0.25; m_x[3] = 1.0; m_y[3] = 1.0; m_spline.init(4, m_x, m_y); int i; for(i = 0; i < 256; i++) { m_gamma[i] = (unsigned char)(y(double(i) / 255.0) * 255.0); } } //------------------------------------------------------------------------ void gamma_spline::values(double* kx1, double* ky1, double* kx2, double* ky2) const { *kx1 = m_x[1] * 4.0; *ky1 = m_y[1] * 4.0; *kx2 = (1.0 - m_x[2]) * 4.0; *ky2 = (1.0 - m_y[2]) * 4.0; } //------------------------------------------------------------------------ void gamma_spline::box(double x1, double y1, double x2, double y2) { m_x1 = x1; m_y1 = y1; m_x2 = x2; m_y2 = y2; } //------------------------------------------------------------------------ void gamma_spline::rewind(unsigned) { m_cur_x = 0.0; } //------------------------------------------------------------------------ unsigned gamma_spline::vertex(double* vx, double* vy) { if(m_cur_x == 0.0) { *vx = m_x1; *vy = m_y1; m_cur_x += 1.0 / (m_x2 - m_x1); return path_cmd_move_to; } if(m_cur_x > 1.0) { return path_cmd_stop; } *vx = m_x1 + m_cur_x * (m_x2 - m_x1); *vy = m_y1 + y(m_cur_x) * (m_y2 - m_y1); m_cur_x += 1.0 / (m_x2 - m_x1); return path_cmd_line_to; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/ctrl/agg_cbox_ctrl.cpp0000644000175000017500000001456712516137326024422 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes rbox_ctrl_impl, rbox_ctrl // //---------------------------------------------------------------------------- #include #include "ctrl/agg_cbox_ctrl.h" namespace agg24 { //------------------------------------------------------------------------ cbox_ctrl_impl::cbox_ctrl_impl(double x, double y, const char* l, bool flip_y) : ctrl(x, y, x + 9.0 * 1.5, y + 9.0 * 1.5, flip_y), m_text_thickness(1.5), m_text_height(9.0), m_text_width(0.0), m_status(false), m_text_poly(m_text) { label(l); } //------------------------------------------------------------------------ void cbox_ctrl_impl::text_size(double h, double w) { m_text_width = w; m_text_height = h; } //------------------------------------------------------------------------ void cbox_ctrl_impl::label(const char* l) { unsigned len = strlen(l); if(len > 127) len = 127; memcpy(m_label, l, len); m_label[len] = 0; } //------------------------------------------------------------------------ bool cbox_ctrl_impl::on_mouse_button_down(double x, double y) { inverse_transform_xy(&x, &y); if(x >= m_x1 && y >= m_y1 && x <= m_x2 && y <= m_y2) { m_status = !m_status; return true; } return false; } //------------------------------------------------------------------------ bool cbox_ctrl_impl::on_mouse_move(double, double, bool) { return false; } //------------------------------------------------------------------------ bool cbox_ctrl_impl::in_rect(double x, double y) const { inverse_transform_xy(&x, &y); return x >= m_x1 && y >= m_y1 && x <= m_x2 && y <= m_y2; } //------------------------------------------------------------------------ bool cbox_ctrl_impl::on_mouse_button_up(double, double) { return false; } //------------------------------------------------------------------------ bool cbox_ctrl_impl::on_arrow_keys(bool, bool, bool, bool) { return false; } //------------------------------------------------------------------------ void cbox_ctrl_impl::rewind(unsigned idx) { m_idx = idx; double d2; double t; switch(idx) { default: case 0: // Border m_vertex = 0; m_vx[0] = m_x1; m_vy[0] = m_y1; m_vx[1] = m_x2; m_vy[1] = m_y1; m_vx[2] = m_x2; m_vy[2] = m_y2; m_vx[3] = m_x1; m_vy[3] = m_y2; m_vx[4] = m_x1 + m_text_thickness; m_vy[4] = m_y1 + m_text_thickness; m_vx[5] = m_x1 + m_text_thickness; m_vy[5] = m_y2 - m_text_thickness; m_vx[6] = m_x2 - m_text_thickness; m_vy[6] = m_y2 - m_text_thickness; m_vx[7] = m_x2 - m_text_thickness; m_vy[7] = m_y1 + m_text_thickness; break; case 1: // Text m_text.text(m_label); m_text.start_point(m_x1 + m_text_height * 2.0, m_y1 + m_text_height / 5.0); m_text.size(m_text_height, m_text_width); m_text_poly.width(m_text_thickness); m_text_poly.line_join(round_join); m_text_poly.line_cap(round_cap); m_text_poly.rewind(0); break; case 2: // Active item m_vertex = 0; d2 = (m_y2 - m_y1) / 2.0; t = m_text_thickness * 1.5; m_vx[0] = m_x1 + m_text_thickness; m_vy[0] = m_y1 + m_text_thickness; m_vx[1] = m_x1 + d2; m_vy[1] = m_y1 + d2 - t; m_vx[2] = m_x2 - m_text_thickness; m_vy[2] = m_y1 + m_text_thickness; m_vx[3] = m_x1 + d2 + t; m_vy[3] = m_y1 + d2; m_vx[4] = m_x2 - m_text_thickness; m_vy[4] = m_y2 - m_text_thickness; m_vx[5] = m_x1 + d2; m_vy[5] = m_y1 + d2 + t; m_vx[6] = m_x1 + m_text_thickness; m_vy[6] = m_y2 - m_text_thickness; m_vx[7] = m_x1 + d2 - t; m_vy[7] = m_y1 + d2; break; } } //------------------------------------------------------------------------ unsigned cbox_ctrl_impl::vertex(double* x, double* y) { unsigned cmd = path_cmd_line_to; switch(m_idx) { case 0: if(m_vertex == 0 || m_vertex == 4) cmd = path_cmd_move_to; if(m_vertex >= 8) cmd = path_cmd_stop; *x = m_vx[m_vertex]; *y = m_vy[m_vertex]; m_vertex++; break; case 1: cmd = m_text_poly.vertex(x, y); break; case 2: if(m_status) { if(m_vertex == 0) cmd = path_cmd_move_to; if(m_vertex >= 8) cmd = path_cmd_stop; *x = m_vx[m_vertex]; *y = m_vy[m_vertex]; m_vertex++; } else { cmd = path_cmd_stop; } break; default: cmd = path_cmd_stop; break; } if(!is_stop(cmd)) { transform_xy(x, y); } return cmd; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/ctrl/agg_polygon_ctrl.cpp0000644000175000017500000002511112516137326025141 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes polygon_ctrl_impl // //---------------------------------------------------------------------------- #include "ctrl/agg_polygon_ctrl.h" namespace agg24 { polygon_ctrl_impl::polygon_ctrl_impl(unsigned np, double point_radius) : ctrl(0, 0, 1, 1, false), m_polygon(np * 2), m_num_points(np), m_node(-1), m_edge(-1), m_vs(&m_polygon[0], m_num_points, false), m_stroke(m_vs), m_point_radius(point_radius), m_status(0), m_dx(0.0), m_dy(0.0) { m_stroke.width(1.0); } void polygon_ctrl_impl::rewind(unsigned) { m_status = 0; m_stroke.rewind(0); } unsigned polygon_ctrl_impl::vertex(double* x, double* y) { unsigned cmd = path_cmd_stop; double r = m_point_radius; if(m_status == 0) { cmd = m_stroke.vertex(x, y); if(!is_stop(cmd)) { transform_xy(x, y); return cmd; } if(m_node >= 0 && m_node == int(m_status)) r *= 1.2; m_ellipse.init(xn(m_status), yn(m_status), r, r, 32); ++m_status; } cmd = m_ellipse.vertex(x, y); if(!is_stop(cmd)) { transform_xy(x, y); return cmd; } if(m_status >= m_num_points) return path_cmd_stop; if(m_node >= 0 && m_node == int(m_status)) r *= 1.2; m_ellipse.init(xn(m_status), yn(m_status), r, r, 32); ++m_status; cmd = m_ellipse.vertex(x, y); if(!is_stop(cmd)) { transform_xy(x, y); } return cmd; } bool polygon_ctrl_impl::check_edge(unsigned i, double x, double y) const { bool ret = false; unsigned n1 = i; unsigned n2 = (i + m_num_points - 1) % m_num_points; double x1 = xn(n1); double y1 = yn(n1); double x2 = xn(n2); double y2 = yn(n2); double dx = x2 - x1; double dy = y2 - y1; if(sqrt(dx*dx + dy*dy) > 0.0000001) { double x3 = x; double y3 = y; double x4 = x3 - dy; double y4 = y3 + dx; double den = (y4-y3) * (x2-x1) - (x4-x3) * (y2-y1); double u1 = ((x4-x3) * (y1-y3) - (y4-y3) * (x1-x3)) / den; double xi = x1 + u1 * (x2 - x1); double yi = y1 + u1 * (y2 - y1); dx = xi - x; dy = yi - y; if (u1 > 0.0 && u1 < 1.0 && sqrt(dx*dx + dy*dy) <= m_point_radius) { ret = true; } } return ret; } bool polygon_ctrl_impl::in_rect(double x, double y) const { return false; } bool polygon_ctrl_impl::on_mouse_button_down(double x, double y) { unsigned i; bool ret = false; m_node = -1; m_edge = -1; inverse_transform_xy(&x, &y); for (i = 0; i < m_num_points; i++) { if(sqrt( (x-xn(i)) * (x-xn(i)) + (y-yn(i)) * (y-yn(i)) ) < m_point_radius) { m_dx = x - xn(i); m_dy = y - yn(i); m_node = int(i); ret = true; break; } } if(!ret) { for (i = 0; i < m_num_points; i++) { if(check_edge(i, x, y)) { m_dx = x; m_dy = y; m_edge = int(i); ret = true; break; } } } if(!ret) { if(point_in_polygon(x, y)) { m_dx = x; m_dy = y; m_node = int(m_num_points); ret = true; } } return ret; } bool polygon_ctrl_impl::on_mouse_move(double x, double y, bool button_flag) { bool ret = false; double dx; double dy; inverse_transform_xy(&x, &y); if(m_node == int(m_num_points)) { dx = x - m_dx; dy = y - m_dy; unsigned i; for(i = 0; i < m_num_points; i++) { xn(i) += dx; yn(i) += dy; } m_dx = x; m_dy = y; ret = true; } else { if(m_edge >= 0) { unsigned n1 = m_edge; unsigned n2 = (n1 + m_num_points - 1) % m_num_points; dx = x - m_dx; dy = y - m_dy; xn(n1) += dx; yn(n1) += dy; xn(n2) += dx; yn(n2) += dy; m_dx = x; m_dy = y; ret = true; } else { if(m_node >= 0) { xn(m_node) = x - m_dx; yn(m_node) = y - m_dy; ret = true; } } } return ret; } bool polygon_ctrl_impl::on_mouse_button_up(double x, double y) { bool ret = (m_node >= 0) || (m_edge >= 0); m_node = -1; m_edge = -1; return ret; } bool polygon_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up) { return false; } //======= Crossings Multiply algorithm of InsideTest ======================== // // By Eric Haines, 3D/Eye Inc, erich@eye.com // // This version is usually somewhat faster than the original published in // Graphics Gems IV; by turning the division for testing the X axis crossing // into a tricky multiplication test this part of the test became faster, // which had the additional effect of making the test for "both to left or // both to right" a bit slower for triangles than simply computing the // intersection each time. The main increase is in triangle testing speed, // which was about 15% faster; all other polygon complexities were pretty much // the same as before. On machines where division is very expensive (not the // case on the HP 9000 series on which I tested) this test should be much // faster overall than the old code. Your mileage may (in fact, will) vary, // depending on the machine and the test data, but in general I believe this // code is both shorter and faster. This test was inspired by unpublished // Graphics Gems submitted by Joseph Samosky and Mark Haigh-Hutchinson. // Related work by Samosky is in: // // Samosky, Joseph, "SectionView: A system for interactively specifying and // visualizing sections through three-dimensional medical image data", // M.S. Thesis, Department of Electrical Engineering and Computer Science, // Massachusetts Institute of Technology, 1993. // // Shoot a test ray along +X axis. The strategy is to compare vertex Y values // to the testing point's Y and quickly discard edges which are entirely to one // side of the test ray. Note that CONVEX and WINDING code can be added as // for the CrossingsTest() code; it is left out here for clarity. // // Input 2D polygon _pgon_ with _numverts_ number of vertices and test point // _point_, returns 1 if inside, 0 if outside. bool polygon_ctrl_impl::point_in_polygon(double tx, double ty) const { if(m_num_points < 3) return false; if(!m_in_polygon_check) return false; unsigned j; int yflag0, yflag1, inside_flag; double vtx0, vty0, vtx1, vty1; vtx0 = xn(m_num_points - 1); vty0 = yn(m_num_points - 1); // get test bit for above/below X axis yflag0 = (vty0 >= ty); vtx1 = xn(0); vty1 = yn(0); inside_flag = 0; for (j = 1; j <= m_num_points; ++j) { yflag1 = (vty1 >= ty); // Check if endpoints straddle (are on opposite sides) of X axis // (i.e. the Y's differ); if so, +X ray could intersect this edge. // The old test also checked whether the endpoints are both to the // right or to the left of the test point. However, given the faster // intersection point computation used below, this test was found to // be a break-even proposition for most polygons and a loser for // triangles (where 50% or more of the edges which survive this test // will cross quadrants and so have to have the X intersection computed // anyway). I credit Joseph Samosky with inspiring me to try dropping // the "both left or both right" part of my code. if (yflag0 != yflag1) { // Check intersection of pgon segment with +X ray. // Note if >= point's X; if so, the ray hits it. // The division operation is avoided for the ">=" test by checking // the sign of the first vertex wrto the test point; idea inspired // by Joseph Samosky's and Mark Haigh-Hutchinson's different // polygon inclusion tests. if ( ((vty1-ty) * (vtx0-vtx1) >= (vtx1-tx) * (vty0-vty1)) == yflag1 ) { inside_flag ^= 1; } } // Move to the next pair of vertices, retaining info as possible. yflag0 = yflag1; vtx0 = vtx1; vty0 = vty1; unsigned k = (j >= m_num_points) ? j - m_num_points : j; vtx1 = xn(k); vty1 = yn(k); } return inside_flag != 0; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/ctrl/agg_bezier_ctrl.cpp0000644000175000017500000002605712516137326024744 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes bezier_ctrl_impl, bezier_ctrl // //---------------------------------------------------------------------------- #include #include #include "ctrl/agg_bezier_ctrl.h" namespace agg24 { //------------------------------------------------------------------------ bezier_ctrl_impl::bezier_ctrl_impl() : ctrl(0,0,1,1,false), m_stroke(m_curve), m_poly(4, 5.0), m_idx(0) { m_poly.in_polygon_check(false); m_poly.xn(0) = 100.0; m_poly.yn(0) = 0.0; m_poly.xn(1) = 100.0; m_poly.yn(1) = 50.0; m_poly.xn(2) = 50.0; m_poly.yn(2) = 100.0; m_poly.xn(3) = 0.0; m_poly.yn(3) = 100.0; } //------------------------------------------------------------------------ void bezier_ctrl_impl::curve(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { m_poly.xn(0) = x1; m_poly.yn(0) = y1; m_poly.xn(1) = x2; m_poly.yn(1) = y2; m_poly.xn(2) = x3; m_poly.yn(2) = y3; m_poly.xn(3) = x4; m_poly.yn(3) = y4; curve(); } //------------------------------------------------------------------------ curve4& bezier_ctrl_impl::curve() { m_curve.init(m_poly.xn(0), m_poly.yn(0), m_poly.xn(1), m_poly.yn(1), m_poly.xn(2), m_poly.yn(2), m_poly.xn(3), m_poly.yn(3)); return m_curve; } //------------------------------------------------------------------------ void bezier_ctrl_impl::rewind(unsigned idx) { m_idx = idx; m_curve.approximation_scale(scale()); switch(idx) { default: case 0: // Control line 1 m_curve.init(m_poly.xn(0), m_poly.yn(0), (m_poly.xn(0) + m_poly.xn(1)) * 0.5, (m_poly.yn(0) + m_poly.yn(1)) * 0.5, (m_poly.xn(0) + m_poly.xn(1)) * 0.5, (m_poly.yn(0) + m_poly.yn(1)) * 0.5, m_poly.xn(1), m_poly.yn(1)); m_stroke.rewind(0); break; case 1: // Control line 2 m_curve.init(m_poly.xn(2), m_poly.yn(2), (m_poly.xn(2) + m_poly.xn(3)) * 0.5, (m_poly.yn(2) + m_poly.yn(3)) * 0.5, (m_poly.xn(2) + m_poly.xn(3)) * 0.5, (m_poly.yn(2) + m_poly.yn(3)) * 0.5, m_poly.xn(3), m_poly.yn(3)); m_stroke.rewind(0); break; case 2: // Curve itself m_curve.init(m_poly.xn(0), m_poly.yn(0), m_poly.xn(1), m_poly.yn(1), m_poly.xn(2), m_poly.yn(2), m_poly.xn(3), m_poly.yn(3)); m_stroke.rewind(0); break; case 3: // Point 1 m_ellipse.init(m_poly.xn(0), m_poly.yn(0), point_radius(), point_radius(), 20); m_ellipse.rewind(0); break; case 4: // Point 2 m_ellipse.init(m_poly.xn(1), m_poly.yn(1), point_radius(), point_radius(), 20); m_ellipse.rewind(0); break; case 5: // Point 3 m_ellipse.init(m_poly.xn(2), m_poly.yn(2), point_radius(), point_radius(), 20); m_ellipse.rewind(0); break; case 6: // Point 4 m_ellipse.init(m_poly.xn(3), m_poly.yn(3), point_radius(), point_radius(), 20); m_ellipse.rewind(0); break; } } //------------------------------------------------------------------------ unsigned bezier_ctrl_impl::vertex(double* x, double* y) { unsigned cmd = path_cmd_stop; switch(m_idx) { case 0: case 1: case 2: cmd = m_stroke.vertex(x, y); break; case 3: case 4: case 5: case 6: case 7: cmd = m_ellipse.vertex(x, y); break; } if(!is_stop(cmd)) { transform_xy(x, y); } return cmd; } //------------------------------------------------------------------------ bool bezier_ctrl_impl::in_rect(double x, double y) const { return false; } //------------------------------------------------------------------------ bool bezier_ctrl_impl::on_mouse_button_down(double x, double y) { inverse_transform_xy(&x, &y); return m_poly.on_mouse_button_down(x, y); } //------------------------------------------------------------------------ bool bezier_ctrl_impl::on_mouse_move(double x, double y, bool button_flag) { inverse_transform_xy(&x, &y); return m_poly.on_mouse_move(x, y, button_flag); } //------------------------------------------------------------------------ bool bezier_ctrl_impl::on_mouse_button_up(double x, double y) { return m_poly.on_mouse_button_up(x, y); } //------------------------------------------------------------------------ bool bezier_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up) { return m_poly.on_arrow_keys(left, right, down, up); } //------------------------------------------------------------------------ curve3_ctrl_impl::curve3_ctrl_impl() : ctrl(0,0,1,1,false), m_stroke(m_curve), m_poly(3, 5.0), m_idx(0) { m_poly.in_polygon_check(false); m_poly.xn(0) = 100.0; m_poly.yn(0) = 0.0; m_poly.xn(1) = 100.0; m_poly.yn(1) = 50.0; m_poly.xn(2) = 50.0; m_poly.yn(2) = 100.0; } //------------------------------------------------------------------------ void curve3_ctrl_impl::curve(double x1, double y1, double x2, double y2, double x3, double y3) { m_poly.xn(0) = x1; m_poly.yn(0) = y1; m_poly.xn(1) = x2; m_poly.yn(1) = y2; m_poly.xn(2) = x3; m_poly.yn(2) = y3; curve(); } //------------------------------------------------------------------------ curve3& curve3_ctrl_impl::curve() { m_curve.init(m_poly.xn(0), m_poly.yn(0), m_poly.xn(1), m_poly.yn(1), m_poly.xn(2), m_poly.yn(2)); return m_curve; } //------------------------------------------------------------------------ void curve3_ctrl_impl::rewind(unsigned idx) { m_idx = idx; switch(idx) { default: case 0: // Control line m_curve.init(m_poly.xn(0), m_poly.yn(0), (m_poly.xn(0) + m_poly.xn(1)) * 0.5, (m_poly.yn(0) + m_poly.yn(1)) * 0.5, m_poly.xn(1), m_poly.yn(1)); m_stroke.rewind(0); break; case 1: // Control line 2 m_curve.init(m_poly.xn(1), m_poly.yn(1), (m_poly.xn(1) + m_poly.xn(2)) * 0.5, (m_poly.yn(1) + m_poly.yn(2)) * 0.5, m_poly.xn(2), m_poly.yn(2)); m_stroke.rewind(0); break; case 2: // Curve itself m_curve.init(m_poly.xn(0), m_poly.yn(0), m_poly.xn(1), m_poly.yn(1), m_poly.xn(2), m_poly.yn(2)); m_stroke.rewind(0); break; case 3: // Point 1 m_ellipse.init(m_poly.xn(0), m_poly.yn(0), point_radius(), point_radius(), 20); m_ellipse.rewind(0); break; case 4: // Point 2 m_ellipse.init(m_poly.xn(1), m_poly.yn(1), point_radius(), point_radius(), 20); m_ellipse.rewind(0); break; case 5: // Point 3 m_ellipse.init(m_poly.xn(2), m_poly.yn(2), point_radius(), point_radius(), 20); m_ellipse.rewind(0); break; } } //------------------------------------------------------------------------ unsigned curve3_ctrl_impl::vertex(double* x, double* y) { unsigned cmd = path_cmd_stop; switch(m_idx) { case 0: case 1: case 2: cmd = m_stroke.vertex(x, y); break; case 3: case 4: case 5: case 6: cmd = m_ellipse.vertex(x, y); break; } if(!is_stop(cmd)) { transform_xy(x, y); } return cmd; } //------------------------------------------------------------------------ bool curve3_ctrl_impl::in_rect(double x, double y) const { return false; } //------------------------------------------------------------------------ bool curve3_ctrl_impl::on_mouse_button_down(double x, double y) { inverse_transform_xy(&x, &y); return m_poly.on_mouse_button_down(x, y); } //------------------------------------------------------------------------ bool curve3_ctrl_impl::on_mouse_move(double x, double y, bool button_flag) { inverse_transform_xy(&x, &y); return m_poly.on_mouse_move(x, y, button_flag); } //------------------------------------------------------------------------ bool curve3_ctrl_impl::on_mouse_button_up(double x, double y) { return m_poly.on_mouse_button_up(x, y); } //------------------------------------------------------------------------ bool curve3_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up) { return m_poly.on_arrow_keys(left, right, down, up); } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/ctrl/Makefile.am0000644000175000017500000000061012516137326023135 0ustar varunvarunif ENABLE_CTRL INCLUDES = -I$(top_srcdir)/include noinst_LTLIBRARIES = libaggctrl.la libaggctrl_la_LDFLAGS = -no-undefined -version-info @AGG_LIB_VERSION@ libaggctrl_la_SOURCES = agg_cbox_ctrl.cpp agg_gamma_ctrl.cpp agg_gamma_spline.cpp agg_rbox_ctrl.cpp \ agg_slider_ctrl.cpp agg_spline_ctrl.cpp agg_scale_ctrl.cpp \ agg_bezier_ctrl.cpp agg_polygon_ctrl.cpp endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/ctrl/agg_spline_ctrl.cpp0000644000175000017500000002714012516137326024750 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes spline_ctrl_impl, spline_ctrl // //---------------------------------------------------------------------------- #include "ctrl/agg_spline_ctrl.h" namespace agg24 { //------------------------------------------------------------------------ spline_ctrl_impl::spline_ctrl_impl(double x1, double y1, double x2, double y2, unsigned num_pnt, bool flip_y) : ctrl(x1, y1, x2, y2, flip_y), m_num_pnt(num_pnt), m_border_width(1.0), m_border_extra(0.0), m_curve_width(1.0), m_point_size(3.0), m_curve_poly(m_curve_pnt), m_idx(0), m_vertex(0), m_active_pnt(-1), m_move_pnt(-1), m_pdx(0.0), m_pdy(0.0) { if(m_num_pnt < 4) m_num_pnt = 4; if(m_num_pnt > 32) m_num_pnt = 32; unsigned i; for(i = 0; i < m_num_pnt; i++) { m_xp[i] = double(i) / double(m_num_pnt - 1); m_yp[i] = 0.5; } calc_spline_box(); update_spline(); } //------------------------------------------------------------------------ void spline_ctrl_impl::border_width(double t, double extra) { m_border_width = t; m_border_extra = extra; calc_spline_box(); } //------------------------------------------------------------------------ void spline_ctrl_impl::calc_spline_box() { m_xs1 = m_x1 + m_border_width; m_ys1 = m_y1 + m_border_width; m_xs2 = m_x2 - m_border_width; m_ys2 = m_y2 - m_border_width; } //------------------------------------------------------------------------ void spline_ctrl_impl::update_spline() { int i; m_spline.init(m_num_pnt, m_xp, m_yp); for(i = 0; i < 256; i++) { m_spline_values[i] = m_spline.get(double(i) / 255.0); if(m_spline_values[i] < 0.0) m_spline_values[i] = 0.0; if(m_spline_values[i] > 1.0) m_spline_values[i] = 1.0; m_spline_values8[i] = (int8u)(m_spline_values[i] * 255.0); } } //------------------------------------------------------------------------ void spline_ctrl_impl::calc_curve() { int i; m_curve_pnt.remove_all(); m_curve_pnt.move_to(m_xs1, m_ys1 + (m_ys2 - m_ys1) * m_spline_values[0]); for(i = 1; i < 256; i++) { m_curve_pnt.line_to(m_xs1 + (m_xs2 - m_xs1) * double(i) / 255.0, m_ys1 + (m_ys2 - m_ys1) * m_spline_values[i]); } } //------------------------------------------------------------------------ double spline_ctrl_impl::calc_xp(unsigned idx) { return m_xs1 + (m_xs2 - m_xs1) * m_xp[idx]; } //------------------------------------------------------------------------ double spline_ctrl_impl::calc_yp(unsigned idx) { return m_ys1 + (m_ys2 - m_ys1) * m_yp[idx]; } //------------------------------------------------------------------------ void spline_ctrl_impl::set_xp(unsigned idx, double val) { if(val < 0.0) val = 0.0; if(val > 1.0) val = 1.0; if(idx == 0) { val = 0.0; } else if(idx == m_num_pnt - 1) { val = 1.0; } else { if(val < m_xp[idx - 1] + 0.001) val = m_xp[idx - 1] + 0.001; if(val > m_xp[idx + 1] - 0.001) val = m_xp[idx + 1] - 0.001; } m_xp[idx] = val; } //------------------------------------------------------------------------ void spline_ctrl_impl::set_yp(unsigned idx, double val) { if(val < 0.0) val = 0.0; if(val > 1.0) val = 1.0; m_yp[idx] = val; } //------------------------------------------------------------------------ void spline_ctrl_impl::point(unsigned idx, double x, double y) { if(idx < m_num_pnt) { set_xp(idx, x); set_yp(idx, y); } } //------------------------------------------------------------------------ void spline_ctrl_impl::value(unsigned idx, double y) { if(idx < m_num_pnt) { set_yp(idx, y); } } //------------------------------------------------------------------------ double spline_ctrl_impl::value(double x) const { x = m_spline.get(x); if(x < 0.0) x = 0.0; if(x > 1.0) x = 1.0; return x; } //------------------------------------------------------------------------ void spline_ctrl_impl::rewind(unsigned idx) { unsigned i; m_idx = idx; switch(idx) { default: case 0: // Background m_vertex = 0; m_vx[0] = m_x1 - m_border_extra; m_vy[0] = m_y1 - m_border_extra; m_vx[1] = m_x2 + m_border_extra; m_vy[1] = m_y1 - m_border_extra; m_vx[2] = m_x2 + m_border_extra; m_vy[2] = m_y2 + m_border_extra; m_vx[3] = m_x1 - m_border_extra; m_vy[3] = m_y2 + m_border_extra; break; case 1: // Border m_vertex = 0; m_vx[0] = m_x1; m_vy[0] = m_y1; m_vx[1] = m_x2; m_vy[1] = m_y1; m_vx[2] = m_x2; m_vy[2] = m_y2; m_vx[3] = m_x1; m_vy[3] = m_y2; m_vx[4] = m_x1 + m_border_width; m_vy[4] = m_y1 + m_border_width; m_vx[5] = m_x1 + m_border_width; m_vy[5] = m_y2 - m_border_width; m_vx[6] = m_x2 - m_border_width; m_vy[6] = m_y2 - m_border_width; m_vx[7] = m_x2 - m_border_width; m_vy[7] = m_y1 + m_border_width; break; case 2: // Curve calc_curve(); m_curve_poly.width(m_curve_width); m_curve_poly.rewind(0); break; case 3: // Inactive points m_curve_pnt.remove_all(); for(i = 0; i < m_num_pnt; i++) { if(int(i) != m_active_pnt) { m_ellipse.init(calc_xp(i), calc_yp(i), m_point_size, m_point_size, 32); m_curve_pnt.concat_path(m_ellipse); } } m_curve_poly.rewind(0); break; case 4: // Active point m_curve_pnt.remove_all(); if(m_active_pnt >= 0) { m_ellipse.init(calc_xp(m_active_pnt), calc_yp(m_active_pnt), m_point_size, m_point_size, 32); m_curve_pnt.concat_path(m_ellipse); } m_curve_poly.rewind(0); break; } } //------------------------------------------------------------------------ unsigned spline_ctrl_impl::vertex(double* x, double* y) { unsigned cmd = path_cmd_line_to; switch(m_idx) { case 0: if(m_vertex == 0) cmd = path_cmd_move_to; if(m_vertex >= 4) cmd = path_cmd_stop; *x = m_vx[m_vertex]; *y = m_vy[m_vertex]; m_vertex++; break; case 1: if(m_vertex == 0 || m_vertex == 4) cmd = path_cmd_move_to; if(m_vertex >= 8) cmd = path_cmd_stop; *x = m_vx[m_vertex]; *y = m_vy[m_vertex]; m_vertex++; break; case 2: cmd = m_curve_poly.vertex(x, y); break; case 3: case 4: cmd = m_curve_pnt.vertex(x, y); break; default: cmd = path_cmd_stop; break; } if(!is_stop(cmd)) { transform_xy(x, y); } return cmd; } //------------------------------------------------------------------------ void spline_ctrl_impl::active_point(int i) { m_active_pnt = i; } //------------------------------------------------------------------------ bool spline_ctrl_impl::in_rect(double x, double y) const { inverse_transform_xy(&x, &y); return x >= m_x1 && x <= m_x2 && y >= m_y1 && y <= m_y2; } //------------------------------------------------------------------------ bool spline_ctrl_impl::on_mouse_button_down(double x, double y) { inverse_transform_xy(&x, &y); unsigned i; for(i = 0; i < m_num_pnt; i++) { double xp = calc_xp(i); double yp = calc_yp(i); if(calc_distance(x, y, xp, yp) <= m_point_size + 1) { m_pdx = xp - x; m_pdy = yp - y; m_active_pnt = m_move_pnt = int(i); return true; } } return false; } //------------------------------------------------------------------------ bool spline_ctrl_impl::on_mouse_button_up(double, double) { if(m_move_pnt >= 0) { m_move_pnt = -1; return true; } return false; } //------------------------------------------------------------------------ bool spline_ctrl_impl::on_mouse_move(double x, double y, bool button_flag) { inverse_transform_xy(&x, &y); if(!button_flag) { return on_mouse_button_up(x, y); } if(m_move_pnt >= 0) { double xp = x + m_pdx; double yp = y + m_pdy; set_xp(m_move_pnt, (xp - m_xs1) / (m_xs2 - m_xs1)); set_yp(m_move_pnt, (yp - m_ys1) / (m_ys2 - m_ys1)); update_spline(); return true; } return false; } //------------------------------------------------------------------------ bool spline_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up) { double kx = 0.0; double ky = 0.0; bool ret = false; if(m_active_pnt >= 0) { kx = m_xp[m_active_pnt]; ky = m_yp[m_active_pnt]; if(left) { kx -= 0.001; ret = true; } if(right) { kx += 0.001; ret = true; } if(down) { ky -= 0.001; ret = true; } if(up) { ky += 0.001; ret = true; } } if(ret) { set_xp(m_active_pnt, kx); set_yp(m_active_pnt, ky); update_spline(); } return ret; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/ctrl/agg_slider_ctrl.cpp0000644000175000017500000002417312516137326024743 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes slider_ctrl_impl, slider_ctrl // //---------------------------------------------------------------------------- #include #include #include "ctrl/agg_slider_ctrl.h" namespace agg24 { //------------------------------------------------------------------------ slider_ctrl_impl::slider_ctrl_impl(double x1, double y1, double x2, double y2, bool flip_y) : ctrl(x1, y1, x2, y2, flip_y), m_border_width(1.0), m_border_extra((y2 - y1) / 2), m_text_thickness(1.0), m_pdx(0.0), m_mouse_move(false), m_value(0.5), m_preview_value(0.5), m_min(0.0), m_max(1.0), m_num_steps(0), m_descending(false), m_text_poly(m_text) { m_label[0] = 0; calc_box(); } //------------------------------------------------------------------------ void slider_ctrl_impl::calc_box() { m_xs1 = m_x1 + m_border_width; m_ys1 = m_y1 + m_border_width; m_xs2 = m_x2 - m_border_width; m_ys2 = m_y2 - m_border_width; } //------------------------------------------------------------------------ bool slider_ctrl_impl::normalize_value(bool preview_value_flag) { bool ret = true; if(m_num_steps) { int step = int(m_preview_value * m_num_steps + 0.5); ret = m_value != step / double(m_num_steps); m_value = step / double(m_num_steps); } else { m_value = m_preview_value; } if(preview_value_flag) { m_preview_value = m_value; } return ret; } //------------------------------------------------------------------------ void slider_ctrl_impl::border_width(double t, double extra) { m_border_width = t; m_border_extra = extra; calc_box(); } //------------------------------------------------------------------------ void slider_ctrl_impl::value(double value) { m_preview_value = (value - m_min) / (m_max - m_min); if(m_preview_value > 1.0) m_preview_value = 1.0; if(m_preview_value < 0.0) m_preview_value = 0.0; normalize_value(true); } //------------------------------------------------------------------------ void slider_ctrl_impl::label(const char* fmt) { m_label[0] = 0; if(fmt) { unsigned len = strlen(fmt); if(len > 63) len = 63; memcpy(m_label, fmt, len); m_label[len] = 0; } } //------------------------------------------------------------------------ void slider_ctrl_impl::rewind(unsigned idx) { m_idx = idx; switch(idx) { default: case 0: // Background m_vertex = 0; m_vx[0] = m_x1 - m_border_extra; m_vy[0] = m_y1 - m_border_extra; m_vx[1] = m_x2 + m_border_extra; m_vy[1] = m_y1 - m_border_extra; m_vx[2] = m_x2 + m_border_extra; m_vy[2] = m_y2 + m_border_extra; m_vx[3] = m_x1 - m_border_extra; m_vy[3] = m_y2 + m_border_extra; break; case 1: // Triangle m_vertex = 0; if(m_descending) { m_vx[0] = m_x1; m_vy[0] = m_y1; m_vx[1] = m_x2; m_vy[1] = m_y1; m_vx[2] = m_x1; m_vy[2] = m_y2; m_vx[3] = m_x1; m_vy[3] = m_y1; } else { m_vx[0] = m_x1; m_vy[0] = m_y1; m_vx[1] = m_x2; m_vy[1] = m_y1; m_vx[2] = m_x2; m_vy[2] = m_y2; m_vx[3] = m_x1; m_vy[3] = m_y1; } break; case 2: m_text.text(m_label); if(m_label[0]) { char buf[256]; sprintf(buf, m_label, value()); m_text.text(buf); } m_text.start_point(m_x1, m_y1); m_text.size((m_y2 - m_y1) * 1.2, m_y2 - m_y1); m_text_poly.width(m_text_thickness); m_text_poly.line_join(round_join); m_text_poly.line_cap(round_cap); m_text_poly.rewind(0); break; case 3: // pointer preview m_ellipse.init(m_xs1 + (m_xs2 - m_xs1) * m_preview_value, (m_ys1 + m_ys2) / 2.0, m_y2 - m_y1, m_y2 - m_y1, 32); break; case 4: // pointer normalize_value(false); m_ellipse.init(m_xs1 + (m_xs2 - m_xs1) * m_value, (m_ys1 + m_ys2) / 2.0, m_y2 - m_y1, m_y2 - m_y1, 32); m_ellipse.rewind(0); break; case 5: m_storage.remove_all(); if(m_num_steps) { unsigned i; double d = (m_xs2 - m_xs1) / m_num_steps; if(d > 0.004) d = 0.004; for(i = 0; i < m_num_steps + 1; i++) { double x = m_xs1 + (m_xs2 - m_xs1) * i / m_num_steps; m_storage.move_to(x, m_y1); m_storage.line_to(x - d * (m_x2 - m_x1), m_y1 - m_border_extra); m_storage.line_to(x + d * (m_x2 - m_x1), m_y1 - m_border_extra); } } } } //------------------------------------------------------------------------ unsigned slider_ctrl_impl::vertex(double* x, double* y) { unsigned cmd = path_cmd_line_to; switch(m_idx) { case 0: if(m_vertex == 0) cmd = path_cmd_move_to; if(m_vertex >= 4) cmd = path_cmd_stop; *x = m_vx[m_vertex]; *y = m_vy[m_vertex]; m_vertex++; break; case 1: if(m_vertex == 0) cmd = path_cmd_move_to; if(m_vertex >= 4) cmd = path_cmd_stop; *x = m_vx[m_vertex]; *y = m_vy[m_vertex]; m_vertex++; break; case 2: cmd = m_text_poly.vertex(x, y); break; case 3: case 4: cmd = m_ellipse.vertex(x, y); break; case 5: cmd = m_storage.vertex(x, y); break; default: cmd = path_cmd_stop; break; } if(!is_stop(cmd)) { transform_xy(x, y); } return cmd; } //------------------------------------------------------------------------ bool slider_ctrl_impl::in_rect(double x, double y) const { inverse_transform_xy(&x, &y); return x >= m_x1 && x <= m_x2 && y >= m_y1 && y <= m_y2; } //------------------------------------------------------------------------ bool slider_ctrl_impl::on_mouse_button_down(double x, double y) { inverse_transform_xy(&x, &y); double xp = m_xs1 + (m_xs2 - m_xs1) * m_value; double yp = (m_ys1 + m_ys2) / 2.0; if(calc_distance(x, y, xp, yp) <= m_y2 - m_y1) { m_pdx = xp - x; m_mouse_move = true; return true; } return false; } //------------------------------------------------------------------------ bool slider_ctrl_impl::on_mouse_move(double x, double y, bool button_flag) { inverse_transform_xy(&x, &y); if(!button_flag) { on_mouse_button_up(x, y); return false; } if(m_mouse_move) { double xp = x + m_pdx; m_preview_value = (xp - m_xs1) / (m_xs2 - m_xs1); if(m_preview_value < 0.0) m_preview_value = 0.0; if(m_preview_value > 1.0) m_preview_value = 1.0; return true; } return false; } //------------------------------------------------------------------------ bool slider_ctrl_impl::on_mouse_button_up(double, double) { m_mouse_move = false; normalize_value(true); return true; } //------------------------------------------------------------------------ bool slider_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up) { double d = 0.005; if(m_num_steps) { d = 1.0 / m_num_steps; } if(right || up) { m_preview_value += d; if(m_preview_value > 1.0) m_preview_value = 1.0; normalize_value(true); return true; } if(left || down) { m_preview_value -= d; if(m_preview_value < 0.0) m_preview_value = 0.0; normalize_value(true); return true; } return false; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/ctrl/agg_scale_ctrl.cpp0000644000175000017500000003333612516137326024551 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes scale_ctrl_impl, scale_ctrl // //---------------------------------------------------------------------------- #include "ctrl/agg_scale_ctrl.h" namespace agg24 { //------------------------------------------------------------------------ scale_ctrl_impl::scale_ctrl_impl(double x1, double y1, double x2, double y2, bool flip_y) : ctrl(x1, y1, x2, y2, flip_y), m_border_thickness(1.0), m_border_extra((fabs(x2 - x1) > fabs(y2 - y1)) ? (y2 - y1) / 2 : (x2 - x1) / 2), m_pdx(0.0), m_pdy(0.0), m_move_what(move_nothing), m_value1(0.3), m_value2(0.7), m_min_d(0.01) { calc_box(); } //------------------------------------------------------------------------ void scale_ctrl_impl::calc_box() { m_xs1 = m_x1 + m_border_thickness; m_ys1 = m_y1 + m_border_thickness; m_xs2 = m_x2 - m_border_thickness; m_ys2 = m_y2 - m_border_thickness; } //------------------------------------------------------------------------ void scale_ctrl_impl::border_thickness(double t, double extra) { m_border_thickness = t; m_border_extra = extra; calc_box(); } //------------------------------------------------------------------------ void scale_ctrl_impl::resize(double x1, double y1, double x2, double y2) { m_x1 = x1; m_y1 = y1; m_x2 = x2; m_y2 = y2; calc_box(); m_border_extra = (fabs(x2 - x1) > fabs(y2 - y1)) ? (y2 - y1) / 2 : (x2 - x1) / 2; } //------------------------------------------------------------------------ void scale_ctrl_impl::value1(double value) { if(value < 0.0) value = 0.0; if(value > 1.0) value = 1.0; if(m_value2 - value < m_min_d) value = m_value2 - m_min_d; m_value1 = value; } //------------------------------------------------------------------------ void scale_ctrl_impl::value2(double value) { if(value < 0.0) value = 0.0; if(value > 1.0) value = 1.0; if(m_value1 + value < m_min_d) value = m_value1 + m_min_d; m_value2 = value; } //------------------------------------------------------------------------ void scale_ctrl_impl::move(double d) { m_value1 += d; m_value2 += d; if(m_value1 < 0.0) { m_value2 -= m_value1; m_value1 = 0.0; } if(m_value2 > 1.0) { m_value1 -= m_value2 - 1.0; m_value2 = 1.0; } } //------------------------------------------------------------------------ void scale_ctrl_impl::rewind(unsigned idx) { m_idx = idx; switch(idx) { default: case 0: // Background m_vertex = 0; m_vx[0] = m_x1 - m_border_extra; m_vy[0] = m_y1 - m_border_extra; m_vx[1] = m_x2 + m_border_extra; m_vy[1] = m_y1 - m_border_extra; m_vx[2] = m_x2 + m_border_extra; m_vy[2] = m_y2 + m_border_extra; m_vx[3] = m_x1 - m_border_extra; m_vy[3] = m_y2 + m_border_extra; break; case 1: // Border m_vertex = 0; m_vx[0] = m_x1; m_vy[0] = m_y1; m_vx[1] = m_x2; m_vy[1] = m_y1; m_vx[2] = m_x2; m_vy[2] = m_y2; m_vx[3] = m_x1; m_vy[3] = m_y2; m_vx[4] = m_x1 + m_border_thickness; m_vy[4] = m_y1 + m_border_thickness; m_vx[5] = m_x1 + m_border_thickness; m_vy[5] = m_y2 - m_border_thickness; m_vx[6] = m_x2 - m_border_thickness; m_vy[6] = m_y2 - m_border_thickness; m_vx[7] = m_x2 - m_border_thickness; m_vy[7] = m_y1 + m_border_thickness; break; case 2: // pointer1 if(fabs(m_x2 - m_x1) > fabs(m_y2 - m_y1)) { m_ellipse.init(m_xs1 + (m_xs2 - m_xs1) * m_value1, (m_ys1 + m_ys2) / 2.0, m_y2 - m_y1, m_y2 - m_y1, 32); } else { m_ellipse.init((m_xs1 + m_xs2) / 2.0, m_ys1 + (m_ys2 - m_ys1) * m_value1, m_x2 - m_x1, m_x2 - m_x1, 32); } m_ellipse.rewind(0); break; case 3: // pointer2 if(fabs(m_x2 - m_x1) > fabs(m_y2 - m_y1)) { m_ellipse.init(m_xs1 + (m_xs2 - m_xs1) * m_value2, (m_ys1 + m_ys2) / 2.0, m_y2 - m_y1, m_y2 - m_y1, 32); } else { m_ellipse.init((m_xs1 + m_xs2) / 2.0, m_ys1 + (m_ys2 - m_ys1) * m_value2, m_x2 - m_x1, m_x2 - m_x1, 32); } m_ellipse.rewind(0); break; case 4: // slider m_vertex = 0; if(fabs(m_x2 - m_x1) > fabs(m_y2 - m_y1)) { m_vx[0] = m_xs1 + (m_xs2 - m_xs1) * m_value1; m_vy[0] = m_y1 - m_border_extra / 2.0; m_vx[1] = m_xs1 + (m_xs2 - m_xs1) * m_value2; m_vy[1] = m_vy[0]; m_vx[2] = m_vx[1]; m_vy[2] = m_y2 + m_border_extra / 2.0; m_vx[3] = m_vx[0]; m_vy[3] = m_vy[2]; } else { m_vx[0] = m_x1 - m_border_extra / 2.0; m_vy[0] = m_ys1 + (m_ys2 - m_ys1) * m_value1; m_vx[1] = m_vx[0]; m_vy[1] = m_ys1 + (m_ys2 - m_ys1) * m_value2; m_vx[2] = m_x2 + m_border_extra / 2.0; m_vy[2] = m_vy[1]; m_vx[3] = m_vx[2]; m_vy[3] = m_vy[0]; } break; } } //------------------------------------------------------------------------ unsigned scale_ctrl_impl::vertex(double* x, double* y) { unsigned cmd = path_cmd_line_to; switch(m_idx) { case 0: case 4: if(m_vertex == 0) cmd = path_cmd_move_to; if(m_vertex >= 4) cmd = path_cmd_stop; *x = m_vx[m_vertex]; *y = m_vy[m_vertex]; m_vertex++; break; case 1: if(m_vertex == 0 || m_vertex == 4) cmd = path_cmd_move_to; if(m_vertex >= 8) cmd = path_cmd_stop; *x = m_vx[m_vertex]; *y = m_vy[m_vertex]; m_vertex++; break; case 2: case 3: cmd = m_ellipse.vertex(x, y); break; default: cmd = path_cmd_stop; break; } if(!is_stop(cmd)) { transform_xy(x, y); } return cmd; } //------------------------------------------------------------------------ bool scale_ctrl_impl::in_rect(double x, double y) const { inverse_transform_xy(&x, &y); return x >= m_x1 && x <= m_x2 && y >= m_y1 && y <= m_y2; } //------------------------------------------------------------------------ bool scale_ctrl_impl::on_mouse_button_down(double x, double y) { inverse_transform_xy(&x, &y); double xp1; double xp2; double ys1; double ys2; double xp; double yp; if(fabs(m_x2 - m_x1) > fabs(m_y2 - m_y1)) { xp1 = m_xs1 + (m_xs2 - m_xs1) * m_value1; xp2 = m_xs1 + (m_xs2 - m_xs1) * m_value2; ys1 = m_y1 - m_border_extra / 2.0; ys2 = m_y2 + m_border_extra / 2.0; yp = (m_ys1 + m_ys2) / 2.0; if(x > xp1 && y > ys1 && x < xp2 && y < ys2) { m_pdx = xp1 - x; m_move_what = move_slider; return true; } //if(x < xp1 && calc_distance(x, y, xp1, yp) <= m_y2 - m_y1) if(calc_distance(x, y, xp1, yp) <= m_y2 - m_y1) { m_pdx = xp1 - x; m_move_what = move_value1; return true; } //if(x > xp2 && calc_distance(x, y, xp2, yp) <= m_y2 - m_y1) if(calc_distance(x, y, xp2, yp) <= m_y2 - m_y1) { m_pdx = xp2 - x; m_move_what = move_value2; return true; } } else { xp1 = m_x1 - m_border_extra / 2.0; xp2 = m_x2 + m_border_extra / 2.0; ys1 = m_ys1 + (m_ys2 - m_ys1) * m_value1; ys2 = m_ys1 + (m_ys2 - m_ys1) * m_value2; xp = (m_xs1 + m_xs2) / 2.0; if(x > xp1 && y > ys1 && x < xp2 && y < ys2) { m_pdy = ys1 - y; m_move_what = move_slider; return true; } //if(y < ys1 && calc_distance(x, y, xp, ys1) <= m_x2 - m_x1) if(calc_distance(x, y, xp, ys1) <= m_x2 - m_x1) { m_pdy = ys1 - y; m_move_what = move_value1; return true; } //if(y > ys2 && calc_distance(x, y, xp, ys2) <= m_x2 - m_x1) if(calc_distance(x, y, xp, ys2) <= m_x2 - m_x1) { m_pdy = ys2 - y; m_move_what = move_value2; return true; } } return false; } //------------------------------------------------------------------------ bool scale_ctrl_impl::on_mouse_move(double x, double y, bool button_flag) { inverse_transform_xy(&x, &y); if(!button_flag) { return on_mouse_button_up(x, y); } double xp = x + m_pdx; double yp = y + m_pdy; double dv; switch(m_move_what) { case move_value1: if(fabs(m_x2 - m_x1) > fabs(m_y2 - m_y1)) { m_value1 = (xp - m_xs1) / (m_xs2 - m_xs1); } else { m_value1 = (yp - m_ys1) / (m_ys2 - m_ys1); } if(m_value1 < 0.0) m_value1 = 0.0; if(m_value1 > m_value2 - m_min_d) m_value1 = m_value2 - m_min_d; return true; case move_value2: if(fabs(m_x2 - m_x1) > fabs(m_y2 - m_y1)) { m_value2 = (xp - m_xs1) / (m_xs2 - m_xs1); } else { m_value2 = (yp - m_ys1) / (m_ys2 - m_ys1); } if(m_value2 > 1.0) m_value2 = 1.0; if(m_value2 < m_value1 + m_min_d) m_value2 = m_value1 + m_min_d; return true; case move_slider: dv = m_value2 - m_value1; if(fabs(m_x2 - m_x1) > fabs(m_y2 - m_y1)) { m_value1 = (xp - m_xs1) / (m_xs2 - m_xs1); } else { m_value1 = (yp - m_ys1) / (m_ys2 - m_ys1); } m_value2 = m_value1 + dv; if(m_value1 < 0.0) { dv = m_value2 - m_value1; m_value1 = 0.0; m_value2 = m_value1 + dv; } if(m_value2 > 1.0) { dv = m_value2 - m_value1; m_value2 = 1.0; m_value1 = m_value2 - dv; } return true; } return false; } //------------------------------------------------------------------------ bool scale_ctrl_impl::on_mouse_button_up(double, double) { m_move_what = move_nothing; return false; } //------------------------------------------------------------------------ bool scale_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up) { /* if(right || up) { m_value += 0.005; if(m_value > 1.0) m_value = 1.0; return true; } if(left || down) { m_value -= 0.005; if(m_value < 0.0) m_value = 0.0; return true; } */ return false; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/ctrl/agg_gamma_ctrl.cpp0000644000175000017500000003332412516137326024541 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class gamma_ctrl_impl // //---------------------------------------------------------------------------- #include #include "agg_math.h" #include "ctrl/agg_gamma_ctrl.h" namespace agg24 { //------------------------------------------------------------------------ gamma_ctrl_impl::gamma_ctrl_impl(double x1, double y1, double x2, double y2, bool flip_y) : ctrl(x1, y1, x2, y2, flip_y), m_border_width(2.0), m_border_extra(0.0), m_curve_width(2.0), m_grid_width(0.2), m_text_thickness(1.5), m_point_size(5.0), m_text_height(9.0), m_text_width(0.0), m_xc1(x1), m_yc1(y1), m_xc2(x2), m_yc2(y2 - m_text_height * 2.0), m_xt1(x1), m_yt1(y2 - m_text_height * 2.0), m_xt2(x2), m_yt2(y2), m_curve_poly(m_gamma_spline), m_text_poly(m_text), m_idx(0), m_vertex(0), m_p1_active(true), m_mouse_point(0), m_pdx(0.0), m_pdy(0.0) { calc_spline_box(); } //------------------------------------------------------------------------ void gamma_ctrl_impl::calc_spline_box() { m_xs1 = m_xc1 + m_border_width; m_ys1 = m_yc1 + m_border_width; m_xs2 = m_xc2 - m_border_width; m_ys2 = m_yc2 - m_border_width * 0.5; } //------------------------------------------------------------------------ void gamma_ctrl_impl::calc_points() { double kx1, ky1, kx2, ky2; m_gamma_spline.values(&kx1, &ky1, &kx2, &ky2); m_xp1 = m_xs1 + (m_xs2 - m_xs1) * kx1 * 0.25; m_yp1 = m_ys1 + (m_ys2 - m_ys1) * ky1 * 0.25; m_xp2 = m_xs2 - (m_xs2 - m_xs1) * kx2 * 0.25; m_yp2 = m_ys2 - (m_ys2 - m_ys1) * ky2 * 0.25; } //------------------------------------------------------------------------ void gamma_ctrl_impl::calc_values() { double kx1, ky1, kx2, ky2; kx1 = (m_xp1 - m_xs1) * 4.0 / (m_xs2 - m_xs1); ky1 = (m_yp1 - m_ys1) * 4.0 / (m_ys2 - m_ys1); kx2 = (m_xs2 - m_xp2) * 4.0 / (m_xs2 - m_xs1); ky2 = (m_ys2 - m_yp2) * 4.0 / (m_ys2 - m_ys1); m_gamma_spline.values(kx1, ky1, kx2, ky2); } //------------------------------------------------------------------------ void gamma_ctrl_impl::text_size(double h, double w) { m_text_width = w; m_text_height = h; m_yc2 = m_y2 - m_text_height * 2.0; m_yt1 = m_y2 - m_text_height * 2.0; calc_spline_box(); } //------------------------------------------------------------------------ void gamma_ctrl_impl::border_width(double t, double extra) { m_border_width = t; m_border_extra = extra; calc_spline_box(); } //------------------------------------------------------------------------ void gamma_ctrl_impl::values(double kx1, double ky1, double kx2, double ky2) { m_gamma_spline.values(kx1, ky1, kx2, ky2); } //------------------------------------------------------------------------ void gamma_ctrl_impl::values(double* kx1, double* ky1, double* kx2, double* ky2) const { m_gamma_spline.values(kx1, ky1, kx2, ky2); } //------------------------------------------------------------------------ void gamma_ctrl_impl::rewind(unsigned idx) { double kx1, ky1, kx2, ky2; char tbuf[32]; m_idx = idx; switch(idx) { default: case 0: // Background m_vertex = 0; m_vx[0] = m_x1 - m_border_extra; m_vy[0] = m_y1 - m_border_extra; m_vx[1] = m_x2 + m_border_extra; m_vy[1] = m_y1 - m_border_extra; m_vx[2] = m_x2 + m_border_extra; m_vy[2] = m_y2 + m_border_extra; m_vx[3] = m_x1 - m_border_extra; m_vy[3] = m_y2 + m_border_extra; break; case 1: // Border m_vertex = 0; m_vx[0] = m_x1; m_vy[0] = m_y1; m_vx[1] = m_x2; m_vy[1] = m_y1; m_vx[2] = m_x2; m_vy[2] = m_y2; m_vx[3] = m_x1; m_vy[3] = m_y2; m_vx[4] = m_x1 + m_border_width; m_vy[4] = m_y1 + m_border_width; m_vx[5] = m_x1 + m_border_width; m_vy[5] = m_y2 - m_border_width; m_vx[6] = m_x2 - m_border_width; m_vy[6] = m_y2 - m_border_width; m_vx[7] = m_x2 - m_border_width; m_vy[7] = m_y1 + m_border_width; m_vx[8] = m_xc1 + m_border_width; m_vy[8] = m_yc2 - m_border_width * 0.5; m_vx[9] = m_xc2 - m_border_width; m_vy[9] = m_yc2 - m_border_width * 0.5; m_vx[10] = m_xc2 - m_border_width; m_vy[10] = m_yc2 + m_border_width * 0.5; m_vx[11] = m_xc1 + m_border_width; m_vy[11] = m_yc2 + m_border_width * 0.5; break; case 2: // Curve m_gamma_spline.box(m_xs1, m_ys1, m_xs2, m_ys2); m_curve_poly.width(m_curve_width); m_curve_poly.rewind(0); break; case 3: // Grid m_vertex = 0; m_vx[0] = m_xs1; m_vy[0] = (m_ys1 + m_ys2) * 0.5 - m_grid_width * 0.5; m_vx[1] = m_xs2; m_vy[1] = (m_ys1 + m_ys2) * 0.5 - m_grid_width * 0.5; m_vx[2] = m_xs2; m_vy[2] = (m_ys1 + m_ys2) * 0.5 + m_grid_width * 0.5; m_vx[3] = m_xs1; m_vy[3] = (m_ys1 + m_ys2) * 0.5 + m_grid_width * 0.5; m_vx[4] = (m_xs1 + m_xs2) * 0.5 - m_grid_width * 0.5; m_vy[4] = m_ys1; m_vx[5] = (m_xs1 + m_xs2) * 0.5 - m_grid_width * 0.5; m_vy[5] = m_ys2; m_vx[6] = (m_xs1 + m_xs2) * 0.5 + m_grid_width * 0.5; m_vy[6] = m_ys2; m_vx[7] = (m_xs1 + m_xs2) * 0.5 + m_grid_width * 0.5; m_vy[7] = m_ys1; calc_points(); m_vx[8] = m_xs1; m_vy[8] = m_yp1 - m_grid_width * 0.5; m_vx[9] = m_xp1 - m_grid_width * 0.5; m_vy[9] = m_yp1 - m_grid_width * 0.5; m_vx[10] = m_xp1 - m_grid_width * 0.5; m_vy[10] = m_ys1; m_vx[11] = m_xp1 + m_grid_width * 0.5; m_vy[11] = m_ys1; m_vx[12] = m_xp1 + m_grid_width * 0.5; m_vy[12] = m_yp1 + m_grid_width * 0.5; m_vx[13] = m_xs1; m_vy[13] = m_yp1 + m_grid_width * 0.5; m_vx[14] = m_xs2; m_vy[14] = m_yp2 + m_grid_width * 0.5; m_vx[15] = m_xp2 + m_grid_width * 0.5; m_vy[15] = m_yp2 + m_grid_width * 0.5; m_vx[16] = m_xp2 + m_grid_width * 0.5; m_vy[16] = m_ys2; m_vx[17] = m_xp2 - m_grid_width * 0.5; m_vy[17] = m_ys2; m_vx[18] = m_xp2 - m_grid_width * 0.5; m_vy[18] = m_yp2 - m_grid_width * 0.5; m_vx[19] = m_xs2; m_vy[19] = m_yp2 - m_grid_width * 0.5; break; case 4: // Point1 calc_points(); if(m_p1_active) m_ellipse.init(m_xp2, m_yp2, m_point_size, m_point_size, 32); else m_ellipse.init(m_xp1, m_yp1, m_point_size, m_point_size, 32); break; case 5: // Point2 calc_points(); if(m_p1_active) m_ellipse.init(m_xp1, m_yp1, m_point_size, m_point_size, 32); else m_ellipse.init(m_xp2, m_yp2, m_point_size, m_point_size, 32); break; case 6: // Text m_gamma_spline.values(&kx1, &ky1, &kx2, &ky2); sprintf(tbuf, "%5.3f %5.3f %5.3f %5.3f", kx1, ky1, kx2, ky2); m_text.text(tbuf); m_text.size(m_text_height, m_text_width); m_text.start_point(m_xt1 + m_border_width * 2.0, (m_yt1 + m_yt2) * 0.5 - m_text_height * 0.5); m_text_poly.width(m_text_thickness); m_text_poly.line_join(round_join); m_text_poly.line_cap(round_cap); m_text_poly.rewind(0); break; } } //------------------------------------------------------------------------ unsigned gamma_ctrl_impl::vertex(double* x, double* y) { unsigned cmd = path_cmd_line_to; switch(m_idx) { case 0: if(m_vertex == 0) cmd = path_cmd_move_to; if(m_vertex >= 4) cmd = path_cmd_stop; *x = m_vx[m_vertex]; *y = m_vy[m_vertex]; m_vertex++; break; case 1: if(m_vertex == 0 || m_vertex == 4 || m_vertex == 8) cmd = path_cmd_move_to; if(m_vertex >= 12) cmd = path_cmd_stop; *x = m_vx[m_vertex]; *y = m_vy[m_vertex]; m_vertex++; break; case 2: cmd = m_curve_poly.vertex(x, y); break; case 3: if(m_vertex == 0 || m_vertex == 4 || m_vertex == 8 || m_vertex == 14) cmd = path_cmd_move_to; if(m_vertex >= 20) cmd = path_cmd_stop; *x = m_vx[m_vertex]; *y = m_vy[m_vertex]; m_vertex++; break; case 4: // Point1 case 5: // Point2 cmd = m_ellipse.vertex(x, y); break; case 6: cmd = m_text_poly.vertex(x, y); break; default: cmd = path_cmd_stop; break; } if(!is_stop(cmd)) { transform_xy(x, y); } return cmd; } //------------------------------------------------------------------------ bool gamma_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up) { double kx1, ky1, kx2, ky2; bool ret = false; m_gamma_spline.values(&kx1, &ky1, &kx2, &ky2); if(m_p1_active) { if(left) { kx1 -= 0.005; ret = true; } if(right) { kx1 += 0.005; ret = true; } if(down) { ky1 -= 0.005; ret = true; } if(up) { ky1 += 0.005; ret = true; } } else { if(left) { kx2 += 0.005; ret = true; } if(right) { kx2 -= 0.005; ret = true; } if(down) { ky2 += 0.005; ret = true; } if(up) { ky2 -= 0.005; ret = true; } } if(ret) { m_gamma_spline.values(kx1, ky1, kx2, ky2); } return ret; } //------------------------------------------------------------------------ void gamma_ctrl_impl::change_active_point() { m_p1_active = m_p1_active ? false : true; } //------------------------------------------------------------------------ bool gamma_ctrl_impl::in_rect(double x, double y) const { inverse_transform_xy(&x, &y); return x >= m_x1 && x <= m_x2 && y >= m_y1 && y <= m_y2; } //------------------------------------------------------------------------ bool gamma_ctrl_impl::on_mouse_button_down(double x, double y) { inverse_transform_xy(&x, &y); calc_points(); if(calc_distance(x, y, m_xp1, m_yp1) <= m_point_size + 1) { m_mouse_point = 1; m_pdx = m_xp1 - x; m_pdy = m_yp1 - y; m_p1_active = true; return true; } if(calc_distance(x, y, m_xp2, m_yp2) <= m_point_size + 1) { m_mouse_point = 2; m_pdx = m_xp2 - x; m_pdy = m_yp2 - y; m_p1_active = false; return true; } return false; } //------------------------------------------------------------------------ bool gamma_ctrl_impl::on_mouse_button_up(double, double) { if(m_mouse_point) { m_mouse_point = 0; return true; } return false; } //------------------------------------------------------------------------ bool gamma_ctrl_impl::on_mouse_move(double x, double y, bool button_flag) { inverse_transform_xy(&x, &y); if(!button_flag) { return on_mouse_button_up(x, y); } if(m_mouse_point == 1) { m_xp1 = x + m_pdx; m_yp1 = y + m_pdy; calc_values(); return true; } if(m_mouse_point == 2) { m_xp2 = x + m_pdx; m_yp2 = y + m_pdy; calc_values(); return true; } return false; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/ctrl/agg_rbox_ctrl.cpp0000644000175000017500000002310112516137326024421 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // classes rbox_ctrl_impl, rbox_ctrl // //---------------------------------------------------------------------------- #include #include "ctrl/agg_rbox_ctrl.h" namespace agg24 { //------------------------------------------------------------------------ rbox_ctrl_impl::rbox_ctrl_impl(double x1, double y1, double x2, double y2, bool flip_y) : ctrl(x1, y1, x2, y2, flip_y), m_border_width(1.0), m_border_extra(0.0), m_text_thickness(1.5), m_text_height(9.0), m_text_width(0.0), m_num_items(0), m_cur_item(-1), m_ellipse_poly(m_ellipse), m_text_poly(m_text), m_idx(0), m_vertex(0) { calc_rbox(); } //------------------------------------------------------------------------ void rbox_ctrl_impl::calc_rbox() { m_xs1 = m_x1 + m_border_width; m_ys1 = m_y1 + m_border_width; m_xs2 = m_x2 - m_border_width; m_ys2 = m_y2 - m_border_width; } //------------------------------------------------------------------------ void rbox_ctrl_impl::add_item(const char* text) { if(m_num_items < 32) { m_items[m_num_items].resize(strlen(text) + 1); strcpy(&m_items[m_num_items][0], text); m_num_items++; } } //------------------------------------------------------------------------ void rbox_ctrl_impl::border_width(double t, double extra) { m_border_width = t; m_border_extra = extra; calc_rbox(); } //------------------------------------------------------------------------ void rbox_ctrl_impl::text_size(double h, double w) { m_text_width = w; m_text_height = h; } //------------------------------------------------------------------------ void rbox_ctrl_impl::rewind(unsigned idx) { m_idx = idx; m_dy = m_text_height * 2.0; m_draw_item = 0; switch(idx) { default: case 0: // Background m_vertex = 0; m_vx[0] = m_x1 - m_border_extra; m_vy[0] = m_y1 - m_border_extra; m_vx[1] = m_x2 + m_border_extra; m_vy[1] = m_y1 - m_border_extra; m_vx[2] = m_x2 + m_border_extra; m_vy[2] = m_y2 + m_border_extra; m_vx[3] = m_x1 - m_border_extra; m_vy[3] = m_y2 + m_border_extra; break; case 1: // Border m_vertex = 0; m_vx[0] = m_x1; m_vy[0] = m_y1; m_vx[1] = m_x2; m_vy[1] = m_y1; m_vx[2] = m_x2; m_vy[2] = m_y2; m_vx[3] = m_x1; m_vy[3] = m_y2; m_vx[4] = m_x1 + m_border_width; m_vy[4] = m_y1 + m_border_width; m_vx[5] = m_x1 + m_border_width; m_vy[5] = m_y2 - m_border_width; m_vx[6] = m_x2 - m_border_width; m_vy[6] = m_y2 - m_border_width; m_vx[7] = m_x2 - m_border_width; m_vy[7] = m_y1 + m_border_width; break; case 2: // Text m_text.text(&m_items[0][0]); m_text.start_point(m_xs1 + m_dy * 1.5, m_ys1 + m_dy / 2.0); m_text.size(m_text_height, m_text_width); m_text_poly.width(m_text_thickness); m_text_poly.line_join(round_join); m_text_poly.line_cap(round_cap); m_text_poly.rewind(0); break; case 3: // Inactive items m_ellipse.init(m_xs1 + m_dy / 1.3, m_ys1 + m_dy / 1.3, m_text_height / 1.5, m_text_height / 1.5, 32); m_ellipse_poly.width(m_text_thickness); m_ellipse_poly.rewind(0); break; case 4: // Active Item if(m_cur_item >= 0) { m_ellipse.init(m_xs1 + m_dy / 1.3, m_ys1 + m_dy * m_cur_item + m_dy / 1.3, m_text_height / 2.0, m_text_height / 2.0, 32); m_ellipse.rewind(0); } break; } } //------------------------------------------------------------------------ unsigned rbox_ctrl_impl::vertex(double* x, double* y) { unsigned cmd = path_cmd_line_to; switch(m_idx) { case 0: if(m_vertex == 0) cmd = path_cmd_move_to; if(m_vertex >= 4) cmd = path_cmd_stop; *x = m_vx[m_vertex]; *y = m_vy[m_vertex]; m_vertex++; break; case 1: if(m_vertex == 0 || m_vertex == 4) cmd = path_cmd_move_to; if(m_vertex >= 8) cmd = path_cmd_stop; *x = m_vx[m_vertex]; *y = m_vy[m_vertex]; m_vertex++; break; case 2: cmd = m_text_poly.vertex(x, y); if(is_stop(cmd)) { m_draw_item++; if(m_draw_item >= m_num_items) { break; } else { m_text.text(&m_items[m_draw_item][0]); m_text.start_point(m_xs1 + m_dy * 1.5, m_ys1 + m_dy * (m_draw_item + 1) - m_dy / 2.0); m_text_poly.rewind(0); cmd = m_text_poly.vertex(x, y); } } break; case 3: cmd = m_ellipse_poly.vertex(x, y); if(is_stop(cmd)) { m_draw_item++; if(m_draw_item >= m_num_items) { break; } else { m_ellipse.init(m_xs1 + m_dy / 1.3, m_ys1 + m_dy * m_draw_item + m_dy / 1.3, m_text_height / 1.5, m_text_height / 1.5, 32); m_ellipse_poly.rewind(0); cmd = m_ellipse_poly.vertex(x, y); } } break; case 4: if(m_cur_item >= 0) { cmd = m_ellipse.vertex(x, y); } else { cmd = path_cmd_stop; } break; default: cmd = path_cmd_stop; break; } if(!is_stop(cmd)) { transform_xy(x, y); } return cmd; } //------------------------------------------------------------------------ bool rbox_ctrl_impl::in_rect(double x, double y) const { inverse_transform_xy(&x, &y); return x >= m_x1 && x <= m_x2 && y >= m_y1 && y <= m_y2; } //------------------------------------------------------------------------ bool rbox_ctrl_impl::on_mouse_button_down(double x, double y) { inverse_transform_xy(&x, &y); unsigned i; for(i = 0; i < m_num_items; i++) { double xp = m_xs1 + m_dy / 1.3; double yp = m_ys1 + m_dy * i + m_dy / 1.3; if(calc_distance(x, y, xp, yp) <= m_text_height / 1.5) { m_cur_item = int(i); return true; } } return false; } //------------------------------------------------------------------------ bool rbox_ctrl_impl::on_mouse_move(double, double, bool) { return false; } //------------------------------------------------------------------------ bool rbox_ctrl_impl::on_mouse_button_up(double, double) { return false; } //------------------------------------------------------------------------ bool rbox_ctrl_impl::on_arrow_keys(bool left, bool right, bool down, bool up) { if(m_cur_item >= 0) { if(up || right) { m_cur_item++; if(m_cur_item >= int(m_num_items)) { m_cur_item = 0; } return true; } if(down || left) { m_cur_item--; if(m_cur_item < 0) { m_cur_item = m_num_items - 1; } return true; } } return false; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/0000755000175000017500000000000012516137725021767 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/mac/0000755000175000017500000000000012516137725022527 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/mac/agg_platform_support.cpp0000644000175000017500000010622512516137326027474 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (McSeem) // Copyright (C) 2003 Hansruedi Baer (MacOS support) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com // baer@karto.baug.eth.ch //---------------------------------------------------------------------------- // // class platform_support // //---------------------------------------------------------------------------- // // Note: // I tried to retain the original structure for the Win32 platform as far // as possible. Currently, not all features are implemented but the examples // should work properly. // HB //---------------------------------------------------------------------------- #include #if defined(__MWERKS__) #include "console.h" #endif #include #include #include "platform/agg_platform_support.h" #include "platform/mac/agg_mac_pmap.h" #include "util/agg_color_conv_rgb8.h" namespace agg24 { pascal OSStatus DoWindowClose (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData); pascal OSStatus DoWindowDrawContent (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData); pascal OSStatus DoAppQuit (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData); pascal OSStatus DoMouseDown (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData); pascal OSStatus DoMouseUp (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData); pascal OSStatus DoMouseDragged (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData); pascal OSStatus DoKeyDown (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData); pascal OSStatus DoKeyUp (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData); pascal void DoPeriodicTask (EventLoopTimerRef theTimer, void* userData); //------------------------------------------------------------------------ class platform_specific { public: platform_specific(pix_format_e format, bool flip_y); void create_pmap(unsigned width, unsigned height, rendering_buffer* wnd); void display_pmap(WindowRef window, const rendering_buffer* src); bool load_pmap(const char* fn, unsigned idx, rendering_buffer* dst); bool save_pmap(const char* fn, unsigned idx, const rendering_buffer* src); unsigned translate(unsigned keycode); pix_format_e m_format; pix_format_e m_sys_format; bool m_flip_y; unsigned m_bpp; unsigned m_sys_bpp; WindowRef m_window; pixel_map m_pmap_window; pixel_map m_pmap_img[platform_support::max_images]; unsigned m_keymap[256]; unsigned m_last_translated_key; int m_cur_x; int m_cur_y; unsigned m_input_flags; bool m_redraw_flag; UnsignedWide m_sw_freq; UnsignedWide m_sw_start; }; //------------------------------------------------------------------------ platform_specific::platform_specific(pix_format_e format, bool flip_y) : m_format(format), m_sys_format(pix_format_undefined), m_flip_y(flip_y), m_bpp(0), m_sys_bpp(0), m_window(nil), m_last_translated_key(0), m_cur_x(0), m_cur_y(0), m_input_flags(0), m_redraw_flag(true) { memset(m_keymap, 0, sizeof(m_keymap)); //Keyboard input is not yet fully supported nor tested //m_keymap[VK_PAUSE] = key_pause; m_keymap[kClearCharCode] = key_clear; //m_keymap[VK_NUMPAD0] = key_kp0; //m_keymap[VK_NUMPAD1] = key_kp1; //m_keymap[VK_NUMPAD2] = key_kp2; //m_keymap[VK_NUMPAD3] = key_kp3; //m_keymap[VK_NUMPAD4] = key_kp4; //m_keymap[VK_NUMPAD5] = key_kp5; //m_keymap[VK_NUMPAD6] = key_kp6; //m_keymap[VK_NUMPAD7] = key_kp7; //m_keymap[VK_NUMPAD8] = key_kp8; //m_keymap[VK_NUMPAD9] = key_kp9; //m_keymap[VK_DECIMAL] = key_kp_period; //m_keymap[VK_DIVIDE] = key_kp_divide; //m_keymap[VK_MULTIPLY] = key_kp_multiply; //m_keymap[VK_SUBTRACT] = key_kp_minus; //m_keymap[VK_ADD] = key_kp_plus; m_keymap[kUpArrowCharCode] = key_up; m_keymap[kDownArrowCharCode] = key_down; m_keymap[kRightArrowCharCode] = key_right; m_keymap[kLeftArrowCharCode] = key_left; //m_keymap[VK_INSERT] = key_insert; m_keymap[kDeleteCharCode] = key_delete; m_keymap[kHomeCharCode] = key_home; m_keymap[kEndCharCode] = key_end; m_keymap[kPageUpCharCode] = key_page_up; m_keymap[kPageDownCharCode] = key_page_down; //m_keymap[VK_F1] = key_f1; //m_keymap[VK_F2] = key_f2; //m_keymap[VK_F3] = key_f3; //m_keymap[VK_F4] = key_f4; //m_keymap[VK_F5] = key_f5; //m_keymap[VK_F6] = key_f6; //m_keymap[VK_F7] = key_f7; //m_keymap[VK_F8] = key_f8; //m_keymap[VK_F9] = key_f9; //m_keymap[VK_F10] = key_f10; //m_keymap[VK_F11] = key_f11; //m_keymap[VK_F12] = key_f12; //m_keymap[VK_F13] = key_f13; //m_keymap[VK_F14] = key_f14; //m_keymap[VK_F15] = key_f15; //m_keymap[VK_NUMLOCK] = key_numlock; //m_keymap[VK_CAPITAL] = key_capslock; //m_keymap[VK_SCROLL] = key_scrollock; switch(m_format) { case pix_format_gray8: m_sys_format = pix_format_gray8; m_bpp = 8; m_sys_bpp = 8; break; case pix_format_rgb565: case pix_format_rgb555: m_sys_format = pix_format_rgb555; m_bpp = 16; m_sys_bpp = 16; break; case pix_format_rgb24: case pix_format_bgr24: m_sys_format = pix_format_rgb24; m_bpp = 24; m_sys_bpp = 24; break; case pix_format_bgra32: case pix_format_abgr32: case pix_format_argb32: case pix_format_rgba32: m_sys_format = pix_format_argb32; m_bpp = 32; m_sys_bpp = 32; break; } ::Microseconds(&m_sw_freq); ::Microseconds(&m_sw_start); } //------------------------------------------------------------------------ void platform_specific::create_pmap(unsigned width, unsigned height, rendering_buffer* wnd) { m_pmap_window.create(width, height, org_e(m_bpp)); wnd->attach(m_pmap_window.buf(), m_pmap_window.width(), m_pmap_window.height(), m_flip_y ? -m_pmap_window.row_bytes() : m_pmap_window.row_bytes()); } //------------------------------------------------------------------------ void platform_specific::display_pmap(WindowRef window, const rendering_buffer* src) { if(m_sys_format == m_format) { m_pmap_window.draw(window); } else { pixel_map pmap_tmp; pmap_tmp.create(m_pmap_window.width(), m_pmap_window.height(), org_e(m_sys_bpp)); rendering_buffer rbuf_tmp; rbuf_tmp.attach(pmap_tmp.buf(), pmap_tmp.width(), pmap_tmp.height(), m_flip_y ? -pmap_tmp.row_bytes() : pmap_tmp.row_bytes()); switch(m_format) { case pix_format_gray8: return; case pix_format_rgb565: color_conv(&rbuf_tmp, src, color_conv_rgb565_to_rgb555()); break; case pix_format_bgr24: color_conv(&rbuf_tmp, src, color_conv_bgr24_to_rgb24()); break; case pix_format_abgr32: color_conv(&rbuf_tmp, src, color_conv_abgr32_to_argb32()); break; case pix_format_bgra32: color_conv(&rbuf_tmp, src, color_conv_bgra32_to_argb32()); break; case pix_format_rgba32: color_conv(&rbuf_tmp, src, color_conv_rgba32_to_argb32()); break; } pmap_tmp.draw(window); } } //------------------------------------------------------------------------ bool platform_specific::save_pmap(const char* fn, unsigned idx, const rendering_buffer* src) { if(m_sys_format == m_format) { return m_pmap_img[idx].save_as_qt(fn); } else { pixel_map pmap_tmp; pmap_tmp.create(m_pmap_img[idx].width(), m_pmap_img[idx].height(), org_e(m_sys_bpp)); rendering_buffer rbuf_tmp; rbuf_tmp.attach(pmap_tmp.buf(), pmap_tmp.width(), pmap_tmp.height(), m_flip_y ? -pmap_tmp.row_bytes() : pmap_tmp.row_bytes()); switch(m_format) { case pix_format_gray8: return false; case pix_format_rgb565: color_conv(&rbuf_tmp, src, color_conv_rgb565_to_rgb555()); break; case pix_format_rgb24: color_conv(&rbuf_tmp, src, color_conv_rgb24_to_bgr24()); break; case pix_format_abgr32: color_conv(&rbuf_tmp, src, color_conv_abgr32_to_bgra32()); break; case pix_format_argb32: color_conv(&rbuf_tmp, src, color_conv_argb32_to_bgra32()); break; case pix_format_rgba32: color_conv(&rbuf_tmp, src, color_conv_rgba32_to_bgra32()); break; } return pmap_tmp.save_as_qt(fn); } return true; } //------------------------------------------------------------------------ bool platform_specific::load_pmap(const char* fn, unsigned idx, rendering_buffer* dst) { pixel_map pmap_tmp; if(!pmap_tmp.load_from_qt(fn)) return false; rendering_buffer rbuf_tmp; rbuf_tmp.attach(pmap_tmp.buf(), pmap_tmp.width(), pmap_tmp.height(), m_flip_y ? -pmap_tmp.row_bytes() : pmap_tmp.row_bytes()); m_pmap_img[idx].create(pmap_tmp.width(), pmap_tmp.height(), org_e(m_bpp), 0); dst->attach(m_pmap_img[idx].buf(), m_pmap_img[idx].width(), m_pmap_img[idx].height(), m_flip_y ? -m_pmap_img[idx].row_bytes() : m_pmap_img[idx].row_bytes()); switch(m_format) { case pix_format_gray8: return false; break; case pix_format_rgb555: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb555()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_rgb555()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_rgb555()); break; } break; case pix_format_rgb565: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb565()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_rgb565()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_rgb565()); break; } break; case pix_format_rgb24: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb24()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_rgb24()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_rgb24()); break; } break; case pix_format_bgr24: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgr24()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_bgr24()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_bgr24()); break; } break; case pix_format_abgr32: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_abgr32()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_abgr32()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_abgr32()); break; } break; case pix_format_argb32: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_argb32()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_argb32()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_argb32()); break; } break; case pix_format_bgra32: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgra32()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_bgra32()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_bgra32()); break; } break; case pix_format_rgba32: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgba32()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_rgb24_to_rgba32()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_argb32_to_rgba32()); break; } break; } return true; } //------------------------------------------------------------------------ unsigned platform_specific::translate(unsigned keycode) { return m_last_translated_key = (keycode > 255) ? 0 : m_keymap[keycode]; } //------------------------------------------------------------------------ platform_support::platform_support(pix_format_e format, bool flip_y) : m_specific(new platform_specific(format, flip_y)), m_format(format), m_bpp(m_specific->m_bpp), m_window_flags(0), m_wait_mode(true), m_flip_y(flip_y), m_initial_width(10), m_initial_height(10) { strcpy(m_caption, "Anti-Grain Geometry Application"); } //------------------------------------------------------------------------ platform_support::~platform_support() { delete m_specific; } //------------------------------------------------------------------------ void platform_support::caption(const char* cap) { strcpy(m_caption, cap); if(m_specific->m_window) { SetWindowTitleWithCFString (m_specific->m_window, CFStringCreateWithCStringNoCopy (nil, cap, kCFStringEncodingASCII, nil)); } } //------------------------------------------------------------------------ static unsigned get_key_flags(UInt32 wflags) { unsigned flags = 0; if(wflags & shiftKey) flags |= kbd_shift; if(wflags & controlKey) flags |= kbd_ctrl; return flags; } //------------------------------------------------------------------------ void platform_support::message(const char* msg) { SInt16 item; Str255 p_msg; ::CopyCStringToPascal (msg, p_msg); ::StandardAlert (kAlertPlainAlert, (const unsigned char*) "\pAGG Message", p_msg, NULL, &item); } //------------------------------------------------------------------------ void platform_support::start_timer() { ::Microseconds (&(m_specific->m_sw_start)); } //------------------------------------------------------------------------ double platform_support::elapsed_time() const { UnsignedWide stop; ::Microseconds(&stop); return double(stop.lo - m_specific->m_sw_start.lo) * 1e6 / double(m_specific->m_sw_freq.lo); } //------------------------------------------------------------------------ bool platform_support::init(unsigned width, unsigned height, unsigned flags) { if(m_specific->m_sys_format == pix_format_undefined) { return false; } m_window_flags = flags; // application EventTypeSpec eventType; EventHandlerUPP handlerUPP; eventType.eventClass = kEventClassApplication; eventType.eventKind = kEventAppQuit; handlerUPP = NewEventHandlerUPP(DoAppQuit); InstallApplicationEventHandler (handlerUPP, 1, &eventType, nil, nil); eventType.eventClass = kEventClassMouse; eventType.eventKind = kEventMouseDown; handlerUPP = NewEventHandlerUPP(DoMouseDown); InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil); eventType.eventKind = kEventMouseUp; handlerUPP = NewEventHandlerUPP(DoMouseUp); InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil); eventType.eventKind = kEventMouseDragged; handlerUPP = NewEventHandlerUPP(DoMouseDragged); InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil); eventType.eventClass = kEventClassKeyboard; eventType.eventKind = kEventRawKeyDown; handlerUPP = NewEventHandlerUPP(DoKeyDown); InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil); eventType.eventKind = kEventRawKeyUp; handlerUPP = NewEventHandlerUPP(DoKeyUp); InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil); eventType.eventKind = kEventRawKeyRepeat; handlerUPP = NewEventHandlerUPP(DoKeyDown); // 'key repeat' is translated to 'key down' InstallApplicationEventHandler (handlerUPP, 1, &eventType, this, nil); WindowAttributes windowAttrs; Rect bounds; // window windowAttrs = kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute | kWindowStandardHandlerAttribute; SetRect (&bounds, 0, 0, width, height); OffsetRect (&bounds, 100, 100); CreateNewWindow (kDocumentWindowClass, windowAttrs, &bounds, &m_specific->m_window); if(m_specific->m_window == nil) { return false; } // I assume the text is ASCII. // Change to kCFStringEncodingMacRoman, kCFStringEncodingISOLatin1, kCFStringEncodingUTF8 or what else you need. SetWindowTitleWithCFString (m_specific->m_window, CFStringCreateWithCStringNoCopy (nil, m_caption, kCFStringEncodingASCII, nil)); eventType.eventClass = kEventClassWindow; eventType.eventKind = kEventWindowClose; handlerUPP = NewEventHandlerUPP(DoWindowClose); InstallWindowEventHandler (m_specific->m_window, handlerUPP, 1, &eventType, this, NULL); eventType.eventKind = kEventWindowDrawContent; handlerUPP = NewEventHandlerUPP(DoWindowDrawContent); InstallWindowEventHandler (m_specific->m_window, handlerUPP, 1, &eventType, this, NULL); // Periodic task // Instead of an idle function I use the Carbon event timer. // You may decide to change the wait value which is currently 50 milliseconds. EventLoopRef mainLoop; EventLoopTimerUPP timerUPP; EventLoopTimerRef theTimer; mainLoop = GetMainEventLoop(); timerUPP = NewEventLoopTimerUPP (DoPeriodicTask); InstallEventLoopTimer (mainLoop, 0, 50 * kEventDurationMillisecond, timerUPP, this, &theTimer); m_specific->create_pmap(width, height, &m_rbuf_window); m_initial_width = width; m_initial_height = height; on_init(); on_resize(width, height); m_specific->m_redraw_flag = true; ShowWindow (m_specific->m_window); SetPortWindowPort (m_specific->m_window); return true; } //------------------------------------------------------------------------ int platform_support::run() { RunApplicationEventLoop (); return true; } //------------------------------------------------------------------------ const char* platform_support::img_ext() const { return ".bmp"; } //------------------------------------------------------------------------ const char* platform_support::full_file_name(const char* file_name) { return file_name; } //------------------------------------------------------------------------ bool platform_support::load_img(unsigned idx, const char* file) { if(idx < max_images) { char fn[1024]; strcpy(fn, file); int len = strlen(fn); #if defined(__MWERKS__) if(len < 4 || stricmp(fn + len - 4, ".BMP") != 0) #else if(len < 4 || strncasecmp(fn + len - 4, ".BMP", 4) != 0) #endif { strcat(fn, ".bmp"); } return m_specific->load_pmap(fn, idx, &m_rbuf_img[idx]); } return true; } //------------------------------------------------------------------------ bool platform_support::save_img(unsigned idx, const char* file) { if(idx < max_images) { char fn[1024]; strcpy(fn, file); int len = strlen(fn); #if defined(__MWERKS__) if(len < 4 || stricmp(fn + len - 4, ".BMP") != 0) #else if(len < 4 || strncasecmp(fn + len - 4, ".BMP", 4) != 0) #endif { strcat(fn, ".bmp"); } return m_specific->save_pmap(fn, idx, &m_rbuf_img[idx]); } return true; } //------------------------------------------------------------------------ bool platform_support::create_img(unsigned idx, unsigned width, unsigned height) { if(idx < max_images) { if(width == 0) width = m_specific->m_pmap_window.width(); if(height == 0) height = m_specific->m_pmap_window.height(); m_specific->m_pmap_img[idx].create(width, height, org_e(m_specific->m_bpp)); m_rbuf_img[idx].attach(m_specific->m_pmap_img[idx].buf(), m_specific->m_pmap_img[idx].width(), m_specific->m_pmap_img[idx].height(), m_flip_y ? -m_specific->m_pmap_img[idx].row_bytes() : m_specific->m_pmap_img[idx].row_bytes()); return true; } return false; } //------------------------------------------------------------------------ void platform_support::force_redraw() { Rect bounds; m_specific->m_redraw_flag = true; // on_ctrl_change (); on_draw(); SetRect(&bounds, 0, 0, m_rbuf_window.width(), m_rbuf_window.height()); InvalWindowRect(m_specific->m_window, &bounds); } //------------------------------------------------------------------------ void platform_support::update_window() { m_specific->display_pmap(m_specific->m_window, &m_rbuf_window); } //------------------------------------------------------------------------ void platform_support::on_init() {} void platform_support::on_resize(int sx, int sy) {} void platform_support::on_idle() {} void platform_support::on_mouse_move(int x, int y, unsigned flags) {} void platform_support::on_mouse_button_down(int x, int y, unsigned flags) {} void platform_support::on_mouse_button_up(int x, int y, unsigned flags) {} void platform_support::on_key(int x, int y, unsigned key, unsigned flags) {} void platform_support::on_ctrl_change() {} void platform_support::on_draw() {} void platform_support::on_post_draw(void* raw_handler) {} //------------------------------------------------------------------------ pascal OSStatus DoWindowClose (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData) { userData; QuitApplicationEventLoop (); return CallNextEventHandler (nextHandler, theEvent); } //------------------------------------------------------------------------ pascal OSStatus DoAppQuit (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData) { userData; return CallNextEventHandler (nextHandler, theEvent); } //------------------------------------------------------------------------ pascal OSStatus DoMouseDown (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData) { Point wheresMyMouse; UInt32 modifier; GetEventParameter (theEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &wheresMyMouse); GlobalToLocal (&wheresMyMouse); GetEventParameter (theEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifier); platform_support * app = reinterpret_cast(userData); app->m_specific->m_cur_x = wheresMyMouse.h; if(app->flip_y()) { app->m_specific->m_cur_y = app->rbuf_window().height() - wheresMyMouse.v; } else { app->m_specific->m_cur_y = wheresMyMouse.v; } app->m_specific->m_input_flags = mouse_left | get_key_flags(modifier); app->m_ctrls.set_cur(app->m_specific->m_cur_x, app->m_specific->m_cur_y); if(app->m_ctrls.on_mouse_button_down(app->m_specific->m_cur_x, app->m_specific->m_cur_y)) { app->on_ctrl_change(); app->force_redraw(); } else { if(app->m_ctrls.in_rect(app->m_specific->m_cur_x, app->m_specific->m_cur_y)) { if(app->m_ctrls.set_cur(app->m_specific->m_cur_x, app->m_specific->m_cur_y)) { app->on_ctrl_change(); app->force_redraw(); } } else { app->on_mouse_button_down(app->m_specific->m_cur_x, app->m_specific->m_cur_y, app->m_specific->m_input_flags); } } return CallNextEventHandler (nextHandler, theEvent); } //------------------------------------------------------------------------ pascal OSStatus DoMouseUp (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData) { Point wheresMyMouse; UInt32 modifier; GetEventParameter (theEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &wheresMyMouse); GlobalToLocal (&wheresMyMouse); GetEventParameter (theEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifier); platform_support * app = reinterpret_cast(userData); app->m_specific->m_cur_x = wheresMyMouse.h; if(app->flip_y()) { app->m_specific->m_cur_y = app->rbuf_window().height() - wheresMyMouse.v; } else { app->m_specific->m_cur_y = wheresMyMouse.v; } app->m_specific->m_input_flags = mouse_left | get_key_flags(modifier); if(app->m_ctrls.on_mouse_button_up(app->m_specific->m_cur_x, app->m_specific->m_cur_y)) { app->on_ctrl_change(); app->force_redraw(); } app->on_mouse_button_up(app->m_specific->m_cur_x, app->m_specific->m_cur_y, app->m_specific->m_input_flags); return CallNextEventHandler (nextHandler, theEvent); } //------------------------------------------------------------------------ pascal OSStatus DoMouseDragged (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData) { Point wheresMyMouse; UInt32 modifier; GetEventParameter (theEvent, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &wheresMyMouse); GlobalToLocal (&wheresMyMouse); GetEventParameter (theEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifier); platform_support * app = reinterpret_cast(userData); app->m_specific->m_cur_x = wheresMyMouse.h; if(app->flip_y()) { app->m_specific->m_cur_y = app->rbuf_window().height() - wheresMyMouse.v; } else { app->m_specific->m_cur_y = wheresMyMouse.v; } app->m_specific->m_input_flags = mouse_left | get_key_flags(modifier); if(app->m_ctrls.on_mouse_move( app->m_specific->m_cur_x, app->m_specific->m_cur_y, (app->m_specific->m_input_flags & mouse_left) != 0)) { app->on_ctrl_change(); app->force_redraw(); } else { app->on_mouse_move(app->m_specific->m_cur_x, app->m_specific->m_cur_y, app->m_specific->m_input_flags); } return CallNextEventHandler (nextHandler, theEvent); } //------------------------------------------------------------------------ pascal OSStatus DoKeyDown (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData) { char key_code; UInt32 modifier; GetEventParameter (theEvent, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &key_code); GetEventParameter (theEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifier); platform_support * app = reinterpret_cast(userData); app->m_specific->m_last_translated_key = 0; switch(modifier) { case controlKey: app->m_specific->m_input_flags |= kbd_ctrl; break; case shiftKey: app->m_specific->m_input_flags |= kbd_shift; break; default: app->m_specific->translate(key_code); break; } if(app->m_specific->m_last_translated_key) { bool left = false; bool up = false; bool right = false; bool down = false; switch(app->m_specific->m_last_translated_key) { case key_left: left = true; break; case key_up: up = true; break; case key_right: right = true; break; case key_down: down = true; break; //On a Mac, screenshots are handled by the system. case key_f2: app->copy_window_to_img(agg24::platform_support::max_images - 1); app->save_img(agg24::platform_support::max_images - 1, "screenshot"); break; } if(app->m_ctrls.on_arrow_keys(left, right, down, up)) { app->on_ctrl_change(); app->force_redraw(); } else { app->on_key(app->m_specific->m_cur_x, app->m_specific->m_cur_y, app->m_specific->m_last_translated_key, app->m_specific->m_input_flags); } } return CallNextEventHandler (nextHandler, theEvent); } //------------------------------------------------------------------------ pascal OSStatus DoKeyUp (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData) { char key_code; UInt32 modifier; GetEventParameter (theEvent, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &key_code); GetEventParameter (theEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifier); platform_support * app = reinterpret_cast(userData); app->m_specific->m_last_translated_key = 0; switch(modifier) { case controlKey: app->m_specific->m_input_flags &= ~kbd_ctrl; break; case shiftKey: app->m_specific->m_input_flags &= ~kbd_shift; break; } return CallNextEventHandler (nextHandler, theEvent); } //------------------------------------------------------------------------ pascal OSStatus DoWindowDrawContent (EventHandlerCallRef nextHandler, EventRef theEvent, void* userData) { platform_support * app = reinterpret_cast(userData); if(app) { if(app->m_specific->m_redraw_flag) { app->on_draw(); app->m_specific->m_redraw_flag = false; } app->m_specific->display_pmap(app->m_specific->m_window, &app->rbuf_window()); } return CallNextEventHandler (nextHandler, theEvent); } //------------------------------------------------------------------------ pascal void DoPeriodicTask (EventLoopTimerRef theTimer, void* userData) { platform_support * app = reinterpret_cast(userData); if(!app->wait_mode()) app->on_idle(); } } //---------------------------------------------------------------------------- int agg_main(int argc, char* argv[]); // Hm. Classic MacOS does not know command line input. // CodeWarrior provides a way to mimic command line input. // The function 'ccommand' can be used to get the command // line arguments. //---------------------------------------------------------------------------- int main(int argc, char* argv[]) { #if defined(__MWERKS__) // argc = ccommand (&argv); #endif // Check if we are launched by double-clicking under OSX // Get rid of extra argument, this will confuse the standard argument parsing // calls used in the examples to get the name of the image file to be used if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) { argc = 1; } launch: return agg_main(argc, argv); }enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/mac/agg_mac_pmap.cpp0000644000175000017500000002135712516137326025633 0ustar varunvarun//---------------------------------------------------------------------------- // //---------------------------------------------------------------------------- // Contact: mcseemagg@yahoo.com // baer@karto.baug.ethz.ch //---------------------------------------------------------------------------- // // class pixel_map // //---------------------------------------------------------------------------- #include #include #include #include #include "platform/mac/agg_mac_pmap.h" #include "agg_basics.h" namespace agg24 { //------------------------------------------------------------------------ pixel_map::~pixel_map() { destroy(); } //------------------------------------------------------------------------ pixel_map::pixel_map() : m_pmap(0), m_buf(0), m_bpp(0), m_img_size(0) { } //------------------------------------------------------------------------ void pixel_map::destroy() { delete[] m_buf; m_buf = NULL; if (m_pmap != nil) { DisposeGWorld(m_pmap); m_pmap = nil; } } //------------------------------------------------------------------------ void pixel_map::create(unsigned width, unsigned height, org_e org, unsigned clear_val) { destroy(); if(width == 0) width = 1; if(height == 0) height = 1; m_bpp = org; Rect r; int row_bytes = calc_row_len (width, m_bpp); MacSetRect(&r, 0, 0, width, height); m_buf = new unsigned char[m_img_size = row_bytes * height]; // The Quicktime version for creating GWorlds is more flexible than the classical function. QTNewGWorldFromPtr (&m_pmap, m_bpp, &r, nil, nil, 0, m_buf, row_bytes); // create_gray_scale_palette(m_pmap); I didn't care about gray scale palettes so far. if(clear_val <= 255) { memset(m_buf, clear_val, m_img_size); } } //------------------------------------------------------------------------ void pixel_map::clear(unsigned clear_val) { if(m_buf) memset(m_buf, clear_val, m_img_size); } //static //This function is just copied from the Win32 plattform support. //Is also seems to be appropriate for MacOS as well, but it is not //thouroughly tested so far. //------------------------------------------------------------------------ unsigned pixel_map::calc_row_len(unsigned width, unsigned bits_per_pixel) { unsigned n = width; unsigned k; switch(bits_per_pixel) { case 1: k = n; n = n >> 3; if(k & 7) n++; break; case 4: k = n; n = n >> 1; if(k & 3) n++; break; case 8: break; case 16: n = n << 1; break; case 24: n = (n << 1) + n; break; case 32: n = n << 2; break; default: n = 0; break; } return ((n + 3) >> 2) << 2; } //------------------------------------------------------------------------ void pixel_map::draw(WindowRef window, const Rect *device_rect, const Rect *pmap_rect) const { if(m_pmap == nil || m_buf == NULL) return; PixMapHandle pm = GetGWorldPixMap (m_pmap); CGrafPtr port = GetWindowPort (window); Rect dest_rect; // Again, I used the Quicktime version. // Good old 'CopyBits' does better interpolation when scaling // but does not support all pixel depths. MacSetRect (&dest_rect, 0, 0, this->width(), this->height()); ImageDescriptionHandle image_description; MakeImageDescriptionForPixMap (pm, &image_description); if (image_description != nil) { DecompressImage (GetPixBaseAddr (pm), image_description, GetPortPixMap (port), nil, &dest_rect, ditherCopy, nil); DisposeHandle ((Handle) image_description); } } //------------------------------------------------------------------------ void pixel_map::draw(WindowRef window, int x, int y, double scale) const { if(m_pmap == nil || m_buf == NULL) return; unsigned width = this->width() * scale; unsigned height = this->height() * scale; Rect rect; SetRect (&rect, x, y, x + width, y + height); draw(window, &rect); } //------------------------------------------------------------------------ void pixel_map::blend(WindowRef window, const Rect *device_rect, const Rect *bmp_rect) const { draw (window, device_rect, bmp_rect); // currently just mapped to drawing method } //------------------------------------------------------------------------ void pixel_map::blend(WindowRef window, int x, int y, double scale) const { draw(window, x, y, scale); // currently just mapped to drawing method } // I let Quicktime handle image import since it supports most popular // image formats such as: // *.psd, *.bmp, *.tif, *.png, *.jpg, *.gif, *.pct, *.pcx //------------------------------------------------------------------------ bool pixel_map::load_from_qt(const char *filename) { FSSpec fss; OSErr err; // get file specification to application directory err = HGetVol(nil, &fss.vRefNum, &fss.parID); if (err == noErr) { CopyCStringToPascal(filename, fss.name); GraphicsImportComponent gi; err = GetGraphicsImporterForFile (&fss, &gi); if (err == noErr) { ImageDescriptionHandle desc; GraphicsImportGetImageDescription(gi, &desc); // For simplicity, all images are currently converted to 32 bit. // create an empty pixelmap short depth = 32; create ((**desc).width, (**desc).height, (org_e)depth, 0xff); DisposeHandle ((Handle)desc); // let Quicktime draw to pixelmap GraphicsImportSetGWorld(gi, m_pmap, nil); GraphicsImportDraw(gi); // Well, this is a hack. The graphics importer sets the alpha channel of the pixelmap to 0x00 // for imported images without alpha channel but this would cause agg to draw an invisible image. // set alpha channel to 0xff unsigned char * buf = m_buf; for (unsigned int size = 0; size < m_img_size; size += 4) { *buf = 0xff; buf += 4; } } } return err == noErr; } //------------------------------------------------------------------------ bool pixel_map::save_as_qt(const char *filename) const { FSSpec fss; OSErr err; // get file specification to application directory err = HGetVol(nil, &fss.vRefNum, &fss.parID); if (err == noErr) { GraphicsExportComponent ge; CopyCStringToPascal(filename, fss.name); // I decided to use PNG as output image file type. // There are a number of other available formats. // Should I check the file suffix to choose the image file format? err = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypePNG, &ge); if (err == noErr) { err = GraphicsExportSetInputGWorld(ge, m_pmap); if (err == noErr) { err = GraphicsExportSetOutputFile (ge, &fss); if (err == noErr) { GraphicsExportDoExport(ge, nil); } } CloseComponent(ge); } } return err == noErr; } //------------------------------------------------------------------------ unsigned char* pixel_map::buf() { return m_buf; } //------------------------------------------------------------------------ unsigned pixel_map::width() const { if(m_pmap == nil) return 0; PixMapHandle pm = GetGWorldPixMap (m_pmap); Rect bounds; GetPixBounds (pm, &bounds); return bounds.right - bounds.left; } //------------------------------------------------------------------------ unsigned pixel_map::height() const { if(m_pmap == nil) return 0; PixMapHandle pm = GetGWorldPixMap (m_pmap); Rect bounds; GetPixBounds (pm, &bounds); return bounds.bottom - bounds.top; } //------------------------------------------------------------------------ int pixel_map::row_bytes() const { if(m_pmap == nil) return 0; PixMapHandle pm = GetGWorldPixMap (m_pmap); return calc_row_len(width(), GetPixDepth(pm)); } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/mac/Makefile.am0000644000175000017500000000055412516137326024564 0ustar varunvarunif ENABLE_OSX lib_LTLIBRARIES = libaggplatformmac.la libaggplatformmac_la_LDFLAGS=-version-info @AGG_LIB_VERSION@ libaggplatformmac_la_SOURCES=agg_mac_pmap.cpp \ agg_platform_support.cpp libaggplatformmac_la_CXXFLAGS = -I$(top_srcdir)/include @OSX_CFLAGS@ libaggplatformmac_la_LIBADD = @OSX_LIBS@ $(top_builddir)/src/libagg.la endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/X11/0000755000175000017500000000000012516137725022340 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/X11/agg_platform_support.cpp0000644000175000017500000014332012516137326027302 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class platform_support. X11 version. // //---------------------------------------------------------------------------- #include #include #include #include #include #include #include #include #include #include "agg_basics.h" #include "util/agg_color_conv_rgb8.h" #include "platform/agg_platform_support.h" namespace agg24 { //------------------------------------------------------------------------ class platform_specific { public: platform_specific(pix_format_e format, bool flip_y); ~platform_specific(); void caption(const char* capt); void put_image(const rendering_buffer* src); pix_format_e m_format; pix_format_e m_sys_format; int m_byte_order; bool m_flip_y; unsigned m_bpp; unsigned m_sys_bpp; Display* m_display; int m_screen; int m_depth; Visual* m_visual; Window m_window; GC m_gc; XImage* m_ximg_window; XSetWindowAttributes m_window_attributes; Atom m_close_atom; unsigned char* m_buf_window; unsigned char* m_buf_img[platform_support::max_images]; unsigned m_keymap[256]; bool m_update_flag; bool m_resize_flag; bool m_initialized; //bool m_wait_mode; clock_t m_sw_start; }; //------------------------------------------------------------------------ platform_specific::platform_specific(pix_format_e format, bool flip_y) : m_format(format), m_sys_format(pix_format_undefined), m_byte_order(LSBFirst), m_flip_y(flip_y), m_bpp(0), m_sys_bpp(0), m_display(0), m_screen(0), m_depth(0), m_visual(0), m_window(0), m_gc(0), m_ximg_window(0), m_close_atom(0), m_buf_window(0), m_update_flag(true), m_resize_flag(true), m_initialized(false) //m_wait_mode(true) { memset(m_buf_img, 0, sizeof(m_buf_img)); unsigned i; for(i = 0; i < 256; i++) { m_keymap[i] = i; } m_keymap[XK_Pause&0xFF] = key_pause; m_keymap[XK_Clear&0xFF] = key_clear; m_keymap[XK_KP_0&0xFF] = key_kp0; m_keymap[XK_KP_1&0xFF] = key_kp1; m_keymap[XK_KP_2&0xFF] = key_kp2; m_keymap[XK_KP_3&0xFF] = key_kp3; m_keymap[XK_KP_4&0xFF] = key_kp4; m_keymap[XK_KP_5&0xFF] = key_kp5; m_keymap[XK_KP_6&0xFF] = key_kp6; m_keymap[XK_KP_7&0xFF] = key_kp7; m_keymap[XK_KP_8&0xFF] = key_kp8; m_keymap[XK_KP_9&0xFF] = key_kp9; m_keymap[XK_KP_Insert&0xFF] = key_kp0; m_keymap[XK_KP_End&0xFF] = key_kp1; m_keymap[XK_KP_Down&0xFF] = key_kp2; m_keymap[XK_KP_Page_Down&0xFF] = key_kp3; m_keymap[XK_KP_Left&0xFF] = key_kp4; m_keymap[XK_KP_Begin&0xFF] = key_kp5; m_keymap[XK_KP_Right&0xFF] = key_kp6; m_keymap[XK_KP_Home&0xFF] = key_kp7; m_keymap[XK_KP_Up&0xFF] = key_kp8; m_keymap[XK_KP_Page_Up&0xFF] = key_kp9; m_keymap[XK_KP_Delete&0xFF] = key_kp_period; m_keymap[XK_KP_Decimal&0xFF] = key_kp_period; m_keymap[XK_KP_Divide&0xFF] = key_kp_divide; m_keymap[XK_KP_Multiply&0xFF] = key_kp_multiply; m_keymap[XK_KP_Subtract&0xFF] = key_kp_minus; m_keymap[XK_KP_Add&0xFF] = key_kp_plus; m_keymap[XK_KP_Enter&0xFF] = key_kp_enter; m_keymap[XK_KP_Equal&0xFF] = key_kp_equals; m_keymap[XK_Up&0xFF] = key_up; m_keymap[XK_Down&0xFF] = key_down; m_keymap[XK_Right&0xFF] = key_right; m_keymap[XK_Left&0xFF] = key_left; m_keymap[XK_Insert&0xFF] = key_insert; m_keymap[XK_Home&0xFF] = key_delete; m_keymap[XK_End&0xFF] = key_end; m_keymap[XK_Page_Up&0xFF] = key_page_up; m_keymap[XK_Page_Down&0xFF] = key_page_down; m_keymap[XK_F1&0xFF] = key_f1; m_keymap[XK_F2&0xFF] = key_f2; m_keymap[XK_F3&0xFF] = key_f3; m_keymap[XK_F4&0xFF] = key_f4; m_keymap[XK_F5&0xFF] = key_f5; m_keymap[XK_F6&0xFF] = key_f6; m_keymap[XK_F7&0xFF] = key_f7; m_keymap[XK_F8&0xFF] = key_f8; m_keymap[XK_F9&0xFF] = key_f9; m_keymap[XK_F10&0xFF] = key_f10; m_keymap[XK_F11&0xFF] = key_f11; m_keymap[XK_F12&0xFF] = key_f12; m_keymap[XK_F13&0xFF] = key_f13; m_keymap[XK_F14&0xFF] = key_f14; m_keymap[XK_F15&0xFF] = key_f15; m_keymap[XK_Num_Lock&0xFF] = key_numlock; m_keymap[XK_Caps_Lock&0xFF] = key_capslock; m_keymap[XK_Scroll_Lock&0xFF] = key_scrollock; switch(m_format) { default: break; case pix_format_gray8: m_bpp = 8; break; case pix_format_rgb565: case pix_format_rgb555: m_bpp = 16; break; case pix_format_rgb24: case pix_format_bgr24: m_bpp = 24; break; case pix_format_bgra32: case pix_format_abgr32: case pix_format_argb32: case pix_format_rgba32: m_bpp = 32; break; } m_sw_start = clock(); } //------------------------------------------------------------------------ platform_specific::~platform_specific() { } //------------------------------------------------------------------------ void platform_specific::caption(const char* capt) { XTextProperty tp; tp.value = (unsigned char *)capt; tp.encoding = XA_WM_NAME; tp.format = 8; tp.nitems = strlen(capt); XSetWMName(m_display, m_window, &tp); XStoreName(m_display, m_window, capt); XSetIconName(m_display, m_window, capt); XSetWMIconName(m_display, m_window, &tp); } //------------------------------------------------------------------------ void platform_specific::put_image(const rendering_buffer* src) { if(m_ximg_window == 0) return; m_ximg_window->data = (char*)m_buf_window; if(m_format == m_sys_format) { XPutImage(m_display, m_window, m_gc, m_ximg_window, 0, 0, 0, 0, src->width(), src->height()); } else { int row_len = src->width() * m_sys_bpp / 8; unsigned char* buf_tmp = new unsigned char[row_len * src->height()]; rendering_buffer rbuf_tmp; rbuf_tmp.attach(buf_tmp, src->width(), src->height(), m_flip_y ? -row_len : row_len); switch(m_sys_format) { default: break; case pix_format_rgb555: switch(m_format) { default: break; case pix_format_rgb555: color_conv(&rbuf_tmp, src, color_conv_rgb555_to_rgb555()); break; case pix_format_rgb565: color_conv(&rbuf_tmp, src, color_conv_rgb565_to_rgb555()); break; case pix_format_rgb24: color_conv(&rbuf_tmp, src, color_conv_rgb24_to_rgb555()); break; case pix_format_bgr24: color_conv(&rbuf_tmp, src, color_conv_bgr24_to_rgb555()); break; case pix_format_rgba32: color_conv(&rbuf_tmp, src, color_conv_rgba32_to_rgb555()); break; case pix_format_argb32: color_conv(&rbuf_tmp, src, color_conv_argb32_to_rgb555()); break; case pix_format_bgra32: color_conv(&rbuf_tmp, src, color_conv_bgra32_to_rgb555()); break; case pix_format_abgr32: color_conv(&rbuf_tmp, src, color_conv_abgr32_to_rgb555()); break; } break; case pix_format_rgb565: switch(m_format) { default: break; case pix_format_rgb555: color_conv(&rbuf_tmp, src, color_conv_rgb555_to_rgb565()); break; case pix_format_rgb565: color_conv(&rbuf_tmp, src, color_conv_rgb565_to_rgb565()); break; case pix_format_rgb24: color_conv(&rbuf_tmp, src, color_conv_rgb24_to_rgb565()); break; case pix_format_bgr24: color_conv(&rbuf_tmp, src, color_conv_bgr24_to_rgb565()); break; case pix_format_rgba32: color_conv(&rbuf_tmp, src, color_conv_rgba32_to_rgb565()); break; case pix_format_argb32: color_conv(&rbuf_tmp, src, color_conv_argb32_to_rgb565()); break; case pix_format_bgra32: color_conv(&rbuf_tmp, src, color_conv_bgra32_to_rgb565()); break; case pix_format_abgr32: color_conv(&rbuf_tmp, src, color_conv_abgr32_to_rgb565()); break; } break; case pix_format_rgba32: switch(m_format) { default: break; case pix_format_rgb555: color_conv(&rbuf_tmp, src, color_conv_rgb555_to_rgba32()); break; case pix_format_rgb565: color_conv(&rbuf_tmp, src, color_conv_rgb565_to_rgba32()); break; case pix_format_rgb24: color_conv(&rbuf_tmp, src, color_conv_rgb24_to_rgba32()); break; case pix_format_bgr24: color_conv(&rbuf_tmp, src, color_conv_bgr24_to_rgba32()); break; case pix_format_rgba32: color_conv(&rbuf_tmp, src, color_conv_rgba32_to_rgba32()); break; case pix_format_argb32: color_conv(&rbuf_tmp, src, color_conv_argb32_to_rgba32()); break; case pix_format_bgra32: color_conv(&rbuf_tmp, src, color_conv_bgra32_to_rgba32()); break; case pix_format_abgr32: color_conv(&rbuf_tmp, src, color_conv_abgr32_to_rgba32()); break; } break; case pix_format_abgr32: switch(m_format) { default: break; case pix_format_rgb555: color_conv(&rbuf_tmp, src, color_conv_rgb555_to_abgr32()); break; case pix_format_rgb565: color_conv(&rbuf_tmp, src, color_conv_rgb565_to_abgr32()); break; case pix_format_rgb24: color_conv(&rbuf_tmp, src, color_conv_rgb24_to_abgr32()); break; case pix_format_bgr24: color_conv(&rbuf_tmp, src, color_conv_bgr24_to_abgr32()); break; case pix_format_abgr32: color_conv(&rbuf_tmp, src, color_conv_abgr32_to_abgr32()); break; case pix_format_rgba32: color_conv(&rbuf_tmp, src, color_conv_rgba32_to_abgr32()); break; case pix_format_argb32: color_conv(&rbuf_tmp, src, color_conv_argb32_to_abgr32()); break; case pix_format_bgra32: color_conv(&rbuf_tmp, src, color_conv_bgra32_to_abgr32()); break; } break; case pix_format_argb32: switch(m_format) { default: break; case pix_format_rgb555: color_conv(&rbuf_tmp, src, color_conv_rgb555_to_argb32()); break; case pix_format_rgb565: color_conv(&rbuf_tmp, src, color_conv_rgb565_to_argb32()); break; case pix_format_rgb24: color_conv(&rbuf_tmp, src, color_conv_rgb24_to_argb32()); break; case pix_format_bgr24: color_conv(&rbuf_tmp, src, color_conv_bgr24_to_argb32()); break; case pix_format_rgba32: color_conv(&rbuf_tmp, src, color_conv_rgba32_to_argb32()); break; case pix_format_argb32: color_conv(&rbuf_tmp, src, color_conv_argb32_to_argb32()); break; case pix_format_abgr32: color_conv(&rbuf_tmp, src, color_conv_abgr32_to_argb32()); break; case pix_format_bgra32: color_conv(&rbuf_tmp, src, color_conv_bgra32_to_argb32()); break; } break; case pix_format_bgra32: switch(m_format) { default: break; case pix_format_rgb555: color_conv(&rbuf_tmp, src, color_conv_rgb555_to_bgra32()); break; case pix_format_rgb565: color_conv(&rbuf_tmp, src, color_conv_rgb565_to_bgra32()); break; case pix_format_rgb24: color_conv(&rbuf_tmp, src, color_conv_rgb24_to_bgra32()); break; case pix_format_bgr24: color_conv(&rbuf_tmp, src, color_conv_bgr24_to_bgra32()); break; case pix_format_rgba32: color_conv(&rbuf_tmp, src, color_conv_rgba32_to_bgra32()); break; case pix_format_argb32: color_conv(&rbuf_tmp, src, color_conv_argb32_to_bgra32()); break; case pix_format_abgr32: color_conv(&rbuf_tmp, src, color_conv_abgr32_to_bgra32()); break; case pix_format_bgra32: color_conv(&rbuf_tmp, src, color_conv_bgra32_to_bgra32()); break; } break; } m_ximg_window->data = (char*)buf_tmp; XPutImage(m_display, m_window, m_gc, m_ximg_window, 0, 0, 0, 0, src->width(), src->height()); delete [] buf_tmp; } } //------------------------------------------------------------------------ platform_support::platform_support(pix_format_e format, bool flip_y) : m_specific(new platform_specific(format, flip_y)), m_format(format), m_bpp(m_specific->m_bpp), m_window_flags(0), m_wait_mode(true), m_flip_y(flip_y), m_initial_width(10), m_initial_height(10) { strcpy(m_caption, "AGG Application"); } //------------------------------------------------------------------------ platform_support::~platform_support() { delete m_specific; } //------------------------------------------------------------------------ void platform_support::caption(const char* cap) { strcpy(m_caption, cap); if(m_specific->m_initialized) { m_specific->caption(cap); } } //------------------------------------------------------------------------ enum xevent_mask_e { xevent_mask = PointerMotionMask| ButtonPressMask| ButtonReleaseMask| ExposureMask| KeyPressMask| StructureNotifyMask }; //------------------------------------------------------------------------ bool platform_support::init(unsigned width, unsigned height, unsigned flags) { m_window_flags = flags; m_specific->m_display = XOpenDisplay(NULL); if(m_specific->m_display == 0) { fprintf(stderr, "Unable to open DISPLAY!\n"); return false; } m_specific->m_screen = XDefaultScreen(m_specific->m_display); m_specific->m_depth = XDefaultDepth(m_specific->m_display, m_specific->m_screen); m_specific->m_visual = XDefaultVisual(m_specific->m_display, m_specific->m_screen); unsigned long r_mask = m_specific->m_visual->red_mask; unsigned long g_mask = m_specific->m_visual->green_mask; unsigned long b_mask = m_specific->m_visual->blue_mask; //printf("depth=%d, red=%08x, green=%08x, blue=%08x\n", // m_specific->m_depth, // m_specific->m_visual->red_mask, // m_specific->m_visual->green_mask, // m_specific->m_visual->blue_mask); // // NOT COMPLETED YET! // // Try to find an appropriate Visual if the default doesn't fit. // if(m_specific->m_depth < 15 || // r_mask == 0 || g_mask == 0 || b_mask == 0) // { // // // This is an attempt to find an appropriate Visual if // // the default one doesn't match the minumum requirements // static int depth[] = { 32, 24, 16, 15 }; // int i; // for(int i = 0; i < 4; i++) // { // XVisualInfo vi; // if(XMatchVisualInfo(m_specific->m_display, // m_specific->m_screen, // depth[i], // TrueColor, // &vi)) // { // // printf("TrueColor depth=%d, red=%08x, green=%08x, blue=%08x, bits=%d\n", // // vi.depth, // // vi.visual->red_mask, // // vi.visual->green_mask, // // vi.visual->blue_mask, // // vi.bits_per_rgb); // m_specific->m_depth = vi.depth; // m_specific->m_visual = vi.visual; // r_mask = m_specific->m_visual->red_mask; // g_mask = m_specific->m_visual->green_mask; // b_mask = m_specific->m_visual->blue_mask; // break; // } // if(XMatchVisualInfo(m_specific->m_display, // m_specific->m_screen, // depth[i], // DirectColor, // &vi)) // { // // printf("DirectColor depth=%d, red=%08x, green=%08x, blue=%08x, bits=%d\n", // // vi.depth, // // vi.visual->red_mask, // // vi.visual->green_mask, // // vi.visual->blue_mask, // // vi.bits_per_rgb); // m_specific->m_depth = vi.depth; // m_specific->m_visual = vi.visual; // r_mask = m_specific->m_visual->red_mask; // g_mask = m_specific->m_visual->green_mask; // b_mask = m_specific->m_visual->blue_mask; // break; // } // } // } if(m_specific->m_depth < 15 || r_mask == 0 || g_mask == 0 || b_mask == 0) { fprintf(stderr, "There's no Visual compatible with minimal AGG requirements:\n" "At least 15-bit color depth and True- or DirectColor class.\n\n"); XCloseDisplay(m_specific->m_display); return false; } int t = 1; int hw_byte_order = LSBFirst; if(*(char*)&t == 0) hw_byte_order = MSBFirst; // Perceive SYS-format by mask switch(m_specific->m_depth) { case 15: m_specific->m_sys_bpp = 16; if(r_mask == 0x7C00 && g_mask == 0x3E0 && b_mask == 0x1F) { m_specific->m_sys_format = pix_format_rgb555; m_specific->m_byte_order = hw_byte_order; } break; case 16: m_specific->m_sys_bpp = 16; if(r_mask == 0xF800 && g_mask == 0x7E0 && b_mask == 0x1F) { m_specific->m_sys_format = pix_format_rgb565; m_specific->m_byte_order = hw_byte_order; } break; case 24: case 32: m_specific->m_sys_bpp = 32; if(g_mask == 0xFF00) { if(r_mask == 0xFF && b_mask == 0xFF0000) { switch(m_specific->m_format) { case pix_format_rgba32: m_specific->m_sys_format = pix_format_rgba32; m_specific->m_byte_order = LSBFirst; break; case pix_format_abgr32: m_specific->m_sys_format = pix_format_abgr32; m_specific->m_byte_order = MSBFirst; break; default: m_specific->m_byte_order = hw_byte_order; m_specific->m_sys_format = (hw_byte_order == LSBFirst) ? pix_format_rgba32 : pix_format_abgr32; break; } } if(r_mask == 0xFF0000 && b_mask == 0xFF) { switch(m_specific->m_format) { case pix_format_argb32: m_specific->m_sys_format = pix_format_argb32; m_specific->m_byte_order = MSBFirst; break; case pix_format_bgra32: m_specific->m_sys_format = pix_format_bgra32; m_specific->m_byte_order = LSBFirst; break; default: m_specific->m_byte_order = hw_byte_order; m_specific->m_sys_format = (hw_byte_order == MSBFirst) ? pix_format_argb32 : pix_format_bgra32; break; } } } break; } if(m_specific->m_sys_format == pix_format_undefined) { fprintf(stderr, "RGB masks are not compatible with AGG pixel formats:\n" "R=%08x, R=%08x, B=%08x\n", r_mask, g_mask, b_mask); XCloseDisplay(m_specific->m_display); return false; } memset(&m_specific->m_window_attributes, 0, sizeof(m_specific->m_window_attributes)); m_specific->m_window_attributes.border_pixel = XBlackPixel(m_specific->m_display, m_specific->m_screen); m_specific->m_window_attributes.background_pixel = XWhitePixel(m_specific->m_display, m_specific->m_screen); m_specific->m_window_attributes.override_redirect = 0; unsigned long window_mask = CWBackPixel | CWBorderPixel; m_specific->m_window = XCreateWindow(m_specific->m_display, XDefaultRootWindow(m_specific->m_display), 0, 0, width, height, 0, m_specific->m_depth, InputOutput, CopyFromParent, window_mask, &m_specific->m_window_attributes); m_specific->m_gc = XCreateGC(m_specific->m_display, m_specific->m_window, 0, 0); m_specific->m_buf_window = new unsigned char[width * height * (m_bpp / 8)]; memset(m_specific->m_buf_window, 255, width * height * (m_bpp / 8)); m_rbuf_window.attach(m_specific->m_buf_window, width, height, m_flip_y ? -width * (m_bpp / 8) : width * (m_bpp / 8)); m_specific->m_ximg_window = XCreateImage(m_specific->m_display, m_specific->m_visual, //CopyFromParent, m_specific->m_depth, ZPixmap, 0, (char*)m_specific->m_buf_window, width, height, m_specific->m_sys_bpp, width * (m_specific->m_sys_bpp / 8)); m_specific->m_ximg_window->byte_order = m_specific->m_byte_order; m_specific->caption(m_caption); m_initial_width = width; m_initial_height = height; if(!m_specific->m_initialized) { on_init(); m_specific->m_initialized = true; } trans_affine_resizing(width, height); on_resize(width, height); m_specific->m_update_flag = true; XSizeHints *hints = XAllocSizeHints(); if(hints) { if(flags & window_resize) { hints->min_width = 32; hints->min_height = 32; hints->max_width = 4096; hints->max_height = 4096; } else { hints->min_width = width; hints->min_height = height; hints->max_width = width; hints->max_height = height; } hints->flags = PMaxSize | PMinSize; XSetWMNormalHints(m_specific->m_display, m_specific->m_window, hints); XFree(hints); } XMapWindow(m_specific->m_display, m_specific->m_window); XSelectInput(m_specific->m_display, m_specific->m_window, xevent_mask); m_specific->m_close_atom = XInternAtom(m_specific->m_display, "WM_DELETE_WINDOW", false); XSetWMProtocols(m_specific->m_display, m_specific->m_window, &m_specific->m_close_atom, 1); return true; } //------------------------------------------------------------------------ void platform_support::update_window() { m_specific->put_image(&m_rbuf_window); // When m_wait_mode is true we can discard all the events // came while the image is being drawn. In this case // the X server does not accumulate mouse motion events. // When m_wait_mode is false, i.e. we have some idle drawing // we cannot afford to miss any events XSync(m_specific->m_display, m_wait_mode); } //------------------------------------------------------------------------ int platform_support::run() { XFlush(m_specific->m_display); bool quit = false; unsigned flags; int cur_x; int cur_y; while(!quit) { if(m_specific->m_update_flag) { on_draw(); update_window(); m_specific->m_update_flag = false; } if(!m_wait_mode) { if(XPending(m_specific->m_display) == 0) { on_idle(); continue; } } XEvent x_event; XNextEvent(m_specific->m_display, &x_event); // In the Idle mode discard all intermediate MotionNotify events if(!m_wait_mode && x_event.type == MotionNotify) { XEvent te = x_event; for(;;) { if(XPending(m_specific->m_display) == 0) break; XNextEvent(m_specific->m_display, &te); if(te.type != MotionNotify) break; } x_event = te; } switch(x_event.type) { case ConfigureNotify: { if(x_event.xconfigure.width != int(m_rbuf_window.width()) || x_event.xconfigure.height != int(m_rbuf_window.height())) { int width = x_event.xconfigure.width; int height = x_event.xconfigure.height; delete [] m_specific->m_buf_window; m_specific->m_ximg_window->data = 0; XDestroyImage(m_specific->m_ximg_window); m_specific->m_buf_window = new unsigned char[width * height * (m_bpp / 8)]; m_rbuf_window.attach(m_specific->m_buf_window, width, height, m_flip_y ? -width * (m_bpp / 8) : width * (m_bpp / 8)); m_specific->m_ximg_window = XCreateImage(m_specific->m_display, m_specific->m_visual, //CopyFromParent, m_specific->m_depth, ZPixmap, 0, (char*)m_specific->m_buf_window, width, height, m_specific->m_sys_bpp, width * (m_specific->m_sys_bpp / 8)); m_specific->m_ximg_window->byte_order = m_specific->m_byte_order; trans_affine_resizing(width, height); on_resize(width, height); on_draw(); update_window(); } } break; case Expose: m_specific->put_image(&m_rbuf_window); XFlush(m_specific->m_display); XSync(m_specific->m_display, false); break; case KeyPress: { KeySym key = XLookupKeysym(&x_event.xkey, 0); flags = 0; if(x_event.xkey.state & Button1Mask) flags |= mouse_left; if(x_event.xkey.state & Button3Mask) flags |= mouse_right; if(x_event.xkey.state & ShiftMask) flags |= kbd_shift; if(x_event.xkey.state & ControlMask) flags |= kbd_ctrl; bool left = false; bool up = false; bool right = false; bool down = false; switch(m_specific->m_keymap[key & 0xFF]) { case key_left: left = true; break; case key_up: up = true; break; case key_right: right = true; break; case key_down: down = true; break; case key_f2: copy_window_to_img(max_images - 1); save_img(max_images - 1, "screenshot"); break; } if(m_ctrls.on_arrow_keys(left, right, down, up)) { on_ctrl_change(); force_redraw(); } else { on_key(x_event.xkey.x, m_flip_y ? m_rbuf_window.height() - x_event.xkey.y : x_event.xkey.y, m_specific->m_keymap[key & 0xFF], flags); } } break; case ButtonPress: { flags = 0; if(x_event.xbutton.state & ShiftMask) flags |= kbd_shift; if(x_event.xbutton.state & ControlMask) flags |= kbd_ctrl; if(x_event.xbutton.button == Button1) flags |= mouse_left; if(x_event.xbutton.button == Button3) flags |= mouse_right; cur_x = x_event.xbutton.x; cur_y = m_flip_y ? m_rbuf_window.height() - x_event.xbutton.y : x_event.xbutton.y; if(flags & mouse_left) { if(m_ctrls.on_mouse_button_down(cur_x, cur_y)) { m_ctrls.set_cur(cur_x, cur_y); on_ctrl_change(); force_redraw(); } else { if(m_ctrls.in_rect(cur_x, cur_y)) { if(m_ctrls.set_cur(cur_x, cur_y)) { on_ctrl_change(); force_redraw(); } } else { on_mouse_button_down(cur_x, cur_y, flags); } } } if(flags & mouse_right) { on_mouse_button_down(cur_x, cur_y, flags); } //m_specific->m_wait_mode = m_wait_mode; //m_wait_mode = true; } break; case MotionNotify: { flags = 0; if(x_event.xmotion.state & Button1Mask) flags |= mouse_left; if(x_event.xmotion.state & Button3Mask) flags |= mouse_right; if(x_event.xmotion.state & ShiftMask) flags |= kbd_shift; if(x_event.xmotion.state & ControlMask) flags |= kbd_ctrl; cur_x = x_event.xbutton.x; cur_y = m_flip_y ? m_rbuf_window.height() - x_event.xbutton.y : x_event.xbutton.y; if(m_ctrls.on_mouse_move(cur_x, cur_y, (flags & mouse_left) != 0)) { on_ctrl_change(); force_redraw(); } else { if(!m_ctrls.in_rect(cur_x, cur_y)) { on_mouse_move(cur_x, cur_y, flags); } } } break; case ButtonRelease: { flags = 0; if(x_event.xbutton.state & ShiftMask) flags |= kbd_shift; if(x_event.xbutton.state & ControlMask) flags |= kbd_ctrl; if(x_event.xbutton.button == Button1) flags |= mouse_left; if(x_event.xbutton.button == Button3) flags |= mouse_right; cur_x = x_event.xbutton.x; cur_y = m_flip_y ? m_rbuf_window.height() - x_event.xbutton.y : x_event.xbutton.y; if(flags & mouse_left) { if(m_ctrls.on_mouse_button_up(cur_x, cur_y)) { on_ctrl_change(); force_redraw(); } } if(flags & (mouse_left | mouse_right)) { on_mouse_button_up(cur_x, cur_y, flags); } } //m_wait_mode = m_specific->m_wait_mode; break; case ClientMessage: if((x_event.xclient.format == 32) && (x_event.xclient.data.l[0] == int(m_specific->m_close_atom))) { quit = true; } break; } } unsigned i = platform_support::max_images; while(i--) { if(m_specific->m_buf_img[i]) { delete [] m_specific->m_buf_img[i]; } } delete [] m_specific->m_buf_window; m_specific->m_ximg_window->data = 0; XDestroyImage(m_specific->m_ximg_window); XFreeGC(m_specific->m_display, m_specific->m_gc); XDestroyWindow(m_specific->m_display, m_specific->m_window); XCloseDisplay(m_specific->m_display); return 0; } //------------------------------------------------------------------------ const char* platform_support::img_ext() const { return ".ppm"; } //------------------------------------------------------------------------ const char* platform_support::full_file_name(const char* file_name) { return file_name; } //------------------------------------------------------------------------ bool platform_support::load_img(unsigned idx, const char* file) { if(idx < max_images) { char buf[1024]; strcpy(buf, file); int len = strlen(buf); if(len < 4 || strcasecmp(buf + len - 4, ".ppm") != 0) { strcat(buf, ".ppm"); } FILE* fd = fopen(buf, "rb"); if(fd == 0) return false; if((len = fread(buf, 1, 1022, fd)) == 0) { fclose(fd); return false; } buf[len] = 0; if(buf[0] != 'P' && buf[1] != '6') { fclose(fd); return false; } char* ptr = buf + 2; while(*ptr && !isdigit(*ptr)) ptr++; if(*ptr == 0) { fclose(fd); return false; } unsigned width = atoi(ptr); if(width == 0 || width > 4096) { fclose(fd); return false; } while(*ptr && isdigit(*ptr)) ptr++; while(*ptr && !isdigit(*ptr)) ptr++; if(*ptr == 0) { fclose(fd); return false; } unsigned height = atoi(ptr); if(height == 0 || height > 4096) { fclose(fd); return false; } while(*ptr && isdigit(*ptr)) ptr++; while(*ptr && !isdigit(*ptr)) ptr++; if(atoi(ptr) != 255) { fclose(fd); return false; } while(*ptr && isdigit(*ptr)) ptr++; if(*ptr == 0) { fclose(fd); return false; } ptr++; fseek(fd, long(ptr - buf), SEEK_SET); create_img(idx, width, height); bool ret = true; if(m_format == pix_format_rgb24) { fread(m_specific->m_buf_img[idx], 1, width * height * 3, fd); } else { unsigned char* buf_img = new unsigned char [width * height * 3]; rendering_buffer rbuf_img; rbuf_img.attach(buf_img, width, height, m_flip_y ? -width * 3 : width * 3); fread(buf_img, 1, width * height * 3, fd); switch(m_format) { case pix_format_rgb555: color_conv(m_rbuf_img+idx, &rbuf_img, color_conv_rgb24_to_rgb555()); break; case pix_format_rgb565: color_conv(m_rbuf_img+idx, &rbuf_img, color_conv_rgb24_to_rgb565()); break; case pix_format_bgr24: color_conv(m_rbuf_img+idx, &rbuf_img, color_conv_rgb24_to_bgr24()); break; case pix_format_rgba32: color_conv(m_rbuf_img+idx, &rbuf_img, color_conv_rgb24_to_rgba32()); break; case pix_format_argb32: color_conv(m_rbuf_img+idx, &rbuf_img, color_conv_rgb24_to_argb32()); break; case pix_format_bgra32: color_conv(m_rbuf_img+idx, &rbuf_img, color_conv_rgb24_to_bgra32()); break; case pix_format_abgr32: color_conv(m_rbuf_img+idx, &rbuf_img, color_conv_rgb24_to_abgr32()); break; default: ret = false; } delete [] buf_img; } fclose(fd); return ret; } return false; } //------------------------------------------------------------------------ bool platform_support::save_img(unsigned idx, const char* file) { if(idx < max_images && rbuf_img(idx).buf()) { char buf[1024]; strcpy(buf, file); int len = strlen(buf); if(len < 4 || strcasecmp(buf + len - 4, ".ppm") != 0) { strcat(buf, ".ppm"); } FILE* fd = fopen(buf, "wb"); if(fd == 0) return false; unsigned w = rbuf_img(idx).width(); unsigned h = rbuf_img(idx).height(); fprintf(fd, "P6\n%d %d\n255\n", w, h); unsigned y; unsigned char* tmp_buf = new unsigned char [w * 3]; for(y = 0; y < rbuf_img(idx).height(); y++) { const unsigned char* src = rbuf_img(idx).row_ptr(m_flip_y ? h - 1 - y : y); switch(m_format) { default: break; case pix_format_rgb555: color_conv_row(tmp_buf, src, w, color_conv_rgb555_to_rgb24()); break; case pix_format_rgb565: color_conv_row(tmp_buf, src, w, color_conv_rgb565_to_rgb24()); break; case pix_format_bgr24: color_conv_row(tmp_buf, src, w, color_conv_bgr24_to_rgb24()); break; case pix_format_rgb24: color_conv_row(tmp_buf, src, w, color_conv_rgb24_to_rgb24()); break; case pix_format_rgba32: color_conv_row(tmp_buf, src, w, color_conv_rgba32_to_rgb24()); break; case pix_format_argb32: color_conv_row(tmp_buf, src, w, color_conv_argb32_to_rgb24()); break; case pix_format_bgra32: color_conv_row(tmp_buf, src, w, color_conv_bgra32_to_rgb24()); break; case pix_format_abgr32: color_conv_row(tmp_buf, src, w, color_conv_abgr32_to_rgb24()); break; } fwrite(tmp_buf, 1, w * 3, fd); } delete [] tmp_buf; fclose(fd); return true; } return false; } //------------------------------------------------------------------------ bool platform_support::create_img(unsigned idx, unsigned width, unsigned height) { if(idx < max_images) { if(width == 0) width = rbuf_window().width(); if(height == 0) height = rbuf_window().height(); delete [] m_specific->m_buf_img[idx]; m_specific->m_buf_img[idx] = new unsigned char[width * height * (m_bpp / 8)]; m_rbuf_img[idx].attach(m_specific->m_buf_img[idx], width, height, m_flip_y ? -width * (m_bpp / 8) : width * (m_bpp / 8)); return true; } return false; } //------------------------------------------------------------------------ void platform_support::force_redraw() { m_specific->m_update_flag = true; } //------------------------------------------------------------------------ void platform_support::message(const char* msg) { fprintf(stderr, "%s\n", msg); } //------------------------------------------------------------------------ void platform_support::start_timer() { m_specific->m_sw_start = clock(); } //------------------------------------------------------------------------ double platform_support::elapsed_time() const { clock_t stop = clock(); return double(stop - m_specific->m_sw_start) * 1000.0 / CLOCKS_PER_SEC; } //------------------------------------------------------------------------ void platform_support::on_init() {} void platform_support::on_resize(int sx, int sy) {} void platform_support::on_idle() {} void platform_support::on_mouse_move(int x, int y, unsigned flags) {} void platform_support::on_mouse_button_down(int x, int y, unsigned flags) {} void platform_support::on_mouse_button_up(int x, int y, unsigned flags) {} void platform_support::on_key(int x, int y, unsigned key, unsigned flags) {} void platform_support::on_ctrl_change() {} void platform_support::on_draw() {} void platform_support::on_post_draw(void* raw_handler) {} } int agg_main(int argc, char* argv[]); int main(int argc, char* argv[]) { return agg_main(argc, argv); } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/X11/Makefile.am0000644000175000017500000000046612516137326024377 0ustar varunvarunif ENABLE_X11 lib_LTLIBRARIES = libaggplatformX11.la libaggplatformX11_la_LDFLAGS = -version-info @AGG_LIB_VERSION@ -L@x_libraries@ libaggplatformX11_la_SOURCES = agg_platform_support.cpp libaggplatformX11_la_CXXFLAGS = -I$(top_srcdir)/include @x_includes@ libaggplatformX11_la_LIBADD = -lX11 endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/win32/0000755000175000017500000000000012516137725022731 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/win32/agg_platform_support.cpp0000644000175000017500000013711612516137326027701 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class platform_support // //---------------------------------------------------------------------------- #include #include #include "platform/agg_platform_support.h" #include "platform/win32/agg_win32_bmp.h" #include "util/agg_color_conv_rgb8.h" #include "util/agg_color_conv_rgb16.h" namespace agg24 { //------------------------------------------------------------------------ HINSTANCE g_windows_instance = 0; int g_windows_cmd_show = 0; //------------------------------------------------------------------------ class platform_specific { public: platform_specific(pix_format_e format, bool flip_y); void create_pmap(unsigned width, unsigned height, rendering_buffer* wnd); void display_pmap(HDC dc, const rendering_buffer* src); bool load_pmap(const char* fn, unsigned idx, rendering_buffer* dst); bool save_pmap(const char* fn, unsigned idx, const rendering_buffer* src); unsigned translate(unsigned keycode); pix_format_e m_format; pix_format_e m_sys_format; bool m_flip_y; unsigned m_bpp; unsigned m_sys_bpp; HWND m_hwnd; pixel_map m_pmap_window; pixel_map m_pmap_img[platform_support::max_images]; unsigned m_keymap[256]; unsigned m_last_translated_key; int m_cur_x; int m_cur_y; unsigned m_input_flags; bool m_redraw_flag; HDC m_current_dc; LARGE_INTEGER m_sw_freq; LARGE_INTEGER m_sw_start; }; //------------------------------------------------------------------------ platform_specific::platform_specific(pix_format_e format, bool flip_y) : m_format(format), m_sys_format(pix_format_undefined), m_flip_y(flip_y), m_bpp(0), m_sys_bpp(0), m_hwnd(0), m_last_translated_key(0), m_cur_x(0), m_cur_y(0), m_input_flags(0), m_redraw_flag(true), m_current_dc(0) { memset(m_keymap, 0, sizeof(m_keymap)); m_keymap[VK_PAUSE] = key_pause; m_keymap[VK_CLEAR] = key_clear; m_keymap[VK_NUMPAD0] = key_kp0; m_keymap[VK_NUMPAD1] = key_kp1; m_keymap[VK_NUMPAD2] = key_kp2; m_keymap[VK_NUMPAD3] = key_kp3; m_keymap[VK_NUMPAD4] = key_kp4; m_keymap[VK_NUMPAD5] = key_kp5; m_keymap[VK_NUMPAD6] = key_kp6; m_keymap[VK_NUMPAD7] = key_kp7; m_keymap[VK_NUMPAD8] = key_kp8; m_keymap[VK_NUMPAD9] = key_kp9; m_keymap[VK_DECIMAL] = key_kp_period; m_keymap[VK_DIVIDE] = key_kp_divide; m_keymap[VK_MULTIPLY] = key_kp_multiply; m_keymap[VK_SUBTRACT] = key_kp_minus; m_keymap[VK_ADD] = key_kp_plus; m_keymap[VK_UP] = key_up; m_keymap[VK_DOWN] = key_down; m_keymap[VK_RIGHT] = key_right; m_keymap[VK_LEFT] = key_left; m_keymap[VK_INSERT] = key_insert; m_keymap[VK_DELETE] = key_delete; m_keymap[VK_HOME] = key_home; m_keymap[VK_END] = key_end; m_keymap[VK_PRIOR] = key_page_up; m_keymap[VK_NEXT] = key_page_down; m_keymap[VK_F1] = key_f1; m_keymap[VK_F2] = key_f2; m_keymap[VK_F3] = key_f3; m_keymap[VK_F4] = key_f4; m_keymap[VK_F5] = key_f5; m_keymap[VK_F6] = key_f6; m_keymap[VK_F7] = key_f7; m_keymap[VK_F8] = key_f8; m_keymap[VK_F9] = key_f9; m_keymap[VK_F10] = key_f10; m_keymap[VK_F11] = key_f11; m_keymap[VK_F12] = key_f12; m_keymap[VK_F13] = key_f13; m_keymap[VK_F14] = key_f14; m_keymap[VK_F15] = key_f15; m_keymap[VK_NUMLOCK] = key_numlock; m_keymap[VK_CAPITAL] = key_capslock; m_keymap[VK_SCROLL] = key_scrollock; switch(m_format) { case pix_format_bw: m_sys_format = pix_format_bw; m_bpp = 1; m_sys_bpp = 1; break; case pix_format_gray8: m_sys_format = pix_format_gray8; m_bpp = 8; m_sys_bpp = 8; break; case pix_format_gray16: m_sys_format = pix_format_gray8; m_bpp = 16; m_sys_bpp = 8; break; case pix_format_rgb565: case pix_format_rgb555: m_sys_format = pix_format_rgb555; m_bpp = 16; m_sys_bpp = 16; break; case pix_format_rgbAAA: case pix_format_bgrAAA: case pix_format_rgbBBA: case pix_format_bgrABB: m_sys_format = pix_format_bgr24; m_bpp = 32; m_sys_bpp = 24; break; case pix_format_rgb24: case pix_format_bgr24: m_sys_format = pix_format_bgr24; m_bpp = 24; m_sys_bpp = 24; break; case pix_format_rgb48: case pix_format_bgr48: m_sys_format = pix_format_bgr24; m_bpp = 48; m_sys_bpp = 24; break; case pix_format_bgra32: case pix_format_abgr32: case pix_format_argb32: case pix_format_rgba32: m_sys_format = pix_format_bgra32; m_bpp = 32; m_sys_bpp = 32; break; case pix_format_bgra64: case pix_format_abgr64: case pix_format_argb64: case pix_format_rgba64: m_sys_format = pix_format_bgra32; m_bpp = 64; m_sys_bpp = 32; break; } ::QueryPerformanceFrequency(&m_sw_freq); ::QueryPerformanceCounter(&m_sw_start); } //------------------------------------------------------------------------ void platform_specific::create_pmap(unsigned width, unsigned height, rendering_buffer* wnd) { m_pmap_window.create(width, height, org_e(m_bpp)); wnd->attach(m_pmap_window.buf(), m_pmap_window.width(), m_pmap_window.height(), m_flip_y ? m_pmap_window.stride() : -m_pmap_window.stride()); } //------------------------------------------------------------------------ static void convert_pmap(rendering_buffer* dst, const rendering_buffer* src, pix_format_e format) { switch(format) { case pix_format_gray8: break; case pix_format_gray16: color_conv(dst, src, color_conv_gray16_to_gray8()); break; case pix_format_rgb565: color_conv(dst, src, color_conv_rgb565_to_rgb555()); break; case pix_format_rgbAAA: color_conv(dst, src, color_conv_rgbAAA_to_bgr24()); break; case pix_format_bgrAAA: color_conv(dst, src, color_conv_bgrAAA_to_bgr24()); break; case pix_format_rgbBBA: color_conv(dst, src, color_conv_rgbBBA_to_bgr24()); break; case pix_format_bgrABB: color_conv(dst, src, color_conv_bgrABB_to_bgr24()); break; case pix_format_rgb24: color_conv(dst, src, color_conv_rgb24_to_bgr24()); break; case pix_format_rgb48: color_conv(dst, src, color_conv_rgb48_to_bgr24()); break; case pix_format_bgr48: color_conv(dst, src, color_conv_bgr48_to_bgr24()); break; case pix_format_abgr32: color_conv(dst, src, color_conv_abgr32_to_bgra32()); break; case pix_format_argb32: color_conv(dst, src, color_conv_argb32_to_bgra32()); break; case pix_format_rgba32: color_conv(dst, src, color_conv_rgba32_to_bgra32()); break; case pix_format_bgra64: color_conv(dst, src, color_conv_bgra64_to_bgra32()); break; case pix_format_abgr64: color_conv(dst, src, color_conv_abgr64_to_bgra32()); break; case pix_format_argb64: color_conv(dst, src, color_conv_argb64_to_bgra32()); break; case pix_format_rgba64: color_conv(dst, src, color_conv_rgba64_to_bgra32()); break; } } //------------------------------------------------------------------------ void platform_specific::display_pmap(HDC dc, const rendering_buffer* src) { if(m_sys_format == m_format) { m_pmap_window.draw(dc); } else { pixel_map pmap_tmp; pmap_tmp.create(m_pmap_window.width(), m_pmap_window.height(), org_e(m_sys_bpp)); rendering_buffer rbuf_tmp; rbuf_tmp.attach(pmap_tmp.buf(), pmap_tmp.width(), pmap_tmp.height(), m_flip_y ? pmap_tmp.stride() : -pmap_tmp.stride()); convert_pmap(&rbuf_tmp, src, m_format); pmap_tmp.draw(dc); } } //------------------------------------------------------------------------ bool platform_specific::save_pmap(const char* fn, unsigned idx, const rendering_buffer* src) { if(m_sys_format == m_format) { return m_pmap_img[idx].save_as_bmp(fn); } pixel_map pmap_tmp; pmap_tmp.create(m_pmap_img[idx].width(), m_pmap_img[idx].height(), org_e(m_sys_bpp)); rendering_buffer rbuf_tmp; rbuf_tmp.attach(pmap_tmp.buf(), pmap_tmp.width(), pmap_tmp.height(), m_flip_y ? pmap_tmp.stride() : -pmap_tmp.stride()); convert_pmap(&rbuf_tmp, src, m_format); return pmap_tmp.save_as_bmp(fn); } //------------------------------------------------------------------------ bool platform_specific::load_pmap(const char* fn, unsigned idx, rendering_buffer* dst) { pixel_map pmap_tmp; if(!pmap_tmp.load_from_bmp(fn)) return false; rendering_buffer rbuf_tmp; rbuf_tmp.attach(pmap_tmp.buf(), pmap_tmp.width(), pmap_tmp.height(), m_flip_y ? pmap_tmp.stride() : -pmap_tmp.stride()); m_pmap_img[idx].create(pmap_tmp.width(), pmap_tmp.height(), org_e(m_bpp), 0); dst->attach(m_pmap_img[idx].buf(), m_pmap_img[idx].width(), m_pmap_img[idx].height(), m_flip_y ? m_pmap_img[idx].stride() : -m_pmap_img[idx].stride()); switch(m_format) { case pix_format_gray8: switch(pmap_tmp.bpp()) { //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_gray8()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_gray8()); break; //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_gray8()); break; } break; case pix_format_gray16: switch(pmap_tmp.bpp()) { //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_gray16()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_gray16()); break; //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_gray16()); break; } break; case pix_format_rgb555: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb555()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgb555()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgb555()); break; } break; case pix_format_rgb565: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb565()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgb565()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgb565()); break; } break; case pix_format_rgb24: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb24()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgb24()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgb24()); break; } break; case pix_format_bgr24: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgr24()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_bgr24()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_bgr24()); break; } break; case pix_format_rgb48: switch(pmap_tmp.bpp()) { //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgb48()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgb48()); break; //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgb48()); break; } break; case pix_format_bgr48: switch(pmap_tmp.bpp()) { //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgr48()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_bgr48()); break; //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_bgr48()); break; } break; case pix_format_abgr32: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_abgr32()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_abgr32()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_abgr32()); break; } break; case pix_format_argb32: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_argb32()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_argb32()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_argb32()); break; } break; case pix_format_bgra32: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgra32()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_bgra32()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_bgra32()); break; } break; case pix_format_rgba32: switch(pmap_tmp.bpp()) { case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgba32()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgba32()); break; case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgba32()); break; } break; case pix_format_abgr64: switch(pmap_tmp.bpp()) { //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_abgr64()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_abgr64()); break; //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_abgr64()); break; } break; case pix_format_argb64: switch(pmap_tmp.bpp()) { //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_argb64()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_argb64()); break; //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_argb64()); break; } break; case pix_format_bgra64: switch(pmap_tmp.bpp()) { //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_bgra64()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_bgra64()); break; //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_bgra64()); break; } break; case pix_format_rgba64: switch(pmap_tmp.bpp()) { //case 16: color_conv(dst, &rbuf_tmp, color_conv_rgb555_to_rgba64()); break; case 24: color_conv(dst, &rbuf_tmp, color_conv_bgr24_to_rgba64()); break; //case 32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgba64()); break; } break; } return true; } //------------------------------------------------------------------------ unsigned platform_specific::translate(unsigned keycode) { return m_last_translated_key = (keycode > 255) ? 0 : m_keymap[keycode]; } //------------------------------------------------------------------------ platform_support::platform_support(pix_format_e format, bool flip_y) : m_specific(new platform_specific(format, flip_y)), m_format(format), m_bpp(m_specific->m_bpp), m_window_flags(0), m_wait_mode(true), m_flip_y(flip_y), m_initial_width(10), m_initial_height(10) { strcpy(m_caption, "Anti-Grain Geometry Application"); } //------------------------------------------------------------------------ platform_support::~platform_support() { delete m_specific; } //------------------------------------------------------------------------ void platform_support::caption(const char* cap) { strcpy(m_caption, cap); if(m_specific->m_hwnd) { SetWindowText(m_specific->m_hwnd, m_caption); } } //------------------------------------------------------------------------ void platform_support::start_timer() { ::QueryPerformanceCounter(&(m_specific->m_sw_start)); } //------------------------------------------------------------------------ double platform_support::elapsed_time() const { LARGE_INTEGER stop; ::QueryPerformanceCounter(&stop); return double(stop.QuadPart - m_specific->m_sw_start.QuadPart) * 1000.0 / double(m_specific->m_sw_freq.QuadPart); } //------------------------------------------------------------------------ static unsigned get_key_flags(int wflags) { unsigned flags = 0; if(wflags & MK_LBUTTON) flags |= mouse_left; if(wflags & MK_RBUTTON) flags |= mouse_right; if(wflags & MK_SHIFT) flags |= kbd_shift; if(wflags & MK_CONTROL) flags |= kbd_ctrl; return flags; } void* platform_support::raw_display_handler() { return m_specific->m_current_dc; } //------------------------------------------------------------------------ LRESULT CALLBACK window_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC paintDC; void* user_data = reinterpret_cast(::GetWindowLong(hWnd, GWL_USERDATA)); platform_support* app = 0; if(user_data) { app = reinterpret_cast(user_data); } if(app == 0) { if(msg == WM_DESTROY) { ::PostQuitMessage(0); return 0; } return ::DefWindowProc(hWnd, msg, wParam, lParam); } HDC dc = ::GetDC(app->m_specific->m_hwnd); app->m_specific->m_current_dc = dc; LRESULT ret = 0; switch(msg) { //-------------------------------------------------------------------- case WM_CREATE: break; //-------------------------------------------------------------------- case WM_SIZE: app->m_specific->create_pmap(LOWORD(lParam), HIWORD(lParam), &app->rbuf_window()); app->trans_affine_resizing(LOWORD(lParam), HIWORD(lParam)); app->on_resize(LOWORD(lParam), HIWORD(lParam)); app->force_redraw(); break; //-------------------------------------------------------------------- case WM_ERASEBKGND: break; //-------------------------------------------------------------------- case WM_LBUTTONDOWN: ::SetCapture(app->m_specific->m_hwnd); app->m_specific->m_cur_x = int16(LOWORD(lParam)); if(app->flip_y()) { app->m_specific->m_cur_y = app->rbuf_window().height() - int16(HIWORD(lParam)); } else { app->m_specific->m_cur_y = int16(HIWORD(lParam)); } app->m_specific->m_input_flags = mouse_left | get_key_flags(wParam); app->m_ctrls.set_cur(app->m_specific->m_cur_x, app->m_specific->m_cur_y); if(app->m_ctrls.on_mouse_button_down(app->m_specific->m_cur_x, app->m_specific->m_cur_y)) { app->on_ctrl_change(); app->force_redraw(); } else { if(app->m_ctrls.in_rect(app->m_specific->m_cur_x, app->m_specific->m_cur_y)) { if(app->m_ctrls.set_cur(app->m_specific->m_cur_x, app->m_specific->m_cur_y)) { app->on_ctrl_change(); app->force_redraw(); } } else { app->on_mouse_button_down(app->m_specific->m_cur_x, app->m_specific->m_cur_y, app->m_specific->m_input_flags); } } /* if(!app->wait_mode()) { app->on_idle(); } */ break; //-------------------------------------------------------------------- case WM_LBUTTONUP: ::ReleaseCapture(); app->m_specific->m_cur_x = int16(LOWORD(lParam)); if(app->flip_y()) { app->m_specific->m_cur_y = app->rbuf_window().height() - int16(HIWORD(lParam)); } else { app->m_specific->m_cur_y = int16(HIWORD(lParam)); } app->m_specific->m_input_flags = mouse_left | get_key_flags(wParam); if(app->m_ctrls.on_mouse_button_up(app->m_specific->m_cur_x, app->m_specific->m_cur_y)) { app->on_ctrl_change(); app->force_redraw(); } app->on_mouse_button_up(app->m_specific->m_cur_x, app->m_specific->m_cur_y, app->m_specific->m_input_flags); /* if(!app->wait_mode()) { app->on_idle(); } */ break; //-------------------------------------------------------------------- case WM_RBUTTONDOWN: ::SetCapture(app->m_specific->m_hwnd); app->m_specific->m_cur_x = int16(LOWORD(lParam)); if(app->flip_y()) { app->m_specific->m_cur_y = app->rbuf_window().height() - int16(HIWORD(lParam)); } else { app->m_specific->m_cur_y = int16(HIWORD(lParam)); } app->m_specific->m_input_flags = mouse_right | get_key_flags(wParam); app->on_mouse_button_down(app->m_specific->m_cur_x, app->m_specific->m_cur_y, app->m_specific->m_input_flags); /* if(!app->wait_mode()) { app->on_idle(); } */ break; //-------------------------------------------------------------------- case WM_RBUTTONUP: ::ReleaseCapture(); app->m_specific->m_cur_x = int16(LOWORD(lParam)); if(app->flip_y()) { app->m_specific->m_cur_y = app->rbuf_window().height() - int16(HIWORD(lParam)); } else { app->m_specific->m_cur_y = int16(HIWORD(lParam)); } app->m_specific->m_input_flags = mouse_right | get_key_flags(wParam); app->on_mouse_button_up(app->m_specific->m_cur_x, app->m_specific->m_cur_y, app->m_specific->m_input_flags); /* if(!app->wait_mode()) { app->on_idle(); } */ break; //-------------------------------------------------------------------- case WM_MOUSEMOVE: app->m_specific->m_cur_x = int16(LOWORD(lParam)); if(app->flip_y()) { app->m_specific->m_cur_y = app->rbuf_window().height() - int16(HIWORD(lParam)); } else { app->m_specific->m_cur_y = int16(HIWORD(lParam)); } app->m_specific->m_input_flags = get_key_flags(wParam); if(app->m_ctrls.on_mouse_move( app->m_specific->m_cur_x, app->m_specific->m_cur_y, (app->m_specific->m_input_flags & mouse_left) != 0)) { app->on_ctrl_change(); app->force_redraw(); } else { if(!app->m_ctrls.in_rect(app->m_specific->m_cur_x, app->m_specific->m_cur_y)) { app->on_mouse_move(app->m_specific->m_cur_x, app->m_specific->m_cur_y, app->m_specific->m_input_flags); } } /* if(!app->wait_mode()) { app->on_idle(); } */ break; //-------------------------------------------------------------------- case WM_SYSKEYDOWN: case WM_KEYDOWN: app->m_specific->m_last_translated_key = 0; switch(wParam) { case VK_CONTROL: app->m_specific->m_input_flags |= kbd_ctrl; break; case VK_SHIFT: app->m_specific->m_input_flags |= kbd_shift; break; default: app->m_specific->translate(wParam); break; } if(app->m_specific->m_last_translated_key) { bool left = false; bool up = false; bool right = false; bool down = false; switch(app->m_specific->m_last_translated_key) { case key_left: left = true; break; case key_up: up = true; break; case key_right: right = true; break; case key_down: down = true; break; case key_f2: app->copy_window_to_img(agg24::platform_support::max_images - 1); app->save_img(agg24::platform_support::max_images - 1, "screenshot"); break; } if(app->window_flags() & window_process_all_keys) { app->on_key(app->m_specific->m_cur_x, app->m_specific->m_cur_y, app->m_specific->m_last_translated_key, app->m_specific->m_input_flags); } else { if(app->m_ctrls.on_arrow_keys(left, right, down, up)) { app->on_ctrl_change(); app->force_redraw(); } else { app->on_key(app->m_specific->m_cur_x, app->m_specific->m_cur_y, app->m_specific->m_last_translated_key, app->m_specific->m_input_flags); } } } /* if(!app->wait_mode()) { app->on_idle(); } */ break; //-------------------------------------------------------------------- case WM_SYSKEYUP: case WM_KEYUP: app->m_specific->m_last_translated_key = 0; switch(wParam) { case VK_CONTROL: app->m_specific->m_input_flags &= ~kbd_ctrl; break; case VK_SHIFT: app->m_specific->m_input_flags &= ~kbd_shift; break; } break; //-------------------------------------------------------------------- case WM_CHAR: case WM_SYSCHAR: if(app->m_specific->m_last_translated_key == 0) { app->on_key(app->m_specific->m_cur_x, app->m_specific->m_cur_y, wParam, app->m_specific->m_input_flags); } break; //-------------------------------------------------------------------- case WM_PAINT: paintDC = ::BeginPaint(hWnd, &ps); app->m_specific->m_current_dc = paintDC; if(app->m_specific->m_redraw_flag) { app->on_draw(); app->m_specific->m_redraw_flag = false; } app->m_specific->display_pmap(paintDC, &app->rbuf_window()); app->on_post_draw(paintDC); app->m_specific->m_current_dc = 0; ::EndPaint(hWnd, &ps); break; //-------------------------------------------------------------------- case WM_COMMAND: break; //-------------------------------------------------------------------- case WM_DESTROY: ::PostQuitMessage(0); break; //-------------------------------------------------------------------- default: ret = ::DefWindowProc(hWnd, msg, wParam, lParam); break; } app->m_specific->m_current_dc = 0; ::ReleaseDC(app->m_specific->m_hwnd, dc); return ret; } //------------------------------------------------------------------------ void platform_support::message(const char* msg) { ::MessageBox(m_specific->m_hwnd, msg, "AGG Message", MB_OK); } //------------------------------------------------------------------------ bool platform_support::init(unsigned width, unsigned height, unsigned flags) { if(m_specific->m_sys_format == pix_format_undefined) { return false; } m_window_flags = flags; int wflags = CS_OWNDC | CS_VREDRAW | CS_HREDRAW; WNDCLASS wc; wc.lpszClassName = "AGGAppClass"; wc.lpfnWndProc = window_proc; wc.style = wflags; wc.hInstance = g_windows_instance; wc.hIcon = LoadIcon(0, IDI_APPLICATION); wc.hCursor = LoadCursor(0, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = "AGGAppMenu"; wc.cbClsExtra = 0; wc.cbWndExtra = 0; ::RegisterClass(&wc); wflags = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; if(m_window_flags & window_resize) { wflags |= WS_THICKFRAME | WS_MAXIMIZEBOX; } m_specific->m_hwnd = ::CreateWindow("AGGAppClass", m_caption, wflags, 100, 100, width, height, 0, 0, g_windows_instance, 0); if(m_specific->m_hwnd == 0) { return false; } RECT rct; ::GetClientRect(m_specific->m_hwnd, &rct); ::MoveWindow(m_specific->m_hwnd, // handle to window 100, // horizontal position 100, // vertical position width + (width - (rct.right - rct.left)), height + (height - (rct.bottom - rct.top)), FALSE); ::SetWindowLong(m_specific->m_hwnd, GWL_USERDATA, (LONG)this); m_specific->create_pmap(width, height, &m_rbuf_window); m_initial_width = width; m_initial_height = height; on_init(); m_specific->m_redraw_flag = true; ::ShowWindow(m_specific->m_hwnd, g_windows_cmd_show); return true; } //------------------------------------------------------------------------ int platform_support::run() { MSG msg; for(;;) { if(m_wait_mode) { if(!::GetMessage(&msg, 0, 0, 0)) { break; } ::TranslateMessage(&msg); ::DispatchMessage(&msg); } else { if(::PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { ::TranslateMessage(&msg); if(msg.message == WM_QUIT) { break; } ::DispatchMessage(&msg); } else { on_idle(); } } } return (int)msg.wParam; } //------------------------------------------------------------------------ const char* platform_support::img_ext() const { return ".bmp"; } //------------------------------------------------------------------------ const char* platform_support::full_file_name(const char* file_name) { return file_name; } //------------------------------------------------------------------------ bool platform_support::load_img(unsigned idx, const char* file) { if(idx < max_images) { char fn[1024]; strcpy(fn, file); int len = strlen(fn); if(len < 4 || stricmp(fn + len - 4, ".BMP") != 0) { strcat(fn, ".bmp"); } return m_specific->load_pmap(fn, idx, &m_rbuf_img[idx]); } return true; } //------------------------------------------------------------------------ bool platform_support::save_img(unsigned idx, const char* file) { if(idx < max_images) { char fn[1024]; strcpy(fn, file); int len = strlen(fn); if(len < 4 || stricmp(fn + len - 4, ".BMP") != 0) { strcat(fn, ".bmp"); } return m_specific->save_pmap(fn, idx, &m_rbuf_img[idx]); } return true; } //------------------------------------------------------------------------ bool platform_support::create_img(unsigned idx, unsigned width, unsigned height) { if(idx < max_images) { if(width == 0) width = m_specific->m_pmap_window.width(); if(height == 0) height = m_specific->m_pmap_window.height(); m_specific->m_pmap_img[idx].create(width, height, org_e(m_specific->m_bpp)); m_rbuf_img[idx].attach(m_specific->m_pmap_img[idx].buf(), m_specific->m_pmap_img[idx].width(), m_specific->m_pmap_img[idx].height(), m_flip_y ? m_specific->m_pmap_img[idx].stride() : -m_specific->m_pmap_img[idx].stride()); return true; } return false; } //------------------------------------------------------------------------ void platform_support::force_redraw() { m_specific->m_redraw_flag = true; ::InvalidateRect(m_specific->m_hwnd, 0, FALSE); } //------------------------------------------------------------------------ void platform_support::update_window() { HDC dc = ::GetDC(m_specific->m_hwnd); m_specific->display_pmap(dc, &m_rbuf_window); ::ReleaseDC(m_specific->m_hwnd, dc); } //------------------------------------------------------------------------ void platform_support::on_init() {} void platform_support::on_resize(int sx, int sy) {} void platform_support::on_idle() {} void platform_support::on_mouse_move(int x, int y, unsigned flags) {} void platform_support::on_mouse_button_down(int x, int y, unsigned flags) {} void platform_support::on_mouse_button_up(int x, int y, unsigned flags) {} void platform_support::on_key(int x, int y, unsigned key, unsigned flags) {} void platform_support::on_ctrl_change() {} void platform_support::on_draw() {} void platform_support::on_post_draw(void* raw_handler) {} } namespace agg24 { // That's ridiculous. I have to parse the command line by myself // because Windows doesn't provide a method of getting the command // line arguments in a form of argc, argv. Of course, there's // CommandLineToArgv() but first, it returns Unicode that I don't // need to deal with, but most of all, it's not compatible with Win98. //----------------------------------------------------------------------- class tokenizer { public: enum sep_flag { single, multiple, whole_str }; struct token { const char* ptr; unsigned len; }; public: tokenizer(const char* sep, const char* trim=0, const char* quote="\"", char mask_chr='\\', sep_flag sf=multiple); void set_str(const char* str); token next_token(); private: int check_chr(const char *str, char chr); private: const char* m_src_string; int m_start; const char* m_sep; const char* m_trim; const char* m_quote; char m_mask_chr; unsigned m_sep_len; sep_flag m_sep_flag; }; //----------------------------------------------------------------------- inline void tokenizer::set_str(const char* str) { m_src_string = str; m_start = 0; } //----------------------------------------------------------------------- inline int tokenizer::check_chr(const char *str, char chr) { return int(strchr(str, chr)); } //----------------------------------------------------------------------- tokenizer::tokenizer(const char* sep, const char* trim, const char* quote, char mask_chr, sep_flag sf) : m_src_string(0), m_start(0), m_sep(sep), m_trim(trim), m_quote(quote), m_mask_chr(mask_chr), m_sep_len(sep ? strlen(sep) : 0), m_sep_flag(sep ? sf : single) { } //----------------------------------------------------------------------- tokenizer::token tokenizer::next_token() { unsigned count = 0; char quote_chr = 0; token tok; tok.ptr = 0; tok.len = 0; if(m_src_string == 0 || m_start == -1) return tok; register const char *pstr = m_src_string + m_start; if(*pstr == 0) { m_start = -1; return tok; } int sep_len = 1; if(m_sep_flag == whole_str) sep_len = m_sep_len; if(m_sep_flag == multiple) { //Pass all the separator symbols at the begin of the string while(*pstr && check_chr(m_sep, *pstr)) { ++pstr; ++m_start; } } if(*pstr == 0) { m_start = -1; return tok; } for(count = 0;; ++count) { char c = *pstr; int found = 0; //We are outside of qotation: find one of separator symbols if(quote_chr == 0) { if(sep_len == 1) { found = check_chr(m_sep, c); } else { found = strncmp(m_sep, pstr, m_sep_len) == 0; } } ++pstr; if(c == 0 || found) { if(m_trim) { while(count && check_chr(m_trim, m_src_string[m_start])) { ++m_start; --count; } while(count && check_chr(m_trim, m_src_string[m_start + count - 1])) { --count; } } tok.ptr = m_src_string + m_start; tok.len = count; //Next time it will be the next separator character //But we must check, whether it is NOT the end of the string. m_start += count; if(c) { m_start += sep_len; if(m_sep_flag == multiple) { //Pass all the separator symbols //after the end of the string while(check_chr(m_sep, m_src_string[m_start])) { ++m_start; } } } break; } //Switch quote. If it is not a quote yet, try to check any of //quote symbols. Otherwise quote must be finished with quote_symb if(quote_chr == 0) { if(check_chr(m_quote, c)) { quote_chr = c; continue; } } else { //We are inside quote: pass all the mask symbols if(m_mask_chr && c == m_mask_chr) { if(*pstr) { ++count; ++pstr; } continue; } if(c == quote_chr) { quote_chr = 0; continue; } } } return tok; } } //---------------------------------------------------------------------------- int agg_main(int argc, char* argv[]); //---------------------------------------------------------------------------- int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow) { agg24::g_windows_instance = hInstance; agg24::g_windows_cmd_show = nCmdShow; char* argv_str = new char [strlen(lpszCmdLine) + 3]; char* argv_ptr = argv_str; char* argv[64]; memset(argv, 0, sizeof(argv)); agg24::tokenizer cmd_line(" ", "\"' ", "\"'", '\\', agg24::tokenizer::multiple); cmd_line.set_str(lpszCmdLine); int argc = 0; argv[argc++] = argv_ptr; *argv_ptr++ = 0; while(argc < 64) { agg24::tokenizer::token tok = cmd_line.next_token(); if(tok.ptr == 0) break; if(tok.len) { memcpy(argv_ptr, tok.ptr, tok.len); argv[argc++] = argv_ptr; argv_ptr += tok.len; *argv_ptr++ = 0; } } int ret = agg_main(argc, argv); delete [] argv_str; return ret; } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/win32/agg_win32_bmp.cpp0000644000175000017500000004622112516137326026055 0ustar varunvarun//---------------------------------------------------------------------------- // //---------------------------------------------------------------------------- // Contact: mcseemagg@yahoo.com //---------------------------------------------------------------------------- // // class pixel_map // //---------------------------------------------------------------------------- #include "platform/win32/agg_win32_bmp.h" #include "agg_basics.h" namespace agg24 { //------------------------------------------------------------------------ pixel_map::~pixel_map() { destroy(); } //------------------------------------------------------------------------ pixel_map::pixel_map() : m_bmp(0), m_buf(0), m_bpp(0), m_is_internal(false), m_img_size(0), m_full_size(0) { } //------------------------------------------------------------------------ void pixel_map::destroy() { if(m_bmp && m_is_internal) delete [] (unsigned char*)m_bmp; m_bmp = 0; m_is_internal = false; m_buf = 0; } //------------------------------------------------------------------------ void pixel_map::create(unsigned width, unsigned height, org_e org, unsigned clear_val) { destroy(); if(width == 0) width = 1; if(height == 0) height = 1; m_bpp = org; create_from_bmp(create_bitmap_info(width, height, m_bpp)); create_gray_scale_palette(m_bmp); m_is_internal = true; if(clear_val <= 255) { memset(m_buf, clear_val, m_img_size); } } //------------------------------------------------------------------------ HBITMAP pixel_map::create_dib_section(HDC h_dc, unsigned width, unsigned height, org_e org, unsigned clear_val) { destroy(); if(width == 0) width = 1; if(height == 0) height = 1; m_bpp = org; HBITMAP h_bitmap = create_dib_section_from_args(h_dc, width, height, m_bpp); create_gray_scale_palette(m_bmp); m_is_internal = true; if(clear_val <= 255) { memset(m_buf, clear_val, m_img_size); } return h_bitmap; } //------------------------------------------------------------------------ void pixel_map::clear(unsigned clear_val) { if(m_buf) memset(m_buf, clear_val, m_img_size); } //------------------------------------------------------------------------ void pixel_map::attach_to_bmp(BITMAPINFO *bmp) { if(bmp) { destroy(); create_from_bmp(bmp); m_is_internal = false; } } //static //------------------------------------------------------------------------ unsigned pixel_map::calc_full_size(BITMAPINFO *bmp) { if(bmp == 0) return 0; return sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * calc_palette_size(bmp) + bmp->bmiHeader.biSizeImage; } //static //------------------------------------------------------------------------ unsigned pixel_map::calc_header_size(BITMAPINFO *bmp) { if(bmp == 0) return 0; return sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * calc_palette_size(bmp); } //static //------------------------------------------------------------------------ unsigned pixel_map::calc_palette_size(unsigned clr_used, unsigned bits_per_pixel) { int palette_size = 0; if(bits_per_pixel <= 8) { palette_size = clr_used; if(palette_size == 0) { palette_size = 1 << bits_per_pixel; } } return palette_size; } //static //------------------------------------------------------------------------ unsigned pixel_map::calc_palette_size(BITMAPINFO *bmp) { if(bmp == 0) return 0; return calc_palette_size(bmp->bmiHeader.biClrUsed, bmp->bmiHeader.biBitCount); } //static //------------------------------------------------------------------------ unsigned char * pixel_map::calc_img_ptr(BITMAPINFO *bmp) { if(bmp == 0) return 0; return ((unsigned char*)bmp) + calc_header_size(bmp); } //static //------------------------------------------------------------------------ BITMAPINFO* pixel_map::create_bitmap_info(unsigned width, unsigned height, unsigned bits_per_pixel) { unsigned line_len = calc_row_len(width, bits_per_pixel); unsigned img_size = line_len * height; unsigned rgb_size = calc_palette_size(0, bits_per_pixel) * sizeof(RGBQUAD); unsigned full_size = sizeof(BITMAPINFOHEADER) + rgb_size + img_size; BITMAPINFO *bmp = (BITMAPINFO *) new unsigned char[full_size]; bmp->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmp->bmiHeader.biWidth = width; bmp->bmiHeader.biHeight = height; bmp->bmiHeader.biPlanes = 1; bmp->bmiHeader.biBitCount = (unsigned short)bits_per_pixel; bmp->bmiHeader.biCompression = 0; bmp->bmiHeader.biSizeImage = img_size; bmp->bmiHeader.biXPelsPerMeter = 0; bmp->bmiHeader.biYPelsPerMeter = 0; bmp->bmiHeader.biClrUsed = 0; bmp->bmiHeader.biClrImportant = 0; return bmp; } //static //------------------------------------------------------------------------ void pixel_map::create_gray_scale_palette(BITMAPINFO *bmp) { if(bmp == 0) return; unsigned rgb_size = calc_palette_size(bmp); RGBQUAD *rgb = (RGBQUAD*)(((unsigned char*)bmp) + sizeof(BITMAPINFOHEADER)); unsigned brightness; unsigned i; for(i = 0; i < rgb_size; i++) { brightness = (255 * i) / (rgb_size - 1); rgb->rgbBlue = rgb->rgbGreen = rgb->rgbRed = (unsigned char)brightness; rgb->rgbReserved = 0; rgb++; } } //static //------------------------------------------------------------------------ unsigned pixel_map::calc_row_len(unsigned width, unsigned bits_per_pixel) { unsigned n = width; unsigned k; switch(bits_per_pixel) { case 1: k = n; n = n >> 3; if(k & 7) n++; break; case 4: k = n; n = n >> 1; if(k & 3) n++; break; case 8: break; case 16: n *= 2; break; case 24: n *= 3; break; case 32: n *= 4; break; case 48: n *= 6; break; case 64: n *= 8; break; default: n = 0; break; } return ((n + 3) >> 2) << 2; } //------------------------------------------------------------------------ void pixel_map::draw(HDC h_dc, const RECT *device_rect, const RECT *bmp_rect) const { if(m_bmp == 0 || m_buf == 0) return; unsigned bmp_x = 0; unsigned bmp_y = 0; unsigned bmp_width = m_bmp->bmiHeader.biWidth; unsigned bmp_height = m_bmp->bmiHeader.biHeight; unsigned dvc_x = 0; unsigned dvc_y = 0; unsigned dvc_width = m_bmp->bmiHeader.biWidth; unsigned dvc_height = m_bmp->bmiHeader.biHeight; if(bmp_rect) { bmp_x = bmp_rect->left; bmp_y = bmp_rect->top; bmp_width = bmp_rect->right - bmp_rect->left; bmp_height = bmp_rect->bottom - bmp_rect->top; } dvc_x = bmp_x; dvc_y = bmp_y; dvc_width = bmp_width; dvc_height = bmp_height; if(device_rect) { dvc_x = device_rect->left; dvc_y = device_rect->top; dvc_width = device_rect->right - device_rect->left; dvc_height = device_rect->bottom - device_rect->top; } if(dvc_width != bmp_width || dvc_height != bmp_height) { ::SetStretchBltMode(h_dc, COLORONCOLOR); ::StretchDIBits( h_dc, // handle of device context dvc_x, // x-coordinate of upper-left corner of source rect. dvc_y, // y-coordinate of upper-left corner of source rect. dvc_width, // width of source rectangle dvc_height, // height of source rectangle bmp_x, bmp_y, // x, y -coordinates of upper-left corner of dest. rect. bmp_width, // width of destination rectangle bmp_height, // height of destination rectangle m_buf, // address of bitmap bits m_bmp, // address of bitmap data DIB_RGB_COLORS, // usage SRCCOPY // raster operation code ); } else { ::SetDIBitsToDevice( h_dc, // handle to device context dvc_x, // x-coordinate of upper-left corner of dvc_y, // y-coordinate of upper-left corner of dvc_width, // source rectangle width dvc_height, // source rectangle height bmp_x, // x-coordinate of lower-left corner of bmp_y, // y-coordinate of lower-left corner of 0, // first scan line in array bmp_height, // number of scan lines m_buf, // address of array with DIB bits m_bmp, // address of structure with bitmap info. DIB_RGB_COLORS // RGB or palette indexes ); } } //------------------------------------------------------------------------ void pixel_map::draw(HDC h_dc, int x, int y, double scale) const { if(m_bmp == 0 || m_buf == 0) return; unsigned width = unsigned(m_bmp->bmiHeader.biWidth * scale); unsigned height = unsigned(m_bmp->bmiHeader.biHeight * scale); RECT rect; rect.left = x; rect.top = y; rect.right = x + width; rect.bottom = y + height; draw(h_dc, &rect); } //------------------------------------------------------------------------ void pixel_map::blend(HDC h_dc, const RECT *device_rect, const RECT *bmp_rect) const { #if !defined(AGG_BMP_ALPHA_BLEND) draw(h_dc, device_rect, bmp_rect); return; #else if(m_bpp != 32) { draw(h_dc, device_rect, bmp_rect); return; } if(m_bmp == 0 || m_buf == 0) return; unsigned bmp_x = 0; unsigned bmp_y = 0; unsigned bmp_width = m_bmp->bmiHeader.biWidth; unsigned bmp_height = m_bmp->bmiHeader.biHeight; unsigned dvc_x = 0; unsigned dvc_y = 0; unsigned dvc_width = m_bmp->bmiHeader.biWidth; unsigned dvc_height = m_bmp->bmiHeader.biHeight; if(bmp_rect) { bmp_x = bmp_rect->left; bmp_y = bmp_rect->top; bmp_width = bmp_rect->right - bmp_rect->left; bmp_height = bmp_rect->bottom - bmp_rect->top; } dvc_x = bmp_x; dvc_y = bmp_y; dvc_width = bmp_width; dvc_height = bmp_height; if(device_rect) { dvc_x = device_rect->left; dvc_y = device_rect->top; dvc_width = device_rect->right - device_rect->left; dvc_height = device_rect->bottom - device_rect->top; } HDC mem_dc = ::CreateCompatibleDC(h_dc); void* buf = 0; HBITMAP bmp = ::CreateDIBSection( mem_dc, m_bmp, DIB_RGB_COLORS, &buf, 0, 0 ); memcpy(buf, m_buf, m_bmp->bmiHeader.biSizeImage); HBITMAP temp = (HBITMAP)::SelectObject(mem_dc, bmp); BLENDFUNCTION blend; blend.BlendOp = AC_SRC_OVER; blend.BlendFlags = 0; #if defined(AC_SRC_ALPHA) blend.AlphaFormat = AC_SRC_ALPHA; //#elif defined(AC_SRC_NO_PREMULT_ALPHA) // blend.AlphaFormat = AC_SRC_NO_PREMULT_ALPHA; #else #error "No appropriate constant for alpha format. Check version of wingdi.h, There must be AC_SRC_ALPHA or AC_SRC_NO_PREMULT_ALPHA" #endif blend.SourceConstantAlpha = 255; ::AlphaBlend( h_dc, dvc_x, dvc_y, dvc_width, dvc_height, mem_dc, bmp_x, bmp_y, bmp_width, bmp_height, blend ); ::SelectObject(mem_dc, temp); ::DeleteObject(bmp); ::DeleteObject(mem_dc); #endif //defined(AGG_BMP_ALPHA_BLEND) } //------------------------------------------------------------------------ void pixel_map::blend(HDC h_dc, int x, int y, double scale) const { if(m_bmp == 0 || m_buf == 0) return; unsigned width = unsigned(m_bmp->bmiHeader.biWidth * scale); unsigned height = unsigned(m_bmp->bmiHeader.biHeight * scale); RECT rect; rect.left = x; rect.top = y; rect.right = x + width; rect.bottom = y + height; blend(h_dc, &rect); } //------------------------------------------------------------------------ bool pixel_map::load_from_bmp(FILE *fd) { BITMAPFILEHEADER bmf; BITMAPINFO *bmi = 0; unsigned bmp_size; fread(&bmf, sizeof(bmf), 1, fd); if(bmf.bfType != 0x4D42) goto bmperr; bmp_size = bmf.bfSize - sizeof(BITMAPFILEHEADER); bmi = (BITMAPINFO*) new unsigned char [bmp_size]; if(fread(bmi, 1, bmp_size, fd) != bmp_size) goto bmperr; destroy(); m_bpp = bmi->bmiHeader.biBitCount; create_from_bmp(bmi); m_is_internal = 1; return true; bmperr: if(bmi) delete [] (unsigned char*) bmi; return false; } //------------------------------------------------------------------------ bool pixel_map::load_from_bmp(const char *filename) { FILE *fd = fopen(filename, "rb"); bool ret = false; if(fd) { ret = load_from_bmp(fd); fclose(fd); } return ret; } //------------------------------------------------------------------------ bool pixel_map::save_as_bmp(FILE *fd) const { if(m_bmp == 0) return 0; BITMAPFILEHEADER bmf; bmf.bfType = 0x4D42; bmf.bfOffBits = calc_header_size(m_bmp) + sizeof(bmf); bmf.bfSize = bmf.bfOffBits + m_img_size; bmf.bfReserved1 = 0; bmf.bfReserved2 = 0; fwrite(&bmf, sizeof(bmf), 1, fd); fwrite(m_bmp, m_full_size, 1, fd); return true; } //------------------------------------------------------------------------ bool pixel_map::save_as_bmp(const char *filename) const { FILE *fd = fopen(filename, "wb"); bool ret = false; if(fd) { ret = save_as_bmp(fd); fclose(fd); } return ret; } //------------------------------------------------------------------------ unsigned char* pixel_map::buf() { return m_buf; } //------------------------------------------------------------------------ unsigned pixel_map::width() const { return m_bmp->bmiHeader.biWidth; } //------------------------------------------------------------------------ unsigned pixel_map::height() const { return m_bmp->bmiHeader.biHeight; } //------------------------------------------------------------------------ int pixel_map::stride() const { return calc_row_len(m_bmp->bmiHeader.biWidth, m_bmp->bmiHeader.biBitCount); } //private //------------------------------------------------------------------------ void pixel_map::create_from_bmp(BITMAPINFO *bmp) { if(bmp) { m_img_size = calc_row_len(bmp->bmiHeader.biWidth, bmp->bmiHeader.biBitCount) * bmp->bmiHeader.biHeight; m_full_size = calc_full_size(bmp); m_bmp = bmp; m_buf = calc_img_ptr(bmp); } } //private //------------------------------------------------------------------------ HBITMAP pixel_map::create_dib_section_from_args(HDC h_dc, unsigned width, unsigned height, unsigned bits_per_pixel) { unsigned line_len = calc_row_len(width, bits_per_pixel); unsigned img_size = line_len * height; unsigned rgb_size = calc_palette_size(0, bits_per_pixel) * sizeof(RGBQUAD); unsigned full_size = sizeof(BITMAPINFOHEADER) + rgb_size; BITMAPINFO *bmp = (BITMAPINFO *) new unsigned char[full_size]; bmp->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmp->bmiHeader.biWidth = width; bmp->bmiHeader.biHeight = height; bmp->bmiHeader.biPlanes = 1; bmp->bmiHeader.biBitCount = (unsigned short)bits_per_pixel; bmp->bmiHeader.biCompression = 0; bmp->bmiHeader.biSizeImage = img_size; bmp->bmiHeader.biXPelsPerMeter = 0; bmp->bmiHeader.biYPelsPerMeter = 0; bmp->bmiHeader.biClrUsed = 0; bmp->bmiHeader.biClrImportant = 0; void* img_ptr = 0; HBITMAP h_bitmap = ::CreateDIBSection(h_dc, bmp, DIB_RGB_COLORS, &img_ptr, NULL, 0); if(img_ptr) { m_img_size = calc_row_len(width, bits_per_pixel) * height; m_full_size = 0; m_bmp = bmp; m_buf = (unsigned char *) img_ptr; } return h_bitmap; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/win32/Makefile.am0000644000175000017500000000061212516137326024761 0ustar varunvarun if ENABLE_WIN32 lib_LTLIBRARIES = libaggplatformwin32.la libaggplatformwin32_la_LDFLAGS = -version-info @AGG_LIB_VERSION@ libaggplatformwin32_la_SOURCES = agg_platform_support.cpp \ agg_win32_bmp.cpp libaggplatformwin32_la_CXXFLAGS = -I$(top_srcdir)/include @WINDOWS_CFLAGS@ libaggplatformwin32_la_LIBADD = @WINDOWS_LIBS@ $(top_builddir)/src/libagg.la endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/AmigaOS/0000755000175000017500000000000012516137725023247 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/AmigaOS/agg_platform_support.cpp0000644000175000017500000006150512516137326030215 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class platform_support // //---------------------------------------------------------------------------- #include "platform/agg_platform_support.h" #include "util/agg_color_conv_rgb8.h" #include #include #include #include #include #include #include #include #include #include #include #include #include Library* DataTypesBase = 0; Library* GraphicsBase = 0; Library* IntuitionBase = 0; Library* KeymapBase = 0; Library* P96Base = 0; DataTypesIFace* IDataTypes = 0; GraphicsIFace* IGraphics = 0; IntuitionIFace* IIntuition = 0; KeymapIFace* IKeymap = 0; P96IFace* IP96 = 0; Class* RequesterClass = 0; Class* WindowClass = 0; namespace agg24 { void handle_idcmp(Hook* hook, APTR win, IntuiMessage* msg); //------------------------------------------------------------------------ class platform_specific { public: platform_specific(platform_support& support, pix_format_e format, bool flip_y); ~platform_specific(); bool handle_input(); bool load_img(const char* file, unsigned idx, rendering_buffer* rbuf); bool create_img(unsigned idx, rendering_buffer* rbuf, unsigned width, unsigned height); bool make_bitmap(); public: platform_support& m_support; RGBFTYPE m_ftype; pix_format_e m_format; unsigned m_bpp; BitMap* m_bitmap; bool m_flip_y; uint16 m_width; uint16 m_height; APTR m_window_obj; Window* m_window; Hook* m_idcmp_hook; unsigned m_input_flags; bool m_dragging; double m_start_time; uint16 m_last_key; BitMap* m_img_bitmaps[platform_support::max_images]; }; //------------------------------------------------------------------------ platform_specific::platform_specific(platform_support& support, pix_format_e format, bool flip_y) : m_support(support), m_ftype(RGBFB_NONE), m_format(format), m_bpp(0), m_bitmap(0), m_flip_y(flip_y), m_width(0), m_height(0), m_window_obj(0), m_window(0), m_idcmp_hook(0), m_input_flags(0), m_dragging(false), m_start_time(0.0), m_last_key(0) { switch ( format ) { case pix_format_gray8: // Not supported. break; case pix_format_rgb555: m_ftype = RGBFB_R5G5B5; m_bpp = 15; break; case pix_format_rgb565: m_ftype = RGBFB_R5G6B5; m_bpp = 16; break; case pix_format_rgb24: m_ftype = RGBFB_R8G8B8; m_bpp = 24; break; case pix_format_bgr24: m_ftype = RGBFB_B8G8R8; m_bpp = 24; break; case pix_format_bgra32: m_ftype = RGBFB_B8G8R8A8; m_bpp = 32; break; case pix_format_abgr32: m_ftype = RGBFB_A8B8G8R8; m_bpp = 32; break; case pix_format_argb32: m_ftype = RGBFB_A8R8G8B8; m_bpp = 32; break; case pix_format_rgba32: m_ftype = RGBFB_R8G8B8A8; m_bpp = 32; break; } for ( unsigned i = 0; i < platform_support::max_images; ++i ) { m_img_bitmaps[i] = 0; } } //------------------------------------------------------------------------ platform_specific::~platform_specific() { IIntuition->DisposeObject(m_window_obj); IP96->p96FreeBitMap(m_bitmap); for ( unsigned i = 0; i < platform_support::max_images; ++i ) { IP96->p96FreeBitMap(m_img_bitmaps[i]); } if ( m_idcmp_hook != 0 ) { IExec->FreeSysObject(ASOT_HOOK, m_idcmp_hook); } } //------------------------------------------------------------------------ bool platform_specific::handle_input() { int16 code = 0; uint32 result = 0; Object* obj = reinterpret_cast(m_window_obj); while ( (result = IIntuition->IDoMethod(obj, WM_HANDLEINPUT, &code)) != WMHI_LASTMSG ) { switch ( result & WMHI_CLASSMASK ) { case WMHI_CLOSEWINDOW: return true; break; case WMHI_INTUITICK: if ( !m_support.wait_mode() ) { m_support.on_idle(); } break; case WMHI_NEWSIZE: if ( make_bitmap() ) { m_support.trans_affine_resizing(m_width, m_height); m_support.on_resize(m_width, m_height); m_support.force_redraw(); } break; } } return false; } //------------------------------------------------------------------------ bool platform_specific::load_img(const char* file, unsigned idx, rendering_buffer* rbuf) { if ( m_img_bitmaps[idx] != 0 ) { IP96->p96FreeBitMap(m_img_bitmaps[idx]); m_img_bitmaps[idx] = 0; } bool result = false; Object* picture = IDataTypes->NewDTObject(const_cast(file), DTA_GroupID, GID_PICTURE, PDTA_DestMode, PMODE_V43, PDTA_Remap, FALSE, TAG_END); if ( picture != 0 ) { gpLayout layout; layout.MethodID = DTM_PROCLAYOUT; layout.gpl_GInfo = 0; layout.gpl_Initial = 1; ULONG loaded = IDataTypes->DoDTMethodA(picture, 0, 0, reinterpret_cast(&layout)); if ( loaded != 0 ) { BitMap* src_bitmap = 0; IDataTypes->GetDTAttrs(picture, PDTA_ClassBitMap, &src_bitmap, TAG_END); bool supported = false; RGBFTYPE ftype = static_cast(IP96->p96GetBitMapAttr( src_bitmap, P96BMA_RGBFORMAT)); switch ( ftype ) { case RGBFB_R8G8B8: supported = true; break; default: m_support.message("File uses unsupported graphics mode."); break; } if ( supported ) { uint16 width = IP96->p96GetBitMapAttr(src_bitmap, P96BMA_WIDTH); uint16 height = IP96->p96GetBitMapAttr(src_bitmap, P96BMA_HEIGHT); m_img_bitmaps[idx] = IP96->p96AllocBitMap(width, height, m_bpp, BMF_USERPRIVATE, 0, m_ftype); if ( m_img_bitmaps[idx] != 0 ) { int8u* buf = reinterpret_cast( IP96->p96GetBitMapAttr(m_img_bitmaps[idx], P96BMA_MEMORY)); int bpr = IP96->p96GetBitMapAttr(m_img_bitmaps[idx], P96BMA_BYTESPERROW); int stride = (m_flip_y) ? -bpr : bpr; rbuf->attach(buf, width, height, stride); // P96 sets the alpha to zero so it can't be used to // color convert true color modes. if ( m_bpp == 32 ) { RenderInfo ri; int32 lock = IP96->p96LockBitMap(src_bitmap, reinterpret_cast(&ri), sizeof(RenderInfo)); rendering_buffer rbuf_src; rbuf_src.attach( reinterpret_cast(ri.Memory), width, height, (m_flip_y) ? -ri.BytesPerRow : ri.BytesPerRow); switch ( m_format ) { case pix_format_bgra32: color_conv(rbuf, &rbuf_src, color_conv_rgb24_to_bgra32()); break; case pix_format_abgr32: color_conv(rbuf, &rbuf_src, color_conv_rgb24_to_abgr32()); break; case pix_format_argb32: color_conv(rbuf, &rbuf_src, color_conv_rgb24_to_argb32()); break; case pix_format_rgba32: color_conv(rbuf, &rbuf_src, color_conv_rgb24_to_rgba32()); break; } IP96->p96UnlockBitMap(src_bitmap, lock); } else { IGraphics->BltBitMap(src_bitmap, 0, 0, m_img_bitmaps[idx], 0, 0, width, height, ABC|ABNC, 0xFF, 0); } result = true; } } } } IGraphics->WaitBlit(); IDataTypes->DisposeDTObject(picture); return result; } //------------------------------------------------------------------------ bool platform_specific::create_img(unsigned idx, rendering_buffer* rbuf, unsigned width, unsigned height) { if ( m_img_bitmaps[idx] != 0 ) { IP96->p96FreeBitMap(m_img_bitmaps[idx]); m_img_bitmaps[idx] = 0; } m_img_bitmaps[idx] = IP96->p96AllocBitMap(width, height, m_bpp, BMF_USERPRIVATE, m_bitmap, m_ftype); if ( m_img_bitmaps[idx] != 0 ) { int8u* buf = reinterpret_cast( IP96->p96GetBitMapAttr(m_img_bitmaps[idx], P96BMA_MEMORY)); int bpr = IP96->p96GetBitMapAttr(m_img_bitmaps[idx], P96BMA_BYTESPERROW); int stride = (m_flip_y) ? -bpr : bpr; rbuf->attach(buf, width, height, stride); return true; } return false; } //------------------------------------------------------------------------ bool platform_specific::make_bitmap() { uint32 width = 0; uint32 height = 0; IIntuition->GetWindowAttrs(m_window, WA_InnerWidth, &width, WA_InnerHeight, &height, TAG_END); BitMap* bm = IP96->p96AllocBitMap(width, height, m_bpp, BMF_USERPRIVATE|BMF_CLEAR, 0, m_ftype); if ( bm == 0 ) { return false; } int8u* buf = reinterpret_cast( IP96->p96GetBitMapAttr(bm, P96BMA_MEMORY)); int bpr = IP96->p96GetBitMapAttr(bm, P96BMA_BYTESPERROW); int stride = (m_flip_y) ? -bpr : bpr; m_support.rbuf_window().attach(buf, width, height, stride); if ( m_bitmap != 0 ) { IP96->p96FreeBitMap(m_bitmap); m_bitmap = 0; } m_bitmap = bm; m_width = width; m_height = height; return true; } //------------------------------------------------------------------------ platform_support::platform_support(pix_format_e format, bool flip_y) : m_specific(new platform_specific(*this, format, flip_y)), m_format(format), m_bpp(m_specific->m_bpp), m_window_flags(0), m_wait_mode(true), m_flip_y(flip_y), m_initial_width(10), m_initial_height(10) { std::strncpy(m_caption, "Anti-Grain Geometry", 256); } //------------------------------------------------------------------------ platform_support::~platform_support() { delete m_specific; } //------------------------------------------------------------------------ void platform_support::caption(const char* cap) { std::strncpy(m_caption, cap, 256); if ( m_specific->m_window != 0 ) { const char* ignore = reinterpret_cast(-1); IIntuition->SetWindowAttr(m_specific->m_window, WA_Title, m_caption, sizeof(char*)); } } //------------------------------------------------------------------------ void platform_support::start_timer() { timeval tv; gettimeofday(&tv, 0); m_specific->m_start_time = tv.tv_secs + tv.tv_micro/1e6; } //------------------------------------------------------------------------ double platform_support::elapsed_time() const { timeval tv; gettimeofday(&tv, 0); double end_time = tv.tv_secs + tv.tv_micro/1e6; double elasped_seconds = end_time - m_specific->m_start_time; double elasped_millis = elasped_seconds*1e3; return elasped_millis; } //------------------------------------------------------------------------ void* platform_support::raw_display_handler() { return 0; // Not available. } //------------------------------------------------------------------------ void platform_support::message(const char* msg) { APTR req = IIntuition->NewObject(RequesterClass, 0, REQ_TitleText, "Anti-Grain Geometry", REQ_Image, REQIMAGE_INFO, REQ_BodyText, msg, REQ_GadgetText, "_Ok", TAG_END); if ( req == 0 ) { IDOS->Printf("Message: %s\n", msg); return; } orRequest reqmsg; reqmsg.MethodID = RM_OPENREQ; reqmsg.or_Attrs = 0; reqmsg.or_Window = m_specific->m_window; reqmsg.or_Screen = 0; IIntuition->IDoMethodA(reinterpret_cast(req), reinterpret_cast(&reqmsg)); IIntuition->DisposeObject(req); } //------------------------------------------------------------------------ bool platform_support::init(unsigned width, unsigned height, unsigned flags) { if( m_specific->m_ftype == RGBFB_NONE ) { message("Unsupported mode requested."); return false; } m_window_flags = flags; m_specific->m_idcmp_hook = reinterpret_cast( IExec->AllocSysObjectTags(ASOT_HOOK, ASOHOOK_Entry, handle_idcmp, ASOHOOK_Data, this, TAG_END)); if ( m_specific->m_idcmp_hook == 0 ) { return false; } m_specific->m_window_obj = IIntuition->NewObject(WindowClass, 0, WA_Title, m_caption, WA_AutoAdjustDClip, TRUE, WA_InnerWidth, width, WA_InnerHeight, height, WA_Activate, TRUE, WA_SmartRefresh, TRUE, WA_NoCareRefresh, TRUE, WA_CloseGadget, TRUE, WA_DepthGadget, TRUE, WA_SizeGadget, (flags & agg24::window_resize) ? TRUE : FALSE, WA_DragBar, TRUE, WA_AutoAdjust, TRUE, WA_ReportMouse, TRUE, WA_RMBTrap, TRUE, WA_MouseQueue, 1, WA_IDCMP, IDCMP_NEWSIZE | IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE | IDCMP_RAWKEY | IDCMP_INTUITICKS, WINDOW_IDCMPHook, m_specific->m_idcmp_hook, WINDOW_IDCMPHookBits, IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE | IDCMP_RAWKEY, TAG_END); if ( m_specific->m_window_obj == 0 ) { return false; } Object* obj = reinterpret_cast(m_specific->m_window_obj); m_specific->m_window = reinterpret_cast(IIntuition->IDoMethod(obj, WM_OPEN)); if ( m_specific->m_window == 0 ) { return false; } RGBFTYPE ftype = static_cast(IP96->p96GetBitMapAttr( m_specific->m_window->RPort->BitMap, P96BMA_RGBFORMAT)); switch ( ftype ) { case RGBFB_A8R8G8B8: case RGBFB_B8G8R8A8: case RGBFB_R5G6B5PC: break; default: message("Unsupported screen mode.\n"); return false; } if ( !m_specific->make_bitmap() ) { return false; } m_initial_width = width; m_initial_height = height; on_init(); on_resize(width, height); force_redraw(); return true; } //------------------------------------------------------------------------ int platform_support::run() { uint32 window_mask = 0; IIntuition->GetAttr(WINDOW_SigMask, m_specific->m_window_obj, &window_mask); uint32 wait_mask = window_mask | SIGBREAKF_CTRL_C; bool done = false; while ( !done ) { uint32 sig_mask = IExec->Wait(wait_mask); if ( sig_mask & SIGBREAKF_CTRL_C ) { done = true; } else { done = m_specific->handle_input(); } } return 0; } //------------------------------------------------------------------------ const char* platform_support::img_ext() const { return ".bmp"; } //------------------------------------------------------------------------ const char* platform_support::full_file_name(const char* file_name) { return file_name; } //------------------------------------------------------------------------ bool platform_support::load_img(unsigned idx, const char* file) { if ( idx < max_images ) { static char fn[1024]; std::strncpy(fn, file, 1024); int len = std::strlen(fn); if ( len < 4 || std::strcmp(fn + len - 4, ".bmp") != 0 ) { std::strncat(fn, ".bmp", 1024); } return m_specific->load_img(fn, idx, &m_rbuf_img[idx]); } return false; } //------------------------------------------------------------------------ bool platform_support::save_img(unsigned idx, const char* file) { message("Not supported"); return false; } //------------------------------------------------------------------------ bool platform_support::create_img(unsigned idx, unsigned width, unsigned height) { if ( idx < max_images ) { if ( width == 0 ) { width = m_specific->m_width; } if ( height == 0 ) { height = m_specific->m_height; } return m_specific->create_img(idx, &m_rbuf_img[idx], width, height); } return false; } //------------------------------------------------------------------------ void platform_support::force_redraw() { on_draw(); update_window(); } //------------------------------------------------------------------------ void platform_support::update_window() { // Note this function does automatic color conversion. IGraphics->BltBitMapRastPort(m_specific->m_bitmap, 0, 0, m_specific->m_window->RPort, m_specific->m_window->BorderLeft, m_specific->m_window->BorderTop, m_specific->m_width, m_specific->m_height, ABC|ABNC); } //------------------------------------------------------------------------ void platform_support::on_init() {} void platform_support::on_resize(int sx, int sy) {} void platform_support::on_idle() {} void platform_support::on_mouse_move(int x, int y, unsigned flags) {} void platform_support::on_mouse_button_down(int x, int y, unsigned flags) {} void platform_support::on_mouse_button_up(int x, int y, unsigned flags) {} void platform_support::on_key(int x, int y, unsigned key, unsigned flags) {} void platform_support::on_ctrl_change() {} void platform_support::on_draw() {} void platform_support::on_post_draw(void* raw_handler) {} //------------------------------------------------------------------------ void handle_idcmp(Hook* hook, APTR obj, IntuiMessage* msg) { platform_support* app = reinterpret_cast(hook->h_Data); Window* window = app->m_specific->m_window; int16 x = msg->MouseX - window->BorderLeft; int16 y = 0; if ( app->flip_y() ) { y = window->Height - window->BorderBottom - msg->MouseY; } else { y = msg->MouseY - window->BorderTop; } switch ( msg->Class ) { case IDCMP_MOUSEBUTTONS: if ( msg->Code & IECODE_UP_PREFIX ) { if ( msg->Code == SELECTUP ) { app->m_specific->m_input_flags = mouse_left; app->m_specific->m_dragging = false; } else if ( msg->Code == MENUUP ) { app->m_specific->m_input_flags = mouse_right; app->m_specific->m_dragging = false; } else { return; } if ( app->m_ctrls.on_mouse_button_up(x, y) ) { app->on_ctrl_change(); app->force_redraw(); } app->on_mouse_button_up(x, y, app->m_specific->m_input_flags); } else { if ( msg->Code == SELECTDOWN ) { app->m_specific->m_input_flags = mouse_left; app->m_specific->m_dragging = true; } else if ( msg->Code == MENUDOWN ) { app->m_specific->m_input_flags = mouse_right; app->m_specific->m_dragging = true; } else { return; } app->m_ctrls.set_cur(x, y); if ( app->m_ctrls.on_mouse_button_down(x, y) ) { app->on_ctrl_change(); app->force_redraw(); } else { if ( app->m_ctrls.in_rect(x, y) ) { if ( app->m_ctrls.set_cur(x, y) ) { app->on_ctrl_change(); app->force_redraw(); } } else { app->on_mouse_button_down(x, y, app->m_specific->m_input_flags); } } } break; case IDCMP_MOUSEMOVE: if ( app->m_specific->m_dragging ) { if ( app->m_ctrls.on_mouse_move(x, y, app->m_specific->m_input_flags & mouse_left) != 0 ) { app->on_ctrl_change(); app->force_redraw(); } else { if ( !app->m_ctrls.in_rect(x, y) ) { app->on_mouse_move(x, y, app->m_specific->m_input_flags); } } } break; case IDCMP_RAWKEY: { static InputEvent ie = { 0 }; ie.ie_Class = IECLASS_RAWKEY; ie.ie_Code = msg->Code; ie.ie_Qualifier = msg->Qualifier; static const unsigned BUF_SIZE = 16; static char key_buf[BUF_SIZE]; int16 num_chars = IKeymap->MapRawKey(&ie, key_buf, BUF_SIZE, 0); uint32 code = 0x00000000; switch ( num_chars ) { case 1: code = key_buf[0]; break; case 2: code = key_buf[0]<<8 | key_buf[1]; break; case 3: code = key_buf[0]<<16 | key_buf[1]<<8 | key_buf[2]; break; } uint16 key_code = 0; if ( num_chars == 1 ) { if ( code >= IECODE_ASCII_FIRST && code <= IECODE_ASCII_LAST ) { key_code = code; } } if ( key_code == 0 ) { switch ( code ) { case 0x00000008: key_code = key_backspace; break; case 0x00000009: key_code = key_tab; break; case 0x0000000D: key_code = key_return; break; case 0x0000001B: key_code = key_escape; break; case 0x0000007F: key_code = key_delete; break; case 0x00009B41: case 0x00009B54: key_code = key_up; break; case 0x00009B42: case 0x00009B53: key_code = key_down; break; case 0x00009B43: case 0x009B2040: key_code = key_right; break; case 0x00009B44: case 0x009B2041: key_code = key_left; break; case 0x009B307E: key_code = key_f1; break; case 0x009B317E: key_code = key_f2; break; case 0x009B327E: key_code = key_f3; break; case 0x009B337E: key_code = key_f4; break; case 0x009B347E: key_code = key_f5; break; case 0x009B357E: key_code = key_f6; break; case 0x009B367E: key_code = key_f7; break; case 0x009B377E: key_code = key_f8; break; case 0x009B387E: key_code = key_f9; break; case 0x009B397E: key_code = key_f10; break; case 0x009B3F7E: key_code = key_scrollock; break; } } if ( ie.ie_Code & IECODE_UP_PREFIX ) { if ( app->m_specific->m_last_key != 0 ) { bool left = (key_code == key_left) ? true : false; bool right = (key_code == key_right) ? true : false; bool down = (key_code == key_down) ? true : false; bool up = (key_code == key_up) ? true : false; if ( app->m_ctrls.on_arrow_keys(left, right, down, up) ) { app->on_ctrl_change(); app->force_redraw(); } else { app->on_key(x, y, app->m_specific->m_last_key, 0); } app->m_specific->m_last_key = 0; } } else { app->m_specific->m_last_key = key_code; } break; } default: break; } } } //---------------------------------------------------------------------------- int agg_main(int argc, char* argv[]); bool open_libs(); void close_libs(); //---------------------------------------------------------------------------- bool open_libs() { DataTypesBase = IExec->OpenLibrary("datatypes.library", 51); GraphicsBase = IExec->OpenLibrary("graphics.library", 51); IntuitionBase = IExec->OpenLibrary("intuition.library", 51); KeymapBase = IExec->OpenLibrary("keymap.library", 51); P96Base = IExec->OpenLibrary("Picasso96API.library", 2); IDataTypes = reinterpret_cast( IExec->GetInterface(DataTypesBase, "main", 1, 0)); IGraphics = reinterpret_cast( IExec->GetInterface(GraphicsBase, "main", 1, 0)); IIntuition = reinterpret_cast( IExec->GetInterface(IntuitionBase, "main", 1, 0)); IKeymap = reinterpret_cast( IExec->GetInterface(KeymapBase, "main", 1, 0)); IP96 = reinterpret_cast( IExec->GetInterface(P96Base, "main", 1, 0)); if ( IDataTypes == 0 || IGraphics == 0 || IIntuition == 0 || IKeymap == 0 || IP96 == 0 ) { close_libs(); return false; } else { return true; } } //---------------------------------------------------------------------------- void close_libs() { IExec->DropInterface(reinterpret_cast(IP96)); IExec->DropInterface(reinterpret_cast(IKeymap)); IExec->DropInterface(reinterpret_cast(IIntuition)); IExec->DropInterface(reinterpret_cast(IGraphics)); IExec->DropInterface(reinterpret_cast(IDataTypes)); IExec->CloseLibrary(P96Base); IExec->CloseLibrary(KeymapBase); IExec->CloseLibrary(IntuitionBase); IExec->CloseLibrary(GraphicsBase); IExec->CloseLibrary(DataTypesBase); } //---------------------------------------------------------------------------- int main(int argc, char* argv[]) { if ( !open_libs() ) { IDOS->Printf("Can't open libraries.\n"); return -1; } ClassLibrary* requester = IIntuition->OpenClass("requester.class", 51, &RequesterClass); ClassLibrary* window = IIntuition->OpenClass("window.class", 51, &WindowClass); if ( requester == 0 || window == 0 ) { IDOS->Printf("Can't open classes.\n"); IIntuition->CloseClass(requester); IIntuition->CloseClass(window); close_libs(); return -1; } int rc = agg_main(argc, argv); IIntuition->CloseClass(window); IIntuition->CloseClass(requester); close_libs(); return rc; } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/AmigaOS/Makefile.am0000644000175000017500000000004512516137326025277 0ustar varunvarunEXTRA_DIST=agg_platform_support.cpp enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/Makefile.am0000644000175000017500000000005212516137326024015 0ustar varunvarunSUBDIRS = X11 sdl win32 AmigaOS BeOS mac enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/sdl/0000755000175000017500000000000012516137725022551 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/sdl/agg_platform_support.cpp0000644000175000017500000005564612516137326027530 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class platform_support. SDL version. // //---------------------------------------------------------------------------- #include #include "platform/agg_platform_support.h" #include "SDL.h" #include "SDL_byteorder.h" namespace agg24 { //------------------------------------------------------------------------ class platform_specific { public: platform_specific(pix_format_e format, bool flip_y); ~platform_specific(); pix_format_e m_format; pix_format_e m_sys_format; bool m_flip_y; unsigned m_bpp; unsigned m_sys_bpp; unsigned m_rmask; unsigned m_gmask; unsigned m_bmask; unsigned m_amask; bool m_update_flag; bool m_resize_flag; bool m_initialized; SDL_Surface* m_surf_screen; SDL_Surface* m_surf_window; SDL_Surface* m_surf_img[platform_support::max_images]; int m_cur_x; int m_cur_y; int m_sw_start; }; //------------------------------------------------------------------------ platform_specific::platform_specific(pix_format_e format, bool flip_y) : m_format(format), m_sys_format(pix_format_undefined), m_flip_y(flip_y), m_bpp(0), m_sys_bpp(0), m_update_flag(true), m_resize_flag(true), m_initialized(false), m_surf_screen(0), m_surf_window(0), m_cur_x(0), m_cur_y(0) { memset(m_surf_img, 0, sizeof(m_surf_img)); switch(m_format) { case pix_format_gray8: m_bpp = 8; break; case pix_format_rgb565: m_rmask = 0xF800; m_gmask = 0x7E0; m_bmask = 0x1F; m_amask = 0; m_bpp = 16; break; case pix_format_rgb555: m_rmask = 0x7C00; m_gmask = 0x3E0; m_bmask = 0x1F; m_amask = 0; m_bpp = 16; break; #if SDL_BYTEORDER == SDL_LIL_ENDIAN case pix_format_rgb24: m_rmask = 0xFF; m_gmask = 0xFF00; m_bmask = 0xFF0000; m_amask = 0; m_bpp = 24; break; case pix_format_bgr24: m_rmask = 0xFF0000; m_gmask = 0xFF00; m_bmask = 0xFF; m_amask = 0; m_bpp = 24; break; case pix_format_bgra32: m_rmask = 0xFF0000; m_gmask = 0xFF00; m_bmask = 0xFF; m_amask = 0xFF000000; m_bpp = 32; break; case pix_format_abgr32: m_rmask = 0xFF000000; m_gmask = 0xFF0000; m_bmask = 0xFF00; m_amask = 0xFF; m_bpp = 32; break; case pix_format_argb32: m_rmask = 0xFF00; m_gmask = 0xFF0000; m_bmask = 0xFF000000; m_amask = 0xFF; m_bpp = 32; break; case pix_format_rgba32: m_rmask = 0xFF; m_gmask = 0xFF00; m_bmask = 0xFF0000; m_amask = 0xFF000000; m_bpp = 32; break; #else //SDL_BIG_ENDIAN (PPC) case pix_format_rgb24: m_rmask = 0xFF0000; m_gmask = 0xFF00; m_bmask = 0xFF; m_amask = 0; m_bpp = 24; break; case pix_format_bgr24: m_rmask = 0xFF; m_gmask = 0xFF00; m_bmask = 0xFF0000; m_amask = 0; m_bpp = 24; break; case pix_format_bgra32: m_rmask = 0xFF00; m_gmask = 0xFF0000; m_bmask = 0xFF000000; m_amask = 0xFF; m_bpp = 32; break; case pix_format_abgr32: m_rmask = 0xFF; m_gmask = 0xFF00; m_bmask = 0xFF0000; m_amask = 0xFF000000; m_bpp = 32; break; case pix_format_argb32: m_rmask = 0xFF0000; m_gmask = 0xFF00; m_bmask = 0xFF; m_amask = 0xFF000000; m_bpp = 32; break; case pix_format_rgba32: m_rmask = 0xFF000000; m_gmask = 0xFF0000; m_bmask = 0xFF00; m_amask = 0xFF; m_bpp = 32; break; #endif } } //------------------------------------------------------------------------ platform_specific::~platform_specific() { int i; for(i = platform_support::max_images - 1; i >= 0; --i) { if(m_surf_img[i]) SDL_FreeSurface(m_surf_img[i]); } if(m_surf_window) SDL_FreeSurface(m_surf_window); if(m_surf_screen) SDL_FreeSurface(m_surf_screen); } //------------------------------------------------------------------------ platform_support::platform_support(pix_format_e format, bool flip_y) : m_specific(new platform_specific(format, flip_y)), m_format(format), m_bpp(m_specific->m_bpp), m_window_flags(0), m_wait_mode(true), m_flip_y(flip_y) { SDL_Init(SDL_INIT_VIDEO); strcpy(m_caption, "Anti-Grain Geometry Application"); } //------------------------------------------------------------------------ platform_support::~platform_support() { delete m_specific; } //------------------------------------------------------------------------ void platform_support::caption(const char* cap) { strcpy(m_caption, cap); if(m_specific->m_initialized) { SDL_WM_SetCaption(cap, 0); } } //------------------------------------------------------------------------ bool platform_support::init(unsigned width, unsigned height, unsigned flags) { m_window_flags = flags; unsigned wflags = SDL_SWSURFACE; if(m_window_flags & window_hw_buffer) { wflags = SDL_HWSURFACE; } if(m_window_flags & window_resize) { wflags |= SDL_RESIZABLE; } if(m_specific->m_surf_screen) SDL_FreeSurface(m_specific->m_surf_screen); m_specific->m_surf_screen = SDL_SetVideoMode(width, height, m_bpp, wflags); if(m_specific->m_surf_screen == 0) { fprintf(stderr, "Unable to set %dx%d %d bpp video: %s\n", width, height, m_bpp, ::SDL_GetError()); return false; } SDL_WM_SetCaption(m_caption, 0); if(m_specific->m_surf_window) SDL_FreeSurface(m_specific->m_surf_window); m_specific->m_surf_window = SDL_CreateRGBSurface(SDL_HWSURFACE, m_specific->m_surf_screen->w, m_specific->m_surf_screen->h, m_specific->m_surf_screen->format->BitsPerPixel, m_specific->m_rmask, m_specific->m_gmask, m_specific->m_bmask, m_specific->m_amask); if(m_specific->m_surf_window == 0) { fprintf(stderr, "Unable to create image buffer %dx%d %d bpp: %s\n", width, height, m_bpp, SDL_GetError()); return false; } m_rbuf_window.attach((unsigned char*)m_specific->m_surf_window->pixels, m_specific->m_surf_window->w, m_specific->m_surf_window->h, m_flip_y ? -m_specific->m_surf_window->pitch : m_specific->m_surf_window->pitch); if(!m_specific->m_initialized) { m_initial_width = width; m_initial_height = height; on_init(); m_specific->m_initialized = true; } on_resize(m_rbuf_window.width(), m_rbuf_window.height()); m_specific->m_update_flag = true; return true; } //------------------------------------------------------------------------ void platform_support::update_window() { SDL_BlitSurface(m_specific->m_surf_window, 0, m_specific->m_surf_screen, 0); SDL_UpdateRect(m_specific->m_surf_screen, 0, 0, 0, 0); } //------------------------------------------------------------------------ int platform_support::run() { SDL_Event event; bool ev_flag = false; for(;;) { if(m_specific->m_update_flag) { on_draw(); update_window(); m_specific->m_update_flag = false; } ev_flag = false; if(m_wait_mode) { SDL_WaitEvent(&event); ev_flag = true; } else { if(SDL_PollEvent(&event)) { ev_flag = true; } else { on_idle(); } } if(ev_flag) { if(event.type == SDL_QUIT) { break; } int y; unsigned flags = 0; switch (event.type) { case SDL_VIDEORESIZE: if(!init(event.resize.w, event.resize.h, m_window_flags)) return false; on_resize(m_rbuf_window.width(), m_rbuf_window.height()); trans_affine_resizing(event.resize.w, event.resize.h); m_specific->m_update_flag = true; break; case SDL_KEYDOWN: { flags = 0; if(event.key.keysym.mod & KMOD_SHIFT) flags |= kbd_shift; if(event.key.keysym.mod & KMOD_CTRL) flags |= kbd_ctrl; bool left = false; bool up = false; bool right = false; bool down = false; switch(event.key.keysym.sym) { case key_left: left = true; break; case key_up: up = true; break; case key_right: right = true; break; case key_down: down = true; break; } if(m_ctrls.on_arrow_keys(left, right, down, up)) { on_ctrl_change(); force_redraw(); } else { on_key(m_specific->m_cur_x, m_specific->m_cur_y, event.key.keysym.sym, flags); } } break; case SDL_MOUSEMOTION: y = m_flip_y ? m_rbuf_window.height() - event.motion.y : event.motion.y; m_specific->m_cur_x = event.motion.x; m_specific->m_cur_y = y; flags = 0; if(event.motion.state & SDL_BUTTON_LMASK) flags |= mouse_left; if(event.motion.state & SDL_BUTTON_RMASK) flags |= mouse_right; if(m_ctrls.on_mouse_move(m_specific->m_cur_x, m_specific->m_cur_y, (flags & mouse_left) != 0)) { on_ctrl_change(); force_redraw(); } else { on_mouse_move(m_specific->m_cur_x, m_specific->m_cur_y, flags); } SDL_Event eventtrash; while (SDL_PeepEvents(&eventtrash, 1, SDL_GETEVENT, SDL_EVENTMASK(SDL_MOUSEMOTION))!=0){;} break; case SDL_MOUSEBUTTONDOWN: y = m_flip_y ? m_rbuf_window.height() - event.button.y : event.button.y; m_specific->m_cur_x = event.button.x; m_specific->m_cur_y = y; flags = 0; switch(event.button.button) { case SDL_BUTTON_LEFT: { flags = mouse_left; if(m_ctrls.on_mouse_button_down(m_specific->m_cur_x, m_specific->m_cur_y)) { m_ctrls.set_cur(m_specific->m_cur_x, m_specific->m_cur_y); on_ctrl_change(); force_redraw(); } else { if(m_ctrls.in_rect(m_specific->m_cur_x, m_specific->m_cur_y)) { if(m_ctrls.set_cur(m_specific->m_cur_x, m_specific->m_cur_y)) { on_ctrl_change(); force_redraw(); } } else { on_mouse_button_down(m_specific->m_cur_x, m_specific->m_cur_y, flags); } } } break; case SDL_BUTTON_RIGHT: flags = mouse_right; on_mouse_button_down(m_specific->m_cur_x, m_specific->m_cur_y, flags); break; } //switch(event.button.button) break; case SDL_MOUSEBUTTONUP: y = m_flip_y ? m_rbuf_window.height() - event.button.y : event.button.y; m_specific->m_cur_x = event.button.x; m_specific->m_cur_y = y; flags = 0; if(m_ctrls.on_mouse_button_up(m_specific->m_cur_x, m_specific->m_cur_y)) { on_ctrl_change(); force_redraw(); } on_mouse_button_up(m_specific->m_cur_x, m_specific->m_cur_y, flags); break; } } } return 0; } //------------------------------------------------------------------------ const char* platform_support::img_ext() const { return ".bmp"; } //------------------------------------------------------------------------ const char* platform_support::full_file_name(const char* file_name) { return file_name; } //------------------------------------------------------------------------ bool platform_support::load_img(unsigned idx, const char* file) { if(idx < max_images) { if(m_specific->m_surf_img[idx]) SDL_FreeSurface(m_specific->m_surf_img[idx]); char fn[1024]; strcpy(fn, file); int len = strlen(fn); if(len < 4 || strcmp(fn + len - 4, ".bmp") != 0) { strcat(fn, ".bmp"); } SDL_Surface* tmp_surf = SDL_LoadBMP(fn); if (tmp_surf == 0) { fprintf(stderr, "Couldn't load %s: %s\n", fn, SDL_GetError()); return false; } SDL_PixelFormat format; format.palette = 0; format.BitsPerPixel = m_bpp; format.BytesPerPixel = m_bpp >> 8; format.Rmask = m_specific->m_rmask; format.Gmask = m_specific->m_gmask; format.Bmask = m_specific->m_bmask; format.Amask = m_specific->m_amask; format.Rshift = 0; format.Gshift = 0; format.Bshift = 0; format.Ashift = 0; format.Rloss = 0; format.Gloss = 0; format.Bloss = 0; format.Aloss = 0; format.colorkey = 0; format.alpha = 0; m_specific->m_surf_img[idx] = SDL_ConvertSurface(tmp_surf, &format, SDL_SWSURFACE); SDL_FreeSurface(tmp_surf); if(m_specific->m_surf_img[idx] == 0) return false; m_rbuf_img[idx].attach((unsigned char*)m_specific->m_surf_img[idx]->pixels, m_specific->m_surf_img[idx]->w, m_specific->m_surf_img[idx]->h, m_flip_y ? -m_specific->m_surf_img[idx]->pitch : m_specific->m_surf_img[idx]->pitch); return true; } return false; } //------------------------------------------------------------------------ bool platform_support::save_img(unsigned idx, const char* file) { if(idx < max_images && m_specific->m_surf_img[idx]) { char fn[1024]; strcpy(fn, file); int len = strlen(fn); if(len < 4 || strcmp(fn + len - 4, ".bmp") != 0) { strcat(fn, ".bmp"); } return SDL_SaveBMP(m_specific->m_surf_img[idx], fn) == 0; } return false; } //------------------------------------------------------------------------ bool platform_support::create_img(unsigned idx, unsigned width, unsigned height) { if(idx < max_images) { if(m_specific->m_surf_img[idx]) SDL_FreeSurface(m_specific->m_surf_img[idx]); m_specific->m_surf_img[idx] = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, m_specific->m_surf_screen->format->BitsPerPixel, m_specific->m_rmask, m_specific->m_gmask, m_specific->m_bmask, m_specific->m_amask); if(m_specific->m_surf_img[idx] == 0) { fprintf(stderr, "Couldn't create image: %s\n", SDL_GetError()); return false; } m_rbuf_img[idx].attach((unsigned char*)m_specific->m_surf_img[idx]->pixels, m_specific->m_surf_img[idx]->w, m_specific->m_surf_img[idx]->h, m_flip_y ? -m_specific->m_surf_img[idx]->pitch : m_specific->m_surf_img[idx]->pitch); return true; } return false; } //------------------------------------------------------------------------ void platform_support::start_timer() { m_specific->m_sw_start = SDL_GetTicks(); } //------------------------------------------------------------------------ double platform_support::elapsed_time() const { int stop = SDL_GetTicks(); return double(stop - m_specific->m_sw_start); } //------------------------------------------------------------------------ void platform_support::message(const char* msg) { fprintf(stderr, "%s\n", msg); } //------------------------------------------------------------------------ void platform_support::force_redraw() { m_specific->m_update_flag = true; } //------------------------------------------------------------------------ void platform_support::on_init() {} void platform_support::on_resize(int sx, int sy) {} void platform_support::on_idle() {} void platform_support::on_mouse_move(int x, int y, unsigned flags) {} void platform_support::on_mouse_button_down(int x, int y, unsigned flags) {} void platform_support::on_mouse_button_up(int x, int y, unsigned flags) {} void platform_support::on_key(int x, int y, unsigned key, unsigned flags) {} void platform_support::on_ctrl_change() {} void platform_support::on_draw() {} void platform_support::on_post_draw(void* raw_handler) {} } int agg_main(int argc, char* argv[]); int main(int argc, char* argv[]) { return agg_main(argc, argv); } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/sdl/Makefile.am0000644000175000017500000000045512516137326024606 0ustar varunvarunif ENABLE_SDL lib_LTLIBRARIES = libaggplatformsdl.la libaggplatformsdl_la_LDFLAGS = -version-info @AGG_LIB_VERSION@ libaggplatformsdl_la_SOURCES = agg_platform_support.cpp libaggplatformsdl_la_CXXFLAGS = -I$(top_srcdir)/include @SDL_CFLAGS@ libaggplatformsdl_la_LIBADD = @SDL_LIBS@ endif enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/BeOS/0000755000175000017500000000000012516137725022557 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/BeOS/agg_platform_support.cpp0000644000175000017500000010260712516137326027524 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: superstippi@gmx.de //---------------------------------------------------------------------------- // // class platform_support // //---------------------------------------------------------------------------- #include #include #include #include #include #include #include #include #include #include #include #include #include #include "platform/agg_platform_support.h" #include "util/agg_color_conv_rgb8.h" class AGGView : public BView { public: AGGView(BRect frame, agg24::platform_support* agg, agg24::pix_format_e format, bool flipY) : BView(frame, "AGG View", B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW), fAGG(agg), fFormat(format), fMouseButtons(0), fFlipY(flipY), fRedraw(true), fPulse(NULL), fLastPulse(0), fEnableTicks(true) { SetViewColor(B_TRANSPARENT_32_BIT); frame.OffsetTo(0.0, 0.0); fBitmap = new BBitmap(frame, 0, B_RGBA32); if (fBitmap->IsValid()) { fAGG->rbuf_window().attach((uint8*)fBitmap->Bits(), fBitmap->Bounds().IntegerWidth() + 1, fBitmap->Bounds().IntegerHeight() + 1, fFlipY ? -fBitmap->BytesPerRow() : fBitmap->BytesPerRow()); } else { delete fBitmap; fBitmap = NULL; } } virtual ~AGGView() { delete fBitmap; delete fPulse; } virtual void AttachedToWindow() { BMessage message('tick'); BMessenger target(this, Looper()); delete fPulse; // BScreen screen; // TODO: calc screen retrace fPulse = new BMessageRunner(target, &message, 40000); // make sure we call this once fAGG->on_resize(Bounds().IntegerWidth() + 1, Bounds().IntegerHeight() + 1); MakeFocus(); } virtual void DetachedFromWindow() { delete fPulse; fPulse = NULL; } virtual void MessageReceived(BMessage* message) { bigtime_t now = system_time(); switch (message->what) { case 'tick': // drop messages that have piled up if (/*now - fLastPulse > 30000*/fEnableTicks) { fLastPulse = now; if (!fAGG->wait_mode()) fAGG->on_idle(); Window()->PostMessage('entk', this); fEnableTicks = false; } else { // fprintf(stderr, "dropping tick message (%lld)\n", now - fLastPulse); } break; case 'entk': fEnableTicks = true; if (now - fLastPulse > 30000) { fLastPulse = now; if (!fAGG->wait_mode()) fAGG->on_idle(); } break; default: BView::MessageReceived(message); break; } } virtual void Draw(BRect updateRect) { if (fBitmap) { if (fRedraw) { fAGG->on_draw(); fRedraw = false; } if (fFormat == agg24::pix_format_bgra32) { DrawBitmap(fBitmap, updateRect, updateRect); } else { BBitmap* bitmap = new BBitmap(fBitmap->Bounds(), 0, B_RGBA32); agg24::rendering_buffer rbuf_src; rbuf_src.attach((uint8*)fBitmap->Bits(), fBitmap->Bounds().IntegerWidth() + 1, fBitmap->Bounds().IntegerHeight() + 1, fFlipY ? -fBitmap->BytesPerRow() : fBitmap->BytesPerRow()); agg24::rendering_buffer rbuf_dst; rbuf_dst.attach((uint8*)bitmap->Bits(), bitmap->Bounds().IntegerWidth() + 1, bitmap->Bounds().IntegerHeight() + 1, fFlipY ? -bitmap->BytesPerRow() : bitmap->BytesPerRow()); switch(fFormat) { case agg24::pix_format_rgb555: agg24::color_conv(&rbuf_dst, &rbuf_src, agg24::color_conv_rgb555_to_bgra32()); break; case agg24::pix_format_rgb565: agg24::color_conv(&rbuf_dst, &rbuf_src, agg24::color_conv_rgb565_to_bgra32()); break; case agg24::pix_format_rgb24: agg24::color_conv(&rbuf_dst, &rbuf_src, agg24::color_conv_rgb24_to_bgra32()); break; case agg24::pix_format_bgr24: agg24::color_conv(&rbuf_dst, &rbuf_src, agg24::color_conv_bgr24_to_bgra32()); break; case agg24::pix_format_rgba32: agg24::color_conv(&rbuf_dst, &rbuf_src, agg24::color_conv_rgba32_to_bgra32()); break; case agg24::pix_format_argb32: agg24::color_conv(&rbuf_dst, &rbuf_src, agg24::color_conv_argb32_to_bgra32()); break; case agg24::pix_format_abgr32: agg24::color_conv(&rbuf_dst, &rbuf_src, agg24::color_conv_abgr32_to_bgra32()); break; case agg24::pix_format_bgra32: agg24::color_conv(&rbuf_dst, &rbuf_src, agg24::color_conv_bgra32_to_bgra32()); break; } DrawBitmap(bitmap, updateRect, updateRect); delete bitmap; } } else { FillRect(updateRect); } } virtual void FrameResized(float width, float height) { BRect r(0.0, 0.0, width, height); BBitmap* bitmap = new BBitmap(r, 0, B_RGBA32); if (bitmap->IsValid()) { delete fBitmap; fBitmap = bitmap; fAGG->rbuf_window().attach((uint8*)fBitmap->Bits(), fBitmap->Bounds().IntegerWidth() + 1, fBitmap->Bounds().IntegerHeight() + 1, fFlipY ? -fBitmap->BytesPerRow() : fBitmap->BytesPerRow()); fAGG->trans_affine_resizing((int)width + 1, (int)height + 1); // pass the event on to AGG fAGG->on_resize((int)width + 1, (int)height + 1); fRedraw = true; Invalidate(); } else delete bitmap; } virtual void KeyDown(const char* bytes, int32 numBytes) { if (bytes && numBytes > 0) { fLastKeyDown = bytes[0]; bool left = false; bool up = false; bool right = false; bool down = false; switch (fLastKeyDown) { case B_LEFT_ARROW: left = true; break; case B_UP_ARROW: up = true; break; case B_RIGHT_ARROW: right = true; break; case B_DOWN_ARROW: down = true; break; } /* case key_f2: fAGG->copy_window_to_img(agg24::platform_support::max_images - 1); fAGG->save_img(agg24::platform_support::max_images - 1, "screenshot"); break; }*/ if (fAGG->m_ctrls.on_arrow_keys(left, right, down, up)) { fAGG->on_ctrl_change(); fAGG->force_redraw(); } else { fAGG->on_key(fMouseX, fMouseY, fLastKeyDown, GetKeyFlags()); } // fAGG->on_key(fMouseX, fMouseY, fLastKeyDown, GetKeyFlags()); } } virtual void MouseDown(BPoint where) { BMessage* currentMessage = Window()->CurrentMessage(); if (currentMessage) { if (currentMessage->FindInt32("buttons", (int32*)&fMouseButtons) < B_OK) fMouseButtons = B_PRIMARY_MOUSE_BUTTON; } else fMouseButtons = B_PRIMARY_MOUSE_BUTTON; fMouseX = (int)where.x; fMouseY = fFlipY ? (int)(Bounds().Height() - where.y) : (int)where.y; // pass the event on to AGG if (fMouseButtons == B_PRIMARY_MOUSE_BUTTON) { // left mouse button -> see if to handle in controls fAGG->m_ctrls.set_cur(fMouseX, fMouseY); if (fAGG->m_ctrls.on_mouse_button_down(fMouseX, fMouseY)) { fAGG->on_ctrl_change(); fAGG->force_redraw(); } else { if (fAGG->m_ctrls.in_rect(fMouseX, fMouseY)) { if (fAGG->m_ctrls.set_cur(fMouseX, fMouseY)) { fAGG->on_ctrl_change(); fAGG->force_redraw(); } } else { fAGG->on_mouse_button_down(fMouseX, fMouseY, GetKeyFlags()); } } } else if (fMouseButtons & B_SECONDARY_MOUSE_BUTTON) { // right mouse button -> simple fAGG->on_mouse_button_down(fMouseX, fMouseY, GetKeyFlags()); } SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); } virtual void MouseMoved(BPoint where, uint32 transit, const BMessage* dragMesage) { // workarround missed mouse up events // (if we react too slowly, app_server might have dropped events) BMessage* currentMessage = Window()->CurrentMessage(); int32 buttons = 0; if (currentMessage->FindInt32("buttons", &buttons) < B_OK) { buttons = 0; } if (!buttons) MouseUp(where); fMouseX = (int)where.x; fMouseY = fFlipY ? (int)(Bounds().Height() - where.y) : (int)where.y; // pass the event on to AGG if (fAGG->m_ctrls.on_mouse_move(fMouseX, fMouseY, (GetKeyFlags() & agg24::mouse_left) != 0)) { fAGG->on_ctrl_change(); fAGG->force_redraw(); } else { if (!fAGG->m_ctrls.in_rect(fMouseX, fMouseY)) { fAGG->on_mouse_move(fMouseX, fMouseY, GetKeyFlags()); } } } virtual void MouseUp(BPoint where) { fMouseX = (int)where.x; fMouseY = fFlipY ? (int)(Bounds().Height() - where.y) : (int)where.y; // pass the event on to AGG if (fMouseButtons == B_PRIMARY_MOUSE_BUTTON) { fMouseButtons = 0; if (fAGG->m_ctrls.on_mouse_button_up(fMouseX, fMouseY)) { fAGG->on_ctrl_change(); fAGG->force_redraw(); } fAGG->on_mouse_button_up(fMouseX, fMouseY, GetKeyFlags()); } else if (fMouseButtons == B_SECONDARY_MOUSE_BUTTON) { fMouseButtons = 0; fAGG->on_mouse_button_up(fMouseX, fMouseY, GetKeyFlags()); } } BBitmap* Bitmap() const { return fBitmap; } uint8 LastKeyDown() const { return fLastKeyDown; } uint32 MouseButtons() { uint32 buttons = 0; if (LockLooper()) { buttons = fMouseButtons; UnlockLooper(); } return buttons; } void Update() { // trigger display update if (LockLooper()) { Invalidate(); UnlockLooper(); } } void ForceRedraw() { // force a redraw (fRedraw = true;) // and trigger display update if (LockLooper()) { fRedraw = true; Invalidate(); UnlockLooper(); } } unsigned GetKeyFlags() { uint32 buttons = fMouseButtons; uint32 mods = modifiers(); unsigned flags = 0; if (buttons & B_PRIMARY_MOUSE_BUTTON) flags |= agg24::mouse_left; if (buttons & B_SECONDARY_MOUSE_BUTTON) flags |= agg24::mouse_right; if (mods & B_SHIFT_KEY) flags |= agg24::kbd_shift; if (mods & B_COMMAND_KEY) flags |= agg24::kbd_ctrl; return flags; } private: BBitmap* fBitmap; uint8 fLastKeyDown; agg24::platform_support* fAGG; agg24::pix_format_e fFormat; uint32 fMouseButtons; int32 fMouseX; int32 fMouseY; bool fFlipY; bool fRedraw; BMessageRunner* fPulse; bigtime_t fLastPulse; bool fEnableTicks; }; class AGGWindow : public BWindow { public: AGGWindow() : BWindow(BRect(-50.0, -50.0, -10.0, -10.0), "AGG Application", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) { } virtual bool QuitRequested() { be_app->PostMessage(B_QUIT_REQUESTED); return true; } bool Init(BRect frame, agg24::platform_support* agg, agg24::pix_format_e format, bool flipY, uint32 flags) { MoveTo(frame.LeftTop()); ResizeTo(frame.Width(), frame.Height()); SetFlags(flags); frame.OffsetTo(0.0, 0.0); fView = new AGGView(frame, agg, format, flipY); AddChild(fView); return fView->Bitmap() != NULL; } AGGView* View() const { return fView; } private: AGGView* fView; }; class AGGApplication : public BApplication { public: AGGApplication() : BApplication("application/x-vnd.AGG-AGG") { fWindow = new AGGWindow(); } virtual void ReadyToRun() { if (fWindow) { fWindow->Show(); } } virtual bool Init(agg24::platform_support* agg, int width, int height, agg24::pix_format_e format, bool flipY, uint32 flags) { // ignore flip_y for now BRect r(50.0, 50.0, 50.0 + width - 1.0, 50.0 + height - 1.0); uint32 windowFlags = B_ASYNCHRONOUS_CONTROLS; if (!(flags & agg24::window_resize)) windowFlags |= B_NOT_RESIZABLE; return fWindow->Init(r, agg, format, flipY, windowFlags);; } AGGWindow* Window() const { return fWindow; } private: AGGWindow* fWindow; }; namespace agg24 { class platform_specific { public: platform_specific(agg24::platform_support* agg, agg24::pix_format_e format, bool flip_y) : fAGG(agg), fApp(NULL), fFormat(format), fFlipY(flip_y), fTimerStart(system_time()) { memset(fImages, 0, sizeof(fImages)); fApp = new AGGApplication(); fAppPath[0] = 0; // figure out where we're running from app_info info; status_t ret = fApp->GetAppInfo(&info); if (ret >= B_OK) { BPath path(&info.ref); ret = path.InitCheck(); if (ret >= B_OK) { ret = path.GetParent(&path); if (ret >= B_OK) { sprintf(fAppPath, "%s", path.Path()); } else { fprintf(stderr, "getting app parent folder failed: %s\n", strerror(ret)); } } else { fprintf(stderr, "making app path failed: %s\n", strerror(ret)); } } else { fprintf(stderr, "GetAppInfo() failed: %s\n", strerror(ret)); } } ~platform_specific() { for (int32 i = 0; i < agg24::platform_support::max_images; i++) delete fImages[i]; delete fApp; } bool Init(int width, int height, unsigned flags) { return fApp->Init(fAGG, width, height, fFormat, fFlipY, flags); } int Run() { status_t ret = B_NO_INIT; if (fApp) { fApp->Run(); ret = B_OK; } return ret; } void SetTitle(const char* title) { if (fApp && fApp->Window() && fApp->Window()->Lock()) { fApp->Window()->SetTitle(title); fApp->Window()->Unlock(); } } void StartTimer() { fTimerStart = system_time(); } double ElapsedTime() const { return (system_time() - fTimerStart) / 1000.0; } void ForceRedraw() { fApp->Window()->View()->ForceRedraw(); } void UpdateWindow() { fApp->Window()->View()->Update(); } agg24::platform_support* fAGG; AGGApplication* fApp; agg24::pix_format_e fFormat; bool fFlipY; bigtime_t fTimerStart; BBitmap* fImages[agg24::platform_support::max_images]; char fAppPath[B_PATH_NAME_LENGTH]; char fFilePath[B_PATH_NAME_LENGTH]; }; //------------------------------------------------------------------------ platform_support::platform_support(pix_format_e format, bool flip_y) : m_specific(new platform_specific(this, format, flip_y)), m_format(format), m_bpp(32/*m_specific->m_bpp*/), m_window_flags(0), m_wait_mode(true), m_flip_y(flip_y), m_initial_width(10), m_initial_height(10) { strcpy(m_caption, "Anti-Grain Geometry Application"); } //------------------------------------------------------------------------ platform_support::~platform_support() { delete m_specific; } //------------------------------------------------------------------------ void platform_support::caption(const char* cap) { strcpy(m_caption, cap); m_specific->SetTitle(cap); } //------------------------------------------------------------------------ void platform_support::start_timer() { m_specific->StartTimer(); } //------------------------------------------------------------------------ double platform_support::elapsed_time() const { return m_specific->ElapsedTime(); } //------------------------------------------------------------------------ void* platform_support::raw_display_handler() { return NULL;//m_specific->m_current_dc; } //------------------------------------------------------------------------ void platform_support::message(const char* msg) { BAlert* alert = new BAlert("AGG Message", msg, "Ok"); alert->Go(/*NULL*/); } //------------------------------------------------------------------------ bool platform_support::init(unsigned width, unsigned height, unsigned flags) { bool success = m_specific->Init(width, height, flags); m_window_flags = flags; // m_specific->create_pmap(width, height, &m_rbuf_window); m_initial_width = width; m_initial_height = height; on_init(); // m_specific->m_redraw_flag = true; return true; } //------------------------------------------------------------------------ int platform_support::run() { return m_specific->Run(); } //------------------------------------------------------------------------ const char* platform_support::img_ext() const { return ".ppm"; } const char* platform_support::full_file_name(const char* file_name) { sprintf(m_specific->fFilePath, "%s/%s", m_specific->fAppPath, file_name); return m_specific->fFilePath; } //------------------------------------------------------------------------ bool platform_support::load_img(unsigned idx, const char* file) { if (idx < max_images) { char path[B_PATH_NAME_LENGTH]; sprintf(path, "%s/%s%s", m_specific->fAppPath, file, img_ext()); BBitmap* transBitmap = BTranslationUtils::GetBitmap(path); if (transBitmap && transBitmap->IsValid()) { if(transBitmap->ColorSpace() != B_RGB32 && transBitmap->ColorSpace() != B_RGBA32) { // ups we got a smart ass Translator making our live harder delete transBitmap; return false; } color_space format = B_RGB24; switch (m_format) { case pix_format_gray8: format = B_GRAY8; break; case pix_format_rgb555: format = B_RGB15; break; case pix_format_rgb565: format = B_RGB16; break; case pix_format_rgb24: format = B_RGB24_BIG; break; case pix_format_bgr24: format = B_RGB24; break; case pix_format_abgr32: case pix_format_argb32: case pix_format_bgra32: format = B_RGB32; break; case pix_format_rgba32: format = B_RGB32_BIG; break; } BBitmap* bitmap = new BBitmap(transBitmap->Bounds(), 0, format); if (!bitmap || !bitmap->IsValid()) { fprintf(stderr, "failed to allocate temporary bitmap!\n"); delete transBitmap; delete bitmap; return false; } delete m_specific->fImages[idx]; rendering_buffer rbuf_tmp; rbuf_tmp.attach((uint8*)transBitmap->Bits(), transBitmap->Bounds().IntegerWidth() + 1, transBitmap->Bounds().IntegerHeight() + 1, m_flip_y ? -transBitmap->BytesPerRow() : transBitmap->BytesPerRow()); m_specific->fImages[idx] = bitmap; m_rbuf_img[idx].attach((uint8*)bitmap->Bits(), bitmap->Bounds().IntegerWidth() + 1, bitmap->Bounds().IntegerHeight() + 1, m_flip_y ? -bitmap->BytesPerRow() : bitmap->BytesPerRow()); rendering_buffer* dst = &m_rbuf_img[idx]; switch(m_format) { case pix_format_gray8: return false; // color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_gray8()); break; break; case pix_format_rgb555: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgb555()); break; break; case pix_format_rgb565: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgb565()); break; break; case pix_format_rgb24: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgb24()); break; break; case pix_format_bgr24: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_bgr24()); break; break; case pix_format_abgr32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_abgr32()); break; break; case pix_format_argb32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_argb32()); break; break; case pix_format_bgra32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_bgra32()); break; break; case pix_format_rgba32: color_conv(dst, &rbuf_tmp, color_conv_bgra32_to_rgba32()); break; break; } delete transBitmap; return true; } else { fprintf(stderr, "failed to load bitmap: '%s'\n", full_file_name(file)); } } return false; } //------------------------------------------------------------------------ bool platform_support::save_img(unsigned idx, const char* file) { // TODO: implement using BTranslatorRoster and friends return false; } //------------------------------------------------------------------------ bool platform_support::create_img(unsigned idx, unsigned width, unsigned height) { if(idx < max_images) { if(width == 0) width = m_specific->fApp->Window()->View()->Bitmap()->Bounds().IntegerWidth() + 1; if(height == 0) height = m_specific->fApp->Window()->View()->Bitmap()->Bounds().IntegerHeight() + 1; BBitmap* bitmap = new BBitmap(BRect(0.0, 0.0, width - 1, height - 1), 0, B_RGBA32);; if (bitmap && bitmap->IsValid()) { delete m_specific->fImages[idx]; m_specific->fImages[idx] = bitmap; m_rbuf_img[idx].attach((uint8*)bitmap->Bits(), width, height, m_flip_y ? -bitmap->BytesPerRow() : bitmap->BytesPerRow()); return true; } else { delete bitmap; } } return false; } //------------------------------------------------------------------------ void platform_support::force_redraw() { m_specific->ForceRedraw(); } //------------------------------------------------------------------------ void platform_support::update_window() { m_specific->UpdateWindow(); } //------------------------------------------------------------------------ void platform_support::on_init() {} void platform_support::on_resize(int sx, int sy) {} void platform_support::on_idle() {} void platform_support::on_mouse_move(int x, int y, unsigned flags) {} void platform_support::on_mouse_button_down(int x, int y, unsigned flags) {} void platform_support::on_mouse_button_up(int x, int y, unsigned flags) {} void platform_support::on_key(int x, int y, unsigned key, unsigned flags) {} void platform_support::on_ctrl_change() {} void platform_support::on_draw() {} void platform_support::on_post_draw(void* raw_handler) {} } //---------------------------------------------------------------------------- int agg_main(int argc, char* argv[]); int main(int argc, char* argv[]) { return agg_main(argc, argv); } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/platform/BeOS/Makefile.am0000644000175000017500000000004512516137326024607 0ustar varunvarunEXTRA_DIST=agg_platform_support.cpp enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_vcgen_dash.cpp0000644000175000017500000001621612516137326023571 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Line dash generator // //---------------------------------------------------------------------------- #include #include "agg_vcgen_dash.h" #include "agg_shorten_path.h" namespace agg24 { //------------------------------------------------------------------------ vcgen_dash::vcgen_dash() : m_total_dash_len(0.0), m_num_dashes(0), m_dash_start(0.0), m_shorten(0.0), m_curr_dash_start(0.0), m_curr_dash(0), m_src_vertices(), m_closed(0), m_status(initial), m_src_vertex(0) { } //------------------------------------------------------------------------ void vcgen_dash::remove_all_dashes() { m_total_dash_len = 0.0; m_num_dashes = 0; m_curr_dash_start = 0.0; m_curr_dash = 0; } //------------------------------------------------------------------------ void vcgen_dash::add_dash(double dash_len, double gap_len) { if(m_num_dashes < max_dashes) { m_total_dash_len += dash_len + gap_len; m_dashes[m_num_dashes++] = dash_len; m_dashes[m_num_dashes++] = gap_len; } } //------------------------------------------------------------------------ void vcgen_dash::dash_start(double ds) { m_dash_start = ds; calc_dash_start(fabs(ds)); } //------------------------------------------------------------------------ void vcgen_dash::calc_dash_start(double ds) { m_curr_dash = 0; m_curr_dash_start = 0.0; while(ds > 0.0) { if(ds > m_dashes[m_curr_dash]) { ds -= m_dashes[m_curr_dash]; ++m_curr_dash; m_curr_dash_start = 0.0; if(m_curr_dash >= m_num_dashes) m_curr_dash = 0; } else { m_curr_dash_start = ds; ds = 0.0; } } } //------------------------------------------------------------------------ void vcgen_dash::remove_all() { m_status = initial; m_src_vertices.remove_all(); m_closed = 0; } //------------------------------------------------------------------------ void vcgen_dash::add_vertex(double x, double y, unsigned cmd) { m_status = initial; if(is_move_to(cmd)) { m_src_vertices.modify_last(vertex_dist(x, y)); } else { if(is_vertex(cmd)) { m_src_vertices.add(vertex_dist(x, y)); } else { m_closed = get_close_flag(cmd); } } } //------------------------------------------------------------------------ void vcgen_dash::rewind(unsigned) { if(m_status == initial) { m_src_vertices.close(m_closed != 0); shorten_path(m_src_vertices, m_shorten, m_closed); } m_status = ready; m_src_vertex = 0; } //------------------------------------------------------------------------ unsigned vcgen_dash::vertex(double* x, double* y) { unsigned cmd = path_cmd_move_to; while(!is_stop(cmd)) { switch(m_status) { case initial: rewind(0); case ready: if(m_num_dashes < 2 || m_src_vertices.size() < 2) { cmd = path_cmd_stop; break; } m_status = polyline; m_src_vertex = 1; m_v1 = &m_src_vertices[0]; m_v2 = &m_src_vertices[1]; m_curr_rest = m_v1->dist; *x = m_v1->x; *y = m_v1->y; if(m_dash_start >= 0.0) calc_dash_start(m_dash_start); return path_cmd_move_to; case polyline: { double dash_rest = m_dashes[m_curr_dash] - m_curr_dash_start; unsigned cmd = (m_curr_dash & 1) ? path_cmd_move_to : path_cmd_line_to; if(m_curr_rest > dash_rest) { m_curr_rest -= dash_rest; ++m_curr_dash; if(m_curr_dash >= m_num_dashes) m_curr_dash = 0; m_curr_dash_start = 0.0; *x = m_v2->x - (m_v2->x - m_v1->x) * m_curr_rest / m_v1->dist; *y = m_v2->y - (m_v2->y - m_v1->y) * m_curr_rest / m_v1->dist; } else { m_curr_dash_start += m_curr_rest; *x = m_v2->x; *y = m_v2->y; ++m_src_vertex; m_v1 = m_v2; m_curr_rest = m_v1->dist; if(m_closed) { if(m_src_vertex > m_src_vertices.size()) { m_status = stop; } else { m_v2 = &m_src_vertices [ (m_src_vertex >= m_src_vertices.size()) ? 0 : m_src_vertex ]; } } else { if(m_src_vertex >= m_src_vertices.size()) { m_status = stop; } else { m_v2 = &m_src_vertices[m_src_vertex]; } } } return cmd; } break; case stop: cmd = path_cmd_stop; break; } } return path_cmd_stop; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_line_aa_basics.cpp0000644000175000017500000000610212516137326024375 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #include #include "agg_line_aa_basics.h" namespace agg24 { //------------------------------------------------------------------------- // The number of the octant is determined as a 3-bit value as follows: // bit 0 = vertical flag // bit 1 = sx < 0 // bit 2 = sy < 0 // // [N] shows the number of the orthogonal quadrant // shows the number of the diagonal quadrant // <1> // [1] | [0] // . (3)011 | 001(1) . // . | . // . | . // . | . // (2)010 .|. 000(0) // <2> ----------.+.----------- <0> // (6)110 . | . 100(4) // . | . // . | . // . | . // (7)111 | 101(5) // [2] | [3] // <3> // 0,1,2,3,4,5,6,7 const int8u line_parameters::s_orthogonal_quadrant[8] = { 0,0,1,1,3,3,2,2 }; const int8u line_parameters::s_diagonal_quadrant[8] = { 0,1,2,1,0,3,2,3 }; //------------------------------------------------------------------------- void bisectrix(const line_parameters& l1, const line_parameters& l2, int* x, int* y) { double k = double(l2.len) / double(l1.len); double tx = l2.x2 - (l2.x1 - l1.x1) * k; double ty = l2.y2 - (l2.y1 - l1.y1) * k; //All bisectrices must be on the right of the line //If the next point is on the left (l1 => l2.2) //then the bisectix should be rotated by 180 degrees. if(double(l2.x2 - l2.x1) * double(l2.y1 - l1.y1) < double(l2.y2 - l2.y1) * double(l2.x1 - l1.x1) + 100.0) { tx -= (tx - l2.x1) * 2.0; ty -= (ty - l2.y1) * 2.0; } // Check if the bisectrix is too short double dx = tx - l2.x1; double dy = ty - l2.y1; if((int)sqrt(dx * dx + dy * dy) < line_subpixel_scale) { *x = (l2.x1 + l2.x1 + (l2.y1 - l1.y1) + (l2.y2 - l2.y1)) >> 1; *y = (l2.y1 + l2.y1 - (l2.x1 - l1.x1) - (l2.x2 - l2.x1)) >> 1; return; } *x = iround(tx); *y = iround(ty); } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_trans_single_path.cpp0000644000175000017500000001516412516137326025175 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #include "agg_math.h" #include "agg_vertex_sequence.h" #include "agg_trans_single_path.h" namespace agg24 { //------------------------------------------------------------------------ trans_single_path::trans_single_path() : m_base_length(0.0), m_kindex(0.0), m_status(initial), m_preserve_x_scale(true) { } //------------------------------------------------------------------------ void trans_single_path::reset() { m_src_vertices.remove_all(); m_kindex = 0.0; m_status = initial; } //------------------------------------------------------------------------ void trans_single_path::move_to(double x, double y) { if(m_status == initial) { m_src_vertices.modify_last(vertex_dist(x, y)); m_status = making_path; } else { line_to(x, y); } } //------------------------------------------------------------------------ void trans_single_path::line_to(double x, double y) { if(m_status == making_path) { m_src_vertices.add(vertex_dist(x, y)); } } //------------------------------------------------------------------------ void trans_single_path::finalize_path() { if(m_status == making_path && m_src_vertices.size() > 1) { unsigned i; double dist; double d; m_src_vertices.close(false); if(m_src_vertices.size() > 2) { if(m_src_vertices[m_src_vertices.size() - 2].dist * 10.0 < m_src_vertices[m_src_vertices.size() - 3].dist) { d = m_src_vertices[m_src_vertices.size() - 3].dist + m_src_vertices[m_src_vertices.size() - 2].dist; m_src_vertices[m_src_vertices.size() - 2] = m_src_vertices[m_src_vertices.size() - 1]; m_src_vertices.remove_last(); m_src_vertices[m_src_vertices.size() - 2].dist = d; } } dist = 0.0; for(i = 0; i < m_src_vertices.size(); i++) { vertex_dist& v = m_src_vertices[i]; double d = v.dist; v.dist = dist; dist += d; } m_kindex = (m_src_vertices.size() - 1) / dist; m_status = ready; } } //------------------------------------------------------------------------ double trans_single_path::total_length() const { if(m_base_length >= 1e-10) return m_base_length; return (m_status == ready) ? m_src_vertices[m_src_vertices.size() - 1].dist : 0.0; } //------------------------------------------------------------------------ void trans_single_path::transform(double *x, double *y) const { if(m_status == ready) { if(m_base_length > 1e-10) { *x *= m_src_vertices[m_src_vertices.size() - 1].dist / m_base_length; } double x1 = 0.0; double y1 = 0.0; double dx = 1.0; double dy = 1.0; double d = 0.0; double dd = 1.0; if(*x < 0.0) { // Extrapolation on the left //-------------------------- x1 = m_src_vertices[0].x; y1 = m_src_vertices[0].y; dx = m_src_vertices[1].x - x1; dy = m_src_vertices[1].y - y1; dd = m_src_vertices[1].dist - m_src_vertices[0].dist; d = *x; } else if(*x > m_src_vertices[m_src_vertices.size() - 1].dist) { // Extrapolation on the right //-------------------------- unsigned i = m_src_vertices.size() - 2; unsigned j = m_src_vertices.size() - 1; x1 = m_src_vertices[j].x; y1 = m_src_vertices[j].y; dx = x1 - m_src_vertices[i].x; dy = y1 - m_src_vertices[i].y; dd = m_src_vertices[j].dist - m_src_vertices[i].dist; d = *x - m_src_vertices[j].dist; } else { // Interpolation //-------------------------- unsigned i = 0; unsigned j = m_src_vertices.size() - 1; if(m_preserve_x_scale) { unsigned k; for(i = 0; (j - i) > 1; ) { if(*x < m_src_vertices[k = (i + j) >> 1].dist) { j = k; } else { i = k; } } d = m_src_vertices[i].dist; dd = m_src_vertices[j].dist - d; d = *x - d; } else { i = unsigned(*x * m_kindex); j = i + 1; dd = m_src_vertices[j].dist - m_src_vertices[i].dist; d = ((*x * m_kindex) - i) * dd; } x1 = m_src_vertices[i].x; y1 = m_src_vertices[i].y; dx = m_src_vertices[j].x - x1; dy = m_src_vertices[j].y - y1; } double x2 = x1 + dx * d / dd; double y2 = y1 + dy * d / dd; *x = x2 - *y * dy / dd; *y = y2 + *y * dx / dd; } } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/Makefile.am0000644000175000017500000000241312516137326022174 0ustar varunvarunSUBDIRS = ctrl . platform INCLUDES = -I$(top_srcdir)/include lib_LTLIBRARIES = libagg.la libagg_la_LDFLAGS = -no-undefined -version-info @AGG_LIB_VERSION@ libagg_la_SOURCES = agg_arc.cpp \ agg_arrowhead.cpp \ agg_bezier_arc.cpp \ agg_bspline.cpp \ agg_curves.cpp \ agg_embedded_raster_fonts.cpp \ agg_gsv_text.cpp \ agg_image_filters.cpp \ agg_line_aa_basics.cpp \ agg_line_profile_aa.cpp \ agg_rounded_rect.cpp \ agg_sqrt_tables.cpp \ agg_trans_affine.cpp \ agg_trans_double_path.cpp \ agg_trans_single_path.cpp \ agg_trans_warp_magnifier.cpp \ agg_vcgen_bspline.cpp \ agg_vcgen_contour.cpp \ agg_vcgen_dash.cpp \ agg_vcgen_markers_term.cpp \ agg_vcgen_smooth_poly1.cpp \ agg_vcgen_stroke.cpp \ agg_vpgen_clip_polygon.cpp \ agg_vpgen_clip_polyline.cpp \ agg_vpgen_segmentator.cpp if ENABLE_GPC GPCLD=$(top_builddir)/gpc/libagggpc.la else GPCLD= endif if ENABLE_CTRL CTRLLD=$(top_builddir)/src/ctrl/libaggctrl.la else CTRLLD= endif libagg_la_LIBADD = $(GPCLD) $(CTRLLD) enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_bezier_arc.cpp0000644000175000017500000002132112516137326023566 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Arc generator. Produces at most 4 consecutive cubic bezier curves, i.e., // 4, 7, 10, or 13 vertices. // //---------------------------------------------------------------------------- #include #include "agg_bezier_arc.h" namespace agg24 { // This epsilon is used to prevent us from adding degenerate curves // (converging to a single point). // The value isn't very critical. Function arc_to_bezier() has a limit // of the sweep_angle. If fabs(sweep_angle) exceeds pi/2 the curve // becomes inaccurate. But slight exceeding is quite appropriate. //-------------------------------------------------bezier_arc_angle_epsilon const double bezier_arc_angle_epsilon = 0.01; //------------------------------------------------------------arc_to_bezier void arc_to_bezier(double cx, double cy, double rx, double ry, double start_angle, double sweep_angle, double* curve) { double x0 = cos(sweep_angle / 2.0); double y0 = sin(sweep_angle / 2.0); double tx = (1.0 - x0) * 4.0 / 3.0; double ty = y0 - tx * x0 / y0; double px[4]; double py[4]; px[0] = x0; py[0] = -y0; px[1] = x0 + tx; py[1] = -ty; px[2] = x0 + tx; py[2] = ty; px[3] = x0; py[3] = y0; double sn = sin(start_angle + sweep_angle / 2.0); double cs = cos(start_angle + sweep_angle / 2.0); unsigned i; for(i = 0; i < 4; i++) { curve[i * 2] = cx + rx * (px[i] * cs - py[i] * sn); curve[i * 2 + 1] = cy + ry * (px[i] * sn + py[i] * cs); } } //------------------------------------------------------------------------ void bezier_arc::init(double x, double y, double rx, double ry, double start_angle, double sweep_angle) { start_angle = fmod(start_angle, 2.0 * pi); if(sweep_angle >= 2.0 * pi) sweep_angle = 2.0 * pi; if(sweep_angle <= -2.0 * pi) sweep_angle = -2.0 * pi; if(fabs(sweep_angle) < 1e-10) { m_num_vertices = 4; m_cmd = path_cmd_line_to; m_vertices[0] = x + rx * cos(start_angle); m_vertices[1] = y + ry * sin(start_angle); m_vertices[2] = x + rx * cos(start_angle + sweep_angle); m_vertices[3] = y + ry * sin(start_angle + sweep_angle); return; } double total_sweep = 0.0; double local_sweep = 0.0; double prev_sweep; m_num_vertices = 2; m_cmd = path_cmd_curve4; bool done = false; do { if(sweep_angle < 0.0) { prev_sweep = total_sweep; local_sweep = -pi * 0.5; total_sweep -= pi * 0.5; if(total_sweep <= sweep_angle + bezier_arc_angle_epsilon) { local_sweep = sweep_angle - prev_sweep; done = true; } } else { prev_sweep = total_sweep; local_sweep = pi * 0.5; total_sweep += pi * 0.5; if(total_sweep >= sweep_angle - bezier_arc_angle_epsilon) { local_sweep = sweep_angle - prev_sweep; done = true; } } arc_to_bezier(x, y, rx, ry, start_angle, local_sweep, m_vertices + m_num_vertices - 2); m_num_vertices += 6; start_angle += local_sweep; } while(!done && m_num_vertices < 26); } //-------------------------------------------------------------------- void bezier_arc_svg::init(double x0, double y0, double rx, double ry, double angle, bool large_arc_flag, bool sweep_flag, double x2, double y2) { m_radii_ok = true; if(rx < 0.0) rx = -rx; if(ry < 0.0) ry = -rx; // Calculate the middle point between // the current and the final points //------------------------ double dx2 = (x0 - x2) / 2.0; double dy2 = (y0 - y2) / 2.0; double cos_a = cos(angle); double sin_a = sin(angle); // Calculate (x1, y1) //------------------------ double x1 = cos_a * dx2 + sin_a * dy2; double y1 = -sin_a * dx2 + cos_a * dy2; // Ensure radii are large enough //------------------------ double prx = rx * rx; double pry = ry * ry; double px1 = x1 * x1; double py1 = y1 * y1; // Check that radii are large enough //------------------------ double radii_check = px1/prx + py1/pry; if(radii_check > 1.0) { rx = sqrt(radii_check) * rx; ry = sqrt(radii_check) * ry; prx = rx * rx; pry = ry * ry; if(radii_check > 10.0) m_radii_ok = false; } // Calculate (cx1, cy1) //------------------------ double sign = (large_arc_flag == sweep_flag) ? -1.0 : 1.0; double sq = (prx*pry - prx*py1 - pry*px1) / (prx*py1 + pry*px1); double coef = sign * sqrt((sq < 0) ? 0 : sq); double cx1 = coef * ((rx * y1) / ry); double cy1 = coef * -((ry * x1) / rx); // // Calculate (cx, cy) from (cx1, cy1) //------------------------ double sx2 = (x0 + x2) / 2.0; double sy2 = (y0 + y2) / 2.0; double cx = sx2 + (cos_a * cx1 - sin_a * cy1); double cy = sy2 + (sin_a * cx1 + cos_a * cy1); // Calculate the start_angle (angle1) and the sweep_angle (dangle) //------------------------ double ux = (x1 - cx1) / rx; double uy = (y1 - cy1) / ry; double vx = (-x1 - cx1) / rx; double vy = (-y1 - cy1) / ry; double p, n; // Calculate the angle start //------------------------ n = sqrt(ux*ux + uy*uy); p = ux; // (1 * ux) + (0 * uy) sign = (uy < 0) ? -1.0 : 1.0; double v = p / n; if(v < -1.0) v = -1.0; if(v > 1.0) v = 1.0; double start_angle = sign * acos(v); // Calculate the sweep angle //------------------------ n = sqrt((ux*ux + uy*uy) * (vx*vx + vy*vy)); p = ux * vx + uy * vy; sign = (ux * vy - uy * vx < 0) ? -1.0 : 1.0; v = p / n; if(v < -1.0) v = -1.0; if(v > 1.0) v = 1.0; double sweep_angle = sign * acos(v); if(!sweep_flag && sweep_angle > 0) { sweep_angle -= pi * 2.0; } else if (sweep_flag && sweep_angle < 0) { sweep_angle += pi * 2.0; } // We can now build and transform the resulting arc //------------------------ m_arc.init(0.0, 0.0, rx, ry, start_angle, sweep_angle); trans_affine mtx = trans_affine_rotation(angle); mtx *= trans_affine_translation(cx, cy); for(unsigned i = 2; i < m_arc.num_vertices()-2; i += 2) { mtx.transform(m_arc.vertices() + i, m_arc.vertices() + i + 1); } // We must make sure that the starting and ending points // exactly coincide with the initial (x0,y0) and (x2,y2) m_arc.vertices()[0] = x0; m_arc.vertices()[1] = y0; if(m_arc.num_vertices() > 2) { m_arc.vertices()[m_arc.num_vertices() - 2] = x2; m_arc.vertices()[m_arc.num_vertices() - 1] = y2; } } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_trans_warp_magnifier.cpp0000644000175000017500000000322712516137326025667 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #include #include "agg_trans_warp_magnifier.h" namespace agg24 { //------------------------------------------------------------------------ void trans_warp_magnifier::transform(double* x, double* y) const { double dx = *x - m_xc; double dy = *y - m_yc; double r = sqrt(dx * dx + dy * dy); if(r < m_radius) { *x = m_xc + dx * m_magn; *y = m_yc + dy * m_magn; return; } double m = (r + m_radius * (m_magn - 1.0)) / r; *x = m_xc + dx * m; *y = m_yc + dy * m; } //------------------------------------------------------------------------ void trans_warp_magnifier::inverse_transform(double* x, double* y) const { trans_warp_magnifier t(*this); t.magnification(1.0 / m_magn); t.radius(m_radius * m_magn); t.transform(x, y); } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_vpgen_segmentator.cpp0000644000175000017500000000374212516137326025217 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #include #include "agg_vpgen_segmentator.h" namespace agg24 { void vpgen_segmentator::move_to(double x, double y) { m_x1 = x; m_y1 = y; m_dx = 0.0; m_dy = 0.0; m_dl = 2.0; m_ddl = 2.0; m_cmd = path_cmd_move_to; } void vpgen_segmentator::line_to(double x, double y) { m_x1 += m_dx; m_y1 += m_dy; m_dx = x - m_x1; m_dy = y - m_y1; double len = sqrt(m_dx * m_dx + m_dy * m_dy) * m_approximation_scale; if(len < 1e-30) len = 1e-30; m_ddl = 1.0 / len; m_dl = (m_cmd == path_cmd_move_to) ? 0.0 : m_ddl; if(m_cmd == path_cmd_stop) m_cmd = path_cmd_line_to; } unsigned vpgen_segmentator::vertex(double* x, double* y) { if(m_cmd == path_cmd_stop) return path_cmd_stop; unsigned cmd = m_cmd; m_cmd = path_cmd_line_to; if(m_dl >= 1.0 - m_ddl) { m_dl = 1.0; m_cmd = path_cmd_stop; *x = m_x1 + m_dx; *y = m_y1 + m_dy; return cmd; } *x = m_x1 + m_dx * m_dl; *y = m_y1 + m_dy * m_dl; m_dl += m_ddl; return cmd; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_embedded_raster_fonts.cpp0000644000175000017500000142631412516137326026017 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #include "agg_embedded_raster_fonts.h" namespace agg24 { const int8u gse4x6[] = { 6, 0, 32, 128-32, 0x00,0x00,0x07,0x00,0x0e,0x00,0x15,0x00,0x1c,0x00,0x23,0x00,0x2a,0x00,0x31,0x00,0x38,0x00, 0x3f,0x00,0x46,0x00,0x4d,0x00,0x54,0x00,0x5b,0x00,0x62,0x00,0x69,0x00,0x70,0x00,0x77,0x00, 0x7e,0x00,0x85,0x00,0x8c,0x00,0x93,0x00,0x9a,0x00,0xa1,0x00,0xa8,0x00,0xaf,0x00,0xb6,0x00, 0xbd,0x00,0xc4,0x00,0xcb,0x00,0xd2,0x00,0xd9,0x00,0xe0,0x00,0xe7,0x00,0xee,0x00,0xf5,0x00, 0xfc,0x00,0x03,0x01,0x0a,0x01,0x11,0x01,0x18,0x01,0x1f,0x01,0x26,0x01,0x2d,0x01,0x34,0x01, 0x3b,0x01,0x42,0x01,0x49,0x01,0x50,0x01,0x57,0x01,0x5e,0x01,0x65,0x01,0x6c,0x01,0x73,0x01, 0x7a,0x01,0x81,0x01,0x88,0x01,0x8f,0x01,0x96,0x01,0x9d,0x01,0xa4,0x01,0xab,0x01,0xb2,0x01, 0xb9,0x01,0xc0,0x01,0xc7,0x01,0xce,0x01,0xd5,0x01,0xdc,0x01,0xe3,0x01,0xea,0x01,0xf1,0x01, 0xf8,0x01,0xff,0x01,0x06,0x02,0x0d,0x02,0x14,0x02,0x1b,0x02,0x22,0x02,0x29,0x02,0x30,0x02, 0x37,0x02,0x3e,0x02,0x45,0x02,0x4c,0x02,0x53,0x02,0x5a,0x02,0x61,0x02,0x68,0x02,0x6f,0x02, 0x76,0x02,0x7d,0x02,0x84,0x02,0x8b,0x02,0x92,0x02,0x99,0x02, 4, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x21 '!' 0x40,0x40,0x40,0x00,0x40,0x00, 4, // 0x22 '"' 0xa0,0xa0,0x00,0x00,0x00,0x00, 4, // 0x23 '#' 0x60,0xf0,0x60,0xf0,0x60,0x00, 4, // 0x24 '$' 0x40,0x60,0xc0,0x60,0xc0,0x40, 4, // 0x25 '%' 0xa0,0x20,0x40,0x80,0xa0,0x00, 4, // 0x26 '&' 0xe0,0xa0,0x50,0xa0,0xd0,0x00, 4, // 0x27 ''' 0x40,0x40,0x00,0x00,0x00,0x00, 4, // 0x28 '(' 0x20,0x40,0x40,0x40,0x20,0x00, 4, // 0x29 ')' 0x40,0x20,0x20,0x20,0x40,0x00, 4, // 0x2a '*' 0xa0,0x40,0xe0,0x40,0xa0,0x00, 4, // 0x2b '+' 0x40,0x40,0xe0,0x40,0x40,0x00, 4, // 0x2c ',' 0x00,0x00,0x00,0x40,0x40,0x80, 4, // 0x2d '-' 0x00,0x00,0xe0,0x00,0x00,0x00, 4, // 0x2e '.' 0x00,0x00,0x00,0x00,0x40,0x00, 4, // 0x2f '/' 0x10,0x20,0x20,0x40,0x40,0x80, 4, // 0x30 '0' 0xe0,0xa0,0xa0,0xa0,0xe0,0x00, 4, // 0x31 '1' 0x40,0xc0,0x40,0x40,0xe0,0x00, 4, // 0x32 '2' 0xe0,0xa0,0x20,0x40,0xe0,0x00, 4, // 0x33 '3' 0xe0,0x20,0x40,0x20,0xe0,0x00, 4, // 0x34 '4' 0xa0,0xa0,0xe0,0x20,0x20,0x00, 4, // 0x35 '5' 0xe0,0x80,0xc0,0x20,0xc0,0x00, 4, // 0x36 '6' 0x40,0x80,0xe0,0xa0,0xe0,0x00, 4, // 0x37 '7' 0xe0,0xa0,0x20,0x40,0x40,0x00, 4, // 0x38 '8' 0xe0,0xa0,0x40,0xa0,0xe0,0x00, 4, // 0x39 '9' 0xe0,0xa0,0xe0,0x20,0xc0,0x00, 4, // 0x3a ':' 0x00,0x40,0x00,0x40,0x00,0x00, 4, // 0x3b ';' 0x00,0x40,0x00,0x40,0x40,0x80, 4, // 0x3c '<' 0x20,0x40,0x80,0x40,0x20,0x00, 4, // 0x3d '=' 0x00,0xe0,0x00,0xe0,0x00,0x00, 4, // 0x3e '>' 0x80,0x40,0x20,0x40,0x80,0x00, 4, // 0x3f '?' 0xc0,0x20,0x40,0x00,0x40,0x00, 4, // 0x40 '@' 0x40,0xa0,0xe0,0xe0,0x80,0x60, 4, // 0x41 'A' 0x40,0xa0,0xe0,0xa0,0xa0,0x00, 4, // 0x42 'B' 0xc0,0xa0,0xc0,0xa0,0xc0,0x00, 4, // 0x43 'C' 0x60,0x80,0x80,0x80,0x60,0x00, 4, // 0x44 'D' 0xc0,0xa0,0xa0,0xa0,0xc0,0x00, 4, // 0x45 'E' 0xe0,0x80,0xc0,0x80,0xe0,0x00, 4, // 0x46 'F' 0xe0,0x80,0xc0,0x80,0x80,0x00, 4, // 0x47 'G' 0x60,0x80,0xa0,0xa0,0x40,0x00, 4, // 0x48 'H' 0xa0,0xa0,0xe0,0xa0,0xa0,0x00, 4, // 0x49 'I' 0xe0,0x40,0x40,0x40,0xe0,0x00, 4, // 0x4a 'J' 0x20,0x20,0x20,0x20,0xa0,0x40, 4, // 0x4b 'K' 0xa0,0xa0,0xc0,0xc0,0xa0,0x00, 4, // 0x4c 'L' 0x80,0x80,0x80,0x80,0xe0,0x00, 4, // 0x4d 'M' 0xa0,0xe0,0xa0,0xa0,0xa0,0x00, 4, // 0x4e 'N' 0x90,0xd0,0xb0,0x90,0x90,0x00, 4, // 0x4f 'O' 0x40,0xa0,0xa0,0xa0,0x40,0x00, 4, // 0x50 'P' 0xc0,0xa0,0xa0,0xc0,0x80,0x00, 4, // 0x51 'Q' 0x40,0xa0,0xa0,0xa0,0x60,0x00, 4, // 0x52 'R' 0xc0,0xa0,0xa0,0xc0,0xa0,0x00, 4, // 0x53 'S' 0x60,0x80,0x40,0x20,0xc0,0x00, 4, // 0x54 'T' 0xe0,0x40,0x40,0x40,0x40,0x00, 4, // 0x55 'U' 0xa0,0xa0,0xa0,0xa0,0xe0,0x00, 4, // 0x56 'V' 0xa0,0xa0,0xa0,0xa0,0x40,0x00, 4, // 0x57 'W' 0xa0,0xa0,0xa0,0xe0,0xa0,0x00, 4, // 0x58 'X' 0xa0,0xa0,0x40,0xa0,0xa0,0x00, 4, // 0x59 'Y' 0xa0,0xa0,0x40,0x40,0x40,0x00, 4, // 0x5a 'Z' 0xe0,0x20,0x40,0x80,0xe0,0x00, 4, // 0x5b '[' 0xc0,0x80,0x80,0x80,0xc0,0x00, 4, // 0x5c '\' 0x80,0x40,0x40,0x20,0x20,0x10, 4, // 0x5d ']' 0xc0,0x40,0x40,0x40,0xc0,0x00, 4, // 0x5e '^' 0x40,0xa0,0x00,0x00,0x00,0x00, 4, // 0x5f '_' 0x00,0x00,0x00,0x00,0x00,0xf0, 4, // 0x60 '`' 0x40,0x20,0x00,0x00,0x00,0x00, 4, // 0x61 'a' 0x00,0x60,0xa0,0xa0,0x70,0x00, 4, // 0x62 'b' 0x80,0x80,0xc0,0xa0,0xc0,0x00, 4, // 0x63 'c' 0x00,0x60,0x80,0x80,0x60,0x00, 4, // 0x64 'd' 0x20,0x20,0x60,0xa0,0x60,0x00, 4, // 0x65 'e' 0x00,0x40,0xe0,0x80,0x60,0x00, 4, // 0x66 'f' 0x20,0x40,0xe0,0x40,0x40,0x00, 4, // 0x67 'g' 0x00,0x60,0xa0,0x60,0x20,0xc0, 4, // 0x68 'h' 0x80,0x80,0xc0,0xa0,0xa0,0x00, 4, // 0x69 'i' 0x40,0x00,0xc0,0x40,0xe0,0x00, 4, // 0x6a 'j' 0x40,0x00,0xc0,0x40,0x40,0x80, 4, // 0x6b 'k' 0x80,0x80,0xa0,0xc0,0xa0,0x00, 4, // 0x6c 'l' 0xc0,0x40,0x40,0x40,0xe0,0x00, 4, // 0x6d 'm' 0x00,0xa0,0xf0,0xf0,0x90,0x00, 4, // 0x6e 'n' 0x00,0xc0,0xa0,0xa0,0xa0,0x00, 4, // 0x6f 'o' 0x00,0x40,0xa0,0xa0,0x40,0x00, 4, // 0x70 'p' 0x00,0xc0,0xa0,0xc0,0x80,0x80, 4, // 0x71 'q' 0x00,0x60,0xa0,0x60,0x20,0x20, 4, // 0x72 'r' 0x00,0xa0,0x50,0x40,0x40,0x00, 4, // 0x73 's' 0x00,0x60,0xc0,0x20,0xc0,0x00, 4, // 0x74 't' 0x40,0x40,0xe0,0x40,0x60,0x00, 4, // 0x75 'u' 0x00,0xa0,0xa0,0xa0,0x60,0x00, 4, // 0x76 'v' 0x00,0xa0,0xa0,0xa0,0x40,0x00, 4, // 0x77 'w' 0x00,0xa0,0xa0,0xe0,0xa0,0x00, 4, // 0x78 'x' 0x00,0xa0,0x40,0xa0,0xa0,0x00, 4, // 0x79 'y' 0x00,0xa0,0xa0,0x60,0x20,0xc0, 4, // 0x7a 'z' 0x00,0xe0,0x40,0x80,0xe0,0x00, 4, // 0x7b '{' 0x30,0x20,0xc0,0x20,0x30,0x00, 4, // 0x7c '|' 0x40,0x40,0x00,0x40,0x40,0x40, 4, // 0x7d '}' 0xc0,0x40,0x30,0x40,0xc0,0x00, 4, // 0x7e '~' 0x50,0xa0,0x00,0x00,0x00,0x00, 4, // 0x7f '' 0x00,0x60,0x90,0xf0,0x00,0x00, 0 }; const int8u gse4x8[] = { 8, 0, 32, 128-32, 0x00,0x00,0x09,0x00,0x12,0x00,0x1b,0x00,0x24,0x00,0x2d,0x00,0x36,0x00,0x3f,0x00,0x48,0x00, 0x51,0x00,0x5a,0x00,0x63,0x00,0x6c,0x00,0x75,0x00,0x7e,0x00,0x87,0x00,0x90,0x00,0x99,0x00, 0xa2,0x00,0xab,0x00,0xb4,0x00,0xbd,0x00,0xc6,0x00,0xcf,0x00,0xd8,0x00,0xe1,0x00,0xea,0x00, 0xf3,0x00,0xfc,0x00,0x05,0x01,0x0e,0x01,0x17,0x01,0x20,0x01,0x29,0x01,0x32,0x01,0x3b,0x01, 0x44,0x01,0x4d,0x01,0x56,0x01,0x5f,0x01,0x68,0x01,0x71,0x01,0x7a,0x01,0x83,0x01,0x8c,0x01, 0x95,0x01,0x9e,0x01,0xa7,0x01,0xb0,0x01,0xb9,0x01,0xc2,0x01,0xcb,0x01,0xd4,0x01,0xdd,0x01, 0xe6,0x01,0xef,0x01,0xf8,0x01,0x01,0x02,0x0a,0x02,0x13,0x02,0x1c,0x02,0x25,0x02,0x2e,0x02, 0x37,0x02,0x40,0x02,0x49,0x02,0x52,0x02,0x5b,0x02,0x64,0x02,0x6d,0x02,0x76,0x02,0x7f,0x02, 0x88,0x02,0x91,0x02,0x9a,0x02,0xa3,0x02,0xac,0x02,0xb5,0x02,0xbe,0x02,0xc7,0x02,0xd0,0x02, 0xd9,0x02,0xe2,0x02,0xeb,0x02,0xf4,0x02,0xfd,0x02,0x06,0x03,0x0f,0x03,0x18,0x03,0x21,0x03, 0x2a,0x03,0x33,0x03,0x3c,0x03,0x45,0x03,0x4e,0x03,0x57,0x03, 4, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x21 '!' 0x00,0x40,0x40,0x40,0x40,0x00,0x40,0x00, 4, // 0x22 '"' 0x00,0xa0,0xa0,0x00,0x00,0x00,0x00,0x00, 4, // 0x23 '#' 0x60,0x60,0xf0,0x60,0x60,0xf0,0x60,0x60, 4, // 0x24 '$' 0x40,0x60,0xc0,0xc0,0x60,0x60,0xc0,0x40, 4, // 0x25 '%' 0x00,0xa0,0x20,0x40,0x40,0x80,0xa0,0x00, 4, // 0x26 '&' 0x00,0x40,0xa0,0xa0,0x40,0xb0,0xa0,0x70, 4, // 0x27 ''' 0x00,0x40,0x40,0x00,0x00,0x00,0x00,0x00, 4, // 0x28 '(' 0x20,0x40,0x80,0x80,0x80,0x80,0x40,0x20, 4, // 0x29 ')' 0x80,0x40,0x20,0x20,0x20,0x20,0x40,0x80, 4, // 0x2a '*' 0x00,0xa0,0x40,0xe0,0x40,0xa0,0x00,0x00, 4, // 0x2b '+' 0x00,0x40,0x40,0xe0,0x40,0x40,0x00,0x00, 4, // 0x2c ',' 0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x80, 4, // 0x2d '-' 0x00,0x00,0x00,0xe0,0x00,0x00,0x00,0x00, 4, // 0x2e '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00, 4, // 0x2f '/' 0x10,0x10,0x20,0x20,0x40,0x40,0x80,0x80, 4, // 0x30 '0' 0x00,0xe0,0xa0,0xa0,0xa0,0xa0,0xe0,0x00, 4, // 0x31 '1' 0x00,0x40,0xc0,0x40,0x40,0x40,0xe0,0x00, 4, // 0x32 '2' 0x00,0xe0,0xa0,0x20,0x40,0x80,0xe0,0x00, 4, // 0x33 '3' 0x00,0xe0,0x20,0x40,0x20,0x20,0xe0,0x00, 4, // 0x34 '4' 0x00,0x60,0xa0,0xa0,0xf0,0x20,0x20,0x00, 4, // 0x35 '5' 0x00,0xe0,0x80,0xc0,0x20,0x20,0xc0,0x00, 4, // 0x36 '6' 0x00,0x40,0x80,0xe0,0xa0,0xa0,0xe0,0x00, 4, // 0x37 '7' 0x00,0xe0,0xa0,0x20,0x40,0x40,0x40,0x00, 4, // 0x38 '8' 0x00,0xe0,0xa0,0x40,0xa0,0xa0,0xe0,0x00, 4, // 0x39 '9' 0x00,0xe0,0xa0,0xe0,0x20,0x20,0x40,0x00, 4, // 0x3a ':' 0x00,0x00,0x40,0x00,0x00,0x40,0x00,0x00, 4, // 0x3b ';' 0x00,0x00,0x40,0x00,0x00,0x40,0x40,0x80, 4, // 0x3c '<' 0x00,0x20,0x40,0x80,0x40,0x20,0x00,0x00, 4, // 0x3d '=' 0x00,0x00,0xe0,0x00,0xe0,0x00,0x00,0x00, 4, // 0x3e '>' 0x00,0x80,0x40,0x20,0x40,0x80,0x00,0x00, 4, // 0x3f '?' 0x00,0x40,0xa0,0x20,0x40,0x00,0x40,0x00, 4, // 0x40 '@' 0x00,0x40,0xa0,0xe0,0xe0,0x80,0x60,0x00, 4, // 0x41 'A' 0x00,0x40,0xa0,0xa0,0xe0,0xa0,0xa0,0x00, 4, // 0x42 'B' 0x00,0xc0,0xa0,0xc0,0xa0,0xa0,0xc0,0x00, 4, // 0x43 'C' 0x00,0x40,0xa0,0x80,0x80,0xa0,0x40,0x00, 4, // 0x44 'D' 0x00,0xc0,0xa0,0xa0,0xa0,0xa0,0xc0,0x00, 4, // 0x45 'E' 0x00,0xe0,0x80,0xc0,0x80,0x80,0xe0,0x00, 4, // 0x46 'F' 0x00,0xe0,0x80,0xc0,0x80,0x80,0x80,0x00, 4, // 0x47 'G' 0x00,0x60,0x80,0xa0,0xa0,0xa0,0x40,0x00, 4, // 0x48 'H' 0x00,0xa0,0xa0,0xe0,0xa0,0xa0,0xa0,0x00, 4, // 0x49 'I' 0x00,0xe0,0x40,0x40,0x40,0x40,0xe0,0x00, 4, // 0x4a 'J' 0x00,0x20,0x20,0x20,0x20,0xa0,0x40,0x00, 4, // 0x4b 'K' 0x00,0xa0,0xa0,0xc0,0xc0,0xa0,0xa0,0x00, 4, // 0x4c 'L' 0x00,0x80,0x80,0x80,0x80,0x80,0xe0,0x00, 4, // 0x4d 'M' 0x00,0xa0,0xe0,0xa0,0xa0,0xa0,0xa0,0x00, 4, // 0x4e 'N' 0x00,0x90,0x90,0xd0,0xb0,0x90,0x90,0x00, 4, // 0x4f 'O' 0x00,0x40,0xa0,0xa0,0xa0,0xa0,0x40,0x00, 4, // 0x50 'P' 0x00,0xc0,0xa0,0xa0,0xc0,0x80,0x80,0x00, 4, // 0x51 'Q' 0x00,0x40,0xa0,0xa0,0xa0,0xa0,0x60,0x00, 4, // 0x52 'R' 0x00,0xc0,0xa0,0xa0,0xc0,0xc0,0xa0,0x00, 4, // 0x53 'S' 0x00,0x60,0x80,0x40,0x20,0x20,0xc0,0x00, 4, // 0x54 'T' 0x00,0xe0,0x40,0x40,0x40,0x40,0x40,0x00, 4, // 0x55 'U' 0x00,0xa0,0xa0,0xa0,0xa0,0xa0,0x40,0x00, 4, // 0x56 'V' 0x00,0xa0,0xa0,0xa0,0xa0,0x40,0x40,0x00, 4, // 0x57 'W' 0x00,0xa0,0xa0,0xa0,0xa0,0xe0,0xa0,0x00, 4, // 0x58 'X' 0x00,0xa0,0xa0,0x40,0xa0,0xa0,0xa0,0x00, 4, // 0x59 'Y' 0x00,0xa0,0xa0,0x40,0x40,0x40,0x40,0x00, 4, // 0x5a 'Z' 0x00,0xe0,0x20,0x40,0x40,0x80,0xe0,0x00, 4, // 0x5b '[' 0xc0,0x80,0x80,0x80,0x80,0x80,0x80,0xc0, 4, // 0x5c '\' 0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10, 4, // 0x5d ']' 0xc0,0x40,0x40,0x40,0x40,0x40,0x40,0xc0, 4, // 0x5e '^' 0x00,0x40,0xa0,0x00,0x00,0x00,0x00,0x00, 4, // 0x5f '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0, 4, // 0x60 '`' 0x00,0x40,0x20,0x00,0x00,0x00,0x00,0x00, 4, // 0x61 'a' 0x00,0x00,0x60,0xa0,0xa0,0xa0,0x70,0x00, 4, // 0x62 'b' 0x00,0x80,0x80,0xc0,0xa0,0xa0,0xc0,0x00, 4, // 0x63 'c' 0x00,0x00,0x40,0xa0,0x80,0xa0,0x40,0x00, 4, // 0x64 'd' 0x00,0x20,0x20,0x60,0xa0,0xa0,0x60,0x00, 4, // 0x65 'e' 0x00,0x00,0x40,0xa0,0xe0,0x80,0x60,0x00, 4, // 0x66 'f' 0x00,0x20,0x40,0x40,0xe0,0x40,0x40,0x00, 4, // 0x67 'g' 0x00,0x00,0x60,0xa0,0xa0,0x60,0x20,0xc0, 4, // 0x68 'h' 0x00,0x80,0x80,0xc0,0xa0,0xa0,0xa0,0x00, 4, // 0x69 'i' 0x00,0x40,0x00,0xc0,0x40,0x40,0xe0,0x00, 4, // 0x6a 'j' 0x00,0x40,0x00,0xc0,0x40,0x40,0x40,0x80, 4, // 0x6b 'k' 0x00,0x80,0x80,0xa0,0xc0,0xc0,0xa0,0x00, 4, // 0x6c 'l' 0x00,0xc0,0x40,0x40,0x40,0x40,0xe0,0x00, 4, // 0x6d 'm' 0x00,0x00,0xa0,0xf0,0xf0,0xf0,0x90,0x00, 4, // 0x6e 'n' 0x00,0x00,0xc0,0xa0,0xa0,0xa0,0xa0,0x00, 4, // 0x6f 'o' 0x00,0x00,0x40,0xa0,0xa0,0xa0,0x40,0x00, 4, // 0x70 'p' 0x00,0x00,0xc0,0xa0,0xa0,0xc0,0x80,0x80, 4, // 0x71 'q' 0x00,0x00,0x60,0xa0,0xa0,0x60,0x20,0x20, 4, // 0x72 'r' 0x00,0x00,0xa0,0x50,0x40,0x40,0x40,0x00, 4, // 0x73 's' 0x00,0x00,0x60,0x80,0x40,0x20,0xc0,0x00, 4, // 0x74 't' 0x00,0x40,0x40,0xe0,0x40,0x40,0x20,0x00, 4, // 0x75 'u' 0x00,0x00,0xa0,0xa0,0xa0,0xa0,0x60,0x00, 4, // 0x76 'v' 0x00,0x00,0xa0,0xa0,0xa0,0x40,0x40,0x00, 4, // 0x77 'w' 0x00,0x00,0xa0,0xa0,0xa0,0xe0,0xa0,0x00, 4, // 0x78 'x' 0x00,0x00,0xa0,0xa0,0x40,0xa0,0xa0,0x00, 4, // 0x79 'y' 0x00,0x00,0xa0,0xa0,0xa0,0x60,0x20,0xc0, 4, // 0x7a 'z' 0x00,0x00,0xe0,0x20,0x40,0x80,0xe0,0x00, 4, // 0x7b '{' 0x10,0x20,0x20,0xc0,0x20,0x20,0x10,0x00, 4, // 0x7c '|' 0x00,0x40,0x40,0x40,0x00,0x40,0x40,0x40, 4, // 0x7d '}' 0x80,0x40,0x40,0x30,0x40,0x40,0x80,0x00, 4, // 0x7e '~' 0x00,0x50,0xa0,0x00,0x00,0x00,0x00,0x00, 4, // 0x7f '' 0x00,0x00,0x00,0x60,0x90,0xf0,0x00,0x00, 0 }; const int8u gse5x7[] = { 7, 0, 32, 128-32, 0x00,0x00,0x08,0x00,0x10,0x00,0x18,0x00,0x20,0x00,0x28,0x00,0x30,0x00,0x38,0x00,0x40,0x00, 0x48,0x00,0x50,0x00,0x58,0x00,0x60,0x00,0x68,0x00,0x70,0x00,0x78,0x00,0x80,0x00,0x88,0x00, 0x90,0x00,0x98,0x00,0xa0,0x00,0xa8,0x00,0xb0,0x00,0xb8,0x00,0xc0,0x00,0xc8,0x00,0xd0,0x00, 0xd8,0x00,0xe0,0x00,0xe8,0x00,0xf0,0x00,0xf8,0x00,0x00,0x01,0x08,0x01,0x10,0x01,0x18,0x01, 0x20,0x01,0x28,0x01,0x30,0x01,0x38,0x01,0x40,0x01,0x48,0x01,0x50,0x01,0x58,0x01,0x60,0x01, 0x68,0x01,0x70,0x01,0x78,0x01,0x80,0x01,0x88,0x01,0x90,0x01,0x98,0x01,0xa0,0x01,0xa8,0x01, 0xb0,0x01,0xb8,0x01,0xc0,0x01,0xc8,0x01,0xd0,0x01,0xd8,0x01,0xe0,0x01,0xe8,0x01,0xf0,0x01, 0xf8,0x01,0x00,0x02,0x08,0x02,0x10,0x02,0x18,0x02,0x20,0x02,0x28,0x02,0x30,0x02,0x38,0x02, 0x40,0x02,0x48,0x02,0x50,0x02,0x58,0x02,0x60,0x02,0x68,0x02,0x70,0x02,0x78,0x02,0x80,0x02, 0x88,0x02,0x90,0x02,0x98,0x02,0xa0,0x02,0xa8,0x02,0xb0,0x02,0xb8,0x02,0xc0,0x02,0xc8,0x02, 0xd0,0x02,0xd8,0x02,0xe0,0x02,0xe8,0x02,0xf0,0x02,0xf8,0x02, 5, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x21 '!' 0x00,0x20,0x20,0x20,0x00,0x20,0x00, 5, // 0x22 '"' 0x00,0x50,0x50,0x00,0x00,0x00,0x00, 5, // 0x23 '#' 0x00,0x50,0xf8,0x50,0xf8,0x50,0x00, 5, // 0x24 '$' 0x20,0x78,0xa0,0x70,0x28,0xf0,0x20, 5, // 0x25 '%' 0x00,0x88,0x10,0x20,0x40,0x88,0x00, 5, // 0x26 '&' 0x00,0x40,0xa0,0x68,0x90,0x68,0x00, 5, // 0x27 ''' 0x00,0x20,0x20,0x00,0x00,0x00,0x00, 5, // 0x28 '(' 0x10,0x20,0x40,0x40,0x40,0x20,0x10, 5, // 0x29 ')' 0x80,0x40,0x20,0x20,0x20,0x40,0x80, 5, // 0x2a '*' 0x00,0x20,0xa8,0x70,0xa8,0x20,0x00, 5, // 0x2b '+' 0x00,0x20,0x20,0xf8,0x20,0x20,0x00, 5, // 0x2c ',' 0x00,0x00,0x00,0x00,0x20,0x20,0x40, 5, // 0x2d '-' 0x00,0x00,0x00,0xf0,0x00,0x00,0x00, 5, // 0x2e '.' 0x00,0x00,0x00,0x00,0x00,0x40,0x00, 5, // 0x2f '/' 0x00,0x08,0x10,0x20,0x40,0x80,0x00, 5, // 0x30 '0' 0x00,0x60,0x90,0x90,0x90,0x60,0x00, 5, // 0x31 '1' 0x00,0x20,0x60,0x20,0x20,0x70,0x00, 5, // 0x32 '2' 0x00,0x60,0x90,0x20,0x40,0xf0,0x00, 5, // 0x33 '3' 0x00,0xf0,0x20,0x60,0x10,0xe0,0x00, 5, // 0x34 '4' 0x00,0x30,0x50,0x90,0xf0,0x10,0x00, 5, // 0x35 '5' 0x00,0xf0,0x80,0xe0,0x10,0xe0,0x00, 5, // 0x36 '6' 0x00,0x60,0x80,0xe0,0x90,0x60,0x00, 5, // 0x37 '7' 0x00,0xf0,0x90,0x20,0x40,0x40,0x00, 5, // 0x38 '8' 0x00,0x60,0x90,0x60,0x90,0x60,0x00, 5, // 0x39 '9' 0x00,0x60,0x90,0x70,0x10,0x60,0x00, 5, // 0x3a ':' 0x00,0x00,0x20,0x00,0x20,0x00,0x00, 5, // 0x3b ';' 0x00,0x00,0x20,0x00,0x20,0x20,0x40, 5, // 0x3c '<' 0x00,0x10,0x20,0x40,0x20,0x10,0x00, 5, // 0x3d '=' 0x00,0x00,0xf0,0x00,0xf0,0x00,0x00, 5, // 0x3e '>' 0x00,0x80,0x40,0x20,0x40,0x80,0x00, 5, // 0x3f '?' 0x00,0x60,0x90,0x20,0x00,0x20,0x00, 5, // 0x40 '@' 0x00,0x60,0x90,0xb0,0x80,0x70,0x00, 5, // 0x41 'A' 0x00,0x60,0x90,0xf0,0x90,0x90,0x00, 5, // 0x42 'B' 0x00,0xe0,0x90,0xe0,0x90,0xe0,0x00, 5, // 0x43 'C' 0x00,0x60,0x90,0x80,0x90,0x60,0x00, 5, // 0x44 'D' 0x00,0xe0,0x90,0x90,0x90,0xe0,0x00, 5, // 0x45 'E' 0x00,0xf0,0x80,0xe0,0x80,0xf0,0x00, 5, // 0x46 'F' 0x00,0xf0,0x80,0xe0,0x80,0x80,0x00, 5, // 0x47 'G' 0x00,0x70,0x80,0xb0,0x90,0x60,0x00, 5, // 0x48 'H' 0x00,0x90,0x90,0xf0,0x90,0x90,0x00, 5, // 0x49 'I' 0x00,0x70,0x20,0x20,0x20,0x70,0x00, 5, // 0x4a 'J' 0x00,0x70,0x20,0x20,0xa0,0x40,0x00, 5, // 0x4b 'K' 0x00,0x90,0xa0,0xc0,0xa0,0x90,0x00, 5, // 0x4c 'L' 0x00,0x80,0x80,0x80,0x80,0xf0,0x00, 5, // 0x4d 'M' 0x00,0x90,0xf0,0x90,0x90,0x90,0x00, 5, // 0x4e 'N' 0x00,0x90,0xd0,0xb0,0x90,0x90,0x00, 5, // 0x4f 'O' 0x00,0x60,0x90,0x90,0x90,0x60,0x00, 5, // 0x50 'P' 0x00,0xe0,0x90,0xe0,0x80,0x80,0x00, 5, // 0x51 'Q' 0x00,0x60,0x90,0x90,0xa0,0x50,0x00, 5, // 0x52 'R' 0x00,0xe0,0x90,0xe0,0xa0,0x90,0x00, 5, // 0x53 'S' 0x00,0x70,0x80,0x60,0x10,0xe0,0x00, 5, // 0x54 'T' 0x00,0x70,0x20,0x20,0x20,0x20,0x00, 5, // 0x55 'U' 0x00,0x90,0x90,0x90,0x90,0x60,0x00, 5, // 0x56 'V' 0x00,0x50,0x50,0x50,0x20,0x20,0x00, 5, // 0x57 'W' 0x00,0x90,0x90,0x90,0xf0,0x90,0x00, 5, // 0x58 'X' 0x00,0x90,0x90,0x60,0x90,0x90,0x00, 5, // 0x59 'Y' 0x00,0x50,0x50,0x20,0x20,0x20,0x00, 5, // 0x5a 'Z' 0x00,0xf0,0x10,0x20,0x40,0xf0,0x00, 5, // 0x5b '[' 0x70,0x40,0x40,0x40,0x40,0x40,0x70, 5, // 0x5c '\' 0x00,0x80,0x40,0x20,0x10,0x08,0x00, 5, // 0x5d ']' 0xe0,0x20,0x20,0x20,0x20,0x20,0xe0, 5, // 0x5e '^' 0x00,0x20,0x50,0x00,0x00,0x00,0x00, 5, // 0x5f '_' 0x00,0x00,0x00,0x00,0x00,0xf8,0x00, 5, // 0x60 '`' 0x00,0x40,0x20,0x00,0x00,0x00,0x00, 5, // 0x61 'a' 0x00,0x00,0x60,0xa0,0xa0,0x50,0x00, 5, // 0x62 'b' 0x00,0x80,0x80,0xe0,0x90,0xe0,0x00, 5, // 0x63 'c' 0x00,0x00,0x70,0x80,0x80,0x70,0x00, 5, // 0x64 'd' 0x00,0x10,0x10,0x70,0x90,0x70,0x00, 5, // 0x65 'e' 0x00,0x00,0x60,0xf0,0x80,0x70,0x00, 5, // 0x66 'f' 0x00,0x30,0x40,0xe0,0x40,0x40,0x00, 5, // 0x67 'g' 0x00,0x00,0x70,0x90,0x70,0x10,0x60, 5, // 0x68 'h' 0x00,0x80,0x80,0xe0,0x90,0x90,0x00, 5, // 0x69 'i' 0x20,0x00,0x60,0x20,0x20,0x70,0x00, 5, // 0x6a 'j' 0x20,0x00,0x60,0x20,0x20,0xa0,0x40, 5, // 0x6b 'k' 0x80,0x80,0x90,0xa0,0xe0,0x90,0x00, 5, // 0x6c 'l' 0x00,0x60,0x20,0x20,0x20,0x70,0x00, 5, // 0x6d 'm' 0x00,0x00,0xa0,0xf0,0xf0,0x90,0x00, 5, // 0x6e 'n' 0x00,0x00,0xa0,0xd0,0x90,0x90,0x00, 5, // 0x6f 'o' 0x00,0x00,0x60,0x90,0x90,0x60,0x00, 5, // 0x70 'p' 0x00,0x00,0xe0,0x90,0xe0,0x80,0x80, 5, // 0x71 'q' 0x00,0x00,0x70,0x90,0x70,0x10,0x10, 5, // 0x72 'r' 0x00,0x00,0xe0,0x90,0x80,0x80,0x00, 5, // 0x73 's' 0x00,0x00,0x70,0xe0,0x10,0xe0,0x00, 5, // 0x74 't' 0x40,0x40,0xe0,0x40,0x40,0x70,0x00, 5, // 0x75 'u' 0x00,0x00,0x90,0x90,0x90,0x70,0x00, 5, // 0x76 'v' 0x00,0x00,0x50,0x50,0x50,0x20,0x00, 5, // 0x77 'w' 0x00,0x00,0x90,0x90,0xf0,0x90,0x00, 5, // 0x78 'x' 0x00,0x00,0x90,0x60,0x60,0x90,0x00, 5, // 0x79 'y' 0x00,0x00,0x90,0x90,0x70,0x10,0x60, 5, // 0x7a 'z' 0x00,0x00,0xf0,0x20,0x40,0xf0,0x00, 5, // 0x7b '{' 0x10,0x20,0x20,0xc0,0x20,0x20,0x10, 5, // 0x7c '|' 0x20,0x20,0x20,0x00,0x20,0x20,0x20, 5, // 0x7d '}' 0x40,0x20,0x20,0x18,0x20,0x20,0x40, 5, // 0x7e '~' 0x00,0x40,0xa8,0x10,0x00,0x00,0x00, 5, // 0x7f '' 0x00,0x00,0x20,0x50,0x88,0xf8,0x00, 0 }; const int8u gse5x9[] = { 9, 0, 32, 128-32, 0x00,0x00,0x0a,0x00,0x14,0x00,0x1e,0x00,0x28,0x00,0x32,0x00,0x3c,0x00,0x46,0x00,0x50,0x00, 0x5a,0x00,0x64,0x00,0x6e,0x00,0x78,0x00,0x82,0x00,0x8c,0x00,0x96,0x00,0xa0,0x00,0xaa,0x00, 0xb4,0x00,0xbe,0x00,0xc8,0x00,0xd2,0x00,0xdc,0x00,0xe6,0x00,0xf0,0x00,0xfa,0x00,0x04,0x01, 0x0e,0x01,0x18,0x01,0x22,0x01,0x2c,0x01,0x36,0x01,0x40,0x01,0x4a,0x01,0x54,0x01,0x5e,0x01, 0x68,0x01,0x72,0x01,0x7c,0x01,0x86,0x01,0x90,0x01,0x9a,0x01,0xa4,0x01,0xae,0x01,0xb8,0x01, 0xc2,0x01,0xcc,0x01,0xd6,0x01,0xe0,0x01,0xea,0x01,0xf4,0x01,0xfe,0x01,0x08,0x02,0x12,0x02, 0x1c,0x02,0x26,0x02,0x30,0x02,0x3a,0x02,0x44,0x02,0x4e,0x02,0x58,0x02,0x62,0x02,0x6c,0x02, 0x76,0x02,0x80,0x02,0x8a,0x02,0x94,0x02,0x9e,0x02,0xa8,0x02,0xb2,0x02,0xbc,0x02,0xc6,0x02, 0xd0,0x02,0xda,0x02,0xe4,0x02,0xee,0x02,0xf8,0x02,0x02,0x03,0x0c,0x03,0x16,0x03,0x20,0x03, 0x2a,0x03,0x34,0x03,0x3e,0x03,0x48,0x03,0x52,0x03,0x5c,0x03,0x66,0x03,0x70,0x03,0x7a,0x03, 0x84,0x03,0x8e,0x03,0x98,0x03,0xa2,0x03,0xac,0x03,0xb6,0x03, 5, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x21 '!' 0x00,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00, 5, // 0x22 '"' 0x00,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x23 '#' 0x00,0x50,0x50,0xf8,0x50,0xf8,0x50,0x50,0x00, 5, // 0x24 '$' 0x00,0x20,0x78,0xa0,0x70,0x28,0xf0,0x20,0x00, 5, // 0x25 '%' 0x00,0xc8,0xc8,0x10,0x20,0x40,0x98,0x98,0x00, 5, // 0x26 '&' 0x00,0x40,0xa0,0xa0,0x40,0xa8,0x90,0x68,0x00, 5, // 0x27 ''' 0x00,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x28 '(' 0x10,0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x10, 5, // 0x29 ')' 0x80,0x40,0x20,0x20,0x20,0x20,0x20,0x40,0x80, 5, // 0x2a '*' 0x00,0x00,0x20,0xa8,0x70,0xa8,0x20,0x00,0x00, 5, // 0x2b '+' 0x00,0x00,0x20,0x20,0xf8,0x20,0x20,0x00,0x00, 5, // 0x2c ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x40, 5, // 0x2d '-' 0x00,0x00,0x00,0x00,0xf0,0x00,0x00,0x00,0x00, 5, // 0x2e '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00, 5, // 0x2f '/' 0x00,0x10,0x10,0x20,0x20,0x40,0x40,0x80,0x80, 5, // 0x30 '0' 0x00,0x60,0x90,0xb0,0xd0,0x90,0x90,0x60,0x00, 5, // 0x31 '1' 0x00,0x20,0x60,0x20,0x20,0x20,0x20,0x70,0x00, 5, // 0x32 '2' 0x00,0x60,0x90,0x10,0x20,0x40,0x80,0xf0,0x00, 5, // 0x33 '3' 0x00,0xf0,0x10,0x20,0x60,0x10,0x90,0x60,0x00, 5, // 0x34 '4' 0x00,0x30,0x50,0x90,0x90,0xf8,0x10,0x10,0x00, 5, // 0x35 '5' 0x00,0xf0,0x80,0xe0,0x10,0x10,0x10,0xe0,0x00, 5, // 0x36 '6' 0x00,0x60,0x80,0xe0,0x90,0x90,0x90,0x60,0x00, 5, // 0x37 '7' 0x00,0xf0,0x90,0x10,0x20,0x40,0x40,0x40,0x00, 5, // 0x38 '8' 0x00,0x60,0x90,0x90,0x60,0x90,0x90,0x60,0x00, 5, // 0x39 '9' 0x00,0x60,0x90,0x90,0x70,0x10,0x90,0x60,0x00, 5, // 0x3a ':' 0x00,0x00,0x00,0x20,0x00,0x00,0x20,0x00,0x00, 5, // 0x3b ';' 0x00,0x00,0x00,0x20,0x00,0x00,0x20,0x20,0x40, 5, // 0x3c '<' 0x00,0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x00, 5, // 0x3d '=' 0x00,0x00,0x00,0xf0,0x00,0xf0,0x00,0x00,0x00, 5, // 0x3e '>' 0x00,0x80,0x40,0x20,0x10,0x20,0x40,0x80,0x00, 5, // 0x3f '?' 0x00,0x60,0x90,0x10,0x20,0x20,0x00,0x20,0x00, 5, // 0x40 '@' 0x00,0x60,0x90,0xb0,0xb0,0xb0,0x80,0x70,0x00, 5, // 0x41 'A' 0x00,0x60,0x90,0x90,0xf0,0x90,0x90,0x90,0x00, 5, // 0x42 'B' 0x00,0xe0,0x90,0x90,0xe0,0x90,0x90,0xe0,0x00, 5, // 0x43 'C' 0x00,0x60,0x90,0x80,0x80,0x80,0x90,0x60,0x00, 5, // 0x44 'D' 0x00,0xe0,0x90,0x90,0x90,0x90,0x90,0xe0,0x00, 5, // 0x45 'E' 0x00,0xf0,0x80,0x80,0xe0,0x80,0x80,0xf0,0x00, 5, // 0x46 'F' 0x00,0xf0,0x80,0x80,0xe0,0x80,0x80,0x80,0x00, 5, // 0x47 'G' 0x00,0x60,0x90,0x80,0xb0,0x90,0x90,0x60,0x00, 5, // 0x48 'H' 0x00,0x90,0x90,0x90,0xf0,0x90,0x90,0x90,0x00, 5, // 0x49 'I' 0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x70,0x00, 5, // 0x4a 'J' 0x00,0x70,0x20,0x20,0x20,0x20,0xa0,0x40,0x00, 5, // 0x4b 'K' 0x00,0x90,0x90,0xa0,0xc0,0xa0,0x90,0x90,0x00, 5, // 0x4c 'L' 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0xf0,0x00, 5, // 0x4d 'M' 0x00,0x90,0xf0,0x90,0x90,0x90,0x90,0x90,0x00, 5, // 0x4e 'N' 0x00,0x90,0x90,0xd0,0xb0,0x90,0x90,0x90,0x00, 5, // 0x4f 'O' 0x00,0x60,0x90,0x90,0x90,0x90,0x90,0x60,0x00, 5, // 0x50 'P' 0x00,0xe0,0x90,0x90,0xe0,0x80,0x80,0x80,0x00, 5, // 0x51 'Q' 0x00,0x60,0x90,0x90,0x90,0x90,0xa0,0x50,0x00, 5, // 0x52 'R' 0x00,0xe0,0x90,0x90,0xe0,0xa0,0x90,0x90,0x00, 5, // 0x53 'S' 0x00,0x60,0x90,0x80,0x60,0x10,0x90,0x60,0x00, 5, // 0x54 'T' 0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x00, 5, // 0x55 'U' 0x00,0x90,0x90,0x90,0x90,0x90,0x90,0x60,0x00, 5, // 0x56 'V' 0x00,0x50,0x50,0x50,0x50,0x50,0x20,0x20,0x00, 5, // 0x57 'W' 0x00,0x90,0x90,0x90,0x90,0x90,0xf0,0x90,0x00, 5, // 0x58 'X' 0x00,0x90,0x90,0x60,0x60,0x90,0x90,0x90,0x00, 5, // 0x59 'Y' 0x00,0x50,0x50,0x50,0x20,0x20,0x20,0x20,0x00, 5, // 0x5a 'Z' 0x00,0xf0,0x10,0x10,0x20,0x40,0x80,0xf0,0x00, 5, // 0x5b '[' 0x70,0x40,0x40,0x40,0x40,0x40,0x40,0x70,0x00, 5, // 0x5c '\' 0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x00, 5, // 0x5d ']' 0xe0,0x20,0x20,0x20,0x20,0x20,0x20,0xe0,0x00, 5, // 0x5e '^' 0x00,0x20,0x50,0x88,0x00,0x00,0x00,0x00,0x00, 5, // 0x5f '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x00, 5, // 0x60 '`' 0x00,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x61 'a' 0x00,0x00,0x60,0x10,0x70,0x90,0x90,0x70,0x00, 5, // 0x62 'b' 0x00,0x80,0x80,0xe0,0x90,0x90,0x90,0xe0,0x00, 5, // 0x63 'c' 0x00,0x00,0x60,0x90,0x80,0x80,0x90,0x60,0x00, 5, // 0x64 'd' 0x00,0x10,0x10,0x70,0x90,0x90,0x90,0x70,0x00, 5, // 0x65 'e' 0x00,0x00,0x60,0x90,0xf0,0x80,0x80,0x70,0x00, 5, // 0x66 'f' 0x00,0x30,0x40,0x40,0xe0,0x40,0x40,0x40,0x00, 5, // 0x67 'g' 0x00,0x00,0x70,0x90,0x90,0x70,0x10,0x90,0x60, 5, // 0x68 'h' 0x00,0x80,0x80,0xe0,0x90,0x90,0x90,0x90,0x00, 5, // 0x69 'i' 0x00,0x20,0x00,0x60,0x20,0x20,0x20,0x70,0x00, 5, // 0x6a 'j' 0x00,0x20,0x00,0x60,0x20,0x20,0x20,0xa0,0x40, 5, // 0x6b 'k' 0x00,0x80,0x80,0x90,0xa0,0xc0,0xa0,0x90,0x00, 5, // 0x6c 'l' 0x00,0x60,0x20,0x20,0x20,0x20,0x20,0x70,0x00, 5, // 0x6d 'm' 0x00,0x00,0xa0,0xf0,0xf0,0xf0,0x90,0x90,0x00, 5, // 0x6e 'n' 0x00,0x00,0xa0,0xd0,0x90,0x90,0x90,0x90,0x00, 5, // 0x6f 'o' 0x00,0x00,0x60,0x90,0x90,0x90,0x90,0x60,0x00, 5, // 0x70 'p' 0x00,0x00,0xe0,0x90,0x90,0x90,0xe0,0x80,0x80, 5, // 0x71 'q' 0x00,0x00,0x70,0x90,0x90,0x90,0x70,0x10,0x10, 5, // 0x72 'r' 0x00,0x00,0xe0,0x90,0x80,0x80,0x80,0x80,0x00, 5, // 0x73 's' 0x00,0x00,0x60,0x90,0x40,0x20,0x90,0x60,0x00, 5, // 0x74 't' 0x00,0x40,0x40,0xe0,0x40,0x40,0x50,0x20,0x00, 5, // 0x75 'u' 0x00,0x00,0x90,0x90,0x90,0x90,0x90,0x70,0x00, 5, // 0x76 'v' 0x00,0x00,0x50,0x50,0x50,0x50,0x20,0x20,0x00, 5, // 0x77 'w' 0x00,0x00,0x90,0x90,0x90,0x90,0xf0,0x90,0x00, 5, // 0x78 'x' 0x00,0x00,0x90,0x90,0x60,0x60,0x90,0x90,0x00, 5, // 0x79 'y' 0x00,0x00,0x90,0x90,0x90,0x90,0x70,0x10,0xe0, 5, // 0x7a 'z' 0x00,0x00,0xf0,0x10,0x20,0x40,0x80,0xf0,0x00, 5, // 0x7b '{' 0x10,0x20,0x20,0x20,0xc0,0x20,0x20,0x20,0x10, 5, // 0x7c '|' 0x00,0x20,0x20,0x20,0x00,0x20,0x20,0x20,0x00, 5, // 0x7d '}' 0x80,0x40,0x40,0x40,0x30,0x40,0x40,0x40,0x80, 5, // 0x7e '~' 0x00,0x40,0xa8,0x10,0x00,0x00,0x00,0x00,0x00, 5, // 0x7f '' 0x00,0x00,0x00,0x20,0x50,0x88,0xf8,0x00,0x00, 0 }; const int8u gse6x12[] = { 12, 0, 32, 128-32, 0x00,0x00,0x0d,0x00,0x1a,0x00,0x27,0x00,0x34,0x00,0x41,0x00,0x4e,0x00,0x5b,0x00,0x68,0x00, 0x75,0x00,0x82,0x00,0x8f,0x00,0x9c,0x00,0xa9,0x00,0xb6,0x00,0xc3,0x00,0xd0,0x00,0xdd,0x00, 0xea,0x00,0xf7,0x00,0x04,0x01,0x11,0x01,0x1e,0x01,0x2b,0x01,0x38,0x01,0x45,0x01,0x52,0x01, 0x5f,0x01,0x6c,0x01,0x79,0x01,0x86,0x01,0x93,0x01,0xa0,0x01,0xad,0x01,0xba,0x01,0xc7,0x01, 0xd4,0x01,0xe1,0x01,0xee,0x01,0xfb,0x01,0x08,0x02,0x15,0x02,0x22,0x02,0x2f,0x02,0x3c,0x02, 0x49,0x02,0x56,0x02,0x63,0x02,0x70,0x02,0x7d,0x02,0x8a,0x02,0x97,0x02,0xa4,0x02,0xb1,0x02, 0xbe,0x02,0xcb,0x02,0xd8,0x02,0xe5,0x02,0xf2,0x02,0xff,0x02,0x0c,0x03,0x19,0x03,0x26,0x03, 0x33,0x03,0x40,0x03,0x4d,0x03,0x5a,0x03,0x67,0x03,0x74,0x03,0x81,0x03,0x8e,0x03,0x9b,0x03, 0xa8,0x03,0xb5,0x03,0xc2,0x03,0xcf,0x03,0xdc,0x03,0xe9,0x03,0xf6,0x03,0x03,0x04,0x10,0x04, 0x1d,0x04,0x2a,0x04,0x37,0x04,0x44,0x04,0x51,0x04,0x5e,0x04,0x6b,0x04,0x78,0x04,0x85,0x04, 0x92,0x04,0x9f,0x04,0xac,0x04,0xb9,0x04,0xc6,0x04,0xd3,0x04, 6, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x21 '!' 0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,0x00, 6, // 0x22 '"' 0x00,0x50,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x23 '#' 0x00,0x50,0x50,0xf8,0x50,0x50,0x50,0xf8,0x50,0x50,0x00,0x00, 6, // 0x24 '$' 0x00,0x20,0x70,0xa8,0xa0,0x70,0x28,0xa8,0x70,0x20,0x00,0x00, 6, // 0x25 '%' 0x00,0xc8,0xd8,0x10,0x30,0x20,0x60,0x40,0xd8,0x98,0x00,0x00, 6, // 0x26 '&' 0x00,0x60,0x90,0x90,0x90,0x60,0xa8,0x90,0x90,0x68,0x00,0x00, 6, // 0x27 ''' 0x00,0x20,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x28 '(' 0x00,0x10,0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x10,0x00,0x00, 6, // 0x29 ')' 0x00,0x40,0x20,0x10,0x10,0x10,0x10,0x10,0x20,0x40,0x00,0x00, 6, // 0x2a '*' 0x00,0x00,0x00,0x50,0x20,0xf8,0x20,0x50,0x00,0x00,0x00,0x00, 6, // 0x2b '+' 0x00,0x00,0x20,0x20,0x20,0xf8,0x20,0x20,0x20,0x00,0x00,0x00, 6, // 0x2c ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x40, 6, // 0x2d '-' 0x00,0x00,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x2e '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00, 6, // 0x2f '/' 0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x80,0x80,0x00,0x00, 6, // 0x30 '0' 0x00,0x70,0x88,0x88,0x98,0xa8,0xc8,0x88,0x88,0x70,0x00,0x00, 6, // 0x31 '1' 0x00,0x20,0x20,0x60,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00, 6, // 0x32 '2' 0x00,0x70,0x88,0x88,0x08,0x10,0x20,0x40,0x80,0xf8,0x00,0x00, 6, // 0x33 '3' 0x00,0xf8,0x10,0x20,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00, 6, // 0x34 '4' 0x00,0x10,0x20,0x40,0x90,0x90,0xf8,0x10,0x10,0x10,0x00,0x00, 6, // 0x35 '5' 0x00,0xf8,0x80,0x80,0xf0,0x08,0x08,0x08,0x88,0x70,0x00,0x00, 6, // 0x36 '6' 0x00,0x70,0x88,0x80,0x80,0xf0,0x88,0x88,0x88,0x70,0x00,0x00, 6, // 0x37 '7' 0x00,0xf8,0x88,0x08,0x08,0x10,0x20,0x20,0x20,0x20,0x00,0x00, 6, // 0x38 '8' 0x00,0x70,0x88,0x88,0x88,0x70,0x88,0x88,0x88,0x70,0x00,0x00, 6, // 0x39 '9' 0x00,0x70,0x88,0x88,0x88,0x78,0x08,0x08,0x88,0x70,0x00,0x00, 6, // 0x3a ':' 0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x00,0x00,0x00, 6, // 0x3b ';' 0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x20,0x20,0x40, 6, // 0x3c '<' 0x00,0x08,0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x08,0x00,0x00, 6, // 0x3d '=' 0x00,0x00,0x00,0x00,0xf8,0x00,0xf8,0x00,0x00,0x00,0x00,0x00, 6, // 0x3e '>' 0x00,0x80,0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x80,0x00,0x00, 6, // 0x3f '?' 0x00,0x70,0x88,0x88,0x08,0x10,0x20,0x20,0x00,0x20,0x00,0x00, 6, // 0x40 '@' 0x00,0x70,0x88,0x88,0xb8,0xb8,0xb0,0x80,0x88,0x70,0x00,0x00, 6, // 0x41 'A' 0x00,0x20,0x50,0x88,0x88,0x88,0xf8,0x88,0x88,0x88,0x00,0x00, 6, // 0x42 'B' 0x00,0xf0,0x88,0x88,0x88,0xf0,0x88,0x88,0x88,0xf0,0x00,0x00, 6, // 0x43 'C' 0x00,0x70,0x88,0x88,0x80,0x80,0x80,0x88,0x88,0x70,0x00,0x00, 6, // 0x44 'D' 0x00,0xe0,0x90,0x88,0x88,0x88,0x88,0x88,0x90,0xe0,0x00,0x00, 6, // 0x45 'E' 0x00,0xf8,0x80,0x80,0x80,0xf0,0x80,0x80,0x80,0xf8,0x00,0x00, 6, // 0x46 'F' 0x00,0xf8,0x80,0x80,0x80,0xf0,0x80,0x80,0x80,0x80,0x00,0x00, 6, // 0x47 'G' 0x00,0x70,0x88,0x80,0x80,0xb8,0x88,0x88,0x88,0x70,0x00,0x00, 6, // 0x48 'H' 0x00,0x88,0x88,0x88,0x88,0xf8,0x88,0x88,0x88,0x88,0x00,0x00, 6, // 0x49 'I' 0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00, 6, // 0x4a 'J' 0x00,0x38,0x10,0x10,0x10,0x10,0x10,0x10,0x90,0x60,0x00,0x00, 6, // 0x4b 'K' 0x00,0x88,0x88,0x90,0xa0,0xc0,0xa0,0x90,0x88,0x88,0x00,0x00, 6, // 0x4c 'L' 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xf8,0x00,0x00, 6, // 0x4d 'M' 0x00,0x88,0x88,0xd8,0xa8,0x88,0x88,0x88,0x88,0x88,0x00,0x00, 6, // 0x4e 'N' 0x00,0x88,0x88,0xc8,0xa8,0x98,0x88,0x88,0x88,0x88,0x00,0x00, 6, // 0x4f 'O' 0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00, 6, // 0x50 'P' 0x00,0xf0,0x88,0x88,0x88,0xf0,0x80,0x80,0x80,0x80,0x00,0x00, 6, // 0x51 'Q' 0x00,0x70,0x88,0x88,0x88,0x88,0x88,0xa8,0x90,0x68,0x00,0x00, 6, // 0x52 'R' 0x00,0xf0,0x88,0x88,0x88,0x88,0xf0,0xa0,0x90,0x88,0x00,0x00, 6, // 0x53 'S' 0x00,0x70,0x88,0x80,0x80,0x70,0x08,0x08,0x88,0x70,0x00,0x00, 6, // 0x54 'T' 0x00,0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00, 6, // 0x55 'U' 0x00,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00, 6, // 0x56 'V' 0x00,0x88,0x88,0x88,0x88,0x88,0x50,0x50,0x20,0x20,0x00,0x00, 6, // 0x57 'W' 0x00,0x88,0x88,0x88,0x88,0x88,0xa8,0xa8,0xd8,0x88,0x00,0x00, 6, // 0x58 'X' 0x00,0x88,0x88,0x88,0x50,0x20,0x50,0x88,0x88,0x88,0x00,0x00, 6, // 0x59 'Y' 0x00,0x88,0x88,0x88,0x50,0x20,0x20,0x20,0x20,0x20,0x00,0x00, 6, // 0x5a 'Z' 0x00,0xf8,0x08,0x08,0x10,0x20,0x40,0x80,0x80,0xf8,0x00,0x00, 6, // 0x5b '[' 0x70,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x70,0x00, 6, // 0x5c '\' 0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x00,0x00, 6, // 0x5d ']' 0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70,0x00, 6, // 0x5e '^' 0x00,0x00,0x20,0x50,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x5f '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x00,0x00, 6, // 0x60 '`' 0x00,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x61 'a' 0x00,0x00,0x00,0x70,0x88,0x08,0x78,0x88,0x88,0x78,0x00,0x00, 6, // 0x62 'b' 0x00,0x80,0x80,0x80,0xf0,0x88,0x88,0x88,0x88,0xf0,0x00,0x00, 6, // 0x63 'c' 0x00,0x00,0x00,0x70,0x88,0x80,0x80,0x80,0x88,0x70,0x00,0x00, 6, // 0x64 'd' 0x00,0x08,0x08,0x08,0x78,0x88,0x88,0x88,0x88,0x78,0x00,0x00, 6, // 0x65 'e' 0x00,0x00,0x00,0x70,0x88,0x88,0xf8,0x80,0x80,0x78,0x00,0x00, 6, // 0x66 'f' 0x00,0x18,0x20,0x20,0xf8,0x20,0x20,0x20,0x20,0x20,0x00,0x00, 6, // 0x67 'g' 0x00,0x00,0x00,0x78,0x88,0x88,0x88,0x88,0x78,0x08,0x08,0xf0, 6, // 0x68 'h' 0x00,0x80,0x80,0x80,0xf0,0x88,0x88,0x88,0x88,0x88,0x00,0x00, 6, // 0x69 'i' 0x00,0x20,0x00,0x00,0x60,0x20,0x20,0x20,0x20,0x70,0x00,0x00, 6, // 0x6a 'j' 0x00,0x10,0x00,0x00,0x30,0x10,0x10,0x10,0x10,0x10,0x90,0x60, 6, // 0x6b 'k' 0x00,0x80,0x80,0x80,0x88,0x90,0xa0,0xd0,0x88,0x88,0x00,0x00, 6, // 0x6c 'l' 0x00,0x60,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00, 6, // 0x6d 'm' 0x00,0x00,0x00,0xd0,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0x00,0x00, 6, // 0x6e 'n' 0x00,0x00,0x00,0xb0,0xc8,0x88,0x88,0x88,0x88,0x88,0x00,0x00, 6, // 0x6f 'o' 0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00, 6, // 0x70 'p' 0x00,0x00,0x00,0xf0,0x88,0x88,0x88,0x88,0xf0,0x80,0x80,0x80, 6, // 0x71 'q' 0x00,0x00,0x00,0x78,0x88,0x88,0x88,0x88,0x78,0x08,0x08,0x08, 6, // 0x72 'r' 0x00,0x00,0x00,0xb0,0xc8,0x88,0x80,0x80,0x80,0x80,0x00,0x00, 6, // 0x73 's' 0x00,0x00,0x00,0x70,0x88,0x80,0x70,0x08,0x88,0x70,0x00,0x00, 6, // 0x74 't' 0x00,0x40,0x40,0x40,0xe0,0x40,0x40,0x40,0x48,0x30,0x00,0x00, 6, // 0x75 'u' 0x00,0x00,0x00,0x88,0x88,0x88,0x88,0x88,0x88,0x78,0x00,0x00, 6, // 0x76 'v' 0x00,0x00,0x00,0x88,0x88,0x88,0x50,0x50,0x20,0x20,0x00,0x00, 6, // 0x77 'w' 0x00,0x00,0x00,0x88,0x88,0x88,0xa8,0xa8,0xd8,0x88,0x00,0x00, 6, // 0x78 'x' 0x00,0x00,0x00,0x88,0x88,0x50,0x20,0x50,0x88,0x88,0x00,0x00, 6, // 0x79 'y' 0x00,0x00,0x00,0x88,0x88,0x88,0x88,0x88,0x78,0x08,0x10,0xe0, 6, // 0x7a 'z' 0x00,0x00,0x00,0xf8,0x08,0x10,0x20,0x40,0x80,0xf8,0x00,0x00, 6, // 0x7b '{' 0x18,0x20,0x20,0x20,0x20,0xc0,0x20,0x20,0x20,0x20,0x18,0x00, 6, // 0x7c '|' 0x00,0x20,0x20,0x20,0x20,0x00,0x20,0x20,0x20,0x20,0x00,0x00, 6, // 0x7d '}' 0xc0,0x20,0x20,0x20,0x20,0x18,0x20,0x20,0x20,0x20,0xc0,0x00, 6, // 0x7e '~' 0x00,0x00,0x40,0xa8,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x7f '' 0x00,0x00,0x00,0x00,0x20,0x50,0x88,0xf8,0x00,0x00,0x00,0x00, 0 }; const int8u gse6x9[] = { 9, 0, 32, 128-32, 0x00,0x00,0x0a,0x00,0x14,0x00,0x1e,0x00,0x28,0x00,0x32,0x00,0x3c,0x00,0x46,0x00,0x50,0x00, 0x5a,0x00,0x64,0x00,0x6e,0x00,0x78,0x00,0x82,0x00,0x8c,0x00,0x96,0x00,0xa0,0x00,0xaa,0x00, 0xb4,0x00,0xbe,0x00,0xc8,0x00,0xd2,0x00,0xdc,0x00,0xe6,0x00,0xf0,0x00,0xfa,0x00,0x04,0x01, 0x0e,0x01,0x18,0x01,0x22,0x01,0x2c,0x01,0x36,0x01,0x40,0x01,0x4a,0x01,0x54,0x01,0x5e,0x01, 0x68,0x01,0x72,0x01,0x7c,0x01,0x86,0x01,0x90,0x01,0x9a,0x01,0xa4,0x01,0xae,0x01,0xb8,0x01, 0xc2,0x01,0xcc,0x01,0xd6,0x01,0xe0,0x01,0xea,0x01,0xf4,0x01,0xfe,0x01,0x08,0x02,0x12,0x02, 0x1c,0x02,0x26,0x02,0x30,0x02,0x3a,0x02,0x44,0x02,0x4e,0x02,0x58,0x02,0x62,0x02,0x6c,0x02, 0x76,0x02,0x80,0x02,0x8a,0x02,0x94,0x02,0x9e,0x02,0xa8,0x02,0xb2,0x02,0xbc,0x02,0xc6,0x02, 0xd0,0x02,0xda,0x02,0xe4,0x02,0xee,0x02,0xf8,0x02,0x02,0x03,0x0c,0x03,0x16,0x03,0x20,0x03, 0x2a,0x03,0x34,0x03,0x3e,0x03,0x48,0x03,0x52,0x03,0x5c,0x03,0x66,0x03,0x70,0x03,0x7a,0x03, 0x84,0x03,0x8e,0x03,0x98,0x03,0xa2,0x03,0xac,0x03,0xb6,0x03, 6, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x21 '!' 0x00,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00, 6, // 0x22 '"' 0x00,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x23 '#' 0x00,0x50,0x50,0xf8,0x50,0xf8,0x50,0x50,0x00, 6, // 0x24 '$' 0x00,0x70,0xa8,0xa0,0x70,0x28,0xa8,0x70,0x00, 6, // 0x25 '%' 0x00,0xc8,0xc8,0x10,0x20,0x40,0x98,0x98,0x00, 6, // 0x26 '&' 0x00,0x60,0x90,0x90,0x60,0xa8,0x90,0x68,0x00, 6, // 0x27 ''' 0x00,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x28 '(' 0x10,0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x10, 6, // 0x29 ')' 0x40,0x20,0x10,0x10,0x10,0x10,0x10,0x20,0x40, 6, // 0x2a '*' 0x00,0x00,0x20,0xa8,0x70,0xa8,0x20,0x00,0x00, 6, // 0x2b '+' 0x00,0x00,0x20,0x20,0xf8,0x20,0x20,0x00,0x00, 6, // 0x2c ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x40, 6, // 0x2d '-' 0x00,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,0x00, 6, // 0x2e '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00, 6, // 0x2f '/' 0x00,0x08,0x08,0x10,0x20,0x40,0x80,0x80,0x00, 6, // 0x30 '0' 0x00,0x70,0x88,0x98,0xa8,0xc8,0x88,0x70,0x00, 6, // 0x31 '1' 0x00,0x20,0x60,0x20,0x20,0x20,0x20,0x70,0x00, 6, // 0x32 '2' 0x00,0x70,0x88,0x08,0x10,0x20,0x40,0xf8,0x00, 6, // 0x33 '3' 0x00,0xf8,0x10,0x20,0x70,0x08,0x88,0x70,0x00, 6, // 0x34 '4' 0x00,0x10,0x20,0x40,0x90,0xf8,0x10,0x10,0x00, 6, // 0x35 '5' 0x00,0xf8,0x80,0xf0,0x08,0x08,0x88,0x70,0x00, 6, // 0x36 '6' 0x00,0x70,0x88,0x80,0xf0,0x88,0x88,0x70,0x00, 6, // 0x37 '7' 0x00,0xf8,0x08,0x08,0x10,0x20,0x40,0x40,0x00, 6, // 0x38 '8' 0x00,0x70,0x88,0x88,0x70,0x88,0x88,0x70,0x00, 6, // 0x39 '9' 0x00,0x70,0x88,0x88,0x78,0x08,0x88,0x70,0x00, 6, // 0x3a ':' 0x00,0x00,0x00,0x20,0x00,0x00,0x20,0x00,0x00, 6, // 0x3b ';' 0x00,0x00,0x00,0x20,0x00,0x00,0x20,0x20,0x40, 6, // 0x3c '<' 0x00,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x00, 6, // 0x3d '=' 0x00,0x00,0x00,0xf8,0x00,0xf8,0x00,0x00,0x00, 6, // 0x3e '>' 0x00,0x80,0x40,0x20,0x10,0x20,0x40,0x80,0x00, 6, // 0x3f '?' 0x00,0x70,0x88,0x08,0x10,0x20,0x00,0x20,0x00, 6, // 0x40 '@' 0x00,0x70,0x88,0x88,0xb8,0xb8,0x80,0x70,0x00, 6, // 0x41 'A' 0x00,0x20,0x50,0x88,0x88,0xf8,0x88,0x88,0x00, 6, // 0x42 'B' 0x00,0xf0,0x88,0x88,0xf0,0x88,0x88,0xf0,0x00, 6, // 0x43 'C' 0x00,0x70,0x88,0x80,0x80,0x80,0x88,0x70,0x00, 6, // 0x44 'D' 0x00,0xe0,0x90,0x88,0x88,0x88,0x90,0xe0,0x00, 6, // 0x45 'E' 0x00,0xf8,0x80,0x80,0xf0,0x80,0x80,0xf8,0x00, 6, // 0x46 'F' 0x00,0xf8,0x80,0x80,0xf0,0x80,0x80,0x80,0x00, 6, // 0x47 'G' 0x00,0x70,0x88,0x80,0xb8,0x88,0x88,0x70,0x00, 6, // 0x48 'H' 0x00,0x88,0x88,0x88,0xf8,0x88,0x88,0x88,0x00, 6, // 0x49 'I' 0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x70,0x00, 6, // 0x4a 'J' 0x00,0x38,0x10,0x10,0x10,0x10,0x90,0x60,0x00, 6, // 0x4b 'K' 0x00,0x88,0x90,0xa0,0xc0,0xa0,0x90,0x88,0x00, 6, // 0x4c 'L' 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0xf8,0x00, 6, // 0x4d 'M' 0x00,0x88,0xd8,0xa8,0x88,0x88,0x88,0x88,0x00, 6, // 0x4e 'N' 0x00,0x88,0x88,0xc8,0xa8,0x98,0x88,0x88,0x00, 6, // 0x4f 'O' 0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x70,0x00, 6, // 0x50 'P' 0x00,0xf0,0x88,0x88,0xf0,0x80,0x80,0x80,0x00, 6, // 0x51 'Q' 0x00,0x70,0x88,0x88,0x88,0xa8,0x90,0x68,0x00, 6, // 0x52 'R' 0x00,0xf0,0x88,0x88,0x88,0xf0,0x90,0x88,0x00, 6, // 0x53 'S' 0x00,0x70,0x88,0x80,0x70,0x08,0x88,0x70,0x00, 6, // 0x54 'T' 0x00,0xf8,0x20,0x20,0x20,0x20,0x20,0x20,0x00, 6, // 0x55 'U' 0x00,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00, 6, // 0x56 'V' 0x00,0x88,0x88,0x88,0x50,0x50,0x20,0x20,0x00, 6, // 0x57 'W' 0x00,0x88,0x88,0x88,0xa8,0xa8,0xd8,0x88,0x00, 6, // 0x58 'X' 0x00,0x88,0x88,0x50,0x20,0x50,0x88,0x88,0x00, 6, // 0x59 'Y' 0x00,0x88,0x88,0x50,0x20,0x20,0x20,0x20,0x00, 6, // 0x5a 'Z' 0x00,0xf8,0x08,0x10,0x20,0x40,0x80,0xf8,0x00, 6, // 0x5b '[' 0x70,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x70, 6, // 0x5c '\' 0x00,0x80,0x80,0x40,0x20,0x10,0x08,0x08,0x00, 6, // 0x5d ']' 0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70, 6, // 0x5e '^' 0x00,0x00,0x20,0x50,0x88,0x00,0x00,0x00,0x00, 6, // 0x5f '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x00, 6, // 0x60 '`' 0x00,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x61 'a' 0x00,0x00,0x00,0x70,0x08,0x78,0x88,0x78,0x00, 6, // 0x62 'b' 0x00,0x80,0x80,0xf0,0x88,0x88,0x88,0xf0,0x00, 6, // 0x63 'c' 0x00,0x00,0x00,0x70,0x88,0x80,0x88,0x70,0x00, 6, // 0x64 'd' 0x00,0x08,0x08,0x78,0x88,0x88,0x88,0x78,0x00, 6, // 0x65 'e' 0x00,0x00,0x00,0x70,0x88,0xf8,0x80,0x78,0x00, 6, // 0x66 'f' 0x00,0x18,0x20,0x20,0xf8,0x20,0x20,0x20,0x00, 6, // 0x67 'g' 0x00,0x00,0x00,0x78,0x88,0x88,0x78,0x08,0x70, 6, // 0x68 'h' 0x00,0x80,0x80,0xf0,0x88,0x88,0x88,0x88,0x00, 6, // 0x69 'i' 0x00,0x20,0x00,0x60,0x20,0x20,0x20,0x70,0x00, 6, // 0x6a 'j' 0x00,0x10,0x00,0x30,0x10,0x10,0x10,0x90,0x60, 6, // 0x6b 'k' 0x00,0x00,0x80,0x88,0x90,0xa0,0xd0,0x88,0x00, 6, // 0x6c 'l' 0x00,0x60,0x20,0x20,0x20,0x20,0x20,0x70,0x00, 6, // 0x6d 'm' 0x00,0x00,0x00,0xd0,0xa8,0xa8,0xa8,0xa8,0x00, 6, // 0x6e 'n' 0x00,0x00,0x00,0xb0,0xc8,0x88,0x88,0x88,0x00, 6, // 0x6f 'o' 0x00,0x00,0x00,0x70,0x88,0x88,0x88,0x70,0x00, 6, // 0x70 'p' 0x00,0x00,0x00,0xf0,0x88,0x88,0xf0,0x80,0x80, 6, // 0x71 'q' 0x00,0x00,0x00,0x78,0x88,0x88,0x78,0x08,0x08, 6, // 0x72 'r' 0x00,0x00,0x00,0xb8,0xc0,0x80,0x80,0x80,0x00, 6, // 0x73 's' 0x00,0x00,0x00,0x78,0x80,0x70,0x08,0xf0,0x00, 6, // 0x74 't' 0x00,0x40,0x40,0xe0,0x40,0x40,0x48,0x30,0x00, 6, // 0x75 'u' 0x00,0x00,0x00,0x88,0x88,0x88,0x88,0x78,0x00, 6, // 0x76 'v' 0x00,0x00,0x00,0x88,0x88,0x88,0x50,0x20,0x00, 6, // 0x77 'w' 0x00,0x00,0x00,0x88,0x88,0xa8,0xd8,0x88,0x00, 6, // 0x78 'x' 0x00,0x00,0x00,0x88,0x50,0x20,0x50,0x88,0x00, 6, // 0x79 'y' 0x00,0x00,0x00,0x88,0x88,0x88,0x78,0x08,0x70, 6, // 0x7a 'z' 0x00,0x00,0x00,0xf8,0x10,0x20,0x40,0xf8,0x00, 6, // 0x7b '{' 0x18,0x20,0x20,0x20,0xc0,0x20,0x20,0x20,0x18, 6, // 0x7c '|' 0x00,0x20,0x20,0x20,0x00,0x20,0x20,0x20,0x00, 6, // 0x7d '}' 0xc0,0x20,0x20,0x20,0x18,0x20,0x20,0x20,0xc0, 6, // 0x7e '~' 0x00,0x40,0xa8,0x10,0x00,0x00,0x00,0x00,0x00, 6, // 0x7f '' 0x00,0x00,0x00,0x20,0x50,0x88,0xf8,0x00,0x00, 0 }; const int8u gse7x11[] = { 11, 0, 32, 128-32, 0x00,0x00,0x0c,0x00,0x18,0x00,0x24,0x00,0x30,0x00,0x3c,0x00,0x48,0x00,0x54,0x00,0x60,0x00, 0x6c,0x00,0x78,0x00,0x84,0x00,0x90,0x00,0x9c,0x00,0xa8,0x00,0xb4,0x00,0xc0,0x00,0xcc,0x00, 0xd8,0x00,0xe4,0x00,0xf0,0x00,0xfc,0x00,0x08,0x01,0x14,0x01,0x20,0x01,0x2c,0x01,0x38,0x01, 0x44,0x01,0x50,0x01,0x5c,0x01,0x68,0x01,0x74,0x01,0x80,0x01,0x8c,0x01,0x98,0x01,0xa4,0x01, 0xb0,0x01,0xbc,0x01,0xc8,0x01,0xd4,0x01,0xe0,0x01,0xec,0x01,0xf8,0x01,0x04,0x02,0x10,0x02, 0x1c,0x02,0x28,0x02,0x34,0x02,0x40,0x02,0x4c,0x02,0x58,0x02,0x64,0x02,0x70,0x02,0x7c,0x02, 0x88,0x02,0x94,0x02,0xa0,0x02,0xac,0x02,0xb8,0x02,0xc4,0x02,0xd0,0x02,0xdc,0x02,0xe8,0x02, 0xf4,0x02,0x00,0x03,0x0c,0x03,0x18,0x03,0x24,0x03,0x30,0x03,0x3c,0x03,0x48,0x03,0x54,0x03, 0x60,0x03,0x6c,0x03,0x78,0x03,0x84,0x03,0x90,0x03,0x9c,0x03,0xa8,0x03,0xb4,0x03,0xc0,0x03, 0xcc,0x03,0xd8,0x03,0xe4,0x03,0xf0,0x03,0xfc,0x03,0x08,0x04,0x14,0x04,0x20,0x04,0x2c,0x04, 0x38,0x04,0x44,0x04,0x50,0x04,0x5c,0x04,0x68,0x04,0x74,0x04, 7, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x21 '!' 0x00,0x10,0x38,0x38,0x38,0x10,0x10,0x00,0x10,0x00,0x00, 7, // 0x22 '"' 0x00,0x00,0x24,0x24,0x24,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x23 '#' 0x00,0x48,0x48,0xfc,0x48,0x48,0xfc,0x48,0x48,0x00,0x00, 7, // 0x24 '$' 0x00,0x10,0x38,0x54,0x50,0x38,0x14,0x54,0x38,0x10,0x00, 7, // 0x25 '%' 0x00,0x00,0x42,0xa4,0x48,0x10,0x24,0x4a,0x84,0x00,0x00, 7, // 0x26 '&' 0x00,0x30,0x48,0x48,0x30,0x60,0x94,0x98,0x6c,0x00,0x00, 7, // 0x27 ''' 0x00,0x20,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x28 '(' 0x00,0x04,0x08,0x10,0x10,0x10,0x10,0x08,0x04,0x00,0x00, 7, // 0x29 ')' 0x00,0x40,0x20,0x10,0x10,0x10,0x10,0x20,0x40,0x00,0x00, 7, // 0x2a '*' 0x00,0x00,0x00,0x20,0xa8,0x70,0xa8,0x20,0x00,0x00,0x00, 7, // 0x2b '+' 0x00,0x00,0x00,0x10,0x10,0x7c,0x10,0x10,0x00,0x00,0x00, 7, // 0x2c ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x60, 7, // 0x2d '-' 0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00, 7, // 0x2e '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00, 7, // 0x2f '/' 0x00,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x00,0x00, 7, // 0x30 '0' 0x00,0x38,0x44,0x4c,0x54,0x64,0x44,0x44,0x38,0x00,0x00, 7, // 0x31 '1' 0x00,0x10,0x30,0x10,0x10,0x10,0x10,0x10,0x7c,0x00,0x00, 7, // 0x32 '2' 0x00,0x38,0x44,0x04,0x08,0x10,0x20,0x44,0x7c,0x00,0x00, 7, // 0x33 '3' 0x00,0x7c,0x48,0x10,0x38,0x04,0x04,0x44,0x38,0x00,0x00, 7, // 0x34 '4' 0x00,0x08,0x10,0x20,0x48,0x48,0x7c,0x08,0x1c,0x00,0x00, 7, // 0x35 '5' 0x00,0x7c,0x40,0x40,0x78,0x04,0x04,0x44,0x38,0x00,0x00, 7, // 0x36 '6' 0x00,0x18,0x20,0x40,0x78,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x37 '7' 0x00,0x7c,0x44,0x04,0x08,0x10,0x10,0x10,0x10,0x00,0x00, 7, // 0x38 '8' 0x00,0x38,0x44,0x44,0x38,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x39 '9' 0x00,0x38,0x44,0x44,0x44,0x3c,0x04,0x08,0x30,0x00,0x00, 7, // 0x3a ':' 0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00, 7, // 0x3b ';' 0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x30,0x60,0x00, 7, // 0x3c '<' 0x00,0x00,0x04,0x08,0x10,0x20,0x10,0x08,0x04,0x00,0x00, 7, // 0x3d '=' 0x00,0x00,0x00,0x00,0xfc,0x00,0xfc,0x00,0x00,0x00,0x00, 7, // 0x3e '>' 0x00,0x00,0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x00,0x00, 7, // 0x3f '?' 0x00,0x70,0x88,0x88,0x10,0x20,0x20,0x00,0x20,0x00,0x00, 7, // 0x40 '@' 0x00,0x30,0x48,0x04,0x34,0x54,0x54,0x54,0x28,0x00,0x00, 7, // 0x41 'A' 0x00,0x10,0x28,0x44,0x44,0x7c,0x44,0x44,0x44,0x00,0x00, 7, // 0x42 'B' 0x00,0x78,0x44,0x44,0x78,0x44,0x44,0x44,0x78,0x00,0x00, 7, // 0x43 'C' 0x00,0x38,0x44,0x40,0x40,0x40,0x40,0x44,0x38,0x00,0x00, 7, // 0x44 'D' 0x00,0x70,0x48,0x44,0x44,0x44,0x44,0x48,0x70,0x00,0x00, 7, // 0x45 'E' 0x00,0x7c,0x40,0x40,0x70,0x40,0x40,0x40,0x7c,0x00,0x00, 7, // 0x46 'F' 0x00,0x7c,0x40,0x40,0x70,0x40,0x40,0x40,0x40,0x00,0x00, 7, // 0x47 'G' 0x00,0x38,0x44,0x40,0x40,0x5c,0x44,0x44,0x38,0x00,0x00, 7, // 0x48 'H' 0x00,0x44,0x44,0x44,0x7c,0x44,0x44,0x44,0x44,0x00,0x00, 7, // 0x49 'I' 0x00,0x38,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00, 7, // 0x4a 'J' 0x00,0x1c,0x08,0x08,0x08,0x08,0x08,0x48,0x30,0x00,0x00, 7, // 0x4b 'K' 0x00,0x44,0x48,0x50,0x60,0x50,0x48,0x44,0x44,0x00,0x00, 7, // 0x4c 'L' 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7c,0x00,0x00, 7, // 0x4d 'M' 0x00,0x44,0x6c,0x54,0x54,0x44,0x44,0x44,0x44,0x00,0x00, 7, // 0x4e 'N' 0x00,0x44,0x44,0x64,0x54,0x4c,0x44,0x44,0x44,0x00,0x00, 7, // 0x4f 'O' 0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x50 'P' 0x00,0x78,0x44,0x44,0x44,0x78,0x40,0x40,0x40,0x00,0x00, 7, // 0x51 'Q' 0x00,0x38,0x44,0x44,0x44,0x44,0x54,0x48,0x34,0x00,0x00, 7, // 0x52 'R' 0x00,0x78,0x44,0x44,0x44,0x78,0x50,0x48,0x44,0x00,0x00, 7, // 0x53 'S' 0x00,0x38,0x44,0x40,0x38,0x04,0x44,0x44,0x38,0x00,0x00, 7, // 0x54 'T' 0x00,0x7c,0x54,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, 7, // 0x55 'U' 0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x56 'V' 0x00,0x44,0x44,0x44,0x44,0x28,0x28,0x10,0x10,0x00,0x00, 7, // 0x57 'W' 0x00,0x44,0x44,0x44,0x44,0x54,0x54,0x6c,0x44,0x00,0x00, 7, // 0x58 'X' 0x00,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x44,0x00,0x00, 7, // 0x59 'Y' 0x00,0x44,0x44,0x44,0x28,0x10,0x10,0x10,0x38,0x00,0x00, 7, // 0x5a 'Z' 0x00,0x7c,0x04,0x08,0x10,0x20,0x40,0x44,0x7c,0x00,0x00, 7, // 0x5b '[' 0x00,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x00,0x00, 7, // 0x5c '\' 0x00,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x00,0x00, 7, // 0x5d ']' 0x00,0x38,0x08,0x08,0x08,0x08,0x08,0x08,0x38,0x00,0x00, 7, // 0x5e '^' 0x00,0x10,0x28,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x5f '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00, 7, // 0x60 '`' 0x00,0x20,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x61 'a' 0x00,0x00,0x00,0x38,0x04,0x3c,0x44,0x44,0x3c,0x00,0x00, 7, // 0x62 'b' 0x00,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x78,0x00,0x00, 7, // 0x63 'c' 0x00,0x00,0x00,0x38,0x44,0x40,0x40,0x44,0x38,0x00,0x00, 7, // 0x64 'd' 0x00,0x04,0x04,0x3c,0x44,0x44,0x44,0x44,0x3c,0x00,0x00, 7, // 0x65 'e' 0x00,0x00,0x00,0x38,0x44,0x7c,0x40,0x44,0x38,0x00,0x00, 7, // 0x66 'f' 0x00,0x18,0x24,0x20,0x70,0x20,0x20,0x20,0x70,0x00,0x00, 7, // 0x67 'g' 0x00,0x00,0x00,0x3c,0x44,0x44,0x44,0x3c,0x04,0x44,0x38, 7, // 0x68 'h' 0x00,0x40,0x40,0x40,0x58,0x64,0x44,0x44,0x44,0x00,0x00, 7, // 0x69 'i' 0x00,0x10,0x00,0x30,0x10,0x10,0x10,0x10,0x38,0x00,0x00, 7, // 0x6a 'j' 0x00,0x08,0x00,0x18,0x08,0x08,0x08,0x08,0x48,0x30,0x00, 7, // 0x6b 'k' 0x00,0x40,0x40,0x44,0x48,0x50,0x68,0x44,0x44,0x00,0x00, 7, // 0x6c 'l' 0x00,0x30,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00, 7, // 0x6d 'm' 0x00,0x00,0x00,0xa8,0x54,0x54,0x54,0x54,0x54,0x00,0x00, 7, // 0x6e 'n' 0x00,0x00,0x00,0xb8,0x44,0x44,0x44,0x44,0x44,0x00,0x00, 7, // 0x6f 'o' 0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x70 'p' 0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x78,0x40,0x40, 7, // 0x71 'q' 0x00,0x00,0x00,0x3c,0x44,0x44,0x44,0x44,0x3c,0x04,0x04, 7, // 0x72 'r' 0x00,0x00,0x00,0x58,0x64,0x44,0x40,0x40,0x40,0x00,0x00, 7, // 0x73 's' 0x00,0x00,0x00,0x3c,0x40,0x38,0x04,0x04,0x78,0x00,0x00, 7, // 0x74 't' 0x00,0x20,0x20,0x70,0x20,0x20,0x20,0x24,0x18,0x00,0x00, 7, // 0x75 'u' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x3a,0x00,0x00, 7, // 0x76 'v' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x28,0x10,0x00,0x00, 7, // 0x77 'w' 0x00,0x00,0x00,0x44,0x44,0x54,0x54,0x6c,0x44,0x00,0x00, 7, // 0x78 'x' 0x00,0x00,0x00,0x44,0x28,0x10,0x28,0x44,0x44,0x00,0x00, 7, // 0x79 'y' 0x00,0x00,0x00,0x44,0x44,0x44,0x3c,0x04,0x08,0x30,0x00, 7, // 0x7a 'z' 0x00,0x00,0x00,0x7c,0x08,0x10,0x20,0x44,0x7c,0x00,0x00, 7, // 0x7b '{' 0x00,0x0c,0x10,0x10,0x10,0x60,0x10,0x10,0x0c,0x00,0x00, 7, // 0x7c '|' 0x00,0x20,0x20,0x20,0x00,0x20,0x20,0x20,0x20,0x00,0x00, 7, // 0x7d '}' 0x00,0x60,0x10,0x10,0x10,0x0c,0x10,0x10,0x60,0x00,0x00, 7, // 0x7e '~' 0x00,0x00,0x64,0x98,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x7f '' 0x00,0x00,0x00,0x10,0x28,0x44,0x44,0x7c,0x00,0x00,0x00, 0 }; const int8u gse7x11_bold[] = { 11, 0, 32, 128-32, 0x00,0x00,0x0c,0x00,0x18,0x00,0x24,0x00,0x30,0x00,0x3c,0x00,0x48,0x00,0x54,0x00,0x60,0x00, 0x6c,0x00,0x78,0x00,0x84,0x00,0x90,0x00,0x9c,0x00,0xa8,0x00,0xb4,0x00,0xc0,0x00,0xcc,0x00, 0xd8,0x00,0xe4,0x00,0xf0,0x00,0xfc,0x00,0x08,0x01,0x14,0x01,0x20,0x01,0x2c,0x01,0x38,0x01, 0x44,0x01,0x50,0x01,0x5c,0x01,0x68,0x01,0x74,0x01,0x80,0x01,0x8c,0x01,0x98,0x01,0xa4,0x01, 0xb0,0x01,0xbc,0x01,0xc8,0x01,0xd4,0x01,0xe0,0x01,0xec,0x01,0xf8,0x01,0x04,0x02,0x10,0x02, 0x1c,0x02,0x28,0x02,0x34,0x02,0x40,0x02,0x4c,0x02,0x58,0x02,0x64,0x02,0x70,0x02,0x7c,0x02, 0x88,0x02,0x94,0x02,0xa0,0x02,0xac,0x02,0xb8,0x02,0xc4,0x02,0xd0,0x02,0xdc,0x02,0xe8,0x02, 0xf4,0x02,0x00,0x03,0x0c,0x03,0x18,0x03,0x24,0x03,0x30,0x03,0x3c,0x03,0x48,0x03,0x54,0x03, 0x60,0x03,0x6c,0x03,0x78,0x03,0x84,0x03,0x90,0x03,0x9c,0x03,0xa8,0x03,0xb4,0x03,0xc0,0x03, 0xcc,0x03,0xd8,0x03,0xe4,0x03,0xf0,0x03,0xfc,0x03,0x08,0x04,0x14,0x04,0x20,0x04,0x2c,0x04, 0x38,0x04,0x44,0x04,0x50,0x04,0x5c,0x04,0x68,0x04,0x74,0x04, 7, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x21 '!' 0x00,0x30,0x30,0x30,0x30,0x30,0x00,0x30,0x30,0x00,0x00, 7, // 0x22 '"' 0x00,0x6c,0x6c,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x23 '#' 0x00,0x48,0x48,0xfc,0x48,0x48,0xfc,0x48,0x48,0x00,0x00, 7, // 0x24 '$' 0x30,0x30,0x78,0xcc,0xc0,0x78,0x0c,0xcc,0x78,0x30,0x30, 7, // 0x25 '%' 0x00,0x00,0xc4,0x0c,0x18,0x30,0x60,0xc0,0x8c,0x00,0x00, 7, // 0x26 '&' 0x00,0x30,0x58,0x58,0x30,0x74,0xdc,0xd8,0x6c,0x00,0x00, 7, // 0x27 ''' 0x00,0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x28 '(' 0x00,0x0c,0x18,0x30,0x30,0x30,0x30,0x18,0x0c,0x00,0x00, 7, // 0x29 ')' 0x00,0xc0,0x60,0x30,0x30,0x30,0x30,0x60,0xc0,0x00,0x00, 7, // 0x2a '*' 0x00,0x00,0x00,0x20,0xa8,0x70,0xa8,0x20,0x00,0x00,0x00, 7, // 0x2b '+' 0x00,0x00,0x00,0x30,0x30,0xfc,0x30,0x30,0x00,0x00,0x00, 7, // 0x2c ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x60,0x00, 7, // 0x2d '-' 0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00, 7, // 0x2e '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00, 7, // 0x2f '/' 0x00,0x0c,0x0c,0x18,0x18,0x30,0x30,0x60,0x60,0x00,0x00, 7, // 0x30 '0' 0x00,0x78,0xcc,0xcc,0xdc,0xec,0xcc,0xcc,0x78,0x00,0x00, 7, // 0x31 '1' 0x00,0x30,0x70,0xf0,0x30,0x30,0x30,0x30,0xfc,0x00,0x00, 7, // 0x32 '2' 0x00,0x78,0xcc,0xcc,0x18,0x30,0x60,0xcc,0xfc,0x00,0x00, 7, // 0x33 '3' 0x00,0xfc,0x98,0x30,0x78,0x0c,0x0c,0xcc,0x78,0x00,0x00, 7, // 0x34 '4' 0x00,0x18,0x30,0x68,0xd8,0xd8,0xfc,0x18,0x3c,0x00,0x00, 7, // 0x35 '5' 0x00,0xfc,0xc0,0xc0,0xf8,0x0c,0x0c,0xcc,0x78,0x00,0x00, 7, // 0x36 '6' 0x00,0x38,0x60,0xc0,0xf8,0xcc,0xcc,0xcc,0x78,0x00,0x00, 7, // 0x37 '7' 0x00,0xfc,0x8c,0x0c,0x18,0x30,0x30,0x30,0x30,0x00,0x00, 7, // 0x38 '8' 0x00,0x78,0xcc,0xcc,0x78,0xcc,0xcc,0xcc,0x78,0x00,0x00, 7, // 0x39 '9' 0x00,0x78,0xcc,0xcc,0xcc,0x7c,0x0c,0x18,0x70,0x00,0x00, 7, // 0x3a ':' 0x00,0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x00,0x00,0x00, 7, // 0x3b ';' 0x00,0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x30,0x60,0x00, 7, // 0x3c '<' 0x00,0x00,0x0c,0x18,0x30,0x60,0x30,0x18,0x0c,0x00,0x00, 7, // 0x3d '=' 0x00,0x00,0x00,0x00,0xfc,0x00,0xfc,0x00,0x00,0x00,0x00, 7, // 0x3e '>' 0x00,0x00,0x60,0x30,0x18,0x0c,0x18,0x30,0x60,0x00,0x00, 7, // 0x3f '?' 0x00,0x78,0xcc,0xcc,0x18,0x30,0x30,0x00,0x30,0x00,0x00, 7, // 0x40 '@' 0x00,0x70,0x88,0x04,0x74,0xb4,0xb4,0xb4,0x68,0x00,0x00, 7, // 0x41 'A' 0x00,0x30,0x78,0xcc,0xcc,0xfc,0xcc,0xcc,0xcc,0x00,0x00, 7, // 0x42 'B' 0x00,0xf8,0xcc,0xcc,0xf8,0xcc,0xcc,0xcc,0xf8,0x00,0x00, 7, // 0x43 'C' 0x00,0x78,0xcc,0xc0,0xc0,0xc0,0xc0,0xcc,0x78,0x00,0x00, 7, // 0x44 'D' 0x00,0xf0,0xd8,0xcc,0xcc,0xcc,0xcc,0xd8,0xf0,0x00,0x00, 7, // 0x45 'E' 0x00,0xfc,0xc4,0xd0,0xf0,0xd0,0xc0,0xc4,0xfc,0x00,0x00, 7, // 0x46 'F' 0x00,0xfc,0xc4,0xd0,0xf0,0xd0,0xc0,0xc0,0xc0,0x00,0x00, 7, // 0x47 'G' 0x00,0x78,0xcc,0xc0,0xc0,0xdc,0xcc,0xcc,0x78,0x00,0x00, 7, // 0x48 'H' 0x00,0xcc,0xcc,0xcc,0xfc,0xcc,0xcc,0xcc,0xcc,0x00,0x00, 7, // 0x49 'I' 0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00, 7, // 0x4a 'J' 0x00,0x3c,0x18,0x18,0x18,0x18,0xd8,0xd8,0x70,0x00,0x00, 7, // 0x4b 'K' 0x00,0xcc,0xcc,0xd8,0xf0,0xd8,0xcc,0xcc,0xcc,0x00,0x00, 7, // 0x4c 'L' 0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc4,0xfc,0x00,0x00, 7, // 0x4d 'M' 0x00,0x84,0xcc,0xfc,0xb4,0xcc,0xcc,0xcc,0xcc,0x00,0x00, 7, // 0x4e 'N' 0x00,0xcc,0xcc,0xec,0xfc,0xdc,0xcc,0xcc,0xcc,0x00,0x00, 7, // 0x4f 'O' 0x00,0x78,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x78,0x00,0x00, 7, // 0x50 'P' 0x00,0xf8,0xcc,0xcc,0xcc,0xf8,0xc0,0xc0,0xc0,0x00,0x00, 7, // 0x51 'Q' 0x00,0x78,0xcc,0xcc,0xcc,0xcc,0xdc,0x78,0x18,0x0c,0x00, 7, // 0x52 'R' 0x00,0xf8,0xcc,0xcc,0xcc,0xf8,0xd8,0xcc,0xcc,0x00,0x00, 7, // 0x53 'S' 0x00,0x78,0xcc,0xe0,0x70,0x38,0x1c,0xcc,0x78,0x00,0x00, 7, // 0x54 'T' 0x00,0xfc,0xb4,0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x00, 7, // 0x55 'U' 0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x78,0x00,0x00, 7, // 0x56 'V' 0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x78,0x30,0x00,0x00, 7, // 0x57 'W' 0x00,0xcc,0xcc,0xcc,0xcc,0xb4,0xfc,0xcc,0x84,0x00,0x00, 7, // 0x58 'X' 0x00,0xcc,0xcc,0x78,0x30,0x78,0xcc,0xcc,0xcc,0x00,0x00, 7, // 0x59 'Y' 0x00,0xcc,0xcc,0xcc,0x78,0x30,0x30,0x30,0x78,0x00,0x00, 7, // 0x5a 'Z' 0x00,0xfc,0x8c,0x18,0x30,0x60,0xc0,0xc4,0xfc,0x00,0x00, 7, // 0x5b '[' 0x00,0x78,0x60,0x60,0x60,0x60,0x60,0x60,0x78,0x00,0x00, 7, // 0x5c '\' 0x00,0x60,0x60,0x30,0x30,0x18,0x18,0x0c,0x0c,0x00,0x00, 7, // 0x5d ']' 0x00,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x78,0x00,0x00, 7, // 0x5e '^' 0x00,0x10,0x38,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x5f '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00, 7, // 0x60 '`' 0x00,0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x61 'a' 0x00,0x00,0x00,0x70,0x18,0x78,0xd8,0xd8,0x6c,0x00,0x00, 7, // 0x62 'b' 0x00,0x60,0x60,0x60,0x78,0x6c,0x6c,0x6c,0x78,0x00,0x00, 7, // 0x63 'c' 0x00,0x00,0x00,0x78,0xcc,0xc0,0xc0,0xcc,0x78,0x00,0x00, 7, // 0x64 'd' 0x00,0x18,0x18,0x18,0x78,0xd8,0xd8,0xd8,0x6c,0x00,0x00, 7, // 0x65 'e' 0x00,0x00,0x00,0x78,0xcc,0xfc,0xc0,0xcc,0x78,0x00,0x00, 7, // 0x66 'f' 0x00,0x18,0x34,0x30,0x78,0x30,0x30,0x30,0x78,0x00,0x00, 7, // 0x67 'g' 0x00,0x00,0x00,0x6c,0xd8,0xd8,0xd8,0x78,0x18,0xd8,0x70, 7, // 0x68 'h' 0x00,0xc0,0xc0,0xd8,0xec,0xcc,0xcc,0xcc,0xcc,0x00,0x00, 7, // 0x69 'i' 0x00,0x30,0x00,0x70,0x30,0x30,0x30,0x30,0x78,0x00,0x00, 7, // 0x6a 'j' 0x00,0x0c,0x00,0x1c,0x0c,0x0c,0x0c,0x0c,0x6c,0x6c,0x38, 7, // 0x6b 'k' 0x00,0xc0,0xc0,0xcc,0xcc,0xd8,0xf0,0xd8,0xcc,0x00,0x00, 7, // 0x6c 'l' 0x00,0x70,0x30,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00, 7, // 0x6d 'm' 0x00,0x00,0x00,0xe8,0xfc,0xd4,0xd4,0xc4,0xc4,0x00,0x00, 7, // 0x6e 'n' 0x00,0x00,0x00,0xd8,0x6c,0x6c,0x6c,0x6c,0x6c,0x00,0x00, 7, // 0x6f 'o' 0x00,0x00,0x00,0x78,0xcc,0xcc,0xcc,0xcc,0x78,0x00,0x00, 7, // 0x70 'p' 0x00,0x00,0x00,0xf8,0xcc,0xcc,0xcc,0xf8,0xc0,0xc0,0xc0, 7, // 0x71 'q' 0x00,0x00,0x00,0x7c,0xcc,0xcc,0xcc,0x7c,0x0c,0x0c,0x0c, 7, // 0x72 'r' 0x00,0x00,0x00,0xd8,0xec,0xcc,0xc0,0xc0,0xc0,0x00,0x00, 7, // 0x73 's' 0x00,0x00,0x00,0x78,0xcc,0x60,0x18,0xcc,0x78,0x00,0x00, 7, // 0x74 't' 0x00,0x20,0x60,0x60,0xf0,0x60,0x60,0x68,0x30,0x00,0x00, 7, // 0x75 'u' 0x00,0x00,0x00,0xd8,0xd8,0xd8,0xd8,0xd8,0x6c,0x00,0x00, 7, // 0x76 'v' 0x00,0x00,0x00,0xcc,0xcc,0xcc,0xcc,0x78,0x30,0x00,0x00, 7, // 0x77 'w' 0x00,0x00,0x00,0xcc,0xcc,0xb4,0xfc,0xcc,0x84,0x00,0x00, 7, // 0x78 'x' 0x00,0x00,0x00,0xcc,0x78,0x30,0x78,0xcc,0xcc,0x00,0x00, 7, // 0x79 'y' 0x00,0x00,0x00,0xcc,0xcc,0xcc,0xcc,0x7c,0x0c,0x18,0xf0, 7, // 0x7a 'z' 0x00,0x00,0x00,0xfc,0x98,0x30,0x60,0xc4,0xfc,0x00,0x00, 7, // 0x7b '{' 0x1c,0x30,0x30,0x30,0xe0,0x30,0x30,0x30,0x1c,0x00,0x00, 7, // 0x7c '|' 0x30,0x30,0x30,0x30,0x00,0x30,0x30,0x30,0x30,0x00,0x00, 7, // 0x7d '}' 0xe0,0x30,0x30,0x30,0x1c,0x30,0x30,0x30,0xe0,0x00,0x00, 7, // 0x7e '~' 0x00,0x34,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x7f '' 0x00,0x00,0x00,0x30,0x78,0xcc,0xcc,0xfc,0x00,0x00,0x00, 0 }; const int8u gse7x15[] = { 15, 0, 32, 128-32, 0x00,0x00,0x10,0x00,0x20,0x00,0x30,0x00,0x40,0x00,0x50,0x00,0x60,0x00,0x70,0x00,0x80,0x00, 0x90,0x00,0xa0,0x00,0xb0,0x00,0xc0,0x00,0xd0,0x00,0xe0,0x00,0xf0,0x00,0x00,0x01,0x10,0x01, 0x20,0x01,0x30,0x01,0x40,0x01,0x50,0x01,0x60,0x01,0x70,0x01,0x80,0x01,0x90,0x01,0xa0,0x01, 0xb0,0x01,0xc0,0x01,0xd0,0x01,0xe0,0x01,0xf0,0x01,0x00,0x02,0x10,0x02,0x20,0x02,0x30,0x02, 0x40,0x02,0x50,0x02,0x60,0x02,0x70,0x02,0x80,0x02,0x90,0x02,0xa0,0x02,0xb0,0x02,0xc0,0x02, 0xd0,0x02,0xe0,0x02,0xf0,0x02,0x00,0x03,0x10,0x03,0x20,0x03,0x30,0x03,0x40,0x03,0x50,0x03, 0x60,0x03,0x70,0x03,0x80,0x03,0x90,0x03,0xa0,0x03,0xb0,0x03,0xc0,0x03,0xd0,0x03,0xe0,0x03, 0xf0,0x03,0x00,0x04,0x10,0x04,0x20,0x04,0x30,0x04,0x40,0x04,0x50,0x04,0x60,0x04,0x70,0x04, 0x80,0x04,0x90,0x04,0xa0,0x04,0xb0,0x04,0xc0,0x04,0xd0,0x04,0xe0,0x04,0xf0,0x04,0x00,0x05, 0x10,0x05,0x20,0x05,0x30,0x05,0x40,0x05,0x50,0x05,0x60,0x05,0x70,0x05,0x80,0x05,0x90,0x05, 0xa0,0x05,0xb0,0x05,0xc0,0x05,0xd0,0x05,0xe0,0x05,0xf0,0x05, 7, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x21 '!' 0x00,0x00,0x10,0x38,0x38,0x38,0x38,0x10,0x10,0x00,0x10,0x10,0x00,0x00,0x00, 7, // 0x22 '"' 0x00,0x00,0x24,0x24,0x24,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x23 '#' 0x00,0x00,0x48,0x48,0x48,0xfc,0x48,0x48,0xfc,0x48,0x48,0x48,0x00,0x00,0x00, 7, // 0x24 '$' 0x00,0x00,0x10,0x38,0x54,0x50,0x38,0x14,0x54,0x54,0x38,0x10,0x00,0x00,0x00, 7, // 0x25 '%' 0x00,0x00,0x44,0x44,0x08,0x08,0x10,0x10,0x20,0x20,0x44,0x44,0x00,0x00,0x00, 7, // 0x26 '&' 0x00,0x00,0x00,0x30,0x48,0x48,0x30,0x60,0x94,0x98,0x90,0x6c,0x00,0x00,0x00, 7, // 0x27 ''' 0x00,0x00,0x20,0x20,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x28 '(' 0x00,0x04,0x08,0x10,0x20,0x20,0x20,0x20,0x20,0x10,0x08,0x04,0x00,0x00,0x00, 7, // 0x29 ')' 0x00,0x40,0x20,0x10,0x08,0x08,0x08,0x08,0x08,0x10,0x20,0x40,0x00,0x00,0x00, 7, // 0x2a '*' 0x00,0x00,0x00,0x00,0x00,0x20,0xa8,0x70,0xa8,0x20,0x00,0x00,0x00,0x00,0x00, 7, // 0x2b '+' 0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x7c,0x10,0x10,0x10,0x00,0x00,0x00,0x00, 7, // 0x2c ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x60,0x00, 7, // 0x2d '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x2e '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00, 7, // 0x2f '/' 0x00,0x00,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x00,0x00,0x00, 7, // 0x30 '0' 0x00,0x00,0x38,0x44,0x44,0x4c,0x54,0x64,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x31 '1' 0x00,0x00,0x10,0x10,0x30,0x10,0x10,0x10,0x10,0x10,0x10,0x7c,0x00,0x00,0x00, 7, // 0x32 '2' 0x00,0x00,0x38,0x44,0x44,0x04,0x08,0x10,0x20,0x40,0x44,0x7c,0x00,0x00,0x00, 7, // 0x33 '3' 0x00,0x00,0x7c,0x44,0x08,0x10,0x38,0x04,0x04,0x04,0x44,0x38,0x00,0x00,0x00, 7, // 0x34 '4' 0x00,0x00,0x08,0x10,0x20,0x40,0x48,0x48,0x7c,0x08,0x08,0x1c,0x00,0x00,0x00, 7, // 0x35 '5' 0x00,0x00,0x7c,0x40,0x40,0x40,0x78,0x04,0x04,0x04,0x44,0x38,0x00,0x00,0x00, 7, // 0x36 '6' 0x00,0x00,0x18,0x20,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x37 '7' 0x00,0x00,0x7c,0x44,0x04,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x00,0x00,0x00, 7, // 0x38 '8' 0x00,0x00,0x38,0x44,0x44,0x44,0x38,0x44,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x39 '9' 0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x3c,0x04,0x04,0x08,0x30,0x00,0x00,0x00, 7, // 0x3a ':' 0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00, 7, // 0x3b ';' 0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x30,0x30,0x60,0x00,0x00, 7, // 0x3c '<' 0x00,0x00,0x00,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x00,0x00,0x00, 7, // 0x3d '=' 0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x3e '>' 0x00,0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x00,0x00,0x00, 7, // 0x3f '?' 0x00,0x00,0x78,0x84,0x84,0x84,0x08,0x10,0x20,0x20,0x00,0x20,0x00,0x00,0x00, 7, // 0x40 '@' 0x00,0x00,0x00,0x30,0x48,0x04,0x34,0x54,0x54,0x54,0x54,0x28,0x00,0x00,0x00, 7, // 0x41 'A' 0x00,0x00,0x10,0x28,0x44,0x44,0x44,0x7c,0x44,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x42 'B' 0x00,0x00,0x78,0x44,0x44,0x44,0x78,0x44,0x44,0x44,0x44,0x78,0x00,0x00,0x00, 7, // 0x43 'C' 0x00,0x00,0x38,0x44,0x44,0x40,0x40,0x40,0x40,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x44 'D' 0x00,0x00,0x70,0x48,0x44,0x44,0x44,0x44,0x44,0x44,0x48,0x70,0x00,0x00,0x00, 7, // 0x45 'E' 0x00,0x00,0x7c,0x40,0x40,0x40,0x70,0x40,0x40,0x40,0x40,0x7c,0x00,0x00,0x00, 7, // 0x46 'F' 0x00,0x00,0x7c,0x40,0x40,0x40,0x70,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 7, // 0x47 'G' 0x00,0x00,0x38,0x44,0x40,0x40,0x40,0x5c,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x48 'H' 0x00,0x00,0x44,0x44,0x44,0x44,0x7c,0x44,0x44,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x49 'I' 0x00,0x00,0x38,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00,0x00, 7, // 0x4a 'J' 0x00,0x00,0x1c,0x08,0x08,0x08,0x08,0x08,0x08,0x48,0x48,0x30,0x00,0x00,0x00, 7, // 0x4b 'K' 0x00,0x00,0x44,0x44,0x48,0x50,0x60,0x50,0x48,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x4c 'L' 0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7c,0x00,0x00,0x00, 7, // 0x4d 'M' 0x00,0x00,0x44,0x6c,0x54,0x54,0x44,0x44,0x44,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x4e 'N' 0x00,0x00,0x44,0x44,0x44,0x64,0x54,0x4c,0x44,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x4f 'O' 0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x50 'P' 0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x78,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 7, // 0x51 'Q' 0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x44,0x54,0x48,0x34,0x00,0x00,0x00, 7, // 0x52 'R' 0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x78,0x50,0x48,0x44,0x44,0x00,0x00,0x00, 7, // 0x53 'S' 0x00,0x00,0x38,0x44,0x44,0x40,0x38,0x04,0x04,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x54 'T' 0x00,0x00,0x7c,0x54,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00, 7, // 0x55 'U' 0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x56 'V' 0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x28,0x28,0x10,0x10,0x00,0x00,0x00, 7, // 0x57 'W' 0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x54,0x54,0x6c,0x44,0x00,0x00,0x00, 7, // 0x58 'X' 0x00,0x00,0x44,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x59 'Y' 0x00,0x00,0x44,0x44,0x44,0x44,0x28,0x10,0x10,0x10,0x10,0x38,0x00,0x00,0x00, 7, // 0x5a 'Z' 0x00,0x00,0x7c,0x04,0x04,0x08,0x10,0x20,0x40,0x40,0x40,0x7c,0x00,0x00,0x00, 7, // 0x5b '[' 0x00,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x00,0x00, 7, // 0x5c '\' 0x00,0x00,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x00,0x00,0x00, 7, // 0x5d ']' 0x00,0x38,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x38,0x00,0x00, 7, // 0x5e '^' 0x00,0x10,0x28,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x5f '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00, 7, // 0x60 '`' 0x00,0x20,0x20,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x61 'a' 0x00,0x00,0x00,0x00,0x38,0x44,0x04,0x3c,0x44,0x44,0x44,0x3a,0x00,0x00,0x00, 7, // 0x62 'b' 0x00,0x00,0x40,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x44,0x78,0x00,0x00,0x00, 7, // 0x63 'c' 0x00,0x00,0x00,0x00,0x38,0x44,0x40,0x40,0x40,0x40,0x44,0x38,0x00,0x00,0x00, 7, // 0x64 'd' 0x00,0x00,0x04,0x04,0x04,0x3c,0x44,0x44,0x44,0x44,0x44,0x3a,0x00,0x00,0x00, 7, // 0x65 'e' 0x00,0x00,0x00,0x00,0x38,0x44,0x44,0x7c,0x40,0x40,0x44,0x38,0x00,0x00,0x00, 7, // 0x66 'f' 0x00,0x00,0x18,0x24,0x20,0x70,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00,0x00, 7, // 0x67 'g' 0x00,0x00,0x00,0x00,0x3a,0x44,0x44,0x44,0x44,0x44,0x3c,0x04,0x44,0x38,0x00, 7, // 0x68 'h' 0x00,0x00,0x40,0x40,0x40,0x58,0x64,0x44,0x44,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x69 'i' 0x00,0x00,0x10,0x10,0x00,0x30,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00,0x00, 7, // 0x6a 'j' 0x00,0x00,0x08,0x08,0x00,0x18,0x08,0x08,0x08,0x08,0x08,0x48,0x48,0x30,0x00, 7, // 0x6b 'k' 0x00,0x00,0x40,0x40,0x44,0x44,0x48,0x50,0x60,0x50,0x48,0x44,0x00,0x00,0x00, 7, // 0x6c 'l' 0x00,0x00,0x30,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00,0x00, 7, // 0x6d 'm' 0x00,0x00,0x00,0x00,0xa8,0x54,0x54,0x54,0x54,0x54,0x54,0x54,0x00,0x00,0x00, 7, // 0x6e 'n' 0x00,0x00,0x00,0x00,0xb8,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x6f 'o' 0x00,0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x70 'p' 0x00,0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x44,0x78,0x40,0x40,0x40,0x00, 7, // 0x71 'q' 0x00,0x00,0x00,0x00,0x3c,0x44,0x44,0x44,0x44,0x44,0x3c,0x04,0x04,0x04,0x00, 7, // 0x72 'r' 0x00,0x00,0x00,0x00,0x58,0x64,0x44,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 7, // 0x73 's' 0x00,0x00,0x00,0x00,0x38,0x44,0x40,0x38,0x04,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x74 't' 0x00,0x00,0x20,0x20,0x20,0x70,0x20,0x20,0x20,0x20,0x24,0x18,0x00,0x00,0x00, 7, // 0x75 'u' 0x00,0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x3a,0x00,0x00,0x00, 7, // 0x76 'v' 0x00,0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x28,0x28,0x10,0x10,0x00,0x00,0x00, 7, // 0x77 'w' 0x00,0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x54,0x54,0x6c,0x44,0x00,0x00,0x00, 7, // 0x78 'x' 0x00,0x00,0x00,0x00,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x79 'y' 0x00,0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x3c,0x04,0x08,0x70,0x00, 7, // 0x7a 'z' 0x00,0x00,0x00,0x00,0x7c,0x04,0x08,0x10,0x20,0x40,0x40,0x7c,0x00,0x00,0x00, 7, // 0x7b '{' 0x00,0x0c,0x10,0x10,0x10,0x10,0x10,0x60,0x10,0x10,0x10,0x10,0x0c,0x00,0x00, 7, // 0x7c '|' 0x00,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x00,0x00, 7, // 0x7d '}' 0x00,0x60,0x10,0x10,0x10,0x10,0x10,0x0c,0x10,0x10,0x10,0x10,0x60,0x00,0x00, 7, // 0x7e '~' 0x00,0x00,0x64,0x98,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x7f '' 0x00,0x00,0x00,0x00,0x00,0x10,0x28,0x44,0x44,0x7c,0x00,0x00,0x00,0x00,0x00, 0 }; const int8u gse7x15_bold[] = { 15, 0, 32, 128-32, 0x00,0x00,0x10,0x00,0x20,0x00,0x30,0x00,0x40,0x00,0x50,0x00,0x60,0x00,0x70,0x00,0x80,0x00, 0x90,0x00,0xa0,0x00,0xb0,0x00,0xc0,0x00,0xd0,0x00,0xe0,0x00,0xf0,0x00,0x00,0x01,0x10,0x01, 0x20,0x01,0x30,0x01,0x40,0x01,0x50,0x01,0x60,0x01,0x70,0x01,0x80,0x01,0x90,0x01,0xa0,0x01, 0xb0,0x01,0xc0,0x01,0xd0,0x01,0xe0,0x01,0xf0,0x01,0x00,0x02,0x10,0x02,0x20,0x02,0x30,0x02, 0x40,0x02,0x50,0x02,0x60,0x02,0x70,0x02,0x80,0x02,0x90,0x02,0xa0,0x02,0xb0,0x02,0xc0,0x02, 0xd0,0x02,0xe0,0x02,0xf0,0x02,0x00,0x03,0x10,0x03,0x20,0x03,0x30,0x03,0x40,0x03,0x50,0x03, 0x60,0x03,0x70,0x03,0x80,0x03,0x90,0x03,0xa0,0x03,0xb0,0x03,0xc0,0x03,0xd0,0x03,0xe0,0x03, 0xf0,0x03,0x00,0x04,0x10,0x04,0x20,0x04,0x30,0x04,0x40,0x04,0x50,0x04,0x60,0x04,0x70,0x04, 0x80,0x04,0x90,0x04,0xa0,0x04,0xb0,0x04,0xc0,0x04,0xd0,0x04,0xe0,0x04,0xf0,0x04,0x00,0x05, 0x10,0x05,0x20,0x05,0x30,0x05,0x40,0x05,0x50,0x05,0x60,0x05,0x70,0x05,0x80,0x05,0x90,0x05, 0xa0,0x05,0xb0,0x05,0xc0,0x05,0xd0,0x05,0xe0,0x05,0xf0,0x05, 7, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x21 '!' 0x00,0x00,0x00,0x30,0x78,0x78,0x78,0x30,0x30,0x00,0x30,0x30,0x00,0x00,0x00, 7, // 0x22 '"' 0x00,0x00,0x6c,0x6c,0x6c,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x23 '#' 0x00,0x00,0x48,0x48,0x48,0xfc,0x48,0x48,0xfc,0x48,0x48,0x48,0x00,0x00,0x00, 7, // 0x24 '$' 0x00,0x30,0x30,0x78,0xcc,0xe0,0x70,0x38,0x1c,0xcc,0x78,0x30,0x30,0x00,0x00, 7, // 0x25 '%' 0x00,0x00,0x00,0x64,0x6c,0x08,0x18,0x10,0x30,0x20,0x6c,0x4c,0x00,0x00,0x00, 7, // 0x26 '&' 0x00,0x00,0x00,0x30,0x58,0x58,0x30,0x74,0xdc,0xd8,0xd8,0x6c,0x00,0x00,0x00, 7, // 0x27 ''' 0x00,0x00,0x30,0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x28 '(' 0x00,0x0c,0x18,0x30,0x60,0x60,0x60,0x60,0x60,0x30,0x18,0x0c,0x00,0x00,0x00, 7, // 0x29 ')' 0x00,0xc0,0x60,0x30,0x18,0x18,0x18,0x18,0x18,0x30,0x60,0xc0,0x00,0x00,0x00, 7, // 0x2a '*' 0x00,0x00,0x00,0x00,0x00,0x20,0xa8,0x70,0xa8,0x20,0x00,0x00,0x00,0x00,0x00, 7, // 0x2b '+' 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0xfc,0x30,0x30,0x00,0x00,0x00,0x00,0x00, 7, // 0x2c ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x60,0x00, 7, // 0x2d '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x2e '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00, 7, // 0x2f '/' 0x00,0x00,0x0c,0x0c,0x18,0x18,0x30,0x30,0x60,0x60,0xc0,0xc0,0x00,0x00,0x00, 7, // 0x30 '0' 0x00,0x00,0x78,0xcc,0xcc,0xcc,0xdc,0xec,0xcc,0xcc,0xcc,0x78,0x00,0x00,0x00, 7, // 0x31 '1' 0x00,0x00,0x30,0x30,0x70,0xf0,0x30,0x30,0x30,0x30,0x30,0xfc,0x00,0x00,0x00, 7, // 0x32 '2' 0x00,0x00,0x78,0xcc,0xcc,0x0c,0x18,0x30,0x60,0xc0,0xcc,0xfc,0x00,0x00,0x00, 7, // 0x33 '3' 0x00,0x00,0xfc,0x8c,0x18,0x30,0x78,0x0c,0x0c,0x0c,0xcc,0x78,0x00,0x00,0x00, 7, // 0x34 '4' 0x00,0x00,0x18,0x30,0x60,0xc8,0xd8,0xd8,0xfc,0x18,0x18,0x3c,0x00,0x00,0x00, 7, // 0x35 '5' 0x00,0x00,0xfc,0xc0,0xc0,0xc0,0xf8,0x0c,0x0c,0x0c,0xcc,0x78,0x00,0x00,0x00, 7, // 0x36 '6' 0x00,0x00,0x38,0x60,0xc0,0xc0,0xf8,0xcc,0xcc,0xcc,0xcc,0x78,0x00,0x00,0x00, 7, // 0x37 '7' 0x00,0x00,0xfc,0x8c,0x0c,0x0c,0x18,0x18,0x30,0x30,0x30,0x30,0x00,0x00,0x00, 7, // 0x38 '8' 0x00,0x00,0x78,0xcc,0xcc,0xcc,0x78,0xcc,0xcc,0xcc,0xcc,0x78,0x00,0x00,0x00, 7, // 0x39 '9' 0x00,0x00,0x78,0xcc,0xcc,0xcc,0xcc,0x7c,0x0c,0x0c,0x18,0x70,0x00,0x00,0x00, 7, // 0x3a ':' 0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00, 7, // 0x3b ';' 0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x60,0x00, 7, // 0x3c '<' 0x00,0x00,0x00,0x0c,0x18,0x30,0x60,0xc0,0x60,0x30,0x18,0x0c,0x00,0x00,0x00, 7, // 0x3d '=' 0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0xfc,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x3e '>' 0x00,0x00,0x00,0xc0,0x60,0x30,0x18,0x0c,0x18,0x30,0x60,0xc0,0x00,0x00,0x00, 7, // 0x3f '?' 0x00,0x00,0x78,0xcc,0xcc,0x18,0x30,0x30,0x30,0x00,0x30,0x30,0x00,0x00,0x00, 7, // 0x40 '@' 0x00,0x00,0x00,0x70,0x88,0x04,0x74,0xb4,0xb4,0xb4,0xb4,0x68,0x00,0x00,0x00, 7, // 0x41 'A' 0x00,0x00,0x30,0x78,0xcc,0xcc,0xcc,0xfc,0xcc,0xcc,0xcc,0xcc,0x00,0x00,0x00, 7, // 0x42 'B' 0x00,0x00,0xf8,0xcc,0xcc,0xcc,0xf8,0xcc,0xcc,0xcc,0xcc,0xf8,0x00,0x00,0x00, 7, // 0x43 'C' 0x00,0x00,0x78,0xcc,0xc4,0xc0,0xc0,0xc0,0xc0,0xc4,0xcc,0x78,0x00,0x00,0x00, 7, // 0x44 'D' 0x00,0x00,0xf0,0xd8,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xd8,0xf0,0x00,0x00,0x00, 7, // 0x45 'E' 0x00,0x00,0xfc,0xc4,0xc0,0xd0,0xf0,0xd0,0xc0,0xc0,0xc4,0xfc,0x00,0x00,0x00, 7, // 0x46 'F' 0x00,0x00,0xfc,0xc4,0xc0,0xd0,0xf0,0xd0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00, 7, // 0x47 'G' 0x00,0x00,0x78,0xcc,0xc0,0xc0,0xc0,0xdc,0xcc,0xcc,0xcc,0x78,0x00,0x00,0x00, 7, // 0x48 'H' 0x00,0x00,0xcc,0xcc,0xcc,0xcc,0xfc,0xcc,0xcc,0xcc,0xcc,0xcc,0x00,0x00,0x00, 7, // 0x49 'I' 0x00,0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00, 7, // 0x4a 'J' 0x00,0x00,0x3c,0x18,0x18,0x18,0x18,0x18,0x18,0xd8,0xd8,0x70,0x00,0x00,0x00, 7, // 0x4b 'K' 0x00,0x00,0xcc,0xcc,0xd8,0xd8,0xf0,0xd8,0xd8,0xcc,0xcc,0xcc,0x00,0x00,0x00, 7, // 0x4c 'L' 0x00,0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc4,0xfc,0x00,0x00,0x00, 7, // 0x4d 'M' 0x00,0x00,0x84,0xcc,0xfc,0xb4,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x00,0x00,0x00, 7, // 0x4e 'N' 0x00,0x00,0xcc,0xcc,0xcc,0xec,0xfc,0xdc,0xcc,0xcc,0xcc,0xcc,0x00,0x00,0x00, 7, // 0x4f 'O' 0x00,0x00,0x78,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x78,0x00,0x00,0x00, 7, // 0x50 'P' 0x00,0x00,0xf8,0xcc,0xcc,0xcc,0xcc,0xf8,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00, 7, // 0x51 'Q' 0x00,0x00,0x78,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xdc,0x78,0x18,0x0c,0x00,0x00, 7, // 0x52 'R' 0x00,0x00,0xf8,0xcc,0xcc,0xcc,0xcc,0xf8,0xd8,0xcc,0xcc,0xcc,0x00,0x00,0x00, 7, // 0x53 'S' 0x00,0x00,0x78,0xcc,0xcc,0xe0,0x70,0x38,0x1c,0xcc,0xcc,0x78,0x00,0x00,0x00, 7, // 0x54 'T' 0x00,0x00,0xfc,0xb4,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x00,0x00, 7, // 0x55 'U' 0x00,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x78,0x00,0x00,0x00, 7, // 0x56 'V' 0x00,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x78,0x30,0x00,0x00,0x00, 7, // 0x57 'W' 0x00,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xb4,0xfc,0xcc,0x84,0x00,0x00,0x00, 7, // 0x58 'X' 0x00,0x00,0xcc,0xcc,0xcc,0x78,0x30,0x78,0xcc,0xcc,0xcc,0xcc,0x00,0x00,0x00, 7, // 0x59 'Y' 0x00,0x00,0xcc,0xcc,0xcc,0xcc,0x78,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00, 7, // 0x5a 'Z' 0x00,0x00,0xfc,0x8c,0x0c,0x18,0x30,0x60,0xc0,0xc0,0xc4,0xfc,0x00,0x00,0x00, 7, // 0x5b '[' 0x00,0x78,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x78,0x00,0x00, 7, // 0x5c '\' 0x00,0x00,0xc0,0xc0,0x60,0x60,0x30,0x30,0x18,0x18,0x0c,0x0c,0x00,0x00,0x00, 7, // 0x5d ']' 0x00,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x78,0x00,0x00, 7, // 0x5e '^' 0x00,0x10,0x38,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x5f '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x00,0x00,0x00, 7, // 0x60 '`' 0x00,0x30,0x30,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x61 'a' 0x00,0x00,0x00,0x00,0x70,0xd8,0x18,0x78,0xd8,0xd8,0xd8,0x6c,0x00,0x00,0x00, 7, // 0x62 'b' 0x00,0x00,0x60,0x60,0x60,0x78,0x6c,0x6c,0x6c,0x6c,0x6c,0x78,0x00,0x00,0x00, 7, // 0x63 'c' 0x00,0x00,0x00,0x00,0x78,0xcc,0xc0,0xc0,0xc0,0xc0,0xcc,0x78,0x00,0x00,0x00, 7, // 0x64 'd' 0x00,0x00,0x18,0x18,0x18,0x78,0xd8,0xd8,0xd8,0xd8,0xd8,0x6c,0x00,0x00,0x00, 7, // 0x65 'e' 0x00,0x00,0x00,0x00,0x78,0xcc,0xcc,0xfc,0xc0,0xc0,0xcc,0x78,0x00,0x00,0x00, 7, // 0x66 'f' 0x00,0x00,0x30,0x68,0x60,0x60,0xf0,0x60,0x60,0x60,0x60,0xf0,0x00,0x00,0x00, 7, // 0x67 'g' 0x00,0x00,0x00,0x00,0x6c,0xd8,0xd8,0xd8,0xd8,0xd8,0x78,0x18,0xd8,0x70,0x00, 7, // 0x68 'h' 0x00,0x00,0xc0,0xc0,0xc0,0xd8,0xec,0xcc,0xcc,0xcc,0xcc,0xcc,0x00,0x00,0x00, 7, // 0x69 'i' 0x00,0x00,0x30,0x30,0x00,0x70,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00, 7, // 0x6a 'j' 0x00,0x00,0x18,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0xd8,0xd8,0x70,0x00, 7, // 0x6b 'k' 0x00,0x00,0xc0,0xc0,0xcc,0xcc,0xcc,0xd8,0xf0,0xd8,0xcc,0xcc,0x00,0x00,0x00, 7, // 0x6c 'l' 0x00,0x00,0x70,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00, 7, // 0x6d 'm' 0x00,0x00,0x00,0x00,0xe8,0xfc,0xd4,0xd4,0xd4,0xc4,0xc4,0xc4,0x00,0x00,0x00, 7, // 0x6e 'n' 0x00,0x00,0x00,0x00,0xd8,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x00,0x00,0x00, 7, // 0x6f 'o' 0x00,0x00,0x00,0x00,0x78,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x78,0x00,0x00,0x00, 7, // 0x70 'p' 0x00,0x00,0x00,0x00,0xf8,0xcc,0xcc,0xcc,0xcc,0xcc,0xf8,0xc0,0xc0,0xc0,0x00, 7, // 0x71 'q' 0x00,0x00,0x00,0x00,0x7c,0xcc,0xcc,0xcc,0xcc,0xcc,0x7c,0x0c,0x0c,0x0c,0x00, 7, // 0x72 'r' 0x00,0x00,0x00,0x00,0xd8,0xec,0xcc,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00, 7, // 0x73 's' 0x00,0x00,0x00,0x00,0x78,0xcc,0xe0,0x70,0x38,0x1c,0xcc,0x78,0x00,0x00,0x00, 7, // 0x74 't' 0x00,0x00,0x20,0x60,0x60,0xf0,0x60,0x60,0x60,0x60,0x6c,0x38,0x00,0x00,0x00, 7, // 0x75 'u' 0x00,0x00,0x00,0x00,0xd8,0xd8,0xd8,0xd8,0xd8,0xd8,0xd8,0x6c,0x00,0x00,0x00, 7, // 0x76 'v' 0x00,0x00,0x00,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x78,0x30,0x00,0x00,0x00, 7, // 0x77 'w' 0x00,0x00,0x00,0x00,0xcc,0xcc,0xcc,0xcc,0xb4,0xfc,0xcc,0x84,0x00,0x00,0x00, 7, // 0x78 'x' 0x00,0x00,0x00,0x00,0xcc,0xcc,0x78,0x30,0x78,0xcc,0xcc,0xcc,0x00,0x00,0x00, 7, // 0x79 'y' 0x00,0x00,0x00,0x00,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0x7c,0x0c,0x18,0xf0,0x00, 7, // 0x7a 'z' 0x00,0x00,0x00,0x00,0xfc,0x8c,0x18,0x30,0x60,0xc0,0xc4,0xfc,0x00,0x00,0x00, 7, // 0x7b '{' 0x00,0x1c,0x30,0x30,0x30,0x30,0x30,0xe0,0x30,0x30,0x30,0x30,0x1c,0x00,0x00, 7, // 0x7c '|' 0x00,0x30,0x30,0x30,0x30,0x30,0x00,0x00,0x30,0x30,0x30,0x30,0x30,0x00,0x00, 7, // 0x7d '}' 0x00,0xe0,0x30,0x30,0x30,0x30,0x30,0x1c,0x30,0x30,0x30,0x30,0xe0,0x00,0x00, 7, // 0x7e '~' 0x00,0x00,0x34,0x58,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x7f '' 0x00,0x00,0x00,0x00,0x00,0x30,0x78,0xcc,0xcc,0xfc,0x00,0x00,0x00,0x00,0x00, 0 }; const int8u gse8x16[] = { 16, 0, 32, 128-32, 0x00,0x00,0x11,0x00,0x22,0x00,0x33,0x00,0x44,0x00,0x55,0x00,0x66,0x00,0x77,0x00,0x88,0x00, 0x99,0x00,0xaa,0x00,0xbb,0x00,0xcc,0x00,0xdd,0x00,0xee,0x00,0xff,0x00,0x10,0x01,0x21,0x01, 0x32,0x01,0x43,0x01,0x54,0x01,0x65,0x01,0x76,0x01,0x87,0x01,0x98,0x01,0xa9,0x01,0xba,0x01, 0xcb,0x01,0xdc,0x01,0xed,0x01,0xfe,0x01,0x0f,0x02,0x20,0x02,0x31,0x02,0x42,0x02,0x53,0x02, 0x64,0x02,0x75,0x02,0x86,0x02,0x97,0x02,0xa8,0x02,0xb9,0x02,0xca,0x02,0xdb,0x02,0xec,0x02, 0xfd,0x02,0x0e,0x03,0x1f,0x03,0x30,0x03,0x41,0x03,0x52,0x03,0x63,0x03,0x74,0x03,0x85,0x03, 0x96,0x03,0xa7,0x03,0xb8,0x03,0xc9,0x03,0xda,0x03,0xeb,0x03,0xfc,0x03,0x0d,0x04,0x1e,0x04, 0x2f,0x04,0x40,0x04,0x51,0x04,0x62,0x04,0x73,0x04,0x84,0x04,0x95,0x04,0xa6,0x04,0xb7,0x04, 0xc8,0x04,0xd9,0x04,0xea,0x04,0xfb,0x04,0x0c,0x05,0x1d,0x05,0x2e,0x05,0x3f,0x05,0x50,0x05, 0x61,0x05,0x72,0x05,0x83,0x05,0x94,0x05,0xa5,0x05,0xb6,0x05,0xc7,0x05,0xd8,0x05,0xe9,0x05, 0xfa,0x05,0x0b,0x06,0x1c,0x06,0x2d,0x06,0x3e,0x06,0x4f,0x06, 8, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x21 '!' 0x00,0x00,0x10,0x38,0x38,0x38,0x38,0x10,0x10,0x00,0x10,0x10,0x00,0x00,0x00,0x00, 8, // 0x22 '"' 0x00,0x24,0x24,0x24,0x24,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x23 '#' 0x00,0x00,0x24,0x24,0x24,0x7e,0x24,0x24,0x7e,0x24,0x24,0x24,0x00,0x00,0x00,0x00, 8, // 0x24 '$' 0x00,0x14,0x14,0x3e,0x55,0x54,0x54,0x3e,0x15,0x15,0x55,0x3e,0x14,0x14,0x00,0x00, 8, // 0x25 '%' 0x00,0x00,0x32,0x56,0x6c,0x04,0x08,0x08,0x10,0x13,0x25,0x26,0x00,0x00,0x00,0x00, 8, // 0x26 '&' 0x00,0x00,0x18,0x24,0x24,0x24,0x18,0x28,0x45,0x46,0x44,0x3b,0x00,0x00,0x00,0x00, 8, // 0x27 ''' 0x00,0x00,0x08,0x08,0x08,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x28 '(' 0x00,0x04,0x08,0x10,0x10,0x20,0x20,0x20,0x20,0x10,0x10,0x08,0x04,0x00,0x00,0x00, 8, // 0x29 ')' 0x00,0x10,0x08,0x04,0x04,0x02,0x02,0x02,0x02,0x04,0x04,0x08,0x10,0x00,0x00,0x00, 8, // 0x2a '*' 0x00,0x00,0x00,0x00,0x66,0x24,0x18,0xff,0x18,0x24,0x66,0x00,0x00,0x00,0x00,0x00, 8, // 0x2b '+' 0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x7f,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00, 8, // 0x2c ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x30,0x20,0x00, 8, // 0x2d '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x2e '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00, 8, // 0x2f '/' 0x00,0x02,0x02,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x00,0x00,0x00, 8, // 0x30 '0' 0x00,0x00,0x3c,0x42,0x42,0x46,0x4a,0x52,0x62,0x42,0x42,0x3c,0x00,0x00,0x00,0x00, 8, // 0x31 '1' 0x00,0x00,0x08,0x08,0x18,0x38,0x08,0x08,0x08,0x08,0x08,0x3e,0x00,0x00,0x00,0x00, 8, // 0x32 '2' 0x00,0x00,0x3c,0x42,0x42,0x02,0x04,0x08,0x10,0x20,0x42,0x7e,0x00,0x00,0x00,0x00, 8, // 0x33 '3' 0x00,0x00,0x7e,0x42,0x04,0x08,0x1c,0x02,0x02,0x02,0x42,0x3c,0x00,0x00,0x00,0x00, 8, // 0x34 '4' 0x00,0x00,0x04,0x08,0x10,0x24,0x44,0x44,0x7e,0x04,0x04,0x0e,0x00,0x00,0x00,0x00, 8, // 0x35 '5' 0x00,0x00,0x7e,0x42,0x40,0x40,0x7c,0x02,0x02,0x02,0x42,0x3c,0x00,0x00,0x00,0x00, 8, // 0x36 '6' 0x00,0x00,0x1c,0x20,0x40,0x40,0x7c,0x42,0x42,0x42,0x42,0x3c,0x00,0x00,0x00,0x00, 8, // 0x37 '7' 0x00,0x00,0x7e,0x42,0x42,0x02,0x04,0x08,0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00, 8, // 0x38 '8' 0x00,0x00,0x3c,0x42,0x42,0x42,0x3c,0x42,0x42,0x42,0x42,0x3c,0x00,0x00,0x00,0x00, 8, // 0x39 '9' 0x00,0x00,0x3c,0x42,0x42,0x42,0x42,0x3e,0x02,0x02,0x04,0x38,0x00,0x00,0x00,0x00, 8, // 0x3a ':' 0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x3b ';' 0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x60,0x40,0x00, 8, // 0x3c '<' 0x00,0x00,0x00,0x02,0x04,0x08,0x10,0x20,0x10,0x08,0x04,0x02,0x00,0x00,0x00,0x00, 8, // 0x3d '=' 0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x3e '>' 0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x20,0x00,0x00,0x00,0x00, 8, // 0x3f '?' 0x00,0x00,0x3c,0x42,0x42,0x42,0x04,0x08,0x08,0x00,0x08,0x08,0x00,0x00,0x00,0x00, 8, // 0x40 '@' 0x00,0x00,0x3c,0x42,0x01,0x39,0x49,0x49,0x49,0x49,0x49,0x36,0x00,0x00,0x00,0x00, 8, // 0x41 'A' 0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x7e,0x42,0x42,0x42,0x42,0x00,0x00,0x00,0x00, 8, // 0x42 'B' 0x00,0x00,0x7c,0x22,0x22,0x22,0x3c,0x22,0x22,0x22,0x22,0x7c,0x00,0x00,0x00,0x00, 8, // 0x43 'C' 0x00,0x00,0x3c,0x42,0x42,0x40,0x40,0x40,0x40,0x42,0x42,0x3c,0x00,0x00,0x00,0x00, 8, // 0x44 'D' 0x00,0x00,0x7c,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x7c,0x00,0x00,0x00,0x00, 8, // 0x45 'E' 0x00,0x00,0x7e,0x22,0x20,0x28,0x38,0x28,0x20,0x20,0x22,0x7e,0x00,0x00,0x00,0x00, 8, // 0x46 'F' 0x00,0x00,0x7e,0x22,0x20,0x28,0x38,0x28,0x20,0x20,0x20,0x70,0x00,0x00,0x00,0x00, 8, // 0x47 'G' 0x00,0x00,0x3c,0x42,0x42,0x40,0x40,0x4e,0x42,0x42,0x42,0x3c,0x00,0x00,0x00,0x00, 8, // 0x48 'H' 0x00,0x00,0x42,0x42,0x42,0x42,0x7e,0x42,0x42,0x42,0x42,0x42,0x00,0x00,0x00,0x00, 8, // 0x49 'I' 0x00,0x00,0x1c,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x1c,0x00,0x00,0x00,0x00, 8, // 0x4a 'J' 0x00,0x00,0x0e,0x04,0x04,0x04,0x04,0x04,0x04,0x44,0x44,0x38,0x00,0x00,0x00,0x00, 8, // 0x4b 'K' 0x00,0x00,0x62,0x22,0x24,0x28,0x30,0x28,0x24,0x22,0x22,0x62,0x00,0x00,0x00,0x00, 8, // 0x4c 'L' 0x00,0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x22,0x7e,0x00,0x00,0x00,0x00, 8, // 0x4d 'M' 0x00,0x00,0x41,0x63,0x55,0x49,0x41,0x41,0x41,0x41,0x41,0x41,0x00,0x00,0x00,0x00, 8, // 0x4e 'N' 0x00,0x00,0x42,0x42,0x62,0x52,0x4a,0x46,0x42,0x42,0x42,0x42,0x00,0x00,0x00,0x00, 8, // 0x4f 'O' 0x00,0x00,0x3c,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3c,0x00,0x00,0x00,0x00, 8, // 0x50 'P' 0x00,0x00,0x7c,0x22,0x22,0x22,0x22,0x3c,0x20,0x20,0x20,0x70,0x00,0x00,0x00,0x00, 8, // 0x51 'Q' 0x00,0x00,0x3c,0x42,0x42,0x42,0x42,0x42,0x42,0x4a,0x44,0x3a,0x02,0x00,0x00,0x00, 8, // 0x52 'R' 0x00,0x00,0x7c,0x22,0x22,0x22,0x22,0x3c,0x28,0x24,0x22,0x62,0x00,0x00,0x00,0x00, 8, // 0x53 'S' 0x00,0x00,0x3c,0x42,0x42,0x40,0x30,0x0c,0x02,0x42,0x42,0x3c,0x00,0x00,0x00,0x00, 8, // 0x54 'T' 0x00,0x00,0x7f,0x49,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x1c,0x00,0x00,0x00,0x00, 8, // 0x55 'U' 0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3c,0x00,0x00,0x00,0x00, 8, // 0x56 'V' 0x00,0x00,0x41,0x41,0x41,0x41,0x22,0x22,0x14,0x14,0x08,0x08,0x00,0x00,0x00,0x00, 8, // 0x57 'W' 0x00,0x00,0x41,0x41,0x41,0x41,0x41,0x49,0x49,0x55,0x63,0x41,0x00,0x00,0x00,0x00, 8, // 0x58 'X' 0x00,0x00,0x42,0x42,0x42,0x24,0x18,0x18,0x24,0x42,0x42,0x42,0x00,0x00,0x00,0x00, 8, // 0x59 'Y' 0x00,0x00,0x22,0x22,0x22,0x22,0x14,0x08,0x08,0x08,0x08,0x1c,0x00,0x00,0x00,0x00, 8, // 0x5a 'Z' 0x00,0x00,0x7e,0x42,0x02,0x04,0x08,0x10,0x20,0x40,0x42,0x7e,0x00,0x00,0x00,0x00, 8, // 0x5b '[' 0x00,0x1e,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1e,0x00,0x00,0x00, 8, // 0x5c '\' 0x00,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x00,0x00,0x00, 8, // 0x5d ']' 0x00,0x3c,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x3c,0x00,0x00,0x00, 8, // 0x5e '^' 0x00,0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x5f '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00, 8, // 0x60 '`' 0x00,0x00,0x08,0x08,0x08,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x61 'a' 0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x04,0x3c,0x44,0x44,0x3e,0x00,0x00,0x00,0x00, 8, // 0x62 'b' 0x00,0x00,0x60,0x20,0x20,0x38,0x24,0x22,0x22,0x22,0x22,0x3c,0x00,0x00,0x00,0x00, 8, // 0x63 'c' 0x00,0x00,0x00,0x00,0x00,0x3c,0x42,0x40,0x40,0x40,0x42,0x3c,0x00,0x00,0x00,0x00, 8, // 0x64 'd' 0x00,0x00,0x0c,0x04,0x04,0x1c,0x24,0x44,0x44,0x44,0x44,0x3e,0x00,0x00,0x00,0x00, 8, // 0x65 'e' 0x00,0x00,0x00,0x00,0x00,0x3c,0x42,0x42,0x7e,0x40,0x42,0x3c,0x00,0x00,0x00,0x00, 8, // 0x66 'f' 0x00,0x00,0x0c,0x12,0x10,0x10,0x38,0x10,0x10,0x10,0x10,0x38,0x00,0x00,0x00,0x00, 8, // 0x67 'g' 0x00,0x00,0x00,0x00,0x00,0x3e,0x44,0x44,0x44,0x44,0x44,0x3c,0x04,0x44,0x38,0x00, 8, // 0x68 'h' 0x00,0x00,0x60,0x20,0x20,0x2c,0x32,0x22,0x22,0x22,0x22,0x62,0x00,0x00,0x00,0x00, 8, // 0x69 'i' 0x00,0x00,0x08,0x08,0x00,0x18,0x08,0x08,0x08,0x08,0x08,0x1c,0x00,0x00,0x00,0x00, 8, // 0x6a 'j' 0x00,0x00,0x04,0x04,0x00,0x0c,0x04,0x04,0x04,0x04,0x04,0x44,0x44,0x38,0x00,0x00, 8, // 0x6b 'k' 0x00,0x00,0x60,0x20,0x20,0x22,0x24,0x28,0x38,0x24,0x22,0x62,0x00,0x00,0x00,0x00, 8, // 0x6c 'l' 0x00,0x00,0x18,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x1c,0x00,0x00,0x00,0x00, 8, // 0x6d 'm' 0x00,0x00,0x00,0x00,0x00,0x76,0x49,0x49,0x49,0x49,0x41,0x41,0x00,0x00,0x00,0x00, 8, // 0x6e 'n' 0x00,0x00,0x00,0x00,0x00,0x5c,0x22,0x22,0x22,0x22,0x22,0x22,0x00,0x00,0x00,0x00, 8, // 0x6f 'o' 0x00,0x00,0x00,0x00,0x00,0x3c,0x42,0x42,0x42,0x42,0x42,0x3c,0x00,0x00,0x00,0x00, 8, // 0x70 'p' 0x00,0x00,0x00,0x00,0x00,0x7c,0x22,0x22,0x22,0x22,0x22,0x3c,0x20,0x20,0x70,0x00, 8, // 0x71 'q' 0x00,0x00,0x00,0x00,0x00,0x3e,0x44,0x44,0x44,0x44,0x44,0x3c,0x04,0x04,0x0e,0x00, 8, // 0x72 'r' 0x00,0x00,0x00,0x00,0x00,0x7c,0x22,0x22,0x20,0x20,0x20,0x70,0x00,0x00,0x00,0x00, 8, // 0x73 's' 0x00,0x00,0x00,0x00,0x00,0x3c,0x42,0x40,0x3c,0x02,0x42,0x3c,0x00,0x00,0x00,0x00, 8, // 0x74 't' 0x00,0x00,0x10,0x10,0x10,0x7c,0x10,0x10,0x10,0x10,0x12,0x0c,0x00,0x00,0x00,0x00, 8, // 0x75 'u' 0x00,0x00,0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x3e,0x00,0x00,0x00,0x00, 8, // 0x76 'v' 0x00,0x00,0x00,0x00,0x00,0x41,0x41,0x41,0x41,0x22,0x14,0x08,0x00,0x00,0x00,0x00, 8, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x41,0x41,0x41,0x49,0x49,0x55,0x22,0x00,0x00,0x00,0x00, 8, // 0x78 'x' 0x00,0x00,0x00,0x00,0x00,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x00,0x00,0x00,0x00, 8, // 0x79 'y' 0x00,0x00,0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x42,0x3e,0x02,0x04,0x78,0x00, 8, // 0x7a 'z' 0x00,0x00,0x00,0x00,0x00,0x7e,0x44,0x08,0x10,0x20,0x42,0x7e,0x00,0x00,0x00,0x00, 8, // 0x7b '{' 0x00,0x06,0x08,0x08,0x08,0x08,0x08,0x30,0x08,0x08,0x08,0x08,0x08,0x06,0x00,0x00, 8, // 0x7c '|' 0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x00, 8, // 0x7d '}' 0x00,0x30,0x08,0x08,0x08,0x08,0x08,0x06,0x08,0x08,0x08,0x08,0x08,0x30,0x00,0x00, 8, // 0x7e '~' 0x00,0x00,0x39,0x4e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x7f '' 0x00,0x00,0x00,0x00,0x00,0x08,0x14,0x22,0x41,0x41,0x7f,0x00,0x00,0x00,0x00,0x00, 0 }; const int8u gse8x16_bold[] = { 16, 0, 32, 128-32, 0x00,0x00,0x11,0x00,0x22,0x00,0x33,0x00,0x44,0x00,0x55,0x00,0x66,0x00,0x77,0x00,0x88,0x00, 0x99,0x00,0xaa,0x00,0xbb,0x00,0xcc,0x00,0xdd,0x00,0xee,0x00,0xff,0x00,0x10,0x01,0x21,0x01, 0x32,0x01,0x43,0x01,0x54,0x01,0x65,0x01,0x76,0x01,0x87,0x01,0x98,0x01,0xa9,0x01,0xba,0x01, 0xcb,0x01,0xdc,0x01,0xed,0x01,0xfe,0x01,0x0f,0x02,0x20,0x02,0x31,0x02,0x42,0x02,0x53,0x02, 0x64,0x02,0x75,0x02,0x86,0x02,0x97,0x02,0xa8,0x02,0xb9,0x02,0xca,0x02,0xdb,0x02,0xec,0x02, 0xfd,0x02,0x0e,0x03,0x1f,0x03,0x30,0x03,0x41,0x03,0x52,0x03,0x63,0x03,0x74,0x03,0x85,0x03, 0x96,0x03,0xa7,0x03,0xb8,0x03,0xc9,0x03,0xda,0x03,0xeb,0x03,0xfc,0x03,0x0d,0x04,0x1e,0x04, 0x2f,0x04,0x40,0x04,0x51,0x04,0x62,0x04,0x73,0x04,0x84,0x04,0x95,0x04,0xa6,0x04,0xb7,0x04, 0xc8,0x04,0xd9,0x04,0xea,0x04,0xfb,0x04,0x0c,0x05,0x1d,0x05,0x2e,0x05,0x3f,0x05,0x50,0x05, 0x61,0x05,0x72,0x05,0x83,0x05,0x94,0x05,0xa5,0x05,0xb6,0x05,0xc7,0x05,0xd8,0x05,0xe9,0x05, 0xfa,0x05,0x0b,0x06,0x1c,0x06,0x2d,0x06,0x3e,0x06,0x4f,0x06, 8, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x21 '!' 0x00,0x00,0x18,0x3c,0x3c,0x3c,0x3c,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00, 8, // 0x22 '"' 0x00,0x66,0x66,0x66,0x66,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x23 '#' 0x00,0x00,0x66,0x66,0x66,0xff,0x66,0x66,0xff,0x66,0x66,0x66,0x00,0x00,0x00,0x00, 8, // 0x24 '$' 0x00,0x08,0x08,0x3e,0x6b,0x6b,0x68,0x3e,0x0b,0x6b,0x6b,0x3e,0x08,0x08,0x00,0x00, 8, // 0x25 '%' 0x00,0x00,0x66,0xbe,0xcc,0x0c,0x18,0x18,0x30,0x33,0x65,0x66,0x00,0x00,0x00,0x00, 8, // 0x26 '&' 0x00,0x00,0x1c,0x36,0x36,0x36,0x1c,0x3b,0x6e,0x66,0x66,0x3b,0x00,0x00,0x00,0x00, 8, // 0x27 ''' 0x00,0x00,0x18,0x18,0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x28 '(' 0x00,0x06,0x0c,0x18,0x18,0x30,0x30,0x30,0x30,0x18,0x18,0x0c,0x06,0x00,0x00,0x00, 8, // 0x29 ')' 0x00,0x30,0x18,0x0c,0x0c,0x06,0x06,0x06,0x06,0x0c,0x0c,0x18,0x30,0x00,0x00,0x00, 8, // 0x2a '*' 0x00,0x00,0x00,0x00,0x66,0x24,0x18,0xff,0x18,0x24,0x66,0x00,0x00,0x00,0x00,0x00, 8, // 0x2b '+' 0x00,0x00,0x00,0x00,0x18,0x18,0x18,0xff,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00, 8, // 0x2c ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x30,0x20,0x00, 8, // 0x2d '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x2e '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00, 8, // 0x2f '/' 0x00,0x03,0x03,0x06,0x06,0x0c,0x0c,0x18,0x18,0x30,0x30,0x60,0x60,0x00,0x00,0x00, 8, // 0x30 '0' 0x00,0x00,0x3e,0x63,0x63,0x67,0x6b,0x73,0x63,0x63,0x63,0x3e,0x00,0x00,0x00,0x00, 8, // 0x31 '1' 0x00,0x00,0x0c,0x0c,0x1c,0x3c,0x0c,0x0c,0x0c,0x0c,0x0c,0x3f,0x00,0x00,0x00,0x00, 8, // 0x32 '2' 0x00,0x00,0x3e,0x63,0x63,0x03,0x06,0x0c,0x18,0x30,0x61,0x7f,0x00,0x00,0x00,0x00, 8, // 0x33 '3' 0x00,0x00,0x7f,0x43,0x06,0x0c,0x1e,0x03,0x03,0x03,0x63,0x3e,0x00,0x00,0x00,0x00, 8, // 0x34 '4' 0x00,0x00,0x06,0x0c,0x18,0x32,0x66,0x66,0x7f,0x06,0x06,0x0f,0x00,0x00,0x00,0x00, 8, // 0x35 '5' 0x00,0x00,0x7f,0x61,0x60,0x60,0x7e,0x03,0x03,0x03,0x63,0x3e,0x00,0x00,0x00,0x00, 8, // 0x36 '6' 0x00,0x00,0x1e,0x30,0x60,0x60,0x7e,0x63,0x63,0x63,0x63,0x3e,0x00,0x00,0x00,0x00, 8, // 0x37 '7' 0x00,0x00,0x7f,0x63,0x63,0x03,0x06,0x0c,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00, 8, // 0x38 '8' 0x00,0x00,0x3e,0x63,0x63,0x63,0x3e,0x63,0x63,0x63,0x63,0x3e,0x00,0x00,0x00,0x00, 8, // 0x39 '9' 0x00,0x00,0x3e,0x63,0x63,0x63,0x63,0x3f,0x03,0x03,0x06,0x3c,0x00,0x00,0x00,0x00, 8, // 0x3a ':' 0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00, 8, // 0x3b ';' 0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x60,0x40,0x00, 8, // 0x3c '<' 0x00,0x00,0x00,0x06,0x0c,0x18,0x30,0x60,0x30,0x18,0x0c,0x06,0x00,0x00,0x00,0x00, 8, // 0x3d '=' 0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x3e '>' 0x00,0x00,0x00,0x30,0x18,0x0c,0x06,0x03,0x06,0x0c,0x18,0x30,0x00,0x00,0x00,0x00, 8, // 0x3f '?' 0x00,0x00,0x3e,0x63,0x63,0x63,0x06,0x0c,0x0c,0x00,0x0c,0x0c,0x00,0x00,0x00,0x00, 8, // 0x40 '@' 0x00,0x00,0x7c,0x86,0x03,0x73,0xdb,0xdb,0xdb,0xdb,0xdb,0x6e,0x00,0x00,0x00,0x00, 8, // 0x41 'A' 0x00,0x00,0x08,0x1c,0x36,0x63,0x63,0x63,0x7f,0x63,0x63,0x63,0x00,0x00,0x00,0x00, 8, // 0x42 'B' 0x00,0x00,0x7e,0x33,0x33,0x33,0x3e,0x33,0x33,0x33,0x33,0x7e,0x00,0x00,0x00,0x00, 8, // 0x43 'C' 0x00,0x00,0x1e,0x33,0x61,0x60,0x60,0x60,0x60,0x61,0x33,0x1e,0x00,0x00,0x00,0x00, 8, // 0x44 'D' 0x00,0x00,0x7c,0x36,0x33,0x33,0x33,0x33,0x33,0x33,0x36,0x7c,0x00,0x00,0x00,0x00, 8, // 0x45 'E' 0x00,0x00,0x7f,0x33,0x31,0x34,0x3c,0x34,0x30,0x31,0x33,0x7f,0x00,0x00,0x00,0x00, 8, // 0x46 'F' 0x00,0x00,0x7f,0x33,0x31,0x34,0x3c,0x34,0x30,0x30,0x30,0x78,0x00,0x00,0x00,0x00, 8, // 0x47 'G' 0x00,0x00,0x1f,0x33,0x61,0x60,0x60,0x6f,0x63,0x63,0x33,0x1e,0x00,0x00,0x00,0x00, 8, // 0x48 'H' 0x00,0x00,0x63,0x63,0x63,0x63,0x7f,0x63,0x63,0x63,0x63,0x63,0x00,0x00,0x00,0x00, 8, // 0x49 'I' 0x00,0x00,0x1e,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x00,0x00, 8, // 0x4a 'J' 0x00,0x00,0x0f,0x06,0x06,0x06,0x06,0x06,0x06,0x66,0x66,0x3c,0x00,0x00,0x00,0x00, 8, // 0x4b 'K' 0x00,0x00,0x73,0x33,0x36,0x36,0x3c,0x36,0x36,0x33,0x33,0x73,0x00,0x00,0x00,0x00, 8, // 0x4c 'L' 0x00,0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x33,0x7f,0x00,0x00,0x00,0x00, 8, // 0x4d 'M' 0x00,0x00,0x63,0x63,0x77,0x77,0x7f,0x6b,0x6b,0x63,0x63,0x63,0x00,0x00,0x00,0x00, 8, // 0x4e 'N' 0x00,0x00,0x63,0x63,0x73,0x7b,0x6f,0x67,0x63,0x63,0x63,0x63,0x00,0x00,0x00,0x00, 8, // 0x4f 'O' 0x00,0x00,0x1c,0x36,0x63,0x63,0x63,0x63,0x63,0x63,0x36,0x1c,0x00,0x00,0x00,0x00, 8, // 0x50 'P' 0x00,0x00,0x7e,0x33,0x33,0x33,0x33,0x3e,0x30,0x30,0x30,0x78,0x00,0x00,0x00,0x00, 8, // 0x51 'Q' 0x00,0x00,0x1c,0x36,0x63,0x63,0x63,0x63,0x63,0x6f,0x36,0x1e,0x03,0x00,0x00,0x00, 8, // 0x52 'R' 0x00,0x00,0x7e,0x33,0x33,0x33,0x33,0x3e,0x36,0x33,0x33,0x73,0x00,0x00,0x00,0x00, 8, // 0x53 'S' 0x00,0x00,0x3e,0x63,0x63,0x30,0x18,0x0c,0x06,0x63,0x63,0x3e,0x00,0x00,0x00,0x00, 8, // 0x54 'T' 0x00,0x00,0x3f,0x3f,0x2d,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x00,0x00, 8, // 0x55 'U' 0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x3e,0x00,0x00,0x00,0x00, 8, // 0x56 'V' 0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x63,0x63,0x36,0x1c,0x08,0x00,0x00,0x00,0x00, 8, // 0x57 'W' 0x00,0x00,0x63,0x63,0x63,0x6b,0x6b,0x7f,0x77,0x77,0x63,0x63,0x00,0x00,0x00,0x00, 8, // 0x58 'X' 0x00,0x00,0x63,0x63,0x63,0x36,0x1c,0x1c,0x36,0x63,0x63,0x63,0x00,0x00,0x00,0x00, 8, // 0x59 'Y' 0x00,0x00,0x33,0x33,0x33,0x33,0x1e,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x00,0x00, 8, // 0x5a 'Z' 0x00,0x00,0x7f,0x63,0x43,0x06,0x0c,0x18,0x30,0x61,0x63,0x7f,0x00,0x00,0x00,0x00, 8, // 0x5b '[' 0x00,0x1f,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1f,0x00,0x00,0x00, 8, // 0x5c '\' 0x00,0x60,0x60,0x30,0x30,0x18,0x18,0x0c,0x0c,0x06,0x06,0x03,0x03,0x00,0x00,0x00, 8, // 0x5d ']' 0x00,0x7c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x7c,0x00,0x00,0x00, 8, // 0x5e '^' 0x00,0x00,0x08,0x1c,0x36,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x5f '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00, 8, // 0x60 '`' 0x00,0x00,0x18,0x18,0x18,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x61 'a' 0x00,0x00,0x00,0x00,0x00,0x3c,0x66,0x06,0x3e,0x66,0x66,0x3b,0x00,0x00,0x00,0x00, 8, // 0x62 'b' 0x00,0x00,0x70,0x30,0x30,0x3c,0x36,0x33,0x33,0x33,0x33,0x3e,0x00,0x00,0x00,0x00, 8, // 0x63 'c' 0x00,0x00,0x00,0x00,0x00,0x3e,0x63,0x63,0x60,0x60,0x63,0x3e,0x00,0x00,0x00,0x00, 8, // 0x64 'd' 0x00,0x00,0x0e,0x06,0x06,0x1e,0x36,0x66,0x66,0x66,0x66,0x3b,0x00,0x00,0x00,0x00, 8, // 0x65 'e' 0x00,0x00,0x00,0x00,0x00,0x3e,0x63,0x63,0x7f,0x60,0x63,0x3e,0x00,0x00,0x00,0x00, 8, // 0x66 'f' 0x00,0x00,0x0e,0x1b,0x1b,0x18,0x3c,0x18,0x18,0x18,0x18,0x3c,0x00,0x00,0x00,0x00, 8, // 0x67 'g' 0x00,0x00,0x00,0x00,0x00,0x3b,0x66,0x66,0x66,0x66,0x66,0x3e,0x06,0x66,0x3c,0x00, 8, // 0x68 'h' 0x00,0x00,0x70,0x30,0x30,0x36,0x3b,0x33,0x33,0x33,0x33,0x73,0x00,0x00,0x00,0x00, 8, // 0x69 'i' 0x00,0x00,0x0c,0x0c,0x00,0x1c,0x0c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x00,0x00, 8, // 0x6a 'j' 0x00,0x00,0x06,0x06,0x00,0x0e,0x06,0x06,0x06,0x06,0x06,0x66,0x66,0x3c,0x00,0x00, 8, // 0x6b 'k' 0x00,0x00,0x70,0x30,0x30,0x33,0x33,0x36,0x3c,0x36,0x33,0x73,0x00,0x00,0x00,0x00, 8, // 0x6c 'l' 0x00,0x00,0x1c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x1e,0x00,0x00,0x00,0x00, 8, // 0x6d 'm' 0x00,0x00,0x00,0x00,0x00,0x76,0x7f,0x6b,0x6b,0x6b,0x63,0x63,0x00,0x00,0x00,0x00, 8, // 0x6e 'n' 0x00,0x00,0x00,0x00,0x00,0x6e,0x33,0x33,0x33,0x33,0x33,0x33,0x00,0x00,0x00,0x00, 8, // 0x6f 'o' 0x00,0x00,0x00,0x00,0x00,0x3e,0x63,0x63,0x63,0x63,0x63,0x3e,0x00,0x00,0x00,0x00, 8, // 0x70 'p' 0x00,0x00,0x00,0x00,0x00,0x6e,0x33,0x33,0x33,0x33,0x33,0x3e,0x30,0x30,0x78,0x00, 8, // 0x71 'q' 0x00,0x00,0x00,0x00,0x00,0x3b,0x66,0x66,0x66,0x66,0x66,0x3e,0x06,0x06,0x0f,0x00, 8, // 0x72 'r' 0x00,0x00,0x00,0x00,0x00,0x6e,0x3b,0x33,0x30,0x30,0x30,0x78,0x00,0x00,0x00,0x00, 8, // 0x73 's' 0x00,0x00,0x00,0x00,0x00,0x3e,0x63,0x60,0x3e,0x03,0x63,0x3e,0x00,0x00,0x00,0x00, 8, // 0x74 't' 0x00,0x00,0x08,0x18,0x18,0x7e,0x18,0x18,0x18,0x18,0x1b,0x0e,0x00,0x00,0x00,0x00, 8, // 0x75 'u' 0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x3b,0x00,0x00,0x00,0x00, 8, // 0x76 'v' 0x00,0x00,0x00,0x00,0x00,0x63,0x63,0x63,0x63,0x36,0x1c,0x08,0x00,0x00,0x00,0x00, 8, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x63,0x63,0x6b,0x6b,0x7f,0x36,0x36,0x00,0x00,0x00,0x00, 8, // 0x78 'x' 0x00,0x00,0x00,0x00,0x00,0x63,0x63,0x36,0x1c,0x36,0x63,0x63,0x00,0x00,0x00,0x00, 8, // 0x79 'y' 0x00,0x00,0x00,0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x63,0x3f,0x03,0x06,0x7c,0x00, 8, // 0x7a 'z' 0x00,0x00,0x00,0x00,0x00,0x7f,0x63,0x06,0x0c,0x18,0x31,0x7f,0x00,0x00,0x00,0x00, 8, // 0x7b '{' 0x00,0x03,0x04,0x0c,0x0c,0x0c,0x08,0x30,0x08,0x0c,0x0c,0x0c,0x04,0x03,0x00,0x00, 8, // 0x7c '|' 0x00,0x00,0x0c,0x0c,0x0c,0x0c,0x0c,0x00,0x0c,0x0c,0x0c,0x0c,0x0c,0x00,0x00,0x00, 8, // 0x7d '}' 0x00,0x60,0x10,0x18,0x18,0x18,0x08,0x06,0x08,0x18,0x18,0x18,0x10,0x60,0x00,0x00, 8, // 0x7e '~' 0x00,0x00,0x3b,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x7f '' 0x00,0x00,0x00,0x00,0x00,0x08,0x1c,0x36,0x63,0x63,0x7f,0x00,0x00,0x00,0x00,0x00, 0 }; const int8u mcs11_prop[] = { 11, 2, 32, 128-32, 0x00,0x00,0x0C,0x00,0x18,0x00,0x24,0x00,0x30,0x00,0x3C,0x00,0x48,0x00,0x54,0x00,0x60,0x00, 0x6C,0x00,0x78,0x00,0x84,0x00,0x90,0x00,0x9C,0x00,0xA8,0x00,0xB4,0x00,0xC0,0x00,0xCC,0x00, 0xD8,0x00,0xE4,0x00,0xF0,0x00,0xFC,0x00,0x08,0x01,0x14,0x01,0x20,0x01,0x2C,0x01,0x38,0x01, 0x44,0x01,0x50,0x01,0x5C,0x01,0x68,0x01,0x74,0x01,0x80,0x01,0x8C,0x01,0x98,0x01,0xA4,0x01, 0xB0,0x01,0xBC,0x01,0xC8,0x01,0xD4,0x01,0xE0,0x01,0xEC,0x01,0xF8,0x01,0x04,0x02,0x10,0x02, 0x1C,0x02,0x28,0x02,0x34,0x02,0x40,0x02,0x4C,0x02,0x58,0x02,0x64,0x02,0x70,0x02,0x7C,0x02, 0x88,0x02,0x94,0x02,0xA0,0x02,0xAC,0x02,0xB8,0x02,0xC4,0x02,0xD0,0x02,0xDC,0x02,0xE8,0x02, 0xF4,0x02,0x00,0x03,0x0C,0x03,0x18,0x03,0x24,0x03,0x30,0x03,0x3C,0x03,0x48,0x03,0x54,0x03, 0x60,0x03,0x6C,0x03,0x78,0x03,0x84,0x03,0x90,0x03,0x9C,0x03,0xA8,0x03,0xB4,0x03,0xC0,0x03, 0xCC,0x03,0xD8,0x03,0xE4,0x03,0xF0,0x03,0xFC,0x03,0x08,0x04,0x14,0x04,0x20,0x04,0x2C,0x04, 0x38,0x04,0x44,0x04,0x50,0x04,0x5C,0x04,0x68,0x04,0x74,0x04, 5, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x21 '!' 0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00, 4, // 0x22 '"' 0x50,0x50,0xA0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x23 '#' 0x00,0x28,0x28,0x7C,0x28,0x28,0x28,0x7C,0x28,0x28,0x00, 6, // 0x24 '$' 0x10,0x10,0x38,0x54,0x50,0x38,0x14,0x54,0x38,0x10,0x10, 6, // 0x25 '%' 0x00,0x00,0x68,0xA8,0xD0,0x10,0x20,0x2C,0x54,0x58,0x00, 6, // 0x26 '&' 0x00,0x20,0x50,0x50,0x50,0x20,0x54,0x54,0x48,0x34,0x00, 3, // 0x27 ''' 0x40,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x28 '(' 0x10,0x20,0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x20,0x10, 5, // 0x29 ')' 0x40,0x20,0x20,0x10,0x10,0x10,0x10,0x10,0x20,0x20,0x40, 6, // 0x2A '*' 0x00,0x00,0x28,0x7C,0x38,0x7C,0x28,0x00,0x00,0x00,0x00, 6, // 0x2B '+' 0x00,0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x00,0x00,0x00, 4, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0xC0, 6, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00, 4, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00, 7, // 0x2F '/' 0x00,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40, 6, // 0x30 '0' 0x00,0x38,0x44,0x44,0x54,0x54,0x54,0x44,0x44,0x38,0x00, 4, // 0x31 '1' 0x00,0x20,0x60,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00, 6, // 0x32 '2' 0x00,0x38,0x44,0x44,0x04,0x08,0x10,0x20,0x40,0x7C,0x00, 6, // 0x33 '3' 0x00,0x38,0x44,0x04,0x04,0x38,0x04,0x04,0x44,0x38,0x00, 6, // 0x34 '4' 0x00,0x08,0x18,0x18,0x28,0x28,0x48,0x7C,0x08,0x08,0x00, 6, // 0x35 '5' 0x00,0x7C,0x40,0x40,0x78,0x44,0x04,0x04,0x44,0x38,0x00, 6, // 0x36 '6' 0x00,0x38,0x44,0x40,0x40,0x78,0x44,0x44,0x44,0x38,0x00, 6, // 0x37 '7' 0x00,0x7C,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x00, 6, // 0x38 '8' 0x00,0x38,0x44,0x44,0x44,0x38,0x44,0x44,0x44,0x38,0x00, 6, // 0x39 '9' 0x00,0x38,0x44,0x44,0x44,0x3C,0x04,0x04,0x44,0x38,0x00, 4, // 0x3A ':' 0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x60,0x60,0x00, 4, // 0x3B ';' 0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x60,0x60,0xC0, 6, // 0x3C '<' 0x00,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x00, 6, // 0x3D '=' 0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x00, 6, // 0x3E '>' 0x00,0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x00, 6, // 0x3F '?' 0x00,0x38,0x44,0x04,0x04,0x08,0x10,0x10,0x00,0x10,0x00, 6, // 0x40 '@' 0x00,0x38,0x44,0x44,0x5C,0x54,0x54,0x4C,0x40,0x38,0x00, 6, // 0x41 'A' 0x00,0x38,0x44,0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x00, 6, // 0x42 'B' 0x00,0x78,0x44,0x44,0x44,0x78,0x44,0x44,0x44,0x78,0x00, 6, // 0x43 'C' 0x00,0x38,0x44,0x40,0x40,0x40,0x40,0x40,0x44,0x38,0x00, 6, // 0x44 'D' 0x00,0x70,0x48,0x44,0x44,0x44,0x44,0x44,0x48,0x70,0x00, 6, // 0x45 'E' 0x00,0x7C,0x40,0x40,0x40,0x78,0x40,0x40,0x40,0x7C,0x00, 6, // 0x46 'F' 0x00,0x7C,0x40,0x40,0x40,0x78,0x40,0x40,0x40,0x40,0x00, 6, // 0x47 'G' 0x00,0x38,0x44,0x40,0x40,0x5C,0x44,0x44,0x4C,0x34,0x00, 6, // 0x48 'H' 0x00,0x44,0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x44,0x00, 4, // 0x49 'I' 0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x70,0x00, 6, // 0x4A 'J' 0x00,0x1C,0x08,0x08,0x08,0x08,0x08,0x08,0x48,0x30,0x00, 6, // 0x4B 'K' 0x00,0x44,0x48,0x50,0x60,0x60,0x50,0x48,0x44,0x44,0x00, 6, // 0x4C 'L' 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7C,0x00, 8, // 0x4D 'M' 0x00,0x41,0x63,0x55,0x49,0x49,0x41,0x41,0x41,0x41,0x00, 7, // 0x4E 'N' 0x00,0x42,0x42,0x62,0x52,0x4A,0x46,0x42,0x42,0x42,0x00, 6, // 0x4F 'O' 0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00, 6, // 0x50 'P' 0x00,0x78,0x44,0x44,0x44,0x78,0x40,0x40,0x40,0x40,0x00, 6, // 0x51 'Q' 0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x54,0x48,0x34,0x00, 6, // 0x52 'R' 0x00,0x78,0x44,0x44,0x44,0x78,0x44,0x44,0x44,0x44,0x00, 6, // 0x53 'S' 0x00,0x38,0x44,0x40,0x40,0x38,0x04,0x04,0x44,0x38,0x00, 6, // 0x54 'T' 0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00, 6, // 0x55 'U' 0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00, 6, // 0x56 'V' 0x00,0x44,0x44,0x44,0x44,0x28,0x28,0x28,0x10,0x10,0x00, 8, // 0x57 'W' 0x00,0x41,0x41,0x41,0x41,0x49,0x49,0x49,0x55,0x22,0x00, 6, // 0x58 'X' 0x00,0x44,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x44,0x00, 6, // 0x59 'Y' 0x00,0x44,0x44,0x44,0x28,0x10,0x10,0x10,0x10,0x10,0x00, 6, // 0x5A 'Z' 0x00,0x7C,0x04,0x04,0x08,0x10,0x20,0x40,0x40,0x7C,0x00, 5, // 0x5B '[' 0x30,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30, 7, // 0x5C '\' 0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x00, 4, // 0x5D ']' 0x60,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x60, 6, // 0x5E '^' 0x00,0x10,0x28,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00, 4, // 0x60 '`' 0x00,0x40,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x61 'a' 0x00,0x00,0x00,0x38,0x04,0x3C,0x44,0x44,0x44,0x3C,0x00, 6, // 0x62 'b' 0x00,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x44,0x78,0x00, 6, // 0x63 'c' 0x00,0x00,0x00,0x38,0x44,0x40,0x40,0x40,0x44,0x38,0x00, 6, // 0x64 'd' 0x00,0x04,0x04,0x3C,0x44,0x44,0x44,0x44,0x44,0x3C,0x00, 6, // 0x65 'e' 0x00,0x00,0x00,0x38,0x44,0x44,0x7C,0x40,0x44,0x38,0x00, 4, // 0x66 'f' 0x00,0x10,0x20,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x00, 6, // 0x67 'g' 0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x3C,0x04,0x44,0x38, 6, // 0x68 'h' 0x00,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x44,0x44,0x00, 2, // 0x69 'i' 0x00,0x40,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00, 3, // 0x6A 'j' 0x00,0x20,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x40, 5, // 0x6B 'k' 0x00,0x40,0x40,0x48,0x50,0x60,0x60,0x50,0x48,0x48,0x00, 2, // 0x6C 'l' 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00, 8, // 0x6D 'm' 0x00,0x00,0x00,0x76,0x49,0x49,0x49,0x49,0x41,0x41,0x00, 6, // 0x6E 'n' 0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x44,0x44,0x00, 6, // 0x6F 'o' 0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x38,0x00, 6, // 0x70 'p' 0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x78,0x40,0x40, 6, // 0x71 'q' 0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x44,0x3C,0x04,0x04, 6, // 0x72 'r' 0x00,0x00,0x00,0x58,0x24,0x20,0x20,0x20,0x20,0x20,0x00, 6, // 0x73 's' 0x00,0x00,0x00,0x38,0x44,0x40,0x38,0x04,0x44,0x38,0x00, 5, // 0x74 't' 0x00,0x20,0x20,0x70,0x20,0x20,0x20,0x20,0x28,0x10,0x00, 6, // 0x75 'u' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x4C,0x34,0x00, 6, // 0x76 'v' 0x00,0x00,0x00,0x44,0x44,0x44,0x28,0x28,0x10,0x10,0x00, 8, // 0x77 'w' 0x00,0x00,0x00,0x41,0x41,0x41,0x41,0x49,0x49,0x36,0x00, 6, // 0x78 'x' 0x00,0x00,0x00,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x00, 6, // 0x79 'y' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x3C,0x04,0x08,0x70, 6, // 0x7A 'z' 0x00,0x00,0x00,0x7C,0x04,0x08,0x10,0x20,0x40,0x7C,0x00, 5, // 0x7B '{' 0x18,0x20,0x20,0x20,0x20,0xC0,0x20,0x20,0x20,0x20,0x18, 3, // 0x7C '|' 0x00,0x40,0x40,0x40,0x40,0x00,0x40,0x40,0x40,0x40,0x00, 5, // 0x7D '}' 0xC0,0x20,0x20,0x20,0x20,0x18,0x20,0x20,0x20,0x20,0xC0, 6, // 0x7E '~' 0x00,0x24,0x54,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x7F '' 0x00,0x10,0x38,0x6C,0x44,0x44,0x7C,0x00,0x00,0x00,0x00, 0 }; const int8u mcs11_prop_condensed[] = { 11, 2, 32, 128-32, 0x00,0x00,0x0C,0x00,0x18,0x00,0x24,0x00,0x30,0x00,0x3C,0x00,0x48,0x00,0x54,0x00,0x60,0x00, 0x6C,0x00,0x78,0x00,0x84,0x00,0x90,0x00,0x9C,0x00,0xA8,0x00,0xB4,0x00,0xC0,0x00,0xCC,0x00, 0xD8,0x00,0xE4,0x00,0xF0,0x00,0xFC,0x00,0x08,0x01,0x14,0x01,0x20,0x01,0x2C,0x01,0x38,0x01, 0x44,0x01,0x50,0x01,0x5C,0x01,0x68,0x01,0x74,0x01,0x80,0x01,0x8C,0x01,0x98,0x01,0xA4,0x01, 0xB0,0x01,0xBC,0x01,0xC8,0x01,0xD4,0x01,0xE0,0x01,0xEC,0x01,0xF8,0x01,0x04,0x02,0x10,0x02, 0x1C,0x02,0x28,0x02,0x34,0x02,0x40,0x02,0x4C,0x02,0x58,0x02,0x64,0x02,0x70,0x02,0x7C,0x02, 0x88,0x02,0x94,0x02,0xA0,0x02,0xAC,0x02,0xB8,0x02,0xC4,0x02,0xD0,0x02,0xDC,0x02,0xE8,0x02, 0xF4,0x02,0x00,0x03,0x0C,0x03,0x18,0x03,0x24,0x03,0x30,0x03,0x3C,0x03,0x48,0x03,0x54,0x03, 0x60,0x03,0x6C,0x03,0x78,0x03,0x84,0x03,0x90,0x03,0x9C,0x03,0xA8,0x03,0xB4,0x03,0xC0,0x03, 0xCC,0x03,0xD8,0x03,0xE4,0x03,0xF0,0x03,0xFC,0x03,0x08,0x04,0x14,0x04,0x20,0x04,0x2C,0x04, 0x38,0x04,0x44,0x04,0x50,0x04,0x5C,0x04,0x68,0x04,0x74,0x04, 3, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 3, // 0x21 '!' 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x40,0x00, 4, // 0x22 '"' 0x50,0x50,0xA0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x23 '#' 0x00,0x50,0x50,0xF8,0x50,0x50,0x50,0xF8,0x50,0x50,0x00, 5, // 0x24 '$' 0x00,0x40,0x60,0x90,0x80,0x60,0x10,0x90,0x60,0x20,0x00, 5, // 0x25 '%' 0x00,0x00,0x90,0x90,0x20,0x20,0x40,0x40,0x90,0x90,0x00, 5, // 0x26 '&' 0x00,0x40,0xA0,0xA0,0xA0,0x40,0xA8,0x90,0x90,0x68,0x00, 5, // 0x27 ''' 0x00,0x00,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x28 '(' 0x10,0x20,0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x20,0x10, 4, // 0x29 ')' 0x80,0x40,0x40,0x20,0x20,0x20,0x20,0x20,0x40,0x40,0x80, 5, // 0x2A '*' 0x00,0x00,0x90,0x60,0xF0,0x60,0x90,0x00,0x00,0x00,0x00, 5, // 0x2B '+' 0x00,0x00,0x00,0x20,0x20,0xF8,0x20,0x20,0x00,0x00,0x00, 4, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0xC0, 5, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00, 4, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x00, 6, // 0x2F '/' 0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x80,0x80,0x00, 5, // 0x30 '0' 0x00,0x70,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0xE0,0x00, 3, // 0x31 '1' 0x00,0x40,0xC0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00, 5, // 0x32 '2' 0x00,0x60,0x90,0x90,0x10,0x10,0x20,0x40,0x80,0xF0,0x00, 5, // 0x33 '3' 0x00,0x60,0x90,0x10,0x10,0x60,0x10,0x10,0x90,0x60,0x00, 5, // 0x34 '4' 0x00,0x10,0x30,0x30,0x50,0x50,0x90,0xF0,0x10,0x10,0x00, 5, // 0x35 '5' 0x00,0xF0,0x80,0x80,0xE0,0x90,0x10,0x10,0x90,0x60,0x00, 5, // 0x36 '6' 0x00,0x60,0x90,0x80,0x80,0xE0,0x90,0x90,0x90,0x60,0x00, 5, // 0x37 '7' 0x00,0xF0,0x10,0x10,0x10,0x20,0x20,0x40,0x40,0x40,0x00, 5, // 0x38 '8' 0x00,0x60,0x90,0x90,0x90,0x60,0x90,0x90,0x90,0x60,0x00, 5, // 0x39 '9' 0x00,0x60,0x90,0x90,0x90,0x70,0x10,0x10,0x90,0x60,0x00, 4, // 0x3A ':' 0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x60,0x60,0x00, 4, // 0x3B ';' 0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x60,0x60,0xC0, 6, // 0x3C '<' 0x00,0x08,0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x08,0x00, 5, // 0x3D '=' 0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0xF0,0x00,0x00,0x00, 6, // 0x3E '>' 0x00,0x80,0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x80,0x00, 5, // 0x3F '?' 0x00,0x60,0x90,0x10,0x10,0x20,0x40,0x00,0x40,0x00,0x00, 5, // 0x40 '@' 0x00,0x60,0x90,0x90,0xB0,0xB0,0xB0,0x80,0x80,0x70,0x00, 5, // 0x41 'A' 0x00,0x60,0x90,0x90,0x90,0xF0,0x90,0x90,0x90,0x90,0x00, 5, // 0x42 'B' 0x00,0xE0,0x90,0x90,0x90,0xE0,0x90,0x90,0x90,0xE0,0x00, 5, // 0x43 'C' 0x00,0x60,0x90,0x80,0x80,0x80,0x80,0x80,0x90,0x60,0x00, 5, // 0x44 'D' 0x00,0xE0,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0xE0,0x00, 5, // 0x45 'E' 0x00,0xF0,0x80,0x80,0x80,0xF0,0x80,0x80,0x80,0xF0,0x00, 5, // 0x46 'F' 0x00,0xF0,0x80,0x80,0x80,0xF0,0x80,0x80,0x80,0x80,0x00, 5, // 0x47 'G' 0x00,0x70,0x80,0x80,0x80,0xB0,0x90,0x90,0x90,0x60,0x00, 5, // 0x48 'H' 0x00,0x90,0x90,0x90,0x90,0xF0,0x90,0x90,0x90,0x90,0x00, 4, // 0x49 'I' 0x00,0xE0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0xE0,0x00, 5, // 0x4A 'J' 0x00,0x70,0x20,0x20,0x20,0x20,0x20,0xA0,0xA0,0x40,0x00, 5, // 0x4B 'K' 0x00,0x90,0x90,0xA0,0xA0,0xC0,0xA0,0xA0,0x90,0x90,0x00, 5, // 0x4C 'L' 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xF0,0x00, 6, // 0x4D 'M' 0x00,0x88,0xD8,0xA8,0xA8,0xA8,0x88,0x88,0x88,0x88,0x00, 5, // 0x4E 'N' 0x00,0x90,0x90,0xD0,0xD0,0xB0,0xB0,0x90,0x90,0x90,0x00, 5, // 0x4F 'O' 0x00,0x60,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x60,0x00, 5, // 0x50 'P' 0x00,0xE0,0x90,0x90,0x90,0x90,0xE0,0x80,0x80,0x80,0x00, 5, // 0x51 'Q' 0x00,0x60,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x60,0x30, 5, // 0x52 'R' 0x00,0xE0,0x90,0x90,0x90,0x90,0xE0,0xA0,0x90,0x90,0x00, 5, // 0x53 'S' 0x00,0x60,0x90,0x80,0x80,0x60,0x10,0x10,0x90,0x60,0x00, 6, // 0x54 'T' 0x00,0xF8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00, 5, // 0x55 'U' 0x00,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x60,0x00, 6, // 0x56 'V' 0x00,0x88,0x88,0x88,0x88,0x50,0x50,0x50,0x20,0x20,0x00, 6, // 0x57 'W' 0x00,0x88,0x88,0x88,0xA8,0xA8,0xA8,0xA8,0xA8,0x50,0x00, 5, // 0x58 'X' 0x00,0x90,0x90,0x90,0x60,0x60,0x90,0x90,0x90,0x90,0x00, 6, // 0x59 'Y' 0x00,0x88,0x88,0x88,0x50,0x20,0x20,0x20,0x20,0x20,0x00, 5, // 0x5A 'Z' 0x00,0xF0,0x10,0x20,0x20,0x40,0x40,0x80,0x80,0xF0,0x00, 4, // 0x5B '[' 0x60,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x60,0x00, 6, // 0x5C '\' 0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x00, 4, // 0x5D ']' 0x60,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x60,0x00, 5, // 0x5E '^' 0x00,0x20,0x50,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00, 5, // 0x60 '`' 0x00,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x61 'a' 0x00,0x00,0x00,0x60,0x90,0x10,0x70,0x90,0x90,0x70,0x00, 5, // 0x62 'b' 0x00,0x80,0x80,0x80,0xE0,0x90,0x90,0x90,0x90,0xE0,0x00, 5, // 0x63 'c' 0x00,0x00,0x00,0x60,0x90,0x80,0x80,0x80,0x90,0x60,0x00, 5, // 0x64 'd' 0x00,0x10,0x10,0x10,0x70,0x90,0x90,0x90,0x90,0x70,0x00, 5, // 0x65 'e' 0x00,0x00,0x00,0x60,0x90,0x90,0xF0,0x80,0x90,0x60,0x00, 4, // 0x66 'f' 0x00,0x20,0x40,0x40,0xE0,0x40,0x40,0x40,0x40,0x40,0x00, 5, // 0x67 'g' 0x00,0x00,0x00,0x70,0x90,0x90,0x90,0x70,0x10,0x90,0x60, 5, // 0x68 'h' 0x00,0x80,0x80,0x80,0xE0,0x90,0x90,0x90,0x90,0x90,0x00, 2, // 0x69 'i' 0x00,0x80,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00, 4, // 0x6A 'j' 0x00,0x20,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0xA0,0x40, 5, // 0x6B 'k' 0x00,0x80,0x80,0x90,0x90,0xA0,0xC0,0xA0,0x90,0x90,0x00, 2, // 0x6C 'l' 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00, 6, // 0x6D 'm' 0x00,0x00,0x00,0xD0,0xA8,0xA8,0xA8,0x88,0x88,0x88,0x00, 5, // 0x6E 'n' 0x00,0x00,0x00,0xA0,0xD0,0x90,0x90,0x90,0x90,0x90,0x00, 5, // 0x6F 'o' 0x00,0x00,0x00,0x60,0x90,0x90,0x90,0x90,0x90,0x60,0x00, 5, // 0x70 'p' 0x00,0x00,0x00,0xE0,0x90,0x90,0x90,0x90,0xE0,0x80,0x80, 5, // 0x71 'q' 0x00,0x00,0x00,0x70,0x90,0x90,0x90,0x90,0x70,0x10,0x10, 6, // 0x72 'r' 0x00,0x00,0x00,0xB8,0x48,0x40,0x40,0x40,0x40,0x40,0x00, 5, // 0x73 's' 0x00,0x00,0x00,0x60,0x90,0x40,0x20,0x10,0x90,0x60,0x00, 4, // 0x74 't' 0x00,0x40,0x40,0xE0,0x40,0x40,0x40,0x40,0x40,0x20,0x00, 5, // 0x75 'u' 0x00,0x00,0x00,0x90,0x90,0x90,0x90,0x90,0x90,0x70,0x00, 6, // 0x76 'v' 0x00,0x00,0x00,0x88,0x88,0x88,0x50,0x50,0x20,0x20,0x00, 6, // 0x77 'w' 0x00,0x00,0x00,0x88,0x88,0x88,0xA8,0xA8,0xA8,0x50,0x00, 5, // 0x78 'x' 0x00,0x00,0x00,0x90,0x90,0x60,0x60,0x90,0x90,0x90,0x00, 5, // 0x79 'y' 0x00,0x00,0x00,0x90,0x90,0x90,0x90,0x70,0x10,0x20,0xC0, 5, // 0x7A 'z' 0x00,0x00,0x00,0xF0,0x10,0x20,0x40,0x80,0x80,0xF0,0x00, 5, // 0x7B '{' 0x30,0x40,0x40,0x40,0x40,0x80,0x40,0x40,0x40,0x40,0x30, 3, // 0x7C '|' 0x00,0x40,0x40,0x40,0x40,0x00,0x40,0x40,0x40,0x40,0x00, 5, // 0x7D '}' 0xC0,0x20,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0xC0, 5, // 0x7E '~' 0x00,0x40,0xA8,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x7F '' 0x00,0x20,0x70,0xD8,0x88,0x88,0xF8,0x00,0x00,0x00,0x00, 0 }; const int8u mcs12_prop[] = { 12, 3, 32, 128-32, 0x00,0x00,0x0D,0x00,0x1A,0x00,0x27,0x00,0x34,0x00,0x41,0x00,0x4E,0x00,0x5B,0x00,0x68,0x00, 0x75,0x00,0x82,0x00,0x8F,0x00,0x9C,0x00,0xA9,0x00,0xB6,0x00,0xC3,0x00,0xD0,0x00,0xDD,0x00, 0xEA,0x00,0xF7,0x00,0x04,0x01,0x11,0x01,0x1E,0x01,0x2B,0x01,0x38,0x01,0x45,0x01,0x52,0x01, 0x5F,0x01,0x6C,0x01,0x79,0x01,0x86,0x01,0x93,0x01,0xA0,0x01,0xAD,0x01,0xBA,0x01,0xC7,0x01, 0xD4,0x01,0xE1,0x01,0xEE,0x01,0xFB,0x01,0x08,0x02,0x15,0x02,0x22,0x02,0x2F,0x02,0x3C,0x02, 0x49,0x02,0x62,0x02,0x6F,0x02,0x7C,0x02,0x89,0x02,0x96,0x02,0xA3,0x02,0xB0,0x02,0xBD,0x02, 0xCA,0x02,0xD7,0x02,0xF0,0x02,0xFD,0x02,0x0A,0x03,0x17,0x03,0x24,0x03,0x31,0x03,0x3E,0x03, 0x4B,0x03,0x58,0x03,0x65,0x03,0x72,0x03,0x7F,0x03,0x8C,0x03,0x99,0x03,0xA6,0x03,0xB3,0x03, 0xC0,0x03,0xCD,0x03,0xDA,0x03,0xE7,0x03,0xF4,0x03,0x01,0x04,0x1A,0x04,0x27,0x04,0x34,0x04, 0x41,0x04,0x4E,0x04,0x5B,0x04,0x68,0x04,0x75,0x04,0x82,0x04,0x8F,0x04,0xA8,0x04,0xB5,0x04, 0xC2,0x04,0xCF,0x04,0xDC,0x04,0xE9,0x04,0xF6,0x04,0x03,0x05, 5, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x21 '!' 0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,0x00, 4, // 0x22 '"' 0x50,0x50,0xA0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x23 '#' 0x28,0x28,0x28,0x7C,0x28,0x28,0x28,0x7C,0x28,0x28,0x28,0x00, 6, // 0x24 '$' 0x10,0x10,0x38,0x54,0x50,0x38,0x14,0x54,0x38,0x10,0x10,0x00, 7, // 0x25 '%' 0x32,0x54,0x64,0x08,0x08,0x10,0x10,0x26,0x2A,0x4C,0x00,0x00, 7, // 0x26 '&' 0x00,0x30,0x48,0x48,0x48,0x30,0x4A,0x4A,0x44,0x3A,0x00,0x00, 3, // 0x27 ''' 0x40,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x28 '(' 0x10,0x20,0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x20,0x10,0x00, 5, // 0x29 ')' 0x40,0x20,0x20,0x10,0x10,0x10,0x10,0x10,0x20,0x20,0x40,0x00, 6, // 0x2A '*' 0x00,0x00,0x10,0x54,0x38,0x7C,0x38,0x54,0x10,0x00,0x00,0x00, 6, // 0x2B '+' 0x00,0x00,0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x00,0x00,0x00, 4, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x40,0x80, 6, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00, 4, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00, 7, // 0x2F '/' 0x00,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x00, 7, // 0x30 '0' 0x00,0x38,0x44,0x44,0x54,0x54,0x54,0x44,0x44,0x38,0x00,0x00, 4, // 0x31 '1' 0x00,0x20,0x60,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00, 7, // 0x32 '2' 0x00,0x38,0x44,0x04,0x04,0x08,0x10,0x20,0x40,0x7C,0x00,0x00, 7, // 0x33 '3' 0x00,0x38,0x44,0x04,0x04,0x38,0x04,0x04,0x44,0x38,0x00,0x00, 6, // 0x34 '4' 0x00,0x08,0x18,0x28,0x28,0x48,0x48,0x7C,0x08,0x08,0x00,0x00, 7, // 0x35 '5' 0x00,0x7C,0x40,0x40,0x78,0x44,0x04,0x04,0x44,0x38,0x00,0x00, 7, // 0x36 '6' 0x00,0x38,0x44,0x40,0x78,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 6, // 0x37 '7' 0x00,0x7C,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x00,0x00, 7, // 0x38 '8' 0x00,0x38,0x44,0x44,0x44,0x38,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x39 '9' 0x00,0x38,0x44,0x44,0x44,0x3C,0x04,0x04,0x44,0x38,0x00,0x00, 4, // 0x3A ':' 0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x60,0x60,0x00,0x00, 4, // 0x3B ';' 0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x60,0x60,0x40,0x80, 6, // 0x3C '<' 0x00,0x00,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x00, 6, // 0x3D '=' 0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x00,0x00, 6, // 0x3E '>' 0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x00, 6, // 0x3F '?' 0x00,0x38,0x44,0x04,0x04,0x08,0x10,0x10,0x00,0x10,0x00,0x00, 7, // 0x40 '@' 0x00,0x38,0x44,0x44,0x5C,0x54,0x54,0x4C,0x40,0x38,0x00,0x00, 7, // 0x41 'A' 0x00,0x38,0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x44,0x00,0x00, 7, // 0x42 'B' 0x00,0x78,0x44,0x44,0x44,0x78,0x44,0x44,0x44,0x78,0x00,0x00, 6, // 0x43 'C' 0x00,0x38,0x44,0x40,0x40,0x40,0x40,0x40,0x44,0x38,0x00,0x00, 7, // 0x44 'D' 0x00,0x70,0x48,0x44,0x44,0x44,0x44,0x44,0x48,0x70,0x00,0x00, 6, // 0x45 'E' 0x00,0x7C,0x40,0x40,0x40,0x78,0x40,0x40,0x40,0x7C,0x00,0x00, 6, // 0x46 'F' 0x00,0x7C,0x40,0x40,0x40,0x78,0x40,0x40,0x40,0x40,0x00,0x00, 7, // 0x47 'G' 0x00,0x38,0x44,0x40,0x40,0x5C,0x44,0x44,0x4C,0x34,0x00,0x00, 7, // 0x48 'H' 0x00,0x44,0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x44,0x00,0x00, 5, // 0x49 'I' 0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00, 6, // 0x4A 'J' 0x00,0x1C,0x08,0x08,0x08,0x08,0x08,0x48,0x48,0x30,0x00,0x00, 6, // 0x4B 'K' 0x00,0x44,0x48,0x50,0x60,0x60,0x50,0x48,0x44,0x44,0x00,0x00, 6, // 0x4C 'L' 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7C,0x00,0x00, 9, // 0x4D 'M' 0x00,0x00,0x41,0x00,0x63,0x00,0x55,0x00,0x49,0x00,0x49,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x00,0x00, 7, // 0x4E 'N' 0x00,0x44,0x64,0x64,0x54,0x54,0x4C,0x4C,0x44,0x44,0x00,0x00, 7, // 0x4F 'O' 0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x50 'P' 0x00,0x78,0x44,0x44,0x44,0x44,0x78,0x40,0x40,0x40,0x00,0x00, 7, // 0x51 'Q' 0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x54,0x48,0x34,0x00,0x00, 7, // 0x52 'R' 0x00,0x78,0x44,0x44,0x44,0x44,0x78,0x48,0x44,0x44,0x00,0x00, 7, // 0x53 'S' 0x00,0x38,0x44,0x40,0x40,0x38,0x04,0x04,0x44,0x38,0x00,0x00, 6, // 0x54 'T' 0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, 7, // 0x55 'U' 0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 6, // 0x56 'V' 0x00,0x44,0x44,0x44,0x44,0x28,0x28,0x28,0x10,0x10,0x00,0x00, 9, // 0x57 'W' 0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x49,0x00,0x49,0x00,0x55,0x00,0x22,0x00,0x00,0x00,0x00,0x00, 7, // 0x58 'X' 0x00,0x44,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x44,0x00,0x00, 7, // 0x59 'Y' 0x00,0x44,0x44,0x44,0x44,0x28,0x10,0x10,0x10,0x10,0x00,0x00, 6, // 0x5A 'Z' 0x00,0x7C,0x04,0x04,0x08,0x10,0x20,0x40,0x40,0x7C,0x00,0x00, 4, // 0x5B '[' 0x70,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x70,0x00, 7, // 0x5C '\' 0x00,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x00, 4, // 0x5D ']' 0xE0,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xE0,0x00, 6, // 0x5E '^' 0x00,0x10,0x28,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00, 4, // 0x60 '`' 0x00,0x40,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x61 'a' 0x00,0x00,0x00,0x38,0x04,0x3C,0x44,0x44,0x44,0x3C,0x00,0x00, 7, // 0x62 'b' 0x00,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x44,0x78,0x00,0x00, 6, // 0x63 'c' 0x00,0x00,0x00,0x38,0x44,0x40,0x40,0x40,0x44,0x38,0x00,0x00, 7, // 0x64 'd' 0x00,0x04,0x04,0x3C,0x44,0x44,0x44,0x44,0x44,0x3C,0x00,0x00, 7, // 0x65 'e' 0x00,0x00,0x00,0x38,0x44,0x44,0x7C,0x40,0x44,0x38,0x00,0x00, 4, // 0x66 'f' 0x00,0x30,0x40,0xE0,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00, 7, // 0x67 'g' 0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x44,0x44,0x3C,0x04,0x78, 7, // 0x68 'h' 0x00,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x44,0x44,0x00,0x00, 3, // 0x69 'i' 0x00,0x40,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00, 5, // 0x6A 'j' 0x00,0x10,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x90,0x60, 6, // 0x6B 'k' 0x00,0x40,0x40,0x44,0x48,0x50,0x60,0x50,0x48,0x44,0x00,0x00, 3, // 0x6C 'l' 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00, 9, // 0x6D 'm' 0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x00,0x49,0x00,0x49,0x00,0x49,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x00,0x00, 7, // 0x6E 'n' 0x00,0x00,0x00,0x58,0x64,0x44,0x44,0x44,0x44,0x44,0x00,0x00, 7, // 0x6F 'o' 0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x70 'p' 0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x44,0x78,0x40,0x40, 7, // 0x71 'q' 0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x44,0x44,0x3C,0x04,0x04, 6, // 0x72 'r' 0x00,0x00,0x00,0x58,0x24,0x20,0x20,0x20,0x20,0x70,0x00,0x00, 7, // 0x73 's' 0x00,0x00,0x00,0x38,0x44,0x40,0x38,0x04,0x44,0x38,0x00,0x00, 5, // 0x74 't' 0x00,0x20,0x20,0x70,0x20,0x20,0x20,0x20,0x20,0x18,0x00,0x00, 7, // 0x75 'u' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x4C,0x34,0x00,0x00, 6, // 0x76 'v' 0x00,0x00,0x00,0x44,0x44,0x44,0x28,0x28,0x10,0x10,0x00,0x00, 9, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x49,0x00,0x49,0x00,0x49,0x00,0x36,0x00,0x00,0x00,0x00,0x00, 7, // 0x78 'x' 0x00,0x00,0x00,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x00,0x00, 7, // 0x79 'y' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x3C,0x08,0x70, 6, // 0x7A 'z' 0x00,0x00,0x00,0x7C,0x04,0x08,0x10,0x20,0x40,0x7C,0x00,0x00, 5, // 0x7B '{' 0x18,0x20,0x20,0x20,0x20,0xC0,0x20,0x20,0x20,0x20,0x18,0x00, 3, // 0x7C '|' 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00, 5, // 0x7D '}' 0xC0,0x20,0x20,0x20,0x20,0x18,0x20,0x20,0x20,0x20,0xC0,0x00, 7, // 0x7E '~' 0x00,0x60,0x92,0x92,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x7F '' 0x00,0x10,0x38,0x6C,0x44,0x44,0x7C,0x00,0x00,0x00,0x00,0x00, 0 }; const int8u mcs13_prop[] = { 13, 4, 32, 128-32, 0x00,0x00,0x0E,0x00,0x1C,0x00,0x2A,0x00,0x38,0x00,0x46,0x00,0x54,0x00,0x62,0x00,0x70,0x00, 0x7E,0x00,0x8C,0x00,0x9A,0x00,0xA8,0x00,0xB6,0x00,0xC4,0x00,0xD2,0x00,0xE0,0x00,0xEE,0x00, 0xFC,0x00,0x0A,0x01,0x18,0x01,0x26,0x01,0x34,0x01,0x42,0x01,0x50,0x01,0x5E,0x01,0x6C,0x01, 0x7A,0x01,0x88,0x01,0x96,0x01,0xA4,0x01,0xB2,0x01,0xC0,0x01,0xCE,0x01,0xDC,0x01,0xEA,0x01, 0xF8,0x01,0x06,0x02,0x14,0x02,0x22,0x02,0x30,0x02,0x3E,0x02,0x4C,0x02,0x5A,0x02,0x68,0x02, 0x76,0x02,0x91,0x02,0x9F,0x02,0xAD,0x02,0xBB,0x02,0xC9,0x02,0xD7,0x02,0xE5,0x02,0xF3,0x02, 0x01,0x03,0x0F,0x03,0x2A,0x03,0x38,0x03,0x46,0x03,0x54,0x03,0x62,0x03,0x70,0x03,0x7E,0x03, 0x8C,0x03,0x9A,0x03,0xA8,0x03,0xB6,0x03,0xC4,0x03,0xD2,0x03,0xE0,0x03,0xEE,0x03,0xFC,0x03, 0x0A,0x04,0x18,0x04,0x26,0x04,0x34,0x04,0x42,0x04,0x50,0x04,0x6B,0x04,0x79,0x04,0x87,0x04, 0x95,0x04,0xA3,0x04,0xB1,0x04,0xBF,0x04,0xCD,0x04,0xDB,0x04,0xE9,0x04,0x04,0x05,0x12,0x05, 0x20,0x05,0x2E,0x05,0x3C,0x05,0x4A,0x05,0x58,0x05,0x66,0x05, 5, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x21 '!' 0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,0x00, 4, // 0x22 '"' 0x00,0x50,0x50,0xA0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x23 '#' 0x00,0x28,0x28,0x28,0x7C,0x28,0x28,0x28,0x7C,0x28,0x28,0x28,0x00, 6, // 0x24 '$' 0x00,0x10,0x10,0x38,0x54,0x50,0x38,0x14,0x54,0x38,0x10,0x10,0x00, 7, // 0x25 '%' 0x00,0x32,0x54,0x64,0x08,0x08,0x10,0x10,0x26,0x2A,0x4C,0x00,0x00, 7, // 0x26 '&' 0x00,0x30,0x48,0x48,0x48,0x30,0x4A,0x4A,0x44,0x3A,0x00,0x00,0x00, 3, // 0x27 ''' 0x00,0x40,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x28 '(' 0x10,0x20,0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x20,0x10,0x00,0x00, 5, // 0x29 ')' 0x40,0x20,0x20,0x10,0x10,0x10,0x10,0x10,0x20,0x20,0x40,0x00,0x00, 6, // 0x2A '*' 0x00,0x00,0x10,0x54,0x38,0x7C,0x38,0x54,0x10,0x00,0x00,0x00,0x00, 6, // 0x2B '+' 0x00,0x00,0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x00,0x00,0x00,0x00, 4, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x20,0x40,0x80, 6, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00, 7, // 0x2F '/' 0x00,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x00,0x00, 7, // 0x30 '0' 0x00,0x38,0x44,0x44,0x54,0x54,0x54,0x44,0x44,0x38,0x00,0x00,0x00, 4, // 0x31 '1' 0x00,0x20,0x60,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00, 7, // 0x32 '2' 0x00,0x38,0x44,0x04,0x04,0x08,0x10,0x20,0x40,0x7C,0x00,0x00,0x00, 7, // 0x33 '3' 0x00,0x38,0x44,0x04,0x04,0x38,0x04,0x04,0x44,0x38,0x00,0x00,0x00, 6, // 0x34 '4' 0x00,0x08,0x18,0x28,0x28,0x48,0x48,0x7C,0x08,0x08,0x00,0x00,0x00, 7, // 0x35 '5' 0x00,0x7C,0x40,0x40,0x78,0x44,0x04,0x04,0x44,0x38,0x00,0x00,0x00, 7, // 0x36 '6' 0x00,0x38,0x44,0x40,0x78,0x44,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 6, // 0x37 '7' 0x00,0x7C,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x00,0x00,0x00, 7, // 0x38 '8' 0x00,0x38,0x44,0x44,0x44,0x38,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x39 '9' 0x00,0x38,0x44,0x44,0x44,0x3C,0x04,0x04,0x44,0x38,0x00,0x00,0x00, 4, // 0x3A ':' 0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00, 4, // 0x3B ';' 0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x60,0x60,0x20,0x40,0x80, 6, // 0x3C '<' 0x00,0x00,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x00,0x00, 6, // 0x3D '=' 0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00, 6, // 0x3E '>' 0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x00,0x00, 6, // 0x3F '?' 0x00,0x38,0x44,0x04,0x04,0x08,0x10,0x10,0x00,0x10,0x00,0x00,0x00, 7, // 0x40 '@' 0x00,0x38,0x44,0x44,0x5C,0x54,0x54,0x4C,0x40,0x38,0x00,0x00,0x00, 7, // 0x41 'A' 0x00,0x38,0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x42 'B' 0x00,0x78,0x44,0x44,0x44,0x78,0x44,0x44,0x44,0x78,0x00,0x00,0x00, 6, // 0x43 'C' 0x00,0x38,0x44,0x40,0x40,0x40,0x40,0x40,0x44,0x38,0x00,0x00,0x00, 7, // 0x44 'D' 0x00,0x70,0x48,0x44,0x44,0x44,0x44,0x44,0x48,0x70,0x00,0x00,0x00, 6, // 0x45 'E' 0x00,0x7C,0x40,0x40,0x40,0x78,0x40,0x40,0x40,0x7C,0x00,0x00,0x00, 6, // 0x46 'F' 0x00,0x7C,0x40,0x40,0x40,0x78,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 7, // 0x47 'G' 0x00,0x38,0x44,0x40,0x40,0x5C,0x44,0x44,0x4C,0x34,0x00,0x00,0x00, 7, // 0x48 'H' 0x00,0x44,0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x44,0x00,0x00,0x00, 5, // 0x49 'I' 0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00,0x00, 6, // 0x4A 'J' 0x00,0x1C,0x08,0x08,0x08,0x08,0x08,0x48,0x48,0x30,0x00,0x00,0x00, 6, // 0x4B 'K' 0x00,0x44,0x48,0x50,0x60,0x60,0x50,0x48,0x44,0x44,0x00,0x00,0x00, 6, // 0x4C 'L' 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7C,0x00,0x00,0x00, 9, // 0x4D 'M' 0x00,0x00,0x41,0x00,0x63,0x00,0x55,0x00,0x49,0x00,0x49,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x4E 'N' 0x00,0x44,0x64,0x64,0x54,0x54,0x4C,0x4C,0x44,0x44,0x00,0x00,0x00, 7, // 0x4F 'O' 0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x50 'P' 0x00,0x78,0x44,0x44,0x44,0x44,0x78,0x40,0x40,0x40,0x00,0x00,0x00, 7, // 0x51 'Q' 0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x54,0x48,0x34,0x00,0x00,0x00, 7, // 0x52 'R' 0x00,0x78,0x44,0x44,0x44,0x44,0x78,0x48,0x44,0x44,0x00,0x00,0x00, 7, // 0x53 'S' 0x00,0x38,0x44,0x40,0x40,0x38,0x04,0x04,0x44,0x38,0x00,0x00,0x00, 6, // 0x54 'T' 0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00, 7, // 0x55 'U' 0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 6, // 0x56 'V' 0x00,0x44,0x44,0x44,0x44,0x28,0x28,0x28,0x10,0x10,0x00,0x00,0x00, 9, // 0x57 'W' 0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x49,0x00,0x49,0x00,0x55,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x58 'X' 0x00,0x44,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x59 'Y' 0x00,0x44,0x44,0x44,0x44,0x28,0x10,0x10,0x10,0x10,0x00,0x00,0x00, 6, // 0x5A 'Z' 0x00,0x7C,0x04,0x04,0x08,0x10,0x20,0x40,0x40,0x7C,0x00,0x00,0x00, 4, // 0x5B '[' 0x70,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x70,0x00,0x00, 7, // 0x5C '\' 0x00,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x00,0x00, 4, // 0x5D ']' 0xE0,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xE0,0x00,0x00, 6, // 0x5E '^' 0x00,0x10,0x28,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00, 4, // 0x60 '`' 0x00,0x40,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x61 'a' 0x00,0x00,0x00,0x38,0x04,0x3C,0x44,0x44,0x44,0x3C,0x00,0x00,0x00, 7, // 0x62 'b' 0x00,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x44,0x78,0x00,0x00,0x00, 6, // 0x63 'c' 0x00,0x00,0x00,0x38,0x44,0x40,0x40,0x40,0x44,0x38,0x00,0x00,0x00, 7, // 0x64 'd' 0x00,0x04,0x04,0x3C,0x44,0x44,0x44,0x44,0x44,0x3C,0x00,0x00,0x00, 7, // 0x65 'e' 0x00,0x00,0x00,0x38,0x44,0x44,0x7C,0x40,0x44,0x38,0x00,0x00,0x00, 4, // 0x66 'f' 0x00,0x30,0x40,0xE0,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 7, // 0x67 'g' 0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x44,0x44,0x3C,0x04,0x44,0x38, 7, // 0x68 'h' 0x00,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x44,0x44,0x00,0x00,0x00, 3, // 0x69 'i' 0x00,0x40,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 5, // 0x6A 'j' 0x00,0x10,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x90,0x60,0x00, 6, // 0x6B 'k' 0x00,0x40,0x40,0x44,0x48,0x50,0x60,0x50,0x48,0x44,0x00,0x00,0x00, 3, // 0x6C 'l' 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 9, // 0x6D 'm' 0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x00,0x49,0x00,0x49,0x00,0x49,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x6E 'n' 0x00,0x00,0x00,0x58,0x64,0x44,0x44,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x6F 'o' 0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x70 'p' 0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x44,0x78,0x40,0x40,0x40, 7, // 0x71 'q' 0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x44,0x44,0x3C,0x04,0x04,0x04, 6, // 0x72 'r' 0x00,0x00,0x00,0x58,0x24,0x20,0x20,0x20,0x20,0x70,0x00,0x00,0x00, 7, // 0x73 's' 0x00,0x00,0x00,0x38,0x44,0x40,0x38,0x04,0x44,0x38,0x00,0x00,0x00, 5, // 0x74 't' 0x00,0x20,0x20,0x70,0x20,0x20,0x20,0x20,0x20,0x18,0x00,0x00,0x00, 7, // 0x75 'u' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x4C,0x34,0x00,0x00,0x00, 6, // 0x76 'v' 0x00,0x00,0x00,0x44,0x44,0x44,0x28,0x28,0x10,0x10,0x00,0x00,0x00, 9, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x49,0x00,0x49,0x00,0x49,0x00,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x78 'x' 0x00,0x00,0x00,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x00,0x00,0x00, 7, // 0x79 'y' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x3C,0x04,0x08,0x70, 6, // 0x7A 'z' 0x00,0x00,0x00,0x7C,0x04,0x08,0x10,0x20,0x40,0x7C,0x00,0x00,0x00, 5, // 0x7B '{' 0x18,0x20,0x20,0x20,0x20,0xC0,0x20,0x20,0x20,0x20,0x18,0x00,0x00, 3, // 0x7C '|' 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00, 5, // 0x7D '}' 0xC0,0x20,0x20,0x20,0x20,0x18,0x20,0x20,0x20,0x20,0xC0,0x00,0x00, 7, // 0x7E '~' 0x00,0x60,0x92,0x92,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x7F '' 0x00,0x10,0x38,0x6C,0x44,0x44,0x7C,0x00,0x00,0x00,0x00,0x00,0x00, 0 }; const int8u mcs5x10_mono[] = { 10, 2, 32, 128-32, 0x00,0x00,0x0B,0x00,0x16,0x00,0x21,0x00,0x2C,0x00,0x37,0x00,0x42,0x00,0x4D,0x00,0x58,0x00, 0x63,0x00,0x6E,0x00,0x79,0x00,0x84,0x00,0x8F,0x00,0x9A,0x00,0xA5,0x00,0xB0,0x00,0xBB,0x00, 0xC6,0x00,0xD1,0x00,0xDC,0x00,0xE7,0x00,0xF2,0x00,0xFD,0x00,0x08,0x01,0x13,0x01,0x1E,0x01, 0x29,0x01,0x34,0x01,0x3F,0x01,0x4A,0x01,0x55,0x01,0x60,0x01,0x6B,0x01,0x76,0x01,0x81,0x01, 0x8C,0x01,0x97,0x01,0xA2,0x01,0xAD,0x01,0xB8,0x01,0xC3,0x01,0xCE,0x01,0xD9,0x01,0xE4,0x01, 0xEF,0x01,0xFA,0x01,0x05,0x02,0x10,0x02,0x1B,0x02,0x26,0x02,0x31,0x02,0x3C,0x02,0x47,0x02, 0x52,0x02,0x5D,0x02,0x68,0x02,0x73,0x02,0x7E,0x02,0x89,0x02,0x94,0x02,0x9F,0x02,0xAA,0x02, 0xB5,0x02,0xC0,0x02,0xCB,0x02,0xD6,0x02,0xE1,0x02,0xEC,0x02,0xF7,0x02,0x02,0x03,0x0D,0x03, 0x18,0x03,0x23,0x03,0x2E,0x03,0x39,0x03,0x44,0x03,0x4F,0x03,0x5A,0x03,0x65,0x03,0x70,0x03, 0x7B,0x03,0x86,0x03,0x91,0x03,0x9C,0x03,0xA7,0x03,0xB2,0x03,0xBD,0x03,0xC8,0x03,0xD3,0x03, 0xDE,0x03,0xE9,0x03,0xF4,0x03,0xFF,0x03,0x0A,0x04,0x15,0x04, 5, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x21 '!' 0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00, 5, // 0x22 '"' 0x00,0x50,0x50,0xA0,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x23 '#' 0x00,0x50,0x50,0xF8,0x50,0x50,0x50,0xF8,0x50,0x50, 5, // 0x24 '$' 0x00,0x40,0x60,0x90,0x80,0x60,0x10,0x90,0x60,0x20, 5, // 0x25 '%' 0x00,0x00,0x90,0x90,0x20,0x20,0x40,0x40,0x90,0x90, 5, // 0x26 '&' 0x00,0x40,0xA0,0xA0,0xA0,0x40,0xA8,0x90,0x90,0x68, 5, // 0x27 ''' 0x00,0x20,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x28 '(' 0x10,0x20,0x20,0x40,0x40,0x40,0x40,0x20,0x20,0x10, 5, // 0x29 ')' 0x40,0x20,0x20,0x10,0x10,0x10,0x10,0x20,0x20,0x40, 5, // 0x2A '*' 0x00,0x00,0x90,0x60,0xF0,0x60,0x90,0x00,0x00,0x00, 5, // 0x2B '+' 0x00,0x00,0x00,0x20,0x20,0xF8,0x20,0x20,0x00,0x00, 5, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0xC0, 5, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00, 5, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00, 5, // 0x2F '/' 0x00,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x80,0x00, 5, // 0x30 '0' 0x00,0x70,0x90,0x90,0x90,0x90,0x90,0x90,0xE0,0x00, 5, // 0x31 '1' 0x00,0x20,0x60,0x20,0x20,0x20,0x20,0x20,0x70,0x00, 5, // 0x32 '2' 0x00,0x60,0x90,0x90,0x10,0x20,0x40,0x80,0xF0,0x00, 5, // 0x33 '3' 0x00,0x60,0x90,0x10,0x60,0x10,0x10,0x90,0x60,0x00, 5, // 0x34 '4' 0x00,0x10,0x30,0x50,0x50,0x90,0xF0,0x10,0x10,0x00, 5, // 0x35 '5' 0x00,0xF0,0x80,0x80,0xE0,0x10,0x10,0x90,0x60,0x00, 5, // 0x36 '6' 0x00,0x60,0x80,0x80,0xE0,0x90,0x90,0x90,0x60,0x00, 5, // 0x37 '7' 0x00,0xF0,0x10,0x10,0x20,0x20,0x40,0x40,0x40,0x00, 5, // 0x38 '8' 0x00,0x60,0x90,0x90,0x60,0x90,0x90,0x90,0x60,0x00, 5, // 0x39 '9' 0x00,0x60,0x90,0x90,0x90,0x70,0x10,0x10,0x60,0x00, 5, // 0x3A ':' 0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x60,0x60,0x00, 5, // 0x3B ';' 0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x60,0x60,0xC0, 5, // 0x3C '<' 0x00,0x08,0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x08, 5, // 0x3D '=' 0x00,0x00,0x00,0x00,0xF0,0x00,0xF0,0x00,0x00,0x00, 5, // 0x3E '>' 0x00,0x80,0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x80, 5, // 0x3F '?' 0x00,0x60,0x90,0x10,0x10,0x20,0x40,0x00,0x40,0x00, 5, // 0x40 '@' 0x00,0x60,0x90,0x90,0xB0,0xB0,0x80,0x80,0x70,0x00, 5, // 0x41 'A' 0x00,0x60,0x90,0x90,0x90,0xF0,0x90,0x90,0x90,0x00, 5, // 0x42 'B' 0x00,0xE0,0x90,0x90,0xE0,0x90,0x90,0x90,0xE0,0x00, 5, // 0x43 'C' 0x00,0x60,0x90,0x80,0x80,0x80,0x80,0x90,0x60,0x00, 5, // 0x44 'D' 0x00,0xE0,0x90,0x90,0x90,0x90,0x90,0x90,0xE0,0x00, 5, // 0x45 'E' 0x00,0xF0,0x80,0x80,0xF0,0x80,0x80,0x80,0xF0,0x00, 5, // 0x46 'F' 0x00,0xF0,0x80,0x80,0xF0,0x80,0x80,0x80,0x80,0x00, 5, // 0x47 'G' 0x00,0x60,0x90,0x80,0x80,0xB0,0x90,0x90,0x60,0x00, 5, // 0x48 'H' 0x00,0x90,0x90,0x90,0x90,0xF0,0x90,0x90,0x90,0x00, 5, // 0x49 'I' 0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x70,0x00, 5, // 0x4A 'J' 0x00,0x70,0x20,0x20,0x20,0x20,0x20,0xA0,0x40,0x00, 5, // 0x4B 'K' 0x00,0x90,0xA0,0xA0,0xC0,0xC0,0xA0,0xA0,0x90,0x00, 5, // 0x4C 'L' 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xF0,0x00, 5, // 0x4D 'M' 0x00,0x90,0x90,0xF0,0xF0,0x90,0x90,0x90,0x90,0x00, 5, // 0x4E 'N' 0x00,0x90,0x90,0xD0,0xD0,0xB0,0xB0,0x90,0x90,0x00, 5, // 0x4F 'O' 0x00,0x60,0x90,0x90,0x90,0x90,0x90,0x90,0x60,0x00, 5, // 0x50 'P' 0x00,0xE0,0x90,0x90,0x90,0xE0,0x80,0x80,0x80,0x00, 5, // 0x51 'Q' 0x00,0x60,0x90,0x90,0x90,0x90,0x90,0x90,0x60,0x30, 5, // 0x52 'R' 0x00,0xE0,0x90,0x90,0x90,0xE0,0xA0,0x90,0x90,0x00, 5, // 0x53 'S' 0x00,0x60,0x90,0x80,0x60,0x10,0x90,0x90,0x60,0x00, 5, // 0x54 'T' 0x00,0xF8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00, 5, // 0x55 'U' 0x00,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x60,0x00, 5, // 0x56 'V' 0x00,0x90,0x90,0x90,0x50,0x50,0x50,0x20,0x20,0x00, 5, // 0x57 'W' 0x00,0x90,0x90,0x90,0x90,0x90,0xF0,0xF0,0x90,0x00, 5, // 0x58 'X' 0x00,0x90,0x90,0x90,0x60,0x60,0x90,0x90,0x90,0x00, 5, // 0x59 'Y' 0x00,0x88,0x88,0x88,0x50,0x20,0x20,0x20,0x20,0x00, 5, // 0x5A 'Z' 0x00,0xF0,0x10,0x20,0x20,0x40,0x40,0x80,0xF0,0x00, 5, // 0x5B '[' 0x60,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x60, 5, // 0x5C '\' 0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08, 5, // 0x5D ']' 0x60,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x60, 5, // 0x5E '^' 0x00,0x20,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00, 5, // 0x60 '`' 0x00,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x61 'a' 0x00,0x00,0x00,0x60,0x10,0x70,0x90,0x90,0x70,0x00, 5, // 0x62 'b' 0x00,0x80,0x80,0xE0,0x90,0x90,0x90,0x90,0xE0,0x00, 5, // 0x63 'c' 0x00,0x00,0x00,0x60,0x90,0x80,0x80,0x90,0x60,0x00, 5, // 0x64 'd' 0x00,0x10,0x10,0x70,0x90,0x90,0x90,0x90,0x70,0x00, 5, // 0x65 'e' 0x00,0x00,0x00,0x60,0x90,0x90,0xF0,0x80,0x70,0x00, 5, // 0x66 'f' 0x00,0x30,0x40,0xE0,0x40,0x40,0x40,0x40,0x40,0x00, 5, // 0x67 'g' 0x00,0x00,0x00,0x70,0x90,0x90,0x90,0x70,0x10,0xE0, 5, // 0x68 'h' 0x00,0x80,0x80,0xE0,0x90,0x90,0x90,0x90,0x90,0x00, 5, // 0x69 'i' 0x00,0x20,0x00,0x60,0x20,0x20,0x20,0x20,0x70,0x00, 5, // 0x6A 'j' 0x00,0x20,0x00,0x60,0x20,0x20,0x20,0x20,0x20,0xC0, 5, // 0x6B 'k' 0x00,0x80,0x80,0x90,0xA0,0xC0,0xA0,0x90,0x90,0x00, 5, // 0x6C 'l' 0x00,0x60,0x20,0x20,0x20,0x20,0x20,0x20,0x70,0x00, 5, // 0x6D 'm' 0x00,0x00,0x00,0x90,0xF0,0x90,0x90,0x90,0x90,0x00, 5, // 0x6E 'n' 0x00,0x00,0x00,0xE0,0x90,0x90,0x90,0x90,0x90,0x00, 5, // 0x6F 'o' 0x00,0x00,0x00,0x60,0x90,0x90,0x90,0x90,0x60,0x00, 5, // 0x70 'p' 0x00,0x00,0x00,0xE0,0x90,0x90,0x90,0xE0,0x80,0x80, 5, // 0x71 'q' 0x00,0x00,0x00,0x70,0x90,0x90,0x90,0x70,0x10,0x10, 5, // 0x72 'r' 0x00,0x00,0x00,0xB0,0x50,0x40,0x40,0x40,0xE0,0x00, 5, // 0x73 's' 0x00,0x00,0x00,0x60,0x90,0x40,0x20,0x90,0x60,0x00, 5, // 0x74 't' 0x00,0x40,0x40,0xE0,0x40,0x40,0x40,0x50,0x20,0x00, 5, // 0x75 'u' 0x00,0x00,0x00,0x90,0x90,0x90,0x90,0x90,0x70,0x00, 5, // 0x76 'v' 0x00,0x00,0x00,0x90,0x90,0x50,0x50,0x20,0x20,0x00, 5, // 0x77 'w' 0x00,0x00,0x00,0x90,0x90,0x90,0x90,0xF0,0x90,0x00, 5, // 0x78 'x' 0x00,0x00,0x00,0x90,0x90,0x60,0x60,0x90,0x90,0x00, 5, // 0x79 'y' 0x00,0x00,0x00,0x90,0x90,0x90,0x90,0x70,0x10,0xE0, 5, // 0x7A 'z' 0x00,0x00,0x00,0xF0,0x10,0x20,0x40,0x80,0xF0,0x00, 5, // 0x7B '{' 0x30,0x40,0x40,0x40,0x80,0x40,0x40,0x40,0x40,0x30, 5, // 0x7C '|' 0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 5, // 0x7D '}' 0xC0,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0xC0, 5, // 0x7E '~' 0x00,0x40,0xA8,0x10,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x7F '' 0x00,0x20,0x70,0xD8,0x88,0x88,0xF8,0x00,0x00,0x00, 0 }; const int8u mcs5x11_mono[] = { 11, 3, 32, 128-32, 0x00,0x00,0x0C,0x00,0x18,0x00,0x24,0x00,0x30,0x00,0x3C,0x00,0x48,0x00,0x54,0x00,0x60,0x00, 0x6C,0x00,0x78,0x00,0x84,0x00,0x90,0x00,0x9C,0x00,0xA8,0x00,0xB4,0x00,0xC0,0x00,0xCC,0x00, 0xD8,0x00,0xE4,0x00,0xF0,0x00,0xFC,0x00,0x08,0x01,0x14,0x01,0x20,0x01,0x2C,0x01,0x38,0x01, 0x44,0x01,0x50,0x01,0x5C,0x01,0x68,0x01,0x74,0x01,0x80,0x01,0x8C,0x01,0x98,0x01,0xA4,0x01, 0xB0,0x01,0xBC,0x01,0xC8,0x01,0xD4,0x01,0xE0,0x01,0xEC,0x01,0xF8,0x01,0x04,0x02,0x10,0x02, 0x1C,0x02,0x28,0x02,0x34,0x02,0x40,0x02,0x4C,0x02,0x58,0x02,0x64,0x02,0x70,0x02,0x7C,0x02, 0x88,0x02,0x94,0x02,0xA0,0x02,0xAC,0x02,0xB8,0x02,0xC4,0x02,0xD0,0x02,0xDC,0x02,0xE8,0x02, 0xF4,0x02,0x00,0x03,0x0C,0x03,0x18,0x03,0x24,0x03,0x30,0x03,0x3C,0x03,0x48,0x03,0x54,0x03, 0x60,0x03,0x6C,0x03,0x78,0x03,0x84,0x03,0x90,0x03,0x9C,0x03,0xA8,0x03,0xB4,0x03,0xC0,0x03, 0xCC,0x03,0xD8,0x03,0xE4,0x03,0xF0,0x03,0xFC,0x03,0x08,0x04,0x14,0x04,0x20,0x04,0x2C,0x04, 0x38,0x04,0x44,0x04,0x50,0x04,0x5C,0x04,0x68,0x04,0x74,0x04, 5, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x21 '!' 0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,0x00, 5, // 0x22 '"' 0x00,0x50,0x50,0xA0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x23 '#' 0x00,0x50,0x50,0xF8,0x50,0x50,0x50,0xF8,0x50,0x50,0x00, 5, // 0x24 '$' 0x00,0x40,0x60,0x90,0x80,0x60,0x10,0x90,0x60,0x20,0x00, 5, // 0x25 '%' 0x00,0x00,0x90,0x90,0x20,0x20,0x40,0x40,0x90,0x90,0x00, 5, // 0x26 '&' 0x00,0x40,0xA0,0xA0,0x40,0xA8,0x90,0x90,0x68,0x00,0x00, 5, // 0x27 ''' 0x00,0x20,0x20,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x28 '(' 0x00,0x10,0x20,0x20,0x40,0x40,0x40,0x40,0x20,0x20,0x10, 5, // 0x29 ')' 0x00,0x40,0x20,0x20,0x10,0x10,0x10,0x10,0x20,0x20,0x40, 5, // 0x2A '*' 0x00,0x00,0x90,0x60,0xF0,0x60,0x90,0x00,0x00,0x00,0x00, 5, // 0x2B '+' 0x00,0x00,0x00,0x20,0x20,0xF8,0x20,0x20,0x00,0x00,0x00, 5, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x40,0x80, 5, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x00, 5, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00, 5, // 0x2F '/' 0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x80,0x80,0x00, 5, // 0x30 '0' 0x00,0x70,0x90,0x90,0x90,0x90,0x90,0x90,0xE0,0x00,0x00, 5, // 0x31 '1' 0x00,0x20,0x60,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00, 5, // 0x32 '2' 0x00,0x60,0x90,0x90,0x10,0x20,0x40,0x80,0xF0,0x00,0x00, 5, // 0x33 '3' 0x00,0x60,0x90,0x10,0x60,0x10,0x10,0x90,0x60,0x00,0x00, 5, // 0x34 '4' 0x00,0x10,0x30,0x50,0x50,0x90,0xF8,0x10,0x10,0x00,0x00, 5, // 0x35 '5' 0x00,0xF0,0x80,0xE0,0x90,0x10,0x10,0x90,0x60,0x00,0x00, 5, // 0x36 '6' 0x00,0x60,0x90,0x80,0xE0,0x90,0x90,0x90,0x60,0x00,0x00, 5, // 0x37 '7' 0x00,0xF0,0x10,0x10,0x20,0x20,0x40,0x40,0x40,0x00,0x00, 5, // 0x38 '8' 0x00,0x60,0x90,0x90,0x60,0x90,0x90,0x90,0x60,0x00,0x00, 5, // 0x39 '9' 0x00,0x60,0x90,0x90,0x90,0x70,0x10,0x90,0x60,0x00,0x00, 5, // 0x3A ':' 0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x60,0x60,0x00,0x00, 5, // 0x3B ';' 0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x60,0x60,0x40,0x80, 5, // 0x3C '<' 0x00,0x08,0x10,0x20,0x40,0x80,0x40,0x20,0x10,0x08,0x00, 5, // 0x3D '=' 0x00,0x00,0x00,0x00,0xF0,0x00,0x00,0xF0,0x00,0x00,0x00, 5, // 0x3E '>' 0x00,0x80,0x40,0x20,0x10,0x08,0x10,0x20,0x40,0x80,0x00, 5, // 0x3F '?' 0x00,0x60,0x90,0x10,0x10,0x20,0x40,0x00,0x40,0x00,0x00, 5, // 0x40 '@' 0x00,0x60,0x90,0x90,0xB0,0xB0,0x80,0x80,0x70,0x00,0x00, 5, // 0x41 'A' 0x00,0x60,0x90,0x90,0x90,0xF0,0x90,0x90,0x90,0x00,0x00, 5, // 0x42 'B' 0x00,0xE0,0x90,0x90,0xE0,0x90,0x90,0x90,0xE0,0x00,0x00, 5, // 0x43 'C' 0x00,0x60,0x90,0x80,0x80,0x80,0x80,0x90,0x60,0x00,0x00, 5, // 0x44 'D' 0x00,0xE0,0x90,0x90,0x90,0x90,0x90,0x90,0xE0,0x00,0x00, 5, // 0x45 'E' 0x00,0xF0,0x80,0x80,0xE0,0x80,0x80,0x80,0xF0,0x00,0x00, 5, // 0x46 'F' 0x00,0xF0,0x80,0x80,0xE0,0x80,0x80,0x80,0x80,0x00,0x00, 5, // 0x47 'G' 0x00,0x60,0x90,0x80,0x80,0xB0,0x90,0x90,0x60,0x00,0x00, 5, // 0x48 'H' 0x00,0x90,0x90,0x90,0xF0,0x90,0x90,0x90,0x90,0x00,0x00, 5, // 0x49 'I' 0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00, 5, // 0x4A 'J' 0x00,0x70,0x20,0x20,0x20,0x20,0xA0,0xA0,0x40,0x00,0x00, 5, // 0x4B 'K' 0x00,0x90,0xA0,0xA0,0xC0,0xA0,0xA0,0x90,0x90,0x00,0x00, 5, // 0x4C 'L' 0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xF0,0x00,0x00, 5, // 0x4D 'M' 0x00,0x90,0xF0,0xF0,0x90,0x90,0x90,0x90,0x90,0x00,0x00, 5, // 0x4E 'N' 0x00,0x90,0x90,0xD0,0xD0,0xB0,0xB0,0x90,0x90,0x00,0x00, 5, // 0x4F 'O' 0x00,0x60,0x90,0x90,0x90,0x90,0x90,0x90,0x60,0x00,0x00, 5, // 0x50 'P' 0x00,0xE0,0x90,0x90,0x90,0xE0,0x80,0x80,0x80,0x00,0x00, 5, // 0x51 'Q' 0x00,0x60,0x90,0x90,0x90,0x90,0x90,0x90,0x60,0x30,0x00, 5, // 0x52 'R' 0x00,0xE0,0x90,0x90,0x90,0xE0,0xA0,0x90,0x90,0x00,0x00, 5, // 0x53 'S' 0x00,0x60,0x90,0x80,0x60,0x10,0x90,0x90,0x60,0x00,0x00, 5, // 0x54 'T' 0x00,0xF8,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00, 5, // 0x55 'U' 0x00,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x60,0x00,0x00, 5, // 0x56 'V' 0x00,0x90,0x90,0x90,0x50,0x50,0x50,0x20,0x20,0x00,0x00, 5, // 0x57 'W' 0x00,0x90,0x90,0x90,0x90,0x90,0xF0,0xF0,0x90,0x00,0x00, 5, // 0x58 'X' 0x00,0x90,0x90,0x90,0x60,0x60,0x90,0x90,0x90,0x00,0x00, 5, // 0x59 'Y' 0x00,0x88,0x88,0x88,0x50,0x20,0x20,0x20,0x20,0x00,0x00, 5, // 0x5A 'Z' 0x00,0xF0,0x10,0x20,0x20,0x40,0x40,0x80,0xF0,0x00,0x00, 5, // 0x5B '[' 0x00,0x60,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x60, 5, // 0x5C '\' 0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x00, 5, // 0x5D ']' 0x00,0x60,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x60, 5, // 0x5E '^' 0x00,0x20,0x50,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x00,0x00, 5, // 0x60 '`' 0x00,0x40,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x61 'a' 0x00,0x00,0x00,0x60,0x10,0x70,0x90,0x90,0x70,0x00,0x00, 5, // 0x62 'b' 0x00,0x80,0x80,0xE0,0x90,0x90,0x90,0x90,0xE0,0x00,0x00, 5, // 0x63 'c' 0x00,0x00,0x00,0x60,0x90,0x80,0x80,0x90,0x60,0x00,0x00, 5, // 0x64 'd' 0x00,0x10,0x10,0x70,0x90,0x90,0x90,0x90,0x70,0x00,0x00, 5, // 0x65 'e' 0x00,0x00,0x00,0x60,0x90,0x90,0xF0,0x80,0x70,0x00,0x00, 5, // 0x66 'f' 0x00,0x30,0x40,0xE0,0x40,0x40,0x40,0x40,0x40,0x00,0x00, 5, // 0x67 'g' 0x00,0x00,0x00,0x70,0x90,0x90,0x90,0x90,0x70,0x10,0xE0, 5, // 0x68 'h' 0x00,0x80,0x80,0xE0,0x90,0x90,0x90,0x90,0x90,0x00,0x00, 5, // 0x69 'i' 0x00,0x20,0x00,0x60,0x20,0x20,0x20,0x20,0x70,0x00,0x00, 5, // 0x6A 'j' 0x00,0x20,0x00,0x60,0x20,0x20,0x20,0x20,0x20,0xA0,0x40, 5, // 0x6B 'k' 0x00,0x80,0x80,0x90,0xA0,0xC0,0xA0,0x90,0x90,0x00,0x00, 5, // 0x6C 'l' 0x00,0x60,0x20,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00, 5, // 0x6D 'm' 0x00,0x00,0x00,0x90,0xF0,0x90,0x90,0x90,0x90,0x00,0x00, 5, // 0x6E 'n' 0x00,0x00,0x00,0xE0,0x90,0x90,0x90,0x90,0x90,0x00,0x00, 5, // 0x6F 'o' 0x00,0x00,0x00,0x60,0x90,0x90,0x90,0x90,0x60,0x00,0x00, 5, // 0x70 'p' 0x00,0x00,0x00,0xE0,0x90,0x90,0x90,0x90,0xE0,0x80,0x80, 5, // 0x71 'q' 0x00,0x00,0x00,0x70,0x90,0x90,0x90,0x90,0x70,0x10,0x10, 5, // 0x72 'r' 0x00,0x00,0x00,0xA0,0x50,0x40,0x40,0x40,0xE0,0x00,0x00, 5, // 0x73 's' 0x00,0x00,0x00,0x60,0x90,0x40,0x20,0x90,0x60,0x00,0x00, 5, // 0x74 't' 0x00,0x40,0x40,0xE0,0x40,0x40,0x40,0x40,0x30,0x00,0x00, 5, // 0x75 'u' 0x00,0x00,0x00,0x90,0x90,0x90,0x90,0x90,0x70,0x00,0x00, 5, // 0x76 'v' 0x00,0x00,0x00,0x90,0x90,0x50,0x50,0x20,0x20,0x00,0x00, 5, // 0x77 'w' 0x00,0x00,0x00,0x90,0x90,0x90,0x90,0xF0,0x90,0x00,0x00, 5, // 0x78 'x' 0x00,0x00,0x00,0x90,0x90,0x60,0x60,0x90,0x90,0x00,0x00, 5, // 0x79 'y' 0x00,0x00,0x00,0x90,0x90,0x90,0x90,0x90,0x70,0x10,0xE0, 5, // 0x7A 'z' 0x00,0x00,0x00,0xF0,0x10,0x20,0x40,0x80,0xF0,0x00,0x00, 5, // 0x7B '{' 0x30,0x40,0x40,0x40,0x40,0x80,0x40,0x40,0x40,0x40,0x30, 5, // 0x7C '|' 0x00,0x20,0x20,0x20,0x20,0x00,0x20,0x20,0x20,0x20,0x00, 5, // 0x7D '}' 0xC0,0x20,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0xC0, 5, // 0x7E '~' 0x00,0x40,0xA8,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x7F '' 0x00,0x20,0x70,0xD8,0x88,0x88,0xF8,0x00,0x00,0x00,0x00, 0 }; const int8u mcs6x10_mono[] = { 10, 3, 32, 128-32, 0x00,0x00,0x0B,0x00,0x16,0x00,0x21,0x00,0x2C,0x00,0x37,0x00,0x42,0x00,0x4D,0x00,0x58,0x00, 0x63,0x00,0x6E,0x00,0x79,0x00,0x84,0x00,0x8F,0x00,0x9A,0x00,0xA5,0x00,0xB0,0x00,0xBB,0x00, 0xC6,0x00,0xD1,0x00,0xDC,0x00,0xE7,0x00,0xF2,0x00,0xFD,0x00,0x08,0x01,0x13,0x01,0x1E,0x01, 0x29,0x01,0x34,0x01,0x3F,0x01,0x4A,0x01,0x55,0x01,0x60,0x01,0x6B,0x01,0x76,0x01,0x81,0x01, 0x8C,0x01,0x97,0x01,0xA2,0x01,0xAD,0x01,0xB8,0x01,0xC3,0x01,0xCE,0x01,0xD9,0x01,0xE4,0x01, 0xEF,0x01,0xFA,0x01,0x05,0x02,0x10,0x02,0x1B,0x02,0x26,0x02,0x31,0x02,0x3C,0x02,0x47,0x02, 0x52,0x02,0x5D,0x02,0x68,0x02,0x73,0x02,0x7E,0x02,0x89,0x02,0x94,0x02,0x9F,0x02,0xAA,0x02, 0xB5,0x02,0xC0,0x02,0xCB,0x02,0xD6,0x02,0xE1,0x02,0xEC,0x02,0xF7,0x02,0x02,0x03,0x0D,0x03, 0x18,0x03,0x23,0x03,0x2E,0x03,0x39,0x03,0x44,0x03,0x4F,0x03,0x5A,0x03,0x65,0x03,0x70,0x03, 0x7B,0x03,0x86,0x03,0x91,0x03,0x9C,0x03,0xA7,0x03,0xB2,0x03,0xBD,0x03,0xC8,0x03,0xD3,0x03, 0xDE,0x03,0xE9,0x03,0xF4,0x03,0xFF,0x03,0x0A,0x04,0x15,0x04, 6, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x21 '!' 0x00,0x10,0x10,0x10,0x10,0x10,0x00,0x10,0x00,0x00, 6, // 0x22 '"' 0x00,0x28,0x28,0x50,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x23 '#' 0x00,0x28,0x28,0x7C,0x28,0x28,0x7C,0x28,0x28,0x00, 6, // 0x24 '$' 0x10,0x38,0x54,0x50,0x38,0x14,0x54,0x38,0x10,0x00, 6, // 0x25 '%' 0x00,0x08,0xC8,0xD0,0x10,0x20,0x2C,0x4C,0x40,0x00, 6, // 0x26 '&' 0x00,0x20,0x50,0x50,0x24,0x54,0x48,0x34,0x00,0x00, 6, // 0x27 ''' 0x00,0x10,0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x28 '(' 0x08,0x10,0x10,0x20,0x20,0x20,0x10,0x10,0x08,0x00, 6, // 0x29 ')' 0x20,0x10,0x10,0x08,0x08,0x08,0x10,0x10,0x20,0x00, 6, // 0x2A '*' 0x00,0x00,0x28,0x7C,0x38,0x7C,0x28,0x00,0x00,0x00, 6, // 0x2B '+' 0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x00,0x00,0x00, 6, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x20,0x40, 6, // 0x2D '-' 0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00, 6, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00, 6, // 0x2F '/' 0x00,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x00, 6, // 0x30 '0' 0x00,0x38,0x44,0x4C,0x54,0x64,0x44,0x38,0x00,0x00, 6, // 0x31 '1' 0x00,0x10,0x30,0x10,0x10,0x10,0x10,0x38,0x00,0x00, 6, // 0x32 '2' 0x00,0x38,0x44,0x04,0x18,0x20,0x40,0x7C,0x00,0x00, 6, // 0x33 '3' 0x00,0x38,0x44,0x04,0x38,0x04,0x44,0x38,0x00,0x00, 6, // 0x34 '4' 0x00,0x08,0x18,0x28,0x48,0x7C,0x08,0x08,0x00,0x00, 6, // 0x35 '5' 0x00,0x7C,0x40,0x40,0x78,0x04,0x44,0x38,0x00,0x00, 6, // 0x36 '6' 0x00,0x38,0x40,0x40,0x78,0x44,0x44,0x38,0x00,0x00, 6, // 0x37 '7' 0x00,0x7C,0x04,0x08,0x10,0x20,0x20,0x20,0x00,0x00, 6, // 0x38 '8' 0x00,0x38,0x44,0x44,0x38,0x44,0x44,0x38,0x00,0x00, 6, // 0x39 '9' 0x00,0x38,0x44,0x44,0x3C,0x04,0x04,0x38,0x00,0x00, 6, // 0x3A ':' 0x00,0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x00,0x00, 6, // 0x3B ';' 0x00,0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x20,0x40, 6, // 0x3C '<' 0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x00, 6, // 0x3D '=' 0x00,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x00, 6, // 0x3E '>' 0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x00, 6, // 0x3F '?' 0x00,0x38,0x44,0x04,0x18,0x10,0x00,0x10,0x00,0x00, 6, // 0x40 '@' 0x00,0x38,0x44,0x5C,0x54,0x5C,0x40,0x38,0x00,0x00, 6, // 0x41 'A' 0x00,0x38,0x44,0x44,0x44,0x7C,0x44,0x44,0x00,0x00, 6, // 0x42 'B' 0x00,0x78,0x44,0x44,0x78,0x44,0x44,0x78,0x00,0x00, 6, // 0x43 'C' 0x00,0x38,0x44,0x40,0x40,0x40,0x44,0x38,0x00,0x00, 6, // 0x44 'D' 0x00,0x78,0x44,0x44,0x44,0x44,0x44,0x78,0x00,0x00, 6, // 0x45 'E' 0x00,0x7C,0x40,0x40,0x78,0x40,0x40,0x7C,0x00,0x00, 6, // 0x46 'F' 0x00,0x7C,0x40,0x40,0x78,0x40,0x40,0x40,0x00,0x00, 6, // 0x47 'G' 0x00,0x38,0x44,0x40,0x4C,0x44,0x44,0x3C,0x00,0x00, 6, // 0x48 'H' 0x00,0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x00,0x00, 6, // 0x49 'I' 0x00,0x38,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00, 6, // 0x4A 'J' 0x00,0x1C,0x08,0x08,0x08,0x48,0x48,0x30,0x00,0x00, 6, // 0x4B 'K' 0x00,0x44,0x48,0x50,0x60,0x50,0x48,0x44,0x00,0x00, 6, // 0x4C 'L' 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x7C,0x00,0x00, 6, // 0x4D 'M' 0x00,0x44,0x6C,0x54,0x54,0x44,0x44,0x44,0x00,0x00, 6, // 0x4E 'N' 0x00,0x44,0x44,0x64,0x54,0x4C,0x44,0x44,0x00,0x00, 6, // 0x4F 'O' 0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 6, // 0x50 'P' 0x00,0x78,0x44,0x44,0x78,0x40,0x40,0x40,0x00,0x00, 6, // 0x51 'Q' 0x00,0x38,0x44,0x44,0x44,0x54,0x48,0x34,0x00,0x00, 6, // 0x52 'R' 0x00,0x78,0x44,0x44,0x78,0x48,0x44,0x44,0x00,0x00, 6, // 0x53 'S' 0x00,0x38,0x44,0x40,0x38,0x04,0x44,0x38,0x00,0x00, 6, // 0x54 'T' 0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, 6, // 0x55 'U' 0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 6, // 0x56 'V' 0x00,0x44,0x44,0x44,0x44,0x28,0x28,0x10,0x00,0x00, 6, // 0x57 'W' 0x00,0x44,0x44,0x54,0x54,0x54,0x54,0x28,0x00,0x00, 6, // 0x58 'X' 0x00,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x00,0x00, 6, // 0x59 'Y' 0x00,0x44,0x44,0x44,0x28,0x10,0x10,0x10,0x00,0x00, 6, // 0x5A 'Z' 0x00,0x78,0x08,0x10,0x20,0x40,0x40,0x78,0x00,0x00, 6, // 0x5B '[' 0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x00, 6, // 0x5C '\' 0x00,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x00, 6, // 0x5D ']' 0x38,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x38,0x00, 6, // 0x5E '^' 0x10,0x28,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00, 6, // 0x60 '`' 0x00,0x10,0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x61 'a' 0x00,0x00,0x00,0x38,0x04,0x3C,0x44,0x3C,0x00,0x00, 6, // 0x62 'b' 0x00,0x40,0x40,0x78,0x44,0x44,0x44,0x78,0x00,0x00, 6, // 0x63 'c' 0x00,0x00,0x00,0x38,0x44,0x40,0x40,0x3C,0x00,0x00, 6, // 0x64 'd' 0x00,0x04,0x04,0x3C,0x44,0x44,0x44,0x3C,0x00,0x00, 6, // 0x65 'e' 0x00,0x00,0x00,0x38,0x44,0x78,0x40,0x3C,0x00,0x00, 6, // 0x66 'f' 0x00,0x0C,0x10,0x10,0x38,0x10,0x10,0x10,0x00,0x00, 6, // 0x67 'g' 0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x3C,0x04,0x38, 6, // 0x68 'h' 0x00,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x00,0x00, 6, // 0x69 'i' 0x00,0x10,0x00,0x30,0x10,0x10,0x10,0x38,0x00,0x00, 6, // 0x6A 'j' 0x00,0x08,0x00,0x18,0x08,0x08,0x08,0x08,0x48,0x30, 6, // 0x6B 'k' 0x00,0x40,0x40,0x48,0x50,0x60,0x50,0x48,0x00,0x00, 6, // 0x6C 'l' 0x00,0x30,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00, 6, // 0x6D 'm' 0x00,0x00,0x00,0x68,0x54,0x54,0x44,0x44,0x00,0x00, 6, // 0x6E 'n' 0x00,0x00,0x00,0x58,0x64,0x44,0x44,0x44,0x00,0x00, 6, // 0x6F 'o' 0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x38,0x00,0x00, 6, // 0x70 'p' 0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x78,0x40,0x40, 6, // 0x71 'q' 0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x3C,0x04,0x04, 6, // 0x72 'r' 0x00,0x00,0x00,0x58,0x24,0x20,0x20,0x70,0x00,0x00, 6, // 0x73 's' 0x00,0x00,0x00,0x38,0x40,0x38,0x04,0x78,0x00,0x00, 6, // 0x74 't' 0x00,0x10,0x10,0x38,0x10,0x10,0x14,0x08,0x00,0x00, 6, // 0x75 'u' 0x00,0x00,0x00,0x44,0x44,0x44,0x4C,0x34,0x00,0x00, 6, // 0x76 'v' 0x00,0x00,0x00,0x44,0x44,0x44,0x28,0x10,0x00,0x00, 6, // 0x77 'w' 0x00,0x00,0x00,0x44,0x44,0x54,0x7C,0x28,0x00,0x00, 6, // 0x78 'x' 0x00,0x00,0x00,0x48,0x48,0x30,0x48,0x48,0x00,0x00, 6, // 0x79 'y' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x3C,0x04,0x38, 6, // 0x7A 'z' 0x00,0x00,0x00,0x78,0x08,0x30,0x40,0x78,0x00,0x00, 6, // 0x7B '{' 0x18,0x20,0x20,0x20,0xC0,0x20,0x20,0x20,0x18,0x00, 6, // 0x7C '|' 0x10,0x10,0x10,0x10,0x00,0x10,0x10,0x10,0x10,0x00, 6, // 0x7D '}' 0x60,0x10,0x10,0x10,0x0C,0x10,0x10,0x10,0x60,0x00, 6, // 0x7E '~' 0x00,0x48,0xA8,0x90,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x7F '' 0x00,0x10,0x38,0x6C,0x44,0x44,0x7C,0x00,0x00,0x00, 0 }; const int8u mcs6x11_mono[] = { 11, 3, 32, 128-32, 0x00,0x00,0x0C,0x00,0x18,0x00,0x24,0x00,0x30,0x00,0x3C,0x00,0x48,0x00,0x54,0x00,0x60,0x00, 0x6C,0x00,0x78,0x00,0x84,0x00,0x90,0x00,0x9C,0x00,0xA8,0x00,0xB4,0x00,0xC0,0x00,0xCC,0x00, 0xD8,0x00,0xE4,0x00,0xF0,0x00,0xFC,0x00,0x08,0x01,0x14,0x01,0x20,0x01,0x2C,0x01,0x38,0x01, 0x44,0x01,0x50,0x01,0x5C,0x01,0x68,0x01,0x74,0x01,0x80,0x01,0x8C,0x01,0x98,0x01,0xA4,0x01, 0xB0,0x01,0xBC,0x01,0xC8,0x01,0xD4,0x01,0xE0,0x01,0xEC,0x01,0xF8,0x01,0x04,0x02,0x10,0x02, 0x1C,0x02,0x28,0x02,0x34,0x02,0x40,0x02,0x4C,0x02,0x58,0x02,0x64,0x02,0x70,0x02,0x7C,0x02, 0x88,0x02,0x94,0x02,0xA0,0x02,0xAC,0x02,0xB8,0x02,0xC4,0x02,0xD0,0x02,0xDC,0x02,0xE8,0x02, 0xF4,0x02,0x00,0x03,0x0C,0x03,0x18,0x03,0x24,0x03,0x30,0x03,0x3C,0x03,0x48,0x03,0x54,0x03, 0x60,0x03,0x6C,0x03,0x78,0x03,0x84,0x03,0x90,0x03,0x9C,0x03,0xA8,0x03,0xB4,0x03,0xC0,0x03, 0xCC,0x03,0xD8,0x03,0xE4,0x03,0xF0,0x03,0xFC,0x03,0x08,0x04,0x14,0x04,0x20,0x04,0x2C,0x04, 0x38,0x04,0x44,0x04,0x50,0x04,0x5C,0x04,0x68,0x04,0x74,0x04, 6, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x21 '!' 0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,0x00, 6, // 0x22 '"' 0x00,0x28,0x28,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x23 '#' 0x00,0x28,0x28,0x7C,0x28,0x28,0x7C,0x28,0x28,0x00,0x00, 6, // 0x24 '$' 0x00,0x10,0x38,0x54,0x50,0x38,0x14,0x54,0x38,0x10,0x00, 6, // 0x25 '%' 0x00,0x68,0xA8,0xD0,0x10,0x20,0x2C,0x54,0x58,0x00,0x00, 6, // 0x26 '&' 0x00,0x20,0x50,0x50,0x20,0x54,0x54,0x48,0x34,0x00,0x00, 6, // 0x27 ''' 0x00,0x10,0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x28 '(' 0x08,0x10,0x10,0x20,0x20,0x20,0x20,0x10,0x10,0x08,0x00, 6, // 0x29 ')' 0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x00, 6, // 0x2A '*' 0x00,0x00,0x28,0x7C,0x38,0x7C,0x28,0x00,0x00,0x00,0x00, 6, // 0x2B '+' 0x00,0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x00,0x00,0x00, 6, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x20,0x40, 6, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00, 6, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00, 6, // 0x2F '/' 0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x00, 6, // 0x30 '0' 0x00,0x38,0x44,0x44,0x54,0x54,0x44,0x44,0x38,0x00,0x00, 6, // 0x31 '1' 0x00,0x10,0x30,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00, 6, // 0x32 '2' 0x00,0x38,0x44,0x44,0x08,0x10,0x20,0x40,0x7C,0x00,0x00, 6, // 0x33 '3' 0x00,0x38,0x44,0x04,0x38,0x04,0x04,0x44,0x38,0x00,0x00, 6, // 0x34 '4' 0x00,0x08,0x18,0x28,0x28,0x48,0x7C,0x08,0x08,0x00,0x00, 6, // 0x35 '5' 0x00,0x7C,0x40,0x78,0x44,0x04,0x04,0x44,0x38,0x00,0x00, 6, // 0x36 '6' 0x00,0x38,0x44,0x40,0x78,0x44,0x44,0x44,0x38,0x00,0x00, 6, // 0x37 '7' 0x00,0x7C,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x00,0x00, 6, // 0x38 '8' 0x00,0x38,0x44,0x44,0x38,0x44,0x44,0x44,0x38,0x00,0x00, 6, // 0x39 '9' 0x00,0x38,0x44,0x44,0x3C,0x04,0x04,0x44,0x38,0x00,0x00, 6, // 0x3A ':' 0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x00,0x00, 6, // 0x3B ';' 0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x20,0x40, 6, // 0x3C '<' 0x00,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x00, 6, // 0x3D '=' 0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x00, 6, // 0x3E '>' 0x00,0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x00, 6, // 0x3F '?' 0x00,0x38,0x44,0x04,0x08,0x10,0x10,0x00,0x10,0x00,0x00, 6, // 0x40 '@' 0x00,0x38,0x44,0x5C,0x54,0x54,0x4C,0x40,0x38,0x00,0x00, 6, // 0x41 'A' 0x00,0x38,0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x00,0x00, 6, // 0x42 'B' 0x00,0x78,0x44,0x44,0x78,0x44,0x44,0x44,0x78,0x00,0x00, 6, // 0x43 'C' 0x00,0x38,0x44,0x40,0x40,0x40,0x40,0x44,0x38,0x00,0x00, 6, // 0x44 'D' 0x00,0x70,0x48,0x44,0x44,0x44,0x44,0x48,0x70,0x00,0x00, 6, // 0x45 'E' 0x00,0x7C,0x40,0x40,0x78,0x40,0x40,0x40,0x7C,0x00,0x00, 6, // 0x46 'F' 0x00,0x7C,0x40,0x40,0x78,0x40,0x40,0x40,0x40,0x00,0x00, 6, // 0x47 'G' 0x00,0x38,0x44,0x40,0x40,0x5C,0x44,0x4C,0x34,0x00,0x00, 6, // 0x48 'H' 0x00,0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x44,0x00,0x00, 6, // 0x49 'I' 0x00,0x38,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00, 6, // 0x4A 'J' 0x00,0x1C,0x08,0x08,0x08,0x08,0x48,0x48,0x30,0x00,0x00, 6, // 0x4B 'K' 0x00,0x44,0x48,0x50,0x60,0x50,0x48,0x44,0x44,0x00,0x00, 6, // 0x4C 'L' 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7C,0x00,0x00, 6, // 0x4D 'M' 0x00,0x44,0x6C,0x54,0x54,0x54,0x44,0x44,0x44,0x00,0x00, 6, // 0x4E 'N' 0x00,0x44,0x64,0x64,0x54,0x54,0x4C,0x4C,0x44,0x00,0x00, 6, // 0x4F 'O' 0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 6, // 0x50 'P' 0x00,0x78,0x44,0x44,0x44,0x78,0x40,0x40,0x40,0x00,0x00, 6, // 0x51 'Q' 0x00,0x38,0x44,0x44,0x44,0x44,0x54,0x48,0x34,0x00,0x00, 6, // 0x52 'R' 0x00,0x78,0x44,0x44,0x44,0x78,0x48,0x44,0x44,0x00,0x00, 6, // 0x53 'S' 0x00,0x38,0x44,0x40,0x38,0x04,0x04,0x44,0x38,0x00,0x00, 6, // 0x54 'T' 0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, 6, // 0x55 'U' 0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 6, // 0x56 'V' 0x00,0x44,0x44,0x44,0x28,0x28,0x28,0x10,0x10,0x00,0x00, 6, // 0x57 'W' 0x00,0x44,0x44,0x54,0x54,0x54,0x54,0x54,0x28,0x00,0x00, 6, // 0x58 'X' 0x00,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x44,0x00,0x00, 6, // 0x59 'Y' 0x00,0x44,0x44,0x44,0x28,0x10,0x10,0x10,0x10,0x00,0x00, 6, // 0x5A 'Z' 0x00,0x7C,0x04,0x08,0x10,0x20,0x40,0x40,0x7C,0x00,0x00, 6, // 0x5B '[' 0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x00, 6, // 0x5C '\' 0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x00, 6, // 0x5D ']' 0x38,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x38,0x00, 6, // 0x5E '^' 0x00,0x10,0x28,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00, 6, // 0x60 '`' 0x00,0x20,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x61 'a' 0x00,0x00,0x00,0x38,0x04,0x3C,0x44,0x44,0x3C,0x00,0x00, 6, // 0x62 'b' 0x00,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x78,0x00,0x00, 6, // 0x63 'c' 0x00,0x00,0x00,0x38,0x44,0x40,0x40,0x44,0x38,0x00,0x00, 6, // 0x64 'd' 0x00,0x04,0x04,0x3C,0x44,0x44,0x44,0x44,0x3C,0x00,0x00, 6, // 0x65 'e' 0x00,0x00,0x00,0x38,0x44,0x7C,0x40,0x44,0x38,0x00,0x00, 6, // 0x66 'f' 0x00,0x0C,0x10,0x38,0x10,0x10,0x10,0x10,0x10,0x00,0x00, 6, // 0x67 'g' 0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x44,0x3C,0x04,0x78, 6, // 0x68 'h' 0x00,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x44,0x00,0x00, 6, // 0x69 'i' 0x00,0x10,0x00,0x30,0x10,0x10,0x10,0x10,0x38,0x00,0x00, 6, // 0x6A 'j' 0x00,0x10,0x00,0x30,0x10,0x10,0x10,0x10,0x10,0x50,0x20, 6, // 0x6B 'k' 0x00,0x40,0x40,0x4C,0x50,0x60,0x50,0x48,0x44,0x00,0x00, 6, // 0x6C 'l' 0x00,0x30,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00, 6, // 0x6D 'm' 0x00,0x00,0x00,0x68,0x54,0x54,0x54,0x44,0x44,0x00,0x00, 6, // 0x6E 'n' 0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x44,0x00,0x00, 6, // 0x6F 'o' 0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 6, // 0x70 'p' 0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x78,0x40,0x40, 6, // 0x71 'q' 0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x44,0x3C,0x04,0x04, 6, // 0x72 'r' 0x00,0x00,0x00,0x58,0x24,0x20,0x20,0x20,0x70,0x00,0x00, 6, // 0x73 's' 0x00,0x00,0x00,0x38,0x44,0x30,0x08,0x44,0x38,0x00,0x00, 6, // 0x74 't' 0x00,0x20,0x20,0x70,0x20,0x20,0x20,0x20,0x18,0x00,0x00, 6, // 0x75 'u' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x4C,0x34,0x00,0x00, 6, // 0x76 'v' 0x00,0x00,0x00,0x44,0x44,0x28,0x28,0x10,0x10,0x00,0x00, 6, // 0x77 'w' 0x00,0x00,0x00,0x44,0x44,0x44,0x54,0x7C,0x28,0x00,0x00, 6, // 0x78 'x' 0x00,0x00,0x00,0x44,0x28,0x10,0x28,0x44,0x44,0x00,0x00, 6, // 0x79 'y' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x3C,0x08,0x70, 6, // 0x7A 'z' 0x00,0x00,0x00,0x7C,0x08,0x10,0x20,0x40,0x7C,0x00,0x00, 6, // 0x7B '{' 0x18,0x20,0x20,0x20,0xC0,0xC0,0x20,0x20,0x20,0x18,0x00, 6, // 0x7C '|' 0x00,0x10,0x10,0x10,0x10,0x00,0x10,0x10,0x10,0x10,0x00, 6, // 0x7D '}' 0x60,0x10,0x10,0x10,0x0C,0x0C,0x10,0x10,0x10,0x60,0x00, 6, // 0x7E '~' 0x00,0x24,0x54,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x7F '' 0x00,0x10,0x38,0x6C,0x44,0x44,0x7C,0x00,0x00,0x00,0x00, 0 }; const int8u mcs7x12_mono_high[] = { 12, 3, 32, 128-32, 0x00,0x00,0x0D,0x00,0x1A,0x00,0x27,0x00,0x34,0x00,0x41,0x00,0x4E,0x00,0x5B,0x00,0x68,0x00, 0x75,0x00,0x82,0x00,0x8F,0x00,0x9C,0x00,0xA9,0x00,0xB6,0x00,0xC3,0x00,0xD0,0x00,0xDD,0x00, 0xEA,0x00,0xF7,0x00,0x04,0x01,0x11,0x01,0x1E,0x01,0x2B,0x01,0x38,0x01,0x45,0x01,0x52,0x01, 0x5F,0x01,0x6C,0x01,0x79,0x01,0x86,0x01,0x93,0x01,0xA0,0x01,0xAD,0x01,0xBA,0x01,0xC7,0x01, 0xD4,0x01,0xE1,0x01,0xEE,0x01,0xFB,0x01,0x08,0x02,0x15,0x02,0x22,0x02,0x2F,0x02,0x3C,0x02, 0x49,0x02,0x56,0x02,0x63,0x02,0x70,0x02,0x7D,0x02,0x8A,0x02,0x97,0x02,0xA4,0x02,0xB1,0x02, 0xBE,0x02,0xCB,0x02,0xD8,0x02,0xE5,0x02,0xF2,0x02,0xFF,0x02,0x0C,0x03,0x19,0x03,0x26,0x03, 0x33,0x03,0x40,0x03,0x4D,0x03,0x5A,0x03,0x67,0x03,0x74,0x03,0x81,0x03,0x8E,0x03,0x9B,0x03, 0xA8,0x03,0xB5,0x03,0xC2,0x03,0xCF,0x03,0xDC,0x03,0xE9,0x03,0xF6,0x03,0x03,0x04,0x10,0x04, 0x1D,0x04,0x2A,0x04,0x37,0x04,0x44,0x04,0x51,0x04,0x5E,0x04,0x6B,0x04,0x78,0x04,0x85,0x04, 0x92,0x04,0x9F,0x04,0xAC,0x04,0xB9,0x04,0xC6,0x04,0xD3,0x04, 7, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x21 '!' 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x10,0x00,0x00, 7, // 0x22 '"' 0x28,0x28,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x23 '#' 0x24,0x24,0x24,0x7E,0x24,0x24,0x24,0x7E,0x24,0x24,0x24,0x00, 7, // 0x24 '$' 0x10,0x10,0x38,0x54,0x50,0x38,0x14,0x54,0x38,0x10,0x10,0x00, 7, // 0x25 '%' 0x32,0x54,0x64,0x08,0x08,0x10,0x10,0x26,0x2A,0x4C,0x00,0x00, 7, // 0x26 '&' 0x00,0x20,0x50,0x50,0x50,0x20,0x54,0x54,0x48,0x34,0x00,0x00, 7, // 0x27 ''' 0x10,0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x28 '(' 0x08,0x10,0x10,0x20,0x20,0x20,0x20,0x20,0x10,0x10,0x08,0x00, 7, // 0x29 ')' 0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x00, 7, // 0x2A '*' 0x00,0x00,0x10,0x54,0x38,0x7C,0x38,0x54,0x10,0x00,0x00,0x00, 7, // 0x2B '+' 0x00,0x00,0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x00,0x00,0x00, 7, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x20,0x40, 7, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00, 7, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00, 7, // 0x2F '/' 0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x00,0x00, 7, // 0x30 '0' 0x00,0x38,0x44,0x44,0x54,0x54,0x54,0x44,0x44,0x38,0x00,0x00, 7, // 0x31 '1' 0x00,0x10,0x30,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00, 7, // 0x32 '2' 0x00,0x38,0x44,0x04,0x04,0x08,0x10,0x20,0x40,0x7C,0x00,0x00, 7, // 0x33 '3' 0x00,0x38,0x44,0x04,0x04,0x38,0x04,0x04,0x44,0x38,0x00,0x00, 7, // 0x34 '4' 0x00,0x08,0x18,0x28,0x28,0x48,0x48,0x7C,0x08,0x08,0x00,0x00, 7, // 0x35 '5' 0x00,0x7C,0x40,0x40,0x78,0x44,0x04,0x04,0x44,0x38,0x00,0x00, 7, // 0x36 '6' 0x00,0x38,0x44,0x40,0x78,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x37 '7' 0x00,0x7C,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x00,0x00, 7, // 0x38 '8' 0x00,0x38,0x44,0x44,0x44,0x38,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x39 '9' 0x00,0x38,0x44,0x44,0x44,0x3C,0x04,0x04,0x44,0x38,0x00,0x00, 7, // 0x3A ':' 0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x30,0x30,0x00,0x00, 7, // 0x3B ';' 0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x30,0x30,0x20,0x40, 7, // 0x3C '<' 0x00,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x00,0x00, 7, // 0x3D '=' 0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x00,0x00, 7, // 0x3E '>' 0x00,0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x00,0x00, 7, // 0x3F '?' 0x00,0x38,0x44,0x04,0x04,0x08,0x10,0x10,0x00,0x10,0x00,0x00, 7, // 0x40 '@' 0x00,0x38,0x44,0x44,0x5C,0x54,0x54,0x4C,0x40,0x38,0x00,0x00, 7, // 0x41 'A' 0x00,0x38,0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x44,0x00,0x00, 7, // 0x42 'B' 0x00,0x78,0x44,0x44,0x44,0x78,0x44,0x44,0x44,0x78,0x00,0x00, 7, // 0x43 'C' 0x00,0x38,0x44,0x40,0x40,0x40,0x40,0x40,0x44,0x38,0x00,0x00, 7, // 0x44 'D' 0x00,0x70,0x48,0x44,0x44,0x44,0x44,0x44,0x48,0x70,0x00,0x00, 7, // 0x45 'E' 0x00,0x7C,0x40,0x40,0x40,0x78,0x40,0x40,0x40,0x7C,0x00,0x00, 7, // 0x46 'F' 0x00,0x7C,0x40,0x40,0x40,0x78,0x40,0x40,0x40,0x40,0x00,0x00, 7, // 0x47 'G' 0x00,0x38,0x44,0x40,0x40,0x5C,0x44,0x44,0x4C,0x34,0x00,0x00, 7, // 0x48 'H' 0x00,0x44,0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x44,0x00,0x00, 7, // 0x49 'I' 0x00,0x38,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00, 7, // 0x4A 'J' 0x00,0x1C,0x08,0x08,0x08,0x08,0x08,0x48,0x48,0x30,0x00,0x00, 7, // 0x4B 'K' 0x00,0x44,0x48,0x50,0x60,0x60,0x50,0x48,0x44,0x44,0x00,0x00, 7, // 0x4C 'L' 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7C,0x00,0x00, 7, // 0x4D 'M' 0x00,0x44,0x6C,0x6C,0x54,0x54,0x44,0x44,0x44,0x44,0x00,0x00, 7, // 0x4E 'N' 0x00,0x44,0x64,0x64,0x54,0x54,0x4C,0x4C,0x44,0x44,0x00,0x00, 7, // 0x4F 'O' 0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x50 'P' 0x00,0x78,0x44,0x44,0x44,0x44,0x78,0x40,0x40,0x40,0x00,0x00, 7, // 0x51 'Q' 0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x54,0x48,0x34,0x00,0x00, 7, // 0x52 'R' 0x00,0x78,0x44,0x44,0x44,0x44,0x78,0x48,0x44,0x44,0x00,0x00, 7, // 0x53 'S' 0x00,0x38,0x44,0x40,0x40,0x38,0x04,0x04,0x44,0x38,0x00,0x00, 7, // 0x54 'T' 0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, 7, // 0x55 'U' 0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x56 'V' 0x00,0x44,0x44,0x44,0x44,0x28,0x28,0x28,0x10,0x10,0x00,0x00, 7, // 0x57 'W' 0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x54,0x54,0x28,0x00,0x00, 7, // 0x58 'X' 0x00,0x44,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x44,0x00,0x00, 7, // 0x59 'Y' 0x00,0x44,0x44,0x44,0x44,0x28,0x10,0x10,0x10,0x10,0x00,0x00, 7, // 0x5A 'Z' 0x00,0x7C,0x04,0x04,0x08,0x10,0x20,0x40,0x40,0x7C,0x00,0x00, 7, // 0x5B '[' 0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x00, 7, // 0x5C '\' 0x00,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x00, 7, // 0x5D ']' 0x38,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x38,0x00, 7, // 0x5E '^' 0x00,0x10,0x28,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00, 7, // 0x60 '`' 0x00,0x20,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x61 'a' 0x00,0x00,0x00,0x38,0x04,0x3C,0x44,0x44,0x44,0x3C,0x00,0x00, 7, // 0x62 'b' 0x00,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x44,0x78,0x00,0x00, 7, // 0x63 'c' 0x00,0x00,0x00,0x38,0x44,0x40,0x40,0x40,0x44,0x38,0x00,0x00, 7, // 0x64 'd' 0x00,0x04,0x04,0x3C,0x44,0x44,0x44,0x44,0x44,0x3C,0x00,0x00, 7, // 0x65 'e' 0x00,0x00,0x00,0x38,0x44,0x44,0x7C,0x40,0x44,0x38,0x00,0x00, 7, // 0x66 'f' 0x00,0x0C,0x10,0x38,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, 7, // 0x67 'g' 0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x44,0x44,0x3C,0x04,0x78, 7, // 0x68 'h' 0x00,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x44,0x44,0x00,0x00, 7, // 0x69 'i' 0x00,0x10,0x00,0x30,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00, 7, // 0x6A 'j' 0x00,0x08,0x00,0x18,0x08,0x08,0x08,0x08,0x08,0x08,0x48,0x30, 7, // 0x6B 'k' 0x00,0x40,0x40,0x44,0x48,0x50,0x60,0x50,0x48,0x44,0x00,0x00, 7, // 0x6C 'l' 0x00,0x30,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00, 7, // 0x6D 'm' 0x00,0x00,0x00,0x68,0x54,0x54,0x44,0x44,0x44,0x44,0x00,0x00, 7, // 0x6E 'n' 0x00,0x00,0x00,0x58,0x64,0x44,0x44,0x44,0x44,0x44,0x00,0x00, 7, // 0x6F 'o' 0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x70 'p' 0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x44,0x78,0x40,0x40, 7, // 0x71 'q' 0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x44,0x44,0x3C,0x04,0x04, 7, // 0x72 'r' 0x00,0x00,0x00,0x58,0x24,0x20,0x20,0x20,0x20,0x70,0x00,0x00, 7, // 0x73 's' 0x00,0x00,0x00,0x38,0x44,0x40,0x38,0x04,0x44,0x38,0x00,0x00, 7, // 0x74 't' 0x00,0x20,0x20,0x70,0x20,0x20,0x20,0x20,0x24,0x18,0x00,0x00, 7, // 0x75 'u' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x4C,0x34,0x00,0x00, 7, // 0x76 'v' 0x00,0x00,0x00,0x44,0x44,0x44,0x28,0x28,0x10,0x10,0x00,0x00, 7, // 0x77 'w' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x54,0x54,0x28,0x00,0x00, 7, // 0x78 'x' 0x00,0x00,0x00,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x00,0x00, 7, // 0x79 'y' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x3C,0x08,0x70, 7, // 0x7A 'z' 0x00,0x00,0x00,0x7C,0x04,0x08,0x10,0x20,0x40,0x7C,0x00,0x00, 7, // 0x7B '{' 0x18,0x20,0x20,0x20,0x20,0xC0,0x20,0x20,0x20,0x20,0x18,0x00, 7, // 0x7C '|' 0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00, 7, // 0x7D '}' 0x60,0x10,0x10,0x10,0x10,0x0C,0x10,0x10,0x10,0x10,0x60,0x00, 7, // 0x7E '~' 0x00,0x60,0x92,0x92,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x7F '' 0x00,0x10,0x38,0x6C,0x44,0x44,0x7C,0x00,0x00,0x00,0x00,0x00, 0 }; const int8u mcs7x12_mono_low[] = { 12, 4, 32, 128-32, 0x00,0x00,0x0D,0x00,0x1A,0x00,0x27,0x00,0x34,0x00,0x41,0x00,0x4E,0x00,0x5B,0x00,0x68,0x00, 0x75,0x00,0x82,0x00,0x8F,0x00,0x9C,0x00,0xA9,0x00,0xB6,0x00,0xC3,0x00,0xD0,0x00,0xDD,0x00, 0xEA,0x00,0xF7,0x00,0x04,0x01,0x11,0x01,0x1E,0x01,0x2B,0x01,0x38,0x01,0x45,0x01,0x52,0x01, 0x5F,0x01,0x6C,0x01,0x79,0x01,0x86,0x01,0x93,0x01,0xA0,0x01,0xAD,0x01,0xBA,0x01,0xC7,0x01, 0xD4,0x01,0xE1,0x01,0xEE,0x01,0xFB,0x01,0x08,0x02,0x15,0x02,0x22,0x02,0x2F,0x02,0x3C,0x02, 0x49,0x02,0x56,0x02,0x63,0x02,0x70,0x02,0x7D,0x02,0x8A,0x02,0x97,0x02,0xA4,0x02,0xB1,0x02, 0xBE,0x02,0xCB,0x02,0xD8,0x02,0xE5,0x02,0xF2,0x02,0xFF,0x02,0x0C,0x03,0x19,0x03,0x26,0x03, 0x33,0x03,0x40,0x03,0x4D,0x03,0x5A,0x03,0x67,0x03,0x74,0x03,0x81,0x03,0x8E,0x03,0x9B,0x03, 0xA8,0x03,0xB5,0x03,0xC2,0x03,0xCF,0x03,0xDC,0x03,0xE9,0x03,0xF6,0x03,0x03,0x04,0x10,0x04, 0x1D,0x04,0x2A,0x04,0x37,0x04,0x44,0x04,0x51,0x04,0x5E,0x04,0x6B,0x04,0x78,0x04,0x85,0x04, 0x92,0x04,0x9F,0x04,0xAC,0x04,0xB9,0x04,0xC6,0x04,0xD3,0x04, 7, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x21 '!' 0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x10,0x00,0x00, 7, // 0x22 '"' 0x28,0x28,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x23 '#' 0x00,0x28,0x28,0x7C,0x28,0x28,0x28,0x7C,0x28,0x28,0x00,0x00, 7, // 0x24 '$' 0x00,0x10,0x38,0x54,0x50,0x38,0x14,0x54,0x38,0x10,0x00,0x00, 7, // 0x25 '%' 0x34,0x54,0x68,0x08,0x10,0x10,0x20,0x2C,0x54,0x58,0x00,0x00, 7, // 0x26 '&' 0x00,0x20,0x50,0x50,0x20,0x54,0x54,0x48,0x34,0x00,0x00,0x00, 7, // 0x27 ''' 0x00,0x10,0x10,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x28 '(' 0x08,0x10,0x10,0x20,0x20,0x20,0x20,0x20,0x10,0x10,0x08,0x00, 7, // 0x29 ')' 0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x00, 7, // 0x2A '*' 0x00,0x00,0x10,0x54,0x38,0x7C,0x38,0x54,0x10,0x00,0x00,0x00, 7, // 0x2B '+' 0x00,0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x00,0x00,0x00,0x00, 7, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x20,0x40,0x00, 7, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00, 7, // 0x2F '/' 0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x00,0x00, 7, // 0x30 '0' 0x00,0x38,0x44,0x44,0x54,0x54,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x31 '1' 0x00,0x10,0x30,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00,0x00, 7, // 0x32 '2' 0x00,0x38,0x44,0x44,0x08,0x10,0x20,0x40,0x7C,0x00,0x00,0x00, 7, // 0x33 '3' 0x00,0x38,0x44,0x04,0x38,0x04,0x04,0x44,0x38,0x00,0x00,0x00, 7, // 0x34 '4' 0x00,0x08,0x18,0x28,0x28,0x48,0x7C,0x08,0x08,0x00,0x00,0x00, 7, // 0x35 '5' 0x00,0x7C,0x40,0x78,0x44,0x04,0x04,0x44,0x38,0x00,0x00,0x00, 7, // 0x36 '6' 0x00,0x38,0x44,0x40,0x78,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x37 '7' 0x00,0x7C,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x00,0x00,0x00, 7, // 0x38 '8' 0x00,0x38,0x44,0x44,0x38,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x39 '9' 0x00,0x38,0x44,0x44,0x44,0x3C,0x04,0x44,0x38,0x00,0x00,0x00, 7, // 0x3A ':' 0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x00,0x00,0x00, 7, // 0x3B ';' 0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x30,0x30,0x20,0x40,0x00, 7, // 0x3C '<' 0x00,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x00,0x00, 7, // 0x3D '=' 0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x7C,0x00,0x00,0x00,0x00, 7, // 0x3E '>' 0x00,0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x00,0x00, 7, // 0x3F '?' 0x00,0x38,0x44,0x04,0x04,0x08,0x10,0x10,0x00,0x10,0x00,0x00, 7, // 0x40 '@' 0x00,0x38,0x44,0x44,0x5C,0x54,0x4C,0x40,0x38,0x00,0x00,0x00, 7, // 0x41 'A' 0x00,0x38,0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x42 'B' 0x00,0x78,0x44,0x44,0x78,0x44,0x44,0x44,0x78,0x00,0x00,0x00, 7, // 0x43 'C' 0x00,0x38,0x44,0x40,0x40,0x40,0x40,0x44,0x38,0x00,0x00,0x00, 7, // 0x44 'D' 0x00,0x70,0x48,0x44,0x44,0x44,0x44,0x48,0x70,0x00,0x00,0x00, 7, // 0x45 'E' 0x00,0x7C,0x40,0x40,0x78,0x40,0x40,0x40,0x7C,0x00,0x00,0x00, 7, // 0x46 'F' 0x00,0x7C,0x40,0x40,0x78,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 7, // 0x47 'G' 0x00,0x38,0x44,0x40,0x40,0x4C,0x44,0x4C,0x34,0x00,0x00,0x00, 7, // 0x48 'H' 0x00,0x44,0x44,0x44,0x7C,0x44,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x49 'I' 0x00,0x38,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00,0x00, 7, // 0x4A 'J' 0x00,0x1C,0x08,0x08,0x08,0x08,0x48,0x48,0x30,0x00,0x00,0x00, 7, // 0x4B 'K' 0x00,0x44,0x48,0x50,0x60,0x60,0x50,0x48,0x44,0x00,0x00,0x00, 7, // 0x4C 'L' 0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7C,0x00,0x00,0x00, 7, // 0x4D 'M' 0x00,0x44,0x6C,0x54,0x54,0x44,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x4E 'N' 0x00,0x44,0x64,0x64,0x54,0x54,0x4C,0x4C,0x44,0x00,0x00,0x00, 7, // 0x4F 'O' 0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x50 'P' 0x00,0x78,0x44,0x44,0x44,0x78,0x40,0x40,0x40,0x00,0x00,0x00, 7, // 0x51 'Q' 0x00,0x38,0x44,0x44,0x44,0x44,0x54,0x48,0x34,0x00,0x00,0x00, 7, // 0x52 'R' 0x00,0x78,0x44,0x44,0x44,0x78,0x48,0x44,0x44,0x00,0x00,0x00, 7, // 0x53 'S' 0x00,0x38,0x44,0x40,0x38,0x04,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x54 'T' 0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00, 7, // 0x55 'U' 0x00,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x56 'V' 0x00,0x44,0x44,0x44,0x28,0x28,0x28,0x10,0x10,0x00,0x00,0x00, 7, // 0x57 'W' 0x00,0x44,0x44,0x44,0x44,0x44,0x54,0x54,0x28,0x00,0x00,0x00, 7, // 0x58 'X' 0x00,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x59 'Y' 0x00,0x44,0x44,0x44,0x28,0x10,0x10,0x10,0x10,0x00,0x00,0x00, 7, // 0x5A 'Z' 0x00,0x7C,0x04,0x08,0x10,0x20,0x40,0x40,0x7C,0x00,0x00,0x00, 7, // 0x5B '[' 0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x00, 7, // 0x5C '\' 0x00,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x00, 7, // 0x5D ']' 0x38,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x38,0x00, 7, // 0x5E '^' 0x00,0x10,0x28,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00, 7, // 0x60 '`' 0x00,0x20,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x61 'a' 0x00,0x00,0x00,0x38,0x04,0x3C,0x44,0x44,0x3C,0x00,0x00,0x00, 7, // 0x62 'b' 0x00,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x78,0x00,0x00,0x00, 7, // 0x63 'c' 0x00,0x00,0x00,0x38,0x44,0x40,0x40,0x44,0x38,0x00,0x00,0x00, 7, // 0x64 'd' 0x00,0x04,0x04,0x3C,0x44,0x44,0x44,0x44,0x3C,0x00,0x00,0x00, 7, // 0x65 'e' 0x00,0x00,0x00,0x38,0x44,0x7C,0x40,0x44,0x38,0x00,0x00,0x00, 7, // 0x66 'f' 0x00,0x0C,0x10,0x38,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00, 7, // 0x67 'g' 0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x44,0x3C,0x04,0x44,0x38, 7, // 0x68 'h' 0x00,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x69 'i' 0x00,0x10,0x00,0x30,0x10,0x10,0x10,0x10,0x38,0x00,0x00,0x00, 7, // 0x6A 'j' 0x00,0x08,0x00,0x18,0x08,0x08,0x08,0x08,0x08,0x48,0x48,0x30, 7, // 0x6B 'k' 0x00,0x40,0x40,0x4C,0x50,0x60,0x50,0x48,0x44,0x00,0x00,0x00, 7, // 0x6C 'l' 0x00,0x30,0x10,0x10,0x10,0x10,0x10,0x10,0x38,0x00,0x00,0x00, 7, // 0x6D 'm' 0x00,0x00,0x00,0x68,0x54,0x54,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x6E 'n' 0x00,0x00,0x00,0x58,0x64,0x44,0x44,0x44,0x44,0x00,0x00,0x00, 7, // 0x6F 'o' 0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x38,0x00,0x00,0x00, 7, // 0x70 'p' 0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x78,0x40,0x40,0x40, 7, // 0x71 'q' 0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x44,0x3C,0x04,0x04,0x04, 7, // 0x72 'r' 0x00,0x00,0x00,0x58,0x24,0x20,0x20,0x20,0x70,0x00,0x00,0x00, 7, // 0x73 's' 0x00,0x00,0x00,0x38,0x44,0x30,0x08,0x44,0x38,0x00,0x00,0x00, 7, // 0x74 't' 0x00,0x20,0x20,0x70,0x20,0x20,0x20,0x24,0x18,0x00,0x00,0x00, 7, // 0x75 'u' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x4C,0x34,0x00,0x00,0x00, 7, // 0x76 'v' 0x00,0x00,0x00,0x44,0x44,0x28,0x28,0x10,0x10,0x00,0x00,0x00, 7, // 0x77 'w' 0x00,0x00,0x00,0x44,0x44,0x44,0x54,0x54,0x28,0x00,0x00,0x00, 7, // 0x78 'x' 0x00,0x00,0x00,0x44,0x28,0x10,0x28,0x44,0x44,0x00,0x00,0x00, 7, // 0x79 'y' 0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x3C,0x04,0x08,0x70, 7, // 0x7A 'z' 0x00,0x00,0x00,0x7C,0x08,0x10,0x20,0x40,0x7C,0x00,0x00,0x00, 7, // 0x7B '{' 0x18,0x20,0x20,0x20,0x20,0xC0,0x20,0x20,0x20,0x20,0x18,0x00, 7, // 0x7C '|' 0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00, 7, // 0x7D '}' 0x60,0x10,0x10,0x10,0x10,0x0C,0x10,0x10,0x10,0x10,0x60,0x00, 7, // 0x7E '~' 0x00,0x24,0x54,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x7F '' 0x00,0x10,0x38,0x6C,0x44,0x44,0x7C,0x00,0x00,0x00,0x00,0x00, 0 }; const int8u verdana12[] = { 12, 3, 32, 128-32, 0x00,0x00,0x0D,0x00,0x1A,0x00,0x27,0x00,0x34,0x00,0x41,0x00,0x5A,0x00,0x67,0x00,0x74,0x00, 0x81,0x00,0x8E,0x00,0x9B,0x00,0xA8,0x00,0xB5,0x00,0xC2,0x00,0xCF,0x00,0xDC,0x00,0xE9,0x00, 0xF6,0x00,0x03,0x01,0x10,0x01,0x1D,0x01,0x2A,0x01,0x37,0x01,0x44,0x01,0x51,0x01,0x5E,0x01, 0x6B,0x01,0x78,0x01,0x85,0x01,0x92,0x01,0x9F,0x01,0xAC,0x01,0xC5,0x01,0xD2,0x01,0xDF,0x01, 0xEC,0x01,0xF9,0x01,0x06,0x02,0x13,0x02,0x20,0x02,0x2D,0x02,0x3A,0x02,0x47,0x02,0x54,0x02, 0x61,0x02,0x7A,0x02,0x87,0x02,0xA0,0x02,0xAD,0x02,0xC6,0x02,0xD3,0x02,0xE0,0x02,0xED,0x02, 0xFA,0x02,0x07,0x03,0x20,0x03,0x2D,0x03,0x3A,0x03,0x47,0x03,0x54,0x03,0x61,0x03,0x6E,0x03, 0x7B,0x03,0x88,0x03,0x95,0x03,0xA2,0x03,0xAF,0x03,0xBC,0x03,0xC9,0x03,0xD6,0x03,0xE3,0x03, 0xF0,0x03,0xFD,0x03,0x0A,0x04,0x17,0x04,0x24,0x04,0x31,0x04,0x4A,0x04,0x57,0x04,0x64,0x04, 0x71,0x04,0x7E,0x04,0x8B,0x04,0x98,0x04,0xA5,0x04,0xB2,0x04,0xBF,0x04,0xCC,0x04,0xD9,0x04, 0xE6,0x04,0xF3,0x04,0x00,0x05,0x0D,0x05,0x1A,0x05,0x27,0x05, 3, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x21 '!' 0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,0x00, 5, // 0x22 '"' 0x00,0x00,0x50,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x23 '#' 0x00,0x00,0x00,0x00,0x28,0x7C,0x28,0x7C,0x28,0x00,0x00,0x00, 7, // 0x24 '$' 0x00,0x00,0x10,0x10,0x3C,0x50,0x30,0x18,0x14,0x78,0x10,0x10, 11, // 0x25 '%' 0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x00,0x4A,0x00,0x4A,0x00,0x35,0x80,0x0A,0x40,0x0A,0x40,0x11,0x80,0x00,0x00,0x00,0x00, 7, // 0x26 '&' 0x00,0x00,0x00,0x30,0x48,0x48,0x32,0x4A,0x44,0x3A,0x00,0x00, 3, // 0x27 ''' 0x00,0x00,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x28 '(' 0x00,0x00,0x10,0x20,0x40,0x40,0x40,0x40,0x40,0x40,0x20,0x10, 4, // 0x29 ')' 0x00,0x00,0x80,0x40,0x20,0x20,0x20,0x20,0x20,0x20,0x40,0x80, 7, // 0x2A '*' 0x00,0x10,0x54,0x38,0x54,0x10,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x2B '+' 0x00,0x00,0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x00,0x00,0x00, 3, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x80,0x00, 5, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00, 3, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x00,0x00, 4, // 0x2F '/' 0x00,0x00,0x10,0x10,0x20,0x20,0x40,0x40,0x40,0x80,0x80,0x00, 7, // 0x30 '0' 0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x31 '1' 0x00,0x00,0x00,0x10,0x30,0x10,0x10,0x10,0x10,0x38,0x00,0x00, 7, // 0x32 '2' 0x00,0x00,0x00,0x38,0x44,0x04,0x08,0x10,0x20,0x7C,0x00,0x00, 7, // 0x33 '3' 0x00,0x00,0x00,0x38,0x44,0x04,0x18,0x04,0x44,0x38,0x00,0x00, 7, // 0x34 '4' 0x00,0x00,0x00,0x08,0x18,0x28,0x48,0x7C,0x08,0x08,0x00,0x00, 7, // 0x35 '5' 0x00,0x00,0x00,0x7C,0x40,0x78,0x04,0x04,0x44,0x38,0x00,0x00, 7, // 0x36 '6' 0x00,0x00,0x00,0x18,0x20,0x40,0x78,0x44,0x44,0x38,0x00,0x00, 7, // 0x37 '7' 0x00,0x00,0x00,0x7C,0x04,0x08,0x08,0x10,0x10,0x10,0x00,0x00, 7, // 0x38 '8' 0x00,0x00,0x00,0x38,0x44,0x44,0x38,0x44,0x44,0x38,0x00,0x00, 7, // 0x39 '9' 0x00,0x00,0x00,0x38,0x44,0x44,0x3C,0x04,0x08,0x30,0x00,0x00, 4, // 0x3A ':' 0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x00,0x40,0x40,0x00,0x00, 4, // 0x3B ';' 0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x00,0x40,0x40,0x80,0x00, 7, // 0x3C '<' 0x00,0x00,0x00,0x00,0x04,0x18,0x60,0x18,0x04,0x00,0x00,0x00, 7, // 0x3D '=' 0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x7C,0x00,0x00,0x00,0x00, 7, // 0x3E '>' 0x00,0x00,0x00,0x00,0x40,0x30,0x0C,0x30,0x40,0x00,0x00,0x00, 6, // 0x3F '?' 0x00,0x00,0x00,0x70,0x08,0x08,0x10,0x20,0x00,0x20,0x00,0x00, 10, // 0x40 '@' 0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x20,0x80,0x4E,0x80,0x52,0x80,0x52,0x80,0x4D,0x00,0x20,0x00,0x1F,0x00,0x00,0x00, 8, // 0x41 'A' 0x00,0x00,0x00,0x18,0x18,0x24,0x24,0x7E,0x42,0x42,0x00,0x00, 7, // 0x42 'B' 0x00,0x00,0x00,0x70,0x48,0x48,0x78,0x44,0x44,0x78,0x00,0x00, 8, // 0x43 'C' 0x00,0x00,0x00,0x1C,0x22,0x40,0x40,0x40,0x22,0x1C,0x00,0x00, 8, // 0x44 'D' 0x00,0x00,0x00,0x78,0x44,0x42,0x42,0x42,0x44,0x78,0x00,0x00, 7, // 0x45 'E' 0x00,0x00,0x00,0x7C,0x40,0x40,0x78,0x40,0x40,0x7C,0x00,0x00, 6, // 0x46 'F' 0x00,0x00,0x00,0x7C,0x40,0x40,0x78,0x40,0x40,0x40,0x00,0x00, 8, // 0x47 'G' 0x00,0x00,0x00,0x1C,0x22,0x40,0x4E,0x42,0x22,0x1C,0x00,0x00, 8, // 0x48 'H' 0x00,0x00,0x00,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x00,0x00, 5, // 0x49 'I' 0x00,0x00,0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00, 5, // 0x4A 'J' 0x00,0x00,0x00,0x30,0x10,0x10,0x10,0x10,0x10,0xE0,0x00,0x00, 7, // 0x4B 'K' 0x00,0x00,0x00,0x44,0x48,0x50,0x60,0x50,0x48,0x44,0x00,0x00, 6, // 0x4C 'L' 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x7C,0x00,0x00, 9, // 0x4D 'M' 0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x63,0x00,0x55,0x00,0x55,0x00,0x49,0x00,0x49,0x00,0x41,0x00,0x00,0x00,0x00,0x00, 8, // 0x4E 'N' 0x00,0x00,0x00,0x42,0x62,0x52,0x4A,0x46,0x42,0x42,0x00,0x00, 9, // 0x4F 'O' 0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x22,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x22,0x00,0x1C,0x00,0x00,0x00,0x00,0x00, 7, // 0x50 'P' 0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x78,0x40,0x40,0x00,0x00, 9, // 0x51 'Q' 0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x22,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x22,0x00,0x1C,0x00,0x04,0x00,0x03,0x00, 7, // 0x52 'R' 0x00,0x00,0x00,0x78,0x44,0x44,0x78,0x50,0x48,0x44,0x00,0x00, 7, // 0x53 'S' 0x00,0x00,0x00,0x38,0x44,0x40,0x38,0x04,0x44,0x38,0x00,0x00, 7, // 0x54 'T' 0x00,0x00,0x00,0xFE,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, 8, // 0x55 'U' 0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00, 8, // 0x56 'V' 0x00,0x00,0x00,0x42,0x42,0x42,0x24,0x24,0x18,0x18,0x00,0x00, 9, // 0x57 'W' 0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x49,0x00,0x49,0x00,0x55,0x00,0x55,0x00,0x22,0x00,0x22,0x00,0x00,0x00,0x00,0x00, 7, // 0x58 'X' 0x00,0x00,0x00,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x00,0x00, 7, // 0x59 'Y' 0x00,0x00,0x00,0x44,0x44,0x28,0x28,0x10,0x10,0x10,0x00,0x00, 7, // 0x5A 'Z' 0x00,0x00,0x00,0x7C,0x04,0x08,0x10,0x20,0x40,0x7C,0x00,0x00, 4, // 0x5B '[' 0x00,0x00,0x60,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x60, 4, // 0x5C '\' 0x00,0x00,0x80,0x80,0x40,0x40,0x40,0x20,0x20,0x10,0x10,0x00, 4, // 0x5D ']' 0x00,0x00,0x60,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x60, 7, // 0x5E '^' 0x00,0x00,0x00,0x10,0x28,0x44,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC, 6, // 0x60 '`' 0x00,0x00,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x61 'a' 0x00,0x00,0x00,0x00,0x00,0x30,0x08,0x38,0x48,0x38,0x00,0x00, 6, // 0x62 'b' 0x00,0x00,0x40,0x40,0x40,0x70,0x48,0x48,0x48,0x70,0x00,0x00, 6, // 0x63 'c' 0x00,0x00,0x00,0x00,0x00,0x38,0x40,0x40,0x40,0x38,0x00,0x00, 6, // 0x64 'd' 0x00,0x00,0x08,0x08,0x08,0x38,0x48,0x48,0x48,0x38,0x00,0x00, 6, // 0x65 'e' 0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x78,0x40,0x38,0x00,0x00, 4, // 0x66 'f' 0x00,0x00,0x30,0x40,0x40,0xE0,0x40,0x40,0x40,0x40,0x00,0x00, 6, // 0x67 'g' 0x00,0x00,0x00,0x00,0x00,0x38,0x48,0x48,0x48,0x38,0x08,0x30, 6, // 0x68 'h' 0x00,0x00,0x40,0x40,0x40,0x70,0x48,0x48,0x48,0x48,0x00,0x00, 3, // 0x69 'i' 0x00,0x00,0x00,0x40,0x00,0x40,0x40,0x40,0x40,0x40,0x00,0x00, 3, // 0x6A 'j' 0x00,0x00,0x00,0x40,0x00,0xC0,0x40,0x40,0x40,0x40,0x40,0x80, 6, // 0x6B 'k' 0x00,0x00,0x40,0x40,0x40,0x48,0x50,0x60,0x50,0x48,0x00,0x00, 3, // 0x6C 'l' 0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00, 9, // 0x6D 'm' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x00,0x49,0x00,0x49,0x00,0x49,0x00,0x49,0x00,0x00,0x00,0x00,0x00, 6, // 0x6E 'n' 0x00,0x00,0x00,0x00,0x00,0x70,0x48,0x48,0x48,0x48,0x00,0x00, 6, // 0x6F 'o' 0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x48,0x48,0x30,0x00,0x00, 6, // 0x70 'p' 0x00,0x00,0x00,0x00,0x00,0x70,0x48,0x48,0x48,0x70,0x40,0x40, 6, // 0x71 'q' 0x00,0x00,0x00,0x00,0x00,0x38,0x48,0x48,0x48,0x38,0x08,0x08, 4, // 0x72 'r' 0x00,0x00,0x00,0x00,0x00,0x50,0x60,0x40,0x40,0x40,0x00,0x00, 6, // 0x73 's' 0x00,0x00,0x00,0x00,0x00,0x38,0x40,0x30,0x08,0x70,0x00,0x00, 4, // 0x74 't' 0x00,0x00,0x00,0x00,0x40,0xF0,0x40,0x40,0x40,0x30,0x00,0x00, 6, // 0x75 'u' 0x00,0x00,0x00,0x00,0x00,0x48,0x48,0x48,0x48,0x38,0x00,0x00, 6, // 0x76 'v' 0x00,0x00,0x00,0x00,0x00,0x48,0x48,0x48,0x30,0x30,0x00,0x00, 7, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x44,0x54,0x54,0x28,0x28,0x00,0x00, 6, // 0x78 'x' 0x00,0x00,0x00,0x00,0x00,0x48,0x48,0x30,0x48,0x48,0x00,0x00, 6, // 0x79 'y' 0x00,0x00,0x00,0x00,0x00,0x48,0x48,0x48,0x30,0x10,0x20,0x20, 5, // 0x7A 'z' 0x00,0x00,0x00,0x00,0x00,0x70,0x10,0x20,0x40,0x70,0x00,0x00, 6, // 0x7B '{' 0x00,0x00,0x18,0x20,0x20,0x20,0x20,0xC0,0x20,0x20,0x20,0x18, 5, // 0x7C '|' 0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 6, // 0x7D '}' 0x00,0x00,0x60,0x10,0x10,0x10,0x10,0x0C,0x10,0x10,0x10,0x60, 7, // 0x7E '~' 0x00,0x00,0x00,0x00,0x00,0x00,0x34,0x58,0x00,0x00,0x00,0x00, 9, // 0x7F '' 0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x7F,0x00,0x00,0x00,0x00,0x00, 0 }; const int8u verdana12_bold[] = { 12, 3, 32, 128-32, 0x00,0x00,0x0D,0x00,0x1A,0x00,0x27,0x00,0x34,0x00,0x41,0x00,0x5A,0x00,0x67,0x00,0x74,0x00, 0x81,0x00,0x8E,0x00,0x9B,0x00,0xA8,0x00,0xB5,0x00,0xC2,0x00,0xCF,0x00,0xDC,0x00,0xE9,0x00, 0xF6,0x00,0x03,0x01,0x10,0x01,0x1D,0x01,0x2A,0x01,0x37,0x01,0x44,0x01,0x51,0x01,0x5E,0x01, 0x6B,0x01,0x78,0x01,0x85,0x01,0x92,0x01,0x9F,0x01,0xAC,0x01,0xC5,0x01,0xD2,0x01,0xDF,0x01, 0xEC,0x01,0xF9,0x01,0x06,0x02,0x13,0x02,0x20,0x02,0x2D,0x02,0x3A,0x02,0x47,0x02,0x54,0x02, 0x61,0x02,0x6E,0x02,0x7B,0x02,0x88,0x02,0x95,0x02,0xA2,0x02,0xAF,0x02,0xBC,0x02,0xC9,0x02, 0xD6,0x02,0xE3,0x02,0xFC,0x02,0x09,0x03,0x16,0x03,0x23,0x03,0x30,0x03,0x3D,0x03,0x4A,0x03, 0x57,0x03,0x64,0x03,0x71,0x03,0x7E,0x03,0x8B,0x03,0x98,0x03,0xA5,0x03,0xB2,0x03,0xBF,0x03, 0xCC,0x03,0xD9,0x03,0xE6,0x03,0xF3,0x03,0x00,0x04,0x0D,0x04,0x26,0x04,0x33,0x04,0x40,0x04, 0x4D,0x04,0x5A,0x04,0x67,0x04,0x74,0x04,0x81,0x04,0x8E,0x04,0x9B,0x04,0xB4,0x04,0xC1,0x04, 0xCE,0x04,0xDB,0x04,0xE8,0x04,0xF5,0x04,0x02,0x05,0x0F,0x05, 3, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x21 '!' 0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x00,0x60,0x00,0x00, 5, // 0x22 '"' 0x00,0x00,0xD8,0xD8,0xD8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x23 '#' 0x00,0x00,0x00,0x14,0x14,0x7E,0x28,0xFC,0x50,0x50,0x00,0x00, 6, // 0x24 '$' 0x00,0x00,0x20,0x20,0x70,0xE8,0xE0,0x38,0xB8,0x70,0x20,0x20, 11, // 0x25 '%' 0x00,0x00,0x00,0x00,0x00,0x00,0x62,0x00,0x94,0x00,0x94,0x00,0x69,0x80,0x0A,0x40,0x0A,0x40,0x11,0x80,0x00,0x00,0x00,0x00, 8, // 0x26 '&' 0x00,0x00,0x00,0x70,0xD8,0xD8,0x76,0xDC,0xCC,0x76,0x00,0x00, 3, // 0x27 ''' 0x00,0x00,0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x28 '(' 0x00,0x00,0x30,0x60,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x60,0x30, 5, // 0x29 ')' 0x00,0x00,0xC0,0x60,0x30,0x30,0x30,0x30,0x30,0x30,0x60,0xC0, 6, // 0x2A '*' 0x00,0x00,0x20,0xA8,0x70,0xA8,0x20,0x00,0x00,0x00,0x00,0x00, 8, // 0x2B '+' 0x00,0x00,0x00,0x00,0x10,0x10,0x7C,0x10,0x10,0x00,0x00,0x00, 3, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x80,0x00, 4, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0x00, 3, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x00,0x00, 6, // 0x2F '/' 0x00,0x00,0x08,0x08,0x10,0x10,0x20,0x40,0x40,0x80,0x80,0x00, 6, // 0x30 '0' 0x00,0x00,0x00,0x70,0xD8,0xD8,0xD8,0xD8,0xD8,0x70,0x00,0x00, 6, // 0x31 '1' 0x00,0x00,0x00,0x30,0x70,0x30,0x30,0x30,0x30,0x78,0x00,0x00, 6, // 0x32 '2' 0x00,0x00,0x00,0x70,0x98,0x18,0x30,0x60,0xC0,0xF8,0x00,0x00, 6, // 0x33 '3' 0x00,0x00,0x00,0x70,0x98,0x18,0x70,0x18,0x98,0x70,0x00,0x00, 6, // 0x34 '4' 0x00,0x00,0x00,0x18,0x38,0x58,0x98,0xFC,0x18,0x18,0x00,0x00, 6, // 0x35 '5' 0x00,0x00,0x00,0xF8,0xC0,0xF0,0x18,0x18,0x98,0x70,0x00,0x00, 6, // 0x36 '6' 0x00,0x00,0x00,0x70,0xC0,0xF0,0xD8,0xD8,0xD8,0x70,0x00,0x00, 6, // 0x37 '7' 0x00,0x00,0x00,0xF8,0x18,0x30,0x30,0x60,0x60,0xC0,0x00,0x00, 6, // 0x38 '8' 0x00,0x00,0x00,0x70,0xD8,0xD8,0x70,0xD8,0xD8,0x70,0x00,0x00, 6, // 0x39 '9' 0x00,0x00,0x00,0x70,0xD8,0xD8,0xD8,0x78,0x18,0x70,0x00,0x00, 4, // 0x3A ':' 0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x60,0x60,0x00,0x00, 4, // 0x3B ';' 0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x60,0x60,0x40,0x00, 8, // 0x3C '<' 0x00,0x00,0x00,0x00,0x04,0x18,0x60,0x60,0x18,0x04,0x00,0x00, 8, // 0x3D '=' 0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x7C,0x00,0x00,0x00,0x00, 8, // 0x3E '>' 0x00,0x00,0x00,0x00,0x40,0x30,0x0C,0x0C,0x30,0x40,0x00,0x00, 6, // 0x3F '?' 0x00,0x00,0x00,0xF0,0x18,0x18,0x30,0x60,0x00,0x60,0x00,0x00, 9, // 0x40 '@' 0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x42,0x00,0x9D,0x00,0xA5,0x00,0xA5,0x00,0x9E,0x00,0x40,0x00,0x3C,0x00,0x00,0x00, 8, // 0x41 'A' 0x00,0x00,0x00,0x38,0x38,0x6C,0x6C,0x7C,0xC6,0xC6,0x00,0x00, 7, // 0x42 'B' 0x00,0x00,0x00,0xF8,0xCC,0xCC,0xF8,0xCC,0xCC,0xF8,0x00,0x00, 6, // 0x43 'C' 0x00,0x00,0x00,0x70,0xC8,0xC0,0xC0,0xC0,0xC8,0x70,0x00,0x00, 7, // 0x44 'D' 0x00,0x00,0x00,0xF8,0xCC,0xCC,0xCC,0xCC,0xCC,0xF8,0x00,0x00, 6, // 0x45 'E' 0x00,0x00,0x00,0xF8,0xC0,0xC0,0xF8,0xC0,0xC0,0xF8,0x00,0x00, 6, // 0x46 'F' 0x00,0x00,0x00,0xF8,0xC0,0xC0,0xF8,0xC0,0xC0,0xC0,0x00,0x00, 7, // 0x47 'G' 0x00,0x00,0x00,0x78,0xC4,0xC0,0xC0,0xDC,0xCC,0x7C,0x00,0x00, 7, // 0x48 'H' 0x00,0x00,0x00,0xCC,0xCC,0xCC,0xFC,0xCC,0xCC,0xCC,0x00,0x00, 5, // 0x49 'I' 0x00,0x00,0x00,0xF0,0x60,0x60,0x60,0x60,0x60,0xF0,0x00,0x00, 5, // 0x4A 'J' 0x00,0x00,0x00,0x70,0x30,0x30,0x30,0x30,0x30,0xE0,0x00,0x00, 7, // 0x4B 'K' 0x00,0x00,0x00,0xCC,0xD8,0xF0,0xE0,0xF0,0xD8,0xCC,0x00,0x00, 6, // 0x4C 'L' 0x00,0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xF8,0x00,0x00, 8, // 0x4D 'M' 0x00,0x00,0x00,0x82,0xC6,0xEE,0xB6,0xB6,0x86,0x86,0x00,0x00, 7, // 0x4E 'N' 0x00,0x00,0x00,0x84,0xC4,0xE4,0xB4,0x9C,0x8C,0x84,0x00,0x00, 8, // 0x4F 'O' 0x00,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x00,0x00, 7, // 0x50 'P' 0x00,0x00,0x00,0xF8,0xCC,0xCC,0xCC,0xF8,0xC0,0xC0,0x00,0x00, 8, // 0x51 'Q' 0x00,0x00,0x00,0x7C,0xC6,0xC6,0xC6,0xC6,0xC6,0x7C,0x18,0x0E, 7, // 0x52 'R' 0x00,0x00,0x00,0xF8,0xCC,0xCC,0xF8,0xD8,0xCC,0xC6,0x00,0x00, 6, // 0x53 'S' 0x00,0x00,0x00,0x70,0xC8,0xC0,0x70,0x18,0x98,0x70,0x00,0x00, 6, // 0x54 'T' 0x00,0x00,0x00,0xFC,0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x00, 7, // 0x55 'U' 0x00,0x00,0x00,0xCC,0xCC,0xCC,0xCC,0xCC,0xCC,0x78,0x00,0x00, 7, // 0x56 'V' 0x00,0x00,0x00,0xCC,0xCC,0x78,0x78,0x78,0x30,0x30,0x00,0x00, 11, // 0x57 'W' 0x00,0x00,0x00,0x00,0x00,0x00,0xCC,0xC0,0xCC,0xC0,0x6D,0x80,0x6D,0x80,0x73,0x80,0x33,0x00,0x33,0x00,0x00,0x00,0x00,0x00, 7, // 0x58 'X' 0x00,0x00,0x00,0xCC,0xCC,0x78,0x30,0x78,0xCC,0xCC,0x00,0x00, 7, // 0x59 'Y' 0x00,0x00,0x00,0xCC,0xCC,0x78,0x30,0x30,0x30,0x30,0x00,0x00, 6, // 0x5A 'Z' 0x00,0x00,0x00,0xF8,0x18,0x30,0x60,0xC0,0xC0,0xF8,0x00,0x00, 5, // 0x5B '[' 0x00,0x00,0x70,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x70, 6, // 0x5C '\' 0x00,0x00,0x80,0x80,0x40,0x40,0x20,0x10,0x10,0x08,0x08,0x00, 5, // 0x5D ']' 0x00,0x00,0x70,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x70, 8, // 0x5E '^' 0x00,0x00,0x00,0x18,0x3C,0x66,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC, 6, // 0x60 '`' 0x00,0x00,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x61 'a' 0x00,0x00,0x00,0x00,0x00,0x70,0x18,0x78,0xD8,0x78,0x00,0x00, 6, // 0x62 'b' 0x00,0x00,0xC0,0xC0,0xC0,0xF0,0xD8,0xD8,0xD8,0xF0,0x00,0x00, 5, // 0x63 'c' 0x00,0x00,0x00,0x00,0x00,0x70,0xC0,0xC0,0xC0,0x70,0x00,0x00, 6, // 0x64 'd' 0x00,0x00,0x18,0x18,0x18,0x78,0xD8,0xD8,0xD8,0x78,0x00,0x00, 6, // 0x65 'e' 0x00,0x00,0x00,0x00,0x00,0x70,0xD8,0xF8,0xC0,0x78,0x00,0x00, 5, // 0x66 'f' 0x00,0x00,0x38,0x60,0x60,0xF8,0x60,0x60,0x60,0x60,0x00,0x00, 6, // 0x67 'g' 0x00,0x00,0x00,0x00,0x00,0x78,0xD8,0xD8,0xD8,0x78,0x18,0x70, 6, // 0x68 'h' 0x00,0x00,0xC0,0xC0,0xC0,0xF0,0xD8,0xD8,0xD8,0xD8,0x00,0x00, 3, // 0x69 'i' 0x00,0x00,0x00,0xC0,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00, 4, // 0x6A 'j' 0x00,0x00,0x00,0x60,0x00,0xE0,0x60,0x60,0x60,0x60,0x60,0xC0, 6, // 0x6B 'k' 0x00,0x00,0xC0,0xC0,0xC0,0xD8,0xD8,0xF0,0xD8,0xD8,0x00,0x00, 3, // 0x6C 'l' 0x00,0x00,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x00,0x00, 9, // 0x6D 'm' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF6,0x00,0xDB,0x00,0xDB,0x00,0xDB,0x00,0xDB,0x00,0x00,0x00,0x00,0x00, 6, // 0x6E 'n' 0x00,0x00,0x00,0x00,0x00,0xF0,0xD8,0xD8,0xD8,0xD8,0x00,0x00, 6, // 0x6F 'o' 0x00,0x00,0x00,0x00,0x00,0x70,0xD8,0xD8,0xD8,0x70,0x00,0x00, 6, // 0x70 'p' 0x00,0x00,0x00,0x00,0x00,0xF0,0xD8,0xD8,0xD8,0xF0,0xC0,0xC0, 6, // 0x71 'q' 0x00,0x00,0x00,0x00,0x00,0x78,0xD8,0xD8,0xD8,0x78,0x18,0x18, 4, // 0x72 'r' 0x00,0x00,0x00,0x00,0x00,0xD0,0xE0,0xC0,0xC0,0xC0,0x00,0x00, 5, // 0x73 's' 0x00,0x00,0x00,0x00,0x00,0x70,0xC0,0xF0,0x30,0xE0,0x00,0x00, 5, // 0x74 't' 0x00,0x00,0x00,0x60,0x60,0xF8,0x60,0x60,0x60,0x38,0x00,0x00, 6, // 0x75 'u' 0x00,0x00,0x00,0x00,0x00,0xD8,0xD8,0xD8,0xD8,0x78,0x00,0x00, 6, // 0x76 'v' 0x00,0x00,0x00,0x00,0x00,0xD8,0xD8,0xD8,0x70,0x70,0x00,0x00, 9, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xDB,0x00,0xDB,0x00,0xDB,0x00,0x66,0x00,0x66,0x00,0x00,0x00,0x00,0x00, 6, // 0x78 'x' 0x00,0x00,0x00,0x00,0x00,0xD8,0xD8,0x70,0xD8,0xD8,0x00,0x00, 6, // 0x79 'y' 0x00,0x00,0x00,0x00,0x00,0xD8,0xD8,0xD8,0x70,0x70,0x30,0x60, 5, // 0x7A 'z' 0x00,0x00,0x00,0x00,0x00,0xF0,0x30,0x60,0xC0,0xF0,0x00,0x00, 6, // 0x7B '{' 0x00,0x00,0x18,0x30,0x30,0x30,0xE0,0x30,0x30,0x30,0x30,0x18, 5, // 0x7C '|' 0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 6, // 0x7D '}' 0x00,0x00,0xC0,0x60,0x60,0x60,0x38,0x60,0x60,0x60,0x60,0xC0, 8, // 0x7E '~' 0x00,0x00,0x00,0x00,0x00,0x00,0x62,0x92,0x8C,0x00,0x00,0x00, 9, // 0x7F '' 0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x7F,0x00,0x00,0x00,0x00,0x00, 0 }; const int8u verdana13[] = { 13, 3, 32, 128-32, 0x00,0x00,0x0E,0x00,0x1C,0x00,0x2A,0x00,0x45,0x00,0x53,0x00,0x6E,0x00,0x7C,0x00,0x8A,0x00, 0x98,0x00,0xA6,0x00,0xB4,0x00,0xCF,0x00,0xDD,0x00,0xEB,0x00,0xF9,0x00,0x07,0x01,0x15,0x01, 0x23,0x01,0x31,0x01,0x3F,0x01,0x4D,0x01,0x5B,0x01,0x69,0x01,0x77,0x01,0x85,0x01,0x93,0x01, 0xA1,0x01,0xAF,0x01,0xCA,0x01,0xE5,0x01,0x00,0x02,0x0E,0x02,0x29,0x02,0x37,0x02,0x45,0x02, 0x60,0x02,0x7B,0x02,0x89,0x02,0x97,0x02,0xB2,0x02,0xC0,0x02,0xCE,0x02,0xDC,0x02,0xEA,0x02, 0xF8,0x02,0x13,0x03,0x21,0x03,0x3C,0x03,0x4A,0x03,0x65,0x03,0x73,0x03,0x81,0x03,0x8F,0x03, 0x9D,0x03,0xAB,0x03,0xC6,0x03,0xD4,0x03,0xE2,0x03,0xF0,0x03,0xFE,0x03,0x0C,0x04,0x1A,0x04, 0x35,0x04,0x43,0x04,0x51,0x04,0x5F,0x04,0x6D,0x04,0x7B,0x04,0x89,0x04,0x97,0x04,0xA5,0x04, 0xB3,0x04,0xC1,0x04,0xCF,0x04,0xDD,0x04,0xEB,0x04,0xF9,0x04,0x14,0x05,0x22,0x05,0x30,0x05, 0x3E,0x05,0x4C,0x05,0x5A,0x05,0x68,0x05,0x76,0x05,0x84,0x05,0x92,0x05,0xAD,0x05,0xBB,0x05, 0xC9,0x05,0xD7,0x05,0xE5,0x05,0xF3,0x05,0x01,0x06,0x1C,0x06, 4, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x21 '!' 0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,0x00, 5, // 0x22 '"' 0x00,0x00,0x50,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x23 '#' 0x00,0x00,0x00,0x00,0x00,0x00,0x0A,0x00,0x0A,0x00,0x3F,0x00,0x14,0x00,0x14,0x00,0x7E,0x00,0x28,0x00,0x28,0x00,0x00,0x00,0x00,0x00, 7, // 0x24 '$' 0x00,0x00,0x10,0x10,0x3C,0x50,0x50,0x38,0x14,0x14,0x78,0x10,0x10, 12, // 0x25 '%' 0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x00,0x49,0x00,0x4A,0x00,0x32,0x00,0x04,0xC0,0x05,0x20,0x09,0x20,0x08,0xC0,0x00,0x00,0x00,0x00, 8, // 0x26 '&' 0x00,0x00,0x00,0x30,0x48,0x48,0x32,0x4A,0x44,0x46,0x39,0x00,0x00, 3, // 0x27 ''' 0x00,0x00,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x28 '(' 0x00,0x00,0x10,0x20,0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x20,0x10, 5, // 0x29 ')' 0x00,0x00,0x40,0x20,0x20,0x10,0x10,0x10,0x10,0x10,0x20,0x20,0x40, 7, // 0x2A '*' 0x00,0x00,0x10,0x54,0x38,0x54,0x10,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x2B '+' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x7F,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00, 4, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x40, 5, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00, 4, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x00, 5, // 0x2F '/' 0x00,0x00,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x80,0x80,0x00, 7, // 0x30 '0' 0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x31 '1' 0x00,0x00,0x00,0x10,0x70,0x10,0x10,0x10,0x10,0x10,0x7C,0x00,0x00, 7, // 0x32 '2' 0x00,0x00,0x00,0x38,0x44,0x04,0x08,0x10,0x20,0x40,0x7C,0x00,0x00, 7, // 0x33 '3' 0x00,0x00,0x00,0x38,0x44,0x04,0x18,0x04,0x04,0x44,0x38,0x00,0x00, 7, // 0x34 '4' 0x00,0x00,0x00,0x08,0x18,0x28,0x48,0x88,0xFC,0x08,0x08,0x00,0x00, 7, // 0x35 '5' 0x00,0x00,0x00,0x7C,0x40,0x40,0x78,0x04,0x04,0x44,0x38,0x00,0x00, 7, // 0x36 '6' 0x00,0x00,0x00,0x18,0x20,0x40,0x78,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x37 '7' 0x00,0x00,0x00,0x7C,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x00,0x00, 7, // 0x38 '8' 0x00,0x00,0x00,0x38,0x44,0x44,0x38,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x39 '9' 0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x3C,0x04,0x08,0x30,0x00,0x00, 5, // 0x3A ':' 0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x00,0x20,0x20,0x00,0x00, 5, // 0x3B ';' 0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x00,0x20,0x20,0x20,0x40, 9, // 0x3C '<' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x18,0x00,0x60,0x00,0x18,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x3D '=' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x3E '>' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x0C,0x00,0x03,0x00,0x0C,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x3F '?' 0x00,0x00,0x00,0x70,0x08,0x08,0x10,0x20,0x20,0x00,0x20,0x00,0x00, 10, // 0x40 '@' 0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x20,0x80,0x4E,0x80,0x52,0x80,0x52,0x80,0x52,0x80,0x4D,0x00,0x20,0x00,0x1E,0x00,0x00,0x00, 8, // 0x41 'A' 0x00,0x00,0x00,0x18,0x18,0x24,0x24,0x24,0x7E,0x42,0x42,0x00,0x00, 8, // 0x42 'B' 0x00,0x00,0x00,0x78,0x44,0x44,0x7C,0x42,0x42,0x42,0x7C,0x00,0x00, 9, // 0x43 'C' 0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00, 9, // 0x44 'D' 0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x42,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x42,0x00,0x7C,0x00,0x00,0x00,0x00,0x00, 7, // 0x45 'E' 0x00,0x00,0x00,0x7C,0x40,0x40,0x7C,0x40,0x40,0x40,0x7C,0x00,0x00, 6, // 0x46 'F' 0x00,0x00,0x00,0x7C,0x40,0x40,0x78,0x40,0x40,0x40,0x40,0x00,0x00, 9, // 0x47 'G' 0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x40,0x00,0x40,0x00,0x47,0x00,0x41,0x00,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00, 8, // 0x48 'H' 0x00,0x00,0x00,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x42,0x00,0x00, 5, // 0x49 'I' 0x00,0x00,0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00, 5, // 0x4A 'J' 0x00,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0xE0,0x00,0x00, 8, // 0x4B 'K' 0x00,0x00,0x00,0x42,0x44,0x48,0x50,0x70,0x48,0x44,0x42,0x00,0x00, 6, // 0x4C 'L' 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7C,0x00,0x00, 9, // 0x4D 'M' 0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x63,0x00,0x55,0x00,0x55,0x00,0x49,0x00,0x49,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x00,0x00, 8, // 0x4E 'N' 0x00,0x00,0x00,0x62,0x62,0x52,0x52,0x4A,0x4A,0x46,0x46,0x00,0x00, 9, // 0x4F 'O' 0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x22,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x22,0x00,0x1C,0x00,0x00,0x00,0x00,0x00, 7, // 0x50 'P' 0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x78,0x40,0x40,0x40,0x00,0x00, 9, // 0x51 'Q' 0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x22,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x22,0x00,0x1C,0x00,0x04,0x00,0x03,0x00, 8, // 0x52 'R' 0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x78,0x48,0x44,0x42,0x00,0x00, 8, // 0x53 'S' 0x00,0x00,0x00,0x3C,0x42,0x40,0x30,0x0C,0x02,0x42,0x3C,0x00,0x00, 7, // 0x54 'T' 0x00,0x00,0x00,0xFE,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, 8, // 0x55 'U' 0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00, 8, // 0x56 'V' 0x00,0x00,0x00,0x42,0x42,0x42,0x24,0x24,0x24,0x18,0x18,0x00,0x00, 11, // 0x57 'W' 0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x40,0x44,0x40,0x2A,0x80,0x2A,0x80,0x2A,0x80,0x2A,0x80,0x11,0x00,0x11,0x00,0x00,0x00,0x00,0x00, 8, // 0x58 'X' 0x00,0x00,0x00,0x42,0x42,0x24,0x18,0x18,0x24,0x42,0x42,0x00,0x00, 7, // 0x59 'Y' 0x00,0x00,0x00,0x82,0x44,0x28,0x10,0x10,0x10,0x10,0x10,0x00,0x00, 8, // 0x5A 'Z' 0x00,0x00,0x00,0x7E,0x02,0x04,0x08,0x10,0x20,0x40,0x7E,0x00,0x00, 5, // 0x5B '[' 0x00,0x00,0x70,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x70, 5, // 0x5C '\' 0x00,0x00,0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x00, 5, // 0x5D ']' 0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70, 9, // 0x5E '^' 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x14,0x00,0x22,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE, 7, // 0x60 '`' 0x00,0x00,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x61 'a' 0x00,0x00,0x00,0x00,0x00,0x38,0x04,0x3C,0x44,0x44,0x3C,0x00,0x00, 7, // 0x62 'b' 0x00,0x00,0x40,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x78,0x00,0x00, 6, // 0x63 'c' 0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x40,0x40,0x44,0x38,0x00,0x00, 7, // 0x64 'd' 0x00,0x00,0x04,0x04,0x04,0x3C,0x44,0x44,0x44,0x44,0x3C,0x00,0x00, 7, // 0x65 'e' 0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x7C,0x40,0x44,0x38,0x00,0x00, 4, // 0x66 'f' 0x00,0x00,0x30,0x40,0x40,0xF0,0x40,0x40,0x40,0x40,0x40,0x00,0x00, 7, // 0x67 'g' 0x00,0x00,0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x44,0x3C,0x04,0x38, 7, // 0x68 'h' 0x00,0x00,0x40,0x40,0x40,0x78,0x44,0x44,0x44,0x44,0x44,0x00,0x00, 3, // 0x69 'i' 0x00,0x00,0x40,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00, 4, // 0x6A 'j' 0x00,0x00,0x20,0x00,0x00,0x60,0x20,0x20,0x20,0x20,0x20,0x20,0xC0, 7, // 0x6B 'k' 0x00,0x00,0x40,0x40,0x40,0x44,0x48,0x50,0x70,0x48,0x44,0x00,0x00, 3, // 0x6C 'l' 0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00, 11, // 0x6D 'm' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7B,0x80,0x44,0x40,0x44,0x40,0x44,0x40,0x44,0x40,0x44,0x40,0x00,0x00,0x00,0x00, 7, // 0x6E 'n' 0x00,0x00,0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x44,0x00,0x00, 7, // 0x6F 'o' 0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x38,0x00,0x00, 7, // 0x70 'p' 0x00,0x00,0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x44,0x78,0x40,0x40, 7, // 0x71 'q' 0x00,0x00,0x00,0x00,0x00,0x3C,0x44,0x44,0x44,0x44,0x3C,0x04,0x04, 5, // 0x72 'r' 0x00,0x00,0x00,0x00,0x00,0x58,0x60,0x40,0x40,0x40,0x40,0x00,0x00, 6, // 0x73 's' 0x00,0x00,0x00,0x00,0x00,0x38,0x40,0x60,0x18,0x08,0x70,0x00,0x00, 4, // 0x74 't' 0x00,0x00,0x00,0x40,0x40,0xF0,0x40,0x40,0x40,0x40,0x30,0x00,0x00, 7, // 0x75 'u' 0x00,0x00,0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x44,0x3C,0x00,0x00, 7, // 0x76 'v' 0x00,0x00,0x00,0x00,0x00,0x44,0x44,0x28,0x28,0x10,0x10,0x00,0x00, 9, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x49,0x00,0x49,0x00,0x55,0x00,0x55,0x00,0x22,0x00,0x22,0x00,0x00,0x00,0x00,0x00, 7, // 0x78 'x' 0x00,0x00,0x00,0x00,0x00,0x44,0x28,0x10,0x10,0x28,0x44,0x00,0x00, 7, // 0x79 'y' 0x00,0x00,0x00,0x00,0x00,0x44,0x28,0x28,0x28,0x10,0x10,0x10,0x20, 6, // 0x7A 'z' 0x00,0x00,0x00,0x00,0x00,0x78,0x08,0x10,0x20,0x40,0x78,0x00,0x00, 7, // 0x7B '{' 0x00,0x00,0x0C,0x10,0x10,0x10,0x10,0x60,0x10,0x10,0x10,0x10,0x0C, 5, // 0x7C '|' 0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 7, // 0x7D '}' 0x00,0x00,0x60,0x10,0x10,0x10,0x10,0x0C,0x10,0x10,0x10,0x10,0x60, 9, // 0x7E '~' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x00,0x49,0x00,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x7F '' 0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x7F,0x80,0x00,0x00,0x00,0x00, 0 }; const int8u verdana13_bold[] = { 13, 3, 32, 128-32, 0x00,0x00,0x0E,0x00,0x1C,0x00,0x2A,0x00,0x45,0x00,0x53,0x00,0x6E,0x00,0x89,0x00,0x97,0x00, 0xA5,0x00,0xB3,0x00,0xC1,0x00,0xDC,0x00,0xEA,0x00,0xF8,0x00,0x06,0x01,0x14,0x01,0x22,0x01, 0x30,0x01,0x3E,0x01,0x4C,0x01,0x5A,0x01,0x68,0x01,0x76,0x01,0x84,0x01,0x92,0x01,0xA0,0x01, 0xAE,0x01,0xBC,0x01,0xD7,0x01,0xF2,0x01,0x0D,0x02,0x1B,0x02,0x36,0x02,0x51,0x02,0x5F,0x02, 0x6D,0x02,0x88,0x02,0x96,0x02,0xA4,0x02,0xBF,0x02,0xDA,0x02,0xE8,0x02,0xF6,0x02,0x04,0x03, 0x12,0x03,0x2D,0x03,0x48,0x03,0x63,0x03,0x71,0x03,0x8C,0x03,0x9A,0x03,0xA8,0x03,0xB6,0x03, 0xD1,0x03,0xDF,0x03,0xFA,0x03,0x08,0x04,0x16,0x04,0x24,0x04,0x32,0x04,0x40,0x04,0x4E,0x04, 0x69,0x04,0x77,0x04,0x85,0x04,0x93,0x04,0xA1,0x04,0xAF,0x04,0xBD,0x04,0xCB,0x04,0xD9,0x04, 0xE7,0x04,0xF5,0x04,0x03,0x05,0x11,0x05,0x1F,0x05,0x2D,0x05,0x48,0x05,0x56,0x05,0x64,0x05, 0x72,0x05,0x80,0x05,0x8E,0x05,0x9C,0x05,0xAA,0x05,0xB8,0x05,0xC6,0x05,0xE1,0x05,0xEF,0x05, 0xFD,0x05,0x0B,0x06,0x19,0x06,0x27,0x06,0x35,0x06,0x50,0x06, 4, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x21 '!' 0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x60,0x00,0x00, 7, // 0x22 '"' 0x00,0x00,0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x23 '#' 0x00,0x00,0x00,0x00,0x00,0x00,0x0A,0x00,0x0A,0x00,0x3F,0x00,0x14,0x00,0x14,0x00,0x7E,0x00,0x28,0x00,0x28,0x00,0x00,0x00,0x00,0x00, 8, // 0x24 '$' 0x00,0x00,0x08,0x08,0x3C,0x6A,0x68,0x3C,0x16,0x56,0x3C,0x10,0x10, 14, // 0x25 '%' 0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x80,0x6C,0x80,0x6D,0x00,0x6D,0x70,0x3A,0xD8,0x02,0xD8,0x04,0xD8,0x04,0x70,0x00,0x00,0x00,0x00, 10, // 0x26 '&' 0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x6C,0x00,0x6C,0x00,0x39,0x80,0x6D,0x00,0x66,0x00,0x63,0x00,0x3D,0x80,0x00,0x00,0x00,0x00, 4, // 0x27 ''' 0x00,0x00,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x28 '(' 0x00,0x00,0x18,0x30,0x30,0x60,0x60,0x60,0x60,0x60,0x30,0x30,0x18, 6, // 0x29 ')' 0x00,0x00,0x60,0x30,0x30,0x18,0x18,0x18,0x18,0x18,0x30,0x30,0x60, 8, // 0x2A '*' 0x00,0x00,0x10,0x54,0x38,0x54,0x10,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x2B '+' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x7F,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00, 4, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x60,0x40, 6, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00, 4, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00, 8, // 0x2F '/' 0x00,0x00,0x06,0x06,0x0C,0x0C,0x18,0x18,0x18,0x30,0x30,0x60,0x60, 8, // 0x30 '0' 0x00,0x00,0x00,0x3C,0x66,0x66,0x66,0x66,0x66,0x66,0x3C,0x00,0x00, 8, // 0x31 '1' 0x00,0x00,0x00,0x18,0x38,0x18,0x18,0x18,0x18,0x18,0x3C,0x00,0x00, 8, // 0x32 '2' 0x00,0x00,0x00,0x3C,0x66,0x06,0x0C,0x18,0x30,0x60,0x7E,0x00,0x00, 8, // 0x33 '3' 0x00,0x00,0x00,0x3C,0x66,0x06,0x1C,0x06,0x06,0x66,0x3C,0x00,0x00, 8, // 0x34 '4' 0x00,0x00,0x00,0x04,0x0C,0x1C,0x2C,0x4C,0x7E,0x0C,0x0C,0x00,0x00, 8, // 0x35 '5' 0x00,0x00,0x00,0x3E,0x30,0x30,0x3C,0x06,0x06,0x66,0x3C,0x00,0x00, 8, // 0x36 '6' 0x00,0x00,0x00,0x1C,0x30,0x60,0x7C,0x66,0x66,0x66,0x3C,0x00,0x00, 8, // 0x37 '7' 0x00,0x00,0x00,0x7E,0x06,0x0C,0x0C,0x18,0x18,0x30,0x30,0x00,0x00, 8, // 0x38 '8' 0x00,0x00,0x00,0x3C,0x66,0x66,0x3C,0x66,0x66,0x66,0x3C,0x00,0x00, 8, // 0x39 '9' 0x00,0x00,0x00,0x3C,0x66,0x66,0x66,0x3E,0x06,0x0C,0x38,0x00,0x00, 4, // 0x3A ':' 0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x60,0x60,0x00,0x00, 4, // 0x3B ';' 0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x60,0x60,0x60,0x40, 9, // 0x3C '<' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x0C,0x00,0x30,0x00,0x40,0x00,0x30,0x00,0x0C,0x00,0x03,0x00,0x00,0x00,0x00,0x00, 9, // 0x3D '=' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x3E '>' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x18,0x00,0x06,0x00,0x01,0x00,0x06,0x00,0x18,0x00,0x60,0x00,0x00,0x00,0x00,0x00, 7, // 0x3F '?' 0x00,0x00,0x00,0x38,0x4C,0x0C,0x18,0x30,0x30,0x00,0x30,0x00,0x00, 11, // 0x40 '@' 0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x20,0x40,0x4F,0x40,0x5B,0x40,0x5B,0x40,0x5B,0x40,0x4F,0x80,0x20,0x00,0x1F,0x00,0x00,0x00, 9, // 0x41 'A' 0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x1C,0x00,0x36,0x00,0x36,0x00,0x36,0x00,0x7F,0x00,0x63,0x00,0x63,0x00,0x00,0x00,0x00,0x00, 8, // 0x42 'B' 0x00,0x00,0x00,0x7C,0x66,0x66,0x7C,0x66,0x66,0x66,0x7C,0x00,0x00, 8, // 0x43 'C' 0x00,0x00,0x00,0x3C,0x62,0x60,0x60,0x60,0x60,0x62,0x3C,0x00,0x00, 9, // 0x44 'D' 0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x66,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x66,0x00,0x7C,0x00,0x00,0x00,0x00,0x00, 8, // 0x45 'E' 0x00,0x00,0x00,0x7E,0x60,0x60,0x7E,0x60,0x60,0x60,0x7E,0x00,0x00, 8, // 0x46 'F' 0x00,0x00,0x00,0x7E,0x60,0x60,0x7E,0x60,0x60,0x60,0x60,0x00,0x00, 9, // 0x47 'G' 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x61,0x00,0x60,0x00,0x60,0x00,0x67,0x00,0x63,0x00,0x63,0x00,0x3F,0x00,0x00,0x00,0x00,0x00, 9, // 0x48 'H' 0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x7F,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x00,0x00,0x00,0x00, 6, // 0x49 'I' 0x00,0x00,0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00, 6, // 0x4A 'J' 0x00,0x00,0x00,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0xF0,0x00,0x00, 8, // 0x4B 'K' 0x00,0x00,0x00,0x66,0x6C,0x78,0x70,0x70,0x78,0x6C,0x66,0x00,0x00, 7, // 0x4C 'L' 0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x7E,0x00,0x00, 10, // 0x4D 'M' 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x80,0x71,0x80,0x7B,0x80,0x5D,0x80,0x49,0x80,0x41,0x80,0x41,0x80,0x41,0x80,0x00,0x00,0x00,0x00, 9, // 0x4E 'N' 0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x61,0x00,0x71,0x00,0x59,0x00,0x4D,0x00,0x47,0x00,0x43,0x00,0x41,0x00,0x00,0x00,0x00,0x00, 9, // 0x4F 'O' 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00, 8, // 0x50 'P' 0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x7C,0x60,0x60,0x60,0x00,0x00, 9, // 0x51 'Q' 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,0x0C,0x00,0x07,0x00, 8, // 0x52 'R' 0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x7C,0x6C,0x66,0x63,0x00,0x00, 8, // 0x53 'S' 0x00,0x00,0x00,0x3C,0x62,0x60,0x7C,0x3E,0x06,0x46,0x3C,0x00,0x00, 8, // 0x54 'T' 0x00,0x00,0x00,0xFF,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00, 9, // 0x55 'U' 0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00, 8, // 0x56 'V' 0x00,0x00,0x00,0x66,0x66,0x66,0x3C,0x3C,0x3C,0x18,0x18,0x00,0x00, 12, // 0x57 'W' 0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x60,0x66,0x60,0x66,0x60,0x36,0xC0,0x3F,0xC0,0x39,0xC0,0x19,0x80,0x19,0x80,0x00,0x00,0x00,0x00, 8, // 0x58 'X' 0x00,0x00,0x00,0x66,0x66,0x3C,0x18,0x18,0x3C,0x66,0x66,0x00,0x00, 8, // 0x59 'Y' 0x00,0x00,0x00,0x66,0x66,0x3C,0x3C,0x18,0x18,0x18,0x18,0x00,0x00, 8, // 0x5A 'Z' 0x00,0x00,0x00,0x7E,0x06,0x0E,0x1C,0x38,0x70,0x60,0x7E,0x00,0x00, 6, // 0x5B '[' 0x00,0x00,0x78,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x78, 8, // 0x5C '\' 0x00,0x00,0x60,0x60,0x30,0x30,0x18,0x18,0x18,0x0C,0x0C,0x06,0x06, 6, // 0x5D ']' 0x00,0x00,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x78, 10, // 0x5E '^' 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x1E,0x00,0x33,0x00,0x61,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 8, // 0x60 '`' 0x00,0x00,0x30,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x61 'a' 0x00,0x00,0x00,0x00,0x00,0x3C,0x06,0x3E,0x66,0x66,0x3E,0x00,0x00, 8, // 0x62 'b' 0x00,0x00,0x60,0x60,0x60,0x7C,0x66,0x66,0x66,0x66,0x7C,0x00,0x00, 7, // 0x63 'c' 0x00,0x00,0x00,0x00,0x00,0x3C,0x60,0x60,0x60,0x60,0x3C,0x00,0x00, 8, // 0x64 'd' 0x00,0x00,0x06,0x06,0x06,0x3E,0x66,0x66,0x66,0x66,0x3E,0x00,0x00, 8, // 0x65 'e' 0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x7E,0x60,0x62,0x3C,0x00,0x00, 5, // 0x66 'f' 0x00,0x00,0x38,0x60,0x60,0xF8,0x60,0x60,0x60,0x60,0x60,0x00,0x00, 8, // 0x67 'g' 0x00,0x00,0x00,0x00,0x00,0x3E,0x66,0x66,0x66,0x66,0x3E,0x06,0x3C, 8, // 0x68 'h' 0x00,0x00,0x60,0x60,0x60,0x7C,0x66,0x66,0x66,0x66,0x66,0x00,0x00, 4, // 0x69 'i' 0x00,0x00,0x00,0x60,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00, 5, // 0x6A 'j' 0x00,0x00,0x00,0x30,0x00,0x70,0x30,0x30,0x30,0x30,0x30,0x30,0xE0, 8, // 0x6B 'k' 0x00,0x00,0x60,0x60,0x60,0x66,0x6C,0x78,0x78,0x6C,0x66,0x00,0x00, 4, // 0x6C 'l' 0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00, 12, // 0x6D 'm' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7D,0xC0,0x66,0x60,0x66,0x60,0x66,0x60,0x66,0x60,0x66,0x60,0x00,0x00,0x00,0x00, 8, // 0x6E 'n' 0x00,0x00,0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x66,0x66,0x00,0x00, 8, // 0x6F 'o' 0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x66,0x66,0x3C,0x00,0x00, 8, // 0x70 'p' 0x00,0x00,0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x66,0x7C,0x60,0x60, 8, // 0x71 'q' 0x00,0x00,0x00,0x00,0x00,0x3E,0x66,0x66,0x66,0x66,0x3E,0x06,0x06, 6, // 0x72 'r' 0x00,0x00,0x00,0x00,0x00,0x6C,0x7C,0x60,0x60,0x60,0x60,0x00,0x00, 7, // 0x73 's' 0x00,0x00,0x00,0x00,0x00,0x3C,0x60,0x78,0x3C,0x0C,0x78,0x00,0x00, 5, // 0x74 't' 0x00,0x00,0x00,0x60,0x60,0xF8,0x60,0x60,0x60,0x60,0x38,0x00,0x00, 8, // 0x75 'u' 0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x3E,0x00,0x00, 8, // 0x76 'v' 0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x3C,0x3C,0x18,0x00,0x00, 10, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6D,0x80,0x6D,0x80,0x6D,0x80,0x6D,0x80,0x33,0x00,0x33,0x00,0x00,0x00,0x00,0x00, 8, // 0x78 'x' 0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x3C,0x3C,0x66,0x66,0x00,0x00, 8, // 0x79 'y' 0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x3C,0x3C,0x18,0x18,0x30,0x30, 7, // 0x7A 'z' 0x00,0x00,0x00,0x00,0x00,0x7C,0x0C,0x18,0x30,0x60,0x7C,0x00,0x00, 8, // 0x7B '{' 0x00,0x00,0x0E,0x18,0x18,0x18,0x18,0x70,0x18,0x18,0x18,0x18,0x0E, 6, // 0x7C '|' 0x00,0x00,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30, 8, // 0x7D '}' 0x00,0x00,0x70,0x18,0x18,0x18,0x18,0x0E,0x18,0x18,0x18,0x18,0x70, 9, // 0x7E '~' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x00,0x49,0x00,0x49,0x00,0x46,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x7F '' 0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x7F,0x80,0x00,0x00,0x00,0x00, 0 }; const int8u verdana14[] = { 14, 3, 32, 128-32, 0x00,0x00,0x0F,0x00,0x1E,0x00,0x2D,0x00,0x4A,0x00,0x59,0x00,0x76,0x00,0x93,0x00,0xA2,0x00, 0xB1,0x00,0xC0,0x00,0xCF,0x00,0xEC,0x00,0xFB,0x00,0x0A,0x01,0x19,0x01,0x28,0x01,0x37,0x01, 0x46,0x01,0x55,0x01,0x64,0x01,0x73,0x01,0x82,0x01,0x91,0x01,0xA0,0x01,0xAF,0x01,0xBE,0x01, 0xCD,0x01,0xDC,0x01,0xF9,0x01,0x16,0x02,0x33,0x02,0x42,0x02,0x5F,0x02,0x6E,0x02,0x7D,0x02, 0x9A,0x02,0xB7,0x02,0xC6,0x02,0xD5,0x02,0xF2,0x02,0x0F,0x03,0x1E,0x03,0x2D,0x03,0x3C,0x03, 0x4B,0x03,0x68,0x03,0x85,0x03,0xA2,0x03,0xB1,0x03,0xCE,0x03,0xDD,0x03,0xEC,0x03,0xFB,0x03, 0x18,0x04,0x27,0x04,0x44,0x04,0x53,0x04,0x62,0x04,0x71,0x04,0x80,0x04,0x8F,0x04,0x9E,0x04, 0xBB,0x04,0xCA,0x04,0xD9,0x04,0xE8,0x04,0xF7,0x04,0x06,0x05,0x15,0x05,0x24,0x05,0x33,0x05, 0x42,0x05,0x51,0x05,0x60,0x05,0x6F,0x05,0x7E,0x05,0x8D,0x05,0xAA,0x05,0xB9,0x05,0xC8,0x05, 0xD7,0x05,0xE6,0x05,0xF5,0x05,0x04,0x06,0x13,0x06,0x22,0x06,0x31,0x06,0x4E,0x06,0x5D,0x06, 0x6C,0x06,0x7B,0x06,0x8A,0x06,0x99,0x06,0xA8,0x06,0xC5,0x06, 4, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x21 '!' 0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,0x00, 6, // 0x22 '"' 0x00,0x00,0x48,0x48,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x23 '#' 0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x09,0x00,0x12,0x00,0x3F,0x80,0x12,0x00,0x12,0x00,0x7F,0x00,0x24,0x00,0x24,0x00,0x00,0x00,0x00,0x00, 8, // 0x24 '$' 0x00,0x00,0x10,0x10,0x3E,0x50,0x50,0x30,0x1C,0x12,0x12,0x7C,0x10,0x10, 13, // 0x25 '%' 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x80,0x49,0x00,0x49,0x00,0x4A,0x00,0x32,0x60,0x02,0x90,0x04,0x90,0x04,0x90,0x08,0x60,0x00,0x00,0x00,0x00, 10, // 0x26 '&' 0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x39,0x00,0x45,0x00,0x42,0x00,0x43,0x00,0x3C,0x80,0x00,0x00,0x00,0x00, 3, // 0x27 ''' 0x00,0x00,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x28 '(' 0x00,0x00,0x10,0x20,0x20,0x40,0x40,0x40,0x40,0x40,0x40,0x20,0x20,0x10, 5, // 0x29 ')' 0x00,0x00,0x40,0x20,0x20,0x10,0x10,0x10,0x10,0x10,0x10,0x20,0x20,0x40, 8, // 0x2A '*' 0x00,0x00,0x10,0x54,0x38,0x54,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x2B '+' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x7F,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00, 4, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x40, 5, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00, 4, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x00, 5, // 0x2F '/' 0x00,0x00,0x08,0x08,0x10,0x10,0x10,0x20,0x20,0x20,0x40,0x40,0x40,0x80, 8, // 0x30 '0' 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00, 8, // 0x31 '1' 0x00,0x00,0x00,0x08,0x38,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00, 8, // 0x32 '2' 0x00,0x00,0x00,0x3C,0x42,0x42,0x02,0x04,0x18,0x20,0x40,0x7E,0x00,0x00, 8, // 0x33 '3' 0x00,0x00,0x00,0x3C,0x42,0x02,0x02,0x1C,0x02,0x02,0x42,0x3C,0x00,0x00, 8, // 0x34 '4' 0x00,0x00,0x00,0x04,0x0C,0x14,0x24,0x44,0x7F,0x04,0x04,0x04,0x00,0x00, 8, // 0x35 '5' 0x00,0x00,0x00,0x7E,0x40,0x40,0x7C,0x02,0x02,0x02,0x42,0x3C,0x00,0x00, 8, // 0x36 '6' 0x00,0x00,0x00,0x1C,0x20,0x40,0x7C,0x42,0x42,0x42,0x42,0x3C,0x00,0x00, 8, // 0x37 '7' 0x00,0x00,0x00,0x7E,0x02,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x00,0x00, 8, // 0x38 '8' 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x3C,0x42,0x42,0x42,0x3C,0x00,0x00, 8, // 0x39 '9' 0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x3E,0x02,0x04,0x38,0x00,0x00, 5, // 0x3A ':' 0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x00,0x00,0x20,0x20,0x00,0x00, 5, // 0x3B ';' 0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x00,0x00,0x20,0x20,0x20,0x40, 9, // 0x3C '<' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x0C,0x00,0x30,0x00,0x40,0x00,0x30,0x00,0x0C,0x00,0x03,0x00,0x00,0x00,0x00,0x00, 9, // 0x3D '=' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x3E '>' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x18,0x00,0x06,0x00,0x01,0x00,0x06,0x00,0x18,0x00,0x60,0x00,0x00,0x00,0x00,0x00, 7, // 0x3F '?' 0x00,0x00,0x00,0x38,0x44,0x04,0x04,0x08,0x10,0x10,0x00,0x10,0x00,0x00, 12, // 0x40 '@' 0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x30,0xC0,0x27,0x40,0x49,0x20,0x49,0x20,0x49,0x20,0x49,0x20,0x27,0xC0,0x30,0x00,0x0F,0x00,0x00,0x00, 8, // 0x41 'A' 0x00,0x00,0x00,0x18,0x18,0x24,0x24,0x42,0x42,0x7E,0x81,0x81,0x00,0x00, 8, // 0x42 'B' 0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x7C,0x42,0x42,0x42,0x7C,0x00,0x00, 9, // 0x43 'C' 0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00, 9, // 0x44 'D' 0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x42,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x42,0x00,0x7C,0x00,0x00,0x00,0x00,0x00, 8, // 0x45 'E' 0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x7E,0x40,0x40,0x40,0x7E,0x00,0x00, 7, // 0x46 'F' 0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x7C,0x40,0x40,0x40,0x40,0x00,0x00, 9, // 0x47 'G' 0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x40,0x00,0x40,0x00,0x47,0x00,0x41,0x00,0x41,0x00,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00, 9, // 0x48 'H' 0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x7F,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x00,0x00, 5, // 0x49 'I' 0x00,0x00,0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00, 5, // 0x4A 'J' 0x00,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xE0,0x00,0x00, 8, // 0x4B 'K' 0x00,0x00,0x00,0x42,0x44,0x48,0x50,0x60,0x50,0x48,0x44,0x42,0x00,0x00, 7, // 0x4C 'L' 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7E,0x00,0x00, 10, // 0x4D 'M' 0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x80,0x61,0x80,0x52,0x80,0x52,0x80,0x52,0x80,0x4C,0x80,0x4C,0x80,0x40,0x80,0x40,0x80,0x00,0x00,0x00,0x00, 9, // 0x4E 'N' 0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x00,0x61,0x00,0x51,0x00,0x51,0x00,0x49,0x00,0x45,0x00,0x45,0x00,0x43,0x00,0x43,0x00,0x00,0x00,0x00,0x00, 10, // 0x4F 'O' 0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00, 8, // 0x50 'P' 0x00,0x00,0x00,0x7C,0x42,0x42,0x42,0x42,0x7C,0x40,0x40,0x40,0x00,0x00, 10, // 0x51 'Q' 0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x21,0x00,0x1E,0x00,0x02,0x00,0x01,0x80, 8, // 0x52 'R' 0x00,0x00,0x00,0x7C,0x42,0x42,0x42,0x7C,0x48,0x44,0x42,0x41,0x00,0x00, 8, // 0x53 'S' 0x00,0x00,0x00,0x3C,0x42,0x40,0x40,0x3C,0x02,0x02,0x42,0x3C,0x00,0x00, 7, // 0x54 'T' 0x00,0x00,0x00,0xFE,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00, 9, // 0x55 'U' 0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x22,0x00,0x1C,0x00,0x00,0x00,0x00,0x00, 8, // 0x56 'V' 0x00,0x00,0x00,0x81,0x81,0x42,0x42,0x42,0x24,0x24,0x18,0x18,0x00,0x00, 13, // 0x57 'W' 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x10,0x42,0x10,0x45,0x10,0x45,0x10,0x25,0x20,0x28,0xA0,0x28,0xA0,0x10,0x40,0x10,0x40,0x00,0x00,0x00,0x00, 8, // 0x58 'X' 0x00,0x00,0x00,0x42,0x42,0x24,0x18,0x18,0x18,0x24,0x42,0x42,0x00,0x00, 7, // 0x59 'Y' 0x00,0x00,0x00,0x82,0x44,0x44,0x28,0x10,0x10,0x10,0x10,0x10,0x00,0x00, 8, // 0x5A 'Z' 0x00,0x00,0x00,0x7E,0x02,0x04,0x08,0x10,0x10,0x20,0x40,0x7E,0x00,0x00, 5, // 0x5B '[' 0x00,0x00,0x70,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x70, 5, // 0x5C '\' 0x00,0x00,0x80,0x80,0x40,0x40,0x40,0x20,0x20,0x10,0x10,0x10,0x08,0x08, 5, // 0x5D ']' 0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70, 10, // 0x5E '^' 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x12,0x00,0x21,0x00,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, 8, // 0x60 '`' 0x00,0x00,0x20,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x61 'a' 0x00,0x00,0x00,0x00,0x00,0x3C,0x02,0x02,0x3E,0x42,0x42,0x3E,0x00,0x00, 8, // 0x62 'b' 0x00,0x00,0x40,0x40,0x40,0x5C,0x62,0x42,0x42,0x42,0x42,0x7C,0x00,0x00, 6, // 0x63 'c' 0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x40,0x40,0x40,0x44,0x38,0x00,0x00, 8, // 0x64 'd' 0x00,0x00,0x02,0x02,0x02,0x3E,0x42,0x42,0x42,0x42,0x46,0x3A,0x00,0x00, 8, // 0x65 'e' 0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x7E,0x40,0x42,0x3C,0x00,0x00, 4, // 0x66 'f' 0x00,0x00,0x30,0x40,0x40,0xF0,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00, 8, // 0x67 'g' 0x00,0x00,0x00,0x00,0x00,0x3E,0x42,0x42,0x42,0x42,0x46,0x3A,0x02,0x3C, 8, // 0x68 'h' 0x00,0x00,0x40,0x40,0x40,0x5C,0x62,0x42,0x42,0x42,0x42,0x42,0x00,0x00, 3, // 0x69 'i' 0x00,0x00,0x40,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00, 4, // 0x6A 'j' 0x00,0x00,0x20,0x00,0x00,0x60,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xC0, 7, // 0x6B 'k' 0x00,0x00,0x40,0x40,0x40,0x44,0x48,0x50,0x60,0x50,0x48,0x44,0x00,0x00, 3, // 0x6C 'l' 0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00, 11, // 0x6D 'm' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7B,0x80,0x44,0x40,0x44,0x40,0x44,0x40,0x44,0x40,0x44,0x40,0x44,0x40,0x00,0x00,0x00,0x00, 8, // 0x6E 'n' 0x00,0x00,0x00,0x00,0x00,0x5C,0x62,0x42,0x42,0x42,0x42,0x42,0x00,0x00, 8, // 0x6F 'o' 0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00, 8, // 0x70 'p' 0x00,0x00,0x00,0x00,0x00,0x5C,0x62,0x42,0x42,0x42,0x42,0x7C,0x40,0x40, 8, // 0x71 'q' 0x00,0x00,0x00,0x00,0x00,0x3E,0x42,0x42,0x42,0x42,0x46,0x3A,0x02,0x02, 5, // 0x72 'r' 0x00,0x00,0x00,0x00,0x00,0x58,0x60,0x40,0x40,0x40,0x40,0x40,0x00,0x00, 7, // 0x73 's' 0x00,0x00,0x00,0x00,0x00,0x3C,0x40,0x40,0x38,0x04,0x04,0x78,0x00,0x00, 5, // 0x74 't' 0x00,0x00,0x00,0x40,0x40,0xF8,0x40,0x40,0x40,0x40,0x40,0x38,0x00,0x00, 8, // 0x75 'u' 0x00,0x00,0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x46,0x3A,0x00,0x00, 7, // 0x76 'v' 0x00,0x00,0x00,0x00,0x00,0x44,0x44,0x28,0x28,0x28,0x10,0x10,0x00,0x00, 11, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x40,0x44,0x40,0x2A,0x80,0x2A,0x80,0x2A,0x80,0x11,0x00,0x11,0x00,0x00,0x00,0x00,0x00, 7, // 0x78 'x' 0x00,0x00,0x00,0x00,0x00,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x00,0x00, 7, // 0x79 'y' 0x00,0x00,0x00,0x00,0x00,0x44,0x44,0x28,0x28,0x28,0x10,0x10,0x10,0x20, 7, // 0x7A 'z' 0x00,0x00,0x00,0x00,0x00,0x7C,0x04,0x08,0x10,0x20,0x40,0x7C,0x00,0x00, 8, // 0x7B '{' 0x00,0x00,0x0C,0x10,0x10,0x10,0x10,0x60,0x10,0x10,0x10,0x10,0x10,0x0C, 5, // 0x7C '|' 0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20, 8, // 0x7D '}' 0x00,0x00,0x30,0x08,0x08,0x08,0x08,0x06,0x08,0x08,0x08,0x08,0x08,0x30, 10, // 0x7E '~' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x80,0x4C,0x80,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x7F '' 0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xE0,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0xE0,0x00,0x00,0x00,0x00, 0 }; const int8u verdana14_bold[] = { 14, 3, 32, 128-32, 0x00,0x00,0x0F,0x00,0x1E,0x00,0x2D,0x00,0x4A,0x00,0x67,0x00,0x84,0x00,0xA1,0x00,0xB0,0x00, 0xBF,0x00,0xCE,0x00,0xEB,0x00,0x08,0x01,0x17,0x01,0x26,0x01,0x35,0x01,0x44,0x01,0x61,0x01, 0x7E,0x01,0x9B,0x01,0xB8,0x01,0xD5,0x01,0xF2,0x01,0x0F,0x02,0x2C,0x02,0x49,0x02,0x66,0x02, 0x75,0x02,0x84,0x02,0xA1,0x02,0xBE,0x02,0xDB,0x02,0xEA,0x02,0x07,0x03,0x24,0x03,0x41,0x03, 0x5E,0x03,0x7B,0x03,0x8A,0x03,0x99,0x03,0xB6,0x03,0xD3,0x03,0xE2,0x03,0xF1,0x03,0x0E,0x04, 0x1D,0x04,0x3A,0x04,0x57,0x04,0x74,0x04,0x91,0x04,0xAE,0x04,0xCB,0x04,0xE8,0x04,0xF7,0x04, 0x14,0x05,0x31,0x05,0x4E,0x05,0x6B,0x05,0x88,0x05,0x97,0x05,0xA6,0x05,0xB5,0x05,0xC4,0x05, 0xE1,0x05,0xFE,0x05,0x1B,0x06,0x2A,0x06,0x39,0x06,0x48,0x06,0x57,0x06,0x66,0x06,0x75,0x06, 0x84,0x06,0x93,0x06,0xA2,0x06,0xB1,0x06,0xC0,0x06,0xCF,0x06,0xEC,0x06,0xFB,0x06,0x0A,0x07, 0x19,0x07,0x28,0x07,0x37,0x07,0x46,0x07,0x55,0x07,0x64,0x07,0x73,0x07,0x90,0x07,0x9F,0x07, 0xAE,0x07,0xBD,0x07,0xDA,0x07,0xE9,0x07,0x06,0x08,0x23,0x08, 4, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x21 '!' 0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x60,0x60,0x00,0x00, 7, // 0x22 '"' 0x00,0x00,0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x23 '#' 0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x09,0x00,0x3F,0x80,0x3F,0x80,0x12,0x00,0x7F,0x00,0x7F,0x00,0x24,0x00,0x24,0x00,0x00,0x00,0x00,0x00, 9, // 0x24 '$' 0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x3E,0x00,0x69,0x00,0x68,0x00,0x7E,0x00,0x3F,0x00,0x0B,0x00,0x4B,0x00,0x3E,0x00,0x08,0x00,0x08,0x00, 15, // 0x25 '%' 0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x40,0x6C,0x40,0x6C,0x80,0x6C,0xB8,0x6D,0x6C,0x3A,0x6C,0x02,0x6C,0x04,0x6C,0x04,0x38,0x00,0x00,0x00,0x00, 10, // 0x26 '&' 0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x6C,0x00,0x6C,0x00,0x6C,0x00,0x39,0x80,0x6D,0x00,0x66,0x00,0x63,0x00,0x3D,0x80,0x00,0x00,0x00,0x00, 4, // 0x27 ''' 0x00,0x00,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x28 '(' 0x00,0x00,0x18,0x30,0x30,0x60,0x60,0x60,0x60,0x60,0x60,0x30,0x30,0x18, 7, // 0x29 ')' 0x00,0x00,0x30,0x18,0x18,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x18,0x18,0x30, 9, // 0x2A '*' 0x00,0x00,0x00,0x00,0x08,0x00,0x2A,0x00,0x1C,0x00,0x1C,0x00,0x2A,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x2B '+' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x7F,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x60,0x40, 6, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00, 8, // 0x2F '/' 0x00,0x00,0x06,0x06,0x0C,0x0C,0x0C,0x18,0x18,0x30,0x30,0x30,0x60,0x60, 9, // 0x30 '0' 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00, 9, // 0x31 '1' 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x3C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x3F,0x00,0x00,0x00,0x00,0x00, 9, // 0x32 '2' 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x03,0x00,0x03,0x00,0x06,0x00,0x0C,0x00,0x18,0x00,0x30,0x00,0x7F,0x00,0x00,0x00,0x00,0x00, 9, // 0x33 '3' 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x03,0x00,0x03,0x00,0x1E,0x00,0x03,0x00,0x03,0x00,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00, 9, // 0x34 '4' 0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x0E,0x00,0x16,0x00,0x16,0x00,0x26,0x00,0x46,0x00,0x7F,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00, 9, // 0x35 '5' 0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x30,0x00,0x30,0x00,0x3E,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00, 9, // 0x36 '6' 0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x30,0x00,0x60,0x00,0x7E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00, 9, // 0x37 '7' 0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x03,0x00,0x06,0x00,0x06,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x30,0x00,0x00,0x00,0x00,0x00, 9, // 0x38 '8' 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00, 9, // 0x39 '9' 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3F,0x00,0x03,0x00,0x06,0x00,0x3C,0x00,0x00,0x00,0x00,0x00, 5, // 0x3A ':' 0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x60,0x60,0x00,0x00, 5, // 0x3B ';' 0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x60,0x60,0x60,0x40, 10, // 0x3C '<' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x06,0x00,0x18,0x00,0x60,0x00,0x60,0x00,0x18,0x00,0x06,0x00,0x01,0x00,0x00,0x00,0x00,0x00, 10, // 0x3D '=' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x3E '>' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x30,0x00,0x0C,0x00,0x03,0x00,0x03,0x00,0x0C,0x00,0x30,0x00,0x40,0x00,0x00,0x00,0x00,0x00, 7, // 0x3F '?' 0x00,0x00,0x00,0x38,0x4C,0x0C,0x18,0x30,0x30,0x00,0x30,0x30,0x00,0x00, 12, // 0x40 '@' 0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x30,0xC0,0x2F,0x40,0x5B,0x20,0x5B,0x20,0x5B,0x20,0x5B,0x20,0x2F,0xC0,0x30,0x00,0x0F,0x00,0x00,0x00, 9, // 0x41 'A' 0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x1C,0x00,0x36,0x00,0x36,0x00,0x36,0x00,0x36,0x00,0x7F,0x00,0x63,0x00,0x63,0x00,0x00,0x00,0x00,0x00, 9, // 0x42 'B' 0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x66,0x00,0x66,0x00,0x66,0x00,0x7E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x7E,0x00,0x00,0x00,0x00,0x00, 9, // 0x43 'C' 0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x31,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x31,0x00,0x1E,0x00,0x00,0x00,0x00,0x00, 10, // 0x44 'D' 0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x63,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x63,0x00,0x7E,0x00,0x00,0x00,0x00,0x00, 8, // 0x45 'E' 0x00,0x00,0x00,0x7E,0x60,0x60,0x60,0x7E,0x60,0x60,0x60,0x7E,0x00,0x00, 8, // 0x46 'F' 0x00,0x00,0x00,0x7E,0x60,0x60,0x60,0x7E,0x60,0x60,0x60,0x60,0x00,0x00, 10, // 0x47 'G' 0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x30,0x80,0x60,0x00,0x60,0x00,0x60,0x00,0x67,0x80,0x61,0x80,0x31,0x80,0x1F,0x80,0x00,0x00,0x00,0x00, 10, // 0x48 'H' 0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x7F,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x00,0x00,0x00,0x00, 6, // 0x49 'I' 0x00,0x00,0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00, 7, // 0x4A 'J' 0x00,0x00,0x00,0x7C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0xF8,0x00,0x00, 9, // 0x4B 'K' 0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x66,0x00,0x6C,0x00,0x78,0x00,0x70,0x00,0x78,0x00,0x6C,0x00,0x66,0x00,0x63,0x00,0x00,0x00,0x00,0x00, 8, // 0x4C 'L' 0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x7F,0x00,0x00, 11, // 0x4D 'M' 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0x71,0xC0,0x71,0xC0,0x5A,0xC0,0x5A,0xC0,0x4C,0xC0,0x4C,0xC0,0x40,0xC0,0x40,0xC0,0x00,0x00,0x00,0x00, 10, // 0x4E 'N' 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x80,0x70,0x80,0x58,0x80,0x58,0x80,0x4C,0x80,0x46,0x80,0x46,0x80,0x43,0x80,0x41,0x80,0x00,0x00,0x00,0x00, 11, // 0x4F 'O' 0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x31,0x80,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x31,0x80,0x1F,0x00,0x00,0x00,0x00,0x00, 9, // 0x50 'P' 0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x7E,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00, 11, // 0x51 'Q' 0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x31,0x80,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x31,0x80,0x1F,0x00,0x06,0x00,0x03,0xC0, 9, // 0x52 'R' 0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x7E,0x00,0x6C,0x00,0x66,0x00,0x63,0x00,0x61,0x80,0x00,0x00,0x00,0x00, 9, // 0x53 'S' 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x61,0x00,0x60,0x00,0x70,0x00,0x3E,0x00,0x07,0x00,0x03,0x00,0x43,0x00,0x3E,0x00,0x00,0x00,0x00,0x00, 8, // 0x54 'T' 0x00,0x00,0x00,0xFF,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00, 10, // 0x55 'U' 0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x3F,0x00,0x00,0x00,0x00,0x00, 9, // 0x56 'V' 0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x36,0x00,0x36,0x00,0x36,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x00,0x00,0x00,0x00, 14, // 0x57 'W' 0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x18,0x63,0x18,0x63,0x18,0x33,0x30,0x37,0xB0,0x34,0xB0,0x1C,0xE0,0x18,0x60,0x18,0x60,0x00,0x00,0x00,0x00, 9, // 0x58 'X' 0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x63,0x00,0x36,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x36,0x00,0x63,0x00,0x63,0x00,0x00,0x00,0x00,0x00, 10, // 0x59 'Y' 0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x80,0x61,0x80,0x33,0x00,0x1E,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00, 8, // 0x5A 'Z' 0x00,0x00,0x00,0x7E,0x0C,0x0C,0x18,0x18,0x30,0x30,0x60,0x7E,0x00,0x00, 6, // 0x5B '[' 0x00,0x00,0x78,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x78, 8, // 0x5C '\' 0x00,0x00,0x60,0x60,0x30,0x30,0x30,0x18,0x18,0x0C,0x0C,0x0C,0x06,0x06, 6, // 0x5D ']' 0x00,0x00,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x78, 10, // 0x5E '^' 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x1E,0x00,0x33,0x00,0x61,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x80, 9, // 0x60 '`' 0x00,0x00,0x00,0x00,0x30,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x61 'a' 0x00,0x00,0x00,0x00,0x00,0x3C,0x06,0x3E,0x66,0x66,0x66,0x3E,0x00,0x00, 8, // 0x62 'b' 0x00,0x00,0x60,0x60,0x60,0x7C,0x66,0x66,0x66,0x66,0x66,0x7C,0x00,0x00, 7, // 0x63 'c' 0x00,0x00,0x00,0x00,0x00,0x3C,0x62,0x60,0x60,0x60,0x62,0x3C,0x00,0x00, 8, // 0x64 'd' 0x00,0x00,0x06,0x06,0x06,0x3E,0x66,0x66,0x66,0x66,0x66,0x3E,0x00,0x00, 8, // 0x65 'e' 0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x7E,0x60,0x62,0x3C,0x00,0x00, 5, // 0x66 'f' 0x00,0x00,0x38,0x60,0x60,0xF8,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00, 8, // 0x67 'g' 0x00,0x00,0x00,0x00,0x00,0x3E,0x66,0x66,0x66,0x66,0x66,0x3E,0x06,0x3C, 8, // 0x68 'h' 0x00,0x00,0x60,0x60,0x60,0x7C,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00, 4, // 0x69 'i' 0x00,0x00,0x60,0x60,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00, 5, // 0x6A 'j' 0x00,0x00,0x30,0x30,0x00,0x70,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0xE0, 8, // 0x6B 'k' 0x00,0x00,0x60,0x60,0x60,0x66,0x6C,0x78,0x78,0x6C,0x66,0x63,0x00,0x00, 4, // 0x6C 'l' 0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00, 12, // 0x6D 'm' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6C,0xC0,0x77,0x60,0x66,0x60,0x66,0x60,0x66,0x60,0x66,0x60,0x66,0x60,0x00,0x00,0x00,0x00, 8, // 0x6E 'n' 0x00,0x00,0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x66,0x66,0x66,0x00,0x00, 8, // 0x6F 'o' 0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x66,0x66,0x66,0x3C,0x00,0x00, 8, // 0x70 'p' 0x00,0x00,0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x66,0x66,0x7C,0x60,0x60, 8, // 0x71 'q' 0x00,0x00,0x00,0x00,0x00,0x3E,0x66,0x66,0x66,0x66,0x66,0x3E,0x06,0x06, 6, // 0x72 'r' 0x00,0x00,0x00,0x00,0x00,0x6C,0x7C,0x60,0x60,0x60,0x60,0x60,0x00,0x00, 7, // 0x73 's' 0x00,0x00,0x00,0x00,0x00,0x3C,0x60,0x60,0x38,0x0C,0x0C,0x78,0x00,0x00, 5, // 0x74 't' 0x00,0x00,0x00,0x60,0x60,0xF8,0x60,0x60,0x60,0x60,0x60,0x38,0x00,0x00, 8, // 0x75 'u' 0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x66,0x66,0x3E,0x00,0x00, 8, // 0x76 'v' 0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x3C,0x3C,0x3C,0x18,0x00,0x00, 12, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x60,0x66,0x60,0x66,0x60,0x69,0x60,0x39,0xC0,0x30,0xC0,0x30,0xC0,0x00,0x00,0x00,0x00, 8, // 0x78 'x' 0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x3C,0x18,0x3C,0x66,0x66,0x00,0x00, 8, // 0x79 'y' 0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x3C,0x3C,0x3C,0x18,0x18,0x30, 7, // 0x7A 'z' 0x00,0x00,0x00,0x00,0x00,0x7C,0x0C,0x18,0x38,0x30,0x60,0x7C,0x00,0x00, 9, // 0x7B '{' 0x00,0x00,0x00,0x00,0x0E,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x70,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x0E,0x00, 6, // 0x7C '|' 0x00,0x00,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30, 9, // 0x7D '}' 0x00,0x00,0x00,0x00,0x38,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x07,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x38,0x00, 10, // 0x7E '~' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x80,0x48,0x80,0x44,0x80,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x7F '' 0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xE0,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3F,0xE0,0x00,0x00,0x00,0x00, 0 }; const int8u verdana16[] = { 16, 4, 32, 128-32, 0x00,0x00,0x11,0x00,0x22,0x00,0x33,0x00,0x54,0x00,0x65,0x00,0x86,0x00,0xA7,0x00,0xB8,0x00, 0xC9,0x00,0xDA,0x00,0xFB,0x00,0x1C,0x01,0x2D,0x01,0x3E,0x01,0x4F,0x01,0x60,0x01,0x71,0x01, 0x82,0x01,0x93,0x01,0xA4,0x01,0xB5,0x01,0xC6,0x01,0xD7,0x01,0xE8,0x01,0xF9,0x01,0x0A,0x02, 0x1B,0x02,0x2C,0x02,0x4D,0x02,0x6E,0x02,0x8F,0x02,0xA0,0x02,0xC1,0x02,0xE2,0x02,0xF3,0x02, 0x14,0x03,0x35,0x03,0x46,0x03,0x57,0x03,0x78,0x03,0x99,0x03,0xAA,0x03,0xBB,0x03,0xCC,0x03, 0xDD,0x03,0xFE,0x03,0x1F,0x04,0x40,0x04,0x51,0x04,0x72,0x04,0x93,0x04,0xB4,0x04,0xD5,0x04, 0xF6,0x04,0x17,0x05,0x38,0x05,0x59,0x05,0x7A,0x05,0x9B,0x05,0xAC,0x05,0xBD,0x05,0xCE,0x05, 0xEF,0x05,0x00,0x06,0x11,0x06,0x22,0x06,0x33,0x06,0x44,0x06,0x55,0x06,0x66,0x06,0x77,0x06, 0x88,0x06,0x99,0x06,0xAA,0x06,0xBB,0x06,0xCC,0x06,0xDD,0x06,0xFE,0x06,0x0F,0x07,0x20,0x07, 0x31,0x07,0x42,0x07,0x53,0x07,0x64,0x07,0x75,0x07,0x86,0x07,0x97,0x07,0xB8,0x07,0xC9,0x07, 0xDA,0x07,0xEB,0x07,0xFC,0x07,0x0D,0x08,0x1E,0x08,0x3F,0x08, 5, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x21 '!' 0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x20,0x00,0x00,0x00, 5, // 0x22 '"' 0x00,0x00,0x00,0x50,0x50,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x23 '#' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x09,0x00,0x3F,0x80,0x12,0x00,0x12,0x00,0x7F,0x00,0x24,0x00,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x24 '$' 0x00,0x00,0x00,0x10,0x10,0x3E,0x50,0x50,0x30,0x1C,0x12,0x12,0x7C,0x10,0x10,0x00, 13, // 0x25 '%' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x40,0x44,0x80,0x45,0x00,0x45,0x00,0x3A,0xE0,0x05,0x10,0x05,0x10,0x09,0x10,0x10,0xE0,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x26 '&' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x44,0x00,0x44,0x00,0x44,0x00,0x38,0x80,0x45,0x00,0x42,0x00,0x46,0x00,0x39,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 3, // 0x27 ''' 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x28 '(' 0x00,0x00,0x00,0x08,0x10,0x20,0x20,0x40,0x40,0x40,0x40,0x40,0x20,0x20,0x10,0x08, 6, // 0x29 ')' 0x00,0x00,0x00,0x40,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x40, 9, // 0x2A '*' 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x2A,0x00,0x1C,0x00,0x2A,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x2B '+' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x7F,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x40,0x00, 7, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x00,0x00, 6, // 0x2F '/' 0x00,0x00,0x00,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x80,0x80,0x00, 8, // 0x30 '0' 0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00,0x00, 8, // 0x31 '1' 0x00,0x00,0x00,0x00,0x08,0x38,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,0x00, 8, // 0x32 '2' 0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x02,0x04,0x18,0x20,0x40,0x7E,0x00,0x00,0x00, 8, // 0x33 '3' 0x00,0x00,0x00,0x00,0x3C,0x42,0x02,0x02,0x1C,0x02,0x02,0x42,0x3C,0x00,0x00,0x00, 8, // 0x34 '4' 0x00,0x00,0x00,0x00,0x04,0x0C,0x14,0x24,0x44,0x7F,0x04,0x04,0x04,0x00,0x00,0x00, 8, // 0x35 '5' 0x00,0x00,0x00,0x00,0x3E,0x20,0x20,0x20,0x3C,0x02,0x02,0x42,0x3C,0x00,0x00,0x00, 8, // 0x36 '6' 0x00,0x00,0x00,0x00,0x1C,0x20,0x40,0x7C,0x42,0x42,0x42,0x42,0x3C,0x00,0x00,0x00, 8, // 0x37 '7' 0x00,0x00,0x00,0x00,0x7E,0x02,0x04,0x04,0x08,0x08,0x10,0x10,0x10,0x00,0x00,0x00, 8, // 0x38 '8' 0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x3C,0x42,0x42,0x42,0x3C,0x00,0x00,0x00, 8, // 0x39 '9' 0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x3E,0x02,0x04,0x38,0x00,0x00,0x00, 6, // 0x3A ':' 0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x00,0x00,0x20,0x20,0x00,0x00,0x00, 6, // 0x3B ';' 0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x00,0x00,0x20,0x20,0x20,0x40,0x00, 9, // 0x3C '<' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x0C,0x00,0x30,0x00,0x40,0x00,0x30,0x00,0x0C,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x3D '=' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x3E '>' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x18,0x00,0x06,0x00,0x01,0x00,0x06,0x00,0x18,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x3F '?' 0x00,0x00,0x00,0x00,0x38,0x44,0x04,0x08,0x10,0x10,0x00,0x10,0x10,0x00,0x00,0x00, 13, // 0x40 '@' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x80,0x10,0x40,0x27,0xA0,0x48,0x90,0x48,0x90,0x48,0x90,0x48,0x90,0x48,0x90,0x27,0xE0,0x10,0x00,0x0F,0x80,0x00,0x00, 9, // 0x41 'A' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x14,0x00,0x14,0x00,0x22,0x00,0x22,0x00,0x3E,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x42 'B' 0x00,0x00,0x00,0x00,0x78,0x44,0x44,0x44,0x7C,0x42,0x42,0x42,0x7C,0x00,0x00,0x00, 9, // 0x43 'C' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x44 'D' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x42,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x42,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x45 'E' 0x00,0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x7E,0x40,0x40,0x40,0x7E,0x00,0x00,0x00, 8, // 0x46 'F' 0x00,0x00,0x00,0x00,0x7E,0x40,0x40,0x40,0x7C,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 9, // 0x47 'G' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x47,0x00,0x41,0x00,0x21,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x48 'H' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x7F,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x49 'I' 0x00,0x00,0x00,0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00,0x00, 6, // 0x4A 'J' 0x00,0x00,0x00,0x00,0x38,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0xF0,0x00,0x00,0x00, 8, // 0x4B 'K' 0x00,0x00,0x00,0x00,0x42,0x44,0x48,0x50,0x60,0x50,0x48,0x44,0x42,0x00,0x00,0x00, 7, // 0x4C 'L' 0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7E,0x00,0x00,0x00, 11, // 0x4D 'M' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0x60,0xC0,0x51,0x40,0x51,0x40,0x4A,0x40,0x4A,0x40,0x44,0x40,0x44,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x4E 'N' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x00,0x61,0x00,0x51,0x00,0x51,0x00,0x49,0x00,0x45,0x00,0x45,0x00,0x43,0x00,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x4F 'O' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x50 'P' 0x00,0x00,0x00,0x00,0x7C,0x42,0x42,0x42,0x42,0x7C,0x40,0x40,0x40,0x00,0x00,0x00, 10, // 0x51 'Q' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x21,0x00,0x1E,0x00,0x02,0x00,0x01,0x80,0x00,0x00, 9, // 0x52 'R' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x42,0x00,0x42,0x00,0x42,0x00,0x44,0x00,0x78,0x00,0x44,0x00,0x42,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x53 'S' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x41,0x00,0x40,0x00,0x40,0x00,0x3E,0x00,0x01,0x00,0x01,0x00,0x41,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x54 'T' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x55 'U' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x22,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x56 'V' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x22,0x00,0x22,0x00,0x14,0x00,0x14,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 13, // 0x57 'W' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x10,0x42,0x10,0x45,0x10,0x45,0x10,0x25,0x20,0x28,0xA0,0x28,0xA0,0x10,0x40,0x10,0x40,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x58 'X' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x22,0x00,0x14,0x00,0x08,0x00,0x14,0x00,0x22,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x59 'Y' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x22,0x00,0x22,0x00,0x14,0x00,0x14,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x5A 'Z' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x01,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x5B '[' 0x00,0x00,0x00,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x00, 6, // 0x5C '\' 0x00,0x00,0x00,0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x00, 6, // 0x5D ']' 0x00,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70,0x00, 11, // 0x5E '^' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x0A,0x00,0x11,0x00,0x20,0x80,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00, 8, // 0x60 '`' 0x00,0x00,0x00,0x10,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x61 'a' 0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x02,0x02,0x3E,0x42,0x42,0x3E,0x00,0x00,0x00, 8, // 0x62 'b' 0x00,0x00,0x00,0x40,0x40,0x40,0x5C,0x62,0x42,0x42,0x42,0x42,0x7C,0x00,0x00,0x00, 8, // 0x63 'c' 0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x40,0x40,0x40,0x42,0x3C,0x00,0x00,0x00, 8, // 0x64 'd' 0x00,0x00,0x00,0x02,0x02,0x02,0x3E,0x42,0x42,0x42,0x42,0x46,0x3A,0x00,0x00,0x00, 8, // 0x65 'e' 0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x7E,0x40,0x42,0x3C,0x00,0x00,0x00, 6, // 0x66 'f' 0x00,0x00,0x00,0x1C,0x20,0x20,0x78,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00, 8, // 0x67 'g' 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x42,0x42,0x42,0x42,0x46,0x3A,0x02,0x02,0x3C, 8, // 0x68 'h' 0x00,0x00,0x00,0x40,0x40,0x40,0x5C,0x62,0x42,0x42,0x42,0x42,0x42,0x00,0x00,0x00, 3, // 0x69 'i' 0x00,0x00,0x00,0x40,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 4, // 0x6A 'j' 0x00,0x00,0x00,0x20,0x00,0x00,0x60,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xC0, 7, // 0x6B 'k' 0x00,0x00,0x00,0x40,0x40,0x40,0x44,0x48,0x50,0x60,0x50,0x48,0x44,0x00,0x00,0x00, 3, // 0x6C 'l' 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 11, // 0x6D 'm' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x59,0x80,0x66,0x40,0x44,0x40,0x44,0x40,0x44,0x40,0x44,0x40,0x44,0x40,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x6E 'n' 0x00,0x00,0x00,0x00,0x00,0x00,0x5C,0x62,0x42,0x42,0x42,0x42,0x42,0x00,0x00,0x00, 8, // 0x6F 'o' 0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00,0x00, 8, // 0x70 'p' 0x00,0x00,0x00,0x00,0x00,0x00,0x5C,0x62,0x42,0x42,0x42,0x42,0x7C,0x40,0x40,0x40, 8, // 0x71 'q' 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x42,0x42,0x42,0x42,0x46,0x3A,0x02,0x02,0x02, 5, // 0x72 'r' 0x00,0x00,0x00,0x00,0x00,0x00,0x58,0x60,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 7, // 0x73 's' 0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x40,0x40,0x38,0x04,0x04,0x78,0x00,0x00,0x00, 6, // 0x74 't' 0x00,0x00,0x00,0x00,0x20,0x20,0x78,0x20,0x20,0x20,0x20,0x20,0x18,0x00,0x00,0x00, 8, // 0x75 'u' 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x42,0x42,0x42,0x42,0x46,0x3A,0x00,0x00,0x00, 8, // 0x76 'v' 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x42,0x24,0x24,0x24,0x18,0x18,0x00,0x00,0x00, 11, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x40,0x44,0x40,0x2A,0x80,0x2A,0x80,0x2A,0x80,0x11,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x78 'x' 0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x44,0x28,0x10,0x28,0x44,0x44,0x00,0x00,0x00, 8, // 0x79 'y' 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x42,0x24,0x24,0x24,0x18,0x18,0x10,0x10,0x20, 7, // 0x7A 'z' 0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x04,0x08,0x10,0x20,0x40,0x7C,0x00,0x00,0x00, 8, // 0x7B '{' 0x00,0x00,0x00,0x0C,0x10,0x10,0x10,0x10,0x60,0x10,0x10,0x10,0x10,0x10,0x0C,0x00, 7, // 0x7C '|' 0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00, 8, // 0x7D '}' 0x00,0x00,0x00,0x30,0x08,0x08,0x08,0x08,0x06,0x08,0x08,0x08,0x08,0x08,0x30,0x00, 11, // 0x7E '~' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x80,0x4C,0x80,0x43,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 13, // 0x7F '' 0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF0,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00, 0 }; const int8u verdana16_bold[] = { 16, 4, 32, 128-32, 0x00,0x00,0x11,0x00,0x22,0x00,0x33,0x00,0x54,0x00,0x75,0x00,0xA6,0x00,0xC7,0x00,0xD8,0x00, 0xE9,0x00,0xFA,0x00,0x1B,0x01,0x3C,0x01,0x4D,0x01,0x5E,0x01,0x6F,0x01,0x90,0x01,0xB1,0x01, 0xD2,0x01,0xF3,0x01,0x14,0x02,0x35,0x02,0x56,0x02,0x77,0x02,0x98,0x02,0xB9,0x02,0xDA,0x02, 0xEB,0x02,0xFC,0x02,0x1D,0x03,0x3E,0x03,0x5F,0x03,0x70,0x03,0x91,0x03,0xB2,0x03,0xD3,0x03, 0xF4,0x03,0x15,0x04,0x36,0x04,0x57,0x04,0x78,0x04,0x99,0x04,0xAA,0x04,0xBB,0x04,0xDC,0x04, 0xED,0x04,0x0E,0x05,0x2F,0x05,0x50,0x05,0x71,0x05,0x92,0x05,0xB3,0x05,0xD4,0x05,0xE5,0x05, 0x06,0x06,0x27,0x06,0x48,0x06,0x69,0x06,0x8A,0x06,0xAB,0x06,0xBC,0x06,0xDD,0x06,0xEE,0x06, 0x0F,0x07,0x30,0x07,0x51,0x07,0x72,0x07,0x93,0x07,0xA4,0x07,0xC5,0x07,0xE6,0x07,0xF7,0x07, 0x18,0x08,0x39,0x08,0x4A,0x08,0x5B,0x08,0x6C,0x08,0x7D,0x08,0x9E,0x08,0xBF,0x08,0xE0,0x08, 0x01,0x09,0x22,0x09,0x33,0x09,0x44,0x09,0x55,0x09,0x76,0x09,0x97,0x09,0xB8,0x09,0xD9,0x09, 0xFA,0x09,0x0B,0x0A,0x2C,0x0A,0x3D,0x0A,0x5E,0x0A,0x7F,0x0A, 4, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x21 '!' 0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x30,0x30,0x00,0x00,0x00, 7, // 0x22 '"' 0x00,0x00,0x00,0x6C,0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x23 '#' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x09,0x00,0x3F,0x80,0x3F,0x80,0x12,0x00,0x7F,0x00,0x7F,0x00,0x24,0x00,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x24 '$' 0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x3E,0x00,0x69,0x00,0x68,0x00,0x78,0x00,0x3E,0x00,0x0F,0x00,0x0B,0x00,0x4B,0x00,0x3E,0x00,0x08,0x00,0x08,0x00,0x00,0x00, 17, // 0x25 '%' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x20,0x00,0x66,0x20,0x00,0x66,0x40,0x00,0x66,0x5E,0x00,0x66,0xB3,0x00,0x3D,0x33,0x00,0x01,0x33,0x00,0x02,0x33,0x00,0x02,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x26 '&' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x66,0x00,0x66,0x00,0x66,0xC0,0x3C,0xC0,0x66,0x80,0x63,0x00,0x63,0x80,0x3C,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x27 ''' 0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x28 '(' 0x00,0x00,0x00,0x0C,0x18,0x30,0x30,0x60,0x60,0x60,0x60,0x60,0x30,0x30,0x18,0x0C, 7, // 0x29 ')' 0x00,0x00,0x00,0x60,0x30,0x18,0x18,0x0C,0x0C,0x0C,0x0C,0x0C,0x18,0x18,0x30,0x60, 9, // 0x2A '*' 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x49,0x00,0x2A,0x00,0x1C,0x00,0x2A,0x00,0x49,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x2B '+' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x3F,0x80,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x60,0x60,0xC0,0xC0, 7, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00, 9, // 0x2F '/' 0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x03,0x00,0x06,0x00,0x06,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x30,0x00,0x30,0x00,0x60,0x00,0x60,0x00,0x00,0x00, 9, // 0x30 '0' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x31 '1' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x3C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x32 '2' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x63,0x00,0x03,0x00,0x06,0x00,0x0C,0x00,0x18,0x00,0x30,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x33 '3' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x63,0x00,0x03,0x00,0x0E,0x00,0x03,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x34 '4' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x0E,0x00,0x16,0x00,0x26,0x00,0x46,0x00,0x7F,0x80,0x06,0x00,0x06,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x35 '5' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x30,0x00,0x30,0x00,0x3E,0x00,0x03,0x00,0x03,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x36 '6' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x30,0x00,0x60,0x00,0x7E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x37 '7' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x03,0x00,0x03,0x00,0x06,0x00,0x06,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x38 '8' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x39 '9' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3F,0x00,0x03,0x00,0x06,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x3A ':' 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00, 5, // 0x3B ';' 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x38,0x30,0x30,0x60,0x60, 11, // 0x3C '<' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x03,0x00,0x0C,0x00,0x30,0x00,0x40,0x00,0x30,0x00,0x0C,0x00,0x03,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x3D '=' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x80,0x00,0x00,0x00,0x00,0x3F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x3E '>' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x18,0x00,0x06,0x00,0x01,0x80,0x00,0x40,0x01,0x80,0x06,0x00,0x18,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x3F '?' 0x00,0x00,0x00,0x00,0x3C,0x66,0x06,0x0C,0x18,0x18,0x00,0x18,0x18,0x00,0x00,0x00, 13, // 0x40 '@' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x80,0x30,0x60,0x27,0xA0,0x4D,0x90,0x4D,0x90,0x4D,0x90,0x4D,0x90,0x27,0xE0,0x30,0x00,0x0F,0x80,0x00,0x00,0x00,0x00, 10, // 0x41 'A' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x1E,0x00,0x1E,0x00,0x33,0x00,0x33,0x00,0x7F,0x80,0x61,0x80,0x61,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x42 'B' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x7F,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x43 'C' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x31,0x80,0x61,0x80,0x60,0x00,0x60,0x00,0x60,0x00,0x61,0x80,0x31,0x80,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x44 'D' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x63,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x63,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x45 'E' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x46 'F' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x47 'G' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x31,0x80,0x61,0x80,0x60,0x00,0x60,0x00,0x63,0x80,0x61,0x80,0x31,0x80,0x1F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x48 'H' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x7F,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x49 'I' 0x00,0x00,0x00,0x00,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x78,0x00,0x00,0x00, 7, // 0x4A 'J' 0x00,0x00,0x00,0x00,0x7C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0xF8,0x00,0x00,0x00, 9, // 0x4B 'K' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x66,0x00,0x6C,0x00,0x78,0x00,0x78,0x00,0x6C,0x00,0x66,0x00,0x63,0x00,0x61,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x4C 'L' 0x00,0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x7F,0x00,0x00,0x00, 12, // 0x4D 'M' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0xE0,0x70,0xE0,0x59,0x60,0x59,0x60,0x4E,0x60,0x4E,0x60,0x44,0x60,0x44,0x60,0x40,0x60,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x4E 'N' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x80,0x70,0x80,0x58,0x80,0x58,0x80,0x4C,0x80,0x46,0x80,0x46,0x80,0x43,0x80,0x43,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x4F 'O' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x31,0x80,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x31,0x80,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x50 'P' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x7E,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x51 'Q' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x31,0x80,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x31,0x80,0x1F,0x00,0x03,0x00,0x01,0xC0,0x00,0x00, 9, // 0x52 'R' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x7E,0x00,0x6C,0x00,0x66,0x00,0x63,0x00,0x61,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x53 'S' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x63,0x00,0x70,0x00,0x3E,0x00,0x07,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x54 'T' 0x00,0x00,0x00,0x00,0xFF,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,0x00, 10, // 0x55 'U' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x56 'V' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x00,0x33,0x00,0x1E,0x00,0x1E,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 14, // 0x57 'W' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x18,0x63,0x18,0x63,0x18,0x33,0x30,0x37,0xB0,0x34,0xB0,0x1C,0xE0,0x18,0x60,0x18,0x60,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x58 'X' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x80,0x33,0x00,0x33,0x00,0x1E,0x00,0x0C,0x00,0x1E,0x00,0x33,0x00,0x33,0x00,0x61,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x59 'Y' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x80,0x61,0x80,0x33,0x00,0x1E,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x5A 'Z' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x06,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x30,0x00,0x30,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x5B '[' 0x00,0x00,0x00,0x78,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x78,0x00, 9, // 0x5C '\' 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0x18,0x00,0x0C,0x00,0x0C,0x00,0x06,0x00,0x06,0x00,0x03,0x00,0x03,0x00,0x00,0x00, 6, // 0x5D ']' 0x00,0x00,0x00,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x78,0x00, 10, // 0x5E '^' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x1E,0x00,0x33,0x00,0x61,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x80,0x00,0x00, 9, // 0x60 '`' 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x61 'a' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x03,0x00,0x3F,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x62 'b' 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x6E,0x00,0x73,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x63 'c' 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x63,0x60,0x60,0x60,0x63,0x3E,0x00,0x00,0x00, 9, // 0x64 'd' 0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x3F,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x67,0x00,0x3B,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x65 'e' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x63,0x00,0x7F,0x00,0x60,0x00,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x66 'f' 0x00,0x00,0x00,0x38,0x60,0x60,0xF8,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x00, 9, // 0x67 'g' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x67,0x00,0x3B,0x00,0x03,0x00,0x03,0x00,0x3E,0x00, 9, // 0x68 'h' 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x6E,0x00,0x73,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x69 'i' 0x00,0x00,0x00,0x60,0x60,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x00, 5, // 0x6A 'j' 0x00,0x00,0x00,0x30,0x30,0x00,0x70,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0xE0, 8, // 0x6B 'k' 0x00,0x00,0x00,0x60,0x60,0x60,0x66,0x6C,0x78,0x78,0x6C,0x66,0x63,0x00,0x00,0x00, 4, // 0x6C 'l' 0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x00, 14, // 0x6D 'm' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6E,0x70,0x73,0x98,0x63,0x18,0x63,0x18,0x63,0x18,0x63,0x18,0x63,0x18,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x6E 'n' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6E,0x00,0x73,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x6F 'o' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x70 'p' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6E,0x00,0x73,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x7E,0x00,0x60,0x00,0x60,0x00,0x60,0x00, 9, // 0x71 'q' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x67,0x00,0x3B,0x00,0x03,0x00,0x03,0x00,0x03,0x00, 6, // 0x72 'r' 0x00,0x00,0x00,0x00,0x00,0x00,0x6C,0x7C,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x00, 8, // 0x73 's' 0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x60,0x70,0x3C,0x0E,0x06,0x7C,0x00,0x00,0x00, 6, // 0x74 't' 0x00,0x00,0x00,0x00,0x60,0x60,0xF8,0x60,0x60,0x60,0x60,0x60,0x38,0x00,0x00,0x00, 9, // 0x75 'u' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x67,0x00,0x3B,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x76 'v' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x36,0x00,0x36,0x00,0x1C,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x60,0x66,0x60,0x66,0x60,0x69,0x60,0x39,0xC0,0x30,0xC0,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x78 'x' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x63,0x00,0x36,0x00,0x1C,0x00,0x36,0x00,0x63,0x00,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x79 'y' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x36,0x00,0x36,0x00,0x1C,0x00,0x1C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00, 8, // 0x7A 'z' 0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x06,0x0C,0x18,0x30,0x60,0x7E,0x00,0x00,0x00, 9, // 0x7B '{' 0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x70,0x00,0x18,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x07,0x00,0x00,0x00, 8, // 0x7C '|' 0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x00, 9, // 0x7D '}' 0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x0C,0x00,0x07,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x18,0x00,0x70,0x00,0x00,0x00, 11, // 0x7E '~' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x40,0x44,0x40,0x44,0x40,0x43,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 13, // 0x7F '' 0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF0,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00, 0 }; const int8u verdana17[] = { 17, 4, 32, 128-32, 0x00,0x00,0x12,0x00,0x24,0x00,0x36,0x00,0x59,0x00,0x7C,0x00,0x9F,0x00,0xC2,0x00,0xD4,0x00, 0xE6,0x00,0xF8,0x00,0x1B,0x01,0x3E,0x01,0x50,0x01,0x62,0x01,0x74,0x01,0x86,0x01,0xA9,0x01, 0xCC,0x01,0xEF,0x01,0x12,0x02,0x35,0x02,0x58,0x02,0x7B,0x02,0x9E,0x02,0xC1,0x02,0xE4,0x02, 0xF6,0x02,0x08,0x03,0x2B,0x03,0x4E,0x03,0x71,0x03,0x83,0x03,0xA6,0x03,0xC9,0x03,0xEC,0x03, 0x0F,0x04,0x32,0x04,0x55,0x04,0x67,0x04,0x8A,0x04,0xAD,0x04,0xBF,0x04,0xD1,0x04,0xF4,0x04, 0x06,0x05,0x29,0x05,0x4C,0x05,0x6F,0x05,0x81,0x05,0xA4,0x05,0xC7,0x05,0xEA,0x05,0x0D,0x06, 0x30,0x06,0x53,0x06,0x76,0x06,0x99,0x06,0xBC,0x06,0xDF,0x06,0xF1,0x06,0x03,0x07,0x15,0x07, 0x38,0x07,0x5B,0x07,0x7E,0x07,0x90,0x07,0xB3,0x07,0xC5,0x07,0xE8,0x07,0xFA,0x07,0x0C,0x08, 0x2F,0x08,0x52,0x08,0x64,0x08,0x76,0x08,0x88,0x08,0x9A,0x08,0xBD,0x08,0xE0,0x08,0x03,0x09, 0x26,0x09,0x49,0x09,0x5B,0x09,0x6D,0x09,0x7F,0x09,0xA2,0x09,0xB4,0x09,0xD7,0x09,0xFA,0x09, 0x0C,0x0A,0x1E,0x0A,0x41,0x0A,0x53,0x0A,0x76,0x0A,0x99,0x0A, 5, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x21 '!' 0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x20,0x00,0x00,0x00, 6, // 0x22 '"' 0x00,0x00,0x00,0x48,0x48,0x48,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x23 '#' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x80,0x04,0x80,0x09,0x00,0x3F,0xC0,0x09,0x00,0x12,0x00,0x7F,0x80,0x12,0x00,0x24,0x00,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x24 '$' 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x3E,0x00,0x49,0x00,0x48,0x00,0x48,0x00,0x3E,0x00,0x09,0x00,0x09,0x00,0x49,0x00,0x3E,0x00,0x08,0x00,0x08,0x00,0x00,0x00, 15, // 0x25 '%' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x20,0x44,0x40,0x44,0x80,0x44,0x80,0x45,0x38,0x39,0x44,0x02,0x44,0x04,0x44,0x04,0x44,0x08,0x38,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x26 '&' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x42,0x00,0x42,0x00,0x44,0x00,0x38,0x80,0x44,0x80,0x42,0x80,0x41,0x00,0x22,0x80,0x1C,0x40,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x27 ''' 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x28 '(' 0x00,0x00,0x00,0x08,0x10,0x20,0x20,0x40,0x40,0x40,0x40,0x40,0x40,0x20,0x20,0x10,0x08, 6, // 0x29 ')' 0x00,0x00,0x00,0x40,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x40, 9, // 0x2A '*' 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x49,0x00,0x2A,0x00,0x1C,0x00,0x2A,0x00,0x49,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x2B '+' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x7F,0xC0,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x40,0x00, 7, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x00,0x00, 6, // 0x2F '/' 0x00,0x00,0x00,0x04,0x08,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x40,0x40,0x80,0x80,0x00, 9, // 0x30 '0' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x22,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x22,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x31 '1' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x38,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x32 '2' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x41,0x00,0x01,0x00,0x01,0x00,0x02,0x00,0x0C,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x33 '3' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x41,0x00,0x01,0x00,0x02,0x00,0x1C,0x00,0x02,0x00,0x01,0x00,0x01,0x00,0x42,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x34 '4' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x06,0x00,0x0A,0x00,0x12,0x00,0x22,0x00,0x42,0x00,0x7F,0x80,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x35 '5' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x7C,0x00,0x02,0x00,0x01,0x00,0x01,0x00,0x42,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x36 '6' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x30,0x00,0x20,0x00,0x40,0x00,0x7C,0x00,0x42,0x00,0x41,0x00,0x41,0x00,0x22,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x37 '7' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x01,0x00,0x02,0x00,0x02,0x00,0x04,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x38 '8' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x3E,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x39 '9' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x22,0x00,0x41,0x00,0x41,0x00,0x21,0x00,0x1F,0x00,0x01,0x00,0x02,0x00,0x06,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x3A ':' 0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x00,0x00, 6, // 0x3B ';' 0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x40,0x00, 11, // 0x3C '<' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x06,0x00,0x18,0x00,0x60,0x00,0x60,0x00,0x18,0x00,0x06,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x3D '=' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xC0,0x00,0x00,0x00,0x00,0x3F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x3E '>' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x0C,0x00,0x03,0x00,0x00,0xC0,0x00,0xC0,0x03,0x00,0x0C,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x3F '?' 0x00,0x00,0x00,0x00,0x3C,0x42,0x02,0x02,0x0C,0x10,0x10,0x00,0x10,0x10,0x00,0x00,0x00, 14, // 0x40 '@' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xC0,0x18,0x20,0x20,0x10,0x27,0xC8,0x48,0x48,0x48,0x48,0x48,0x48,0x48,0x48,0x27,0xF0,0x20,0x00,0x18,0x00,0x07,0xC0,0x00,0x00, 10, // 0x41 'A' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x12,0x00,0x12,0x00,0x21,0x00,0x21,0x00,0x21,0x00,0x7F,0x80,0x40,0x80,0x80,0x40,0x80,0x40,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x42 'B' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x7E,0x00,0x41,0x00,0x40,0x80,0x40,0x80,0x41,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x43 'C' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x30,0x80,0x20,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x30,0x80,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x44 'D' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x41,0x80,0x40,0x80,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x80,0x41,0x80,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x45 'E' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x7F,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x46 'F' 0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x7E,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 11, // 0x47 'G' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x30,0xC0,0x20,0x40,0x40,0x00,0x40,0x00,0x43,0xC0,0x40,0x40,0x20,0x40,0x30,0x40,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x48 'H' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x7F,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x49 'I' 0x00,0x00,0x00,0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00,0x00, 6, // 0x4A 'J' 0x00,0x00,0x00,0x00,0x38,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0xF0,0x00,0x00,0x00, 10, // 0x4B 'K' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x42,0x00,0x44,0x00,0x48,0x00,0x50,0x00,0x68,0x00,0x44,0x00,0x42,0x00,0x41,0x00,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x4C 'L' 0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7F,0x00,0x00,0x00, 11, // 0x4D 'M' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0x60,0xC0,0x51,0x40,0x51,0x40,0x4A,0x40,0x4A,0x40,0x44,0x40,0x44,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x4E 'N' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x80,0x60,0x80,0x50,0x80,0x48,0x80,0x48,0x80,0x44,0x80,0x44,0x80,0x42,0x80,0x41,0x80,0x41,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x4F 'O' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x31,0x80,0x20,0x80,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x20,0x80,0x31,0x80,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x50 'P' 0x00,0x00,0x00,0x00,0x7C,0x42,0x41,0x41,0x42,0x7C,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 11, // 0x51 'Q' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x31,0x80,0x20,0x80,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x20,0x80,0x31,0x80,0x0E,0x00,0x02,0x00,0x02,0x00,0x01,0xC0, 10, // 0x52 'R' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x42,0x00,0x42,0x00,0x42,0x00,0x44,0x00,0x78,0x00,0x44,0x00,0x42,0x00,0x41,0x00,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x53 'S' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x20,0x80,0x40,0x00,0x40,0x00,0x38,0x00,0x07,0x00,0x00,0x80,0x40,0x80,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x54 'T' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x80,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x55 'U' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x56 'V' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x80,0x40,0x40,0x80,0x40,0x80,0x21,0x00,0x21,0x00,0x21,0x00,0x12,0x00,0x12,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 15, // 0x57 'W' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x04,0x41,0x04,0x22,0x88,0x22,0x88,0x22,0x88,0x14,0x50,0x14,0x50,0x14,0x50,0x08,0x20,0x08,0x20,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x58 'X' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x21,0x00,0x12,0x00,0x12,0x00,0x0C,0x00,0x0C,0x00,0x12,0x00,0x12,0x00,0x21,0x00,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x59 'Y' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x41,0x00,0x22,0x00,0x22,0x00,0x14,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x5A 'Z' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x80,0x00,0x80,0x01,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x5B '[' 0x00,0x00,0x00,0x3C,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3C, 6, // 0x5C '\' 0x00,0x00,0x00,0x80,0x40,0x40,0x40,0x20,0x20,0x10,0x10,0x10,0x08,0x08,0x08,0x04,0x00, 6, // 0x5D ']' 0x00,0x00,0x00,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x78, 11, // 0x5E '^' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x0A,0x00,0x11,0x00,0x20,0x80,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x80,0x00,0x00, 9, // 0x60 '`' 0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x61 'a' 0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x02,0x3E,0x42,0x42,0x46,0x3A,0x00,0x00,0x00, 9, // 0x62 'b' 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x5C,0x00,0x62,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x42,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x63 'c' 0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x22,0x40,0x40,0x40,0x40,0x22,0x1C,0x00,0x00,0x00, 9, // 0x64 'd' 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x1F,0x00,0x21,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x23,0x00,0x1D,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x65 'e' 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x24,0x42,0x7E,0x40,0x40,0x22,0x1C,0x00,0x00,0x00, 6, // 0x66 'f' 0x00,0x00,0x00,0x1C,0x20,0x20,0x7C,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00, 9, // 0x67 'g' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x21,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x23,0x00,0x1D,0x00,0x01,0x00,0x22,0x00,0x1C,0x00, 9, // 0x68 'h' 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x5E,0x00,0x61,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 3, // 0x69 'i' 0x00,0x00,0x00,0x00,0x40,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 5, // 0x6A 'j' 0x00,0x00,0x00,0x00,0x10,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xE0, 8, // 0x6B 'k' 0x00,0x00,0x00,0x40,0x40,0x40,0x42,0x44,0x48,0x50,0x70,0x48,0x44,0x42,0x00,0x00,0x00, 3, // 0x6C 'l' 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 13, // 0x6D 'm' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5C,0xE0,0x63,0x10,0x42,0x10,0x42,0x10,0x42,0x10,0x42,0x10,0x42,0x10,0x42,0x10,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x6E 'n' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5E,0x00,0x61,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x6F 'o' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x22,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x22,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x70 'p' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5C,0x00,0x62,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x42,0x00,0x7C,0x00,0x40,0x00,0x40,0x00,0x40,0x00, 9, // 0x71 'q' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x21,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x23,0x00,0x1D,0x00,0x01,0x00,0x01,0x00,0x01,0x00, 6, // 0x72 'r' 0x00,0x00,0x00,0x00,0x00,0x00,0x5C,0x60,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 8, // 0x73 's' 0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x40,0x30,0x0C,0x02,0x42,0x3C,0x00,0x00,0x00, 6, // 0x74 't' 0x00,0x00,0x00,0x00,0x20,0x20,0x7C,0x20,0x20,0x20,0x20,0x20,0x20,0x1C,0x00,0x00,0x00, 9, // 0x75 'u' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x43,0x00,0x3D,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x76 'v' 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x42,0x24,0x24,0x24,0x18,0x18,0x18,0x00,0x00,0x00, 11, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x40,0x44,0x40,0x2A,0x80,0x2A,0x80,0x2A,0x80,0x2A,0x80,0x11,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x78 'x' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x22,0x00,0x14,0x00,0x08,0x00,0x08,0x00,0x14,0x00,0x22,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x79 'y' 0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x42,0x24,0x24,0x24,0x18,0x18,0x18,0x10,0x10,0x20, 8, // 0x7A 'z' 0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x02,0x04,0x08,0x10,0x20,0x40,0x7E,0x00,0x00,0x00, 9, // 0x7B '{' 0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x60,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x07,0x00, 6, // 0x7C '|' 0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, 9, // 0x7D '}' 0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x04,0x00,0x03,0x00,0x04,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x70,0x00, 11, // 0x7E '~' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x40,0x44,0x40,0x44,0x40,0x43,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 14, // 0x7F '' 0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF8,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00, 0 }; const int8u verdana17_bold[] = { 17, 4, 32, 128-32, 0x00,0x00,0x12,0x00,0x24,0x00,0x36,0x00,0x59,0x00,0x7C,0x00,0xB0,0x00,0xD3,0x00,0xE5,0x00, 0xF7,0x00,0x09,0x01,0x2C,0x01,0x4F,0x01,0x61,0x01,0x73,0x01,0x85,0x01,0xA8,0x01,0xCB,0x01, 0xEE,0x01,0x11,0x02,0x34,0x02,0x57,0x02,0x7A,0x02,0x9D,0x02,0xC0,0x02,0xE3,0x02,0x06,0x03, 0x18,0x03,0x2A,0x03,0x4D,0x03,0x70,0x03,0x93,0x03,0xB6,0x03,0xD9,0x03,0xFC,0x03,0x1F,0x04, 0x42,0x04,0x65,0x04,0x88,0x04,0xAB,0x04,0xCE,0x04,0xF1,0x04,0x03,0x05,0x15,0x05,0x38,0x05, 0x5B,0x05,0x7E,0x05,0xA1,0x05,0xC4,0x05,0xE7,0x05,0x0A,0x06,0x2D,0x06,0x50,0x06,0x73,0x06, 0x96,0x06,0xB9,0x06,0xDC,0x06,0xFF,0x06,0x22,0x07,0x45,0x07,0x57,0x07,0x7A,0x07,0x8C,0x07, 0xAF,0x07,0xD2,0x07,0xF5,0x07,0x18,0x08,0x3B,0x08,0x4D,0x08,0x70,0x08,0x93,0x08,0xA5,0x08, 0xC8,0x08,0xEB,0x08,0xFD,0x08,0x0F,0x09,0x32,0x09,0x44,0x09,0x67,0x09,0x8A,0x09,0xAD,0x09, 0xD0,0x09,0xF3,0x09,0x05,0x0A,0x17,0x0A,0x29,0x0A,0x4C,0x0A,0x6F,0x0A,0x92,0x0A,0xB5,0x0A, 0xD8,0x0A,0xEA,0x0A,0x0D,0x0B,0x1F,0x0B,0x42,0x0B,0x65,0x0B, 5, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x21 '!' 0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x30,0x30,0x00,0x00,0x00, 8, // 0x22 '"' 0x00,0x00,0x00,0x66,0x66,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x23 '#' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x40,0x04,0x40,0x3F,0xE0,0x3F,0xE0,0x08,0x80,0x11,0x00,0x7F,0xC0,0x7F,0xC0,0x22,0x00,0x22,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x24 '$' 0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x1F,0x00,0x34,0x80,0x64,0x00,0x74,0x00,0x3C,0x00,0x0F,0x00,0x0B,0x80,0x09,0x80,0x4B,0x00,0x3E,0x00,0x08,0x00,0x08,0x00,0x00,0x00, 18, // 0x25 '%' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x08,0x00,0x66,0x10,0x00,0x66,0x20,0x00,0x66,0x2F,0x00,0x66,0x59,0x80,0x66,0x99,0x80,0x3D,0x19,0x80,0x01,0x19,0x80,0x02,0x19,0x80,0x04,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x26 '&' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x33,0x00,0x33,0x00,0x36,0x00,0x1C,0x60,0x36,0x60,0x63,0x60,0x61,0xC0,0x31,0xC0,0x1F,0x60,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x27 ''' 0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x28 '(' 0x00,0x00,0x00,0x0C,0x18,0x30,0x30,0x60,0x60,0x60,0x60,0x60,0x60,0x30,0x30,0x18,0x0C, 8, // 0x29 ')' 0x00,0x00,0x00,0x30,0x18,0x0C,0x0C,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0x0C,0x18,0x30, 10, // 0x2A '*' 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x49,0x00,0x2A,0x00,0x1C,0x00,0x2A,0x00,0x49,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x2B '+' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x7F,0xC0,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x60,0x60,0xC0,0xC0,0x00, 7, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x00,0x00,0x00, 10, // 0x2F '/' 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,0x03,0x00,0x03,0x00,0x06,0x00,0x06,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x30,0x00,0x30,0x00,0x60,0x00,0x60,0x00,0x00,0x00, 10, // 0x30 '0' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x33,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x31 '1' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x3C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x32 '2' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x61,0x80,0x61,0x80,0x01,0x80,0x03,0x00,0x06,0x00,0x0C,0x00,0x18,0x00,0x30,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x33 '3' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x61,0x80,0x61,0x80,0x01,0x80,0x0F,0x00,0x03,0x00,0x01,0x80,0x61,0x80,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x34 '4' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x07,0x00,0x0B,0x00,0x13,0x00,0x23,0x00,0x43,0x00,0x7F,0xC0,0x03,0x00,0x03,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x35 '5' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x80,0x30,0x00,0x30,0x00,0x3E,0x00,0x03,0x00,0x01,0x80,0x01,0x80,0x61,0x80,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x36 '6' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x38,0x00,0x30,0x00,0x6E,0x00,0x73,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x37 '7' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x80,0x01,0x80,0x03,0x00,0x03,0x00,0x06,0x00,0x06,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x38 '8' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x3F,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x39 '9' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x33,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x80,0x1D,0x80,0x03,0x00,0x07,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x3A ':' 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x00,0x00,0x30,0x30,0x30,0x00,0x00,0x00, 6, // 0x3B ';' 0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x00,0x00,0x38,0x30,0x30,0x60,0x60,0x00, 12, // 0x3C '<' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0x00,0x0C,0x00,0x30,0x00,0x40,0x00,0x30,0x00,0x0C,0x00,0x03,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x3D '=' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x3E '>' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x18,0x00,0x06,0x00,0x01,0x80,0x00,0x40,0x01,0x80,0x06,0x00,0x18,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x3F '?' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x03,0x00,0x06,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 14, // 0x40 '@' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xC0,0x18,0x20,0x20,0x10,0x27,0xC8,0x4C,0xC8,0x4C,0xC8,0x4C,0xC8,0x4C,0xC8,0x27,0xF0,0x20,0x00,0x18,0x00,0x07,0xC0,0x00,0x00, 11, // 0x41 'A' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x1B,0x00,0x1B,0x00,0x31,0x80,0x3F,0x80,0x31,0x80,0x60,0xC0,0x60,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x42 'B' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x7F,0x00,0x61,0x80,0x60,0xC0,0x60,0xC0,0x61,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x43 'C' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x80,0x30,0xC0,0x30,0xC0,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x30,0xC0,0x30,0xC0,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x44 'D' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x61,0x80,0x61,0x80,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x61,0x80,0x61,0x80,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x45 'E' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x80,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0x80,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x46 'F' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x47 'G' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x80,0x30,0xC0,0x30,0xC0,0x60,0x00,0x60,0x00,0x63,0xC0,0x60,0xC0,0x30,0xC0,0x30,0xC0,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x48 'H' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x7F,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x49 'I' 0x00,0x00,0x00,0x00,0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x00,0x00,0x00, 8, // 0x4A 'J' 0x00,0x00,0x00,0x00,0x3E,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0xF8,0x00,0x00,0x00, 11, // 0x4B 'K' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0x61,0x80,0x63,0x00,0x66,0x00,0x6C,0x00,0x7C,0x00,0x76,0x00,0x63,0x00,0x61,0x80,0x60,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x4C 'L' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 13, // 0x4D 'M' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x70,0x70,0x70,0x70,0xF0,0x58,0xB0,0x59,0xB0,0x4D,0x30,0x4F,0x30,0x46,0x30,0x46,0x30,0x40,0x30,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x4E 'N' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x40,0x70,0x40,0x58,0x40,0x4C,0x40,0x4C,0x40,0x46,0x40,0x43,0x40,0x43,0x40,0x41,0xC0,0x40,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x4F 'O' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x30,0xC0,0x30,0xC0,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x30,0xC0,0x30,0xC0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x50 'P' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x63,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x63,0x00,0x7E,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x51 'Q' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x30,0xC0,0x30,0xC0,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x30,0xC0,0x30,0xC0,0x0F,0x80,0x03,0x00,0x03,0x00,0x01,0xE0, 11, // 0x52 'R' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x61,0x80,0x60,0xC0,0x60,0xC0,0x61,0x80,0x7F,0x00,0x63,0x00,0x61,0x80,0x60,0xC0,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x53 'S' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x31,0x80,0x61,0x80,0x60,0x00,0x3E,0x00,0x1F,0x00,0x01,0x80,0x61,0x80,0x63,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x54 'T' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x80,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x55 'U' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x31,0x80,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x56 'V' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x31,0x80,0x31,0x80,0x31,0x80,0x1B,0x00,0x1B,0x00,0x0E,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 16, // 0x57 'W' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x86,0x61,0x86,0x63,0xC6,0x32,0x4C,0x36,0x6C,0x36,0x6C,0x34,0x2C,0x1C,0x38,0x18,0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x58 'X' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0x31,0x80,0x31,0x80,0x1B,0x00,0x0E,0x00,0x0E,0x00,0x1B,0x00,0x31,0x80,0x31,0x80,0x60,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x59 'Y' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x61,0x80,0x61,0x80,0x33,0x00,0x1E,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x5A 'Z' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x80,0x01,0x80,0x03,0x00,0x06,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x30,0x00,0x60,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x5B '[' 0x00,0x00,0x00,0x3E,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3E, 10, // 0x5C '\' 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0x18,0x00,0x0C,0x00,0x06,0x00,0x06,0x00,0x03,0x00,0x03,0x00,0x01,0x80,0x01,0x80,0x00,0x00, 8, // 0x5D ']' 0x00,0x00,0x00,0x7C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x7C, 12, // 0x5E '^' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x0E,0x00,0x1B,0x00,0x31,0x80,0x60,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xC0,0x00,0x00, 10, // 0x60 '`' 0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x61 'a' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x03,0x00,0x03,0x00,0x3F,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x62 'b' 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x6E,0x00,0x73,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x63,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x63 'c' 0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x33,0x60,0x60,0x60,0x60,0x33,0x1E,0x00,0x00,0x00, 10, // 0x64 'd' 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,0x01,0x80,0x1F,0x80,0x31,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x80,0x1D,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x65 'e' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x33,0x00,0x63,0x00,0x7F,0x00,0x60,0x00,0x60,0x00,0x33,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x66 'f' 0x00,0x00,0x00,0x1C,0x30,0x30,0x7C,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x00,0x00, 10, // 0x67 'g' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x31,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x80,0x1D,0x80,0x01,0x80,0x03,0x00,0x3E,0x00, 10, // 0x68 'h' 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x6F,0x00,0x71,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x69 'i' 0x00,0x00,0x00,0x60,0x60,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x00, 6, // 0x6A 'j' 0x00,0x00,0x00,0x18,0x18,0x00,0x38,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xF0, 9, // 0x6B 'k' 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x63,0x00,0x66,0x00,0x6C,0x00,0x78,0x00,0x7C,0x00,0x66,0x00,0x63,0x00,0x61,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x6C 'l' 0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x00, 14, // 0x6D 'm' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6E,0x70,0x73,0x98,0x63,0x18,0x63,0x18,0x63,0x18,0x63,0x18,0x63,0x18,0x63,0x18,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x6E 'n' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6F,0x00,0x71,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x6F 'o' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x33,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x70 'p' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6E,0x00,0x73,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x63,0x00,0x7E,0x00,0x60,0x00,0x60,0x00,0x60,0x00, 10, // 0x71 'q' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x31,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x80,0x1D,0x80,0x01,0x80,0x01,0x80,0x01,0x80, 7, // 0x72 'r' 0x00,0x00,0x00,0x00,0x00,0x00,0x6E,0x7E,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x00, 8, // 0x73 's' 0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x62,0x60,0x7C,0x3E,0x06,0x46,0x3C,0x00,0x00,0x00, 6, // 0x74 't' 0x00,0x00,0x00,0x00,0x60,0x60,0xFC,0x60,0x60,0x60,0x60,0x60,0x60,0x3C,0x00,0x00,0x00, 10, // 0x75 'u' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x63,0x80,0x3D,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x76 'v' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x36,0x00,0x36,0x00,0x36,0x00,0x1C,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 14, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x18,0x63,0x18,0x33,0x30,0x37,0xB0,0x34,0xB0,0x1C,0xE0,0x1C,0xE0,0x0C,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x78 'x' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x63,0x00,0x36,0x00,0x1C,0x00,0x1C,0x00,0x36,0x00,0x63,0x00,0x63,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x79 'y' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x00,0x63,0x00,0x63,0x00,0x36,0x00,0x36,0x00,0x36,0x00,0x1C,0x00,0x1C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00, 8, // 0x7A 'z' 0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x06,0x0C,0x18,0x18,0x30,0x60,0x7E,0x00,0x00,0x00, 10, // 0x7B '{' 0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x70,0x00,0x18,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x07,0x80, 8, // 0x7C '|' 0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 10, // 0x7D '}' 0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x06,0x00,0x03,0x80,0x06,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x78,0x00, 12, // 0x7E '~' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x20,0x24,0x20,0x46,0x20,0x42,0x40,0x41,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 14, // 0x7F '' 0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF8,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00, 0 }; const int8u verdana18[] = { 18, 4, 32, 128-32, 0x00,0x00,0x13,0x00,0x26,0x00,0x39,0x00,0x5E,0x00,0x83,0x00,0xA8,0x00,0xCD,0x00,0xE0,0x00, 0xF3,0x00,0x06,0x01,0x2B,0x01,0x50,0x01,0x63,0x01,0x76,0x01,0x89,0x01,0x9C,0x01,0xC1,0x01, 0xE6,0x01,0x0B,0x02,0x30,0x02,0x55,0x02,0x7A,0x02,0x9F,0x02,0xC4,0x02,0xE9,0x02,0x0E,0x03, 0x21,0x03,0x34,0x03,0x59,0x03,0x7E,0x03,0xA3,0x03,0xB6,0x03,0xDB,0x03,0x00,0x04,0x25,0x04, 0x4A,0x04,0x6F,0x04,0x94,0x04,0xB9,0x04,0xDE,0x04,0x03,0x05,0x16,0x05,0x29,0x05,0x4E,0x05, 0x61,0x05,0x86,0x05,0xAB,0x05,0xD0,0x05,0xF5,0x05,0x1A,0x06,0x3F,0x06,0x64,0x06,0x89,0x06, 0xAE,0x06,0xD3,0x06,0xF8,0x06,0x1D,0x07,0x42,0x07,0x67,0x07,0x7A,0x07,0x8D,0x07,0xA0,0x07, 0xC5,0x07,0xEA,0x07,0x0F,0x08,0x34,0x08,0x59,0x08,0x6C,0x08,0x91,0x08,0xB6,0x08,0xC9,0x08, 0xEE,0x08,0x13,0x09,0x26,0x09,0x39,0x09,0x5E,0x09,0x71,0x09,0x96,0x09,0xBB,0x09,0xE0,0x09, 0x05,0x0A,0x2A,0x0A,0x3D,0x0A,0x50,0x0A,0x63,0x0A,0x88,0x0A,0xAD,0x0A,0xD2,0x0A,0xF7,0x0A, 0x1C,0x0B,0x41,0x0B,0x66,0x0B,0x79,0x0B,0x9E,0x0B,0xC3,0x0B, 5, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x21 '!' 0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x20,0x00,0x00,0x00, 7, // 0x22 '"' 0x00,0x00,0x00,0x48,0x48,0x48,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x23 '#' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x80,0x04,0x80,0x09,0x00,0x3F,0xC0,0x09,0x00,0x11,0x00,0x12,0x00,0x7F,0x80,0x12,0x00,0x24,0x00,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x24 '$' 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x08,0x00,0x3E,0x00,0x49,0x00,0x48,0x00,0x48,0x00,0x38,0x00,0x0E,0x00,0x09,0x00,0x09,0x00,0x49,0x00,0x3E,0x00,0x08,0x00,0x08,0x00,0x08,0x00, 16, // 0x25 '%' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x20,0x44,0x40,0x44,0x40,0x44,0x80,0x44,0x80,0x38,0x9C,0x01,0x22,0x01,0x22,0x02,0x22,0x02,0x22,0x04,0x1C,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x26 '&' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x21,0x00,0x21,0x00,0x1E,0x40,0x24,0x40,0x42,0x40,0x41,0x40,0x40,0x80,0x21,0x40,0x1E,0x20,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x27 ''' 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x28 '(' 0x00,0x00,0x00,0x08,0x10,0x20,0x20,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x20,0x20,0x10,0x08, 7, // 0x29 ')' 0x00,0x00,0x00,0x20,0x10,0x08,0x08,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x08,0x08,0x10,0x20, 10, // 0x2A '*' 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x49,0x00,0x2A,0x00,0x1C,0x00,0x2A,0x00,0x49,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x2B '+' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x3F,0xE0,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,0x40,0x40, 7, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x00,0x00,0x00, 7, // 0x2F '/' 0x00,0x00,0x00,0x02,0x04,0x04,0x04,0x08,0x08,0x10,0x10,0x20,0x20,0x40,0x40,0x40,0x80,0x00, 10, // 0x30 '0' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x31 '1' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x1C,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x32 '2' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x41,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x01,0x00,0x02,0x00,0x0C,0x00,0x30,0x00,0x40,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x33 '3' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x40,0x80,0x00,0x80,0x01,0x00,0x0E,0x00,0x01,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x41,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x34 '4' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x03,0x00,0x05,0x00,0x09,0x00,0x11,0x00,0x21,0x00,0x41,0x00,0x7F,0xC0,0x01,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x35 '5' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x80,0x20,0x00,0x20,0x00,0x20,0x00,0x3E,0x00,0x01,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x41,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x36 '6' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x5E,0x00,0x61,0x00,0x40,0x80,0x40,0x80,0x40,0x80,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x37 '7' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x01,0x00,0x02,0x00,0x02,0x00,0x04,0x00,0x04,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x10,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x38 '8' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x40,0x80,0x40,0x80,0x21,0x00,0x1E,0x00,0x21,0x00,0x40,0x80,0x40,0x80,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x39 '9' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x40,0x80,0x40,0x80,0x40,0x80,0x20,0x80,0x1F,0x80,0x00,0x80,0x01,0x00,0x02,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x3A ':' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x00,0x00,0x00,0x00,0x10,0x10,0x00,0x00,0x00, 7, // 0x3B ';' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x10,0x00,0x00,0x00,0x00,0x10,0x10,0x10,0x20,0x20, 12, // 0x3C '<' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0x00,0x0C,0x00,0x30,0x00,0x30,0x00,0x0C,0x00,0x03,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x3D '=' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xE0,0x00,0x00,0x00,0x00,0x3F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x3E '>' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x0C,0x00,0x03,0x00,0x00,0xC0,0x00,0xC0,0x03,0x00,0x0C,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x3F '?' 0x00,0x00,0x00,0x00,0x3C,0x42,0x02,0x02,0x04,0x08,0x10,0x10,0x00,0x10,0x10,0x00,0x00,0x00, 15, // 0x40 '@' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x18,0x60,0x20,0x10,0x23,0xD0,0x44,0x48,0x48,0x48,0x48,0x48,0x48,0x48,0x44,0x48,0x23,0xF0,0x20,0x00,0x18,0x00,0x07,0xC0,0x00,0x00, 10, // 0x41 'A' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x12,0x00,0x12,0x00,0x12,0x00,0x21,0x00,0x21,0x00,0x40,0x80,0x7F,0x80,0x40,0x80,0x80,0x40,0x80,0x40,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x42 'B' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x7E,0x00,0x41,0x00,0x40,0x80,0x40,0x80,0x40,0x80,0x41,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x43 'C' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x30,0xC0,0x20,0x40,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x20,0x40,0x30,0xC0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x44 'D' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x41,0x80,0x40,0x80,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x80,0x41,0x80,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x45 'E' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x7F,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x46 'F' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x80,0x40,0x00,0x40,0x00,0x40,0x00,0x7F,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x47 'G' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x80,0x30,0x60,0x20,0x20,0x40,0x00,0x40,0x00,0x41,0xE0,0x40,0x20,0x40,0x20,0x20,0x20,0x30,0x20,0x0F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x48 'H' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7F,0xC0,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x49 'I' 0x00,0x00,0x00,0x00,0x70,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00,0x00, 7, // 0x4A 'J' 0x00,0x00,0x00,0x00,0x3C,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x08,0xF0,0x00,0x00,0x00, 10, // 0x4B 'K' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x41,0x00,0x42,0x00,0x44,0x00,0x48,0x00,0x50,0x00,0x68,0x00,0x44,0x00,0x42,0x00,0x41,0x00,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x4C 'L' 0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x7F,0x00,0x00,0x00, 13, // 0x4D 'M' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x30,0x50,0x50,0x50,0x50,0x48,0x90,0x48,0x90,0x45,0x10,0x45,0x10,0x42,0x10,0x42,0x10,0x40,0x10,0x40,0x10,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x4E 'N' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x60,0x40,0x50,0x40,0x48,0x40,0x48,0x40,0x44,0x40,0x42,0x40,0x42,0x40,0x41,0x40,0x40,0xC0,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x4F 'O' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x30,0xC0,0x20,0x40,0x40,0x20,0x40,0x20,0x40,0x20,0x40,0x20,0x40,0x20,0x20,0x40,0x30,0xC0,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x50 'P' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,0x41,0x00,0x40,0x80,0x40,0x80,0x40,0x80,0x41,0x00,0x7E,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x51 'Q' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x30,0xC0,0x20,0x40,0x40,0x20,0x40,0x20,0x40,0x20,0x40,0x20,0x40,0x20,0x20,0x40,0x30,0xC0,0x0F,0x00,0x01,0x00,0x01,0x00,0x00,0xE0, 10, // 0x52 'R' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x42,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x42,0x00,0x7C,0x00,0x42,0x00,0x41,0x00,0x40,0x80,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x53 'S' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x20,0x80,0x40,0x00,0x40,0x00,0x20,0x00,0x1E,0x00,0x01,0x00,0x00,0x80,0x40,0x80,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x54 'T' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x80,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x55 'U' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x20,0x80,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x56 'V' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x80,0x40,0x40,0x80,0x40,0x80,0x40,0x80,0x21,0x00,0x21,0x00,0x12,0x00,0x12,0x00,0x12,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 15, // 0x57 'W' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x04,0x41,0x04,0x22,0x88,0x22,0x88,0x22,0x88,0x12,0x90,0x14,0x50,0x14,0x50,0x14,0x50,0x08,0x20,0x08,0x20,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x58 'X' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x21,0x00,0x21,0x00,0x12,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x12,0x00,0x21,0x00,0x21,0x00,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x59 'Y' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x41,0x00,0x22,0x00,0x22,0x00,0x14,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x5A 'Z' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x80,0x00,0x80,0x01,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x5B '[' 0x00,0x00,0x00,0x3C,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x3C, 7, // 0x5C '\' 0x00,0x00,0x00,0x80,0x40,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x04,0x02,0x00, 7, // 0x5D ']' 0x00,0x00,0x00,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x78, 12, // 0x5E '^' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x09,0x00,0x10,0x80,0x20,0x40,0x40,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xC0,0x00,0x00, 10, // 0x60 '`' 0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x61 'a' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x01,0x00,0x3F,0x00,0x41,0x00,0x41,0x00,0x43,0x00,0x3D,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x62 'b' 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x5C,0x00,0x62,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x42,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x63 'c' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x21,0x40,0x40,0x40,0x40,0x21,0x1E,0x00,0x00,0x00, 9, // 0x64 'd' 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x1F,0x00,0x21,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x23,0x00,0x1D,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x65 'e' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x00,0x22,0x00,0x41,0x00,0x7F,0x00,0x40,0x00,0x40,0x00,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x66 'f' 0x00,0x00,0x00,0x1C,0x20,0x20,0x20,0x7C,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x00,0x00, 9, // 0x67 'g' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x21,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x23,0x00,0x1D,0x00,0x01,0x00,0x22,0x00,0x1C,0x00, 9, // 0x68 'h' 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x5E,0x00,0x61,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 3, // 0x69 'i' 0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 5, // 0x6A 'j' 0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0xE0, 9, // 0x6B 'k' 0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x42,0x00,0x44,0x00,0x48,0x00,0x50,0x00,0x68,0x00,0x44,0x00,0x42,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 3, // 0x6C 'l' 0x00,0x00,0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 15, // 0x6D 'm' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2E,0x70,0x31,0x88,0x21,0x08,0x21,0x08,0x21,0x08,0x21,0x08,0x21,0x08,0x21,0x08,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x6E 'n' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5E,0x00,0x61,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x6F 'o' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x21,0x00,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x21,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x70 'p' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5C,0x00,0x62,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x42,0x00,0x7C,0x00,0x40,0x00,0x40,0x00,0x40,0x00, 9, // 0x71 'q' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x21,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x23,0x00,0x1D,0x00,0x01,0x00,0x01,0x00,0x01,0x00, 6, // 0x72 'r' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5C,0x60,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x00,0x00, 8, // 0x73 's' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x40,0x30,0x0C,0x02,0x42,0x3C,0x00,0x00,0x00, 6, // 0x74 't' 0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x7C,0x20,0x20,0x20,0x20,0x20,0x20,0x1C,0x00,0x00,0x00, 9, // 0x75 'u' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x41,0x00,0x43,0x00,0x3D,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x76 'v' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x22,0x00,0x22,0x00,0x22,0x00,0x14,0x00,0x14,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 13, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x42,0x10,0x42,0x10,0x25,0x20,0x25,0x20,0x28,0xA0,0x28,0xA0,0x10,0x40,0x10,0x40,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x78 'x' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x22,0x00,0x14,0x00,0x08,0x00,0x08,0x00,0x14,0x00,0x22,0x00,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x79 'y' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x00,0x41,0x00,0x22,0x00,0x22,0x00,0x22,0x00,0x14,0x00,0x14,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x10,0x00, 9, // 0x7A 'z' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x02,0x00,0x04,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x7B '{' 0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x60,0x00,0x10,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x07,0x00, 7, // 0x7C '|' 0x00,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, 10, // 0x7D '}' 0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x02,0x00,0x01,0x80,0x02,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x38,0x00, 12, // 0x7E '~' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x20,0x24,0x20,0x42,0x40,0x41,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 15, // 0x7F '' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF8,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00, 0 }; const int8u verdana18_bold[] = { 18, 4, 32, 128-32, 0x00,0x00,0x13,0x00,0x26,0x00,0x4B,0x00,0x70,0x00,0x95,0x00,0xCC,0x00,0xF1,0x00,0x04,0x01, 0x17,0x01,0x2A,0x01,0x4F,0x01,0x74,0x01,0x87,0x01,0x9A,0x01,0xAD,0x01,0xD2,0x01,0xF7,0x01, 0x1C,0x02,0x41,0x02,0x66,0x02,0x8B,0x02,0xB0,0x02,0xD5,0x02,0xFA,0x02,0x1F,0x03,0x44,0x03, 0x57,0x03,0x6A,0x03,0x8F,0x03,0xB4,0x03,0xD9,0x03,0xFE,0x03,0x23,0x04,0x48,0x04,0x6D,0x04, 0x92,0x04,0xB7,0x04,0xDC,0x04,0x01,0x05,0x26,0x05,0x4B,0x05,0x5E,0x05,0x71,0x05,0x96,0x05, 0xBB,0x05,0xE0,0x05,0x05,0x06,0x2A,0x06,0x4F,0x06,0x74,0x06,0x99,0x06,0xBE,0x06,0xE3,0x06, 0x08,0x07,0x2D,0x07,0x52,0x07,0x77,0x07,0x9C,0x07,0xC1,0x07,0xD4,0x07,0xF9,0x07,0x0C,0x08, 0x31,0x08,0x56,0x08,0x7B,0x08,0xA0,0x08,0xC5,0x08,0xD8,0x08,0xFD,0x08,0x22,0x09,0x35,0x09, 0x5A,0x09,0x7F,0x09,0x92,0x09,0xA5,0x09,0xCA,0x09,0xDD,0x09,0x02,0x0A,0x27,0x0A,0x4C,0x0A, 0x71,0x0A,0x96,0x0A,0xA9,0x0A,0xCE,0x0A,0xE1,0x0A,0x06,0x0B,0x2B,0x0B,0x50,0x0B,0x75,0x0B, 0x9A,0x0B,0xBF,0x0B,0xE4,0x0B,0xF7,0x0B,0x1C,0x0C,0x41,0x0C, 5, // 0x20 ' ' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x21 '!' 0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x30,0x30,0x00,0x00,0x00, 9, // 0x22 '"' 0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x00,0x36,0x00,0x36,0x00,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 13, // 0x23 '#' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x20,0x04,0x20,0x08,0x40,0x3F,0xF0,0x3F,0xF0,0x08,0x40,0x10,0x80,0x7F,0xE0,0x7F,0xE0,0x21,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x24 '$' 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x04,0x00,0x1F,0x80,0x34,0xC0,0x64,0xC0,0x64,0x00,0x3C,0x00,0x07,0x80,0x04,0xC0,0x64,0xC0,0x65,0x80,0x3F,0x00,0x04,0x00,0x04,0x00,0x00,0x00, 19, // 0x25 '%' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x08,0x00,0x63,0x10,0x00,0x63,0x10,0x00,0x63,0x20,0x00,0x63,0x2F,0x80,0x63,0x58,0xC0,0x3E,0x98,0xC0,0x00,0x98,0xC0,0x01,0x18,0xC0,0x01,0x18,0xC0,0x02,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 13, // 0x26 '&' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x33,0x00,0x33,0x00,0x33,0x00,0x1E,0x60,0x36,0x60,0x63,0x60,0x61,0xC0,0x60,0xC0,0x30,0xE0,0x1F,0x30,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x27 ''' 0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x28 '(' 0x00,0x00,0x00,0x06,0x0C,0x18,0x30,0x30,0x60,0x60,0x60,0x60,0x60,0x30,0x30,0x18,0x0C,0x06, 8, // 0x29 ')' 0x00,0x00,0x00,0x60,0x30,0x18,0x0C,0x0C,0x06,0x06,0x06,0x06,0x06,0x0C,0x0C,0x18,0x30,0x60, 11, // 0x2A '*' 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x24,0x80,0x15,0x00,0x0E,0x00,0x15,0x00,0x24,0x80,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 13, // 0x2B '+' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x3F,0xE0,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x2C ',' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x60,0x60,0x60,0xC0,0xC0, 7, // 0x2D '-' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 5, // 0x2E '.' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x00,0x00,0x00, 10, // 0x2F '/' 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,0x03,0x00,0x03,0x00,0x06,0x00,0x06,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x30,0x00,0x30,0x00,0x60,0x00,0x60,0x00,0x00,0x00, 11, // 0x30 '0' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x31,0x80,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x31,0x80,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x31 '1' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x1E,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x1F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x32 '2' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x61,0x80,0x60,0xC0,0x00,0xC0,0x01,0x80,0x03,0x00,0x06,0x00,0x0C,0x00,0x18,0x00,0x30,0x00,0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x33 '3' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x61,0x80,0x60,0xC0,0x00,0xC0,0x01,0x80,0x0F,0x00,0x01,0x80,0x00,0xC0,0x60,0xC0,0x61,0x80,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x34 '4' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x03,0x80,0x05,0x80,0x09,0x80,0x11,0x80,0x21,0x80,0x41,0x80,0x7F,0xE0,0x01,0x80,0x01,0x80,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x35 '5' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xC0,0x30,0x00,0x30,0x00,0x30,0x00,0x3F,0x00,0x01,0x80,0x00,0xC0,0x00,0xC0,0x60,0xC0,0x61,0x80,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x36 '6' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x80,0x18,0x00,0x30,0x00,0x60,0x00,0x6F,0x00,0x71,0x80,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x31,0x80,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x37 '7' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xC0,0x00,0xC0,0x01,0x80,0x01,0x80,0x03,0x00,0x03,0x00,0x06,0x00,0x06,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x38 '8' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x31,0x80,0x60,0xC0,0x60,0xC0,0x31,0x80,0x1F,0x00,0x31,0x80,0x60,0xC0,0x60,0xC0,0x31,0x80,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x39 '9' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x31,0x80,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x31,0xC0,0x1E,0xC0,0x00,0xC0,0x01,0x80,0x03,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x3A ':' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x00,0x00,0x30,0x30,0x30,0x00,0x00,0x00, 6, // 0x3B ';' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x30,0x00,0x00,0x38,0x30,0x30,0x30,0x60,0x60, 13, // 0x3C '<' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0xC0,0x03,0x00,0x0C,0x00,0x30,0x00,0x30,0x00,0x0C,0x00,0x03,0x00,0x00,0xC0,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00, 13, // 0x3D '=' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 13, // 0x3E '>' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x18,0x00,0x06,0x00,0x01,0x80,0x00,0x60,0x00,0x60,0x01,0x80,0x06,0x00,0x18,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 9, // 0x3F '?' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x63,0x00,0x03,0x00,0x03,0x00,0x06,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x18,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 14, // 0x40 '@' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x18,0x60,0x20,0x10,0x27,0xD0,0x4C,0xC8,0x4C,0xC8,0x4C,0xC8,0x4C,0xC8,0x4C,0xC8,0x27,0xF0,0x20,0x00,0x18,0x00,0x07,0xC0,0x00,0x00, 12, // 0x41 'A' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x06,0x00,0x0F,0x00,0x0F,0x00,0x19,0x80,0x19,0x80,0x30,0xC0,0x3F,0xC0,0x30,0xC0,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x42 'B' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x63,0x00,0x7F,0x00,0x61,0x80,0x60,0xC0,0x60,0xC0,0x61,0x80,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x43 'C' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x80,0x38,0xC0,0x30,0xC0,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x30,0xC0,0x38,0xC0,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x44 'D' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x61,0xC0,0x60,0xC0,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0xC0,0x61,0xC0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x45 'E' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x80,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0x80,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x46 'F' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x80,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0x80,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x47 'G' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xC0,0x38,0x60,0x30,0x60,0x60,0x00,0x60,0x00,0x63,0xE0,0x60,0x60,0x60,0x60,0x30,0x60,0x38,0x60,0x0F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x48 'H' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x7F,0xE0,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x49 'I' 0x00,0x00,0x00,0x00,0x7E,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x7E,0x00,0x00,0x00, 8, // 0x4A 'J' 0x00,0x00,0x00,0x00,0x3E,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x0C,0xF8,0x00,0x00,0x00, 12, // 0x4B 'K' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x60,0xC0,0x61,0x80,0x63,0x00,0x66,0x00,0x6C,0x00,0x7E,0x00,0x73,0x00,0x61,0x80,0x60,0xC0,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x4C 'L' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 14, // 0x4D 'M' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x38,0x70,0x38,0x70,0x78,0x58,0x58,0x58,0xD8,0x4C,0x98,0x4D,0x98,0x47,0x18,0x47,0x18,0x42,0x18,0x40,0x18,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x4E 'N' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x20,0x70,0x20,0x58,0x20,0x4C,0x20,0x4C,0x20,0x46,0x20,0x43,0x20,0x43,0x20,0x41,0xA0,0x40,0xE0,0x40,0xE0,0x00,0x00,0x00,0x00,0x00,0x00, 13, // 0x4F 'O' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x80,0x38,0xE0,0x30,0x60,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x30,0x60,0x38,0xE0,0x0F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x50 'P' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x61,0x80,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x61,0x80,0x7F,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 13, // 0x51 'Q' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x80,0x38,0xE0,0x30,0x60,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x60,0x30,0x30,0x60,0x38,0xE0,0x0F,0x80,0x03,0x00,0x03,0x80,0x01,0xF0, 12, // 0x52 'R' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x61,0x80,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x61,0x80,0x7F,0x00,0x61,0x80,0x60,0xC0,0x60,0x60,0x60,0x30,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x53 'S' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x30,0xC0,0x60,0xC0,0x60,0x00,0x7C,0x00,0x3F,0x80,0x03,0xC0,0x00,0xC0,0x60,0xC0,0x61,0x80,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x54 'T' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x80,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 12, // 0x55 'U' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x30,0xC0,0x1F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x56 'V' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0x60,0xC0,0x60,0xC0,0x31,0x80,0x31,0x80,0x31,0x80,0x1B,0x00,0x1B,0x00,0x1B,0x00,0x0E,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 16, // 0x57 'W' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x86,0x61,0x86,0x63,0xC6,0x33,0xCC,0x32,0x4C,0x32,0x4C,0x1E,0x78,0x1C,0x38,0x1C,0x38,0x0C,0x30,0x0C,0x30,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x58 'X' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0xC0,0x31,0x80,0x31,0x80,0x1B,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x1B,0x00,0x31,0x80,0x31,0x80,0x60,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x59 'Y' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x61,0x80,0x61,0x80,0x33,0x00,0x1E,0x00,0x1E,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x5A 'Z' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x80,0x01,0x80,0x03,0x00,0x06,0x00,0x06,0x00,0x0C,0x00,0x18,0x00,0x18,0x00,0x30,0x00,0x60,0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x5B '[' 0x00,0x00,0x00,0x3E,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x3E, 10, // 0x5C '\' 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x30,0x00,0x30,0x00,0x18,0x00,0x18,0x00,0x0C,0x00,0x0C,0x00,0x06,0x00,0x06,0x00,0x03,0x00,0x03,0x00,0x01,0x80,0x01,0x80,0x00,0x00, 8, // 0x5D ']' 0x00,0x00,0x00,0x7C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x7C, 13, // 0x5E '^' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x0F,0x00,0x19,0x80,0x30,0xC0,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x5F '_' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xE0,0x00,0x00, 11, // 0x60 '`' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x61 'a' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0x01,0x80,0x01,0x80,0x3F,0x80,0x61,0x80,0x61,0x80,0x63,0x80,0x3D,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x62 'b' 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x6E,0x00,0x73,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x63,0x00,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 8, // 0x63 'c' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x33,0x60,0x60,0x60,0x60,0x33,0x1E,0x00,0x00,0x00, 10, // 0x64 'd' 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x1F,0x80,0x31,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x80,0x1D,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x65 'e' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x33,0x00,0x61,0x80,0x7F,0x80,0x60,0x00,0x60,0x00,0x31,0x80,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 6, // 0x66 'f' 0x00,0x00,0x00,0x1C,0x30,0x30,0x30,0x7C,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x00,0x00, 10, // 0x67 'g' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x31,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x80,0x1D,0x80,0x01,0x80,0x03,0x00,0x3E,0x00, 10, // 0x68 'h' 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x6F,0x00,0x71,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x69 'i' 0x00,0x00,0x00,0x60,0x60,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x00, 6, // 0x6A 'j' 0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x78,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0xF0, 10, // 0x6B 'k' 0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x61,0x80,0x63,0x00,0x66,0x00,0x6C,0x00,0x7E,0x00,0x73,0x00,0x61,0x80,0x60,0xC0,0x00,0x00,0x00,0x00,0x00,0x00, 4, // 0x6C 'l' 0x00,0x00,0x00,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x00, 16, // 0x6D 'm' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6F,0x3C,0x71,0xC6,0x61,0x86,0x61,0x86,0x61,0x86,0x61,0x86,0x61,0x86,0x61,0x86,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x6E 'n' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6F,0x00,0x71,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x6F 'o' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x00,0x33,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x70 'p' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6E,0x00,0x73,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x63,0x00,0x7E,0x00,0x60,0x00,0x60,0x00,0x60,0x00, 10, // 0x71 'q' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x31,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x33,0x80,0x1D,0x80,0x01,0x80,0x01,0x80,0x01,0x80, 7, // 0x72 'r' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6E,0x7E,0x60,0x60,0x60,0x60,0x60,0x60,0x00,0x00,0x00, 9, // 0x73 's' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3E,0x00,0x61,0x00,0x60,0x00,0x7E,0x00,0x3F,0x00,0x03,0x00,0x43,0x00,0x3E,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 7, // 0x74 't' 0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x7E,0x30,0x30,0x30,0x30,0x30,0x30,0x1E,0x00,0x00,0x00, 10, // 0x75 'u' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x61,0x80,0x63,0x80,0x3D,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x76 'v' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x80,0x61,0x80,0x33,0x00,0x33,0x00,0x33,0x00,0x1E,0x00,0x1E,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 14, // 0x77 'w' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x18,0x63,0x18,0x63,0x18,0x37,0xB0,0x34,0xB0,0x3C,0xF0,0x18,0x60,0x18,0x60,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x78 'x' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x80,0x33,0x00,0x33,0x00,0x1E,0x00,0x1E,0x00,0x33,0x00,0x33,0x00,0x61,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 10, // 0x79 'y' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x80,0x61,0x80,0x33,0x00,0x33,0x00,0x33,0x00,0x1E,0x00,0x1E,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x18,0x00, 9, // 0x7A 'z' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x03,0x00,0x06,0x00,0x0C,0x00,0x18,0x00,0x30,0x00,0x60,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 11, // 0x7B '{' 0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x18,0x00,0x70,0x00,0x18,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x07,0x80, 8, // 0x7C '|' 0x00,0x00,0x00,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18, 11, // 0x7D '}' 0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x03,0x00,0x01,0xC0,0x03,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x06,0x00,0x3C,0x00, 13, // 0x7E '~' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x10,0x24,0x10,0x42,0x10,0x41,0x20,0x40,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 15, // 0x7F '' 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF8,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00, 0 }; } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_rounded_rect.cpp0000644000175000017500000001236612516137326024147 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Rounded rectangle vertex generator // //---------------------------------------------------------------------------- #include #include "agg_rounded_rect.h" namespace agg24 { //------------------------------------------------------------------------ rounded_rect::rounded_rect(double x1, double y1, double x2, double y2, double r) : m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2), m_rx1(r), m_ry1(r), m_rx2(r), m_ry2(r), m_rx3(r), m_ry3(r), m_rx4(r), m_ry4(r) { if(x1 > x2) { m_x1 = x2; m_x2 = x1; } if(y1 > y2) { m_y1 = y2; m_y2 = y1; } } //-------------------------------------------------------------------- void rounded_rect::rect(double x1, double y1, double x2, double y2) { m_x1 = x1; m_y1 = y1; m_x2 = x2; m_y2 = y2; if(x1 > x2) { m_x1 = x2; m_x2 = x1; } if(y1 > y2) { m_y1 = y2; m_y2 = y1; } } //-------------------------------------------------------------------- void rounded_rect::radius(double r) { m_rx1 = m_ry1 = m_rx2 = m_ry2 = m_rx3 = m_ry3 = m_rx4 = m_ry4 = r; } //-------------------------------------------------------------------- void rounded_rect::radius(double rx, double ry) { m_rx1 = m_rx2 = m_rx3 = m_rx4 = rx; m_ry1 = m_ry2 = m_ry3 = m_ry4 = ry; } //-------------------------------------------------------------------- void rounded_rect::radius(double rx_bottom, double ry_bottom, double rx_top, double ry_top) { m_rx1 = m_rx2 = rx_bottom; m_rx3 = m_rx4 = rx_top; m_ry1 = m_ry2 = ry_bottom; m_ry3 = m_ry4 = ry_top; } //-------------------------------------------------------------------- void rounded_rect::radius(double rx1, double ry1, double rx2, double ry2, double rx3, double ry3, double rx4, double ry4) { m_rx1 = rx1; m_ry1 = ry1; m_rx2 = rx2; m_ry2 = ry2; m_rx3 = rx3; m_ry3 = ry3; m_rx4 = rx4; m_ry4 = ry4; } //-------------------------------------------------------------------- void rounded_rect::normalize_radius() { double dx = fabs(m_y2 - m_y1); double dy = fabs(m_x2 - m_x1); double k = 1.0; double t; t = dx / (m_rx1 + m_rx2); if(t < k) k = t; t = dx / (m_rx3 + m_rx4); if(t < k) k = t; t = dy / (m_ry1 + m_ry2); if(t < k) k = t; t = dy / (m_ry3 + m_ry4); if(t < k) k = t; if(k < 1.0) { m_rx1 *= k; m_ry1 *= k; m_rx2 *= k; m_ry2 *= k; m_rx3 *= k; m_ry3 *= k; m_rx4 *= k; m_ry4 *= k; } } //-------------------------------------------------------------------- void rounded_rect::rewind(unsigned) { m_status = 0; } //-------------------------------------------------------------------- unsigned rounded_rect::vertex(double* x, double* y) { unsigned cmd = path_cmd_stop; switch(m_status) { case 0: m_arc.init(m_x1 + m_rx1, m_y1 + m_ry1, m_rx1, m_ry1, pi, pi+pi*0.5); m_arc.rewind(0); m_status++; case 1: cmd = m_arc.vertex(x, y); if(is_stop(cmd)) m_status++; else return cmd; case 2: m_arc.init(m_x2 - m_rx2, m_y1 + m_ry2, m_rx2, m_ry2, pi+pi*0.5, 0.0); m_arc.rewind(0); m_status++; case 3: cmd = m_arc.vertex(x, y); if(is_stop(cmd)) m_status++; else return path_cmd_line_to; case 4: m_arc.init(m_x2 - m_rx3, m_y2 - m_ry3, m_rx3, m_ry3, 0.0, pi*0.5); m_arc.rewind(0); m_status++; case 5: cmd = m_arc.vertex(x, y); if(is_stop(cmd)) m_status++; else return path_cmd_line_to; case 6: m_arc.init(m_x1 + m_rx4, m_y2 - m_ry4, m_rx4, m_ry4, pi*0.5, pi); m_arc.rewind(0); m_status++; case 7: cmd = m_arc.vertex(x, y); if(is_stop(cmd)) m_status++; else return path_cmd_line_to; case 8: cmd = path_cmd_end_poly | path_flags_close | path_flags_ccw; m_status++; break; } return cmd; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_sqrt_tables.cpp0000644000175000017500000002043312516137326024007 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // static tables for fast integer sqrt // //---------------------------------------------------------------------------- #include "agg_basics.h" namespace agg24 { int16u g_sqrt_table[1024] = { 0, 2048,2896,3547,4096,4579,5017,5418,5793,6144,6476,6792,7094,7384,7663,7932,8192,8444, 8689,8927,9159,9385,9606,9822,10033,10240,10443,10642,10837,11029,11217,11403,11585, 11765,11942,12116,12288,12457,12625,12790,12953,13114,13273,13430,13585,13738,13890, 14040,14189,14336,14482,14626,14768,14910,15050,15188,15326,15462,15597,15731,15864, 15995,16126,16255,16384,16512,16638,16764,16888,17012,17135,17257,17378,17498,17618, 17736,17854,17971,18087,18203,18318,18432,18545,18658,18770,18882,18992,19102,19212, 19321,19429,19537,19644,19750,19856,19961,20066,20170,20274,20377,20480,20582,20684, 20785,20886,20986,21085,21185,21283,21382,21480,21577,21674,21771,21867,21962,22058, 22153,22247,22341,22435,22528,22621,22713,22806,22897,22989,23080,23170,23261,23351, 23440,23530,23619,23707,23796,23884,23971,24059,24146,24232,24319,24405,24491,24576, 24661,24746,24831,24915,24999,25083,25166,25249,25332,25415,25497,25580,25661,25743, 25824,25905,25986,26067,26147,26227,26307,26387,26466,26545,26624,26703,26781,26859, 26937,27015,27092,27170,27247,27324,27400,27477,27553,27629,27705,27780,27856,27931, 28006,28081,28155,28230,28304,28378,28452,28525,28599,28672,28745,28818,28891,28963, 29035,29108,29180,29251,29323,29394,29466,29537,29608,29678,29749,29819,29890,29960, 30030,30099,30169,30238,30308,30377,30446,30515,30583,30652,30720,30788,30856,30924, 30992,31059,31127,31194,31261,31328,31395,31462,31529,31595,31661,31727,31794,31859, 31925,31991,32056,32122,32187,32252,32317,32382,32446,32511,32575,32640,32704,32768, 32832,32896,32959,33023,33086,33150,33213,33276,33339,33402,33465,33527,33590,33652, 33714,33776,33839,33900,33962,34024,34086,34147,34208,34270,34331,34392,34453,34514, 34574,34635,34695,34756,34816,34876,34936,34996,35056,35116,35176,35235,35295,35354, 35413,35472,35531,35590,35649,35708,35767,35825,35884,35942,36001,36059,36117,36175, 36233,36291,36348,36406,36464,36521,36578,36636,36693,36750,36807,36864,36921,36978, 37034,37091,37147,37204,37260,37316,37372,37429,37485,37540,37596,37652,37708,37763, 37819,37874,37929,37985,38040,38095,38150,38205,38260,38315,38369,38424,38478,38533, 38587,38642,38696,38750,38804,38858,38912,38966,39020,39073,39127,39181,39234,39287, 39341,39394,39447,39500,39553,39606,39659,39712,39765,39818,39870,39923,39975,40028, 40080,40132,40185,40237,40289,40341,40393,40445,40497,40548,40600,40652,40703,40755, 40806,40857,40909,40960,41011,41062,41113,41164,41215,41266,41317,41368,41418,41469, 41519,41570,41620,41671,41721,41771,41821,41871,41922,41972,42021,42071,42121,42171, 42221,42270,42320,42369,42419,42468,42518,42567,42616,42665,42714,42763,42813,42861, 42910,42959,43008,43057,43105,43154,43203,43251,43300,43348,43396,43445,43493,43541, 43589,43637,43685,43733,43781,43829,43877,43925,43972,44020,44068,44115,44163,44210, 44258,44305,44352,44400,44447,44494,44541,44588,44635,44682,44729,44776,44823,44869, 44916,44963,45009,45056,45103,45149,45195,45242,45288,45334,45381,45427,45473,45519, 45565,45611,45657,45703,45749,45795,45840,45886,45932,45977,46023,46069,46114,46160, 46205,46250,46296,46341,46386,46431,46477,46522,46567,46612,46657,46702,46746,46791, 46836,46881,46926,46970,47015,47059,47104,47149,47193,47237,47282,47326,47370,47415, 47459,47503,47547,47591,47635,47679,47723,47767,47811,47855,47899,47942,47986,48030, 48074,48117,48161,48204,48248,48291,48335,48378,48421,48465,48508,48551,48594,48637, 48680,48723,48766,48809,48852,48895,48938,48981,49024,49067,49109,49152,49195,49237, 49280,49322,49365,49407,49450,49492,49535,49577,49619,49661,49704,49746,49788,49830, 49872,49914,49956,49998,50040,50082,50124,50166,50207,50249,50291,50332,50374,50416, 50457,50499,50540,50582,50623,50665,50706,50747,50789,50830,50871,50912,50954,50995, 51036,51077,51118,51159,51200,51241,51282,51323,51364,51404,51445,51486,51527,51567, 51608,51649,51689,51730,51770,51811,51851,51892,51932,51972,52013,52053,52093,52134, 52174,52214,52254,52294,52334,52374,52414,52454,52494,52534,52574,52614,52654,52694, 52734,52773,52813,52853,52892,52932,52972,53011,53051,53090,53130,53169,53209,53248, 53287,53327,53366,53405,53445,53484,53523,53562,53601,53640,53679,53719,53758,53797, 53836,53874,53913,53952,53991,54030,54069,54108,54146,54185,54224,54262,54301,54340, 54378,54417,54455,54494,54532,54571,54609,54647,54686,54724,54762,54801,54839,54877, 54915,54954,54992,55030,55068,55106,55144,55182,55220,55258,55296,55334,55372,55410, 55447,55485,55523,55561,55599,55636,55674,55712,55749,55787,55824,55862,55900,55937, 55975,56012,56049,56087,56124,56162,56199,56236,56273,56311,56348,56385,56422,56459, 56497,56534,56571,56608,56645,56682,56719,56756,56793,56830,56867,56903,56940,56977, 57014,57051,57087,57124,57161,57198,57234,57271,57307,57344,57381,57417,57454,57490, 57527,57563,57599,57636,57672,57709,57745,57781,57817,57854,57890,57926,57962,57999, 58035,58071,58107,58143,58179,58215,58251,58287,58323,58359,58395,58431,58467,58503, 58538,58574,58610,58646,58682,58717,58753,58789,58824,58860,58896,58931,58967,59002, 59038,59073,59109,59144,59180,59215,59251,59286,59321,59357,59392,59427,59463,59498, 59533,59568,59603,59639,59674,59709,59744,59779,59814,59849,59884,59919,59954,59989, 60024,60059,60094,60129,60164,60199,60233,60268,60303,60338,60373,60407,60442,60477, 60511,60546,60581,60615,60650,60684,60719,60753,60788,60822,60857,60891,60926,60960, 60995,61029,61063,61098,61132,61166,61201,61235,61269,61303,61338,61372,61406,61440, 61474,61508,61542,61576,61610,61644,61678,61712,61746,61780,61814,61848,61882,61916, 61950,61984,62018,62051,62085,62119,62153,62186,62220,62254,62287,62321,62355,62388, 62422,62456,62489,62523,62556,62590,62623,62657,62690,62724,62757,62790,62824,62857, 62891,62924,62957,62991,63024,63057,63090,63124,63157,63190,63223,63256,63289,63323, 63356,63389,63422,63455,63488,63521,63554,63587,63620,63653,63686,63719,63752,63785, 63817,63850,63883,63916,63949,63982,64014,64047,64080,64113,64145,64178,64211,64243, 64276,64309,64341,64374,64406,64439,64471,64504,64536,64569,64601,64634,64666,64699, 64731,64763,64796,64828,64861,64893,64925,64957,64990,65022,65054,65086,65119,65151, 65183,65215,65247,65279,65312,65344,65376,65408,65440,65472,65504 }; int8 g_elder_bit_table[256] = { 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 }; } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_vcgen_markers_term.cpp0000644000175000017500000000651512516137326025346 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Terminal markers generator (arrowhead/arrowtail) // //---------------------------------------------------------------------------- #include "agg_vcgen_markers_term.h" namespace agg24 { //------------------------------------------------------------------------ void vcgen_markers_term::remove_all() { m_markers.remove_all(); } //------------------------------------------------------------------------ void vcgen_markers_term::add_vertex(double x, double y, unsigned cmd) { if(is_move_to(cmd)) { if(m_markers.size() & 1) { // Initial state, the first coordinate was added. // If two of more calls of start_vertex() occures // we just modify the last one. m_markers.modify_last(coord_type(x, y)); } else { m_markers.add(coord_type(x, y)); } } else { if(is_vertex(cmd)) { if(m_markers.size() & 1) { // Initial state, the first coordinate was added. // Add three more points, 0,1,1,0 m_markers.add(coord_type(x, y)); m_markers.add(m_markers[m_markers.size() - 1]); m_markers.add(m_markers[m_markers.size() - 3]); } else { if(m_markers.size()) { // Replace two last points: 0,1,1,0 -> 0,1,2,1 m_markers[m_markers.size() - 1] = m_markers[m_markers.size() - 2]; m_markers[m_markers.size() - 2] = coord_type(x, y); } } } } } //------------------------------------------------------------------------ void vcgen_markers_term::rewind(unsigned path_id) { m_curr_id = path_id * 2; m_curr_idx = m_curr_id; } //------------------------------------------------------------------------ unsigned vcgen_markers_term::vertex(double* x, double* y) { if(m_curr_id > 2 || m_curr_idx >= m_markers.size()) { return path_cmd_stop; } const coord_type& c = m_markers[m_curr_idx]; *x = c.x; *y = c.y; if(m_curr_idx & 1) { m_curr_idx += 3; return path_cmd_line_to; } ++m_curr_idx; return path_cmd_move_to; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_vpgen_clip_polyline.cpp0000644000175000017500000000474212516137326025532 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #include "agg_vpgen_clip_polyline.h" #include "agg_clip_liang_barsky.h" namespace agg24 { //---------------------------------------------------------------------------- void vpgen_clip_polyline::reset() { m_vertex = 0; m_num_vertices = 0; m_move_to = false; } //---------------------------------------------------------------------------- void vpgen_clip_polyline::move_to(double x, double y) { m_vertex = 0; m_num_vertices = 0; m_x1 = x; m_y1 = y; m_move_to = true; } //---------------------------------------------------------------------------- void vpgen_clip_polyline::line_to(double x, double y) { double x2 = x; double y2 = y; unsigned flags = clip_line_segment(&m_x1, &m_y1, &x2, &y2, m_clip_box); m_vertex = 0; m_num_vertices = 0; if((flags & 4) == 0) { if((flags & 1) != 0 || m_move_to) { m_x[0] = m_x1; m_y[0] = m_y1; m_cmd[0] = path_cmd_move_to; m_num_vertices = 1; } m_x[m_num_vertices] = x2; m_y[m_num_vertices] = y2; m_cmd[m_num_vertices++] = path_cmd_line_to; m_move_to = (flags & 2) != 0; } m_x1 = x; m_y1 = y; } //---------------------------------------------------------------------------- unsigned vpgen_clip_polyline::vertex(double* x, double* y) { if(m_vertex < m_num_vertices) { *x = m_x[m_vertex]; *y = m_y[m_vertex]; return m_cmd[m_vertex++]; } return path_cmd_stop; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/news0000644000175000017500000000000012516137326021025 0ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/autogen.sh0000644000175000017500000000047212516137326022141 0ustar varunvarun# autogen.sh # # invoke the auto* tools to create the configureation system # build aclocal.m4 aclocal # build the configure script autoconf # set up libtool libtoolize --force # invoke automake automake --foreign --add-missing # and finally invoke our new configure ./configure $* # end enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/ChangeLog0000644000175000017500000000000012516137326021700 0ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_bspline.cpp0000644000175000017500000001774112516137326023130 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // class bspline // //---------------------------------------------------------------------------- #include "agg_bspline.h" namespace agg24 { //------------------------------------------------------------------------ bspline::bspline() : m_max(0), m_num(0), m_x(0), m_y(0), m_last_idx(-1) { } //------------------------------------------------------------------------ bspline::bspline(int num) : m_max(0), m_num(0), m_x(0), m_y(0), m_last_idx(-1) { init(num); } //------------------------------------------------------------------------ bspline::bspline(int num, const double* x, const double* y) : m_max(0), m_num(0), m_x(0), m_y(0), m_last_idx(-1) { init(num, x, y); } //------------------------------------------------------------------------ void bspline::init(int max) { if(max > 2 && max > m_max) { m_am.resize(max * 3); m_max = max; m_x = &m_am[m_max]; m_y = &m_am[m_max * 2]; } m_num = 0; m_last_idx = -1; } //------------------------------------------------------------------------ void bspline::add_point(double x, double y) { if(m_num < m_max) { m_x[m_num] = x; m_y[m_num] = y; ++m_num; } } //------------------------------------------------------------------------ void bspline::prepare() { if(m_num > 2) { int i, k, n1; double* temp; double* r; double* s; double h, p, d, f, e; for(k = 0; k < m_num; k++) { m_am[k] = 0.0; } n1 = 3 * m_num; pod_array al(n1); temp = &al[0]; for(k = 0; k < n1; k++) { temp[k] = 0.0; } r = temp + m_num; s = temp + m_num * 2; n1 = m_num - 1; d = m_x[1] - m_x[0]; e = (m_y[1] - m_y[0]) / d; for(k = 1; k < n1; k++) { h = d; d = m_x[k + 1] - m_x[k]; f = e; e = (m_y[k + 1] - m_y[k]) / d; al[k] = d / (d + h); r[k] = 1.0 - al[k]; s[k] = 6.0 * (e - f) / (h + d); } for(k = 1; k < n1; k++) { p = 1.0 / (r[k] * al[k - 1] + 2.0); al[k] *= -p; s[k] = (s[k] - r[k] * s[k - 1]) * p; } m_am[n1] = 0.0; al[n1 - 1] = s[n1 - 1]; m_am[n1 - 1] = al[n1 - 1]; for(k = n1 - 2, i = 0; i < m_num - 2; i++, k--) { al[k] = al[k] * al[k + 1] + s[k]; m_am[k] = al[k]; } } m_last_idx = -1; } //------------------------------------------------------------------------ void bspline::init(int num, const double* x, const double* y) { if(num > 2) { init(num); int i; for(i = 0; i < num; i++) { add_point(*x++, *y++); } prepare(); } m_last_idx = -1; } //------------------------------------------------------------------------ void bspline::bsearch(int n, const double *x, double x0, int *i) { int j = n - 1; int k; for(*i = 0; (j - *i) > 1; ) { if(x0 < x[k = (*i + j) >> 1]) j = k; else *i = k; } } //------------------------------------------------------------------------ double bspline::interpolation(double x, int i) const { int j = i + 1; double d = m_x[i] - m_x[j]; double h = x - m_x[j]; double r = m_x[i] - x; double p = d * d / 6.0; return (m_am[j] * r * r * r + m_am[i] * h * h * h) / 6.0 / d + ((m_y[j] - m_am[j] * p) * r + (m_y[i] - m_am[i] * p) * h) / d; } //------------------------------------------------------------------------ double bspline::extrapolation_left(double x) const { double d = m_x[1] - m_x[0]; return (-d * m_am[1] / 6 + (m_y[1] - m_y[0]) / d) * (x - m_x[0]) + m_y[0]; } //------------------------------------------------------------------------ double bspline::extrapolation_right(double x) const { double d = m_x[m_num - 1] - m_x[m_num - 2]; return (d * m_am[m_num - 2] / 6 + (m_y[m_num - 1] - m_y[m_num - 2]) / d) * (x - m_x[m_num - 1]) + m_y[m_num - 1]; } //------------------------------------------------------------------------ double bspline::get(double x) const { if(m_num > 2) { int i; // Extrapolation on the left if(x < m_x[0]) return extrapolation_left(x); // Extrapolation on the right if(x >= m_x[m_num - 1]) return extrapolation_right(x); // Interpolation bsearch(m_num, m_x, x, &i); return interpolation(x, i); } return 0.0; } //------------------------------------------------------------------------ double bspline::get_stateful(double x) const { if(m_num > 2) { // Extrapolation on the left if(x < m_x[0]) return extrapolation_left(x); // Extrapolation on the right if(x >= m_x[m_num - 1]) return extrapolation_right(x); if(m_last_idx >= 0) { // Check if x is not in current range if(x < m_x[m_last_idx] || x > m_x[m_last_idx + 1]) { // Check if x between next points (most probably) if(m_last_idx < m_num - 2 && x >= m_x[m_last_idx + 1] && x <= m_x[m_last_idx + 2]) { ++m_last_idx; } else if(m_last_idx > 0 && x >= m_x[m_last_idx - 1] && x <= m_x[m_last_idx]) { // x is between pevious points --m_last_idx; } else { // Else perform full search bsearch(m_num, m_x, x, &m_last_idx); } } return interpolation(x, m_last_idx); } else { // Interpolation bsearch(m_num, m_x, x, &m_last_idx); return interpolation(x, m_last_idx); } } return 0.0; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/install0000644000175000017500000000000012516137326021517 0ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_arrowhead.cpp0000644000175000017500000000726212516137326023445 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Simple arrowhead/arrowtail generator // //---------------------------------------------------------------------------- #include "agg_arrowhead.h" namespace agg24 { //------------------------------------------------------------------------ arrowhead::arrowhead() : m_head_d1(1.0), m_head_d2(1.0), m_head_d3(1.0), m_head_d4(0.0), m_tail_d1(1.0), m_tail_d2(1.0), m_tail_d3(1.0), m_tail_d4(0.0), m_head_flag(false), m_tail_flag(false), m_curr_id(0), m_curr_coord(0) { } //------------------------------------------------------------------------ void arrowhead::rewind(unsigned path_id) { m_curr_id = path_id; m_curr_coord = 0; if(path_id == 0) { if(!m_tail_flag) { m_cmd[0] = path_cmd_stop; return; } m_coord[0] = m_tail_d1; m_coord[1] = 0.0; m_coord[2] = m_tail_d1 - m_tail_d4; m_coord[3] = m_tail_d3; m_coord[4] = -m_tail_d2 - m_tail_d4; m_coord[5] = m_tail_d3; m_coord[6] = -m_tail_d2; m_coord[7] = 0.0; m_coord[8] = -m_tail_d2 - m_tail_d4; m_coord[9] = -m_tail_d3; m_coord[10] = m_tail_d1 - m_tail_d4; m_coord[11] = -m_tail_d3; m_cmd[0] = path_cmd_move_to; m_cmd[1] = path_cmd_line_to; m_cmd[2] = path_cmd_line_to; m_cmd[3] = path_cmd_line_to; m_cmd[4] = path_cmd_line_to; m_cmd[5] = path_cmd_line_to; m_cmd[7] = path_cmd_end_poly | path_flags_close | path_flags_ccw; m_cmd[6] = path_cmd_stop; return; } if(path_id == 1) { if(!m_head_flag) { m_cmd[0] = path_cmd_stop; return; } m_coord[0] = -m_head_d1; m_coord[1] = 0.0; m_coord[2] = m_head_d2 + m_head_d4; m_coord[3] = -m_head_d3; m_coord[4] = m_head_d2; m_coord[5] = 0.0; m_coord[6] = m_head_d2 + m_head_d4; m_coord[7] = m_head_d3; m_cmd[0] = path_cmd_move_to; m_cmd[1] = path_cmd_line_to; m_cmd[2] = path_cmd_line_to; m_cmd[3] = path_cmd_line_to; m_cmd[4] = path_cmd_end_poly | path_flags_close | path_flags_ccw; m_cmd[5] = path_cmd_stop; return; } } //------------------------------------------------------------------------ unsigned arrowhead::vertex(double* x, double* y) { if(m_curr_id < 2) { unsigned curr_idx = m_curr_coord * 2; *x = m_coord[curr_idx]; *y = m_coord[curr_idx + 1]; return m_cmd[m_curr_coord++]; } return path_cmd_stop; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_gsv_text.cpp0000644000175000017500000010117412516137326023331 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Class gsv_text // //---------------------------------------------------------------------------- #include #include #include "agg_gsv_text.h" namespace agg24 { int8u gsv_default_font[] = { 0x40,0x00,0x6c,0x0f,0x15,0x00,0x0e,0x00,0xf9,0xff, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x0d,0x0a,0x0d,0x0a,0x46,0x6f,0x6e,0x74,0x20,0x28, 0x63,0x29,0x20,0x4d,0x69,0x63,0x72,0x6f,0x50,0x72, 0x6f,0x66,0x20,0x32,0x37,0x20,0x53,0x65,0x70,0x74, 0x65,0x6d,0x62,0x2e,0x31,0x39,0x38,0x39,0x00,0x0d, 0x0a,0x0d,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x00,0x12,0x00,0x34,0x00,0x46,0x00,0x94,0x00, 0xd0,0x00,0x2e,0x01,0x3e,0x01,0x64,0x01,0x8a,0x01, 0x98,0x01,0xa2,0x01,0xb4,0x01,0xba,0x01,0xc6,0x01, 0xcc,0x01,0xf0,0x01,0xfa,0x01,0x18,0x02,0x38,0x02, 0x44,0x02,0x68,0x02,0x98,0x02,0xa2,0x02,0xde,0x02, 0x0e,0x03,0x24,0x03,0x40,0x03,0x48,0x03,0x52,0x03, 0x5a,0x03,0x82,0x03,0xec,0x03,0xfa,0x03,0x26,0x04, 0x4c,0x04,0x6a,0x04,0x7c,0x04,0x8a,0x04,0xb6,0x04, 0xc4,0x04,0xca,0x04,0xe0,0x04,0xee,0x04,0xf8,0x04, 0x0a,0x05,0x18,0x05,0x44,0x05,0x5e,0x05,0x8e,0x05, 0xac,0x05,0xd6,0x05,0xe0,0x05,0xf6,0x05,0x00,0x06, 0x12,0x06,0x1c,0x06,0x28,0x06,0x36,0x06,0x48,0x06, 0x4e,0x06,0x60,0x06,0x6e,0x06,0x74,0x06,0x84,0x06, 0xa6,0x06,0xc8,0x06,0xe6,0x06,0x08,0x07,0x2c,0x07, 0x3c,0x07,0x68,0x07,0x7c,0x07,0x8c,0x07,0xa2,0x07, 0xb0,0x07,0xb6,0x07,0xd8,0x07,0xec,0x07,0x10,0x08, 0x32,0x08,0x54,0x08,0x64,0x08,0x88,0x08,0x98,0x08, 0xac,0x08,0xb6,0x08,0xc8,0x08,0xd2,0x08,0xe4,0x08, 0xf2,0x08,0x3e,0x09,0x48,0x09,0x94,0x09,0xc2,0x09, 0xc4,0x09,0xd0,0x09,0xe2,0x09,0x04,0x0a,0x0e,0x0a, 0x26,0x0a,0x34,0x0a,0x4a,0x0a,0x66,0x0a,0x70,0x0a, 0x7e,0x0a,0x8e,0x0a,0x9a,0x0a,0xa6,0x0a,0xb4,0x0a, 0xd8,0x0a,0xe2,0x0a,0xf6,0x0a,0x18,0x0b,0x22,0x0b, 0x32,0x0b,0x56,0x0b,0x60,0x0b,0x6e,0x0b,0x7c,0x0b, 0x8a,0x0b,0x9c,0x0b,0x9e,0x0b,0xb2,0x0b,0xc2,0x0b, 0xd8,0x0b,0xf4,0x0b,0x08,0x0c,0x30,0x0c,0x56,0x0c, 0x72,0x0c,0x90,0x0c,0xb2,0x0c,0xce,0x0c,0xe2,0x0c, 0xfe,0x0c,0x10,0x0d,0x26,0x0d,0x36,0x0d,0x42,0x0d, 0x4e,0x0d,0x5c,0x0d,0x78,0x0d,0x8c,0x0d,0x8e,0x0d, 0x90,0x0d,0x92,0x0d,0x94,0x0d,0x96,0x0d,0x98,0x0d, 0x9a,0x0d,0x9c,0x0d,0x9e,0x0d,0xa0,0x0d,0xa2,0x0d, 0xa4,0x0d,0xa6,0x0d,0xa8,0x0d,0xaa,0x0d,0xac,0x0d, 0xae,0x0d,0xb0,0x0d,0xb2,0x0d,0xb4,0x0d,0xb6,0x0d, 0xb8,0x0d,0xba,0x0d,0xbc,0x0d,0xbe,0x0d,0xc0,0x0d, 0xc2,0x0d,0xc4,0x0d,0xc6,0x0d,0xc8,0x0d,0xca,0x0d, 0xcc,0x0d,0xce,0x0d,0xd0,0x0d,0xd2,0x0d,0xd4,0x0d, 0xd6,0x0d,0xd8,0x0d,0xda,0x0d,0xdc,0x0d,0xde,0x0d, 0xe0,0x0d,0xe2,0x0d,0xe4,0x0d,0xe6,0x0d,0xe8,0x0d, 0xea,0x0d,0xec,0x0d,0x0c,0x0e,0x26,0x0e,0x48,0x0e, 0x64,0x0e,0x88,0x0e,0x92,0x0e,0xa6,0x0e,0xb4,0x0e, 0xd0,0x0e,0xee,0x0e,0x02,0x0f,0x16,0x0f,0x26,0x0f, 0x3c,0x0f,0x58,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f, 0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f, 0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f, 0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x6c,0x0f,0x10,0x80, 0x05,0x95,0x00,0x72,0x00,0xfb,0xff,0x7f,0x01,0x7f, 0x01,0x01,0xff,0x01,0x05,0xfe,0x05,0x95,0xff,0x7f, 0x00,0x7a,0x01,0x86,0xff,0x7a,0x01,0x87,0x01,0x7f, 0xfe,0x7a,0x0a,0x87,0xff,0x7f,0x00,0x7a,0x01,0x86, 0xff,0x7a,0x01,0x87,0x01,0x7f,0xfe,0x7a,0x05,0xf2, 0x0b,0x95,0xf9,0x64,0x0d,0x9c,0xf9,0x64,0xfa,0x91, 0x0e,0x00,0xf1,0xfa,0x0e,0x00,0x04,0xfc,0x08,0x99, 0x00,0x63,0x04,0x9d,0x00,0x63,0x04,0x96,0xff,0x7f, 0x01,0x7f,0x01,0x01,0x00,0x01,0xfe,0x02,0xfd,0x01, 0xfc,0x00,0xfd,0x7f,0xfe,0x7e,0x00,0x7e,0x01,0x7e, 0x01,0x7f,0x02,0x7f,0x06,0x7e,0x02,0x7f,0x02,0x7e, 0xf2,0x89,0x02,0x7e,0x02,0x7f,0x06,0x7e,0x02,0x7f, 0x01,0x7f,0x01,0x7e,0x00,0x7c,0xfe,0x7e,0xfd,0x7f, 0xfc,0x00,0xfd,0x01,0xfe,0x02,0x00,0x01,0x01,0x01, 0x01,0x7f,0xff,0x7f,0x10,0xfd,0x15,0x95,0xee,0x6b, 0x05,0x95,0x02,0x7e,0x00,0x7e,0xff,0x7e,0xfe,0x7f, 0xfe,0x00,0xfe,0x02,0x00,0x02,0x01,0x02,0x02,0x01, 0x02,0x00,0x02,0x7f,0x03,0x7f,0x03,0x00,0x03,0x01, 0x02,0x01,0xfc,0xf2,0xfe,0x7f,0xff,0x7e,0x00,0x7e, 0x02,0x7e,0x02,0x00,0x02,0x01,0x01,0x02,0x00,0x02, 0xfe,0x02,0xfe,0x00,0x07,0xf9,0x15,0x8d,0xff,0x7f, 0x01,0x7f,0x01,0x01,0x00,0x01,0xff,0x01,0xff,0x00, 0xff,0x7f,0xff,0x7e,0xfe,0x7b,0xfe,0x7d,0xfe,0x7e, 0xfe,0x7f,0xfd,0x00,0xfd,0x01,0xff,0x02,0x00,0x03, 0x01,0x02,0x06,0x04,0x02,0x02,0x01,0x02,0x00,0x02, 0xff,0x02,0xfe,0x01,0xfe,0x7f,0xff,0x7e,0x00,0x7e, 0x01,0x7d,0x02,0x7d,0x05,0x79,0x02,0x7e,0x03,0x7f, 0x01,0x00,0x01,0x01,0x00,0x01,0xf1,0xfe,0xfe,0x01, 0xff,0x02,0x00,0x03,0x01,0x02,0x02,0x02,0x00,0x86, 0x01,0x7e,0x08,0x75,0x02,0x7e,0x02,0x7f,0x05,0x80, 0x05,0x93,0xff,0x01,0x01,0x01,0x01,0x7f,0x00,0x7e, 0xff,0x7e,0xff,0x7f,0x06,0xf1,0x0b,0x99,0xfe,0x7e, 0xfe,0x7d,0xfe,0x7c,0xff,0x7b,0x00,0x7c,0x01,0x7b, 0x02,0x7c,0x02,0x7d,0x02,0x7e,0xfe,0x9e,0xfe,0x7c, 0xff,0x7d,0xff,0x7b,0x00,0x7c,0x01,0x7b,0x01,0x7d, 0x02,0x7c,0x05,0x85,0x03,0x99,0x02,0x7e,0x02,0x7d, 0x02,0x7c,0x01,0x7b,0x00,0x7c,0xff,0x7b,0xfe,0x7c, 0xfe,0x7d,0xfe,0x7e,0x02,0x9e,0x02,0x7c,0x01,0x7d, 0x01,0x7b,0x00,0x7c,0xff,0x7b,0xff,0x7d,0xfe,0x7c, 0x09,0x85,0x08,0x95,0x00,0x74,0xfb,0x89,0x0a,0x7a, 0x00,0x86,0xf6,0x7a,0x0d,0xf4,0x0d,0x92,0x00,0x6e, 0xf7,0x89,0x12,0x00,0x04,0xf7,0x06,0x81,0xff,0x7f, 0xff,0x01,0x01,0x01,0x01,0x7f,0x00,0x7e,0xff,0x7e, 0xff,0x7f,0x06,0x84,0x04,0x89,0x12,0x00,0x04,0xf7, 0x05,0x82,0xff,0x7f,0x01,0x7f,0x01,0x01,0xff,0x01, 0x05,0xfe,0x00,0xfd,0x0e,0x18,0x00,0xeb,0x09,0x95, 0xfd,0x7f,0xfe,0x7d,0xff,0x7b,0x00,0x7d,0x01,0x7b, 0x02,0x7d,0x03,0x7f,0x02,0x00,0x03,0x01,0x02,0x03, 0x01,0x05,0x00,0x03,0xff,0x05,0xfe,0x03,0xfd,0x01, 0xfe,0x00,0x0b,0xeb,0x06,0x91,0x02,0x01,0x03,0x03, 0x00,0x6b,0x09,0x80,0x04,0x90,0x00,0x01,0x01,0x02, 0x01,0x01,0x02,0x01,0x04,0x00,0x02,0x7f,0x01,0x7f, 0x01,0x7e,0x00,0x7e,0xff,0x7e,0xfe,0x7d,0xf6,0x76, 0x0e,0x00,0x03,0x80,0x05,0x95,0x0b,0x00,0xfa,0x78, 0x03,0x00,0x02,0x7f,0x01,0x7f,0x01,0x7d,0x00,0x7e, 0xff,0x7d,0xfe,0x7e,0xfd,0x7f,0xfd,0x00,0xfd,0x01, 0xff,0x01,0xff,0x02,0x11,0xfc,0x0d,0x95,0xf6,0x72, 0x0f,0x00,0xfb,0x8e,0x00,0x6b,0x07,0x80,0x0f,0x95, 0xf6,0x00,0xff,0x77,0x01,0x01,0x03,0x01,0x03,0x00, 0x03,0x7f,0x02,0x7e,0x01,0x7d,0x00,0x7e,0xff,0x7d, 0xfe,0x7e,0xfd,0x7f,0xfd,0x00,0xfd,0x01,0xff,0x01, 0xff,0x02,0x11,0xfc,0x10,0x92,0xff,0x02,0xfd,0x01, 0xfe,0x00,0xfd,0x7f,0xfe,0x7d,0xff,0x7b,0x00,0x7b, 0x01,0x7c,0x02,0x7e,0x03,0x7f,0x01,0x00,0x03,0x01, 0x02,0x02,0x01,0x03,0x00,0x01,0xff,0x03,0xfe,0x02, 0xfd,0x01,0xff,0x00,0xfd,0x7f,0xfe,0x7e,0xff,0x7d, 0x10,0xf9,0x11,0x95,0xf6,0x6b,0xfc,0x95,0x0e,0x00, 0x03,0xeb,0x08,0x95,0xfd,0x7f,0xff,0x7e,0x00,0x7e, 0x01,0x7e,0x02,0x7f,0x04,0x7f,0x03,0x7f,0x02,0x7e, 0x01,0x7e,0x00,0x7d,0xff,0x7e,0xff,0x7f,0xfd,0x7f, 0xfc,0x00,0xfd,0x01,0xff,0x01,0xff,0x02,0x00,0x03, 0x01,0x02,0x02,0x02,0x03,0x01,0x04,0x01,0x02,0x01, 0x01,0x02,0x00,0x02,0xff,0x02,0xfd,0x01,0xfc,0x00, 0x0c,0xeb,0x10,0x8e,0xff,0x7d,0xfe,0x7e,0xfd,0x7f, 0xff,0x00,0xfd,0x01,0xfe,0x02,0xff,0x03,0x00,0x01, 0x01,0x03,0x02,0x02,0x03,0x01,0x01,0x00,0x03,0x7f, 0x02,0x7e,0x01,0x7c,0x00,0x7b,0xff,0x7b,0xfe,0x7d, 0xfd,0x7f,0xfe,0x00,0xfd,0x01,0xff,0x02,0x10,0xfd, 0x05,0x8e,0xff,0x7f,0x01,0x7f,0x01,0x01,0xff,0x01, 0x00,0xf4,0xff,0x7f,0x01,0x7f,0x01,0x01,0xff,0x01, 0x05,0xfe,0x05,0x8e,0xff,0x7f,0x01,0x7f,0x01,0x01, 0xff,0x01,0x01,0xf3,0xff,0x7f,0xff,0x01,0x01,0x01, 0x01,0x7f,0x00,0x7e,0xff,0x7e,0xff,0x7f,0x06,0x84, 0x14,0x92,0xf0,0x77,0x10,0x77,0x04,0x80,0x04,0x8c, 0x12,0x00,0xee,0xfa,0x12,0x00,0x04,0xfa,0x04,0x92, 0x10,0x77,0xf0,0x77,0x14,0x80,0x03,0x90,0x00,0x01, 0x01,0x02,0x01,0x01,0x02,0x01,0x04,0x00,0x02,0x7f, 0x01,0x7f,0x01,0x7e,0x00,0x7e,0xff,0x7e,0xff,0x7f, 0xfc,0x7e,0x00,0x7d,0x00,0xfb,0xff,0x7f,0x01,0x7f, 0x01,0x01,0xff,0x01,0x09,0xfe,0x12,0x8d,0xff,0x02, 0xfe,0x01,0xfd,0x00,0xfe,0x7f,0xff,0x7f,0xff,0x7d, 0x00,0x7d,0x01,0x7e,0x02,0x7f,0x03,0x00,0x02,0x01, 0x01,0x02,0xfb,0x88,0xfe,0x7e,0xff,0x7d,0x00,0x7d, 0x01,0x7e,0x01,0x7f,0x07,0x8b,0xff,0x78,0x00,0x7e, 0x02,0x7f,0x02,0x00,0x02,0x02,0x01,0x03,0x00,0x02, 0xff,0x03,0xff,0x02,0xfe,0x02,0xfe,0x01,0xfd,0x01, 0xfd,0x00,0xfd,0x7f,0xfe,0x7f,0xfe,0x7e,0xff,0x7e, 0xff,0x7d,0x00,0x7d,0x01,0x7d,0x01,0x7e,0x02,0x7e, 0x02,0x7f,0x03,0x7f,0x03,0x00,0x03,0x01,0x02,0x01, 0x01,0x01,0xfe,0x8d,0xff,0x78,0x00,0x7e,0x01,0x7f, 0x08,0xfb,0x09,0x95,0xf8,0x6b,0x08,0x95,0x08,0x6b, 0xf3,0x87,0x0a,0x00,0x04,0xf9,0x04,0x95,0x00,0x6b, 0x00,0x95,0x09,0x00,0x03,0x7f,0x01,0x7f,0x01,0x7e, 0x00,0x7e,0xff,0x7e,0xff,0x7f,0xfd,0x7f,0xf7,0x80, 0x09,0x00,0x03,0x7f,0x01,0x7f,0x01,0x7e,0x00,0x7d, 0xff,0x7e,0xff,0x7f,0xfd,0x7f,0xf7,0x00,0x11,0x80, 0x12,0x90,0xff,0x02,0xfe,0x02,0xfe,0x01,0xfc,0x00, 0xfe,0x7f,0xfe,0x7e,0xff,0x7e,0xff,0x7d,0x00,0x7b, 0x01,0x7d,0x01,0x7e,0x02,0x7e,0x02,0x7f,0x04,0x00, 0x02,0x01,0x02,0x02,0x01,0x02,0x03,0xfb,0x04,0x95, 0x00,0x6b,0x00,0x95,0x07,0x00,0x03,0x7f,0x02,0x7e, 0x01,0x7e,0x01,0x7d,0x00,0x7b,0xff,0x7d,0xff,0x7e, 0xfe,0x7e,0xfd,0x7f,0xf9,0x00,0x11,0x80,0x04,0x95, 0x00,0x6b,0x00,0x95,0x0d,0x00,0xf3,0xf6,0x08,0x00, 0xf8,0xf5,0x0d,0x00,0x02,0x80,0x04,0x95,0x00,0x6b, 0x00,0x95,0x0d,0x00,0xf3,0xf6,0x08,0x00,0x06,0xf5, 0x12,0x90,0xff,0x02,0xfe,0x02,0xfe,0x01,0xfc,0x00, 0xfe,0x7f,0xfe,0x7e,0xff,0x7e,0xff,0x7d,0x00,0x7b, 0x01,0x7d,0x01,0x7e,0x02,0x7e,0x02,0x7f,0x04,0x00, 0x02,0x01,0x02,0x02,0x01,0x02,0x00,0x03,0xfb,0x80, 0x05,0x00,0x03,0xf8,0x04,0x95,0x00,0x6b,0x0e,0x95, 0x00,0x6b,0xf2,0x8b,0x0e,0x00,0x04,0xf5,0x04,0x95, 0x00,0x6b,0x04,0x80,0x0c,0x95,0x00,0x70,0xff,0x7d, 0xff,0x7f,0xfe,0x7f,0xfe,0x00,0xfe,0x01,0xff,0x01, 0xff,0x03,0x00,0x02,0x0e,0xf9,0x04,0x95,0x00,0x6b, 0x0e,0x95,0xf2,0x72,0x05,0x85,0x09,0x74,0x03,0x80, 0x04,0x95,0x00,0x6b,0x00,0x80,0x0c,0x00,0x01,0x80, 0x04,0x95,0x00,0x6b,0x00,0x95,0x08,0x6b,0x08,0x95, 0xf8,0x6b,0x08,0x95,0x00,0x6b,0x04,0x80,0x04,0x95, 0x00,0x6b,0x00,0x95,0x0e,0x6b,0x00,0x95,0x00,0x6b, 0x04,0x80,0x09,0x95,0xfe,0x7f,0xfe,0x7e,0xff,0x7e, 0xff,0x7d,0x00,0x7b,0x01,0x7d,0x01,0x7e,0x02,0x7e, 0x02,0x7f,0x04,0x00,0x02,0x01,0x02,0x02,0x01,0x02, 0x01,0x03,0x00,0x05,0xff,0x03,0xff,0x02,0xfe,0x02, 0xfe,0x01,0xfc,0x00,0x0d,0xeb,0x04,0x95,0x00,0x6b, 0x00,0x95,0x09,0x00,0x03,0x7f,0x01,0x7f,0x01,0x7e, 0x00,0x7d,0xff,0x7e,0xff,0x7f,0xfd,0x7f,0xf7,0x00, 0x11,0xf6,0x09,0x95,0xfe,0x7f,0xfe,0x7e,0xff,0x7e, 0xff,0x7d,0x00,0x7b,0x01,0x7d,0x01,0x7e,0x02,0x7e, 0x02,0x7f,0x04,0x00,0x02,0x01,0x02,0x02,0x01,0x02, 0x01,0x03,0x00,0x05,0xff,0x03,0xff,0x02,0xfe,0x02, 0xfe,0x01,0xfc,0x00,0x03,0xef,0x06,0x7a,0x04,0x82, 0x04,0x95,0x00,0x6b,0x00,0x95,0x09,0x00,0x03,0x7f, 0x01,0x7f,0x01,0x7e,0x00,0x7e,0xff,0x7e,0xff,0x7f, 0xfd,0x7f,0xf7,0x00,0x07,0x80,0x07,0x75,0x03,0x80, 0x11,0x92,0xfe,0x02,0xfd,0x01,0xfc,0x00,0xfd,0x7f, 0xfe,0x7e,0x00,0x7e,0x01,0x7e,0x01,0x7f,0x02,0x7f, 0x06,0x7e,0x02,0x7f,0x01,0x7f,0x01,0x7e,0x00,0x7d, 0xfe,0x7e,0xfd,0x7f,0xfc,0x00,0xfd,0x01,0xfe,0x02, 0x11,0xfd,0x08,0x95,0x00,0x6b,0xf9,0x95,0x0e,0x00, 0x01,0xeb,0x04,0x95,0x00,0x71,0x01,0x7d,0x02,0x7e, 0x03,0x7f,0x02,0x00,0x03,0x01,0x02,0x02,0x01,0x03, 0x00,0x0f,0x04,0xeb,0x01,0x95,0x08,0x6b,0x08,0x95, 0xf8,0x6b,0x09,0x80,0x02,0x95,0x05,0x6b,0x05,0x95, 0xfb,0x6b,0x05,0x95,0x05,0x6b,0x05,0x95,0xfb,0x6b, 0x07,0x80,0x03,0x95,0x0e,0x6b,0x00,0x95,0xf2,0x6b, 0x11,0x80,0x01,0x95,0x08,0x76,0x00,0x75,0x08,0x95, 0xf8,0x76,0x09,0xf5,0x11,0x95,0xf2,0x6b,0x00,0x95, 0x0e,0x00,0xf2,0xeb,0x0e,0x00,0x03,0x80,0x03,0x93, 0x00,0x6c,0x01,0x94,0x00,0x6c,0xff,0x94,0x05,0x00, 0xfb,0xec,0x05,0x00,0x02,0x81,0x00,0x95,0x0e,0x68, 0x00,0x83,0x06,0x93,0x00,0x6c,0x01,0x94,0x00,0x6c, 0xfb,0x94,0x05,0x00,0xfb,0xec,0x05,0x00,0x03,0x81, 0x03,0x87,0x08,0x05,0x08,0x7b,0xf0,0x80,0x08,0x04, 0x08,0x7c,0x03,0xf9,0x01,0x80,0x10,0x00,0x01,0x80, 0x06,0x95,0xff,0x7f,0xff,0x7e,0x00,0x7e,0x01,0x7f, 0x01,0x01,0xff,0x01,0x05,0xef,0x0f,0x8e,0x00,0x72, 0x00,0x8b,0xfe,0x02,0xfe,0x01,0xfd,0x00,0xfe,0x7f, 0xfe,0x7e,0xff,0x7d,0x00,0x7e,0x01,0x7d,0x02,0x7e, 0x02,0x7f,0x03,0x00,0x02,0x01,0x02,0x02,0x04,0xfd, 0x04,0x95,0x00,0x6b,0x00,0x8b,0x02,0x02,0x02,0x01, 0x03,0x00,0x02,0x7f,0x02,0x7e,0x01,0x7d,0x00,0x7e, 0xff,0x7d,0xfe,0x7e,0xfe,0x7f,0xfd,0x00,0xfe,0x01, 0xfe,0x02,0x0f,0xfd,0x0f,0x8b,0xfe,0x02,0xfe,0x01, 0xfd,0x00,0xfe,0x7f,0xfe,0x7e,0xff,0x7d,0x00,0x7e, 0x01,0x7d,0x02,0x7e,0x02,0x7f,0x03,0x00,0x02,0x01, 0x02,0x02,0x03,0xfd,0x0f,0x95,0x00,0x6b,0x00,0x8b, 0xfe,0x02,0xfe,0x01,0xfd,0x00,0xfe,0x7f,0xfe,0x7e, 0xff,0x7d,0x00,0x7e,0x01,0x7d,0x02,0x7e,0x02,0x7f, 0x03,0x00,0x02,0x01,0x02,0x02,0x04,0xfd,0x03,0x88, 0x0c,0x00,0x00,0x02,0xff,0x02,0xff,0x01,0xfe,0x01, 0xfd,0x00,0xfe,0x7f,0xfe,0x7e,0xff,0x7d,0x00,0x7e, 0x01,0x7d,0x02,0x7e,0x02,0x7f,0x03,0x00,0x02,0x01, 0x02,0x02,0x03,0xfd,0x0a,0x95,0xfe,0x00,0xfe,0x7f, 0xff,0x7d,0x00,0x6f,0xfd,0x8e,0x07,0x00,0x03,0xf2, 0x0f,0x8e,0x00,0x70,0xff,0x7d,0xff,0x7f,0xfe,0x7f, 0xfd,0x00,0xfe,0x01,0x09,0x91,0xfe,0x02,0xfe,0x01, 0xfd,0x00,0xfe,0x7f,0xfe,0x7e,0xff,0x7d,0x00,0x7e, 0x01,0x7d,0x02,0x7e,0x02,0x7f,0x03,0x00,0x02,0x01, 0x02,0x02,0x04,0xfd,0x04,0x95,0x00,0x6b,0x00,0x8a, 0x03,0x03,0x02,0x01,0x03,0x00,0x02,0x7f,0x01,0x7d, 0x00,0x76,0x04,0x80,0x03,0x95,0x01,0x7f,0x01,0x01, 0xff,0x01,0xff,0x7f,0x01,0xf9,0x00,0x72,0x04,0x80, 0x05,0x95,0x01,0x7f,0x01,0x01,0xff,0x01,0xff,0x7f, 0x01,0xf9,0x00,0x6f,0xff,0x7d,0xfe,0x7f,0xfe,0x00, 0x09,0x87,0x04,0x95,0x00,0x6b,0x0a,0x8e,0xf6,0x76, 0x04,0x84,0x07,0x78,0x02,0x80,0x04,0x95,0x00,0x6b, 0x04,0x80,0x04,0x8e,0x00,0x72,0x00,0x8a,0x03,0x03, 0x02,0x01,0x03,0x00,0x02,0x7f,0x01,0x7d,0x00,0x76, 0x00,0x8a,0x03,0x03,0x02,0x01,0x03,0x00,0x02,0x7f, 0x01,0x7d,0x00,0x76,0x04,0x80,0x04,0x8e,0x00,0x72, 0x00,0x8a,0x03,0x03,0x02,0x01,0x03,0x00,0x02,0x7f, 0x01,0x7d,0x00,0x76,0x04,0x80,0x08,0x8e,0xfe,0x7f, 0xfe,0x7e,0xff,0x7d,0x00,0x7e,0x01,0x7d,0x02,0x7e, 0x02,0x7f,0x03,0x00,0x02,0x01,0x02,0x02,0x01,0x03, 0x00,0x02,0xff,0x03,0xfe,0x02,0xfe,0x01,0xfd,0x00, 0x0b,0xf2,0x04,0x8e,0x00,0x6b,0x00,0x92,0x02,0x02, 0x02,0x01,0x03,0x00,0x02,0x7f,0x02,0x7e,0x01,0x7d, 0x00,0x7e,0xff,0x7d,0xfe,0x7e,0xfe,0x7f,0xfd,0x00, 0xfe,0x01,0xfe,0x02,0x0f,0xfd,0x0f,0x8e,0x00,0x6b, 0x00,0x92,0xfe,0x02,0xfe,0x01,0xfd,0x00,0xfe,0x7f, 0xfe,0x7e,0xff,0x7d,0x00,0x7e,0x01,0x7d,0x02,0x7e, 0x02,0x7f,0x03,0x00,0x02,0x01,0x02,0x02,0x04,0xfd, 0x04,0x8e,0x00,0x72,0x00,0x88,0x01,0x03,0x02,0x02, 0x02,0x01,0x03,0x00,0x01,0xf2,0x0e,0x8b,0xff,0x02, 0xfd,0x01,0xfd,0x00,0xfd,0x7f,0xff,0x7e,0x01,0x7e, 0x02,0x7f,0x05,0x7f,0x02,0x7f,0x01,0x7e,0x00,0x7f, 0xff,0x7e,0xfd,0x7f,0xfd,0x00,0xfd,0x01,0xff,0x02, 0x0e,0xfd,0x05,0x95,0x00,0x6f,0x01,0x7d,0x02,0x7f, 0x02,0x00,0xf8,0x8e,0x07,0x00,0x03,0xf2,0x04,0x8e, 0x00,0x76,0x01,0x7d,0x02,0x7f,0x03,0x00,0x02,0x01, 0x03,0x03,0x00,0x8a,0x00,0x72,0x04,0x80,0x02,0x8e, 0x06,0x72,0x06,0x8e,0xfa,0x72,0x08,0x80,0x03,0x8e, 0x04,0x72,0x04,0x8e,0xfc,0x72,0x04,0x8e,0x04,0x72, 0x04,0x8e,0xfc,0x72,0x07,0x80,0x03,0x8e,0x0b,0x72, 0x00,0x8e,0xf5,0x72,0x0e,0x80,0x02,0x8e,0x06,0x72, 0x06,0x8e,0xfa,0x72,0xfe,0x7c,0xfe,0x7e,0xfe,0x7f, 0xff,0x00,0x0f,0x87,0x0e,0x8e,0xf5,0x72,0x00,0x8e, 0x0b,0x00,0xf5,0xf2,0x0b,0x00,0x03,0x80,0x09,0x99, 0xfe,0x7f,0xff,0x7f,0xff,0x7e,0x00,0x7e,0x01,0x7e, 0x01,0x7f,0x01,0x7e,0x00,0x7e,0xfe,0x7e,0x01,0x8e, 0xff,0x7e,0x00,0x7e,0x01,0x7e,0x01,0x7f,0x01,0x7e, 0x00,0x7e,0xff,0x7e,0xfc,0x7e,0x04,0x7e,0x01,0x7e, 0x00,0x7e,0xff,0x7e,0xff,0x7f,0xff,0x7e,0x00,0x7e, 0x01,0x7e,0xff,0x8e,0x02,0x7e,0x00,0x7e,0xff,0x7e, 0xff,0x7f,0xff,0x7e,0x00,0x7e,0x01,0x7e,0x01,0x7f, 0x02,0x7f,0x05,0x87,0x04,0x95,0x00,0x77,0x00,0xfd, 0x00,0x77,0x04,0x80,0x05,0x99,0x02,0x7f,0x01,0x7f, 0x01,0x7e,0x00,0x7e,0xff,0x7e,0xff,0x7f,0xff,0x7e, 0x00,0x7e,0x02,0x7e,0xff,0x8e,0x01,0x7e,0x00,0x7e, 0xff,0x7e,0xff,0x7f,0xff,0x7e,0x00,0x7e,0x01,0x7e, 0x04,0x7e,0xfc,0x7e,0xff,0x7e,0x00,0x7e,0x01,0x7e, 0x01,0x7f,0x01,0x7e,0x00,0x7e,0xff,0x7e,0x01,0x8e, 0xfe,0x7e,0x00,0x7e,0x01,0x7e,0x01,0x7f,0x01,0x7e, 0x00,0x7e,0xff,0x7e,0xff,0x7f,0xfe,0x7f,0x09,0x87, 0x03,0x86,0x00,0x02,0x01,0x03,0x02,0x01,0x02,0x00, 0x02,0x7f,0x04,0x7d,0x02,0x7f,0x02,0x00,0x02,0x01, 0x01,0x02,0xee,0xfe,0x01,0x02,0x02,0x01,0x02,0x00, 0x02,0x7f,0x04,0x7d,0x02,0x7f,0x02,0x00,0x02,0x01, 0x01,0x03,0x00,0x02,0x03,0xf4,0x10,0x80,0x03,0x80, 0x07,0x15,0x08,0x6b,0xfe,0x85,0xf5,0x00,0x10,0xfb, 0x0d,0x95,0xf6,0x00,0x00,0x6b,0x0a,0x00,0x02,0x02, 0x00,0x08,0xfe,0x02,0xf6,0x00,0x0e,0xf4,0x03,0x80, 0x00,0x15,0x0a,0x00,0x02,0x7e,0x00,0x7e,0x00,0x7d, 0x00,0x7e,0xfe,0x7f,0xf6,0x00,0x0a,0x80,0x02,0x7e, 0x01,0x7e,0x00,0x7d,0xff,0x7d,0xfe,0x7f,0xf6,0x00, 0x10,0x80,0x03,0x80,0x00,0x15,0x0c,0x00,0xff,0x7e, 0x03,0xed,0x03,0xfd,0x00,0x03,0x02,0x00,0x00,0x12, 0x02,0x03,0x0a,0x00,0x00,0x6b,0x02,0x00,0x00,0x7d, 0xfe,0x83,0xf4,0x00,0x11,0x80,0x0f,0x80,0xf4,0x00, 0x00,0x15,0x0c,0x00,0xff,0xf6,0xf5,0x00,0x0f,0xf5, 0x04,0x95,0x07,0x76,0x00,0x0a,0x07,0x80,0xf9,0x76, 0x00,0x75,0xf8,0x80,0x07,0x0c,0x09,0xf4,0xf9,0x0c, 0x09,0xf4,0x03,0x92,0x02,0x03,0x07,0x00,0x03,0x7d, 0x00,0x7b,0xfc,0x7e,0x04,0x7d,0x00,0x7a,0xfd,0x7e, 0xf9,0x00,0xfe,0x02,0x06,0x89,0x02,0x00,0x06,0xf5, 0x03,0x95,0x00,0x6b,0x0c,0x15,0x00,0x6b,0x02,0x80, 0x03,0x95,0x00,0x6b,0x0c,0x15,0x00,0x6b,0xf8,0x96, 0x03,0x00,0x07,0xea,0x03,0x80,0x00,0x15,0x0c,0x80, 0xf7,0x76,0xfd,0x00,0x03,0x80,0x0a,0x75,0x03,0x80, 0x03,0x80,0x07,0x13,0x02,0x02,0x03,0x00,0x00,0x6b, 0x02,0x80,0x03,0x80,0x00,0x15,0x09,0x6b,0x09,0x15, 0x00,0x6b,0x03,0x80,0x03,0x80,0x00,0x15,0x00,0xf6, 0x0d,0x00,0x00,0x8a,0x00,0x6b,0x03,0x80,0x07,0x80, 0xfd,0x00,0xff,0x03,0x00,0x04,0x00,0x07,0x00,0x04, 0x01,0x02,0x03,0x01,0x06,0x00,0x03,0x7f,0x01,0x7e, 0x01,0x7c,0x00,0x79,0xff,0x7c,0xff,0x7d,0xfd,0x00, 0xfa,0x00,0x0e,0x80,0x03,0x80,0x00,0x15,0x0c,0x00, 0x00,0x6b,0x02,0x80,0x03,0x80,0x00,0x15,0x0a,0x00, 0x02,0x7f,0x01,0x7d,0x00,0x7b,0xff,0x7e,0xfe,0x7f, 0xf6,0x00,0x10,0xf7,0x11,0x8f,0xff,0x03,0xff,0x02, 0xfe,0x01,0xfa,0x00,0xfd,0x7f,0xff,0x7e,0x00,0x7c, 0x00,0x79,0x00,0x7b,0x01,0x7e,0x03,0x00,0x06,0x00, 0x02,0x00,0x01,0x03,0x01,0x02,0x03,0xfb,0x03,0x95, 0x0c,0x00,0xfa,0x80,0x00,0x6b,0x09,0x80,0x03,0x95, 0x00,0x77,0x06,0x7a,0x06,0x06,0x00,0x09,0xfa,0xf1, 0xfa,0x7a,0x0e,0x80,0x03,0x87,0x00,0x0b,0x02,0x02, 0x03,0x00,0x02,0x7e,0x01,0x02,0x04,0x00,0x02,0x7e, 0x00,0x75,0xfe,0x7e,0xfc,0x00,0xff,0x01,0xfe,0x7f, 0xfd,0x00,0xfe,0x02,0x07,0x8e,0x00,0x6b,0x09,0x80, 0x03,0x80,0x0e,0x15,0xf2,0x80,0x0e,0x6b,0x03,0x80, 0x03,0x95,0x00,0x6b,0x0e,0x00,0x00,0x7d,0xfe,0x98, 0x00,0x6b,0x05,0x80,0x03,0x95,0x00,0x75,0x02,0x7d, 0x0a,0x00,0x00,0x8e,0x00,0x6b,0x02,0x80,0x03,0x95, 0x00,0x6b,0x10,0x00,0x00,0x15,0xf8,0x80,0x00,0x6b, 0x0a,0x80,0x03,0x95,0x00,0x6b,0x10,0x00,0x00,0x15, 0xf8,0x80,0x00,0x6b,0x0a,0x00,0x00,0x7d,0x02,0x83, 0x10,0x80,0x03,0x95,0x00,0x6b,0x09,0x00,0x03,0x02, 0x00,0x08,0xfd,0x02,0xf7,0x00,0x0e,0x89,0x00,0x6b, 0x03,0x80,0x03,0x95,0x00,0x6b,0x09,0x00,0x03,0x02, 0x00,0x08,0xfd,0x02,0xf7,0x00,0x0e,0xf4,0x03,0x92, 0x02,0x03,0x07,0x00,0x03,0x7d,0x00,0x70,0xfd,0x7e, 0xf9,0x00,0xfe,0x02,0x03,0x89,0x09,0x00,0x02,0xf5, 0x03,0x80,0x00,0x15,0x00,0xf5,0x07,0x00,0x00,0x08, 0x02,0x03,0x06,0x00,0x02,0x7d,0x00,0x70,0xfe,0x7e, 0xfa,0x00,0xfe,0x02,0x00,0x08,0x0c,0xf6,0x0f,0x80, 0x00,0x15,0xf6,0x00,0xfe,0x7d,0x00,0x79,0x02,0x7e, 0x0a,0x00,0xf4,0xf7,0x07,0x09,0x07,0xf7,0x03,0x8c, 0x01,0x02,0x01,0x01,0x05,0x00,0x02,0x7f,0x01,0x7e, 0x00,0x74,0x00,0x86,0xff,0x01,0xfe,0x01,0xfb,0x00, 0xff,0x7f,0xff,0x7f,0x00,0x7c,0x01,0x7e,0x01,0x00, 0x05,0x00,0x02,0x00,0x01,0x02,0x03,0xfe,0x04,0x8e, 0x02,0x01,0x04,0x00,0x02,0x7f,0x01,0x7e,0x00,0x77, 0xff,0x7e,0xfe,0x7f,0xfc,0x00,0xfe,0x01,0xff,0x02, 0x00,0x09,0x01,0x02,0x02,0x02,0x03,0x01,0x02,0x01, 0x01,0x01,0x01,0x02,0x02,0xeb,0x03,0x80,0x00,0x15, 0x03,0x00,0x02,0x7e,0x00,0x7b,0xfe,0x7e,0xfd,0x00, 0x03,0x80,0x04,0x00,0x03,0x7e,0x00,0x78,0xfd,0x7e, 0xf9,0x00,0x0c,0x80,0x03,0x8c,0x02,0x02,0x02,0x01, 0x03,0x00,0x02,0x7f,0x01,0x7d,0xfe,0x7e,0xf9,0x7d, 0xff,0x7e,0x00,0x7d,0x03,0x7f,0x02,0x00,0x03,0x01, 0x02,0x01,0x02,0xfe,0x0d,0x8c,0xff,0x02,0xfe,0x01, 0xfc,0x00,0xfe,0x7f,0xff,0x7e,0x00,0x77,0x01,0x7e, 0x02,0x7f,0x04,0x00,0x02,0x01,0x01,0x02,0x00,0x0f, 0xff,0x02,0xfe,0x01,0xf9,0x00,0x0c,0xeb,0x03,0x88, 0x0a,0x00,0x00,0x02,0x00,0x03,0xfe,0x02,0xfa,0x00, 0xff,0x7e,0xff,0x7d,0x00,0x7b,0x01,0x7c,0x01,0x7f, 0x06,0x00,0x02,0x02,0x03,0xfe,0x03,0x8f,0x06,0x77, 0x06,0x09,0xfa,0x80,0x00,0x71,0xff,0x87,0xfb,0x79, 0x07,0x87,0x05,0x79,0x02,0x80,0x03,0x8d,0x02,0x02, 0x06,0x00,0x02,0x7e,0x00,0x7d,0xfc,0x7d,0x04,0x7e, 0x00,0x7d,0xfe,0x7e,0xfa,0x00,0xfe,0x02,0x04,0x85, 0x02,0x00,0x06,0xf9,0x03,0x8f,0x00,0x73,0x01,0x7e, 0x07,0x00,0x02,0x02,0x00,0x0d,0x00,0xf3,0x01,0x7e, 0x03,0x80,0x03,0x8f,0x00,0x73,0x01,0x7e,0x07,0x00, 0x02,0x02,0x00,0x0d,0x00,0xf3,0x01,0x7e,0xf8,0x90, 0x03,0x00,0x08,0xf0,0x03,0x80,0x00,0x15,0x00,0xf3, 0x02,0x00,0x06,0x07,0xfa,0xf9,0x07,0x78,0x03,0x80, 0x03,0x80,0x04,0x0c,0x02,0x03,0x04,0x00,0x00,0x71, 0x02,0x80,0x03,0x80,0x00,0x0f,0x06,0x77,0x06,0x09, 0x00,0x71,0x02,0x80,0x03,0x80,0x00,0x0f,0x0a,0xf1, 0x00,0x0f,0xf6,0xf8,0x0a,0x00,0x02,0xf9,0x05,0x80, 0xff,0x01,0xff,0x04,0x00,0x05,0x01,0x03,0x01,0x02, 0x06,0x00,0x02,0x7e,0x00,0x7d,0x00,0x7b,0x00,0x7c, 0xfe,0x7f,0xfa,0x00,0x0b,0x80,0x03,0x80,0x00,0x0f, 0x00,0xfb,0x01,0x03,0x01,0x02,0x05,0x00,0x02,0x7e, 0x01,0x7d,0x00,0x76,0x03,0x80,0x10,0x80,0x10,0x80, 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80, 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80, 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80, 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80, 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80, 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80, 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80, 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80, 0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80, 0x10,0x80,0x0a,0x8f,0x02,0x7f,0x01,0x7e,0x00,0x76, 0xff,0x7f,0xfe,0x7f,0xfb,0x00,0xff,0x01,0xff,0x01, 0x00,0x0a,0x01,0x02,0x01,0x01,0x05,0x00,0xf9,0x80, 0x00,0x6b,0x0c,0x86,0x0d,0x8a,0xff,0x03,0xfe,0x02, 0xfb,0x00,0xff,0x7e,0xff,0x7d,0x00,0x7b,0x01,0x7c, 0x01,0x7f,0x05,0x00,0x02,0x01,0x01,0x03,0x03,0xfc, 0x03,0x80,0x00,0x0f,0x00,0xfb,0x01,0x03,0x01,0x02, 0x04,0x00,0x01,0x7e,0x01,0x7d,0x00,0x76,0x00,0x8a, 0x01,0x03,0x02,0x02,0x03,0x00,0x02,0x7e,0x01,0x7d, 0x00,0x76,0x03,0x80,0x03,0x8f,0x00,0x74,0x01,0x7e, 0x02,0x7f,0x04,0x00,0x02,0x01,0x01,0x01,0x00,0x8d, 0x00,0x6e,0xff,0x7e,0xfe,0x7f,0xfb,0x00,0xfe,0x01, 0x0c,0x85,0x03,0x8d,0x01,0x02,0x03,0x00,0x02,0x7e, 0x01,0x02,0x03,0x00,0x02,0x7e,0x00,0x74,0xfe,0x7f, 0xfd,0x00,0xff,0x01,0xfe,0x7f,0xfd,0x00,0xff,0x01, 0x00,0x0c,0x06,0x82,0x00,0x6b,0x08,0x86,0x03,0x80, 0x0a,0x0f,0xf6,0x80,0x0a,0x71,0x03,0x80,0x03,0x8f, 0x00,0x73,0x01,0x7e,0x07,0x00,0x02,0x02,0x00,0x0d, 0x00,0xf3,0x01,0x7e,0x00,0x7e,0x03,0x82,0x03,0x8f, 0x00,0x79,0x02,0x7e,0x08,0x00,0x00,0x89,0x00,0x71, 0x02,0x80,0x03,0x8f,0x00,0x73,0x01,0x7e,0x03,0x00, 0x02,0x02,0x00,0x0d,0x00,0xf3,0x01,0x7e,0x03,0x00, 0x02,0x02,0x00,0x0d,0x00,0xf3,0x01,0x7e,0x03,0x80, 0x03,0x8f,0x00,0x73,0x01,0x7e,0x03,0x00,0x02,0x02, 0x00,0x0d,0x00,0xf3,0x01,0x7e,0x03,0x00,0x02,0x02, 0x00,0x0d,0x00,0xf3,0x01,0x7e,0x00,0x7e,0x03,0x82, 0x03,0x8d,0x00,0x02,0x02,0x00,0x00,0x71,0x08,0x00, 0x02,0x02,0x00,0x06,0xfe,0x02,0xf8,0x00,0x0c,0xf6, 0x03,0x8f,0x00,0x71,0x07,0x00,0x02,0x02,0x00,0x06, 0xfe,0x02,0xf9,0x00,0x0c,0x85,0x00,0x71,0x02,0x80, 0x03,0x8f,0x00,0x71,0x07,0x00,0x03,0x02,0x00,0x06, 0xfd,0x02,0xf9,0x00,0x0c,0xf6,0x03,0x8d,0x02,0x02, 0x06,0x00,0x02,0x7e,0x00,0x75,0xfe,0x7e,0xfa,0x00, 0xfe,0x02,0x04,0x85,0x06,0x00,0x02,0xf9,0x03,0x80, 0x00,0x0f,0x00,0xf8,0x04,0x00,0x00,0x06,0x02,0x02, 0x04,0x00,0x02,0x7e,0x00,0x75,0xfe,0x7e,0xfc,0x00, 0xfe,0x02,0x00,0x05,0x0a,0xf9,0x0d,0x80,0x00,0x0f, 0xf7,0x00,0xff,0x7e,0x00,0x7b,0x01,0x7e,0x09,0x00, 0xf6,0xfa,0x04,0x06,0x08,0xfa }; //------------------------------------------------------------------------- gsv_text::gsv_text() : m_x(0.0), m_y(0.0), m_start_x(0.0), m_width(10.0), m_height(0.0), m_space(0.0), m_line_space(0.0), m_text(m_chr), m_text_buf(), m_cur_chr(m_chr), m_font(gsv_default_font), m_loaded_font(), m_status(initial), m_big_endian(false), m_flip(false) { m_chr[0] = m_chr[1] = 0; int t = 1; if(*(char*)&t == 0) m_big_endian = true; } //------------------------------------------------------------------------- void gsv_text::font(const void* font) { m_font = font; if(m_font == 0) m_font = &m_loaded_font[0]; } //------------------------------------------------------------------------- void gsv_text::size(double height, double width) { m_height = height; m_width = width; } //------------------------------------------------------------------------- void gsv_text::space(double space) { m_space = space; } //------------------------------------------------------------------------- void gsv_text::line_space(double line_space) { m_line_space = line_space; } //------------------------------------------------------------------------- void gsv_text::start_point(double x, double y) { m_x = m_start_x = x; m_y = y; //if(m_flip) m_y += m_height; } //------------------------------------------------------------------------- void gsv_text::load_font(const char* file) { m_loaded_font.resize(0); FILE* fd = fopen(file, "rb"); if(fd) { unsigned len; fseek(fd, 0l, SEEK_END); len = ftell(fd); fseek(fd, 0l, SEEK_SET); if(len > 0) { m_loaded_font.resize(len); fread(&m_loaded_font[0], 1, len, fd); m_font = &m_loaded_font[0]; } fclose(fd); } } //------------------------------------------------------------------------- void gsv_text::text(const char* text) { if(text == 0) { m_chr[0] = 0; m_text = m_chr; return; } unsigned new_size = strlen(text) + 1; if(new_size > m_text_buf.size()) { m_text_buf.resize(new_size); } memcpy(&m_text_buf[0], text, new_size); m_text = &m_text_buf[0]; } //------------------------------------------------------------------------- void gsv_text::rewind(unsigned) { m_status = initial; if(m_font == 0) return; m_indices = (int8u*)m_font; double base_height = value(m_indices + 4); m_indices += value(m_indices); m_glyphs = (int8*)(m_indices + 257*2); m_h = m_height / base_height; m_w = (m_width == 0.0) ? m_h : m_width / base_height; if(m_flip) m_h = -m_h; m_cur_chr = m_text; } //------------------------------------------------------------------------- unsigned gsv_text::vertex(double* x, double* y) { unsigned idx; int8 yc, yf; int dx, dy; bool quit = false; while(!quit) { switch(m_status) { case initial: if(m_font == 0) { quit = true; break; } m_status = next_char; case next_char: if(*m_cur_chr == 0) { quit = true; break; } idx = (*m_cur_chr++) & 0xFF; if(idx == '\n') { m_x = m_start_x; m_y -= m_flip ? -m_height - m_line_space : m_height + m_line_space; break; } idx <<= 1; m_bglyph = m_glyphs + value(m_indices + idx); m_eglyph = m_glyphs + value(m_indices + idx + 2); m_status = start_glyph; case start_glyph: *x = m_x; *y = m_y; m_status = glyph; return path_cmd_move_to; case glyph: if(m_bglyph >= m_eglyph) { m_status = next_char; m_x += m_space; break; } dx = int(*m_bglyph++); yf = (yc = *m_bglyph++) & 0x80; yc <<= 1; yc >>= 1; dy = int(yc); m_x += double(dx) * m_w; m_y += double(dy) * m_h; *x = m_x; *y = m_y; return yf ? path_cmd_move_to : path_cmd_line_to; } } return path_cmd_stop; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_trans_double_path.cpp0000644000175000017500000002032612516137326025162 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #include "agg_math.h" #include "agg_trans_double_path.h" namespace agg24 { //------------------------------------------------------------------------ trans_double_path::trans_double_path() : m_kindex1(0.0), m_kindex2(0.0), m_base_length(0.0), m_base_height(1.0), m_status1(initial), m_status2(initial), m_preserve_x_scale(true) { } //------------------------------------------------------------------------ void trans_double_path::reset() { m_src_vertices1.remove_all(); m_src_vertices2.remove_all(); m_kindex1 = 0.0; m_kindex1 = 0.0; m_status1 = initial; m_status2 = initial; } //------------------------------------------------------------------------ void trans_double_path::move_to1(double x, double y) { if(m_status1 == initial) { m_src_vertices1.modify_last(vertex_dist(x, y)); m_status1 = making_path; } else { line_to1(x, y); } } //------------------------------------------------------------------------ void trans_double_path::line_to1(double x, double y) { if(m_status1 == making_path) { m_src_vertices1.add(vertex_dist(x, y)); } } //------------------------------------------------------------------------ void trans_double_path::move_to2(double x, double y) { if(m_status2 == initial) { m_src_vertices2.modify_last(vertex_dist(x, y)); m_status2 = making_path; } else { line_to2(x, y); } } //------------------------------------------------------------------------ void trans_double_path::line_to2(double x, double y) { if(m_status2 == making_path) { m_src_vertices2.add(vertex_dist(x, y)); } } //------------------------------------------------------------------------ double trans_double_path::finalize_path(vertex_storage& vertices) { unsigned i; double dist; double d; vertices.close(false); if(vertices.size() > 2) { if(vertices[vertices.size() - 2].dist * 10.0 < vertices[vertices.size() - 3].dist) { d = vertices[vertices.size() - 3].dist + vertices[vertices.size() - 2].dist; vertices[vertices.size() - 2] = vertices[vertices.size() - 1]; vertices.remove_last(); vertices[vertices.size() - 2].dist = d; } } dist = 0; for(i = 0; i < vertices.size(); i++) { vertex_dist& v = vertices[i]; d = v.dist; v.dist = dist; dist += d; } return (vertices.size() - 1) / dist; } //------------------------------------------------------------------------ void trans_double_path::finalize_paths() { if(m_status1 == making_path && m_src_vertices1.size() > 1 && m_status2 == making_path && m_src_vertices2.size() > 1) { m_kindex1 = finalize_path(m_src_vertices1); m_kindex2 = finalize_path(m_src_vertices2); m_status1 = ready; m_status2 = ready; } } //------------------------------------------------------------------------ double trans_double_path::total_length1() const { if(m_base_length >= 1e-10) return m_base_length; return (m_status1 == ready) ? m_src_vertices1[m_src_vertices1.size() - 1].dist : 0.0; } //------------------------------------------------------------------------ double trans_double_path::total_length2() const { if(m_base_length >= 1e-10) return m_base_length; return (m_status2 == ready) ? m_src_vertices2[m_src_vertices2.size() - 1].dist : 0.0; } //------------------------------------------------------------------------ void trans_double_path::transform1(const vertex_storage& vertices, double kindex, double kx, double *x, double* y) const { double x1 = 0.0; double y1 = 0.0; double dx = 1.0; double dy = 1.0; double d = 0.0; double dd = 1.0; *x *= kx; if(*x < 0.0) { // Extrapolation on the left //-------------------------- x1 = vertices[0].x; y1 = vertices[0].y; dx = vertices[1].x - x1; dy = vertices[1].y - y1; dd = vertices[1].dist - vertices[0].dist; d = *x; } else if(*x > vertices[vertices.size() - 1].dist) { // Extrapolation on the right //-------------------------- unsigned i = vertices.size() - 2; unsigned j = vertices.size() - 1; x1 = vertices[j].x; y1 = vertices[j].y; dx = x1 - vertices[i].x; dy = y1 - vertices[i].y; dd = vertices[j].dist - vertices[i].dist; d = *x - vertices[j].dist; } else { // Interpolation //-------------------------- unsigned i = 0; unsigned j = vertices.size() - 1; if(m_preserve_x_scale) { unsigned k; for(i = 0; (j - i) > 1; ) { if(*x < vertices[k = (i + j) >> 1].dist) { j = k; } else { i = k; } } d = vertices[i].dist; dd = vertices[j].dist - d; d = *x - d; } else { i = unsigned(*x * kindex); j = i + 1; dd = vertices[j].dist - vertices[i].dist; d = ((*x * kindex) - i) * dd; } x1 = vertices[i].x; y1 = vertices[i].y; dx = vertices[j].x - x1; dy = vertices[j].y - y1; } *x = x1 + dx * d / dd; *y = y1 + dy * d / dd; } //------------------------------------------------------------------------ void trans_double_path::transform(double *x, double *y) const { if(m_status1 == ready && m_status2 == ready) { if(m_base_length > 1e-10) { *x *= m_src_vertices1[m_src_vertices1.size() - 1].dist / m_base_length; } double x1 = *x; double y1 = *y; double x2 = *x; double y2 = *y; double dd = m_src_vertices2[m_src_vertices2.size() - 1].dist / m_src_vertices1[m_src_vertices1.size() - 1].dist; transform1(m_src_vertices1, m_kindex1, 1.0, &x1, &y1); transform1(m_src_vertices2, m_kindex2, dd, &x2, &y2); *x = x1 + *y * (x2 - x1) / m_base_height; *y = y1 + *y * (y2 - y1) / m_base_height; } } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_vcgen_stroke.cpp0000644000175000017500000001601012516137326024151 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Stroke generator // //---------------------------------------------------------------------------- #include #include "agg_vcgen_stroke.h" #include "agg_shorten_path.h" namespace agg24 { //------------------------------------------------------------------------ vcgen_stroke::vcgen_stroke() : m_stroker(), m_src_vertices(), m_out_vertices(), m_shorten(0.0), m_closed(0), m_status(initial), m_src_vertex(0), m_out_vertex(0) { } //------------------------------------------------------------------------ void vcgen_stroke::remove_all() { m_src_vertices.remove_all(); m_closed = 0; m_status = initial; } //------------------------------------------------------------------------ void vcgen_stroke::add_vertex(double x, double y, unsigned cmd) { m_status = initial; if(is_move_to(cmd)) { m_src_vertices.modify_last(vertex_dist(x, y)); } else { if(is_vertex(cmd)) { m_src_vertices.add(vertex_dist(x, y)); } else { m_closed = get_close_flag(cmd); } } } //------------------------------------------------------------------------ void vcgen_stroke::rewind(unsigned) { if(m_status == initial) { m_src_vertices.close(m_closed != 0); shorten_path(m_src_vertices, m_shorten, m_closed); if(m_src_vertices.size() < 3) m_closed = 0; } m_status = ready; m_src_vertex = 0; m_out_vertex = 0; } //------------------------------------------------------------------------ unsigned vcgen_stroke::vertex(double* x, double* y) { unsigned cmd = path_cmd_line_to; while(!is_stop(cmd)) { switch(m_status) { case initial: rewind(0); case ready: if(m_src_vertices.size() < 2 + unsigned(m_closed != 0)) { cmd = path_cmd_stop; break; } m_status = m_closed ? outline1 : cap1; cmd = path_cmd_move_to; m_src_vertex = 0; m_out_vertex = 0; break; case cap1: m_stroker.calc_cap(m_out_vertices, m_src_vertices[0], m_src_vertices[1], m_src_vertices[0].dist); m_src_vertex = 1; m_prev_status = outline1; m_status = out_vertices; m_out_vertex = 0; break; case cap2: m_stroker.calc_cap(m_out_vertices, m_src_vertices[m_src_vertices.size() - 1], m_src_vertices[m_src_vertices.size() - 2], m_src_vertices[m_src_vertices.size() - 2].dist); m_prev_status = outline2; m_status = out_vertices; m_out_vertex = 0; break; case outline1: if(m_closed) { if(m_src_vertex >= m_src_vertices.size()) { m_prev_status = close_first; m_status = end_poly1; break; } } else { if(m_src_vertex >= m_src_vertices.size() - 1) { m_status = cap2; break; } } m_stroker.calc_join(m_out_vertices, m_src_vertices.prev(m_src_vertex), m_src_vertices.curr(m_src_vertex), m_src_vertices.next(m_src_vertex), m_src_vertices.prev(m_src_vertex).dist, m_src_vertices.curr(m_src_vertex).dist); ++m_src_vertex; m_prev_status = m_status; m_status = out_vertices; m_out_vertex = 0; break; case close_first: m_status = outline2; cmd = path_cmd_move_to; case outline2: if(m_src_vertex <= unsigned(m_closed == 0)) { m_status = end_poly2; m_prev_status = stop; break; } --m_src_vertex; m_stroker.calc_join(m_out_vertices, m_src_vertices.next(m_src_vertex), m_src_vertices.curr(m_src_vertex), m_src_vertices.prev(m_src_vertex), m_src_vertices.curr(m_src_vertex).dist, m_src_vertices.prev(m_src_vertex).dist); m_prev_status = m_status; m_status = out_vertices; m_out_vertex = 0; break; case out_vertices: if(m_out_vertex >= m_out_vertices.size()) { m_status = m_prev_status; } else { const point_d& c = m_out_vertices[m_out_vertex++]; *x = c.x; *y = c.y; return cmd; } break; case end_poly1: m_status = m_prev_status; return path_cmd_end_poly | path_flags_close | path_flags_ccw; case end_poly2: m_status = m_prev_status; return path_cmd_end_poly | path_flags_close | path_flags_cw; case stop: cmd = path_cmd_stop; break; } } return cmd; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_vcgen_smooth_poly1.cpp0000644000175000017500000001610312516137326025302 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Smooth polygon generator // //---------------------------------------------------------------------------- #include "agg_vcgen_smooth_poly1.h" namespace agg24 { //------------------------------------------------------------------------ vcgen_smooth_poly1::vcgen_smooth_poly1() : m_src_vertices(), m_smooth_value(0.5), m_closed(0), m_status(initial), m_src_vertex(0) { } //------------------------------------------------------------------------ void vcgen_smooth_poly1::remove_all() { m_src_vertices.remove_all(); m_closed = 0; m_status = initial; } //------------------------------------------------------------------------ void vcgen_smooth_poly1::add_vertex(double x, double y, unsigned cmd) { m_status = initial; if(is_move_to(cmd)) { m_src_vertices.modify_last(vertex_dist(x, y)); } else { if(is_vertex(cmd)) { m_src_vertices.add(vertex_dist(x, y)); } else { m_closed = get_close_flag(cmd); } } } //------------------------------------------------------------------------ void vcgen_smooth_poly1::rewind(unsigned) { if(m_status == initial) { m_src_vertices.close(m_closed != 0); } m_status = ready; m_src_vertex = 0; } //------------------------------------------------------------------------ void vcgen_smooth_poly1::calculate(const vertex_dist& v0, const vertex_dist& v1, const vertex_dist& v2, const vertex_dist& v3) { double k1 = v0.dist / (v0.dist + v1.dist); double k2 = v1.dist / (v1.dist + v2.dist); double xm1 = v0.x + (v2.x - v0.x) * k1; double ym1 = v0.y + (v2.y - v0.y) * k1; double xm2 = v1.x + (v3.x - v1.x) * k2; double ym2 = v1.y + (v3.y - v1.y) * k2; m_ctrl1_x = v1.x + m_smooth_value * (v2.x - xm1); m_ctrl1_y = v1.y + m_smooth_value * (v2.y - ym1); m_ctrl2_x = v2.x + m_smooth_value * (v1.x - xm2); m_ctrl2_y = v2.y + m_smooth_value * (v1.y - ym2); } //------------------------------------------------------------------------ unsigned vcgen_smooth_poly1::vertex(double* x, double* y) { unsigned cmd = path_cmd_line_to; while(!is_stop(cmd)) { switch(m_status) { case initial: rewind(0); case ready: if(m_src_vertices.size() < 2) { cmd = path_cmd_stop; break; } if(m_src_vertices.size() == 2) { *x = m_src_vertices[m_src_vertex].x; *y = m_src_vertices[m_src_vertex].y; m_src_vertex++; if(m_src_vertex == 1) return path_cmd_move_to; if(m_src_vertex == 2) return path_cmd_line_to; cmd = path_cmd_stop; break; } cmd = path_cmd_move_to; m_status = polygon; m_src_vertex = 0; case polygon: if(m_closed) { if(m_src_vertex >= m_src_vertices.size()) { *x = m_src_vertices[0].x; *y = m_src_vertices[0].y; m_status = end_poly; return path_cmd_curve4; } } else { if(m_src_vertex >= m_src_vertices.size() - 1) { *x = m_src_vertices[m_src_vertices.size() - 1].x; *y = m_src_vertices[m_src_vertices.size() - 1].y; m_status = end_poly; return path_cmd_curve3; } } calculate(m_src_vertices.prev(m_src_vertex), m_src_vertices.curr(m_src_vertex), m_src_vertices.next(m_src_vertex), m_src_vertices.next(m_src_vertex + 1)); *x = m_src_vertices[m_src_vertex].x; *y = m_src_vertices[m_src_vertex].y; m_src_vertex++; if(m_closed) { m_status = ctrl1; return ((m_src_vertex == 1) ? path_cmd_move_to : path_cmd_curve4); } else { if(m_src_vertex == 1) { m_status = ctrl_b; return path_cmd_move_to; } if(m_src_vertex >= m_src_vertices.size() - 1) { m_status = ctrl_e; return path_cmd_curve3; } m_status = ctrl1; return path_cmd_curve4; } break; case ctrl_b: *x = m_ctrl2_x; *y = m_ctrl2_y; m_status = polygon; return path_cmd_curve3; case ctrl_e: *x = m_ctrl1_x; *y = m_ctrl1_y; m_status = polygon; return path_cmd_curve3; case ctrl1: *x = m_ctrl1_x; *y = m_ctrl1_y; m_status = ctrl2; return path_cmd_curve4; case ctrl2: *x = m_ctrl2_x; *y = m_ctrl2_y; m_status = polygon; return path_cmd_curve4; case end_poly: m_status = stop; return path_cmd_end_poly | m_closed; case stop: return path_cmd_stop; } } return cmd; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_vcgen_contour.cpp0000644000175000017500000001224712516137326024343 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- // // Contour generator // //---------------------------------------------------------------------------- #include #include "agg_vcgen_contour.h" namespace agg24 { //------------------------------------------------------------------------ vcgen_contour::vcgen_contour() : m_stroker(), m_width(1), m_src_vertices(), m_out_vertices(), m_status(initial), m_src_vertex(0), m_closed(0), m_orientation(0), m_auto_detect(false) { } //------------------------------------------------------------------------ void vcgen_contour::remove_all() { m_src_vertices.remove_all(); m_closed = 0; m_orientation = 0; m_status = initial; } //------------------------------------------------------------------------ void vcgen_contour::add_vertex(double x, double y, unsigned cmd) { m_status = initial; if(is_move_to(cmd)) { m_src_vertices.modify_last(vertex_dist(x, y)); } else { if(is_vertex(cmd)) { m_src_vertices.add(vertex_dist(x, y)); } else { if(is_end_poly(cmd)) { m_closed = get_close_flag(cmd); if(m_orientation == path_flags_none) { m_orientation = get_orientation(cmd); } } } } } //------------------------------------------------------------------------ void vcgen_contour::rewind(unsigned) { if(m_status == initial) { m_src_vertices.close(true); if(m_auto_detect) { if(!is_oriented(m_orientation)) { m_orientation = (calc_polygon_area(m_src_vertices) > 0.0) ? path_flags_ccw : path_flags_cw; } } if(is_oriented(m_orientation)) { m_stroker.width(is_ccw(m_orientation) ? m_width : -m_width); } } m_status = ready; m_src_vertex = 0; } //------------------------------------------------------------------------ unsigned vcgen_contour::vertex(double* x, double* y) { unsigned cmd = path_cmd_line_to; while(!is_stop(cmd)) { switch(m_status) { case initial: rewind(0); case ready: if(m_src_vertices.size() < 2 + unsigned(m_closed != 0)) { cmd = path_cmd_stop; break; } m_status = outline; cmd = path_cmd_move_to; m_src_vertex = 0; m_out_vertex = 0; case outline: if(m_src_vertex >= m_src_vertices.size()) { m_status = end_poly; break; } m_stroker.calc_join(m_out_vertices, m_src_vertices.prev(m_src_vertex), m_src_vertices.curr(m_src_vertex), m_src_vertices.next(m_src_vertex), m_src_vertices.prev(m_src_vertex).dist, m_src_vertices.curr(m_src_vertex).dist); ++m_src_vertex; m_status = out_vertices; m_out_vertex = 0; case out_vertices: if(m_out_vertex >= m_out_vertices.size()) { m_status = outline; } else { const point_d& c = m_out_vertices[m_out_vertex++]; *x = c.x; *y = c.y; return cmd; } break; case end_poly: if(!m_closed) return path_cmd_stop; m_status = stop; return path_cmd_end_poly | path_flags_close | path_flags_ccw; case stop: return path_cmd_stop; } } return cmd; } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_curves.cpp0000644000175000017500000004361512516137326023002 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #include #include "agg_curves.h" #include "agg_math.h" namespace agg24 { //------------------------------------------------------------------------ const double curve_distance_epsilon = 1e-30; const double curve_collinearity_epsilon = 1e-30; const double curve_angle_tolerance_epsilon = 0.01; enum curve_recursion_limit_e { curve_recursion_limit = 32 }; //------------------------------------------------------------------------ void curve3_inc::approximation_scale(double s) { m_scale = s; } //------------------------------------------------------------------------ double curve3_inc::approximation_scale() const { return m_scale; } //------------------------------------------------------------------------ void curve3_inc::init(double x1, double y1, double x2, double y2, double x3, double y3) { m_start_x = x1; m_start_y = y1; m_end_x = x3; m_end_y = y3; double dx1 = x2 - x1; double dy1 = y2 - y1; double dx2 = x3 - x2; double dy2 = y3 - y2; double len = sqrt(dx1 * dx1 + dy1 * dy1) + sqrt(dx2 * dx2 + dy2 * dy2); m_num_steps = uround(len * 0.25 * m_scale); if(m_num_steps < 4) { m_num_steps = 4; } double subdivide_step = 1.0 / m_num_steps; double subdivide_step2 = subdivide_step * subdivide_step; double tmpx = (x1 - x2 * 2.0 + x3) * subdivide_step2; double tmpy = (y1 - y2 * 2.0 + y3) * subdivide_step2; m_saved_fx = m_fx = x1; m_saved_fy = m_fy = y1; m_saved_dfx = m_dfx = tmpx + (x2 - x1) * (2.0 * subdivide_step); m_saved_dfy = m_dfy = tmpy + (y2 - y1) * (2.0 * subdivide_step); m_ddfx = tmpx * 2.0; m_ddfy = tmpy * 2.0; m_step = m_num_steps; } //------------------------------------------------------------------------ void curve3_inc::rewind(unsigned) { if(m_num_steps == 0) { m_step = -1; return; } m_step = m_num_steps; m_fx = m_saved_fx; m_fy = m_saved_fy; m_dfx = m_saved_dfx; m_dfy = m_saved_dfy; } //------------------------------------------------------------------------ unsigned curve3_inc::vertex(double* x, double* y) { if(m_step < 0) return path_cmd_stop; if(m_step == m_num_steps) { *x = m_start_x; *y = m_start_y; --m_step; return path_cmd_move_to; } if(m_step == 0) { *x = m_end_x; *y = m_end_y; --m_step; return path_cmd_line_to; } m_fx += m_dfx; m_fy += m_dfy; m_dfx += m_ddfx; m_dfy += m_ddfy; *x = m_fx; *y = m_fy; --m_step; return path_cmd_line_to; } //------------------------------------------------------------------------ void curve3_div::init(double x1, double y1, double x2, double y2, double x3, double y3) { m_points.remove_all(); m_distance_tolerance_square = 0.5 / m_approximation_scale; m_distance_tolerance_square *= m_distance_tolerance_square; m_distance_tolerance_manhattan = 4.0 / m_approximation_scale; bezier(x1, y1, x2, y2, x3, y3); m_count = 0; } //------------------------------------------------------------------------ void curve3_div::recursive_bezier(double x1, double y1, double x2, double y2, double x3, double y3, unsigned level) { if(level > curve_recursion_limit) { return; } // Calculate all the mid-points of the line segments //---------------------- double x12 = (x1 + x2) / 2; double y12 = (y1 + y2) / 2; double x23 = (x2 + x3) / 2; double y23 = (y2 + y3) / 2; double x123 = (x12 + x23) / 2; double y123 = (y12 + y23) / 2; double dx = x3-x1; double dy = y3-y1; double d = fabs(((x2 - x3) * dy - (y2 - y3) * dx)); if(d > curve_collinearity_epsilon) { // Regular care //----------------- if(d * d <= m_distance_tolerance_square * (dx*dx + dy*dy)) { // If the curvature doesn't exceed the distance_tolerance value // we tend to finish subdivisions. //---------------------- if(m_angle_tolerance < curve_angle_tolerance_epsilon) { m_points.add(point_d(x123, y123)); return; } // Angle & Cusp Condition //---------------------- double da = fabs(atan2(y3 - y2, x3 - x2) - atan2(y2 - y1, x2 - x1)); if(da >= pi) da = 2*pi - da; if(da < m_angle_tolerance) { // Finally we can stop the recursion //---------------------- m_points.add(point_d(x123, y123)); return; } } } else { if(fabs(x1 + x3 - x2 - x2) + fabs(y1 + y3 - y2 - y2) <= m_distance_tolerance_manhattan) { m_points.add(point_d(x123, y123)); return; } } // Continue subdivision //---------------------- recursive_bezier(x1, y1, x12, y12, x123, y123, level + 1); recursive_bezier(x123, y123, x23, y23, x3, y3, level + 1); } //------------------------------------------------------------------------ void curve3_div::bezier(double x1, double y1, double x2, double y2, double x3, double y3) { m_points.add(point_d(x1, y1)); recursive_bezier(x1, y1, x2, y2, x3, y3, 0); m_points.add(point_d(x3, y3)); } //------------------------------------------------------------------------ void curve4_inc::approximation_scale(double s) { m_scale = s; } //------------------------------------------------------------------------ double curve4_inc::approximation_scale() const { return m_scale; } //------------------------------------------------------------------------ static double MSC60_fix_ICE(double v) { return v; } //------------------------------------------------------------------------ void curve4_inc::init(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { m_start_x = x1; m_start_y = y1; m_end_x = x4; m_end_y = y4; double dx1 = x2 - x1; double dy1 = y2 - y1; double dx2 = x3 - x2; double dy2 = y3 - y2; double dx3 = x4 - x3; double dy3 = y4 - y3; double len = (sqrt(dx1 * dx1 + dy1 * dy1) + sqrt(dx2 * dx2 + dy2 * dy2) + sqrt(dx3 * dx3 + dy3 * dy3)) * 0.25 * m_scale; #if defined(_MSC_VER) && _MSC_VER <= 1200 m_num_steps = uround(MSC60_fix_ICE(len)); #else m_num_steps = uround(len); #endif if(m_num_steps < 4) { m_num_steps = 4; } double subdivide_step = 1.0 / m_num_steps; double subdivide_step2 = subdivide_step * subdivide_step; double subdivide_step3 = subdivide_step * subdivide_step * subdivide_step; double pre1 = 3.0 * subdivide_step; double pre2 = 3.0 * subdivide_step2; double pre4 = 6.0 * subdivide_step2; double pre5 = 6.0 * subdivide_step3; double tmp1x = x1 - x2 * 2.0 + x3; double tmp1y = y1 - y2 * 2.0 + y3; double tmp2x = (x2 - x3) * 3.0 - x1 + x4; double tmp2y = (y2 - y3) * 3.0 - y1 + y4; m_saved_fx = m_fx = x1; m_saved_fy = m_fy = y1; m_saved_dfx = m_dfx = (x2 - x1) * pre1 + tmp1x * pre2 + tmp2x * subdivide_step3; m_saved_dfy = m_dfy = (y2 - y1) * pre1 + tmp1y * pre2 + tmp2y * subdivide_step3; m_saved_ddfx = m_ddfx = tmp1x * pre4 + tmp2x * pre5; m_saved_ddfy = m_ddfy = tmp1y * pre4 + tmp2y * pre5; m_dddfx = tmp2x * pre5; m_dddfy = tmp2y * pre5; m_step = m_num_steps; } //------------------------------------------------------------------------ void curve4_inc::rewind(unsigned) { if(m_num_steps == 0) { m_step = -1; return; } m_step = m_num_steps; m_fx = m_saved_fx; m_fy = m_saved_fy; m_dfx = m_saved_dfx; m_dfy = m_saved_dfy; m_ddfx = m_saved_ddfx; m_ddfy = m_saved_ddfy; } //------------------------------------------------------------------------ unsigned curve4_inc::vertex(double* x, double* y) { if(m_step < 0) return path_cmd_stop; if(m_step == m_num_steps) { *x = m_start_x; *y = m_start_y; --m_step; return path_cmd_move_to; } if(m_step == 0) { *x = m_end_x; *y = m_end_y; --m_step; return path_cmd_line_to; } m_fx += m_dfx; m_fy += m_dfy; m_dfx += m_ddfx; m_dfy += m_ddfy; m_ddfx += m_dddfx; m_ddfy += m_dddfy; *x = m_fx; *y = m_fy; --m_step; return path_cmd_line_to; } //------------------------------------------------------------------------ void curve4_div::init(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { m_points.remove_all(); m_distance_tolerance_square = 0.5 / m_approximation_scale; m_distance_tolerance_square *= m_distance_tolerance_square; m_distance_tolerance_manhattan = 4.0 / m_approximation_scale; bezier(x1, y1, x2, y2, x3, y3, x4, y4); m_count = 0; } //------------------------------------------------------------------------ void curve4_div::recursive_bezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, unsigned level) { if(level > curve_recursion_limit) { return; } // Calculate all the mid-points of the line segments //---------------------- double x12 = (x1 + x2) / 2; double y12 = (y1 + y2) / 2; double x23 = (x2 + x3) / 2; double y23 = (y2 + y3) / 2; double x34 = (x3 + x4) / 2; double y34 = (y3 + y4) / 2; double x123 = (x12 + x23) / 2; double y123 = (y12 + y23) / 2; double x234 = (x23 + x34) / 2; double y234 = (y23 + y34) / 2; double x1234 = (x123 + x234) / 2; double y1234 = (y123 + y234) / 2; // Try to approximate the full cubic curve by a single straight line //------------------ double dx = x4-x1; double dy = y4-y1; double d2 = fabs(((x2 - x4) * dy - (y2 - y4) * dx)); double d3 = fabs(((x3 - x4) * dy - (y3 - y4) * dx)); double da1, da2; switch((int(d2 > curve_collinearity_epsilon) << 1) + int(d3 > curve_collinearity_epsilon)) { case 0: // All collinear OR p1==p4 //---------------------- if(fabs(x1 + x3 - x2 - x2) + fabs(y1 + y3 - y2 - y2) + fabs(x2 + x4 - x3 - x3) + fabs(y2 + y4 - y3 - y3) <= m_distance_tolerance_manhattan) { m_points.add(point_d(x1234, y1234)); return; } break; case 1: // p1,p2,p4 are collinear, p3 is considerable //---------------------- if(d3 * d3 <= m_distance_tolerance_square * (dx*dx + dy*dy)) { if(m_angle_tolerance < curve_angle_tolerance_epsilon) { m_points.add(point_d(x23, y23)); return; } // Angle Condition //---------------------- da1 = fabs(atan2(y4 - y3, x4 - x3) - atan2(y3 - y2, x3 - x2)); if(da1 >= pi) da1 = 2*pi - da1; if(da1 < m_angle_tolerance) { m_points.add(point_d(x2, y2)); m_points.add(point_d(x3, y3)); return; } if(m_cusp_limit != 0.0) { if(da1 > m_cusp_limit) { m_points.add(point_d(x3, y3)); return; } } } break; case 2: // p1,p3,p4 are collinear, p2 is considerable //---------------------- if(d2 * d2 <= m_distance_tolerance_square * (dx*dx + dy*dy)) { if(m_angle_tolerance < curve_angle_tolerance_epsilon) { m_points.add(point_d(x23, y23)); return; } // Angle Condition //---------------------- da1 = fabs(atan2(y3 - y2, x3 - x2) - atan2(y2 - y1, x2 - x1)); if(da1 >= pi) da1 = 2*pi - da1; if(da1 < m_angle_tolerance) { m_points.add(point_d(x2, y2)); m_points.add(point_d(x3, y3)); return; } if(m_cusp_limit != 0.0) { if(da1 > m_cusp_limit) { m_points.add(point_d(x2, y2)); return; } } } break; case 3: // Regular care //----------------- if((d2 + d3)*(d2 + d3) <= m_distance_tolerance_square * (dx*dx + dy*dy)) { // If the curvature doesn't exceed the distance_tolerance value // we tend to finish subdivisions. //---------------------- if(m_angle_tolerance < curve_angle_tolerance_epsilon) { m_points.add(point_d(x23, y23)); return; } // Angle & Cusp Condition //---------------------- double a23 = atan2(y3 - y2, x3 - x2); da1 = fabs(a23 - atan2(y2 - y1, x2 - x1)); da2 = fabs(atan2(y4 - y3, x4 - x3) - a23); if(da1 >= pi) da1 = 2*pi - da1; if(da2 >= pi) da2 = 2*pi - da2; if(da1 + da2 < m_angle_tolerance) { // Finally we can stop the recursion //---------------------- m_points.add(point_d(x23, y23)); return; } if(m_cusp_limit != 0.0) { if(da1 > m_cusp_limit) { m_points.add(point_d(x2, y2)); return; } if(da2 > m_cusp_limit) { m_points.add(point_d(x3, y3)); return; } } } break; } // Continue subdivision //---------------------- recursive_bezier(x1, y1, x12, y12, x123, y123, x1234, y1234, level + 1); recursive_bezier(x1234, y1234, x234, y234, x34, y34, x4, y4, level + 1); } //------------------------------------------------------------------------ void curve4_div::bezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) { m_points.add(point_d(x1, y1)); recursive_bezier(x1, y1, x2, y2, x3, y3, x4, y4, 0); m_points.add(point_d(x4, y4)); } } enthought-chaco2-4.5.1.orig/kiva/agg/agg-24/src/agg_vcgen_bspline.cpp0000644000175000017500000001527412516137326024311 0ustar varunvarun//---------------------------------------------------------------------------- // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // // Permission to copy, use, modify, sell and distribute this software // is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // //---------------------------------------------------------------------------- // Contact: mcseem@antigrain.com // mcseemagg@yahoo.com // http://www.antigrain.com //---------------------------------------------------------------------------- #include "agg_vcgen_bspline.h" namespace agg24 { //------------------------------------------------------------------------ vcgen_bspline::vcgen_bspline() : m_src_vertices(), m_spline_x(), m_spline_y(), m_interpolation_step(1.0/50.0), m_closed(0), m_status(initial), m_src_vertex(0) { } //------------------------------------------------------------------------ void vcgen_bspline::remove_all() { m_src_vertices.remove_all(); m_closed = 0; m_status = initial; m_src_vertex = 0; } //------------------------------------------------------------------------ void vcgen_bspline::add_vertex(double x, double y, unsigned cmd) { m_status = initial; if(is_move_to(cmd)) { m_src_vertices.modify_last(point_d(x, y)); } else { if(is_vertex(cmd)) { m_src_vertices.add(point_d(x, y)); } else { m_closed = get_close_flag(cmd); } } } //------------------------------------------------------------------------ void vcgen_bspline::rewind(unsigned) { m_cur_abscissa = 0.0; m_max_abscissa = 0.0; m_src_vertex = 0; if(m_status == initial && m_src_vertices.size() > 2) { if(m_closed) { m_spline_x.init(m_src_vertices.size() + 8); m_spline_y.init(m_src_vertices.size() + 8); m_spline_x.add_point(0.0, m_src_vertices.prev(m_src_vertices.size() - 3).x); m_spline_y.add_point(0.0, m_src_vertices.prev(m_src_vertices.size() - 3).y); m_spline_x.add_point(1.0, m_src_vertices[m_src_vertices.size() - 3].x); m_spline_y.add_point(1.0, m_src_vertices[m_src_vertices.size() - 3].y); m_spline_x.add_point(2.0, m_src_vertices[m_src_vertices.size() - 2].x); m_spline_y.add_point(2.0, m_src_vertices[m_src_vertices.size() - 2].y); m_spline_x.add_point(3.0, m_src_vertices[m_src_vertices.size() - 1].x); m_spline_y.add_point(3.0, m_src_vertices[m_src_vertices.size() - 1].y); } else { m_spline_x.init(m_src_vertices.size()); m_spline_y.init(m_src_vertices.size()); } unsigned i; for(i = 0; i < m_src_vertices.size(); i++) { double x = m_closed ? i + 4 : i; m_spline_x.add_point(x, m_src_vertices[i].x); m_spline_y.add_point(x, m_src_vertices[i].y); } m_cur_abscissa = 0.0; m_max_abscissa = m_src_vertices.size() - 1; if(m_closed) { m_cur_abscissa = 4.0; m_max_abscissa += 5.0; m_spline_x.add_point(m_src_vertices.size() + 4, m_src_vertices[0].x); m_spline_y.add_point(m_src_vertices.size() + 4, m_src_vertices[0].y); m_spline_x.add_point(m_src_vertices.size() + 5, m_src_vertices[1].x); m_spline_y.add_point(m_src_vertices.size() + 5, m_src_vertices[1].y); m_spline_x.add_point(m_src_vertices.size() + 6, m_src_vertices[2].x); m_spline_y.add_point(m_src_vertices.size() + 6, m_src_vertices[2].y); m_spline_x.add_point(m_src_vertices.size() + 7, m_src_vertices.next(2).x); m_spline_y.add_point(m_src_vertices.size() + 7, m_src_vertices.next(2).y); } m_spline_x.prepare(); m_spline_y.prepare(); } m_status = ready; } //------------------------------------------------------------------------ unsigned vcgen_bspline::vertex(double* x, double* y) { unsigned cmd = path_cmd_line_to; while(!is_stop(cmd)) { switch(m_status) { case initial: rewind(0); case ready: if(m_src_vertices.size() < 2) { cmd = path_cmd_stop; break; } if(m_src_vertices.size() == 2) { *x = m_src_vertices[m_src_vertex].x; *y = m_src_vertices[m_src_vertex].y; m_src_vertex++; if(m_src_vertex == 1) return path_cmd_move_to; if(m_src_vertex == 2) return path_cmd_line_to; cmd = path_cmd_stop; break; } cmd = path_cmd_move_to; m_status = polygon; m_src_vertex = 0; case polygon: if(m_cur_abscissa >= m_max_abscissa) { if(m_closed) { m_status = end_poly; break; } else { *x = m_src_vertices[m_src_vertices.size() - 1].x; *y = m_src_vertices[m_src_vertices.size() - 1].y; m_status = end_poly; return path_cmd_line_to; } } *x = m_spline_x.get_stateful(m_cur_abscissa); *y = m_spline_y.get_stateful(m_cur_abscissa); m_src_vertex++; m_cur_abscissa += m_interpolation_step; return (m_src_vertex == 1) ? path_cmd_move_to : path_cmd_line_to; case end_poly: m_status = stop; return path_cmd_end_poly | m_closed; case stop: return path_cmd_stop; } } return cmd; } } enthought-chaco2-4.5.1.orig/kiva/agg/__init__.py0000644000175000017500000000340212516137326020500 0ustar varunvarunfrom agg import * pix_format_string_map = {} pix_format_string_map["gray8"] = pix_format_gray8 pix_format_string_map["rgb555"] = pix_format_rgb555 pix_format_string_map["rgb565"] = pix_format_rgb565 pix_format_string_map["rgb24"] = pix_format_rgb24 pix_format_string_map["bgr24"] = pix_format_bgr24 pix_format_string_map["rgba32"] = pix_format_rgba32 pix_format_string_map["argb32"] = pix_format_argb32 pix_format_string_map["abgr32"] = pix_format_abgr32 pix_format_string_map["bgra32"] = pix_format_bgra32 default_pix_format = "bgra32" import types try: # Define a system-dependent GraphicsContext if there is a PixelMap # class defined for the system (i.e. if plat_support was built) from plat_support import PixelMap class GraphicsContextSystem(GraphicsContextArray): def __init__(self, size, pix_format=default_pix_format, interpolation="nearest", bottom_up=True): assert isinstance(size, types.TupleType), repr(size) width,height = size pixel_map = PixelMap( width, height, pix_format_string_map[pix_format], 255, bool(bottom_up) ).set_bmp_array() GraphicsContextArray.__init__(self, pixel_map.bmp_array, pix_format, interpolation, bottom_up) self.pixel_map = pixel_map except ImportError, ex: # warn to stderr containing the exception. The warning should # be an ImportWarning, but that is python 2.5+ specific import warnings warnings.warn("Error initializing Agg: %s" % ex, Warning, 2) GraphicsContextSystem = None enthought-chaco2-4.5.1.orig/kiva/agg/setup.py0000644000175000017500000002240312516137326020103 0ustar varunvarun#!/usr/bin/env python import sys import os import re import platform freetype2_sources =['autofit/autofit.c', 'base/ftbase.c','base/ftsystem.c','base/ftinit.c', 'base/ftglyph.c','base/ftmm.c','base/ftbdf.c', 'base/ftbbox.c','base/ftdebug.c','base/ftxf86.c', 'base/fttype1.c', 'bdf/bdf.c', 'cff/cff.c', 'cid/type1cid.c', 'lzw/ftlzw.c', 'pcf/pcf.c','pfr/pfr.c', 'psaux/psaux.c', 'pshinter/pshinter.c', 'psnames/psnames.c', 'raster/raster.c', 'sfnt/sfnt.c', 'smooth/smooth.c', 'truetype/truetype.c', 'type1/type1.c', 'type42/type42.c', 'winfonts/winfnt.c', 'gzip/ftgzip.c', 'base/ftmac.c', ] freetype2_dirs = [ 'autofit', 'base', 'bdf', 'cache', 'cff', 'cid', 'gxvalid', 'gzip', 'lzw', 'otvalid', 'pcf', 'pfr', 'psaux', 'pshinter', 'psnames', 'raster', 'sfnt', 'smooth', 'tools', 'truetype', 'type1', 'type42', 'winfonts', 'gzip' ] def configuration(parent_package='', top_path=None): from numpy.distutils.misc_util import Configuration from numpy.distutils.system_info import dict_append, get_info agg_dir = 'agg-24' agg_lib = 'agg24_src' config = Configuration('agg', parent_package,top_path) numerix_info = get_info('numerix') if ('NUMPY', None) in numerix_info.get('define_macros',[]): dict_append(numerix_info, define_macros = [('PY_ARRAY_TYPES_PREFIX','NUMPY_CXX'), ('OWN_DIMENSIONS','0'), ('OWN_STRIDES','0')]) #------------------------------------------------------------------------- # Configure the Agg backend to use on each platform #------------------------------------------------------------------------- if sys.platform=='win32': plat = 'win32' elif sys.platform == 'darwin': plat = 'gl' else: #plat = 'gtk1' # use with gtk1, it's fast plat = 'x11' # use with gtk2, it's slow but reliable #plat = 'gdkpixbuf2' #------------------------------------------------------------------------- # Add the freetype library (agg 2.4 links against this) #------------------------------------------------------------------------- prefix = config.paths('freetype2/src')[0] freetype_lib = 'freetype2_src' def get_ft2_sources((lib_name, build_info), build_dir): sources = [prefix + "/" + s for s in freetype2_sources] if sys.platform=='darwin': return sources[:] return sources[:-1] ft2_incl_dirs = ['freetype2/src/' + s for s in freetype2_dirs] \ + ['freetype2/include', 'freetype2/src'] ft2_incl_dirs = config.paths(*ft2_incl_dirs) if sys.platform == 'darwin' and '64bit' not in platform.architecture(): ft2_incl_dirs.append("/Developer/Headers/FlatCarbon") config.add_library(freetype_lib, sources = [get_ft2_sources], include_dirs = ft2_incl_dirs, # This macro was introduced in Freetype 2.2; if it is # not defined, then the ftheader.h file (one of the # primary headers) won't pull in any additional internal # Freetype headers, and the library will mysteriously # fail to build. macros = [("FT2_BUILD_LIBRARY", None)], depends = ['freetype2'], ) #------------------------------------------------------------------------- # Add the Agg sources #------------------------------------------------------------------------- agg_include_dirs = [agg_dir+'/include',agg_dir+'/font_freetype'] + \ ft2_incl_dirs agg_sources = [agg_dir+'/src/*.cpp', agg_dir+'/font_freetype/*.cpp'] config.add_library(agg_lib, agg_sources, include_dirs = agg_include_dirs, depends = [agg_dir]) #------------------------------------------------------------------------- # Add the Kiva sources #------------------------------------------------------------------------- if sys.platform == 'darwin': define_macros = [('__DARWIN__', None)] macros = [('__DARWIN__', None)] extra_link_args = ['-framework', 'Carbon'] else: define_macros = [] macros = [] extra_link_args = [] kiva_include_dirs = ['src'] + agg_include_dirs config.add_library('kiva_src', ['src/kiva_*.cpp', 'src/gl_graphics_context.cpp'], include_dirs = kiva_include_dirs, # Use "macros" instead of "define_macros" because the # latter is only used for extensions, and not clibs macros = macros, ) # MSVC6.0: uncomment to handle template parameters: #extra_compile_args = ['/Zm1000'] extra_compile_args = [] # XXX: test whether numpy has weakref support #------------------------------------------------------------------------- # Build the extension itself #------------------------------------------------------------------------- # Check for g++ < 4.0 on 64-bit Linux use_32bit_workaround = False if sys.platform == 'linux2' and '64bit' in platform.architecture(): f = os.popen("g++ --version") line0 = f.readline() f.close() m = re.match(r'.+?\s(3|4)\.\d+', line0) if int(m.group(1)) < 4: use_32bit_workaround = True # Enable workaround of agg bug on 64-bit machines with g++ < 4.0 if use_32bit_workaround: define_macros.append(("ALWAYS_32BIT_WORKAROUND", 1)) # Options to make OS X link OpenGL if '64bit' not in platform.architecture(): darwin_frameworks = ['Carbon', 'ApplicationServices', 'OpenGL'] else: darwin_frameworks = ['ApplicationServices', 'OpenGL'] darwin_opengl_opts = dict( include_dirs = [ '/System/Library/Frameworks/%s.framework/Versions/A/Headers' % x for x in darwin_frameworks], define_macros = [('__DARWIN__',None)], extra_link_args = ['-framework %s' % x for x in darwin_frameworks] ) build_info = {} kiva_lib = 'kiva_src' build_libraries = [kiva_lib, agg_lib, freetype_lib] if sys.platform == "win32": build_libraries += ["opengl32", "glu32"] elif sys.platform == "darwin": dict_append(build_info, **darwin_opengl_opts) else: # This should work for most linuxes (linuces?) build_libraries += ["GL", "GLU"] dict_append(build_info, sources = ['agg.i'], include_dirs = kiva_include_dirs, libraries = build_libraries, depends = ['src/*.[ih]'], extra_compile_args = extra_compile_args, extra_link_args = extra_link_args, define_macros=define_macros, ) dict_append(build_info, **numerix_info) config.add_extension('_agg', **build_info) sources = [os.path.join('src',plat,'plat_support.i'), os.path.join('src',plat,'agg_bmp.cpp'), ] if plat != 'gl': sources.append(os.path.join('src',plat,'agg_platform_specific.cpp')) plat_info = {} dict_append(plat_info, libraries = [agg_lib], include_dirs = kiva_include_dirs, extra_compile_args = extra_compile_args, depends = ['src']) dict_append(plat_info, **numerix_info) if plat=='win32': dict_append(plat_info, libraries = ['gdi32','user32']) elif plat in ['x11','gtk1']: # Make sure we raise an error if the information is not found. # Frequently, the 64-bit libraries are not in a known location and need # manual configuration. From experience, this is usually not detected by # the builder if we do not raise an exception. x11_info = get_info('x11', notfound_action=2) dict_append(plat_info, **x11_info) elif plat=='gdkpixbuf2': #gdk_pixbuf_xlib_2 = get_info('gdk_pixbuf_xlib_2',notfound_action=1) #dict_append(plat_info,**gdk_pixbuf_xlib_2) gtk_info = get_info('gtk+-2.0') dict_append(plat_info, **gtk_info) #x11_info = get_info('x11',notfound_action=1) #dict_append(plat_info,**x11_info) elif plat == 'gl': if sys.platform == 'darwin': dict_append(plat_info, **darwin_opengl_opts) else: msg = "OpenGL build support only on MacOSX right now." raise NotImplementedError, msg config.add_extension('_plat_support', sources, **plat_info ) config.add_data_dir('tests') config.add_data_files('*.txt', '*.bat') return config enthought-chaco2-4.5.1.orig/kiva/agg/src/0000755000175000017500000000000012516137726017163 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/src/font_type.i0000644000175000017500000000410612516137326021341 0ustar varunvarun%{ #include "kiva_font_type.h" %} %include "agg_std_string.i" namespace kiva { %rename(AggFontType) font_type; class font_type { public: %mutable; int size; std::string name; int family; int style; int encoding; std::string filename; // constructor font_type(std::string _name="Arial", int _size=12, int _family=0, int _style=0, int _encoding=0, bool validate=true); int change_filename(std::string _filename); bool is_loaded(); }; } %extend kiva::font_type { char *__repr__() { static char tmp[1024]; // Write out elements of trans_affine in a,b,c,d,tx,ty order // !! We should work to make output formatting conform to // !! whatever it Numeric does (which needs to be cleaned up also). sprintf(tmp,"Font(%s,%d,%d,%d,%d)", self->name.c_str(), self->family, self->size, self->style, self->encoding); return tmp; } int __eq__(kiva::font_type& other) { return (self->name == other.name && self->family == other.family && self->size == other.size && self->style == other.style && self->encoding == other.encoding); } } %pythoncode %{ def unicode_safe_init(self, _name="Arial", _size=12, _family=0, _style=0, _encoding=0, validate=True): if isinstance(_name, unicode): _name = _name.encode("latin1") obj = _agg.new_AggFontType(_name, _size, _family, _style, _encoding, validate) _swig_setattr(self, AggFontType, "this", obj) _swig_setattr(self, AggFontType, "thisown", 1) # This is a crappy way of overriding the constructor AggFontType.__init__ = unicode_safe_init %} enthought-chaco2-4.5.1.orig/kiva/agg/src/agg_typemaps.i0000644000175000017500000002562712516137326022025 0ustar varunvarun// -------------------------------------------------------------------------- // Generic typemap to handle enumerated types. // // Both agg and kiva have quite a few enumerated types. SWIG will wrap // functions that use these as arguments to require a pointer to an // enumerated type object. This isn't very convenient. It is much nicer // to just pass an integer. this generic converter can be used in to // allow this. // // To apply it to a type, for example agg24::marker_e, do the following // // %apply(kiva_enum_typemap) { agg24::marker_e } // // Now any function that expects a marker_e will accept integer values as // input. // -------------------------------------------------------------------------- %include "numeric.i" %typemap(in) kiva_enum_typemap type { int temp = PyInt_AsLong($input); if (PyErr_Occurred()) SWIG_fail; $1 = $1_ltype(temp); } // -------------------------------------------------------------------------- // Typemaps for (double x, double y) points // // For: * // // This is useful for places where ints may be passed in and need to // be converted. Python 2.6 requires this // -------------------------------------------------------------------------- %typemap(in) double x, double y { if (PyNumber_Check($input)) { $1 = static_cast(PyFloat_AsDouble($input)); } else { SWIG_exception(SWIG_TypeError, "Expected argument $argnum of type '$1_type'"); } } // -------------------------------------------------------------------------- // Typemaps for (double* pts, int Npts) used in lines() // // For: compiled_path and graphics_context // // This typemap takes any Nx2 input (nested sequences or an Nx2 array). If // the input has the wrong shape or can't be converted to a double, an // exception is raised. It is more efficient if the input passed in is a // contiguous array, so if you're calling lines(pts) a lot of times, make // pts an array. // // -------------------------------------------------------------------------- %typemap(in) (double* point_array, int point_count) (PyArrayObject* ary=NULL, int is_new_object) { ary = obj_to_array_contiguous_allow_conversion($input, PyArray_DOUBLE, is_new_object); int size[2] = {-1,2}; if (!ary || !require_dimensions(ary,2) || !require_size(ary,size,2)) { goto fail; } $1 = (double*) ary->data; $2 = ary->dimensions[0]; } %typemap(freearg) (double* point_array, int point_count) { if (is_new_object$argnum) { Py_XDECREF(ary$argnum); } } // -------------------------------------------------------------------------- // Typemaps for (int* results, int Nresults) // // For: points_in_polygon // // This typemap takes any N input. // // -------------------------------------------------------------------------- %typemap(in) (int* results, int Nresults) (PyArrayObject* ary=NULL, int is_new_object) { ary = obj_to_array_contiguous_allow_conversion($input, PyArray_INT, is_new_object); int size[1] = {-1}; if (!ary || !require_dimensions(ary,1) || !require_size(ary,size,1)) { goto fail; } $1 = (int*) ary->data; $2 = ary->dimensions[0]; } %typemap(freearg) (int* results, int Nresults) { if (is_new_object$argnum) { Py_XDECREF(ary$argnum); } } /* Typemaps for rects(double* all_rects, int Nrects) For: compiled_path and graphics_context This typemap takes any Nx4 input (nested sequences or an Nx4 array). If the input has the wrong shape or can't be converted to a double, an exception is raised. It is more efficient if the input passed in is a contiguous array, so if you're calling rects(all_rects) a lot of times, make all_rects an array. */ %typemap(in) (double* rect_array, int rect_count) (PyArrayObject* ary=NULL, int is_new_object) { ary = obj_to_array_contiguous_allow_conversion($input, PyArray_DOUBLE, is_new_object); int size[2] = {-1,4}; if (!ary || !require_dimensions(ary,2) || !require_size(ary,size,2)) { goto fail; } $1 = (double*) ary->data; $2 = ary->dimensions[0]; } %typemap(freearg) (double* rect_array, int rect_count) { if (is_new_object$argnum) { Py_XDECREF(ary$argnum); } } // -------------------------------------------------------------------------- // // vertex() returns ( pt, cmd) where pt is a tuple (x,y) // // This tells SWIG to treat an double * argument with name 'x' as // an output value. We'll append the value to the current result which // is guaranteed to be a List object by SWIG. // -------------------------------------------------------------------------- %typemap(in,numinputs=0) (double *vertex_x, double* vertex_y)(double temp1, double temp2) { temp1 = 0; $1 = &temp1; temp2 = 0; $2 = &temp2; } %typemap(argout) (double *vertex_x, double* vertex_y) { PyObject *px = PyFloat_FromDouble(*$1); PyObject *py = PyFloat_FromDouble(*$2); PyObject *pt = PyTuple_New(2); PyTuple_SetItem(pt,0,px); PyTuple_SetItem(pt,1,py); PyObject *return_val = PyTuple_New(2); PyTuple_SetItem(return_val,0,pt); // result is what was returned from vertex PyTuple_SetItem(return_val,1,$result); //Py_DECREF($result); $result = return_val; } // -------------------------------------------------------------------------- // map to output arguments into a 2-tuple // -------------------------------------------------------------------------- %typemap(in,numinputs=0) (double *pt_x, double* pt_y)(double temp1, double temp2) { temp1 = 0; $1 = &temp1; temp2 = 0; $2 = &temp2; } %typemap(argout) (double *pt_x, double *pt_y) { PyObject *px = PyFloat_FromDouble(*$1); PyObject *py = PyFloat_FromDouble(*$2); PyObject *pt = PyTuple_New(2); PyTuple_SetItem(pt,0,px); PyTuple_SetItem(pt,1,py); //Py_DECREF($result); $result = pt; } // -------------------------------------------------------------------------- // map an 6 element double* output into a Numeric array. // -------------------------------------------------------------------------- %typemap(in, numinputs=0) double *array6 (double temp[6]) { $1 = temp; } %typemap(argout) double *array6 { // Append output value $1 to $result npy_intp dims = 6; PyArrayObject* ary_obj = (PyArrayObject*) PyArray_SimpleNew(1,&dims,PyArray_DOUBLE); if( ary_obj == NULL ) return NULL; double* data = (double*)ary_obj->data; for (int i=0; i < 6;i++) data[i] = $1[i]; Py_DECREF($result); $result = PyArray_Return(ary_obj); } // -------------------------------------------------------------------------- // Typemaps for graphics_context.set_line_dash() // // For: // // This typemap takes None or any N element input (sequence or array). If // the input is None, it passes a 2 element array of zeros to in as the // pattern. If the input is a sequence and isn't 1D or can't be converted // to a double, an exception is raised. // -------------------------------------------------------------------------- %typemap(in) (double* dash_pattern, int n) (PyArrayObject* ary=NULL, int is_new_object, double temp[2]) { is_new_object = 0; if ($input == Py_None) { temp[0] = 0.0; temp[1] = 0.0; $1 = temp; $2 = 2; } else { ary = obj_to_array_contiguous_allow_conversion($input, PyArray_DOUBLE, is_new_object); if (!ary || !require_dimensions(ary,1)) { goto fail; } $1 = (double*) ary->data; $2 = ary->dimensions[0]; } } %typemap(freearg) (double* dash_pattern, int n) { if (is_new_object$argnum) { Py_XDECREF(ary$argnum); } } // -------------------------------------------------------------------------- // Image typemaps // // Currently, this requires a contiguous array. It should be fixed to // allow arrays that are only contiguous along the last two dimensions. // This is because the windows bitmap format requires that each row of // pixels (scan line) is word aligned (16 bit boundaries). As a result, rgb // images compatible with this format potentially // need a pad byte at the end of each scanline. // -------------------------------------------------------------------------- %typemap(in) (unsigned char *image_data=NULL, int width, int height, int stride) { PyArrayObject* ary = obj_to_array_no_conversion($input, PyArray_UBYTE); int dimensions[2] = {2,3}; // !! No longer requiring contiguity because some bitmaps are padded at the // !! end (i.e. Windows). We should probably special case that one though, // !! and re-instate the contiguous policy... // if (!ary || // !require_dimensions(ary,dimensions,2) || // !require_contiguous(ary)) if (!ary || !require_dimensions(ary,dimensions,2)) { goto fail; } $1 = (unsigned char*) ary->data; // notice reversed orders... $2 = ary->dimensions[1]; $3 = ary->dimensions[0]; $4 = ary->strides[0]; } // -------------------------------------------------------------------------- // Some functions create new objects and return these to python. By // default, SWIG sets these objects as "unowned" by the shadow class // created to represent them in python. The result is that these objects // are not freed when the shadow object calls its __del__ method. Here // the thisown flag is set to 1 so that the object will be destroyed on // destruction. // -------------------------------------------------------------------------- %typemap(out) owned_pointer { $result = SWIG_NewPointerObj((void *) $1, $1_descriptor, 1); } //--------------------------------------------------------------------- // Gradient support //--------------------------------------------------------------------- %typemap(in) std::vector (PyArrayObject* ary=NULL, int is_new_object) { PyArrayObject* ary = obj_to_array_no_conversion($input, PyArray_DOUBLE); if (ary == NULL) { goto fail; } std::vector stops; for (int i = 0; i < ary->dimensions[0]; i++) { // the stop is offset, red, green, blue, alpha double* data = (double*)(ary->data); agg24::rgba8 color(data[5*i+1]*255, data[5*i+2]*255, data[5*i+3]*255, data[5*i+4]*255); stops.push_back(kiva::gradient_stop(data[5*i], color)); } $1 = stops; } enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_gradient.h0000644000175000017500000002503712516137326022146 0ustar varunvarun#ifndef KIVA_GRADIENT_H #define KIVA_GRADIENT_H #include #include #include #include "agg_pixfmt_rgb.h" #include "agg_rasterizer_scanline_aa.h" #include "agg_renderer_scanline.h" #include "agg_scanline_u.h" #include "agg_span_gradient.h" #include "agg_span_allocator.h" #include "agg_span_interpolator_linear.h" #include "agg_renderer_mclip.h" #include "kiva_affine_helpers.h" #include "kiva_constants.h" namespace kiva { class gradient_stop { public: double offset; agg24::rgba8 color; gradient_stop(double offset, agg24::rgba8& color) : offset(offset), color(color) { } }; class gradient { public: typedef std::pair point; std::vector points; std::vector stops; gradient_type_e gradient_type; gradient_spread_e spread_method; gradient_units_e units; private: agg24::trans_affine affine_mtx; public: gradient(gradient_type_e gradient_type); gradient(gradient_type_e gradient_type, std::vector points, std::vector stops, const char* spread_method, const char* units="userSpaceOnUse"); ~gradient(); template void apply(pixfmt_type pixfmt, agg24::rasterizer_scanline_aa<>* ras, agg24::renderer_mclip* rbase) { if (this->gradient_type == kiva::grad_linear) { if (this->points[0].first == this->points[1].first) { agg24::gradient_y grad_func; // apply the proper fill adapter based on the spread method if (this->spread_method == kiva::reflect) { agg24::gradient_reflect_adaptor adaptor(grad_func); this->_apply(pixfmt, ras, rbase, adaptor); } else if (this->spread_method == kiva::repeat) { agg24::gradient_repeat_adaptor adaptor(grad_func); this->_apply(pixfmt, ras, rbase, adaptor); } else { this->_apply(pixfmt, ras, rbase, grad_func); } } else if (this->points[0].second == this->points[1].second) { agg24::gradient_x grad_func; // apply the proper fill adapter based on the spread method if (this->spread_method == kiva::reflect) { agg24::gradient_reflect_adaptor adaptor(grad_func); this->_apply(pixfmt, ras, rbase, adaptor); } else if (this->spread_method == kiva::repeat) { agg24::gradient_repeat_adaptor adaptor(grad_func); this->_apply(pixfmt, ras, rbase, adaptor); } else { this->_apply(pixfmt, ras, rbase, grad_func); } } else { agg24::gradient_x grad_func; // apply the proper fill adapter based on the spread method if (this->spread_method == kiva::reflect) { agg24::gradient_reflect_adaptor adaptor(grad_func); this->_apply(pixfmt, ras, rbase, adaptor); } else if (this->spread_method == kiva::repeat) { agg24::gradient_repeat_adaptor adaptor(grad_func); this->_apply(pixfmt, ras, rbase, adaptor); } else { this->_apply(pixfmt, ras, rbase, grad_func); } } } else { agg24::gradient_radial_focus grad_func(points[1].first, points[2].first - points[0].first, points[2].second - points[0].second); if (this->spread_method == kiva::reflect) { agg24::gradient_reflect_adaptor adaptor(grad_func); this->_apply(pixfmt, ras, rbase, adaptor); } else if (this->spread_method == kiva::repeat) { agg24::gradient_repeat_adaptor adaptor(grad_func); this->_apply(pixfmt, ras, rbase, adaptor); } else { this->_apply(pixfmt, ras, rbase, grad_func); } } } void set_ctm(const agg24::trans_affine& mtx) { this->affine_mtx = mtx; } protected: template void _apply(pixfmt_type pixfmt, agg24::rasterizer_scanline_aa<>* ras, agg24::renderer_mclip* rbase, gradient_func_type gradient_func) { typedef agg24::renderer_mclip renderer_base_type; typedef agg24::span_interpolator_linear<> interpolator_type; typedef agg24::span_allocator span_allocator_type; typedef agg24::pod_auto_array color_array_type; typedef agg24::span_gradient span_gradient_type; typedef agg24::renderer_scanline_aa renderer_gradient_type; agg24::trans_affine gradient_mtx; // Affine transformer interpolator_type span_interpolator(gradient_mtx); // Span interpolator span_allocator_type span_allocator; // Span Allocator color_array_type color_array; // Gradient colors agg24::scanline_u8 scanline; double dx = points[1].first - points[0].first; double dy = points[1].second - points[0].second; double d1 = 0, d2 = 0; if ((this->gradient_type == kiva::grad_radial) && (this->points.size() >2)) { // length is the radius d2 = points[1].first; } else if (this->gradient_type == kiva::grad_linear) { // length is the distance between the two points d2 = sqrt(dx * dx + dy * dy); if (points[0].first == points[1].first) { // gradient_y. handle flips gradient_mtx *= agg24::trans_affine_rotation(atan2(0.0, dy)); } else if (points[0].second == points[1].second) { // gradient_x. handle flips gradient_mtx *= agg24::trans_affine_rotation(atan2(0.0, dx)); } else { // general case: arbitrary rotation gradient_mtx *= agg24::trans_affine_rotation(atan2(dy, dx)); } } gradient_mtx *= agg24::trans_affine_translation(points[0].first, points[0].second); if (this->units == kiva::user_space) { gradient_mtx *= this->affine_mtx; } gradient_mtx.invert(); //std::cout << "drawing with affine matrix " << gradient_mtx.m0 // << ", " << gradient_mtx.m1 // << ", " << gradient_mtx.m2 // << ", " << gradient_mtx.m3 // << ", " << gradient_mtx.m4 // << ", " << gradient_mtx.m5 << std::endl; span_gradient_type span_gradient(span_interpolator, gradient_func, color_array, d1, d2); renderer_gradient_type grad_renderer(*rbase, span_allocator, span_gradient); this->fill_color_array(color_array); agg24::render_scanlines(*ras, scanline, grad_renderer); } template void fill_color_array(Array& array) { // The agg24::rgb::gradient function is not documented, so here's // my guess at what it does: the first argument is obvious, // since we are constructing a gradient from one color to another. // The 2nd argument is a float, which must be between 0 and 1, and // represents the ratio of the first color to the second color. // Hence, it should always go from 0->1. In a multi-stop scenario // we will loop through the stops, for each pair the gradient call // will go from 0% to 100% of the 2nd color. // I hope that makes sense. std::vector::iterator stop_it = this->stops.begin(); double offset = 0.0; unsigned int i = 0; unsigned int const array_size = array.size(); for (; stop_it+1 != this->stops.end(); stop_it++) { std::vector::iterator next_it = stop_it+1; double offset_range = next_it->offset - stop_it->offset; while ( (offset <= next_it->offset) && (i < array_size)) { array[i++] = stop_it->color.gradient(next_it->color, (offset-stop_it->offset)/offset_range); offset = i/double(array_size-1); } } } }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_rect.cpp0000755000175000017500000002541712516137326021646 0ustar varunvarun#include "kiva_rect.h" #include #include #include #include namespace kiva { rect_type disjoint_intersect(const rect_type &a, const rect_type &b) { double xl = max(a.x, b.x); double yb = max(a.y, b.y); double xr = min(a.x2(), b.x2()); double yt = min(a.y2(), b.y2()); if ((xr >= xl) && (yt >= yb)) { return rect_type(xl, yb, xr-xl, yt-yb); } else { return rect_type(xl, yb, -1, -1); } } rect_list_type disjoint_intersect(const rect_list_type &rects) { if (rects.size() < 2) { return rects; } rect_list_type result_list; result_list.push_back(rects[0]); for (unsigned int i=1; i= 0) && (result_rect.h >= 0)) { result_list.push_back(result_rect); } } return result_list; } rect_list_type disjoint_union(const rect_type &a, const rect_type &b) { rect_list_type rlist; rlist.push_back(a); return disjoint_union(rlist, b); } rect_list_type disjoint_union(const rect_list_type &rects) { if (rects.size() < 2) { return rects; } rect_list_type rlist; rlist.push_back(rects[0]); for (unsigned int i=1; ix; double yb1 = cur_todo->y; double xr1 = cur_todo->x2(); double yt1 = cur_todo->y2(); double xl2, yb2, xr2, yt2; unsigned int orig_count = 0; while (orig_count < original_list.size()) { rect_type *cur_orig = &original_list[orig_count]; xl2 = cur_orig->x; yb2 = cur_orig->y; xr2 = cur_orig->x2(); yt2 = cur_orig->y2(); // Test for non-overlapping if ((xl1 >= xr2) || (xr1 <= xl2) || (yb1 >= yt2) || (yt1 <= yb2)) { orig_count++; continue; } // Test for new rect being wholly contained in an existing one bool x1inx2 = ((xl1 >= xl2) && (xr1 <= xr2)); bool y1iny2 = ((yb1 >= yb2) && (yt1 <= yt2)); if (x1inx2 && y1iny2) { use_leftover = false; break; } // Test for existing rect being wholly contained in new rect bool x2inx1 = ((xl2 >= xl1) && (xr2 <= xr1)); bool y2iny1 = ((yb2 >= yb1) && (yt2 <= yt1)); if (x2inx1 && y2iny1) { // Erase the existing rectangle from the original_list // and set the iterator to the next one. original_list.erase(original_list.begin() + orig_count); continue; } // Test for rect 1 being within rect 2 along the x-axis: if (x1inx2) { if (yb1 < yb2) { if (yt1 > yt2) { todo.push_back(rect_type(xl1, yt2, xr1-xl1, yt1-yt2)); } yt1 = yb2; } else { yb1 = yt2; } orig_count++; continue; } // Test for rect 2 being within rect 1 along the x-axis: if (x2inx1) { if (yb2 < yb1) { if (yt2 > yt1) { original_list.insert(original_list.begin() + orig_count, rect_type(xl2, yt1, xr2-xl2, yt2-yt1)); orig_count++; } original_list[orig_count] = rect_type(xl2, yb2, xr2-xl2, yb1-yb2); } else { original_list[orig_count] = rect_type(xl2, yt1, xr2-xl2, yt2-yt1); } orig_count++; continue; } // Test for rect 1 being within rect 2 along the y-axis: if (y1iny2) { if (xl1 < xl2) { if (xr1 > xr2) { todo.push_back(rect_type(xr2, yb1, xr1-xr2, yt1-yb1)); } xr1 = xl2; } else { xl1 = xr2; } orig_count++; continue; } // Test for rect 2 being within rect 1 along the y-axis: if (y2iny1) { if (xl2 < xl1) { if (xr2 > xr1) { original_list.insert(original_list.begin() + orig_count, rect_type(xr1, yb2, xr2-xr1, yt2-yb2)); orig_count++; } original_list[orig_count] = rect_type(xl2, yb2, xl1-xl2, yt2-yb2); } else { original_list[orig_count] = rect_type(xr1, yb2, xr2-xr1, yt2-yb2); } orig_count++; continue; } // Handle a 'corner' overlap of rect 1 and rect 2: double xl, yb, xr, yt; if (xl1 < xl2) { xl = xl1; xr = xl2; } else { xl = xr2; xr = xr1; } if (yb1 < yb2) { yb = yb2; yt = yt1; yt1 = yb2; } else { yb = yb1; yt = yt2; yb1 = yt2; } todo.push_back(rect_type(xl, yb, xr-xl, yt-yb)); orig_count++; } if (use_leftover) { additional_rects.push_back(rect_type(xl1, yb1, xr1-xl1, yt1-yb1)); } todo_count++; } for (rect_list_type::iterator it = additional_rects.begin(); it != additional_rects.end(); it++) { original_list.push_back(*it); } return original_list; } bool rect_list_contains(rect_list_type &l, rect_type &r) { return (std::find(l.begin(), l.end(), r) != l.end()); } // Test code // // There are 17 types of rectangle-rectangle intersection: // 1. no intersections // 2. new rect is contained by old rect // 3. new rect surrounds old rect // 4-7. new rect overlaps one of the four corners // 8-11. new rect overlaps (but doesn't span) one of the edges // 12-15. new rect contains one of the existing edges // 16-17. new rect overlaps (but doesn't span) two opposite edges // case 1 void test_disjoint_outside() { rect_list_type cliprects; rect_type rect1(20,20,40,40); rect_type rect2(70,20,40,40); cliprects = disjoint_union(rect1, rect2); assert(cliprects.size() == 2); assert(rect_list_contains(cliprects, rect1)); assert(rect_list_contains(cliprects, rect2)); } // cases 2 and 3 void test_disjoint_2_3() { rect_list_type cliprects; rect_type bigrect(10,10,80,80); rect_type smallrect(15,15,50,10); // case 2 cliprects = disjoint_union(bigrect, smallrect); if ((cliprects.size() != 1) || (cliprects[0] != bigrect)) { printf("Error in test_disjoint_2_3(): case 2.\n"); } // case 3 cliprects = disjoint_union(smallrect, bigrect); if ((cliprects.size() != 1) || (cliprects[0] != bigrect)) { printf("Error in test_disjoint_2_3(): case 3.\n"); } } // cases 4-7 void test_disjoint_corner() { bool all_pass = false; rect_list_type cliprects; rect_type mainrect(40,40,20,20); rect_type ul(35,55,10,10); rect_type ur(55,55,10,10); rect_type ll(35,35,10,10); rect_type lr(55,35,10,10); // upper left cliprects = disjoint_union(mainrect, ul); rect_type ul_1(35, 55, 5, 5); rect_type ul_2(35, 60, 10, 5); all_pass = (cliprects.size() == 3) && rect_list_contains(cliprects, ul_1) && \ rect_list_contains(cliprects, ul_2) && rect_list_contains(cliprects, mainrect); if (!all_pass) { printf("Error in test_disjoint_corner()i: upper left\n"); } // lower left cliprects = disjoint_union(mainrect, ll); rect_type ll_1(35, 35, 10, 5); rect_type ll_2(35, 40, 5, 5); all_pass = (cliprects.size() == 3) && rect_list_contains(cliprects, ll_1) && \ rect_list_contains(cliprects, ll_2) && rect_list_contains(cliprects, mainrect); if (!all_pass) { printf("Error in test_disjoint_corner()i: upper left\n"); } // upper right cliprects = disjoint_union(mainrect, ur); rect_type ur_1(55, 60, 10, 5); rect_type ur_2(60, 55, 5, 5); all_pass = (cliprects.size() == 3) && rect_list_contains(cliprects, ur_1) && \ rect_list_contains(cliprects, ur_2) && rect_list_contains(cliprects, mainrect); if (!all_pass) { printf("Error in test_disjoint_corner()i: upper right\n"); } // lower right cliprects = disjoint_union(mainrect, lr); rect_type lr_1(55, 35, 10, 5); rect_type lr_2(60, 40, 5, 5); all_pass = (cliprects.size() == 3) && rect_list_contains(cliprects, lr_1) && \ rect_list_contains(cliprects, lr_2) && rect_list_contains(cliprects, mainrect); if (!all_pass) { printf("Error in test_disjoint_corner()i: lower right\n"); } } // cases 8-11 void test_disjoint_edge_overlap() { return; //rect_list_type cliprects; //rect_type mainrect(40,40,20,20); } void test_disjoint_union() { test_disjoint_outside(); test_disjoint_2_3(); test_disjoint_corner(); } } // end namespace kiva enthought-chaco2-4.5.1.orig/kiva/agg/src/swig_questions.txt0000644000175000017500000001475312516137326023015 0ustar varunvarun1. Shouldn't the std_string.i have typemaps for std::string* in them? Currently, public members of a class with type std::string are not converted automatically by SWIG. // file: std_string_ex.py %module foo %include "std_string.i" %{ class foo { public: std::string bar; foo() { bar = "bar"; } }; %} class foo { public: std::string bar; }; C:\wrk\chaco_all\kiva\agg\src>swig -c++ -python -shadow std_string_ex.py C:\wrk\chaco_all\kiva\agg\src>g++ -shared -Ic:/Python22/include std_string_ex_wrap.cxx -Lc:/Python22/libs -lpython22 -o _foo.dll C:\wrk\chaco_all\kiva\agg\src>python Enthought Edition 1.0a1 based on Python 2.2.3 (#42, Jun 4 2003, 10:33:42) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import foo >>> q = foo.foo() >>> q.bar '_b8498c00_p_std__string' Adding the following typemaps to the file fixes this issue: %typemap(python,in) std::string * { if (PyString_Check ($input)) { $1 = new std::string((char *)PyString_AsString($input)); } else { PyErr_SetString (PyExc_TypeError, "not a String"); return NULL; } } %typemap(python,out) std::string * { $result = PyString_FromString((const char *)$1->c_str()); } %typemap (python, freearg) std::string * { if ($1) { delete $1; } } C:\wrk\chaco_all\kiva\agg\src>swig -c++ -python -shadow std_string_ex.py C:\wrk\chaco_all\kiva\agg\src>g++ -shared -Ic:/Python22/include std_string_ex_wrap.cxx -Lc:/Python22/libs -lpython22 -o _foo.dll C:\wrk\chaco_all\kiva\agg\src>python Enthought Edition 1.0a1 based on Python 2.2.3 (#42, Jun 4 2003, 10:33:42) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import foo >>> q = foo.foo() >>> q.bar 'bar' Is there a downside to adding these? Perhaps they should be declared as memberin and memberout ?? 2. How do you add a new constructor to a class? I would like to modify a class that takes foo(double, double, double, double, double, double) so that it can be initialized through a Numeric array with 6 elements. I haven't gotten very far. I tried doing the following: // file: affine_matrix.i %{ #include "Numeric/arrayobject.h" #include "agg_affine_matrix.h" agg::affine_matrix* new_affine_matrix(double ary[6]) { agg::affine_matrix* result = new agg::affine_matrix(ary[0], ary[1], ary[2], ary[3], ary[4], ary[5]); return result; } } %} %typemap(in) (double ary[6]) { // !! cheap and cheerful -- add checks later PyArrayObject* ary = (PyArrayObject*) $input; $1 = (double*) ary->data; } %include "agg_affine_matrix.h" %extend agg::affine_matrix { // constructors from array affine_matrix(double ary[6]); // also tried // agg::affine_matrix(double ary[6]); } Unfortunately, the constructor wasn't added into the logic for overloaded constructor searches in the generated code. Where am I going wrong here? My temporary fix has been to create a helper function and use it when I want to create an affine_matrix abject from an array: %{ #include "Numeric/arrayobject.h" #include "agg_affine_matrix.h" agg::affine_matrix* affine_from_array(double ary[6]) { return new agg::affine_matrix(ary[0], ary[1], ary[2], ary[3], ary[4], ary[5]); } %} // constructors from sequences %typemap(python,in) (double ary[6]) { // !! cheap and cheerful -- add checks later PyArrayObject* ary = (PyArrayObject*) $input; $1 = (double*) ary->data; } %include "agg_affine_matrix.h" agg::affine_matrix* affine_from_array(double ary[6]); Not elegant, but it works: C:\wrk\chaco_all\kiva\agg\src>python Enthought Edition 1.0a1 based on Python 2.2.3 (#42, Jun 4 2003, 10:33:42) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from Numeric import * >>> import agg >>> agg.affine_from_array >>> agg.affine_from_array(array((1,2,3,4,5,6.))) affine_matrix(1,2,3,4,5,6) 3. The following is an improved typemap for sequence->array conversion found in 19.5.5 of the SWIG manual as it handles coersion of values that can be converted to floats. // Map a Python sequence into any sized C double array // This handles arrays and sequences with non-float values correctly. %typemap(in) double[ANY](double temp[$1_dim0]) { int i; if (!PySequence_Check($input)) { PyErr_SetString(PyExc_TypeError,"Expecting a sequence"); return NULL; } if (PyObject_Length($input) != $1_dim0) { PyErr_SetString(PyExc_ValueError,"Expecting a sequence with $1_dim0 elements"); return NULL; } for (i =0; i < $1_dim0; i++) { PyObject *o = PySequence_GetItem($input,i); if (PyFloat_Check(o)) { temp[i] = PyFloat_AsDouble(o); } else { PyObject* converted = PyNumber_Float(o); if (!converted) { PyErr_SetString(PyExc_ValueError,"Expecting a sequence of floats"); return NULL; } temp[i] = PyFloat_AsDouble(converted); Py_DECREF(converted); } else } $1 = &temp[0]; } 3. Something is broken on my const affine_matrix& operator *=(const affine_matrix& other) { } wrappers. It appears that whenever affine_matrix& is returned, the this and thisown pointers are getting goofed up because affine_matrix destructors are being called (and therefore clobbering memory) at times when they shouldn't... 4. Immutable data members should emit an error when the user tries to set them. Currently they are silent... enthought-chaco2-4.5.1.orig/kiva/agg/src/constants.i0000644000175000017500000001204612516137326021350 0ustar varunvarun///////////////////////////////////////////////////////////////////////////// // // 1) Wraps constants and enumerated types commonly used in agg and kiva. // 2) Provides typemaps to accpet integer inputs for enumerated types. // 3) Provides python dictionaries to map back and forth between enumerated // types and more descriptive strings that can be used in python. // // A number of constants (and some functions and types) are defined in // agg_basics.h and kiva_constants.h. // // agg_renderer_markers.h is used for rendering simple shapes at multiple // data points. It is useful for generating scatter plots in simple cases. // This wrapper is used to pick up the enumerated types for markers such // as marker_square, marker_circle, etc. The only classes in the header are // template definitions so they are all ignored by swig. // // ///////////////////////////////////////////////////////////////////////////// %{ #include "agg_basics.h" #include "kiva_constants.h" #include "agg_renderer_markers.h" %} %include "agg_basics.h" %include "kiva_constants.h" %include "agg_renderer_markers.h" %{ inline unsigned path_cmd(unsigned c) { return c & agg24::path_cmd_mask; } inline unsigned path_flags(unsigned c) { return c & agg24::path_flags_mask; } %} %include "agg_typemaps.i" %apply(kiva_enum_typemap) { agg24::path_flags_e }; %apply(kiva_enum_typemap) { agg24::marker_e }; %apply(kiva_enum_typemap) { kiva::draw_mode_e mode, kiva::text_draw_mode_e, kiva::line_join_e, kiva::line_cap_e, kiva::blend_mode_e }; %apply(kiva_enum_typemap) { kiva::pix_format_e, kiva::interpolation_e }; %apply(kiva_enum_typemap) { kiva::blend_mode_e mode}; unsigned path_cmd(unsigned c); unsigned path_flags(unsigned c); %pythoncode { #---------------------------------------------------------------------------- # # map strings values to the marker enumerated values and back with: # marker_string_map[string] = enum # marker_enum_map[enum] = string # #---------------------------------------------------------------------------- kiva_marker_to_agg = {} kiva_marker_to_agg[1] = marker_square kiva_marker_to_agg[2] = marker_diamond kiva_marker_to_agg[3] = marker_circle kiva_marker_to_agg[4] = marker_crossed_circle kiva_marker_to_agg[5] = marker_x kiva_marker_to_agg[6] = marker_triangle_up kiva_marker_to_agg[7] = marker_triangle_down kiva_marker_to_agg[8] = marker_cross # "plus" sign; Agg calls this "cross" kiva_marker_to_agg[9] = marker_dot kiva_marker_to_agg[10] = marker_pixel #---------------------------------------------------------------------------- # # Map strings values to the pix_format enumerated values and back with: # pix_format_string_map[string] = enum # pix_format_enum_map[enum] = string # #---------------------------------------------------------------------------- pix_format_string_map = {} pix_format_string_map["gray8"] = pix_format_gray8 pix_format_string_map["rgb555"] = pix_format_rgb555 pix_format_string_map["rgb565"] = pix_format_rgb565 pix_format_string_map["rgb24"] = pix_format_rgb24 pix_format_string_map["bgr24"] = pix_format_bgr24 pix_format_string_map["rgba32"] = pix_format_rgba32 pix_format_string_map["argb32"] = pix_format_argb32 pix_format_string_map["abgr32"] = pix_format_abgr32 pix_format_string_map["bgra32"] = pix_format_bgra32 pix_format_enum_map = {} for key,value in pix_format_string_map.items(): pix_format_enum_map[value] = key #---------------------------------------------------------------------------- # Map a pix format string value to the number of bytes per pixel #---------------------------------------------------------------------------- pix_format_bytes = {} pix_format_bytes["gray8"] = 1 pix_format_bytes["rgb555"] = 2 pix_format_bytes["rgb565"] = 2 pix_format_bytes["rgb24"] = 3 pix_format_bytes["bgr24"] = 3 pix_format_bytes["rgba32"] = 4 pix_format_bytes["argb32"] = 4 pix_format_bytes["abgr32"] = 4 pix_format_bytes["bgra32"] = 4 pix_format_bits = {} pix_format_bits["gray8"] = 8 pix_format_bits["rgb555"] = 15 pix_format_bits["rgb565"] = 16 pix_format_bits["rgb24"] = 24 pix_format_bits["bgr24"] = 24 pix_format_bits["rgba32"] = 32 pix_format_bits["argb32"] = 32 pix_format_bits["abgr32"] = 32 pix_format_bits["bgra32"] = 32 #---------------------------------------------------------------------------- # # Map strings values to the interpolation enumerated values and back with: # interp_string_map[string] = enum # interp_enum_map[enum] = string # #---------------------------------------------------------------------------- interp_string_map = {} interp_string_map["nearest"] = nearest interp_string_map["bilinear"] = bilinear interp_string_map["bicubic"] = bicubic interp_string_map["spline16"] = spline16 interp_string_map["spline36"] = spline36 interp_string_map["sinc64"] = sinc64 interp_string_map["sinc144"] = sinc144 interp_string_map["sinc256"] = sinc256 interp_string_map["blackman64"] = blackman64 interp_string_map["blackman100"] = blackman100 interp_string_map["blackman256"] = blackman256 interp_enum_map = {} for key,value in interp_string_map.items(): interp_enum_map[value] = key } enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_graphics_context_base.h0000644000175000017500000003240012516137326024677 0ustar varunvarun#ifndef KIVA_GRAPHICS_CONTEXT_BASE_H #define KIVA_GRAPHICS_CONTEXT_BASE_H #define KIVA_USE_FREETYPE #ifdef KIVA_USE_FREETYPE #include "agg_font_freetype.h" #endif #ifdef KIVA_USE_WIN32 #include "agg_font_win32_tt.h" #endif #include #include #include "agg_basics.h" #include "agg_color_rgba.h" #include "agg_rendering_buffer.h" #include "agg_renderer_markers.h" #include "kiva_constants.h" #include "kiva_pix_format.h" #include "kiva_rect.h" #include "kiva_graphics_state.h" #include "kiva_affine_helpers.h" // text includes #include "agg_glyph_raster_bin.h" #include "agg_renderer_scanline.h" #include "agg_renderer_raster_text.h" #include "agg_embedded_raster_fonts.h" #include "agg_font_cache_manager.h" namespace kiva { #ifdef KIVA_USE_FREETYPE typedef agg24::font_engine_freetype_int32 font_engine_type; #endif #ifdef KIVA_USE_WIN32 typedef agg24::font_engine_win32_tt_int32 font_engine_type; #endif typedef agg24::font_cache_manager font_manager_type; font_engine_type* GlobalFontEngine(); font_manager_type* GlobalFontManager(); void cleanup_font_threading_primitives(); class graphics_context_base { public: // The current path. This also includes the ctm. kiva::compiled_path path; // The text matrix is *not* part of the graphics state. agg24::trans_affine text_matrix; kiva::graphics_state state; std::stack state_stack; agg24::rendering_buffer buf; // fix me: Not sure this should be here, but, putting it here completely // unifies images and graphics contexts. // (TODO-PZW: revisit this) kiva::interpolation_e _image_interpolation; // text handling. graphics_context_base(unsigned char *data, int width, int height, int stride, kiva::interpolation_e interp); virtual ~graphics_context_base(); int width(); int height(); int stride(); int bottom_up(); virtual kiva::pix_format_e format() = 0; agg24::rendering_buffer* rendering_buffer_ptr(); kiva::interpolation_e get_image_interpolation(); void set_image_interpolation(interpolation_e interpolation); //--------------------------------------------------------------- // set graphics_state values //--------------------------------------------------------------- void set_stroke_color(agg24::rgba& value); agg24::rgba& get_stroke_color(); // TODO-PZW: do we need corresponding get() functions for // all of the following? void set_line_width(double value); void set_line_join(line_join_e value); void set_line_cap(line_cap_e value); void set_line_dash(double* pattern, int n, double phase=0); // fix me: Blend mode is *barely* supported and // probably abused (my copy setting). void set_blend_mode(blend_mode_e value); kiva::blend_mode_e get_blend_mode(); void set_fill_color(agg24::rgba& value); // need get method for freetype renderer. // should I return a reference?? agg24::rgba& get_fill_color(); // need get method for freetype renderer. // fix me: Is the get method still needed? void set_alpha(double value); double get_alpha(); // need get method for freetype renderer. // fix me: Is the get method still needed? void set_antialias(int value); int get_antialias(); // TODO-PZW: get() functions needed? void set_miter_limit(double value); void set_flatness(double value); //--------------------------------------------------------------- // text and font functions //--------------------------------------------------------------- // Text drawing information needs to have get/set methods void set_text_position(double tx, double ty); void get_text_position(double* tx, double* ty); void set_text_matrix(agg24::trans_affine& value); agg24::trans_affine get_text_matrix(); void set_character_spacing(double value); double get_character_spacing(); void set_text_drawing_mode(text_draw_mode_e value); // The following methods all return true if successful and false // otherwise. bool set_font(kiva::font_type& font); bool is_font_initialized(); bool set_font_size(int size); virtual bool show_text(char *text)=0; bool show_text_at_point(char *text, double tx, double ty); // This will always return a font_type object. The font's // is_loaded() method should be checked to see if the font is valid. kiva::font_type& get_font(); // Returns a rectangle representing the bounds of the text string. // The rectangle is measured in the transformed space of the text // itself, and its origin is not necessarily 0,0 (for fonts with // overhanging glyphs). // is_font_initialized() should be checked to make sure the font // has been properly loaded and initialized. kiva::rect_type get_text_extent(char *text); bool get_text_bbox_as_rect(char *text); //--------------------------------------------------------------- // save/restore graphics state //--------------------------------------------------------------- void save_state(); virtual void restore_state() = 0; //--------------------------------------------------------------- // coordinate transform matrix transforms //--------------------------------------------------------------- void translate_ctm(double x, double y); void rotate_ctm(double angle); void scale_ctm(double sx, double sy); void concat_ctm(agg24::trans_affine& m); void set_ctm(agg24::trans_affine& m); agg24::trans_affine get_ctm(); void get_freetype_text_matrix(double* out); //--------------------------------------------------------------- // Sending drawing data to a device //--------------------------------------------------------------- void flush(); void synchronize(); //--------------------------------------------------------------- // Page Definitions //--------------------------------------------------------------- void begin_page(); void end_page(); //--------------------------------------------------------------- // Path operations //--------------------------------------------------------------- void begin_path(); void move_to(double x, double y); void line_to( double x, double y); void curve_to(double cpx1, double cpy1, double cpx2, double cpy2, double x, double y); void quad_curve_to(double cpx, double cpy, double x, double y); // arc() and arc_to() draw circular segments. When the arc // is added to the current path, it may become an elliptical // arc depending on the CTM. // Draws a circular segment centered at the point (x,y) with the // given radius. void arc(double x, double y, double radius, double start_angle, double end_angle, bool cw=false); // Sweeps a circular arc from the pen position to a point on the // line from (x1,y1) to (x2,y2). // The arc is tangent to the line from the current pen position // to (x1,y1), and it is also tangent to the line from (x1,y1) // to (x2,y2). (x1,y1) is the imaginary intersection point of // the two lines tangent to the arc at the current point and // at (x2,y2). // If the tangent point on the line from the current pen position // to (x1,y1) is not equal to the current pen position, a line is // drawn to it. Depending on the supplied radius, the tangent // point on the line fron (x1,y1) to (x2,y2) may or may not be // (x2,y2). In either case, the arc is drawn to the point of // tangency, which is also the new pen position. // // Consider the common case of rounding a rectangle's upper left // corner. Let "r" be the radius of rounding. Let the current // pen position be (x_left + r, y_top). Then (x2,y2) would be // (x_left, y_top - radius), and (x1,y1) would be (x_left, y_top). void arc_to(double x1, double y1, double x2, double y2, double radius); void close_path(); void add_path(kiva::compiled_path& other_path); compiled_path _get_path(); kiva::rect_type _get_path_bounds(); void lines(double* pts, int Npts); void line_set(double* start, int Nstart, double* end, int Nend); void rect(double x, double y, double sx, double sy); void rect(kiva::rect_type &rect); void rects(double* all_rects, int Nrects); void rects(kiva::rect_list_type &rectlist); agg24::path_storage boundary_path(agg24::trans_affine& affine_mtx); //--------------------------------------------------------------- // Clipping path manipulation //--------------------------------------------------------------- virtual void clip() = 0; virtual void even_odd_clip() = 0; virtual void clip_to_rect(double x, double y, double sx, double sy) = 0; virtual void clip_to_rect(kiva::rect_type &rect) = 0; virtual void clip_to_rects(double* new_rects, int Nrects) = 0; virtual void clip_to_rects(kiva::rect_list_type &rects) = 0; virtual void clear_clip_path() = 0; // The following two are meant for debugging purposes, and are not part // of the formal interface for GraphicsContexts. virtual int get_num_clip_regions() = 0; virtual kiva::rect_type get_clip_region(unsigned int i) = 0; //--------------------------------------------------------------- // Painting paths (drawing and filling contours) //--------------------------------------------------------------- virtual void clear(agg24::rgba value=agg24::rgba(1,1,1,1)) = 0; //virtual void clear(double alpha) = 0; virtual void fill_path() = 0; virtual void eof_fill_path() = 0; virtual void stroke_path() = 0; virtual void _stroke_path() = 0; virtual void draw_path(draw_mode_e mode=FILL_STROKE) = 0; virtual void draw_rect(double rect[4], draw_mode_e mode=FILL_STROKE) = 0; // Draw a marker at all the points in the list. This is a // very fast function that only works in special cases. // The succeeds if the line_width != 0.0 or 1.0, the line_join // is set to JOIN_MITER (!! NOT CURRENTLY ENFORCED), and the // ctm only has translational components. // // Typically this is called before trying the more general // draw_path_at_points() command. It is typically 5-10 times // faster. // // Returns: int // 0 on failure // 1 on success virtual int draw_marker_at_points(double* pts,int Npts,int size, agg24::marker_e type=agg24::marker_square) = 0; virtual void draw_path_at_points(double* pts,int Npts, kiva::compiled_path& marker, draw_mode_e mode) = 0; //--------------------------------------------------------------- // Image handling //--------------------------------------------------------------- // Draws an image into the rectangle specified as (x, y, width, height); // The image is scaled and/or stretched to fit inside the rectangle area // specified. virtual int draw_image(kiva::graphics_context_base* img, double rect[4], bool force_copy=false) = 0; int draw_image(kiva::graphics_context_base* img); // fix me: This is a temporary fix to help with speed issues in draw image. // WE SHOULD GET RID OF IT AND SUPPORT DRAWING MODES. //virtual int copy_image(kiva::graphics_context_base* img, int tx, int ty); //--------------------------------------------------------------------- // Gradient support //--------------------------------------------------------------------- // // // virtual void linear_gradient(double x1, double y1, double x2, double y2, std::vector stops, const char* spread_method, const char* units="userSpaceOnUse"); // // // virtual void radial_gradient(double cx, double cy, double r, double fx, double fy, std::vector stops, const char* spread_method, const char* units="userSpaceOnUse"); protected: // Grabs and configure the font engine with the settings on our current // state's font object. void _grab_font_manager(); void _release_font_manager(); bool _is_font_initialized; }; } #endif /* KIVA_GRAPHICS_CONTEXT_BASE_H */ enthought-chaco2-4.5.1.orig/kiva/agg/src/tst_convert.py0000644000175000017500000000014512516137326022103 0ustar varunvarunimport agg q=agg.Image((10,10),pix_format="rgb24") q.convert_pixel_format("rgba32") print q.format() enthought-chaco2-4.5.1.orig/kiva/agg/src/gl_graphics_context.h0000644000175000017500000001337012516137326023362 0ustar varunvarun#ifndef KIVA_GL_GRAPHICS_CONTEXT_H #define KIVA_GL_GRAPHICS_CONTEXT_H #ifdef _MSC_VER #pragma warning(disable:4786) #endif #ifdef __DARWIN__ #include #include #else #ifdef _MSC_VER #include #endif #include #include // The following mechanism is necessary in order to use MultiDrawElements // on Windows with mingw. // 11/24/2010: glMultiDrawElements is not being used right now in the GL // backend, so comment this out for the time being, especially since it // causes build problems with 64-bit mingw. //#ifdef __MINGW32__ // #define GL_GLEXT_PROTOTYPES 1 // #include // #define MULTI_DRAW_ELEMENTS glMultiDrawElementsEXT //#endif #endif #include "agg_basics.h" #include "kiva_compiled_path.h" #include "kiva_graphics_context_base.h" #include "kiva_pix_format.h" namespace kiva { // This function pointer is used by various draw_marker functions class gl_graphics_context; typedef void(gl_graphics_context::* PathDefinitionFunc)(int); class gl_graphics_context : public graphics_context_base { public: gl_graphics_context(int width, int height, kiva::pix_format_e format=kiva::pix_format_rgb24); ~gl_graphics_context(); //--------------------------------------------------------------- // GL-specific methods //--------------------------------------------------------------- void gl_init(); void gl_cleanup(); void begin_page(); void gl_render_path(kiva::compiled_path *path, bool polygon=false, bool fill=false); void gl_render_points(double** points, bool polygon, bool fill, kiva::draw_mode_e mode = FILL); //--------------------------------------------------------------- // GraphicsContextBase interface //--------------------------------------------------------------- kiva::pix_format_e format(); void save_state(); void restore_state(); //--------------------------------------------------------------- // Clipping path manipulation //--------------------------------------------------------------- void clip(); void even_odd_clip(); void clip_to_rect(double x, double y, double sx, double sy); void clip_to_rect(kiva::rect_type &rect); void clip_to_rects(double* new_rects, int Nrects); void clip_to_rects(kiva::rect_list_type &rects); kiva::rect_type transform_clip_rectangle(const kiva::rect_type &rect); void clear_clip_path(); int get_num_clip_regions(); kiva::rect_type get_clip_region(unsigned int i); //--------------------------------------------------------------- // Painting paths (drawing and filling contours) //--------------------------------------------------------------- void clear(agg24::rgba value=agg24::rgba(1,1,1,1)); void fill_path(); void eof_fill_path(); void stroke_path(); // empty function; for some reason this is abstract in the base class inline void _stroke_path() { } void draw_path(draw_mode_e mode=FILL_STROKE); void draw_rect(double rect[4], draw_mode_e mode=FILL_STROKE); int draw_marker_at_points(double* pts,int Npts,int size, agg24::marker_e type=agg24::marker_square); void draw_path_at_points(double* pts,int Npts, kiva::compiled_path& marker, draw_mode_e mode); inline bool show_text(char *text) { return false; } void draw_glyphs(kiva::graphics_context_base* img, double tx, double ty); int draw_image(kiva::graphics_context_base* img, double rect[4], bool force_copy=false); int draw_image(kiva::graphics_context_base* img); protected: void draw_display_list_at_pts(GLuint list, double *pts, int Npts, kiva::draw_mode_e mode, double x0, double y0); void draw_display_list_at_pts(GLuint fill_list, GLuint stroke_list, double *pts, int Npts, kiva::draw_mode_e mode, double x0, double y0); // Given a path function, returns two OpenGL display lists representing // the list to fill and the list to stroke. The caller is responsible // for calling glDeleteLists on the two. // Only the list name of the first list (fill list) will be returned; // the stroke list can be accessed by just adding 1. GLuint make_marker_lists(kiva::PathDefinitionFunc path_func, kiva::draw_mode_e mode, int size); void circle_path_func(int size); void triangle_up_func(int size); void triangle_down_func(int size); void draw_square(double *pts, int Npts, int size, kiva::draw_mode_e mode, double x0, double y0); void draw_diamond(double *pts, int Npts, int size, kiva::draw_mode_e mode, double x0, double y0); void draw_crossed_circle(double *pts, int Npts, int size, kiva::draw_mode_e mode, double x0, double y0); void draw_x_marker(double *pts, int Npts, int size, kiva::draw_mode_e mode, double x0, double y0); void draw_cross(double *pts, int Npts, int size, kiva::draw_mode_e mode, double x0, double y0); void draw_dot(double *pts, int Npts, int size, kiva::draw_mode_e mode, double x0, double y0); void draw_pixel(double *pts, int Npts, int size, kiva::draw_mode_e mode, double x0, double y0); private: int m_width; int m_height; bool m_gl_initialized; kiva::pix_format_e m_pixfmt; }; } #endif /* KIVA_GL_GRAPHICS_CONTEXT_H */ enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_graphics_context.h0000644000175000017500000016561212516137326023721 0ustar varunvarun#ifndef KIVA_GRAPHICS_CONTEXT_H #define KIVA_GRAPHICS_CONTEXT_H #ifdef _MSC_VER // Turn off MSDEV warning about truncated long identifiers #pragma warning(disable:4786) #endif #include #include #include #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) #include #endif #include #include #include #include "agg_trans_affine.h" #include "agg_path_storage.h" #include "agg_conv_stroke.h" #include "agg_conv_dash.h" #include "agg_conv_curve.h" #include "agg_conv_clip_polygon.h" #include "agg_conv_clip_polyline.h" #include "agg_span_allocator.h" #include "agg_span_converter.h" #include "kiva_image_filters.h" #include "agg_scanline_u.h" #include "agg_scanline_bin.h" #include "agg_scanline_p.h" #include "agg_renderer_mclip.h" #include "agg_renderer_scanline.h" #include "agg_renderer_outline_aa.h" #include "agg_renderer_primitives.h" #include "agg_rasterizer_outline.h" #include "agg_rasterizer_outline_aa.h" #include "agg_rasterizer_scanline_aa.h" #include "agg_span_gradient.h" #include "kiva_image_filters.h" #include "kiva_dash_type.h" #include "kiva_compiled_path.h" #include "kiva_font_type.h" #include "kiva_pix_format.h" #include "kiva_exceptions.h" #include "kiva_graphics_context_base.h" #include "kiva_alpha_gamma.h" #include "kiva_gradient.h" namespace kiva { template class graphics_context : public graphics_context_base { // agg_pixfmt has low level rendering commands (hspan, etc.) // This really should be a template parameter //typedef agg24::pixfmt_bgra32 agg_pixfmt; public: agg_pixfmt renderer_pixfmt; private: // The next level of renderer adds clipping to the low level // pixfmt object (renderer). This is what attaches to a // rendering buffer. // The multi-clip renderer uses the single clip inside it, // so there is no need to define both and do our own switching. //typedef agg24::renderer_base renderer_base_type; typedef agg24::renderer_mclip renderer_base_type; renderer_base_type renderer; public: //--------------------------------------------------------------- // constructor //--------------------------------------------------------------- graphics_context(unsigned char *data, int width, int height, int stride, kiva::interpolation_e interp=nearest); ~graphics_context() { } // TODO: write copy constructor kiva::pix_format_e format(); void restore_state(); //--------------------------------------------------------------- // Clipping path manipulation //--------------------------------------------------------------- // Clips to the current path. If the current path is empty, // does nothing. void clip(); void even_odd_clip(); // clip_to_rect() expects an array of doubles (x1,y1,x2,y2); // clip_to_rects() expects a repeated array of these. void clip_to_rect(double x, double y, double sx, double sy); void clip_to_rect(kiva::rect_type &rect); // Computes the (possibly disjoint) union of the input rectangles // and clips to them. NOTE that this is not the same thing as // simply calling clip_to_rect() on each rectangle separately! void clip_to_rects(double* new_rects, int Nrects); void clip_to_rects(kiva::rect_list_type &rects); void clear_clip_path(); int get_num_clip_regions(); kiva::rect_type get_clip_region(unsigned int i); //--------------------------------------------------------------- // Painting paths (drawing and filling contours) //--------------------------------------------------------------- void clear(agg24::rgba value=agg24::rgba(1,1,1,1)); void clear(double alpha); void draw_path(draw_mode_e mode=FILL_STROKE); void draw_rect(double rect[4], draw_mode_e mode=FILL_STROKE); int draw_marker_at_points(double* pts,int Npts,int size, agg24::marker_e type=agg24::marker_square); void draw_path_at_points(double* pts,int Npts, kiva::compiled_path& marker, draw_mode_e mode); //--------------------------------------------------------------- // Text handling //--------------------------------------------------------------- bool show_text(char *text); //--------------------------------------------------------------- // Image handling //--------------------------------------------------------------- void draw_glyphs(kiva::graphics_context_base* img, double tx, double ty); int draw_image(kiva::graphics_context_base* img, double rect[4], bool force_copy=false); private: int blend_image(kiva::graphics_context_base* img, int tx, int ty); int copy_image(kiva::graphics_context_base* img, int tx, int ty); int transform_image(kiva::graphics_context_base* img, agg24::trans_affine& img_mtx); private: // Transforms a clipping rectangle into device coordinates. kiva::rect_type transform_clip_rectangle(const kiva::rect_type &rect); public: //-------------------------------------------------------------------- // Stroke Path Pipeline. // // See implementation_notes.txt for details. //-------------------------------------------------------------------- void stroke_path() { this->_stroke_path(); this->path.remove_all(); } private: void _stroke_path() { // 1. Choose whether to do a curve conversion or not. // 2. Pick whether the line is dashed. // short circuit for transparent or 0 width lines if (this->state.line_color.a == 0 || this->state.line_width == 0.0) return; if (!this->path.has_curves()) { this->stroke_path_dash_conversion(this->path); } else { agg24::conv_curve curved_path(this->path); this->stroke_path_dash_conversion(curved_path); } } private: template void stroke_path_dash_conversion(path_type& input_path) { if (this->state.line_dash.is_solid()) { this->stroke_path_choose_clipping_renderer(input_path); } else { agg24::conv_dash dashed_path(input_path); std::vector &pattern = this->state.line_dash.pattern; // pattern always has even length for(unsigned int i = 0; i < pattern.size(); i+=2) { dashed_path.add_dash(pattern[i], pattern[i+1]); } dashed_path.dash_start(this->state.line_dash.phase); this->stroke_path_choose_clipping_renderer(dashed_path); } } private: template void stroke_path_choose_clipping_renderer(path_type& input_path) { agg24::conv_clip_polyline clipped(input_path); // fix me: We can do this more intelligently based on the current clip path. // fix me: What coordinates should this be in? I think in user space instead // of device space. This looks wrong... clipped.clip_box(0,0, this->buf.width(), this->buf.height()); // fix me: We should be doing a vector clip of the path as well. // where is this step? // fix me: pick the renderer type (clipping, etc.) if(1) { this->stroke_path_choose_rasterizer(clipped, this->renderer); } else { // fix me: pick the renderer type (clipping, etc.) } } private: template void stroke_path_choose_rasterizer(path_type& input_path, renderer_type& input_renderer) { if (!this->state.should_antialias) { if ( this->state.line_width <= 1.0) { // ignore cap and join type here. this->stroke_path_outline(input_path, input_renderer); } // 2005-04-01: the AGG outline_aa rasterizer has a bug in it; // Go with the slower scanline_aa rasterizer until it's fixed // in AGG. // else if ( this->state.line_width <=10.0 && // (this->state.line_cap == CAP_ROUND || // this->state.line_cap == CAP_BUTT) && // this->state.line_join == JOIN_MITER) // { // // fix me: how to force this to be aliased??? // this->stroke_path_outline_aa(input_path, input_renderer); // } else { // fix me: This appears to be anti-aliased still. typedef agg24::renderer_scanline_bin_solid renderer_bin_type; renderer_bin_type renderer(input_renderer); agg24::scanline_bin scanline; this->stroke_path_scanline_aa(input_path, renderer, scanline); } } else // anti-aliased { // if ( (this->state.line_cap == CAP_ROUND || this->state.line_cap == CAP_BUTT) && // this->state.line_join == JOIN_MITER) // { // this->stroke_path_outline_aa(input_path, input_renderer); // } // else // { typedef agg24::renderer_scanline_aa_solid renderer_aa_type; renderer_aa_type renderer(input_renderer); agg24::scanline_u8 scanline; this->stroke_path_scanline_aa(input_path, renderer, scanline); // } } } private: template void stroke_path_outline(path_type& input_path, renderer_type& input_renderer) { typedef agg24::renderer_primitives primitives_renderer_type; typedef agg24::rasterizer_outline rasterizer_type; primitives_renderer_type primitives_renderer(input_renderer); // set line color -- multiply by alpha if it is set. agg24::rgba color; color = this->state.line_color; color.a *= this->state.alpha; primitives_renderer.line_color(color); rasterizer_type rasterizer(primitives_renderer); rasterizer.add_path(input_path); } private: template void stroke_path_outline_aa(path_type& input_path, renderer_type& input_renderer) { // fix me: How do you render aliased lines with this? // rasterizer_outline_aa algorithm only works for // CAP_ROUND or CAP_BUTT. It also only works for JOIN_MITER typedef agg24::renderer_outline_aa outline_renderer_type; typedef agg24::rasterizer_outline_aa rasterizer_type; // fix me: scale width by ctm agg24::line_profile_aa profile(this->state.line_width, agg24::gamma_none()); outline_renderer_type renderer(input_renderer, profile); // set line color -- multiply by alpha if it is set. agg24::rgba color; color = this->state.line_color; color.a *= this->state.alpha; renderer.color(color); rasterizer_type rasterizer(renderer); if (this->state.line_cap == CAP_ROUND) { rasterizer.round_cap(true); } else if (this->state.line_cap == CAP_BUTT) { //default behavior } // fix me: not sure about the setting for this... rasterizer.accurate_join(true); rasterizer.add_path(input_path); } private: template void stroke_path_scanline_aa(path_type& input_path, renderer_type& renderer, scanline_type& scanline) { agg24::rasterizer_scanline_aa<> rasterizer; agg24::conv_stroke stroked_path(input_path); // fix me: scale width by ctm stroked_path.width(this->state.line_width); // handle line cap agg24::line_cap_e cap = agg24::butt_cap; if (this->state.line_cap == CAP_ROUND) { cap = agg24::round_cap; } else if (this->state.line_cap == CAP_BUTT) { cap = agg24::butt_cap; } else if (this->state.line_cap == CAP_SQUARE) { cap = agg24::square_cap; } stroked_path.line_cap(cap); // handle join agg24::line_join_e join = agg24::miter_join; if (this->state.line_join == JOIN_MITER) { join = agg24::miter_join; } else if (this->state.line_join == JOIN_ROUND) { join = agg24::round_join; } else if (this->state.line_join == JOIN_BEVEL) { join = agg24::bevel_join; } stroked_path.line_join(join); // set line color -- multiply by alpha if it is set. agg24::rgba color; color = this->state.line_color; color.a *= this->state.alpha; renderer.color(color); // render rasterizer.add_path(stroked_path); agg24::render_scanlines(rasterizer, scanline, renderer); } //-------------------------------------------------------------------- // Fill Path Pipeline. // // See implementation_notes.txt for details. //-------------------------------------------------------------------- public: void fill_path() { this->_fill_path(agg24::fill_non_zero); this->path.remove_all(); } public: void eof_fill_path() { this->_fill_path(agg24::fill_even_odd); this->path.remove_all(); } private: void _fill_path(agg24::filling_rule_e rule) { // 1. Choose whether to do a curve conversion or not. // 2. Pick whether the line is dashed. // short circuit for transparent if (this->state.fill_color.a == 0) return; if (!this->path.has_curves()) { this->fill_path_clip_conversion(this->path, rule); } else { agg24::conv_curve curved_path(this->path); this->fill_path_clip_conversion(curved_path, rule); } } //--------------------------------------------------------------------- // Gradient support //--------------------------------------------------------------------- void linear_gradient(double x1, double y1, double x2, double y2, std::vector stops, const char* spread_method, const char* units="userSpaceOnUse") { typedef std::pair point_type; std::vector stops_list; std::vector points; if (strcmp(units, "objectBoundingBox") == 0) { // Transform from relative coordinates kiva::rect_type const clip_rect = _get_path_bounds(); x1 = clip_rect.x + x1 * clip_rect.w; x2 = clip_rect.x + x2 * clip_rect.w; y1 = clip_rect.y + y1 * clip_rect.h; y2 = clip_rect.y + y2 * clip_rect.h; } points.push_back(point_type(x1, y1)); points.push_back(point_type(x2, y2)); this->state.gradient_fill = gradient(kiva::grad_linear, points, stops, spread_method, units); this->state.gradient_fill.set_ctm(this->get_ctm()); } void radial_gradient(double cx, double cy, double r, double fx, double fy, std::vector stops, const char* spread_method, const char* units="userSpaceOnUse") { typedef std::pair point_type; std::vector points; if (strcmp(units, "objectBoundingBox") == 0) { // Transform from relative coordinates kiva::rect_type const clip_rect = _get_path_bounds(); r = r * clip_rect.w; cx = clip_rect.x + cx * clip_rect.w; fx = clip_rect.x + fx * clip_rect.w; cy = clip_rect.y + cy * clip_rect.h; fy = clip_rect.y + fy * clip_rect.h; } points.push_back(point_type(cx, cy)); points.push_back(point_type(r, 0)); points.push_back(point_type(fx, fy)); this->state.gradient_fill = gradient(kiva::grad_radial, points, stops, spread_method, units); this->state.gradient_fill.set_ctm(this->get_ctm()); } private: template void fill_path_clip_conversion(path_type& input_path, agg24::filling_rule_e rule) { // !! non-clipped version is about 8% faster or so for lion if it // !! is entirely on the screen. It is slower, however, when // !! things are rendered off screen. Perhaps we should add a // !! compiled_path method for asking path what its bounding box // !! is and call this if it is all within the screen. //rasterizer.add_path(this->path); agg24::conv_clip_polygon clipped(input_path); clipped.clip_box(0,0, this->buf.width(), this->buf.height()); // fix me: We can do this more intelligently based on the current clip path. // fix me: What coordinates should this be in? I think in user space instead // of device space. This looks wrong... agg24::rasterizer_scanline_aa<> rasterizer; rasterizer.filling_rule(rule); rasterizer.add_path(clipped); if (this->state.gradient_fill.gradient_type == kiva::grad_none) { agg24::scanline_u8 scanline; // fix me: we need to select the renderer in another method. agg24::renderer_scanline_aa_solid< renderer_base_type > aa_renderer(this->renderer); // set fill color -- multiply by alpha if it is set. agg24::rgba color; color = this->state.fill_color; color.a *= this->state.alpha; aa_renderer.color(color); // draw the filled path to the buffer agg24::render_scanlines(rasterizer, scanline, aa_renderer); } else { this->state.gradient_fill.apply(this->renderer_pixfmt, &rasterizer, &this->renderer); } } //--------------------------------------------------------------- // Handle drawing filled rect quickly in some cases. //--------------------------------------------------------------- private: int _draw_rect_simple(double rect[4], draw_mode_e mode=FILL_STROKE); //--------------------------------------------------------------- // Draw_image pipeline //--------------------------------------------------------------- private: template void transform_image_interpolate(kiva::graphics_context& img, agg24::trans_affine& img_mtx) { agg24::path_storage img_outline = img.boundary_path(img_mtx); agg24::rendering_buffer* src_buf = img.rendering_buffer_ptr(); agg24::trans_affine inv_img_mtx = img_mtx; inv_img_mtx.invert(); agg24::span_interpolator_linear<> interpolator(inv_img_mtx); agg24::rgba back_color = agg24::rgba(1,1,1,0); agg24::span_allocator span_alloc; // 1. Switch on filter type. switch (img.get_image_interpolation()) { case nearest: { typedef typename kiva::image_filters::nearest_type span_gen_type; typedef typename kiva::image_filters::source_type source_type; source_type source(*src_buf, back_color); span_gen_type span_generator(source, interpolator); this->transform_image_final(img_outline, span_generator); break; } case bilinear: { typedef typename kiva::image_filters::bilinear_type span_gen_type; typedef typename kiva::image_filters::source_type source_type; source_type source(*src_buf, back_color); span_gen_type span_generator(source, interpolator); this->transform_image_final(img_outline, span_generator); break; } case bicubic: case spline16: case spline36: case sinc64: case sinc144: case sinc256: case blackman64: case blackman100: case blackman256: { agg24::image_filter_lut filter; switch (img.get_image_interpolation()) { case bicubic: filter.calculate(agg24::image_filter_bicubic()); break; case spline16: filter.calculate(agg24::image_filter_spline16()); break; case spline36: filter.calculate(agg24::image_filter_spline36()); break; case sinc64: filter.calculate(agg24::image_filter_sinc64()); break; case sinc144: filter.calculate(agg24::image_filter_sinc144()); break; case sinc256: filter.calculate(agg24::image_filter_sinc256()); break; case blackman64: filter.calculate(agg24::image_filter_blackman64()); break; case blackman100: filter.calculate(agg24::image_filter_blackman100()); break; case blackman256: filter.calculate(agg24::image_filter_blackman256()); break; case nearest: case bilinear: break; } typedef typename kiva::image_filters::general_type span_gen_type; typedef typename kiva::image_filters::source_type source_type; source_type source(*src_buf, back_color); span_gen_type span_generator(source, interpolator, filter); this->transform_image_final(img_outline, span_generator); break; } } } private: template void transform_image_final(agg24::path_storage& img_outline, span_gen_type span_generator) { typedef agg24::span_allocator span_alloc_type; span_alloc_type span_allocator; agg24::scanline_u8 scanline; agg24::rasterizer_scanline_aa<> rasterizer; if (this->state.alpha != 1.0) { rasterizer.gamma(alpha_gamma(this->state.alpha, 1.0)); } // fix me: This isn't handling clipping. [ Test. I think it should now] rasterizer.add_path(img_outline); agg24::render_scanlines_aa(rasterizer, scanline, this->renderer, span_allocator, span_generator); } }; template graphics_context::graphics_context(unsigned char *data, int width, int height, int stride, kiva::interpolation_e interp): graphics_context_base(data,width,height,stride,interp), renderer_pixfmt(buf), //renderer_single_clip(renderer_pixfmt), renderer(renderer_pixfmt) { // Required to set the clipping area of the renderer to the size of the buf. this->clear_clip_path(); } template kiva::pix_format_e graphics_context::format() { // The following dummy parameter is needed to pass in to agg_pix_to_kiva // because MSVC++ 6.0 doesn't properly handle template function // specialization (see notes in kiva_pix_format.h). agg_pixfmt *msvc6_dummy = NULL; return kiva::agg_pix_to_kiva(msvc6_dummy); } //--------------------------------------------------------------- // Restore state //--------------------------------------------------------------- template void graphics_context::restore_state() { if (this->state_stack.size() == 0) { return; } this->state = this->state_stack.top(); this->state_stack.pop(); this->path.restore_ctm(); // clear clippings paths and make renderer visible if (this->state.use_rect_clipping()) { if (this->state.device_space_clip_rects.size() > 0) { this->renderer.reset_clipping(true); // add all the clipping rectangles in sequence std::vector::iterator it; for (it = this->state.device_space_clip_rects.begin(); it < this->state.device_space_clip_rects.end(); it++) { this->renderer.add_clip_box(int(it->x), int(it->y), int(it->x2()), int(it->y2())); } } else { this->renderer.reset_clipping(false); } } else { this->renderer.reset_clipping(true); this->state.clipping_path = this->path; } } //--------------------------------------------------------------- // Clipping path manipulation //--------------------------------------------------------------- template void graphics_context::clip() { // this->state.clipping_path = this->path; agg24::scanline_p8 scanline; agg24::renderer_scanline_aa_solid< renderer_base_type > aa_renderer(this->renderer); agg24::rgba transparent = this->state.fill_color; transparent.a = 0; aa_renderer.color(transparent); this->stroke_path_scanline_aa(this->state.clipping_path, aa_renderer, scanline); } template void graphics_context::even_odd_clip() { throw kiva::even_odd_clip_error; } template kiva::rect_type graphics_context::transform_clip_rectangle(const kiva::rect_type &rect) { // This only works if the ctm doesn't have any rotation. // otherwise, we need to use a clipping path. Test for this. agg24::trans_affine tmp(this->path.get_ctm()); if ( !only_scale_and_translation(tmp)) { throw kiva::ctm_rotation_error; } double x = rect.x; double y = rect.y; double x2 = rect.x2(); double y2 = rect.y2(); this->path.get_ctm().transform(&x, &y); this->path.get_ctm().transform(&x2, &y2); // fix me: How should we round here? // maybe we should lrint, but I don't think it is portable. See // here: http://www.cs.unc.edu/~sud/tips/Programming_Tips.html x = int(floor(x+0.5)); y = int(floor(y+0.5)); // subtract 1 to account for agg (inclusive) vs. kiva (exclusive) clipping x2 = int(floor(x2+0.5))-1; y2 = int(floor(y2+0.5))-1; //x2 = int(floor(x2+0.5)); //y2 = int(floor(y2+0.5)); return kiva::rect_type(x, y, x2-x, y2-y); } template void graphics_context::clip_to_rect(double x, double y, double sx, double sy) { kiva::rect_type tmp(x, y, sx, sy); this->clip_to_rect(tmp); } template void graphics_context::clip_to_rect(kiva::rect_type &rect) { // Intersect the input rectangle with the current clipping path. // // 2/3/2005 Robert Kern noted that the Mac version forces a clear // of the path when calling clip_to_rect. We'll do the same to // lessen the potential for inconsistencies. this->path.remove_all(); if (this->state.use_rect_clipping()) { kiva::rect_type device_rect(transform_clip_rectangle(rect)); // optimize for case when there is only one existing rectangle if (this->state.device_space_clip_rects.size() == 1) { kiva::rect_type old(this->state.device_space_clip_rects.back()); this->state.device_space_clip_rects.pop_back(); kiva::rect_type newrect(kiva::disjoint_intersect(old, device_rect)); if ((newrect.w < 0) || (newrect.h < 0)) { // new clip rectangle doesn't intersect anything, so we push on // an empty rect as the new clipping region. this->renderer.reset_clipping(false); this->state.device_space_clip_rects.push_back(kiva::rect_type(0, 0, -1, -1)); } else { this->renderer.reset_clipping(true); this->renderer.add_clip_box(int(newrect.x), int(newrect.y), int(newrect.x2()), int(newrect.y2())); this->state.device_space_clip_rects.push_back(newrect); } } else { // we need to compute the intersection of the new rectangle with // the current set of clip rectangles. we assume that the existing // clip_rects are a disjoint set. this->state.device_space_clip_rects = kiva::disjoint_intersect( this->state.device_space_clip_rects, device_rect); if (this->state.device_space_clip_rects.size() == 0) { this->renderer.reset_clipping(false); this->state.device_space_clip_rects.push_back(kiva::rect_type(0, 0, -1, -1)); } else { this->renderer.reset_clipping(true); for (unsigned int i=0; istate.device_space_clip_rects.size(); i++) { kiva::rect_type *tmp = &this->state.device_space_clip_rects[i]; this->renderer.add_clip_box(int(tmp->x), int(tmp->y), int(tmp->x2()), int(tmp->y2())); } } } } else { // We don't support non-rect clipping. throw clipping_path_unsupported; } } template void graphics_context::clip_to_rects(kiva::rect_list_type &rects) { // calculate the disjoint union of the input rectangles kiva::rect_list_type new_rects = disjoint_union(rects); if (this->state.use_rect_clipping()) { // tranform and clip each new rectangle against the current clip_rects kiva::rect_list_type result_rects; for (kiva::rect_iterator it = new_rects.begin(); it != new_rects.end(); it++) { kiva::rect_type device_rect(transform_clip_rectangle(*it)); kiva::rect_list_type new_result_rects( kiva::disjoint_intersect(this->state.device_space_clip_rects, device_rect)); for (kiva::rect_iterator tmp_iter = new_result_rects.begin(); tmp_iter != new_result_rects.end(); tmp_iter++) { result_rects.push_back(*tmp_iter); } } if (result_rects.size() == 0) { // All areas are clipped out. this->state.device_space_clip_rects.clear(); this->state.device_space_clip_rects.push_back(kiva::rect_type(0, 0, -1, -1)); this->renderer.reset_clipping(false); } else { // Reset the renderer's clipping and add each new clip rectangle this->renderer.reset_clipping(true); for (kiva::rect_iterator it2 = result_rects.begin(); it2 != result_rects.end(); it2++) { this->renderer.add_clip_box(int(it2->x), int(it2->y), int(it2->x2()), int(it2->y2())); } this->state.device_space_clip_rects = result_rects; } } else { // We don't support non-rect clipping. throw clipping_path_unsupported; } } template void graphics_context::clip_to_rects(double* new_rects, int Nrects) { kiva::rect_list_type rectlist; for (int rectNum=0; rectNum < Nrects; rectNum++) { int ndx = rectNum*4; rectlist.push_back(kiva::rect_type(new_rects[ndx], new_rects[ndx+1], new_rects[ndx+2], new_rects[ndx+3])); } clip_to_rects(rectlist); } template void graphics_context::clear_clip_path() { // clear the existing clipping paths this->state.clipping_path.remove_all(); this->state.device_space_clip_rects.clear(); // set everything visible again. this->renderer.reset_clipping(1); // store the new clipping rectangle back into the first // rectangle of the graphics state clipping rects. this->state.device_space_clip_rects.push_back(this->renderer.clip_box()); } template int graphics_context::get_num_clip_regions() { return this->state.device_space_clip_rects.size(); } template kiva::rect_type graphics_context::get_clip_region(unsigned int i) { if (i >= this->state.device_space_clip_rects.size()) { return kiva::rect_type(); } else { return this->state.device_space_clip_rects[i]; } } //--------------------------------------------------------------- // Painting paths (drawing and filling contours) //--------------------------------------------------------------- template void graphics_context::clear(agg24::rgba value) { this->renderer.clear(value); } /* template void graphics_context::clear(double value) { this->renderer_single_clip.clear(value); } */ template void graphics_context::draw_path(draw_mode_e mode) { switch(mode) { case FILL: this->_fill_path(agg24::fill_non_zero); break; case EOF_FILL: this->_fill_path(agg24::fill_even_odd); break; case STROKE: this->_stroke_path(); break; case FILL_STROKE: this->_fill_path(agg24::fill_non_zero); this->_stroke_path(); break; case EOF_FILL_STROKE: this->_fill_path(agg24::fill_even_odd); this->_stroke_path(); break; } this->path.remove_all(); } template void graphics_context::draw_rect(double rect[4], draw_mode_e mode) { // Try a fast renderer first. int fast_worked = this->_draw_rect_simple(rect, mode); if (!fast_worked) { double x = rect[0]; double y = rect[1]; double sx = rect[2]; double sy = rect[3]; this->begin_path(); this->move_to(x, y); this->line_to(x+sx, y); this->line_to(x+sx, y+sy); this->line_to(x, y+sy); this->close_path(); this->draw_path(mode); } else { //printf("simple worked!\n"); } this->path.remove_all(); } template int graphics_context::_draw_rect_simple(double rect[4], draw_mode_e mode) { /* function requires that antialiasing is false and ctm doesn't have any rotation. */ //printf("trying _simple\n"); int success = 0; agg24::trans_affine ctm = this->get_ctm(); if ( !this->state.should_antialias && only_scale_and_translation(ctm) && (this->state.line_width == 1.0 || this->state.line_width == 0.0)) // fix me: should test for join style //&& this->state.line_join == JOIN_MITER ) { agg24::renderer_primitives renderer(this->renderer); renderer.fill_color(this->get_fill_color()); // use transparency to indicate a 0 width line agg24::rgba line_color = this->get_stroke_color(); line_color.a *= this->state.line_width; renderer.line_color(line_color); double temp[6]; ctm.store_to(temp); double scale_x = temp[0]; double scale_y = temp[3]; double tx = temp[4]; double ty = temp[5]; //printf("rect: %d, %d %d, %d\n", rect[0], rect[1], rect[2], rect[3]); //printf("trans, scale: %d, %d %d, %d\n", tx, ty, scale_x, scale_y); // fix me: need to handle rounding here... int x1 = int(rect[0]*scale_x + tx); int y1 = int(rect[1]*scale_y + ty); int x2 = int((rect[0]+rect[2])*scale_x + tx); int y2 = int((rect[1]+rect[3])*scale_y + ty); if (mode == FILL_STROKE || mode == EOF_FILL_STROKE) { //printf("fill stroke: %d, %d %d, %d\n", x1, y1, x2, y2); renderer.outlined_rectangle(x1, y1, x2, y2); // This isn't right, but it should be faster. Interestingly, // it didn't seem to be. //this->renderer.copy_bar(x1, y1, x2, y2, this->get_fill_color()); success = 1; } else if (mode == STROKE ) { //printf("stroke: %d, %d %d, %d\n", x1, y1, x2, y2); renderer.rectangle(x1, y1, x2, y2); success = 1; } else if (mode == FILL || mode == EOF_FILL ) { //printf("fill: %d, %d %d, %d\n", x1, y1, x2, y2); renderer.solid_rectangle(x1, y1, x2, y2); success = 1; } } return success; } template int graphics_context::draw_marker_at_points(double* pts,int Npts,int size, agg24::marker_e type) { int success = 0; agg24::trans_affine ctm = this->get_ctm(); if ( only_translation(ctm) && (this->state.line_width == 1.0 || this->state.line_width == 0.0)) //&& this->state.line_join == JOIN_MITER ) { // TODO-PZW: fix this!! agg24::renderer_markers< renderer_base_type > m(this->renderer); m.fill_color(this->get_fill_color()); // use transparency to indicate an 0 width line agg24::rgba line_color = this->get_stroke_color(); line_color.a *= this->state.line_width; m.line_color(line_color); double tx, ty; get_translation(ctm, &tx, &ty); for(int i = 0; i < Npts*2; i+=2) { m.marker((int)(pts[i]+tx), int(pts[i+1]+ty), size, type); } success = 1; } return success; } template void graphics_context::draw_path_at_points(double* pts,int Npts, kiva::compiled_path& marker, draw_mode_e mode) { // This routine draws a path (i.e. marker) at multiple points // on the screen. It is used heavily when rendering scatter // plots. // // The routine has been special cased to handle the filling // markers without outlining them when the ctm doesn't have // rotation, scaling, or skew. // // fastest path // (1) We're only using FILL mode. // (2) ctm is identity matrix // fast path // (1) We're only using FILL mode. // (2) ctm just has translational components (tx,ty) // normal path // Everything else. // !! This path commented out. We don't have any cases // !! currently where draw_marker_at_points won't work, // !! so we provide fast and slow without taking the time // !! to update the inbetween route. // no outline if (0) //(!(mode & STROKE) || state.line_color.a == 0.0) { /* // set fill color -- multiply by alpha if it is set. agg24::rgba color; color = this->state.fill_color; color.a *= this->state.alpha; this->renderer.attribute(color); agg24::trans_affine ctm = this->get_ctm(); // set the rasterizer filling rule if (mode & FILL) this->rasterizer.filling_rule(agg24::fill_non_zero); else if (mode & EOF_FILL) this->rasterizer.filling_rule(agg24::fill_even_odd); // fastest path if (is_identity(ctm)) { for(int i = 0; i < Npts*2; i+=2) { const double x = pts[i]; const double y = pts[i+1]; this->rasterizer.add_path(marker,x,y); this->rasterizer.render(renderer); } } // 2nd fastest path else if (only_translation(ctm)) { double temp[6]; this->get_ctm().store_to(temp); double tx = temp[4]; double ty = temp[5]; for(int i = 0; i < Npts*2; i+=2) { const double x = pts[i] + tx; const double y = pts[i+1] + ty; this->rasterizer.add_path(marker,x,y); this->rasterizer.render(renderer); } } */ } // outlined draw mode or // complicated ctm (rotation,scaling, or skew) else { this->begin_path(); for(int i = 0; i < Npts*2; i+=2) { const double x = pts[i]; const double y = pts[i+1]; // This is faster than saving the entire state. this->path.save_ctm(); this->translate_ctm(x,y); this->add_path(marker); this->draw_path(mode); this->path.restore_ctm(); } } } template bool graphics_context::show_text(char*text) { typedef agg24::glyph_raster_bin GlyphGeneratorType; typedef agg24::renderer_scanline_aa_solid ScanlineRendererType; //GlyphGeneratorType glyphGen(0); ScanlineRendererType scanlineRenderer(this->renderer); const agg24::glyph_cache *glyph = NULL; #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) int required = MultiByteToWideChar(CP_UTF8, 0, text, -1, 0, 0); std::vector p_(required + 1); MultiByteToWideChar(CP_UTF8, 0, text, -1, &p_[0], required); wchar_t *p = &p_[0]; #else std::vector p_(1024); size_t length = mbstowcs(&p_[0], text, 1024); if (length > 1024) { p_.resize (length + 1); mbstowcs(&p_[0], text, length); } wchar_t *p = &p_[0]; #endif bool retval = true; // Check to make sure the font's loaded. if (!this->is_font_initialized()) { return false; } this->_grab_font_manager(); font_engine_type *font_engine = kiva::GlobalFontEngine(); font_manager_type *font_manager = kiva::GlobalFontManager(); // Concatenate the CTM with the text matrix to get the full transform for the // font engine. agg24::trans_affine full_text_xform(this->text_matrix * this->path.get_ctm()); // the AGG freetype transform is a per character transform. We need to remove the // offset part of the transform to prevent that offset from occuring between each // character. We'll handle the intial offset ourselves. double start_x, start_y; double text_xform_array[6]; full_text_xform.store_to(text_xform_array); // Pull the translation values out of the matrix as our starting offset and // then replace them with zeros for use in the font engine. start_x = text_xform_array[4]; start_y = text_xform_array[5]; text_xform_array[4] = 0.0; text_xform_array[5] = 0.0; full_text_xform.load_from(text_xform_array); font_engine->transform(full_text_xform); if (this->state.text_drawing_mode == kiva::TEXT_FILL) { scanlineRenderer.color(this->state.fill_color); } else if ((this->state.text_drawing_mode == kiva::TEXT_STROKE) || (this->state.text_drawing_mode == kiva::TEXT_FILL_STROKE)) { scanlineRenderer.color(this->state.line_color); } double advance_x = 0.0; double advance_y = 0.0; while (*p) { double x = start_x + advance_x; double y = start_y + advance_y; glyph = font_manager->glyph(*p); if (glyph == NULL) { retval = false; break; } font_manager->add_kerning(&x, &y); font_manager->init_embedded_adaptors(glyph, x, y); if (this->state.text_drawing_mode != kiva::TEXT_INVISIBLE) { agg24::render_scanlines(font_manager->gray8_adaptor(), font_manager->gray8_scanline(), scanlineRenderer); } advance_x += glyph->advance_x; advance_y += glyph->advance_y; p++; } agg24::trans_affine null_xform = agg24::trans_affine_translation(0., 0.); font_engine->transform(null_xform); this->_release_font_manager(); agg24::trans_affine trans = agg24::trans_affine_translation(advance_x, advance_y); this->text_matrix.multiply(trans); return retval; } template int graphics_context::draw_image(kiva::graphics_context_base* img, double rect[4], bool force_copy) { int success = 0; // We have to scale first and then translate; otherwise, Agg will cause // the translation to be scaled as well. double sx = rect[2]/img->width(); double sy = rect[3]/img->height(); agg24::trans_affine img_mtx = agg24::trans_affine_scaling(sx,sy); img_mtx *= agg24::trans_affine_translation(rect[0],rect[1]); img_mtx *= this->path.get_ctm(); double tx, ty; get_translation(img_mtx, &tx, &ty); //success = transform_image(img, img_mtx); // The following section attempts to use a fast method for blending in // cases where the full interpolation methods aren't needed. // When there isn't any scaling or rotation, try a fast method for // copy or blending the pixels. They will fail if pixel formats differ... // If the user is forcing us to respect the blend_copy mode regardless // of the CTM, then we make it so. // fix me: Not testing whether tx, ty are (nearly) integer values. // We should. if (only_translation(img_mtx) || force_copy) { if (this->state.blend_mode == kiva::blend_copy) { success = this->copy_image(img, (int) tx, (int) ty); } else { success = this->blend_image(img, (int)tx, (int)ty); } } if (!success) { // looks like the fast approach didn't work -- there is some // transform to the matrix so we'll use an interpolation scheme. // We're just starting blend_mode support. From here down, we // only support normal. if (!(this->state.blend_mode == kiva::blend_normal)) { success = 0; return success; } success = transform_image(img, img_mtx); } return success; } template int graphics_context::copy_image(kiva::graphics_context_base* img, int tx, int ty) { // This function is only valid if only_translation(ctm) == True and // image is not to be scaled. int success = 0; // Copy only works if images have the same format. // fix me: This restriction should be fixed. // fix me: We are ignoring that tx and ty are double. test that // we are close. Otherwise, we need to use interpolation. if (img->format() != this->format()) { //doesn't meet requirements printf("copy_image() on this gc requires format %d, got %d.", this->format(), img->format()); success = 0; } else { agg24::rect_i r(0, 0, img->width(), img->height()); this->renderer.copy_from(img->buf, &r, tx, ty); success = 1; } return success; } template int graphics_context::blend_image(kiva::graphics_context_base* img, int tx, int ty) { // This function is only valid if only_translation(ctm) == True and // image is not to be scaled. // Note: I thought I needed to negate the tx,ty in here, but it doesn't // turn out to be true. int success = 0; unsigned int alpha = unsigned(this->state.alpha*255); // Check that format match. I think the formats // actually only have to have the same number of channels, // so this test is to restrictive. // fix me: lighten up this format restrictions. // fix me: We are ignoring that tx and ty are double. test that // we are close. Otherwise, we need to use interpolation. if (img->format() != this->format()) { //doesn't meet requirements success = 0; } else { agg24::rect_i r(0, 0, img->width(), img->height()); switch (img->format()) { // fix me: agg 2.4 doesn't work for blending rgb values into other buffers. // I think this should be fixed, but I also think it would take // some major agg hackery. case kiva::pix_format_rgb24: case kiva::pix_format_bgr24: success = 0; break; //case kiva::pix_format_rgb24: //{ // typedef kiva::graphics_context pix_format_type; // this->renderer.blend_from(static_cast(img)->renderer_pixfmt, // &r, tx, ty, alpha); // success = 1; // break; //} // //case kiva::pix_format_bgr24: //{ // typedef kiva::graphics_context pix_format_type; // this->renderer.blend_from(static_cast(img)->renderer_pixfmt, // &r, tx, ty, alpha); // success = 1; // break; //} case kiva::pix_format_rgba32: { typedef kiva::graphics_context pix_format_type; this->renderer.blend_from(static_cast(img)->renderer_pixfmt, &r, tx, ty, alpha); success = 1; break; } case kiva::pix_format_argb32: { typedef kiva::graphics_context pix_format_type; this->renderer.blend_from(static_cast(img)->renderer_pixfmt, &r, tx, ty, alpha); success = 1; break; } case kiva::pix_format_abgr32: { typedef kiva::graphics_context pix_format_type; this->renderer.blend_from(static_cast(img)->renderer_pixfmt, &r, tx, ty, alpha); success = 1; break; } case kiva::pix_format_bgra32: { typedef kiva::graphics_context pix_format_type; this->renderer.blend_from(static_cast(img)->renderer_pixfmt, &r, tx, ty, alpha); success = 1; break; } case kiva::pix_format_undefined: case kiva::pix_format_gray8: case kiva::pix_format_rgb555: case kiva::pix_format_rgb565: case kiva::end_of_pix_formats: default: { // format not valid. success = 0; } } } return success; } template int graphics_context::transform_image(kiva::graphics_context_base* img, agg24::trans_affine& img_mtx) { int success = 0; switch (img->format()) { case kiva::pix_format_rgb24: { typedef kiva::graphics_context gc_type; this->transform_image_interpolate(*(static_cast(img)), img_mtx); success = 1; break; } case kiva::pix_format_bgr24: { typedef kiva::graphics_context gc_type; this->transform_image_interpolate(*(static_cast(img)), img_mtx); success = 1; break; } case kiva::pix_format_rgba32: { typedef kiva::graphics_context gc_type; this->transform_image_interpolate(*(static_cast(img)), img_mtx); success = 1; break; } case kiva::pix_format_argb32: { typedef kiva::graphics_context gc_type; this->transform_image_interpolate(*(static_cast(img)),img_mtx); success = 1; break; } case kiva::pix_format_abgr32: { typedef kiva::graphics_context gc_type; this->transform_image_interpolate(*(static_cast(img)),img_mtx); success = 1; break; } case kiva::pix_format_bgra32: { typedef kiva::graphics_context gc_type; this->transform_image_interpolate(*(static_cast(img)),img_mtx); success = 1; break; } case kiva::pix_format_undefined: case kiva::pix_format_gray8: case kiva::pix_format_rgb555: case kiva::pix_format_rgb565: case kiva::end_of_pix_formats: default: { // format not valid. success = 0; } } return success; } typedef graphics_context graphics_context_rgb24; typedef graphics_context graphics_context_bgr24; typedef graphics_context graphics_context_bgra32; typedef graphics_context graphics_context_rgba32; typedef graphics_context graphics_context_argb32; typedef graphics_context graphics_context_abgr32; } // namespace kiva #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/numeric_ext.i0000644000175000017500000000616212516137326021660 0ustar varunvarun%include "numeric.i" %{ #ifndef NUMPY #include "Numeric/arrayobject.h" /* This is the basic array allocation function. */ PyObject *PyArray_FromDimsAndStridesAndDataAndDescr(int nd, int *d, int* st, PyArray_Descr *descr, char *data) { PyArrayObject *self; int i,sd; int *dimensions, *strides; int flags= CONTIGUOUS | OWN_DIMENSIONS | OWN_STRIDES; //static int calls = 0; //calls++; //printf("allocs: %d\n;", calls); dimensions = strides = NULL; if (nd < 0) { PyErr_SetString(PyExc_ValueError, "number of dimensions must be >= 0"); return NULL; } if (nd > 0) { if ((dimensions = (int *)malloc(nd*sizeof(int))) == NULL) { PyErr_SetString(PyExc_MemoryError, "can't allocate memory for array"); goto fail; } if ((strides = (int *)malloc(nd*sizeof(int))) == NULL) { PyErr_SetString(PyExc_MemoryError, "can't allocate memory for array"); goto fail; } memmove(dimensions, d, sizeof(int)*nd); memmove(strides, st, sizeof(int)*nd); } // This test for continguity sd = descr->elsize; for(i=nd-1;i>=0;i--) { if (strides[i] <= 0) { PyErr_SetString(PyExc_ValueError, "strides must be positive"); goto fail; } if (dimensions[i] <= 0) { /* only allow positive dimensions in this function */ PyErr_SetString(PyExc_ValueError, "dimensions must be positive"); goto fail; } if (strides[i] != sd) { flags &= !CONTIGUOUS; } /* This may waste some space, but it seems to be (unsuprisingly) unhealthy to allow strides that are longer than sd. */ sd *= dimensions[i] ? dimensions[i] : 1; } /* Make sure we're alligned on ints. */ sd += sizeof(int) - sd%sizeof(int); if (data == NULL) { if ((data = (char *)malloc(sd)) == NULL) { PyErr_SetString(PyExc_MemoryError, "can't allocate memory for array"); goto fail; } flags |= OWN_DATA; } if((self = PyObject_NEW(PyArrayObject, &PyArray_Type)) == NULL) goto fail; if (flags & OWN_DATA) memset(data, 0, sd); self->data=data; self->dimensions = dimensions; self->strides = strides; self->nd=nd; self->descr=descr; self->base = (PyObject *)NULL; self->flags = flags; /* Numeric versions prior to 23.3 do not have the weakreflist field. By default we include it. You must explicitly define: NUMERIC_DOES_NOT_HAVE_WEAKREF */ #ifndef NUMERIC_DOES_NOT_HAVE_WEAKREF self->weakreflist = (PyObject *)NULL; #endif return (PyObject*)self; fail: if (flags & OWN_DATA) free(data); if (dimensions != NULL) free(dimensions); if (strides != NULL) free(strides); return NULL; } #endif %}enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_dash_type.h0000644000175000017500000000227212516137326022325 0ustar varunvarun#ifndef DASH_TYPE_H #define DASH_TYPE_H #include namespace kiva { //----------------------------------------------------------------------- // line dash type //----------------------------------------------------------------------- class dash_type { public: double phase; std::vector pattern; // constructor dash_type(): phase(0),pattern(2,0) { } // this forces even length of pattern dash_type(double _phase, double* _pattern, int n): phase(_phase), pattern(n%2 ? n+1 : n) { for(int i = 0; i < n; i++) pattern[i] = _pattern[i]; // for odd length patterns, use the first entry as the // last gap size. (this is arbitrary) if (n%2) pattern[n] = _pattern[0]; } ~dash_type() { } bool is_solid() { return (pattern.size() == 2 && pattern[0] == 0.); } // TODO-PZW: define a copy constructor }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_graphics_state.h0000644000175000017500000000651312516137326023347 0ustar varunvarun#ifndef GRAPHICS_STATE_H #define GRAPHICS_STATE_H #include #include "agg_trans_affine.h" #include "kiva_constants.h" #include "kiva_font_type.h" #include "kiva_dash_type.h" #include "kiva_compiled_path.h" #include "kiva_gradient.h" #include namespace kiva { //----------------------------------------------------------------------- // graphics_state class //----------------------------------------------------------------------- class graphics_state { public: // line attributes agg24::rgba line_color; double line_width; kiva::line_cap_e line_cap; kiva::line_join_e line_join; kiva::dash_type line_dash; // other attributes kiva::blend_mode_e blend_mode; kiva::font_type font; agg24::rgba fill_color; gradient gradient_fill; double alpha; // clipping path // In general, we need a path to store the clipping region. // However, in most cases, the clipping region can be represented // by a list of rectangles. The graphics state can support one or // the other, but not both. By default, device_space_clip_rects is // used; but as soon as a non-rectangular clip path is added to // the graphics state or the rectangular region is rotated, then // it becomes an arbitrary clipping path. // // device_space_clip_rects always contains at least one rectangle. // In the event that everything is clipped out, the clip rectangle // will have dimensions (0,0). // // The function use_rect_clipping is used to determine whether or // not to use device_space_clip_rects. 'true' means to use it, 'false' // means ot use clipping_path; kiva::compiled_path clipping_path; std::vector device_space_clip_rects; inline bool use_rect_clipping(); double current_point[2]; // !! not sure about this. int should_antialias; double miter_limit; double flatness; // !! not sure about this type. double character_spacing; //!! not sure about this type. kiva::text_draw_mode_e text_drawing_mode; // double rendering_intent; // !! I know this type is wrong... graphics_state(): line_color(agg24::rgba(0.0,0.0,0.0)),line_width(1.0), line_cap(kiva::CAP_BUTT), line_join(kiva::JOIN_MITER), blend_mode(kiva::blend_normal), font(kiva::font_type("")), fill_color(agg24::rgba(0.0,0.0,0.0)), gradient_fill(kiva::grad_none), alpha(1.0), should_antialias(1), text_drawing_mode(kiva::TEXT_FILL) { } ~graphics_state() { } inline bool is_singleclip() { return (device_space_clip_rects.size() <= 1 ? true : false); } }; inline bool graphics_state::use_rect_clipping() { if (clipping_path.total_vertices() > 0) { std::cout << "clipping path has vertices" << std::endl; return false; } return true; } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/gl/0000755000175000017500000000000012516137726017565 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/src/gl/plat_support.i0000644000175000017500000000713212516137326022472 0ustar varunvarun// -*- c++ -*- // OpenGL support for AGG // Author: Robert Kern // I've consolidated agg_platform_specific and agg_bmp in the process of // understanding the code. // plat_support defines a function resize_gl(width, height) which should be called // every time the window gets resized. All OpenGL initialization and glViewport // calls need to be done by the widget toolkit. // Currently, OpenGL support is only tested with wxWidgets 2.5.1.5 on MacOS X // version 10.3 %module plat_support %include numeric.i %{ #include "gl/agg_bmp.h" namespace agg24 { PyObject* pixel_map_as_unowned_array(agg24::pixel_map& pix_map) { npy_intp dims[3]; npy_intp rows = pix_map.height(); npy_intp cols = pix_map.width(); npy_intp depth = pix_map.bpp() / 8; dims[0] = rows; dims[1] = cols; dims[2] = depth; return PyArray_SimpleNewFromData(3,dims,NPY_UINT8,(void*)pix_map.buf()); } void resize_gl(unsigned width, unsigned height) { GLint viewport[4]; glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0, (GLfloat)width, 0.0, (GLfloat)height); glPixelZoom(1.0, -1.0); glGetIntegerv(GL_VIEWPORT, viewport); glRasterPos2d(0.0, ((double)height*height)/viewport[3]); } } %} // More permissive unsigned typemap that converts any numeric type to an // unsigned value. It is cleared at the end of this file. %typemap(in) unsigned { PyObject* obj = PyNumber_Int($input); if (PyErr_Occurred()) SWIG_fail; $1 = (unsigned) PyLong_AsLong(obj); if (PyErr_Occurred()) SWIG_fail; } namespace agg24 { enum pix_format_e { pix_format_undefined = 0, // By default. No conversions are applied pix_format_gray8, // Simple 256 level grayscale pix_format_rgb555, // 15 bit rgb. Depends on the byte ordering! pix_format_rgb565, // 16 bit rgb. Depends on the byte ordering! pix_format_rgb24, // R-G-B, one byte per color component pix_format_bgr24, // B-G-R, native win32 BMP format. pix_format_rgba32, // R-G-B-A, one byte per color component pix_format_argb32, // A-R-G-B, native MAC format pix_format_abgr32, // A-B-G-R, one byte per color component pix_format_bgra32, // B-G-R-A, native win32 BMP format end_of_pix_formats }; %name(PixelMap) class pixel_map { public: ~pixel_map(); pixel_map(unsigned width, unsigned height, pix_format_e format, unsigned clear_val, bool bottom_up); public: %feature("shadow") draw(int x, int y, double scale) %{ def draw(self, x=0, y=0, scale=1.0): # fix me: brittle becuase we are hard coding # module and class name. Done cause SWIG 1.3.24 does # some funky overloading stuff in it that breaks keyword # arguments. result = _plat_support.PixelMap_draw(self, x, y, scale) return result %} void draw(int x, int y, double scale); PyObject* convert_to_argb32string() const; %pythoncode %{ def set_bmp_array(self): self.bmp_array = pixel_map_as_unowned_array(self) return self def draw_to_glcanvas(self, x, y): self.draw(x, y) %} }; PyObject* pixel_map_as_unowned_array(pixel_map& pix_map); void resize_gl(unsigned width, unsigned height); } // clear the "permissive" unsigned typemap we are using. %typemap(in) unsigned; enthought-chaco2-4.5.1.orig/kiva/agg/src/gl/agg_bmp.cpp0000644000175000017500000001606212516137326021666 0ustar varunvarun#include #include #include "gl/agg_bmp.h" //#include "gl/agg_platform_specific.h" #include "agg_pixfmt_rgba.h" #include "agg_color_rgba.h" #if 0 #define DEBUG_MTH(NAME) fprintf(stderr, NAME "\n"); #define DEBUG_MTH2(STR,ARG1,ARG2) fprintf(stderr, STR "\n",(ARG1),(ARG2)); #define DEBUG_MTH5(STR,ARG1,ARG2,ARG3,ARG4,ARG5) fprintf(stderr, STR "\n",(ARG1),(ARG2),(ARG3),(ARG4),(ARG5)); #else #define DEBUG_MTH(NAME) #define DEBUG_MTH2(STR,ARG1,ARG2) #define DEBUG_MTH5(STR,ARG1,ARG2,ARG3,ARG4,ARG5) #endif namespace agg24 { //------------------------------------------------------------------------ pixel_map::pixel_map(unsigned width, unsigned height, pix_format_e format, unsigned clear_val, bool bottom_up): m_buf(NULL), m_buf2(NULL), m_format(format) // m_specific(new platform_specific(format, bottom_up)) { DEBUG_MTH5("pixel_map::pixel_map(%d,%d,%d,%d,%d)",width,height,format,clear_val,bottom_up); init_platform(format, bottom_up); create(width, height, clear_val); } //------------------------------------------------------------------------ void pixel_map::init_platform(pix_format_e format, bool bottom_up) { switch(m_format) { case pix_format_gray8: m_sys_format = pix_format_gray8; m_bpp = 8; m_sys_bpp = 8; m_gl_format = GL_LUMINANCE; m_gl_pixel_type = GL_UNSIGNED_BYTE; break; case pix_format_rgb555: case pix_format_rgb565: m_sys_format = pix_format_rgb565; m_bpp = 16; m_sys_bpp = 16; m_gl_format = GL_RGB; m_gl_pixel_type = GL_UNSIGNED_SHORT_5_6_5; break; case pix_format_rgb24: m_sys_format = pix_format_rgb24; m_bpp = 24; m_sys_bpp = 24; m_gl_format = GL_RGB; m_gl_pixel_type = GL_UNSIGNED_BYTE; break; case pix_format_bgr24: m_sys_format = pix_format_bgr24; m_bpp = 24; m_sys_bpp = 24; m_gl_format = GL_BGR; m_gl_pixel_type = GL_UNSIGNED_BYTE; break; case pix_format_bgra32: case pix_format_abgr32: m_sys_format = pix_format_bgra32; m_bpp = 32; m_sys_bpp = 32; m_gl_format = GL_BGRA; m_gl_pixel_type = GL_UNSIGNED_BYTE; break; case pix_format_argb32: case pix_format_rgba32: m_sys_format = pix_format_rgba32; m_bpp = 32; m_sys_bpp = 32; m_gl_format = GL_RGBA; m_gl_pixel_type = GL_UNSIGNED_BYTE; break; case pix_format_undefined: case end_of_pix_formats: ; } } //------------------------------------------------------------------------ unsigned pixel_map::calc_row_len(unsigned width, unsigned bits_per_pixel) { unsigned n = width; unsigned k; switch(bits_per_pixel) { case 1: k = n; n = n >> 3; if(k & 7) n++; break; case 4: k = n; n = n >> 1; if(k & 3) n++; break; case 8: break; case 16: n = n << 1; break; case 24: n = (n << 1) + n; break; case 32: n = n << 2; break; default: n = 0; break; } return ((n + 3) >> 2) << 2; } //------------------------------------------------------------------------ pixel_map::~pixel_map() { DEBUG_MTH("pixel_map::~pixel_map"); destroy(); } //------------------------------------------------------------------------ void pixel_map::destroy() { if (m_buf) { delete [] (unsigned char*)m_buf; } m_buf = NULL; if (m_buf2) { delete [] (unsigned char*)m_buf2; } m_buf2 = NULL; } //------------------------------------------------------------------------ void pixel_map::create(unsigned width, unsigned height, unsigned clear_val) { destroy(); if(width == 0) width = 1; if(height == 0) height = 1; unsigned row_len = calc_row_len(width, m_bpp); unsigned img_size = row_len * height; m_buf = new unsigned char[img_size]; if(clear_val <= 255) { memset(m_buf, clear_val, img_size); } m_rbuf_window.attach(m_buf, width, height, row_len); if (m_format != m_sys_format) { row_len = calc_row_len(width, m_sys_bpp); img_size = row_len*height; m_buf2 = new unsigned char[img_size]; if (clear_val <= 255) { memset(m_buf2, clear_val, img_size); } m_rbuf_window2.attach(m_buf2, width, height, row_len); } } //------------------------------------------------------------------------ void pixel_map::draw(int x, int y, double scale) { DEBUG_MTH("pixel_map::draw"); if(m_buf == 0) return; // m_specific->display_pmap(&m_rbuf_window); if (m_sys_format == m_format) { glDrawPixels(width(), height(), m_gl_format, m_gl_pixel_type, m_buf); } else { switch(m_format) { case pix_format_abgr32: color_conv(&m_rbuf_window2, &m_rbuf_window, color_conv_abgr32_to_bgra32()); break; case pix_format_argb32: color_conv(&m_rbuf_window2, &m_rbuf_window, color_conv_argb32_to_bgra32()); break; case pix_format_rgb555: color_conv(&m_rbuf_window2, &m_rbuf_window, color_conv_rgb555_to_rgb565()); break; // case pix_format_rgb565: // case pix_format_rgb24: // case pix_format_bgr24: // case pix_format_rgba32: // case pix_format_bgra32: // case pix_format_gray8: case end_of_pix_formats: case pix_format_undefined: ; } glDrawPixels(width(), height(), m_gl_format, m_gl_pixel_type, m_buf2); } } pix_format_e pixel_map::get_pix_format() const { return m_format; } unsigned char* pixel_map::buf() { return m_buf; } unsigned char* pixel_map::buf2() { return m_buf2; } unsigned pixel_map::width() const { return m_rbuf_window.width(); } unsigned pixel_map::height() const { return m_rbuf_window.height(); } int pixel_map::stride() { return calc_row_len(width(), m_bpp); } // Convert to a Python string containing 32 bit ARGB values. PyObject* pixel_map::convert_to_argb32string() const { unsigned w = width(); unsigned h = height(); PyObject *str = PyString_FromStringAndSize(NULL, w * h * 4); if (str == NULL) return NULL; unsigned *data = (unsigned *)PyString_AS_STRING(str); pix_format_e format = get_pix_format(); switch (format) { case pix_format_bgra32: { pixfmt_bgra32 r((rendering_buffer &)m_rbuf_window); for (unsigned j = 0; j < h; ++j) for (unsigned i = 0; i < w; ++i) { rgba8 c = r.pixel(i, h - j - 1); *data++ = (((unsigned char)c.a) << 24) | (((unsigned char)c.r) << 16) | (((unsigned char)c.g) << 8) | ((unsigned char)c.b); } } break; default: Py_DECREF(str); PyErr_Format(PyExc_ValueError, "pix_format %d not handled", format); return NULL; } return str; } } enthought-chaco2-4.5.1.orig/kiva/agg/src/gl/agg_bmp.h0000644000175000017500000000461412516137326021333 0ustar varunvarun// -*- c++ -*- #ifndef AGG_GL_BMP_INCLUDED #define AGG_GL_BMP_INCLUDED #include "Python.h" #include "agg_basics.h" #include "agg_rendering_buffer.h" #include "util/agg_color_conv_rgb8.h" #ifdef __DARWIN__ #include #include #else #include #include #endif namespace agg24 { enum pix_format_e { pix_format_undefined = 0, // By default. No conversions are applied pix_format_gray8, // Simple 256 level grayscale pix_format_rgb555, // 15 bit rgb. Depends on the byte ordering! pix_format_rgb565, // 16 bit rgb. Depends on the byte ordering! pix_format_rgb24, // R-G-B, one byte per color component pix_format_bgr24, // B-G-R, native win32 BMP format. pix_format_rgba32, // R-G-B-A, one byte per color component pix_format_argb32, // A-R-G-B, native MAC format pix_format_abgr32, // A-B-G-R, one byte per color component pix_format_bgra32, // B-G-R-A, native win32 BMP format end_of_pix_formats }; class pixel_map { public: pixel_map(unsigned width, unsigned height, pix_format_e format, unsigned clear_val, bool bottom_up); ~pixel_map(); void draw(int x=0, int y=0, double scale=1.0); void init_platform(pix_format_e format, bool bottom_up); unsigned calc_row_len(unsigned width, unsigned bits_per_pixel); pix_format_e get_pix_format() const; unsigned char* buf(); unsigned char* buf2(); unsigned width() const; unsigned height() const; int stride(); unsigned bpp() const { return m_bpp; } rendering_buffer& rbuf() { return m_rbuf_window; } rendering_buffer& rbuf2() { return m_rbuf_window2; } PyObject* convert_to_argb32string() const; pix_format_e m_format; pix_format_e m_sys_format; private: void destroy(); void create(unsigned width, unsigned height, unsigned clear_val=256); unsigned char* m_buf; unsigned char* m_buf2; rendering_buffer m_rbuf_window; rendering_buffer m_rbuf_window2; unsigned m_bpp; unsigned m_sys_bpp; GLenum m_gl_format; GLenum m_gl_pixel_type; // public: // platform_specific* m_specific; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/win32/0000755000175000017500000000000012516137726020125 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/src/win32/agg_platform_specific.cpp0000644000175000017500000002267412516137326025147 0ustar varunvarun #include #include #include #include "agg_basics.h" #include "util/agg_color_conv_rgb8.h" #include "win32/agg_platform_specific.h" #include "win32/agg_bmp.h" #if 0 #define DEBUG_MTH(NAME) fprintf(stderr, NAME "\n"); #define DEBUG_MTH2(STR,ARG1,ARG2) fprintf(stderr, STR "\n",(ARG1),(ARG2)); #define DEBUG_MTH5(STR,ARG1,ARG2,ARG3,ARG4,ARG5) fprintf(stderr, STR "\n",(ARG1),(ARG2),(ARG3),(ARG4),(ARG5)); #else #define DEBUG_MTH(NAME) #define DEBUG_MTH2(STR,ARG1,ARG2) #define DEBUG_MTH5(STR,ARG1,ARG2,ARG3,ARG4,ARG5) #endif namespace agg24 { dib_display::dib_display() { } dib_display::~dib_display() { } BImage* dib_display::create_image(const rendering_buffer* rbuf, unsigned bits_per_pixel) { DEBUG_MTH("dib_display::create_image"); unsigned width = rbuf->width(); unsigned height = rbuf->height(); unsigned line_len = platform_specific::calc_row_len(width, bits_per_pixel); unsigned img_size = line_len * height; unsigned rgb_size = calc_palette_size(0, bits_per_pixel) * sizeof(RGBQUAD); unsigned full_size = sizeof(BITMAPINFOHEADER) + rgb_size;// + img_size; BITMAPINFO *bmp = (BITMAPINFO *) new unsigned char[full_size]; bmp->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmp->bmiHeader.biWidth = width; bmp->bmiHeader.biHeight = -height; bmp->bmiHeader.biPlanes = 1; bmp->bmiHeader.biBitCount = (unsigned short)bits_per_pixel; bmp->bmiHeader.biCompression = 0; bmp->bmiHeader.biSizeImage = img_size; bmp->bmiHeader.biXPelsPerMeter = 0; bmp->bmiHeader.biYPelsPerMeter = 0; bmp->bmiHeader.biClrUsed = 0; bmp->bmiHeader.biClrImportant = 0; RGBQUAD *rgb = (RGBQUAD*)(((unsigned char*)bmp) + sizeof(BITMAPINFOHEADER)); unsigned brightness; unsigned i; for(i = 0; i < rgb_size; i++) { brightness = (255 * i) / (rgb_size - 1); rgb->rgbBlue = rgb->rgbGreen = rgb->rgbRed = (unsigned char)brightness; rgb->rgbReserved = 0; rgb++; } BImage* image = new BImage; image->bmp = bmp; image->data = (unsigned char*)rbuf->buf(); return image; } void dib_display::destroy_image(BImage* image) { if (image != NULL) { delete [] (unsigned char*)(image->bmp); delete [] (unsigned char*)(image->data); // using XDestroyImage behavior. delete image; } } unsigned dib_display::calc_header_size(BITMAPINFO *bmp) { if (bmp == NULL) { return 0; } else { return sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * calc_palette_size(bmp); } } unsigned dib_display::calc_palette_size(BITMAPINFO *bmp) { if (bmp == 0) { return 0; } else { return calc_palette_size(bmp->bmiHeader.biClrUsed, bmp->bmiHeader.biBitCount); } } unsigned dib_display::calc_palette_size(unsigned clr_used, unsigned bits_per_pixel) { int palette_size = 0; if(bits_per_pixel <= 8) { palette_size = clr_used; if(palette_size == 0) { palette_size = 1 << bits_per_pixel; } } return palette_size; } bool dib_display::put_image(HDC dc, BImage *image, int draw_x, int draw_y, int draw_width, int draw_height) { DEBUG_MTH("dib_display::put_image"); // If specified, only do a partial blit of the image int dest_x, dest_y, src_x, src_y, src_width, src_height; if (draw_x != -1 && draw_y != -1 && draw_width != -1 && draw_height != -1) { src_x = draw_x; src_y = draw_y; dest_y = -image->bmp->bmiHeader.biHeight - draw_y - draw_height; dest_x = draw_x; src_width = draw_width; src_height = draw_height; } else { src_x = 0; src_y = 0; dest_x = 0; dest_y = 0; src_width = image->bmp->bmiHeader.biWidth; src_height = -image->bmp->bmiHeader.biHeight; } ::SetDIBitsToDevice( dc, // handle to device context dest_x, // x-coordinate of upper-left corner of dest dest_y, // y-coordinate of upper-left corner of dest src_width, // source rectangle width src_height, // source rectangle height src_x, // x-coordinate of lower-left corner of source src_y, // y-coordinate of lower-left corner of source 0, // first scan line in array -image->bmp->bmiHeader.biHeight, // number of scan lines image->data, // address of array with DIB bits image->bmp, // address of structure with bitmap info. DIB_RGB_COLORS // RGB or palette indexes ); return true; } dib_display platform_specific::dib; //------------------------------------------------------------------------ platform_specific::platform_specific(pix_format_e format, bool flip_y) : m_bpp(0), m_flip_y(flip_y), m_bimage(0), m_format(format), m_sys_format(pix_format_undefined), m_sys_bpp(0) { switch(m_format) { case pix_format_gray8: m_sys_format = pix_format_gray8; m_bpp = 8; m_sys_bpp = 8; break; case pix_format_rgb565: case pix_format_rgb555: m_sys_format = pix_format_rgb555; m_bpp = 16; m_sys_bpp = 16; break; case pix_format_rgb24: case pix_format_bgr24: m_sys_format = pix_format_bgr24; m_bpp = 24; m_sys_bpp = 24; break; case pix_format_bgra32: case pix_format_abgr32: case pix_format_argb32: case pix_format_rgba32: m_sys_format = pix_format_bgra32; m_bpp = 32; m_sys_bpp = 32; break; case pix_format_undefined: case end_of_pix_formats: ; } } void platform_specific::destroy() { DEBUG_MTH("platform_specific::destroy"); if (m_bimage != NULL) { dib.destroy_image(m_bimage); m_bimage = 0; } } //------------------------------------------------------------------------ void platform_specific::display_pmap(HDC dc, const rendering_buffer* rbuf, int draw_x, int draw_y, int draw_width, int draw_height) { if(m_sys_format == m_format) { if (m_bimage == 0) { m_bimage = dib.create_image(rbuf, m_bpp); } dib.put_image(dc, m_bimage, draw_x, draw_y, draw_width, draw_height); return; } // Optimization hint: make pmap_tmp as a private class member and reused it when possible. pixel_map pmap_tmp(rbuf->width(), rbuf->height(), m_sys_format, 256, m_flip_y); rendering_buffer* rbuf2 = &pmap_tmp.rbuf(); switch(m_format) { case pix_format_rgb565: color_conv(rbuf2, rbuf, color_conv_rgb565_to_rgb555()); break; case pix_format_rgb24: color_conv(rbuf2, rbuf, color_conv_rgb24_to_bgr24()); break; case pix_format_abgr32: color_conv(rbuf2, rbuf, color_conv_abgr32_to_bgra32()); break; case pix_format_argb32: color_conv(rbuf2, rbuf, color_conv_argb32_to_bgra32()); break; case pix_format_rgba32: color_conv(rbuf2, rbuf, color_conv_rgba32_to_bgra32()); break; case pix_format_gray8: case end_of_pix_formats: case pix_format_undefined: ; } // This will ultimately call back to us, going to the top if branch since // the pix_format is compatible. pmap_tmp.draw(dc, draw_x, draw_y, draw_width, draw_height); } //------------------------------------------------------------------------ unsigned platform_specific::calc_row_len(unsigned width, unsigned bits_per_pixel) { unsigned n = width; unsigned k; switch(bits_per_pixel) { case 1: k = n; n = n >> 3; if(k & 7) n++; break; case 4: k = n; n = n >> 1; if(k & 3) n++; break; case 8: break; case 16: n = n << 1; break; case 24: n = (n << 1) + n; break; case 32: n = n << 2; break; default: n = 0; break; } return ((n + 3) >> 2) << 2; } } enthought-chaco2-4.5.1.orig/kiva/agg/src/win32/wx_agg_debug/0000755000175000017500000000000012516137726022547 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/src/win32/wx_agg_debug/wx_agg_debug.dsp0000755000175000017500000001043512516137326025703 0ustar varunvarun# Microsoft Developer Studio Project File - Name="wx_agg" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=wx_agg - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "wx_agg_debug.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "wx_agg_debug.mak" CFG="wx_agg - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "wx_agg - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "wx_agg - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "wx_agg - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WX_AGG_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WX_AGG_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 !ELSEIF "$(CFG)" == "wx_agg - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WX_AGG_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "../../" /I "c:/python23/include" /I "../../../agg2/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WX_AGG_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 c:\python23\libs\python23.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../../../_plat_support.pyd" /pdbtype:sept !ENDIF # Begin Target # Name "wx_agg - Win32 Release" # Name "wx_agg - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=..\agg_bmp.cpp # End Source File # Begin Source File SOURCE=..\agg_platform_specific.cpp # End Source File # Begin Source File SOURCE=..\plat_support_wrap.cpp # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=..\agg_bmp.h # End Source File # Begin Source File SOURCE=..\agg_platform_specific.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project enthought-chaco2-4.5.1.orig/kiva/agg/src/win32/wx_agg_debug/wx_agg_debug.dsw0000755000175000017500000000100612516137326025704 0ustar varunvarunMicrosoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "wx_agg_debug"=.\wx_agg_debug.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### enthought-chaco2-4.5.1.orig/kiva/agg/src/win32/plat_support.i0000644000175000017500000000724712516137326023041 0ustar varunvarun// -*- c++ -*- %module plat_support %include numeric.i %{ #include "win32/agg_bmp.h" namespace agg24 { PyObject* pixel_map_as_unowned_array(agg24::pixel_map& pix_map) { npy_intp dims[3]; npy_intp rows = pix_map.height(); npy_intp cols = pix_map.width(); npy_intp depth = pix_map.bpp() / 8; dims[0] = rows; dims[1] = cols; dims[2] = depth; return PyArray_SimpleNewFromData(3,dims,NPY_UINT8,(void*)pix_map.buf()); } } %} %typemap(in) HDC { %#if SIZEOF_SIZE_T == 8 $1 = ($1_ltype) PyLong_AsLongLong($input); %#else $1 = ($1_ltype) PyLong_AsLong($input); %#endif if (PyErr_Occurred()) SWIG_fail; } %typemap(out) HDC { %#if SIZEOF_SIZE_T == 8 $result = PyLong_FromLongLong((long long) $1); %#else $result = PyLong_FromLong((long) $1); %#endif if (PyErr_Occurred()) SWIG_fail; } %apply HDC { HWND }; // More permissive unsigned typemap that converts any numeric type to an // unsigned value. It is cleared at the end of this file. %typemap(in) unsigned { PyObject* obj = PyNumber_Int($input); if (PyErr_Occurred()) SWIG_fail; $1 = (unsigned) PyLong_AsLong(obj); if (PyErr_Occurred()) SWIG_fail; } namespace agg24 { enum pix_format_e { pix_format_undefined = 0, // By default. No conversions are applied pix_format_gray8, // Simple 256 level grayscale pix_format_rgb555, // 15 bit rgb. Depends on the byte ordering! pix_format_rgb565, // 16 bit rgb. Depends on the byte ordering! pix_format_rgb24, // R-G-B, one byte per color component pix_format_bgr24, // B-G-R, native win32 BMP format. pix_format_rgba32, // R-G-B-A, one byte per color component pix_format_argb32, // A-R-G-B, native MAC format pix_format_abgr32, // A-B-G-R, one byte per color component pix_format_bgra32, // B-G-R-A, native win32 BMP format end_of_pix_formats }; %rename(PixelMap) pixel_map; class pixel_map { public: ~pixel_map(); pixel_map(unsigned width, unsigned height, pix_format_e format, unsigned clear_val, bool bottom_up); public: %feature("shadow") draw(HDC h_dc, int x, int y, double scale) const %{ def draw(self, h_dc, x=0, y=0, width=0, height=0): # fix me: brittle becuase we are hard coding # module and class name. Done cause SWIG 1.3.24 does # some funky overloading stuff in it that breaks keyword # arguments. result = _plat_support.PixelMap_draw(self, h_dc, x, y, width, height) return result %} void draw(HDC h_dc, int x, int y, int width, int height) const; PyObject* convert_to_argb32string() const; %pythoncode %{ def set_bmp_array(self): self.bmp_array = pixel_map_as_unowned_array(self) return self def draw_to_tkwindow(self, window, x, y): window_id = window._tk_widget.winfo_id() hdc = GetDC(window_id) self.draw(hdc, x, y) ReleaseDC(window_id, hdc) return def draw_to_wxwindow(self, window, x, y, width=-1, height=-1): window_dc = getattr(window,'_dc',None) if window_dc is None: window_dc = wx.PaintDC(window) self.draw(window_dc.GetHDC(), x, y, width, height) return %} }; PyObject* pixel_map_as_unowned_array(pixel_map& pix_map); } HDC GetDC(HWND hWnd); int ReleaseDC(HWND hWnd, HDC hDC); // clear the "permissive" unsigned typemap we are using. %typemap(in) unsigned; enthought-chaco2-4.5.1.orig/kiva/agg/src/win32/agg_platform_specific.h0000644000175000017500000000504112516137326024601 0ustar varunvarun// -*- c++ -*- #ifndef AGG_WIN32_SPECIFIC_INCLUDED #define AGG_WIN32_SPECIFIC_INCLUDED #include #include "agg_basics.h" #include "agg_rendering_buffer.h" namespace agg24 { enum pix_format_e { pix_format_undefined = 0, // By default. No conversions are applied pix_format_gray8, // Simple 256 level grayscale pix_format_rgb555, // 15 bit rgb. Depends on the byte ordering! pix_format_rgb565, // 16 bit rgb. Depends on the byte ordering! pix_format_rgb24, // R-G-B, one byte per color component pix_format_bgr24, // B-G-R, native win32 BMP format. pix_format_rgba32, // R-G-B-A, one byte per color component pix_format_argb32, // A-R-G-B, native MAC format pix_format_abgr32, // A-B-G-R, one byte per color component pix_format_bgra32, // B-G-R-A, native win32 BMP format end_of_pix_formats }; typedef struct { BITMAPINFO* bmp; unsigned char* data; } BImage; class dib_display { public: dib_display(); ~dib_display(); bool put_image(HDC dc, BImage* image, int draw_x=-1, int draw_y=-1, int draw_width=-1, int draw_height=-1); BImage* create_image(const rendering_buffer* rbuf, unsigned bits_per_pixel); void destroy_image(BImage* image); private: static unsigned calc_header_size(BITMAPINFO *bmp); static unsigned calc_palette_size(BITMAPINFO *bmp); static unsigned calc_palette_size(unsigned clr_used, unsigned bits_per_pixel); }; class platform_specific { static dib_display dib; public: platform_specific(pix_format_e format, bool flip_y); ~platform_specific() {} void display_pmap(HDC dc, const rendering_buffer* src, int draw_x=-1, int draw_y=-1, int draw_width=-1, int draw_height=-1); void destroy(); static unsigned calc_row_len(unsigned width, unsigned bits_per_pixel); unsigned m_bpp; bool m_flip_y; BImage* m_bimage; pix_format_e m_format; private: pix_format_e m_sys_format; unsigned m_sys_bpp; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/win32/agg_bmp.cpp0000644000175000017500000001032612516137326022223 0ustar varunvarun#include #include #include "win32/agg_bmp.h" #include "win32/agg_platform_specific.h" #include "agg_pixfmt_rgba.h" #include "agg_color_rgba.h" #if 0 #define DEBUG_MTH(NAME) fprintf(stderr, NAME "\n"); #define DEBUG_MTH2(STR,ARG1,ARG2) fprintf(stderr, STR "\n",(ARG1),(ARG2)); #define DEBUG_MTH5(STR,ARG1,ARG2,ARG3,ARG4,ARG5) fprintf(stderr, STR "\n",(ARG1),(ARG2),(ARG3),(ARG4),(ARG5)); #else #define DEBUG_MTH(NAME) #define DEBUG_MTH2(STR,ARG1,ARG2) #define DEBUG_MTH5(STR,ARG1,ARG2,ARG3,ARG4,ARG5) #endif namespace agg24 { //------------------------------------------------------------------------ pixel_map::pixel_map(unsigned width, unsigned height, pix_format_e format, unsigned clear_val, bool bottom_up): m_buf(NULL), m_specific(new platform_specific(format, bottom_up)) { DEBUG_MTH5("pixel_map::pixel_map(%d,%d,%d,%d,%d)",width,height,format,clear_val,bottom_up); m_bpp = m_specific->m_bpp; create(width, height, clear_val); } //------------------------------------------------------------------------ pixel_map::~pixel_map() { DEBUG_MTH("pixel_map::~pixel_map"); destroy(); delete m_specific; } //------------------------------------------------------------------------ void pixel_map::destroy() { DEBUG_MTH("pixel_map::destroy()"); if (m_specific->m_bimage != NULL) { DEBUG_MTH("pixel_map::destroy() m_bimage != NULL"); m_specific->destroy(); m_buf = NULL; } if (m_buf != NULL) { delete[] m_buf; m_buf = NULL; } } //------------------------------------------------------------------------ void pixel_map::create(unsigned width, unsigned height, unsigned clear_val) { destroy(); if(width == 0) width = 1; if(height == 0) height = 1; unsigned row_len = platform_specific::calc_row_len(width, m_bpp); unsigned img_size = row_len * height; m_buf = new unsigned char[img_size]; if(clear_val <= 255) { memset(m_buf, clear_val, img_size); } m_rbuf_window.attach(m_buf, width, height, (m_specific->m_flip_y ? -row_len : row_len)); } //------------------------------------------------------------------------ void pixel_map::draw(HDC dc, int draw_x, int draw_y, int draw_width, int draw_height) const { DEBUG_MTH("pixel_map::draw"); if (m_buf != NULL) { m_specific->display_pmap(dc, &m_rbuf_window, draw_x, draw_y, draw_width, draw_height); } } pix_format_e pixel_map::get_pix_format() const { return m_specific->m_format; } unsigned char* pixel_map::buf() { return m_buf; } unsigned pixel_map::width() const { return m_rbuf_window.width(); } unsigned pixel_map::height() const { return m_rbuf_window.height(); } int pixel_map::stride() const { return platform_specific::calc_row_len(width(), m_bpp); } // Convert to a Python string containing 32 bit ARGB values. PyObject* pixel_map::convert_to_argb32string() const { unsigned w = width(); unsigned h = height(); PyObject *str = PyString_FromStringAndSize(NULL, w * h * 4); if (str == NULL) return NULL; unsigned *data = (unsigned *)PyString_AS_STRING(str); pix_format_e format = get_pix_format(); switch (format) { case pix_format_bgra32: { pixfmt_bgra32 r((rendering_buffer &)m_rbuf_window); for (unsigned j = 0; j < h; ++j) for (unsigned i = 0; i < w; ++i) { rgba8 c = r.pixel(i, h - j - 1); *data++ = (((unsigned char)c.a) << 24) | (((unsigned char)c.r) << 16) | (((unsigned char)c.g) << 8) | ((unsigned char)c.b); } } break; default: Py_DECREF(str); PyErr_Format(PyExc_ValueError, "pix_format %d not handled", format); return NULL; } return str; } } enthought-chaco2-4.5.1.orig/kiva/agg/src/win32/agg_bmp.h0000644000175000017500000000244312516137326021671 0ustar varunvarun// -*- c++ -*- #ifndef AGG_WIN32_BMP_INCLUDED #define AGG_WIN32_BMP_INCLUDED #include "Python.h" #include "win32/agg_platform_specific.h" namespace agg24 { class pixel_map { public: pixel_map(unsigned width, unsigned height, pix_format_e format, unsigned clear_val, bool bottom_up); ~pixel_map(); void draw(HDC h_dc, int draw_x=-1, int draw_y=-1, int draw_width=-1, int draw_height=-1) const; pix_format_e get_pix_format() const; unsigned char* buf(); unsigned width() const; unsigned height() const; int stride() const; unsigned bpp() const { return m_bpp; } rendering_buffer& rbuf() { return m_rbuf_window; } platform_specific* m_specific; PyObject* convert_to_argb32string() const; private: void destroy(); void create(unsigned width, unsigned height, unsigned clear_val=256); unsigned char* m_buf; unsigned m_bpp; rendering_buffer m_rbuf_window; public: }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_rect.h0000755000175000017500000000711712516137326021310 0ustar varunvarun#ifndef RECT_H #define RECT_H #include "agg_basics.h" #include "kiva_basics.h" #include namespace kiva { //----------------------------------------------------------------------- // graphics_state class //----------------------------------------------------------------------- class rect_type { public: // constructors inline rect_type(): x(0), y(0), w(-1), h(-1) { } inline rect_type(double newx, double newy, double neww, double newh): x(newx), y(newy), w(neww), h(newh) { } inline rect_type(agg24::rect_i r) { *this = r; } inline rect_type(agg24::rect_d r) { *this = r; } // conversion from agg24::rect inline rect_type& operator=(agg24::rect_i &r) { x = int(r.x1); y = int(r.y1); w = int(r.x2 - r.x1); h = int(r.y2 - r.y1); return *this; } inline rect_type& operator=(agg24::rect_d &r) { x = r.x1; y = r.y1; w = r.x2 - r.x1; h = r.y2 - r.y1; return *this; } inline bool operator==(rect_type& other) { return ((x == other.x) && (y == other.y) && (w == other.w) && (h == other.h)); } inline bool operator!=(rect_type& other) { return !(*this == other); } // conversion to agg24::rect inline operator agg24::rect_i() const { return agg24::rect_i(int(x), int(y), int(w), int(h)); } inline operator agg24::rect_d() const { return agg24::rect_d(x, y, w, h); } // conversion to double[4] inline double operator[](unsigned int ndx) const { switch (ndx) { case 0: return x; case 1: return y; case 2: return w; case 3: return h; } } // comparison inline bool operator==(const rect_type &b) const { return ((this->x == b.x) && (this->y == b.y) && (this->w == b.w) && (this->h == b.h)); } // utility functions: inline double x2() const { return x+w; } inline double y2() const { return y+h; } double x, y, w, h; }; typedef std::vector rect_list_type; typedef rect_list_type::iterator rect_iterator; // This returns the rectangle representing the overlapping area between // rectangles a and b. If they do not overlap, the returned rectangle // will have width and height -1. // // (We use -1 instead of 0 because Agg will accept clip rectangles of // size 0.) rect_type disjoint_intersect(const rect_type &a, const rect_type &b); // Returns a list of rectangles resulting from the intersection of the // input list of rectangles. If there are no intersection regions, // returns an empty list. rect_list_type disjoint_intersect(const rect_list_type &rects); // Intersects a single rectangle against a list of existing, non- // intersecting rectangles, and returns a list of the intersection regions. // If there are no intersection regions, returns an empty list. rect_list_type disjoint_intersect(const rect_list_type &original_list, const rect_type &new_rect); rect_list_type disjoint_union(const rect_type &a, const rect_type &b); rect_list_type disjoint_union(const rect_list_type &rects); rect_list_type disjoint_union(rect_list_type original_list, const rect_type &new_rect); void test_disjoint_union(); } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/numeric.i0000644000175000017500000002561012516137326020777 0ustar varunvarun/* -*- c -*- */ /* Set the input argument to point to a temporary variable */ /* Here are the typemap helper functions for numeric arrays: PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode) PyArrayObject* obj_to_array_allow_conversion(PyObject* input, int typecode, int& is_new_object) PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input, int typecode, int& is_new_object) PyArrayObject* make_contiguous(PyArrayObject* ary, int& is_new_object, int min_dims = 0, int max_dims = 0) int require_contiguous(PyArrayObject* ary) int require_last_dimensions_contiguous(PyArrayObject* ary, int dim_count) int require_dimensions(PyArrayObject* ary, int exact_dimensions) int require_dimensions(PyArrayObject* ary, int* exact_dimensions, int n) int require_size(PyArrayObject* ary, int* size, int n) */ %{ #ifdef NUMPY #include "numpy/arrayobject.h" # ifndef PyArray_SBYTE # include "numpy/oldnumeric.h" # include "numpy/old_defines.h" # endif #else #include "Numeric/arrayobject.h" #define PyArray_UBYTELTR 'b' #endif #include #define is_array(a) ((a) && PyArray_Check((PyArrayObject *)a)) #define array_type(a) (int)(((PyArrayObject *)a)->descr->type_num) #define array_dimensions(a) (((PyArrayObject *)a)->nd) #define array_size(a,i) (((PyArrayObject *)a)->dimensions[i]) #define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(ary)) std::string pytype_string(PyObject* py_obj) { if(py_obj == NULL) return "C NULL value"; if(PyCallable_Check(py_obj)) return "callable"; if(PyString_Check(py_obj)) return "string"; if(PyInt_Check(py_obj)) return "int"; if(PyFloat_Check(py_obj)) return "float"; if(PyDict_Check(py_obj)) return "dict"; if(PyList_Check(py_obj)) return "list"; if(PyTuple_Check(py_obj)) return "tuple"; if(PyFile_Check(py_obj)) return "file"; if(PyModule_Check(py_obj)) return "module"; //should probably do more intergation (and thinking) on these. if(PyCallable_Check(py_obj) && PyInstance_Check(py_obj)) return "callable"; if(PyInstance_Check(py_obj)) return "instance"; if(PyCallable_Check(py_obj)) return "callable"; return "unkown type"; } std::string typecode_string(int typecode) { std::string type_names[20] = {"char","unsigned byte","byte", "short", "unsigned short", "int", "unsigned int", "long", "float", "double", "complex float", "complex double", "object","ntype", "unkown"}; return type_names[typecode]; } int type_match(int actual_type, int desired_type) { int match; // Make sure input has correct numeric type. Allow character and byte to // match also allow int and long to match. if ( actual_type != desired_type && !(desired_type == PyArray_CHAR && actual_type == PyArray_SBYTE) && !(desired_type == PyArray_SBYTE && actual_type == PyArray_CHAR) && !(desired_type == PyArray_INT && actual_type == PyArray_LONG) && !(desired_type == PyArray_LONG && actual_type == PyArray_INT)) { match = 0; } else { match = 1; } return match; } PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode) { PyArrayObject* ary = NULL; if (is_array(input) && array_type(input) == typecode) { ary = (PyArrayObject*) input; } else if is_array(input) { char msg[255] = "Array of type '%s' required. Array of type '%s' given"; std::string desired_type = typecode_string(typecode); std::string actual_type = typecode_string(array_type(input)); PyErr_Format(PyExc_TypeError, msg, desired_type.c_str(), actual_type.c_str()); ary = NULL; } else { char msg[255] = "Array of type '%s' required. A %s was given"; std::string desired_type = typecode_string(typecode); std::string actual_type = pytype_string(input); PyErr_Format(PyExc_TypeError, msg, desired_type.c_str(), actual_type.c_str()); ary = NULL; } return ary; } PyArrayObject* obj_to_array_allow_conversion(PyObject* input, int typecode, int& is_new_object) { // Convert object to a Numeric array with the given typecode. // // Return: // On Success, return a valid PyArrayObject* with the correct type. // On failure, return NULL. A python error will have been set. PyArrayObject* ary = NULL; if (is_array(input) && type_match(array_type(input),typecode)) { ary = (PyArrayObject*) input; is_new_object = 0; } else { PyObject* py_obj = PyArray_FromObject(input, typecode, 0, 0); // If NULL, PyArray_FromObject will have set python error value. ary = (PyArrayObject*) py_obj; is_new_object = 1; } return ary; } PyArrayObject* make_contiguous(PyArrayObject* ary, int& is_new_object, int min_dims = 0, int max_dims = 0) { PyArrayObject* result; if (array_is_contiguous(ary)) { result = ary; is_new_object = 0; } else { result = (PyArrayObject*) PyArray_ContiguousFromObject( (PyObject*)ary, array_type(ary), min_dims, max_dims); is_new_object = 1; } return result; } PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject* input, int typecode, int& is_new_object) { int is_new1 = 0; int is_new2 = 0; PyArrayObject* ary1 = obj_to_array_allow_conversion(input, typecode, is_new1); if (ary1) { PyArrayObject* ary2 = make_contiguous(ary1, is_new2); if ( is_new1 && is_new2) { Py_DECREF(ary1); } ary1 = ary2; } is_new_object = is_new1 || is_new2; return ary1; } int require_contiguous(PyArrayObject* ary) { // Test whether a python object is contiguous. // // Return: // 1 if array is contiguous. // Otherwise, return 0 and set python exception. int contiguous = 1; if (!array_is_contiguous(ary)) { char msg[255] = "Array must be contiguous. A discontiguous array was given"; PyErr_SetString(PyExc_TypeError, msg); contiguous = 0; } return contiguous; } // Useful for allowing images with discontiguous first dimension. // This sort of array is used for arrays mapped to Windows bitmaps. /* int require_last_dimensions_contiguous(PyArrayObject* ary, int dim_count) { int contiguous = 1; if (array_is_contiguous(ary)) { char msg[255] = "Array must be contiguous. A discontiguous array was given"; PyErr_SetString(PyExc_TypeError, msg); contiguous = 0; } return contiguous; } */ int require_dimensions(PyArrayObject* ary, int exact_dimensions) { int success = 1; if (array_dimensions(ary) != exact_dimensions) { char msg[255] = "Array must be have %d dimensions. Given array has %d dimensions"; PyErr_Format(PyExc_TypeError, msg, exact_dimensions, array_dimensions(ary)); success = 0; } return success; } int require_dimensions(PyArrayObject* ary, int* exact_dimensions, int n) { int success = 0; int i; for (i = 0; i < n && !success; i++) { if (array_dimensions(ary) == exact_dimensions[i]) { success = 1; } } if (!success) { char dims_str[255] = ""; char s[255]; for (int i = 0; i < n-1; i++) { sprintf(s, "%d, ", exact_dimensions[i]); strcat(dims_str,s); } sprintf(s, " or %d", exact_dimensions[n-1]); strcat(dims_str,s); char msg[255] = "Array must be have %s dimensions. Given array has %d dimensions"; PyErr_Format(PyExc_TypeError, msg, dims_str, array_dimensions(ary)); } return success; } int require_size(PyArrayObject* ary, int* size, int n) { int i; int success = 1; for(i=0; i < n;i++) { if (size[i] != -1 && size[i] != array_size(ary,i)) { success = 0; } } if (!success) { int len; char desired_dims[255] = "["; char s[255]; for (i = 0; i < n; i++) { if (size[i] == -1) { sprintf(s, "*,"); } else { sprintf(s, "%d,", size[i]); } strcat(desired_dims,s); } len = strlen(desired_dims); desired_dims[len-1] = ']'; char actual_dims[255] = "["; for (i = 0; i < n; i++) { sprintf(s, "%d,", (int)array_size(ary,i)); strcat(actual_dims,s); } len = strlen(actual_dims); actual_dims[len-1] = ']'; char msg[255] = "Array must be have shape of %s. Given array has shape of %s"; PyErr_Format(PyExc_TypeError, msg, desired_dims, actual_dims); } return success; } %} %pythoncode %{ from numpy import ndarray def is_array(obj): return type(obj) is ndarray def is_correct_type(obj, numeric_type): return is_array(obj) and (obj.dtype == numeric_type) def numpy_check(obj, typecode, exact_size = [], must_be_contiguous = 1, allow_coersion = 0): if is_correct_type(obj, typecode): ary = obj elif allow_coersion: ary = asarray(obj,typecode) else: raise TypeError, "input is not an array or the array has the wrong type" if must_be_contiguous and not ary.flags["CONTIGUOUS"]: if allow_coersion: ary = ary.copy() else: raise TypeError, "input array must be contiguous" # check number of dimensions required_dims = len(exact_size) if required_dims and required_dims != len(ary.shape): raise ValueError, "The input array does not have the correct shape" # check exact shape of each dimension cnt = 0 for desired,actual in zip(exact_size,ary.shape): if desired != -1 and desired != actual: raise ValueError, "The %d dimensions of the array has the wrong shape" % (cnt) cnt += 1 return ary %} %init %{ Py_Initialize(); import_array(); #ifdef NUMPY PyImport_ImportModule("numpy"); #else PyImport_ImportModule("Numeric"); #endif %} enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_image_filters.h0000644000175000017500000001010012516137326023144 0ustar varunvarun#ifndef KIVA_IMAGE_FILTERS_H #define KIVA_IMAGE_FILTERS_H #include "agg_pixfmt_rgb.h" #include "agg_pixfmt_rgba.h" #include "agg_span_image_filter_rgba.h" #include "agg_span_image_filter_rgb.h" #include "agg_image_accessors.h" #include "agg_span_interpolator_linear.h" namespace kiva { typedef agg24::span_interpolator_linear<> interpolator_type; template class image_filters { }; template<> class image_filters { public: typedef agg24::image_accessor_clip source_type; typedef agg24::span_image_filter_rgba_nn nearest_type; typedef agg24::span_image_filter_rgba_bilinear bilinear_type; typedef agg24::span_image_filter_rgba general_type; }; template<> class image_filters { public: typedef agg24::image_accessor_clip source_type; typedef agg24::span_image_filter_rgba_nn nearest_type; typedef agg24::span_image_filter_rgba_bilinear bilinear_type; typedef agg24::span_image_filter_rgba general_type; }; template<> class image_filters { public: typedef agg24::image_accessor_clip source_type; typedef agg24::span_image_filter_rgba_nn nearest_type; typedef agg24::span_image_filter_rgba_bilinear bilinear_type; typedef agg24::span_image_filter_rgba general_type; }; template<> class image_filters { public: typedef agg24::image_accessor_clip source_type; typedef agg24::span_image_filter_rgba_nn nearest_type; typedef agg24::span_image_filter_rgba_bilinear bilinear_type; typedef agg24::span_image_filter_rgba general_type; }; template<> class image_filters { public: typedef agg24::image_accessor_clip source_type; typedef agg24::span_image_filter_rgb_nn nearest_type; typedef agg24::span_image_filter_rgb_bilinear bilinear_type; typedef agg24::span_image_filter_rgb general_type; }; template<> class image_filters { public: typedef agg24::image_accessor_clip source_type; typedef agg24::span_image_filter_rgb_nn nearest_type; typedef agg24::span_image_filter_rgb_bilinear bilinear_type; typedef agg24::span_image_filter_rgb general_type; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/gl_graphics_context.cpp0000644000175000017500000010246512516137326023721 0ustar varunvarun // #ifndef MULTI_DRAW_ELEMENTS // #define MULTI_DRAW_ELEMENTS glMultiDrawElements // #endif #include #include "kiva_affine_helpers.h" #include "kiva_exceptions.h" #include "kiva_rect.h" #include "gl_graphics_context.h" using namespace kiva; #ifndef CALLBACK #define CALLBACK #endif #ifndef M_PI #define M_PI 3.1415926535 #endif #define EXPAND_COLOR(c) c->r, c->g, c->b, (c->a * this->state.alpha) // This should be just double, but as long as we're using C++... typedef agg24::path_storage::container_type::value_type VertexType; struct PointType { VertexType x,y,z; }; typedef std::vector PointListType; static void _submit_path_points(PointListType const & points, bool polygon, bool fill); static void CALLBACK _combine_callback(GLdouble coords[3], GLdouble *vert_data[4], GLfloat weight[4], GLdouble **dataOut); static void CALLBACK _vertex_callback(GLvoid *vertex); gl_graphics_context::gl_graphics_context(int width, int height, kiva::pix_format_e format) : graphics_context_base(NULL, width, height, 1, kiva::nearest) , m_width(width) , m_height(height) , m_gl_initialized(false) , m_pixfmt(format) { } gl_graphics_context::~gl_graphics_context() { if (m_gl_initialized) { this->gl_cleanup(); } } void gl_graphics_context::gl_init() { glViewport(0, 0, m_width, m_height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, m_width, 0, m_height, 1, -1); glMatrixMode(GL_MODELVIEW); //glPushMatrix(); glLoadIdentity(); // Use scissors to implement clipping glEnable(GL_SCISSOR_TEST); // Need to set up blending for antialiasing glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE); glHint(GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE); // Clear the clip region // This is important. Since GL maintains a persistent, global context // across the application, we may very well inherit the scissor mask // from a clip_to_rect() call on a previous GC. clip_to_rect(0, 0, m_width, m_height); } void gl_graphics_context::gl_cleanup() { //glMatrixMode(GL_MODELVIEW); //glPopMatrix(); } kiva::pix_format_e gl_graphics_context::format() { return m_pixfmt; } void gl_graphics_context::save_state() { graphics_context_base::save_state(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); } void gl_graphics_context::restore_state() { if (this->state_stack.size() == 0) { return; } this->state = this->state_stack.top(); this->state_stack.pop(); this->path.restore_ctm(); // Restore the clip state: // Compute the intersection of all the rects and use those as // the clip box if (this->state.use_rect_clipping()) { if (this->state.device_space_clip_rects.size() > 0) { kiva::rect_list_type rects = disjoint_intersect(this->state.device_space_clip_rects); // XXX: Right now we don't support disjoint clip rects. To implement // this, we would probably want to use a mask or stencil, or just // re-render with each clip rect set as the scissor. // XXX: figure out better way to round out the floating-point // dimensions for kiva_rect than just casting to int(). kiva::rect_iterator it = rects.begin(); glScissor(int(it->x), int(it->y), int(it->w), int(it->h)); } } else { throw clipping_path_unsupported; } // Restore the transformation matrices glMatrixMode(GL_MODELVIEW); glPopMatrix(); } void gl_graphics_context::begin_page() { glClearColor( 1.f, 1.f, 1.f, 0.f ); glClear( GL_COLOR_BUFFER_BIT ); } void gl_graphics_context::clip() { throw kiva::not_implemented_error; } void gl_graphics_context::even_odd_clip() { throw kiva::not_implemented_error; } void gl_graphics_context::clip_to_rect(double x, double y, double sx, double sy) { kiva::rect_type tmp(x, y, sx, sy); clip_to_rect(tmp); } void gl_graphics_context::clip_to_rect(kiva::rect_type &rect) { this->path.remove_all(); if (!this->state.use_rect_clipping()) { throw clipping_path_unsupported; } kiva::rect_type device_rect(transform_clip_rectangle(rect)); if (this->state.device_space_clip_rects.size() == 1) { kiva::rect_type old(this->state.device_space_clip_rects.back()); this->state.device_space_clip_rects.pop_back(); kiva::rect_type newrect(kiva::disjoint_intersect(old, device_rect)); if ((newrect.w < 0) || (newrect.h < 0)) { // new clip rectangle doesn't intersect anything, so we push on // an empty rect as the new clipping region. glScissor(0,0,0,0); //printf("NULL intersection area in clip_to_rect\n"); this->state.device_space_clip_rects.push_back(kiva::rect_type(0, 0, -1, -1)); } else { glScissor(int(newrect.x), int(newrect.y), int(newrect.w), int(newrect.h)); this->state.device_space_clip_rects.push_back(newrect); } } else { // we need to compute the intersection of the new rectangle with // the current set of clip rectangles. we assume that the existing // clip_rects are a disjoint set. this->state.device_space_clip_rects = kiva::disjoint_intersect( this->state.device_space_clip_rects, device_rect); if (this->state.device_space_clip_rects.size() == 0) { glScissor(0,0,0,0); //printf("NULL intersection area in clip_to_rect\n"); this->state.device_space_clip_rects.push_back(kiva::rect_type(0, 0, -1, -1)); } else { kiva::rect_list_type rects = disjoint_intersect(this->state.device_space_clip_rects); // XXX: Right now we don't support disjoint clip rects. // (same problem as in restore_state()) kiva::rect_iterator it = rects.begin(); glScissor(int(it->x), int(it->y), int(it->w), int(it->h)); if (rects.size() > 1) { //printf("Warning: more than 1 clip rect in clip_to_rect()\n"); } } } } void gl_graphics_context::clip_to_rects(double* new_rects, int Nrects) { printf("Clip to rects() unsupported\n"); } void gl_graphics_context::clip_to_rects(kiva::rect_list_type &rects) { printf("Clip to rects() unsupported\n"); } void gl_graphics_context::clear_clip_path() { // clear the existing clipping paths this->state.clipping_path.remove_all(); this->state.device_space_clip_rects.clear(); // set everything visible again. glScissor(0, 0, m_width, m_height); // store the new clipping rectangle back into the first // rectangle of the graphics state clipping rects. this->state.device_space_clip_rects.push_back(kiva::rect_type(0, 0, m_width, m_height)); } // XXX: This is cut and paste from graphics_context.h; refactor into base // class. kiva::rect_type gl_graphics_context::transform_clip_rectangle(const kiva::rect_type &rect) { // This only works if the ctm doesn't have any rotation. // otherwise, we need to use a clipping path. Test for this. agg24::trans_affine tmp(this->path.get_ctm()); if ( !only_scale_and_translation(tmp)) { throw kiva::ctm_rotation_error; } double x = rect.x; double y = rect.y; double x2 = rect.x2(); double y2 = rect.y2(); this->path.get_ctm().transform(&x, &y); this->path.get_ctm().transform(&x2, &y2); // fix me: How should we round here? // maybe we should lrint, but I don't think it is portable. See // here: http://www.cs.unc.edu/~sud/tips/Programming_Tips.html x = int(floor(x+0.5)); y = int(floor(y+0.5)); // subtract 1 to account for agg (inclusive) vs. kiva (exclusive) clipping x2 = int(floor(x2+0.5))-1; y2 = int(floor(y2+0.5))-1; //x2 = int(floor(x2+0.5)); //y2 = int(floor(y2+0.5)); return kiva::rect_type(x, y, x2-x, y2-y); } int gl_graphics_context::get_num_clip_regions() { return this->state.device_space_clip_rects.size(); } kiva::rect_type gl_graphics_context::get_clip_region(unsigned int i) { throw kiva::not_implemented_error; } void gl_graphics_context::clear(agg24::rgba value) { glClearColor(float(value.r), float(value.g), float(value.b), float(value.a)); glClear(GL_COLOR_BUFFER_BIT); } void gl_graphics_context::fill_path() { draw_path(FILL); } void gl_graphics_context::eof_fill_path() { draw_path(EOF_FILL); } void gl_graphics_context::stroke_path() { draw_path(STROKE); } void gl_graphics_context::gl_render_path(kiva::compiled_path *path, bool polygon, bool fill) { if ((path == NULL) || (path->total_vertices() == 0)) return; unsigned command = 0; PointListType pointList; // Set the matrix mode so we support move_to commands glMatrixMode(GL_MODELVIEW); // Records the last move_to command position so that when // we finally encounter the first line_to, we can use this // vertex as the starting vertex. bool first_vertex_drawn = false; PointType v0 = {0.f, 0.f, 0.f}; PointType v = {0.f, 0.f, 0.f}; PointType vv = {0.f, 0.f, 0.f}; VertexType c1x, c1y, ccx, ccy, c2x, c2y, c3x, c3y; VertexType t, t2, t3, u, u2, u3; unsigned int j; unsigned int _Npoints = 100; // make space for points pointList.reserve(path->total_vertices()); for (unsigned int i=0; i < path->total_vertices(); i++) { command = path->vertex(i, &v.x, &v.y); switch (command & agg24::path_cmd_mask) { case agg24::path_cmd_line_to: if (!first_vertex_drawn) { pointList.push_back(v0); first_vertex_drawn = true; } pointList.push_back(v); break; case agg24::path_cmd_end_poly: // We shouldn't need to do anything because if this is a closed path // //if (command & agg24::path_flags_close) // glVertex2f(x0, y0); break; case agg24::path_cmd_curve3: // FIXME: refactor! if (!first_vertex_drawn) { pointList.push_back(v0); first_vertex_drawn = true; } path->vertex(i+1, &ccx, &ccy); path->vertex(i+2, &c3x, &c3y); i += 2; c1x = (v.x + ccx + ccx) / 3.0; c1y = (v.y + ccy + ccy) / 3.0; c2x = (c3x + ccx + ccx) / 3.0; c2y = (c3y + ccy + ccy) / 3.0; for (j=1; j<=_Npoints; j++) { t = ((VertexType)j) / _Npoints; t2 = t*t; t3 = t2*t; u = 1 - t; u2 = u*u; u3 = u2*u; vv.x = v.x * u3 + 3*(c1x*t*u2 + c2x*t2*u) + c3x*t3; vv.y = v.y * u3 + 3*(c1y*t*u2 + c2y*t2*u) + c3y*t3; pointList.push_back(vv); } break; case agg24::path_cmd_curve4: if (!first_vertex_drawn) { pointList.push_back(v0); first_vertex_drawn = true; } // The current point is implicitly the first control point v0 = pointList.back(); c1x = v.x; c1y = v.y; v.x = v0.x; v.y = v0.y; path->vertex(i+1, &c2x, &c2y); path->vertex(i+2, &c3x, &c3y); i += 2; for (j=1; j<=_Npoints; j++) { t = ((VertexType)j) / _Npoints; t2 = t*t; t3 = t2*t; u = 1 - t; u2 = u*u; u3 = u2*u; vv.x = v.x * u3 + 3*(c1x*t*u2 + c2x*t2*u) + c3x*t3; vv.y = v.y * u3 + 3*(c1y*t*u2 + c2y*t2*u) + c3y*t3; pointList.push_back(vv); } break; // The following commands are ignored. case agg24::path_cmd_move_to: if (!pointList.empty()) { // do a full glBegin/glEnd sequence for the points in the buffer _submit_path_points(pointList, polygon, fill); // flush pointList.clear(); } v0.x = v.x; v0.y = v.y; first_vertex_drawn = false; break; case agg24::path_cmd_ubspline: break; // XXX: This case number is already used?? //case agg24::path_cmd_mask: // break; // Unsupported // XXX: We need to have better error handling/reporting from the C++ // layer up to the Python layer. case agg24::path_cmd_catrom: case agg24::path_cmd_curveN: break; } } // submit the points if (!pointList.empty()) _submit_path_points(pointList, polygon, fill); } void gl_graphics_context::gl_render_points(double** points, bool polygon, bool fill, kiva::draw_mode_e mode) { } void gl_graphics_context::draw_path(draw_mode_e mode) { // XXX: This is a direct transcription from basecore2d. The algorithm // and approach can probably be improved tremendously for OpenGL. agg24::rgba *line_color = &this->state.line_color; agg24::rgba *fill_color = &this->state.fill_color; // CNP if (this->state.should_antialias) { glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); } else { glDisable(GL_LINE_SMOOTH); glDisable(GL_POLYGON_SMOOTH); } // Check to see if we have closed polygons typedef agg24::path_storage::container_type::value_type VertexType; unsigned numvertices = this->path.total_vertices(); bool polygon = false; if (numvertices > 1) { // Get the first vertex VertexType x0, y0, xf, yf; this->path.vertex(0, &x0, &y0); // Go backwards from the last vertex until we find an actual line_to // or curve3 or curve4 comand. for (int i=numvertices-1; i>0; i--) { unsigned cmd = this->path.vertex(i, &xf, &yf); if (((cmd & agg24::path_cmd_mask) == agg24::path_cmd_curve3) || ((cmd & agg24::path_cmd_mask) == agg24::path_cmd_curve4) || ((cmd & agg24::path_cmd_mask) == agg24::path_cmd_line_to)) { if ((x0 == xf) && (y0 == yf)) polygon = true; break; } if ((cmd & agg24::path_cmd_mask) == agg24::path_cmd_end_poly) { polygon = true; break; } } } // Fill the path, if necessary if (mode != STROKE) { // device_update_fill_state //glColor4f(fill_color->r, fill_color->g, fill_color->b, fill_color->a); glColor4f(EXPAND_COLOR(fill_color)); // call gl_render_path() gl_render_path(&this->path, true, true); } // Stroke the path, if necessary if (mode != FILL) { // CNP // device_update_line_state //glColor4f(line_color->r, line_color->g, line_color->b, line_color->a); glColor4f(EXPAND_COLOR(line_color)); glLineWidth(this->state.line_width); if (this->state.line_dash.is_solid()) { glDisable(GL_LINE_STIPPLE); } else { glDisable(GL_LINE_STIPPLE); } gl_render_path(&this->path, polygon, false); } this->path.remove_all(); } void gl_graphics_context::draw_rect(double rect[4], draw_mode_e mode) { agg24::rgba *line_color = &this->state.line_color; agg24::rgba *fill_color = &this->state.fill_color; // CNP if (this->state.should_antialias) { glEnable(GL_LINE_SMOOTH); glEnable(GL_POLYGON_SMOOTH); } else { glDisable(GL_LINE_SMOOTH); glDisable(GL_POLYGON_SMOOTH); } this->path.get_ctm().translation(rect, rect+1); // Fill the rect first if (mode != STROKE) { glColor4f(EXPAND_COLOR(fill_color)); glRectf(rect[0], rect[1], rect[0]+rect[2], rect[1]+rect[3]); } // Stroke the path if (mode != FILL) { // CNP glColor4f(EXPAND_COLOR(line_color)); glLineWidth(this->state.line_width); if (this->state.line_dash.is_solid()) { glDisable(GL_LINE_STIPPLE); } else { glDisable(GL_LINE_STIPPLE); } glBegin(GL_LINE_LOOP); glVertex2f(rect[0], rect[1]); glVertex2f(rect[0], rect[1] + rect[3]); glVertex2f(rect[0] + rect[2], rect[1] + rect[3]); glVertex2f(rect[0] + rect[2], rect[1]); glEnd(); } this->path.remove_all(); } int gl_graphics_context::draw_marker_at_points(double *pts, int Npts, int size, agg24::marker_e type) { agg24::rgba *line_color = &this->state.line_color; agg24::rgba *fill_color = &this->state.fill_color; bool do_fill = (fill_color->a != 0); bool do_stroke = ((line_color->a != 0) && (this->state.line_width > 0.0)); if (do_stroke) glLineWidth(this->state.line_width); // Get the current origin double x0=0.0, y0=0.0; this->path.get_ctm().translation(&x0, &y0); kiva::draw_mode_e draw_mode = FILL; if (do_fill & !do_stroke) draw_mode = FILL; else if (do_stroke & !do_fill) draw_mode = STROKE; else if (do_fill & do_stroke) draw_mode = FILL_STROKE; GLuint fill_list, stroke_list; bool list_created = false; switch (type) { // Simple paths that only need to be stroked case agg24::marker_x: draw_x_marker(pts, Npts, size, draw_mode, x0, y0); break; case agg24::marker_cross: draw_cross(pts, Npts, size, draw_mode, x0, y0); break; case agg24::marker_dot: draw_dot(pts, Npts, size, draw_mode, x0, y0); break; case agg24::marker_pixel: draw_pixel(pts, Npts, size, draw_mode, x0, y0); break; // Paths that need to be filled and stroked // There are experimental approaches taken for drawing squares and // diamonds, so they are in their own block here. There's no reason // why they cannot be treated in the same way as the circle and // triangle markers. case agg24::marker_square: draw_square(pts, Npts, size, draw_mode, x0, y0); break; case agg24::marker_diamond: draw_diamond(pts, Npts, size, draw_mode, x0, y0); break; case agg24::marker_crossed_circle: draw_crossed_circle(pts, Npts, size, draw_mode, x0, y0); break; case agg24::marker_circle: fill_list = make_marker_lists(&kiva::gl_graphics_context::circle_path_func, draw_mode, size); list_created = true; // Fall through to next case case agg24::marker_triangle_up: if (!list_created) { fill_list = make_marker_lists(&kiva::gl_graphics_context::triangle_up_func, draw_mode, size); list_created = true; } // Fall through to next case case agg24::marker_triangle_down: if (!list_created) { fill_list = make_marker_lists(&kiva::gl_graphics_context::triangle_down_func, draw_mode, size); list_created = true; } stroke_list = fill_list + 1; draw_display_list_at_pts(fill_list, stroke_list, pts, Npts, draw_mode, x0, y0); glDeleteLists(fill_list, 2); break; default: return 0; } // Indicate success return 1; } void gl_graphics_context::draw_path_at_points(double *pts, int Npts, kiva::compiled_path &marker, draw_mode_e mode) { return; } void gl_graphics_context::draw_glyphs(kiva::graphics_context_base* img, double tx, double ty) { } int gl_graphics_context::draw_image(kiva::graphics_context_base* img, double rect[4], bool force_copy) { return 0; } int gl_graphics_context::draw_image(kiva::graphics_context_base* img) { return 0; } //--------------------------------------------------------------------------- // Marker drawing methods //--------------------------------------------------------------------------- void gl_graphics_context::draw_display_list_at_pts(GLuint list, double *pts, int Npts, kiva::draw_mode_e mode, double x0, double y0) { draw_display_list_at_pts(list, list, pts, Npts, mode, x0, y0); } void gl_graphics_context::draw_display_list_at_pts(GLuint fill_list, GLuint stroke_list, double *pts, int Npts, kiva::draw_mode_e mode, double x0, double y0) { agg24::rgba *colors[2] = { &this->state.fill_color, &this->state.line_color }; GLuint lists[2] = { fill_list, stroke_list }; float x = 0.f, y = 0.f; for (int pass=0; pass < 2; pass++) { if (((pass == 0) && ((mode == FILL) || (mode == FILL_STROKE))) || ((pass == 1) && ((mode == STROKE) || (mode == FILL_STROKE)))) { glColor4f(EXPAND_COLOR(colors[pass])); for (int i=0; i < Npts; i++) { x = pts[i*2] + x0; y = pts[i*2 + 1] + y0; glTranslatef(x, y, 0.0); glCallList(lists[pass]); glTranslatef(-x, -y, 0.0); } } } #if 0 if ((mode == FILL) || (mode == FILL_STROKE)) { glColor4f(EXPAND_COLOR(fill_color)); for (int i=0; i < Npts; i++) { x = pts[i*2] + x0; y = pts[i*2 + 1] + y0; glTranslatef(x, y, 0.0); glCallList(stroke_list); glTranslatef(-x, -y, 0.0); } } if ((mode == STROKE) || (mode == FILL_STROKE)) { glColor4f(EXPAND_COLOR(line_color)); for (int i=0; i < Npts; i++) { x = pts[i*2] + x0; y = pts[i*2 + 1] + y0; glTranslatef(x, y, 0.0); glCallList(fill_list); glTranslatef(-x, -y, 0.0); } } #endif } GLuint gl_graphics_context::make_marker_lists(PathDefinitionFunc path_func, kiva::draw_mode_e mode, int size) { GLuint fill_list = glGenLists(2); GLuint stroke_list = fill_list + 1; for (int dummy=0; dummy < 2; dummy++) { if (dummy == 0) { glNewList(fill_list, GL_COMPILE); glBegin(GL_POLYGON); } else { glNewList(stroke_list, GL_COMPILE); glBegin(GL_LINE_LOOP); } ((this)->*(path_func))(size); glEnd(); glEndList(); } return fill_list; } void gl_graphics_context::draw_square(double *pts, int Npts, int size, kiva::draw_mode_e mode, double x0, double y0) { agg24::rgba *line_color = &this->state.line_color; agg24::rgba *fill_color = &this->state.fill_color; // We build up a VertexArray of the vertices of all the squares. // We then use glDrawElements with GL_QUADS or GL_LINE_LOOP to fill // and stroke the markers. // The vertex array contains all the vertices in all the rects. // The convention is that each rect's vertices are stored // clockwise, starting with the lower-left vertex. GLdouble *vertices = new GLdouble[Npts*4*2]; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_DOUBLE, 0, vertices); for (int i=0; istate.line_color; agg24::rgba *fill_color = &this->state.fill_color; // Each marker consists of four vertices in this order: left, top, right, bottom. GLdouble *vertices = new GLdouble[Npts * 4 * 2]; glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_DOUBLE, 0, vertices); float s = size / 2.0; for (int i=0; istate.line_color; glColor4f(EXPAND_COLOR(line_color)); glBegin(GL_POINTS); for (int i=0; i < Npts; i++) { glVertex2f(pts[i*2] + x0, pts[i*2+1] + y0); } glEnd(); } void _submit_path_points(PointListType const & points, bool polygon, bool fill) { // Uncomment this when we turn the glPolygonMode calls back on (below) //glPushAttrib(GL_POLYGON_BIT); if (polygon) { if (fill) { #if defined(_MSC_VER) || defined(__MINGW32__) typedef void (__stdcall*cbFunc)(void); #else typedef void (*cbFunc)(); #endif GLUtesselator* pTess = gluNewTess(); gluTessCallback(pTess, GLU_TESS_VERTEX, (cbFunc)&_vertex_callback); gluTessCallback(pTess, GLU_TESS_BEGIN, (cbFunc)&glBegin); gluTessCallback(pTess, GLU_TESS_END, (cbFunc)&glEnd); gluTessCallback(pTess, GLU_TESS_COMBINE, (cbFunc)&_combine_callback); gluTessBeginPolygon(pTess, NULL); gluTessBeginContour(pTess); // XXX: For some reason setting the polygon mode breaks pyglet's // font rendering. It doesn't really have an effect on any of // Kiva's rendering right now, so it's commented out for now. //glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); for (int i=0; i < points.size(); ++i) { VertexType * pV = (VertexType *)&points[i]; gluTessVertex(pTess, (GLdouble*)pV, (GLvoid*)pV); } gluTessEndContour(pTess); gluTessEndPolygon(pTess); gluDeleteTess(pTess); } else { glBegin(GL_LINE_LOOP); //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); for (int i=0; i < points.size(); ++i) glVertex2dv((VertexType *)&points[i]); glEnd(); } } else { glBegin(GL_LINE_STRIP); for (int i=0; i < points.size(); ++i) glVertex2dv((VertexType *)&points[i]); glEnd(); } //glPopAttrib(); } void CALLBACK _combine_callback(GLdouble coords[3], GLdouble *vert_data[4], GLfloat weight[4], GLdouble **dataOut) { GLdouble *vertex = (GLdouble *)malloc(3 * sizeof(GLdouble)); vertex[0] = coords[0]; vertex[1] = coords[1]; vertex[2] = coords[2]; *dataOut = vertex; } void CALLBACK _vertex_callback(GLvoid *vertex) { GLdouble *ptr = (GLdouble *)vertex; glVertex3dv(ptr); } enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_compiled_path.cpp0000644000175000017500000002072112516137326023507 0ustar varunvarun#include "agg_bezier_arc.h" #include "kiva_compiled_path.h" #include "kiva_basics.h" #include #include using namespace kiva; void compiled_path::remove_all() { //agg24::path_storage::remove_all(); // fix me: call to base:: to appease VC++6.0 this->base::remove_all(); this->_has_curves = false; //ptm = agg24::trans_affine(); } void compiled_path::begin_path() { this->remove_all(); } void compiled_path::close_path() { this->close_polygon(); } void compiled_path::move_to(double x, double y) { this->ptm.transform(&x, &y); // fix me: call to base:: to appease VC++6.0 this->base::move_to(x,y); } void compiled_path::line_to(double x, double y) { this->ptm.transform(&x, &y); // fix me: call to base:: to appease VC++6.0 this->base::line_to(x,y); } void compiled_path::quad_curve_to(double x_ctrl, double y_ctrl, double x_to, double y_to) { this->ptm.transform(&x_ctrl, &y_ctrl); this->ptm.transform(&x_to, &y_to); // fix me: call to base:: to appease VC++6.0 this->base::curve3(x_ctrl,y_ctrl,x_to,y_to); this->_has_curves = true; } void compiled_path::curve_to(double x_ctrl1, double y_ctrl1, double x_ctrl2, double y_ctrl2, double x_to, double y_to) { this->ptm.transform(&x_ctrl1, &y_ctrl1); this->ptm.transform(&x_ctrl2, &y_ctrl2); this->ptm.transform(&x_to, &y_to); // fix me: call to base:: to appease VC++6.0 this->base::curve4(x_ctrl1,y_ctrl1, x_ctrl2,y_ctrl2, x_to,y_to); this->_has_curves = true; } void compiled_path::arc(double x, double y, double radius, double start_angle, double end_angle, bool cw) { // Rather than try to transform the center and scale the axes correctly, // we'll just create an untransformed agg curve, grab its Bezier control // points, transform them, and manually add them to the path. double sweep_angle = end_angle - start_angle; if (cw) { sweep_angle = -(2*agg24::pi - sweep_angle); } agg24::bezier_arc aggarc(x, y, radius, radius, start_angle, sweep_angle); // Now manually transform each vertex and add it. For some reason, trying // to transform aggarc in place and then using this->base::add_path() // causes an access violation if cw=true (but works fine if cw=false). int numverts = aggarc.num_vertices(); container_type& vertices = this->vertices(); double vx, vy; unsigned int cmd; aggarc.rewind(0); for (int i = 0; i <= numverts/2; i++) { cmd = aggarc.vertex(&vx, &vy); if (!agg24::is_stop(cmd)) { this->ptm.transform(&vx, &vy); vertices.add_vertex(vx, vy, cmd); } } this->_has_curves = true; } void compiled_path::arc_to(double x1, double y1, double x2, double y2, double radius) { // We have to do some work above and beyond what Agg offers. The Agg // arc_to() happily creates rotated elliptical arcs, but to match the // DisplayPDF spec, we need to compute the correct tangent points on // the tangent lines defined by (cur_x,cur_y), (x1,y1), and (x2,y2) such // that a circular arc of the given radius will be created. // The general approach is to transform the coordinates of the three // points so that x1,y1 is at the origin, x0,y0 is to the right of x1,y1, // and y0==y1. This should be just a translation followed by a rotation. // We then compute the relative position of the circle's center as well // as the start angle and then inverse transform these back. (The angular // sweep of the arc is unchanged.) double x0=0, y0=0; this->last_vertex(&x0, &y0); this->ptm.inverse_transform(&x0, &y0); // Calculate the offset and rotation so that x1,y1, is at the origin (0,0), // and x0, y0 sites on the positive x axis (right side of x1,y1). agg24::trans_affine_translation xform(-x1, -y1); double xform_angle = -atan2(y0-y1, x0-x1); if (!kiva::almost_equal(fmod(xform_angle, 2*agg24::pi), 0.0)) { xform *= agg24::trans_affine_rotation(xform_angle); } // Transform and rotate the points. xform.transform(&x0, &y0); xform.transform(&x1, &y1); xform.transform(&x2, &y2); assert(kiva::almost_equal(y1, 0.0)); assert(kiva::almost_equal(x1, 0.0)); double cx, cy; // location of circle's center double center_angle = atan2(y2, x2) / 2; bool sweep_flag = (center_angle >= 0) ? false : true; double hypotenuse = fabs(radius / sin(center_angle)); cx = hypotenuse * cos(center_angle); cy = hypotenuse * sin(center_angle); // determine if we need to draw a line to the first tangent point // from the current pen position. if (!kiva::almost_equal(x0, cx)) { x0 = cx; xform.inverse_transform(&x0, &y0); this->line_to(x0, y0); } else { xform.inverse_transform(&x0, &y0); } // determine the second tangent point double point2_scale = cx / sqrt(x2*x2 + y2*y2); x2 *= point2_scale; y2 *= point2_scale; xform.inverse_transform(&x2, &y2); agg24::bezier_arc_svg aggarc(x0, y0, radius, radius, 0.0, false, sweep_flag, x2, y2); int numverts = aggarc.num_vertices(); double *vertices = aggarc.vertices(); double *v = NULL; for (int i = 0; i <= numverts/2; i++) { v = vertices + i*2; this->ptm.transform(v, v+1); } // I believe join_path is equivalent to the old add_path() with solid_path=true this->join_path(aggarc, 0); // This is the alternative call. //this->concat_path(aggarc, 0); this->_has_curves = true; } void compiled_path::add_path(compiled_path& other_path) { container_type& vertices = this->vertices(); double x=0.0; double y=0.0; unsigned cmd; other_path.rewind(0); cmd = other_path.vertex(&x, &y); while(!agg24::is_stop(cmd)) { this->_has_curves |= agg24::is_curve(cmd); this->ptm.transform(&x,&y); vertices.add_vertex(x, y, cmd); cmd = other_path.vertex(&x, &y); } this->concat_ctm(other_path.ptm); } //{ // agg24::conv_transform trans(p,ptm); // agg24::path_storage::add_path(trans); // concat_ctm(p.ptm); //} void compiled_path::lines(double* pts, int Npts) { this->move_to(pts[0],pts[1]); for(int i=2; i < Npts*2; i+=2) this->line_to(pts[i],pts[i+1]); } void compiled_path::line_set(double* start, int Nstart, double* end, int Nend) { int num_pts = (Nstart > Nend) ? Nend : Nstart; for (int i=0; i < num_pts*2; i += 2) { this->move_to(start[i], start[i+1]); this->line_to(end[i], end[i+1]); } } void compiled_path::rect(double x, double y, double sx, double sy) { this->move_to(x, y); this->line_to(x, y+sy); this->line_to(x+sx, y+sy); this->line_to(x+sx, y); this->close_path(); } void compiled_path::rect(kiva::rect_type &r) { this->rect(r.x, r.y, r.w, r.h); } void compiled_path::rects(double* all_rects, int Nrects) { double *tmp; for(int i = 0; i < Nrects*4; i+=4) { tmp = &all_rects[i]; this->rect(tmp[0], tmp[1], tmp[2], tmp[3]); } } void compiled_path::rects(kiva::rect_list_type &rectlist) { for (kiva::rect_list_type::iterator it=rectlist.begin(); it != rectlist.end(); it++) { this->rect(it->x, it->y, it->w, it->h); } } void compiled_path::_transform_ctm(agg24::trans_affine& m) { this->ptm.premultiply(m); } void compiled_path::translate_ctm(double x, double y) { agg24::trans_affine_translation m(x,y); this->_transform_ctm(m); } void compiled_path::rotate_ctm(double angle) { agg24::trans_affine_rotation m(angle); this->_transform_ctm(m); } void compiled_path::scale_ctm(double sx, double sy) { agg24::trans_affine_scaling m(sx,sy); this->_transform_ctm(m); } void compiled_path::concat_ctm(agg24::trans_affine& m) { agg24::trans_affine m_copy(m); this->_transform_ctm(m_copy); } void compiled_path::set_ctm(agg24::trans_affine& m) { this->ptm = agg24::trans_affine(m); } agg24::trans_affine compiled_path::get_ctm() { return this->ptm; } void compiled_path::save_ctm() { this->ptm_stack.push(this->ptm); } void compiled_path::restore_ctm() { // !! need to check what error should be on empty stack. if ( !this->ptm_stack.empty()) { this->ptm = this->ptm_stack.top(); this->ptm_stack.pop(); } } enthought-chaco2-4.5.1.orig/kiva/agg/src/gl_test/0000755000175000017500000000000012516137726020624 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/src/gl_test/gl_test.cpp0000644000175000017500000000334112516137326022766 0ustar varunvarun #include "Lesson2.h" #include "gl_graphics_context.h" using namespace kiva; #define WIDTH 640 #define HEIGHT 480 int OrigDrawGLScene(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer glLoadIdentity(); // Reset The Current Modelview Matrix glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0 glBegin(GL_TRIANGLES); // Drawing Using Triangles glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glEnd(); // Finished Drawing The Triangle glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units glBegin(GL_QUADS); // Draw A Quad glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glEnd(); // Done Drawing The Quad return TRUE; // Keep Going } int KivaDrawGLScene(GLvoid) { gl_graphics_context gc(WIDTH, HEIGHT); gc.gl_init(); // XXX: Verify antialiasing from python //gc.set_antialias(1); gc.set_fill_color(agg24::rgba(1.0, 0.0, 0.0)); gc.set_stroke_color(agg24::rgba(0.0, 1.0, 0.0)); gc.set_line_width(1.0); gc.move_to(100.0, 100.0); gc.line_to(100.0, 200.0); gc.line_to(200.0, 200.0); gc.close_path(); gc.draw_path(FILL_STROKE); gc.begin_path(); gc.line_to(50, 50); gc.line_to(75, 75); gc.line_to(275, 75); gc.line_to(275, 50); gc.close_path(); gc.draw_path(FILL_STROKE); return TRUE; } int DrawGLScene(GLvoid) { //return OrigDrawGLScene(); return KivaDrawGLScene(); }enthought-chaco2-4.5.1.orig/kiva/agg/src/gl_test/gl_test.vcproj0000644000175000017500000000732212516137326023512 0ustar varunvarun enthought-chaco2-4.5.1.orig/kiva/agg/src/gl_test/Lesson2.cpp0000644000175000017500000003671012516137326022660 0ustar varunvarun/* Modified Lesson2.cpp from NeHe tutorials * * This has been modified in the following ways: * WinMain has been renamed to DefaultWinMain * DrawGLScene has been renamed to DefaultDrawGLScene * * -- pzw */ /* * This Code Was Created By Jeff Molofee 2000 * A HUGE Thanks To Fredric Echols For Cleaning Up * And Optimizing The Base Code, Making It More Flexible! * If You've Found This Code Useful, Please Let Me Know. * Visit My Site At nehe.gamedev.net */ #include "Lesson2.h" HDC hDC=NULL; // Private GDI Device Context HGLRC hRC=NULL; // Permanent Rendering Context HWND hWnd=NULL; // Holds Our Window Handle HINSTANCE hInstance; // Holds The Instance Of The Application bool keys[256]; // Array Used For The Keyboard Routine bool active=TRUE; // Window Active Flag Set To TRUE By Default bool fullscreen=FALSE; // Fullscreen Flag Set To Fullscreen Mode By Default LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window { if (height==0) // Prevent A Divide By Zero By { height=1; // Making Height Equal One } glViewport(0,0,width,height); // Reset The Current Viewport glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix // Calculate The Aspect Ratio Of The Window //gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); glOrtho(0, width, 0, height, 1, -1); glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glLoadIdentity(); // Reset The Modelview Matrix } int InitGL(GLvoid) // All Setup For OpenGL Goes Here { glShadeModel(GL_SMOOTH); // Enable Smooth Shading glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background glClearDepth(1.0f); // Depth Buffer Setup //glEnable(GL_DEPTH_TEST); // Enables Depth Testing //glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do //glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations return TRUE; // Initialization Went OK } int DefaultDrawGLScene(GLvoid) // Here's Where We Do All The Drawing { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer glLoadIdentity(); // Reset The Current Modelview Matrix glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0 glBegin(GL_TRIANGLES); // Drawing Using Triangles glVertex3f( 0.0f, 1.0f, 0.0f); // Top glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glEnd(); // Finished Drawing The Triangle glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units glBegin(GL_QUADS); // Draw A Quad glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left glEnd(); // Done Drawing The Quad return TRUE; // Keep Going } GLvoid KillGLWindow(GLvoid) // Properly Kill The Window { if (fullscreen) // Are We In Fullscreen Mode? { ChangeDisplaySettings(NULL,0); // If So Switch Back To The Desktop ShowCursor(TRUE); // Show Mouse Pointer } if (hRC) // Do We Have A Rendering Context? { if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts? { MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); } if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC? { MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); } hRC=NULL; // Set RC To NULL } if (hDC && !ReleaseDC(hWnd,hDC)) // Are We Able To Release The DC { MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); hDC=NULL; // Set DC To NULL } if (hWnd && !DestroyWindow(hWnd)) // Are We Able To Destroy The Window? { MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); hWnd=NULL; // Set hWnd To NULL } if (!UnregisterClass("OpenGL",hInstance)) // Are We Able To Unregister Class { MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); hInstance=NULL; // Set hInstance To NULL } } /* This Code Creates Our OpenGL Window. Parameters Are: * * title - Title To Appear At The Top Of The Window * * width - Width Of The GL Window Or Fullscreen Mode * * height - Height Of The GL Window Or Fullscreen Mode * * bits - Number Of Bits To Use For Color (8/16/24/32) * * fullscreenflag - Use Fullscreen Mode (TRUE) Or Windowed Mode (FALSE) */ BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag) { GLuint PixelFormat; // Holds The Results After Searching For A Match WNDCLASS wc; // Windows Class Structure DWORD dwExStyle; // Window Extended Style DWORD dwStyle; // Window Style RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values WindowRect.left=(long)0; // Set Left Value To 0 WindowRect.right=(long)width; // Set Right Value To Requested Width WindowRect.top=(long)0; // Set Top Value To 0 WindowRect.bottom=(long)height; // Set Bottom Value To Requested Height fullscreen=fullscreenflag; // Set The Global Fullscreen Flag hInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window. wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc Handles Messages wc.cbClsExtra = 0; // No Extra Window Data wc.cbWndExtra = 0; // No Extra Window Data wc.hInstance = hInstance; // Set The Instance wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // Load The Default Icon wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer wc.hbrBackground = NULL; // No Background Required For GL wc.lpszMenuName = NULL; // We Don't Want A Menu wc.lpszClassName = "OpenGL"; // Set The Class Name if (!RegisterClass(&wc)) // Attempt To Register The Window Class { MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if (fullscreen) // Attempt Fullscreen Mode? { DEVMODE dmScreenSettings; // Device Mode memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // Makes Sure Memory's Cleared dmScreenSettings.dmSize=sizeof(dmScreenSettings); // Size Of The Devmode Structure dmScreenSettings.dmPelsWidth = width; // Selected Screen Width dmScreenSettings.dmPelsHeight = height; // Selected Screen Height dmScreenSettings.dmBitsPerPel = bits; // Selected Bits Per Pixel dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT; // Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar. if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) { // If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode. if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES) { fullscreen=FALSE; // Windowed Mode Selected. Fullscreen = FALSE } else { // Pop Up A Message Box Letting User Know The Program Is Closing. MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP); return FALSE; // Return FALSE } } } if (fullscreen) // Are We Still In Fullscreen Mode? { dwExStyle=WS_EX_APPWINDOW; // Window Extended Style dwStyle=WS_POPUP; // Windows Style ShowCursor(FALSE); // Hide Mouse Pointer } else { dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style dwStyle=WS_OVERLAPPEDWINDOW; // Windows Style } AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size // Create The Window if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window "OpenGL", // Class Name title, // Window Title dwStyle | // Defined Window Style WS_CLIPSIBLINGS | // Required Window Style WS_CLIPCHILDREN, // Required Window Style 0, 0, // Window Position WindowRect.right-WindowRect.left, // Calculate Window Width WindowRect.bottom-WindowRect.top, // Calculate Window Height NULL, // No Parent Window NULL, // No Menu hInstance, // Instance NULL))) // Dont Pass Anything To WM_CREATE { KillGLWindow(); // Reset The Display MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } static PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format bits, // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 16, // 16Bit Z-Buffer (Depth Buffer) 0, // No Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved 0, 0, 0 // Layer Masks Ignored }; if (!(hDC=GetDC(hWnd))) // Did We Get A Device Context? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if(!SetPixelFormat(hDC,PixelFormat,&pfd)) // Are We Able To Set The Pixel Format? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if (!(hRC=wglCreateContext(hDC))) // Are We Able To Get A Rendering Context? { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } if(!wglMakeCurrent(hDC,hRC)) // Try To Activate The Rendering Context { KillGLWindow(); // Reset The Display MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } ShowWindow(hWnd,SW_SHOW); // Show The Window SetForegroundWindow(hWnd); // Slightly Higher Priority SetFocus(hWnd); // Sets Keyboard Focus To The Window ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen if (!InitGL()) // Initialize Our Newly Created GL Window { KillGLWindow(); // Reset The Display MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION); return FALSE; // Return FALSE } return TRUE; // Success } LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window UINT uMsg, // Message For This Window WPARAM wParam, // Additional Message Information LPARAM lParam) // Additional Message Information { switch (uMsg) // Check For Windows Messages { case WM_ACTIVATE: // Watch For Window Activate Message { if (!HIWORD(wParam)) // Check Minimization State { active=TRUE; // Program Is Active } else { active=FALSE; // Program Is No Longer Active } return 0; // Return To The Message Loop } case WM_SYSCOMMAND: { switch (wParam) { case SC_SCREENSAVE: case SC_MONITORPOWER: return 0; } break; } case WM_CLOSE: // Did We Receive A Close Message? { PostQuitMessage(0); // Send A Quit Message return 0; // Jump Back } case WM_KEYDOWN: // Is A Key Being Held Down? { keys[wParam] = TRUE; // If So, Mark It As TRUE return 0; // Jump Back } case WM_KEYUP: // Has A Key Been Released? { keys[wParam] = FALSE; // If So, Mark It As FALSE return 0; // Jump Back } case WM_SIZE: // Resize The OpenGL Window { ReSizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height return 0; // Jump Back } } // Pass All Unhandled Messages To DefWindowProc return DefWindowProc(hWnd,uMsg,wParam,lParam); } int WINAPI WinMain( HINSTANCE hInstance, // Instance HINSTANCE hPrevInstance, // Previous Instance LPSTR lpCmdLine, // Command Line Parameters int nCmdShow) // Window Show State { MSG msg; // Windows Message Structure BOOL done=FALSE; // Bool Variable To Exit Loop // Ask The User Which Screen Mode They Prefer //if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO) //{ // fullscreen=FALSE; // Windowed Mode //} // Create Our OpenGL Window if (!CreateGLWindow("NeHe's First Polygon Tutorial",640,480,16,fullscreen)) { return 0; // Quit If Window Was Not Created } while(!done) // Loop That Runs While done=FALSE { if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting? { if (msg.message==WM_QUIT) // Have We Received A Quit Message? { done=TRUE; // If So done=TRUE } else // If Not, Deal With Window Messages { TranslateMessage(&msg); // Translate The Message DispatchMessage(&msg); // Dispatch The Message } } else // If There Are No Messages { // Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene() if ((active && !DrawGLScene()) || keys[VK_ESCAPE]) // Active? Was There A Quit Received? { done=TRUE; // ESC or DrawGLScene Signalled A Quit } else // Not Time To Quit, Update Screen { SwapBuffers(hDC); // Swap Buffers (Double Buffering) } if (keys[VK_F1]) // Is F1 Being Pressed? { keys[VK_F1]=FALSE; // If So Make Key FALSE KillGLWindow(); // Kill Our Current Window fullscreen=!fullscreen; // Toggle Fullscreen / Windowed Mode // Recreate Our OpenGL Window if (!CreateGLWindow("NeHe's First Polygon Tutorial",640,480,16,fullscreen)) { return 0; // Quit If Window Was Not Created } } } } // Shutdown KillGLWindow(); // Kill The Window return (msg.wParam); // Exit The Program } enthought-chaco2-4.5.1.orig/kiva/agg/src/gl_test/Lesson2.h0000644000175000017500000000135012516137326022315 0ustar varunvarun#ifndef LESSON2_H #define LESSON2_H #include // Header File For Windows #include // Header File For The OpenGL32 Library #include // Header File For The GLu32 Library #include // Implement your own version of this function int DrawGLScene(GLvoid); // Functions implemented in Lesson2.cpp GLvoid ReSizeGLScene(GLsizei width, GLsizei height); int InitGL(GLvoid); GLvoid KillGLWindow(GLvoid); BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag); int DefaultDrawGLScene(GLvoid); int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow); #endif /* LESSON2_H */ enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_exceptions.h0000644000175000017500000000041212516137326022520 0ustar varunvarun#ifndef KIVA_EXCEPTIONS_H #define KIVA_EXCEPTIONS_H namespace kiva { // exception codes used in graphics_context enum { not_implemented_error = 0, ctm_rotation_error, bad_clip_state_error, even_odd_clip_error, clipping_path_unsupported }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/agg_std_string.i0000644000175000017500000000113212516137326022324 0ustar varunvarun%include "std_string.i" // These typemaps are needed to handle member access to font_type.name // and friends. They really should by part of std_string.i, shouldn't // they? #ifdef SWIGPYTHON %typemap(in) std::string * { if (PyString_Check ($input)) { $1 = new std::string((char *)PyString_AsString($input)); } else { PyErr_SetString (PyExc_TypeError, "not a String"); return NULL; } } %typemap(out) std::string * { $result = PyString_FromString((const char *)$1->c_str()); } %typemap(freearg) std::string * { if ($1) { delete $1; } } #endif /* SWIGPYTHON */ enthought-chaco2-4.5.1.orig/kiva/agg/src/x11/0000755000175000017500000000000012516137726017574 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/src/x11/agg_platform_specific.cpp0000644000175000017500000003136012516137326024606 0ustar varunvarun#include #include #include #include #include #include "x11/agg_platform_specific.h" #include "util/agg_color_conv_rgb8.h" #include "x11/agg_bmp.h" //#define DEBUG_MTH(NAME) fprintf(stderr, NAME "\n"); #define DEBUG_MTH(NAME) typedef struct { short x1, x2, y1, y2; } Box, BOX, BoxRec, *BoxPtr; typedef struct { short x, y, width, height; }RECTANGLE, RectangleRec, *RectanglePtr; typedef struct _XRegion { long size; long numRects; BOX *rects; BOX extents; } REGION; namespace agg24 { x11_display::x11_display(): m_screen(0), m_depth(0), m_visual(0), m_dc(0), m_gc(0), m_sys_bpp(0) { DEBUG_MTH("x11_display::x11_display"); } x11_display::~x11_display() { DEBUG_MTH("x11_display::~x11_display"); close(); } bool x11_display::open(const char* display_name) { DEBUG_MTH("x11_display::open"); if (m_display != 0) { fprintf(stderr, "X11 display is opened already\n"); return false; } //printf("Opened X11 display: %s\n", display_name); m_display = XOpenDisplay(display_name); if (m_display == 0) { fprintf(stderr, "Unable to open DISPLAY=%s!\n",display_name); return false; } m_screen = DefaultScreen(m_display); m_depth = DefaultDepth(m_display, m_screen); m_visual = DefaultVisual(m_display, m_screen); switch(m_depth) { case 15: case 16: m_sys_bpp = 16; break; case 24: case 32: m_sys_bpp = 32; break; default: fprintf(stderr, "Unexpected X11 display depth=%d!\n",m_depth); } return true; } void x11_display::close() { DEBUG_MTH("x11_display::close"); if (m_display != 0) { if (m_gc != 0) XFreeGC(m_display, m_gc); XCloseDisplay(m_display); } m_display = 0; m_screen = 0; m_depth = 0; m_visual = 0; m_dc = 0; m_gc = 0; } bool x11_display::put_image(Window dc, XImage* image) { DEBUG_MTH("x11_display::put_image"); if (m_dc != dc) { if (m_gc) XFreeGC(m_display, m_gc); m_dc = dc; //m_gc = DefaultGC(m_display, m_screen); m_gc = XCreateGC(m_display, m_dc, 0, 0); } // Region r = XCreateRegion(); // r->numRects = 1; // r->size = 1; // r->rects = &r->extents; // r->extents.x1 = 0; // r->extents.x2 = image->width; // r->extents.y1 = 0; // r->extents.y2 = image->height; //XSetClipMask( m_display, m_gc, None ); //XSetClipOrigin(m_display, m_gc, 0, 0); XPutImage(m_display, dc, m_gc, image, 0, 0, 0, 0, image->width, image->height ); // XSetRegion(m_display,m_gc,r); //XDestroyRegion(r); //XMapWindow(m_display, dc); //XSync(m_display, false); return true; } XImage* x11_display::create_image(const rendering_buffer* rbuf) { DEBUG_MTH("x11_display::create_image"); unsigned width = rbuf->width(); unsigned height = rbuf->height(); return XCreateImage(m_display, m_visual, //CopyFromParent, m_depth, ZPixmap, 0, (char*)(rbuf->buf()), width, height, m_sys_bpp, width * (m_sys_bpp / 8)); } void x11_display::destroy_image(XImage* ximg) { DEBUG_MTH("x11_display::destroy_image"); if (ximg != 0) XDestroyImage(ximg); /* XDestroyImage function frees both the image structure and the data pointed to by the image structure. */ } //------------------------------------------------------------------------ platform_specific::platform_specific(pix_format_e format, bool flip_y) : m_bpp(0), m_flip_y(flip_y), m_ximage(0), m_format(format), m_sys_bpp(0), m_sys_format(pix_format_undefined) { DEBUG_MTH("platform_specific::platform_specific"); init(); } platform_specific::~platform_specific() { DEBUG_MTH("platform_specific::~platform_specific"); } x11_display platform_specific::x11; bool platform_specific::init() { DEBUG_MTH("platform_specific::init"); if (x11.m_display == 0 && !x11.open()) { fprintf(stderr, "No X11 display available!\n"); return false; } unsigned long r_mask = x11.m_visual->red_mask; unsigned long g_mask = x11.m_visual->green_mask; unsigned long b_mask = x11.m_visual->blue_mask; if(x11.m_depth < 15 || r_mask == 0 || g_mask == 0 || b_mask == 0) { fprintf(stderr, "There's no Visual compatible with minimal AGG requirements:\n" "At least 15-bit color depth and True- or DirectColor class.\n\n" ); return false; } switch(m_format) { case pix_format_gray8: m_bpp = 8; break; case pix_format_rgb565: case pix_format_rgb555: m_bpp = 16; break; case pix_format_rgb24: case pix_format_bgr24: m_bpp = 24; break; case pix_format_bgra32: case pix_format_abgr32: case pix_format_argb32: case pix_format_rgba32: m_bpp = 32; break; case pix_format_undefined: case end_of_pix_formats: ; } // // Calculate m_sys_format, m_byte_order, m_sys_bpp: // int t = 1; int hw_byte_order = LSBFirst; if(*(char*)&t == 0) hw_byte_order = MSBFirst; switch(x11.m_depth) { case 15: m_sys_bpp = 16; if(r_mask == 0x7C00 && g_mask == 0x3E0 && b_mask == 0x1F) { m_sys_format = pix_format_rgb555; m_byte_order = hw_byte_order; } break; case 16: m_sys_bpp = 16; if(r_mask == 0xF800 && g_mask == 0x7E0 && b_mask == 0x1F) { m_sys_format = pix_format_rgb565; m_byte_order = hw_byte_order; } break; case 24: case 32: m_sys_bpp = 32; if(g_mask == 0xFF00) { if(r_mask == 0xFF && b_mask == 0xFF0000) { switch(m_format) { case pix_format_rgba32: m_sys_format = pix_format_rgba32; m_byte_order = LSBFirst; break; case pix_format_abgr32: m_sys_format = pix_format_abgr32; m_byte_order = MSBFirst; break; default: m_byte_order = hw_byte_order; m_sys_format = (hw_byte_order == LSBFirst) ? pix_format_rgba32 : pix_format_abgr32; break; } } if(r_mask == 0xFF0000 && b_mask == 0xFF) { switch(m_format) { case pix_format_argb32: m_sys_format = pix_format_argb32; m_byte_order = MSBFirst; break; case pix_format_bgra32: m_sys_format = pix_format_bgra32; m_byte_order = LSBFirst; break; default: m_byte_order = hw_byte_order; m_sys_format = (hw_byte_order == MSBFirst) ? pix_format_argb32 : pix_format_bgra32; break; } } } break; } if(m_sys_format == pix_format_undefined) { fprintf(stderr, "RGB masks are not compatible with AGG pixel formats:\n" "R=%08x, G=%08x, B=%08x\n", (unsigned int)r_mask, (unsigned int)g_mask, (unsigned int)b_mask); return false; } return true; } #define UNHANDLED_PIX_FORMATS \ case end_of_pix_formats: ; \ case pix_format_gray8: ; \ case pix_format_undefined: ; void platform_specific::destroy() { DEBUG_MTH("platform_specific::destroy"); if (m_ximage != 0) { x11.destroy_image(m_ximage); m_ximage = 0; } } void platform_specific::display_pmap(Window dc, const rendering_buffer* rbuf) { DEBUG_MTH("platform_specific::display_map"); if (m_format == m_sys_format) { if (m_ximage == 0) { m_ximage = x11.create_image(rbuf); m_ximage->byte_order = m_byte_order; } x11.put_image(dc, m_ximage); return; } // Optimization hint: make pmap_tmp as a private class member and reused it when possible. pixel_map pmap_tmp(rbuf->width(), rbuf->height(), m_sys_format, 256, m_flip_y); rendering_buffer* rbuf2 = &pmap_tmp.rbuf(); switch(m_sys_format) { case pix_format_rgb555: switch(m_format) { case pix_format_rgb555: color_conv(rbuf2, rbuf, color_conv_rgb555_to_rgb555()); break; case pix_format_rgb565: color_conv(rbuf2, rbuf, color_conv_rgb565_to_rgb555()); break; case pix_format_rgb24: color_conv(rbuf2, rbuf, color_conv_rgb24_to_rgb555()); break; case pix_format_bgr24: color_conv(rbuf2, rbuf, color_conv_bgr24_to_rgb555()); break; case pix_format_rgba32: color_conv(rbuf2, rbuf, color_conv_rgba32_to_rgb555()); break; case pix_format_argb32: color_conv(rbuf2, rbuf, color_conv_argb32_to_rgb555()); break; case pix_format_bgra32: color_conv(rbuf2, rbuf, color_conv_bgra32_to_rgb555()); break; case pix_format_abgr32: color_conv(rbuf2, rbuf, color_conv_abgr32_to_rgb555()); break; UNHANDLED_PIX_FORMATS; } break; case pix_format_rgb565: switch(m_format) { case pix_format_rgb555: color_conv(rbuf2, rbuf, color_conv_rgb555_to_rgb565()); break; case pix_format_rgb565: color_conv(rbuf2, rbuf, color_conv_rgb565_to_rgb565()); break; case pix_format_rgb24: color_conv(rbuf2, rbuf, color_conv_rgb24_to_rgb565()); break; case pix_format_bgr24: color_conv(rbuf2, rbuf, color_conv_bgr24_to_rgb565()); break; case pix_format_rgba32: color_conv(rbuf2, rbuf, color_conv_rgba32_to_rgb565()); break; case pix_format_argb32: color_conv(rbuf2, rbuf, color_conv_argb32_to_rgb565()); break; case pix_format_bgra32: color_conv(rbuf2, rbuf, color_conv_bgra32_to_rgb565()); break; case pix_format_abgr32: color_conv(rbuf2, rbuf, color_conv_abgr32_to_rgb565()); break; UNHANDLED_PIX_FORMATS; } break; case pix_format_rgba32: switch(m_format) { case pix_format_rgb555: color_conv(rbuf2, rbuf, color_conv_rgb555_to_rgba32()); break; case pix_format_rgb565: color_conv(rbuf2, rbuf, color_conv_rgb565_to_rgba32()); break; case pix_format_rgb24: color_conv(rbuf2, rbuf, color_conv_rgb24_to_rgba32()); break; case pix_format_bgr24: color_conv(rbuf2, rbuf, color_conv_bgr24_to_rgba32()); break; case pix_format_rgba32: color_conv(rbuf2, rbuf, color_conv_rgba32_to_rgba32()); break; case pix_format_argb32: color_conv(rbuf2, rbuf, color_conv_argb32_to_rgba32()); break; case pix_format_bgra32: color_conv(rbuf2, rbuf, color_conv_bgra32_to_rgba32()); break; case pix_format_abgr32: color_conv(rbuf2, rbuf, color_conv_abgr32_to_rgba32()); break; UNHANDLED_PIX_FORMATS; } break; case pix_format_abgr32: switch(m_format) { case pix_format_rgb555: color_conv(rbuf2, rbuf, color_conv_rgb555_to_abgr32()); break; case pix_format_rgb565: color_conv(rbuf2, rbuf, color_conv_rgb565_to_abgr32()); break; case pix_format_rgb24: color_conv(rbuf2, rbuf, color_conv_rgb24_to_abgr32()); break; case pix_format_bgr24: color_conv(rbuf2, rbuf, color_conv_bgr24_to_abgr32()); break; case pix_format_abgr32: color_conv(rbuf2, rbuf, color_conv_abgr32_to_abgr32()); break; case pix_format_rgba32: color_conv(rbuf2, rbuf, color_conv_rgba32_to_abgr32()); break; case pix_format_argb32: color_conv(rbuf2, rbuf, color_conv_argb32_to_abgr32()); break; case pix_format_bgra32: color_conv(rbuf2, rbuf, color_conv_bgra32_to_abgr32()); break; UNHANDLED_PIX_FORMATS; } break; case pix_format_argb32: switch(m_format) { case pix_format_rgb555: color_conv(rbuf2, rbuf, color_conv_rgb555_to_argb32()); break; case pix_format_rgb565: color_conv(rbuf2, rbuf, color_conv_rgb565_to_argb32()); break; case pix_format_rgb24: color_conv(rbuf2, rbuf, color_conv_rgb24_to_argb32()); break; case pix_format_bgr24: color_conv(rbuf2, rbuf, color_conv_bgr24_to_argb32()); break; case pix_format_rgba32: color_conv(rbuf2, rbuf, color_conv_rgba32_to_argb32()); break; case pix_format_argb32: color_conv(rbuf2, rbuf, color_conv_argb32_to_argb32()); break; case pix_format_abgr32: color_conv(rbuf2, rbuf, color_conv_abgr32_to_argb32()); break; case pix_format_bgra32: color_conv(rbuf2, rbuf, color_conv_bgra32_to_argb32()); break; UNHANDLED_PIX_FORMATS; } break; case pix_format_bgra32: switch(m_format) { case pix_format_rgb555: color_conv(rbuf2, rbuf, color_conv_rgb555_to_bgra32()); break; case pix_format_rgb565: color_conv(rbuf2, rbuf, color_conv_rgb565_to_bgra32()); break; case pix_format_rgb24: color_conv(rbuf2, rbuf, color_conv_rgb24_to_bgra32()); break; case pix_format_bgr24: color_conv(rbuf2, rbuf, color_conv_bgr24_to_bgra32()); break; case pix_format_rgba32: color_conv(rbuf2, rbuf, color_conv_rgba32_to_bgra32()); break; case pix_format_argb32: color_conv(rbuf2, rbuf, color_conv_argb32_to_bgra32()); break; case pix_format_abgr32: color_conv(rbuf2, rbuf, color_conv_abgr32_to_bgra32()); break; case pix_format_bgra32: color_conv(rbuf2, rbuf, color_conv_bgra32_to_bgra32()); break; UNHANDLED_PIX_FORMATS; } break; UNHANDLED_PIX_FORMATS; } pmap_tmp.draw(dc); } unsigned platform_specific::calc_row_len(unsigned width, unsigned bits_per_pixel) { return width * (bits_per_pixel / 8); } } enthought-chaco2-4.5.1.orig/kiva/agg/src/x11/plat_support.i0000644000175000017500000000667412516137326022513 0ustar varunvarun// -*- c++ -*- %module plat_support %include numeric.i %{ #include "x11/agg_bmp.h" namespace agg24 { PyObject* pixel_map_as_unowned_array(agg24::pixel_map& pix_map) { npy_intp dims[3]; npy_intp rows = pix_map.height(); npy_intp cols = pix_map.width(); npy_intp depth = pix_map.bpp() / 8; dims[0] = rows; dims[1] = cols; dims[2] = depth; return PyArray_SimpleNewFromData(3,dims,NPY_UINT8,(void*)pix_map.buf()); } } %} %typemap(in)(Window) { $1 = (Window) PyInt_AsLong($input); } // More permissive unsigned typemap that converts any numeric type to an // unsigned value. It is cleared at the end of this file. %typemap(in) unsigned { PyObject* obj = PyNumber_Int($input); if (PyErr_Occurred()) SWIG_fail; $1 = (unsigned) PyLong_AsLong(obj); if (PyErr_Occurred()) SWIG_fail; } namespace agg24 { enum pix_format_e { pix_format_undefined = 0, // By default. No conversions are applied pix_format_gray8, // Simple 256 level grayscale pix_format_rgb555, // 15 bit rgb. Depends on the byte ordering! pix_format_rgb565, // 16 bit rgb. Depends on the byte ordering! pix_format_rgb24, // R-G-B, one byte per color component pix_format_bgr24, // B-G-R, native win32 BMP format. pix_format_rgba32, // R-G-B-A, one byte per color component pix_format_argb32, // A-R-G-B, native MAC format pix_format_abgr32, // A-B-G-R, one byte per color component pix_format_bgra32, // B-G-R-A, native win32 BMP format end_of_pix_formats }; %rename(PixelMap) pixel_map; class pixel_map { public: ~pixel_map(); pixel_map(unsigned width, unsigned height, pix_format_e format, unsigned clear_val, bool bottom_up); public: %feature("shadow") draw(Window h_dc, int x, int y, double scale) const %{ def draw(self, h_dc, x=0, y=0, scale=1.0): # fix me: brittle becuase we are hard coding # module and class name. Done cause SWIG 1.3.24 does # some funky overloading stuff in it that breaks keyword # arguments. result = _plat_support.PixelMap_draw(self, h_dc, x, y, scale) return result %} void draw(Window h_dc, int x, int y, double scale) const; PyObject* convert_to_rgbarray() const; PyObject* convert_to_argb32string() const; %pythoncode %{ def set_bmp_array(self): self.bmp_array = pixel_map_as_unowned_array(self) return self def draw_to_tkwindow(self, window, x, y): window_id = window._tk_widget.winfo_id() self.draw(window_id, x, y) return def draw_to_wxwindow(self, window, x, y): import wx window_dc = getattr(window,'_dc',None) if window_dc is None: window_dc = wx.PaintDC(window) arr = self.convert_to_rgbarray() sz = arr.shape[:2] image = wx.EmptyImage(*sz) image.SetDataBuffer(arr.data) bmp = wx.BitmapFromImage(image, depth=-1) window_dc.BeginDrawing() window_dc.DrawBitmap(bmp,x,y) window_dc.EndDrawing() return %} }; } PyObject* pixel_map_as_unowned_array(agg24::pixel_map& pix_map); // clear the "permissive" unsigned typemap we are using. %typemap(in) unsigned; enthought-chaco2-4.5.1.orig/kiva/agg/src/x11/agg_platform_specific.h0000644000175000017500000000446212516137326024256 0ustar varunvarun// -*- c++ -*- #ifndef AGG_X11_SPECIFIC_INCLUDED #define AGG_X11_SPECIFIC_INCLUDED #include #include "agg_basics.h" #include "agg_rendering_buffer.h" namespace agg24 { enum pix_format_e { pix_format_undefined = 0, // By default. No conversions are applied pix_format_gray8, // Simple 256 level grayscale pix_format_rgb555, // 15 bit rgb. Depends on the byte ordering! pix_format_rgb565, // 16 bit rgb. Depends on the byte ordering! pix_format_rgb24, // R-G-B, one byte per color component pix_format_bgr24, // B-G-R, native win32 BMP format. pix_format_rgba32, // R-G-B-A, one byte per color component pix_format_argb32, // A-R-G-B, native MAC format pix_format_abgr32, // A-B-G-R, one byte per color component pix_format_bgra32, // B-G-R-A, native win32 BMP format end_of_pix_formats }; class x11_display { public: x11_display(); ~x11_display(); bool open(const char* display_name = NULL); void close(); bool put_image(Window dc, XImage* image); XImage* create_image(const rendering_buffer* rbuf); void destroy_image(XImage* ximg); public: Display* m_display; int m_screen; int m_depth; Visual* m_visual; Window m_dc; GC m_gc; unsigned m_sys_bpp; }; //------------------------------------------------------------------------ class platform_specific { static x11_display x11; public: platform_specific(pix_format_e format, bool flip_y); ~platform_specific(); void display_pmap(Window dc, const rendering_buffer* src); void destroy(); static unsigned calc_row_len(unsigned width, unsigned bits_per_pixel); private: bool init(); public: unsigned m_bpp; // init() bool m_flip_y; // platform_specific() XImage* m_ximage; // display_pmap() pix_format_e m_format; // platform_specific() private: int m_byte_order; // init() unsigned m_sys_bpp; // init() pix_format_e m_sys_format; // init() }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/x11/agg_bmp.cpp0000644000175000017500000001413712516137326021676 0ustar varunvarun #include #include #include #include "x11/agg_bmp.h" #include "x11/agg_platform_specific.h" /* #include */ #include "agg_pixfmt_rgb.h" #include "agg_pixfmt_rgba.h" #include "agg_color_rgba.h" #ifdef NUMPY #include "numpy/arrayobject.h" # ifndef PyArray_SBYTE # include "numpy/noprefix.h" # include "numpy/oldnumeric.h" # include "numpy/old_defines.h" # endif #else #include "Numeric/arrayobject.h" #define PyArray_UBYTELTR 'b' #endif #if 0 #define DEBUG_MTH(NAME) fprintf(stderr, NAME "\n"); #define DEBUG_MTH2(STR,ARG1,ARG2) fprintf(stderr, STR "\n",(ARG1),(ARG2)); #define DEBUG_MTH5(STR,ARG1,ARG2,ARG3,ARG4,ARG5) fprintf(stderr, STR "\n",(ARG1),(ARG2),(ARG3),(ARG4),(ARG5)); #else #define DEBUG_MTH(NAME) #define DEBUG_MTH2(STR,ARG1,ARG2) #define DEBUG_MTH5(STR,ARG1,ARG2,ARG3,ARG4,ARG5) #endif namespace agg24 { //------------------------------------------------------------------------ pixel_map::pixel_map(unsigned width, unsigned height, pix_format_e format, unsigned clear_val, bool bottom_up): m_bmp(0), m_buf(0), m_specific(new platform_specific(format, bottom_up)) { DEBUG_MTH5("pixel_map::pixel_map(%d,%d,%d,%d,%d)",width,height,format,clear_val,bottom_up); m_bpp = m_specific->m_bpp; create(width, height, clear_val); } //------------------------------------------------------------------------ pixel_map::~pixel_map() { DEBUG_MTH("pixel_map::~pixel_map"); destroy(); delete m_specific; } //------------------------------------------------------------------------ void pixel_map::destroy() { if (m_specific->m_ximage != 0) { m_specific->destroy(); } else if(m_bmp) { delete [] (unsigned char*)m_bmp; } m_bmp = 0; m_buf = 0; } //------------------------------------------------------------------------ void pixel_map::create(unsigned width, unsigned height, unsigned clear_val) { destroy(); if(width == 0) width = 1; if(height == 0) height = 1; unsigned row_len = platform_specific::calc_row_len(width, m_bpp); unsigned img_size = row_len * height; m_bmp = (Pixmap*) new unsigned char[img_size]; m_buf = (unsigned char*)m_bmp; if(clear_val <= 255) { memset(m_buf, clear_val, img_size); } m_rbuf_window.attach(m_buf, width, height, (m_specific->m_flip_y ? -row_len : row_len)); } //------------------------------------------------------------------------ void pixel_map::draw(Window dc, int x, int y, double scale) const { DEBUG_MTH("pixel_map::draw"); if(m_bmp == 0 || m_buf == 0) return; m_specific->display_pmap(dc, &m_rbuf_window); } pix_format_e pixel_map::get_pix_format() const { return m_specific->m_format; } unsigned char* pixel_map::buf() { return m_buf; } unsigned pixel_map::width() const { return m_rbuf_window.width(); } unsigned pixel_map::height() const { return m_rbuf_window.height(); } unsigned pixel_map::stride() const { return platform_specific::calc_row_len(width(),m_bpp); } PyObject* pixel_map::convert_to_rgbarray() const { unsigned w = width(); unsigned h = height(); pix_format_e format = get_pix_format(); rgba8 c; unsigned i,j; npy_intp dims[3]; PyObject* arr = NULL; char* data = NULL; dims[0] = w; dims[1] = h; dims[2] = 3; import_array(); arr = PyArray_SimpleNew(3,dims,PyArray_BYTE); if (arr==NULL) return NULL; data = ((PyArrayObject *)arr)->data; switch (format) { case pix_format_bgra32: { pixfmt_bgra32 r((rendering_buffer&)m_rbuf_window); for (j=0;jGetData(); pix_format_e format = get_pix_format(); rgba8 c; unsigned i,j; switch (format) { case pix_format_bgra32: #ifdef WX_RELEASE_2_5 image->SetAlpha(); printf("image->HasAlpha()=%d\n",image->HasAlpha()); #endif { pixel_formats_rgba32 r((rendering_buffer&)m_rbuf_window); for (j=0;jSetAlpha((int)i,(int)j,(unsigned char)c.a); #endif } } break; default: fprintf(stderr,"pix_format %d not handled!\n",format); } return image; } #endif } enthought-chaco2-4.5.1.orig/kiva/agg/src/x11/agg_bmp.h0000644000175000017500000000245412516137326021342 0ustar varunvarun// -*- c++ -*- #ifndef AGG_X11_BMP_INCLUDED #define AGG_X11_BMP_INCLUDED #include "Python.h" #include "x11/agg_platform_specific.h" #ifdef WX_INFO #include #endif namespace agg24 { class pixel_map { public: ~pixel_map(); pixel_map(unsigned width, unsigned height, pix_format_e format, unsigned clear_val, bool bottom_up); void draw(Window h_dc, int x=0, int y=0, double scale=1.0) const; pix_format_e get_pix_format() const; public: unsigned char* buf(); unsigned width() const; unsigned height() const; unsigned stride() const; unsigned bpp() const { return m_bpp; } rendering_buffer& rbuf() { return m_rbuf_window; } PyObject* convert_to_rgbarray() const; PyObject* convert_to_argb32string() const; #ifdef WX_INFO wxImage* convert_to_wximage() const; #endif private: void destroy(); void create(unsigned width, unsigned height, unsigned clear_val=256); private: Pixmap* m_bmp; unsigned char* m_buf; // -> m_bmp unsigned m_bpp; // calculated from format rendering_buffer m_rbuf_window; public: platform_specific* m_specific; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/sequence_to_array.i0000644000175000017500000000175512516137326023051 0ustar varunvarun// Map a Python sequence into any sized C double array // This handles arrays and sequences with non-float values correctly. // !! Optimize for array conversion?? #ifdef SWIGPYTHON %typemap(in) double[ANY](double temp[$1_dim0]) { int i; if (!PySequence_Check($input)) { PyErr_SetString(PyExc_TypeError,"Expecting a sequence"); return NULL; } if (PyObject_Length($input) != $1_dim0) { PyErr_SetString(PyExc_ValueError,"Expecting a sequence with $1_dim0 elements"); return NULL; } for (i =0; i < $1_dim0; i++) { PyObject *o = PySequence_GetItem($input,i); if (PyFloat_Check(o)) { temp[i] = PyFloat_AsDouble(o); } else { PyObject* converted = PyNumber_Float(o); if (!converted) { PyErr_SetString(PyExc_TypeError,"Expecting a sequence of floats"); return NULL; } temp[i] = PyFloat_AsDouble(converted); Py_DECREF(converted); } } $1 = &temp[0]; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_basics.h0000755000175000017500000000666612516137326021627 0ustar varunvarun#ifndef KIVA_BASICS_H #define KIVA_BASICS_H #include "kiva_constants.h" namespace kiva { #ifdef _MSC_VER #if _MSC_VER => 1300 typedef signed __int64 INT64, *PINT64; #else #ifndef INT64 #define INT64 __int64 #endif #endif #endif #ifdef __GNUC__ typedef long long INT64; #endif #ifdef max #undef max #endif #ifdef min #undef min #endif inline double max(double a, double b) { if (a>b) return a; else return b; } inline double min(double a, double b) { if (a=0) { if (y>=0) return 1; else return 4; } else { if (y>=0) return 2; else return 3; } } // Determines whether or not two floating point numbers are // essentially equal. This uses an aspect of the IEEE floating- // point spec described in // http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm // The code for both functions are from this same page. // // The basic idea is to cast the floats to ints and look at then // number of floating point numbers between them. This take advantage // of the fact that the IEEE representation puts the mantissa on the right, // meaning that incrementing an int representation of a float yields the // next representable float. The two's complement stuff is to ensure // that comparisons across the 0 boundary work. // For floating point, a maxUlps (ULP=units in last place) is roughly // equivalent to a precision of 1/8,000,000 to 1/16,000,000 inline bool almost_equal(float A, float B, int maxUlps = 100) { if (A==B) return true; // Make sure maxUlps is non-negative and small enough that the // default NAN won't compare as equal to anything. //assert(maxUlps > 0 && maxUlps < 4 * 1024 * 1024); int aInt = *(int*)&A; // Make aInt lexicographically ordered as a twos-complement int if (aInt < 0) aInt = 0x80000000 - aInt; // Make bInt lexicographically ordered as a twos-complement int int bInt = *(int*)&B; if (bInt < 0) bInt = 0x80000000 - bInt; int intDiff = aInt - bInt; if (intDiff < 0) intDiff = -intDiff; if (intDiff <= maxUlps) return true; return false; } // For double, a maxUlps (ULP=units in last place) is roughly // equivalent to a precision of 1/4e15 to 1/8e15. inline bool almost_equal(double A, double B, int maxUlps = 10000) { // Make sure maxUlps is non-negative and small enough that the // default NAN won't compare as equal to anything. //assert(maxUlps > 0 && maxUlps < 4 * 1024 * 1024); if (A==B) return true; INT64 aInt = *(INT64*)&A; // Make aInt lexicographically ordered as a twos-complement int if (aInt < 0) aInt = 0x80000000 - aInt; // Make bInt lexicographically ordered as a twos-complement int INT64 bInt = *(INT64*)&B; if (bInt < 0) bInt = 0x80000000 - bInt; INT64 intDiff = aInt - bInt; if (intDiff < 0) intDiff = -intDiff; if (intDiff <= maxUlps) return true; return false; } } #endif /* KIVA_BASICS_H */ enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_affine_helpers.cpp0000644000175000017500000000264112516137326023652 0ustar varunvarun#include "kiva_affine_helpers.h" #include #define f_eq(a,b) (fabs((a)-(b)) < epsilon) namespace kiva { bool is_identity(agg24::trans_affine& mat, double epsilon) { double temp[6]; mat.store_to(temp); return (f_eq(temp[0], 1.0) && f_eq(temp[1], 0.0) && f_eq(temp[2], 0.0) && f_eq(temp[3], 1.0) && f_eq(temp[4], 0.0) && f_eq(temp[5], 0.0)); // return (temp[0] == 1.0 && temp[1] == 0.0 && // temp[2] == 0.0 && temp[3] == 1.0 && // temp[4] == 0.0 && temp[5] == 0.0); } bool only_translation(agg24::trans_affine& mat, double epsilon) { double temp[6]; mat.store_to(temp); return (f_eq(temp[0], 1.0) && f_eq(temp[1], 0.0) && f_eq(temp[2], 0.0) && f_eq(temp[3], 1.0)); } bool only_scale_and_translation(agg24::trans_affine& mat, double epsilon) { double temp[6]; mat.store_to(temp); return (f_eq(temp[1], 0.0) && f_eq(temp[2], 0.0)); } void get_translation(agg24::trans_affine& m, double* tx, double* ty) { double temp[6]; m.store_to(temp); *tx = temp[4]; *ty = temp[5]; } void get_scale(agg24::trans_affine& m, double* dx, double* dy) { { double temp[6]; m.store_to(temp); *dx = temp[0]; *dy = temp[3]; } } } enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva.dsp0000644000175000017500000004743512516137326020636 0ustar varunvarun# Microsoft Developer Studio Project File - Name="kiva" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=kiva - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "kiva.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "kiva.mak" CFG="kiva - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "kiva - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "kiva - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "kiva - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I "..\agg2\include" /I "..\agg2\font_freetype" /I "..\freetype2\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 ..\freetype2\objs\ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "kiva - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /G6 /MD /W3 /Gm /GX /ZI /Od /I "..\agg2\include" /I "..\agg2\font_win32_tt" /I "..\agg2\font_freetype" /I "..\..\..\freetype\freetype2\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /Zm1000 /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 ..\build\temp.win32-2.3\freetype2_src.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # SUBTRACT LINK32 /pdb:none !ENDIF # Begin Target # Name "kiva - Win32 Release" # Name "kiva - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\kiva_affine_helpers.cpp # End Source File # Begin Source File SOURCE=.\kiva_affine_helpers.h # End Source File # Begin Source File SOURCE=.\kiva_affine_matrix.h # End Source File # Begin Source File SOURCE=.\kiva_basics.h # End Source File # Begin Source File SOURCE=.\kiva_compiled_path.cpp # End Source File # Begin Source File SOURCE=.\kiva_compiled_path.h # End Source File # Begin Source File SOURCE=.\kiva_constants.h # End Source File # Begin Source File SOURCE=.\kiva_dash_type.h # End Source File # Begin Source File SOURCE=.\kiva_font_type.cpp # End Source File # Begin Source File SOURCE=.\kiva_font_type.h # End Source File # Begin Source File SOURCE=.\kiva_graphics_context.h # End Source File # Begin Source File SOURCE=.\kiva_graphics_context_base.cpp # End Source File # Begin Source File SOURCE=.\kiva_graphics_context_base.h # End Source File # Begin Source File SOURCE=.\kiva_graphics_state.h # End Source File # Begin Source File SOURCE=.\kiva_hit_test.cpp # End Source File # Begin Source File SOURCE=.\kiva_hit_test.h # End Source File # Begin Source File SOURCE=.\kiva_image_filters.h # End Source File # Begin Source File SOURCE=.\kiva_pix_format.h # End Source File # Begin Source File SOURCE=.\kiva_rect.cpp # End Source File # Begin Source File SOURCE=.\kiva_rect.h # End Source File # Begin Source File SOURCE=.\kiva_span_conv_alpha.cpp # End Source File # Begin Source File SOURCE=.\kiva_span_conv_alpha.h # End Source File # Begin Source File SOURCE=.\kiva_text_image.h # End Source File # End Group # Begin Group "SWIG wrappers" # PROP Default_Filter ".i" # Begin Source File SOURCE=.\affine_matrix.i # End Source File # Begin Source File SOURCE=.\agg_std_string.i # End Source File # Begin Source File SOURCE=.\agg_typemaps.i # End Source File # Begin Source File SOURCE=..\build\src\agg_wrap.cpp # PROP Exclude_From_Build 1 # End Source File # Begin Source File SOURCE=.\compiled_path.i # End Source File # Begin Source File SOURCE=.\constants.i # End Source File # Begin Source File SOURCE=.\font_type.i # End Source File # Begin Source File SOURCE=.\graphics_context.i # End Source File # Begin Source File SOURCE=.\numeric.i # End Source File # Begin Source File SOURCE=.\numeric_ext.i # End Source File # Begin Source File SOURCE=.\rect.i # End Source File # Begin Source File SOURCE=.\rgba.i # End Source File # Begin Source File SOURCE=.\rgba_array.i # End Source File # Begin Source File SOURCE=.\sequence_to_array.i # End Source File # End Group # Begin Group "Python files" # PROP Default_Filter "" # Begin Source File SOURCE=.\chaco_ex.py # End Source File # Begin Source File SOURCE=.\code_tst.py # End Source File # Begin Source File SOURCE=.\examples.py # End Source File # Begin Source File SOURCE=.\setup_swig_agg.py # End Source File # Begin Source File SOURCE=.\tst_convert.py # End Source File # Begin Source File SOURCE=.\win32_tst.py # End Source File # End Group # Begin Group "Test files" # PROP Default_Filter "" # Begin Source File SOURCE=.\dummy.cpp # End Source File # End Group # Begin Group "agg sources" # PROP Default_Filter "" # Begin Source File SOURCE=..\agg2\src\agg_arc.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_arrowhead.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_bezier_arc.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_bspline.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_curves.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_embedded_raster_fonts.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_gsv_text.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_image_filters.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_line_aa_basics.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_line_profile_aa.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_path_storage.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_rasterizer_scanline_aa.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_rounded_rect.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_sqrt_tables.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_trans_affine.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_trans_double_path.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_trans_single_path.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_trans_warp_magnifier.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_vcgen_bspline.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_vcgen_contour.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_vcgen_dash.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_vcgen_markers_term.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_vcgen_smooth_poly1.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_vcgen_stroke.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_vpgen_clip_polygon.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_vpgen_clip_polyline.cpp # End Source File # Begin Source File SOURCE=..\agg2\src\agg_vpgen_segmentator.cpp # End Source File # End Group # Begin Group "agg freetype" # PROP Default_Filter "" # Begin Source File SOURCE=..\agg2\font_freetype\agg_font_freetype.cpp # End Source File # Begin Source File SOURCE=..\agg2\font_freetype\agg_font_freetype.h # End Source File # End Group # Begin Group "agg_headers" # PROP Default_Filter "" # Begin Source File SOURCE=..\agg2\include\agg_alpha_mask_u8.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_arc.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_array.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_arrowhead.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_basics.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_bezier_arc.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_bitset_iterator.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_bounding_rect.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_bspline.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_clip_liang_barsky.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_color_rgba.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_color_rgba8.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_adaptor_vcgen.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_adaptor_vpgen.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_bspline.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_clip_polygon.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_clip_polyline.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_close_polygon.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_concat.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_contour.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_curve.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_dash.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_gpc.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_marker.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_marker_adaptor.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_segmentator.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_shorten_path.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_smooth_poly1.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_stroke.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_transform.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_conv_unclose_polygon.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_curves.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_dda_line.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_ellipse.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_ellipse_bresenham.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_embedded_raster_fonts.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_font_cache_manager.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_gamma_functions.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_gamma_lut.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_glyph_raster_bin.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_gray8.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_gsv_text.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_image_filters.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_line_aa_basics.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_math.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_math_stroke.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_path_storage.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_path_storage_integer.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_pattern_filters_rgba8.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_pixfmt_amask_adaptor.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_pixfmt_crb_rgba32.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_pixfmt_crb_rgba32_pre.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_pixfmt_gray8.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_pixfmt_rgb24.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_pixfmt_rgb24_gamma.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_pixfmt_rgb24_pre.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_pixfmt_rgb555.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_pixfmt_rgb565.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_pixfmt_rgba32.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_pixfmt_rgba32_plain.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_pixfmt_rgba32_pre.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_rasterizer_outline.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_rasterizer_outline_aa.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_rasterizer_scanline_aa.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_render_scanlines.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_renderer_base.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_renderer_markers.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_renderer_mclip.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_renderer_outline_aa.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_renderer_outline_image.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_renderer_primitives.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_renderer_raster_text.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_renderer_scanline.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_rendering_buffer.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_rendering_buffer_dynarow.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_rounded_rect.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_scanline_bin.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_scanline_boolean_algebra.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_scanline_p.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_scanline_storage_aa.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_scanline_storage_bin.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_scanline_u.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_shorten_path.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_simul_eq.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_allocator.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_converter.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_generator.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_gouraud.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_gouraud_gray8.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_gouraud_rgba8.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_gouraud_rgba8_gamma.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_gradient.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_gradient_alpha.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_image_filter.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_image_filter_rgb24.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_image_filter_rgb24_gamma.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_image_filter_rgba32.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_interpolator_adaptor.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_interpolator_linear.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_interpolator_trans.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_pattern.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_pattern_filter_rgba32.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_pattern_rgb24.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_pattern_rgba32.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_span_solid.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_trans_affine.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_trans_bilinear.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_trans_double_path.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_trans_perspective.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_trans_single_path.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_trans_viewport.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_trans_warp_magnifier.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_vcgen_bspline.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_vcgen_contour.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_vcgen_dash.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_vcgen_markers_term.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_vcgen_smooth_poly1.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_vcgen_stroke.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_vcgen_vertex_sequence.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_vertex_iterator.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_vertex_sequence.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_vpgen_clip_polygon.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_vpgen_clip_polyline.h # End Source File # Begin Source File SOURCE=..\agg2\include\agg_vpgen_segmentator.h # End Source File # End Group # Begin Source File SOURCE=.\readme.txt # End Source File # Begin Source File SOURCE=.\swig_questions.txt # End Source File # Begin Source File SOURCE=.\todo.txt # End Source File # End Target # End Project enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva.sln0000644000175000017500000000257412516137326020637 0ustar varunvarunMicrosoft Visual Studio Solution File, Format Version 8.00 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kiva", "kiva.vcproj", "{4B72DC63-F35B-45EE-B100-A50A2C79A432}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gl_test", "gl_test\gl_test.vcproj", "{FB096497-AD67-49E8-9C91-790B5C59B5F8}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {4B72DC63-F35B-45EE-B100-A50A2C79A432}.Debug.ActiveCfg = Debug|Win32 {4B72DC63-F35B-45EE-B100-A50A2C79A432}.Debug.Build.0 = Debug|Win32 {4B72DC63-F35B-45EE-B100-A50A2C79A432}.Release.ActiveCfg = Release|Win32 {4B72DC63-F35B-45EE-B100-A50A2C79A432}.Release.Build.0 = Release|Win32 {FB096497-AD67-49E8-9C91-790B5C59B5F8}.Debug.ActiveCfg = Debug|Win32 {FB096497-AD67-49E8-9C91-790B5C59B5F8}.Debug.Build.0 = Debug|Win32 {FB096497-AD67-49E8-9C91-790B5C59B5F8}.Release.ActiveCfg = Release|Win32 {FB096497-AD67-49E8-9C91-790B5C59B5F8}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_pix_format.h0000644000175000017500000000620712516137326022517 0ustar varunvarun///////////////////////////////////////////////////////////////////////////// // // This set of templatized functions return a kiva::pix_format_e value based // on the agg pixel format template parameter. The function is called from // the graphics_context.format() method. // ///////////////////////////////////////////////////////////////////////////// #ifndef KIVA_PIX_FORMAT_H #define KIVA_PIX_FORMAT_H #include "agg_pixfmt_gray.h" #include "agg_pixfmt_rgb.h" #include "agg_pixfmt_rgba.h" #include "kiva_constants.h" namespace kiva { // Templatized conversion function to turn Agg pixel formats // into the right kiva pixfmt enumeration instance. // The default function returns "undefined", and the template // is specialized for each of the actual Agg pixel formats. template kiva::pix_format_e agg_pix_to_kiva(void *dummy=NULL) { return kiva::pix_format_undefined; } // Specializations follow. // The dummy pointer argument is needed because MSVC++ 6.0 doesn't properly // support specialization of template functions. When it generates code for // template functions, the mangled name of an instance of a function template // only includes the function parameter types (and not the template arguments). // The linker then discards the seemingly duplicate function definitions, // and all calls to agg_pix_to_kiva() end up in an arbitrary one of the // following specializations (usually the first). The obvious workaround is // to add optional function parameters corresponding to the template parameter. // // Furthermore, when calling these functions, MSVC will complain about // ambiguous overloading, so you have to create a dummy pointer and pass it // in. Normally, you would be able to do this: // // template void Foo() // { // do_something( agg_pix_to_kiva() ); // } // // But with MSVC, you have to do this: // // template void Foo() // { // agg_pix_fmt *dummy = NULL; // do_something( agg_pix_to_kiva(dummy) ); // } // // inline kiva::pix_format_e agg_pix_to_kiva(agg24::pixfmt_gray8 *msvc6_dummy = NULL) { return kiva::pix_format_gray8; } inline kiva::pix_format_e agg_pix_to_kiva(agg24::pixfmt_rgb24 *msvc6_dummy = NULL) { return kiva::pix_format_rgb24; } inline kiva::pix_format_e agg_pix_to_kiva(agg24::pixfmt_bgr24 *msvc6_dummy = NULL) { return kiva::pix_format_bgr24; } inline kiva::pix_format_e agg_pix_to_kiva(agg24::pixfmt_bgra32 *msvc6_dummy = NULL) { return kiva::pix_format_bgra32; } inline kiva::pix_format_e agg_pix_to_kiva(agg24::pixfmt_rgba32 *msvc6_dummy = NULL) { return kiva::pix_format_rgba32; } inline kiva::pix_format_e agg_pix_to_kiva(agg24::pixfmt_argb32 *msvc6_dummy = NULL) { return kiva::pix_format_argb32; } inline kiva::pix_format_e agg_pix_to_kiva(agg24::pixfmt_abgr32 *msvc6_dummy = NULL) { return kiva::pix_format_abgr32; } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_hit_test.h0000644000175000017500000000123712516137326022170 0ustar varunvarun#ifndef KIVA_HIT_TEST_H #define KIVA_HIT_TEST_H namespace kiva { bool point_in_polygon(double x, double y, double* poly_pts, int Npoly_pts); void points_in_polygon(double* pts, int Npts, double* poly_pts, int Npoly_pts, int* results, int Nresults); bool point_in_polygon_winding(double x, double y, double* poly_pts, int Npoly_pts); void points_in_polygon_winding(double* pts, int Npts, double* poly_pts, int Npoly_pts, int* results, int Nresults); } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/gtk1/0000755000175000017500000000000012516137726020031 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/agg/src/gtk1/agg_platform_specific.cpp0000644000175000017500000003036712516137326025051 0ustar varunvarun#include #include #include #include #include #include "gtk1/agg_platform_specific.h" #include "util/agg_color_conv_rgb8.h" #include "gtk1/agg_bmp.h" //#define DEBUG_MTH(NAME) fprintf(stderr, NAME "\n"); #define DEBUG_MTH(NAME) typedef struct { short x1, x2, y1, y2; } Box, BOX, BoxRec, *BoxPtr; typedef struct { short x, y, width, height; }RECTANGLE, RectangleRec, *RectanglePtr; typedef struct _XRegion { long size; long numRects; BOX *rects; BOX extents; } REGION; namespace agg24 { x11_display::x11_display(): m_screen(0), m_depth(0), m_visual(0), m_dc(0), m_gc(0), m_sys_bpp(0) { DEBUG_MTH("x11_display::x11_display"); } x11_display::~x11_display() { DEBUG_MTH("x11_display::~x11_display"); close(); } bool x11_display::open(const char* display_name) { DEBUG_MTH("x11_display::open"); if (m_display != 0) { fprintf(stderr, "X11 display is opened already\n"); return false; } //printf("Opened X11 display: %s\n", display_name); m_display = XOpenDisplay(display_name); if (m_display == 0) { fprintf(stderr, "Unable to open DISPLAY=%s!\n",display_name); return false; } m_screen = DefaultScreen(m_display); m_depth = DefaultDepth(m_display, m_screen); m_visual = DefaultVisual(m_display, m_screen); switch(m_depth) { case 15: case 16: m_sys_bpp = 16; break; case 24: case 32: m_sys_bpp = 32; break; default: fprintf(stderr, "Unexpected X11 display depth=%d!\n",m_depth); } return true; } void x11_display::close() { DEBUG_MTH("x11_display::close"); if (m_display != 0) { if (m_gc != 0) XFreeGC(m_display, m_gc); XCloseDisplay(m_display); } m_display = 0; m_screen = 0; m_depth = 0; m_visual = 0; m_dc = 0; m_gc = 0; } bool x11_display::put_image(Window dc, XImage* image) { DEBUG_MTH("x11_display::put_image"); if (m_dc != dc) { if (m_gc) XFreeGC(m_display, m_gc); m_dc = dc; //m_gc = DefaultGC(m_display, m_screen); m_gc = XCreateGC(m_display, m_dc, 0, 0); } XPutImage(m_display, dc, m_gc, image, 0, 0, 0, 0, image->width, image->height ); return true; } XImage* x11_display::create_image(const rendering_buffer* rbuf) { DEBUG_MTH("x11_display::create_image"); unsigned width = rbuf->width(); unsigned height = rbuf->height(); return XCreateImage(m_display, m_visual, //CopyFromParent, m_depth, ZPixmap, 0, (char*)(rbuf->buf()), width, height, m_sys_bpp, width * (m_sys_bpp / 8)); } void x11_display::destroy_image(XImage* ximg) { DEBUG_MTH("x11_display::destroy_image"); if (ximg != 0) XDestroyImage(ximg); /* XDestroyImage function frees both the image structure and the data pointed to by the image structure. */ } //------------------------------------------------------------------------ platform_specific::platform_specific(pix_format_e format, bool flip_y) : m_format(format), m_flip_y(flip_y), m_bpp(0), m_sys_bpp(0), m_sys_format(pix_format_undefined), m_ximage(0) { DEBUG_MTH("platform_specific::platform_specific"); init(); } platform_specific::~platform_specific() { DEBUG_MTH("platform_specific::~platform_specific"); } x11_display platform_specific::x11; bool platform_specific::init() { DEBUG_MTH("platform_specific::init"); if (x11.m_display == 0 && !x11.open()) { fprintf(stderr, "No X11 display available!\n"); return false; } unsigned long r_mask = x11.m_visual->red_mask; unsigned long g_mask = x11.m_visual->green_mask; unsigned long b_mask = x11.m_visual->blue_mask; if(x11.m_depth < 15 || r_mask == 0 || g_mask == 0 || b_mask == 0) { fprintf(stderr, "There's no Visual compatible with minimal AGG requirements:\n" "At least 15-bit color depth and True- or DirectColor class.\n\n" ); return false; } switch(m_format) { case pix_format_gray8: m_bpp = 8; break; case pix_format_rgb565: case pix_format_rgb555: m_bpp = 16; break; case pix_format_rgb24: case pix_format_bgr24: m_bpp = 24; break; case pix_format_bgra32: case pix_format_abgr32: case pix_format_argb32: case pix_format_rgba32: m_bpp = 32; break; case pix_format_undefined: case end_of_pix_formats: ; } // // Calculate m_sys_format, m_byte_order, m_sys_bpp: // int t = 1; int hw_byte_order = LSBFirst; if(*(char*)&t == 0) hw_byte_order = MSBFirst; switch(x11.m_depth) { case 15: m_sys_bpp = 16; if(r_mask == 0x7C00 && g_mask == 0x3E0 && b_mask == 0x1F) { m_sys_format = pix_format_rgb555; m_byte_order = hw_byte_order; } break; case 16: m_sys_bpp = 16; if(r_mask == 0xF800 && g_mask == 0x7E0 && b_mask == 0x1F) { m_sys_format = pix_format_rgb565; m_byte_order = hw_byte_order; } break; case 24: case 32: m_sys_bpp = 32; if(g_mask == 0xFF00) { if(r_mask == 0xFF && b_mask == 0xFF0000) { switch(m_format) { case pix_format_rgba32: m_sys_format = pix_format_rgba32; m_byte_order = LSBFirst; break; case pix_format_abgr32: m_sys_format = pix_format_abgr32; m_byte_order = MSBFirst; break; default: m_byte_order = hw_byte_order; m_sys_format = (hw_byte_order == LSBFirst) ? pix_format_rgba32 : pix_format_abgr32; break; } } if(r_mask == 0xFF0000 && b_mask == 0xFF) { switch(m_format) { case pix_format_argb32: m_sys_format = pix_format_argb32; m_byte_order = MSBFirst; break; case pix_format_bgra32: m_sys_format = pix_format_bgra32; m_byte_order = LSBFirst; break; default: m_byte_order = hw_byte_order; m_sys_format = (hw_byte_order == MSBFirst) ? pix_format_argb32 : pix_format_bgra32; break; } } } break; } if(m_sys_format == pix_format_undefined) { fprintf(stderr, "RGB masks are not compatible with AGG pixel formats:\n" "R=%08x, G=%08x, B=%08x\n", r_mask, g_mask, b_mask); return false; } return true; } #define UNHANDLED_PIX_FORMATS \ case end_of_pix_formats: ; \ case pix_format_gray8: ; \ case pix_format_undefined: ; void platform_specific::destroy() { DEBUG_MTH("platform_specific::destroy"); if (m_ximage != 0) { x11.destroy_image(m_ximage); m_ximage = 0; } } void platform_specific::display_pmap(Window dc, const rendering_buffer* rbuf) { DEBUG_MTH("platform_specific::display_map"); if (m_format == m_sys_format) { if (m_ximage == 0) { m_ximage = x11.create_image(rbuf); m_ximage->byte_order = m_byte_order; } x11.put_image(dc, m_ximage); return; } // Optimization hint: make pmap_tmp as a private class member and reused it when possible. pixel_map pmap_tmp(rbuf->width(), rbuf->height(), m_sys_format, 256, m_flip_y); rendering_buffer* rbuf2 = &pmap_tmp.rbuf(); switch(m_sys_format) { case pix_format_rgb555: switch(m_format) { case pix_format_rgb555: color_conv(rbuf2, rbuf, color_conv_rgb555_to_rgb555()); break; case pix_format_rgb565: color_conv(rbuf2, rbuf, color_conv_rgb565_to_rgb555()); break; case pix_format_rgb24: color_conv(rbuf2, rbuf, color_conv_rgb24_to_rgb555()); break; case pix_format_bgr24: color_conv(rbuf2, rbuf, color_conv_bgr24_to_rgb555()); break; case pix_format_rgba32: color_conv(rbuf2, rbuf, color_conv_rgba32_to_rgb555()); break; case pix_format_argb32: color_conv(rbuf2, rbuf, color_conv_argb32_to_rgb555()); break; case pix_format_bgra32: color_conv(rbuf2, rbuf, color_conv_bgra32_to_rgb555()); break; case pix_format_abgr32: color_conv(rbuf2, rbuf, color_conv_abgr32_to_rgb555()); break; UNHANDLED_PIX_FORMATS; } break; case pix_format_rgb565: switch(m_format) { case pix_format_rgb555: color_conv(rbuf2, rbuf, color_conv_rgb555_to_rgb565()); break; case pix_format_rgb565: color_conv(rbuf2, rbuf, color_conv_rgb565_to_rgb565()); break; case pix_format_rgb24: color_conv(rbuf2, rbuf, color_conv_rgb24_to_rgb565()); break; case pix_format_bgr24: color_conv(rbuf2, rbuf, color_conv_bgr24_to_rgb565()); break; case pix_format_rgba32: color_conv(rbuf2, rbuf, color_conv_rgba32_to_rgb565()); break; case pix_format_argb32: color_conv(rbuf2, rbuf, color_conv_argb32_to_rgb565()); break; case pix_format_bgra32: color_conv(rbuf2, rbuf, color_conv_bgra32_to_rgb565()); break; case pix_format_abgr32: color_conv(rbuf2, rbuf, color_conv_abgr32_to_rgb565()); break; UNHANDLED_PIX_FORMATS; } break; case pix_format_rgba32: switch(m_format) { case pix_format_rgb555: color_conv(rbuf2, rbuf, color_conv_rgb555_to_rgba32()); break; case pix_format_rgb565: color_conv(rbuf2, rbuf, color_conv_rgb565_to_rgba32()); break; case pix_format_rgb24: color_conv(rbuf2, rbuf, color_conv_rgb24_to_rgba32()); break; case pix_format_bgr24: color_conv(rbuf2, rbuf, color_conv_bgr24_to_rgba32()); break; case pix_format_rgba32: color_conv(rbuf2, rbuf, color_conv_rgba32_to_rgba32()); break; case pix_format_argb32: color_conv(rbuf2, rbuf, color_conv_argb32_to_rgba32()); break; case pix_format_bgra32: color_conv(rbuf2, rbuf, color_conv_bgra32_to_rgba32()); break; case pix_format_abgr32: color_conv(rbuf2, rbuf, color_conv_abgr32_to_rgba32()); break; UNHANDLED_PIX_FORMATS; } break; case pix_format_abgr32: switch(m_format) { case pix_format_rgb555: color_conv(rbuf2, rbuf, color_conv_rgb555_to_abgr32()); break; case pix_format_rgb565: color_conv(rbuf2, rbuf, color_conv_rgb565_to_abgr32()); break; case pix_format_rgb24: color_conv(rbuf2, rbuf, color_conv_rgb24_to_abgr32()); break; case pix_format_bgr24: color_conv(rbuf2, rbuf, color_conv_bgr24_to_abgr32()); break; case pix_format_abgr32: color_conv(rbuf2, rbuf, color_conv_abgr32_to_abgr32()); break; case pix_format_rgba32: color_conv(rbuf2, rbuf, color_conv_rgba32_to_abgr32()); break; case pix_format_argb32: color_conv(rbuf2, rbuf, color_conv_argb32_to_abgr32()); break; case pix_format_bgra32: color_conv(rbuf2, rbuf, color_conv_bgra32_to_abgr32()); break; UNHANDLED_PIX_FORMATS; } break; case pix_format_argb32: switch(m_format) { case pix_format_rgb555: color_conv(rbuf2, rbuf, color_conv_rgb555_to_argb32()); break; case pix_format_rgb565: color_conv(rbuf2, rbuf, color_conv_rgb565_to_argb32()); break; case pix_format_rgb24: color_conv(rbuf2, rbuf, color_conv_rgb24_to_argb32()); break; case pix_format_bgr24: color_conv(rbuf2, rbuf, color_conv_bgr24_to_argb32()); break; case pix_format_rgba32: color_conv(rbuf2, rbuf, color_conv_rgba32_to_argb32()); break; case pix_format_argb32: color_conv(rbuf2, rbuf, color_conv_argb32_to_argb32()); break; case pix_format_abgr32: color_conv(rbuf2, rbuf, color_conv_abgr32_to_argb32()); break; case pix_format_bgra32: color_conv(rbuf2, rbuf, color_conv_bgra32_to_argb32()); break; UNHANDLED_PIX_FORMATS; } break; case pix_format_bgra32: switch(m_format) { case pix_format_rgb555: color_conv(rbuf2, rbuf, color_conv_rgb555_to_bgra32()); break; case pix_format_rgb565: color_conv(rbuf2, rbuf, color_conv_rgb565_to_bgra32()); break; case pix_format_rgb24: color_conv(rbuf2, rbuf, color_conv_rgb24_to_bgra32()); break; case pix_format_bgr24: color_conv(rbuf2, rbuf, color_conv_bgr24_to_bgra32()); break; case pix_format_rgba32: color_conv(rbuf2, rbuf, color_conv_rgba32_to_bgra32()); break; case pix_format_argb32: color_conv(rbuf2, rbuf, color_conv_argb32_to_bgra32()); break; case pix_format_abgr32: color_conv(rbuf2, rbuf, color_conv_abgr32_to_bgra32()); break; case pix_format_bgra32: color_conv(rbuf2, rbuf, color_conv_bgra32_to_bgra32()); break; UNHANDLED_PIX_FORMATS; } break; UNHANDLED_PIX_FORMATS; } pmap_tmp.draw(dc); } unsigned platform_specific::calc_row_len(unsigned width, unsigned bits_per_pixel) { return width * (bits_per_pixel / 8); } } enthought-chaco2-4.5.1.orig/kiva/agg/src/gtk1/plat_support.i0000644000175000017500000000625012516137326022736 0ustar varunvarun// -*- c++ -*- %module plat_support %include numeric.i %{ #include "gtk1/agg_bmp.h" namespace agg24 { PyObject* pixel_map_as_unowned_array(agg24::pixel_map& pix_map) { npy_intp dims[3]; npy_intp rows = pix_map.height(); npy_intp cols = pix_map.width(); npy_intp depth = pix_map.bpp() / 8; dims[0] = rows; dims[1] = cols; dims[2] = depth; return PyArray_SimpleNewFromData(3,dims,NPY_UINT8,(void*)pix_map.buf()); } } %} %typemap(in)(Window) { $1 = (Window) PyInt_AsLong($input); } // More permissive unsigned typemap that converts any numeric type to an // unsigned value. It is cleared at the end of this file. %typemap(in) unsigned { PyObject* obj = PyNumber_Int($input); if (PyErr_Occurred()) SWIG_fail; $1 = (unsigned) PyLong_AsLong(obj); if (PyErr_Occurred()) SWIG_fail; } namespace agg24 { enum pix_format_e { pix_format_undefined = 0, // By default. No conversions are applied pix_format_gray8, // Simple 256 level grayscale pix_format_rgb555, // 15 bit rgb. Depends on the byte ordering! pix_format_rgb565, // 16 bit rgb. Depends on the byte ordering! pix_format_rgb24, // R-G-B, one byte per color component pix_format_bgr24, // B-G-R, native win32 BMP format. pix_format_rgba32, // R-G-B-A, one byte per color component pix_format_argb32, // A-R-G-B, native MAC format pix_format_abgr32, // A-B-G-R, one byte per color component pix_format_bgra32, // B-G-R-A, native win32 BMP format end_of_pix_formats }; %name(PixelMap) class pixel_map { public: ~pixel_map(); pixel_map(unsigned width, unsigned height, pix_format_e format, unsigned clear_val, bool bottom_up); public: // Should really fix this using a typecheck typemap. Read the // "typemaps and overloading" section of the SWIG docs. %feature("shadow") draw(Window h_dc, int x, int y, double scale) const %{ def draw(self, h_dc, x=0, y=0, scale=1.0): # fix me: brittle becuase we are hard coding # module and class name. Done cause SWIG 1.3.24 does # some funky overloading stuff in it that breaks keyword # arguments. result = _plat_support.PixelMap_draw(self, h_dc, x, y, scale) return result %} void draw(Window h_dc, int x, int y, double scale) const; PyObject* convert_to_rgbarray() const; %pythoncode %{ def set_bmp_array(self): self.bmp_array = pixel_map_as_unowned_array(self) return self def draw_to_tkwindow(self, window, x, y): window_id = window._tk_widget.winfo_id() self.draw(window_id, x, y) return def draw_to_wxwindow(self, window, x, y): window_id = window.GetHandle() self.draw(window_id, x, y) return %} }; } PyObject* pixel_map_as_unowned_array(agg24::pixel_map& pix_map); // clear the "permissive" unsigned typemap we are using. %typemap(in) unsigned; enthought-chaco2-4.5.1.orig/kiva/agg/src/gtk1/agg_platform_specific.h0000644000175000017500000000446412516137326024515 0ustar varunvarun// -*- c++ -*- #ifndef AGG_GTK1_SPECIFIC_INCLUDED #define AGG_GTK1_SPECIFIC_INCLUDED #include #include "agg_basics.h" #include "agg_rendering_buffer.h" namespace agg24 { enum pix_format_e { pix_format_undefined = 0, // By default. No conversions are applied pix_format_gray8, // Simple 256 level grayscale pix_format_rgb555, // 15 bit rgb. Depends on the byte ordering! pix_format_rgb565, // 16 bit rgb. Depends on the byte ordering! pix_format_rgb24, // R-G-B, one byte per color component pix_format_bgr24, // B-G-R, native win32 BMP format. pix_format_rgba32, // R-G-B-A, one byte per color component pix_format_argb32, // A-R-G-B, native MAC format pix_format_abgr32, // A-B-G-R, one byte per color component pix_format_bgra32, // B-G-R-A, native win32 BMP format end_of_pix_formats }; class x11_display { public: x11_display(); ~x11_display(); bool open(const char* display_name = NULL); void close(); bool put_image(Window dc, XImage* image); XImage* create_image(const rendering_buffer* rbuf); void destroy_image(XImage* ximg); public: Display* m_display; int m_screen; int m_depth; Visual* m_visual; Window m_dc; GC m_gc; unsigned m_sys_bpp; }; //------------------------------------------------------------------------ class platform_specific { static x11_display x11; public: platform_specific(pix_format_e format, bool flip_y); ~platform_specific(); void display_pmap(Window dc, const rendering_buffer* src); void destroy(); static unsigned calc_row_len(unsigned width, unsigned bits_per_pixel); private: bool init(); public: unsigned m_bpp; // init() bool m_flip_y; // platform_specific() XImage* m_ximage; // display_pmap() pix_format_e m_format; // platform_specific() private: int m_byte_order; // init() unsigned m_sys_bpp; // init() pix_format_e m_sys_format; // init() }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/gtk1/agg_bmp.cpp0000644000175000017500000000756612516137326022143 0ustar varunvarun #include #include #include #include "gtk1/agg_bmp.h" #include "gtk1/agg_platform_specific.h" //#include #include "agg_pixfmt_rgba.h" #include "agg_color_rgba.h" #ifdef NUMPY #include "numpy/arrayobject.h" # ifndef PyArray_SBYTE # include "numpy/noprefix.h" # include "numpy/oldnumeric.h" # include "numpy/old_defines.h" # endif #else #include "Numeric/arrayobject.h" #define PyArray_UBYTELTR 'b' #endif #if 0 #define DEBUG_MTH(NAME) fprintf(stderr, NAME "\n"); #define DEBUG_MTH2(STR,ARG1,ARG2) fprintf(stderr, STR "\n",(ARG1),(ARG2)); #define DEBUG_MTH5(STR,ARG1,ARG2,ARG3,ARG4,ARG5) fprintf(stderr, STR "\n",(ARG1),(ARG2),(ARG3),(ARG4),(ARG5)); #else #define DEBUG_MTH(NAME) #define DEBUG_MTH2(STR,ARG1,ARG2) #define DEBUG_MTH5(STR,ARG1,ARG2,ARG3,ARG4,ARG5) #endif namespace agg24 { //------------------------------------------------------------------------ pixel_map::pixel_map(unsigned width, unsigned height, pix_format_e format, unsigned clear_val, bool bottom_up): m_bmp(0), m_buf(0), m_specific(new platform_specific(format, bottom_up)) { DEBUG_MTH5("pixel_map::pixel_map(%d,%d,%d,%d,%d)",width,height,format,clear_val,bottom_up); m_bpp = m_specific->m_bpp; create(width, height, clear_val); } //------------------------------------------------------------------------ pixel_map::~pixel_map() { DEBUG_MTH("pixel_map::~pixel_map"); destroy(); delete m_specific; } //------------------------------------------------------------------------ void pixel_map::destroy() { if (m_specific->m_ximage != 0) { m_specific->destroy(); } else if(m_bmp) { delete [] (unsigned char*)m_bmp; } m_bmp = 0; m_buf = 0; } //------------------------------------------------------------------------ void pixel_map::create(unsigned width, unsigned height, unsigned clear_val) { destroy(); if(width == 0) width = 1; if(height == 0) height = 1; unsigned row_len = platform_specific::calc_row_len(width, m_bpp); unsigned img_size = row_len * height; m_bmp = (Pixmap*) new unsigned char[img_size]; m_buf = (unsigned char*)m_bmp; if(clear_val <= 255) { memset(m_buf, clear_val, img_size); } m_rbuf_window.attach(m_buf, width, height, (m_specific->m_flip_y ? -row_len : row_len)); } //------------------------------------------------------------------------ void pixel_map::draw(Window dc, int x, int y, double scale) const { DEBUG_MTH("pixel_map::draw"); if(m_bmp == 0 || m_buf == 0) return; m_specific->display_pmap(dc, &m_rbuf_window); } pix_format_e pixel_map::get_pix_format() const { return m_specific->m_format; } unsigned char* pixel_map::buf() { return m_buf; } unsigned pixel_map::width() const { return m_rbuf_window.width(); } unsigned pixel_map::height() const { return m_rbuf_window.height(); } unsigned pixel_map::stride() const { return platform_specific::calc_row_len(width(),m_bpp); } PyObject* pixel_map::convert_to_rgbarray() const { unsigned w = width(); unsigned h = height(); pix_format_e format = get_pix_format(); rgba8 c; unsigned i,j; npy_intp dims[3]; PyObject* arr = NULL; char* data = NULL; dims[0] = w; dims[1] = h; dims[2] = 3; import_array(); arr = PyArray_SimpleNew(3, dims, PyArray_BYTE); if (arr==NULL) return NULL; data = ((PyArrayObject *)arr)->data; switch (format) { case pix_format_bgra32: { pixfmt_bgra32 r((rendering_buffer&)m_rbuf_window); for (j=0;j m_bmp unsigned m_bpp; // calculated from format rendering_buffer m_rbuf_window; public: platform_specific* m_specific; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/affine_matrix.i0000644000175000017500000001537512516137326022160 0ustar varunvarun/* -*- c -*- */ /* AffineMatrix class wrapper 1. C++ class 'trans_affine' is renamed to python '_AffineMatrix' 2. All methods accept 'transform' and 'inverse_transform' are wrapped. 3. __repr__ and __str__ methods are added to print out an _AffineMatrix object as: "AffineMatrix(a,b,c,d,tx,ty)" 4. A subclass called 'AffineMatrix' is derived from '_AffineMatrix' using a %pythoncode directive. This is so that __init__ can be overloadeded to convert a sequence into the appropriate argument convention for the _AffineMatrix constructor. 5. Classes such as trans_affine_rotation were converted to factory functions so that they return an trans_affine class instead of having a new class type (such as RotationMatrix). Notes: !! 1. !! (4) is a hack to get around the fact that I couldn't !! figure out how to get the overloaded constructor for trans_affine !! to accept a Numeric array as input -- even if I added a function !! new_AffineMatrix(double ary[6]); and then put the !! trans_affine(double ary[6]) signature in the class interface. It !! appears that SWIG is a little overzealous in its type checking !! in the constructor call, only allowing double* pointers through !! instead of allowing any sequence through. This is the correct !! default behavior, but I couldn't figure out how to overload it with !! my own test. !! !! 2. !! The C++ operator *= is definitely broken -- probably not setting the !! thisown property correctly on returned pointers. It is currently !! set to return void so that it can't cause any mischief, but it also !! breaks its functionality. !! FIX: I have just created this function in Python and call the !! C++ multiply() method. */ %include "numeric.i" %include "sequence_to_array.i" %{ #ifdef NUMPY #include "numpy/arrayobject.h" #else #include "Numeric/arrayobject.h" #endif #include "agg_trans_affine.h" // These factories mimic the functionality of like-named classes in agg. // Making them functions that return trans_affine types leads to a cleaner // and easier to maintain Python interface. agg24::trans_affine* trans_affine_rotation(double a) { return new agg24::trans_affine(cos(a), sin(a), -sin(a), cos(a), 0.0, 0.0); } agg24::trans_affine* trans_affine_scaling(double sx, double sy) { return new agg24::trans_affine(sx, 0.0, 0.0, sy, 0.0, 0.0); } agg24::trans_affine* trans_affine_translation(double tx, double ty) { return new agg24::trans_affine(1.0, 0.0, 0.0, 1.0, tx, ty); } agg24::trans_affine* trans_affine_skewing(double sx, double sy) { return new agg24::trans_affine(1.0, tan(sy), tan(sx), 1.0, 0.0, 0.0); } %} %newobject trans_affine_rotation; %rename(rotation_matrix) trans_affine_rotation(double); agg24::trans_affine* trans_affine_rotation(double a); %newobject trans_affine_scaling; %rename(scaling_matrix) trans_affine_scaling(double, double); agg24::trans_affine* trans_affine_scaling(double sx, double sy); %newobject trans_affine_translation; %rename(translation_matrix) trans_affine_translation(double, double); agg24::trans_affine* trans_affine_translation(double tx, double ty); %newobject trans_affine_skewing; %rename(skewing_matrix) trans_affine_skewing(double, double); agg24::trans_affine* trans_affine_skewing(double sx, double sy); %include "agg_typemaps.i" %apply (double* array6) {(double* out)}; // used by __getitem__ %typemap(check) (int affine_index) { if ($1 < 0 || $1 > 5) { PyErr_Format(PyExc_IndexError, "affine matrices are indexed 0 to 5. Received %d", $1); return NULL; } } %apply owned_pointer { agg24::trans_affine* }; namespace agg24 { %rename(_AffineMatrix) trans_affine; %rename(asarray) trans_affine::store_to(double*) const; class trans_affine { public: trans_affine(); trans_affine(const trans_affine& m); trans_affine(double v0, double v1, double v2, double v3, double v4, double v5); trans_affine operator ~ () const; // I added this to trans_affine -- it really isn't there. // trans_affine operator *(const trans_affine& m); // Returning trans_affine& causes problems, so these are all // changed to void. //const trans_affine& operator *= (const trans_affine& m); //const trans_affine& reset(); // const trans_affine& multiply(const trans_affine& m); // const trans_affine& invert(); // const trans_affine& flip_x(); // const trans_affine& flip_y(); //void operator *= (const trans_affine& m); void reset(); void multiply(const trans_affine& m); void invert(); void flip_x(); void flip_y(); double scale() const; double determinant() const; void store_to(double* out) const; //const trans_affine& load_from(double ary[6]); void load_from(double ary[6]); // !! omitted //void transform(double* x, double* y) const; //void inverse_transform(double* x, double* y) const; }; }; %pythoncode { def is_sequence(arg): try: len(arg) return 1 except: return 0 # AffineMatrix sub-class to get around problems with adding # a AffineMatrix constructor that accepts a Numeric array # as input. class AffineMatrix(_AffineMatrix): def __init__(self,*args): if len(args) == 1 and is_sequence(args[0]): args = tuple(args[0]) if len(args) != 6: raise ValueError, "array argument must be 1x6" _AffineMatrix.__init__(self,*args) def __imul__(self,other): """ inplace multiply We don't use the C++ version of this because it ends up deleting the object out from under itself. """ self.multiply(other) return self } %extend agg24::trans_affine { char *__repr__() { // Write out elements of trans_affine in a,b,c,d,tx,ty order // !! We should work to make output formatting conform to // !! whatever it Numeric does (which needs to be cleaned up also). static char tmp[1024]; double m[6]; self->store_to(m); sprintf(tmp,"AffineMatrix(%g,%g,%g,%g,%g,%g)", m[0], m[1], m[2], m[3], m[4], m[5]); return tmp; } double __getitem__(int affine_index) { double ary[6]; self->store_to(ary); return ary[affine_index]; } int __eq__(agg24::trans_affine& other) { double ary1[6], ary2[6]; self->store_to(ary1); other.store_to(ary2); int eq = 1; for (int i = 0; i < 6; i++) eq &= (ary1[i] == ary2[i]); return eq; } } enthought-chaco2-4.5.1.orig/kiva/agg/src/hit_test.i0000644000175000017500000000642612516137326021164 0ustar varunvarun%{ #include "kiva_hit_test.h" %} %include "agg_typemaps.i" %apply (double* point_array, int point_count) {(double* pts, int Npts)}; %apply (double* point_array, int point_count) {(double* poly_pts, int Npoly_pts)}; %apply (int* results, int Nresults) {(int* results, int Nresults)}; namespace kiva { bool point_in_polygon(double x, double y, double* poly_pts, int Npoly_pts); void points_in_polygon(double* pts, int Npts, double* poly_pts, int Npoly_pts, int* results, int Nresults); bool point_in_polygon_winding(double x, double y, double* poly_pts, int Npoly_pts); void points_in_polygon_winding(double* pts, int Npts, double* poly_pts, int Npoly_pts, int* results, int Nresults); } %pythoncode { from numpy import shape, transpose, zeros, rank, reshape, int32 def points_in_polygon(pts, poly_pts, use_winding=False): """ Test whether point pairs in pts are within the polygon, poly_pts. Parameters ---------- pts an Nx2 array of x,y point pairs (floating point). Each point is tested to determine whether it falls within the polygon defined by `poly_pts`. poly_pts an Mx2 array of x,y point pairs (floating point) that define the boundaries of a polygon. The last point is considered to be connected to the first point. return a 1D array of integers. 1 is returned if the corresponding x,y pair in `pts` falls within `poly_pts`. 0 is returned otherwise. This algorithm works for complex polygons. Note: If the test point is on the border of the polygon, this algorithm will deliver unpredictable results; i.e. the result may be "inside" or "outside" depending on arbitrary factors such as how the polygon is oriented with respect to the coordinate system. Adapted from: http://www.alienryderflex.com/polygon/ Example:: >>> from numpy import * >>> from kiva import agg >>> poly = array(((0.0, 0.0), (10.0, 0.0), (10.0, 10.0), ( 0.0, 10.0))) >>> pts = array(((-1.0, -1.0), ( 5.0, 5.0), ( 15.0, 15.0))) >>> results = agg.points_in_polygon(pts, poly) [0 1 0] """ # Check the shape of pts and transpose if necessary. if rank(pts) == 1: pts = reshape(pts, (1,)+shape(pts)) if shape(pts)[1] != 2: if shape(pts)[0] == 2: pts = transpose(pts) else: raise ValueError('pts must be an Nx2 or 2xN array') # Check the shape of poly_pts and transpose if necessary if rank(poly_pts) == 1: poly_pts = reshape(poly_pts, (1,)+shape(poly_pts)) if shape(poly_pts)[1] != 2: if shape(poly_pts)[0] == 2: poly_pts = transpose(poly_pts) else: raise ValueError('poly_pts must be an Nx2 or 2xN array') results = zeros(len(pts),int32) if use_winding: _agg.points_in_polygon_winding(pts, poly_pts, results) else: _agg.points_in_polygon(pts, poly_pts, results) return results } enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_font_type.h0000644000175000017500000000267712516137326022365 0ustar varunvarun#ifndef FONT_TYPE_H #define FONT_TYPE_H #include #ifdef _MSC_VER // Turn off MSDEV warning about truncated long identifiers #pragma warning(disable:4786) #endif namespace kiva { class font_type { public: std::string name; std::string filename; int size; int family; int style; int encoding; // Constructors // Creates a font object. By default, searches the hardcoded // font paths for a file named like the face name; to override // this, set validate=false. font_type(std::string _name="Arial", int _size=12, int _family=0, int _style=0, int _encoding=0, bool validate=true); font_type(const font_type &font); font_type &operator=(const font_type& font); int change_filename(std::string _filename); // Is the font loaded properly? inline bool is_loaded() const { return _is_loaded; } private: bool _is_loaded; }; inline bool operator==(font_type &a, font_type &b) { return (a.size == b.size) && (a.name == b.name) && (a.style == b.style) && (a.encoding == b.encoding) && (a.family == b.family); } } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/graphics_context.i0000644000175000017500000012407212516137326022703 0ustar varunvarun//--------------------------------------------------------------------------- // // Wrapper for graphics_context_base->GraphicsContextArray // A derived class called GraphicsContextArray is in the %pythoncode and // overrides a large number of functions to handle type conversions in // python instead of having to write them in C/C++. // // Todo: // *. Fix dash_type constructor overload for accepting a pattern // !! Should we reverse the order of _pattern and phase and // !! default the phase to be 0?? (I think so...) // *. use properties to replace set/get methods. //--------------------------------------------------------------------------- // typemaps for many enumerated types used in graphics_contexts %include "constants.i" // Language independent exception handler %include exception.i // handle kiva::rect declarations %include "rect.i" //%apply kiva::rect_type {kiva::rect_type}; %include "agg_typemaps.i" %apply (double* point_array, int point_count) {(double* pts, int Npts)}; %apply (double* point_array, int point_count) {(double* start, int Nstart)}; %apply (double* point_array, int point_count) {(double* end, int Nend)}; %apply (double* rect_array, int rect_count) {(double* rects, int Nrects)}; %apply (double* pt_x, double* pt_y) {(double* tx, double* ty)}; %apply (double* array6) {(double* out)}; %apply (double* dash_pattern, int n) { (double* pattern, int n)}; %apply (unsigned char *image_data, int width, int height, int stride) { (unsigned char *data, int width, int height, int stride) }; %apply (owned_pointer) { kiva::graphics_context* }; // map string input into standard string and back %include "agg_std_string.i" // typemaps for double ary[] %include "sequence_to_array.i" %include "rgba_array.i" %apply rgba_as_array {agg24::rgba&}; %{ agg24::rgba _clear_color = agg24::rgba(1,1,1,1); %} %include "numeric_ext.i" %typemap(out) PyObject* { $result = $1; } %{ #include "kiva_graphics_context.h" #include "kiva_gradient.h" #ifdef ALWAYS_32BIT_WORKAROUND bool ALWAYS_32BIT_WORKAROUND_FLAG = true; #else bool ALWAYS_32BIT_WORKAROUND_FLAG = false; #endif // hack to get around SWIGs typechecking for overloaded constructors kiva::graphics_context_base* graphics_context_from_array( unsigned char *data, int width, int height, int stride, kiva::pix_format_e format, kiva::interpolation_e interpolation=kiva::nearest, int bottom_up = 1) { if (bottom_up) { stride *= -1; } switch (format) { case kiva::pix_format_rgb24: { return (kiva::graphics_context_base*) new kiva::graphics_context_rgb24(data,width,height,stride,interpolation); } case kiva::pix_format_bgr24: { return (kiva::graphics_context_base*) new kiva::graphics_context_bgr24(data,width,height,stride,interpolation); } case kiva::pix_format_rgba32: { return (kiva::graphics_context_base*) new kiva::graphics_context_rgba32(data,width,height,stride,interpolation); } case kiva::pix_format_bgra32: { return (kiva::graphics_context_base*) new kiva::graphics_context_bgra32(data,width,height,stride,interpolation); } case kiva::pix_format_argb32: { return (kiva::graphics_context_base*) new kiva::graphics_context_argb32(data,width,height,stride,interpolation); } case kiva::pix_format_abgr32: { return (kiva::graphics_context_base*) new kiva::graphics_context_abgr32(data,width,height,stride,interpolation); } case kiva::pix_format_gray8: { //return (kiva::graphics_context_base*) // new kiva::graphics_context_gray8(data,width,height,stride,interpolation); return (kiva::graphics_context_base*) NULL; } case kiva::pix_format_rgb555: case kiva::pix_format_rgb565: case kiva::end_of_pix_formats: default: { // format not valid. return (kiva::graphics_context_base*) NULL; } } } int destroy_graphics_context(kiva::graphics_context_base* gc) { switch (gc->format()) { case kiva::pix_format_rgb24: { delete (kiva::graphics_context_rgb24*) gc; break; } case kiva::pix_format_bgr24: { delete (kiva::graphics_context_bgr24*) gc; break; } case kiva::pix_format_rgba32: { delete (kiva::graphics_context_rgba32*) gc; break; } case kiva::pix_format_argb32: { delete (kiva::graphics_context_argb32*) gc; break; } case kiva::pix_format_abgr32: { delete (kiva::graphics_context_abgr32*) gc; break; } case kiva::pix_format_bgra32: { delete (kiva::graphics_context_bgra32*) gc; break; } case kiva::pix_format_gray8: { // we don't handle this format at the moment. return 1; //delete (kiva::graphics_context_gray8*) gc; //break; } case kiva::pix_format_rgb555: case kiva::pix_format_rgb565: case kiva::end_of_pix_formats: default: { // format not valid. return 1; } } return 0; } void graphics_context_multiply_alpha(double alpha, unsigned char *data, int width, int height, int stride) { for (int i=3;i stops, const char* spread_method, const char* units="userSpaceOnUse"); void radial_gradient(double cx, double cy, double r, double fx, double fy, std::vector stops, const char* spread_method, const char* units="userSpaceOnUse"); }; } %pythoncode %{ # constructors for GraphicsContextArray and Image # !! Temporary until we get the __init__ code in swig fixed. def init(self, ary_or_size, pix_format="bgra32", interpolation="nearest",bottom_up = 1): """ When specifying size, it must be a two element tuple. Array input is always treated as an image. This class handles the polymorphism of the underlying template classes for individual pixel formats. """ pix_format_id = pix_format_string_map[pix_format] img_depth = pix_format_bytes[pix_format] interpolation_id = interp_string_map[interpolation] if type(ary_or_size) is tuple: width,height = ary_or_size ary = zeros((height,width,img_depth),uint8) ary[:] = 255 else: ary = ary_or_size sh = shape(ary) if len(sh) == 2: if img_depth != 1: msg = "2D arrays must use a format that is one byte per pixel" raise ValueError(msg) elif len(sh) == 3: if img_depth != sh[2]: msg = "Image depth and format are incompatible" raise ValueError(msg) else: msg = "only 2 or 3 dimensional arrays are supported as images" msg += " but got sh=%r" % (sh,) raise TypeError, msg msg = "Only UnsignedInt8 arrays are supported but got " assert ary.dtype == dtype('uint8'), msg + repr(ary.dtype) if cvar.ALWAYS_32BIT_WORKAROUND_FLAG: if ary.shape[-1] == 3: if pix_format not in ('rgb24', 'bgr24'): import warnings warnings.warn('need to workaround AGG bug since ' 'ALWAYS_32BIT_WORKAROUND is on, but got unhandled ' 'format %r' % pix_format) else: pix_format = '%sa32' % pix_format[:3] ary = numpy.dstack([ary, numpy.empty(ary.shape[:2], dtype=uint8)]) ary[:,:,-1].fill(255) pix_format_id = pix_format_string_map[pix_format] img_depth = pix_format_bytes[pix_format] obj = graphics_context_from_array(ary,pix_format_id,interpolation_id, bottom_up) _swig_setattr(self, GraphicsContextArray, 'this', obj) # swig 1.3.28 does not have real thisown, thisown is mapped # to this.own() but with previous 'self.this=obj' an # attribute 'own' error is raised. Does this workaround # work with pre-1.3.28 swig? _swig_setattr(self, GraphicsContextArray, 'thisown2', 1) self.bmp_array = ary GraphicsContextArray.__init__ = init pil_format_map = {} pil_format_map["RGB"] = "rgb24" pil_format_map["RGBA"] = "rgba32" pil_depth_map = {} pil_depth_map["RGB"] = 3 pil_depth_map["RGBA"] = 4 class Image(GraphicsContextArray): """ Image is a GraphicsContextArray sub-class created from an image file. """ def __init__(self, file, interpolation="nearest", bottom_up=1): """ Create an Image object (GraphicsContextArray) from a file. Parameters ---------- file can be either a file name or an open file object interpolation specifies the type of filter used when putting the image into another GraphicsContextArray """ # read the file using PIL import Image as PilImage pil_img = PilImage.open(file) # Convert image to a numeric array if (pil_img.mode not in ["RGB","RGBA"] or (cvar.ALWAYS_32BIT_WORKAROUND_FLAG and pil_img.mode != "RGBA")): pil_img = pil_img.convert(mode="RGBA") depth = pil_depth_map[pil_img.mode] img = fromstring(pil_img.tostring(),uint8) img = resize(img, (pil_img.size[1],pil_img.size[0],depth)) format = pil_format_map[pil_img.mode] GraphicsContextArray.__init__(self, img, pix_format=format, interpolation=interpolation, bottom_up = bottom_up) def convert_pixel_format(self,pix_format,inplace=0): "Convert gc from one pixel format to another." # We override the one in the base GraphicsContextArray because that # one calls our __init__, which is not really the behavior we want. # # This problem can be avoided altogether down the road when the # Image subclass is turned into a factory function. new_img = GraphicsContextArray((self.width(),self.height()), pix_format=pix_format, interpolation=self.get_image_interpolation(), bottom_up = self.bottom_up()) new_img.draw_image(self) if inplace: old_this = self.this self.this = new_img.this new_img.this = old_this self.bmp_array = new_img.bmp_array return self else: return new_img %} %{ #include "gl_graphics_context.h" %} namespace kiva { %rename(GraphicsContextGL) gl_graphics_context; class gl_graphics_context : public graphics_context_base { public: gl_graphics_context(int width, int height, kiva::pix_format_e format=kiva::pix_format_rgb24); ~gl_graphics_context(); //--------------------------------------------------------------- // GL-specific methods //--------------------------------------------------------------- void gl_init(); void gl_cleanup(); void begin_page(); void gl_render_path(kiva::compiled_path *path, bool polygon=false, bool fill=false); void gl_render_points(double** points, bool polygon, bool fill, kiva::draw_mode_e mode = FILL); //--------------------------------------------------------------- // GraphicsContextBase interface //--------------------------------------------------------------- kiva::pix_format_e format(); void save_state(); void restore_state(); //--------------------------------------------------------------- // Clipping path manipulation //--------------------------------------------------------------- void clip(); void even_odd_clip(); void clip_to_rect(double x, double y, double sx, double sy); void clip_to_rect(kiva::rect_type &rect); void clip_to_rects(double* new_rects, int Nrects); void clip_to_rects(kiva::rect_list_type &rects); kiva::rect_type transform_clip_rectangle(const kiva::rect_type &rect); void clear_clip_path(); int get_num_clip_regions(); kiva::rect_type get_clip_region(unsigned int i); //--------------------------------------------------------------- // Painting paths (drawing and filling contours) //--------------------------------------------------------------- // Declare clear() to pass by reference so that the typemap applies, // even though it is pass by value in the actual C++ class void clear(agg24::rgba& value=_clear_color); void fill_path(); void eof_fill_path(); void stroke_path(); // empty function; for some reason this is abstract in the base class inline void _stroke_path() { } void draw_path(draw_mode_e mode=FILL_STROKE); void draw_rect(double rect[4], draw_mode_e mode=FILL_STROKE); %feature("shadow") draw_marker_at_points(double* pts,int Npts, int size, agg24::marker_e type = agg24::marker_square) %{ def draw_marker_at_points(self,pts,size,kiva_marker_type): marker = kiva_marker_to_agg.get(kiva_marker_type, None) if marker is None: success = 0 else: args = (self,pts,int(size),marker) success = _agg.GraphicsContextGL_draw_marker_at_points(self, pts, int(size), marker) return success %} int draw_marker_at_points(double* pts,int Npts,int size, agg24::marker_e type=agg24::marker_square); void draw_path_at_points(double* pts,int Npts, kiva::compiled_path& marker, draw_mode_e mode); bool show_text(char *text); void draw_glyphs(kiva::graphics_context_base* img, double tx, double ty); int draw_image(kiva::graphics_context_base* img, double rect[4], bool force_copy=false); int draw_image(kiva::graphics_context_base* img); }; } enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_hit_test.cpp0000644000175000017500000001043712516137326022525 0ustar varunvarun#include "kiva_hit_test.h" namespace kiva { // Adapted from: http://www.alienryderflex.com/polygon/ // // The function will return TRUE if the point x,y is inside the // polygon, or FALSE if it is not. If the point x,y is exactly on // the edge of the polygon, then the function may return TRUE or // FALSE. // // Note that division by zero is avoided because the division is // protected by the "if" clause which surrounds it. // // Note: If the test point is on the border of the polygon, this // algorithm will deliver unpredictable results; i.e. the result // may be "inside" or "outside" depending on arbitrary factors // such as how the polygon is oriented with respect to the // coordinate system. inline bool toggle_odd_node(double x, double y, double p1x, double p1y, double p2x, double p2y) { bool toggle = false; if( ((p1y=y)) || ((p2y=y)) ) { if (p1x + (y-p1y)/(p2y-p1y) * (p2x-p1x) < x) { toggle = true; } } return toggle; } bool point_in_polygon(double x, double y, double* poly_pts, int Npoly_pts) { bool odd_nodes=false; double p1_x, p1_y, p2_x, p2_y; for (int i=0; i y) { if ( is_left( x, y, x1, y1, x2, y2 ) > 0 ) { return 1; } } } else { if (y2 <= y) { if ( is_left( x, y, x1, y1, x2, y2 ) < 0 ) { return -1; } } } return 0; } bool point_in_polygon_winding(double x, double y, double* poly_pts, int Npoly_pts) { int winding_number = 0; double p1_x, p1_y, p2_x, p2_y; for (int i=0; i // ripped from Agg bool write_ppm(const unsigned char* buf, unsigned width, unsigned height, const char* file_name) { FILE* fd = fopen(file_name, "wb"); if(fd) { fprintf(fd, "P6 %d %d 255 ", width, height); fwrite(buf, 1, width * height * 3, fd); fclose(fd); return true; } return false; } agg24::rgba black(0.0, 0.0, 0.0); agg24::rgba white(1.0, 1.0, 1.0); agg24::rgba lightgray(0.2, 0.2, 0.2); agg24::rgba red(1.0, 0.0, 0.0); agg24::rgba green(0.0, 1.0, 0.0); agg24::rgba blue(0.0, 0.0, 1.0); agg24::rgba niceblue(0.411, 0.584, 0.843); typedef agg24::pixfmt_rgb24 AGG_PIX_TYPE; typedef kiva::graphics_context GC_TYPE; typedef std::vector rect_list_type; void draw_sub_image(GC_TYPE &gc_img, unsigned int width, unsigned int height) { gc_img.clear(white); gc_img.set_alpha(0.4); gc_img.set_fill_color(green); gc_img.rect(0, 0, width, height); gc_img.fill_path(); gc_img.set_alpha(1.0); gc_img.set_stroke_color(red); gc_img.move_to(0.0,0.0); gc_img.line_to(width,height); gc_img.stroke_path(); gc_img.set_stroke_color(blue); gc_img.move_to(0.0, height); gc_img.line_to(width, 0.0); gc_img.stroke_path(); //show_clip_rects(gc_img); } void test_arc_to2(GC_TYPE &gc, double x2, double y2, double radiusstep=25.0) { gc.set_stroke_color(lightgray); //gc.move_to(100, 0); //gc.line_to(0, 0); gc.move_to(0, 0); gc.line_to(100, 0); gc.line_to(x2, y2); gc.stroke_path(); gc.set_stroke_color(black); int numradii = 7; for (int i=0; ix << " " << it->y << " " << it->w << " " << it->h << std::endl; // } //gc.clip_to_rects(mclip_rects); //kiva::test_disjoint_union(); //draw_sub_image(gc, 200, 200); double color_delta = 0.0; for (kiva::rect_iterator it=actual_rects.begin(); it != actual_rects.end(); it++) { agg24::rgba tmpcolor(0.0, 0.4+color_delta, 0.0); gc.set_fill_color(tmpcolor); gc.rect(*it); gc.fill_path(); color_delta += 0.5/actual_rects.size(); } gc.set_alpha(1.0); gc.set_stroke_color(black); gc.set_line_width(1); //gc.clear_clip_path(); gc.rects(mclip_rects); gc.rect(0, 0, 200, 200); gc.stroke_path(); gc.restore_state(); } void test_disjoint_intersect(GC_TYPE &gc) { kiva::rect_list_type output_rects; kiva::rect_list_type input_rects; //kiva::rect_type rect1(atof(argv[0]),atof(argv[1]),atof(argv[2]),atof(argv[3])); //kiva::rect_type rect2(atof(argv[4]),atof(argv[5]),atof(argv[6]),atof(argv[7])); input_rects.push_back(kiva::rect_type(20.5,20.5,60,50)); //input_rects.push_back(kiva::rect_type(40.5,40.5,60,10)); input_rects.push_back(kiva::rect_type(60.5,80.5,35,60)); // input_rects.push_back(kiva::rect_type(40.5,60.5,60,60)); kiva::rect_type new_rect(40.5,60.5,60,60); output_rects = kiva::disjoint_intersect(input_rects, new_rect); gc.save_state(); gc.set_alpha(1.0); gc.set_stroke_color(blue); gc.rects(input_rects); gc.rect(new_rect); gc.stroke_path(); gc.set_alpha(0.4); gc.set_fill_color(red); gc.rects(output_rects); gc.fill_path(); gc.restore_state(); } void test_compiled_path(GC_TYPE &gc) { // Compiled path test kiva::compiled_path mypath; mypath.begin_path(); mypath.move_to(0.0, 0.0); mypath.line_to(20.0, 0.0); mypath.line_to(20.0,20.0); mypath.line_to(0.0, 20.0); mypath.line_to(0.0, 10.0); mypath.close_path(); agg24::rgba tmpcolor(0.0, 0.0, 1.0); gc.set_stroke_color(tmpcolor); gc.add_path(mypath); gc.stroke_path(); double points[] = {25, 25, 75, 25, 25, 75, 75, 75, 50, 50}; gc.draw_path_at_points(points, 5, mypath, kiva::STROKE); } void test_handling_text(GC_TYPE &gc) { char unicodeString[] = {230, 234, 223, 220, 0}; // Text handling test. Make sure timesi.ttf is in the current directory! kiva::font_type timesFont("times", 12, "regular"); kiva::font_type copperFont("coprgtl", 12, "regular"); kiva::font_type curlzFont("arial", 12, "regular"); //kiva::font_type unicodeFont("uni_font", 12, "regular"); gc.set_alpha(1.0); gc.set_text_drawing_mode(kiva::TEXT_FILL); gc.set_font(timesFont); //gc.set_font(unicodeFont); gc.translate_ctm(100.0, 100.0); gc.move_to(-5,0); gc.line_to(5,0); gc.move_to(0,5); gc.line_to(0,-5); gc.move_to(0,0); gc.stroke_path(); //agg24::trans_affine_translation txtTrans(200.0,150.0); agg24::trans_affine_rotation txtRot(agg24::deg2rad(30)); //txtTrans.premultiply(txtRot); //txtTrans *= txtRot; gc.set_text_matrix(txtRot); //gc.set_text_position(150.5, 350.5); //kiva::rect_type bbox(gc.get_text_extent("Hello")); //gc.get_text_matrix().transform(&bbox.x, &bbox.y); gc.show_text("Hello"); gc.show_text("foobar"); gc.show_text(unicodeString); //txtRot.invert(); //gc.set_text_matrix(txtRot); //gc.show_text("inverted"); // gc.rect(bbox); // gc.stroke_path(); /* gc.set_font(copperFont); gc.set_text_position(150.5, 250.5); kiva::rect_type bbox2(gc.get_text_extent("Hello")); gc.get_text_matrix().transform(&bbox2.x, &bbox2.y); gc.show_text("Hello"); // gc.rect(bbox2); // gc.stroke_path(); gc.set_font(curlzFont); gc.set_text_position(150.5, 150.5); kiva::rect_type bbox3(gc.get_text_extent("Hello")); gc.get_text_matrix().transform(&bbox3.x, &bbox3.y); gc.show_text("Hello"); // gc.rect(bbox3); // gc.stroke_path(); */ //gc.set_stroke_color(red); //gc.show_text("blah"); //gc.set_text_position(200.0, 100.0); //gc.show_text("Hello"); //gc.show_text_translate("Hello", 10.0, 360.0); //gc.set_font_size(36); //gc.show_text_translate("Hello", 10.0, 190.0); } void gc_stress_test() { int width = 100; int height = 100; int pixelsize = 3; unsigned char *buf = new unsigned char[width * height * pixelsize]; bool tmp = true; for (int i=0; i<100000; i++) { if (i%1000 == 0) { printf("%d\n", i); } GC_TYPE gc(buf, width, height, -width*pixelsize); kiva::font_type f("arial"); gc.set_font(f); // tmp = gc.show_text("hello"); if (f.filename == "") { int q = 5; } } delete[] buf; } void brandon_draw_test(GC_TYPE &gc) { gc.set_stroke_color(red); gc.set_line_width(1.0); gc.begin_path(); gc.move_to(30.0, 10.0); gc.line_to(20.0, 10.0); gc.line_to(20.0, 90.0); gc.line_to(10.0, 10.0); gc.close_path(); gc.stroke_path(); } int main(int argc, char **argv) { unsigned int width = 640; unsigned int height = 480; unsigned char pixelsize = 0; AGG_PIX_TYPE *msvc6_dummy = NULL; switch (kiva::agg_pix_to_kiva(msvc6_dummy)) { case (kiva::pix_format_gray8) : pixelsize = 1; break; case (kiva::pix_format_rgb24) : case (kiva::pix_format_bgr24) : pixelsize = 3; break; case (kiva::pix_format_bgra32): case (kiva::pix_format_rgba32): case (kiva::pix_format_argb32): case (kiva::pix_format_abgr32): pixelsize = 4; break; } unsigned char *buf = new unsigned char[width * height * pixelsize]; GC_TYPE gc((unsigned char*)buf, width, height, -width * pixelsize); gc.clear(); //brandon_draw_test(gc); //gc_stress_test(); //test_handling_text(gc); test_clip_stack(gc); //test_arc_curve(gc); //test_arc_to(gc); //test_clip_stack(gc); if (!write_ppm(buf, width, height, "dummy.ppm")) { printf("\nError writing file.\n"); } delete[] buf; return 0; } /* void hit_test_example() { double x_max = 20.0; // 100000.0; double y_max = 20.0; //100000.0; kiva::compiled_path mypath; mypath.begin_path(); mypath.move_to(0.0, 0.0); mypath.line_to(x_max, 0.0); mypath.line_to(x_max,y_max); mypath.line_to(0.0, y_max); mypath.close_path(); agg24::trans_affine ctm; int x_list[] = {-1, 0, 10, 19, 19, 20, 20, 21}; int y_list[] = {-1, 0, 10, 19, 20, 19, 20, 21}; for (int i=0; i < 8; i++) { int res; int x = x_list[i]; int y = y_list[i]; res = kiva::hit_test(x, y, mypath, ctm, agg24::fill_non_zero); if (res) printf("%d: %d, %d is in (0,0)->(20,20) square\n", res, x, y); else printf("%d: %d, %d is not in (0,0)->(20,20) square\n", res, x, y); } } */ enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_gradient.cpp0000644000175000017500000000146012516137326022473 0ustar varunvarun#include "kiva_gradient.h" using namespace kiva; gradient::gradient(gradient_type_e gradient_type) : gradient_type(gradient_type), spread_method(pad) { } gradient::gradient(gradient_type_e gradient_type, std::vector points, std::vector stops, const char* spread_method, const char* units) : points(points), stops(stops), gradient_type(gradient_type), spread_method(pad) { if (strcmp(spread_method, "reflect") == 0) this->spread_method = kiva::reflect; else if (strcmp(spread_method, "repeat") == 0) this->spread_method = kiva::repeat; if (strcmp(units, "userSpaceOnUse") == 0) this->units = kiva::user_space; else this->units = kiva::object_bounding_box; } gradient::~gradient() { } enthought-chaco2-4.5.1.orig/kiva/agg/src/compiled_path.i0000644000175000017500000001110412516137326022136 0ustar varunvarun%{ #include "kiva_compiled_path.h" %} // handle kiva::rect declarations %include "rect.i" %include "agg_typemaps.i" %apply (double* point_array, int point_count) {(double* pts, int Npts)}; %apply (double* point_array, int point_count) {(double* start, int Nstart)}; %apply (double* point_array, int point_count) {(double* end, int Nend)}; %apply (double* rect_array, int rect_count) {(double* all_rects, int Nrects)}; %apply (double *vertex_x, double* vertex_y) {(double* x, double *y)}; namespace kiva { %rename(CompiledPath) compiled_path; class compiled_path { public: compiled_path(); void remove_all(); void begin_path(); void close_path(); void move_to(double x, double y); void line_to(double x, double y); void quad_curve_to(double x_ctrl, double y_ctrl, double x_to, double y_to); void curve_to(double x_ctrl1, double y_ctrl1, double x_ctrl2, double y_ctrl2, double x_to, double y_to); void arc(double x, double y, double radius, double start_angle, double end_angle, bool cw=false); void arc_to(double x1, double y1, double x2, double y2, double radius); void add_path(compiled_path& vs); void lines(double* pts, int Npts); void line_set(double* start, int Nstart, double* end, int Nend); void rect(kiva::rect_type &rect); void rect(double x, double y, double sx, double sy); void rects(double* all_rects, int Nrects); void translate_ctm(double x, double y); void rotate_ctm(double angle); void scale_ctm(double sx, double sy); %rename(concat_ctm_agg) concat_ctm(agg24::trans_affine&); void concat_ctm(agg24::trans_affine& m); %rename(set_ctm_agg) set_ctm(agg24::trans_affine&); void set_ctm(agg24::trans_affine& m); %pythoncode %{ def kivaaffine_to_aggaffine(self, ctm): return AffineMatrix(ctm[0,0], ctm[0,1], ctm[1,0], ctm[1,1], ctm[2,0], ctm[2,1]) def concat_ctm(self, ctm): # This is really tortured and may cause performance problems. # Unfortunately I don't see a much better way right now. if '__class__' in dir(ctm) and ctm.__class__.__name__.count('AffineMatrix'): self.concat_ctm_agg(ctm) else: self.concat_ctm_agg(self.kivaaffine_to_aggaffine(ctm)) def set_ctm(self, ctm): if '__class__' in dir(ctm) and ctm.__class__.__name__.count('AffineMatrix'): self.set_ctm_agg(ctm) else: self.set_ctm_agg(self.kivaaffine_to_aggaffine(ctm)) %} agg24::trans_affine get_ctm(); void save_ctm(); void restore_ctm(); // methods from agg24::path_storage that are used in testing unsigned total_vertices() const; %rename(_rewind) rewind(unsigned); void rewind(unsigned start=0); %rename (_vertex) vertex(unsigned, double*, double*); unsigned vertex(unsigned idx, double* x, double* y) const; %rename (_vertex) vertex(double*, double*); unsigned vertex(double* x, double* y); }; } %pythoncode { from numpy import array, float64 def _vertices(self): """ This is only used for testing. It allows us to retrieve all the vertices in the path at once. The vertices are returned as an Nx4 array of the following format. x0, y0, cmd0, flag0 x1, y1, cmd0, flag1 ... """ vertices = [] self._rewind() cmd_flag = 1 while cmd_flag != 0: pt, cmd_flag = self._vertex() cmd,flag = _agg.path_cmd(cmd_flag),_agg.path_flags(cmd_flag) vertices.append((pt[0],pt[1], cmd, flag)) return array(vertices) CompiledPath._vertices = _vertices def get_kiva_ctm(self): aff = self.get_ctm() return array([[aff[0], aff[1], 0], [aff[2], aff[3], 0], [aff[4], aff[5], 1]], float64) CompiledPath.get_kiva_ctm = get_kiva_ctm } %clear (double *x, double *y); enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_graphics_context_base.cpp0000755000175000017500000004123612516137326025244 0ustar varunvarun #ifdef _WIN32 // Win32 threads #include static CRITICAL_SECTION gCriticalSection; #else // POSIX threads #endif #include #include "agg_path_storage.h" #include "kiva_exceptions.h" #include "kiva_graphics_context_base.h" using namespace kiva; #ifdef KIVA_USE_FREETYPE static font_engine_type gFontEngine; #endif #ifdef KIVA_USE_WIN32 static font_engine_type gFontEngine(hdc); #endif static font_manager_type gFontManager(gFontEngine); font_engine_type* kiva::GlobalFontEngine() { return &gFontEngine; } font_manager_type* kiva::GlobalFontManager() { return &gFontManager; } void kiva::cleanup_font_threading_primitives() { #ifdef _WIN32 DeleteCriticalSection(&gCriticalSection); #else #endif } // Create a static pool of font engines that get recycled. //static FontEngineCache font_engine_cache = FontEngineCache(); graphics_context_base::graphics_context_base(unsigned char *data, int width, int height, int stride, interpolation_e interp): buf(), _image_interpolation(interp) { this->buf.attach(data, width, height, stride); } graphics_context_base::~graphics_context_base() { } int graphics_context_base::width() { return this->buf.width(); } int graphics_context_base::height() { return this->buf.height(); } int graphics_context_base::stride() { return this->buf.stride(); } int graphics_context_base::bottom_up() { return (this->stride() > 0 ? 0 : 1); } agg24::rendering_buffer* graphics_context_base::rendering_buffer_ptr() { return &(this->buf); } kiva::interpolation_e graphics_context_base::get_image_interpolation() { return this->_image_interpolation; } void graphics_context_base::set_image_interpolation(kiva::interpolation_e interpolation) { this->_image_interpolation = interpolation; } //--------------------------------------------------------------- // set graphics_state values //--------------------------------------------------------------- void graphics_context_base::set_stroke_color(agg24::rgba& value) { this->state.line_color = value; } agg24::rgba& graphics_context_base::get_stroke_color() { return this->state.line_color; } void graphics_context_base::set_line_width(double value) { this->state.line_width = value; } void graphics_context_base::set_line_join(kiva::line_join_e value) { this->state.line_join = value; } void graphics_context_base::set_line_cap(kiva::line_cap_e value) { this->state.line_cap = value; } void graphics_context_base::set_line_dash(double* pattern, int n, double phase) { this->state.line_dash = kiva::dash_type(phase, pattern, n); } void graphics_context_base::set_blend_mode(kiva::blend_mode_e value) { this->state.blend_mode = value; } kiva::blend_mode_e graphics_context_base::get_blend_mode() { return this->state.blend_mode; } void graphics_context_base::set_fill_color(agg24::rgba& value) { this->state.fill_color = value; } agg24::rgba& graphics_context_base::get_fill_color() { return this->state.fill_color; } void graphics_context_base::set_alpha(double value) { // alpha should be between 0 and 1, so clamp: if (value < 0.0) { value = 0.0; } else if (value > 1.0) { value = 1.0; } this->state.alpha = value; } double graphics_context_base::get_alpha() { return this->state.alpha; } void graphics_context_base::set_antialias(int value) { this->state.should_antialias = value; } int graphics_context_base::get_antialias() { return this->state.should_antialias; } void graphics_context_base::set_miter_limit(double value) { this->state.miter_limit = value; } void graphics_context_base::set_flatness(double value) { this->state.flatness = value; } //--------------------------------------------------------------- // text and font functions //--------------------------------------------------------------- void graphics_context_base::set_text_position(double tx, double ty) { double temp[6]; this->text_matrix.store_to(temp); temp[4] = tx; temp[5] = ty; this->text_matrix.load_from(temp); } void graphics_context_base::get_text_position(double* tx, double* ty) { double temp[6]; agg24::trans_affine result = this->get_text_matrix(); result.store_to(temp); *tx = temp[4]; *ty = temp[5]; } bool graphics_context_base::is_font_initialized() { // This method is left in here just for legacy reasons. Although // technically the font is *never* initialized now that all GCs // are sharing a single font_cache_manager, external users of the // class should be able to proceed as if the font were initialized. return true; } void graphics_context_base::set_text_matrix(agg24::trans_affine& value) { this->text_matrix = value; } agg24::trans_affine graphics_context_base::get_text_matrix() { return this->text_matrix; } void graphics_context_base::set_character_spacing(double value) { this->state.character_spacing = value; } double graphics_context_base::get_character_spacing() { return this->state.character_spacing; } void graphics_context_base::set_text_drawing_mode(kiva::text_draw_mode_e value) { this->state.text_drawing_mode = value; } //--------------------------------------------------------------- // save/restore graphics state //--------------------------------------------------------------- void graphics_context_base::save_state() { this->state_stack.push(this->state); this->path.save_ctm(); } //--------------------------------------------------------------- // coordinate transform matrix transforms //--------------------------------------------------------------- void graphics_context_base::translate_ctm(double x, double y) { this->path.translate_ctm(x, y); } void graphics_context_base::rotate_ctm(double angle) { this->path.rotate_ctm(angle); } void graphics_context_base::scale_ctm(double sx, double sy) { this->path.scale_ctm(sx, sy); } void graphics_context_base::concat_ctm(agg24::trans_affine& m) { this->path.concat_ctm(m); } void graphics_context_base::set_ctm(agg24::trans_affine& m) { this->path.set_ctm(m); } agg24::trans_affine graphics_context_base::get_ctm() { return this->path.get_ctm(); } void graphics_context_base::get_freetype_text_matrix(double* out) { agg24::trans_affine result = this->get_ctm(); result.multiply(this->get_text_matrix()); result.store_to(out); // freetype and agg transpose their matrix conventions double temp = out[1]; out[1] = out[2]; out[2] = temp; } //--------------------------------------------------------------- // Sending drawing data to a device //--------------------------------------------------------------- void graphics_context_base::flush() { // TODO-PZW: clarify this and other "not sure if anything is needed" functions // not sure if anything is needed. } void graphics_context_base::synchronize() { // not sure if anything is needed. } //--------------------------------------------------------------- // Page Definitions //--------------------------------------------------------------- void graphics_context_base::begin_page() { // not sure if anything is needed. } void graphics_context_base::end_page() { // not sure if anything is needed. } //--------------------------------------------------------------- // Path operations //--------------------------------------------------------------- void graphics_context_base::begin_path() { this->path.begin_path(); } void graphics_context_base::move_to(double x, double y) { this->path.move_to(x, y); } void graphics_context_base::line_to( double x, double y) { this->path.line_to(x, y); } void graphics_context_base::curve_to(double cpx1, double cpy1, double cpx2, double cpy2, double x, double y) { this->path.curve_to(cpx1, cpy1, cpx2, cpy2, x, y); } void graphics_context_base::quad_curve_to(double cpx, double cpy, double x, double y) { this->path.quad_curve_to(cpx, cpy, x, y); } void graphics_context_base::arc(double x, double y, double radius, double start_angle, double end_angle, bool cw) { this->path.arc(x, y, radius, start_angle, end_angle, cw); } void graphics_context_base::arc_to(double x1, double y1, double x2, double y2, double radius) { this->path.arc_to(x1, y1, x2, y2, radius); } void graphics_context_base::close_path() { this->path.close_polygon(); } void graphics_context_base::add_path(kiva::compiled_path& other_path) { this->path.add_path(other_path); } void graphics_context_base::lines(double* pts, int Npts) { this->path.lines(pts, Npts); } void graphics_context_base::line_set(double* start, int Nstart, double* end, int Nend) { this->path.line_set(start, Nstart, end, Nend); } void graphics_context_base::rect(double x, double y, double sx, double sy) { this->path.rect(x, y, sx, sy); } void graphics_context_base::rect(kiva::rect_type &rect) { this->path.rect(rect); } void graphics_context_base::rects(double* all_rects, int Nrects) { this->path.rects(all_rects,Nrects); } void graphics_context_base::rects(kiva::rect_list_type &rectlist) { this->path.rects(rectlist); } kiva::compiled_path graphics_context_base::_get_path() { return this->path; } kiva::rect_type graphics_context_base::_get_path_bounds() { double xmin = 0., ymin = 0., xmax = 0., ymax = 0.; double x = 0., y = 0.; for (unsigned i = 0; i < this->path.total_vertices(); ++i) { this->path.vertex(i, &x, &y); if (i == 0) { xmin = xmax = x; ymin = ymax = y; continue; } if (x < xmin) xmin = x; else if (xmax < x) xmax = x; if (y < ymin) ymin = y; else if (ymax < y) ymax = y; } return kiva::rect_type(xmin, ymin, xmax-xmin, ymax-ymin); } agg24::path_storage graphics_context_base::boundary_path(agg24::trans_affine& affine_mtx) { // Return the path that outlines the image in device space // This is used in _draw to specify the device area // that should be rendered. agg24::path_storage clip_path; double p0x = 0; double p0y = 0; double p1x = this->width(); double p1y = 0; double p2x = this->width(); double p2y = this->height(); double p3x = 0; double p3y = this->height(); affine_mtx.transform(&p0x, &p0y); affine_mtx.transform(&p1x, &p1y); affine_mtx.transform(&p2x, &p2y); affine_mtx.transform(&p3x, &p3y); clip_path.move_to(p0x, p0y); clip_path.line_to(p1x, p1y); clip_path.line_to(p2x, p2y); clip_path.line_to(p3x, p3y); clip_path.close_polygon(); return clip_path; } ///////////////////////////////////////////////////////////////////////////// // Text methods ///////////////////////////////////////////////////////////////////////////// bool graphics_context_base::set_font(kiva::font_type& font) { // See if the font is the same; if it is, then do nothing: if (font == this->state.font) { return true; } this->state.font = font; // short-circuit: if the font didn't even load properly, then this // call can't succeed. if (!this->state.font.is_loaded()) { return false; } else { return true; } } kiva::font_type& graphics_context_base::get_font() { return this->state.font; } bool graphics_context_base::set_font_size(int size) { // just make sure the font is loaded; don't check is_font_initialized if (!this->state.font.is_loaded()) { return false; } else { this->state.font.size = size; return true; } } bool graphics_context_base::show_text_at_point(char *text, double tx, double ty) { double oldx, oldy; this->get_text_position(&oldx, &oldy); this->set_text_position(tx, ty); bool retval = this->show_text(text); this->set_text_position(oldx, oldy); return retval; } kiva::rect_type graphics_context_base::get_text_extent(char *text) { const agg24::glyph_cache *glyph = NULL; #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) int required = MultiByteToWideChar(CP_UTF8, 0, text, -1, 0, 0); std::vector p_(required + 1); MultiByteToWideChar(CP_UTF8, 0, text, -1, &p_[0], required); wchar_t *p = &p_[0]; #else std::vector p_(1024); size_t length = mbstowcs(&p_[0], text, 1024); if (length > 1024) { p_.resize (length + 1); mbstowcs(&p_[0], text, length); } wchar_t *p = &p_[0]; #endif double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2= 0.0; static font_manager_type *font_manager = GlobalFontManager(); if (font_manager == NULL) return kiva::rect_type(0, 0, 0, 0); this->_grab_font_manager(); //typedef agg24::glyph_raster_bin GlyphGeneratorType; //GlyphGeneratorType glyphGen(this->font_manager.glyph(*p)->data); while (*p) { glyph = font_manager->glyph(*p); if (glyph == NULL) { p++; continue; } font_manager->add_kerning(&x2, &y2); x1 = kiva::min(x1, glyph->bounds.x1); x2 += glyph->advance_x; y1 = kiva::min(y1, glyph->bounds.y1); y2 = kiva::max(y2, glyph->bounds.y2); p++; } this->_release_font_manager(); return kiva::rect_type(x1, y1, x2-x1, y2 - y1); } bool graphics_context_base::get_text_bbox_as_rect(char *text) { return false; } int graphics_context_base::draw_image(kiva::graphics_context_base* img) { double tmp[] = {0, 0, img->width(), img->height()}; return this->draw_image(img, tmp); } void graphics_context_base::_grab_font_manager() { // Win32 threads #ifdef _WIN32 static bool critical_section_initialized = false; if (!critical_section_initialized) { // FIXME: We need to delete the CriticalSection object when the process // exits, but where should we put that code? InitializeCriticalSection(&gCriticalSection); critical_section_initialized = true; } EnterCriticalSection(&gCriticalSection); // POSIX threads #else #endif // _WIN32 font_engine_type *font_engine = GlobalFontEngine(); if (font_engine == NULL) return; font_type *font = &this->state.font; #ifdef KIVA_USE_FREETYPE if (font->filename != "") { font_engine->load_font(font->filename.c_str(), 0, agg24::glyph_ren_agg_gray8); } else { font_engine->load_font(font->name.c_str(), 0, agg24::glyph_ren_agg_gray8); } #endif #ifdef KIVA_USE_WIN32 font_engine->create_font(font->name, agg24::glyph_ren_native_gray8, font->size); #endif font_engine->hinting(1); font_engine->resolution(72); // The following is a more laborious but more "correct" way of determining // the correct font size to use under Win32. Unfortunately, it doesn't // work exactly right either; characters come out just a few pixels larger. // Thus, for the time being, we're going to punt and leave the hard-coded // adjustment factor. // // this->font_engine.height(12.0); // this->font_engine.width(12.0); // kiva::rect_type tmp(this->get_text_extent("X")); // this->font_engine.height(font.size*12.0/tmp.h); // this->font_engine.width(font.size*12.0/tmp.w); font_engine->height(font->size); font_engine->width(font->size); } void graphics_context_base::_release_font_manager() { // Win32 thread-safe implementations of GlobalFontEngine and GlobalFontManager #ifdef _WIN32 LeaveCriticalSection(&gCriticalSection); // POSIX thread-safe implementations of GlobalFontEngine and GlobalFontManager #else #endif // _WIN32 } //--------------------------------------------------------------------- // Gradient support //--------------------------------------------------------------------- void graphics_context_base::linear_gradient(double x1, double y1, double x2, double y2, std::vector stops, const char* spread_method, const char* units) { // not implemented throw kiva::not_implemented_error; } void graphics_context_base::radial_gradient(double cx, double cy, double r, double fx, double fy, std::vector stops, const char* spread_method, const char* units) { // not implemented throw kiva::not_implemented_error; } enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_font_type.cpp0000755000175000017500000000653612516137326022721 0ustar varunvarun#include "kiva_font_type.h" #include // In the python layer, the enthought.freetype library is used for font lookup. // Since we can't use that, we emulate the functionality here. #ifdef _WIN32 const char* font_dirs[] = { "c:/windows/fonts/", "./", "c:/winnt/fonts/", "c:/windows/system32/fonts/" }; #elif defined SUNOS const char* font_dirs[] = { "/usr/openwin/lib/X11/fonts" }; #elif defined DARWIN const char* font_dirs[] = { "/Library/Fonts/" }; #else const char* font_dirs[] = { "./", "/usr/lib/X11/fonts/", "/usr/share/fonts/truetype/", "/usr/share/fonts/msttcorefonts/", "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType/", "/usr/share/fonts/truetype/msttcorefonts/", }; #endif const char* freetype_suffixes[] = { ".ttf", ".pfa", ".pfb" }; // This really only for testing purposes. Font searching is superceded by the code borrowed from // matplotlib, however, since that is in python, we can't load a font from C++ for C++ tests. // Therefore this simple function is left in. kiva::font_type::font_type(std::string _name, int _size, int _family, int _style, int _encoding, bool validate): name(_name), size(_size), family(_family), style(_style), encoding(_encoding), _is_loaded(false) { std::string full_file_name; if (validate) { if (this->name == "") { this->_is_loaded = false; } else { for (unsigned int d=0; d < sizeof(font_dirs) / sizeof(char*); d++) { for (unsigned int e=0; e < sizeof(freetype_suffixes) / sizeof(char*); e++) { full_file_name = font_dirs[d]; full_file_name.append(this->name); full_file_name.append(freetype_suffixes[e]); FILE *f = fopen(full_file_name.c_str(), "rb"); if (f != NULL) { fclose(f); this->filename = full_file_name; this->_is_loaded = true; break; } } } } this->filename = ""; this->name = ""; this->_is_loaded = false; } else { this->filename = this->name; this->_is_loaded = true; } } kiva::font_type::font_type(const kiva::font_type &font) : name(font.name), filename(font.filename), size(font.size), _is_loaded(font.is_loaded()) { this->family = font.family; this->style = font.style; } kiva::font_type &kiva::font_type::operator=(const kiva::font_type& font) { this->size = font.size; this->family = font.family; this->style = font.style; this->encoding = font.encoding; this->name = font.name; this->filename = font.filename; this->_is_loaded = font.is_loaded(); return *this; } int kiva::font_type::change_filename(std::string _filename) { FILE *f = fopen(_filename.c_str(), "rb"); if (f != NULL) { fclose(f); this->filename = _filename; this->_is_loaded = true; return 1; } else return 0; } enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_alpha_gamma.h0000644000175000017500000000065612516137326022600 0ustar varunvarun#ifndef KIVA_ALPHA_GAMMA_H #define KIVA_ALPHA_GAMMA_H #include "agg_gamma_functions.h" namespace kiva { struct alpha_gamma { alpha_gamma(double alpha, double gamma) : m_alpha(alpha), m_gamma(gamma) {} double operator() (double x) const { return m_alpha(m_gamma(x)); } agg24::gamma_multiply m_alpha; agg24::gamma_power m_gamma; }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/rect.i0000644000175000017500000000166012516137326020271 0ustar varunvarun%{ #include "kiva_rect.h" %} %typemap(in) (kiva::rect_type &rect) { PyArrayObject* ary=NULL; int is_new_object; ary = obj_to_array_contiguous_allow_conversion($input, PyArray_DOUBLE, is_new_object); int size[1] = {4}; if (!ary || !require_dimensions(ary, 1) || !require_size(ary, size, 1)) { goto fail; } double* data = (double*)(ary->data); kiva::rect_type rect(data[0], data[1], data[2], data[3]); $1 = ▭ if (is_new_object) { Py_DECREF(ary); } } %typemap(out) kiva::rect_type { PyObject *pt = PyTuple_New(4); PyTuple_SetItem(pt,0,PyFloat_FromDouble($1.x)); PyTuple_SetItem(pt,1,PyFloat_FromDouble($1.y)); PyTuple_SetItem(pt,2,PyFloat_FromDouble($1.w)); PyTuple_SetItem(pt,3,PyFloat_FromDouble($1.h)); $result = pt; } enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_compiled_path.h0000644000175000017500000001133612516137326023156 0ustar varunvarun#ifndef COMPILED_PATH_H #define COMPILED_PATH_H #include #include #include "agg_basics.h" #include "agg_path_storage.h" #include "agg_trans_affine.h" #include "kiva_rect.h" namespace kiva { class compiled_path : public agg24::path_storage { /*------------------------------------------------------------------- This extends the standard agg24::path_storage class to include matrix transforms within the path definition. Doing so requires overriding a number of methods to apply the matrix transformation to vertices added to the path. The overridden methods are: move_to line_to add_path curve3 curve4 add_path There are a few others that need to be looked at also... In addition, we need to add several methods: translate_ctm rotate_ctm scale_ctm concat_ctm set_ctm get_ctm save_ctm restore_ctm -------------------------------------------------------------------*/ // hack to get VC++ 6.0 to compile correctly typedef agg24::path_storage base; /*------------------------------------------------------------------- ptm -- path transform matrix. This is used to transform each point added to the path. It begins as an identity matrix and accumulates every transform made during the path formation. At the end of the path creation, the ptm holds the total transformation seen during the path formation. It can thus be multiplied with the ctm to determine what the ctm should be after the compiled_path has been drawn. Todo: Should this default to the identity matrix or the current ctm? -------------------------------------------------------------------*/ agg24::trans_affine ptm; // ptm_stack is used for save/restore of the ptm std::stack ptm_stack; // If the path contains curves, this value is true; bool _has_curves; public: // constructor compiled_path() : base(), ptm(agg24::trans_affine()) {} //--------------------------------------------------------------- // path_storage interface //--------------------------------------------------------------- void remove_all(); void begin_path(); void close_path(); void move_to(double x, double y); void line_to(double x, double y); void quad_curve_to(double x_ctrl, double y_ctrl, double x_to, double y_to); void curve_to(double x_ctrl1, double y_ctrl1, double x_ctrl2, double y_ctrl2, double x_to, double y_to); // see graphics_context_base for descriptions of these functions void arc(double x, double y, double radius, double start_angle, double end_angle, bool cw=false); void arc_to(double x1, double y1, double x2, double y2, double radius); void add_path(compiled_path& other_path); void lines(double* pts, int Npts); void line_set(double* start, int Nstart, double* end, int Nend); void rect(double x, double y, double sx, double sy); void rect(kiva::rect_type &rect); void rects(double* all_rects, int Nrects); void rects(kiva::rect_list_type &rectlist); //--------------------------------------------------------------- // compiled_path interface //--------------------------------------------------------------- void _transform_ctm(agg24::trans_affine& m); void translate_ctm(double x, double y); void rotate_ctm(double angle); void scale_ctm(double sx, double sy); void concat_ctm(agg24::trans_affine& m); void set_ctm(agg24::trans_affine& m); agg24::trans_affine get_ctm(); //--------------------------------------------------------------- // save/restore ptm methods //--------------------------------------------------------------- void save_ctm(); void restore_ctm(); //--------------------------------------------------------------- // Test whether curves exist in path. //--------------------------------------------------------------- inline bool has_curves() { return this->_has_curves;} }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/rgba_array.i0000644000175000017500000000476512516137326021456 0ustar varunvarun// -------------------------------------------------------------------------- // // Convert agg24::rgba types to/from Numeric arrays. The rgba_as_array // typemap will accept any 3 or 4 element sequence of float compatible // objects and convert them into an agg24::rgba object. // // The typemap also converts any rgba output value back to a numeric array // in python. This is a more useful representation for numerical // manipulation. // // -------------------------------------------------------------------------- %{ #include "agg_color_rgba.h" %} %include "numeric.i" #ifdef SWIGPYTHON %typemap(in) rgba_as_array (int must_free=0) { must_free = 0; if ((SWIG_ConvertPtr($input,(void **) &$1, SWIGTYPE_p_agg24__rgba, SWIG_POINTER_EXCEPTION | 0 )) == -1) { PyErr_Clear(); if (!PySequence_Check($input)) { PyErr_SetString(PyExc_TypeError,"Expecting a sequence"); return NULL; } int seq_len = PyObject_Length($input); if (seq_len != 3 && seq_len != 4) { PyErr_SetString(PyExc_ValueError, "Expecting a sequence with 3 or 4 elements"); return NULL; } double temp[4] = {0.0,0.0,0.0,1.0}; for (int i =0; i < seq_len; i++) { PyObject *o = PySequence_GetItem($input,i); if (PyFloat_Check(o)) { temp[i] = PyFloat_AsDouble(o); } else { PyObject* converted = PyNumber_Float(o); if (!converted) { PyErr_SetString(PyExc_TypeError, "Expecting a sequence of floats"); return NULL; } temp[i] = PyFloat_AsDouble(converted); Py_DECREF(converted); } if ((temp[i] < 0.0) || (temp [i] > 1.0)) { PyErr_SetString(PyExc_ValueError, "Color values must be between 0.0 an 1.0"); return NULL; } } $1 = new agg24::rgba(temp[0],temp[1],temp[2],temp[3]); must_free = 1; } } %typemap(freearg) rgba_as_array { if (must_free$argnum) delete $1; } %typemap(out) rgba_as_array { npy_intp size = 4; $result = PyArray_SimpleNew(1, &size, PyArray_DOUBLE); double* data = (double*)((PyArrayObject*)$result)->data; data[0] = $1->r; data[1] = $1->g; data[2] = $1->b; data[3] = $1->a; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_constants.h0000644000175000017500000001165212516137326022363 0ustar varunvarun#ifndef KIVA_CONSTANTS_H #define KIVA_CONSTANTS_H namespace kiva { //----------------------------------------------------------------------- // Line Cap Constants //----------------------------------------------------------------------- enum line_cap_e { CAP_ROUND = 0, CAP_BUTT = 1, CAP_SQUARE = 2 }; //----------------------------------------------------------------------- // Line Join Constants //----------------------------------------------------------------------- enum line_join_e { JOIN_ROUND = 0, JOIN_BEVEL = 1, JOIN_MITER = 2 }; //----------------------------------------------------------------------- // Path Drawing Mode Constants // // Path drawing modes for path drawing methods. // The values are chosen so that bit flags can be checked in a later // C version. //----------------------------------------------------------------------- enum draw_mode_e { FILL = 1, EOF_FILL = 2, STROKE = 4, FILL_STROKE = 5, EOF_FILL_STROKE = 6 }; //----------------------------------------------------------------------- // Font Constants // // These are pretty much taken from wxPython. // !! Not sure if they are needed. //----------------------------------------------------------------------- enum text_style_e { NORMAL = 0, BOLD = 1, ITALIC = 2 }; //----------------------------------------------------------------------- // Text Drawing Mode Constants //----------------------------------------------------------------------- enum text_draw_mode_e { TEXT_FILL = 0, TEXT_STROKE = 1, TEXT_FILL_STROKE = 2, TEXT_INVISIBLE = 3, TEXT_FILL_CLIP = 4, TEXT_STROKE_CLIP = 5, TEXT_FILL_STROKE_CLIP = 6, TEXT_CLIP = 7 }; //----------------------------------------------------------------------- // The following enums are Agg-specific, and might not be applicable // to other backends. //----------------------------------------------------------------------- enum interpolation_e { nearest = 0, bilinear = 1, bicubic = 2, spline16 = 3, spline36 = 4, sinc64 = 5, sinc144 = 6, sinc256 = 7, blackman64 = 8, blackman100 = 9, blackman256 = 10 }; enum pix_format_e { pix_format_undefined = 0, // By default. No conversions are applied pix_format_gray8, // Simple 256 level grayscale pix_format_rgb555, // 15 bit rgb. Depends on the byte ordering! pix_format_rgb565, // 16 bit rgb. Depends on the byte ordering! pix_format_rgb24, // R-G-B, one byte per color component pix_format_bgr24, // B-G-R, native win32 BMP format. pix_format_rgba32, // R-G-B-A, one byte per color component pix_format_argb32, // A-R-G-B, native MAC format pix_format_abgr32, // A-B-G-R, one byte per color component pix_format_bgra32, // B-G-R-A, native win32 BMP format end_of_pix_formats }; enum blend_mode_e { blend_normal, // pdf nrmal blending mode. blend_copy, // overright destination with src ignoring any alpha setting. /* // these are copies from agg -- but not yet supported. blend_clear, //----clear blend_src, //----src blend_dst, //----dst blend_src_over, //----src_over blend_dst_over, //----dst_over blend_src_in, //----src_in blend_dst_in, //----dst_in blend_src_out, //----src_out blend_dst_out, //----dst_out blend_src_atop, //----src_atop blend_dst_atop, //----dst_atop blend_xor, //----xor blend_plus, //----plus blend_minus, //----minus blend_multiply, //----multiply blend_screen, //----screen blend_overlay, //----overlay blend_darken, //----darken blend_lighten, //----lighten blend_color_dodge, //----color_dodge blend_color_burn, //----color_burn blend_hard_light, //----hard_light blend_soft_light, //----soft_light blend_difference, //----difference blend_exclusion, //----exclusion blend_contrast, //----contrast */ end_of_e }; enum gradient_type_e { grad_none = 0, grad_linear, grad_radial }; enum gradient_spread_e { pad = 0, reflect, repeat }; enum gradient_units_e { user_space = 0, object_bounding_box }; } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva_affine_helpers.h0000644000175000017500000000074612516137326023323 0ustar varunvarun#ifndef KIVA_AFFINE_MATRIX_H #define KIVA_AFFINE_MATRIX_H #include "agg_trans_affine.h" namespace kiva { bool is_identity(agg24::trans_affine& mat, double epsilon=1e-3); bool only_translation(agg24::trans_affine& mat, double epsilon=1e-3); bool only_scale_and_translation(agg24::trans_affine& mat, double epsilon=1e-3); void get_translation(agg24::trans_affine& m, double* tx, double* ty); void get_scale(agg24::trans_affine& m, double* dx, double* dy); } #endif enthought-chaco2-4.5.1.orig/kiva/agg/src/todo.txt0000644000175000017500000003024312516137326020667 0ustar varunvarun Kiva Demo: *. Add tool for sticking these all in a single notebook example. DONE (wx_demo.py)* set up simple example *. fix flicker. DONE*. Lion example DONE *. add use/don't use image. *. VLSI circuit with multiple layers example *. Ask Chris for a file. *. Laplace's equation or FDTD example. *. Medical image registration. DONE*. Get an example running. *. Ask dad if he has access to better images? *. Work on scaling methodolgy so that it is centered around the image. *. Force image to keep the dimensions we want. *. moving objects around with tied points. *. How does Dave do hit testing for polygons? *. Satellite overlay example. *. Ask someone as NOAA for a good *. Andrew loop *. US ground image *. State border outlines. *. Slides *. add image example. *. DONE *. fix lion path so that it is centered at 0,0 DONE*. Clean up text positioning DONE*. get text to draw right-side up DONE*. Fix text positioning with respect to bottom_up DONE*. show_text should accept x,y position coordinates. DONE*. Handle image positioning correctly. *. get_current_position() isn't currently defined. *. update to newest agg. *. add load method. *. Fix ImageFromFile *. Work on fancy examples based on wxcore2d examples. DONE * fix convert_pix_format. DONE (although doesn't work for RGBA) * add save method. DONE * It looks to me like some memory is not being kept correctly on image conversions. We need to look into this... DONE (1) Move GraphicsContextBitmap to GraphicsContextArray DONE graphics_context_bitmap -> graphics_context DONE GraphicsContextBitmap -> GraphicsContextArray DONE GraphicsContextBitmap.bitmap -> GraphicsContextArray.bmp_array (2) Rework Image DONE *. derive Image from _GraphicsContextArray DONE *. add ImageFromFile method DONE *. outline_path -> boundary_path *. need to check that strides match on images when checking for conversion.? *. Unify pixel_map constants and agg constants DONE (3) Add GraphicsContextSystem method that builds a GraphicsContextArray using a PixelMap DONE *. Fix GraphicsContextArray to allow for a bottom_up parameter. (5) Move from factory to using a constructor for GraphicsContextArray (6) Add convert_pix_format(new_format) function to GraphicsContextArray cleaning up agg: DONE* is fast text used at all? DONE * If not, delete it. DONE * take it out of setup.py DONE* clean up enumeration typemaps. * can we get McSeem to move agg typemaps into a single file? DONE* track down memory leak in the library initializer in _ft. DONE* track down memory leak in the transform initializers. DONE* fix errors in test_image suite. * re-factor test functions like test_name() and save() DONE* change "interpolation_scheme" to "interpolation" DONE* change "simple" to "nearest" gotcha: *. Clicking on a bar in the far right column should move to the first point in the calling function where this routine is called. F3 should find the next call, etc. !! Gotcha says that a function call is happening in a particular !! enclosing function, but I am not able to find the call to the !! function in the source code for the enclosing function. It !! appears that it is missing at least one level of nesting here. *. Try getting rid of bar outlines and see if that helps make the text more readable. *. Make text at least one font size smaller and see if that also helps. Perhaps there should be a user preference setting for the font size. Changing this would also make the bars wider or thinner as appropriate. agg: *. add is_identity to affine_transform class *. add only_translation to affine_transform class *. Get all enum types to have an xxx_end value to make it easy to check for correct values in typemaps. *. Fix typemaps to use these values. priority: *. The y-axis on the middle graph is offset to the left of the actual graph. It should be on top of the graph edge just like the other graphs. *. distributions should remember there values when you switch between them. *. Make Oil Expelled the default graph shown in the middle graph -- not GOR. *. Text labels at the top-right of P10, P50 marker lines -- still inside the bounds of the graph with a small font. (figure out how to do this) *. fix clipping on upper and left of plot. The clip box appears to be 2-3 pixels to large currently. Or maybe it has to do with the lines being drawn to long.? Well, markers also overshoot the boundary, so I do think it is the clop box. *. track down why min_size is always called when rendering. It accounts for about 20% of the time. *. Are line widths scaling correctly. *. color choices reviewed. DONE*. fix line dash bug. (!Woohoo!) *. Check index test -- set joining type to miter causes problems. *. Fix the lookup table to be a lot faster -- search sorted is called way to many times, and it is the source of most of the overhead. *. Look into whether we can speed draw_path_at_points any faster. *. document the API. DONE*. speed up scatter plot rendering. *. Test clipping for images and text. *. write fast version of blit to window fo wxPython. *. Add get/set functions for all the set_*** and get_*** methods. *. sub-class image from gc. *. add save/load functions to image. *. search down memory leaks in freetype wrappers. These appear in the init_ft call which is strange to me. DONE*. Fix rendering of text images. DONE 1. Images without a gc_alpha value are rendered as colored squares. DONE 2. Fill color alpha is being ignored in image rendering. DONE*. Add test suite for image rendering *. Add test suite for text rendering DONE*. Start weeding out potential problems with dashed lines. DONE *. Walk through and stub calls in gc to see if that fixes it DONE *. Look at the path output for the dashed line and see what DONE its problem might be. !! The problems was in the SWIG wrapper. DONE*. See if bypassing the rgb_as_array typemap fixes our troubles DONE even with the rendering of dashed lines... *. rename this to rgb_from_array *. clean up array typemaps. DONE *. Mostly Done. They live in agg_typemaps.i now. DONE *. Alter image typemaps to allow non-contiguous arrays that are only non-contiguous in in the first dimension to handle window bitmaps correctly. DONE *. Do this in combinations with building method to wrap windows bitmaps with arrays. DONE*. find problem in render method return PyObject_NULL sometimes in freetype wrappers DONE*. chase down problem in color_from_array code... DONE This exhibits itself on the first run of test_image.main() DONE after a build of the library. DONE !! It isn't appearin any more after I've cleaned up the DONE !! typemaps above. I thought there was a problem with the DONE !! color typemaps though, so it may resurface... DONE*. set_text_position doesn't exist DONE*. set_text_matrix needs to work with whatever kind of matrix it is DONE handed. *. Look at how we handle the set_font issues in the standard agg *. Review and clean it all up. DONE*. handle pixel formats intelligently. User must specify the format now. It is never assumed accept for on a gc (bgra32). We will need to make this a platform specific value in the future. BUT... needs testing... DONE *. speed up text rendering I'm sure this can be sped up by moving more and more into agg, but this is "fast enough" for our purpose. It takes about 1.5 milleseconds to render a 10 character string in a "normal" font size. That is *way* to slow for a general drawing engine, but will work fine for drawing 20 or so labels, etc. on a graph. DONE *. Move image array creation code to weave. DONE *. Move to standard module so that it can be built without weave. *. allow images to be created from a file (use PIL) DONE *. add a convert() method to convert to a new image format. This will require some coordination between python and C++. Create the array in Python, and hand it into the array so that we can keep the bitmap array pointing to the correct data. DONE*. try intel compiler and see if it is any better. add these around line 240 of distutils msvccompiler.py file self.cc = "icl.exe" self.linker = "xilink.exe" self.compile_options = [ '/nologo', '/O3', '/QxW', '/Qipo', '/Fe_ipo_file', '/Qvec_reportN','/MD', '/W3' ] !!I was rewarded with a slight slow down compared to the microsoft compiler. !!That doesn't sound promising... DONE*. Fix clipping on image insertion. BUT... No attempt to reconcile this with the actual clipping path is made. 7. Add an Image class to kiva to pass into draw_image a. work on format conversions. DONE b. fix clipping boundaries c. handle scaling to rect. DONE d. fix text to use new algorithm. DONE e. templatize routines so that we can use faster null_alpha_color class when alpha = 1.0 DONE f. The only thing different about the image and graphics_context_bitmap is that the image has a interpolation_scheme and the gc does not. This could lead to a bit of confusion, but I don't think much. We should unify the two. DONE *. This brings up the point... Should we attach the interpolation flag to the image or to the gc?? PDF doesn't so the answer is probably no... DONE 11. Create an image with the correct strides for a windows bitmap. DONE*. check gc.set_alpha() transparency for rendering images. DONE *. Add a clear method to GraphicsContextBitmap agg::renderer_util ru(rbuf_img(0)); ru.clear(agg::rgba(1.0, 1.0, 1.0)); *. Clipping support DONE *. Test with chaco. DONE *. Make available to the world. other: DONE1. split dash_type and font_type into their own files. DONE3. add freetype stuff to GraphicsContextBitmap I added this stuff through the graphics_context.i file. It is getting a little hairy... DONE4. Fix FreeType engine to use "unic" if encoding is empty. DONE5. Test it out with a real image... -- see test_image.py !!!! 5a. Figure out why PIL isn't installed correctly. 2. set_line_dash should accept a dash_type object. ?? 9. Test as replacement for current gc wrappers. *. Make the text handling for kiva robust. DONE a. Get rotation working correctly. DONE b. Test all transformation modes. BUT... test_image.py requires visual inspection. c. Should font_type size be a double? d. We need better diagnostics to calculate bounding region of text. DONE 1. add bbox_as_rect() to freetype a. use this in all kiva implementations e. drawing is slow. All the time is in draw_glyphs. Figure out what is eating all the time in the agg C++ code. DONE*. Add type conversions from sequences to colors. BUT... Need more testing. *. Move from using get_xxx() to python's new property mechanism. 12. Add curve support for path rendering 13. Fix filling rules for thick lines (use presentation examples as guide) PART10. Make typemaps for image arrays in safe... I've elected to do most typechecking in Python because it is less error prone. I handle this by just overriding the affected class methods/functions in the %pythoncode section WAIT6. Figure out how to create a agg_a8_image that allows me to set the color and only use an alpha channel in the image. Should be fairly easy... !! Wait until McSeem is back and ask him about this. 8. Get the box scaling for images working correctly. 8a. Look at how this is done on the Mac. *. Should the graphics state store the current point? *. font_type should be shared between kiva and freetype... FUTURE VERSIONS: *. Look into shading??? *. Color spaces for grayscale images. Tests: enthought-chaco2-4.5.1.orig/kiva/agg/src/rgba.i0000644000175000017500000000406312516137326020247 0ustar varunvarun%{ #include "agg_color_rgba.h" %} %include "numeric.i" %typemap(in, numinputs=0) double* out (double temp[4]) { $1 = temp; } %typemap(argout) double *out { // Append output value $1 to $result npy_intp dims = 4; PyArrayObject* ary_obj = (PyArrayObject*) PyArray_SimpleNew(1,&dims,PyArray_DOUBLE); if( ary_obj == NULL ) return NULL; double* data = (double*)ary_obj->data; for (int i=0; i < 4;i++) data[i] = $1[i]; Py_DECREF($result); $result = PyArray_Return(ary_obj); } %typemap(check) (double r) { if ($1 < 0.0 || $1 > 1.0) { PyErr_Format(PyExc_ValueError, "color values must be between 0.0 and 1.0, Got: %g", $1); } } %apply (double r) {double g, double b, double a}; namespace agg24 { %rename(_Rgba) rgba; struct rgba { double r; double g; double b; double a; rgba(double r_=0.0, double g_=0.0, double b_=0.0, double a_=1.0); //void opacity(double a_); //double opacity() const; rgba gradient(rgba c, double k) const; const rgba &premultiply(); }; } %extend agg24::rgba { char *__repr__() { static char tmp[1024]; sprintf(tmp,"Rgba(%g,%g,%g,%g)", self->r,self->g,self->b,self->a); return tmp; } int __eq__(agg24::rgba& o) { return (self->r == o.r && self->g == o.g && self->b == o.b && self->a == o.a); } void asarray(double* out) { out[0] = self->r; out[1] = self->g; out[2] = self->b; out[3] = self->a; } } %pythoncode { def is_sequence(arg): try: len(arg) return 1 except: return 0 # Use sub-class to allow sequence as input class Rgba(_Rgba): def __init__(self,*args): if len(args) == 1 and is_sequence(args[0]): args = tuple(args[0]) if len(args) not in [3,4]: raise ValueError, "array argument must be 1x3 or 1x4" _Rgba.__init__(self,*args) } %clear double r, double g, double b, double a; enthought-chaco2-4.5.1.orig/kiva/agg/src/readme.txt0000644000175000017500000000524012516137326021156 0ustar varunvarunThis directory contains the C++ source files and SWIG wrappers for Kiva's Agg backend. Support files ------------------------------ readme.txt this file todo.txt Eric's old todo file SWIG wrappers (*.i) ------------------------------ affine_matrix.i agg_trans_affine.h classes agg_std_string.i typemaps for member access to font_type.name agg_typemaps.i typemaps for various agg classes (rect, color, etc.) compiled_path.i wrapper for kiva_compiled_path.h constants.i common enumerations and constants used by Agg and Kiva font_type.i wrapper for kiva_font_type.h graphic_context.i the main wrapper defining the Agg graphics context hit_test.i defines a point-in-polygon test; currently not used numeric.i typemaps and wrappers for Numeric array used in kiva numeric_ext.i same as numeric.i rect.i wrapper for kiva_rect.h rgba.i RGBA color class and utility functions rgba_array.i maps Numeric 3- and 4-tuples into RGBA color instances sequence_to_array.i maps Python tuples into double[] swig_questions.txt questions and problems we are currently having with our use of SWIG C/C++ files ------------------------------- agg_examples.cpp C++ source code for demonstrating use of various agg features kiva_affine_helpers.h/.cpp kiva_affine_matrix.h kiva_basics.h kiva_compiled_path.h/.cpp kiva_constants.h kiva_dash_type.h kiva_exceptions.h kiva_font_type.h kiva_graphics_context_base.h/.cpp non-templatized base class for graphics contexts (which are templatized on pixel format) kiva_graphics_context.h template graphics_context class and typedef specializations for various pixel formats. kiva_hit_test.h/.cpp kiva_image_filters.h A helper class that associates the right types of image filters for various pixel formats kiva_pix_format.h defines agg_pix_to_kiva() kiva_rect.h/.cpp Kiva rectangle class (with converters to/from double*, Agg rects, etc.) Visual Studio 6 files ------------------------------- kiva.dsp Project file for the agg wrapper kiva.dsw workspace file for kiva.dsp The following files are generated by Visual Studio during compilation kiva.ncd kiva.opt kiva.plg Directories ------------------------------- gtk1 support files for grabbing a graphics context in GTK win32 " " " " " " " " win32 x11 " " " " " " " " xwindows gl " " " " " " " " openGL enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva.vcproj0000644000175000017500000010346312516137326021345 0ustar varunvarun enthought-chaco2-4.5.1.orig/kiva/agg/src/kiva.dsw0000644000175000017500000000076612516137326020641 0ustar varunvarunMicrosoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "kiva"=.\kiva.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### enthought-chaco2-4.5.1.orig/kiva/basecore2d.py0000644000175000017500000013333212516137326020222 0ustar varunvarun# Copyright (c) 2005-2014, Enthought, Inc. # some parts copyright Space Telescope Science Institute # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! """ Pure-Python reference implementation of a Kiva graphics context. Data Structures --------------- color 1-D array with 4 elements. The array elements represent (red, green, blue, alpha) and are each between 0 and 1. Alpha is a transparency value with 0 being fully transparent and 1 being fully opaque. Many backends do not handle tranparency and treat any alpha value greater than 0 as fully opaque. transform currently a 3x3 array. This is not the most convenient in some backends. Mac and OpenGL use a 1-D 6 element array. We need to either make transform a class or always use accessor functions to access its values. Currently, I do the latter. """ from __future__ import absolute_import, print_function import numpy as np from numpy import alltrue, array, asarray, float64, shape, pi, concatenate from .constants import (POINT, LINE, LINES, RECT, NO_DASH, CLOSE, CAP_ROUND, CAP_BUTT, CAP_SQUARE, JOIN_ROUND, JOIN_BEVEL, JOIN_MITER, STROKE, FILL_STROKE, EOF_FILL_STROKE, FILL, EOF_FILL, TEXT_FILL, TEXT_STROKE, TEXT_FILL_STROKE, TEXT_INVISIBLE, TEXT_FILL_CLIP, TEXT_STROKE_CLIP, TEXT_FILL_STROKE_CLIP, TEXT_CLIP, TEXT_OUTLINE, SCALE_CTM, TRANSLATE_CTM, ROTATE_CTM, CONCAT_CTM, LOAD_CTM) from .abstract_graphics_context import AbstractGraphicsContext from .line_state import LineState, line_state_equal from .graphics_state import GraphicsState from .fonttools import Font import kiva.affine as affine # -------------------------------------------------------------------- # Drawing style tests. # # Simple tests used by drawing methods to determine what kind of # drawing command is supposed to be executed. # -------------------------------------------------------------------- def is_point(tup): return tup[0] == POINT def is_line(tup): return tup[0] == LINE def is_fully_transparent(color): """ Tests a color array to see whether it is fully transparent or not. This is true if the alpha value (4th entry in the color array) is 0.0. """ transparent = (color[3] == 0.0) return transparent def fill_equal(fill1, fill2): """ Compares the two fill colors. """ return alltrue(fill1 == fill2) class GraphicsContextBase(AbstractGraphicsContext): """ Concrete base implementation of a GraphicsContext Attributes ---------- state Current state of graphics context. state_stack Stack used to save graphics states path The drawing path. active_subpath The active drawing subpath This class needs to be sub-classed by device types that handle drawing but don't handle more advanced concepts like paths, graphics state, and coordinate transformations. This class can also be used as a null backend for testing purposes. """ def __init__(self, *args, **kwargs): super(GraphicsContextBase, self).__init__() self.state = GraphicsState() # The line state has multiple properties that are tracked by a class self.last_drawn_line_state = LineState(None, None, None, None, None) # The fill state is simply a color. self.last_drawn_fill_state = None self.last_font_state = None # Used by save/restore state. self.state_stack = [] # Variables for used in drawing paths. # The path_transform_indices holds a list of indices pointing into # active_subpath that affect the ctm. It is necessary to preserve # these across begin_path calls. self.active_subpath = [] self.path_transform_indices = [] self.path = [self.active_subpath] # Whether the particular underlying graphics context considers the # "origin" of a pixel to be the center of the pixel or the lower-left # corner. Most vector-based drawing systems consider the origin to # be at the corner, whereas most raster systems place the origin at # the center. # # This is ultimately used to determine whether certain methods should # automatically tack on a (0.5, 0.5) offset. self.corner_pixel_origin = True # -------------------------------------------------------------------- # We're currently maintaining a couple of copies of the ctm around. # The state.ctm is used mainly for user querying, etc. We also have # something called the device_ctm which is actually used in the # drawing of objects. In some implementation (OpenGL), the # device_ctm is actually maintained in hardware. # -------------------------------------------------------------------- self.device_prepare_device_ctm() # ------------------------------------------------------------------------ # Coordinate Transform Matrix Manipulation # # Note: I'm not sure we really need to keep the state.ctm around now # that we're keeping the device_ctm around, but I'm reluctant to # unify the two yet. I think it can (and probably should) be done # though. # ------------------------------------------------------------------------ def scale_ctm(self, sx, sy): """ Sets the coordinate system scale to the given values, (sx, sy). Parameters ---------- sx : float The new scale factor for the x axis sy : float The new scale factor for the y axis """ self.state.ctm = affine.scale(self.state.ctm, sx, sy) self.active_subpath.append((SCALE_CTM, (sx, sy))) self.path_transform_indices.append(len(self.active_subpath)-1) def translate_ctm(self, tx, ty): """ Translates the coordinate system by the value given by (tx, ty) Parameters ---------- tx : float The distance to move in the x direction ty : float The distance to move in the y direction """ self.state.ctm = affine.translate(self.state.ctm, tx, ty) self.active_subpath.append((TRANSLATE_CTM, (tx, ty))) self.path_transform_indices.append(len(self.active_subpath)-1) def rotate_ctm(self, angle): """ Rotates the coordinate space for drawing by the given angle. Parameters ---------- angle : float the angle, in radians, to rotate the coordinate system """ self.state.ctm = affine.rotate(self.state.ctm, angle) self.active_subpath.append((ROTATE_CTM, (angle,))) self.path_transform_indices.append(len(self.active_subpath)-1) def concat_ctm(self, transform): """ Concatenates the transform to current coordinate transform matrix. Parameters ---------- transform : affine_matrix the transform matrix to concatenate with the current coordinate matrix. """ self.state.ctm = affine.concat(self.state.ctm, transform) self.active_subpath.append((CONCAT_CTM, (transform,))) self.path_transform_indices.append(len(self.active_subpath)-1) def get_ctm(self): """ Returns the current coordinate transform matrix. """ return self.state.ctm.copy() def set_ctm(self, transform): """ Returns the current coordinate transform matrix. """ self.state.ctm = transform self.active_subpath.append((LOAD_CTM, (transform,))) self.path_transform_indices.append(len(self.active_subpath)-1) # ---------------------------------------------------------------- # Save/Restore graphics state. # ---------------------------------------------------------------- def save_state(self): """ Saves the current graphic's context state. Always pair this with a `restore_state()`, for example using try ... finally ... or the context manager interface. """ self.state_stack.append(self.state) self.state = self.state.copy() def restore_state(self): """ Restores the previous graphics state. """ self.state = self.state_stack.pop(-1) self.active_subpath.append((LOAD_CTM, (self.state.ctm,))) self.path_transform_indices.append(len(self.active_subpath)-1) # ---------------------------------------------------------------- # context manager interface # ---------------------------------------------------------------- def __enter__(self): self.save_state() def __exit__(self, type, value, traceback): self.restore_state() # ---------------------------------------------------------------- # Manipulate graphics state attributes. # ---------------------------------------------------------------- def set_antialias(self, value): """ Sets/Unsets anti-aliasing for bitmap graphics context. Ignored on most platforms. """ self.state.antialias = value def get_antialias(self, value): """ Returns the anti-aliasing for bitmap graphics context. Ignored on most platforms. """ return self.state.antialias def set_image_interpolation(self, value): """ Sets image interpolation for bitmap graphics context. Ignored on most platforms. """ self.state.image_interpolation = value def get_image_interpolation(self, value): """ Sets/Unsets anti-aliasing for bitmap graphics context. Ignored on most platforms. """ return self.state.image_interpolation def set_line_width(self, width): """ Sets the line width for drawing Parameters ---------- width : float The new width for lines in user space units. """ self.state.line_state.line_width = width def set_line_join(self, style): """ Sets the style for joining lines in a drawing. Parameters ---------- style : join_style The line joining style. The available styles are JOIN_ROUND, JOIN_BEVEL, JOIN_MITER. """ if style not in (JOIN_ROUND, JOIN_BEVEL, JOIN_MITER): msg = "Invalid line join style. See documentation for valid styles" raise ValueError(msg) self.state.line_state.line_join = style def set_miter_limit(self, limit): """ Specifies limits on line lengths for mitering line joins. If line_join is set to miter joins, the limit specifies which line joins should actually be mitered. If lines are not mitered, they are joined with a bevel. The line width is divided by the length of the miter. If the result is greater than the limit, the bevel style is used. This is not implemented on most platforms. Parameters ---------- limit : float limit for mitering joins. defaults to 1.0. """ self.state.miter_limit = limit def set_line_cap(self, style): """ Specifies the style of endings to put on line ends. Parameters ---------- style : cap_style The line cap style to use. Available styles are CAP_ROUND, CAP_BUTT, CAP_SQUARE. """ if style not in (CAP_ROUND, CAP_BUTT, CAP_SQUARE): msg = "Invalid line cap style. See documentation for valid styles" raise ValueError(msg) self.state.line_state.line_cap = style def set_line_dash(self, pattern, phase=0): """ Sets the line dash pattern and phase for line painting. Parameters ---------- pattern : float array An array of floating point values specifing the lengths of on/off painting pattern for lines. phase : float Specifies how many units into dash pattern to start. phase defaults to 0. """ if not alltrue(pattern): self.state.line_state.line_dash = NO_DASH return pattern = asarray(pattern) if len(pattern) < 2: raise ValueError("dash pattern should have at least two entries.") # not sure if this check is really needed. if phase < 0: raise ValueError("dash phase should be a positive value.") self.state.line_state.line_dash = (phase, pattern) def set_flatness(self, flatness): """ Not implemented It is device dependent and therefore not recommended by the PDF documentation. flatness determines how accurately curves are rendered. Setting it to values less than one will result in more accurate drawings, but they take longer. It defaults to None """ self.state.flatness = flatness # ---------------------------------------------------------------- # Sending drawing data to a device # ---------------------------------------------------------------- def flush(self): """ Sends all drawing data to the destination device. """ pass def synchronize(self): """ Prepares drawing data to be updated on a destination device. Currently this is a NOP for all implementations. """ pass # ---------------------------------------------------------------- # Page Definitions # ---------------------------------------------------------------- def begin_page(self): """ Creates a new page within the graphics context. Currently this is a NOP for all implementations. The PDF backend should probably implement it, but the ReportLab Canvas uses the showPage() method to handle both begin_page and end_page issues. """ pass def end_page(self): """ Ends drawing in the current page of the graphics context. Currently this is a NOP for all implementations. The PDF backend should probably implement it, but the ReportLab Canvas uses the showPage() method to handle both begin_page and end_page issues. """ pass # ---------------------------------------------------------------- # Building paths (contours that are drawn) # # + Currently, nothing is drawn as the path is built. Instead, the # instructions are stored and later drawn. Should this be changed? # We will likely draw to a buffer instead of directly to the canvas # anyway. # # Hmmm. No. We have to keep the path around for storing as a # clipping region and things like that. # # + I think we should keep the current_path_point hanging around. # # ---------------------------------------------------------------- def begin_path(self): """ Clears the current drawing path and begin a new one. """ # Need to check here if the current subpath contains matrix # transforms. If it does, pull these out, and stick them # in the new subpath. if self.path_transform_indices: tf = array(self.active_subpath, object)[self.path_transform_indices, :] self.path_transform_indices = range(len(tf)) self.active_subpath = list(tf) else: self.active_subpath = [] self.path = [self.active_subpath] def move_to(self, x, y): """ Starts a new drawing subpath and place the current point at (x, y). Notes: Not sure how to treat state.current_point. Should it be the value of the point before or after the matrix transformation? It looks like before in the PDF specs. """ self._new_subpath() pt = array((x, y), dtype=float64) self.state.current_point = pt self.active_subpath.append((POINT, pt)) def line_to(self, x, y): """ Adds a line from the current point to the given point (x, y). The current point is moved to (x, y). What should happen if move_to hasn't been called? Should it always begin at (0, 0) or raise an error? Notes: See note in move_to about the current_point. """ pt = array((x, y), dtype=float64) self.state.current_point = pt self.active_subpath.append((LINE, pt)) def lines(self, points): """ Adds a series of lines as a new subpath. Parameters ---------- points an Nx2 array of x, y pairs The current_point is moved to the last point in 'points' """ self._new_subpath() pts = points self.active_subpath.append((LINES, pts)) self.state.current_point = points[-1] def line_set(self, starts, ends): """ Adds a set of disjoint lines as a new subpath. Parameters ---------- starts an Nx2 array of x, y pairs ends an Nx2 array of x, y pairs Starts and ends should have the same length. The current point is moved to the last point in 'ends'. """ self._new_subpath() for i in xrange(min(len(starts), len(ends))): self.active_subpath.append((POINT, starts[i])) self.active_subpath.append((LINE, ends[i])) self.state.current_point = ends[i] def rect(self, x, y, sx, sy): """ Adds a rectangle as a new subpath. """ pts = array(((x, y), (x, y+sy), (x+sx, y+sy), (x+sx, y),)) self.lines(pts) self.close_path('rect') def draw_rect(self, rect, mode): self.rect(*rect) self.draw_path(mode=mode) def rects(self, rects): """ Adds multiple rectangles as separate subpaths to the path. Not very efficient -- calls rect multiple times. """ for x, y, sx, sy in rects: self.rect(x, y, sx, sy) def close_path(self, tag=None): """ Closes the path of the current subpath. Currently starts a new subpath -- is this what we want? """ self.active_subpath.append((CLOSE, (tag,))) self._new_subpath() def curve_to(self, x_ctrl1, y_ctrl1, x_ctrl2, y_ctrl2, x_to, y_to): """ Draw a cubic bezier curve from the current point. Parameters ---------- x_ctrl1 : float X-value of the first control point. y_ctrl1 : float Y-value of the first control point. x_ctrl2 : float X-value of the second control point. y_ctrl2 : float Y-value of the second control point. x_to : float X-value of the ending point of the curve. y_to : float Y-value of the ending point of the curve. """ # XXX: figure out a reasonable number of points from the current scale # and arc length. Since the arc length is expensive to calculate, the # sum of the lengths of the line segments from (xy0, xy_ctrl1), # (xy_ctrl1, xy_ctrl2), and (xy_ctrl2, xy_to) would be a reasonable # approximation. n = 100 t = np.arange(1, n+1) / float(n) t2 = t*t t3 = t2*t u = 1 - t u2 = u*u u3 = u2*u x0, y0 = self.state.current_point pts = np.column_stack([ x0*u3 + 3*(x_ctrl1*t*u2 + x_ctrl2*t2*u) + x_to*t3, y0*u3 + 3*(y_ctrl1*t*u2 + y_ctrl2*t2*u) + y_to*t3, ]) self.active_subpath.append((LINES, pts)) self.state.current_point = pts[-1] def quad_curve_to(self, x_ctrl, y_ctrl, x_to, y_to): """ Draw a quadratic bezier curve from the current point. Parameters ---------- x_ctrl : float X-value of the control point y_ctrl : float Y-value of the control point. x_to : float X-value of the ending point of the curve y_to : float Y-value of the ending point of the curve. """ # A quadratic Bezier curve is just a special case of the cubic. Reuse # its implementation in case it has been implemented for the specific # backend. x0, y0 = self.state.current_point xc1 = (x0 + x_ctrl + x_ctrl) / 3.0 yc1 = (y0 + y_ctrl + y_ctrl) / 3.0 xc2 = (x_to + x_ctrl + x_ctrl) / 3.0 yc2 = (y_to + y_ctrl + y_ctrl) / 3.0 self.curve_to(xc1, yc1, xc2, yc2, x_to, y_to) def arc(self, x, y, radius, start_angle, end_angle, cw=False): """ Draw a circular arc. If there is a current path and the current point is not the initial point of the arc, a line will be drawn to the start of the arc. If there is no current path, then no line will be drawn. Parameters ---------- x : float X-value of the center of the arc. y : float Y-value of the center of the arc. radius : float The radius of the arc. start_angle : float The angle, in radians, that the starting point makes with respect to the positive X-axis from the center point. end_angle : float The angles, in radians, that the final point makes with respect to the positive X-axis from the center point. cw : bool, optional Whether the arc should be drawn clockwise or not. """ # XXX: pick the number of line segments based on the current scale and # the radius. n = 100 if end_angle < start_angle and not cw: end_angle += 2*pi elif start_angle < end_angle and cw: start_angle += 2*pi theta = np.linspace(start_angle, end_angle, n) pts = radius * np.column_stack([np.cos(theta), np.sin(theta)]) pts += np.array([x, y]) self.active_subpath.append((LINES, pts)) self.state.current_point = pts[-1] def arc_to(self, x1, y1, x2, y2, radius): """ """ raise NotImplementedError("arc_to is not implemented") def _new_subpath(self): """ Starts a new drawing subpath. Only creates a new subpath if the current one contains objects. """ if self.active_subpath: self.active_subpath = [] self.path_transform_indices = [] self.path.append(self.active_subpath) # ---------------------------------------------------------------- # Getting infomration on paths # ---------------------------------------------------------------- def is_path_empty(self): """ Tests to see whether the current drawing path is empty """ # If the first subpath is empty, then the path is empty res = 0 if not self.path[0]: res = 1 else: res = 1 for sub in self.path: if not is_point(sub[-1]): res = 0 break return res def get_path_current_point(self): """ Returns the current point from the graphics context. Note: Currently the current_point is only affected by move_to, line_to, and lines. It should also be affected by text operations. I'm not sure how rect and rects and friends should affect it -- will find out on Mac. """ pass def get_path_bounding_box(self): """ """ pass def from_agg_affine(self, aff): """Convert an agg.AffineTransform to a numpy matrix representing the affine transform usable by kiva.affine and other non-agg parts of kiva""" return array([[aff[0], aff[1], 0], [aff[2], aff[3], 0], [aff[4], aff[5], 1]], float64) def add_path(self, path): """Draw a compiled path into this gc. Note: if the CTM is changed and not restored to the identity in the compiled path, the CTM change will continue in this GC.""" # Local import to avoid a dependency if we can avoid it. from kiva import agg multi_state = 0 # For multi-element path commands we keep the previous x_ctrl1 = 0 # information in these variables. y_ctrl1 = 0 x_ctrl2 = 0 y_ctrl2 = 0 for x, y, cmd, flag in path._vertices(): if cmd == agg.path_cmd_line_to: self.line_to(x, y) elif cmd == agg.path_cmd_move_to: self.move_to(x, y) elif cmd == agg.path_cmd_stop: self.concat_ctm(path.get_kiva_ctm()) elif cmd == agg.path_cmd_end_poly: self.close_path() elif cmd == agg.path_cmd_curve3: if multi_state == 0: x_ctrl1 = x y_ctrl1 = y multi_state = 1 else: self.quad_curve_to(x_ctrl1, y_ctrl1, x, y) multi_state = 0 elif cmd == agg.path_cmd_curve4: if multi_state == 0: x_ctrl1 = x y_ctrl1 = y multi_state = 1 elif multi_state == 1: x_ctrl2 = x y_ctrl2 = y multi_state = 2 elif multi_state == 2: self.curve_to(x_ctrl1, y_ctrl1, x_ctrl2, y_ctrl2, x, y) # ---------------------------------------------------------------- # Clipping path manipulation # ---------------------------------------------------------------- def clip(self): """ """ pass def even_odd_clip(self): """ """ pass def clip_to_rect(self, x, y, width, height): """ Sets the clipping path to the intersection of the current clipping path with the area defined by the specified rectangle """ if not self.state.clipping_path: self.state.clipping_path = (x, y, width, height) self.device_set_clipping_path(x, y, width, height) else: # Find the intersection of the clipping regions: xmin1, ymin1, width1, height1 = self.state.clipping_path xclip_min = max(xmin1, x) xclip_max = min(xmin1 + width1, x + width) yclip_min = max(ymin1, y) yclip_max = min(ymin1 + height1, y + height) height_clip = max(0, yclip_max - yclip_min) width_clip = max(0, xclip_max - xclip_min) self.state.clipping_path = (xclip_min, yclip_min, width_clip, height_clip) self.device_set_clipping_path(xclip_min, yclip_min, width_clip, height_clip) def clip_to_rects(self): """ """ pass def clear_clip_path(self): self.state.clipping_path = None self.device_destroy_clipping_path() # ---------------------------------------------------------------- # Color manipulation # ---------------------------------------------------------------- def set_fill_color(self, color): """ set_fill_color takes a sequences of rgb or rgba values between 0.0 and 1.0 """ if len(color) == 3: self.state.fill_color[:3] = color self.state.fill_color[3] = 1.0 else: self.state.fill_color[:] = color def get_fill_color(self, color): """ set_fill_color returns a sequence of rgb or rgba values between 0.0 and 1.0 """ return self.state.fill_color def linear_gradient(self, x1, y1, x2, y2, stops, spread_method, units): """ Modify the fill color to be a linear gradient """ pass def radial_gradient(self, cx, cy, r, fx, fy, stops, spread_method, units): """ Modify the fill color to be a linear gradient """ pass def set_stroke_color(self, color): """ set_stroke_color takes a sequences of rgb or rgba values between 0.0 and 1.0 """ if len(color) == 3: self.state.line_state.line_color[:3] = color self.state.line_state.line_color[3] = 1.0 else: self.state.line_state.line_color[:] = color def get_stroke_color(self, color): """ set_stroke_color returns a sequence of rgb or rgba values between 0.0 and 1.0 """ return self.state.stroke_color def set_alpha(self, alpha): """ Set the alpha to use when drawing """ self.state.alpha = alpha def get_alpha(self, alpha): """ Return the alpha used when drawing """ return self.state.alpha # ---------------------------------------------------------------- # Drawing Images # ---------------------------------------------------------------- def draw_image(self, img, rect=None): """ """ self.device_draw_image(img, rect) # ------------------------------------------------------------------------- # Drawing Text # # Font handling needs more attention. # # ------------------------------------------------------------------------- def select_font(self, face_name, size=12, style="regular", encoding=None): """ Selects a new font for drawing text. Parameters ---------- face_name The name of a font. E.g.: "Times New Roman" !! Need to specify a way to check for all the types size The font size in points. style One of "regular", "bold", "italic", "bold italic" encoding A 4 letter encoding name. Common ones are: * "unic" -- unicode * "armn" -- apple roman * "symb" -- symbol Not all fonts support all encodings. If none is specified, fonts that have unicode encodings default to unicode. Symbol is the second choice. If neither are available, the encoding defaults to the first one returned in the FreeType charmap list for the font face. """ # !! should check if name and encoding are valid. self.state.font = Font(face_name, size=size, style=style) def set_font(self, font): """ Set the font for the current graphics context. """ self.state.font = font.copy() def get_font(self, font): """ Set the font for the current graphics context. """ return self.state.font.copy() def set_font_size(self, size): """ Sets the size of the font. The size is specified in user space coordinates. Note: I don't think the units of this are really "user space coordinates" on most platforms. I haven't looked into the text drawing that much, so this stuff needs more attention. """ self.state.font.size = size def set_character_spacing(self, spacing): """ Sets the amount of additional spacing between text characters. Parameters ---------- spacing : float units of space extra space to add between text coordinates. It is specified in text coordinate system. Notes ----- 1. I'm assuming this is horizontal spacing? 2. Not implemented in wxPython. """ self.state.character_spacing = spacing def get_character_spacing(self): """ Gets the amount of additional spacing between text characters. """ return self.state.character_spacing def set_text_drawing_mode(self, mode): """ Specifies whether text is drawn filled or outlined or both. Parameters ---------- mode determines how text is drawn to the screen. If a CLIP flag is set, the font outline is added to the clipping path. Possible values: TEXT_FILL fill the text TEXT_STROKE paint the outline TEXT_FILL_STROKE fill and outline TEXT_INVISIBLE paint it invisibly ?? TEXT_FILL_CLIP fill and add outline clipping path TEXT_STROKE_CLIP outline and add outline to clipping path TEXT_FILL_STROKE_CLIP fill, outline, and add to clipping path TEXT_CLIP add text outline to clipping path Note: wxPython currently ignores all but the INVISIBLE flag. """ if mode not in (TEXT_FILL, TEXT_STROKE, TEXT_FILL_STROKE, TEXT_INVISIBLE, TEXT_FILL_CLIP, TEXT_STROKE_CLIP, TEXT_FILL_STROKE_CLIP, TEXT_CLIP, TEXT_OUTLINE): msg = ("Invalid text drawing mode. See documentation for valid " + "modes") raise ValueError(msg) self.state.text_drawing_mode = mode def set_text_position(self, x, y): """ """ a, b, c, d, tx, ty = affine.affine_params(self.state.text_matrix) tx, ty = x, y self.state.text_matrix = affine.affine_from_values(a, b, c, d, tx, ty) def get_text_position(self): """ """ a, b, c, d, tx, ty = affine.affine_params(self.state.text_matrix) return tx, ty def set_text_matrix(self, ttm): """ """ self.state.text_matrix = ttm.copy() def get_text_matrix(self): """ """ return self.state.text_matrix.copy() def show_text(self, text): """ Draws text on the device at the current text position. This calls the device dependent device_show_text() method to do all the heavy lifting. It is not clear yet how this should affect the current point. """ self.device_show_text(text) def show_text_tanslate(self, text, dx, dy): """ Draws text at the specified offset. """ x, y = self.get_text_position() self.set_text_position(x+dx, y+dy) self.device_show_text(text) self.set_text_position(x, y) # ------------------------------------------------------------------------ # kiva defaults to drawing text using the freetype rendering engine. # # If you would like to use a systems native text rendering engine, # override this method in the class concrete derived from this one. # ------------------------------------------------------------------------ def device_show_text(self, text): """ Draws text on the device at the current text position. This relies on the FreeType engine to render the text to an array and then calls the device dependent device_show_text() to display the rendered image to the screen. !! antiliasing is turned off until we get alpha blending !! of images figured out. """ # This is not currently implemented in a device-independent way. return def show_glyphs(self): """ """ pass def show_text_at_point(self, text, x, y): """ """ pass def show_glyphs_at_point(self): """ """ pass # ---------------------------------------------------------------- # Painting paths (drawing and filling contours) # ---------------------------------------------------------------- def get_empty_path(self): """ Get an empty CompiledPath instance """ pass def stroke_path(self): self.draw_path(mode=STROKE) def fill_path(self): self.draw_path(mode=FILL) def eof_fill_path(self): self.draw_path(mode=EOF_FILL) def draw_path(self, mode=FILL_STROKE): """ Walks through all the drawing subpaths and draw each element. Each subpath is drawn separately. Parameters ---------- mode Specifies how the subpaths are drawn. The default is FILL_STROKE. The following are valid values. FILL Paint the path using the nonzero winding rule to determine the regions for painting. EOF_FILL Paint the path using the even-odd fill rule. STROKE Draw the outline of the path with the current width, end caps, etc settings. FILL_STROKE First fill the path using the nonzero winding rule, then stroke the path. EOF_FILL_STROKE First fill the path using the even-odd fill method, then stroke the path. """ # --------------------------------------------------------------------- # FILL AND STROKE settings are handled by setting the alpha value of # the line and fill colors to zero (transparent) if stroke or fill # is not needed. # --------------------------------------------------------------------- old_line_alpha = self.state.line_state.line_color[3] old_fill_alpha = self.state.fill_color[3] if mode not in [STROKE, FILL_STROKE, EOF_FILL_STROKE]: self.state.line_state.line_color[3] = 0.0 if mode not in [FILL, EOF_FILL, FILL_STROKE, EOF_FILL_STROKE]: self.state.fill_color[3] = 0.0 self.device_update_line_state() self.device_update_fill_state() for subpath in self.path: # reset the current point for drawing. self.clear_subpath_points() for func, args in subpath: if func == POINT: self.draw_subpath(mode) self.add_point_to_subpath(args) self.first_point = args elif func == LINE: self.add_point_to_subpath(args) elif func == LINES: self.draw_subpath(mode) # add all points in list to subpath. self.add_point_to_subpath(args) self.first_point = args[0] elif func == CLOSE: self.add_point_to_subpath(self.first_point) self.draw_subpath(mode) elif func == RECT: self.draw_subpath(mode) self.device_draw_rect(args[0], args[1], args[2], args[3], mode) elif func in [SCALE_CTM, ROTATE_CTM, TRANSLATE_CTM, CONCAT_CTM, LOAD_CTM]: self.device_transform_device_ctm(func, args) else: print('oops:', func) # finally, draw any remaining paths. self.draw_subpath(mode) # --------------------------------------------------------------------- # reset the alpha values for line and fill values. # --------------------------------------------------------------------- self.state.line_state.line_color[3] = old_line_alpha self.state.fill_color[3] = old_fill_alpha # --------------------------------------------------------------------- # drawing methods always consume the path on Mac OS X. We'll follow # this convention to make implementation there easier. # --------------------------------------------------------------------- self.begin_path() def device_prepare_device_ctm(self): self.device_ctm = affine.affine_identity() def device_transform_device_ctm(self, func, args): """ Default implementation for handling scaling matrices. Many implementations will just use this function. Others, like OpenGL, can benefit from overriding the method and using hardware acceleration. """ if func == SCALE_CTM: self.device_ctm = affine.scale(self.device_ctm, args[0], args[1]) elif func == ROTATE_CTM: self.device_ctm = affine.rotate(self.device_ctm, args[0]) elif func == TRANSLATE_CTM: self.device_ctm = affine.translate(self.device_ctm, args[0], args[1]) elif func == CONCAT_CTM: self.device_ctm = affine.concat(self.device_ctm, args[0]) elif func == LOAD_CTM: self.device_ctm = args[0].copy() def device_draw_rect(self, x, y, sx, sy, mode): """ Default implementation of drawing a rect. """ self._new_subpath() # When rectangles are rotated, they have to be drawn as a polygon # on most devices. We'll need to specialize this on API's that # can handle rotated rects such as Quartz and OpenGL(?). # All transformations are done in the call to lines(). pts = array(((x, y), (x, y+sy), (x+sx, y+sy), (x+sx, y), (x, y))) self.add_point_to_subpath(pts) self.draw_subpath(mode) def stroke_rect(self): """ """ pass def stroke_rect_with_width(self): """ """ pass def fill_rect(self): """ """ pass def fill_rects(self): """ """ pass def clear_rect(self): """ """ pass # ---------------------------------------------------------------- # Subpath point management and drawing routines. # ---------------------------------------------------------------- def add_point_to_subpath(self, pt): self.draw_points.append(pt) def clear_subpath_points(self): self.draw_points = [] def get_subpath_points(self, debug=0): """ Gets the points that are in the current path. The first entry in the draw_points list may actually be an array. If this is true, the other points are converted to an array and concatenated with the first """ if self.draw_points and len(shape(self.draw_points[0])) > 1: first_points = self.draw_points[0] other_points = asarray(self.draw_points[1:]) if len(other_points): pts = concatenate((first_points, other_points), 0) else: pts = first_points else: pts = asarray(self.draw_points) return pts def draw_subpath(self, mode): """ Fills and strokes the point path. After the path is drawn, the subpath point list is cleared and ready for the next subpath. Parameters ---------- mode Specifies how the subpaths are drawn. The default is FILL_STROKE. The following are valid values. FILL Paint the path using the nonzero winding rule to determine the regions for painting. EOF_FILL Paint the path using the even-odd fill rule. STROKE Draw the outline of the path with the current width, end caps, etc settings. FILL_STROKE First fill the path using the nonzero winding rule, then stroke the path. EOF_FILL_STROKE First fill the path using the even-odd fill method, then stroke the path. Note: If path is closed, it is about 50% faster to call DrawPolygon with the correct pen set than it is to call DrawPolygon and DrawLines separately in wxPython. But, because paths can be left open, Polygon can't be called in the general case because it automatically closes the path. We might want a separate check in here and allow devices to specify a faster version if the path is closed. """ pts = self.get_subpath_points() if len(pts) > 1: self.device_fill_points(pts, mode) self.device_stroke_points(pts, mode) self.clear_subpath_points() def get_text_extent(self, textstring): """ Calls device specific text extent method. """ return self.device_get_text_extent(textstring) def device_get_text_extent(self, textstring): return self.device_get_full_text_extent(textstring) def get_full_text_extent(self, textstring): """ Calls device specific text extent method. """ return self.device_get_full_text_extent(textstring) def device_get_full_text_extent(self, textstring): return (0.0, 0.0, 0.0, 0.0) # ------------------------------------------- # Misc functions # ------------------------------------------- def save(self, filename, file_format=None, pil_options=None): """ Save the graphics context to a file """ raise NotImplementedError enthought-chaco2-4.5.1.orig/kiva/line_state.py0000644000175000017500000000765612516137326020351 0ustar varunvarun""" LineState Class The LineState class is used by the GraphicsState for Kiva backends which need to have their state tracked by Python, rather than by an internal graphics state (eg. Wx, SVG and PDF backends, but not Agg or QPainter). """ from __future__ import absolute_import, print_function from numpy import alltrue, array, asarray, shape, sometrue from .constants import NO_DASH def exactly_equal(arr1, arr2): return shape(arr1) == shape(arr2) and alltrue(arr1 == arr2) def is_dashed(dash): # if all the values in the dash settings are 0, then it is a solid line. result = 0 if dash is not None and sometrue(asarray(dash[1]) != 0): result = 1 return result def line_state_equal(line1, line2): """ Compares two `LineState` objects to see if they are equivalent. This is generally called by device-specific drawing routines before they stroke a path. It determines whether previously set line settings are equivalent to desired line settings for this drawing command. If true, the routine can bypass all the work needed to set all the line settings of the graphics device. With the current Python implementation, this may not provide any time savings over just setting all the graphics state values. However, in C this could be a very fast memcmp if the C structure is set up correctly. While this could be the __cmp__ method for `LineState`, I have left it as a function because I think it will move to C and be used to compare structures. """ # --------------------------------------------------------------------- # line_dash is a little persnickety. It is a 2-tuple # with the second entry being an array. If the arrays are different, # just comparing the tuple will yield true because of how rich # the result from the array comparison is a non-empty array which # tests true. Thus, the tuple comparison will test true even if the # arrays are different. Its almost like we need a "deep compare" # method or something like that. # # Note: I think should be easy, but is breaking because of a bug in # Numeric. Waiting for confirmation. # --------------------------------------------------------------------- dash_equal = (line1.line_dash[0] == line2.line_dash[0] and exactly_equal(line1.line_dash[1], line2.line_dash[1])) result = (dash_equal and exactly_equal(line1.line_color, line2.line_color) and line1.line_width == line2.line_width and line1.line_cap == line2.line_cap and line1.line_join == line2.line_join) return result class LineState(object): """ Stores information about the current line drawing settings. This is split off from `GraphicsState` to make it easier to track line state changes. All the methods for setting these variables are left in the GraphicsStateBase class. """ def __init__(self, color, width, cap, join, dash): """ Creates a new `LineState` object. All input arguments that are containers are copied by the constructor. This prevents two `LineState` objects from ever sharing and modifying the other's data. """ self.line_color = array(color, copy=1) self.line_width = width self.line_cap = cap self.line_join = join if not dash: # always set line_dash to be a tuple self.line_dash = NO_DASH else: self.line_dash = (dash[0], array(dash[1], copy=1)) def copy(self): """ Makes a copy of the current line state """ # Could just use deepcopy... return LineState(self.line_color, self.line_width, self.line_cap, self.line_join, self.line_dash) def is_dashed(self): # if line_dash only has one entry, it is a solid line. return is_dashed(self.line_dash) enthought-chaco2-4.5.1.orig/kiva/__init__.py0000644000175000017500000000203512516137326017743 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2005, Enthought, Inc. # some parts copyright 2002 by Space Telescope Science Institute # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ """ A multi-platform DisplayPDF vector drawing engine. Part of the Enable project of the Enthought Tool Suite. """ from kiva._version import full_version as __version__ from constants import * from fonttools import Font import os if os.environ.has_key('KIVA_WISHLIST'): from warnings import warn warn("Use of the KIVA_WISHLIST environment variable to select Kiva backends" "is no longer supported.") del os enthought-chaco2-4.5.1.orig/kiva/graphics_state.py0000644000175000017500000000766312516137326021220 0ustar varunvarun""" GraphicsState Class The GraphicsState class is used Kiva backends which need to have their state tracked by Python, rather than by an internal graphics state (eg. Wx, SVG and PDF backends, but not Agg or QPainter). """ from __future__ import absolute_import, print_function import copy from numpy import array, float64 from .constants import CAP_ROUND, JOIN_MITER, TEXT_FILL from .fonttools import Font from .line_state import LineState import kiva.affine as affine class GraphicsState(LineState): """ Holds information used by a graphics context when drawing. I'm not sure if these should be a separate class, a dictionary, or part of the GraphicsContext object. Making them a dictionary or object simplifies save_state and restore_state a little bit. Also, this is a pretty good candidate for using slots. I'm not going to use them right now, but, if we standardize on 2.2, slots might speed things up some. Attributes ---------- ctm context transform matrix fill_color RGBA array(4) of values 0.0 to 1.0 alpha transparency value of drawn objects font either a special device independent font object (what does anygui use?) or a device dependent font object. text_matrix coordinate transformation matrix for text clipping_path defines the path of the clipping region. For now, this can only be a rectangle. current_point location where next object is drawn. should_antialias whether anti-aliasing should be used when drawing lines and fonts miter_limit specifies when and when not to miter line joins. flatness specifies tolerance for bumpiness of curves character_spacing spacing between drawing text characters text_drawing_mode style for drawing text: outline, fill, etc. These are inherited from LineState: line_color RGBA array(4) of values 0.0 to 1.0 line_width width of drawn lines line_join style of how lines are joined. The choices are: JOIN_ROUND, JOIN_BEVEL, JOIN_MITER line_cap style of the end cap on lines. The choices are: CAP_ROUND, CAP_SQUARE, CAP_BUTT line_dash (phase,pattern) dash pattern for lines. phase is a single value specifying how many units into the pattern to start. dash is a 1-D array of floats that alternate between specifying the number of units on and off in the pattern. When the end of the array is reached, the pattern repeats. Not yet supported: rendering_intent deals with colors and color correction in a sophisticated way. """ def __init__(self): # Line state default values. line_color = array((0.0, 0.0, 0.0, 1.0)) line_width = 1 line_cap = CAP_ROUND line_join = JOIN_MITER line_dash = (0, array([0])) # This will draw a solid line # FIXME: This is a very wierd class. The following code is here to # make the basecore2d and the PS, SVG context managers happy super(GraphicsState, self).__init__( line_color, line_width, line_cap, line_join, line_dash) self.line_state = self # All other default values. self.ctm = affine.affine_identity() self.fill_color = array((0.0, 0.0, 0.0, 1.0)) self.alpha = 1.0 self.font = Font() self.text_matrix = affine.affine_identity() self.clipping_path = None # Not sure what the default should be? # Technically uninitialized in the PDF spec, but 0,0 seems fine to me: self.current_point = array((0, 0), dtype=float64) self.antialias = True self.miter_limit = 1.0 self.flatness = 1.0 self.character_spacing = 0.0 self.text_drawing_mode = TEXT_FILL self.alpha = 1.0 def copy(self): return copy.deepcopy(self) enthought-chaco2-4.5.1.orig/kiva/setup.py0000644000175000017500000000262312516137326017347 0ustar varunvarun#!/usr/bin/env python #------------------------------------------------------------------------------ # Copyright (c) 2005, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # # Author: Enthought, Inc. # Description: #------------------------------------------------------------------------------ import sys import os def configuration(parent_package=None, top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('kiva', parent_package, top_path) config.add_data_dir('tests') config.add_data_files('*.txt') config.add_subpackage('agg') config.add_subpackage('fonttools') config.add_subpackage('fonttools.*') config.add_subpackage('fonttools.*.*') config.add_subpackage('fonttools.*.*.*') config.add_data_files('fonttools/fontTools/*.txt') config.add_subpackage('trait_defs') config.add_subpackage('trait_defs.ui') config.add_subpackage('trait_defs.ui.*') if sys.platform == 'darwin': config.add_subpackage('quartz') config.get_version() return config enthought-chaco2-4.5.1.orig/kiva/image.py0000644000175000017500000000320012516137326017261 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2005, Enthought, Inc. # some parts copyright 2002 by Space Telescope Science Institute # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ """ This backend supports Kiva drawing into memory buffers. Though this can be used to perform drawing in non-GUI applications, the Image backend is also used by many of the GUI backends to draw into the memory space of the graphics contexts. """ # Soon the Agg subpackage will be renamed for real. For now, just # proxy the imports. from agg import GraphicsContextArray as GraphicsContext # FontType will be unified with the Kiva FontType soon. from agg import AggFontType as FontType # GraphicsContextSystem wraps up platform- and toolkit- specific low # level calls with a GraphicsContextArray. Eventually this low-level code # will be moved out of the Agg subpackage, and we won't have be importing # this here. from agg import GraphicsContextSystem, Image # CompiledPath is an object that can efficiently store paths to be reused # multiple times. from agg import CompiledPath def font_metrics_provider(): """ Create an object to be used for querying font metrics. """ return GraphicsContext((1, 1)) enthought-chaco2-4.5.1.orig/kiva/trait_defs/0000755000175000017500000000000012516137726017762 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/trait_defs/__init__.py0000644000175000017500000000007712516137326022073 0ustar varunvarun# Copyright (c) 2007 by Enthought, Inc. # All rights reserved. enthought-chaco2-4.5.1.orig/kiva/trait_defs/kiva_font_trait.py0000644000175000017500000001341212516137326023514 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2005-2007 by Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # #------------------------------------------------------------------------------ """ Trait definition for a wxPython-based Kiva font. """ #------------------------------------------------------------------------------- # Imports: #------------------------------------------------------------------------------- from traits.etsconfig.api import ETSConfig if ETSConfig.toolkit == 'wx': from .ui.wx.kiva_font_editor import KivaFontEditor elif ETSConfig.toolkit == 'qt4': # FIXME #from .ui.qt4.kiva_font_editor import KivaFontEditor KivaFontEditor = None else: KivaFontEditor = None from traits.api import Trait, TraitError, TraitHandler, TraitFactory #------------------------------------------------------------------------------- # Convert a string into a valid 'Font' object (if possible): #------------------------------------------------------------------------------- # Strings to ignore in text representations of fonts font_noise = [ 'pt', 'point', 'family' ] font_families = font_styles = font_weights = DEFAULT = NORMAL = None def init_constants ( ): """ Dynamically load Kiva constants to avoid import dependencies. """ global font_families, font_styles, font_weights, default_face, DEFAULT, NORMAL if font_families is not None: return import kiva.constants as kc DEFAULT = kc.DEFAULT NORMAL = kc.NORMAL # Mapping of strings to valid Kiva font families: font_families = { 'default': kc.DEFAULT, 'decorative': kc.DECORATIVE, 'roman': kc.ROMAN, 'script': kc.SCRIPT, 'swiss': kc.SWISS, 'modern': kc.MODERN } # Mapping of strings to Kiva font styles: font_styles = { 'italic': kc.ITALIC } # Mapping of strings to Kiva font weights: font_weights = { 'bold': kc.BOLD } default_face = { kc.SWISS: "Arial", kc.ROMAN: "Times", kc.MODERN: "Courier", kc.SCRIPT: "Zapfino", kc.DECORATIVE: "Zapfino", # need better choice for this } # Strings to ignore in text representations of fonts font_noise = [ 'pt', 'point', 'family' ] #------------------------------------------------------------------------------- # 'TraitKivaFont' class' #------------------------------------------------------------------------------- class TraitKivaFont ( TraitHandler ): """ Ensures that values assigned to a trait attribute are valid font descriptor strings for Kiva fonts; the value actually assigned is the corresponding Kiva font. """ #--------------------------------------------------------------------------- # Validates that the value is a valid font: #--------------------------------------------------------------------------- def validate ( self, object, name, value ): """ Validates that the value is a valid font. """ from kiva.fonttools import Font if isinstance( value, Font ): return value # Make sure all Kiva related data is loaded: init_constants() try: point_size = 10 family = DEFAULT style = NORMAL weight = NORMAL underline = 0 facename = [] for word in value.split(): lword = word.lower() if font_families.has_key( lword ): family = font_families[ lword ] elif font_styles.has_key( lword ): style = font_styles[ lword ] elif font_weights.has_key( lword ): weight = font_weights[ lword ] elif lword == 'underline': underline = 1 elif lword not in font_noise: try: point_size = int( lword ) except: facename.append( word ) if facename == "": facename = default_face.get(family, "") return Font(face_name = " ".join(facename), size = point_size, family = family, weight = weight, style = style, underline = underline) except: pass raise TraitError, ( object, name, 'a font descriptor string', repr( value ) ) def info ( self ): return ( "a string describing a font (e.g. '12 pt bold italic " "swiss family Arial' or 'default 12')" ) fh = TraitKivaFont() if KivaFontEditor is not None: KivaFontTrait = Trait(fh.validate(None, None, 'modern 12'), fh, editor = KivaFontEditor) else: KivaFontTrait = Trait(fh.validate(None, None, 'modern 12'), fh) def KivaFontFunc ( *args, **metadata ): """ Returns a trait whose value must be a GUI toolkit-specific font. Description ----------- For wxPython, the returned trait accepts any of the following: * an kiva.fonttools.Font instance * a string describing the font, including one or more of the font family, size, weight, style, and typeface name. Default Value ------------- For wxPython, 'Arial 10' """ return KivaFontTrait( *args, **metadata ) KivaFont = TraitFactory( KivaFontFunc ) enthought-chaco2-4.5.1.orig/kiva/trait_defs/api.py0000644000175000017500000000004512516137326021100 0ustar varunvarunfrom kiva_font_trait import KivaFont enthought-chaco2-4.5.1.orig/kiva/trait_defs/ui/0000755000175000017500000000000012516137726020377 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/trait_defs/ui/__init__.py0000644000175000017500000000007712516137326022510 0ustar varunvarun# Copyright (c) 2007 by Enthought, Inc. # All rights reserved. enthought-chaco2-4.5.1.orig/kiva/trait_defs/ui/wx/0000755000175000017500000000000012516137726021035 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/trait_defs/ui/wx/__init__.py0000644000175000017500000000007712516137326023146 0ustar varunvarun# Copyright (c) 2007 by Enthought, Inc. # All rights reserved. enthought-chaco2-4.5.1.orig/kiva/trait_defs/ui/wx/kiva_font_editor.py0000644000175000017500000001217712516137326024741 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2005-2007 by Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # #------------------------------------------------------------------------------ """ Defines the font editor factory for Kiva fonts, for the wxPython user interface toolkit. """ #------------------------------------------------------------------------------- # Imports: #------------------------------------------------------------------------------- import wx from traits.trait_base \ import SequenceTypes from traitsui.wx.font_editor \ import ToolkitEditorFactory as EditorFactory from kiva.fonttools.font_manager import fontManager #------------------------------------------------------------------------------- # 'ToolkitEditorFactory' class: #------------------------------------------------------------------------------- class ToolkitEditorFactory ( EditorFactory ): """ wxPython editor factory for Kiva fonts. """ #--------------------------------------------------------------------------- # Returns a Font's 'face name': #--------------------------------------------------------------------------- def face_name ( self, font ): """ Returns a Font's typeface name. """ face_name = font.face_name if type( face_name ) in SequenceTypes: face_name = face_name[0] return face_name #--------------------------------------------------------------------------- # Returns a wxFont object corresponding to a specified object's font trait: #--------------------------------------------------------------------------- def to_wx_font ( self, editor ): """ Returns a wxFont object corresponding to a specified object's font trait. """ import kiva.constants as kc font = editor.value weight = ( wx.NORMAL, wx.BOLD )[ font.weight == kc.BOLD ] style = ( wx.NORMAL, wx.ITALIC )[ font.style == kc.ITALIC ] family = { kc.DEFAULT: wx.DEFAULT, kc.DECORATIVE: wx.DECORATIVE, kc.ROMAN: wx.ROMAN, kc.SCRIPT: wx.SCRIPT, kc.SWISS: wx.SWISS, kc.MODERN: wx.MODERN }.get( font.family, wx.SWISS ) return wx.Font( font.size, family, style, weight, (font.underline != 0), self.face_name( font ) ) #--------------------------------------------------------------------------- # Gets the application equivalent of a wxPython value: #--------------------------------------------------------------------------- def from_wx_font ( self, font ): """ Gets the application equivalent of a wxPython value. """ import kiva.constants as kc from kiva.fonttools import Font return Font( size = font.GetPointSize(), family = { wx.DEFAULT: kc.DEFAULT, wx.DECORATIVE: kc.DECORATIVE, wx.ROMAN: kc.ROMAN, wx.SCRIPT: kc.SCRIPT, wx.SWISS: kc.SWISS, wx.MODERN: kc.MODERN }.get( font.GetFamily(), kc.SWISS ), weight = ( kc.NORMAL, kc.BOLD )[ font.GetWeight() == wx.BOLD ], style = ( kc.NORMAL, kc.ITALIC )[ font.GetStyle() == wx.ITALIC ], underline = font.GetUnderlined() - 0, #convert Bool to an int type face_name = font.GetFaceName() ) #--------------------------------------------------------------------------- # Returns the text representation of the specified object trait value: #--------------------------------------------------------------------------- def str_font ( self, font ): """ Returns the text representation of the specified object trait value. """ import kiva.constants as kc weight = { kc.BOLD: ' Bold' }.get( font.weight, '' ) style = { kc.ITALIC: ' Italic' }.get( font.style, '' ) underline = [ '', ' Underline' ][ font.underline != 0 ] return '%s point %s%s%s%s' % ( font.size, self.face_name( font ), style, weight, underline ) #--------------------------------------------------------------------------- # Returns a list of all available font facenames: #--------------------------------------------------------------------------- def all_facenames ( self ): """ Returns a list of all available font typeface names. """ facenames = fontManager.ttfdict.keys() return facenames def KivaFontEditor (*args, **traits): return ToolkitEditorFactory (*args, **traits) enthought-chaco2-4.5.1.orig/kiva/gl.py0000644000175000017500000003647112516137326016621 0ustar varunvarun from __future__ import absolute_import, print_function # Major library imports import ctypes from math import floor from numpy import array, ndarray # Pyglet and pyglet-related imports # Before we import anything else from pyglet, we need to set the shadow_window # option to False, so that it does not conflict with WX, in case someone is # trying to use the kiva GL GraphicsContext from within WX. # This is necessary as of pyglet 1.1. import pyglet pyglet.options['shadow_window'] = False from pyglet.text import Label from pyglet.font import load as load_font from pyglet.font.base import Font as PygletFont from pyglet import gl from pygarrayimage.arrayimage import ArrayInterfaceImage # Local kiva imports from .affine import affine_from_values, transform_points from .agg import GraphicsContextGL as _GCL from .agg import AggFontType from .agg import CompiledPath from .constants import BOLD, BOLD_ITALIC, ITALIC from .fonttools import Font class ArrayImage(ArrayInterfaceImage): """ pyglet ImageData made from numpy arrays. Customized from pygarrayimage's ArrayInterfaceImage to override the texture creation. """ def create_texture(self, cls, rectangle=False, force_rectangle=False): '''Create a texture containing this image. If the image's dimensions are not powers of 2, a TextureRegion of a larger Texture will be returned that matches the dimensions of this image. :Parameters: `cls` : class (subclass of Texture) Class to construct. `rectangle` : bool ``True`` if a rectangle can be created; see `AbstractImage.get_texture`. :rtype: cls or cls.region_class ''' _is_pow2 = lambda v: (v & (v - 1)) == 0 target = gl.GL_TEXTURE_2D if rectangle and not (_is_pow2(self.width) and _is_pow2(self.height)): if gl.gl_info.have_extension('GL_ARB_texture_rectangle'): target = gl.GL_TEXTURE_RECTANGLE_ARB elif gl.gl_info.have_extension('GL_NV_texture_rectangle'): target = gl.GL_TEXTURE_RECTANGLE_NV texture = cls.create_for_size(target, self.width, self.height) subimage = False if texture.width != self.width or texture.height != self.height: texture = texture.get_region(0, 0, self.width, self.height) subimage = True internalformat = self._get_internalformat(self.format) gl.glBindTexture(texture.target, texture.id) gl.glTexParameteri(texture.target, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE) gl.glTexParameteri(texture.target, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE) gl.glTexParameteri(texture.target, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR) gl.glTexParameteri(texture.target, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR) if subimage: width = texture.owner.width height = texture.owner.height blank = (ctypes.c_ubyte * (width * height * 4))() gl.glTexImage2D(texture.target, texture.level, internalformat, width, height, 1, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, blank) internalformat = None self.blit_to_texture(texture.target, texture.level, 0, 0, 0, internalformat) return texture def blit_to_texture(self, target, level, x, y, z, internalformat=None): '''Draw this image to to the currently bound texture at `target`. If `internalformat` is specified, glTexImage is used to initialise the texture; otherwise, glTexSubImage is used to update a region. ''' data_format = self.format data_pitch = abs(self._current_pitch) # Determine pixel format from format string matrix = None format, type = self._get_gl_format_and_type(data_format) if format is None: if (len(data_format) in (3, 4) and gl.gl_info.have_extension('GL_ARB_imaging')): # Construct a color matrix to convert to GL_RGBA def component_column(component): try: pos = 'RGBA'.index(component) return [0] * pos + [1] + [0] * (3 - pos) except ValueError: return [0, 0, 0, 0] # pad to avoid index exceptions lookup_format = data_format + 'XXX' matrix = (component_column(lookup_format[0]) + component_column(lookup_format[1]) + component_column(lookup_format[2]) + component_column(lookup_format[3])) format = { 3: gl.GL_RGB, 4: gl.GL_RGBA}.get(len(data_format)) type = gl.GL_UNSIGNED_BYTE gl.glMatrixMode(gl.GL_COLOR) gl.glPushMatrix() gl.glLoadMatrixf((gl.GLfloat * 16)(*matrix)) else: # Need to convert data to a standard form data_format = { 1: 'L', 2: 'LA', 3: 'RGB', 4: 'RGBA'}.get(len(data_format)) format, type = self._get_gl_format_and_type(data_format) # Workaround: don't use GL_UNPACK_ROW_LENGTH if gl.current_context._workaround_unpack_row_length: data_pitch = self.width * len(data_format) # Get data in required format (hopefully will be the same format it's # already in, unless that's an obscure format, upside-down or the # driver is old). data = self._convert(data_format, data_pitch) if data_pitch & 0x1: alignment = 1 elif data_pitch & 0x2: alignment = 2 else: alignment = 4 row_length = data_pitch / len(data_format) gl.glPushClientAttrib(gl.GL_CLIENT_PIXEL_STORE_BIT) gl.glPixelStorei(gl.GL_UNPACK_ALIGNMENT, alignment) gl.glPixelStorei(gl.GL_UNPACK_ROW_LENGTH, row_length) self._apply_region_unpack() gl.glTexParameteri(target, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE) gl.glTexParameteri(target, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE) gl.glTexParameteri(target, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR) gl.glTexParameteri(target, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR) if target == gl.GL_TEXTURE_3D: assert not internalformat gl.glTexSubImage3D(target, level, x, y, z, self.width, self.height, 1, format, type, data) elif internalformat: gl.glTexImage2D(target, level, internalformat, self.width, self.height, 0, format, type, data) else: gl.glTexSubImage2D(target, level, x, y, self.width, self.height, format, type, data) gl.glPopClientAttrib() if matrix: gl.glPopMatrix() gl.glMatrixMode(gl.GL_MODELVIEW) def image_as_array(img): """ Adapt an image object into a numpy array. Typically, this is used to adapt an agg GraphicsContextArray which has been used for image storage in Kiva applications. """ if hasattr(img, 'bmp_array'): # Yup, a GraphicsContextArray. return img.bmp_array elif isinstance(img, ndarray): return img else: msg = "can't convert %r into a numpy array" % (img,) raise NotImplementedError(msg) def get_dpi(): """ Returns the appropriate DPI setting for the system""" pass class MRU(dict): def __init__(self, *args, **kw): # An ordering of keys in self; the last item was the most recently used self.__order__ = [] self.__maxlength__ = 30 dict.__init__(self, *args, **kw) def __getitem__(self, key): val = dict.__getitem__(self, key) # If we get here, then key was found in our dict self.__touch__(key) return val def __setitem__(self, key, value): dict.__setitem__(self, key, value) self.__touch__(key) def __delitem__(self, key): dict.__delitem__(self, key) if key in self.__order__: self.__order__.remove(key) def __touch__(self, key): """ Puts **key** as the most recently used item """ if len(self.__order__) == 0: self.__order__.append(key) if (len(self.__order__) == self.__maxlength__) and \ key not in self.__order__: # The MRU is full, so pop the oldest element del self[self.__order__[0]] if key != self.__order__[-1]: try: ndx = self.__order__.index(key) self.__order__[ndx:-1] = self.__order__[ndx+1:] self.__order__[-1] = key except ValueError: # new key that's not already in the cache if len(self.__order__) == self.__maxlength__: self.__order__ = self.__order__[1:] + [key] else: self.__order__.append(key) return # Use a singleton for the font cache GlobalFontCache = MRU() def GetFont(font): """ Returns a Pylget Font object for the given Agg or Kiva font """ if isinstance(font, PygletFont): pyglet_font = font else: # AggFontType key = (font.name, font.size, font.family, font.style) if key not in GlobalFontCache: if isinstance(font, AggFontType): agg_font = font font = Font(face_name=agg_font.name, size=agg_font.size, family=agg_font.family, style=agg_font.style) bold = False italic = False if font.style in [BOLD, BOLD_ITALIC] or font.weight == BOLD: bold = True if font.style in [ITALIC, BOLD_ITALIC]: italic = True pyglet_font = load_font(font.findfontname(), font.size, bold, italic) GlobalFontCache[key] = pyglet_font else: pyglet_font = GlobalFontCache[key] return pyglet_font # Because Pyglet 1.1 uses persistent Label objects to efficiently lay # out and render text, we cache these globally to minimize the creation # time. An MRU is not really the right structure to use here, though. # (We typically expect that the same numbers of labels will be rendered.) GlobalTextCache = MRU() GlobalTextCache.__maxlength__ = 100 def GetLabel(text, pyglet_font): """ Returns a Pyglet Label object for the given text and font """ key = (text, pyglet_font) if key not in GlobalTextCache: # Use anchor_y="bottom" because by default, pyglet sets the baseline to # the y coordinate given. Unfortunately, it doesn't expose a per-Text # descent (only a per-Font descent), so it's impossible to know how to # offset the y value properly for a given string. label = Label(text, font_name=pyglet_font.name, font_size=pyglet_font.size, anchor_y="bottom") GlobalTextCache[key] = label else: label = GlobalTextCache[key] return label class GraphicsContext(_GCL): def __init__(self, size, *args, **kw): # Ignore the pix_format argument for now if "pix_format" in kw: kw.pop("pix_format") _GCL.__init__(self, size[0], size[1], *args, **kw) self.corner_pixel_origin = True self._font_stack = [] self._current_font = None def save_state(self): super(GraphicsContext, self).save_state() self._font_stack.append(self._current_font) def restore_state(self): super(GraphicsContext, self).restore_state() self._current_font = self._font_stack.pop() def set_font(self, font): super(GraphicsContext, self).set_font(font) self._current_font = font def get_text_extent(self, text): if self._current_font is None: return (0, 0, 0, 0) pyglet_font = GetFont(self._current_font) label = GetLabel(text, pyglet_font) return (0, 0, label.content_width, label.content_height) def show_text(self, text, point=None): if point is None: point = (0, 0) return self.show_text_at_point(text, *point) def show_text_at_point(self, text, x, y): if self._current_font is None: return pyglet_font = GetFont(self._current_font) label = GetLabel(text, pyglet_font) xform = self.get_ctm() x0 = xform[4] y0 = xform[5] # The GL backend places the center of a pixel at (0.5, 0.5); however, # for show_text_at_point, we don't actually want to render the text # offset by half a pixel. There is probably a better, more uniform way # to handle this across all of Kiva, because this is probably a common # issue that will arise, but for now, we just round the position down. x = floor(x + x0) y = floor(y + y0) label.x = x label.y = y c = self.get_fill_color() label.color = (int(c[0]*255), int(c[1]*255), int(c[2]*255), int(c[3]*255)) label.draw() return True def linear_gradient(self, x1, y1, x2, y2, stops, spread_method, units='userSpaceOnUse'): """ Not implemented. """ pass def radial_gradient(self, cx, cy, r, fx, fy, stops, spread_method, units='userSpaceOnUse'): """ Not implemented. """ pass def draw_image(self, img, rect=None, force_copy=False): """ Renders a GraphicsContextArray into this GC """ xform = self.get_ctm() image = image_as_array(img) shape = image.shape if shape[2] == 4: fmt = "RGBA" else: fmt = "RGB" aii = ArrayImage(image, format=fmt) texture = aii.texture # The texture coords consists of (u,v,r) for each corner of the # texture rectangle. The coordinates are stored in the order # bottom left, bottom right, top right, top left. x, y, w, h = rect texture.width = w texture.height = h t = texture.tex_coords points = array([ [x, y+h], [x+w, y+h], [x+w, y], [x, y], ]) p = transform_points(affine_from_values(*xform), points) a = (gl.GLfloat*32)( t[0], t[1], t[2], 1., p[0, 0], p[0, 1], 0, 1., t[3], t[4], t[5], 1., p[1, 0], p[1, 1], 0, 1., t[6], t[7], t[8], 1., p[2, 0], p[2, 1], 0, 1., t[9], t[10], t[11], 1., p[3, 0], p[3, 1], 0, 1., ) gl.glPushAttrib(gl.GL_ENABLE_BIT) gl.glEnable(texture.target) gl.glBindTexture(texture.target, texture.id) gl.glPushClientAttrib(gl.GL_CLIENT_VERTEX_ARRAY_BIT) gl.glInterleavedArrays(gl.GL_T4F_V4F, 0, a) gl.glDrawArrays(gl.GL_QUADS, 0, 4) gl.glPopClientAttrib() gl.glPopAttrib() def font_metrics_provider(): return GraphicsContext((1, 1)) enthought-chaco2-4.5.1.orig/kiva/ps.py0000644000175000017500000002720012516137326016627 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2005, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ """ Chaco's PostScript (PS/EPSF) backend :Copyright: ActiveState :License: BSD Style :Author: David Ascher (davida@activestate.com) :Version: $Revision: 1.2 $ """ # Major library imports import os import sys from cStringIO import StringIO from numpy import arange, ravel, array import warnings # Local, relative Kiva imports import affine import basecore2d import constants from constants import * import agg # This backend does not have compiled paths, yet. CompiledPath = None try: import logging import tempfile _logfile = os.path.join(tempfile.gettempdir(), "kivaps.log") hdlr = logging.FileHandler(_logfile) BASIC_FORMAT = "%(levelname)s: %(name)s: %(message)s" fmt = logging.Formatter(BASIC_FORMAT) hdlr.setFormatter(fmt) logging.root.addHandler(hdlr) log = logging.getLogger('') log.setLevel(logging.INFO) except ImportError: class FakeLogger: def debug(self, message): print >> sys.stderr, "DEBUG:", message def info(self, message): print >> sys.stderr, "INFO:", message def warn(self, message): print >> sys.stderr, "WARN:", message def error(self, message): print >> sys.stderr, "ERROR:", message def critical(self, message): print >> sys.stderr, "CRITICAL:", message log = FakeLogger() def _strpoints(points): c = StringIO() for x,y in points: c.write('%3.2f,%3.2f ' % (x,y)) return c.getvalue() def _mkstyle(kw): return '"' + '; '.join([str(k) + ':' + str(v) for k,v in kw.items()]) +'"' def default_filter(kw1): kw = {} for (k,v) in kw1.items(): if type(v) == type(()): if v[0] != v[1]: kw[k] = v[0] else: kw[k] = v return kw line_cap_map = { constants.CAP_BUTT: 0, constants.CAP_ROUND: 1, constants.CAP_SQUARE: 2, } line_join_map = { constants.JOIN_MITER: 0, constants.JOIN_ROUND: 1, constants.JOIN_BEVEL: 2, } font_map = {'Arial': 'Helvetica'} import _fontdata font_map = {'Arial': 'Helvetica'} try: # reportlab supports more fonts import reportlab.pdfbase.pdfmetrics as pdfmetrics import reportlab.pdfbase._fontdata as _fontdata _reportlab_loaded = 1 except ImportError: # we support the basic 14 import pdfmetrics import _fontdata _reportlab_loaded = 0 font_face_map = {'Arial': 'Helvetica', '': 'Helvetica'} _clip_counter = 0 fill_stroke_map = {FILL_STROKE: ('fill', 'stroke'), EOF_FILL_STROKE: ('eofill', 'stroke'), FILL: ('fill', None), STROKE: ('stroke', None), EOF_FILL: ('eofill', None) } class PSGC(basecore2d.GraphicsContextBase): def __init__(self, size, *args, **kwargs): super(PSGC, self).__init__(size, *args, **kwargs) self.size = size self._height = size[1] self.contents = StringIO() self._clipmap = {} self.clip_id = None def clear(self): self.contents = StringIO() def width(self): return self.size[0] def height(self): return self.size[1] def save(self, filename): f = open(filename, 'w') ext = os.path.splitext(filename)[1] if ext in ('.eps', '.epsf'): f.write("%!PS-Adobe-3.0 EPSF-3.0\n") f.write('%%%%BoundingBox: 0 0 %d %d\n' % self.size) f.write(self.contents.getvalue()) elif ext == '.ps': f.write("%!PS-Adobe-2.0\n") f.write(self.contents.getvalue()) else: raise ValueError, "don't know how to write a %s file" % ext # Text handling code def set_font(self, font): self.face_name = font_face_map.get(font.face_name, font.face_name) self.font = pdfmetrics.Font(self.face_name, self.face_name, pdfmetrics.defaultEncoding) self.font_size = font.size self.contents.write("""/%s findfont %3.3f scalefont setfont\n""" % (self.face_name, self.font_size)) def device_show_text(self, text): ttm = self.get_text_matrix() ctm = self.get_ctm() # not device_ctm!! m = affine.concat(ctm,ttm) if self.state.clipping_path: self.contents.write('clipsave\n') self.contents.write('%3.3f %3.3f %3.3f %3.3f rectclip\n' % self.state.clipping_path) self.contents.write('gsave\n') self.device_transform_device_ctm(LOAD_CTM, [m]) self.contents.write('%3.3f %3.3f moveto\n' % (0,0)) r,g,b,a = self.state.line_color self.contents.write('%1.3f %1.3f %1.3f setrgbcolor\n' % (r,g,b) ) self.contents.write('(%s) show\n' % text) self.contents.write('grestore\n') if self.state.clipping_path: self.contents.write('cliprestore\n') def get_full_text_extent(self, text): ascent,descent=_fontdata.ascent_descent[self.face_name] descent = (-descent) * self.font_size / 1000.0 ascent = ascent * self.font_size / 1000.0 height = ascent + descent width = pdfmetrics.stringWidth(text, self.face_name, self.font_size) return width, height, descent, height*1.2 # assume leading of 1.2*height # actual implementation =) def device_draw_image(self, img, rect): """ draw_image(img_gc, rect=(x,y,w,h)) Draws another gc into this one. If 'rect' is not provided, then the image gc is drawn into this one, rooted at (0,0) and at full pixel size. If 'rect' is provided, then the image is resized into the (w,h) given and drawn into this GC at point (x,y). img_gc is either a Numeric array (WxHx3 or WxHx4) or a GC from Kiva's Agg backend (kiva.agg.GraphicsContextArray). Requires the Python Imaging Library (PIL). """ from PIL import Image as PilImage if type(img) == type(array([])): # Numeric array converted_img = agg.GraphicsContextArray(img, pix_format='rgba32') format = 'RGBA' elif isinstance(img, agg.GraphicsContextArray): if img.format().startswith('RGBA'): format = 'RGBA' elif img.format().startswith('RGB'): format = 'RGB' else: converted_img = img.convert_pixel_format('rgba32', inplace=0) format = 'RGBA' # Should probably take this into account # interp = img.get_image_interpolation() else: warnings.warn("Cannot render image of type %r into EPS context." % type(img)) return # converted_img now holds an Agg graphics context with the image pil_img = PilImage.fromstring(format, (converted_img.width(), converted_img.height()), converted_img.bmp_array.tostring()) if rect == None: rect = (0, 0, img.width(), img.height()) # PIL PS output doesn't support alpha. if format != 'RGB': pil_img = pil_img.convert('RGB') left, top, width, height = rect if width != img.width() or height != img.height(): # This is not strictly required. pil_img = pil_img.resize((int(width), int(height)), PilImage.NEAREST) self.contents.write('gsave\n') self.contents.write('initmatrix\n') m = self.get_ctm() self.contents.write('[%.3f %.3f %.3f %.3f %.3f %.3f] concat\n' % \ affine.affine_params(m)) self.contents.write('%.3f %.3f translate\n' % (left, top)) # Rely on PIL's EpsImagePlugin to do the hard work here. pil_img.save(self.contents, 'eps', eps=0) self.contents.write('grestore\n') def device_transform_device_ctm(self,func,args): if func == LOAD_CTM: self.contents.write('initmatrix\n') func = CONCAT_CTM if func == SCALE_CTM: sx, sy = args self.contents.write('%.3f %.3f scale\n' % (sx, sy)) elif func == ROTATE_CTM: r, = args self.contents.write('%.3f rotate\n' % r) elif func == TRANSLATE_CTM: tx, ty = args self.contents.write('%.3f %.3f translate\n' % (tx, ty)) elif func == CONCAT_CTM: m, = args self.contents.write('[%.3f %.3f %.3f %.3f %.3f %.3f] concat\n' % \ affine.affine_params(m)) def device_fill_points(self, points, mode): if self.state.clipping_path: self.contents.write('clipsave\n') self.contents.write('%3.3f %3.3f %3.3f %3.3f rectclip\n' % self.state.clipping_path) linecap = line_cap_map[self.state.line_cap] linejoin = line_join_map[self.state.line_join] dasharray = self._dasharray() if dasharray: self.contents.write('%s 0 setdash\n' % dasharray) self.contents.write('%3.3f setlinewidth\n' % self.state.line_width) self.contents.write('%d setlinecap\n' % linecap) self.contents.write('%d setlinejoin\n' % linejoin) self.contents.write('newpath\n') x,y = points[0] self.contents.write(' %3.3f %3.3f moveto\n' % (x,y)) for (x,y) in points[1:]: self.contents.write(' %3.3f %3.3f lineto\n' % (x,y)) first_pass, second_pass = fill_stroke_map[mode] if second_pass: if first_pass in ('fill', 'eofill'): r,g,b,a = self.state.fill_color self.contents.write('%1.3f %1.3f %1.3f setrgbcolor\n' % (r,g,b) ) else: r,g,b,a = self.state.line_color self.contents.write('%1.3f %1.3f %1.3f setrgbcolor\n' % (r,g,b) ) self.contents.write('gsave %s grestore %s\n' % (first_pass, second_pass)) else: if first_pass in ('fill', 'eofill'): r,g,b,a = self.state.fill_color self.contents.write('%1.3f %1.3f %1.3f setrgbcolor\n' % (r,g,b) ) else: r,g,b,a = self.state.line_color self.contents.write('%1.3f %1.3f %1.3f setrgbcolor\n' % (r,g,b) ) self.contents.write(first_pass + '\n') if self.state.clipping_path: self.contents.write('cliprestore\n') def device_stroke_points(self, points, mode): # handled by device_fill_points pass def device_set_clipping_path(self, x, y, width, height): pass def device_destroy_clipping_path(self): pass # utility routines def _color(self, color): r,g,b,a = color return '#%02x%02x%02x' % (r*255,g*255,b*255) def _dasharray(self): dasharray = '' for x in self.state.line_dash: if type(x) == type(arange(3)): # why is this so hard? x = ravel(x)[0] dasharray += ' ' + '%3.2f' % x if not dasharray or dasharray == " 0.00 0.00": return '[]' return '[ ' + dasharray + ' ]' # noops which seem to be needed def device_update_line_state(self): pass def device_update_fill_state(self): pass enthought-chaco2-4.5.1.orig/kiva/fonttools/0000755000175000017500000000000012564247427017670 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/fonttools/afm.py0000644000175000017500000002705012516137326021002 0ustar varunvarun""" This is a python interface to Adobe Font Metrics Files. Although a number of other python implementations exist (and may be more complete than mine) I decided not to go with them because either they were either 1) copyighted or used a non-BSD compatible license 2) had too many dependencies and I wanted a free standing lib 3) Did more than I needed and it was easier to write my own than figure out how to just get what I needed from theirs It is pretty easy to use, and requires only built-in python libs >>> from afm import AFM >>> fh = file('ptmr8a.afm') >>> afm = AFM(fh) >>> afm.string_width_height('What the heck?') (6220.0, 683) >>> afm.get_fontname() 'Times-Roman' >>> afm.get_kern_dist('A', 'f') 0 >>> afm.get_kern_dist('A', 'y') -92.0 >>> afm.get_bbox_char('!') [130, -9, 238, 676] >>> afm.get_bbox_font() [-168, -218, 1000, 898] AUTHOR: John D. Hunter """ from __future__ import absolute_import, print_function import os import logging logger = logging.getLogger(__name__) # Convert value to a python type _to_int = int _to_float = float _to_str = str def _to_list_of_ints(s): s = s.replace(',', ' ') return [_to_int(val) for val in s.split()] def _to_list_of_floats(s): return [_to_float(val) for val in s.split()] def _to_bool(s): return s.lower().strip() in ('false', '0', 'no') def _parse_header(fh): """ Reads the font metrics header (up to the char metrics) and returns a dictionary mapping key to val. val will be converted to the appropriate python type as necessary; eg 'False'->False, '0'->0, '-168 -218 1000 898'-> [-168, -218, 1000, 898] Dictionary keys are StartFontMetrics, FontName, FullName, FamilyName, Weight, ItalicAngle, IsFixedPitch, FontBBox, UnderlinePosition, UnderlineThickness, Version, Notice, EncodingScheme, CapHeight, XHeight, Ascender, Descender, StartCharMetrics """ headerConverters = { 'StartFontMetrics': _to_float, 'FontName': _to_str, 'FullName': _to_str, 'FamilyName': _to_str, 'Weight': _to_str, 'ItalicAngle': _to_float, 'IsFixedPitch': _to_bool, 'FontBBox': _to_list_of_ints, 'UnderlinePosition': _to_int, 'UnderlineThickness': _to_int, 'Version': _to_str, 'Notice': _to_str, 'EncodingScheme': _to_str, 'CapHeight': _to_float, 'XHeight': _to_float, 'Ascender': _to_float, 'Descender': _to_float, 'StartCharMetrics': _to_int, 'Characters': _to_int, 'Capheight': _to_int, } d = {} while True: line = fh.readline() if not line: break line = line.rstrip() if line.startswith('Comment'): continue lst = line.split(' ', 1) key = lst[0] if len(lst) == 2: val = lst[1] else: val = '' try: d[key] = headerConverters[key](val) except ValueError: msg = 'Value error parsing header in AFM: {} {}'.format(key, val) logger.error(msg) continue except KeyError: logging.error('Key error converting in AFM') continue if key == 'StartCharMetrics': return d raise RuntimeError('Bad parse') def _parse_char_metrics(fh): """ Return a character metric dictionary. Keys are the ASCII num of the character, values are a (wx, name, bbox) tuple, where wx is the character width name is the postscript language name bbox (llx, lly, urx, ury) This function is incomplete per the standard, but thus far parse all the sample afm files I have """ d = {} while 1: line = fh.readline() if not line: break line = line.rstrip() if line.startswith('EndCharMetrics'): return d vals = line.split(';')[:4] if len(vals) != 4: raise RuntimeError('Bad char metrics line: %s' % line) num = _to_int(vals[0].split()[1]) if num == -1: continue wx = _to_float(vals[1].split()[1]) name = vals[2].split()[1] bbox = _to_list_of_ints(vals[3][2:]) d[num] = (wx, name, bbox) raise RuntimeError('Bad parse') def _parse_kern_pairs(fh): """ Return a kern pairs dictionary; keys are (char1, char2) tuples and values are the kern pair value. For example, a kern pairs line like KPX A y -50 will be represented as d[ ('A', 'y') ] = -50 """ line = fh.readline() if not line.startswith('StartKernPairs'): raise RuntimeError('Bad start of kern pairs data: %s' % line) d = {} while 1: line = fh.readline() if not line: break line = line.rstrip() if len(line) == 0: continue if line.startswith('EndKernPairs'): fh.readline() # EndKernData return d vals = line.split() if len(vals) != 4 or vals[0] != 'KPX': raise RuntimeError('Bad kern pairs line: %s' % line) c1, c2, val = vals[1], vals[2], _to_float(vals[3]) d[(c1, c2)] = val raise RuntimeError('Bad kern pairs parse') def _parse_composites(fh): """ Return a composites dictionary. Keys are the names of the composites. vals are a num parts list of composite information, with each element being a (name, dx, dy) tuple. Thus if a composites line reading: CC Aacute 2 ; PCC A 0 0 ; PCC acute 160 170 ; will be represented as d['Aacute'] = [ ('A', 0, 0), ('acute', 160, 170) ] """ d = {} while 1: line = fh.readline() if not line: break line = line.rstrip() if len(line) == 0: continue if line.startswith('EndComposites'): return d vals = line.split(';') cc = vals[0].split() name = cc[1] pccParts = [] for s in vals[1:-1]: pcc = s.split() name, dx, dy = pcc[1], _to_float(pcc[2]), _to_float(pcc[3]) pccParts.append((name, dx, dy)) d[name] = pccParts raise RuntimeError('Bad composites parse') def _parse_optional(fh): """ Parse the optional fields for kern pair data and composites return value is a kernDict, compositeDict which are the return values from parse_kern_pairs, and parse_composites if the data exists, or empty dicts otherwise """ optional = { 'StartKernData': _parse_kern_pairs, 'StartComposites': _parse_composites, } d = {'StartKernData': {}, 'StartComposites': {}} while 1: line = fh.readline() if not line: break line = line.rstrip() if len(line) == 0: continue key = line.split()[0] if key in optional: d[key] = optional[key](fh) l = (d['StartKernData'], d['StartComposites']) return l def parse_afm(fh): """ Parse the Adobe Font Metics file in file handle fh Return value is a (dhead, dcmetrics, dkernpairs, dcomposite) tuple where dhead : a parse_header dict dcmetrics : a parse_composites dict dkernpairs : a parse_kern_pairs dict, possibly {} dcomposite : a parse_composites dict , possibly {} """ dhead = _parse_header(fh) dcmetrics = _parse_char_metrics(fh) doptional = _parse_optional(fh) return dhead, dcmetrics, doptional[0], doptional[1] class AFM(object): def __init__(self, fh): """ Parse the AFM file in file object fh """ (dhead, dcmetrics, dkernpairs, dcomposite) = parse_afm(fh) self._header = dhead self._kern = dkernpairs self._metrics = dcmetrics self._composite = dcomposite def get_bbox_char(self, c, isord=False): if not isord: c = ord(c) wx, name, bbox = self._metrics[c] return bbox def string_width_height(self, s): """ Return the string width (including kerning) and string height as a w,h tuple """ if not len(s): return (0, 0) totalw = 0 namelast = None miny = 1e9 maxy = 0 for c in s: if c == '\n': continue wx, name, bbox = self._metrics[ord(c)] l, b, w, h = bbox # find the width with kerning try: kp = self._kern[(namelast, name)] except KeyError: kp = 0 totalw += wx + kp # find the max y thismax = b+h if thismax > maxy: maxy = thismax # find the min y thismin = b if thismin < miny: miny = thismin return totalw, maxy-miny def get_str_bbox(self, s): """ Return the string bounding box """ if not len(s): return (0, 0, 0, 0) totalw = 0 namelast = None miny = 1e9 maxy = 0 left = 0 for c in s: if c == '\n': continue wx, name, bbox = self._metrics[ord(c)] l, b, w, h = bbox if l < left: left = l # find the width with kerning try: kp = self._kern[(namelast, name)] except KeyError: kp = 0 totalw += wx + kp # find the max y thismax = b+h if thismax > maxy: maxy = thismax # find the min y thismin = b if thismin < miny: miny = thismin return left, miny, totalw, maxy-miny def get_name_char(self, c): """ Get the name of the character, ie, ';' is 'semicolon' """ wx, name, bbox = self._metrics[ord(c)] return name def get_width_char(self, c, isord=False): """ Get the width of the character from the character metric WX field """ if not isord: c = ord(c) wx, name, bbox = self._metrics[c] return wx def get_height_char(self, c, isord=False): """ Get the height of character c from the bounding box. This is the ink height (space is 0) """ if not isord: c = ord(c) wx, name, bbox = self._metrics[c] return bbox[-1] def get_kern_dist(self, c1, c2): """ Return the kerning pair distance (possibly 0) for chars c1 and c2 """ name1, name2 = self.get_name_char(c1), self.get_name_char(c2) try: return self._kern[(name1, name2)] except: return 0 def get_fontname(self): "Return the font name, eg, Times-Roman" return self._header['FontName'] def get_fullname(self): "Return the font full name, eg, Times-Roman" return self._header['FullName'] def get_familyname(self): "Return the font family name, eg, Times" return self._header['FamilyName'] def get_weight(self): "Return the font weight, eg, 'Bold' or 'Roman'" return self._header['Weight'] def get_angle(self): "Return the fontangle as float" return self._header['ItalicAngle'] if __name__ == '__main__': pathname = '/usr/local/share/fonts/afms/adobe' for fname in os.listdir(pathname): fh = file(os.path.join(pathname, fname)) afm = AFM(fh) w, h = afm.string_width_height('John Hunter is the Man!') enthought-chaco2-4.5.1.orig/kiva/fonttools/font_manager.py0000644000175000017500000013102612516137326022676 0ustar varunvarun""" ####### NOTE ####### This is based heavily on matplotlib's font_manager.py rev 8713, but has been modified to not use other matplotlib modules #################### A module for finding, managing, and using fonts across platforms. This module provides a single :class:`FontManager` instance that can be shared across backends and platforms. The :func:`findfont` function returns the best TrueType (TTF) font file in the local or system font path that matches the specified :class:`FontProperties` instance. The :class:`FontManager` also handles Adobe Font Metrics (AFM) font files for use by the PostScript backend. The design is based on the `W3C Cascading Style Sheet, Level 1 (CSS1) font specification `_. Future versions may implement the Level 2 or 2.1 specifications. Experimental support is included for using `fontconfig` on Unix variant platforms (Linux, OS X, Solaris). To enable it, set the constant ``USE_FONTCONFIG`` in this file to ``True``. Fontconfig has the advantage that it is the standard way to look up fonts on X11 platforms, so if a font is installed, it is much more likely to be found. KNOWN ISSUES - documentation - font variant is untested - font stretch is incomplete - font size is incomplete - font size_adjust is incomplete - default font algorithm needs improvement and testing - setWeights function needs improvement - 'light' is an invalid weight value, remove it. - update_fonts not implemented Authors : John Hunter Paul Barrett Michael Droettboom Copyright : John Hunter (2004,2005), Paul Barrett (2004,2005) License : matplotlib license (PSF compatible) The font directory code is from ttfquery, see license/LICENSE_TTFQUERY. """ from __future__ import absolute_import, print_function import os import sys import glob import subprocess import warnings import tempfile import errno try: import cPickle as pickle except ImportError: import pickle from traits.etsconfig.api import ETSConfig from kiva.fonttools.fontTools.ttLib import TTFont, TTLibError from kiva.fonttools import afm USE_FONTCONFIG = False font_scalings = { 'xx-small': 0.579, 'x-small': 0.694, 'small': 0.833, 'medium': 1.0, 'large': 1.200, 'x-large': 1.440, 'xx-large': 1.728, 'larger': 1.2, 'smaller': 0.833, None: 1.0 } stretch_dict = { 'ultra-condensed': 100, 'extra-condensed': 200, 'condensed': 300, 'semi-condensed': 400, 'normal': 500, 'semi-expanded': 600, 'expanded': 700, 'extra-expanded': 800, 'ultra-expanded': 900 } weight_dict = { 'ultralight': 100, 'light': 200, 'normal': 400, 'regular': 400, 'book': 400, 'medium': 500, 'roman': 500, 'semibold': 600, 'demibold': 600, 'demi': 600, 'bold': 700, 'heavy': 800, 'extra bold': 800, 'black': 900 } font_family_aliases = set(['serif', 'sans-serif', 'sans serif', 'cursive', 'fantasy', 'monospace', 'sans']) # OS Font paths MSFolders = \ r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders' MSFontDirectories = [ r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts', r'SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts' ] X11FontDirectories = [ # an old standard installation point "/usr/X11R6/lib/X11/fonts/TTF/", # here is the new standard location for fonts "/usr/share/fonts/", # documented as a good place to install new fonts "/usr/local/share/fonts/", # common application, not really useful "/usr/lib/openoffice/share/fonts/truetype/", ] OSXFontDirectories = [ "/Library/Fonts/", "/Network/Library/Fonts/", "/System/Library/Fonts/" ] if not USE_FONTCONFIG: home = os.environ.get('HOME') if home is not None: # user fonts on OSX path = os.path.join(home, 'Library', 'Fonts') OSXFontDirectories.append(path) path = os.path.join(home, '.fonts') X11FontDirectories.append(path) ############################################################################### # functions to replace those that matplotlib ship in different modules ############################################################################### preferred_fonts = { 'fantasy': ['Comic Sans MS', 'Chicago', 'Charcoal', 'ImpactWestern', 'fantasy'], 'cursive': ['Apple Chancery', 'Textile', 'Zapf Chancery', 'Sand', 'cursive'], 'monospace': ['Bitstream Vera Sans Mono', 'DejaVu Sans Mono', 'Andale Mono', 'Nimbus Mono L', 'Courier New', 'Courier', 'Fixed', 'Terminal', 'monospace'], 'serif': ['Bitstream Vera Serif', 'DejaVu Serif', 'New Century Schoolbook', 'Century Schoolbook L', 'Utopia', 'ITC Bookman', 'Bookman', 'Nimbus Roman No9 L', 'Times New Roman', 'Times', 'Palatino', 'Charter', 'serif'], 'sans-serif': ['Bitstream Vera Sans', 'DejaVu Sans', 'Lucida Grande', 'Verdana', 'Geneva', 'Lucid', 'Arial', 'Helvetica', 'Avant Garde', 'sans-serif'] } class verbose(object): ''' class to fake matplotlibs verbose module. No idea why logging module isnt used instead ''' @staticmethod def report(text, level='info'): return def _is_writable_dir(p): """ p is a string pointing to a putative writable dir -- return True p is such a string, else False """ if not isinstance(p, basestring): return False try: t = tempfile.TemporaryFile(dir=p) t.write('kiva.test') t.close() except OSError: return False else: return True def get_configdir(): """ Return the string representing the configuration dir. If s is the special string _default_, use HOME/.kiva. s must be writable """ p = os.path.join(ETSConfig.application_data, 'kiva') try: os.makedirs(p) except OSError, e: if e.errno != errno.EEXIST: raise if not _is_writable_dir(p): raise IOError('Configuration directory %s must be writable' % p) return p def is_string_like(obj): 'Return True if *obj* looks like a string' from numpy import ma if isinstance(obj, basestring): return True # numpy strings are subclass of str, ma strings are not if ma.isMaskedArray(obj): if obj.ndim == 0 and obj.dtype.kind in 'SU': return True else: return False try: obj + '' except: return False return True def getPropDict(font): n = font['name'] propdict = {} for prop in n.names: prop_key = (prop.platformID, prop.platEncID, prop.langID, prop.nameID) propdict[prop_key] = prop.string return propdict ############################################################################### # matplotlib code below ############################################################################### synonyms = {'ttf': ('ttf', 'otf'), 'otf': ('ttf', 'otf'), 'afm': ('afm',)} def get_fontext_synonyms(fontext): """ Return a list of file extensions extensions that are synonyms for the given file extension *fileext*. """ return synonyms[fontext] def win32FontDirectory(): """ Return the user-specified font directory for Win32. This is looked up from the registry key:: \\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Fonts # noqa If the key is not found, $WINDIR/Fonts will be returned. """ try: import _winreg except ImportError: pass # Fall through to default else: try: user = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, MSFolders) try: try: return _winreg.QueryValueEx(user, 'Fonts')[0] except OSError: pass # Fall through to default finally: _winreg.CloseKey(user) except OSError: pass # Fall through to default return os.path.join(os.environ['WINDIR'], 'Fonts') def win32InstalledFonts(directory=None, fontext='ttf'): """ Search for fonts in the specified font directory, or use the system directories if none given. A list of TrueType font filenames are returned by default, or AFM fonts if *fontext* == 'afm'. """ import _winreg if directory is None: directory = win32FontDirectory() fontext = get_fontext_synonyms(fontext) key, items = None, {} for fontdir in MSFontDirectories: try: local = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, fontdir) except OSError: continue if not local: files = [] for ext in fontext: files.extend(glob.glob(os.path.join(directory, '*.'+ext))) return files try: for j in range(_winreg.QueryInfoKey(local)[1]): try: key, direc, any = _winreg.EnumValue(local, j) if not os.path.dirname(direc): direc = os.path.join(directory, direc) direc = os.path.abspath(direc).lower() if os.path.splitext(direc)[1][1:] in fontext: items[direc] = 1 except EnvironmentError: continue except WindowsError: continue return items.keys() finally: _winreg.CloseKey(local) return None def OSXFontDirectory(): """ Return the system font directories for OS X. This is done by starting at the list of hardcoded paths in :attr:`OSXFontDirectories` and returning all nested directories within them. """ fontpaths = [] def add(arg, directory, files): fontpaths.append(directory) for fontdir in OSXFontDirectories: try: if os.path.isdir(fontdir): os.path.walk(fontdir, add, None) except (IOError, OSError, TypeError, ValueError): pass return fontpaths def OSXInstalledFonts(directory=None, fontext='ttf'): """ Get list of font files on OS X - ignores font suffix by default. """ if directory is None: directory = OSXFontDirectory() fontext = get_fontext_synonyms(fontext) files = [] for path in directory: if fontext is None: files.extend(glob.glob(os.path.join(path, '*'))) else: for ext in fontext: files.extend(glob.glob(os.path.join(path, '*.'+ext))) files.extend(glob.glob(os.path.join(path, '*.'+ext.upper()))) return files def x11FontDirectory(): """ Return the system font directories for X11. This is done by starting at the list of hardcoded paths in :attr:`X11FontDirectories` and returning all nested directories within them. """ fontpaths = [] def add(arg, directory, files): fontpaths.append(directory) for fontdir in X11FontDirectories: try: if os.path.isdir(fontdir): os.path.walk(fontdir, add, None) except (IOError, OSError, TypeError, ValueError): pass return fontpaths def get_fontconfig_fonts(fontext='ttf'): """ Grab a list of all the fonts that are being tracked by fontconfig by making a system call to ``fc-list``. This is an easy way to grab all of the fonts the user wants to be made available to applications, without needing knowing where all of them reside. """ fontext = get_fontext_synonyms(fontext) fontfiles = {} try: pipe = subprocess.Popen(['fc-list', '', 'file'], stdout=subprocess.PIPE) output = pipe.communicate()[0] except OSError: # Calling fc-list did not work, so we'll just return nothing return fontfiles if pipe.returncode == 0: for line in output.split('\n'): fname = line.split(':')[0] if (os.path.splitext(fname)[1][1:] in fontext and os.path.exists(fname)): fontfiles[fname] = 1 return fontfiles def findSystemFonts(fontpaths=None, fontext='ttf'): """ Search for fonts in the specified font paths. If no paths are given, will use a standard set of system paths, as well as the list of fonts tracked by fontconfig if fontconfig is installed and available. A list of TrueType fonts are returned by default with AFM fonts as an option. """ fontfiles = {} fontexts = get_fontext_synonyms(fontext) if fontpaths is None: if sys.platform == 'win32': fontdir = win32FontDirectory() fontpaths = [fontdir] # now get all installed fonts directly... for f in win32InstalledFonts(fontdir): base, ext = os.path.splitext(f) if len(ext) > 1 and ext[1:].lower() in fontexts: fontfiles[f] = 1 else: fontpaths = x11FontDirectory() # check for OS X & load its fonts if present if sys.platform == 'darwin': for f in OSXInstalledFonts(fontext=fontext): fontfiles[f] = 1 for f in get_fontconfig_fonts(fontext): fontfiles[f] = 1 elif isinstance(fontpaths, (str, unicode)): fontpaths = [fontpaths] for path in fontpaths: files = [] for ext in fontexts: files.extend(glob.glob(os.path.join(path, '*.'+ext))) files.extend(glob.glob(os.path.join(path, '*.'+ext.upper()))) for fname in files: abs_path = os.path.abspath(fname) # Handle dirs which look like font files, but may contain font # files if os.path.isdir(abs_path): fontpaths.append(abs_path) else: fontfiles[abs_path] = 1 return [fname for fname in fontfiles.keys() if os.path.exists(fname)] def weight_as_number(weight): """ Return the weight property as a numeric value. String values are converted to their corresponding numeric value. """ if isinstance(weight, str): try: weight = weight_dict[weight.lower()] except KeyError: weight = 400 elif weight in range(100, 1000, 100): pass else: raise ValueError('weight not a valid integer') return weight class FontEntry(object): """ A class for storing Font properties. It is used when populating the font lookup dictionary. """ def __init__(self, fname='', name='', style='normal', variant='normal', weight='normal', stretch='normal', size='medium'): self.fname = fname self.name = name self.style = style self.variant = variant self.weight = weight self.stretch = stretch try: self.size = str(float(size)) except ValueError: self.size = size def __repr__(self): return "" % ( self.name, os.path.basename(self.fname), self.style, self.variant, self.weight, self.stretch) def ttfFontProperty(fpath, font): """ A function for populating the :class:`FontKey` by extracting information from the TrueType font file. *font* is a :class:`FT2Font` instance. """ props = getPropDict(font) name = props[(1, 0, 0, 1)] # Styles are: italic, oblique, and normal (default) try: sfnt2 = props[(1, 0, 0, 2)] except: sfnt2 = None try: sfnt4 = props[(1, 0, 0, 4)] except: sfnt4 = None if sfnt2: sfnt2 = sfnt2.lower() else: sfnt2 = '' if sfnt4: sfnt4 = sfnt4.lower() else: sfnt4 = '' if sfnt4.find('oblique') >= 0: style = 'oblique' elif sfnt4.find('italic') >= 0: style = 'italic' elif sfnt2.find('regular') >= 0: style = 'normal' else: style = 'normal' # Variants are: small-caps and normal (default) # !!!! Untested if name.lower() in ['capitals', 'small-caps']: variant = 'small-caps' else: variant = 'normal' # Weights are: 100, 200, 300, 400 (normal: default), 500 (medium), # 600 (semibold, demibold), 700 (bold), 800 (heavy), 900 (black) # lighter and bolder are also allowed. weight = None for w in weight_dict.keys(): if sfnt4.find(w) >= 0: weight = w break if not weight: weight = 400 weight = weight_as_number(weight) # Stretch can be absolute and relative # Absolute stretches are: ultra-condensed, extra-condensed, condensed, # semi-condensed, normal, semi-expanded, expanded, extra-expanded, # and ultra-expanded. # Relative stretches are: wider, narrower # Child value is: inherit if (sfnt4.find('narrow') >= 0 or sfnt4.find('condensed') >= 0 or sfnt4.find('cond') >= 0): stretch = 'condensed' elif sfnt4.find('demi cond') >= 0: stretch = 'semi-condensed' elif sfnt4.find('wide') >= 0 or sfnt4.find('expanded') >= 0: stretch = 'expanded' else: stretch = 'normal' # Sizes can be absolute and relative. # Absolute sizes are: xx-small, x-small, small, medium, large, x-large, # and xx-large. # Relative sizes are: larger, smaller # Length value is an absolute font size, e.g. 12pt # Percentage values are in 'em's. Most robust specification. # !!!! Incomplete size = 'scalable' return FontEntry(fpath, name, style, variant, weight, stretch, size) def afmFontProperty(fontpath, font): """ A function for populating a :class:`FontKey` instance by extracting information from the AFM font file. *font* is a class:`AFM` instance. """ name = font.get_familyname() fontname = font.get_fontname().lower() # Styles are: italic, oblique, and normal (default) if font.get_angle() != 0 or name.lower().find('italic') >= 0: style = 'italic' elif name.lower().find('oblique') >= 0: style = 'oblique' else: style = 'normal' # Variants are: small-caps and normal (default) # !!!! Untested if name.lower() in ['capitals', 'small-caps']: variant = 'small-caps' else: variant = 'normal' # Weights are: 100, 200, 300, 400 (normal: default), 500 (medium), # 600 (semibold, demibold), 700 (bold), 800 (heavy), 900 (black) # lighter and bolder are also allowed. weight = weight_as_number(font.get_weight().lower()) # Stretch can be absolute and relative # Absolute stretches are: ultra-condensed, extra-condensed, condensed, # semi-condensed, normal, semi-expanded, expanded, extra-expanded, # and ultra-expanded. # Relative stretches are: wider, narrower # Child value is: inherit if (fontname.find('narrow') >= 0 or fontname.find('condensed') >= 0 or fontname.find('cond') >= 0): stretch = 'condensed' elif fontname.find('demi cond') >= 0: stretch = 'semi-condensed' elif fontname.find('wide') >= 0 or fontname.find('expanded') >= 0: stretch = 'expanded' else: stretch = 'normal' # Sizes can be absolute and relative. # Absolute sizes are: xx-small, x-small, small, medium, large, x-large, # and xx-large. # Relative sizes are: larger, smaller # Length value is an absolute font size, e.g. 12pt # Percentage values are in 'em's. Most robust specification. # All AFM fonts are apparently scalable. size = 'scalable' return FontEntry(fontpath, name, style, variant, weight, stretch, size) def createFontList(fontfiles, fontext='ttf'): """ A function to create a font lookup list. The default is to create a list of TrueType fonts. An AFM font list can optionally be created. """ fontlist = [] # Add fonts from list of known font files. seen = {} for fpath in fontfiles: verbose.report('createFontDict: %s' % (fpath), 'debug') fname = os.path.split(fpath)[1] if fname in seen: continue else: seen[fname] = 1 if fontext == 'afm': try: fh = open(fpath, 'r') except: verbose.report("Could not open font file %s" % fpath) continue try: try: font = afm.AFM(fh) finally: fh.close() except RuntimeError: verbose.report("Could not parse font file %s" % fpath) continue try: prop = afmFontProperty(fpath, font) except: continue else: try: font = TTFont(str(fpath)) except (RuntimeError, TTLibError): verbose.report("Could not open font file %s" % fpath) continue except UnicodeError: verbose.report("Cannot handle unicode filenames") continue try: prop = ttfFontProperty(fpath, font) except: continue fontlist.append(prop) return fontlist class FontProperties(object): """ A class for storing and manipulating font properties. The font properties are those described in the `W3C Cascading Style Sheet, Level 1 `_ font specification. The six properties are: - family: A list of font names in decreasing order of priority. The items may include a generic font family name, either 'serif', 'sans-serif', 'cursive', 'fantasy', or 'monospace'. In that case, the actual font to be used will be looked up from the associated rcParam in :file:`matplotlibrc`. - style: Either 'normal', 'italic' or 'oblique'. - variant: Either 'normal' or 'small-caps'. - stretch: A numeric value in the range 0-1000 or one of 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded' or 'ultra-expanded' - weight: A numeric value in the range 0-1000 or one of 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black' - size: Either an relative value of 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large' or an absolute font size, e.g. 12 The default font property for TrueType fonts (as specified in the default :file:`matplotlibrc` file) is:: sans-serif, normal, normal, normal, normal, scalable. Alternatively, a font may be specified using an absolute path to a .ttf file, by using the *fname* kwarg. The preferred usage of font sizes is to use the relative values, e.g. 'large', instead of absolute font sizes, e.g. 12. This approach allows all text sizes to be made larger or smaller based on the font manager's default font size. This class will also accept a `fontconfig `_ pattern, if it is the only argument provided. See the documentation on `fontconfig patterns `_. This support does not require fontconfig to be installed. We are merely borrowing its pattern syntax for use here. Note that matplotlib's internal font manager and fontconfig use a different algorithm to lookup fonts, so the results of the same pattern may be different in matplotlib than in other applications that use fontconfig. """ def __init__(self, family=None, style=None, variant=None, weight=None, stretch=None, size=None, fname=None, _init=None): # if fname is set, it's a hardcoded filename to use # _init is used only by copy() self._family = None self._slant = None self._variant = None self._weight = None self._stretch = None self._size = None self._file = None # This is used only by copy() if _init is not None: self.__dict__.update(_init.__dict__) return if is_string_like(family): # Treat family as a fontconfig pattern if it is the only # parameter provided. if (style is None and variant is None and weight is None and stretch is None and size is None and fname is None): self.set_fontconfig_pattern(family) return self.set_family(family) self.set_style(style) self.set_variant(variant) self.set_weight(weight) self.set_stretch(stretch) self.set_file(fname) self.set_size(size) def __hash__(self): l = [(k, getattr(self, "get" + k)()) for k in sorted(self.__dict__)] return hash(repr(l)) def __str__(self): return str((self._family, self._slant, self._variant, self._weight, self._stretch, self._size)) def get_family(self): """ Return a list of font names that comprise the font family. """ return self._family def get_name(self): """ Return the name of the font that best matches the font properties. """ filename = str(fontManager.findfont(self)) if filename.endswith('.afm'): return afm.AFM(file(filename)).get_familyname() font = fontManager.findfont(self) return getPropDict(TTFont(str(font)))[(1, 0, 0, 1)] def get_style(self): """ Return the font style. Values are: 'normal', 'italic' or 'oblique'. """ return self._slant get_slant = get_style def get_variant(self): """ Return the font variant. Values are: 'normal' or 'small-caps'. """ return self._variant def get_weight(self): """ Set the font weight. Options are: A numeric value in the range 0-1000 or one of 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black' """ return self._weight def get_stretch(self): """ Return the font stretch or width. Options are: 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'. """ return self._stretch def get_size(self): """ Return the font size. """ return self._size def get_size_in_points(self): if self._size is not None: try: return float(self._size) except ValueError: pass default_size = fontManager.get_default_size() return default_size * font_scalings.get(self._size) def get_file(self): """ Return the filename of the associated font. """ return self._file def set_family(self, family): """ Change the font family. May be either an alias (generic name is CSS parlance), such as: 'serif', 'sans-serif', 'cursive', 'fantasy', or 'monospace', or a real font name. """ if family is None: self._family = None else: if is_string_like(family): family = [family] self._family = family set_name = set_family def set_style(self, style): """ Set the font style. Values are: 'normal', 'italic' or 'oblique'. """ if style not in ('normal', 'italic', 'oblique', None): raise ValueError("style must be normal, italic or oblique") self._slant = style set_slant = set_style def set_variant(self, variant): """ Set the font variant. Values are: 'normal' or 'small-caps'. """ if variant not in ('normal', 'small-caps', None): raise ValueError("variant must be normal or small-caps") self._variant = variant def set_weight(self, weight): """ Set the font weight. May be either a numeric value in the range 0-1000 or one of 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black' """ if weight is not None: try: weight = int(weight) if weight < 0 or weight > 1000: raise ValueError() except ValueError: if weight not in weight_dict: raise ValueError("weight is invalid") self._weight = weight def set_stretch(self, stretch): """ Set the font stretch or width. Options are: 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded' or 'ultra-expanded', or a numeric value in the range 0-1000. """ if stretch is not None: try: stretch = int(stretch) if stretch < 0 or stretch > 1000: raise ValueError() except ValueError: if stretch not in stretch_dict: raise ValueError("stretch is invalid") else: stretch = 500 self._stretch = stretch def set_size(self, size): """ Set the font size. Either an relative value of 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large' or an absolute font size, e.g. 12. """ if size is not None: try: size = float(size) except ValueError: if size is not None and size not in font_scalings: raise ValueError("size is invalid") self._size = size def set_file(self, file): """ Set the filename of the fontfile to use. In this case, all other properties will be ignored. """ self._file = file def copy(self): """Return a deep copy of self""" return FontProperties(_init=self) def ttfdict_to_fnames(d): """ flatten a ttfdict to all the filenames it contains """ fnames = [] for named in d.values(): for styled in named.values(): for variantd in styled.values(): for weightd in variantd.values(): for stretchd in weightd.values(): for fname in stretchd.values(): fnames.append(fname) return fnames def pickle_dump(data, filename): """ Equivalent to pickle.dump(data, open(filename, 'w')) but closes the file to prevent filehandle leakage. """ fh = open(filename, 'w') try: pickle.dump(data, fh) finally: fh.close() def pickle_load(filename): """ Equivalent to pickle.load(open(filename, 'r')) but closes the file to prevent filehandle leakage. """ fh = open(filename, 'r') try: data = pickle.load(fh) finally: fh.close() return data class FontManager: """ On import, the :class:`FontManager` singleton instance creates a list of TrueType fonts based on the font properties: name, style, variant, weight, stretch, and size. The :meth:`findfont` method does a nearest neighbor search to find the font that most closely matches the specification. If no good enough match is found, a default font is returned. """ # Increment this version number whenever the font cache data # format or behavior has changed and requires a existing font # cache files to be rebuilt. __version__ = 7 def __init__(self, size=None, weight='normal'): self._version = self.__version__ self.__default_weight = weight self.default_size = size paths = [] # Create list of font paths for pathname in ['TTFPATH', 'AFMPATH']: if pathname in os.environ: ttfpath = os.environ[pathname] if ttfpath.find(';') >= 0: # win32 style paths.extend(ttfpath.split(';')) elif ttfpath.find(':') >= 0: # unix style paths.extend(ttfpath.split(':')) else: paths.append(ttfpath) verbose.report('font search path %s' % (str(paths))) # Load TrueType fonts and create font dictionary. self.ttffiles = findSystemFonts(paths) + findSystemFonts() self.defaultFamily = { 'ttf': 'Bitstream Vera Sans', 'afm': 'Helvetica'} self.defaultFont = {} for fname in self.ttffiles: verbose.report('trying fontname %s' % fname, 'debug') if fname.lower().find('vera.ttf') >= 0: self.defaultFont['ttf'] = fname break else: # use anything self.defaultFont['ttf'] = self.ttffiles[0] self.ttflist = createFontList(self.ttffiles) self.afmfiles = findSystemFonts(paths, fontext='afm') + \ findSystemFonts(fontext='afm') self.afmlist = createFontList(self.afmfiles, fontext='afm') self.defaultFont['afm'] = None self.ttf_lookup_cache = {} self.afm_lookup_cache = {} def get_default_weight(self): """ Return the default font weight. """ return self.__default_weight def get_default_size(self): """ Return the default font size. """ return self.default_size def set_default_weight(self, weight): """ Set the default font weight. The initial value is 'normal'. """ self.__default_weight = weight def update_fonts(self, filenames): """ Update the font dictionary with new font files. Currently not implemented. """ # !!!! Needs implementing raise NotImplementedError # Each of the scoring functions below should return a value between # 0.0 (perfect match) and 1.0 (terrible match) def score_family(self, families, family2): """ Returns a match score between the list of font families in *families* and the font family name *family2*. An exact match anywhere in the list returns 0.0. A match by generic font name will return 0.1. No match will return 1.0. """ global preferred_fonts family2 = family2.lower() for i, family1 in enumerate(families): family1 = family1.lower() if family1 in font_family_aliases: if family1 in ('sans', 'sans serif'): family1 = 'sans-serif' options = preferred_fonts[family1] options = [x.lower() for x in options] if family2 in options: idx = options.index(family2) return 0.1 * (float(idx) / len(options)) elif family1 == family2: return 0.0 return 1.0 def score_style(self, style1, style2): """ Returns a match score between *style1* and *style2*. An exact match returns 0.0. A match between 'italic' and 'oblique' returns 0.1. No match returns 1.0. """ if style1 == style2: return 0.0 elif style1 in ('italic', 'oblique') and \ style2 in ('italic', 'oblique'): return 0.1 return 1.0 def score_variant(self, variant1, variant2): """ Returns a match score between *variant1* and *variant2*. An exact match returns 0.0, otherwise 1.0. """ if variant1 == variant2: return 0.0 else: return 1.0 def score_stretch(self, stretch1, stretch2): """ Returns a match score between *stretch1* and *stretch2*. The result is the absolute value of the difference between the CSS numeric values of *stretch1* and *stretch2*, normalized between 0.0 and 1.0. """ try: stretchval1 = int(stretch1) except ValueError: stretchval1 = stretch_dict.get(stretch1, 500) try: stretchval2 = int(stretch2) except ValueError: stretchval2 = stretch_dict.get(stretch2, 500) return abs(stretchval1 - stretchval2) / 1000.0 def score_weight(self, weight1, weight2): """ Returns a match score between *weight1* and *weight2*. The result is the absolute value of the difference between the CSS numeric values of *weight1* and *weight2*, normalized between 0.0 and 1.0. """ try: weightval1 = int(weight1) except ValueError: weightval1 = weight_dict.get(weight1, 500) try: weightval2 = int(weight2) except ValueError: weightval2 = weight_dict.get(weight2, 500) return abs(weightval1 - weightval2) / 1000.0 def score_size(self, size1, size2): """ Returns a match score between *size1* and *size2*. If *size2* (the size specified in the font file) is 'scalable', this function always returns 0.0, since any font size can be generated. Otherwise, the result is the absolute distance between *size1* and *size2*, normalized so that the usual range of font sizes (6pt - 72pt) will lie between 0.0 and 1.0. """ if size2 == 'scalable': return 0.0 # Size value should have already been try: sizeval1 = float(size1) except ValueError: sizeval1 = self.default_size * font_scalings(size1) try: sizeval2 = float(size2) except ValueError: return 1.0 return abs(sizeval1 - sizeval2) / 72.0 def findfont(self, prop, fontext='ttf', directory=None, fallback_to_default=True, rebuild_if_missing=True): """ Search the font list for the font that most closely matches the :class:`FontProperties` *prop*. :meth:`findfont` performs a nearest neighbor search. Each font is given a similarity score to the target font properties. The first font with the highest score is returned. If no matches below a certain threshold are found, the default font (usually Vera Sans) is returned. `directory`, is specified, will only return fonts from the given directory (or subdirectory of that directory). The result is cached, so subsequent lookups don't have to perform the O(n) nearest neighbor search. If `fallback_to_default` is True, will fallback to the default font family (usually "Bitstream Vera Sans" or "Helvetica") if the first lookup hard-fails. See the `W3C Cascading Style Sheet, Level 1 `_ documentation for a description of the font finding algorithm. """ if not isinstance(prop, FontProperties): prop = FontProperties(prop) fname = prop.get_file() if fname is not None: verbose.report('findfont returning %s' % fname, 'debug') return fname if fontext == 'afm': font_cache = self.afm_lookup_cache fontlist = self.afmlist else: font_cache = self.ttf_lookup_cache fontlist = self.ttflist if directory is None: cached = font_cache.get(hash(prop)) if cached: return cached best_score = 1e64 best_font = None for font in fontlist: fname = font.fname if (directory is not None and os.path.commonprefix([fname, directory]) != directory): continue # Matching family should have highest priority, so it is multiplied # by 10.0 score = \ self.score_family(prop.get_family(), font.name) * 10.0 + \ self.score_style(prop.get_style(), font.style) + \ self.score_variant(prop.get_variant(), font.variant) + \ self.score_weight(prop.get_weight(), font.weight) + \ self.score_stretch(prop.get_stretch(), font.stretch) + \ self.score_size(prop.get_size(), font.size) if score < best_score: best_score = score best_font = font if score == 0: break if best_font is None or best_score >= 10.0: if fallback_to_default: warnings.warn( 'findfont: Font family %s not found. Falling back to %s' % (prop.get_family(), self.defaultFamily[fontext])) default_prop = prop.copy() default_prop.set_family(self.defaultFamily[fontext]) return self.findfont(default_prop, fontext, directory, False) else: # This is a hard fail -- we can't find anything reasonable, # so just return the vera.ttf warnings.warn( 'findfont: Could not match %s. Returning %s' % (prop, self.defaultFont[fontext]), UserWarning) result = self.defaultFont[fontext] else: verbose.report( 'findfont: Matching %s to %s (%s) with score of %f' % (prop, best_font.name, best_font.fname, best_score)) result = best_font.fname if not os.path.isfile(result): if rebuild_if_missing: verbose.report( 'findfont: Found a missing font file. Rebuilding cache.') _rebuild() return fontManager.findfont( prop, fontext, directory, True, False) else: raise ValueError("No valid font could be found") if directory is None: font_cache[hash(prop)] = result return result _is_opentype_cff_font_cache = {} def is_opentype_cff_font(filename): """ Returns True if the given font is a Postscript Compact Font Format Font embedded in an OpenType wrapper. Used by the PostScript and PDF backends that can not subset these fonts. """ if os.path.splitext(filename)[1].lower() == '.otf': result = _is_opentype_cff_font_cache.get(filename) if result is None: fd = open(filename, 'rb') tag = fd.read(4) fd.close() result = (tag == 'OTTO') _is_opentype_cff_font_cache[filename] = result return result return False fontManager = None _fmcache = os.path.join(get_configdir(), 'fontList.cache') def _rebuild(): global fontManager fontManager = FontManager() pickle_dump(fontManager, _fmcache) verbose.report("generated new fontManager") # The experimental fontconfig-based backend. if USE_FONTCONFIG and sys.platform != 'win32': import re def fc_match(pattern, fontext): fontexts = get_fontext_synonyms(fontext) try: pipe = subprocess.Popen(['fc-match', '-sv', pattern], stdout=subprocess.PIPE) output = pipe.communicate()[0] except OSError: return None if pipe.returncode == 0: for match in _fc_match_regex.finditer(output): file = match.group(1) if os.path.splitext(file)[1][1:] in fontexts: return file return None _fc_match_regex = re.compile(r'\sfile:\s+"([^"]*)"') _fc_match_cache = {} def findfont(prop, fontext='ttf'): if not is_string_like(prop): prop = prop.get_fontconfig_pattern() cached = _fc_match_cache.get(prop) if cached is not None: return cached result = fc_match(prop, fontext) if result is None: result = fc_match(':', fontext) _fc_match_cache[prop] = result return result else: try: fontManager = pickle_load(_fmcache) if (not hasattr(fontManager, '_version') or fontManager._version != FontManager.__version__): _rebuild() else: fontManager.default_size = None verbose.report("Using fontManager instance from %s" % _fmcache) except: _rebuild() def findfont(prop, **kw): global fontManager font = fontManager.findfont(prop, **kw) return font enthought-chaco2-4.5.1.orig/kiva/fonttools/__init__.py0000644000175000017500000000004312516137326021767 0ustar varunvarunfrom font import Font, str_to_font enthought-chaco2-4.5.1.orig/kiva/fonttools/sstruct.py0000644000175000017500000001466112516137326021752 0ustar varunvarun"""sstruct.py -- SuperStruct Higher level layer on top of the struct module, enabling to bind names to struct elements. The interface is similar to struct, except the objects passed and returned are not tuples (or argument lists), but dictionaries or instances. Just like struct, we use format strings to describe a data structure, except we use one line per element. Lines are separated by newlines or semi-colons. Each line contains either one of the special struct characters ('@', '=', '<', '>' or '!') or a 'name:formatchar' combo (eg. 'myFloat:f'). Repetitions, like the struct module offers them are not useful in this context, except for fixed length strings (eg. 'myInt:5h' is not allowed but 'myString:5s' is). The 'x' format character (pad byte) is treated as 'special', since it is by definition anonymous. Extra whitespace is allowed everywhere. The sstruct module offers one feature that the "normal" struct module doesn't: support for fixed point numbers. These are spelled as "n.mF", where n is the number of bits before the point, and m the number of bits after the point. Fixed point numbers get converted to floats. pack(format, object): 'object' is either a dictionary or an instance (or actually anything that has a __dict__ attribute). If it is a dictionary, its keys are used for names. If it is an instance, it's attributes are used to grab struct elements from. Returns a string containing the data. unpack(format, data, object=None) If 'object' is omitted (or None), a new dictionary will be returned. If 'object' is a dictionary, it will be used to add struct elements to. If it is an instance (or in fact anything that has a __dict__ attribute), an attribute will be added for each struct element. In the latter two cases, 'object' itself is returned. unpack2(format, data, object=None) Convenience function. Same as unpack, except data may be longer than needed. The returned value is a tuple: (object, leftoverdata). calcsize(format) like struct.calcsize(), but uses our own format strings: it returns the size of the data in bytes. """ # XXX I would like to support pascal strings, too, but I'm not # sure if that's wise. Would be nice if struct supported them # "properly", but that would certainly break calcsize()... # Updated to Python 2.7/3.0, CJW from __future__ import absolute_import, print_function __version__ = "1.2" __copyright__ = "Copyright 1998, Just van Rossum " import struct import re class SStructError(Exception): pass def pack(format, obj): """ Return bytes of values v1, v2, ... packed according to format. """ formatstring, names, fixes = getformat(format) elements = [] if not isinstance(obj, dict): obj = obj.__dict__ for name in names: value = obj[name] if name in fixes: # fixed point conversion value = int(round(value*fixes[name])) elements.append(value) data = apply(struct.pack, (formatstring,) + tuple(elements)) return data def unpack(format, data, obj=None): """ Unpack bytes containing packed C structure data, according to format. Requires len(bytes) == calcsize(format). By default returns a dictionary of data, but can be given existing dict or an arbitrary object which has its __dict__ populated. """ if obj is None: obj = {} formatstring, names, fixes = getformat(format) if isinstance(obj, dict): d = obj else: d = obj.__dict__ elements = struct.unpack(formatstring, data) for i in range(len(names)): name = names[i] value = elements[i] if name in fixes: # fixed point conversion value = value / fixes[name] d[name] = value return obj def unpack2(format, data, object=None): """ As unpack(), but truncating to length of format """ length = calcsize(format) return unpack(format, data[:length], object), data[length:] def calcsize(format): """ Compute the size of the data structure described by format """ formatstring, names, fixes = getformat(format) return struct.calcsize(formatstring) # matches "name:formatchar" (whitespace is allowed) _elementRE = re.compile( "\s*" # whitespace "([A-Za-z_][A-Za-z_0-9]*)" # name (python identifier) "\s*:\s*" # whitespace : whitespace "([cbBhHiIlLfd]|[0-9]+[ps]|" # formatchar... "([0-9]+)\.([0-9]+)(F))" # ...formatchar # noqa "\s*" # whitespace "(#.*)?$" # [comment] + end of string ) # matches the special struct format chars and 'x' (pad byte) _extraRE = re.compile("\s*([x@=<>!])\s*(#.*)?$") # matches an "empty" string, possibly containing whitespace and/or a comment _emptyRE = re.compile("\s*(#.*)?$") _fixedpointmappings = { 8: "b", 16: "h", 32: "l" } _formatcache = {} def getformat(format): """ Convert sstruct format to struct format, names and fixed point data """ try: formatstring, names, fixes = _formatcache[format] except KeyError: lines = re.split("[\n;]", format) formatstring = "" names = [] fixes = {} for line in lines: if _emptyRE.match(line): continue m = _extraRE.match(line) if m: formatchar = m.group(1) if formatchar != 'x' and formatstring: raise SStructError("Special format chars must be first") else: m = _elementRE.match(line) if not m: raise SStructError("syntax error in format: '%s'" % line) name = m.group(1) names.append(name) formatchar = m.group(2) if m.group(3): # fixed point before = int(m.group(3)) after = int(m.group(4)) bits = before + after if bits not in [8, 16, 32]: msg = "fixed point must be 8, 16 or 32 bits long" raise SStructError(msg) formatchar = _fixedpointmappings[bits] assert m.group(5) == "F" fixes[name] = float(1 << after) formatstring = formatstring + formatchar _formatcache[format] = formatstring, names, fixes return formatstring, names, fixes enthought-chaco2-4.5.1.orig/kiva/fonttools/tests/0000755000175000017500000000000012516137726021027 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/fonttools/tests/__init__.py0000644000175000017500000000000012516137326023122 0ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/fonttools/tests/test_sstruct.py0000644000175000017500000000405312516137326024145 0ustar varunvarun from unittest import TestCase from ..sstruct import SStructError, calcsize, getformat, pack, unpack class TestSStruct(TestCase): def test_roundtrip(self): format = """ # comments are allowed > # big endian (see documentation for struct) # empty lines are allowed: ashort: h along: l abyte: b # a byte achar: c astr: 5s afloat: f; adouble: d # multiple "statements" are allowed afixed: 16.16F """ self.assertEqual(calcsize(format), 29) class foo(object): pass i = foo() i.ashort = 0x7fff i.along = 0x7fffffff i.abyte = 0x7f i.achar = b"a" i.astr = b"12345" i.afloat = 0.5 i.adouble = 0.5 i.afixed = 1.5 data = pack(format, i) self.assertEqual( data, b'\x7f\xff' + b'\x7f\xff\xff\xff' + b'\x7f' + b'a' + b'12345' + b'\x3f\x00\x00\x00' + b'\x3f\xe0\x00\x00\x00\x00\x00\x00' + b'\x00\x01\x80\x00' ) self.assertEqual( unpack(format, data), { 'ashort': i.ashort, 'abyte': i.abyte, 'achar': i.achar, 'along': i.along, 'astr': i.astr, 'afloat': i.afloat, 'adouble': i.adouble, 'afixed': i.afixed, } ) i2 = foo() unpack(format, data, i2) self.assertEqual(vars(i), vars(i2)) def test_bad_format_char(self): format = "test: b; >" with self.assertRaises(SStructError): getformat(format) def test_format_syntax_error(self): format = "test: z" with self.assertRaises(SStructError): getformat(format) def test_fixed_point_error(self): format = "test: 4.8F" with self.assertRaises(SStructError): getformat(format) enthought-chaco2-4.5.1.orig/kiva/fonttools/misc/0000755000175000017500000000000012516137726020620 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/fonttools/misc/textTools.py0000644000175000017500000000526212516137326023200 0ustar varunvarun"""fontTools.misc.textTools.py -- miscelaneous routines.""" import string def safeEval(data, eval=eval): """A safe replacement for eval.""" return eval(data, {"__builtins__":{}}, {}) def readHex(content): """Convert a list of hex strings to binary data.""" hexdata = "" for chunk in content: if type(chunk) == type(""): hexdata = hexdata + chunk return deHexStr(hexdata) def deHexStr(hexdata): """Convert a hex string to binary data.""" parts = string.split(hexdata) hexdata = string.join(parts, "") if len(hexdata) % 2: hexdata = hexdata + "0" data = "" for i in range(0, len(hexdata), 2): data = data + chr(string.atoi(hexdata[i:i+2], 16)) return data def hexStr(data): """Convert binary data to a hex string.""" h = string.hexdigits r = '' for c in data: i = ord(c) r = r + h[(i >> 4) & 0xF] + h[i & 0xF] return r def num2binary(l, bits=32): all = [] bin = "" for i in range(bits): if l & 0x1: bin = "1" + bin else: bin = "0" + bin l = l >> 1 if not ((i+1) % 8): all.append(bin) bin = "" if bin: all.append(bin) all.reverse() assert l in (0, -1), "number doesn't fit in number of bits" return string.join(all, " ") def binary2num(bin): bin = string.join(string.split(bin), "") l = 0 for digit in bin: l = l << 1 if digit <> "0": l = l | 0x1 return l def caselessSort(alist): """Return a sorted copy of a list. If there are only strings in the list, it will not consider case. """ try: # turn ['FOO', 'aaBc', 'ABcD'] into # [('foo', 'FOO'), ('aabc', 'aaBc'), ('abcd', 'ABcD')], # but only if all elements are strings tupledlist = map(lambda item, lower = string.lower: (lower(item), item), alist) except TypeError: # at least one element in alist is not a string, proceed the normal way... alist = alist[:] alist.sort() return alist else: tupledlist.sort() # turn [('aabc', 'aaBc'), ('abcd', 'ABcD'), ('foo', 'FOO')] into # ['aaBc', 'ABcD', 'FOO'] return map(lambda x: x[1], tupledlist) enthought-chaco2-4.5.1.orig/kiva/fonttools/misc/__init__.py0000644000175000017500000000022312516137326022722 0ustar varunvarun"""Empty __init__.py file to signal Python this directory is a package. (It can't be completely empty since WinZip seems to skip empty files.) """ enthought-chaco2-4.5.1.orig/kiva/fonttools/font.py0000644000175000017500000001266212516137326021210 0ustar varunvarun""" Defines the Kiva Font class and a utility method to parse free-form font specification strings into Font instances. """ from __future__ import absolute_import, print_function import copy from kiva.constants import (DEFAULT, DECORATIVE, ROMAN, SCRIPT, SWISS, MODERN, TELETYPE, NORMAL, ITALIC, BOLD, BOLD_ITALIC) from .font_manager import FontProperties, fontManager # Various maps used by str_to_font font_families = { 'default': DEFAULT, 'decorative': DECORATIVE, 'roman': ROMAN, 'script': SCRIPT, 'swiss': SWISS, 'modern': MODERN } font_styles = {'italic': ITALIC} font_weights = {'bold': BOLD} font_noise = ['pt', 'point', 'family'] def str_to_font(fontspec): """ Converts a string specification of a font into a Font instance. string specifications are of the form: "modern 12", "9 roman italic", and so on. """ point_size = 10 family = DEFAULT style = NORMAL weight = NORMAL underline = 0 facename = [] for word in fontspec.split(): lword = word.lower() if lword in font_families: family = font_families[lword] elif lword in font_styles: style = font_styles[lword] elif lword in font_weights: weight = font_weights[lword] elif lword == 'underline': underline = 1 elif lword not in font_noise: try: point_size = int(lword) except: facename.append(word) return Font(size=point_size, family=family, weight=weight, style=style, underline=underline, face_name=' '.join(facename)) class Font(object): """ Font class for device independent font specification. It is primarily based on wxPython, but looks to be similar to the needs of Mac OS X, etc. The family defaults to SWISS so that font rotation will work correctly under wxPython. Revisit as we get more platforms defined. """ # Maps the constants for font families to names to use when searching for # fonts. familymap = { DEFAULT: "serif", SWISS: "sans-serif", ROMAN: "serif", MODERN: "sans-serif", DECORATIVE: "fantasy", SCRIPT: "script", TELETYPE: "monospace" } def __init__(self, face_name="", size=12, family=SWISS, weight=NORMAL, style=NORMAL, underline=0, encoding=DEFAULT): if (type(size) != int) or (type(family) != type(SWISS)) or \ (type(weight) != type(NORMAL)) or (type(style) != type(NORMAL)) or \ (type(underline) != int) or (not isinstance(face_name, basestring)) or \ (type(encoding) != type(DEFAULT)): raise RuntimeError("Bad value in Font() constructor.") # HACK: C++ stuff expects a string (not unicode) for the face_name, # so fix if needed. See ticket #2111 in the CP Trac. if isinstance(face_name, unicode): face_name = face_name.encode("latin1") self.size = size self.family = family self.weight = weight self.style = style self.underline = underline self.face_name = face_name self.encoding = encoding def findfont(self): """ Returns the file name containing the font that most closely matches our font properties. """ fp = self._make_font_props() return str(fontManager.findfont(fp)) def findfontname(self): """ Returns the name of the font that most closely matches our font properties """ fp = self._make_font_props() return fp.get_name() def _make_font_props(self): """ Returns a font_manager.FontProperties object that encapsulates our font properties """ # XXX: change the weight to a numerical value if self.style == BOLD or self.style == BOLD_ITALIC: weight = "bold" else: weight = "normal" if self.style == ITALIC or self.style == BOLD_ITALIC: style = "italic" else: style = "normal" fp = FontProperties(family=self.familymap[self.family], style=style, weight=weight, size=self.size) if self.face_name != "": fp.set_name(self.face_name) return fp def _get_name(self): return self.face_name def _set_name(self, val): self.face_name = val name = property(_get_name, _set_name) def copy(self): """ Returns a copy of the font object.""" return copy.deepcopy(self) def __eq__(self, other): result = False try: if (self.family == other.family and self.size == other.size and self.weight == other.weight and self.style == other.style and self.underline == other.underline and self.face_name == other.face_name and self.encoding == other.encoding): result = True except AttributeError: pass return result def __ne__(self, other): return not self.__eq__(other) def __repr__(self): fmt = ("Font(size=%d,family=%d,weight=%d, style=%d, face_name='%s', " + "encoding=%d)") return fmt % (self.size, self.family, self.weight, self.style, self.face_name, self.encoding) enthought-chaco2-4.5.1.orig/kiva/qpainter.py0000644000175000017500000007243212516137326020037 0ustar varunvarun# ------------------------------------------------------------------------------ # Copyright (c) 2010, Enthought, Inc # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # ------------------------------------------------------------------------------ """ This is the QPainter backend for kiva. """ from __future__ import absolute_import, print_function from functools import partial from itertools import izip import numpy as np import warnings # Major package imports. from pyface.qt import QtCore, QtGui # Local imports. from .abstract_graphics_context import AbstractGraphicsContext from .arc_conversion import arc_to_tangent_points from .fonttools import Font import kiva.constants as constants # These are the symbols that a backend has to define. __all__ = ["CompiledPath", "Font", "font_metrics_provider", "GraphicsContext"] cap_style = {} cap_style[constants.CAP_ROUND] = QtCore.Qt.RoundCap cap_style[constants.CAP_SQUARE] = QtCore.Qt.SquareCap cap_style[constants.CAP_BUTT] = QtCore.Qt.FlatCap join_style = {} join_style[constants.JOIN_ROUND] = QtCore.Qt.RoundJoin join_style[constants.JOIN_BEVEL] = QtCore.Qt.BevelJoin join_style[constants.JOIN_MITER] = QtCore.Qt.MiterJoin draw_modes = {} draw_modes[constants.FILL] = QtCore.Qt.OddEvenFill draw_modes[constants.EOF_FILL] = QtCore.Qt.WindingFill draw_modes[constants.STROKE] = 0 draw_modes[constants.FILL_STROKE] = QtCore.Qt.OddEvenFill draw_modes[constants.EOF_FILL_STROKE] = QtCore.Qt.WindingFill gradient_coord_modes = {} gradient_coord_modes['userSpaceOnUse'] = QtGui.QGradient.LogicalMode gradient_coord_modes['objectBoundingBox'] = QtGui.QGradient.ObjectBoundingMode gradient_spread_modes = {} gradient_spread_modes['pad'] = QtGui.QGradient.PadSpread gradient_spread_modes['repeat'] = QtGui.QGradient.RepeatSpread gradient_spread_modes['reflect'] = QtGui.QGradient.ReflectSpread class GraphicsContext(object): """ Simple wrapper around a Qt QPainter object. """ def __init__(self, size, *args, **kwargs): super(GraphicsContext, self).__init__() self._width = size[0] self._height = size[1] self.text_pos = [0.0, 0.0] self.text_transform = (1.0, 0.0, 0.0, 1.0, 0.0, 0.0) # create some sort of device context parent = kwargs.pop("parent", None) if parent is None: # no parent -> offscreen context self.qt_dc = QtGui.QPixmap(*size) else: # normal windowed context self.qt_dc = parent self.gc = QtGui.QPainter(self.qt_dc) self.path = CompiledPath() # flip y trans = QtGui.QTransform() trans.translate(0, size[1]) trans.scale(1.0, -1.0) self.gc.setWorldTransform(trans) # enable antialiasing self.gc.setRenderHints(QtGui.QPainter.Antialiasing | QtGui.QPainter.TextAntialiasing, True) # set the pen and brush to useful defaults self.gc.setPen(QtCore.Qt.black) self.gc.setBrush(QtGui.QBrush(QtCore.Qt.SolidPattern)) def __del__(self): # stop the painter if needed if self.gc.isActive(): self.gc.end() # ---------------------------------------------------------------- # Size info # ---------------------------------------------------------------- def height(self): """ Returns the height of the context. """ return self._height def width(self): """ Returns the width of the context. """ return self._width # ---------------------------------------------------------------- # Coordinate Transform Matrix Manipulation # ---------------------------------------------------------------- def scale_ctm(self, sx, sy): """ Set the coordinate system scale to the given values, (sx, sy). sx:float -- The new scale factor for the x axis sy:float -- The new scale factor for the y axis """ self.gc.scale(sx, sy) def translate_ctm(self, tx, ty): """ Translate the coordinate system by the given value by (tx, ty) tx:float -- The distance to move in the x direction ty:float -- The distance to move in the y direction """ self.gc.translate(tx, ty) def rotate_ctm(self, angle): """ Rotates the coordinate space for drawing by the given angle. angle:float -- the angle, in radians, to rotate the coordinate system """ self.gc.rotate(np.rad2deg(angle)) def concat_ctm(self, transform): """ Concatenate the transform to current coordinate transform matrix. transform:affine_matrix -- the transform matrix to concatenate with the current coordinate matrix. """ m11, m12, m21, m22, tx, ty = transform self.gc.setTransform(QtGui.QTransform(m11, m12, m21, m22, tx, ty), True) def get_ctm(self): """ Return the current coordinate transform matrix. """ t = self.gc.transform() return (t.m11(), t.m12(), t.m21(), t.m22(), t.dx(), t.dy()) # ---------------------------------------------------------------- # Save/Restore graphics state. # ---------------------------------------------------------------- def save_state(self): """ Save the current graphic's context state. This should always be paired with a restore_state """ self.gc.save() def restore_state(self): """ Restore the previous graphics state. """ self.gc.restore() # ---------------------------------------------------------------- # context manager interface # ---------------------------------------------------------------- def __enter__(self): self.save_state() def __exit__(self, type, value, traceback): self.restore_state() # ---------------------------------------------------------------- # Manipulate graphics state attributes. # ---------------------------------------------------------------- def set_antialias(self, value): """ Set/Unset antialiasing for bitmap graphics context. """ self.gc.setRenderHints(QtGui.QPainter.Antialiasing | QtGui.QPainter.TextAntialiasing, value) def set_line_width(self, width): """ Set the line width for drawing width:float -- The new width for lines in user space units. """ pen = self.gc.pen() pen.setWidthF(width) self.gc.setPen(pen) def set_line_join(self, style): """ Set style for joining lines in a drawing. style:join_style -- The line joining style. The available styles are JOIN_ROUND, JOIN_BEVEL, JOIN_MITER. """ try: sjoin = join_style[style] except KeyError: msg = "Invalid line join style. See documentation for valid styles" raise ValueError(msg) pen = self.gc.pen() pen.setJoinStyle(sjoin) self.gc.setPen(pen) def set_miter_limit(self, limit): """ Specifies limits on line lengths for mitering line joins. If line_join is set to miter joins, the limit specifies which line joins should actually be mitered. If lines aren't mitered, they are joined with a bevel. The line width is divided by the length of the miter. If the result is greater than the limit, the bevel style is used. limit:float -- limit for mitering joins. """ pen = self.gc.pen() pen.setMiterLimit(limit) self.gc.setPen(pen) def set_line_cap(self, style): """ Specify the style of endings to put on line ends. style:cap_style -- the line cap style to use. Available styles are CAP_ROUND, CAP_BUTT, CAP_SQUARE """ try: scap = cap_style[style] except KeyError: msg = "Invalid line cap style. See documentation for valid styles" raise ValueError(msg) pen = self.gc.pen() pen.setCapStyle(scap) self.gc.setPen(pen) def set_line_dash(self, lengths, phase=0): """ lengths:float array -- An array of floating point values specifing the lengths of on/off painting pattern for lines. phase:float -- Specifies how many units into dash pattern to start. phase defaults to 0. """ lengths = list(lengths) if lengths is not None else [] pen = self.gc.pen() pen.setDashPattern(lengths) pen.setDashOffset(phase) self.gc.setPen(pen) def set_flatness(self, flatness): """ Not implemented It is device dependent and therefore not recommended by the PDF documentation. """ raise NotImplementedError() # ---------------------------------------------------------------- # Sending drawing data to a device # ---------------------------------------------------------------- def flush(self): """ Send all drawing data to the destination device. """ pass def synchronize(self): """ Prepares drawing data to be updated on a destination device. """ pass # ---------------------------------------------------------------- # Page Definitions # ---------------------------------------------------------------- def begin_page(self): """ Create a new page within the graphics context. """ pass def end_page(self): """ End drawing in the current page of the graphics context. """ pass # ---------------------------------------------------------------- # Building paths (contours that are drawn) # # + Currently, nothing is drawn as the path is built. Instead, the # instructions are stored and later drawn. Should this be changed? # We will likely draw to a buffer instead of directly to the canvas # anyway. # # Hmmm. No. We have to keep the path around for storing as a # clipping region and things like that. # # + I think we should keep the current_path_point hanging around. # # ---------------------------------------------------------------- def begin_path(self): """ Clear the current drawing path and begin a new one. """ self.path = CompiledPath() def move_to(self, x, y): """ Start a new drawing subpath at place the current point at (x, y). """ self.path.move_to(x, y) def line_to(self, x, y): """ Add a line from the current point to the given point (x, y). The current point is moved to (x, y). """ self.path.line_to(x, y) def lines(self, points): """ Add a series of lines as a new subpath. Currently implemented by calling line_to a zillion times. Points is an Nx2 array of x, y pairs. """ self.path.lines(points) def line_set(self, starts, ends): """ Draw multiple disjoint line segments. """ for start, end in izip(starts, ends): self.path.path.moveTo(start[0], start[1]) self.path.path.lineTo(end[0], end[1]) def rect(self, x, y, sx, sy): """ Add a rectangle as a new subpath. """ self.path.rect(x, y, sx, sy) def rects(self, rects): """ Add multiple rectangles as separate subpaths to the path. """ self.path.rects(rects) def draw_rect(self, rect, mode=constants.FILL_STROKE): """ Draw a rect. """ rect = QtCore.QRectF(*rect) if mode == constants.STROKE: save_brush = self.gc.brush() self.gc.setBrush(QtGui.QBrush(QtCore.Qt.NoBrush)) self.gc.drawRect(rect) self.gc.setBrush(save_brush) elif mode in [constants.FILL, constants.EOF_FILL]: self.gc.fillRect(rect, self.gc.brush()) else: self.gc.fillRect(rect, self.gc.brush()) self.gc.drawRect(rect) def add_path(self, path): """ Add a subpath to the current path. """ self.path.add_path(path) def close_path(self): """ Close the path of the current subpath. """ self.path.close_path() def curve_to(self, cp1x, cp1y, cp2x, cp2y, x, y): """ """ self.path.curve_to(cp1x, cp1y, cp2x, cp2y, x, y) def quad_curve_to(self, cpx, cpy, x, y): """ """ self.path.quad_curve_to(cpx, cpy, x, y) def arc(self, x, y, radius, start_angle, end_angle, clockwise=False): """ """ self.path.arc(x, y, radius, start_angle, end_angle, clockwise) def arc_to(self, x1, y1, x2, y2, radius): """ """ self.path.arc_to(x1, y1, x2, y2, radius) # ---------------------------------------------------------------- # Getting infomration on paths # ---------------------------------------------------------------- def is_path_empty(self): """ Test to see if the current drawing path is empty """ return self.path.is_empty() def get_path_current_point(self): """ Return the current point from the graphics context. """ return self.path.get_current_point() def get_path_bounding_box(self): """ Return the bounding box for the current path object. """ return self.path.get_bounding_box() # ---------------------------------------------------------------- # Clipping path manipulation # ---------------------------------------------------------------- def clip(self): """ """ self.gc.setClipPath(self.path.path) def even_odd_clip(self): """ """ self.gc.setClipPath(self.path.path, operation=QtCore.Qt.IntersectClip) def clip_to_rect(self, x, y, w, h): """ Clip context to the given rectangular region. Region should be a 4-tuple or a sequence. """ self.gc.setClipRect(QtCore.QRectF(x, y, w, h), operation=QtCore.Qt.IntersectClip) def clip_to_rects(self, rects): """ """ # Create a region which is a union of all rects. clip_region = QtGui.QRegion() for rect in rects: clip_region = clip_region.unite(QtGui.QRegion(*rect)) # Then intersect that region with the current clip region. self.gc.setClipRegion(clip_region, operation=QtCore.Qt.IntersectClip) # ---------------------------------------------------------------- # Color space manipulation # # I'm not sure we'll mess with these at all. They seem to # be for setting the color system. Hard coding to RGB or # RGBA for now sounds like a reasonable solution. # ---------------------------------------------------------------- def set_fill_color_space(self): """ """ msg = "set_fill_color_space not implemented on Qt yet." raise NotImplementedError(msg) def set_stroke_color_space(self): """ """ msg = "set_stroke_color_space not implemented on Qt yet." raise NotImplementedError(msg) def set_rendering_intent(self): """ """ msg = "set_rendering_intent not implemented on Qt yet." raise NotImplementedError(msg) # ---------------------------------------------------------------- # Color manipulation # ---------------------------------------------------------------- def set_fill_color(self, color): """ """ r, g, b = color[:3] try: a = color[3] except IndexError: a = 1.0 brush = self.gc.brush() brush.setColor(QtGui.QColor.fromRgbF(r, g, b, a)) self.gc.setBrush(brush) def set_stroke_color(self, color): """ """ r, g, b = color[:3] try: a = color[3] except IndexError: a = 1.0 pen = self.gc.pen() pen.setColor(QtGui.QColor.fromRgbF(r, g, b, a)) self.gc.setPen(pen) def set_alpha(self, alpha): """ """ self.gc.setOpacity(alpha) # ---------------------------------------------------------------- # Gradients # ---------------------------------------------------------------- def _apply_gradient(self, grad, stops, spread_method, units): """ Configures a gradient object and sets it as the current brush. """ grad.setSpread(gradient_spread_modes.get(spread_method, QtGui.QGradient.PadSpread)) grad.setCoordinateMode(gradient_coord_modes.get( units, QtGui.QGradient.LogicalMode)) for stop in stops: grad.setColorAt(stop[0], QtGui.QColor.fromRgbF(*stop[1:])) self.gc.setBrush(QtGui.QBrush(grad)) def linear_gradient(self, x1, y1, x2, y2, stops, spread_method, units='userSpaceOnUse'): """ Sets a linear gradient as the current brush. """ grad = QtGui.QLinearGradient(x1, y1, x2, y2) self._apply_gradient(grad, stops, spread_method, units) def radial_gradient(self, cx, cy, r, fx, fy, stops, spread_method, units='userSpaceOnUse'): """ Sets a radial gradient as the current brush. """ grad = QtGui.QRadialGradient(cx, cy, r, fx, fy) self._apply_gradient(grad, stops, spread_method, units) # ---------------------------------------------------------------- # Drawing Images # ---------------------------------------------------------------- def draw_image(self, img, rect=None): """ img is either a N*M*3 or N*M*4 numpy array, or a Kiva image rect - a tuple (x, y, w, h) """ from kiva import agg def copy_padded(array): """ Pad image width to a multiple of 4 pixels, and minimum dims of 12x12. QImage is very particular about its data. """ y, x, d = array.shape pad = lambda v: (4 - (v % 4)) % 4 nx = max(x + pad(x), 12) ny = max(y, 12) if x == nx and y == ny: return array ret = np.zeros((ny, nx, d), dtype=np.uint8) ret[:y, :x] = array[:] return ret if type(img) == type(np.array([])): # Numeric array if img.shape[2] == 3: format = QtGui.QImage.Format_RGB888 elif img.shape[2] == 4: format = QtGui.QImage.Format_RGB32 width, height = img.shape[:2] copy_array = copy_padded(img) draw_img = QtGui.QImage(img.astype(np.uint8), copy_array.shape[1], height, format) pixmap = QtGui.QPixmap.fromImage(draw_img) elif isinstance(img, agg.GraphicsContextArray): converted_img = img.convert_pixel_format('bgra32', inplace=0) copy_array = copy_padded(converted_img.bmp_array) width, height = img.width(), img.height() draw_img = QtGui.QImage(copy_array.flatten(), copy_array.shape[1], height, QtGui.QImage.Format_RGB32) pixmap = QtGui.QPixmap.fromImage(draw_img) elif (isinstance(img, GraphicsContext) and isinstance(img.qt_dc, QtGui.QPixmap) and img.gc.isActive()): # An offscreen Qt kiva context # Calling qpainter.device() appears to introduce a memory leak. # using the display context and calling qpainter.isActive() has # the same outcome. pixmap = img.qt_dc width, height = pixmap.width(), pixmap.height() else: msg = ("Cannot render image of type '%r' into Qt4 context." % type(img)) warnings.warn(msg) return # create a rect object to draw into if rect is None: dest_rect = QtCore.QRectF(0.0, 0.0, self.width(), self.height()) else: dest_rect = QtCore.QRectF(*rect) # draw using the entire image's data source_rect = QtCore.QRectF(0.0, 0.0, width, height) flip_trans = QtGui.QTransform() flip_trans.scale(1.0, -1.0) pixmap = pixmap.transformed(flip_trans) # draw self.gc.drawPixmap(dest_rect, pixmap, source_rect) # ---------------------------------------------------------------- # Drawing Text # ---------------------------------------------------------------- def select_font(self, name, size, textEncoding): """ Set the font for the current graphics context. """ self.gc.setFont(QtGui.QFont(name, size)) def set_font(self, font): """ Set the font for the current graphics context. """ self.select_font(font.face_name, font.size, None) def set_font_size(self, size): """ """ font = self.gc.font() font.setPointSizeF(size) self.gc.setFont(font) def set_character_spacing(self, spacing): """ """ font = self.gc.font() font.setLetterSpacing(QtGui.QFont.AbsoluteSpacing, spacing) self.gc.setFont(font) def set_text_drawing_mode(self): """ """ pass def set_text_position(self, x, y): """ """ self.text_pos = [x, y] def get_text_position(self): """ """ return self.text_pos def set_text_matrix(self, ttm): """ """ self.text_transform = ttm def get_text_matrix(self): """ """ return self.text_transform def show_text(self, text, point=None): """ Draw text on the device at current text position. This is also used for showing text at a particular point specified by x and y. """ if point is None: pos = tuple(self.text_pos) else: pos = tuple(point) unflip_trans = QtGui.QTransform(*self.text_transform) unflip_trans.translate(0, self._height) unflip_trans.scale(1.0, -1.0) self.gc.save() self.gc.setTransform(unflip_trans, True) self.gc.drawText(QtCore.QPointF(pos[0], self._flip_y(pos[1])), text) self.gc.restore() def show_text_at_point(self, text, x, y): """ Draw text at some point (x, y). """ self.show_text(text, (x, y)) def show_glyphs(self): """ """ msg = "show_glyphs not implemented on Qt yet." raise NotImplementedError(msg) def get_text_extent(self, text): """ Returns the bounding rect of the rendered text """ fm = self.gc.fontMetrics() rect = fm.boundingRect(text) return rect.left(), -fm.descent(), rect.right(), fm.height() def get_full_text_extent(self, text): """ Backwards compatibility API over .get_text_extent() for Enable """ x1, y1, x2, y2 = self.get_text_extent(text) return x2, y2, y1, x1 # ---------------------------------------------------------------- # Painting paths (drawing and filling contours) # ---------------------------------------------------------------- def stroke_path(self): """ """ self.gc.strokePath(self.path.path, self.gc.pen()) self.begin_path() def fill_path(self): """ """ self.gc.fillPath(self.path.path, self.gc.brush()) self.begin_path() def eof_fill_path(self): """ """ self.path.path.setFillRule(QtCore.Qt.OddEvenFill) self.gc.fillPath(self.path.path, self.gc.brush()) self.begin_path() def stroke_rect(self, rect): """ """ self.gc.drawRect(QtCore.QRectF(*rect)) def stroke_rect_with_width(self, rect, width): """ """ save_pen = self.gc.pen() draw_pen = QtGui.QPen(save_pen) draw_pen.setWidthF(width) self.gc.setPen(draw_pen) self.stroke_rect(rect) self.gc.setPen(save_pen) def fill_rect(self, rect): """ """ self.gc.fillRect(QtCore.QRectF(*rect), self.gc.brush()) def fill_rects(self): """ """ msg = "fill_rects not implemented on Qt yet." raise NotImplementedError(msg) def clear_rect(self, rect): """ """ self.gc.eraseRect(QtCore.QRectF(*rect)) def clear(self, clear_color=(1.0, 1.0, 1.0, 1.0)): """ """ if len(clear_color) == 4: r, g, b, a = clear_color else: r, g, b = clear_color a = 1.0 self.gc.setBackground(QtGui.QBrush(QtGui.QColor.fromRgbF(r, g, b, a))) self.gc.eraseRect(QtCore.QRectF(0, 0, self.width(), self.height())) def draw_path(self, mode=constants.FILL_STROKE): """ Walk through all the drawing subpaths and draw each element. Each subpath is drawn separately. """ if mode == constants.STROKE: self.stroke_path() elif mode in [constants.FILL, constants.EOF_FILL]: mode = draw_modes[mode] self.path.path.setFillRule(mode) self.fill_path() else: mode = draw_modes[mode] self.path.path.setFillRule(mode) self.gc.drawPath(self.path.path) self.begin_path() def get_empty_path(self): """ Return a path object that can be built up and then reused. """ return CompiledPath() def draw_path_at_points(self, points, path, mode=constants.FILL_STROKE): # set up drawing state and function if mode == constants.STROKE: draw_func = partial(self.gc.strokePath, path.path, self.gc.pen()) elif mode in [constants.FILL, constants.EOF_FILL]: mode = draw_modes[mode] path.path.setFillRule(mode) draw_func = partial(self.gc.fillPath, path.path, self.gc.brush()) else: mode = draw_modes[mode] path.path.setFillRule(mode) draw_func = partial(self.gc.drawPath, path.path) for point in points: x, y = point self.gc.save() self.gc.translate(x, y) draw_func() self.gc.restore() def _flip_y(self, y): "Converts between a Kiva and a Qt y coordinate" return self._height - y - 1 def save(self, filename, file_format=None): """ Save the contents of the context to a file """ if isinstance(self.qt_dc, QtGui.QPixmap): self.qt_dc.save(filename, format=file_format) else: msg = "save not implemented for window contexts." raise NotImplementedError(msg) class CompiledPath(object): def __init__(self): self.path = QtGui.QPainterPath() def begin_path(self): return def move_to(self, x, y): self.path.moveTo(x, y) def arc(self, x, y, r, start_angle, end_angle, clockwise=False): sweep_angle = (end_angle-start_angle if not clockwise else start_angle-end_angle) self.path.moveTo(x, y) self.path.arcTo(QtCore.QRectF(x-r, y-r, r*2, r*2), np.rad2deg(start_angle), np.rad2deg(sweep_angle)) def arc_to(self, x1, y1, x2, y2, r): # get the current pen position current_point = self.get_current_point() # Get the two points on the curve where it touches the line segments t1, t2 = arc_to_tangent_points(current_point, (x1, y1), (x2, y2), r) # draw! self.path.lineTo(*t1) self.path.quadTo(x1, y1, *t2) self.path.lineTo(x2, y2) def line_to(self, x, y): self.path.lineTo(x, y) def lines(self, points): self.path.moveTo(points[0][0], points[0][1]) for x, y in points[1:]: self.path.lineTo(x, y) def curve_to(self, cx1, cy1, cx2, cy2, x, y): self.path.cubicTo(cx1, cy1, cx2, cy2, x, y) def quad_curve_to(self, cx, cy, x, y): self.path.quadTo(cx, cy, x, y) def rect(self, x, y, sx, sy): self.path.addRect(x, y, sx, sy) def rects(self, rects): for x, y, sx, sy in rects: self.path.addRect(x, y, sx, sy) def add_path(self, other_path): if isinstance(other_path, CompiledPath): self.path.addPath(other_path.path) def close_path(self): self.path.closeSubpath() def is_empty(self): return self.path.isEmpty() def get_current_point(self): point = self.path.currentPosition() return point.x(), point.y() def get_bounding_box(self): rect = self.path.boundingRect() return rect.x(), rect.y(), rect.width(), rect.height() # GraphicsContext should implement AbstractGraphicsContext AbstractGraphicsContext.register(GraphicsContext) def font_metrics_provider(): """ Creates an object to be used for querying font metrics. """ return GraphicsContext((1, 1)) enthought-chaco2-4.5.1.orig/kiva/quartz/0000755000175000017500000000000012516137726017164 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/quartz/__init__.py0000644000175000017500000000066712516137326021302 0ustar varunvarun# :Author: Robert Kern # :Copyright: 2004, Enthought, Inc. # :License: BSD Style from mac_context import get_mac_context def get_macport(dc): """ Returns the Port or the CGContext of a wxDC (or child class) instance. """ if 'GetCGContext' in dir(dc): ptr = dc.GetCGContext() return int(ptr) else: from macport import get_macport as _get_macport return _get_macport(str(dc.this)) enthought-chaco2-4.5.1.orig/kiva/quartz/setup.py0000644000175000017500000000771612516137326020705 0ustar varunvarun#!/usr/bin/env python import os import platform import sys def configuration(parent_package='', top_path=None): from numpy.distutils.misc_util import Configuration from numpy.distutils.system_info import dict_append, get_info config = Configuration('quartz', parent_package, top_path) def generate_c_from_cython(extension, build_dir): if not sys.platform == 'darwin': print 'No %s will be built for this platform.' % (extension.name) return from distutils.dep_util import newer_group name = extension.name.split('.')[-1] source = extension.depends[0] target = os.path.join(build_dir, name+'.c') if newer_group(extension.depends, target): from Cython.Compiler import Main options = Main.CompilationOptions( defaults=Main.default_options, output_file=target) cython_result = Main.compile(source, options=options) if cython_result.num_errors != 0: raise RuntimeError("%d errors in Cython compile" % cython_result.num_errors) return target frameworks = ['CoreFoundation','ApplicationServices','Foundation'] extra_link_args=['-framework %s' % x for x in frameworks] include_dirs = [ '/System/Library/Frameworks/%s.framework/Versions/A/Headers' % x for x in frameworks ] config.add_extension('ABCGI', [generate_c_from_cython], extra_link_args = extra_link_args, depends = ["ABCGI.pyx", "Python.pxi", "numpy.pxi", "c_numpy.pxd", "CoreFoundation.pxi", "CoreGraphics.pxi", "CoreText.pxi", ] ) config.add_extension('CTFont', [generate_c_from_cython], extra_link_args = extra_link_args, depends=["CTFont.pyx", "CoreFoundation.pxi", "CoreGraphics.pxi", "CoreText.pxi", ], ) config.add_extension("mac_context", ["mac_context.c", "mac_context_cocoa.m"], include_dirs = include_dirs, extra_link_args = extra_link_args, depends = ["mac_context.h"], ) wx_info = get_info('wx') if wx_info: wx_release = '2.6' for macro, value in wx_info['define_macros']: if macro.startswith('WX_RELEASE_'): wx_release = macro[len('WX_RELEASE_'):].replace('_', '.') break # only build macport for wxPython version 2.6, it's not needed in the # newer releases (see __init__.py) if wx_release == '2.6': macport_cpp = config.paths('macport26.cpp')[0] def get_macport_cpp(extension, build_dir): if sys.platform != 'darwin': print 'No %s will be built for this platform.'%(extension.name) return None elif wx_release not in ('2.6', '2.8'): print ('No %s will be built because we do not recognize ' 'wx version %s' % (extension.name, wx_release)) return None return macport_cpp info = {} dict_append(info, define_macros=[("__WXMAC__", 1)]) dict_append(info, **wx_info) config.add_extension('macport', [get_macport_cpp], depends = [macport_cpp], **wx_info ) return config enthought-chaco2-4.5.1.orig/kiva/svg.py0000644000175000017500000003637412516137326017020 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2005, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ """ Chaco's SVG backend :Copyright: ActiveState :License: BSD Style :Author: David Ascher (davida@activestate.com) :Version: $Revision: 1.5 $ """ #### # # Known limitations # # * BUG: Weird behavior with compound plots # * Limitation: text widths are lousy if reportlab is not installed # * Missing feature: rotated text """ Miscellaneous notes: * the way to do links: """ # Major library imports import os import sys from cStringIO import StringIO from numpy import arange, ravel, array import warnings # Local, relative Kiva imports import affine import basecore2d import constants from constants import FILL, FILL_STROKE, EOF_FILL_STROKE, EOF_FILL, STROKE import agg from base64 import b64encode def _strpoints(points): c = StringIO() for x,y in points: c.write('%3.2f,%3.2f ' % (x,y)) return c.getvalue() def _mkstyle(kw): return '; '.join([str(k) + ':' + str(v) for k,v in kw.items()]) def default_filter(kw1): kw = {} for (k,v) in kw1.items(): if type(v) == type(()): if v[0] != v[1]: kw[k] = v[0] else: kw[k] = v return kw line_cap_map = { constants.CAP_ROUND: 'round', constants.CAP_SQUARE: 'square', constants.CAP_BUTT: 'butt' } line_join_map = { constants.JOIN_ROUND: 'round', constants.JOIN_BEVEL: 'bevel', constants.JOIN_MITER: 'miter' } font_map = {'Arial': 'Helvetica', } import _fontdata xmltemplate = """ %(contents)s """ htmltemplate = """ %(contents)s """ font_map = {'Arial': 'Helvetica', } try: # expensive way of computing string widths import reportlab.pdfbase.pdfmetrics as pdfmetrics import reportlab.pdfbase._fontdata as _fontdata _reportlab_loaded = 1 except ImportError: import pdfmetrics import _fontdata _reportlab_loaded = 0 font_face_map = {'Arial': 'Helvetica', '': 'Helvetica'} # This backend has no compiled path object, yet. class CompiledPath(object): pass _clip_counter = 0 class GraphicsContext(basecore2d.GraphicsContextBase): def __init__(self, size, *args, **kwargs): super(GraphicsContext, self).__init__(self, size, *args, **kwargs) self.size = size self._height = size[1] self.contents = StringIO() self._clipmap = {} def render(self, format): assert format == 'svg' height, width = self.size contents = self.contents.getvalue().replace("\n' return x def _debug_draw_clipping_path(self, x, y, width, height): a,b,c,d,tx,ty = affine.affine_params(self.get_ctm()) transform = 'matrix(%(a)f,%(b)f,%(c)f,%(d)f,%(tx)f,%(ty)f)' % locals() self._emit('rect', x=x, y=y, width=width, height=height, transform=transform, style=_mkstyle({'stroke-width': 5, 'fill':'none', 'stroke': 'green'})) def device_set_clipping_path(self, x, y, width, height): #self._debug_draw_clipping_path(x, y, width, height) #return global _clip_counter self.state._clip_id = 'clip_%d' % _clip_counter _clip_counter += 1 x,y = self._fixpoints([[x,y]])[0] a,b,c,d,tx,ty = affine.affine_params(self.get_ctm()) transform = 'matrix(%(a)f,%(b)f,%(c)f,%(d)f,%(tx)f,%(ty)f)' % locals() rect = self._build('rect', x=x, y=y, width=width, height=height) clippath = self._build('clipPath', contents=rect, id=self.state._clip_id) self._emit('g', transform=transform, contents=clippath) def device_destroy_clipping_path(self): self.state._clip_id = None # utility routines def _fixpoints(self, points): return points # convert lines from Kiva coordinate space to PIL coordinate space # XXX I suspect this is the location of the bug w.r.t. compound graphs and # "global" sizing. # XXX this should be made more efficient for NumPy arrays np = [] for (x,y) in points: np.append((x,self._height-y)) return np def _emit(self, name, contents=None, kw={}, **otherkw): self.contents.write('\n') else: self.contents.write('>') if name != 'text': self.contents.write('\n') self.contents.write(contents) self.contents.write('\n') def _color(self, color): r,g,b,a = color return '#%02x%02x%02x' % (r*255,g*255,b*255) def _dasharray(self): dasharray = '' for x in self.state.line_dash: if type(x) == type(arange(3)): # why is this so hard? x = ravel(x)[0] dasharray += ' ' + '%3.2f' % x if not dasharray or dasharray == " 0.00 0.00": dasharray = 'none' return dasharray # noops which seem to be needed def device_update_line_state(self): pass def device_update_fill_state(self): pass def font_metrics_provider(): return GraphicsContext((1,1)) SVGGC = GraphicsContext # for b/w compatibility enthought-chaco2-4.5.1.orig/kiva/_fontdata.py0000644000175000017500000016626312516137326020161 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2005, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # # Author: Enthought, Inc. # Description: #------------------------------------------------------------------------------ #copyright ReportLab Inc. 2001 #see license.txt for license details #history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/pdfbase/_fontdata.py?cvsroot=reportlab #$Header $ __version__=''' $Id: _fontdata.py,v 1.1 2002/12/03 08:06:29 da Exp $ ''' __doc__=""" database of font related things standardFonts tuple of the 14 standard string font names standardEncodings tuple of the known standard font names encodings a mapping object from standard encoding names (and minor variants) to the encoding vectors ie the tuple of string glyph names widthsByFontGlyph fontname x glyphname --> width of glyph widthVectorsByFont fontName -> vector of widths """ import string, UserDict, os, sys # mapping of name to width vector, starts empty until fonts are added # e.g. widths['Courier'] = [...600,600,600,...] widthVectorsByFont = {} fontsByName = {} fontsByBaseEnc = {} # this is a list of the standard 14 font names in Acrobat Reader standardFonts = ( 'Courier', 'Courier-Bold', 'Courier-Oblique', 'Courier-BoldOblique', 'Helvetica', 'Helvetica-Bold', 'Helvetica-Oblique', 'Helvetica-BoldOblique', 'Times-Roman', 'Times-Bold', 'Times-Italic', 'Times-BoldItalic', 'Symbol','ZapfDingbats') #this maps fontnames to the equivalent filename root. if sys.platform in ('linux2',): _font2fnrMap = { 'symbol': 'Symbol', 'zapfdingbats': 'ZapfDingbats', 'helvetica': 'Arial', 'helvetica-bold': 'Arial-Bold', 'helvetica-boldoblique': 'Arial-BoldItalic', 'helvetica-oblique': 'Arial-Italic', 'times-bold': 'TimesNewRoman-Bold', 'times-bolditalic':'TimesNewRoman-BoldItalic', 'times-italic': 'TimesNewRoman-Italic', 'times-roman': 'TimesNewRoman', 'courier-bold': 'Courier-Bold', 'courier-boldoblique': 'Courier-BoldOblique', 'courier': 'Courier', 'courier-oblique': 'Courier-Oblique', } else: _font2fnrMap = { 'symbol': 'Sy______', 'zapfdingbats': 'Zd______', 'helvetica': '_a______', 'helvetica-bold': '_ab_____', 'helvetica-boldoblique': '_abi____', 'helvetica-oblique': '_ai_____', 'times-bold': '_eb_____', 'times-bolditalic': '_ebi____', 'times-italic': '_ei_____', 'times-roman': '_er_____', 'courier-bold': 'cob_____', 'courier-boldoblique': 'cobo____', 'courier': 'com_____', 'courier-oblique': 'coo_____', } def _findFNR(fontName): return _font2fnrMap[string.lower(fontName)] def findT1File(fontName,ext='.pfb'): # XXX Kiva-specific changes T1SearchPath = [] # XXX should be modified if Kiva wants to support T1 fonts assert T1SearchPath!=[], "No Type-1 font search path" if sys.platform in ('linux2',) and ext=='.pfb': ext = '' n = _findFNR(fontName)+ext for d in T1SearchPath: f = os.path.join(d,n) if os.path.isfile(f): return f return None # this lists the predefined font encodings - WinAnsi and MacRoman. We have # not added MacExpert - it's possible, but would complicate life and nobody # is asking. StandardEncoding means something special. standardEncodings = ('WinAnsiEncoding','MacRomanEncoding','StandardEncoding','SymbolEncoding','ZapfDingbatsEncoding','PDFDocEncoding', 'MacExpertEncoding') #this is the global mapping of standard encodings to name vectors class _Name2StandardEncodingMap(UserDict.UserDict): '''Trivial fake dictionary with some [] magic''' _XMap = {'winansi':'WinAnsiEncoding','macroman': 'MacRomanEncoding','standard':'StandardEncoding','symbol':'SymbolEncoding', 'zapfdingbats':'ZapfDingbatsEncoding','pdfdoc':'PDFDocEncoding', 'macexpert':'MacExpertEncoding'} def __setitem__(self,x,v): y = string.lower(x) if y[-8:]=='encoding': y = y[:-8] y = self._XMap[y] if y in self.keys(): raise IndexError, 'Encoding %s is already set' % y self.data[y] = v def __getitem__(self,x): y = string.lower(x) if y[-8:]=='encoding': y = y[:-8] y = self._XMap[y] return self.data[y] encodings = _Name2StandardEncodingMap() encodings['WinAnsiEncoding'] = ( None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent', 'ampersand', 'quotesingle', 'parenleft', 'parenright', 'asterisk', 'plus', 'comma', 'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon', 'less', 'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright', 'asciicircum', 'underscore', 'grave', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'braceleft', 'bar', 'braceright', 'asciitilde', 'bullet', 'Euro', 'bullet', 'quotesinglbase', 'florin', 'quotedblbase', 'ellipsis', 'dagger', 'daggerdbl', 'circumflex', 'perthousand', 'Scaron', 'guilsinglleft', 'OE', 'bullet', 'Zcaron', 'bullet', 'bullet', 'quoteleft', 'quoteright', 'quotedblleft', 'quotedblright', 'bullet', 'endash', 'emdash', 'tilde', 'trademark', 'scaron', 'guilsinglright', 'oe', 'bullet', 'zcaron', 'Ydieresis', 'space', 'exclamdown', 'cent', 'sterling', 'currency', 'yen', 'brokenbar', 'section', 'dieresis', 'copyright', 'ordfeminine', 'guillemotleft', 'logicalnot', 'hyphen', 'registered', 'macron', 'degree', 'plusminus', 'twosuperior', 'threesuperior', 'acute', 'mu', 'paragraph', 'periodcentered', 'cedilla', 'onesuperior', 'ordmasculine', 'guillemotright', 'onequarter', 'onehalf', 'threequarters', 'questiondown', 'Agrave', 'Aacute', 'Acircumflex', 'Atilde', 'Adieresis', 'Aring', 'AE', 'Ccedilla', 'Egrave', 'Eacute', 'Ecircumflex', 'Edieresis', 'Igrave', 'Iacute', 'Icircumflex', 'Idieresis', 'Eth', 'Ntilde', 'Ograve', 'Oacute', 'Ocircumflex', 'Otilde', 'Odieresis', 'multiply', 'Oslash', 'Ugrave', 'Uacute', 'Ucircumflex', 'Udieresis', 'Yacute', 'Thorn', 'germandbls', 'agrave', 'aacute', 'acircumflex', 'atilde', 'adieresis', 'aring', 'ae', 'ccedilla', 'egrave', 'eacute', 'ecircumflex', 'edieresis', 'igrave', 'iacute', 'icircumflex', 'idieresis', 'eth', 'ntilde', 'ograve', 'oacute', 'ocircumflex', 'otilde', 'odieresis', 'divide', 'oslash', 'ugrave', 'uacute', 'ucircumflex', 'udieresis', 'yacute', 'thorn', 'ydieresis') encodings['MacRomanEncoding'] = ( None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent', 'ampersand', 'quotesingle', 'parenleft', 'parenright', 'asterisk', 'plus', 'comma', 'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon', 'less', 'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright', 'asciicircum', 'underscore', 'grave', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'braceleft', 'bar', 'braceright', 'asciitilde', None, 'Adieresis', 'Aring', 'Ccedilla', 'Eacute', 'Ntilde', 'Odieresis', 'Udieresis', 'aacute', 'agrave', 'acircumflex', 'adieresis', 'atilde', 'aring', 'ccedilla', 'eacute', 'egrave', 'ecircumflex', 'edieresis', 'iacute', 'igrave', 'icircumflex', 'idieresis', 'ntilde', 'oacute', 'ograve', 'ocircumflex', 'odieresis', 'otilde', 'uacute', 'ugrave', 'ucircumflex', 'udieresis', 'dagger', 'degree', 'cent', 'sterling', 'section', 'bullet', 'paragraph', 'germandbls', 'registered', 'copyright', 'trademark', 'acute', 'dieresis', None, 'AE', 'Oslash', None, 'plusminus', None, None, 'yen', 'mu', None, None, None, None, None, 'ordfeminine', 'ordmasculine', None, 'ae', 'oslash', 'questiondown', 'exclamdown', 'logicalnot', None, 'florin', None, None, 'guillemotleft', 'guillemotright', 'ellipsis', 'space', 'Agrave', 'Atilde', 'Otilde', 'OE', 'oe', 'endash', 'emdash', 'quotedblleft', 'quotedblright', 'quoteleft', 'quoteright', 'divide', None, 'ydieresis', 'Ydieresis', 'fraction', 'currency', 'guilsinglleft', 'guilsinglright', 'fi', 'fl', 'daggerdbl', 'periodcentered', 'quotesinglbase', 'quotedblbase', 'perthousand', 'Acircumflex', 'Ecircumflex', 'Aacute', 'Edieresis', 'Egrave', 'Iacute', 'Icircumflex', 'Idieresis', 'Igrave', 'Oacute', 'Ocircumflex', None, 'Ograve', 'Uacute', 'Ucircumflex', 'Ugrave', 'dotlessi', 'circumflex', 'tilde', 'macron', 'breve', 'dotaccent', 'ring', 'cedilla', 'hungarumlaut', 'ogonek', 'caron') encodings['SymbolEncoding']=(None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'space', 'exclam', 'universal', 'numbersign', 'existential', 'percent', 'ampersand', 'suchthat', 'parenleft', 'parenright', 'asteriskmath', 'plus', 'comma', 'minus', 'period', 'slash', 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon', 'less', 'equal', 'greater', 'question', 'congruent', 'Alpha', 'Beta', 'Chi', 'Delta', 'Epsilon', 'Phi', 'Gamma', 'Eta', 'Iota', 'theta1', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Omicron', 'Pi', 'Theta', 'Rho', 'Sigma', 'Tau', 'Upsilon', 'sigma1', 'Omega', 'Xi', 'Psi', 'Zeta', 'bracketleft', 'therefore', 'bracketright', 'perpendicular', 'underscore', 'radicalex', 'alpha', 'beta', 'chi', 'delta', 'epsilon', 'phi', 'gamma', 'eta', 'iota', 'phi1', 'kappa', 'lambda', 'mu', 'nu', 'omicron', 'pi', 'theta', 'rho', 'sigma', 'tau', 'upsilon', 'omega1', 'omega', 'xi', 'psi', 'zeta', 'braceleft', 'bar', 'braceright', 'similar', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'Euro', 'Upsilon1', 'minute', 'lessequal', 'fraction', 'infinity', 'florin', 'club', 'diamond', 'heart', 'spade', 'arrowboth', 'arrowleft', 'arrowup', 'arrowright', 'arrowdown', 'degree', 'plusminus', 'second', 'greaterequal', 'multiply', 'proportional', 'partialdiff', 'bullet', 'divide', 'notequal', 'equivalence', 'approxequal', 'ellipsis', 'arrowvertex', 'arrowhorizex', 'carriagereturn', 'aleph', 'Ifraktur', 'Rfraktur', 'weierstrass', 'circlemultiply', 'circleplus', 'emptyset', 'intersection', 'union', 'propersuperset', 'reflexsuperset', 'notsubset', 'propersubset', 'reflexsubset', 'element', 'notelement', 'angle', 'gradient', 'registerserif', 'copyrightserif', 'trademarkserif', 'product', 'radical', 'dotmath', 'logicalnot', 'logicaland', 'logicalor', 'arrowdblboth', 'arrowdblleft', 'arrowdblup', 'arrowdblright', 'arrowdbldown', 'lozenge', 'angleleft', 'registersans', 'copyrightsans', 'trademarksans', 'summation', 'parenlefttp', 'parenleftex', 'parenleftbt', 'bracketlefttp', 'bracketleftex', 'bracketleftbt', 'bracelefttp', 'braceleftmid', 'braceleftbt', 'braceex', None, 'angleright', 'integral', 'integraltp', 'integralex', 'integralbt', 'parenrighttp', 'parenrightex', 'parenrightbt', 'bracketrighttp', 'bracketrightex', 'bracketrightbt', 'bracerighttp', 'bracerightmid', 'bracerightbt', None) encodings['ZapfDingbatsEncoding'] = ( None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'space', 'a1', 'a2', 'a202', 'a3', 'a4', 'a5', 'a119', 'a118', 'a117', 'a11', 'a12', 'a13', 'a14', 'a15', 'a16', 'a105', 'a17', 'a18', 'a19', 'a20', 'a21', 'a22', 'a23', 'a24', 'a25', 'a26', 'a27', 'a28', 'a6', 'a7', 'a8', 'a9', 'a10', 'a29', 'a30', 'a31', 'a32', 'a33', 'a34', 'a35', 'a36', 'a37', 'a38', 'a39', 'a40', 'a41', 'a42', 'a43', 'a44', 'a45', 'a46', 'a47', 'a48', 'a49', 'a50', 'a51', 'a52', 'a53', 'a54', 'a55', 'a56', 'a57', 'a58', 'a59', 'a60', 'a61', 'a62', 'a63', 'a64', 'a65', 'a66', 'a67', 'a68', 'a69', 'a70', 'a71', 'a72', 'a73', 'a74', 'a203', 'a75', 'a204', 'a76', 'a77', 'a78', 'a79', 'a81', 'a82', 'a83', 'a84', 'a97', 'a98', 'a99', 'a100', None, 'a89', 'a90', 'a93', 'a94', 'a91', 'a92', 'a205', 'a85', 'a206', 'a86', 'a87', 'a88', 'a95', 'a96', None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'a101', 'a102', 'a103', 'a104', 'a106', 'a107', 'a108', 'a112', 'a111', 'a110', 'a109', 'a120', 'a121', 'a122', 'a123', 'a124', 'a125', 'a126', 'a127', 'a128', 'a129', 'a130', 'a131', 'a132', 'a133', 'a134', 'a135', 'a136', 'a137', 'a138', 'a139', 'a140', 'a141', 'a142', 'a143', 'a144', 'a145', 'a146', 'a147', 'a148', 'a149', 'a150', 'a151', 'a152', 'a153', 'a154', 'a155', 'a156', 'a157', 'a158', 'a159', 'a160', 'a161', 'a163', 'a164', 'a196', 'a165', 'a192', 'a166', 'a167', 'a168', 'a169', 'a170', 'a171', 'a172', 'a173', 'a162', 'a174', 'a175', 'a176', 'a177', 'a178', 'a179', 'a193', 'a180', 'a199', 'a181', 'a200', 'a182', None, 'a201', 'a183', 'a184', 'a197', 'a185', 'a194', 'a198', 'a186', 'a195', 'a187', 'a188', 'a189', 'a190', 'a191', None) encodings['StandardEncoding']=(None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,"space","exclam", "quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus", "comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon", "semicolon","less","equal","greater","question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O", "P","Q","R","S","T","U","V","W","X","Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore", "quoteleft","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y", "z","braceleft","bar","braceright","asciitilde",None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None, None,None,None,"exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft", "guillemotleft","guilsinglleft","guilsinglright","fi","fl",None,"endash","dagger","daggerdbl","periodcentered",None, "paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand", None,"questiondown",None,"grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis",None,"ring", "cedilla",None,"hungarumlaut","ogonek","caron","emdash",None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,"AE",None,"ordfeminine", None,None,None,None,"Lslash","Oslash","OE","ordmasculine",None,None,None,None,None,"ae",None,None,None,"dotlessi",None,None,"lslash","oslash", "oe","germandbls",None,None,None,None) encodings['PDFDocEncoding']=(None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None, None,None,None,None,None,"breve","caron","circumflex", "dotaccent","hungarumlaut","ogonek","ring","tilde","space","exclam","quotedbl","numbersign","dollar","percent", "ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero", "one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater", "question","at","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X", "Y","Z","bracketleft","backslash","bracketright","asciicircum","underscore","grave","a","b","c","d","e","f","g", "h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","braceleft","bar","braceright", "asciitilde",None,"bullet","dagger","daggerdbl","ellipsis","emdash","endash","florin","fraction","guilsinglleft", "guilsinglright","minus","perthousand","quotedblbase","quotedblleft","quotedblright","quoteleft","quoteright", "quotesinglbase","trademark","fi","fl","Lslash","OE","Scaron","Ydieresis","Zcaron","dotlessi","lslash","oe", "scaron","zcaron",None,"Euro","exclamdown","cent","sterling","currency","yen","brokenbar","section","dieresis", "copyright","ordfeminine","guillemotleft","logicalnot",None,"registered","macron","degree","plusminus","twosuperior", "threesuperior","acute","mu","paragraph","periodcentered","cedilla","onesuperior","ordmasculine","guillemotright", "onequarter","onehalf","threequarters","questiondown","Agrave","Aacute","Acircumflex","Atilde","Adieresis","Aring", "AE","Ccedilla","Egrave","Eacute","Ecircumflex","Edieresis","Igrave","Iacute","Icircumflex","Idieresis","Eth", "Ntilde","Ograve","Oacute","Ocircumflex","Otilde","Odieresis","multiply","Oslash","Ugrave","Uacute","Ucircumflex", "Udieresis","Yacute","Thorn","germandbls","agrave","aacute","acircumflex","atilde","adieresis","aring","ae", "ccedilla","egrave","eacute","ecircumflex","edieresis","igrave","iacute","icircumflex","idieresis","eth","ntilde", "ograve","oacute","ocircumflex","otilde","odieresis","divide","oslash","ugrave","uacute","ucircumflex","udieresis", "yacute","thorn","ydieresis") encodings['MacExpertEncoding'] = (None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 'space', 'exclamsmall', 'Hungarumlautsmall', 'centoldstyle', 'dollaroldstyle', 'dollarsuperior', 'ampersandsmall', 'Acutesmall', 'parenleftsuperior', 'parenrightsuperior', 'twodotenleader', 'onedotenleader', 'comma', 'hyphen', 'period', 'fraction', 'zerooldstyle', 'oneoldstyle', 'twooldstyle', 'threeoldstyle', 'fouroldstyle', 'fiveoldstyle', 'sixoldstyle', 'sevenoldstyle', 'eightoldstyle', 'nineoldstyle', 'colon', 'semicolon', None, 'threequartersemdash', None, 'questionsmall', None, None, None, None, 'Ethsmall', None, None, 'onequarter', 'onehalf', 'threequarters', 'oneeighth', 'threeeighths', 'fiveeighths', 'seveneighths', 'onethird', 'twothirds', None, None, None, None, None, None, 'ff', 'fi', 'fl', 'ffi', 'ffl', 'parenleftinferior', None, 'parenrightinferior', 'Circumflexsmall', 'hypheninferior', 'Gravesmall', 'Asmall', 'Bsmall', 'Csmall', 'Dsmall', 'Esmall', 'Fsmall', 'Gsmall', 'Hsmall', 'Ismall', 'Jsmall', 'Ksmall', 'Lsmall', 'Msmall', 'Nsmall', 'Osmall', 'Psmall', 'Qsmall', 'Rsmall', 'Ssmall', 'Tsmall', 'Usmall', 'Vsmall', 'Wsmall', 'Xsmall', 'Ysmall', 'Zsmall', 'colonmonetary', 'onefitted', 'rupiah', 'Tildesmall', None, None, 'asuperior', 'centsuperior', None, None, None, None, 'Aacutesmall', 'Agravesmall', 'Acircumflexsmall', 'Adieresissmall', 'Atildesmall', 'Aringsmall', 'Ccedillasmall', 'Eacutesmall', 'Egravesmall', 'Ecircumflexsmall', 'Edieresissmall', 'Iacutesmall', 'Igravesmall', 'Icircumflexsmall', 'Idieresissmall', 'Ntildesmall', 'Oacutesmall', 'Ogravesmall', 'Ocircumflexsmall', 'Odieresissmall', 'Otildesmall', 'Uacutesmall', 'Ugravesmall', 'Ucircumflexsmall', 'Udieresissmall', None, 'eightsuperior', 'fourinferior', 'threeinferior', 'sixinferior', 'eightinferior', 'seveninferior', 'Scaronsmall', None, 'centinferior', 'twoinferior', None, 'Dieresissmall', None, 'Caronsmall', 'osuperior', 'fiveinferior', None, 'commainferior', 'periodinferior', 'Yacutesmall', None, 'dollarinferior', None, None, 'Thornsmall', None, 'nineinferior', 'zeroinferior', 'Zcaronsmall', 'AEsmall', 'Oslashsmall', 'questiondownsmall', 'oneinferior', 'Lslashsmall', None, None, None, None, None, None, 'Cedillasmall', None, None, None, None, None, 'OEsmall', 'figuredash', 'hyphensuperior', None, None, None, None, 'exclamdownsmall', None, 'Ydieresissmall', None, 'onesuperior', 'twosuperior', 'threesuperior', 'foursuperior', 'fivesuperior', 'sixsuperior', 'sevensuperior', 'ninesuperior', 'zerosuperior', None, 'esuperior', 'rsuperior', 'tsuperior', None, None, 'isuperior', 'ssuperior', 'dsuperior', None, None, None, None, None, 'lsuperior', 'Ogoneksmall', 'Brevesmall', 'Macronsmall', 'bsuperior', 'nsuperior', 'msuperior', 'commasuperior', 'periodsuperior', 'Dotaccentsmall', 'Ringsmall', None, None, None, None) ascent_descent = { 'Courier': (629, -157), 'Courier-Bold': (626, -142), 'Courier-BoldOblique': (626, -142), 'Courier-Oblique': (629, -157), 'Helvetica': (718, -207), 'Helvetica-Bold': (718, -207), 'Helvetica-BoldOblique': (718, -207), 'Helvetica-Oblique': (718, -207), 'Times-Roman': (683, -217), 'Times-Bold': (676, -205), 'Times-BoldItalic': (699, -205), 'Times-Italic': (683, -205), 'Symbol': (0, 0), 'ZapfDingbats': (0, 0) } # nuild this up one entry at a time to stay under JPython's 64k limit. widthsByFontGlyph = {} widthsByFontGlyph['Helvetica'] = {'A': 667, 'AE': 1000, 'Aacute': 667, 'Acircumflex': 667, 'Adieresis': 667, 'Agrave': 667, 'Aring': 667, 'Atilde': 667, 'B': 667, 'C': 722, 'Ccedilla': 722, 'D': 722, 'E': 667, 'Eacute': 667, 'Ecircumflex': 667, 'Edieresis': 667, 'Egrave': 667, 'Eth': 722, 'Euro': 556, 'F': 611, 'G': 778, 'H': 722, 'I': 278, 'Iacute': 278, 'Icircumflex': 278, 'Idieresis': 278, 'Igrave': 278, 'J': 500, 'K': 667, 'L': 556, 'Lslash': 556, 'M': 833, 'N': 722, 'Ntilde': 722, 'O': 778, 'OE': 1000, 'Oacute': 778, 'Ocircumflex': 778, 'Odieresis': 778, 'Ograve': 778, 'Oslash': 778, 'Otilde': 778, 'P': 667, 'Q': 778, 'R': 722, 'S': 667, 'Scaron': 667, 'T': 611, 'Thorn': 667, 'U': 722, 'Uacute': 722, 'Ucircumflex': 722, 'Udieresis': 722, 'Ugrave': 722, 'V': 667, 'W': 944, 'X': 667, 'Y': 667, 'Yacute': 667, 'Ydieresis': 667, 'Z': 611, 'Zcaron': 611, 'a': 556, 'aacute': 556, 'acircumflex': 556, 'acute': 333, 'adieresis': 556, 'ae': 889, 'agrave': 556, 'ampersand': 667, 'aring': 556, 'asciicircum': 469, 'asciitilde': 584, 'asterisk': 389, 'at': 1015, 'atilde': 556, 'b': 556, 'backslash': 278, 'bar': 260, 'braceleft': 334, 'braceright': 334, 'bracketleft': 278, 'bracketright': 278, 'breve': 333, 'brokenbar': 260, 'bullet': 350, 'c': 500, 'caron': 333, 'ccedilla': 500, 'cedilla': 333, 'cent': 556, 'circumflex': 333, 'colon': 278, 'comma': 278, 'copyright': 737, 'currency': 556, 'd': 556, 'dagger': 556, 'daggerdbl': 556, 'degree': 400, 'dieresis': 333, 'divide': 584, 'dollar': 556, 'dotaccent': 333, 'dotlessi': 278, 'e': 556, 'eacute': 556, 'ecircumflex': 556, 'edieresis': 556, 'egrave': 556, 'eight': 556, 'ellipsis': 1000, 'emdash': 1000, 'endash': 556, 'equal': 584, 'eth': 556, 'exclam': 278, 'exclamdown': 333, 'f': 278, 'fi': 500, 'five': 556, 'fl': 500, 'florin': 556, 'four': 556, 'fraction': 167, 'g': 556, 'germandbls': 611, 'grave': 333, 'greater': 584, 'guillemotleft': 556, 'guillemotright': 556, 'guilsinglleft': 333, 'guilsinglright': 333, 'h': 556, 'hungarumlaut': 333, 'hyphen': 333, 'i': 222, 'iacute': 278, 'icircumflex': 278, 'idieresis': 278, 'igrave': 278, 'j': 222, 'k': 500, 'l': 222, 'less': 584, 'logicalnot': 584, 'lslash': 222, 'm': 833, 'macron': 333, 'minus': 584, 'mu': 556, 'multiply': 584, 'n': 556, 'nine': 556, 'ntilde': 556, 'numbersign': 556, 'o': 556, 'oacute': 556, 'ocircumflex': 556, 'odieresis': 556, 'oe': 944, 'ogonek': 333, 'ograve': 556, 'one': 556, 'onehalf': 834, 'onequarter': 834, 'onesuperior': 333, 'ordfeminine': 370, 'ordmasculine': 365, 'oslash': 611, 'otilde': 556, 'p': 556, 'paragraph': 537, 'parenleft': 333, 'parenright': 333, 'percent': 889, 'period': 278, 'periodcentered': 278, 'perthousand': 1000, 'plus': 584, 'plusminus': 584, 'q': 556, 'question': 556, 'questiondown': 611, 'quotedbl': 355, 'quotedblbase': 333, 'quotedblleft': 333, 'quotedblright': 333, 'quoteleft': 222, 'quoteright': 222, 'quotesinglbase': 222, 'quotesingle': 191, 'r': 333, 'registered': 737, 'ring': 333, 's': 500, 'scaron': 500, 'section': 556, 'semicolon': 278, 'seven': 556, 'six': 556, 'slash': 278, 'space': 278, 'sterling': 556, 't': 278, 'thorn': 556, 'three': 556, 'threequarters': 834, 'threesuperior': 333, 'tilde': 333, 'trademark': 1000, 'two': 556, 'twosuperior': 333, 'u': 556, 'uacute': 556, 'ucircumflex': 556, 'udieresis': 556, 'ugrave': 556, 'underscore': 556, 'v': 500, 'w': 722, 'x': 500, 'y': 500, 'yacute': 500, 'ydieresis': 500, 'yen': 556, 'z': 500, 'zcaron': 500, 'zero': 556} widthsByFontGlyph['Helvetica-Bold'] = {'A': 722, 'AE': 1000, 'Aacute': 722, 'Acircumflex': 722, 'Adieresis': 722, 'Agrave': 722, 'Aring': 722, 'Atilde': 722, 'B': 722, 'C': 722, 'Ccedilla': 722, 'D': 722, 'E': 667, 'Eacute': 667, 'Ecircumflex': 667, 'Edieresis': 667, 'Egrave': 667, 'Eth': 722, 'Euro': 556, 'F': 611, 'G': 778, 'H': 722, 'I': 278, 'Iacute': 278, 'Icircumflex': 278, 'Idieresis': 278, 'Igrave': 278, 'J': 556, 'K': 722, 'L': 611, 'Lslash': 611, 'M': 833, 'N': 722, 'Ntilde': 722, 'O': 778, 'OE': 1000, 'Oacute': 778, 'Ocircumflex': 778, 'Odieresis': 778, 'Ograve': 778, 'Oslash': 778, 'Otilde': 778, 'P': 667, 'Q': 778, 'R': 722, 'S': 667, 'Scaron': 667, 'T': 611, 'Thorn': 667, 'U': 722, 'Uacute': 722, 'Ucircumflex': 722, 'Udieresis': 722, 'Ugrave': 722, 'V': 667, 'W': 944, 'X': 667, 'Y': 667, 'Yacute': 667, 'Ydieresis': 667, 'Z': 611, 'Zcaron': 611, 'a': 556, 'aacute': 556, 'acircumflex': 556, 'acute': 333, 'adieresis': 556, 'ae': 889, 'agrave': 556, 'ampersand': 722, 'aring': 556, 'asciicircum': 584, 'asciitilde': 584, 'asterisk': 389, 'at': 975, 'atilde': 556, 'b': 611, 'backslash': 278, 'bar': 280, 'braceleft': 389, 'braceright': 389, 'bracketleft': 333, 'bracketright': 333, 'breve': 333, 'brokenbar': 280, 'bullet': 350, 'c': 556, 'caron': 333, 'ccedilla': 556, 'cedilla': 333, 'cent': 556, 'circumflex': 333, 'colon': 333, 'comma': 278, 'copyright': 737, 'currency': 556, 'd': 611, 'dagger': 556, 'daggerdbl': 556, 'degree': 400, 'dieresis': 333, 'divide': 584, 'dollar': 556, 'dotaccent': 333, 'dotlessi': 278, 'e': 556, 'eacute': 556, 'ecircumflex': 556, 'edieresis': 556, 'egrave': 556, 'eight': 556, 'ellipsis': 1000, 'emdash': 1000, 'endash': 556, 'equal': 584, 'eth': 611, 'exclam': 333, 'exclamdown': 333, 'f': 333, 'fi': 611, 'five': 556, 'fl': 611, 'florin': 556, 'four': 556, 'fraction': 167, 'g': 611, 'germandbls': 611, 'grave': 333, 'greater': 584, 'guillemotleft': 556, 'guillemotright': 556, 'guilsinglleft': 333, 'guilsinglright': 333, 'h': 611, 'hungarumlaut': 333, 'hyphen': 333, 'i': 278, 'iacute': 278, 'icircumflex': 278, 'idieresis': 278, 'igrave': 278, 'j': 278, 'k': 556, 'l': 278, 'less': 584, 'logicalnot': 584, 'lslash': 278, 'm': 889, 'macron': 333, 'minus': 584, 'mu': 611, 'multiply': 584, 'n': 611, 'nine': 556, 'ntilde': 611, 'numbersign': 556, 'o': 611, 'oacute': 611, 'ocircumflex': 611, 'odieresis': 611, 'oe': 944, 'ogonek': 333, 'ograve': 611, 'one': 556, 'onehalf': 834, 'onequarter': 834, 'onesuperior': 333, 'ordfeminine': 370, 'ordmasculine': 365, 'oslash': 611, 'otilde': 611, 'p': 611, 'paragraph': 556, 'parenleft': 333, 'parenright': 333, 'percent': 889, 'period': 278, 'periodcentered': 278, 'perthousand': 1000, 'plus': 584, 'plusminus': 584, 'q': 611, 'question': 611, 'questiondown': 611, 'quotedbl': 474, 'quotedblbase': 500, 'quotedblleft': 500, 'quotedblright': 500, 'quoteleft': 278, 'quoteright': 278, 'quotesinglbase': 278, 'quotesingle': 238, 'r': 389, 'registered': 737, 'ring': 333, 's': 556, 'scaron': 556, 'section': 556, 'semicolon': 333, 'seven': 556, 'six': 556, 'slash': 278, 'space': 278, 'sterling': 556, 't': 333, 'thorn': 611, 'three': 556, 'threequarters': 834, 'threesuperior': 333, 'tilde': 333, 'trademark': 1000, 'two': 556, 'twosuperior': 333, 'u': 611, 'uacute': 611, 'ucircumflex': 611, 'udieresis': 611, 'ugrave': 611, 'underscore': 556, 'v': 556, 'w': 778, 'x': 556, 'y': 556, 'yacute': 556, 'ydieresis': 556, 'yen': 556, 'z': 500, 'zcaron': 500, 'zero': 556} widthsByFontGlyph['Helvetica-Oblique'] = {'A': 667, 'AE': 1000, 'Aacute': 667, 'Acircumflex': 667, 'Adieresis': 667, 'Agrave': 667, 'Aring': 667, 'Atilde': 667, 'B': 667, 'C': 722, 'Ccedilla': 722, 'D': 722, 'E': 667, 'Eacute': 667, 'Ecircumflex': 667, 'Edieresis': 667, 'Egrave': 667, 'Eth': 722, 'Euro': 556, 'F': 611, 'G': 778, 'H': 722, 'I': 278, 'Iacute': 278, 'Icircumflex': 278, 'Idieresis': 278, 'Igrave': 278, 'J': 500, 'K': 667, 'L': 556, 'Lslash': 556, 'M': 833, 'N': 722, 'Ntilde': 722, 'O': 778, 'OE': 1000, 'Oacute': 778, 'Ocircumflex': 778, 'Odieresis': 778, 'Ograve': 778, 'Oslash': 778, 'Otilde': 778, 'P': 667, 'Q': 778, 'R': 722, 'S': 667, 'Scaron': 667, 'T': 611, 'Thorn': 667, 'U': 722, 'Uacute': 722, 'Ucircumflex': 722, 'Udieresis': 722, 'Ugrave': 722, 'V': 667, 'W': 944, 'X': 667, 'Y': 667, 'Yacute': 667, 'Ydieresis': 667, 'Z': 611, 'Zcaron': 611, 'a': 556, 'aacute': 556, 'acircumflex': 556, 'acute': 333, 'adieresis': 556, 'ae': 889, 'agrave': 556, 'ampersand': 667, 'aring': 556, 'asciicircum': 469, 'asciitilde': 584, 'asterisk': 389, 'at': 1015, 'atilde': 556, 'b': 556, 'backslash': 278, 'bar': 260, 'braceleft': 334, 'braceright': 334, 'bracketleft': 278, 'bracketright': 278, 'breve': 333, 'brokenbar': 260, 'bullet': 350, 'c': 500, 'caron': 333, 'ccedilla': 500, 'cedilla': 333, 'cent': 556, 'circumflex': 333, 'colon': 278, 'comma': 278, 'copyright': 737, 'currency': 556, 'd': 556, 'dagger': 556, 'daggerdbl': 556, 'degree': 400, 'dieresis': 333, 'divide': 584, 'dollar': 556, 'dotaccent': 333, 'dotlessi': 278, 'e': 556, 'eacute': 556, 'ecircumflex': 556, 'edieresis': 556, 'egrave': 556, 'eight': 556, 'ellipsis': 1000, 'emdash': 1000, 'endash': 556, 'equal': 584, 'eth': 556, 'exclam': 278, 'exclamdown': 333, 'f': 278, 'fi': 500, 'five': 556, 'fl': 500, 'florin': 556, 'four': 556, 'fraction': 167, 'g': 556, 'germandbls': 611, 'grave': 333, 'greater': 584, 'guillemotleft': 556, 'guillemotright': 556, 'guilsinglleft': 333, 'guilsinglright': 333, 'h': 556, 'hungarumlaut': 333, 'hyphen': 333, 'i': 222, 'iacute': 278, 'icircumflex': 278, 'idieresis': 278, 'igrave': 278, 'j': 222, 'k': 500, 'l': 222, 'less': 584, 'logicalnot': 584, 'lslash': 222, 'm': 833, 'macron': 333, 'minus': 584, 'mu': 556, 'multiply': 584, 'n': 556, 'nine': 556, 'ntilde': 556, 'numbersign': 556, 'o': 556, 'oacute': 556, 'ocircumflex': 556, 'odieresis': 556, 'oe': 944, 'ogonek': 333, 'ograve': 556, 'one': 556, 'onehalf': 834, 'onequarter': 834, 'onesuperior': 333, 'ordfeminine': 370, 'ordmasculine': 365, 'oslash': 611, 'otilde': 556, 'p': 556, 'paragraph': 537, 'parenleft': 333, 'parenright': 333, 'percent': 889, 'period': 278, 'periodcentered': 278, 'perthousand': 1000, 'plus': 584, 'plusminus': 584, 'q': 556, 'question': 556, 'questiondown': 611, 'quotedbl': 355, 'quotedblbase': 333, 'quotedblleft': 333, 'quotedblright': 333, 'quoteleft': 222, 'quoteright': 222, 'quotesinglbase': 222, 'quotesingle': 191, 'r': 333, 'registered': 737, 'ring': 333, 's': 500, 'scaron': 500, 'section': 556, 'semicolon': 278, 'seven': 556, 'six': 556, 'slash': 278, 'space': 278, 'sterling': 556, 't': 278, 'thorn': 556, 'three': 556, 'threequarters': 834, 'threesuperior': 333, 'tilde': 333, 'trademark': 1000, 'two': 556, 'twosuperior': 333, 'u': 556, 'uacute': 556, 'ucircumflex': 556, 'udieresis': 556, 'ugrave': 556, 'underscore': 556, 'v': 500, 'w': 722, 'x': 500, 'y': 500, 'yacute': 500, 'ydieresis': 500, 'yen': 556, 'z': 500, 'zcaron': 500, 'zero': 556} widthsByFontGlyph['Helvetica-BoldOblique'] = {'A': 722, 'AE': 1000, 'Aacute': 722, 'Acircumflex': 722, 'Adieresis': 722, 'Agrave': 722, 'Aring': 722, 'Atilde': 722, 'B': 722, 'C': 722, 'Ccedilla': 722, 'D': 722, 'E': 667, 'Eacute': 667, 'Ecircumflex': 667, 'Edieresis': 667, 'Egrave': 667, 'Eth': 722, 'Euro': 556, 'F': 611, 'G': 778, 'H': 722, 'I': 278, 'Iacute': 278, 'Icircumflex': 278, 'Idieresis': 278, 'Igrave': 278, 'J': 556, 'K': 722, 'L': 611, 'Lslash': 611, 'M': 833, 'N': 722, 'Ntilde': 722, 'O': 778, 'OE': 1000, 'Oacute': 778, 'Ocircumflex': 778, 'Odieresis': 778, 'Ograve': 778, 'Oslash': 778, 'Otilde': 778, 'P': 667, 'Q': 778, 'R': 722, 'S': 667, 'Scaron': 667, 'T': 611, 'Thorn': 667, 'U': 722, 'Uacute': 722, 'Ucircumflex': 722, 'Udieresis': 722, 'Ugrave': 722, 'V': 667, 'W': 944, 'X': 667, 'Y': 667, 'Yacute': 667, 'Ydieresis': 667, 'Z': 611, 'Zcaron': 611, 'a': 556, 'aacute': 556, 'acircumflex': 556, 'acute': 333, 'adieresis': 556, 'ae': 889, 'agrave': 556, 'ampersand': 722, 'aring': 556, 'asciicircum': 584, 'asciitilde': 584, 'asterisk': 389, 'at': 975, 'atilde': 556, 'b': 611, 'backslash': 278, 'bar': 280, 'braceleft': 389, 'braceright': 389, 'bracketleft': 333, 'bracketright': 333, 'breve': 333, 'brokenbar': 280, 'bullet': 350, 'c': 556, 'caron': 333, 'ccedilla': 556, 'cedilla': 333, 'cent': 556, 'circumflex': 333, 'colon': 333, 'comma': 278, 'copyright': 737, 'currency': 556, 'd': 611, 'dagger': 556, 'daggerdbl': 556, 'degree': 400, 'dieresis': 333, 'divide': 584, 'dollar': 556, 'dotaccent': 333, 'dotlessi': 278, 'e': 556, 'eacute': 556, 'ecircumflex': 556, 'edieresis': 556, 'egrave': 556, 'eight': 556, 'ellipsis': 1000, 'emdash': 1000, 'endash': 556, 'equal': 584, 'eth': 611, 'exclam': 333, 'exclamdown': 333, 'f': 333, 'fi': 611, 'five': 556, 'fl': 611, 'florin': 556, 'four': 556, 'fraction': 167, 'g': 611, 'germandbls': 611, 'grave': 333, 'greater': 584, 'guillemotleft': 556, 'guillemotright': 556, 'guilsinglleft': 333, 'guilsinglright': 333, 'h': 611, 'hungarumlaut': 333, 'hyphen': 333, 'i': 278, 'iacute': 278, 'icircumflex': 278, 'idieresis': 278, 'igrave': 278, 'j': 278, 'k': 556, 'l': 278, 'less': 584, 'logicalnot': 584, 'lslash': 278, 'm': 889, 'macron': 333, 'minus': 584, 'mu': 611, 'multiply': 584, 'n': 611, 'nine': 556, 'ntilde': 611, 'numbersign': 556, 'o': 611, 'oacute': 611, 'ocircumflex': 611, 'odieresis': 611, 'oe': 944, 'ogonek': 333, 'ograve': 611, 'one': 556, 'onehalf': 834, 'onequarter': 834, 'onesuperior': 333, 'ordfeminine': 370, 'ordmasculine': 365, 'oslash': 611, 'otilde': 611, 'p': 611, 'paragraph': 556, 'parenleft': 333, 'parenright': 333, 'percent': 889, 'period': 278, 'periodcentered': 278, 'perthousand': 1000, 'plus': 584, 'plusminus': 584, 'q': 611, 'question': 611, 'questiondown': 611, 'quotedbl': 474, 'quotedblbase': 500, 'quotedblleft': 500, 'quotedblright': 500, 'quoteleft': 278, 'quoteright': 278, 'quotesinglbase': 278, 'quotesingle': 238, 'r': 389, 'registered': 737, 'ring': 333, 's': 556, 'scaron': 556, 'section': 556, 'semicolon': 333, 'seven': 556, 'six': 556, 'slash': 278, 'space': 278, 'sterling': 556, 't': 333, 'thorn': 611, 'three': 556, 'threequarters': 834, 'threesuperior': 333, 'tilde': 333, 'trademark': 1000, 'two': 556, 'twosuperior': 333, 'u': 611, 'uacute': 611, 'ucircumflex': 611, 'udieresis': 611, 'ugrave': 611, 'underscore': 556, 'v': 556, 'w': 778, 'x': 556, 'y': 556, 'yacute': 556, 'ydieresis': 556, 'yen': 556, 'z': 500, 'zcaron': 500, 'zero': 556} # Courier can be expressed more compactly! _w = {} for charname in widthsByFontGlyph['Helvetica'].keys(): _w[charname] = 600 widthsByFontGlyph['Courier'] = _w widthsByFontGlyph['Courier-Bold'] = _w widthsByFontGlyph['Courier-Oblique'] = _w widthsByFontGlyph['Courier-BoldOblique'] = _w widthsByFontGlyph['Times-Roman'] = {'A': 722, 'AE': 889, 'Aacute': 722, 'Acircumflex': 722, 'Adieresis': 722, 'Agrave': 722, 'Aring': 722, 'Atilde': 722, 'B': 667, 'C': 667, 'Ccedilla': 667, 'D': 722, 'E': 611, 'Eacute': 611, 'Ecircumflex': 611, 'Edieresis': 611, 'Egrave': 611, 'Eth': 722, 'Euro': 500, 'F': 556, 'G': 722, 'H': 722, 'I': 333, 'Iacute': 333, 'Icircumflex': 333, 'Idieresis': 333, 'Igrave': 333, 'J': 389, 'K': 722, 'L': 611, 'Lslash': 611, 'M': 889, 'N': 722, 'Ntilde': 722, 'O': 722, 'OE': 889, 'Oacute': 722, 'Ocircumflex': 722, 'Odieresis': 722, 'Ograve': 722, 'Oslash': 722, 'Otilde': 722, 'P': 556, 'Q': 722, 'R': 667, 'S': 556, 'Scaron': 556, 'T': 611, 'Thorn': 556, 'U': 722, 'Uacute': 722, 'Ucircumflex': 722, 'Udieresis': 722, 'Ugrave': 722, 'V': 722, 'W': 944, 'X': 722, 'Y': 722, 'Yacute': 722, 'Ydieresis': 722, 'Z': 611, 'Zcaron': 611, 'a': 444, 'aacute': 444, 'acircumflex': 444, 'acute': 333, 'adieresis': 444, 'ae': 667, 'agrave': 444, 'ampersand': 778, 'aring': 444, 'asciicircum': 469, 'asciitilde': 541, 'asterisk': 500, 'at': 921, 'atilde': 444, 'b': 500, 'backslash': 278, 'bar': 200, 'braceleft': 480, 'braceright': 480, 'bracketleft': 333, 'bracketright': 333, 'breve': 333, 'brokenbar': 200, 'bullet': 350, 'c': 444, 'caron': 333, 'ccedilla': 444, 'cedilla': 333, 'cent': 500, 'circumflex': 333, 'colon': 278, 'comma': 250, 'copyright': 760, 'currency': 500, 'd': 500, 'dagger': 500, 'daggerdbl': 500, 'degree': 400, 'dieresis': 333, 'divide': 564, 'dollar': 500, 'dotaccent': 333, 'dotlessi': 278, 'e': 444, 'eacute': 444, 'ecircumflex': 444, 'edieresis': 444, 'egrave': 444, 'eight': 500, 'ellipsis': 1000, 'emdash': 1000, 'endash': 500, 'equal': 564, 'eth': 500, 'exclam': 333, 'exclamdown': 333, 'f': 333, 'fi': 556, 'five': 500, 'fl': 556, 'florin': 500, 'four': 500, 'fraction': 167, 'g': 500, 'germandbls': 500, 'grave': 333, 'greater': 564, 'guillemotleft': 500, 'guillemotright': 500, 'guilsinglleft': 333, 'guilsinglright': 333, 'h': 500, 'hungarumlaut': 333, 'hyphen': 333, 'i': 278, 'iacute': 278, 'icircumflex': 278, 'idieresis': 278, 'igrave': 278, 'j': 278, 'k': 500, 'l': 278, 'less': 564, 'logicalnot': 564, 'lslash': 278, 'm': 778, 'macron': 333, 'minus': 564, 'mu': 500, 'multiply': 564, 'n': 500, 'nine': 500, 'ntilde': 500, 'numbersign': 500, 'o': 500, 'oacute': 500, 'ocircumflex': 500, 'odieresis': 500, 'oe': 722, 'ogonek': 333, 'ograve': 500, 'one': 500, 'onehalf': 750, 'onequarter': 750, 'onesuperior': 300, 'ordfeminine': 276, 'ordmasculine': 310, 'oslash': 500, 'otilde': 500, 'p': 500, 'paragraph': 453, 'parenleft': 333, 'parenright': 333, 'percent': 833, 'period': 250, 'periodcentered': 250, 'perthousand': 1000, 'plus': 564, 'plusminus': 564, 'q': 500, 'question': 444, 'questiondown': 444, 'quotedbl': 408, 'quotedblbase': 444, 'quotedblleft': 444, 'quotedblright': 444, 'quoteleft': 333, 'quoteright': 333, 'quotesinglbase': 333, 'quotesingle': 180, 'r': 333, 'registered': 760, 'ring': 333, 's': 389, 'scaron': 389, 'section': 500, 'semicolon': 278, 'seven': 500, 'six': 500, 'slash': 278, 'space': 250, 'sterling': 500, 't': 278, 'thorn': 500, 'three': 500, 'threequarters': 750, 'threesuperior': 300, 'tilde': 333, 'trademark': 980, 'two': 500, 'twosuperior': 300, 'u': 500, 'uacute': 500, 'ucircumflex': 500, 'udieresis': 500, 'ugrave': 500, 'underscore': 500, 'v': 500, 'w': 722, 'x': 500, 'y': 500, 'yacute': 500, 'ydieresis': 500, 'yen': 500, 'z': 444, 'zcaron': 444, 'zero': 500} widthsByFontGlyph['Times-Bold'] = {'A': 722, 'AE': 1000, 'Aacute': 722, 'Acircumflex': 722, 'Adieresis': 722, 'Agrave': 722, 'Aring': 722, 'Atilde': 722, 'B': 667, 'C': 722, 'Ccedilla': 722, 'D': 722, 'E': 667, 'Eacute': 667, 'Ecircumflex': 667, 'Edieresis': 667, 'Egrave': 667, 'Eth': 722, 'Euro': 500, 'F': 611, 'G': 778, 'H': 778, 'I': 389, 'Iacute': 389, 'Icircumflex': 389, 'Idieresis': 389, 'Igrave': 389, 'J': 500, 'K': 778, 'L': 667, 'Lslash': 667, 'M': 944, 'N': 722, 'Ntilde': 722, 'O': 778, 'OE': 1000, 'Oacute': 778, 'Ocircumflex': 778, 'Odieresis': 778, 'Ograve': 778, 'Oslash': 778, 'Otilde': 778, 'P': 611, 'Q': 778, 'R': 722, 'S': 556, 'Scaron': 556, 'T': 667, 'Thorn': 611, 'U': 722, 'Uacute': 722, 'Ucircumflex': 722, 'Udieresis': 722, 'Ugrave': 722, 'V': 722, 'W': 1000, 'X': 722, 'Y': 722, 'Yacute': 722, 'Ydieresis': 722, 'Z': 667, 'Zcaron': 667, 'a': 500, 'aacute': 500, 'acircumflex': 500, 'acute': 333, 'adieresis': 500, 'ae': 722, 'agrave': 500, 'ampersand': 833, 'aring': 500, 'asciicircum': 581, 'asciitilde': 520, 'asterisk': 500, 'at': 930, 'atilde': 500, 'b': 556, 'backslash': 278, 'bar': 220, 'braceleft': 394, 'braceright': 394, 'bracketleft': 333, 'bracketright': 333, 'breve': 333, 'brokenbar': 220, 'bullet': 350, 'c': 444, 'caron': 333, 'ccedilla': 444, 'cedilla': 333, 'cent': 500, 'circumflex': 333, 'colon': 333, 'comma': 250, 'copyright': 747, 'currency': 500, 'd': 556, 'dagger': 500, 'daggerdbl': 500, 'degree': 400, 'dieresis': 333, 'divide': 570, 'dollar': 500, 'dotaccent': 333, 'dotlessi': 278, 'e': 444, 'eacute': 444, 'ecircumflex': 444, 'edieresis': 444, 'egrave': 444, 'eight': 500, 'ellipsis': 1000, 'emdash': 1000, 'endash': 500, 'equal': 570, 'eth': 500, 'exclam': 333, 'exclamdown': 333, 'f': 333, 'fi': 556, 'five': 500, 'fl': 556, 'florin': 500, 'four': 500, 'fraction': 167, 'g': 500, 'germandbls': 556, 'grave': 333, 'greater': 570, 'guillemotleft': 500, 'guillemotright': 500, 'guilsinglleft': 333, 'guilsinglright': 333, 'h': 556, 'hungarumlaut': 333, 'hyphen': 333, 'i': 278, 'iacute': 278, 'icircumflex': 278, 'idieresis': 278, 'igrave': 278, 'j': 333, 'k': 556, 'l': 278, 'less': 570, 'logicalnot': 570, 'lslash': 278, 'm': 833, 'macron': 333, 'minus': 570, 'mu': 556, 'multiply': 570, 'n': 556, 'nine': 500, 'ntilde': 556, 'numbersign': 500, 'o': 500, 'oacute': 500, 'ocircumflex': 500, 'odieresis': 500, 'oe': 722, 'ogonek': 333, 'ograve': 500, 'one': 500, 'onehalf': 750, 'onequarter': 750, 'onesuperior': 300, 'ordfeminine': 300, 'ordmasculine': 330, 'oslash': 500, 'otilde': 500, 'p': 556, 'paragraph': 540, 'parenleft': 333, 'parenright': 333, 'percent': 1000, 'period': 250, 'periodcentered': 250, 'perthousand': 1000, 'plus': 570, 'plusminus': 570, 'q': 556, 'question': 500, 'questiondown': 500, 'quotedbl': 555, 'quotedblbase': 500, 'quotedblleft': 500, 'quotedblright': 500, 'quoteleft': 333, 'quoteright': 333, 'quotesinglbase': 333, 'quotesingle': 278, 'r': 444, 'registered': 747, 'ring': 333, 's': 389, 'scaron': 389, 'section': 500, 'semicolon': 333, 'seven': 500, 'six': 500, 'slash': 278, 'space': 250, 'sterling': 500, 't': 333, 'thorn': 556, 'three': 500, 'threequarters': 750, 'threesuperior': 300, 'tilde': 333, 'trademark': 1000, 'two': 500, 'twosuperior': 300, 'u': 556, 'uacute': 556, 'ucircumflex': 556, 'udieresis': 556, 'ugrave': 556, 'underscore': 500, 'v': 500, 'w': 722, 'x': 500, 'y': 500, 'yacute': 500, 'ydieresis': 500, 'yen': 500, 'z': 444, 'zcaron': 444, 'zero': 500} widthsByFontGlyph['Times-Italic'] = {'A': 611, 'AE': 889, 'Aacute': 611, 'Acircumflex': 611, 'Adieresis': 611, 'Agrave': 611, 'Aring': 611, 'Atilde': 611, 'B': 611, 'C': 667, 'Ccedilla': 667, 'D': 722, 'E': 611, 'Eacute': 611, 'Ecircumflex': 611, 'Edieresis': 611, 'Egrave': 611, 'Eth': 722, 'Euro': 500, 'F': 611, 'G': 722, 'H': 722, 'I': 333, 'Iacute': 333, 'Icircumflex': 333, 'Idieresis': 333, 'Igrave': 333, 'J': 444, 'K': 667, 'L': 556, 'Lslash': 556, 'M': 833, 'N': 667, 'Ntilde': 667, 'O': 722, 'OE': 944, 'Oacute': 722, 'Ocircumflex': 722, 'Odieresis': 722, 'Ograve': 722, 'Oslash': 722, 'Otilde': 722, 'P': 611, 'Q': 722, 'R': 611, 'S': 500, 'Scaron': 500, 'T': 556, 'Thorn': 611, 'U': 722, 'Uacute': 722, 'Ucircumflex': 722, 'Udieresis': 722, 'Ugrave': 722, 'V': 611, 'W': 833, 'X': 611, 'Y': 556, 'Yacute': 556, 'Ydieresis': 556, 'Z': 556, 'Zcaron': 556, 'a': 500, 'aacute': 500, 'acircumflex': 500, 'acute': 333, 'adieresis': 500, 'ae': 667, 'agrave': 500, 'ampersand': 778, 'aring': 500, 'asciicircum': 422, 'asciitilde': 541, 'asterisk': 500, 'at': 920, 'atilde': 500, 'b': 500, 'backslash': 278, 'bar': 275, 'braceleft': 400, 'braceright': 400, 'bracketleft': 389, 'bracketright': 389, 'breve': 333, 'brokenbar': 275, 'bullet': 350, 'c': 444, 'caron': 333, 'ccedilla': 444, 'cedilla': 333, 'cent': 500, 'circumflex': 333, 'colon': 333, 'comma': 250, 'copyright': 760, 'currency': 500, 'd': 500, 'dagger': 500, 'daggerdbl': 500, 'degree': 400, 'dieresis': 333, 'divide': 675, 'dollar': 500, 'dotaccent': 333, 'dotlessi': 278, 'e': 444, 'eacute': 444, 'ecircumflex': 444, 'edieresis': 444, 'egrave': 444, 'eight': 500, 'ellipsis': 889, 'emdash': 889, 'endash': 500, 'equal': 675, 'eth': 500, 'exclam': 333, 'exclamdown': 389, 'f': 278, 'fi': 500, 'five': 500, 'fl': 500, 'florin': 500, 'four': 500, 'fraction': 167, 'g': 500, 'germandbls': 500, 'grave': 333, 'greater': 675, 'guillemotleft': 500, 'guillemotright': 500, 'guilsinglleft': 333, 'guilsinglright': 333, 'h': 500, 'hungarumlaut': 333, 'hyphen': 333, 'i': 278, 'iacute': 278, 'icircumflex': 278, 'idieresis': 278, 'igrave': 278, 'j': 278, 'k': 444, 'l': 278, 'less': 675, 'logicalnot': 675, 'lslash': 278, 'm': 722, 'macron': 333, 'minus': 675, 'mu': 500, 'multiply': 675, 'n': 500, 'nine': 500, 'ntilde': 500, 'numbersign': 500, 'o': 500, 'oacute': 500, 'ocircumflex': 500, 'odieresis': 500, 'oe': 667, 'ogonek': 333, 'ograve': 500, 'one': 500, 'onehalf': 750, 'onequarter': 750, 'onesuperior': 300, 'ordfeminine': 276, 'ordmasculine': 310, 'oslash': 500, 'otilde': 500, 'p': 500, 'paragraph': 523, 'parenleft': 333, 'parenright': 333, 'percent': 833, 'period': 250, 'periodcentered': 250, 'perthousand': 1000, 'plus': 675, 'plusminus': 675, 'q': 500, 'question': 500, 'questiondown': 500, 'quotedbl': 420, 'quotedblbase': 556, 'quotedblleft': 556, 'quotedblright': 556, 'quoteleft': 333, 'quoteright': 333, 'quotesinglbase': 333, 'quotesingle': 214, 'r': 389, 'registered': 760, 'ring': 333, 's': 389, 'scaron': 389, 'section': 500, 'semicolon': 333, 'seven': 500, 'six': 500, 'slash': 278, 'space': 250, 'sterling': 500, 't': 278, 'thorn': 500, 'three': 500, 'threequarters': 750, 'threesuperior': 300, 'tilde': 333, 'trademark': 980, 'two': 500, 'twosuperior': 300, 'u': 500, 'uacute': 500, 'ucircumflex': 500, 'udieresis': 500, 'ugrave': 500, 'underscore': 500, 'v': 444, 'w': 667, 'x': 444, 'y': 444, 'yacute': 444, 'ydieresis': 444, 'yen': 500, 'z': 389, 'zcaron': 389, 'zero': 500} widthsByFontGlyph['Times-BoldItalic'] = {'A': 667, 'AE': 944, 'Aacute': 667, 'Acircumflex': 667, 'Adieresis': 667, 'Agrave': 667, 'Aring': 667, 'Atilde': 667, 'B': 667, 'C': 667, 'Ccedilla': 667, 'D': 722, 'E': 667, 'Eacute': 667, 'Ecircumflex': 667, 'Edieresis': 667, 'Egrave': 667, 'Eth': 722, 'Euro': 500, 'F': 667, 'G': 722, 'H': 778, 'I': 389, 'Iacute': 389, 'Icircumflex': 389, 'Idieresis': 389, 'Igrave': 389, 'J': 500, 'K': 667, 'L': 611, 'Lslash': 611, 'M': 889, 'N': 722, 'Ntilde': 722, 'O': 722, 'OE': 944, 'Oacute': 722, 'Ocircumflex': 722, 'Odieresis': 722, 'Ograve': 722, 'Oslash': 722, 'Otilde': 722, 'P': 611, 'Q': 722, 'R': 667, 'S': 556, 'Scaron': 556, 'T': 611, 'Thorn': 611, 'U': 722, 'Uacute': 722, 'Ucircumflex': 722, 'Udieresis': 722, 'Ugrave': 722, 'V': 667, 'W': 889, 'X': 667, 'Y': 611, 'Yacute': 611, 'Ydieresis': 611, 'Z': 611, 'Zcaron': 611, 'a': 500, 'aacute': 500, 'acircumflex': 500, 'acute': 333, 'adieresis': 500, 'ae': 722, 'agrave': 500, 'ampersand': 778, 'aring': 500, 'asciicircum': 570, 'asciitilde': 570, 'asterisk': 500, 'at': 832, 'atilde': 500, 'b': 500, 'backslash': 278, 'bar': 220, 'braceleft': 348, 'braceright': 348, 'bracketleft': 333, 'bracketright': 333, 'breve': 333, 'brokenbar': 220, 'bullet': 350, 'c': 444, 'caron': 333, 'ccedilla': 444, 'cedilla': 333, 'cent': 500, 'circumflex': 333, 'colon': 333, 'comma': 250, 'copyright': 747, 'currency': 500, 'd': 500, 'dagger': 500, 'daggerdbl': 500, 'degree': 400, 'dieresis': 333, 'divide': 570, 'dollar': 500, 'dotaccent': 333, 'dotlessi': 278, 'e': 444, 'eacute': 444, 'ecircumflex': 444, 'edieresis': 444, 'egrave': 444, 'eight': 500, 'ellipsis': 1000, 'emdash': 1000, 'endash': 500, 'equal': 570, 'eth': 500, 'exclam': 389, 'exclamdown': 389, 'f': 333, 'fi': 556, 'five': 500, 'fl': 556, 'florin': 500, 'four': 500, 'fraction': 167, 'g': 500, 'germandbls': 500, 'grave': 333, 'greater': 570, 'guillemotleft': 500, 'guillemotright': 500, 'guilsinglleft': 333, 'guilsinglright': 333, 'h': 556, 'hungarumlaut': 333, 'hyphen': 333, 'i': 278, 'iacute': 278, 'icircumflex': 278, 'idieresis': 278, 'igrave': 278, 'j': 278, 'k': 500, 'l': 278, 'less': 570, 'logicalnot': 606, 'lslash': 278, 'm': 778, 'macron': 333, 'minus': 606, 'mu': 576, 'multiply': 570, 'n': 556, 'nine': 500, 'ntilde': 556, 'numbersign': 500, 'o': 500, 'oacute': 500, 'ocircumflex': 500, 'odieresis': 500, 'oe': 722, 'ogonek': 333, 'ograve': 500, 'one': 500, 'onehalf': 750, 'onequarter': 750, 'onesuperior': 300, 'ordfeminine': 266, 'ordmasculine': 300, 'oslash': 500, 'otilde': 500, 'p': 500, 'paragraph': 500, 'parenleft': 333, 'parenright': 333, 'percent': 833, 'period': 250, 'periodcentered': 250, 'perthousand': 1000, 'plus': 570, 'plusminus': 570, 'q': 500, 'question': 500, 'questiondown': 500, 'quotedbl': 555, 'quotedblbase': 500, 'quotedblleft': 500, 'quotedblright': 500, 'quoteleft': 333, 'quoteright': 333, 'quotesinglbase': 333, 'quotesingle': 278, 'r': 389, 'registered': 747, 'ring': 333, 's': 389, 'scaron': 389, 'section': 500, 'semicolon': 333, 'seven': 500, 'six': 500, 'slash': 278, 'space': 250, 'sterling': 500, 't': 278, 'thorn': 500, 'three': 500, 'threequarters': 750, 'threesuperior': 300, 'tilde': 333, 'trademark': 1000, 'two': 500, 'twosuperior': 300, 'u': 556, 'uacute': 556, 'ucircumflex': 556, 'udieresis': 556, 'ugrave': 556, 'underscore': 500, 'v': 444, 'w': 667, 'x': 500, 'y': 444, 'yacute': 444, 'ydieresis': 444, 'yen': 500, 'z': 389, 'zcaron': 389, 'zero': 500} widthsByFontGlyph['Symbol'] = {'Alpha': 722, 'Beta': 667, 'Chi': 722, 'Delta': 612, 'Epsilon': 611, 'Eta': 722, 'Euro': 750, 'Gamma': 603, 'Ifraktur': 686, 'Iota': 333, 'Kappa': 722, 'Lambda': 686, 'Mu': 889, 'Nu': 722, 'Omega': 768, 'Omicron': 722, 'Phi': 763, 'Pi': 768, 'Psi': 795, 'Rfraktur': 795, 'Rho': 556, 'Sigma': 592, 'Tau': 611, 'Theta': 741, 'Upsilon': 690, 'Upsilon1': 620, 'Xi': 645, 'Zeta': 611, 'aleph': 823, 'alpha': 631, 'ampersand': 778, 'angle': 768, 'angleleft': 329, 'angleright': 329, 'apple': 790, 'approxequal': 549, 'arrowboth': 1042, 'arrowdblboth': 1042, 'arrowdbldown': 603, 'arrowdblleft': 987, 'arrowdblright': 987, 'arrowdblup': 603, 'arrowdown': 603, 'arrowhorizex': 1000, 'arrowleft': 987, 'arrowright': 987, 'arrowup': 603, 'arrowvertex': 603, 'asteriskmath': 500, 'bar': 200, 'beta': 549, 'braceex': 494, 'braceleft': 480, 'braceleftbt': 494, 'braceleftmid': 494, 'bracelefttp': 494, 'braceright': 480, 'bracerightbt': 494, 'bracerightmid': 494, 'bracerighttp': 494, 'bracketleft': 333, 'bracketleftbt': 384, 'bracketleftex': 384, 'bracketlefttp': 384, 'bracketright': 333, 'bracketrightbt': 384, 'bracketrightex': 384, 'bracketrighttp': 384, 'bullet': 460, 'carriagereturn': 658, 'chi': 549, 'circlemultiply': 768, 'circleplus': 768, 'club': 753, 'colon': 278, 'comma': 250, 'congruent': 549, 'copyrightsans': 790, 'copyrightserif': 790, 'degree': 400, 'delta': 494, 'diamond': 753, 'divide': 549, 'dotmath': 250, 'eight': 500, 'element': 713, 'ellipsis': 1000, 'emptyset': 823, 'epsilon': 439, 'equal': 549, 'equivalence': 549, 'eta': 603, 'exclam': 333, 'existential': 549, 'five': 500, 'florin': 500, 'four': 500, 'fraction': 167, 'gamma': 411, 'gradient': 713, 'greater': 549, 'greaterequal': 549, 'heart': 753, 'infinity': 713, 'integral': 274, 'integralbt': 686, 'integralex': 686, 'integraltp': 686, 'intersection': 768, 'iota': 329, 'kappa': 549, 'lambda': 549, 'less': 549, 'lessequal': 549, 'logicaland': 603, 'logicalnot': 713, 'logicalor': 603, 'lozenge': 494, 'minus': 549, 'minute': 247, 'mu': 576, 'multiply': 549, 'nine': 500, 'notelement': 713, 'notequal': 549, 'notsubset': 713, 'nu': 521, 'numbersign': 500, 'omega': 686, 'omega1': 713, 'omicron': 549, 'one': 500, 'parenleft': 333, 'parenleftbt': 384, 'parenleftex': 384, 'parenlefttp': 384, 'parenright': 333, 'parenrightbt': 384, 'parenrightex': 384, 'parenrighttp': 384, 'partialdiff': 494, 'percent': 833, 'period': 250, 'perpendicular': 658, 'phi': 521, 'phi1': 603, 'pi': 549, 'plus': 549, 'plusminus': 549, 'product': 823, 'propersubset': 713, 'propersuperset': 713, 'proportional': 713, 'psi': 686, 'question': 444, 'radical': 549, 'radicalex': 500, 'reflexsubset': 713, 'reflexsuperset': 713, 'registersans': 790, 'registerserif': 790, 'rho': 549, 'second': 411, 'semicolon': 278, 'seven': 500, 'sigma': 603, 'sigma1': 439, 'similar': 549, 'six': 500, 'slash': 278, 'space': 250, 'spade': 753, 'suchthat': 439, 'summation': 713, 'tau': 439, 'therefore': 863, 'theta': 521, 'theta1': 631, 'three': 500, 'trademarksans': 786, 'trademarkserif': 890, 'two': 500, 'underscore': 500, 'union': 768, 'universal': 713, 'upsilon': 576, 'weierstrass': 987, 'xi': 493, 'zero': 500, 'zeta': 494} widthsByFontGlyph['ZapfDingbats'] = {'a1': 974, 'a10': 692, 'a100': 668, 'a101': 732, 'a102': 544, 'a103': 544, 'a104': 910, 'a105': 911, 'a106': 667, 'a107': 760, 'a108': 760, 'a109': 626, 'a11': 960, 'a110': 694, 'a111': 595, 'a112': 776, 'a117': 690, 'a118': 791, 'a119': 790, 'a12': 939, 'a120': 788, 'a121': 788, 'a122': 788, 'a123': 788, 'a124': 788, 'a125': 788, 'a126': 788, 'a127': 788, 'a128': 788, 'a129': 788, 'a13': 549, 'a130': 788, 'a131': 788, 'a132': 788, 'a133': 788, 'a134': 788, 'a135': 788, 'a136': 788, 'a137': 788, 'a138': 788, 'a139': 788, 'a14': 855, 'a140': 788, 'a141': 788, 'a142': 788, 'a143': 788, 'a144': 788, 'a145': 788, 'a146': 788, 'a147': 788, 'a148': 788, 'a149': 788, 'a15': 911, 'a150': 788, 'a151': 788, 'a152': 788, 'a153': 788, 'a154': 788, 'a155': 788, 'a156': 788, 'a157': 788, 'a158': 788, 'a159': 788, 'a16': 933, 'a160': 894, 'a161': 838, 'a162': 924, 'a163': 1016, 'a164': 458, 'a165': 924, 'a166': 918, 'a167': 927, 'a168': 928, 'a169': 928, 'a17': 945, 'a170': 834, 'a171': 873, 'a172': 828, 'a173': 924, 'a174': 917, 'a175': 930, 'a176': 931, 'a177': 463, 'a178': 883, 'a179': 836, 'a18': 974, 'a180': 867, 'a181': 696, 'a182': 874, 'a183': 760, 'a184': 946, 'a185': 865, 'a186': 967, 'a187': 831, 'a188': 873, 'a189': 927, 'a19': 755, 'a190': 970, 'a191': 918, 'a192': 748, 'a193': 836, 'a194': 771, 'a195': 888, 'a196': 748, 'a197': 771, 'a198': 888, 'a199': 867, 'a2': 961, 'a20': 846, 'a200': 696, 'a201': 874, 'a202': 974, 'a203': 762, 'a204': 759, 'a205': 509, 'a206': 410, 'a21': 762, 'a22': 761, 'a23': 571, 'a24': 677, 'a25': 763, 'a26': 760, 'a27': 759, 'a28': 754, 'a29': 786, 'a3': 980, 'a30': 788, 'a31': 788, 'a32': 790, 'a33': 793, 'a34': 794, 'a35': 816, 'a36': 823, 'a37': 789, 'a38': 841, 'a39': 823, 'a4': 719, 'a40': 833, 'a41': 816, 'a42': 831, 'a43': 923, 'a44': 744, 'a45': 723, 'a46': 749, 'a47': 790, 'a48': 792, 'a49': 695, 'a5': 789, 'a50': 776, 'a51': 768, 'a52': 792, 'a53': 759, 'a54': 707, 'a55': 708, 'a56': 682, 'a57': 701, 'a58': 826, 'a59': 815, 'a6': 494, 'a60': 789, 'a61': 789, 'a62': 707, 'a63': 687, 'a64': 696, 'a65': 689, 'a66': 786, 'a67': 787, 'a68': 713, 'a69': 791, 'a7': 552, 'a70': 785, 'a71': 791, 'a72': 873, 'a73': 761, 'a74': 762, 'a75': 759, 'a76': 892, 'a77': 892, 'a78': 788, 'a79': 784, 'a8': 537, 'a81': 438, 'a82': 138, 'a83': 277, 'a84': 415, 'a85': 509, 'a86': 410, 'a87': 234, 'a88': 234, 'a89': 390, 'a9': 577, 'a90': 390, 'a91': 276, 'a92': 276, 'a93': 317, 'a94': 317, 'a95': 334, 'a96': 334, 'a97': 392, 'a98': 392, 'a99': 668, 'space': 278} enthought-chaco2-4.5.1.orig/kiva/pdf.py0000644000175000017500000006253512516137326016770 0ustar varunvarun# Copyright (c) 2005-2014, Enthought, Inc. # some parts copyright 2002 by Space Telescope Science Institute # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! """ PDF implementation of the core2d drawing library :Author: Eric Jones, Enthought, Inc., eric@enthought.com :Copyright: Space Telescope Science Institute :License: BSD Style The PDF implementation relies heavily on the ReportLab project. """ from __future__ import absolute_import, print_function # standard library imports from itertools import izip import warnings import copy from numpy import array, pi # ReportLab PDF imports import reportlab.pdfbase.pdfmetrics import reportlab.pdfbase._fontdata from reportlab.pdfgen import canvas # local, relative Kiva imports from .arc_conversion import arc_to_tangent_points from .basecore2d import GraphicsContextBase from .line_state import is_dashed from .constants import FILL, STROKE, EOF_FILL import kiva.constants as constants import kiva.affine as affine cap_style = {} cap_style[constants.CAP_ROUND] = 1 cap_style[constants.CAP_SQUARE] = 2 cap_style[constants.CAP_BUTT] = 0 join_style = {} join_style[constants.JOIN_ROUND] = 1 join_style[constants.JOIN_BEVEL] = 2 join_style[constants.JOIN_MITER] = 0 # stroke, fill, mode path_mode = {} path_mode[constants.FILL_STROKE] = (1, 1, canvas.FILL_NON_ZERO) path_mode[constants.FILL] = (0, 1, canvas.FILL_NON_ZERO) path_mode[constants.EOF_FILL] = (0, 1, canvas.FILL_EVEN_ODD) path_mode[constants.STROKE] = (1, 0, canvas.FILL_NON_ZERO) path_mode[constants.EOF_FILL_STROKE] = (1, 1, canvas.FILL_EVEN_ODD) # fixme: I believe this can be implemented but for now, it is not. class CompiledPath(object): pass class GraphicsContext(GraphicsContextBase): """ Simple wrapper around a PDF graphics context. """ def __init__(self, pdf_canvas, *args, **kwargs): from .image import GraphicsContext as GraphicsContextImage self.gc = pdf_canvas self.current_pdf_path = None self.current_point = (0, 0) self.text_xy = None, None # get an agg backend to assist in measuring text self._agg_gc = GraphicsContextImage((1, 1)) super(GraphicsContext, self).__init__(self, *args, **kwargs) # ---------------------------------------------------------------- # Coordinate Transform Matrix Manipulation # ---------------------------------------------------------------- def scale_ctm(self, sx, sy): """ scale_ctm(sx: float, sy: float) -> None Sets the coordinate system scale to the given values, (sx, sy). """ self.gc.scale(sx, sy) def translate_ctm(self, tx, ty): """ translate_ctm(tx: float, ty: float) -> None Translates the coordinate syetem by the given value by (tx, ty) """ self.gc.translate(tx, ty) def rotate_ctm(self, angle): """ rotate_ctm(angle: float) -> None Rotates the coordinate space by the given angle (in radians). """ self.gc.rotate(angle * 180 / pi) def concat_ctm(self, transform): """ concat_ctm(transform: affine_matrix) Concatenates the transform to current coordinate transform matrix. transform is an affine transformation matrix (see kiva.affine_matrix). """ self.gc.transform(transform) def get_ctm(self): """ Returns the current coordinate transform matrix. XXX: This should really return a 3x3 matrix (or maybe an affine object?) like the other API's. Needs thought. """ return affine.affine_from_values(*copy.copy(self.gc._currentMatrix)) def set_ctm(self, transform): """ Set the coordinate transform matrix """ # We have to do this by inverting the current state to zero it out, # then transform by desired transform, as Reportlab Canvas doesn't # provide a method to directly set the ctm. current = self.get_ctm() self.concat_ctm(affine.invert(current)) self.concat_ctm(transform) # ---------------------------------------------------------------- # Save/Restore graphics state. # ---------------------------------------------------------------- def save_state(self): """ Saves the current graphic's context state. Always pair this with a `restore_state()` """ self.gc.saveState() def restore_state(self): """ Restores the previous graphics state. """ self.gc.restoreState() # ---------------------------------------------------------------- # Manipulate graphics state attributes. # ---------------------------------------------------------------- def set_should_antialias(self, value): """ Sets/Unsets anti-aliasing for bitmap graphics context. """ msg = "antialias is not part of the PDF canvas. Should it be?" raise NotImplementedError(msg) def set_line_width(self, width): """ Sets the line width for drawing Parameters ---------- width : float The new width for lines in user space units. """ self.gc.setLineWidth(width) def set_line_join(self, style): """ Sets style for joining lines in a drawing. style : join_style The line joining style. The available styles are JOIN_ROUND, JOIN_BEVEL, JOIN_MITER. """ try: sjoin = join_style[style] except KeyError: msg = "Invalid line join style. See documentation for valid styles" raise ValueError(msg) self.gc.setLineJoin(sjoin) def set_miter_limit(self, limit): """ Specifies limits on line lengths for mitering line joins. If line_join is set to miter joins, the limit specifies which line joins should actually be mitered. If lines aren't mitered, they are joined with a bevel. The line width is divided by the length of the miter. If the result is greater than the limit, the bevel style is used. Parameters ---------- limit : float limit for mitering joins. """ self.gc.setMiterLimit(limit) def set_line_cap(self, style): """ Specifies the style of endings to put on line ends. Parameters ---------- style : cap_style the line cap style to use. Available styles are CAP_ROUND, CAP_BUTT, CAP_SQUARE """ try: scap = cap_style[style] except KeyError: msg = "Invalid line cap style. See documentation for valid styles" raise ValueError(msg) self.gc.setLineCap(scap) def set_line_dash(self, lengths, phase=0): """ Parameters ---------- lengths : float array An array of floating point values specifing the lengths of on/off painting pattern for lines. phase : float Specifies how many units into dash pattern to start. phase defaults to 0. """ if is_dashed((phase, lengths)): lengths = list(lengths) if lengths is not None else [] self.gc.setDash(lengths, phase) def set_flatness(self, flatness): """ It is device dependent and therefore not recommended by the PDF documentation. """ raise NotImplementedError("Flatness not implemented yet on PDF") # ---------------------------------------------------------------- # Sending drawing data to a device # ---------------------------------------------------------------- def flush(self): """ Sends all drawing data to the destination device. Currently, this is a NOP. It used to call ReportLab's save() method, and maybe it still should, but flush() is likely to be called a lot, so this will really slow things down. Also, I think save() affects the paging of a document I think. We'll have to look into this more. """ pass def synchronize(self): """ Prepares drawing data to be updated on a destination device. Currently, doesn't do anything. Should this call ReportLab's canvas object's showPage() method. """ pass # ---------------------------------------------------------------- # Page Definitions # ---------------------------------------------------------------- def begin_page(self): """ Creates a new page within the graphics context. Currently, this just calls ReportLab's canvas object's showPage() method. Not sure about this... """ self.gc.showPage() def end_page(self): """ Ends drawing in the current page of the graphics context. Currently, this just calls ReportLab's canvas object's showPage() method. Not sure about this... """ self.gc.showPage() # ---------------------------------------------------------------- # Building paths (contours that are drawn) # # + Currently, nothing is drawn as the path is built. Instead, the # instructions are stored and later drawn. Should this be changed? # We will likely draw to a buffer instead of directly to the canvas # anyway. # # Hmmm. No. We have to keep the path around for storing as a # clipping region and things like that. # # + I think we should keep the current_path_point hanging around. # # ---------------------------------------------------------------- def begin_path(self): """ Clears the current drawing path and begins a new one. """ self.current_pdf_path = self.gc.beginPath() self.current_point = (0, 0) def move_to(self, x, y): """ Starts a new drawing subpath at place the current point at (x, y). """ if self.current_pdf_path is None: self.begin_path() self.current_pdf_path.moveTo(x, y) self.current_point = (x, y) def line_to(self, x, y): """ Adds a line from the current point to the given point (x, y). The current point is moved to (x, y). """ if self.current_pdf_path is None: self.begin_path() self.current_pdf_path.lineTo(x, y) self.current_point = (x, y) def lines(self, points): """ Adds a series of lines as a new subpath. Currently implemented by calling line_to a zillion times. Points is an Nx2 array of x, y pairs. current_point is moved to the last point in points """ if self.current_pdf_path is None: self.begin_path() self.current_pdf_path.moveTo(points[0][0], points[0][1]) for x, y in points[1:]: self.current_pdf_path.lineTo(x, y) self.current_point = (x, y) def line_set(self, starts, ends): if self.current_pdf_path is None: self.begin_path() for start, end in izip(starts, ends): self.current_pdf_path.moveTo(start[0], start[1]) self.current_pdf_path.lineTo(end[0], end[1]) self.current_point = (end[0], end[1]) def rect(self, *args): """ Adds a rectangle as a new subpath. Can be called in two ways: rect(x, y, w, h) rect( (x, y, w, h) ) """ if self.current_pdf_path is None: self.begin_path() if len(args) == 1: args = args[0] self.current_pdf_path.rect(*args) self.current_point = (args[0], args[1]) def draw_rect(self, rect, mode=constants.FILL_STROKE): self.rect(rect) self.draw_path(mode) self.current_point = (rect[0], rect[1]) def rects(self, rects): """ Adds multiple rectangles as separate subpaths to the path. Currently implemented by calling rect a zillion times. """ if self.current_pdf_path is None: self.begin_path() for x, y, sx, sy in rects: self.current_pdf_path.rect(x, y, sx, sy) self.current_point = (x, y) def close_path(self): """ Closes the path of the current subpath. """ self.current_pdf_path.close() def curve_to(self, cp1x, cp1y, cp2x, cp2y, x, y): """ """ if self.current_pdf_path is None: self.begin_path() self.current_pdf_path.curveTo(cp1x, cp1y, cp2x, cp2y, x, y) self.current_point = (x, y) def quad_curve_to(self, cpx, cpy, x, y): """ """ msg = "quad curve to not implemented yet on PDF" raise NotImplementedError(msg) def arc(self, x, y, radius, start_angle, end_angle, clockwise=False): """ """ if self.current_pdf_path is None: self.begin_path() self.current_pdf_path.arc(x - radius, y - radius, x + radius, y + radius, start_angle * 180.0 / pi, (end_angle-start_angle) * 180.0 / pi) self.current_point = (x, y) def arc_to(self, x1, y1, x2, y2, radius): """ """ if self.current_pdf_path is None: self.begin_path() # Get the endpoints on the curve where it touches the line segments t1, t2 = arc_to_tangent_points(self.current_point, (x1, y1), (x2, y2), radius) # draw! self.current_pdf_path.lineTo(*t1) self.current_pdf_path.curveTo(x1, y1, x1, y1, *t2) self.current_pdf_path.lineTo(x2, y2) self.current_point = (x2, y2) # ---------------------------------------------------------------- # Getting infomration on paths # ---------------------------------------------------------------- def is_path_empty(self): """ Tests to see whether the current drawing path is empty """ msg = "is_path_empty not implemented yet on PDF" raise NotImplementedError(msg) def get_path_current_point(self): """ Returns the current point from the graphics context. Note: This should be a tuple or array. """ return self.current_point def get_path_bounding_box(self): """ Should return a tuple or array instead of a strange object. """ msg = "get_path_bounding_box not implemented yet on PDF" raise NotImplementedError(msg) # ---------------------------------------------------------------- # Clipping path manipulation # ---------------------------------------------------------------- def clip(self): """ """ self.gc._fillMode = canvas.FILL_NON_ZERO self.gc.clipPath(self.current_pdf_path, stroke=0, fill=0) def even_odd_clip(self): """ """ self.gc._fillMode = canvas.FILL_EVEN_ODD self.gc.clipPath(self.current_pdf_path, stroke=0, fill=1) def clip_to_rect(self, x, y, width, height): """ Clips context to the given rectangular region. Region should be a 4-tuple or a sequence. """ clip_path = self.gc.beginPath() clip_path.rect(x, y, width, height) self.gc.clipPath(clip_path, stroke=0, fill=0) def clip_to_rects(self): """ """ msg = "clip_to_rects not implemented yet on PDF." raise NotImplementedError(msg) def clear_clip_path(self): """ """ return self.clip_to_rect(0, 0, 10000, 10000) # ---------------------------------------------------------------- # Color space manipulation # # I'm not sure we'll mess with these at all. They seem to # be for setting the color syetem. Hard coding to RGB or # RGBA for now sounds like a reasonable solution. # ---------------------------------------------------------------- def set_fill_color_space(self): """ """ msg = "set_fill_color_space not implemented on PDF yet." raise NotImplementedError(msg) def set_stroke_color_space(self): """ """ msg = "set_stroke_color_space not implemented on PDF yet." raise NotImplementedError(msg) def set_rendering_intent(self): """ """ msg = "set_rendering_intent not implemented on PDF yet." raise NotImplementedError(msg) # ---------------------------------------------------------------- # Color manipulation # ---------------------------------------------------------------- def set_fill_color(self, color): """ """ r, g, b = color[:3] try: a = color[3] except IndexError: a = 1.0 self.gc.setFillColorRGB(r, g, b, a) def set_stroke_color(self, color): """ """ r, g, b = color[:3] try: a = color[3] except IndexError: a = 1.0 self.gc.setStrokeColorRGB(r, g, b, a) def set_alpha(self, alpha): """ Sets alpha globally. Note that this will not affect draw_image because reportlab does not currently support drawing images with alpha. """ self.gc.setFillAlpha(alpha) self.gc.setStrokeAlpha(alpha) super(GraphicsContext, self).set_alpha(alpha) # ---------------------------------------------------------------- # Drawing Images # ---------------------------------------------------------------- def draw_image(self, img, rect=None): """ draw_image(img_gc, rect=(x, y, w, h)) Draws another gc into this one. If 'rect' is not provided, then the image gc is drawn into this one, rooted at (0, 0) and at full pixel size. If 'rect' is provided, then the image is resized into the (w, h) given and drawn into this GC at point (x, y). img_gc is either a Numeric array (WxHx3 or WxHx4) or a GC from Kiva's Agg backend (kiva.agg.GraphicsContextArray). Requires the Python Imaging Library (PIL). """ # We turn img into a PIL object, since that is what ReportLab # requires. To do this, we first determine if the input image # GC needs to be converted to RGBA/RGB. If so, we see if we can # do it nicely (using convert_pixel_format), and if not, we do # it brute-force using Agg. from reportlab.lib.utils import ImageReader from PIL import Image as PilImage from kiva import agg if type(img) == type(array([])): # Numeric array converted_img = agg.GraphicsContextArray(img, pix_format='rgba32') format = 'RGBA' elif isinstance(img, agg.GraphicsContextArray): if img.format().startswith('RGBA'): format = 'RGBA' elif img.format().startswith('RGB'): format = 'RGB' else: converted_img = img.convert_pixel_format('rgba32', inplace=0) format = 'RGBA' else: warnings.warn("Cannot render image of type %r into PDF context." % type(img)) return # converted_img now holds an Agg graphics context with the image pil_img = PilImage.fromstring(format, (converted_img.width(), converted_img.height()), converted_img.bmp_array.tostring()) if rect is None: rect = (0, 0, img.width(), img.height()) # Draw the actual image. # Wrap it in an ImageReader object, because that's what reportlab # actually needs. self.gc.drawImage(ImageReader(pil_img), rect[0], rect[1], rect[2], rect[3]) # ---------------------------------------------------------------- # Drawing Text # ---------------------------------------------------------------- def select_font(self, name, size, textEncoding): """ PDF ignores the Encoding variable. """ self.gc.setFont(name, size) def set_font(self, font): """ Sets the font for the current graphics context. """ # TODO: Make this actually do the right thing if font.face_name == "": font.face_name = "Helvetica" self.gc.setFont(font.face_name, font.size) def get_font(self): """ Get the current font """ raise NotImplementedError def set_font_size(self, size): """ """ font = self.gc._fontname self.gc.setFont(font, size) def set_character_spacing(self): """ """ pass def get_character_spacing(self): """ Get the current font """ raise NotImplementedError def set_text_drawing_mode(self): """ """ pass def set_text_position(self, x, y): """ """ self.text_xy = x, y def get_text_position(self): """ """ return self.state.text_matrix[2, :2] def set_text_matrix(self, ttm): """ """ a, b, c, d, tx, ty = affine.affine_params(ttm) self.gc._textMatrix = (a, b, c, d, tx, ty) def get_text_matrix(self): """ """ a, b, c, d, tx, ty = self.gc._textMatrix return affine.affine_from_values(a, b, c, d, tx, ty) def show_text(self, text, x=None, y=None): """ Draws text on the device at current text position. This is also used for showing text at a particular point specified by x and y. This ignores the text matrix for now. """ if x and y: pass else: x, y = self.text_xy self.gc.drawString(x, y, text) def show_text_at_point(self, text, x, y): self.show_text(text, x, y) def show_glyphs(self): """ """ msg = "show_glyphs not implemented on PDF yet." raise NotImplementedError(msg) def get_full_text_extent(self, textstring): fontname = self.gc._fontname fontsize = self.gc._fontsize ascent, descent = reportlab.pdfbase._fontdata.ascent_descent[fontname] # get the AGG extent (we just care about the descent) aw, ah, ad, al = self._agg_gc.get_full_text_extent(textstring) # ignore the descent returned by reportlab if AGG returned 0.0 descent descent = 0.0 if ad == 0.0 else descent * fontsize / 1000.0 ascent = ascent * fontsize / 1000.0 height = ascent + abs(descent) width = self.gc.stringWidth(textstring, fontname, fontsize) # the final return value is defined as leading. do not know # how to get that number so returning zero return width, height, descent, 0 def get_text_extent(self, textstring): w, h, d, l = self.get_full_text_extent(textstring) return w, h # ---------------------------------------------------------------- # Painting paths (drawing and filling contours) # ---------------------------------------------------------------- def clear(self): """ """ warnings.warn("clear() is ignored for the pdf backend") def stroke_path(self): """ """ self.draw_path(mode=STROKE) def fill_path(self): """ """ self.draw_path(mode=FILL) def eof_fill_path(self): """ """ self.draw_path(mode=EOF_FILL) def stroke_rect(self, rect): """ """ self.begin_path() self.rect(rect[0], rect[1], rect[2], rect[3]) self.stroke_path() def stroke_rect_with_width(self, rect, width): """ """ msg = "stroke_rect_with_width not implemented on PDF yet." raise NotImplementedError(msg) def fill_rect(self, rect): """ """ self.begin_path() self.rect(rect[0], rect[1], rect[2], rect[3]) self.fill_path() def fill_rects(self): """ """ msg = "fill_rects not implemented on PDF yet." raise NotImplementedError(msg) def clear_rect(self, rect): """ """ msg = "clear_rect not implemented on PDF yet." raise NotImplementedError(msg) def draw_path(self, mode=constants.FILL_STROKE): """ Walks through all the drawing subpaths and draw each element. Each subpath is drawn separately. """ if self.current_pdf_path is not None: stroke, fill, mode = path_mode[mode] self.gc._fillMode = mode self.gc.drawPath(self.current_pdf_path, stroke=stroke, fill=fill) # erase the current path. self.current_pdf_path = None def save(self): self.gc.save() def simple_test(): pdf = canvas.Canvas("bob.pdf") gc = GraphicsContext(pdf) gc.begin_path() gc.move_to(50, 50) gc.line_to(100, 100) gc.draw_path() gc.flush() pdf.save() if __name__ == "__main__": import sys if len(sys.argv) == 1: sys.exit("Usage: %s output_file" % sys.argv[0]) enthought-chaco2-4.5.1.orig/kiva/arc_conversion.py0000644000175000017500000000424312516137326021221 0ustar varunvarunfrom numpy import sqrt, dot, sin, array, pi from math import atan2, acos def two_point_arc_to_kiva_arc(p1, p2, theta): """ Converts an arc in two point and subtended angle format (startpoint, endpoint, theta (positive for ccw, negative for cw)) into kiva format (x, y, radius, start_angle, end_angle, cw) """ chord = p2-p1 chordlen = sqrt(dot(chord, chord)) radius = abs(chordlen/(2*sin(theta/2))) altitude = sqrt(pow(radius, 2) - pow(chordlen/2, 2)) if theta > pi or theta < 0: altitude = -altitude chordmidpoint = (p1+p2)/2 rotate90 = array(((0.0, -1.0), (1.0, 0.0))) centerpoint = dot(rotate90, (chord/chordlen))*altitude + chordmidpoint start_angle = atan2(*(p1 - centerpoint)[::-1]) end_angle = start_angle + theta if theta < 0: start_angle, end_angle, = end_angle, start_angle cw = False radius = abs(radius) return (centerpoint[0], centerpoint[1], radius, start_angle, end_angle, cw) def arc_to_tangent_points(start, p1, p2, radius): """ Given a starting point, two endpoints of a line segment, and a radius, calculate the tangent points for arc_to(). """ def normalize_vector(x, y): """ Given a vector, return its unit length representation. """ length = sqrt(x**2+y**2) if length <= 1e-6: return (0.0, 0.0) return (x/length, y/length) # calculate the angle between the two line segments v1 = normalize_vector(start[0]-p1[0], start[1]-p1[1]) v2 = normalize_vector(p2[0]-p1[0], p2[1]-p1[1]) angle = acos(v1[0]*v2[0]+v1[1]*v2[1]) # punt if the half angle is zero or a multiple of pi sin_half_angle = sin(angle/2.0) if sin_half_angle == 0.0: return (p1, p2) # calculate the distance from p1 to the center of the arc dist_to_center = radius / sin_half_angle # calculate the distance from p1 to each tangent point dist_to_tangent = sqrt(dist_to_center**2-radius**2) # calculate the tangent points t1 = (p1[0]+v1[0]*dist_to_tangent, p1[1]+v1[1]*dist_to_tangent) t2 = (p1[0]+v2[0]*dist_to_tangent, p1[1]+v2[1]*dist_to_tangent) return (t1, t2) enthought-chaco2-4.5.1.orig/kiva/testing.py0000644000175000017500000000511712516137326017665 0ustar varunvarun# Copyright (c) 2008-2013 by Enthought, Inc. # All rights reserved. from mock import Mock from kiva.image import GraphicsContext class KivaTestAssistant(object): """ Mixin test helper for kiva drawing tests. """ def create_mock_gc( self, width, height, methods=()): """ Create an image graphics context that with mocked methods. Parameters ---------- width, height : The size of the graphics context canvas. methods : iterable the methods which are going to be mocked with a Mock object. """ gc = GraphicsContext((int(width), int(height))) gc.clear((0.0, 0.0, 0.0, 0.0)) for method in methods: setattr(gc, method, Mock()) return gc def assertPathsAreProcessed(self, drawable, width=200, height=200): """ Check that all the paths have been compiled and processed. Parameters ---------- drawable : A drawable object that has a draw method. width : int, optional The width of the array buffer (default is 200). height : int, optional The height of the array buffer (default is 200). note :: A drawable that draws nothing will pass this check. """ gc = GraphicsContext((width, height)) drawable.draw(gc) compiled_path = gc._get_path() total_vertices = compiled_path.total_vertices() self.assertEqual( total_vertices, 0, msg='There are {0} vertices in compiled paths {1} that ' 'have not been processed'.format(total_vertices, compiled_path)) def assertPathsAreCreated(self, drawable, width=200, height=200): """ Check that drawing creates paths. When paths and lines creation methods are used from a graphics context the drawing paths are compiled and processed. By using a mock graphics context we can check if something has been drawn. Parameters ---------- drawable : A drawable object that has a draw method. width : int, optional The width of the array buffer (default is 200). height : int, optional The height of the array buffer (default is 200). """ gc = self.create_mock_gc(width, height, ('draw_path', 'stroke_path')) drawable.draw(gc) compiled_path = gc._get_path() self.assertTrue( compiled_path.total_vertices() > 0, msg='There are no compiled paths ' 'created: {0}'.format(compiled_path)) enthought-chaco2-4.5.1.orig/kiva/abstract_graphics_context.py0000644000175000017500000003745312516137326023447 0ustar varunvarunfrom __future__ import absolute_import from abc import ABCMeta, abstractmethod from .constants import FILL_STROKE, SQUARE_MARKER class AbstractGraphicsContext(object): """ Abstract Base Class for Kiva Graphics Contexts """ __metaclass__ = ABCMeta # ---------------------------------------------------------------- # Save/Restore graphics state. # ---------------------------------------------------------------- @abstractmethod def save_state(self): """ Push the current graphics state onto the stack """ @abstractmethod def restore_state(self): """ Pop the previous graphics state from the stack """ # ---------------------------------------------------------------- # context manager interface # ---------------------------------------------------------------- def __enter__(self): self.save_state() def __exit__(self, type, value, traceback): self.restore_state() # ------------------------------------------- # Graphics state methods # ------------------------------------------- @abstractmethod def set_stroke_color(self, color): """ Set the color used when stroking a path """ @abstractmethod def get_stroke_color(self): """ Get the current color used when stroking a path """ @abstractmethod def set_line_width(self, width): """ Set the width of the pen used to stroke a path """ @abstractmethod def set_line_join(self, line_join): """ Set the style of join to use a path corners """ @abstractmethod def set_line_cap(self, line_cap): """ Set the style of cap to use a path ends """ @abstractmethod def set_line_dash(self, line_dash): """ Set the dash style to use when stroking a path Parameters ---------- line_dash An even-lengthed tuple of floats that represents the width of each dash and gap in the dash pattern. """ @abstractmethod def set_fill_color(self, color): """ Set the color used to fill the region bounded by a path """ @abstractmethod def get_fill_color(self): """ Get the color used to fill the region bounded by a path """ @abstractmethod def linear_gradient(self, x1, y1, x2, y2, stops, spread_method, units): """ Modify the fill color to be a linear gradient """ @abstractmethod def radial_gradient(self, cx, cy, r, fx, fy, stops, spread_method, units): """ Modify the fill color to be a linear gradient """ @abstractmethod def set_alpha(self, alpha): """ Set the alpha to use when drawing """ @abstractmethod def get_alpha(self, alpha): """ Return the alpha used when drawing """ @abstractmethod def set_antialias(self, antialias): """ Set whether or not to antialias when drawing """ @abstractmethod def get_antialias(self): """ Set whether or not to antialias when drawing """ @abstractmethod def set_miter_limit(self, miter_limit): """ Set the limit at which mitered joins are flattened """ @abstractmethod def set_flatness(self, flatness): """ Set the error tolerance when drawing curved paths """ @abstractmethod def set_image_interpolation(self, interpolation): """ Set the type of interpolation to use when scaling images """ @abstractmethod def get_image_interpolation(self): """ Get the type of interpolation to use when scaling images """ # ------------------------------------------- # Transformation matrix methods # ------------------------------------------- @abstractmethod def translate_ctm(self, x, y): """ Concatenate a translation to the current transformation matrix """ @abstractmethod def rotate_ctm(self, angle): """ Concatenate a rotation to the current transformation matrix """ @abstractmethod def concat_ctm(self, matrix): """ Concatenate an arbitrary affine matrix to the current transformation matrix """ @abstractmethod def scale_ctm(self, x_scale, y_scale): """ Concatenate a scaling to the current transformation matrix """ @abstractmethod def set_ctm(self, matrix): """ Set the current transformation matrix """ @abstractmethod def get_ctm(self): """ Get the current transformation matrix """ # ------------------------------------------- # Clipping functions # ------------------------------------------- @abstractmethod def clip_to_rect(self, rect): """ Set the clipping region to the specified rectangle """ @abstractmethod def clip_to_rects(self, rect_array): """ Set the clipping region to the collection of rectangles """ @abstractmethod def clip(self): """ Set the clipping region to the current path """ @abstractmethod def even_odd_clip(self): """ Modify clipping region with current path using even-odd rule """ # ------------------------------------------- # Path construction functions # ------------------------------------------- @abstractmethod def begin_path(self): """ Start a new path """ @abstractmethod def close_path(self): """ Finish a subpath, connecting back to the start """ @abstractmethod def get_empty_path(self): """ Get an empty CompiledPath instance """ @abstractmethod def add_path(self, compiled_path): """ Add the current path to a compiled path """ @abstractmethod def move_to(self, x, y): """ Move the current point on the path without drawing """ @abstractmethod def line_to(self, x, y): """ Add a line from the current point to (x, y) to the path """ @abstractmethod def lines(self, points): """ Adds a series of lines as a new subpath. Parameters ---------- points an Nx2 sequence of (x, y) pairs The current_point is moved to the last point in `point_array`. """ @abstractmethod def line_set(self, starts, ends): """ Adds a set of disjoint lines as a new subpath. Parameters ---------- starts an Nx2 array of x,y pairs ends an Nx2 array of x,y pairs Starts and ends arrays should have the same length. The current point is moved to the last point in 'ends'. """ @abstractmethod def rect(self, x, y, w, h): """ Add a rectangle as a new sub-path The bottom left corner is (x, y) the width is w and height is h. """ @abstractmethod def rects(self, rect_array): """ Add a sequence of rectangles as separate sub-paths. Parameters ---------- rect_array: An Nx4 array of (x, y, w, h) quadruples """ @abstractmethod def curve_to(self, x1, y1, x2, y2, end_x, end_y): """ Draw a cubic bezier curve The curve starts from the current point and ends at (end_x, end_y), with control points (x1,y1) and (x2,y2). """ @abstractmethod def quad_curve_to(self, cp_x, cp_y, end_x, end_y): """ Draw a quadratic bezier curve The curve starts the current point and ends at (end_x, end_y), with control point (cp_x, cp_y) """ @abstractmethod def arc(self, x, y, radius, start_angle, end_angle, cw=False): """ Draw a circular arc of the given radius, centered at (x,y) The angular span is from start_angle to end_angle, where angles are measured counter-clockwise from the positive X axis. If "cw" is true, then the arc is swept from the end_angle back to the start_angle (it does not change the sense in which the angles are measured, but may affect rendering based on winding number calculations). """ @abstractmethod def arc_to(self, x1, y1, x2, y2, radius): """ Draw a circular arc from current point to tangent line The arc is tangent to the line from the current pen position to (x1,y1), and it is also tangent to the line from (x1,y1) to (x2,y2). (x1,y1) is the imaginary intersection point of the two lines tangent to the arc at the current point and at (x2,y2). If the tangent point on the line from the current pen position to (x1,y1) is not equal to the current pen position, a line is drawn to it. Depending on the supplied radius, the tangent point on the line fron (x1,y1) to (x2,y2) may or may not be (x2,y2). In either case, the arc is drawn to the point of tangency, which is also the new pen position. Consider the common case of rounding a rectangle's upper left corner. Let "r" be the radius of rounding. Let the current pen position be (x_left + r, y_top). Then (x2,y2) would be (x_left, y_top - radius), and (x1,y1) would be (x_left, y_top). """ # ------------------------------------------- # Drawing functions # ------------------------------------------- @abstractmethod def stroke_path(self): """ Stroke the current path with pen settings from current state """ @abstractmethod def fill_path(self): """ Fill the current path with fill settings from the current state This fills using the nonzero rule filling algorithm """ @abstractmethod def eof_fill_path(self): """ Fill the current path with fill settings from the current state This fills using the even-odd rule filling algorithm """ @abstractmethod def draw_path(self, draw_mode=FILL_STROKE): """ Draw the current path with the specified mode """ @abstractmethod def draw_rect(self, rect, draw_mode=FILL_STROKE): """ Draw a rectangle with the specified mode The rectangle is specified by a tuple (x, y, w, h). """ @abstractmethod def draw_image(image, rect=None): """ Render an image into a rectangle The rectangle is specified as an (x, y, w, h) tuple. If it is not specified then the bounds of the the graphics context are used as the rectangle. """ # ------------------------------------------- # Text functions # ------------------------------------------- @abstractmethod def set_text_drawing_mode(self, draw_mode): """ Set the drawing mode to use with text """ @abstractmethod def set_text_matrix(self, text_matrix): """ Set the transformation matrix to use when drawing text """ @abstractmethod def get_text_matrix(self): """ Get the transformation matrix to use when drawing text """ @abstractmethod def set_text_position(self, x, y): """ Set the current point for drawing text This point is on the baseline of the text """ @abstractmethod def get_text_position(self): """ Get the current point where text will be drawn """ @abstractmethod def show_text(self, text): """ Draw the specified string at the current point """ @abstractmethod def get_text_extent(self, text): """ Return a rectangle which encloses the specified text The rectangle (x, y, w, h) is relative to an origin which is at the baseline of the text and at the left of the first character rendered. In other words, x is the leading and y the descent. """ @abstractmethod def get_full_text_extent(self, string): """ Get the text extent as a tuple (w, h, x, y) This method is deprecated: you should use get_text_extent() instead. This order is provided for backwards-compatibility with existing Enable code. """ @abstractmethod def select_font(self, name, size=12, style="regular", encoding=None): """ Set the font based on the provided parameters Parameters ---------- name: The name of a font. E.g.: "Times New Roman" size The font size in points. style One of "regular", "bold", "italic", "bold italic" encoding A 4 letter encoding name. Common ones are: * "unic" -- unicode * "armn" -- apple roman * "symb" -- symbol Not all fonts support all encodings. If none is specified, fonts that have unicode encodings default to unicode. Symbol is the second choice. If neither are available, the encoding defaults to the first one returned in the FreeType charmap list for the font face. """ @abstractmethod def set_font(self, font): """ Set the font with a Kiva font object """ @abstractmethod def get_font(self): """ Get the current font """ @abstractmethod def set_font_size(self, size): """ Set the size of the current font """ @abstractmethod def set_character_spacing(self, spacing): """ Set the spacing between characters when drawing text Parameters ---------- spacing : float units of space extra space to add between text coordinates. It is specified in text coordinate system. """ @abstractmethod def get_character_spacing(self): """ Get the current spacing between characters when drawing text """ @abstractmethod def show_text_at_point(self, x, y): """ Draw text at the absolute position specified by the point """ # ------------------------------------------- # Misc functions # ------------------------------------------- @abstractmethod def flush(self): """ Render all pending draw operations immediately This only makes sense in GUI window contexts (eg. Quartz or QPainter). """ @abstractmethod def synchronize(self): """ A deferred version of flush() Also only relevant in window contexts. """ @abstractmethod def begin_page(self): """ Start rendering in a new page """ @abstractmethod def end_page(self): """ Finish rendering in a page """ @abstractmethod def clear_rect(self, rect): """ Set rectangle to background colour This may not be available in some backends, such as PDF or PostScript. """ @abstractmethod def save(self, filename, file_format=None, pil_options=None): """ Save the graphics context to a file Data is always saved in RGB or RGBA format, and converted to that format if not already in it. If the file_format argument is None, then the file format is inferred from the filename extension, and so is not usually needed. The pil_options argument is a dictionary of format-specific options that can be passed directly to PIL's image file writers. For example, this can be used to control the compression level of JPEG or PNG output. Unrecognized options are silently ignored. """ class EnhancedAbstractGraphicsContext(AbstractGraphicsContext): """ ABC for graphics contexts which provide additional methods """ @abstractmethod def draw_marker_at_points(self, point_array, size, marker=SQUARE_MARKER): """ Draw a marker at a collection of points The shape and size of the marker are specified by the size and marker arguments. """ @abstractmethod def draw_path_at_points(self, point_array, compiled_path, draw_mode): """ Draw a compiled path at a collection of points The starting point of the paths are specified by the points, and the drawing mode is specified by the third argument. """ @abstractmethod def show_text_translate(self, text, dx, dy): """ Draw the specified text translated as specified """ enthought-chaco2-4.5.1.orig/kiva/constants.py0000644000175000017500000000752612516137326020232 0ustar varunvarun# ------------------------------------------------------------------------------ # Copyright (c) 2005, Enthought, Inc. # some parts copyright Space Telescope Science Institute # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # ------------------------------------------------------------------------------ """ Constants used by core2d drawing engine. """ from numpy import array # -------------------------------------------------------------------- # Line Dash Constants # -------------------------------------------------------------------- NO_DASH = (0, array([0])) del array # -------------------------------------------------------------------- # Line Cap Constants # -------------------------------------------------------------------- CAP_ROUND = 0 CAP_BUTT = 1 CAP_SQUARE = 2 # -------------------------------------------------------------------- # Line Join Constants # -------------------------------------------------------------------- JOIN_ROUND = 0 JOIN_BEVEL = 1 JOIN_MITER = 2 # -------------------------------------------------------------------- # Path Drawing Mode Constants # # Path drawing modes for path drawing methods. # The values are chosen so that bit flags can be checked in a later # C version. # -------------------------------------------------------------------- FILL = 1 EOF_FILL = 2 STROKE = 4 FILL_STROKE = 5 EOF_FILL_STROKE = 6 # ----------------------------------------------------------------------------- # Font Constants # ----------------------------------------------------------------------------- NORMAL = 0 BOLD = 1 ITALIC = 2 BOLD_ITALIC = 3 # Font families, as defined by the Windows API, and their CSS equivalents DEFAULT = 0 SWISS = 1 # Sans-serif ROMAN = 2 # Serif MODERN = 3 # Monospace DECORATIVE = 4 # Fantasy SCRIPT = 5 # Cursive TELETYPE = 6 # ----------------------------------------------------------------------------- # Text Drawing Mode Constants # ----------------------------------------------------------------------------- TEXT_FILL = 0 TEXT_STROKE = 1 TEXT_FILL_STROKE = 2 TEXT_INVISIBLE = 3 TEXT_FILL_CLIP = 4 TEXT_STROKE_CLIP = 5 TEXT_FILL_STROKE_CLIP = 6 TEXT_CLIP = 7 TEXT_OUTLINE = 8 # ----------------------------------------------------------------------------- # Subpath Drawing Primitive Constants # # Used by the drawing state machine to determine what object to draw. # ----------------------------------------------------------------------------- POINT = 0 LINE = 1 LINES = 2 RECT = 3 CLOSE = 4 CURVE_TO = 5 QUAD_CURVE_TO = 6 ARC = 7 ARC_TO = 8 # ----------------------------------------------------------------------------- # Subpath CTM Constants # # These are added so its possible for OpenGL to do the matrix transformations # on the data (its much faster than doing it with Numeric). # ----------------------------------------------------------------------------- SCALE_CTM = 5 TRANSLATE_CTM = 6 ROTATE_CTM = 7 CONCAT_CTM = 8 LOAD_CTM = 9 # ----------------------------------------------------------------------------- # Marker Types # # These are the marker types for draw_marker_at_points. Some backends # (like Agg) have fast implementations for these; other backends manually # construct the paths representing these markers. # # Note that draw_marker_at_points takes a marker name as a string. # ----------------------------------------------------------------------------- NO_MARKER = 0 SQUARE_MARKER = 1 DIAMOND_MARKER = 2 CIRCLE_MARKER = 3 CROSSED_CIRCLE_MARKER = 4 CROSS_MARKER = 5 TRIANGLE_MARKER = 6 INVERTED_TRIANGLE_MARKER = 7 PLUS_MARKER = 8 DOT_MARKER = 9 PIXEL_MARKER = 10 enthought-chaco2-4.5.1.orig/kiva/cairo.py0000644000175000017500000013111412516137326017302 0ustar varunvarun""" Implementation of the core2d drawing library, using cairo for rendering :Author: Bryan Cole (bryan@cole.uklinux.net) :Copyright: Bryan Cole (except parts copied from basecore2d) :License: BSD Style This is currently under development and is not yet fully functional. """ from __future__ import absolute_import import cairo import copy from itertools import izip import numpy import warnings from .arc_conversion import arc_to_tangent_points from . import basecore2d, constants line_join = {constants.JOIN_BEVEL: cairo.LINE_JOIN_BEVEL, constants.JOIN_MITER: cairo.LINE_JOIN_MITER, constants.JOIN_ROUND: cairo.LINE_JOIN_ROUND } line_cap = {constants.CAP_BUTT: cairo.LINE_CAP_BUTT, constants.CAP_ROUND: cairo.LINE_CAP_ROUND, constants.CAP_SQUARE: cairo.LINE_CAP_SQUARE } font_slant = {"regular":cairo.FONT_SLANT_NORMAL, "bold":cairo.FONT_SLANT_NORMAL, "italic":cairo.FONT_SLANT_ITALIC, "bold italic":cairo.FONT_SLANT_ITALIC } font_weight = {"regular":cairo.FONT_WEIGHT_NORMAL, "bold":cairo.FONT_WEIGHT_BOLD, "italic":cairo.FONT_WEIGHT_NORMAL, "bold italic":cairo.FONT_WEIGHT_BOLD } spread_methods = {"pad":cairo.EXTEND_PAD, "reflect":cairo.EXTEND_REFLECT, "repeat":cairo.EXTEND_REPEAT } text_draw_modes = {'FILL': (constants.TEXT_FILL, constants.TEXT_FILL_CLIP, constants.TEXT_FILL_STROKE, constants.TEXT_FILL_STROKE_CLIP), 'STROKE':(constants.TEXT_FILL_STROKE, constants.TEXT_FILL_STROKE_CLIP, constants.TEXT_STROKE, constants.TEXT_STROKE_CLIP), 'CLIP':(constants.TEXT_CLIP, constants.TEXT_FILL_CLIP, constants.TEXT_FILL_STROKE_CLIP, constants.TEXT_STROKE_CLIP), 'INVISIBLE': constants.TEXT_INVISIBLE } class PixelMap(object): def __init__(self, surface, width, height): self.surface = surface self.width = width self.height = height def draw_to_wxwindow(self, window, x, y): import wx window_dc = getattr(window,'_dc',None) if window_dc is None: window_dc = wx.PaintDC(window) arr = self.convert_to_rgbarray() image = wx.EmptyImage(self.width, self.height) image.SetDataBuffer(arr.data) bmp = wx.BitmapFromImage(image, depth=-1) window_dc.BeginDrawing() window_dc.DrawBitmap(bmp,x,y) window_dc.EndDrawing() return def convert_to_rgbarray(self): pixels = numpy.frombuffer(self.surface.get_data(), numpy.uint8) red = pixels[2::4] green = pixels[1::4] blue = pixels[0::4] return numpy.vstack((red, green, blue)).T.flatten() def convert_to_argbarray(self, flip=False): pixels = numpy.frombuffer(self.surface.get_data(), numpy.uint8) alpha = pixels[0::4] red = pixels[1::4] green = pixels[2::4] blue = pixels[3::4] if flip: return numpy.vstack((alpha, red, green, blue)).T\ .reshape((self.height, self.width, 4))[::-1,...].flatten() # no flip return numpy.vstack((alpha, red, green, blue)).T.flatten() class GraphicsState(object): """ Holds information used by a graphics context when drawing. The Cairo state stores the following: * Operator (the blend mode) * Tolerance * Antialias (bool) * stroke style (line width, cap, join, mitre-limit, dash-style) * fill rule * font face * scaled font * font matrix (includes font size) * font options (antialias, subpixel order, hint style, hint metrics) * clip region * target surface and previous target surface * CTM, CTM-inverse, source CTM The Quartz2D state (which kiva follows AFAIK) includes: * CTM * stroke style (line width, cap, join, mitre, dash) * clip region * tolerance (accuracy) * anti-alias * \*fill- and stroke- colors * \*fill- and stroke- Color Space (RGB, HSV, CMYK etc.) * \*Rendering intent (something to do with Color Spaces) * \*alpha value * blend mode * text font * text font size * \*text drawing mode (stroked, filled, clipped and combinations of these) * \*text character spacing (extra space between glyphs) \*: items in the Quartz2D state that Cairo doesn't support directly. basecore2d GraphicsState includes: * ctm * line_color * line_width * line_join * line_cap * line_dash * fill_color * alpha * font * \*text_matrix * clipping_path * \*current_point * should_antialias * miter_limit * flatness * character_spacing * text_drawing_mode * rendering_intent (not yet implemented) \*: discrepancies compared to Quartz2D """ def __init__(self): self.fill_color = [1,1,1] self.stroke_color = [1,1,1] self.alpha = 1.0 self.text_drawing_mode = constants.TEXT_FILL self.has_gradient = False #not implemented yet... self.text_character_spacing = None self.fill_colorspace = None self.stroke_colorspace = None self.rendering_intent = None def copy(self): return copy.deepcopy(self) class GraphicsContext(basecore2d.GraphicsContextBase): def __init__(self, size, *args, **kw): super(GraphicsContext, self).__init__(size, *args, **kw) w,h = size self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h) self.surface.set_device_offset(0,h) if 'context' in kw: ctx = kw.pop('context') else: ctx = cairo.Context(self.surface) ctx.set_source_rgb(1,1,1) ctx.scale(1,-1) self._ctx = ctx self.state = GraphicsState() self.state_stack = [] #the text-matrix includes the text position self.text_matrix = cairo.Matrix(1,0,0,-1,0,0) #not part of the graphics state self.pixel_map = PixelMap(self.surface, w, h) def clear(self, color=(1,1,1)): self.save_state() if len(color) == 4: self._ctx.set_source_rgba(*color) else: self._ctx.set_source_rgb(*color) self.rect(0, 0, self.width(), self.height()) self.draw_path(constants.FILL) self.restore_state() def height(self): return self._ctx.get_target().get_height() def width(self): return self._ctx.get_target().get_width() def scale_ctm(self, sx, sy): """ Sets the coordinate system scale to the given values, (sx,sy). Parameters ---------- sx : float The new scale factor for the x axis sy : float The new scale factor for the y axis """ self._ctx.scale(sx, sy) def translate_ctm(self, tx, ty): """ Translates the coordinate system by the value given by (tx,ty) Parameters ---------- tx : float The distance to move in the x direction ty : float The distance to move in the y direction """ self._ctx.translate(tx, ty) def rotate_ctm(self, angle): """ Rotates the coordinate space for drawing by the given angle. Parameters ---------- angle : float the angle, in radians, to rotate the coordinate system """ self._ctx.rotate(angle) def concat_ctm(self, transform): """ Concatenates the transform to current coordinate transform matrix. Parameters ---------- transform : affine_matrix the transform matrix to concatenate with the current coordinate matrix. """ try: #assume transform is a cairo.Matrix object self._ctx.transform(transform) except TypeError: #now assume transform is a list of matrix elements (floats) self._ctx.transform(cairo.Matrix(*transform)) def get_ctm(self): """ Returns the current coordinate transform matrix as a list of matrix elements """ return list(self._ctx.get_matrix()) #---------------------------------------------------------------- # Save/Restore graphics state. #---------------------------------------------------------------- def save_state(self): """ Saves the current graphic's context state. Always pair this with a `restore_state()`. """ self._ctx.save() self.state_stack.append(self.state) self.state = self.state.copy() def restore_state(self): """ Restores the previous graphics state. """ self._ctx.restore() self.state = self.state_stack.pop() #---------------------------------------------------------------- # Manipulate graphics state attributes. #---------------------------------------------------------------- def set_antialias(self,value): """ Sets/Unsets anti-aliasing for bitmap graphics context. Ignored on most platforms. """ if bool(value): val = cairo.ANTIALIAS_DEFAULT else: val = cairo.ANTIALIAS_NONE self._ctx.set_antialias(val) def set_line_width(self,width): """ Sets the line width for drawing Parameters ---------- width : float The new width for lines in user space units. """ self._ctx.set_line_width(width) def set_line_join(self,style): """ Sets the style for joining lines in a drawing. Parameters ---------- style : join_style The line joining style. The available styles are JOIN_ROUND, JOIN_BEVEL, JOIN_MITER. """ try: self._ctx.set_line_join(line_join[style]) except KeyError: raise ValueError("Invalid line-join style") def set_miter_limit(self,limit): """ Specifies limits on line lengths for mitering line joins. If line_join is set to miter joins, the limit specifies which line joins should actually be mitered. If lines are not mitered, they are joined with a bevel. The line width is divided by the length of the miter. If the result is greater than the limit, the bevel style is used. This is not implemented on most platforms. Parameters ---------- limit : float limit for mitering joins. defaults to 1.0. (XXX is this the correct default?) """ self._ctx.set_miter_limit(limit) def set_line_cap(self,style): """ Specifies the style of endings to put on line ends. Parameters ---------- style : cap_style The line cap style to use. Available styles are CAP_ROUND, CAP_BUTT, CAP_SQUARE. """ try: self._ctx.set_line_cap(line_cap[style]) except KeyError: raise ValueError("Invalid line cap style") def set_line_dash(self,pattern,phase=0): """ Sets the line dash pattern and phase for line painting. Parameters ---------- pattern : float array An array of floating point values specifing the lengths of on/off painting pattern for lines. phase : float Specifies how many units into dash pattern to start. phase defaults to 0. """ if pattern is not None: pattern = list(pattern) self._ctx.set_dash(pattern, phase) def set_flatness(self,flatness): """ Not implemented It is device dependent and therefore not recommended by the PDF documentation. flatness determines how accurately lines are rendered. Setting it to values less than one will result in more accurate drawings, but they take longer. It defaults to None """ self._ctx.set_tolerance(flatness) #---------------------------------------------------------------- # Sending drawing data to a device #---------------------------------------------------------------- def flush(self): """ Sends all drawing data to the destination device. Currently this is a NOP for wxPython. """ s = self._ctx.get_target() s.flush() def synchronize(self): """ Prepares drawing data to be updated on a destination device. Currently this is a NOP for all implementations. """ pass #---------------------------------------------------------------- # Page Definitions #---------------------------------------------------------------- def begin_page(self): """ Creates a new page within the graphics context. Currently this is a NOP for all implementations. The PDF backend should probably implement it, but the ReportLab Canvas uses the showPage() method to handle both begin_page and end_page issues. """ pass def end_page(self): """ Ends drawing in the current page of the graphics context. Currently this is a NOP for all implementations. The PDF backend should probably implement it, but the ReportLab Canvas uses the showPage() method to handle both begin_page and end_page issues. """ pass def radial_gradient(self, cx, cy, r, fx, fy, stops, spreadMethod='pad', units='userSpaceOnUse', transforms=None): """ Set a radial gradient as the fill color. """ # TODO: handle transforms if units == 'objectBoundingBox': # transform from relative coordinates path_rect = self._ctx.path_extents() width = path_rect[2]-path_rect[0] height = path_rect[3]-path_rect[1] r = r * width cx = path_rect[0] + cx * width fx = path_rect[0] + fx * width cy = path_rect[1] + cy * height fy = path_rect[1] + fy * height gradient = cairo.RadialGradient(fx, fy, 0.0, cx, cy, r) gradient.set_extend(spread_methods.get(spreadMethod, cairo.EXTEND_NONE)) for stop in stops: #FIXME: the stops are possibly being generated wrong if the offset is specified if stop.size == 10: start = tuple(stop[0:5]) end = tuple(stop[5:10]) gradient.add_color_stop_rgba(*start) gradient.add_color_stop_rgba(*end) else: start = tuple(stop[0:5]) gradient.add_color_stop_rgba(*start) self.state.has_gradient = True self._ctx.set_source(gradient) def linear_gradient(self, x1, y1, x2, y2, stops, spreadMethod='pad', units='userSpaceOnUse', transforms=None): """ Set a linear gradient as the fill color. """ # TODO: handle transforms if units == 'objectBoundingBox': # transform from relative coordinates path_rect = self._ctx.path_extents() width = path_rect[2]-path_rect[0] height = path_rect[3]-path_rect[1] x1 = path_rect[0] + x1 * width x2 = path_rect[0] + x2 * width y1 = path_rect[1] + y1 * height y2 = path_rect[1] + y2 * height gradient = cairo.LinearGradient(x1, y1, x2, y2) gradient.set_extend(spread_methods.get(spreadMethod, cairo.EXTEND_NONE)) for stop in stops: # FIXME: the stops are possibly being generated wrong if the offset is specified if stop.size == 10: start = tuple(stop[0:5]) end = tuple(stop[5:10]) gradient.add_color_stop_rgba(*start) gradient.add_color_stop_rgba(*end) else: start = tuple(stop[0:5]) gradient.add_color_stop_rgba(*start) self.state.has_gradient = True self._ctx.set_source(gradient) #---------------------------------------------------------------- # Building paths (contours that are drawn) # # + Currently, nothing is drawn as the path is built. Instead, the # instructions are stored and later drawn. Should this be changed? # We will likely draw to a buffer instead of directly to the canvas # anyway. # # Hmmm. No. We have to keep the path around for storing as a # clipping region and things like that. # # + I think we should keep the current_path_point hanging around. # #---------------------------------------------------------------- def begin_path(self): """ Clears the current drawing path and begin a new one. """ # Need to check here if the current subpath contains matrix # transforms. If it does, pull these out, and stick them # in the new subpath. self._ctx.new_path() def move_to(self,x,y): """ Starts a new drawing subpath and place the current point at (x,y). Notes: Not sure how to treat state.current_point. Should it be the value of the point before or after the matrix transformation? It looks like before in the PDF specs. """ self._ctx.move_to(x,y) def line_to(self,x,y): """ Adds a line from the current point to the given point (x,y). The current point is moved to (x,y). What should happen if move_to hasn't been called? Should it always begin at 0,0 or raise an error? Notes: See note in move_to about the current_point. """ self._ctx.line_to(x,y) def lines(self,points): """ Adds a series of lines as a new subpath. Parameters ---------- points an Nx2 array of x,y pairs The current_point is moved to the last point in 'points' """ self._ctx.new_sub_path() for point in points: self._ctx.line_to(*point) def line_set(self, starts, ends): """ Adds a set of disjoint lines as a new subpath. Parameters ---------- starts an Nx2 array of x,y pairs ends an Nx2 array of x,y pairs Starts and ends should have the same length. The current point is moved to the last point in 'ends'. N.B. Cairo cannot make disjointed lines as a single subpath, thus each line forms it's own subpath """ for start, end in izip(starts, ends): self._ctx.move_to(*start) self._ctx.line_to(*end) def rect(self,x,y,sx,sy): """ Adds a rectangle as a new subpath. """ self._ctx.rectangle(x,y,sx,sy) # def draw_rect(self, rect, mode): # self.rect(*rect) # self.draw_path(mode=mode) # # def rects(self,rects): # """ Adds multiple rectangles as separate subpaths to the path. # # Not very efficient -- calls rect multiple times. # """ # for x,y,sx,sy in rects: # self.rect(x,y,sx,sy) def close_path(self,tag=None): """ Closes the path of the current subpath. Currently starts a new subpath -- is this what we want? ... Cairo starts a new subpath automatically. """ self._ctx.close_path() def curve_to(self, x_ctrl1, y_ctrl1, x_ctrl2, y_ctrl2, x_to, y_to): """ Draw a cubic bezier curve from the current point. Parameters ---------- x_ctrl1 : float X-value of the first control point. y_ctrl1 : float Y-value of the first control point. x_ctrl2 : float X-value of the second control point. y_ctrl2 : float Y-value of the second control point. x_to : float X-value of the ending point of the curve. y_to : float Y-value of the ending point of the curve. """ self._ctx.curve_to(x_ctrl1, y_ctrl1, x_ctrl2, y_ctrl2, x_to, y_to) # def quad_curve_to(self, x_ctrl, y_ctrl, x_to, y_to): # """ Draw a quadratic bezier curve from the current point. # # Parameters # ---------- # x_ctrl : float # X-value of the control point # y_ctrl : float # Y-value of the control point. # x_to : float # X-value of the ending point of the curve # y_to : float # Y-value of the ending point of the curve. # """ # # A quadratic Bezier curve is just a special case of the cubic. Reuse # # its implementation in case it has been implemented for the specific # # backend. # x0, y0 = self.state.current_point # xc1 = (x0 + x_ctrl + x_ctrl) / 3.0 # yc1 = (y0 + y_ctrl + y_ctrl) / 3.0 # xc2 = (x_to + x_ctrl + x_ctrl) / 3.0 # yc2 = (y_to + y_ctrl + y_ctrl) / 3.0 # self.curve_to(xc1, yc1, xc2, yc2, x_to, y_to) def arc(self, x, y, radius, start_angle, end_angle, cw=False): """ Draw a circular arc. If there is a current path and the current point is not the initial point of the arc, a line will be drawn to the start of the arc. If there is no current path, then no line will be drawn. Parameters ---------- x : float X-value of the center of the arc. y : float Y-value of the center of the arc. radius : float The radius of the arc. start_angle : float The angle, in radians, that the starting point makes with respect to the positive X-axis from the center point. end_angle : float The angles, in radians, that the final point makes with respect to the positive X-axis from the center point. cw : bool, optional Whether the arc should be drawn clockwise or not. """ if cw: #not sure if I've got this the right way round self._ctx.arc_negative( x, y, radius, start_angle, end_angle) else: self._ctx.arc( x, y, radius, start_angle, end_angle) def arc_to(self, x1, y1, x2, y2, radius): """ Draw an arc between the line segments from the current point to (x1,y1) and from (x1,y1) to (x2,y2). Straight lines are also added from the current point to the start of the curve and from the end of the curve to (x2,y2). """ current_point = self.get_path_current_point() # Get the endpoints on the curve where it touches the line segments t1, t2 = arc_to_tangent_points(current_point, (x1,y1), (x2,y2), radius) # draw! self._ctx.line_to(*t1) self._ctx.curve_to(x1,y1, x1,y1, *t2) self._ctx.line_to(x2,y2) #---------------------------------------------------------------- # Getting infomration on paths #---------------------------------------------------------------- def is_path_empty(self): """ Tests to see whether the current drawing path is empty What does 'empty' mean??? """ p = self._ctx.copy_path() return any(a[0] for a in p) def get_path_current_point(self): """ Returns the current point from the graphics context. Note: Currently the current_point is only affected by move_to, line_to, and lines. It should also be affected by text operations. I'm not sure how rect and rects and friends should affect it -- will find out on Mac. """ return self._ctx.get_current_point() def get_path_bounding_box(self): """ cairo.Context.path_extents not yet implemented on my cairo version. It's in new ones though. What should this method return? """ if self.is_path_empty(): return [[0,0],[0,0]] p = [a[1] for a in self._ctx.copy_path()] p = numpy.array(p) return [p.min(axis=1), p.max(axis=1)] def add_path(self, path): """Draw a compiled path into this gc. In this case, a compiled path is a Cairo.Path""" if isinstance(path, CompiledPath): self.begin_path() for op_name, op_args in path.state: op = getattr(self, op_name) op(*op_args) self.close_path() #---------------------------------------------------------------- # Clipping path manipulation #---------------------------------------------------------------- def clip(self): """ Should this use clip or clip_preserve """ fr = self._ctx.get_fill_rule() self._ctx.set_fill_rule(cairo.FILL_RULE_WINDING) self._ctx.clip() self._ctx.set_fill_rule(fr) def even_odd_clip(self): """ """ fr = self._ctx.get_fill_rule() self._ctx.set_fill_rule(cairo.FILL_RULE_EVEN_ODD) self._ctx.clip() self._ctx.set_fill_rule(fr) def clip_to_rect(self,x,y,width,height): """ Sets the clipping path to the intersection of the current clipping path with the area defined by the specified rectangle """ ctx = self._ctx #get the current path p = ctx.copy_path() ctx.new_path() ctx.rectangle(x,y,width,height) ctx.clip() ctx.append_path(p) # def clip_to_rects(self): # """ # """ # pass def clear_clip_path(self): self._ctx.reset_clip() #---------------------------------------------------------------- # Color space manipulation # # I'm not sure we'll mess with these at all. They seem to # be for setting the color system. Hard coding to RGB or # RGBA for now sounds like a reasonable solution. #---------------------------------------------------------------- #def set_fill_color_space(self): # """ # """ # pass #def set_stroke_color_space(self): # """ # """ # pass #def set_rendering_intent(self): # """ # """ # pass #---------------------------------------------------------------- # Color manipulation #---------------------------------------------------------------- def _set_source_color(self, color): if len(color) == 3: self._ctx.set_source_rgb(*color) else: self._ctx.set_source_rgba(*color) # gradients or other source patterns are blown away by set_source_rgb* self.state.has_gradient = False def set_fill_color(self,color): """ set_fill_color takes a sequences of rgb or rgba values between 0.0 and 1.0 """ self.state.fill_color = color def set_stroke_color(self,color): """ set_stroke_color takes a sequences of rgb or rgba values between 0.0 and 1.0 """ self.state.stroke_color = color def set_alpha(self,alpha): """ """ self.state.alpha = alpha #---------------------------------------------------------------- # Drawing Images #---------------------------------------------------------------- def draw_image(self,img,rect=None): """ img is either a N*M*3 or N*M*4 numpy array, or a Kiva image rect - what is this? assume it's a tuple (x,y, w, h) Only works with numpy arrays. What is a "Kiva Image" anyway? Not Yet Tested. """ from kiva import agg if type(img) == type(numpy.array([])): # Numeric array if img.shape[2]==3: format = cairo.FORMAT_RGB24 elif img.shape[2]==4: format = cairo.FORMAT_ARGB32 img_width, img_height = img.shape[:2] img_surface = cairo.ImageSurface.create_for_data(img.astype(numpy.uint8), format, img_width, img_height) elif isinstance(img, agg.GraphicsContextArray): converted_img = img.convert_pixel_format('rgba32', inplace=0) flipped_array = numpy.flipud(converted_img.bmp_array) img_width, img_height = converted_img.width(), converted_img.height() img_surface = cairo.ImageSurface.create_for_data(flipped_array.flatten(), cairo.FORMAT_RGB24, img_width, img_height) elif isinstance(img, GraphicsContext): # Another cairo kiva context img_width, img_height = img.pixel_map.width, img.pixel_map.height img_surface = cairo.ImageSurface.create_for_data(img.pixel_map.convert_to_argbarray(flip=True), cairo.FORMAT_ARGB32, img_width, img_height) else: warnings.warn("Cannot render image of type '%r' into cairo context." % \ type(img)) return ctx = self._ctx img_pattern = cairo.SurfacePattern(img_surface) if rect: x,y,sx,sy = rect if sx != img_width or sy != img_height: scaler = cairo.Matrix() scaler.scale(img_width/float(sx), img_height/float(sy)) img_pattern.set_matrix(scaler) img_pattern.set_filter(cairo.FILTER_BEST) ctx.set_source(img_pattern) #p = ctx.copy_path() #need to save the path ctx.new_path() ctx.rectangle(x,y,sx,sy) ctx.fill() else: ctx.set_source(img_pattern) ctx.paint() #------------------------------------------------------------------------- # Drawing Text # # Font handling needs more attention. # #------------------------------------------------------------------------- def select_font(self,face_name,size=12,style="regular",encoding=None): """ Selects a new font for drawing text. Parameters ---------- face_name The name of a font. E.g.: "Times New Roman" !! Need to specify a way to check for all the types size The font size in points. style One of "regular", "bold", "italic", "bold italic" encoding A 4 letter encoding name. Common ones are: * "unic" -- unicode * "armn" -- apple roman * "symb" -- symbol Not all fonts support all encodings. If none is specified, fonts that have unicode encodings default to unicode. Symbol is the second choice. If neither are available, the encoding defaults to the first one returned in the FreeType charmap list for the font face. """ # !! should check if name and encoding are valid. # self.state.font = freetype.FontInfo(face_name,size,style,encoding) self._ctx.select_font_face(face_name, font_slant[style], font_weight[style]) self._ctx.set_font_size(size) def set_font(self,font): """ Set the font for the current graphics context. A device-specific font object. In this case, a cairo FontFace object. It's not clear how this can be used right now. """ if font.weight in (constants.BOLD, constants.BOLD_ITALIC): weight = cairo.FONT_WEIGHT_BOLD else: weight = cairo.FONT_WEIGHT_NORMAL if font.style in (constants.ITALIC, constants.BOLD_ITALIC): style = cairo.FONT_SLANT_ITALIC else: style = cairo.FONT_SLANT_NORMAL face_name = font.face_name ctx = self._ctx ctx.select_font_face(face_name, style, weight) ctx.set_font_size(font.size) #facename = font.face_name #slant = font.style #self._ctx.set_font_face(font) def set_font_size(self,size): """ Sets the size of the font. The size is specified in user space coordinates. """ self._ctx.set_font_size(size) def set_character_spacing(self,spacing): """ Sets the amount of additional spacing between text characters. Parameters ---------- spacing : float units of space extra space to add between text coordinates. It is specified in text coordinate system. Notes ----- 1. I'm assuming this is horizontal spacing? 2. Not implemented in wxPython, or cairo (for the time being) """ self.state.character_spacing = spacing def set_text_drawing_mode(self, mode): """ Specifies whether text is drawn filled or outlined or both. Parameters ---------- mode determines how text is drawn to the screen. If a CLIP flag is set, the font outline is added to the clipping path. Possible values: TEXT_FILL fill the text TEXT_STROKE paint the outline TEXT_FILL_STROKE fill and outline TEXT_INVISIBLE paint it invisibly ?? TEXT_FILL_CLIP fill and add outline clipping path TEXT_STROKE_CLIP outline and add outline to clipping path TEXT_FILL_STROKE_CLIP fill, outline, and add to clipping path TEXT_CLIP add text outline to clipping path Note: wxPython currently ignores all but the INVISIBLE flag. """ if mode not in (TEXT_FILL, TEXT_STROKE, TEXT_FILL_STROKE, TEXT_INVISIBLE, TEXT_FILL_CLIP, TEXT_STROKE_CLIP, TEXT_FILL_STROKE_CLIP, TEXT_CLIP, TEXT_OUTLINE): msg = "Invalid text drawing mode. See documentation for valid modes" raise ValueError, msg self.state.text_drawing_mode = mode def set_text_position(self,x,y): """ """ m = list(self.text_matrix) m[4:6] = x,y self.text_matrix = cairo.Matrix(*m) def get_text_position(self): """ """ return tuple(self.text_matrix)[4:6] def set_text_matrix(self,ttm): """ """ if isinstance(ttm, cairo.Matrix): m = ttm else: m = cairo.Matrix(ttm) self.text_matrix = m def get_text_matrix(self): """ """ return copy.copy(self.text_matrix) def show_text(self,text, point=(0.0,0.0)): """ Draws text on the device at the current text position. Leaves the current point unchanged. """ self.show_text_at_point(text, point[0], point[1]) def show_glyphs(self): """ """ pass def show_text_at_point(self, text, x, y): """ """ ctx = self._ctx #print text, list(ctx.get_matrix()) cur_path = ctx.copy_path() ctx.save() ctx.transform(self.text_matrix) ctx.transform(cairo.Matrix(1,0,0,1,x,y)) ctx.new_path() ctx.text_path(text) #need to set up text drawing mode #'outline' and 'invisible' modes are not supported. mode = self.state.text_drawing_mode if mode in text_draw_modes['STROKE']: self._set_source_color(self.state.stroke_color) ctx.stroke_preserve() if mode in text_draw_modes['FILL']: self._set_source_color(self.state.fill_color) ctx.fill_preserve() if mode in text_draw_modes['CLIP']: ctx.clip_preserve() ctx.restore() ctx.new_path() ctx.append_path(cur_path) def show_glyphs_at_point(self): """ """ pass #---------------------------------------------------------------- # Painting paths (drawing and filling contours) #---------------------------------------------------------------- def draw_path(self, mode=constants.FILL_STROKE): """ Walks through all the drawing subpaths and draw each element. Each subpath is drawn separately. Parameters ---------- mode Specifies how the subpaths are drawn. The default is FILL_STROKE. The following are valid values. FILL Paint the path using the nonzero winding rule to determine the regions for painting. EOF_FILL Paint the path using the even-odd fill rule. STROKE Draw the outline of the path with the current width, end caps, etc settings. FILL_STROKE First fill the path using the nonzero winding rule, then stroke the path. EOF_FILL_STROKE First fill the path using the even-odd fill method, then stroke the path. """ ctx = self._ctx fr = ctx.get_fill_rule() if mode in [constants.EOF_FILL, constants.EOF_FILL_STROKE]: ctx.set_fill_rule(cairo.FILL_RULE_EVEN_ODD) else: ctx.set_fill_rule(cairo.FILL_RULE_WINDING) if mode in [constants.FILL, constants.EOF_FILL]: if not self.state.has_gradient: self._set_source_color(self.state.fill_color) ctx.fill() elif mode == constants.STROKE: if not self.state.has_gradient: self._set_source_color(self.state.stroke_color) ctx.stroke() elif mode in [constants.FILL_STROKE, constants.EOF_FILL_STROKE]: if not self.state.has_gradient: self._set_source_color(self.state.fill_color) ctx.fill_preserve() if not self.state.has_gradient: self._set_source_color(self.state.stroke_color) ctx.stroke() ctx.set_fill_rule(fr) def stroke_rect(self): """ How does this affect the current path? """ pass def stroke_rect_with_width(self): """ """ pass def fill_rect(self): """ """ pass def fill_rects(self): """ """ pass def clear_rect(self): """ """ pass def get_text_extent(self,textstring): """ returns the width and height of the rendered text """ xb, yb, w, h, xa, ya = self._ctx.text_extents(textstring) return xb, yb, w, h def get_full_text_extent(self,textstring): """ How does this differ from 'get_text_extent' ??? This just calls get_text_extent, for the time being. """ x,y,w,h = self.get_text_extent(textstring) ascent, descent, height, maxx, maxy = self._ctx.font_extents() return w, ascent+descent, -descent, height def render_component(self, component, container_coords=False): """ Renders the given component. Parameters ---------- component : Component The component to be rendered. container_coords : Boolean Whether to use coordinates of the component's container Description ----------- If *container_coords* is False, then the (0,0) coordinate of this graphics context corresponds to the lower-left corner of the component's **outer_bounds**. If *container_coords* is True, then the method draws the component as it appears inside its container, i.e., it treats (0,0) of the graphics context as the lower-left corner of the container's outer bounds. """ x, y = component.outer_position w, h = component.outer_bounds if not container_coords: x = -x y = -y self.translate_ctm(x, y) component.draw(self, view_bounds=(0, 0, w, h)) return def save(self, filename, file_format=None): """ Save the GraphicsContext to a (PNG) file. file_format is ignored. """ self.surface.flush() self.surface.write_to_png(filename) class CompiledPath(object): def __init__(self): self.state = [] def add_path(self, *args): self.state.append(('begin_path', args)) def rect(self, *args): self.state.append(('rect', args)) def move_to(self, *args): self.state.append(('move_to', args)) def line_to(self, *args): self.state.append(('line_to', args)) def close_path(self, *args): self.state.append(('close_path', args)) def quad_curve_to(self, *args): self.state.append(('quad_curve_to', args)) def curve_to(self, *args): self.state.append(('curve_to', args)) def arc(self, *args): self.state.append(('arc', args)) def total_vertices(self): return len(self.state) + 1 def vertex(self, index): return (self.state[index-1][1][0:2],) def font_metrics_provider(): return GraphicsContext((1,1)) if __name__=="__main__": from numpy import fabs, linspace, pi, sin from scipy.special import jn from traits.api import false from chaco.api import ArrayPlotData, Plot, PlotGraphicsContext from chaco.example_support import COLOR_PALETTE from itertools import cycle, izip DPI = 72.0 dpi_scale = DPI / 72.0 def create_plot(): numpoints = 100 low = -5 high = 15.0 x = linspace(low, high, numpoints) pd = ArrayPlotData(index=x) p = Plot(pd, bgcolor="lightgray", padding=50, border_visible=True) for t,i in izip(cycle(['line','scatter']),range(10)): pd.set_data("y" + str(i), jn(i,x)) p.plot(("index", "y" + str(i)), color=tuple(COLOR_PALETTE[i]), width = 2.0 * dpi_scale, type=t) p.x_grid.visible = True p.x_grid.line_width *= dpi_scale p.y_grid.visible = True p.y_grid.line_width *= dpi_scale p.legend.visible = True return p container = create_plot() container.outer_bounds = [800,600] container.do_layout(force=True) def render_cairo_png(): w,h = 800,600 scale = 1.0 s = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(w*scale),int(h*scale)) s.set_device_offset(0,h*scale) ctx = cairo.Context(s) ctx.set_source_rgb(1,1,1) ctx.paint() ctx.scale(1,-1) ctx.scale(scale,scale) gc = GraphicsContext((w,h), context=ctx) gc.render_component(container) s.flush() s.write_to_png("/tmp/kiva_cairo.png") def render_cairo_svg(): w,h = 800,600 scale = 1.0 s = cairo.SVGSurface("/tmp/kiva_cairo.svg", w*scale,h*scale) s.set_device_offset(0,h*scale) ctx = cairo.Context(s) ctx.set_source_rgb(1,1,1) ctx.paint() ctx.scale(1,-1) ctx.scale(scale,scale) gc = GraphicsContext((w,h), context=ctx) gc.render_component(container) s.finish() def render_cairo_pdf(): w,h = 800,600 scale = 1.0 s = cairo.PDFSurface("/tmp/kiva_cairo.pdf", w*scale,h*scale) s.set_device_offset(0,h*scale) ctx = cairo.Context(s) ctx.set_source_rgb(1,1,1) ctx.paint() ctx.scale(1,-1) ctx.scale(scale,scale) gc = GraphicsContext((w,h), context=ctx) gc.render_component(container) s.finish() def render_agg(): gc2 = PlotGraphicsContext((800,600), dpi=DPI) gc2.render_component(container) gc2.save("/tmp/kiva_agg.png") #render_agg() render_cairo_png() render_cairo_svg() render_cairo_pdf() render_agg() enthought-chaco2-4.5.1.orig/kiva/affine.py0000644000175000017500000002024412516137326017436 0ustar varunvarun# ------------------------------------------------------------------------------ # Copyright (c) 2005, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # # Author: Enthought, Inc. # Description: # ------------------------------------------------------------------------------ """ Functions for affine matrices. :Copyright: Space Telescope Science Institute :License: BSD Style :Author: Eric Jones, Enthought, Inc., eric@enthought.com These affine operations are based coordinate system transformations, not translations of pts, etc. To translate a point, you multiply it by the affine transform matrix:: a b 0 [x, y, 1] * c d 0 = [x', y', 1] tx ty 1 This is the opposite order of multiplication from what many are accustomed to. Here is a useful link: http://mathworld.wolfram.com/AffineTransformation.html Notes: I'm not using a class because of possible speed implications. Currently the affine transform is a 3x3 array. Other tools use a 6-tuple of (a, b, c, d, tx, ty) to represent the transform because the other 3 array entries are constant. Other code should call methods from this module instead of manipulating the array, in case the implementation is changed at some future date. """ from numpy import (array, array_equal, arctan2, cos, dot, eye, float64, ones, ravel, sin, zeros) # ----------------------------------------------------------------------------- # Affine transform construction # ----------------------------------------------------------------------------- def affine_identity(): """ Returns a new identity affine_transform object. """ return eye(3, 3) def affine_from_values(a, b, c, d, tx, ty): """ Return the affine matrix corresponding to the values The result is the array:: [ a b 0 ] [ c d 0 ] [ tx ty 1 ] """ transform = array(((a, b, 0), (c, d, 0), (tx, ty, 1)), float64) return transform def affine_from_scale(sx, sy): """ Returns an affine transform providing the given scaling. """ r = affine_identity() return scale(r, sx, sy) def affine_from_rotation(angle): """ Returns an affine transform rotated by angle in radians. """ r = affine_identity() return rotate(r, angle) def affine_from_translation(x, y): """ Returns an affine transform with the given translation. """ r = affine_identity() return translate(r, x, y) # ----------------------------------------------------------------------------- # Affine transform manipulation # ----------------------------------------------------------------------------- def scale(transform, sx, sy): """ Returns a scaled version of the transform by the given values. Scaling is done using the following formula:: sx 0 0 a b 0 sx*a sx*b 0 0 sy 0 * c d 0 = sy*c sy*d 0 0 0 1 tx ty 1 0 0 1 """ # this isn't the operation described above, but produces the # same results. scaled = transform.copy() scaled[0] *= sx scaled[1] *= sy return scaled def rotate(transform, angle): """ Rotates transform by angle in radians. Rotation is done using the following formula:: cos(x) sin(x) 0 a b 0 -sin(x) cos(x) 0 * c d 0 = 0 0 1 tx ty 1 :: cos(x)*a+sin(x)*b cos(x)*b+sin(x)*d 0 -sin(x)*a+cos(x)*c -sin(x)*b+cos(x)*d 0 tx ty 1 where x = angle. """ a = cos(angle) b = sin(angle) c = -b d = a tx = 0. ty = 0. rot = affine_from_values(a, b, c, d, tx, ty) return dot(rot, transform) def translate(transform, x, y): """ Returns transform translated by (x, y). Translation:: 1 0 0 a b 0 a b 0 0 1 0 * c d 0 = c d 0 x y 1 tx ty 1 x*a+y*c+y x*b+y*d+ty 1 """ r = affine_identity() r[2, 0] = x r[2, 1] = y return dot(r, transform) def concat(transform, other): """ Returns the concatenation of transform with other. This is simply transform pre-multiplied by other. """ return dot(other, transform) def invert(m): """ Returns the inverse of the transform, m. """ inv = zeros(m.shape, float64) det = m[0, 0] * m[1, 1] - m[0, 1]*m[1, 0] inv[0, 0] = m[1, 1] inv[0, 1] = -m[0, 1] inv[0, 2] = 0 inv[1, 0] = -m[1, 0] inv[1, 1] = m[0, 0] inv[1, 2] = 0 inv[2, 0] = m[1, 0]*m[2, 1] - m[1, 1]*m[2, 0] inv[2, 1] = -m[0, 0]*m[2, 1] + m[0, 1]*m[2, 0] inv[2, 2] = m[0, 0]*m[1, 1] - m[0, 1]*m[1, 0] inv /= det return inv # ----------------------------------------------------------------------------- # Affine transform information # ----------------------------------------------------------------------------- IDENTITY = affine_identity() def is_identity(m): """ Tests whether an affine transform is the identity transform. """ return array_equal(m, IDENTITY) def affine_params(m): """ Returns the a, b, c, d, tx, ty values of an affine transform. """ a = m[0, 0] b = m[0, 1] c = m[1, 0] d = m[1, 1] tx = m[2, 0] ty = m[2, 1] return a, b, c, d, tx, ty def trs_factor(m): """ Factors a matrix as if it is the product of translate/rotate/scale matrices applied (i.e., concatenated) in that order. It returns: tx, ty, sx, sy, angle where tx and ty are the translations, sx and sy are the scaling values and angle is the rotational angle in radians. If the input matrix was created in a way other than concatenating t/r/s matrices, the results could be wrong. For example, if there is any skew in the matrix, the returned results are wrong. Needs Test! """ # ------------------------------------------------------------------------- # Extract Values from Matrix # # Translation values are correct as extracted. Rotation and # scaling need a little massaging. # ------------------------------------------------------------------------- a, b, c, d, tx, ty = affine_params(m) # ------------------------------------------------------------------------- # Rotation -- tan(angle) = b/d # ------------------------------------------------------------------------- angle = arctan2(b, d) # ------------------------------------------------------------------------- # Scaling # # sx = a/cos(angle) or sx = -c/sin(angle) # sy = d/cos(angle) or sy = b/sin(angle) # ------------------------------------------------------------------------- cos_ang = cos(angle) sin_ang = sin(angle) if cos_ang != 0.0: sx, sy = a/cos_ang, d/cos_ang else: sx, sy = -c/sin_ang, b/sin_ang return tx, ty, sx, sy, angle # ----------------------------------------------------------------------------- # Transforming points and arrays of points # ----------------------------------------------------------------------------- def transform_point(ctm, pt): """ Returns pt transformed by the affine transform, ctm. """ p1 = ones(3, float64) p1[:2] = pt res = dot(p1, ctm)[:2] return res def transform_points(ctm, pts): """ Transforms an array of points using the affine transform, ctm. """ if is_identity(ctm): res = pts else: x = pts[..., 0] y = pts[..., 1] a, b, c, d, tx, ty = affine_params(ctm) res = zeros(pts.shape, float64) res[..., 0] = a*x+c*y+tx res[..., 1] = b*x+d*y+ty return res enthought-chaco2-4.5.1.orig/kiva/_version.py0000644000175000017500000000026312516137724020033 0ustar varunvarun# THIS FILE IS GENERATED FROM ENABLE SETUP.PY version = '4.5.1' full_version = '4.5.1' git_revision = 'Unknown' is_released = True if not is_released: version = full_version enthought-chaco2-4.5.1.orig/kiva/tests/0000755000175000017500000000000012516137726017000 5ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/tests/basecore2d_test_case.py0000644000175000017500000004330512516137326023416 0ustar varunvarun""" Test suite for affine transforms. :Author: Eric Jones, Enthought, Inc., eric@enthought.com :Copyright: Space Telescope Science Institute :License: BSD Style So far, this is mainly a "smoke test" suite to make sure nothing is obviously wrong. """ from __future__ import with_statement import unittest from numpy import alltrue, array, ravel from kiva import affine from kiva import basecore2d from kiva import constants class test_is_fully_transparent(unittest.TestCase): def test_simple(self): self.assert_(basecore2d.is_fully_transparent([1, 1, 1, 0])) self.assert_(not basecore2d.is_fully_transparent([0, 0, 0, 1])) self.assert_(not basecore2d.is_fully_transparent([0, 0, 0, .5])) class test_fill_equal(unittest.TestCase): def test_simple(self): self.assert_(basecore2d.fill_equal(array([0, 0, 0, 0]), array([0, 0, 0, 0]))) self.assert_(not basecore2d.fill_equal(array([0, 0, 0, 0]), array([0, 0, 0, 1]))) self.assert_(not basecore2d.fill_equal(array([0, 0, 0, 0]), array([1, 0, 0, 0]))) class LineStateTestCase(unittest.TestCase): def create_ls(self): color = array([0, 0, 0, 1]) width = 2 join = basecore2d.JOIN_MITER cap = basecore2d.CAP_ROUND phase = 0 pattern = array([5, 5]) dash = (phase, pattern) ls = basecore2d.LineState(color, width, cap, join, dash) return ls def test_create(self): self.create_ls() def test_color_on_copy(self): # The following test to make sure that a copy # was actually made of the line_color container(array). # If it isn't, both ls1 and ls2 will point at the same # data, and the change to the color affects both # line_states instead of just ls1. ls1 = self.create_ls() ls2 = ls1.copy() ls1.line_color[1] = 10 self.assert_(not basecore2d.line_state_equal(ls1, ls2)) def test_dash_on_copy(self): ls1 = self.create_ls() ls2 = ls1.copy() ls1.line_dash[1][0] = 10 self.assert_(not basecore2d.line_state_equal(ls1, ls2)) def test_cmp_for_different_length_dash_patterns(self): ls1 = self.create_ls() ls2 = ls1.copy() ls1.line_dash = (ls1.line_dash[0], array([10, 10, 10, 10])) self.assert_(not basecore2d.line_state_equal(ls1, ls2)) def test_cmp(self): ls1 = self.create_ls() ls2 = ls1.copy() self.assert_(basecore2d.line_state_equal(ls1, ls2)) #line_dash no longer allowed to be none. #def test_cmp_with_dash_as_none(self): # ls1 = self.create_ls() # ls2 = ls1.copy() # #ls1.line_dash = None # assert(not basecore2d.line_state_equal(ls1,ls2)) class GraphicsContextTestCase(unittest.TestCase): def test_create_gc(self): gc = basecore2d.GraphicsContextBase() #---------------------------------------------------------------- # Test ctm transformations #---------------------------------------------------------------- def test_get_ctm(self): gc = basecore2d.GraphicsContextBase() # default ctm should be identity matrix. desired = affine.affine_identity() actual = gc.get_ctm() self.assert_(alltrue(ravel(actual == desired))) def test_scale_ctm(self): gc = basecore2d.GraphicsContextBase() ident = affine.affine_identity() sx, sy = 2., 3. desired = affine.scale(ident, sx, sy) gc.scale_ctm(sx, sy) actual = gc.get_ctm() self.assert_(alltrue(ravel(actual == desired))) def test_rotate_ctm(self): gc = basecore2d.GraphicsContextBase() ident = affine.affine_identity() angle = 2. desired = affine.rotate(ident, angle) gc.rotate_ctm(angle) actual = gc.get_ctm() self.assert_(alltrue(ravel(actual == desired))) def test_translate_ctm(self): gc = basecore2d.GraphicsContextBase() ident = affine.affine_identity() x, y = 2., 3. desired = affine.translate(ident, x, y) gc.translate_ctm(x, y) actual = gc.get_ctm() self.assert_(alltrue(ravel(actual == desired))) def test_concat_ctm(self): gc = basecore2d.GraphicsContextBase() ident = affine.affine_identity() trans = affine.affine_from_rotation(2.) x, y = 2., 3. desired = affine.concat(ident, trans) gc.concat_ctm(trans) actual = gc.get_ctm() self.assert_(alltrue(ravel(actual == desired))) #------------------------------------------------------------------------- # Setting drawing state variables # # These tests also check that the value is restored correctly with # save/restore state. # # Checks are only done to see if variables are represented correctly in # the graphics state. The effects on graphics rendering for these # variables is not checked. That is all pretty much handled in the # device_update_line_state and device_update_fill_state routines which # access the state variables. # # Note: The tests peek into the state object to see if the if state # variables are set. This ain't perfect, but core2d doesn't # define accessor functions... #------------------------------------------------------------------------- def test_state_antialias(self): gc = basecore2d.GraphicsContextBase() # defaults to 1 self.assertEqual(gc.state.antialias, 1) gc.set_antialias(0) gc.save_state() gc.set_antialias(1) self.assertEqual(gc.state.antialias, 1) gc.restore_state() self.assertEqual(gc.state.antialias, 0) def test_state_line_width(self): gc = basecore2d.GraphicsContextBase() # defaults to 1 self.assertEqual(gc.state.line_state.line_width, 1) gc.set_line_width(5) gc.save_state() gc.set_line_width(10) self.assertEqual(gc.state.line_state.line_width, 10) gc.restore_state() self.assertEqual(gc.state.line_state.line_width, 5) def test_state_line_join(self): gc = basecore2d.GraphicsContextBase() # defaults to JOIN_MITER self.assertEqual(gc.state.line_state.line_join, constants.JOIN_MITER) gc.set_line_join(constants.JOIN_BEVEL) gc.save_state() gc.set_line_join(constants.JOIN_ROUND) self.assertEqual(gc.state.line_state.line_join, constants.JOIN_ROUND) gc.restore_state() self.assertEqual(gc.state.line_state.line_join, constants.JOIN_BEVEL) # set_line_join should fail if one attempts to set a bad value. self.assertRaises(ValueError, gc.set_line_join, (100,)) def test_state_miter_limit(self): gc = basecore2d.GraphicsContextBase() # defaults to 1.0 self.assertEqual(gc.state.miter_limit, 1.0) gc.set_miter_limit(2.0) gc.save_state() gc.set_miter_limit(3.0) self.assertEqual(gc.state.miter_limit, 3.0) gc.restore_state() self.assertEqual(gc.state.miter_limit, 2.0) def test_state_line_cap(self): gc = basecore2d.GraphicsContextBase() # defaults to CAP_ROUND self.assertEqual(gc.state.line_state.line_cap, constants.CAP_ROUND) gc.set_line_cap(constants.CAP_BUTT) gc.save_state() gc.set_line_cap(constants.CAP_SQUARE) self.assertEqual(gc.state.line_state.line_cap, constants.CAP_SQUARE) gc.restore_state() self.assertEqual(gc.state.line_state.line_cap, constants.CAP_BUTT) # set_line_cap should fail if one attempts to set a bad value. self.assertRaises(ValueError, gc.set_line_cap, (100,)) def test_state_line_dash(self): gc = basecore2d.GraphicsContextBase() # defaults to non-dashed line self.assert_(not gc.state.line_state.is_dashed()) gc.set_line_dash([1.0, 2.0], phase=2.0) gc.save_state() gc.set_line_dash([3.0, 4.0]) self.assert_(gc.state.line_state.is_dashed()) self.assertEqual(gc.state.line_state.line_dash[0], 0) self.assert_(alltrue(ravel(gc.state.line_state.line_dash[1] == array([3.0, 4.0])))) gc.restore_state() self.assert_(gc.state.line_state.is_dashed()) self.assertEqual(gc.state.line_state.line_dash[0], 2.0) self.assert_(alltrue(ravel(gc.state.line_state.line_dash[1] == array([1.0, 2.0])))) # pattern must be a container with atleast two values self.assertRaises(ValueError, gc.set_line_cap, (100,)) self.assertRaises(ValueError, gc.set_line_cap, ([100],)) # phase must be positive. self.assertRaises(ValueError, gc.set_line_cap, ([100, 200], -1)) def test_state_flatness(self): gc = basecore2d.GraphicsContextBase() # defaults to 1.0 self.assertEqual(gc.state.flatness, 1.0) gc.set_flatness(2.0) gc.save_state() gc.set_flatness(3.0) self.assertEqual(gc.state.flatness, 3.0) gc.restore_state() self.assertEqual(gc.state.flatness, 2.0) def test_state_alpha(self): gc = basecore2d.GraphicsContextBase() # defaults to 1.0 self.assertEqual(gc.state.alpha, 1.0) gc.set_alpha(0.0) gc.save_state() gc.set_alpha(0.5) self.assertEqual(gc.state.alpha, 0.5) gc.restore_state() self.assertEqual(gc.state.alpha, 0.0) def test_state_fill_color(self): gc = basecore2d.GraphicsContextBase() # defaults to [0,0,0,1] self.assert_(alltrue(gc.state.fill_color == array([0, 0, 0, 1]))) gc.set_fill_color((0, 1, 0, 1)) gc.save_state() gc.set_fill_color((1, 1, 1, 1)) self.assert_(alltrue(gc.state.fill_color == array([1, 1, 1, 1]))) gc.restore_state() self.assert_(alltrue(gc.state.fill_color == array([0, 1, 0, 1]))) def test_state_stroke_color(self): gc = basecore2d.GraphicsContextBase() # defaults to [0,0,0,1] self.assert_(alltrue(gc.state.line_state.line_color == array([0, 0, 0, 1]))) gc.set_stroke_color((0, 1, 0, 1)) gc.save_state() gc.set_stroke_color((1, 1, 1, 1)) self.assert_(alltrue(gc.state.line_state.line_color == array([1, 1, 1, 1]))) gc.restore_state() self.assert_(alltrue(gc.state.line_state.line_color == array([0, 1, 0, 1]))) def test_state_character_spacing(self): gc = basecore2d.GraphicsContextBase() # defaults to None self.assertEqual(gc.state.character_spacing, 0.0) gc.set_character_spacing(1.0) gc.save_state() gc.set_character_spacing(2.0) self.assertEqual(gc.state.character_spacing, 2.0) gc.restore_state() self.assertEqual(gc.state.character_spacing, 1.0) def test_state_text_drawing_mode(self): gc = basecore2d.GraphicsContextBase() # defaults to None self.assertEqual(gc.state.text_drawing_mode, constants.TEXT_FILL) gc.set_text_drawing_mode(constants.TEXT_OUTLINE) gc.save_state() gc.set_text_drawing_mode(constants.TEXT_CLIP) self.assertEqual(gc.state.text_drawing_mode, constants.TEXT_CLIP) gc.restore_state() self.assertEqual(gc.state.text_drawing_mode, constants.TEXT_OUTLINE) # try an unacceptable value. self.assertRaises(ValueError, gc.set_text_drawing_mode, (10,)) #------------------------------------------------------------------------- # Use context manager for saving and restoring state. #------------------------------------------------------------------------- def test_state_context_manager(self): gc = basecore2d.GraphicsContextBase() # Set an assortment of state properties. gc.set_antialias(0) gc.set_line_width(5) gc.set_fill_color((0, 1, 0, 1)) with gc: # Change the state properties. gc.set_antialias(1) self.assertEqual(gc.state.antialias, 1) gc.set_line_width(10) self.assertEqual(gc.state.line_state.line_width, 10) gc.set_fill_color((1, 1, 1, 1)) self.assert_(alltrue(gc.state.fill_color == array([1, 1, 1, 1]))) # Verify that we're back to the earlier settings. self.assertEqual(gc.state.antialias, 0) self.assertEqual(gc.state.line_state.line_width, 5) self.assert_(alltrue(gc.state.fill_color == array([0, 1, 0, 1]))) def test_state_context_manager_nested(self): gc = basecore2d.GraphicsContextBase() # Set an assortment of state properties. gc.set_antialias(0) gc.set_line_width(5) gc.set_fill_color((0, 1, 0, 1)) with gc: # Change the state properties. gc.set_antialias(1) self.assertEqual(gc.state.antialias, 1) gc.set_line_width(10) self.assertEqual(gc.state.line_state.line_width, 10) gc.set_fill_color((1, 1, 1, 1)) self.assert_(alltrue(gc.state.fill_color == array([1, 1, 1, 1]))) with gc: # Change the state properties. gc.set_antialias(0) self.assertEqual(gc.state.antialias, 0) gc.set_line_width(2) self.assertEqual(gc.state.line_state.line_width, 2) gc.set_fill_color((1, 1, 0, 1)) self.assert_(alltrue(gc.state.fill_color == array([1, 1, 0, 1]))) # Verify that we're back to the earlier settings. self.assertEqual(gc.state.antialias, 1) self.assertEqual(gc.state.line_state.line_width, 10) self.assert_(alltrue(gc.state.fill_color == array([1, 1, 1, 1]))) # Verify that we're back to the earlier settings. self.assertEqual(gc.state.antialias, 0) self.assertEqual(gc.state.line_state.line_width, 5) self.assert_(alltrue(gc.state.fill_color == array([0, 1, 0, 1]))) #------------------------------------------------------------------------- # Begin/End Page # These are implemented yet. The tests are just here to remind me that # they need to be. #------------------------------------------------------------------------- def test_begin_page(self): #just to let me know it needs implementation. gc = basecore2d.GraphicsContextBase() gc.begin_page() def test_end_page(self): #just to let me know it needs implementation. gc = basecore2d.GraphicsContextBase() gc.end_page() #------------------------------------------------------------------------- # flush/synchronize # These are implemented yet. The tests are just here to remind me that # they need to be. #------------------------------------------------------------------------- def test_synchronize(self): #just to let me know it needs implementation. gc = basecore2d.GraphicsContextBase() gc.synchronize() def test_flush(self): #just to let me know it needs implementation. gc = basecore2d.GraphicsContextBase() gc.flush() #------------------------------------------------------------------------- # save/restore state. # # Note: These test peek into the state object to see if the if state # variables are set. This ain't perfect, but core2d doesn't # define accessor functions... # # items that need to be tested: # ctm # clip region (not implemented) # line width # line join # #------------------------------------------------------------------------- def test_save_state_line_width(self): gc = basecore2d.GraphicsContextBase() gc.set_line_width(5) gc.save_state() gc.set_line_width(10) self.assertEqual(gc.state.line_state.line_width, 10) gc.restore_state() self.assertEqual(gc.state.line_state.line_width, 5) #------------------------------------------------------------------------- # Test drawing path empty #------------------------------------------------------------------------- def test_is_path_empty1(self): """ A graphics context should start with an empty path. """ gc = basecore2d.GraphicsContextBase() self.assert_(gc.is_path_empty()) def test_is_path_empty2(self): """ A path that has moved to a point, but still hasn't drawn anything is empty. """ gc = basecore2d.GraphicsContextBase() x, y = 1., 2. gc.move_to(x, y) self.assert_(gc.is_path_empty()) def test_is_path_empty3(self): """ A path that has moved to a point multiple times, but hasn't drawn anything is empty. """ gc = basecore2d.GraphicsContextBase() x, y = 1., 2. gc.move_to(x, y) # this should create another path. x, y = 1., 2.5 gc.move_to(x, y) self.assert_(gc.is_path_empty()) def test_is_path_empty4(self): """ We've added a line, so the path is no longer empty. """ gc = basecore2d.GraphicsContextBase() x, y = 1., 2. gc.move_to(x, y) gc.line_to(x, y) self.assert_(not gc.is_path_empty()) #------------------------------------------------------------------------- # Test drawing path add line # # Testing needed! #------------------------------------------------------------------------- def test_add_line(self): """ """ pass ################################################## if __name__ == "__main__": unittest.main() enthought-chaco2-4.5.1.orig/kiva/tests/test_cairo_drawing.py0000644000175000017500000000105112516137326023212 0ustar varunvarunfrom kiva.tests.drawing_tester import DrawingImageTester from traits.testing.unittest_tools import unittest try: import cairo # noqa except ImportError: CAIRO_NOT_AVAILABLE = True else: CAIRO_NOT_AVAILABLE = False @unittest.skipIf(CAIRO_NOT_AVAILABLE, "Cannot import cairo") class TestCairoDrawing(DrawingImageTester, unittest.TestCase): def create_graphics_context(self, width, height): from kiva.cairo import GraphicsContext return GraphicsContext((width, height)) if __name__ == "__main__": unittest.main() enthought-chaco2-4.5.1.orig/kiva/tests/test_qpainter_drawing.py0000644000175000017500000000145312516137326023746 0ustar varunvaruntry: from pyface.qt import QtGui except ImportError: QT_NOT_AVAILABLE = True else: QT_NOT_AVAILABLE = False from kiva.tests.drawing_tester import DrawingImageTester from traits.testing.unittest_tools import unittest @unittest.skipIf(QT_NOT_AVAILABLE, "Cannot import qt") class TestQPainterDrawing(DrawingImageTester, unittest.TestCase): def setUp(self): application = QtGui.QApplication.instance() if application is None: self.application = QtGui.QApplication([]) else: self.application = application DrawingImageTester.setUp(self) def create_graphics_context(self, width, height): from kiva.qpainter import GraphicsContext return GraphicsContext((width, height)) if __name__ == "__main__": unittest.main() enthought-chaco2-4.5.1.orig/kiva/tests/__init__.py0000644000175000017500000000000012516137326021073 0ustar varunvarunenthought-chaco2-4.5.1.orig/kiva/tests/affine_test_case.py0000644000175000017500000001530712516137326022636 0ustar varunvarun""" Test suite for affine transforms. :Author: Eric Jones, Enthought, Inc., eric@enthought.com :Copyright: Space Telescope Science Institute :License: BSD Style So far, this is mainly a "smoke test" suite to make sure nothing is obviously wrong. It relies on the transforms being stored in 3x3 array. """ import unittest import sys from numpy import arctan2, alltrue, array, identity, dot, ravel, allclose, pi,cos from kiva import affine class AffineConstructorsTestCase(unittest.TestCase): def test_identity(self): i = affine.affine_identity() self.assertTrue(allclose(identity(3), i)) def test_from_values(self): a,b,c,d,tx,ty = 1,2,3,4,5,6 mat = affine.affine_from_values(a,b,c,d,tx,ty) desired = array([[a, b, 0], [c, d, 0], [tx,ty, 1]]) assert(alltrue(ravel(mat)==ravel(desired))) def test_from_scale(self): transform = affine.affine_from_scale(5.,6.) pt1 = array([1.,1.,1.]) actual = dot(pt1,transform) desired = pt1*array((5.,6.,1.)) assert(alltrue( actual == desired )) def test_from_translation(self): transform = affine.affine_from_translation(5.,6.) pt1 = array([1.,1.,1.]) actual = dot(pt1,transform) desired = pt1+array((5.,6.,0.)) assert(alltrue( actual == desired )) def test_from_rotation(self): transform = affine.affine_from_rotation(pi/4.) pt1 = array([1.,0.,1.]) actual = dot(pt1,transform) #cos_pi_4 = 0.70710678118654757 cos_pi_4 = cos(pi/4.0) desired = array((cos_pi_4, cos_pi_4, 1.0)) assert(alltrue( (actual - desired) < 1e-6 )) class AffineOperationsTestCase(unittest.TestCase): """ Test are generally run by operating on a matrix and using it to transform a point. We then transform the point using some known sequence of operations that should produce the same results. """ def test_scale(self): a,b,c,d,tx,ty = 1,2,3,4,5,6 transform1 = affine.affine_from_values(a,b,c,d,tx,ty) transform2 = affine.scale(transform1,.5,1.5) pt1 = array([1.,-1.,1.]) actual = dot(pt1,transform2) # this does the first transform and the scaling separately desired = dot(pt1,transform1) *array((.5,1.5,1.)) assert(alltrue( (actual - desired) < 1e-6 )) def test_translate(self): a,b,c,d,tx,ty = 1,2,3,4,5,6 transform1 = affine.affine_from_values(a,b,c,d,tx,ty) translate_transform = array([[0,0,0], [0,0,0], [.5,1.5,1]]) tot_transform = affine.translate(transform1,.5,1.5) pt1 = array([1.,-1.,1.]) actual = dot(pt1,tot_transform) # this does the first transform and the translate separately desired = dot(dot(pt1,translate_transform), transform1) assert(alltrue( (actual - desired) < 1e-6 )) def test_rotate(self): a,b,c,d,tx,ty = 1.,0,0,1.,0,0 transform1 = affine.affine_from_values(a,b,c,d,tx,ty) tot_transform = affine.rotate(transform1,pi/4) pt1 = array([1.,0.,1.]) actual = dot(pt1,tot_transform) # this does the first transform and the translate separately cos_pi_4 = 0.70710678118654757 desired = array((cos_pi_4,cos_pi_4,1.)) assert(alltrue( (actual - desired) < 1e-6 )) def test_invert(self): """ An matrix times its inverse should produce the identity matrix """ a,b,c,d,tx,ty = 1,2,3,4,5,6 transform1 = affine.affine_from_values(a,b,c,d,tx,ty) transform2 = affine.invert(transform1) desired = affine.affine_identity() actual = dot(transform2,transform1) assert(alltrue( (ravel(actual) - ravel(desired)) < 1e-6 )) def test_concat(self): a,b,c,d,tx,ty = 1,2,3,4,5,6 transform1 = affine.affine_from_values(a,b,c,d,tx,ty) a,b,c,d,tx,ty = 2,3,4,5,6,7 transform2 = affine.affine_from_values(a,b,c,d,tx,ty) tot_transform = affine.concat(transform1,transform2) pt1 = array([1.,-1.,1.]) actual = dot(pt1,tot_transform) # this does the first transform and the scaling separately desired = dot(dot(pt1,transform2),transform1) assert(alltrue( (actual - desired) < 1e-6 )) class AffineInformationTestCase(unittest.TestCase): """ Test are generally run by operating on a matrix and using it to transform a point. We then transform the point using some known sequence of operations that should produce the same results. """ def test_is_identity(self): # a true case. m = affine.affine_identity() assert(affine.is_identity(m)) # and a false one. a,b,c,d,tx,ty = 1,2,3,4,5,6 m = affine.affine_from_values(a,b,c,d,tx,ty) assert(not affine.is_identity(m)) def test_affine_params(self): a,b,c,d,tx,ty = 1,2,3,4,5,6 trans = affine.affine_from_values(a,b,c,d,tx,ty) aa,bb,cc,dd,txx,tyy = affine.affine_params(trans) assert( (a,b,c,d,tx,ty) == (aa,bb,cc,dd,txx,tyy)) def test_trs_factor(self): trans = affine.affine_identity() trans = affine.translate(trans,5,5) trans = affine.rotate(trans,2.4) trans = affine.scale(trans,10,10) tx,ty,sx,sy,angle = affine.trs_factor(trans) assert( (tx,ty) == (5,5)) assert( (sx,sy) == (10,10)) assert( angle == 2.4) class TransformPointsTestCase(unittest.TestCase): def test_transform_point(self): pt = array((1,1)) ctm = affine.affine_identity() ctm = affine.translate(ctm,5,5) new_pt = affine.transform_point(ctm, pt) assert(alltrue(new_pt == array((6,6)))) ctm = affine.rotate(ctm,pi) new_pt = affine.transform_point(ctm, pt) assert(sum(new_pt - array((4.,4.))) < 1e-15) ctm = affine.scale(ctm,10,10) new_pt = affine.transform_point(ctm, pt) assert(sum(new_pt - array((-5.,-5.))) < 1e-15) def test_transform_points(self): # not that thorough... pt = array(((1,1),)) ctm = affine.affine_identity() ctm = affine.translate(ctm,5,5) new_pt = affine.transform_points(ctm, pt) assert(alltrue(new_pt[0] == array((6,6)))) ctm = affine.rotate(ctm,pi) new_pt = affine.transform_points(ctm, pt) assert(sum(new_pt[0] - array((4.,4.))) < 1e-15) ctm = affine.scale(ctm,10,10) new_pt = affine.transform_points(ctm, pt) assert(sum(new_pt[0] - array((-5.,-5.))) < 1e-15) if __name__ == "__main__": unittest.main() enthought-chaco2-4.5.1.orig/kiva/tests/test_agg_drawing.py0000644000175000017500000000055212516137326022660 0ustar varunvarunfrom kiva.tests.drawing_tester import DrawingImageTester from kiva.image import GraphicsContext from traits.testing.unittest_tools import unittest class TestAggDrawing(DrawingImageTester, unittest.TestCase): def create_graphics_context(self, width, height): return GraphicsContext((width, height)) if __name__ == "__main__": unittest.main() enthought-chaco2-4.5.1.orig/kiva/tests/test_gl_drawing.py0000644000175000017500000000332312516137326022523 0ustar varunvarunimport contextlib try: import pyglet except ImportError: PYGLET_NOT_AVAILABLE = True else: PYGLET_NOT_AVAILABLE = False from kiva.tests.drawing_tester import DrawingImageTester from traits.testing.unittest_tools import unittest @unittest.skipIf(PYGLET_NOT_AVAILABLE, "Cannot import pyglet") class TestGLDrawing(DrawingImageTester, unittest.TestCase): def tearDown(self): if hasattr(self, 'window') and self.window is not None: self.window.close() del self.window DrawingImageTester.tearDown(self) def create_graphics_context(self, width, height): from kiva.gl import GraphicsContext self.window = pyglet.window.Window(width=width, height=height) gc = GraphicsContext((width, height)) gc.gl_init() return gc @unittest.skip("gl graphics context does not support star_clip (#164)") def test_star_clip(self): # FIXME: overriding test since it segfaults DrawingImageTester.test_star_clip(self) @unittest.expectedFailure def test_text_clip(self): # gl graphics context does not clip text properly (#165). DrawingImageTester.test_text_clip(self) @contextlib.contextmanager def draw_and_check(self): from pyglet.image.codecs.png import PNGImageEncoder self.window.clear() self.window.switch_to() self.window.dispatch_events() yield self.window.dispatch_events() filename = "{0}.png".format(self.filename) buffer = pyglet.image.get_buffer_manager() buffer.get_color_buffer().save(filename, encoder=PNGImageEncoder()) self.assertImageSavedWithContent(filename) if __name__ == "__main__": unittest.main() enthought-chaco2-4.5.1.orig/kiva/tests/test_ps_drawing.py0000644000175000017500000000170012516137326022540 0ustar varunvarunimport contextlib from kiva.tests.drawing_tester import DrawingTester from kiva.ps import PSGC from traits.testing.unittest_tools import unittest class TestPSDrawing(DrawingTester, unittest.TestCase): def create_graphics_context(self, width, height): return PSGC((width, height)) @contextlib.contextmanager def draw_and_check(self): yield filename = "{0}.eps".format(self.filename) self.gc.save(filename) with open(filename, 'r') as handle: lines = handle.readlines() # Just a simple check that the path has been closed or the text has # been drawn. line = lines[-1].strip() if not any(( line.endswith('fill'), line.endswith('stroke'), line.endswith('cliprestore'), '(hello kiva) show\n' in lines)): self.fail('Path was not closed') if __name__ == "__main__": unittest.main() enthought-chaco2-4.5.1.orig/kiva/tests/test_svg_drawing.py0000644000175000017500000000141212516137326022715 0ustar varunvarunimport contextlib from xml.etree import ElementTree from kiva.tests.drawing_tester import DrawingTester from kiva.svg import GraphicsContext from traits.testing.unittest_tools import unittest class TestSVGDrawing(DrawingTester, unittest.TestCase): def create_graphics_context(self, width, height): return GraphicsContext((width, height)) @contextlib.contextmanager def draw_and_check(self): yield filename = "{0}.svg".format(self.filename) self.gc.save(filename) tree = ElementTree.parse(filename) elements = [element for element in tree.getiterator()] if not len(elements) in [4, 7]: self.fail('The expected number of elements was not found') if __name__ == "__main__": unittest.main() enthought-chaco2-4.5.1.orig/kiva/tests/test_pdf_drawing.py0000644000175000017500000000326512516137326022677 0ustar varunvarunimport contextlib from kiva.tests.drawing_tester import DrawingTester from traits.testing.unittest_tools import unittest try: import PyPDF2 # Tests require the PyPDF2 library. except ImportError: PYPDF2_NOT_AVAILABLE = True else: PYPDF2_NOT_AVAILABLE = False try: import reportlab # noqa except ImportError: REPORTLAB_NOT_AVAILABLE = True else: REPORTLAB_NOT_AVAILABLE = False @unittest.skipIf(PYPDF2_NOT_AVAILABLE, "PDF tests require PyPDF2") @unittest.skipIf(REPORTLAB_NOT_AVAILABLE, "Cannot import reportlab") class TestPDFDrawing(DrawingTester, unittest.TestCase): def create_graphics_context(self, width, height): from reportlab.pdfgen.canvas import Canvas from kiva.pdf import GraphicsContext filename = "{0}.pdf".format(self.filename) canvas = Canvas(filename, (width, height)) return GraphicsContext(canvas) @contextlib.contextmanager def draw_and_check(self): yield # Save the pdf file. filename = "{0}.pdf".format(self.filename) self.gc.save() reader = PyPDF2.PdfFileReader(filename) self.assertEqual(reader.getNumPages(), 1) # Find the graphics in the page page = reader.getPage(0) content = page.getContents() # Just a simple check that the path has been closed or the text has # been drawn. line = content.getData().splitlines()[-2] if not any(( line.endswith('f'), line.endswith('S'), line.endswith('f*'), line.endswith('ET') and 'hello kiva' in line)): self.fail('Path was not closed') if __name__ == "__main__": unittest.main() enthought-chaco2-4.5.1.orig/kiva/tests/drawing_tester.py0000644000175000017500000001251412516137326022372 0ustar varunvarunimport contextlib import os import shutil import tempfile import numpy from PIL import Image from kiva.fonttools import Font from kiva.constants import MODERN class DrawingTester(object): """ Basic drawing tests for graphics contexts. """ def setUp(self): self.directory = tempfile.mkdtemp() self.filename = os.path.join(self.directory, 'rendered') self.gc = self.create_graphics_context(300, 300) self.gc.clear() self.gc.set_stroke_color((1.0, 0.0, 0.0)) self.gc.set_fill_color((1.0, 0.0, 0.0)) self.gc.set_line_width(5) def tearDown(self): del self.gc shutil.rmtree(self.directory) def test_line(self): with self.draw_and_check(): self.gc.begin_path() self.gc.move_to(107, 204) self.gc.line_to(107, 104) self.gc.stroke_path() def test_rectangle(self): with self.draw_and_check(): self.gc.begin_path() self.gc.move_to(107, 104) self.gc.line_to(107, 184) self.gc.line_to(187, 184) self.gc.line_to(187, 104) self.gc.line_to(107, 104) self.gc.stroke_path() def test_rect(self): with self.draw_and_check(): self.gc.begin_path() self.gc.rect(0, 0, 200, 200) self.gc.stroke_path() def test_circle(self): with self.draw_and_check(): self.gc.begin_path() self.gc.arc(150, 150, 100, 0.0, 2 * numpy.pi) self.gc.stroke_path() def test_quarter_circle(self): with self.draw_and_check(): self.gc.begin_path() self.gc.arc(150, 150, 100, 0.0, numpy.pi / 2) self.gc.stroke_path() def test_text(self): with self.draw_and_check(): font = Font(family=MODERN) font.size = 24 self.gc.set_font(font) self.gc.set_text_position(23, 67) self.gc.show_text("hello kiva") def test_circle_fill(self): with self.draw_and_check(): self.gc.begin_path() self.gc.arc(150, 150, 100, 0.0, 2 * numpy.pi) self.gc.fill_path() def test_star_fill(self): with self.draw_and_check(): self.gc.begin_path() self.gc.move_to(100, 100) self.gc.line_to(150, 200) self.gc.line_to(200, 100) self.gc.line_to(100, 150) self.gc.line_to(200, 150) self.gc.line_to(100, 100) self.gc.fill_path() def test_star_eof_fill(self): with self.draw_and_check(): self.gc.begin_path() self.gc.move_to(100, 100) self.gc.line_to(150, 200) self.gc.line_to(200, 100) self.gc.line_to(100, 150) self.gc.line_to(200, 150) self.gc.line_to(100, 100) self.gc.eof_fill_path() def test_circle_clip(self): with self.draw_and_check(): self.gc.clip_to_rect(150, 150, 100, 100) self.gc.begin_path() self.gc.arc(150, 150, 100, 0.0, 2 * numpy.pi) self.gc.fill_path() def test_text_clip(self): with self.draw_and_check(): self.gc.clip_to_rect(23, 77, 100, 23) font = Font(family=MODERN) font.size = 24 self.gc.set_font(font) self.gc.set_text_position(23, 67) self.gc.show_text("hello kiva") def test_star_clip(self): with self.draw_and_check(): self.gc.begin_path() self.gc.move_to(100, 100) self.gc.line_to(150, 200) self.gc.line_to(200, 100) self.gc.line_to(100, 150) self.gc.line_to(200, 150) self.gc.line_to(100, 100) self.gc.close_path() self.gc.clip() self.gc.begin_path() self.gc.arc(150, 150, 100, 0.0, 2 * numpy.pi) self.gc.fill_path() #### Required methods #################################################### @contextlib.contextmanager def draw_and_check(self): """ A context manager to check the result. """ raise NotImplementedError() def create_graphics_context(self, width, length): """ Create the desired graphics context """ raise NotImplementedError() class DrawingImageTester(DrawingTester): """ Basic drawing tests for graphics contexts of gui toolkits. """ @contextlib.contextmanager def draw_and_check(self): yield filename = "{0}.png".format(self.filename) self.gc.save(filename) self.assertImageSavedWithContent(filename) def assertImageSavedWithContent(self, filename): """ Load the image and check that there is some content in it. """ image = numpy.array(Image.open(filename)) # default is expected to be a totally white image self.assertEqual(image.shape[:2], (300, 300)) if image.shape[2] == 3: check = numpy.sum(image == [255, 0, 0], axis=2) == 3 elif image.shape[2] == 4: check = numpy.sum(image == [255, 0, 0, 255], axis=2) == 4 else: self.fail( 'Pixel size is not 3 or 4, but {0}'.format(image.shape[2])) if check.any(): return self.fail('The image looks empty, no red pixels where drawn') enthought-chaco2-4.5.1.orig/kiva/tests/test_macport.py0000644000175000017500000000254312516137326022056 0ustar varunvarunimport sys def test_macport(): if sys.platform == 'darwin': import wx from kiva.quartz import get_macport class SimpleWindow(wx.Frame): """ Simple test of get_macport(). """ def __init__(self): wx.Frame.__init__(self, parent=None, id=-1, title="foo", pos=(100,100), size=(300,300)) oldstyle = self.GetWindowStyle() oldstyle = oldstyle | wx.FULL_REPAINT_ON_RESIZE self.SetWindowStyle(oldstyle) self.Show(1) self.Bind(wx.EVT_PAINT, self.OnPaint) self.memdc = wx.MemoryDC() self.bitmap = wx.EmptyBitmap(200,200) self.memdc.SelectObject(self.bitmap) def OnPaint(self, evt): dc = wx.PaintDC(self) print "paintdc.this:", dc.this print "paintdc.macport: %x" % get_macport(dc) print "memdc.this:", self.memdc.this print "memdc.macport: %x" % get_macport(self.memdc) # We're done here self.Close() class MyApp(wx.App): def OnInit(self): w = SimpleWindow() return 1 app = MyApp(False) app.MainLoop() enthought-chaco2-4.5.1.orig/kiva/tests/test_kiva_test_assistant.py0000644000175000017500000000276112516137326024475 0ustar varunvarunimport unittest from kiva.testing import KivaTestAssistant class Drawable(object): def __init__(self, should_draw=True, should_process=True): self.should_draw = should_draw self.should_process = should_process def draw(self, gc): with gc: if self.should_draw: gc.move_to(-5,0) gc.line_to(5,0) gc.move_to(0,5) gc.line_to(0,-5) gc.move_to(0,0) # The path will not be processed and remain in the gc cache # if we do not execute the stroke_path command. if self.should_process: gc.stroke_path() class TestKivaTestAssistant(KivaTestAssistant, unittest.TestCase): def test_path_created_assertions(self): drawable = Drawable(should_draw=False) # drawing nothing self.assertRaises(AssertionError, self.assertPathsAreCreated, drawable) #drawing something drawable.should_draw = True self.assertPathsAreCreated(drawable) def test_paths_processed_assertions(self): drawable = Drawable(should_draw=True, should_process=False) # not finishing the path self.assertRaises( AssertionError, self.assertPathsAreProcessed, drawable) #drawing something drawable.should_process = True self.assertPathsAreProcessed(drawable) if __name__ == '__main__': unittest.main() enthought-chaco2-4.5.1.orig/kiva/tests/dummy.py0000644000175000017500000001500312516137326020500 0ustar varunvarunfrom __future__ import with_statement from enable.kiva_graphics_context import GraphicsContext from kiva import affine from kiva.fonttools import Font # Do some basic drawing tests and write the results out to files. # This is mostly a python translation of the tests in kiva/agg/src/dummy.cpp black = (0.0, 0.0, 0.0, 1.0) white = (1.0, 1.0, 1.0, 1.0) lightgray = (0.2, 0.2, 0.2, 1.0) red = (1.0, 0.0, 0.0, 1.0) green = (0.0, 1.0, 0.0, 1.0) blue = (0.0, 0.0, 1.0, 1.0) niceblue = (0.411, 0.584, 0.843, 1.0) PI = 3.141592654 def draw_sub_image(gc, width, height): gc.clear(white) fill_color = green[:3] + (0.4,) #We want green, but with an alpha of 0.4 gc.set_fill_color(fill_color) gc.rect(0,0,width,height) gc.fill_path() gc.set_stroke_color(red) gc.move_to(0.0, 0.0) gc.line_to(width, height) gc.stroke_path() gc.set_stroke_color(blue) gc.move_to(0.0, height) gc.line_to(width, 0.0) gc.stroke_path() def test_arc_to2(gc, x2, y2, radiusstep=25.0): gc.set_stroke_color(lightgray) gc.move_to(0,0) gc.line_to(100,0) gc.line_to(x2, y2) gc.stroke_path() gc.set_stroke_color(black) numradii = 7 for i in range(numradii): gc.move_to(0,0) gc.arc_to(100, 0, x2, y2, i*radiusstep+20.0) gc.stroke_path() def test_arc_curve(gc): with gc: gc.translate_ctm(50.0, 50.0) gc.rotate_ctm(PI/8) gc.set_stroke_color(blue) gc.rect(0.5, 0.5, 210, 210) gc.stroke_path() gc.set_stroke_color(black) gc.set_line_width(1) gc.move_to(50.5, 25.5) gc.arc(50.5, 50.5, 50.0, 0.0, PI/2, False) gc.move_to(100.5, 50.5) gc.arc(100.5, 50.5, 50.0, 0.0, -PI/2*0.8, False) gc.stroke_path() with gc: gc.translate_ctm(250.5, 50.5) gc.set_stroke_color(blue) gc.rect(0.5, 0.5, 250.0, 250.0) gc.stroke_path() gc.set_stroke_color(red) gc.move_to(100.0, 100.0) gc.line_to(100.0, 150.0) gc.arc_to(100.0, 200.0, 150.0, 200.0, 50.0) gc.line_to(200.0, 200.0) gc.close_path() gc.stroke_path() def test_arc_to(gc): # We don't have compiled paths yet, so we simulate them by python functions def axes(gc): gc.move_to(0.5, 50.5) gc.line_to(100.5, 50.5) gc.move_to(50.5, 0.5) gc.line_to(50.5, 100.5) def box(gc): gc.move_to(0.5, 0.5) gc.line_to(100.5, 0.5) gc.line_to(100.5, 100.5) gc.line_to(0.5, 100.5) gc.close_path() def arc(gc): gc.move_to(10,10) gc.line_to(20,10) gc.arc_to(40, 10, 40, 30, 20) gc.line_to(40,40) def whole_shebang(gc): with gc: axes(gc) box(gc) gc.translate_ctm(0.0, 50.5) arc(gc) gc.translate_ctm(50.5, 50.5) gc.rotate_ctm(-PI/2) arc(gc) gc.rotate_ctm(PI/2) gc.translate_ctm(50.5, -50.5) gc.rotate_ctm(-PI) arc(gc) gc.rotate_ctm(PI) gc.translate_ctm(-50.5, -50.5) gc.rotate_ctm(-3*PI/2) arc(gc) gc.set_stroke_color(red) gc.set_line_width(1.0) with gc: gc.translate_ctm(50.5, 300.5) whole_shebang(gc) gc.stroke_path() gc.translate_ctm(130.5, 50.0) with gc: gc.rotate_ctm(PI/6) whole_shebang(gc) gc.set_stroke_color(blue) gc.stroke_path() gc.translate_ctm(130.5, 0.0) with gc: gc.rotate_ctm(PI/3) gc.scale_ctm(1.0, 2.0) whole_shebang(gc) gc.stroke_path() with gc: gc.translate_ctm(150.5, 20.5) test_arc_to2(gc, 160.4, 76.5, 50.0) gc.translate_ctm(120.5, 100.5) gc.scale_ctm(-1.0, 1.0) test_arc_to2(gc, 70.5, 96.5) gc.translate_ctm(-300.5, 100.5) gc.scale_ctm(0.75, -1.0) test_arc_to2(gc, 160.5, 76.5, 50.0) def test_simple_clip_stack(gc): gc.clear(white) gc.clip_to_rect(100.0, 100.0, 1.0, 1.0) gc.rect(0.0, 0.0, gc.width(), gc.height()) gc.set_fill_color(red) gc.fill_path() def test_clip_stack(gc): sub_windows = ((10.5, 250, 200, 200), (220.5, 250, 200, 200), (430.5, 250, 200, 200), (10.5, 10, 200, 200), (220.5, 10, 200, 200), (430.5, 10, 200, 200)) gc.set_line_width(2) gc.set_stroke_color(black) gc.rects(sub_windows) gc.stroke_path() img = GraphicsContext((200, 200)) main_rects = ((40.5, 30.5, 120, 50), (40.5, 120.5, 120, 50)) disjoint_rects = ((60.5, 115.5, 80, 15), (60.5, 70.5, 80, 15)) vert_rect = (60.5, 10.5, 55, 180) # Draw the full image draw_sub_image(img, 200, 200) gc.draw_image(img, sub_windows[0]) img.clear() # First clip img.clip_to_rects(main_rects) draw_sub_image(img, 200, 200); gc.draw_image(img, sub_windows[1]) # Second Clip with img: img.clear() img.clip_to_rects(main_rects) img.clip_to_rect(*vert_rect) draw_sub_image(img, 200, 200) gc.draw_image(img, sub_windows[2]) # Pop back to first clip img.clear() draw_sub_image(img, 200, 200) gc.draw_image(img, sub_windows[3]) # Adding a disjoing set of rects img.clear() with img: img.clip_to_rects(main_rects) img.clip_to_rects(disjoint_rects) draw_sub_image(img, 200, 200) gc.draw_image(img, sub_windows[4]) # Pop back to first clip img.clear() draw_sub_image(img, 200, 200) gc.draw_image(img, sub_windows[5]) def test_handling_text(gc): font = Font(face_name="Arial", size = 32) gc.set_font(font) gc.translate_ctm(100.0, 100.0) gc.move_to(-5,0) gc.line_to(5,0) gc.move_to(0,5) gc.line_to(0,-5) gc.move_to(0,0) gc.stroke_path() txtRot = affine.affine_from_rotation(PI/6) gc.set_text_matrix(txtRot) gc.show_text("Hello") txtRot = affine.invert(txtRot) gc.set_text_matrix(txtRot) gc.show_text("inverted") if __name__ == "__main__": from kiva import ps, svg tests = ( test_clip_stack, # test_arc_to, # not supported test_handling_text, ) gcs = { 'eps': ps.PSGC, 'svg': svg.GraphicsContext } for fmt, gc in gcs.iteritems(): for test_func in tests: context = gc((800, 600)) test_func(context) context.save(test_func.__name__ + '.' + fmt) enthought-chaco2-4.5.1.orig/setup.py0000644000175000017500000002030312516137340016404 0ustar varunvarun# Copyright (c) 2008-2013 by Enthought, Inc. # All rights reserved. # These are necessary to get the clib compiled. The following also adds # an additional option --compiler=STR to develop, which usually does not # have such an option. The code below is a bad hack, as it changes # sys.argv to fool setuptools which therefore has to be imported BELOW # this hack. import sys if 'develop' in sys.argv: idx = sys.argv.index('develop') compiler = [] for arg in sys.argv[idx+1:]: if arg.startswith('--compiler='): compiler = ['-c', arg[11:]] del sys.argv[idx+1:] # insert extra options right before 'develop' sys.argv[idx:idx] = ['build_src', '--inplace', 'build_clib'] + compiler + \ ['build_ext', '--inplace'] + compiler from os.path import join # Setuptools must be imported BEFORE numpy.distutils for things to work right! import setuptools import distutils import distutils.command.clean import os import re import shutil import subprocess from numpy.distutils.core import setup MAJOR = 4 MINOR = 5 MICRO = 1 IS_RELEASED = True VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO) # Return the git revision as a string def git_version(): def _minimal_ext_cmd(cmd): # construct minimal environment env = {} for k in ['SYSTEMROOT', 'PATH']: v = os.environ.get(k) if v is not None: env[k] = v # LANGUAGE is used on win32 env['LANGUAGE'] = 'C' env['LANG'] = 'C' env['LC_ALL'] = 'C' out = subprocess.Popen( cmd, stdout=subprocess.PIPE, env=env, ).communicate()[0] return out try: out = _minimal_ext_cmd(['git', 'describe', '--tags']) except OSError: out = '' git_description = out.strip().decode('ascii') expr = r'.*?\-(?P\d+)-g(?P[a-fA-F0-9]+)' match = re.match(expr, git_description) if match is None: git_revision, git_count = 'Unknown', '0' else: git_revision, git_count = match.group('hash'), match.group('count') return git_revision, git_count def write_version_py(filename): template = """\ # THIS FILE IS GENERATED FROM ENABLE SETUP.PY version = '{version}' full_version = '{full_version}' git_revision = '{git_revision}' is_released = {is_released} if not is_released: version = full_version """ # Adding the git rev number needs to be done inside # write_version_py(), otherwise the import of kiva._version messes # up the build under Python 3. fullversion = VERSION if os.path.exists('.git'): git_revision, dev_num = git_version() elif os.path.exists('kiva/_version.py'): # must be a source distribution, use existing version file try: from kiva._version import git_revision, full_version except ImportError: raise ImportError("Unable to import git_revision. Try removing " "kiva/_version.py and the build directory " "before building.") match = re.match(r'.*?\.dev(?P\d+)', full_version) if match is None: dev_num = '0' else: dev_num = match.group('dev_num') else: git_revision = 'Unknown' dev_num = '0' if not IS_RELEASED: fullversion += '.dev{0}'.format(dev_num) with open(filename, "wt") as fp: fp.write(template.format(version=VERSION, full_version=fullversion, git_revision=git_revision, is_released=IS_RELEASED)) # Configure python extensions. def configuration(parent_package='', top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration(None, parent_package, top_path) config.set_options( ignore_setup_xxx_py=True, assume_default_configuration=True, delegate_options_to_subpackages=True, quiet=True, ) config.add_subpackage('kiva') return config class MyClean(distutils.command.clean.clean): ''' Subclass to remove any files created in an inplace build. This subclasses distutils' clean because neither setuptools nor numpy.distutils implements a clean command. ''' def run(self): distutils.command.clean.clean.run(self) # Clean any build or dist directory if os.path.isdir("build"): shutil.rmtree("build", ignore_errors=True) if os.path.isdir("dist"): shutil.rmtree("dist", ignore_errors=True) # Clean out any files produced by an in-place build. Note that our # code assumes the files are relative to the 'kiva' dir. INPLACE_FILES = ( # Common AGG join("agg", "agg.py"), join("agg", "plat_support.py"), join("agg", "agg_wrap.cpp"), # Mac join("quartz", "ABCGI.so"), join("quartz", "ABCGI.c"), join("quartz", "macport.so"), join("quartz", "mac_context.so"), join("quartz", "CTFont.so"), join("quartz", "CTFont.c"), # Win32 Agg join("agg", "_agg.pyd"), join("agg", "_plat_support.pyd"), join("agg", "src", "win32", "plat_support.pyd"), # *nix Agg join("agg", "_agg.so"), join("agg", "_plat_support.so"), join("agg", "src", "x11", "plat_support_wrap.cpp"), # Misc join("agg", "src", "gl", "plat_support_wrap.cpp"), join("agg", "src", "gl", "plat_support.py"), ) for f in INPLACE_FILES: f = join("kiva", f) if os.path.isfile(f): os.remove(f) if __name__ == "__main__": write_version_py(filename='enable/_version.py') write_version_py(filename='kiva/_version.py') from enable import __version__, __requires__ # Build the full set of packages by appending any found by setuptools' # find_packages to those discovered by numpy.distutils. config = configuration().todict() packages = setuptools.find_packages(exclude=config['packages'] + ['docs', 'examples']) packages += ['enable.savage.trait_defs.ui.wx.data'] config['packages'] += packages setup(name='enable', version=__version__, author='Enthought, Inc', author_email='info@enthought.com', maintainer='ETS Developers', maintainer_email='enthought-dev@enthought.com', url='https://github.com/enthought/enable/', classifiers=[c.strip() for c in """\ Development Status :: 5 - Production/Stable Intended Audience :: Developers Intended Audience :: Science/Research License :: OSI Approved :: BSD License Operating System :: MacOS Operating System :: Microsoft :: Windows Operating System :: OS Independent Operating System :: POSIX Operating System :: Unix Programming Language :: C Programming Language :: Python Topic :: Scientific/Engineering Topic :: Software Development Topic :: Software Development :: Libraries """.splitlines() if len(c.strip()) > 0], cmdclass={ # Work around a numpy distutils bug by forcing the use of the # setuptools' sdist command. 'sdist': setuptools.command.sdist.sdist, # Use our customized commands 'clean': MyClean, }, description='low-level drawing and interaction', long_description=open('README.rst').read(), # Note that this URL is only valid for tagged releases. download_url=('https://github.com/enthought/enable/archive/' '{0}.tar.gz'.format(__version__)), install_requires=__requires__, license='BSD', package_data = { '': ['*.zip', '*.svg', 'images/*'], 'enable': ['tests/primitives/data/PngSuite/*.png'], }, platforms=["Windows", "Linux", "Mac OS-X", "Unix", "Solaris"], zip_safe=False, **config) enthought-chaco2-4.5.1.orig/setup.cfg0000644000175000017500000000007312516137726016525 0ustar varunvarun[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 enthought-chaco2-4.5.1.orig/README.rst0000644000175000017500000000725512516137326016400 0ustar varunvarun========================================= enable: low-level drawing and interaction ========================================= http://github.enthought.com/enable .. image:: https://travis-ci.org/enthought/enable.svg?branch=master :target: https://travis-ci.org/enthought/enable :alt: Build status .. image:: https://coveralls.io/repos/enthought/enable/badge.png :target: https://coveralls.io/r/enthought/enable :alt: Coverage status The Enable *project* provides two related multi-platform *packages* for drawing GUI objects. - **Enable**: An object drawing library that supports containment and event notification. - **Kiva**: A multi-platform DisplayPDF vector drawing engine. Enable ------ The Enable package is a multi-platform object drawing library built on top of Kiva. The core of Enable is a container/component model for drawing and event notification. The core concepts of Enable are: - Component - Container - Events (mouse, drag, and key events) Enable provides a high-level interface for creating GUI objects, while enabling a high level of control over user interaction. Enable is a supporting technology for the Chaco and BlockCanvas projects. Kiva ---- Kiva is a multi-platform DisplayPDF vector drawing engine that supports multiple output backends, including Windows, GTK, and Macintosh native windowing systems, a variety of raster image formats, PDF, and Postscript. DisplayPDF is more of a convention than an actual specification. It is a path-based drawing API based on a subset of the Adobe PDF specification. Besides basic vector drawing concepts such as paths, rects, line sytles, and the graphics state stack, it also supports pattern fills, antialiasing, and transparency. Perhaps the most popular implementation of DisplayPDF is Apple's Quartz 2-D graphics API in Mac OS X. Kiva Features ````````````` Kiva currently implements the following features: - paths and compiled paths; arcs, bezier curves, rectangles - graphics state stack - clip stack, disjoint rectangular clip regions - raster image blitting - arbitrary affine transforms of the graphics context - bevelled and mitered joins - line width, line dash - Freetype or native fonts - RGB, RGBA, or grayscale color depths - transparency Prerequisites ------------- You must have the following libraries installed before building the Enable/Kiva project: - `Setuptools `_ - `Numpy `_ - `SWIG `_ - (on Linux) X11-devel (development tools for X11) - (on Mac OS X) `Cython `_ Enable/Kiva also have the following requirements: .. rubric:: Runtime: - `Numpy `_ - `PIL `_ - `traits 4.5.0 `_ - `traitsui 4.4.0 `_ - `pyface 4.5.0 `_ .. rubric:: Optional: - `apptools 4.3.0 `_ - (Qt backend) `PySide `_ or `PyQt4 `_ - (WX backend) `WxPython version 2.8.11.0 `_ - (GL backend) `pyglet version 1.1.4 `_ - (GL backend) `pygarrayimage `_ - (SVG backend) `PyParsing `_ - (PDF backend) `ReportLab Toolkit version 3.1 `_ - (Cairo backend) `PyCairo 1.10.0 `_ - (Constrained layout) `kiwisolver `_ enthought-chaco2-4.5.1.orig/enable/0000755000175000017500000000000012516137725016131 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/enable_traits.py0000644000175000017500000000750112516137326021317 0ustar varunvarun""" Define the base Enable object traits """ # Major library imports from numpy import arange, array from types import ListType, TupleType # Enthought library imports from kiva.trait_defs.kiva_font_trait import KivaFont from traits.api import Trait, Range, TraitPrefixList, TraitPrefixMap, \ List, TraitFactory from traitsui.api import ImageEnumEditor, EnumEditor # Try to get the CList trait; for traits 2 backwards compatibility, fall back # to a normal List trait if we can't import it try: from traits.api import CList except ImportError: CList = List # Relative imports import base from base import default_font_name #------------------------------------------------------------------------------ # Constants: #------------------------------------------------------------------------------ # numpy 'array' type: ArrayType = type( arange( 1.0 ) ) # Basic sequence types: basic_sequence_types = ( ListType, TupleType ) # Sequence types: sequence_types = [ ArrayType, ListType, TupleType ] # Valid pointer shape names: pointer_shapes = [ 'arrow', 'right arrow', 'blank', 'bullseye', 'char', 'cross', 'hand', 'ibeam', 'left button', 'magnifier', 'middle button', 'no entry', 'paint brush', 'pencil', 'point left', 'point right', 'question arrow', 'right button', 'size top', 'size bottom', 'size left', 'size right', 'size top right', 'size bottom left', 'size top left', 'size bottom right', 'sizing', 'spray can', 'wait', 'watch', 'arrow wait' ] # Cursor styles: CURSOR_X = 1 CURSOR_Y = 2 cursor_styles = { 'default': -1, 'none': 0, 'horizontal': CURSOR_Y, 'vertical': CURSOR_X, 'both': CURSOR_X | CURSOR_Y } border_size_editor = ImageEnumEditor( values = [ x for x in range( 9 ) ], suffix = '_weight', cols = 3, module = base ) #------------------------------------------------------------------------------- # LineStyle trait #------------------------------------------------------------------------------- # Privates used for specification of line style trait. __line_style_trait_values = { 'solid': None, 'dot dash': array( [ 3.0, 5.0, 9.0, 5.0 ] ), 'dash': array( [ 6.0, 6.0 ] ), 'dot': array( [ 2.0, 2.0 ] ), 'long dash': array( [ 9.0, 5.0 ] ) } __line_style_trait_map_keys = __line_style_trait_values.keys() LineStyleEditor = EnumEditor( values=__line_style_trait_map_keys) def __line_style_trait( value='solid', **metadata ): return Trait( value, __line_style_trait_values, editor=LineStyleEditor, **metadata) # A mapped trait for use in specification of line style attributes. LineStyle = TraitFactory( __line_style_trait ) #------------------------------------------------------------------------------- # Trait definitions: #------------------------------------------------------------------------------- # Font trait: font_trait = KivaFont(default_font_name) # Bounds trait bounds_trait = CList( [0.0, 0.0] ) # (w,h) coordinate_trait = CList( [0.0, 0.0] ) # (x,y) #bounds_trait = Trait((0.0, 0.0, 20.0, 20.0), valid_bounds, editor=bounds_editor) # Component minimum size trait # PZW: Make these just floats, or maybe remove them altogether. ComponentMinSize = Range(0.0, 99999.0) ComponentMaxSize = ComponentMinSize(99999.0) # Pointer shape trait: Pointer = Trait('arrow', TraitPrefixList(pointer_shapes)) # Cursor style trait: cursor_style_trait = Trait('default', TraitPrefixMap(cursor_styles)) spacing_trait = Range(0, 63, value = 4) padding_trait = Range(0, 63, value = 4) margin_trait = Range(0, 63) border_size_trait = Range(0, 8, editor = border_size_editor) # Time interval trait: TimeInterval = Trait(None, None, Range(0.0, 3600.0)) # Stretch traits: Stretch = Range(0.0, 1.0, value = 1.0) NoStretch = Stretch(0.0) enthought-chaco2-4.5.1.orig/enable/coordinate_box.py0000644000175000017500000002023312516137326021477 0ustar varunvarun # Enthought library imports from traits.api import HasTraits, Enum, Instance, Property, Tuple # Local, relative imports from enable_traits import bounds_trait, coordinate_trait from layout.ab_constrainable import ABConstrainable from layout.constraints_namespace import ConstraintsNamespace from layout.utils import add_symbolic_constraints, STRENGTHS ConstraintPolicyEnum = Enum('ignore', *STRENGTHS) def get_from_constraints_namespace(self, name): """ Property getter for all attributes that come from the constraints namespace. """ return getattr(self._constraints_vars, name) class CoordinateBox(HasTraits): """ Represents a box in screen space, and provides convenience properties to access bounds and coordinates in a variety of ways. Primary attributes (not properties): position : [x, y] bounds : [width, height] Secondary attributes (properties): x, y : coordinates of the lower-left pixel of the box x2, y2 : coordinates of the upper-right pixel of the box width : the number of horizontal pixels in the box; equal to x2-x+1 height : the number of vertical pixels in the box; equal to y2-y+1 Note that setting x and y will modify the position, but setting any of the other secondary attributes will modify the bounds of the box. """ bounds = bounds_trait # The position relative to the container. If container is None, then # position will be set to (0,0). position = coordinate_trait x = Property y = Property x2 = Property y2 = Property width = Property height = Property #------------------------------------------------------------------------ # Constraints-based layout #------------------------------------------------------------------------ # A read-only symbolic object that represents the left boundary of # the component left = Property(fget=get_from_constraints_namespace) # A read-only symbolic object that represents the right boundary # of the component right = Property(fget=get_from_constraints_namespace) # A read-only symbolic object that represents the bottom boundary # of the component bottom = Property(fget=get_from_constraints_namespace) # A read-only symbolic object that represents the top boundary of # the component top = Property(fget=get_from_constraints_namespace) # A read-only symbolic object that represents the width of the # component layout_width = Property(fget=get_from_constraints_namespace) # A read-only symbolic object that represents the height of the # component layout_height = Property(fget=get_from_constraints_namespace) # A read-only symbolic object that represents the vertical center # of the component v_center = Property(fget=get_from_constraints_namespace) # A read-only symbolic object that represents the horizontal # center of the component h_center = Property(fget=get_from_constraints_namespace) # A size hint for the layout layout_size_hint = Tuple(0.0, 0.0) # How strongly a layout box hugs it's width hint. hug_width = ConstraintPolicyEnum('weak') # How strongly a layout box hugs it's height hint. hug_height = ConstraintPolicyEnum('weak') # How strongly a layout box resists clipping its contents. resist_width = ConstraintPolicyEnum('strong') # How strongly a layout box resists clipping its contents. resist_height = ConstraintPolicyEnum('strong') # A namespace containing the constraints for this CoordinateBox _constraints_vars = Instance(ConstraintsNamespace) # The list of hard constraints which must be applied to the object. _hard_constraints = Property # The list of size constraints to apply to the object. _size_constraints = Property #------------------------------------------------------------------------ # Public methods #------------------------------------------------------------------------ def is_in(self, x, y): "Returns if the point x,y is in the box" p = self.position b = self.bounds dx = x - p[0] dy = y - p[1] return (dx >= 0) and (dx < b[0]) and (dy >= 0) and (dy < b[1]) def as_coordinates(self): "Returns a 4-tuple (x, y, x2, y2)" p = self.position b = self.bounds return (p[0], p[1], p[0] + b[0] - 1, p[1] + b[1] - 1) #------------------------------------------------------------------------ # Property setters and getters #------------------------------------------------------------------------ def _get_x(self): return self.position[0] def _set_x(self, val): self.position[0] = val return def _get_y(self): return self.position[1] def _set_y(self, val): self.position[1] = val return def _get_width(self): return self.bounds[0] def _set_width(self, val): if isinstance(val, basestring): try: val = float(val) except: pass old_value = self.bounds[0] self.bounds[0] = val self.trait_property_changed('width', old_value, val) return def _get_height(self): return self.bounds[1] def _set_height(self, val): if isinstance(val, basestring): try: val = float(val) except: pass old_value = self.bounds[1] self.bounds[1] = val self.trait_property_changed('height', old_value, val) return def _get_x2(self): if self.bounds[0] == 0: return self.position[0] return self.position[0] + self.bounds[0] - 1 def _set_x2(self, val): self.position[0] = val - self.bounds[0] + 1 return def _old_set_x2(self, val): new_width = val - self.position[0] + 1 if new_width < 0.0: raise RuntimeError("Attempted to set negative component width.") else: self.bounds[0] = new_width return def _get_y2(self): if self.bounds[1] == 0: return self.position[1] return self.position[1] + self.bounds[1] - 1 def _set_y2(self, val): self.position[1] = val - self.bounds[1] + 1 return def _old_set_y2(self, val): new_height = val - self.position[1] + 1 if new_height < 0.0: raise RuntimeError("Attempted to set negative component height.") else: self.bounds[1] = new_height return def __constraints_vars_default(self): obj_name = self.id if hasattr(self, 'id') else '' cns_names = ConstraintsNamespace(type(self).__name__, obj_name) add_symbolic_constraints(cns_names) return cns_names def _get__hard_constraints(self): """ Generate the constraints which must always be applied. """ left = self.left bottom = self.bottom width = self.layout_width height = self.layout_height cns = [left >= 0, bottom >= 0, width >= 0, height >= 0] return cns def _get__size_constraints(self): """ Creates the list of size hint constraints for this box. """ cns = [] push = cns.append width_hint, height_hint = self.layout_size_hint width = self.layout_width height = self.layout_height hug_width, hug_height = self.hug_width, self.hug_height resist_width, resist_height = self.resist_width, self.resist_height if width_hint >= 0: if hug_width != 'ignore': cn = (width == width_hint) | hug_width push(cn) if resist_width != 'ignore': cn = (width >= width_hint) | resist_width push(cn) if height_hint >= 0: if hug_height != 'ignore': cn = (height == height_hint) | hug_height push(cn) if resist_height != 'ignore': cn = (height >= height_hint) | resist_height push(cn) return cns # Register with ABConstrainable so that layout helpers will recognize # CoordinateBox instances. ABConstrainable.register(CoordinateBox) enthought-chaco2-4.5.1.orig/enable/example_support.py0000644000175000017500000001067312516137326021736 0ustar varunvarun""" Support class that wraps up the boilerplate toolkit calls that virtually all demo programs have to use. """ from __future__ import absolute_import from traits.etsconfig.api import ETSConfig # FIXME - it should be enough to do the following import, but because of the # PyQt/traits problem (see below) we can't because it would drag in traits too # early. Until it is fixed we just assume wx if we can import it. # Force the selection of a valid toolkit. #import enable.toolkit if not ETSConfig.toolkit: for toolkit, toolkit_module in (('wx', 'wx'), ('qt4', 'PyQt4')): try: exec "import " + toolkit_module ETSConfig.toolkit = toolkit break except ImportError: pass else: raise RuntimeError("Can't load wx or qt4 backend for Chaco.") if ETSConfig.toolkit == 'wx': import wx from pyface.util.guisupport import start_event_loop_wx, get_app_wx class DemoFrame(wx.Frame): def __init__ ( self, *args, **kw ): wx.Frame.__init__( *(self,) + args, **kw ) #self.SetTitle("Enable Demo") self.SetAutoLayout( True ) # Create the subclass's window self.enable_win = self._create_window() # Listen for the Activate event so we can restore keyboard focus. wx.EVT_ACTIVATE( self, self._on_activate ) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.enable_win.control, 1, wx.EXPAND) self.SetSizer(sizer) self.Show( True ) return def _on_activate(self, event): if self.enable_win is not None and self.enable_win.control is not None: self.enable_win.control.SetFocus() def _create_window(self): "Subclasses should override this method and return an enable.Window" raise NotImplementedError def demo_main(demo_class, size=(400,400), title="Enable Demo"): "Takes the class of the demo to run as an argument." app = get_app_wx() frame = demo_class(None, size=size, title=title) app.SetTopWindow(frame) start_event_loop_wx(app) return frame elif ETSConfig.toolkit == 'qt4': from pyface.qt import QtGui from pyface.util.guisupport import start_event_loop_qt4, get_app_qt4 class DemoFrame(QtGui.QWidget): def __init__ (self, parent, **kw): QtGui.QWidget.__init__(self) # Create the subclass's window self.enable_win = self._create_window() layout = QtGui.QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.enable_win.control) self.setLayout(layout) if 'size' in kw: self.resize(*kw['size']) if 'title' in kw: self.setWindowTitle(kw['title']) self.show() def _create_window(self): "Subclasses should override this method and return an enable.Window" raise NotImplementedError def demo_main(demo_class, size=(400,400), title="Enable Demo"): "Takes the class of the demo to run as an argument." app = get_app_qt4() frame = demo_class(None, size=size, title=title) start_event_loop_qt4(app) return frame elif ETSConfig.toolkit == 'pyglet': from pyglet import app from pyglet import clock class DemoFrame(object): def __init__(self): if app: window = self._create_window() if window: self.enable_win = window else: self.enable_win = None return def _create_window(self): raise NotImplementedError def demo_main(demo_class, size=(640,480), title="Enable Example"): """ Runs a simple application in Pyglet using an instance of **demo_class** as the main window or frame. **demo_class** should be a subclass of DemoFrame or the pyglet backend's Window class. """ if issubclass(demo_class, DemoFrame): frame = demo_class() if frame.enable_win is not None: window = frame.enable_win.control else: window = None else: window = demo_class().control if window is not None: if not window.fullscreen: window.set_size(*size) window.set_caption(title) app.run() enthought-chaco2-4.5.1.orig/enable/example_application.py0000644000175000017500000000433312516137326022521 0ustar varunvarun# # (C) Copyright 2015 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in # LICENSE.txt # """ Example Application Support =========================== This module provides a simple Pyface application that can be used by examples in places where a DemoFrame is insufficient. """ from __future__ import (division, absolute_import, print_function, unicode_literals) from pyface.api import ApplicationWindow, GUI class DemoApplication(ApplicationWindow): """ Simple Pyface application displaying a component. This application has the same interface as the DemoFrames from the example_support module, but the window is embedded in a full Pyface application. This means that subclasses have the opportunity of adding Menus, Toolbars, and other similar features to the demo, where needed. """ def _create_contents(self, parent): self.enable_win = self._create_window() return self.enable_win.control def _create_window(self): "Subclasses should override this method and return an enable.Window" raise NotImplementedError() @classmethod def demo_main(cls, **traits): """ Create the demo application and start the mainloop, if needed This should be called with appropriate arguments which will be passed to the class' constructor. """ # get the Pyface GUI gui = GUI() # create the application's main window window = cls(**traits) window.open() # start the application # if there isn't already a running mainloop, this will block gui.start_event_loop() # if there is already a running mainloop (eg. in an IPython session), # return a reference to the window so that our caller can hold on to it return window def demo_main(cls, **traits): """ Create the demo application and start the mainloop, if needed. This is a simple wrapper around `cls.demo_main` for compatibility with the `DemoFrame` implementation. This should be called with appropriate arguments which will be passed to the class' constructor. """ cls.demo_main(**traits) enthought-chaco2-4.5.1.orig/enable/colors.py0000644000175000017500000003065512516137326020012 0ustar varunvarun# This is a redirection file that determines what constitutes a color trait # in Chaco, and what constitutes the standard colors. from __future__ import absolute_import import sys from traits.etsconfig.api import ETSConfig from traits.api import List, Str, Trait, Tuple, TraitError # Color definitions transparent_color = (0.0, 0.0, 0.0, 0.0) color_table = {"aliceblue": (0.941, 0.973, 1.000, 1.0), "antiquewhite": (0.980, 0.922, 0.843, 1.0), "aqua": (0.000, 1.000, 1.000, 1.0), "aquamarine": (0.498, 1.000, 0.831, 1.0), "azure": (0.941, 1.000, 1.000, 1.0), "beige": (0.961, 0.961, 0.863, 1.0), "bisque": (1.000, 0.894, 0.769, 1.0), "black": (0.000, 0.000, 0.000, 1.0), "blanchedalmond": (1.000, 0.922, 0.804, 1.0), "blue": (0.000, 0.000, 1.000, 1.0), "blueviolet": (0.541, 0.169, 0.886, 1.0), "brown": (0.647, 0.165, 0.165, 1.0), "burlywood": (0.871, 0.722, 0.529, 1.0), "cadetblue": (0.373, 0.620, 0.627, 1.0), "chartreuse": (0.498, 1.000, 0.000, 1.0), "chocolate": (0.824, 0.412, 0.118, 1.0), "coral": (1.000, 0.498, 0.314, 1.0), "cornflowerblue": (0.392, 0.584, 0.929, 1.0), "cornsilk": (1.000, 0.973, 0.863, 1.0), "crimson": (0.863, 0.078, 0.235, 1.0), "cyan": (0.000, 1.000, 1.000, 1.0), "darkblue": (0.000, 0.000, 0.545, 1.0), "darkcyan": (0.000, 0.545, 0.545, 1.0), "darkgoldenrod": (0.722, 0.525, 0.043, 1.0), "darkgray": (0.663, 0.663, 0.663, 1.0), "darkgreen": (0.000, 0.392, 0.000, 1.0), "darkgrey": (0.663, 0.663, 0.663, 1.0), "darkkhaki": (0.741, 0.718, 0.420, 1.0), "darkmagenta": (0.545, 0.000, 0.545, 1.0), "darkolivegreen": (0.333, 0.420, 0.184, 1.0), "darkorange": (1.000, 0.549, 0.000, 1.0), "darkorchid": (0.600, 0.196, 0.800, 1.0), "darkred": (0.545, 0.000, 0.000, 1.0), "darksalmon": (0.914, 0.588, 0.478, 1.0), "darkseagreen": (0.561, 0.737, 0.561, 1.0), "darkslateblue": (0.282, 0.239, 0.545, 1.0), "darkslategray": (0.184, 0.310, 0.310, 1.0), "darkslategrey": (0.184, 0.310, 0.310, 1.0), "darkturquoise": (0.000, 0.808, 0.820, 1.0), "darkviolet": (0.580, 0.000, 0.827, 1.0), "deeppink": (1.000, 0.078, 0.576, 1.0), "deepskyblue": (0.000, 0.749, 1.000, 1.0), "dimgray": (0.412, 0.412, 0.412, 1.0), "dimgrey": (0.412, 0.412, 0.412, 1.0), "dodgerblue": (0.118, 0.565, 1.000, 1.0), "firebrick": (0.698, 0.133, 0.133, 1.0), "floralwhite": (1.000, 0.980, 0.941, 1.0), "forestgreen": (0.133, 0.545, 0.133, 1.0), "fuchsia": (1.000, 0.000, 1.000, 1.0), "gainsboro": (0.863, 0.863, 0.863, 1.0), "ghostwhite": (0.973, 0.973, 1.000, 1.0), "gold": (1.000, 0.843, 0.000, 1.0), "goldenrod": (0.855, 0.647, 0.125, 1.0), "gray": (0.502, 0.502, 0.502, 1.0), "green": (0.000, 0.502, 0.000, 1.0), "greenyellow": (0.678, 1.000, 0.184, 1.0), "grey": (0.502, 0.502, 0.502, 1.0), "honeydew": (0.941, 1.000, 0.941, 1.0), "hotpink": (1.000, 0.412, 0.706, 1.0), "indianred": (0.804, 0.361, 0.361, 1.0), "indigo": (0.294, 0.000, 0.510, 1.0), "ivory": (1.000, 1.000, 0.941, 1.0), "khaki": (0.941, 0.902, 0.549, 1.0), "lavender": (0.902, 0.902, 0.980, 1.0), "lavenderblush": (1.000, 0.941, 0.961, 1.0), "lawngreen": (0.486, 0.988, 0.000, 1.0), "lemonchiffon": (1.000, 0.980, 0.804, 1.0), "lightblue": (0.678, 0.847, 0.902, 1.0), "lightcoral": (0.941, 0.502, 0.502, 1.0), "lightcyan": (0.878, 1.000, 1.000, 1.0), "lightgoldenrodyellow": (0.980, 0.980, 0.824, 1.0), "lightgray": (0.827, 0.827, 0.827, 1.0), "lightgreen": (0.565, 0.933, 0.565, 1.0), "lightgrey": (0.827, 0.827, 0.827, 1.0), "lightpink": (1.000, 0.714, 0.757, 1.0), "lightsalmon": (1.000, 0.627, 0.478, 1.0), "lightseagreen": (0.125, 0.698, 0.667, 1.0), "lightskyblue": (0.529, 0.808, 0.980, 1.0), "lightslategray": (0.467, 0.533, 0.600, 1.0), "lightslategrey": (0.467, 0.533, 0.600, 1.0), "lightsteelblue": (0.690, 0.769, 0.871, 1.0), "lightyellow": (1.000, 1.000, 0.878, 1.0), "lime": (0.000, 1.000, 0.000, 1.0), "limegreen": (0.196, 0.804, 0.196, 1.0), "linen": (0.980, 0.941, 0.902, 1.0), "magenta": (1.000, 0.000, 1.000, 1.0), "maroon": (0.502, 0.000, 0.000, 1.0), "mediumaquamarine": (0.400, 0.804, 0.667, 1.0), "mediumblue": (0.000, 0.000, 0.804, 1.0), "mediumorchid": (0.729, 0.333, 0.827, 1.0), "mediumpurple": (0.576, 0.439, 0.859, 1.0), "mediumseagreen": (0.235, 0.702, 0.443, 1.0), "mediumslateblue": (0.482, 0.408, 0.933, 1.0), "mediumspringgreen": (0.000, 0.980, 0.604, 1.0), "mediumturquoise": (0.282, 0.820, 0.800, 1.0), "mediumvioletred": (0.780, 0.082, 0.522, 1.0), "midnightblue": (0.098, 0.098, 0.439, 1.0), "mintcream": (0.961, 1.000, 0.980, 1.0), "mistyrose": (1.000, 0.894, 0.882, 1.0), "moccasin": (1.000, 0.894, 0.710, 1.0), "navajowhite": (1.000, 0.871, 0.678, 1.0), "navy": (0.000, 0.000, 0.502, 1.0), "oldlace": (0.992, 0.961, 0.902, 1.0), "olive": (0.502, 0.502, 0.000, 1.0), "olivedrab": (0.420, 0.557, 0.137, 1.0), "orange": (1.000, 0.647, 0.000, 1.0), "orangered": (1.000, 0.271, 0.000, 1.0), "orchid": (0.855, 0.439, 0.839, 1.0), "palegoldenrod": (0.933, 0.910, 0.667, 1.0), "palegreen": (0.596, 0.984, 0.596, 1.0), "paleturquoise": (0.686, 0.933, 0.933, 1.0), "palevioletred": (0.859, 0.439, 0.576, 1.0), "papayawhip": (1.000, 0.937, 0.835, 1.0), "peachpuff": (1.000, 0.855, 0.725, 1.0), "peru": (0.804, 0.522, 0.247, 1.0), "pink": (1.000, 0.753, 0.796, 1.0), "plum": (0.867, 0.627, 0.867, 1.0), "powderblue": (0.690, 0.878, 0.902, 1.0), "purple": (0.502, 0.000, 0.502, 1.0), "red": (1.000, 0.000, 0.000, 1.0), "rosybrown": (0.737, 0.561, 0.561, 1.0), "royalblue": (0.255, 0.412, 0.882, 1.0), "saddlebrown": (0.545, 0.271, 0.075, 1.0), "salmon": (0.980, 0.502, 0.447, 1.0), "sandybrown": (0.957, 0.643, 0.376, 1.0), "seagreen": (0.180, 0.545, 0.341, 1.0), "seashell": (1.000, 0.961, 0.933, 1.0), "sienna": (0.627, 0.322, 0.176, 1.0), "silver": (0.753, 0.753, 0.753, 1.0), "skyblue": (0.529, 0.808, 0.922, 1.0), "slateblue": (0.416, 0.353, 0.804, 1.0), "slategray": (0.439, 0.502, 0.565, 1.0), "slategrey": (0.439, 0.502, 0.565, 1.0), "snow": (1.000, 0.980, 0.980, 1.0), "springgreen": (0.000, 1.000, 0.498, 1.0), "steelblue": (0.275, 0.510, 0.706, 1.0), "tan": (0.824, 0.706, 0.549, 1.0), "teal": (0.000, 0.502, 0.502, 1.0), "thistle": (0.847, 0.749, 0.847, 1.0), "tomato": (1.000, 0.388, 0.278, 1.0), "turquoise": (0.251, 0.878, 0.816, 1.0), "violet": (0.933, 0.510, 0.933, 1.0), "wheat": (0.961, 0.871, 0.702, 1.0), "white": (1.000, 1.000, 1.000, 1.0), "whitesmoke": (0.961, 0.961, 0.961, 1.0), "yellow": (1.000, 1.000, 0.000, 1.0), "yellowgreen": (0.604, 0.804, 0.196, 1.0), # Several aliases for transparent "clear": transparent_color, "transparent": transparent_color, "none": transparent_color, # Placeholders for system- and toolkit-specific UI colors; the # toolkit-dependent code below will fill these with the appropriate # values. These hardcoded defaults are for the Windows Classic # theme. "sys_window" : (0.83137, 0.81569, 0.78431, 1.0), } if not ETSConfig.toolkit: # Force Traits to decide on its toolkit if it hasn't already from traitsui.toolkit import toolkit as traits_toolkit traits_toolkit() if ETSConfig.toolkit == 'wx': import wx from traitsui.wx.color_editor \ import ToolkitEditorFactory as StandardColorEditorFactory # Version dependent imports (ColourPtr not defined in wxPython 2.8): try: ColourPtr = wx.ColourPtr except: class ColourPtr ( object ): pass # Mostly copied from traits/ui/wx/color_trait.py def convert_from_wx_color(obj, name, value): if isinstance(value, ColourPtr) or isinstance(value, wx.Colour): return (value.Red()/255.0, value.Green()/255.0, value.Blue()/255.0, 1.0) elif type(value) is int: num = int( value ) return ((num >> 16)/255.0, ((num>>8) & 0xFF)/255.0, (num & 0xFF)/255.0, 1.0) elif type(value) in (list, tuple): if len(value) == 3: return (value[0]/255.0, value[1]/255.0, value[2]/255.0, 1.0) elif len(value) == 4: return value else: raise TraitError else: raise TraitError convert_from_wx_color.info = ('a wx.Colour instance, an integer which in hex is of ' 'the form 0xRRGGBB, where RR is red, GG is green, ' 'and BB is blue, a list/tuple of (r,g,b) or (r,g,b,a)') # Set the system color from traitsui.wx.constants import WindowColor color_table["sys_window"] = (WindowColor.Red()/255.0, WindowColor.Green()/255.0, WindowColor.Blue()/255.0, 1.0) class ColorEditorFactory(StandardColorEditorFactory): def to_wx_color(self, editor): if self.mapped: retval = getattr( editor.object, editor.name + '_' ) else: retval = getattr( editor.object, editor.name ) if isinstance(retval, tuple): retval = wx.Colour(int(255*retval[0]), int(255*retval[1]), int(255*retval[2])) return retval def from_wx_color ( self, color ): """ Gets the application equivalent of a wxPython value. """ return convert_from_wx_color(self, 'color', color) def str_color(self, color): if isinstance( color, ( wx.Colour, ColourPtr ) ): return "(%d,%d,%d)" % ( color.Red(), color.Green(), color.Blue() ) elif isinstance(color, tuple): fmt = "(" + ",".join(["%0.3f"]*len(color)) + ")" return fmt % color return color ColorTrait = Trait("black", Tuple, List, color_table, convert_from_wx_color, editor=ColorEditorFactory) elif ETSConfig.toolkit == 'qt4': from pyface.qt import QtGui from traitsui.qt4.color_editor \ import ToolkitEditorFactory as StandardColorEditorFactory def convert_from_pyqt_color(obj, name, value): if isinstance(value, QtGui.QColor): return value.getRgbF() elif type(value) is int: num = int(value) return ((num >> 16)/255.0, ((num>>8) & 0xFF)/255.0, (num & 0xFF)/255.0, 1.0) elif type(value) in (list, tuple): if len(value) == 3: return (value[0]/255.0, value[1]/255.0, value[2]/255.0, 1.0) elif len(value) == 4: return value else: raise TraitError else: raise TraitError convert_from_pyqt_color.info = ("a QtGui.Color instance, an SVG color " "name, an integer which in hex is of the form 0xRRGGBB, where RR " "is red, GG is green, and BB is blue, a list/tuple of (r,g,b) or " "(r,g,b,a)") window_color = QtGui.QApplication.palette().window().color() color_table["sys_window"] = (window_color.red()/255.0, window_color.green()/255.0, window_color.blue()/255.0, 1.0) class ColorEditorFactory(StandardColorEditorFactory): def to_qt4_color(self, editor): if self.mapped: retval = getattr(editor.object, editor.name + '_') else: retval = getattr(editor.object, editor.name) if isinstance(retval, tuple): col = QtGui.QColor() col.setRgbF(*retval) retval = col return retval def str_color(self, color): if isinstance(color, QtGui.QColor): color = color.getRgbF() if isinstance(color, tuple): fmt = "(" + ",".join(["%0.3f"] * len(color)) + ")" color = fmt % color return color ColorTrait = Trait("black", Tuple, List, color_table, convert_from_pyqt_color, editor=ColorEditorFactory) else: ColorTrait = Trait("black", Tuple, List, Str, color_table) ColorEditorFactory = None black_color_trait = ColorTrait("black") white_color_trait = ColorTrait("white") transparent_color_trait = ColorTrait("transparent") # EOF enthought-chaco2-4.5.1.orig/enable/drawing/0000755000175000017500000000000012516137725017564 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/drawing/drawing_tool.py0000644000175000017500000000331712516137326022627 0ustar varunvarun from traits.api import Enum from enable.api import Component class DrawingTool(Component): """ A drawing tool is just a component that also defines a certain drawing mode so that its container knows how to render it and pass control to it. The DrawingTool base class also defines a draw() dispatch, so that different draw methods are called depending on the event state of the tool. """ # The mode in which this tool draws: # # "normal" # The tool draws like a normal component, alongside other components # in the container # "overlay" # The tool draws on top of over components in the container # "exclusive" # The tool gets total control of how the container should be rendered draw_mode = Enum("normal", "overlay", "exclusive") def reset(self): """ Causes the tool to reset any saved state and revert its event_state back to the initial value (usually "normal"). """ pass def complete_left_down(self, event): """ Default function that causes the tool to reset if the user starts drawing again. """ self.reset() self.request_redraw() self.normal_left_down(event) return def _draw_mainlayer(self, gc, view_bounds, mode="default"): draw_func = getattr(self, self.event_state + "_draw", None) if draw_func: draw_func(gc) return def request_redraw(self): if self.container is not None: self.container.request_redraw() elif hasattr(self, "canvas") and self.canvas is not None: self.canvas.request_redraw() else: pass return # EOF enthought-chaco2-4.5.1.orig/enable/drawing/point_polygon.py0000644000175000017500000001665312516137326023046 0ustar varunvarun""" A point-to-point drawn polygon. """ # Enthought library imports. from enable.primitives.api import Polygon from traits.api import Int, Instance from drawing_tool import DrawingTool class PointPolygon(DrawingTool): """ A point-to-point drawn polygon. """ # The actual polygon primitive we are editing. polygon = Instance(Polygon, args=()) # The pixel distance from a vertex that is considered 'on' the vertex. proximity_distance = Int(4) # Override the default value of this inherited trait draw_mode = "overlay" # The index of the vertex being dragged, if any. _dragged = Int def reset(self): self.polygon.model.reset() self.event_state = "normal" return #------------------------------------------------------------------------ # "complete" state #------------------------------------------------------------------------ def complete_draw(self, gc): """ Draw a closed polygon. """ self.polygon.border_dash = None self.polygon._draw_closed(gc) return def complete_left_down(self, event): """ Handle the left mouse button coming up in the 'complete' state. """ # Ignore the click if it contains modifiers we do not handle. polygon = self.polygon if event.shift_down or event.alt_down: event.handled = False else: # If we are over a point, we will either move it or remove it. over = self._over_point(event, polygon.model.points) if over is not None: # Control down means remove it. if event.control_down: del polygon.model.points[over] # Otherwise, prepare to drag it. else: self._dragged = over event.window.set_pointer('right arrow') self.event_state = 'drag_point' self.request_redraw() return def complete_mouse_move(self, event): """ Handle the mouse moving in the 'complete' state. """ # If we are over a point, then we have to prepare to move it. over = self._over_point(event, self.polygon.model.points) if over is not None: if event.control_down: event.window.set_pointer('bullseye') else: event.window.set_pointer('right arrow') else: event.handled = False event.window.set_pointer('arrow') self.request_redraw() return #------------------------------------------------------------------------ # "drag_point" state #------------------------------------------------------------------------ def drag_point_draw(self, gc): """ Draw the polygon in the 'drag_point' state. """ self.complete_draw(gc) return def drag_point_left_up(self, event): """ Handle the left mouse coming up in the 'drag_point' state. """ self.event_state = 'complete' self.request_redraw() return def drag_point_mouse_move(self, event): """ Handle the mouse moving in the 'drag_point' state. """ # Only worry about the event if it's inside our bounds. polygon = self.polygon dragged_point = polygon.model.points[self._dragged] # If the point has actually moved, update it. if dragged_point != (event.x, event.y): polygon.model.points[self._dragged] = \ (event.x + self.x, event.y - self.y) self.request_redraw() return #------------------------------------------------------------------------ # "incomplete" state #------------------------------------------------------------------------ def incomplete_draw(self, gc): """ Draw the polygon in the 'incomplete' state. """ self.polygon.border_dash = (4.0, 2.0) self.polygon._draw_open(gc) return def incomplete_left_dclick(self, event): """ Handle a left double-click in the incomplete state. """ # Remove the point that was placed by the first mouse up, since # another one will be placed on the up stroke of the double click. del self.polygon.model.points[-1] event.window.set_pointer('right arrow') self.event_state = 'complete' self.complete = True self.request_redraw() return def incomplete_left_up(self, event): """ Handle the left mouse button coming up in incomplete state. """ # If the click was over the start vertex, we are done. if self._is_over_start( event ): del self.polygon.model.points[-1] self.event_state = 'complete' event.window.set_pointer('right arrow') self.complete = True # Otherwise, add the point and move on. else: self.polygon.model.points.append((event.x + self.x, event.y - self.y)) self.request_redraw() return def incomplete_mouse_move(self, event): """ Handle the mouse moving in incomplete state. """ # If we move over the initial point, then we change the cursor. if self._is_over_start( event ): event.window.set_pointer('bullseye') else: event.window.set_pointer('pencil') # If the point has actually changed, then we need to update our model. if self.polygon.model.points != (event.x + self.x, event.y - self.y): self.polygon.model.points[-1] = (event.x + self.x, event.y - self.y) self.request_redraw() return #------------------------------------------------------------------------ # "normal" state #------------------------------------------------------------------------ def normal_left_up(self, event): """ Handle the left button up in the 'normal' state. """ # Append the current point twice, because we need to have the starting # point and the current point be separate, since the current point # will be moved with the mouse from now on. pt = (event.x + self.x, event.y - self.y) self.polygon.model.points.append(pt) self.polygon.model.points.append(pt) self.event_state = 'incomplete' return def normal_mouse_move(self, event): """ Handle the mouse moving in the 'normal' state. """ event.window.set_pointer('pencil') return #------------------------------------------------------------------------ # private methods #------------------------------------------------------------------------ def _is_near_point(self, point, event): """ Determine if the pointer is near a specified point. """ event_point = (event.x + self.x, event.y - self.y) return ((abs(point[0] - event_point[0]) + \ abs(point[1] - event_point[1])) <= self.proximity_distance) def _is_over_start(self, event): """ Test if the event is 'over' the starting vertex. """ return (len(self.polygon.model.points) > 0 and self._is_near_point(self.polygon.model.points[0], event)) def _over_point(self, event, points): """ Return the index of a point in points that event is 'over'. Returns none if there is no such point. """ for i, point in enumerate(points): if self._is_near_point(point, event): result = i break else: result = None return result # EOF enthought-chaco2-4.5.1.orig/enable/drawing/drag_line.py0000644000175000017500000000510612516137326022061 0ustar varunvarun""" A drag drawn line. """ from __future__ import with_statement from enable.api import Line from traits.api import Instance from drawing_tool import DrawingTool class DragLine(DrawingTool): """ A drag drawn line. This is not a straight line, but can be a free-form, curved path. """ # Override the vertex color so as to not draw it. vertex_color = (0.0, 0.0, 0.0, 0.0) # Because this class subclasses DrawingTool and not Line, it contains # an instance of the Line primitive. line = Instance(Line, args=()) # Override the default value of this inherited trait draw_mode="overlay" def reset(self): self.line.vertex_color = self.vertex_color self.line.points = [] self.event_state = "normal" return #------------------------------------------------------------------------ # "complete" state #------------------------------------------------------------------------ def complete_draw(self, gc): """ Draw the completed line. """ self.line.line_dash = None self.line._draw_mainlayer(gc) return #------------------------------------------------------------------------ # "drawing" state #------------------------------------------------------------------------ def drawing_draw(self, gc): self.line.line_dash = (4.0, 2.0) self.line._draw_mainlayer(gc) return def drawing_left_up(self, event): """ Handle the left mouse button coming up in the 'drawing' state. """ self.event_state = 'complete' event.window.set_pointer('arrow') self.request_redraw() self.complete = True event.handled = True return def drawing_mouse_move(self, event): """ Handle the mouse moving in 'drawing' state. """ last_point = self.line.points[-1] # If we have moved, we need to add a point. if last_point != (event.x + self.x, event.y - self.y): self.line.points.append((event.x + self.x, event.y - self.y)) self.request_redraw() return #------------------------------------------------------------------------ # "normal" state #------------------------------------------------------------------------ def normal_left_down(self, event): """ Handle the left button down in the 'normal' state. """ self.line.points.append((event.x + self.x, event.y - self.y)) self.event_state = 'drawing' event.window.set_pointer('pencil') event.handled = True self.request_redraw() return enthought-chaco2-4.5.1.orig/enable/drawing/__init__.py0000644000175000017500000000000012516137326021660 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/drawing/drag_box.py0000644000175000017500000000733112516137326021724 0ustar varunvarun#----------------------------------------------------------------------------- # # Copyright (c) 2005, Enthought, Inc. # All rights reserved. # # Author: Scott Swarts # #----------------------------------------------------------------------------- """A drag drawn box """ # Standard library imports. # Major packages. # Enthought library imports from enable.primitives.api import Box from enable.enable_traits import Pointer from traits.api import Event, Float, Trait, Tuple # Application specific imports. # Local imports. ############################################################################## # class 'DragBox' ############################################################################## class DragBox(Box): """A drag drawn box """ ########################################################################## # Traits ########################################################################## ### 'DragBox' interface ############################################ # Event fired when complete: complete = Event # Constraints on size: x_bounds = Trait(None, None, Tuple(Float, Float)) y_bounds = Trait(None, None, Tuple(Float, Float)) #### Pointers. #### # Pointer for the complete state: complete_pointer = Pointer('cross') # Pointer for the drawing state: drawing_pointer = Pointer('cross') # Pointer for the normal state: normal_pointer = Pointer('cross') #### Private traits # Position of the left down: start_x = Float start_y = Float ########################################################################## # 'object' interface ########################################################################## ########################################################################## # 'Component' interface ########################################################################## #### 'normal' state ###################################################### def normal_left_down ( self, event ): """ Handle the left button down in the 'normal' state. """ self.event_state = 'drawing' self.pointer = self.drawing_pointer self.start_x = event.x self.start_y = event.y self._set_bounds(event) return def normal_mouse_move (self, event): """ Handle the mouse moving in the 'normal' state. """ self.pointer = self.normal_pointer return #### 'drawing' state ##################################################### def drawing_mouse_move(self, event): """ Handle the mouse moving in the 'drawing' state. """ self._set_bounds(event) def drawing_left_up(self, event): """ Handle the left mouse button coming up in the 'drawing' state. """ self.event_state = 'complete' self.pointer = self.complete_pointer self.complete = True self._set_bounds(event) return ########################################################################## # Private interface ########################################################################## def _set_bounds(self, event): """ Sets the bounds based on start_x, start_y, the event position and any constrants. """ if self.x_bounds is not None: x, dx = self.x_bounds else: x = min(self.start_x, event.x) dx = abs(event.x-self.start_x) if self.y_bounds is not None: y, dy = self.y_bounds else: y = min(self.start_y, event.y) dy = abs(event.y-self.start_y) self.bounds = (x, y, dx, dy) #### EOF ###################################################################### enthought-chaco2-4.5.1.orig/enable/drawing/api.py0000644000175000017500000000051112516137326020701 0ustar varunvarunfrom drag_line import DragLine from drag_polygon import DragPolygon from point_line import PointLine from point_polygon import PointPolygon from drag_segment import DragSegment from drag_box import DragBox from drawing_tool import DrawingTool from drawing_canvas import Button, ToolbarButton, DrawingCanvasToolbar, DrawingCanvas enthought-chaco2-4.5.1.orig/enable/drawing/point_line.py0000644000175000017500000002030012516137326022266 0ustar varunvarun""" A point-to-point drawn polygon. """ from __future__ import with_statement from enable.api import cursor_style_trait, Line from traits.api import Event, Int, Instance from drawing_tool import DrawingTool class PointLine(DrawingTool): """ A point-to-point drawn line. """ # Our contained "Line" instance; it stores the points and does the actual # drawing. line = Instance(Line, args=()) # Override the draw_mode value we inherit from DrawingTool draw_mode = "overlay" # The pixel distance from a vertex that is considered 'on' the vertex. proximity_distance = Int(4) # The cursor shapes to use for various modes normal_cursor = cursor_style_trait('arrow') drawing_cursor = cursor_style_trait('pencil') delete_cursor = cursor_style_trait('bullseye') move_cursor = cursor_style_trait('sizing') # The index of the vertex being dragged, if any. _dragged = Int complete = Event def add_point(self, point): """ Add the point. """ self.line.points.append(point) return def get_point(self, index): """ Get the point at the specified index. """ return self.line.points[ index ] def set_point(self, index, point): """ Set the point at the specified index to point. """ self.line.points[index] = point return def remove_point(self, index): """ Remove the point with the specified index. """ del self.line.points[index] return #------------------------------------------------------------------------ # DrawingTool interface #------------------------------------------------------------------------ def reset(self): self.line.points = [] self.event_state = "normal" return #------------------------------------------------------------------------ # "complete" state #------------------------------------------------------------------------ def complete_draw(self, gc): # Draw the completed line self.line.line_dash = None with gc: self.line._draw_mainlayer(gc) return def complete_left_down(self, event): """ Handle the left mouse button going down in the 'complete' state. """ # Ignore the click if it contains modifiers we do not handle. if event.shift_down or event.alt_down: event.handled = False else: # If we are over a point, we will either move it or remove it. over = self._over_point(event, self.line.points) if over is not None: # Control down means remove it. if event.control_down: self.remove_point(over) self.updated = self # Otherwise, prepare to drag it. else: self._dragged = over event.window.set_pointer(self.move_cursor) self.event_state = 'drag_point' self.request_redraw() return def complete_mouse_move(self, event): """ Handle the mouse moving in the 'complete' state. """ # If we are over a point, then we have to prepare to move it. over = self._over_point(event, self.line.points) if over is not None: if event.control_down: event.window.set_pointer(self.delete_cursor) else: event.window.set_pointer(self.move_cursor) else: event.handled = False event.window.set_pointer(self.normal_cursor) self.request_redraw() return #------------------------------------------------------------------------ # "drag" state #------------------------------------------------------------------------ def drag_point_draw(self, gc): """ Draw the polygon in the 'drag_point' state. """ self.line._draw_mainlayer(gc) return def drag_point_left_up(self, event): """ Handle the left mouse coming up in the 'drag_point' state. """ self.event_state = 'complete' self.updated = self return def drag_point_mouse_move(self, event): """ Handle the mouse moving in the 'drag_point' state. """ # Only worry about the event if it's inside our bounds. dragged_point = self.get_point(self._dragged) # If the point has actually moved, update it. if dragged_point != (event.x, event.y): self.set_point(self._dragged, (event.x, event.y)) self.request_redraw() return #------------------------------------------------------------------------ # "incomplete" state #------------------------------------------------------------------------ def incomplete_draw(self, gc): """ Draw the line in the 'incomplete' state. """ with gc: gc.set_fill_color((0, 0, 0, 0)) gc.rect(50, 50, 100, 100) self.line._draw_mainlayer(gc) return def incomplete_left_dclick(self, event): """ Handle a left double-click in the incomplete state. """ # Remove the point that was placed by the first mouse down, since # another one will be placed on the down stroke of the double click. self.remove_point(-1) event.window.set_pointer(self.move_cursor) self.event_state = 'complete' self.complete = True self.request_redraw() return def incomplete_left_down(self, event): """ Handle the left mouse button coming up in incomplete state. """ # Add the point. self.add_point((event.x, event.y)) self.updated = self return def incomplete_mouse_move(self, event): """ Handle the mouse moving in incomplete state. """ # If we move over the initial point, then we change the cursor. event.window.set_pointer(self.drawing_cursor) # If the point has actually changed, then we need to update our model. if self.get_point(-1) != (event.x, event.y): self.set_point(-1, (event.x, event.y)) self.request_redraw() return #------------------------------------------------------------------------ # "normal" state #------------------------------------------------------------------------ def normal_left_down(self, event): """ Handle the left button up in the 'normal' state. """ # Append the current point twice, because we need to have the starting # point and the current point be separate, since the current point # will be moved with the mouse from now on. self.add_point((event.x, event.y)) self.add_point((event.x, event.y)) self.event_state = 'incomplete' self.updated = self self.line_dash = (4.0, 2.0) return def normal_mouse_move(self, event): """ Handle the mouse moving in the 'normal' state. """ event.window.set_pointer(self.drawing_cursor) return #------------------------------------------------------------------------ # Private interface #------------------------------------------------------------------------ def _updated_fired(self, event): # The self.updated trait is used by point_line and can be used by # others to indicate that the model has been updated. For now, the # only action taken is to do a redraw. self.request_redraw() def _is_near_point(self, point, event): """ Determine if the pointer is near a specified point. """ event_point = (event.x, event.y) return ((abs( point[0] - event_point[0] ) + \ abs( point[1] - event_point[1] )) <= self.proximity_distance) def _is_over_start(self, event): """ Test if the event is 'over' the starting vertex. """ return (len(self.points) > 0 and self._is_near_point(self.points[0], event)) def _over_point(self, event, points): """ Return the index of a point in points that event is 'over'. Returns None if there is no such point. """ for i, point in enumerate(points): if self._is_near_point(point, event): result = i break else: result = None return result # EOF enthought-chaco2-4.5.1.orig/enable/drawing/drag_polygon.py0000644000175000017500000000745612516137326022633 0ustar varunvarun""" A drag drawn polygon. """ from __future__ import with_statement from enable.primitives.api import Polygon from enable.api import Pointer from pyface.action.api import MenuManager from traits.api import Delegate, Instance from drawing_tool import DrawingTool class DragPolygon(DrawingTool): """ A drag drawn polygon. """ poly = Instance(Polygon, args=()) draw_mode = "overlay" #### Visible style. #### # Override the vertex color so as to not draw it. vertex_color = Delegate('poly', modify=True) # Override the vertex size so as to not draw it. vertex_size = Delegate('poly', modify=True) background_color = Delegate('poly', modify=True) #### Pointers. #### # Pointer for the complete state. complete_pointer = Pointer('cross') # Pointer for the drawing state. drawing_pointer = Pointer('cross') # Pointer for the normal state. normal_pointer = Pointer('cross') #### Miscellaneous. #### # The context menu for the polygon. menu = Instance(MenuManager) def reset(self): self.vertex_color = (0,0,0,0) self.vertex_size = 0 self.poly.model.points = [] self.event_state = "normal" return ########################################################################### # 'Component' interface. ########################################################################### #### 'complete' state ##################################################### def complete_draw ( self, gc ): """ Draw the completed polygon. """ with gc: self.poly.border_dash = None self.poly._draw_closed(gc) return def complete_left_down ( self, event ): """ Draw a new polygon. """ self.reset() self.normal_left_down( event ) return def complete_right_down ( self, event ): """ Do the context menu if available. """ if self.menu is not None: if self._is_in((event.x + self.x, event.y - self.y)): menu = self.menu.create_menu(event.window.control) ### FIXME : The call to _flip_y is necessary but inappropriate. menu.show(event.x, event.window._flip_y(event.y)) return #### 'drawing' state ###################################################### def drawing_draw ( self, gc ): """ Draw the polygon while in 'drawing' state. """ with gc: self.poly.border_dash = (4.0, 2.0) self.poly._draw_open(gc) return def drawing_left_up ( self, event ): """ Handle the left mouse button coming up in 'drawing' state. """ self.event_state = 'complete' self.pointer = self.complete_pointer self.request_redraw() self.complete = True return def drawing_mouse_move ( self, event ): """ Handle the mouse moving in 'drawing' state. """ last_point = self.poly.model.points[-1] # If we have moved, we need to add a point. if last_point != (event.x + self.x, event.y - self.y): self.poly.model.points.append((event.x + self.x, event.y - self.y)) self.request_redraw() return #### 'normal' state ####################################################### def normal_left_down ( self, event ): """ Handle the left button down in the 'normal' state. """ self.poly.model.points.append((event.x + self.x, event.y - self.y)) self.event_state = 'drawing' self.pointer = self.drawing_pointer self.request_redraw() return def normal_mouse_move ( self, event ): """ Handle the mouse moving in the 'normal' state. """ self.pointer = self.normal_pointer return #### EOF ###################################################################### enthought-chaco2-4.5.1.orig/enable/drawing/drag_segment.py0000644000175000017500000000652112516137326022576 0ustar varunvarun#----------------------------------------------------------------------------- # # Copyright (c) 2005, Enthought, Inc. # All rights reserved. # # Author: Scott Swarts # #----------------------------------------------------------------------------- # Enthought library imports from enable.api import Line, Pointer from traits.api import Event, Instance from drawing_tool import DrawingTool class DragSegment(DrawingTool): """A dragged line segment""" # Override the vertex color so as to not draw it. vertex_color = (0.0, 0.0, 0.0, 0.0) # Because this class subclasses DrawingTool and not Line, it contains # an instance of the Line primitive. line = Instance(Line, args=()) # Event fired when the line is complete complete = Event # Pointer for the complete state. complete_pointer = Pointer('arrow') # Pointer for the drawing state. drawing_pointer = Pointer('cross') # Pointer for the normal state. normal_pointer = Pointer('cross') #------------------------------------------------------------------------ # DrawingTool interface #------------------------------------------------------------------------ def reset(self): self.line.vertex_color = self.vertex_color self.line.points = [] self.event_state = "normal" return #------------------------------------------------------------------------ # "complete" state #------------------------------------------------------------------------ def complete_draw(self, gc): """ Draw the completed line. """ self.line.line_dash = None self.line._draw_mainlayer(gc) self.request_redraw() return #------------------------------------------------------------------------ # "drawing" state #------------------------------------------------------------------------ def drawing_draw(self, gc): self.line.line_dash = (4.0, 2.0) self.line._draw_mainlayer(gc) return def drawing_mouse_move(self, event): """ Handle the mouse moving in drawing state. """ # Change the last point to the current event point self.line.points[-1] = (event.x, event.y) self.updated = self self.request_redraw() return def drawing_left_up(self, event): """ Handle the left mouse button coming up in the 'drawing' state. """ self.event_state = 'complete' event.window.set_pointer(self.complete_pointer) self.request_redraw() self.complete = True return #------------------------------------------------------------------------ # "normal" state #------------------------------------------------------------------------ def normal_left_down(self, event): """ Handle the left button down in the 'normal' state. """ # Set points the current segment, which is just the # current point twice. current_point = (event.x, event.y) self.line.points = [current_point, current_point] self.updated = self # Go into the drawing state self.event_state = 'drawing' event.window.set_pointer(self.drawing_pointer) self.request_redraw() return def normal_mouse_move(self, event): event.window.set_pointer(self.normal_pointer) return # EOF enthought-chaco2-4.5.1.orig/enable/drawing/drawing_canvas.py0000644000175000017500000001650312516137326023126 0ustar varunvarun from __future__ import with_statement from enable.api import Container, Component, ColorTrait from kiva.constants import FILL, FILL_STROKE from kiva.trait_defs.kiva_font_trait import KivaFont from traits.api import Any, Bool, Delegate, Enum, Instance, Int, List, Str class Button(Component): color = ColorTrait("lightblue") down_color = ColorTrait("darkblue") border_color = ColorTrait("blue") label = Str label_font = KivaFont("modern 12") label_color = ColorTrait("white") down_label_color = ColorTrait("white") button_state = Enum("up", "down") # A reference to the radio group that this button belongs to radio_group = Any # Default size of the button if no label is present bounds=[32,32] # Generally, buttons are not resizable resizable = "" _got_mousedown = Bool(False) def perform(self, event): """ Called when the button is depressed. 'event' is the Enable mouse event that triggered this call. """ pass def _draw_mainlayer(self, gc, view_bounds, mode="default"): if self.button_state == "up": self.draw_up(gc, view_bounds) else: self.draw_down(gc, view_bounds) return def draw_up(self, gc, view_bounds): with gc: gc.set_fill_color(self.color_) gc.set_stroke_color(self.border_color_) gc.draw_rect((int(self.x), int(self.y), int(self.width)-1, int(self.height)-1), FILL_STROKE) self._draw_label(gc) return def draw_down(self, gc, view_bounds): with gc: gc.set_fill_color(self.down_color_) gc.set_stroke_color(self.border_color_) gc.draw_rect((int(self.x), int(self.y), int(self.width)-1, int(self.height)-1), FILL_STROKE) self._draw_label(gc, color=self.down_label_color_) return def _draw_label(self, gc, color=None): if self.label != "": gc.set_font(self.label_font) x,y,w,h = gc.get_text_extent(self.label) if color is None: color = self.label_color_ gc.set_fill_color(color) gc.set_stroke_color(color) gc.show_text(self.label, (self.x+(self.width-w-x)/2, self.y+(self.height-h-y)/2)) return def normal_left_down(self, event): self.button_state = "down" self._got_mousedown = True self.request_redraw() event.handled = True return def normal_left_up(self, event): self.button_state = "up" self._got_mousedown = False self.request_redraw() self.perform(event) event.handled = True return class ToolbarButton(Button): toolbar = Any canvas = Delegate("toolbar") def __init__(self, *args, **kw): toolbar = kw.pop("toolbar", None) super(ToolbarButton, self).__init__(*args, **kw) if toolbar: self.toolbar = toolbar toolbar.add(self) return class DrawingCanvasToolbar(Container): """ The tool bar hosts Buttons and also consumes other mouse events, so that tools on the underlying canvas don't get them. FIXME: Right now this toolbar only supports the addition of buttons, and not button removal. (Why would you ever want to remove a useful button?) """ canvas = Instance("DrawingCanvas") button_spacing = Int(5) auto_size = False _last_button_position = Int(0) def add_button(self, *buttons): for button in buttons: self.add(button) button.toolbar = self # Compute the new position for the button button.x = self.button_spacing + self._last_button_position self._last_button_position += button.width + self.button_spacing * 2 button.y = int((self.height - button.height) / 2) return def _canvas_changed(self, old, new): if old: old.on_trait_change(self._canvas_bounds_changed, "bounds", remove=True) old.on_trait_change(self._canvas_bounds_changed, "bounds_items", remove=True) if new: new.on_trait_change(self._canvas_bounds_changed, "bounds") new.on_trait_change(self._canvas_bounds_changed, "bounds_items") return def _canvas_bounds_changed(self): self.width = self.canvas.width self.y = self.canvas.height - self.height return def _dispatch_stateful_event(self, event, suffix): super(DrawingCanvasToolbar, self)._dispatch_stateful_event(event, suffix) event.handled = True return class DrawingCanvas(Container): """ A DrawingCanvas has some buttons which toggle what kind of drawing tools are active on the canvas, then allow arbitrary painting on the canvas. """ # The active tool is the primary interactor on the canvas. It gets # a chance to handle events before they are passed on to other components # and listener tools. active_tool = Any # Listening tools are always enabled and get all events (unless the active # tool has vetoed it), but they cannot prevent other tools from getting events. listening_tools = List # The background color of the canvas bgcolor = ColorTrait("white") toolbar = Instance(DrawingCanvasToolbar, args=()) fit_window = True def dispatch(self, event, suffix): # See if the event happened on the toolbar: event.offset_xy(*self.position) if self.toolbar.is_in(event.x, event.y): self.toolbar.dispatch(event, suffix) event.pop() if event.handled: return if self.active_tool is not None: self.active_tool.dispatch(event, suffix) if event.handled: return for tool in self.listening_tools: tool.dispatch(event, suffix) super(DrawingCanvas, self).dispatch(event, suffix) return def activate(self, tool): """ Makes the indicated tool the active tool on the canvas and moves the current active tool back into the list of tools. """ self.active_tool = tool return def _draw_container_mainlayer(self, gc, view_bounds=None, mode="default"): active_tool = self.active_tool if active_tool and active_tool.draw_mode == "exclusive": active_tool.draw(gc, view_bounds, mode) else: #super(DrawingCanvas, self)._draw(gc, view_bounds, mode) for tool in self.listening_tools: tool.draw(gc, view_bounds, mode) if active_tool: active_tool.draw(gc, view_bounds, mode) self.toolbar.draw(gc, view_bounds, mode) return def _draw_container_background(self, gc, view_bounds=None, mode="default"): if self.bgcolor not in ("clear", "transparent", "none"): with gc: gc.set_antialias(False) gc.set_fill_color(self.bgcolor_) gc.draw_rect((int(self.x), int(self.y), int(self.width)-1, int(self.height)-1), FILL) return #------------------------------------------------------------------------ # Event listeners #------------------------------------------------------------------------ def _tools_items_changed(self): self.request_redraw() return # EOF enthought-chaco2-4.5.1.orig/enable/slider.py0000644000175000017500000004370112516137326017767 0ustar varunvarun from __future__ import with_statement from numpy import linspace, zeros # Enthought library imports from kiva.constants import STROKE from traits.api import (Any, Bool, Enum, Float, Int, Property, on_trait_change, Trait) from traitsui.api import EnumEditor # Local, relative imports from colors import ColorTrait from component import Component from markers import MarkerNameDict, marker_names, CustomMarker slider_marker_names = list(marker_names) + ["rect"] SliderMarkerTrait = Trait("rect", "rect", MarkerNameDict, editor=EnumEditor(values=slider_marker_names)) class Slider(Component): """ A horizontal or vertical slider bar """ #------------------------------------------------------------------------ # Model traits #------------------------------------------------------------------------ min = Float() max = Float() value = Float() # The number of ticks to show on the slider. num_ticks = Int(4) #------------------------------------------------------------------------ # Bar and endcap appearance #------------------------------------------------------------------------ # Whether this is a horizontal or vertical slider orientation = Enum("h", "v") # The thickness, in pixels, of the lines used to render the ticks, # endcaps, and main slider bar. bar_width = Int(4) bar_color = ColorTrait("black") # Whether or not to render endcaps on the slider bar endcaps = Bool(True) # The extent of the endcaps, in pixels. This is a read-only property, # since the endcap size can be set as either a fixed number of pixels or # a percentage of the widget's size in the transverse direction. endcap_size = Property # The extent of the tickmarks, in pixels. This is a read-only property, # since the endcap size can be set as either a fixed number of pixels or # a percentage of the widget's size in the transverse direction. tick_size = Property #------------------------------------------------------------------------ # Slider appearance #------------------------------------------------------------------------ # The kind of marker to use for the slider. slider = SliderMarkerTrait("rect") # If the slider marker is "rect", this is the thickness of the slider, # i.e. its extent in the dimension parallel to the long axis of the widget. # For other slider markers, this has no effect. slider_thickness = Int(9) # The size of the slider, in pixels. This is a read-only property, since # the slider size can be set as either a fixed number of pixels or a # percentage of the widget's size in the transverse direction. slider_size = Property # For slider markers with a filled area, this is the color of the filled # area. For slider markers that are just lines/strokes (e.g. cross, plus), # this is the color of the stroke. slider_color = ColorTrait("red") # For slider markers with a filled area, this is the color of the outline # border drawn around the filled area. For slider markers that have just # lines/strokes, this has no effect. slider_border = ColorTrait("none") # For slider markers with a filled area, this is the width, in pixels, # of the outline around the area. For slider markers that are just lines/ # strokes, this is the thickness of the stroke. slider_outline_width = Int(1) # The kiva.CompiledPath representing the custom path to render for the # slider, if the **slider** trait is set to "custom". custom_slider = Any() #------------------------------------------------------------------------ # Interaction traits #------------------------------------------------------------------------ # Can this slider be interacted with, or is it just a display interactive = Bool(True) mouse_button = Enum("left", "right") event_state = Enum("normal", "dragging") #------------------------------------------------------------------------ # Private traits #------------------------------------------------------------------------ # Returns the coordinate index (0 or 1) corresponding to our orientation. # Used internally; read-only property. axis_ndx = Property() _slider_size_mode = Enum("fixed", "percent") _slider_percent = Float(0.0) _cached_slider_size = Int(10) _endcap_size_mode = Enum("fixed", "percent") _endcap_percent = Float(0.0) _cached_endcap_size = Int(20) _tick_size_mode = Enum("fixed", "percent") _tick_size_percent = Float(0.0) _cached_tick_size = Int(20) # A tuple of (dx, dy) of the difference between the mouse position and # center of the slider. _offset = Any((0,0)) def set_range(self, min, max): self.min = min self.max = max def map_screen(self, val): """ Returns an (x,y) coordinate corresponding to the location of **val** on the slider. """ # Some local variables to handle orientation dependence axis_ndx = self.axis_ndx other_ndx = 1 - axis_ndx screen_low = self.position[axis_ndx] screen_high = screen_low + self.bounds[axis_ndx] # The return coordinate. The return value along the non-primary # axis will be the same in all cases. coord = [0,0] coord[other_ndx] = self.position[other_ndx] + self.bounds[other_ndx]/2 # Handle exceptional/boundary cases if val <= self.min: coord[axis_ndx] = screen_low return coord elif val >= self.max: coord[axis_ndx] = screen_high return coord elif self.min == self.max: coord[axis_ndx] = (screen_low + screen_high) / 2 return coord # Handle normal cases coord[axis_ndx] = (val - self.min) / (self.max - self.min) * self.bounds[axis_ndx] + screen_low return coord def map_data(self, x, y, clip=True): """ Returns a value between min and max that corresponds to the given x and y values. Parameters ========== x, y : Float The screen coordinates to map clip : Bool (default=True) Whether points outside the range should be clipped to the max or min value of the slider (depending on which it's closer to) Returns ======= value : Float """ # Some local variables to handle orientation dependence axis_ndx = self.axis_ndx other_ndx = 1 - axis_ndx screen_low = self.position[axis_ndx] screen_high = screen_low + self.bounds[axis_ndx] if self.orientation == "h": coord = x else: coord = y # Handle exceptional/boundary cases if coord >= screen_high: return self.max elif coord <= screen_low: return self.min elif screen_high == screen_low: return (self.max + self.min) / 2 # Handle normal cases return (coord - screen_low) /self.bounds[axis_ndx] * \ (self.max - self.min) + self.min def set_slider_pixels(self, pixels): """ Sets the width of the slider to be a fixed number of pixels Parameters ========== pixels : int The number of pixels wide that the slider should be """ self._slider_size_mode = "fixed" self._cached_slider_size = pixels def set_slider_percent(self, percent): """ Sets the width of the slider to be a percentage of the width of the slider widget. Parameters ========== percent : float The percentage, between 0.0 and 1.0 """ self._slider_size_mode = "percent" self._slider_percent = percent self._update_sizes() def set_endcap_pixels(self, pixels): """ Sets the width of the endcap to be a fixed number of pixels Parameters ========== pixels : int The number of pixels wide that the endcap should be """ self._endcap_size_mode = "fixed" self._cached_endcap_size = pixels def set_endcap_percent(self, percent): """ Sets the width of the endcap to be a percentage of the width of the endcap widget. Parameters ========== percent : float The percentage, between 0.0 and 1.0 """ self._endcap_size_mode = "percent" self._endcap_percent = percent self._update_sizes() def set_tick_pixels(self, pixels): """ Sets the width of the tick marks to be a fixed number of pixels Parameters ========== pixels : int The number of pixels wide that the endcap should be """ self._tick_size_mode = "fixed" self._cached_tick_size = pixels def set_tick_percent(self, percent): """ Sets the width of the tick marks to be a percentage of the width of the endcap widget. Parameters ========== percent : float The percentage, between 0.0 and 1.0 """ self._tick_size_mode = "percent" self._tick_percent = percent self._update_sizes() #------------------------------------------------------------------------ # Rendering methods #------------------------------------------------------------------------ def _draw_mainlayer(self, gc, view_bounds=None, mode="normal"): start = [0,0] end = [0,0] axis_ndx = self.axis_ndx other_ndx = 1 - axis_ndx bar_x = self.x + self.width / 2 bar_y = self.y + self.height / 2 # Draw the bar and endcaps gc.set_stroke_color(self.bar_color_) gc.set_line_width(self.bar_width) if self.orientation == "h": gc.move_to(self.x, bar_y) gc.line_to(self.x2, bar_y) gc.stroke_path() if self.endcaps: start_y = bar_y - self._cached_endcap_size / 2 end_y = bar_y + self._cached_endcap_size / 2 gc.move_to(self.x, start_y) gc.line_to(self.x, end_y) gc.move_to(self.x2, start_y) gc.line_to(self.x2, end_y) if self.num_ticks > 0: x_pts = linspace(self.x, self.x2, self.num_ticks+2).astype(int) starts = zeros((len(x_pts), 2),dtype=int) starts[:,0] = x_pts starts[:,1] = bar_y - self._cached_tick_size / 2 ends = starts.copy() ends[:,1] = bar_y + self._cached_tick_size / 2 gc.line_set(starts, ends) else: gc.move_to(bar_x, self.y) gc.line_to(bar_x, self.y2) if self.endcaps: start_x = bar_x - self._cached_endcap_size / 2 end_x = bar_x + self._cached_endcap_size / 2 gc.move_to(start_x, self.y) gc.line_to(end_x, self.y) gc.move_to(start_x, self.y2) gc.line_to(end_x, self.y2) if self.num_ticks > 0: y_pts = linspace(self.y, self.y2, self.num_ticks+2).astype(int) starts = zeros((len(y_pts), 2),dtype=int) starts[:,1] = y_pts starts[:,0] = bar_x - self._cached_tick_size / 2 ends = starts.copy() ends[:,0] = bar_x + self._cached_tick_size / 2 gc.line_set(starts, ends) gc.stroke_path() # Draw the slider pt = self.map_screen(self.value) if self.slider == "rect": gc.set_fill_color(self.slider_color_) gc.set_stroke_color(self.slider_border_) gc.set_line_width(self.slider_outline_width) rect = self._get_rect_slider_bounds() gc.rect(*rect) gc.draw_path() else: self._render_marker(gc, pt, self._cached_slider_size, self.slider_(), self.custom_slider) def _get_rect_slider_bounds(self): """ Returns the (x, y, w, h) bounds of the rectangle representing the slider. Used for rendering and hit detection. """ bar_x = self.x + self.width / 2 bar_y = self.y + self.height / 2 pt = self.map_screen(self.value) if self.orientation == "h": slider_height = self._cached_slider_size return (pt[0] - self.slider_thickness, bar_y - slider_height/2, self.slider_thickness, slider_height) else: slider_width = self._cached_slider_size return (bar_x - slider_width/2, pt[1] - self.slider_thickness, slider_width, self.slider_thickness) def _render_marker(self, gc, point, size, marker, custom_path): with gc: gc.begin_path() if marker.draw_mode == STROKE: gc.set_stroke_color(self.slider_color_) gc.set_line_width(self.slider_thickness) else: gc.set_fill_color(self.slider_color_) gc.set_stroke_color(self.slider_border_) gc.set_line_width(self.slider_outline_width) if hasattr(gc, "draw_marker_at_points") and \ (marker.__class__ != CustomMarker) and \ (gc.draw_marker_at_points([point], size, marker.kiva_marker) != 0): pass elif hasattr(gc, "draw_path_at_points"): if marker.__class__ != CustomMarker: path = gc.get_empty_path() marker.add_to_path(path, size) mode = marker.draw_mode else: path = custom_path mode = STROKE if not marker.antialias: gc.set_antialias(False) gc.draw_path_at_points([point], path, mode) else: if not marker.antialias: gc.set_antialias(False) if marker.__class__ != CustomMarker: gc.translate_ctm(*point) # Kiva GCs have a path-drawing interface marker.add_to_path(gc, size) gc.draw_path(marker.draw_mode) else: path = custom_path gc.translate_ctm(*point) gc.add_path(path) gc.draw_path(STROKE) #------------------------------------------------------------------------ # Interaction event handlers #------------------------------------------------------------------------ def normal_left_down(self, event): if self.mouse_button == "left": return self._mouse_pressed(event) def dragging_left_up(self, event): if self.mouse_button == "left": return self._mouse_released(event) def normal_right_down(self, event): if self.mouse_button == "right": return self._mouse_pressed(event) def dragging_right_up(self, event): if self.mouse_button == "right": return self._mouse_released(event) def dragging_mouse_move(self, event): dx, dy = self._offset self.value = self.map_data(event.x - dx, event.y - dy) event.handled = True self.request_redraw() def dragging_mouse_leave(self, event): self.event_state = "normal" def _mouse_pressed(self, event): # Determine the slider bounds so we can hit test it pt = self.map_screen(self.value) if self.slider == "rect": x, y, w, h = self._get_rect_slider_bounds() x2 = x + w y2 = y + h else: x, y = pt size = self._cached_slider_size x -= size/2 y -= size/2 x2 = x + size y2 = y + size # Hit test both the slider and against the bar. If the user has # clicked on the bar but outside of the slider, we set the _offset # and call dragging_mouse_move() to teleport the slider to the # mouse click position. if self.orientation == "v" and (x <= event.x <= x2): if not (y <= event.y <= y2): self._offset = (event.x - pt[0], 0) self.dragging_mouse_move(event) else: self._offset = (event.x - pt[0], event.y - pt[1]) elif self.orientation == "h" and (y <= event.y <= y2): if not (x <= event.x <= x2): self._offset = (0, event.y - pt[1]) self.dragging_mouse_move(event) else: self._offset = (event.x - pt[0], event.y - pt[1]) else: # The mouse click missed the bar and the slider. return event.handled = True self.event_state = "dragging" return def _mouse_released(self, event): self.event_state = "normal" event.handled = True #------------------------------------------------------------------------ # Private trait event handlers and property getters/setters #------------------------------------------------------------------------ def _get_axis_ndx(self): if self.orientation == "h": return 0 else: return 1 def _get_slider_size(self): return self._cached_slider_size def _get_endcap_size(self): return self._cached_endcap_size def _get_tick_size(self): return self._cached_tick_size @on_trait_change("bounds,bounds_items") def _update_sizes(self): if self._slider_size_mode == "percent": if self.orientation == "h": self._cached_slider_size = int(self.height * self._slider_percent) else: self._cached_slider_size = int(self.width * self._slider_percent) if self._endcap_size_mode == "percent": if self.orientation == "h": self._cached_endcap_size = int(self.height * self._endcap_percent) else: self._cached_endcap_size = int(self.width * self._endcap_percent) return enthought-chaco2-4.5.1.orig/enable/native_scrollbar.py0000644000175000017500000000152112516137326022030 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2005, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # # Author: Enthought, Inc. # Description: #------------------------------------------------------------------------------ # Import the toolkit specific version. from toolkit import toolkit_object NativeScrollBar = toolkit_object('NativeScrollBar') #### EOF ###################################################################### enthought-chaco2-4.5.1.orig/enable/simple_layout.py0000644000175000017500000000620412516137326021370 0ustar varunvarun"""Helper functions for a simple layout algorithm -- the same one used by OverlayPlotContainer. Designed to be called from a container, but separated out because they are useful from ViewPort and Container""" def simple_container_get_preferred_size(container, components=None): """ Returns the size (width,height) that is preferred for this component. Overrides PlotComponent. """ if container.fixed_preferred_size is not None: return container.fixed_preferred_size if container.resizable == "": return container.outer_bounds if components is None: components = container.components fit_components = getattr(container, "fit_components", "") # this is used to determine if we should use our default bounds no_visible_components = True max_width = 0.0 max_height = 0.0 if fit_components != "": for component in components: if not container._should_layout(component): continue no_visible_components = False pref_size = None if "h" in fit_components: pref_size = component.get_preferred_size() if pref_size[0] > max_width: max_width = pref_size[0] if "v" in fit_components: if pref_size is None: pref_size = component.get_preferred_size() if pref_size[1] > max_height: max_height = pref_size[1] if "h" not in fit_components: max_width = container.width if no_visible_components or (max_width == 0): max_width = container.default_size[0] if "v" not in fit_components: max_height = container.height if no_visible_components or (max_height == 0): max_height = container.default_size[1] # Add in our padding and border container._cached_preferred_size = (max_width + container.hpadding, max_height + container.vpadding) return container._cached_preferred_size def simple_container_do_layout(container, components=None): """ Actually performs a layout (called by do_layout()). """ if components is None: components = container.components x = container.x y = container.y width = container.width height = container.height for component in components: if hasattr(container, '_should_layout'): if not container._should_layout(component): continue position = list(component.outer_position) bounds = list(component.outer_bounds) if "h" in component.resizable: position[0] = 0 bounds[0] = width if "v" in component.resizable: position[1] = 0 bounds[1] = height # Set both bounds at once. This is a slight perforance fix because # it only fires two trait events instead of four. It is also needed # in order for the event-based aspect ratio enforcement code to work. component.outer_position = position component.outer_bounds = bounds # Tell all of our components to do a layout for component in components: component.do_layout() return enthought-chaco2-4.5.1.orig/enable/images/0000755000175000017500000000000012516137725017376 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/images/left_align.gif0000644000175000017500000000143612516137326022172 0ustar varunvarunGIF89a<æþþþúúúÅÅþ||ýææÿddüNNûÂÂöééó••üýòòòöööYYü$$úrróÈÈê­­ð’’ùýæææêêêîîî==ü}}òÚÚÚü¥¥èÞÞÞâââõõýkkûýJJøÒÒð==ù ý22ñ::ïþúçÖÖÖTTý88ûžží¢¢çPPï##üÞÞä——çEEì~~ÐþWWࢢÎ÷ÜÜø»»ç¹¹Ø´´Ó­­Ì÷ÞÎÎÎjjܽ½½ úŽŽÑÆÆÆ²²öffÛÀÀÀ¶¶óÂÂÕ··ÆººÉÁÁÇooáËËË––ÙááíwwéÇÇØ¢¢Ùœœà55ôƒƒèJJî--öÑÑ×qqðff嬬Ýiié^^넄㊊鰰ãbbí,<ÿ€‚ƒ„…†‡ˆ‰Š†Ž‘’“”•Ž‚–™š›“˜œŸ ”ž¡¥¡ ž¥– §œž ­” ½µ•ž ”ÅÇÈÊÏ !"# $%&'()*ÙÚ’˜Þ)+à ,-.^Àˆ!cF 5jظCƒ…qö áS¶Bƒ‡~:lìàÑÃÇ AL2¤D#+FŒ„/…}AA³&’!"“”<éâÊFõi @‰%L’6qbÄÄ“ P6D Ò¡ÞO Ü¸„ÙOJ‰)F‚P9Q%ä +6XéiìêDWƒâ^qP YBhÙ²ÂÄY ?´¡×ö'>º(î‚¥¢—/`Âlé A̘ÆÒAåU¬X@dL”+zWY2*8û ºÛ… L[´ÀÛƒ†²/èÒu[xá•£0¸Ð [âÍvñâ%àyŸn¹Ñþ€!b‰Lœ@ʈR¨PÁÁá l»~DY"B´p!â bÈQÆG'´¨aC8rè@`ïǰ;xôèáF„@‚Qa#Â"BŠ„91¡È$I"(Y¤‰':·t¶ˆñ"7šôˆÂBÊ”Tªa‡W„`É¢¥Èœ\ºDÿ‰rB€gŽž´‚ÅK…#,¢Œ3%™2㣘é&É™íhÑÃáÜy¥WA|X¤Q„€­1ÅL°!ßLHÁÂm0D[ˆÀE,Œ ‚p.^ ñwFp„ auÈEDÈ6‡#ˆ@‚w!LD` HœX=FGu„@ŸvÜQxàà I´˜@æ¡Ç"p† Fð±F'¨€}øA è@‚‚¸ÀƒBH:è`È!: RÅu*˜7q¨‰WœpB!sÕ‘Q¤‡Qˆ ÃZ(tŠ‚ 'ô)æ¡+dÕ[`ði[ŠTpC E,CÂH!°eÕ­ª~zÕ˜ ¢„WÀbÐ Ž<’ !ÐÅUTÀp•‘)f”ê diªBWñ­C©zÚV-$î¸ä.;enthought-chaco2-4.5.1.orig/enable/images/top_left_position.gif0000644000175000017500000000064312516137326023625 0ustar varunvarunGIF89a<ÕÀÀÀêêêòüÿÿÿÿ@@@%ÒþÏÿäó÷ûûûÜëïööö$Òþ¯¾ÂÞÞÞ!Îú‚‘•ÅÅÅ–ÌÙl§¶e ®]˜§aœ«‰ŽÜÜܸ¸¸²²²ªªª®®®ÛÛÛííí×××ÓÓÓééé,<È@@`H,ȤrI™Ð¨é جv[èz¿à°xì5ªƒbÍn· ²|.6£ÕîüzÁ ûévBizzˆcV„y‰’_‹Žm“›•—˜kš›’Ÿl¡¢ˆ•®¯°‘¨©g‚½¾¿¶·h !ËÌÍ! Å• ØÙÚÚ}Ó€¸VÞâeàÒãâ•çèåêÞéíÅóôõö÷øùúûôUSÿ•H° Áƒ*\x0;enthought-chaco2-4.5.1.orig/enable/images/5_weight.gif0000644000175000017500000000012512516137326021573 0ustar varunvarunGIF89a<€ÿÿÿ,<4„©Ëí£œ´Ú‹³Þ¼û†âHVÁ‰¦êʶ®ê¼òL§qçv£÷x ‡Ä¢ñˆL*—Ä;enthought-chaco2-4.5.1.orig/enable/images/1_weight.gif0000644000175000017500000000011412516137326021565 0ustar varunvarunGIF89a<€ÿÿÿ,<+„©Ëí£œ´Ú‹³Þ¼û†âH–æyêʶî Ç-J×öçúÎ÷þt;enthought-chaco2-4.5.1.orig/enable/images/4_weight.gif0000644000175000017500000000012512516137326021572 0ustar varunvarunGIF89a<€ÿÿÿ,<4„©Ëí£œ´Ú‹³Þ¼û†âHVÁ‰¦êʶ®ê¼òL§qçv£÷x ‡Ä¢ñˆL*—Ä;enthought-chaco2-4.5.1.orig/enable/images/0_weight.gif0000644000175000017500000000010412516137326021563 0ustar varunvarunGIF89a<€ÿÿÿ,<#„©Ëí£œ´Ú‹³Þ¼û†âH–扦êʶî ÇòL×v\;enthought-chaco2-4.5.1.orig/enable/images/bottom_left_position.gif0000644000175000017500000000063212516137326024325 0ustar varunvarunGIF89a<ÕÀÀÀêêêÿÿÿ@@@òüÿ%ÒþÏÿäó÷ûûûÜëï÷÷÷$Òþ¯¾ÂÞÞÞ!Îú‚‘•ÅÅÅ–ÌÙl§¶e ®]˜§aœ«‰ŽÜÜܸ¸¸²²²ªªª®®®:::666555444,<¿@@`H,ȤrI™Ð¨é جvËíz¿ßB z›Ï讘œn»ÃcaùM¯åõ|ûnÕûÍ|sƒZ‡ˆ‰Š„i‘’’ Œ€qV“œ —`Ž¡pd¤œ¨^«¬’®°j™³´¶·[²¼‘¾¿YËÌͯÅƹÙÚÛ§ÓXwçèéé!äîïðñòóïUS÷øJûüýþÿ ø/;enthought-chaco2-4.5.1.orig/enable/images/center_align.gif0000644000175000017500000000261312516137326022516 0ustar varunvarunGIF89a<÷þþþúúúÚÚþzzþNNúVVúššöòòòöööææþššúþBBúrròZZö þFFöææêFFþ––úÖÖþŽŽòÞÞÞÖÖÖ®®Ú‚‚îæææîîî..þ’’öjjþ22úÚÚÚ’’ê®®âêêê––ö&&þþ®®òbbþvvúRRú""ú¦¦ò^^öþúffêâââÒÒîþfföææîÆÆöZZú~~ö66þjjòÒÒÒªªêrræ²²ÞJJòvvâFFòþúNNêššÒÊÊÒúVVö¦¦êššê22ö¶¶îNNöžžæººæ**ú¾¾Ú²²Ö®®ÎRRêNNîÂÂÚÎÎÎ&&özzÞÆÆÆ††ÞººÚ¶¶Ò²²ÒžžÎÂÂÖ¦¦Þ::öbbòúúþ..î¾¾¾>>î^^êÊÊʶ¶ÎÆÆÊ&&òvvÚbbâ––ÎvvöbbúFFúŽŽâººÊ¶¶ÆÆÆÞjjæ22ò²²Âjjê¾¾þ>>òÂÂÂZZêvvâÖÖîÂÂÞ""ö~~⢢ڞžÒªªÞ66òÆÆÒžžÖžžîNNòBBî66î~~æzz梢޾¾ÖŽŽæÒÒÞbbê––Þ,<ÿH° Áƒ*4 ¡Ã‡#JœH±¢C3jÜ8#Ç )z¬( ¤€(!Ž”8€@$© eÕ0hàà„drœ@!ÁI”8V``á hØÀafF$@Œ0@H#d¼ „SÀÄZŽ<¹A”ƒðð!ðpi8W¾Ü˜}€à 1HÂC˜`1©“„%Bœgƒ•`P…%fq‰%–\by˜pŨ„!@™§eYFÂ2e– ¨µ•q•]`ìXc•%òjYE«Dg’`lpTÕw«eTm•À¶·«ZÁÊŸ°Å¥÷£ Ù- [¤nq2eÔ£Û&—½öWU½%‘iÓ¿¡ ðÀê-dðÁ';enthought-chaco2-4.5.1.orig/enable/images/3_weight.gif0000644000175000017500000000012312516137326021567 0ustar varunvarunGIF89a<€ÿÿÿ,<2„©Ëí£œ´Ú‹³Þ¼û†âH–¦¤êÊ¶î ³hL×¶:ßúŽŸþ ‡Ä¢ñˆL> ;enthought-chaco2-4.5.1.orig/enable/images/image_LICENSE.txt0000644000175000017500000000213112516137326022355 0ustar varunvarunThese are my best guesses at where each icon came from, this file should be updated whenever icons change. filename source -------------------------------------------------------------- 0_weight.gif D. Morrill 1_weight.gif D. Morrill 2_weight.gif D. Morrill 3_weight.gif D. Morrill 4_weight.gif D. Morrill 5_weight.gif D. Morrill 6_weight.gif D. Morrill 7_weight.gif D. Morrill 8_weight.gif D. Morrill bottom_center_position.gif D. Morrill bottom_left_position.gif D. Morrill bottom_right_position.gif D. Morrill center_align.gif D. Morrill center_left_position.gif D. Morrill center_position.gif D. Morrill center_right_position.gif D. Morrill left_align.gif D. Morrill right_align.gif D. Morrill top_center_position.gif D. Morrill top_left_position.gif D. Morrill top_right_position.gif D. Morrill enthought-chaco2-4.5.1.orig/enable/images/bottom_right_position.gif0000644000175000017500000000063212516137326024510 0ustar varunvarunGIF89a<ÕÀÀÀêêêÿÿÿ@@@òüÿ%ÒþÏÿäó÷ûûûÜëï÷÷÷$Òþ¯¾ÂÞÞÞ!Îú‚‘•ÅÅÅ–ÌÙl§¶e ®]˜§aœ«‰ŽÜÜܸ¸¸²²²ªªª®®®:::666555444,<¿@@`H,ȤrI™Ð¨é جvËíz¿ßB z›Ï讘œn»ÃcaùM¯åõ|ûnÕûÍ|sƒZ„g‰Š‹ŒX†‡`“”•• ^’–ž“ š›\Ÿ–£¤Z§ž«¬X®¯•±³´¶·“¹q}´[¼½¿lÂZÍÎϲÀ‚ÈÛÜݪqäåæçèéêåîïðð!äUS÷øJûüýþÿ ø/;enthought-chaco2-4.5.1.orig/enable/images/center_left_position.gif0000644000175000017500000000064312516137326024303 0ustar varunvarunGIF89a<ÕÀÀÀêêêÿÿÿ@@@òüÿ%ÒþÏÿäó÷ûûûÜëïööö$Òþ¯¾ÂÞÞÞ!Îú‚‘•ÅÅÅ–ÌÙl§¶e ®]˜§aœ«‰ŽÜÜܸ¸¸²²²ªªª®®®ÛÛÛííí×××ÓÓÓééé,<È@@`H,ȤrI™Ð¨é جvËíz¿ßB z›Ï讘œn»ÃcáÀ@¯Ûïï¼v-? þ€ zy|V~‚‹ †oˆŠŒ‚n’•‹™m›‚Ÿ¡i£¤€¦§g©ª¬­`’¹º» ³´qVÈÉÊÁÂd !Öר! eÐjà äåææÞßlê¡’íîqóôõö÷øùúûôUSÿ•H° Áƒ*\x0;enthought-chaco2-4.5.1.orig/enable/images/top_center_position.gif0000644000175000017500000000065512516137326024156 0ustar varunvarunGIF89a<ÕÀÀÀêêêÿÿÿòüÿ@@@%ÒþÏÿäó÷ûûûÜëïööö$Òþ¯¾ÂÞÞÞ!Îú‚‘•ÅÅÅ–ÌÙl§¶e ®]˜§aœ«‰ŽÜÜܸ¸¸²²²ªªª®®®ÛÛÛííí×××ÓÓÓééé,<Ò@@`H,ȤrI™Ð¨é جv›-x¿à0wL6ªW²ú€h»ßï„BM7£éd6|ß^0ðegBi€Zz|p…\vƒŒZˆ{ZŽV—X’“o•›X™„žm ¡£¡¦§©›«›¶·¸–ª‚š›ÅÆÇ¡±— !ÔÕÖ! ¤Ï áâãã¾wÍéŒÝêícìîñ¢¿ÛòñðöíŽüýþÿ H°_•)*À°¡Ã‡#JœHb;enthought-chaco2-4.5.1.orig/enable/images/center_right_position.gif0000644000175000017500000000064512516137326024470 0ustar varunvarunGIF89a<ÕÀÀÀêêêÿÿÿ@@@òüÿ%ÒþÏÿäó÷ûûûÜëïööö$Òþ¯¾ÂÞÞÞ!Îú‚‘•ÅÅÅ–ÌÙl§¶e ®]˜§aœ«‰ŽÜÜܸ¸¸²²²ªªª®®®ÛÛÛííí×××ÓÓÓééé,<Ê@@`H,ȤrI™Ð¨é جvËíz¿ßB z›Ï讘œn»ÃcaùM7Øïø old: for i in range(old, new): self._add_row(i) else: for i in range(new, old): self._remove_row(i) self.request_redraw() def _columns_changed(self, old, new): if new > old: for i in range(old, new): self._add_column(i) else: for i in range(new, old): self._remove_column(i) self.request_redraw() def _cells_changed(self, new): self.request_redraw() # Test if __name__ == '__main__': from enable.wx_backend.api import Window from enable.api import Container from enable.example_support import DemoFrame, demo_main class MyFrame(DemoFrame): def _create_window(self): box1 = TextFieldGrid(4, 2, position=[50, 300]) box1.set_cell(1,1,"apple") box1.set_cell(0,3,"pear") container = Container(bounds=[800,600], use_backbuffer=False) container.add(box1) return Window(self, -1, size=[800, 600], component=container) demo_main(MyFrame) enthought-chaco2-4.5.1.orig/enable/graphics_context.py0000644000175000017500000000720212516137326022045 0ustar varunvarun from __future__ import with_statement from kiva.constants import FILL # Relative imports from abstract_window import AbstractWindow from base import bounding_coordinates, coordinates_to_bounds from kiva_graphics_context import GraphicsContext class EnableGCMixin(object): """ Subclass of Kiva GraphicsContext that provides a few more utility methods. Most importantly, it provides a pointer back to the window that this GC is being drawn to. This will eventually be deprecated as the follow methods are folded into Kiva or their use is discontinuted in Enable. """ # The window that this GraphicsContext is being drawn to. It is OK to leave # this as None if the graphics context is used as a backbuffer; however, in # such cases, it is more appropriate to use a GC from Kiva directly as opposed # to using the Enable one, as some draw methods may need to parent controls # or dialogs from the Window. window = None #Instance(AbstractWindow) def __init__(self, *args, **kwargs): if kwargs.has_key("window"): self.window = kwargs.pop("window") super(EnableGCMixin, self).__init__(*args, **kwargs) return def clip_to_rect(self, x, y, width, height): if getattr(self, "corner_pixel_origin", True): super(EnableGCMixin, self).clip_to_rect(x-0.5, y-0.5, width+1, height+1) else: super(EnableGCMixin, self).clip_to_rect(x, y, width, height) def clear_clip(self, color, coordinates): "Clip and clear a Kiva graphics context to a specified area and color" bounds = coordinates_to_bounds(coordinates) self.clip_to_rect(*bounds) self.set_fill_color(color) self.draw_rect(bounds, FILL) return def clear_clip_region(self, color, update_region): "Clip and clear a Kiva graphics context to a specified region and color" bounds = coordinates_to_bounds(bounding_coordinates(update_region)) self.clip_to_rect(*bounds) self.set_fill_color(color) for coordinates in update_region: bounds = coordinates_to_bounds(coordinates) self.begin_path() self.rect(*bounds) self.fill_path() return def alpha(self, alpha): raise NotImplementedError, \ "The alpha() method is not compatible with DisplayPDF; use clear() instead." def stretch_draw(self, image, x, y, dx, dy): "Draws an image 'stretched' to fit a specified area" idx = image.width() idy = image.height() with self: self.clip_to_rect(x, y, dx, dy) cx, cy, cdx, cdy = x, y, dx, dy yt = cy + cdy xr = cx + cdx x += (int(cx - x) / idx) * idx y += (int(cy - y) / idy) * idy while y < yt: x0 = x while x0 < xr: self.draw_image(image,(x0, y, idx, idy)) x0 += idx y += idy return # Define a GraphicsContextEnable that subclasses whatever the Kiva backend's # GraphicsContext is. class GraphicsContextEnable(EnableGCMixin, GraphicsContext): pass # Define an ImageGraphicsContextEnable that is guaranteed to be a subclass of # an ImageGraphicsContext, regardless of the actual Kiva backend. If the kiva # backend is already the GraphicsContextImage, then just create an alias. from kiva.image import GraphicsContext as GraphicsContextImage if isinstance(GraphicsContext, GraphicsContextImage): ImageGraphicsContextEnable = GraphicsContextEnable else: class ImageGraphicsContextEnable(EnableGCMixin, GraphicsContextImage): pass enthought-chaco2-4.5.1.orig/enable/scroll_handler.py0000644000175000017500000000215112516137326021472 0ustar varunvarun""" Interface for scroll handlers. """ class ScrollHandler: """ The interface for scroll handlers. A scroll handler handles the scroll events generated by scrollbar events in a Scrolled component. By default, a Scrolled will serve as its own ScrollHandler. In that role, Scrolled will merely move and clip the child component. If a component wishes to manage its own scrolling, it may do so, by implementing this interface and attaching itself as its parent's scroll manager. """ def handle_vertical_scroll(self, position): """ Called when the vertical scroll position has changed. The position parameter will be the current position of the vertical scroll bar. """ raise NotImplementedError def handle_horizontal_scroll(self, position): """ Called when the horizontal scroll position has changed. The position parameter will be the current position of the horizontal scroll bar. """ raise NotImplementedError #### EOF ###################################################################### enthought-chaco2-4.5.1.orig/enable/component_editor.py0000644000175000017500000000640512516137326022055 0ustar varunvarun""" Defines a Traits editor for displaying an Enable component. """ #------------------------------------------------------------------------------- # Written by: David C. Morrill # Date: 01/26/2007 # (c) Copyright 2007 by Enthought, Inc. #---------------------------------------------------------------------------- from enable.colors import ColorTrait from enable.window import Window from traits.etsconfig.api import ETSConfig from traits.api import Property, Tuple from traitsui.api import BasicEditorFactory if ETSConfig.toolkit == 'wx': from traitsui.wx.editor import Editor elif ETSConfig.toolkit == 'qt4': from traitsui.qt4.editor import Editor else: Editor = object class _ComponentEditor( Editor ): #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- # The plot editor is scrollable (overrides Traits UI Editor). scrollable = True def init( self, parent ): """ Finishes initializing the editor by creating the underlying toolkit widget. """ size = self._get_initial_size() self._window = Window(parent, size=size, component=self.value) self.control = self._window.control self._window.bgcolor = self.factory.bgcolor self._parent = parent def dispose(self): """ Disposes of the contents of an editor. """ self._window.cleanup() self._window = None self._parent = None super(_ComponentEditor, self).dispose() def update_editor( self ): """ Updates the editor when the object trait changes externally to the editor. """ self._window.component = self.value return def _get_initial_size(self): """ Compute the initial size of the component. Use the item size to set the size of the component; if not specified, use the default size given in ComponentEditor.size """ width = self.item.width if width < 0: width = self.factory.size[0] height = self.item.height if height < 0: height = self.factory.size[1] return width, height class ComponentEditor( BasicEditorFactory ): """ wxPython editor factory for Enable components. """ #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- # The class used to create all editor styles (overrides BasicEditorFactory). klass = _ComponentEditor # The background color for the window bgcolor = ColorTrait('sys_window') # The default size of the Window wrapping this Enable component size = Tuple((400,400)) # Convenience function for accessing the width width = Property # Convenience function for accessing the width height = Property def _get_width(self): return self.size[0] def _set_width(self, width): self.size = (width, self.size[1]) def _get_height(self): return self.size[1] def _set_height(self, height): self.size = (self.size[0], height) enthought-chaco2-4.5.1.orig/enable/base.py0000644000175000017500000002154312516137326017417 0ustar varunvarun""" Define a base set of constants and functions used by the remainder of the Enable package. """ #------------------------------------------------------------------------------- # Functions defined: bounding_box # intersect_coordinates # union_coordinates # intersect_bounds # union_bounds # disjoint_intersect_coordinates # does_disjoint_intersect_coordinates # bounding_coordinates # bounds_to_coordinates # coordinates_to_bounds # coordinates_to_size # add_rectangles # xy_in_bounds # gc_image_for # send_event_to # subclasses_of #------------------------------------------------------------------------------- from __future__ import generators # Major library imports # Enthought library imports from traits.api import TraitError from kiva.constants import DEFAULT, DECORATIVE, ROMAN, SCRIPT, SWISS,\ MODERN, NORMAL, BOLD, ITALIC from kiva.fonttools import Font from colors import color_table, transparent_color # Special 'empty rectangle' indicator: empty_rectangle = -1 # Used to offset positions by half a pixel and bounding width/height by 1. # TODO: Resolve this in a more intelligent manner. half_pixel_bounds_inset = ( 0.5, 0.5, -1.0, -1.0 ) # Positions: TOP = 32 VCENTER = 16 BOTTOM = 8 LEFT = 4 HCENTER = 2 RIGHT = 1 TOP_LEFT = TOP + LEFT TOP_RIGHT = TOP + RIGHT BOTTOM_LEFT = BOTTOM + LEFT BOTTOM_RIGHT = BOTTOM + RIGHT #------------------------------------------------------------------------------- # Helper font functions #------------------------------------------------------------------------------- font_families = { 'default': DEFAULT, 'decorative': DECORATIVE, 'roman': ROMAN, 'script': SCRIPT, 'swiss': SWISS, 'modern': MODERN } font_styles = {'italic': ITALIC} font_weights = {'bold': BOLD} font_noise = [ 'pt', 'point', 'family' ] def str_to_font ( object, name, value ): "Converts a (somewhat) free-form string into a valid Font object." # FIXME: Make this less free-form and more well-defined. try: point_size = 10 family = SWISS style = NORMAL weight = NORMAL underline = 0 face_name = [] for word in value.split(): lword = word.lower() if font_families.has_key( lword ): family = font_families[ lword ] elif font_styles.has_key( lword ): style = font_styles[ lword ] elif font_weights.has_key( lword ): weight = font_weights[ lword ] elif lword == 'underline': underline = 1 elif lword not in font_noise: try: point_size = int( lword ) except: face_name.append( word ) return Font(face_name = " ".join(face_name), size = point_size, family = family, weight = weight, style = style, underline = underline) except: pass raise TraitError, ( object, name, 'a font descriptor string', repr( value ) ) str_to_font.info = ( "a string describing a font (e.g. '12 pt bold italic " + "swiss family Arial' or 'default 12')" ) # Pick a default font that should work on all platforms. default_font_name = 'modern 10' default_font = str_to_font( None, None, default_font_name ) def bounding_box ( components ): "Compute the bounding box for a set of components" bxl, byb, bxr, byt = bounds_to_coordinates( components[0].bounds ) for component in components[1:]: xl, yb, xr, yt = bounds_to_coordinates( component.bounds ) bxl = min( bxl, xl ) byb = min( byb, yb ) bxr = max( bxr, xr ) byt = max( byt, yt ) return ( bxl, byb, bxr, byt ) def intersect_coordinates ( coordinates1, coordinates2 ): "Compute the intersection of two coordinate based rectangles" if (coordinates1 is empty_rectangle) or ( coordinates2 is empty_rectangle): return empty_rectangle xl1, yb1, xr1, yt1 = coordinates1 xl2, yb2, xr2, yt2 = coordinates2 xl = max( xl1, xl2 ) yb = max( yb1, yb2 ) xr = min( xr1, xr2 ) yt = min( yt1, yt2 ) if (xr > xl) and (yt > yb): return ( xl, yb, xr, yt ) return empty_rectangle def intersect_bounds ( bounds1, bounds2 ): "Compute the intersection of two bounds rectangles" if (bounds1 is empty_rectangle) or (bounds2 is empty_rectangle): return empty_rectangle intersection = intersect_coordinates( bounds_to_coordinates( bounds1 ), bounds_to_coordinates( bounds2 ) ) if intersection is empty_rectangle: return empty_rectangle xl, yb, xr, yt = intersection return ( xl, yb, xr - xl, yt - yb ) def union_coordinates ( coordinates1, coordinates2 ): "Compute the union of two coordinate based rectangles" if coordinates1 is empty_rectangle: return coordinates2 elif coordinates2 is empty_rectangle: return coordinates1 xl1, yb1, xr1, yt1 = coordinates1 xl2, yb2, xr2, yt2 = coordinates2 return ( min( xl1, xl2 ), min( yb1, yb2 ), max( xr1, xr2 ), max( yt1, yt2 ) ) def union_bounds ( bounds1, bounds2 ): "Compute the union of two bounds rectangles" xl, yb, xr, yt = union_coordinates( bounds_to_coordinates( bounds1 ), bounds_to_coordinates( bounds2 ) ) if xl is None: return empty_rectangle return ( xl, yb, xr - xl, yt - yb ) def does_disjoint_intersect_coordinates ( coordinates_list, coordinates ): "Return whether a rectangle intersects a disjoint set of rectangles anywhere" # If new rectangle is empty, the result is empty: if coordinates is empty_rectangle: return False # If we have an 'infinite' area, then return the new rectangle: if coordinates_list is None: return True # Intersect the new rectangle against each rectangle in the list until an # non_empty intersection is found: xl1, yb1, xr1, yt1 = coordinates for xl2, yb2, xr2, yt2 in coordinates_list: if ((min( xr1, xr2 ) > max( xl1, xl2 )) and (min( yt1, yt2 ) > max( yb1, yb2 ))): return True return False def bounding_coordinates ( coordinates_list ): "Return the bounding rectangle for a list of rectangles" if coordinates_list is None: return None if len( coordinates_list ) == 0: return empty_rectangle xl, yb, xr, yt = 1.0E10, 1.0E10, -1.0E10, -1.0E10 for xl1, yb1, xr1, yt1 in coordinates_list: xl = min( xl, xl1 ) yb = min( yb, yb1 ) xr = max( xr, xr1 ) yt = max( yt, yt1 ) return ( xl, yb, xr, yt ) def bounds_to_coordinates ( bounds ): "Convert a bounds rectangle to a coordinate rectangle" x, y, dx, dy = bounds return ( x, y, x + dx, y + dy ) def coordinates_to_bounds ( coordinates ): "Convert a coordinates rectangle to a bounds rectangle" xl, yb, xr, yt = coordinates return ( xl, yb, xr - xl, yt - yb ) def coordinates_to_size ( coordinates ): "Convert a coordinates rectangle to a size tuple" xl, yb, xr, yt = coordinates return ( xr - xl, yt - yb ) def add_rectangles ( rectangle1, rectangle2 ): "Add two bounds or coordinate rectangles" return ( rectangle1[0] + rectangle2[0], rectangle1[1] + rectangle2[1], rectangle1[2] + rectangle2[2], rectangle1[3] + rectangle2[3] ) def xy_in_bounds ( x, y, bounds ): "Test whether a specified (x,y) point is in a specified bounds" x0, y0, dx, dy = bounds return (x0 <= x < x0 + dx) and (y0 <= y < y0 + dy) def send_event_to ( components, event_name, event ): "Send an event to a specified set of components until it is 'handled'" pre_event_name = 'pre_' + event_name for component in components: setattr( component, pre_event_name, event ) if event.handled: return len( components ) for i in xrange( len( components ) - 1, -1, -1 ): setattr( components[i], event_name, event ) if event.handled: return i return 0 def subclasses_of ( klass ): "Generate all of the classes (and subclasses) for a specified class" yield klass for subclass in klass.__bases__: for result in subclasses_of( subclass ): yield result return class IDroppedOnHandler: "Interface for draggable objects that handle the 'dropped_on' event" def was_dropped_on ( self, component, event ): raise NotImplementedError enthought-chaco2-4.5.1.orig/enable/layout/0000755000175000017500000000000012516137725017446 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/layout/utils.py0000644000175000017500000000234512516137326021161 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2013, Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ STRENGTHS = set(['required', 'strong', 'medium', 'weak']) def add_symbolic_constraints(namespace): """ Add constraints to a namespace that are LinearExpressions of basic constraints. """ bottom = namespace.bottom left = namespace.left width = namespace.layout_width height = namespace.layout_height namespace.right = left + width namespace.top = bottom + height namespace.h_center = left + width / 2.0 namespace.v_center = bottom + height / 2.0 def add_symbolic_contents_constraints(namespace): """ Add constraints to a namespace that are LinearExpressions of basic constraints. """ left = namespace.contents_left right = namespace.contents_right top = namespace.contents_top bottom = namespace.contents_bottom namespace.contents_width = right - left namespace.contents_height = top - bottom namespace.contents_v_center = bottom + namespace.contents_height / 2.0 namespace.contents_h_center = left + namespace.contents_width / 2.0 enthought-chaco2-4.5.1.orig/enable/layout/__init__.py0000644000175000017500000000000012516137326021542 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/layout/api.py0000644000175000017500000000053012516137326020564 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2013, Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ from .layout_helpers import (horizontal, vertical, hbox, vbox, align, grid, spacer, expand_constraints, is_spacer) enthought-chaco2-4.5.1.orig/enable/layout/linear_symbolic.py0000644000175000017500000000102312516137326023164 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2014, Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ from abc import ABCMeta import kiwisolver as kiwi class LinearSymbolic(object): """ An abstract base class for testing linear symbolic interfaces. """ __metaclass__ = ABCMeta LinearSymbolic.register(kiwi.Variable) LinearSymbolic.register(kiwi.Term) LinearSymbolic.register(kiwi.Expression) enthought-chaco2-4.5.1.orig/enable/layout/layout_manager.py0000644000175000017500000002072612516137326023033 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2013, Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ from contextlib import contextmanager import kiwisolver as kiwi class LayoutManager(object): """ A class which uses a kiwi solver to manage a system of constraints. """ def __init__(self): self._solver = kiwi.Solver() self._edit_stack = [] self._initialized = False self._running = False def initialize(self, constraints): """ Initialize the solver with the given constraints. Parameters ---------- constraints : Iterable An iterable that yields the constraints to add to the solvers. """ if self._initialized: raise RuntimeError('Solver already initialized') solver = self._solver for cn in constraints: solver.addConstraint(cn) self._initialized = True def replace_constraints(self, old_cns, new_cns): """ Replace constraints in the solver. Parameters ---------- old_cns : list The list of kiwi constraints to remove from the solver. new_cns : list The list of kiwi constraints to add to the solver. """ if not self._initialized: raise RuntimeError('Solver not yet initialized') solver = self._solver for cn in old_cns: solver.removeConstraint(cn) for cn in new_cns: solver.addConstraint(cn) def layout(self, cb, width, height, size, strength=kiwi.strength.medium): """ Perform an iteration of the solver for the new width and height constraint variables. Parameters ---------- cb : callable A callback which will be called when new values from the solver are available. This will be called from within a solver context while the solved values are valid. Thus the new values should be consumed before the callback returns. width : Constraint Variable The constraint variable representing the width of the main layout container. height : Constraint Variable The constraint variable representing the height of the main layout container. size : (int, int) The (width, height) size tuple which is the current size of the main layout container. strength : kiwisolver strength, optional The strength with which to perform the layout using the current size of the container. i.e. the strength of the resize. The default is kiwisolver.strength.medium. """ if not self._initialized: raise RuntimeError('Layout with uninitialized solver') if self._running: return try: self._running = True w, h = size solver = self._solver pairs = ((width, strength), (height, strength)) with self._edit_context(pairs): solver.suggestValue(width, w) solver.suggestValue(height, h) solver.updateVariables() cb() finally: self._running = False def get_min_size(self, width, height, strength=kiwi.strength.medium): """ Run an iteration of the solver with the suggested size of the component set to (0, 0). This will cause the solver to effectively compute the minimum size that the window can be to solve the system. Parameters ---------- width : Constraint Variable The constraint variable representing the width of the main layout container. height : Constraint Variable The constraint variable representing the height of the main layout container. strength : kiwisolver strength, optional The strength with which to perform the layout using the current size of the container. i.e. the strength of the resize. The default is kiwisolver.strength.medium. Returns ------- result : (float, float) The floating point (min_width, min_height) size of the container which would best satisfy the set of constraints. """ if not self._initialized: raise RuntimeError('Get min size on uninitialized solver') solver = self._solver pairs = ((width, strength), (height, strength)) with self._edit_context(pairs): solver.suggestValue(width, 0.0) solver.suggestValue(height, 0.0) solver.updateVariables() min_width = width.value() min_height = height.value() return (min_width, min_height) def get_max_size(self, width, height, strength=kiwi.strength.medium): """ Run an iteration of the solver with the suggested size of the component set to a very large value. This will cause the solver to effectively compute the maximum size that the window can be to solve the system. The return value is a tuple numbers. If one of the numbers is -1, it indicates there is no maximum in that direction. Parameters ---------- width : Constraint Variable The constraint variable representing the width of the main layout container. height : Constraint Variable The constraint variable representing the height of the main layout container. strength : kiwisolver strength, optional The strength with which to perform the layout using the current size of the container. i.e. the strength of the resize. The default is kiwisolver.strength.medium. Returns ------- result : (float or -1, float or -1) The floating point (max_width, max_height) size of the container which would best satisfy the set of constraints. """ if not self._initialized: raise RuntimeError('Get max size on uninitialized solver') max_val = 2**24 - 1 # Arbitrary, but the max allowed by Qt. solver = self._solver pairs = ((width, strength), (height, strength)) with self._edit_context(pairs): solver.suggestValue(width, max_val) solver.suggestValue(height, max_val) solver.updateVariables() max_width = width.value() max_height = width.value() width_diff = abs(max_val - int(round(max_width))) height_diff = abs(max_val - int(round(max_height))) if width_diff <= 1: max_width = -1 if height_diff <= 1: max_height = -1 return (max_width, max_height) def _push_edit_vars(self, pairs): """ Push edit variables into the solver. The current edit variables will be removed and the new edit variables will be added. Parameters ---------- pairs : sequence A sequence of 2-tuples of (var, strength) which should be added as edit variables to the solver. """ solver = self._solver stack = self._edit_stack if stack: for v, strength in stack[-1]: solver.removeEditVariable(v) stack.append(pairs) for v, strength in pairs: solver.addEditVariable(v, strength) def _pop_edit_vars(self): """ Restore the previous edit variables in the solver. The current edit variables will be removed and the previous edit variables will be re-added. """ solver = self._solver stack = self._edit_stack for v, strength in stack.pop(): solver.removeEditVariable(v) if stack: for v, strength in stack[-1]: solver.addEditVariable(v, strength) @contextmanager def _edit_context(self, pairs): """ A context manager for temporary solver edits. This manager will push the edit vars into the solver and pop them when the context exits. Parameters ---------- pairs : list A list of 2-tuple of (var, strength) which should be added as temporary edit variables to the solver. """ self._push_edit_vars(pairs) yield self._pop_edit_vars() enthought-chaco2-4.5.1.orig/enable/layout/constraints_namespace.py0000644000175000017500000000440012516137326024376 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2013, Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ from kiwisolver import Variable from .linear_symbolic import LinearSymbolic class ConstraintsNamespace(object): """ A class which acts as a namespace for kiwi constraint variables. The constraint variables are created on an as-needed basis, this allows components to define new constraints and build layouts with them, without having to specifically update this client code. """ def __init__(self, name, owner): """ Initialize a ConstraintsNamespace. Parameters ---------- name : str A name to use in the label for the constraint variables in this namespace. owner : str The owner id to use in the label for the constraint variables in this namespace. """ self._name = name self._owner = owner self._constraints = {} def __getattr__(self, name): """ Returns a kiwi constraint variable for the given name, unless the name is already in the instance dictionary. Parameters ---------- name : str The name of the constraint variable to return. """ try: return super(ConstraintsNamespace, self).__getattr__(name) except AttributeError: pass constraints = self._constraints if name in constraints: res = constraints[name] else: label = '{0}|{1}|{2}'.format(self._name, self._owner, name) res = constraints[name] = Variable(label) return res def __setattr__(self, name, value): """ Adds a kiwi constraint variable to the constraints dictionary. Parameters ---------- name : str The name of the constraint variable to set. value : LinearSymbolic The kiwi variable to add to the constraints dictionary. """ if isinstance(value, LinearSymbolic): self._constraints[name] = value else: super(ConstraintsNamespace, self).__setattr__(name, value) enthought-chaco2-4.5.1.orig/enable/layout/geometry.py0000644000175000017500000002134712516137326021657 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # Rect #------------------------------------------------------------------------------ class BaseRect(tuple): """ A tuple subclass representing an (x, y, width, height) bounding box. Subclasses should override the __new__ method to enforce any necessary typing. """ __slots__ = () def __new__(cls, x, y, width, height): return super(BaseRect, cls).__new__(cls, (x, y, width, height)) def __getnewargs__(self): return tuple(self) def __repr__(self): template = '%s(x=%s, y=%s, width=%s, height=%s)' values = (self.__class__.__name__,) + self return template % values @property def x(self): """ The 'x' position component of the rect. """ return self[0] @property def y(self): """ The 'y' position component of the rect. """ return self[1] @property def width(self): """ The 'width' size component of the rect. """ return self[2] @property def height(self): """ The 'height' size component of the rect. """ return self[3] class Rect(BaseRect): """ A BaseRect implementation for integer values. """ __slots__ = () def __new__(cls, x, y, width, height): i = int return super(Rect, cls).__new__(cls, i(x), i(y), i(width), i(height)) @property def box(self): """ The equivalent Box for this rect. """ x, y, width, height = self return Box(y, x + width, y + height, x) @property def pos(self): """ The position of the rect as a Pos object. """ return Pos(self.x, self.y) @property def size(self): """ The size of the rect as a Size object. """ return Size(self.width, self.height) class RectF(BaseRect): """ A BaseRect implementation for floating point values. """ __slots__ = () def __new__(cls, x, y, width, height): f = float return super(RectF, cls).__new__(cls, f(x), f(y), f(width), f(height)) @property def box(self): """ The equivalent Box for this rect. """ x, y, width, height = self return BoxF(y, x + width, y + height, x) @property def pos(self): """ The position of the rect as a Pos object. """ return PosF(self.x, self.y) @property def size(self): """ The size of the rect as a Size object. """ return SizeF(self.width, self.height) #------------------------------------------------------------------------------ # Box #------------------------------------------------------------------------------ class BaseBox(tuple): """ A tuple subclass representing a (top, right, bottom, left) box. Subclasses should override the __new__ method to enforce any typing. """ __slots__ = () @staticmethod def coerce_type(item): return item def __new__(cls, top=None, right=None, bottom=None, left=None): if isinstance(top, (tuple, BaseBox)): return cls(*top) c = cls.coerce_type top = c(top) if right is None: right = top else: right = c(right) if bottom is None: bottom = top else: bottom = c(bottom) if left is None: left = right else: left = c(left) return super(BaseBox, cls).__new__(cls, (top, right, bottom, left)) def __getnewargs__(self): return tuple(self) def __repr__(self): template = '%s(top=%s, right=%s, bottom=%s, left=%s)' values = (self.__class__.__name__,) + self return template % values @property def top(self): """ The 'top' component of the box. """ return self[0] @property def right(self): """ The 'right' component of the box. """ return self[1] @property def bottom(self): """ The 'bottom' component of the box. """ return self[2] @property def left(self): """ The 'left' component of the box. """ return self[3] class Box(BaseBox): """ A BaseBox implementation for integer values. """ __slots__ = () @staticmethod def coerce_type(item): return 0 if item is None else int(item) @property def rect(self): """ The equivalent Rect for this box. """ top, right, bottom, left = self return Rect(left, top, right - left, bottom - top) @property def size(self): """ The Size of this box. """ top, right, bottom, left = self return Size(right - left, bottom - top) @property def pos(self): """ The Pos of this box. """ return Pos(self.left, self.top) class BoxF(BaseBox): """ A BaseBox implementation for floating point values. """ __slots__ = () @staticmethod def coerce_type(item): return 0.0 if item is None else float(item) @property def rect(self): """ The equivalent Rect for this box. """ top, right, bottom, left = self return RectF(left, top, right - left, bottom - top) @property def size(self): """ The Size of this box. """ top, right, bottom, left = self return SizeF(right - left, bottom - top) @property def pos(self): """ The Pos of this box. """ return PosF(self.left, self.top) #------------------------------------------------------------------------------ # Pos #------------------------------------------------------------------------------ class BasePos(tuple): """ A tuple subclass representing a (x, y) positions. Subclasses should override the __new__ method to enforce any necessary typing. """ __slots__ = () def __new__(cls, x, y): return super(BasePos, cls).__new__(cls, (x, y)) def __getnewargs__(self): return tuple(self) def __repr__(self): template = '%s(x=%s, y=%s)' values = (self.__class__.__name__,) + self return template % values @property def x(self): """ The 'x' component of the size. """ return self[0] @property def y(self): """ The 'y' component of the size. """ return self[1] class Pos(BasePos): """ An implementation of BasePos for integer values. """ __slots__ = () def __new__(cls, x, y): i = int return super(Pos, cls).__new__(cls, i(x), i(y)) class PosF(BasePos): """ An implementation of BasePos of floating point values. """ __slots__ = () def __new__(cls, x, y): f = float return super(PosF, cls).__new__(cls, f(x), f(y)) #------------------------------------------------------------------------------ # Size #------------------------------------------------------------------------------ class BaseSize(tuple): """ A tuple subclass representing a (width, height) size. Subclasses should override the __new__ method to enforce any necessary typing. """ __slots__ = () @staticmethod def coerce_type(item): return item def __new__(cls, width=None, height=None): if isinstance(width, (tuple, BaseSize)): return cls(*width) c = cls.coerce_type width = c(width) if height is None: height = width else: height = c(height) return super(BaseSize, cls).__new__(cls, (width, height)) def __getnewargs__(self): return tuple(self) def __repr__(self): template = '%s(width=%s, height=%s)' values = (self.__class__.__name__,) + self return template % values @property def width(self): """ The 'width' component of the size. """ return self[0] @property def height(self): """ The 'height' component of the size. """ return self[1] class Size(BaseSize): """ A BaseSize implementation for integer values. """ __slots__ = () @staticmethod def coerce_type(item): return 0 if item is None else int(item) class SizeF(BaseSize): """ A BaseSize implementation for floating point values. """ __slots__ = () @staticmethod def coerce_type(item): return 0.0 if item is None else float(item) enthought-chaco2-4.5.1.orig/enable/layout/ab_constrainable.py0000644000175000017500000000112512516137326023302 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2012, Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ from abc import ABCMeta class ABConstrainable(object): """ An abstract base class for objects that can be laid out using layout helpers. Minimally, instances need to have `top`, `bottom`, `left`, `right`, `layout_width`, `layout_height`, `v_center` and `h_center` attributes which are `LinearSymbolic` instances. """ __metaclass__ = ABCMeta enthought-chaco2-4.5.1.orig/enable/layout/layout_helpers.py0000644000175000017500000013053112516137326023057 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2013, Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ from abc import ABCMeta, abstractmethod from collections import defaultdict from uuid import uuid4 from kiwisolver import Variable, Constraint from traits.api import HasTraits, Instance, Range from .ab_constrainable import ABConstrainable from .constraints_namespace import ConstraintsNamespace from .geometry import Box from .linear_symbolic import LinearSymbolic from .utils import add_symbolic_constraints, STRENGTHS #------------------------------------------------------------------------------ # Default Spacing #------------------------------------------------------------------------------ class DefaultSpacing(HasTraits): """ A class which encapsulates the default spacing parameters for the various layout helper objects. """ #: The space between abutted components ABUTMENT = Range(low=0, value=10) #: The space between aligned anchors ALIGNMENT = Range(low=0, value=0) #: The margins for box helpers BOX_MARGINS = Instance(Box, default=Box(0, 0, 0, 0)) # We only require a singleton of DefaultSpacing DefaultSpacing = DefaultSpacing() #------------------------------------------------------------------------------ # Helper Functions #------------------------------------------------------------------------------ def expand_constraints(component, constraints): """ A function which expands any DeferredConstraints in the provided list. This is a generator function which yields the flattened stream of constraints. Paramters --------- component : Constrainable The constrainable component with which the constraints are associated. This will be passed to the .get_constraints() method of any DeferredConstraint instance. constraints : list The list of constraints. Yields ------ constraints The stream of expanded constraints. """ for cn in constraints: if isinstance(cn, DeferredConstraints): for item in cn.get_constraints(component): if item is not None: yield item else: if cn is not None and isinstance(cn, Constraint): yield cn def is_spacer(item): """ Returns True if the given item can be considered a spacer, False other otherwise. """ return isinstance(item, (Spacer, int)) #------------------------------------------------------------------------------ # Deferred Constraints #------------------------------------------------------------------------------ class DeferredConstraints(object): """ Abstract base class for objects that will yield lists of constraints upon request. """ __metaclass__ = ABCMeta def __init__(self): """ Initialize a DeferredConstraints instance. """ # __or__() will set the default_strength. If provided, it will be # combined with the constraints created by this instance. self.default_strength = None def __or__(self, other): """ Set the strength of all of the constraints to a common strength. """ if isinstance(other, (float, int, long)): self.default_string = float(other) elif isinstance(other, basestring): if other not in STRENGTHS: raise ValueError('Invalid strength %r' % other) self.default_strength = other else: msg = 'Strength must be a string or number. Got %s instead.' raise TypeError(msg % type(other)) return self def when(self, switch): """ A simple method that can be used to switch off the generated constraints depending on a boolean value. """ if switch: return self def get_constraints(self, component): """ Returns a list of constraints. Parameters ---------- component : Component or None The component that owns this DeferredConstraints. It can be None for contexts in which there is not a containing component, such as in certain nested DeferredConstraints. Returns ------- result : list of Constraints The list of Constraint objects which have been weighted by any provided strengths. """ cn_list = self._get_constraints(component) strength = self.default_strength if strength is not None: cn_list = [cn | strength for cn in cn_list] return cn_list @abstractmethod def _get_constraints(self, component): """ Returns a list of LinearConstraint objects. Subclasses must implement this method to actually yield their constraints. Users of instances should instead call the `get_constraints()` method which will combine these constraints with the `default_strength` if provided. Parameters ---------- component : Component or None The component that owns this DeferredConstraints. It can be None for contexts in which there is not a containing component, such as in certain nested DeferredConstraints. Returns ------- result : list of LinearConstraints The list of LinearConstraint objects for this deferred instance. """ raise NotImplementedError #------------------------------------------------------------------------------ # Deferred Constraints Implementations #------------------------------------------------------------------------------ class DeferredConstraintsFunction(DeferredConstraints): """ A concrete implementation of DeferredConstraints which will call a function to get the constraint list upon request. """ def __init__(self, func, *args, **kwds): """ Initialize a DeferredConstraintsFunction. Parameters ---------- func : callable A callable object which will return the list of constraints. *args The arguments to pass to 'func'. **kwds The keyword arguments to pass to 'func'. """ super(DeferredConstraintsFunction, self).__init__() self.func = func self.args = args self.kwds = kwds def _get_constraints(self, component): """ Abstract method implementation which calls the underlying function to generate the list of constraints. """ return self.func(*self.args, **self.kwds) class AbutmentHelper(DeferredConstraints): """ A concrete implementation of DeferredConstraints which will lay out its components by abutting them in a given orientation. """ def __init__(self, orientation, *items, **config): """ Initialize an AbutmentHelper. Parameters ---------- orientation A string which is either 'horizontal' or 'vertical' which indicates the abutment orientation. *items The components to abut in the given orientation. **config Configuration options for how this helper should behave. The following options are currently supported: spacing An integer >= 0 which indicates how many pixels of inter-element spacing to use during abutment. The default is the value of DefaultSpacing.ABUTMENT. """ super(AbutmentHelper, self).__init__() self.orientation = orientation self.items = items self.spacing = config.get('spacing', DefaultSpacing.ABUTMENT) def __repr__(self): """ A pretty string representation of the helper. """ items = ', '.join(map(repr, self.items)) return '{0}({1})'.format(self.orientation, items) def _get_constraints(self, component): """ Abstract method implementation which applies the constraints to the given items, after filtering them for None values. """ items = [item for item in self.items if item is not None] factories = AbutmentConstraintFactory.from_items( items, self.orientation, self.spacing, ) cn_lists = (f.constraints() for f in factories) return list(cn for cns in cn_lists for cn in cns) class AlignmentHelper(DeferredConstraints): """ A deferred constraints helper class that lays out with a given anchor to align. """ def __init__(self, anchor, *items, **config): """ Initialize an AlignmentHelper. Parameters ---------- anchor A string which is either 'left', 'right', 'top', 'bottom', 'v_center', or 'h_center'. *items The components to align on the given anchor. **config Configuration options for how this helper should behave. The following options are currently supported: spacing An integer >= 0 which indicates how many pixels of inter-element spacing to use during alignement. The default is the value of DefaultSpacing.ALIGNMENT. """ super(AlignmentHelper, self).__init__() self.anchor = anchor self.items = items self.spacing = config.get('spacing', DefaultSpacing.ALIGNMENT) def __repr__(self): """ A pretty string representation of the layout helper. """ items = ', '.join(map(repr, self.items)) return 'align({0!r}, {1})'.format(self.anchor, items) def _get_constraints(self, component): """ Abstract method implementation which applies the constraints to the given items, after filtering them for None values. """ items = [item for item in self.items if item is not None] # If there are less than two items, no alignment needs to # happen, so return no constraints. if len(items) < 2: return [] factories = AlignmentConstraintFactory.from_items( items, self.anchor, self.spacing, ) cn_lists = (f.constraints() for f in factories) return list(cn for cns in cn_lists for cn in cns) class BoxHelper(DeferredConstraints): """ A DeferredConstraints helper class which adds a box model to the helper. The addition of the box model allows the helper to be registered as ABConstrainable which has the effect of allowing box helper instances to be nested. """ def __init__(self, name): """ Initialize a BoxHelper. Parameters ---------- name : str A string name to prepend to a unique owner id generated for this box helper, to aid in debugging. """ super(BoxHelper, self).__init__() owner = uuid4().hex[:8] self.constraints_id = name + '|' + owner self._namespace = ConstraintsNamespace(name, owner) add_symbolic_constraints(self._namespace) left = property(lambda self: self._namespace.left) top = property(lambda self: self._namespace.top) right = property(lambda self: self._namespace.right) bottom = property(lambda self: self._namespace.bottom) layout_width = property(lambda self: self._namespace.layout_width) layout_height = property(lambda self: self._namespace.layout_height) v_center = property(lambda self: self._namespace.v_center) h_center = property(lambda self: self._namespace.h_center) ABConstrainable.register(BoxHelper) class LinearBoxHelper(BoxHelper): """ A layout helper which arranges items in a linear box. """ #: A mapping orientation to the anchor names needed to make the #: constraints on the containing component. orientation_map = { 'horizontal': ('left', 'right'), 'vertical': ('top', 'bottom'), } #: A mapping of ortho orientations ortho_map = { 'horizontal': 'vertical', 'vertical': 'horizontal', } def __init__(self, orientation, *items, **config): """ Initialize a LinearBoxHelper. Parameters ---------- orientation : str The layout orientation of the box. This must be either 'horizontal' or 'vertical'. *items The components to align on the given anchor. **config Configuration options for how this helper should behave. The following options are currently supported: spacing An integer >= 0 which indicates how many pixels of inter-element spacing to use during abutment. The default is the value of DefaultSpacing.ABUTMENT. margins A int, tuple of ints, or Box of ints >= 0 which indicate how many pixels of margin to add around the bounds of the box. The default is the value of DefaultSpacing.BOX_MARGIN. """ super(LinearBoxHelper, self).__init__(orientation[0] + 'box') self.items = items self.orientation = orientation self.ortho_orientation = self.ortho_map[orientation] self.spacing = config.get('spacing', DefaultSpacing.ABUTMENT) self.margins = Box(config.get('margins', DefaultSpacing.BOX_MARGINS)) def __repr__(self): """ A pretty string representation of the layout helper. """ items = ', '.join(map(repr, self.items)) return '{0}box({1})'.format(self.orientation[0], items) def _get_constraints(self, component): """ Generate the linear box constraints. This is an abstractmethod implementation which will use the space available on the provided component to layout the items. """ items = [item for item in self.items if item is not None] if len(items) == 0: return items first, last = self.orientation_map[self.orientation] first_boundary = getattr(self, first) last_boundary = getattr(self, last) first_ortho, last_ortho = self.orientation_map[self.ortho_orientation] first_ortho_boundary = getattr(self, first_ortho) last_ortho_boundary = getattr(self, last_ortho) # Setup the initial outer constraints of the box if component is not None: # This box helper is inside a real component, not just nested # inside of another box helper. Check if the component is a # PaddingConstraints object and use it's contents anchors. attrs = ['top', 'bottom', 'left', 'right'] # XXX hack! if hasattr(component, 'contents_top'): other_attrs = ['contents_' + attr for attr in attrs] else: other_attrs = attrs[:] constraints = [ getattr(self, attr) == getattr(component, other) for (attr, other) in zip(attrs, other_attrs) ] else: constraints = [] # Create the margin spacers that will be used. margins = self.margins if self.orientation == 'vertical': first_spacer = EqSpacer(margins.top) last_spacer = EqSpacer(margins.bottom) first_ortho_spacer = FlexSpacer(margins.left) last_ortho_spacer = FlexSpacer(margins.right) else: first_spacer = EqSpacer(margins.left) last_spacer = EqSpacer(margins.right) first_ortho_spacer = FlexSpacer(margins.top) last_ortho_spacer = FlexSpacer(margins.bottom) # Add a pre and post padding spacer if the user hasn't specified # their own spacer as the first/last element of the box items. if not is_spacer(items[0]): pre_along_args = [first_boundary, first_spacer] else: pre_along_args = [first_boundary] if not is_spacer(items[-1]): post_along_args = [last_spacer, last_boundary] else: post_along_args = [last_boundary] # Accummulate the constraints in the direction of the layout along_args = pre_along_args + items + post_along_args kwds = dict(spacing=self.spacing) helpers = [AbutmentHelper(self.orientation, *along_args, **kwds)] ortho = self.ortho_orientation for item in items: # Add the helpers for the ortho constraints if isinstance(item, ABConstrainable): abutment_items = ( first_ortho_boundary, first_ortho_spacer, item, last_ortho_spacer, last_ortho_boundary, ) helpers.append(AbutmentHelper(ortho, *abutment_items, **kwds)) # Pull out nested helpers so that their constraints get # generated during the pass over the helpers list. if isinstance(item, DeferredConstraints): helpers.append(item) # Pass over the list of child helpers and generate the # flattened list of constraints. for helper in helpers: constraints.extend(helper.get_constraints(None)) return constraints class _GridCell(object): """ A private class used by a GridHelper to track item cells. """ def __init__(self, item, row, col): """ Initialize a _GridCell. Parameters ---------- item : object The item contained in the cell. row : int The row index of the cell. col : int The column index of the cell. """ self.item = item self.start_row = row self.start_col = col self.end_row = row self.end_col = col def expand_to(self, row, col): """ Expand the cell to enclose the given row and column. """ self.start_row = min(row, self.start_row) self.end_row = max(row, self.end_row) self.start_col = min(col, self.start_col) self.end_col = max(col, self.end_col) class GridHelper(BoxHelper): """ A layout helper which arranges items in a grid. """ def __init__(self, *rows, **config): """ Initialize a GridHelper. Parameters ---------- *rows: iterable of lists The rows to layout in the grid. A row must be composed of constrainable objects and None. An item will be expanded to span all of the cells in which it appears. **config Configuration options for how this helper should behave. The following options are currently supported: row_align A string which is the name of a constraint variable on a item. If given, it is used to add constraints on the alignment of items in a row. The constraints will only be applied to items that do not span rows. row_spacing An integer >= 0 which indicates how many pixels of space should be placed between rows in the grid. The default is the value of DefaultSpacing.ABUTMENT. column_align A string which is the name of a constraint variable on a item. If given, it is used to add constraints on the alignment of items in a column. The constraints will only be applied to items that do not span columns. column_spacing An integer >= 0 which indicates how many pixels of space should be placed between columns in the grid. The default is the value of DefaultSpacing.ABUTMENT. margins A int, tuple of ints, or Box of ints >= 0 which indicate how many pixels of margin to add around the bounds of the grid. The default is the value of DefaultSpacing.BOX_MARGIN. """ super(GridHelper, self).__init__('grid') self.grid_rows = rows self.row_align = config.get('row_align', '') self.col_align = config.get('col_align', '') self.row_spacing = config.get('row_spacing', DefaultSpacing.ABUTMENT) self.col_spacing = config.get('column_spacing', DefaultSpacing.ABUTMENT) self.margins = Box(config.get('margins', DefaultSpacing.BOX_MARGINS)) def __repr__(self): """ A pretty string representation of the layout helper. """ items = ', '.join(map(repr, self.grid_rows)) return 'grid({0})'.format(items) def _get_constraints(self, component): """ Generate the grid constraints. This is an abstractmethod implementation which will use the space available on the provided component to layout the items. """ grid_rows = self.grid_rows if not grid_rows: return [] # Validate and compute the cell span for the items in the grid. cells = [] cell_map = {} num_cols = 0 num_rows = len(grid_rows) for row_idx, row in enumerate(grid_rows): for col_idx, item in enumerate(row): if item is None: continue elif isinstance(item, ABConstrainable): if item in cell_map: cell_map[item].expand_to(row_idx, col_idx) else: cell = _GridCell(item, row_idx, col_idx) cell_map[item] = cell cells.append(cell) else: m = ('Grid cells must be constrainable objects or None. ' 'Got object of type `%s` instead.') raise TypeError(m % type(item).__name__) num_cols = max(num_cols, col_idx + 1) # Setup the initial outer constraints of the grid if component is not None: # This box helper is inside a real component, not just nested # inside of another box helper. Check if the component is a # PaddingConstraints object and use it's contents anchors. attrs = ['top', 'bottom', 'left', 'right'] # XXX hack! if hasattr(component, 'contents_top'): other_attrs = ['contents_' + attr for attr in attrs] else: other_attrs = attrs[:] constraints = [ getattr(self, attr) == getattr(component, other) for (attr, other) in zip(attrs, other_attrs) ] else: constraints = [] # Create the row and column constraint variables along with # some default limits row_vars = [] col_vars = [] cn_id = self.constraints_id for idx in xrange(num_rows + 1): name = 'row' + str(idx) var = Variable('{0}|{1}'.format(cn_id, name)) row_vars.append(var) constraints.append(var >= 0) for idx in xrange(num_cols + 1): name = 'col' + str(idx) var = Variable('{0}|{1}'.format(cn_id, name)) col_vars.append(var) constraints.append(var >= 0) # Add some neighbor relations to the row and column vars. for r1, r2 in zip(row_vars[:-1], row_vars[1:]): constraints.append(r1 >= r2) for c1, c2 in zip(col_vars[:-1], col_vars[1:]): constraints.append(c1 <= c2) # Setup the initial interior bounding box for the grid. margins = self.margins bottom_items = (self.bottom, EqSpacer(margins.bottom), row_vars[-1]) top_items = (row_vars[0], EqSpacer(margins.top), self.top) left_items = (self.left, EqSpacer(margins.left), col_vars[0]) right_items = (col_vars[-1], EqSpacer(margins.right), self.right) helpers = [ AbutmentHelper('vertical', *bottom_items), AbutmentHelper('vertical', *top_items), AbutmentHelper('horizontal', *left_items), AbutmentHelper('horizontal', *right_items), ] # Setup the spacer list for constraining the cell items row_spacer = FlexSpacer(self.row_spacing / 2.) col_spacer = FlexSpacer(self.col_spacing / 2.) rspace = [row_spacer] * len(row_vars) rspace[0] = 0 rspace[-1] = 0 cspace = [col_spacer] * len(col_vars) cspace[0] = 0 cspace[-1] = 0 # Setup the constraints for each constrainable grid cell. for cell in cells: sr = cell.start_row er = cell.end_row + 1 sc = cell.start_col ec = cell.end_col + 1 item = cell.item row_item = ( row_vars[sr], rspace[sr], item, rspace[er], row_vars[er] ) col_item = ( col_vars[sc], cspace[sc], item, cspace[ec], col_vars[ec] ) helpers.append(AbutmentHelper('vertical', *row_item)) helpers.append(AbutmentHelper('horizontal', *col_item)) if isinstance(item, DeferredConstraints): helpers.append(item) # Add the row alignment constraints if given. This will only # apply the alignment constraint to items which do not span # multiple rows. if self.row_align: row_map = defaultdict(list) for cell in cells: if cell.start_row == cell.end_row: row_map[cell.start_row].append(cell.item) for items in row_map.itervalues(): if len(items) > 1: helpers.append(AlignmentHelper(self.row_align, *items)) # Add the column alignment constraints if given. This will only # apply the alignment constraint to items which do not span # multiple columns. if self.col_align: col_map = defaultdict(list) for cell in cells: if cell.start_col == cell.end_col: col_map[cell.start_col].append(cell.item) for items in row_map.itervalues(): if len(items) > 1: helpers.append(AlignmentHelper(self.col_align, *items)) # Add the child helpers constraints to the constraints list. for helper in helpers: constraints.extend(helper.get_constraints(None)) return constraints #------------------------------------------------------------------------------ # Abstract Constraint Factory #------------------------------------------------------------------------------ class AbstractConstraintFactory(object): """ An abstract constraint factory class. Subclasses must implement the 'constraints' method implement which returns a LinearConstraint instance. """ __metaclass__ = ABCMeta @staticmethod def validate(items): """ A validator staticmethod that insures a sequence of items is appropriate for generating a sequence of linear constraints. The following conditions are verified of the sequence of given items: * The number of items in the sequence is 0 or >= 2. * The first and last items are instances of either LinearSymbolic or Constrainable. * All of the items in the sequence are instances of LinearSymbolic, Constrainable, Spacer, or int. If any of the above conditions do not hold, an exception is raised with a (hopefully) useful error message. """ if len(items) == 0: return if len(items) < 2: msg = 'Two or more items required to setup abutment constraints.' raise ValueError(msg) extrema_types = (LinearSymbolic, ABConstrainable) def extrema_test(item): return isinstance(item, extrema_types) item_types = (LinearSymbolic, ABConstrainable, Spacer, int) def item_test(item): return isinstance(item, item_types) if not all(extrema_test(item) for item in (items[0], items[-1])): msg = ('The first and last items of a constraint sequence ' 'must be anchors or Components. Got %s instead.') args = [type(items[0]), type(items[-1])] raise TypeError(msg % args) if not all(map(item_test, items)): msg = ('The allowed items for a constraint sequence are' 'anchors, Components, Spacers, and ints. ' 'Got %s instead.') args = [type(item) for item in items] raise TypeError(msg % args) @abstractmethod def constraints(self): """ An abstract method which must be implemented by subclasses. It should return a list of LinearConstraint instances. """ raise NotImplementedError #------------------------------------------------------------------------------ # Abstract Constraint Factory Implementations #------------------------------------------------------------------------------ class BaseConstraintFactory(AbstractConstraintFactory): """ A base constraint factory class that implements basic common logic. It is not meant to be used directly but should rather be subclassed to be useful. """ def __init__(self, first_anchor, spacer, second_anchor): """ Create an base constraint instance. Parameters ---------- first_anchor : LinearSymbolic A symbolic object that can be used in a constraint expression. spacer : Spacer A spacer instance to put space between the items. second_anchor : LinearSymbolic The second anchor for the constraint expression. """ self.first_anchor = first_anchor self.spacer = spacer self.second_anchor = second_anchor def constraints(self): """ Returns LinearConstraint instance which is formed through an appropriate linear expression for the given space between the anchors. """ first = self.first_anchor second = self.second_anchor spacer = self.spacer return spacer.constrain(first, second) class SequenceConstraintFactory(BaseConstraintFactory): """ A BaseConstraintFactory subclass that represents a constraint between two anchors of different components separated by some amount of space. It has a '_make_cns' classmethod which will create a list of constraint factory instances from a sequence of items, the two anchor names, and a default spacing. """ @classmethod def _make_cns(cls, items, first_anchor_name, second_anchor_name, spacing): """ A classmethod that generates a list of constraints factories given a sequence of items, two anchor names, and default spacing. Parameters ---------- items : sequence A valid sequence of constrainable objects. These inclue instances of Constrainable, LinearSymbolic, Spacer, and int. first_anchor_name : string The name of the anchor on the first item in a constraint pair. second_anchor_name : string The name of the anchor on the second item in a constraint pair. spacing : int The spacing to use between items if no spacing is explicitly provided by in the sequence of items. Returns ------- result : list A list of constraint factory instance. """ # Make sure the items we'll be dealing with are valid for the # algorithm. This is a basic validation. Further error handling # is performed as needed. cls.validate(items) # The list of constraints we'll be creating for the given # sequence of items. cns = [] # The list of items is treated as a stack. So we want to first # reverse it so the first items are at the top of the stack. items = list(reversed(items)) while items: # Grab the item that will provide the first anchor first_item = items.pop() # first_item will be a Constrainable or a LinearSymbolic. # For the first iteration, this is enforced by 'validate'. # For subsequent iterations, this condition is enforced by # the fact that this loop only pushes those types back onto # the stack. if isinstance(first_item, ABConstrainable): first_anchor = getattr(first_item, first_anchor_name) elif isinstance(first_item, LinearSymbolic): first_anchor = first_item else: raise TypeError('This should never happen') # Grab the next item off the stack. It will be an instance # of Constrainable, LinearSymbolic, Spacer, or int. If it # can't provide an anchor, we grab the item after it which # *should* be able to provide one. If no space is given, we # use the provided default space. next_item = items.pop() if isinstance(next_item, Spacer): spacer = next_item second_item = items.pop() elif isinstance(next_item, int): spacer = EqSpacer(next_item) second_item = items.pop() elif isinstance(next_item, (ABConstrainable, LinearSymbolic)): spacer = EqSpacer(spacing) second_item = next_item else: raise ValueError('This should never happen') # If the second_item can't provide an anchor, such as two # spacers next to each other, then this is an error and we # raise an appropriate exception. if isinstance(second_item, ABConstrainable): second_anchor = getattr(second_item, second_anchor_name) elif isinstance(second_item, LinearSymbolic): second_anchor = second_item else: msg = 'Expected anchor or Constrainable. Got %r instead.' raise TypeError(msg % second_item) # Create the class instance for this constraint factory = cls(first_anchor, spacer, second_anchor) # If there are still items on the stack, then the second_item # will be used as the first_item in the next iteration. # Otherwise, we have exhausted all constraints and can exit. if items: items.append(second_item) # Finally, store away the created factory for returning. cns.append(factory) return cns class AbutmentConstraintFactory(SequenceConstraintFactory): """ A SequenceConstraintFactory subclass that represents an abutment constraint, which is a constraint between two anchors of different components separated by some amount of space. It has a 'from_items' classmethod which will create a sequence of abutment constraints from a sequence of items, a direction, and default spacing. """ #: A mapping from orientation to the order of anchor names to #: lookup for a pair of items in order to make the constraint. orientation_map = { 'horizontal': ('right', 'left'), 'vertical': ('top', 'bottom'), } @classmethod def from_items(cls, items, orientation, spacing): """ A classmethod that generates a list of abutment constraints given a sequence of items, an orientation, and default spacing. Parameters ---------- items : sequence A valid sequence of constrainable objects. These inclue instances of Constrainable, LinearSymbolic, Spacer, and int. orientation : string Either 'vertical' or 'horizontal', which represents the orientation in which to abut the items. spacing : int The spacing to use between items if no spacing is explicitly provided by in the sequence of items. Returns ------- result : list A list of AbutmentConstraint instances. Notes ------ The order of abutment is left-to-right for horizontal direction and top-to-bottom for vertical direction. """ # Grab the tuple of anchor names to lookup for each pair of # items in order to make the connection. orient = cls.orientation_map.get(orientation) if orient is None: msg = ("Valid orientations for abutment are 'vertical' or " "'horizontal'. Got %r instead.") raise ValueError(msg % orientation) first_name, second_name = orient if orientation == 'vertical': items.reverse() return cls._make_cns(items, first_name, second_name, spacing) class AlignmentConstraintFactory(SequenceConstraintFactory): """ A SequenceConstraintFactory subclass which represents an alignmnent constraint, which is a constraint between two anchors of different components which are aligned but may be separated by some amount of space. It provides a 'from_items' classmethod which will create a list of alignment constraints from a sequence of items an anchor name, and a default spacing. """ @classmethod def from_items(cls, items, anchor_name, spacing): """ A classmethod that will create a seqence of alignment constraints given a sequence of items, an anchor name, and a default spacing. Parameters ---------- items : sequence A valid sequence of constrainable objects. These inclue instances of Constrainable, LinearSymbolic, Spacer, and int. anchor_name : string The name of the anchor on the components which should be aligned. Either 'left', 'right', 'top', 'bottom', 'v_center', or 'h_center'. spacing : int The spacing to use between items if no spacing is explicitly provided by in the sequence of items. Returns ------- result : list A list of AbutmentConstraint instances. Notes ----- For every item in the sequence, if the item is a component, then anchor for the given anchor_name on that component will be used. If a LinearSymbolic is given, then that symbolic will be used and the anchor_name will be ignored. Specifying space between items via integers or spacers is allowed. """ return cls._make_cns(items, anchor_name, anchor_name, spacing) #------------------------------------------------------------------------------ # Spacers #------------------------------------------------------------------------------ class Spacer(object): """ An abstract base class for spacers. Subclasses must implement the 'constrain' method. """ __metaclass__ = ABCMeta def __init__(self, amt, strength=None): self.amt = max(0, amt) self.strength = strength def when(self, switch): """ A simple method that can be used to switch off the generated space depending on a boolean value. """ if switch: return self def constrain(self, first_anchor, second_anchor): """ Returns the list of generated constraints appropriately weighted by the default strength, if provided. """ constraints = self._constrain(first_anchor, second_anchor) strength = self.strength if strength is not None: constraints = [cn | strength for cn in constraints] return constraints @abstractmethod def _constrain(self, first_anchor, second_anchor): """ An abstract method. Subclasses should implement this method to return a list of LinearConstraint instances which separate the two anchors according to the amount of space represented by the spacer. """ raise NotImplementedError class EqSpacer(Spacer): """ A spacer which represents a fixed amount of space. """ def _constrain(self, first_anchor, second_anchor): """ A constraint of the form (anchor_1 + space == anchor_2) """ return [(first_anchor + self.amt) == second_anchor] class LeSpacer(Spacer): """ A spacer which represents a flexible space with a maximum value. """ def _constrain(self, first_anchor, second_anchor): """ A constraint of the form (anchor_1 + space >= anchor_2) That is, the visible space must be less than or equal to the given amount. An additional constraint is applied which constrains (anchor_1 <= anchor_2) to prevent negative space. """ return [(first_anchor + self.amt) >= second_anchor, first_anchor <= second_anchor] class GeSpacer(Spacer): """ A spacer which represents a flexible space with a minimum value. """ def _constrain(self, first_anchor, second_anchor): """ A constraint of the form (anchor_1 + space <= anchor_2) That is, the visible space must be greater than or equal to the given amount. """ return [(first_anchor + self.amt) <= second_anchor] class FlexSpacer(Spacer): """ A spacer which represents a space with a hard minimum, but also a weaker preference for being that minimum. """ def __init__(self, amt, min_strength='required', eq_strength='medium'): self.amt = max(0, amt) self.min_strength = min_strength self.eq_strength = eq_strength def constrain(self, first_anchor, second_anchor): """ Return list of LinearConstraint objects that are appropriate to separate the two anchors according to the amount of space represented by the spacer. """ return self._constrain(first_anchor, second_anchor) def _constrain(self, first_anchor, second_anchor): """ Constraints of the form (anchor_1 + space <= anchor_2) and (anchor_1 + space == anchor_2) """ return [ ((first_anchor + self.amt) <= second_anchor) | self.min_strength, ((first_anchor + self.amt) == second_anchor) | self.eq_strength, ] class LayoutSpacer(Spacer): """ A Spacer instance which supplies convenience symbolic and normal methods to facilitate specifying spacers in layouts. """ def __call__(self, *args, **kwargs): return self.__class__(*args, **kwargs) def __eq__(self, other): if not isinstance(other, int): raise TypeError('space can only be created from ints') return EqSpacer(other, self.strength) def __le__(self, other): if not isinstance(other, int): raise TypeError('space can only be created from ints') return LeSpacer(other, self.strength) def __ge__(self, other): if not isinstance(other, int): raise TypeError('space can only be created from ints') return GeSpacer(other, self.strength) def _constrain(self, first_anchor, second_anchor): """ Returns a greater than or equal to spacing constraint. """ spacer = GeSpacer(self.amt, self.strength) return spacer._constrain(first_anchor, second_anchor) def flex(self, **kwargs): """ Returns a flex spacer for the current amount. """ return FlexSpacer(self.amt, **kwargs) #------------------------------------------------------------------------------ # Layout Helper Functions and Objects #------------------------------------------------------------------------------ def horizontal(*items, **config): """ Create a DeferredConstraints object composed of horizontal abutments for the given sequence of items. """ return AbutmentHelper('horizontal', *items, **config) def vertical(*items, **config): """ Create a DeferredConstraints object composed of vertical abutments for the given sequence of items. """ return AbutmentHelper('vertical', *items, **config) def hbox(*items, **config): """ Create a DeferredConstraints object composed of horizontal abutments for a given sequence of items. """ return LinearBoxHelper('horizontal', *items, **config) def vbox(*items, **config): """ Create a DeferredConstraints object composed of vertical abutments for a given sequence of items. """ return LinearBoxHelper('vertical', *items, **config) def align(anchor, *items, **config): """ Align the given anchors of the given components. Inter-component spacing is allowed. """ return AlignmentHelper(anchor, *items, **config) def grid(*rows, **config): """ Create a DeferredConstraints object which lays out items in a grid. """ return GridHelper(*rows, **config) spacer = LayoutSpacer(DefaultSpacing.ABUTMENT) enthought-chaco2-4.5.1.orig/enable/__init__.py0000644000175000017500000000074212516137340020236 0ustar varunvarun# Copyright (c) 2007-2014 by Enthought, Inc. # All rights reserved. """ A multi-platform object drawing library. Part of the Enable project of the Enthought Tool Suite. """ import sys from ._version import full_version as __version__ __all__ = [ '__version__', ] __requires__ = [ 'numpy', 'traits', 'traitsui', 'PIL', 'pyface', ] # Cython is only necessary to build the quartz backend. if sys.platform == 'darwin': __requires__.append('cython') enthought-chaco2-4.5.1.orig/enable/scrollbar.py0000644000175000017500000003646012516137326020474 0ustar varunvarun""" Define a standard horizontal and vertical Enable 'scrollbar' component. The scrollbar uses images for the pieces of the scrollbar itself and stretches them appropriately in the draw phase. """ from __future__ import with_statement # PZW: Define a scrollbar that uses the system/wx-native scrollbar instead # of drawing our own. from types import TupleType from traits.api import Event, Property, Trait, TraitError from traitsui.api import Group, View # Relative imports from component import Component from enable_traits import layout_style_trait #------------------------------------------------------------------------------ # Constants: #------------------------------------------------------------------------------ # Scroll bar zones: NO_SCROLL = -1 LINE_UP = 0 PAGE_UP = 1 LINE_DOWN = 2 PAGE_DOWN = 3 SLIDER = 4 # Scrollbar suffix names by zone: zone_suffixes = [ '_line_up_suffix', '', '_line_down_suffix', '', '_slider_suffix' ] # Scroll information look-up table: scroll_info = [ ( 'line_up', 1.0, 3 ), ( 'page_up', 1.0, 2 ), ( 'line_down', -1.0, 3 ), ( 'page_down', -1.0, 2 ) ] # Scroll bar images and sizes: sb_image = {} v_width = 0 v_height = 0 vs_height = 0 h_width = 0 h_height = 0 hs_width = 0 #------------------------------------------------------------------------------ # Traits validators #------------------------------------------------------------------------------ def valid_range ( object, name, value ): "Verify that a set of range values for a scrollbar is valid" try: if (type( value ) is TupleType) and (len( value ) == 4): low, high, page_size, line_size = value if high < low: low, high = high, low elif high == low: high = low + 1.0 page_size = max( min( page_size, high - low ), 0.0 ) line_size = max( min( line_size, page_size ), 0.0 ) return ( float( low ), float( high ), float( page_size ), float( line_size ) ) except: pass raise TraitError valid_range.info = 'a (low,high,page_size,line_size) range tuple' def valid_position ( object, name, value ): "Verify that a specified scroll bar position is valid" try: low, high, page_size, line_size = object.range return max( min( float( value ), high - page_size ), low ) except: pass raise TraitError class ScrollBar ( Component ): position = Trait( 0.0, valid_position ) range = Trait( ( 0.0, 100.0, 10.0, 1.0 ), valid_range ) style = layout_style_trait line_up = Event line_down = Event page_up = Event page_down = Event scroll_done = Event traits_view = View( Group( '', id = 'component' ), Group( '', id = 'links' ), Group( 'style', ' ', 'position', 'low', 'high', 'page_size', 'line_size', id = 'scrollbar', style = 'custom' ) ) #--------------------------------------------------------------------------- # Property definitions: #--------------------------------------------------------------------------- def __low_get(self): return self.range[0] def __low_set(self, low): ignore, high, page_size, line_size = self.range self.range =(low, high, page_size, line_size) return def __high_get(self): return self.range[1] def __high_set(self, high): low, ignore, page_size, line_size = self.range self.range =(low, high, page_size, line_size) def __page_size_get(self): return self.range[2] def __page_size_set(self, page_size): low, high, ignore, line_size = self.range self.range =(low, high, page_size, line_size) def __line_size_get(self): return self.range[3] def __line_size_set(self, line_size): low, high, page_size, ignore = self.range self.range =(low, high, page_size, line_size) # Define 'position, low, high, page_size' properties: low = Property( __low_get, __low_set) high = Property( __high_get, __high_set) page_size = Property( __page_size_get, __page_size_set) line_size = Property( __line_size_get, __line_size_set) def __init__(self, **traits): if v_width == 0: self._init_images() Component.__init__(self, **traits) self._scrolling = self._zone = NO_SCROLL self._line_up_suffix = self._line_down_suffix = self._slider_suffix = '' self._style_changed(self.style) return def _init_images(self): "One time initialization of the scrollbar images" global sb_image, v_width, v_height, vs_height, h_width, h_height, \ hs_width for name in [ 'aup' , 'adown', 'aleft', 'aright', 'vtop', 'vbottom', 'vmid', 'vpad', 'hleft', 'hright', 'hmid', 'hpad' ]: sb_image[ name ] = self.image_for('=sb_%s' % name) sb_image[ name + '_over' ] = self.image_for('=sb_%s_over' % name) sb_image[ name + '_down' ] = self.image_for('=sb_%s_down' % name) sb_image[ 'vtrack' ] = self.image_for('=sb_vtrack') sb_image[ 'htrack' ] = self.image_for('=sb_htrack') v_width = sb_image[ 'vtrack' ].width() vs_height = reduce(lambda a, b: a + sb_image[b].height(), [ 'vtop', 'vbottom', 'vmid' ], 0) v_height = reduce(lambda a, b: a + sb_image[b].height(), [ 'aup', 'adown' ], vs_height) hs_width = reduce(lambda a, b: a + sb_image[b].width(), [ 'hleft', 'hright', 'hmid' ], 0) h_width = reduce(lambda a, b: a + sb_image[b].width(), [ 'aleft', 'aright' ], hs_width) h_height = sb_image[ 'htrack' ].height() return def _range_changed(self): "Handle any of the range elements values being changed" low, high, page_size, line_size = self.range self.position = max(min(self.position, high - page_size), low) self.redraw() return def _position_changed(self): self.redraw() return def _style_changed(self, style): "Handle the orientation style being changed" if style[0] == 'v': self.min_width = self.max_width = v_width self.min_height = v_height self.max_height = 99999.0 self.stretch_width = 0.0 self.stretch_height = 1.0 else: self.min_width = h_width self.max_width = 99999.0 self.min_height = self.max_height = h_height self.stretch_width = 1.0 self.stretch_height = 0.0 return def _draw(self, gc): "Draw the contents of the control" with gc: if self.style[0] == 'v': self._draw_vertical(gc) else: self._draw_horizontal(gc) return def _draw_vertical(self, gc): "Draw a vertical scrollbar" low, high, page_size, line_size = self.range position = self.position x, y, dx, dy = self.bounds adown = sb_image[ 'adown' + self._line_down_suffix ] adown_dy = adown.height() aup = sb_image[ 'aup' + self._line_up_suffix ] aup_dy = aup.height() vtrack = sb_image[ 'vtrack' ] t_dy = dy - aup_dy - adown_dy t_y = s_y = y + adown_dy u_y = y + dy - aup_dy gc.stretch_draw(vtrack, x, t_y, dx, t_dy) gc.draw_image(adown,(x, y, dx, adown_dy)) gc.draw_image(aup, (x, u_y, dx, aup_dy)) if page_size > 0.0: s_dy = max(vs_height, round((page_size * t_dy) / (high - low))) self._range = range_dy = t_dy - s_dy range = high - low - page_size if range > 0.0: s_y = round(s_y + (((position - low) * range_dy) / range)) suffix = self._slider_suffix vbottom = sb_image[ 'vbottom' + suffix ] vbottom_dy = vbottom.height() vtop = sb_image[ 'vtop' + suffix ] vtop_dy = vtop.height() vmid = sb_image[ 'vmid' + suffix ] vmid_dy = vmid.height() gc.stretch_draw(sb_image[ 'vpad' + suffix ], x, s_y + vbottom_dy, dx, s_dy - vbottom_dy - vtop_dy) gc.draw_image(vbottom,(x, s_y, dx, vbottom_dy)) gc.draw_image(vtop,(x, s_y + s_dy - vtop_dy, dx, vtop_dy)) gc.draw_image(vmid,(x, round(s_y + vbottom_dy + (s_dy - vbottom_dy - vtop_dy - vmid_dy) / 2.0), dx, vmid_dy)) self._info =(t_y, s_y, s_y + s_dy, u_y) return def _draw_horizontal(self, gc): "Draw a horizontal scroll bar" low, high, page_size, line_size = self.range position = self.position x, y, dx, dy = self.bounds aleft = sb_image[ 'aleft' + self._line_up_suffix ] aleft_dx = aleft.width() aright = sb_image[ 'aright' + self._line_down_suffix ] aright_dx = aright.width() htrack = sb_image[ 'htrack' ] t_dx = dx - aleft_dx - aright_dx t_x = s_x = x + aleft_dx r_x = x + dx - aright_dx gc.stretch_draw(htrack, t_x, y, t_dx, dy) gc.draw_image(aleft, (x, y, aleft_dx, dy)) gc.draw_image(aright,(r_x, y, aright_dx, dy)) if page_size > 0.0: s_dx = max(hs_width, round((page_size * t_dx) / (high - low))) self._range = range_dx = t_dx - s_dx range = high - low - page_size if range > 0.0: s_x = round(s_x + (((position - low) * range_dx) / range)) suffix = self._slider_suffix hleft = sb_image[ 'hleft' + suffix ] hleft_dx = hleft.width() hright = sb_image[ 'hright' + suffix ] hright_dx = hright.width() hmid = sb_image[ 'hmid' + suffix ] hmid_dx = hmid.width() gc.stretch_draw(sb_image[ 'hpad' + suffix ], s_x + hleft_dx, y, s_dx - hleft_dx - hright_dx, dy) gc.draw_image(hleft, (s_x, y, hleft_dx, dy)) gc.draw_image(hright,(s_x + s_dx - hright_dx, y, hright_dx, dy)) gc.draw_image(hmid,(round(s_x + hleft_dx + (s_dx - hleft_dx - hright_dx - hmid_dx) / 2.0), y, hmid_dx, dy)) self._info =(t_x, s_x, s_x + s_dx, r_x) return def _get_zone(self, event): "Determine which scrollbar zone the mouse pointer is over" if not self.xy_in_bounds(event) or (self._info is None): return NO_SCROLL cbl, csl, csh, ctr = self._info c = [ event.x, event.y ][ self.style[0] == 'v' ] if c < cbl: return LINE_DOWN if c >= ctr: return LINE_UP if c < csl: return PAGE_DOWN if c >= csh: return PAGE_UP return SLIDER def _scroll(self): "Perform an incremental scroll (line up/down, page up/down)" incr = self._scroll_incr if incr != 0.0: low, high, page_size, line_size = self.range position = max(min(self.position + incr, high - page_size), low) if position == self.position: return self.position = position setattr(self, self._event_name, True) return def _set_zone_suffix(self, zone, suffix): "Set a particular zone's image suffix" if zone != NO_SCROLL: suffix_name = zone_suffixes[ zone ] if suffix_name != '': setattr(self, suffix_name, suffix) self.redraw() return #--------------------------------------------------------------------------- # Handle mouse events: #--------------------------------------------------------------------------- def _left_down_changed(self, event): event.handled = True if self.range[2] == 0.0: return zone = self._get_zone(event) if zone != NO_SCROLL: self.window.mouse_owner = self self._scrolling = zone self._set_zone_suffix(zone, '_down') if zone == SLIDER: self._xy =(event.x, event.y)[ self.style[0] == 'v' ] self._position = self.position else: self._event_name, sign, index = scroll_info[ zone ] line_size = self.range[3] incr = 0.0 if line_size != 0.0: incr = sign * self.range[ index ] if index == 2: incr -= sign * line_size self._scroll_incr = incr self._scroll() self._in_zone = True self.timer_interval = 0.5 return def _left_dclick_changed(self, event): self._left_down_changed(event) return def _left_up_changed(self, event): event.handled = True scrolling = self._scrolling if scrolling != NO_SCROLL: zone = self._get_zone(event) self._set_zone_suffix(scrolling, '') self._set_zone_suffix(zone, '_over') if scrolling != SLIDER: self.timer_interval = None self._scrolling = NO_SCROLL self._zone = zone if zone == NO_SCROLL: self.window.mouse_owner = None self.scroll_done = True return def _mouse_move_changed(self, event): event.handled = True self.pointer = 'arrow' zone = self._get_zone(event) scrolling = self._scrolling if scrolling == SLIDER: xy =(event.x, event.y)[ self.style[0] == 'v' ] low, high, page_size, line_size = self.range position = (self._position + ((xy - self._xy) * (high - low - page_size) / self._range)) self.position = max(min(position, high - page_size), low) elif scrolling != NO_SCROLL: in_zone = (zone == scrolling) if in_zone != self._in_zone: self._in_zone = in_zone self._set_zone_suffix(scrolling, [ '', '_down' ][ in_zone ]) elif zone != self._zone: self._set_zone_suffix(self._zone, '') self._set_zone_suffix(zone, '_over') self._zone = zone self.window.mouse_owner = [ self, None ][ zone == NO_SCROLL ] return def _mouse_wheel_changed(self, event): "Scrolls when the mouse scroll wheel is spun" event.handled = True self.position += (event.mouse_wheel * self.page_size) / 20 return def _timer_changed(self): "Handle timer events" if self._scrolling != NO_SCROLL: self.timer_interval = 0.1 if self._in_zone: self._scroll() return # EOF enthought-chaco2-4.5.1.orig/enable/component.py0000644000175000017500000013645412516137326020517 0ustar varunvarun""" Defines the Component class """ from __future__ import with_statement from uuid import uuid4 # Enthought library imports from traits.api \ import Any, Bool, Delegate, Enum, Float, Instance, Int, List, \ Property, Str, Trait from kiva.constants import FILL, STROKE # Local relative imports from colors import black_color_trait, white_color_trait from coordinate_box import CoordinateBox from enable_traits import bounds_trait, coordinate_trait, LineStyle from interactor import Interactor coordinate_delegate = Delegate("inner", modify=True) DEFAULT_DRAWING_ORDER = ["background", "underlay", "mainlayer", "border", "overlay"] class Component(CoordinateBox, Interactor): """ Component is the base class for most Enable objects. In addition to the basic position and container features of Component, it also supports Viewports and has finite bounds. Since Components can have a border and padding, there is an additional set of bounds and position attributes that define the "outer box" of the components. These cannot be set, since they are secondary attributes (computed from the component's "inner" size and margin-area attributes). """ #------------------------------------------------------------------------ # Basic appearance traits #------------------------------------------------------------------------ # Is the component visible? visible = Bool(True) # Does the component use space in the layout even if it is not visible? invisible_layout = Bool(False) # Fill the padding area with the background color? fill_padding = Bool(False) #------------------------------------------------------------------------ # Object/containment hierarchy traits #------------------------------------------------------------------------ # Our container object container = Any # Instance("Container") # A reference to our top-level Enable Window. This is stored as a shadow # attribute if this component is the direct child of the Window; otherwise, # the getter function recurses up the containment hierarchy. window = Property # Instance("Window") # The list of viewport that are viewing this component viewports = List(Instance("enable.viewport.Viewport")) #------------------------------------------------------------------------ # Layout traits #------------------------------------------------------------------------ # The layout system to use: # # * 'chaco': Chaco-level layout (the "old" system) # * 'enable': Enable-level layout, based on the db/resolver containment # model. # NB: this is in preparation for future work #layout_switch = Enum("chaco", "enable") # Dimensions that this component is resizable in. For resizable # components, get_preferred_size() is called before their actual # bounds are set. # # * 'v': resizable vertically # * 'h': resizable horizontally # * 'hv': resizable horizontally and vertically # * '': not resizable # # Note that this setting means only that the *parent* can and should resize # this component; it does *not* mean that the component automatically # resizes itself. resizable = Enum("hv", "h", "v", "") # The ratio of the component's width to its height. This is used by # the component itself to maintain bounds when the bounds are changed # independently, and is also used by the layout system. aspect_ratio = Trait(None, None, Float) # When the component's bounds are set to a (width,height) tuple that does # not conform to the set aspect ratio, does the component center itself # in the free space? auto_center = Bool(True) # A read-only property that returns True if this component needs layout. # It is a reflection of both the value of the component's private # _layout_needed attribute as well as any logical layout dependencies with # other components. layout_needed = Property # If the component is resizable, this attribute can be used to specify the # amount of space that the component would like to get in each dimension, # as a tuple (width, height). This attribute can be used to establish # relative sizes between resizable components in a container: if one # component specifies, say, a fixed preferred width of 50 and another one # specifies a fixed preferred width of 100, then the latter component will # always be twice as wide as the former. fixed_preferred_size = Trait(None, None, bounds_trait) #------------------------------------------------------------------------ # Overlays and underlays #------------------------------------------------------------------------ # A list of underlays for this plot. By default, underlays get a chance to # draw onto the plot area underneath plot itself but above any images and # backgrounds of the plot. underlays = List #[AbstractOverlay] # A list of overlays for the plot. By default, overlays are drawn above the # plot and its annotations. overlays = List #[AbstractOverlay] # Listen for changes to selection metadata on # the underlying data sources, and render them specially? use_selection = Bool(False) #------------------------------------------------------------------------ # Tool and interaction handling traits #------------------------------------------------------------------------ # An Enable Interactor that all events are deferred to. controller = Any # Events are *not* automatically considered "handled" if there is a handler # defined. Overrides an inherited trait from Enable's Interactor class. auto_handle_event = False #------------------------------------------------------------------------ # Padding-related traits # Padding in each dimension is defined as the number of pixels that are # part of the component but outside of its position and bounds. Containers # need to be aware of padding when doing layout, object collision/overlay # calculations, etc. #------------------------------------------------------------------------ # The amount of space to put on the left side of the component padding_left = Int(0) # The amount of space to put on the right side of the component padding_right = Int(0) # The amount of space to put on top of the component padding_top = Int(0) # The amount of space to put below the component padding_bottom = Int(0) # This property allows a way to set the padding in bulk. It can either be # set to a single Int (which sets padding on all sides) or a tuple/list of # 4 Ints representing the left, right, top, bottom padding amounts. When # it is read, this property always returns the padding as a list of four # elements even if they are all the same. padding = Property # Readonly property expressing the total amount of horizontal padding hpadding = Property # Readonly property expressing the total amount of vertical padding vpadding = Property # Does the component respond to mouse events over the padding area? padding_accepts_focus = Bool(True) #------------------------------------------------------------------------ # Position and bounds of outer box (encloses the padding and border area) # All of these are read-only properties. To set them directly, use # set_outer_coordinates() or set_outer_pos_bounds(). #------------------------------------------------------------------------ # The x,y point of the lower left corner of the padding outer box around # the component. Setting this position will move the component, but # will not change the padding or bounds. # This returns a tuple because modifying the returned value has no effect. # To modify outer_position element-wise, use set_outer_position(). outer_position = Property # The number of horizontal and vertical pixels in the padding outer box. # Setting these bounds will modify the bounds of the component, but # will not change the lower-left position (self.outer_position) or # the padding. # This returns a tuple because modifying the returned value has no effect. # To modify outer_bounds element-wise, use set_outer_bounds(). outer_bounds = Property outer_x = Property outer_x2 = Property outer_y = Property outer_y2 = Property outer_width = Property outer_height = Property #------------------------------------------------------------------------ # Rendering control traits #------------------------------------------------------------------------ # The order in which various rendering classes on this component are drawn. # Note that if this component is placed in a container, in most cases # the container's draw order is used, since the container calls # each of its contained components for each rendering pass. # Typically, the definitions of the layers are: # # #. 'background': Background image, shading, and (possibly) borders # #. 'mainlayer': The main layer that most objects should draw on # #. 'border': A special layer for rendering the border on top of the # component instead of under its main layer (see **overlay_border**) # #. 'overlay': Legends, selection regions, and other tool-drawn visual # elements draw_order = Instance(list, args=(DEFAULT_DRAWING_ORDER,)) # If True, then this component draws as a unified whole, # and its parent container calls this component's _draw() method when # drawing the layer indicated by **draw_layer**. # If False, it tries to cooperate in its container's layer-by-layer drawing. # Its parent container calls self._dispatch_draw() with the name of each # layer as it goes through its list of layers. unified_draw = Bool(False) # If **unified_draw** is True for this component, then this attribute # determines what layer it will be drawn on. This is used by containers # and external classes, whose drawing loops call this component. # If **unified_draw** is False, then this attribute is ignored. draw_layer = Str("mainlayer") # Draw the border as part of the overlay layer? If False, draw the # border as part of the background layer. overlay_border = Bool(True) # Draw the border inset (on the plot)? If False, draw the border # outside the plot area. inset_border = Bool(True) #------------------------------------------------------------------------ # Border and background traits #------------------------------------------------------------------------ # The width of the border around this component. This is taken into account # during layout, but only if the border is visible. border_width = Int(1) # Is the border visible? If this is false, then all the other border # properties are not used. border_visible = Bool(False) # The line style (i.e. dash pattern) of the border. border_dash = LineStyle # The color of the border. Only used if border_visible is True. border_color = black_color_trait # The background color of this component. By default all components have # a white background. This can be set to "transparent" or "none" if the # component should be see-through. bgcolor = white_color_trait #------------------------------------------------------------------------ # Backbuffer traits #------------------------------------------------------------------------ # Should this component do a backbuffered draw, i.e. render itself to an # offscreen buffer that is cached for later use? If False, then # the component will *never* render itself backbuffered, even if asked # to do so. use_backbuffer = Bool(False) # Should the backbuffer extend to the pad area? backbuffer_padding = Bool(True) # If a draw were to occur, whether the component would actually change. # This is useful for determining whether a backbuffer is valid, and is # usually set by the component itself or set on the component by calling # _invalidate_draw(). It is exposed as a public trait for the rare cases # when another component wants to know the validity of this component's # backbuffer. draw_valid = Bool(False) # drawn_outer_position specifies the outer position this component was drawn to # on the last draw cycle. This is used to determine what areas of the screen # are damaged. drawn_outer_position = coordinate_trait # drawn_outer_bounds specifies the bounds of this component on the last draw # cycle. Used in conjunction with outer_position_last_draw drawn_outer_bounds = bounds_trait # The backbuffer of this component. In most cases, this is an # instance of GraphicsContext, but this requirement is not enforced. _backbuffer = Any #------------------------------------------------------------------------ # New layout/object containment hierarchy traits # These are not used yet. #------------------------------------------------------------------------ # A list of strings defining the classes to which this component belongs. # These classes will be used to determine how this component is styled, # is rendered, is laid out, and receives events. There is no automatic # management of conflicting class names, so if a component is placed # into more than one class and that class classes = List # The element ID of this component. id = Str # These will be used by the new layout system, but are currently unused. #max_width = Any #min_width = Any #max_height = Any #min_height = Any #------------------------------------------------------------------------ # Private traits #------------------------------------------------------------------------ # Shadow trait for self.window. Only gets set if this is the top-level # enable component in a Window. _window = Any # Instance("Window") # Whether or not component itself needs to be laid out. Some times # components are composites of others, in which case the layout # invalidation relationships should be implemented in layout_needed. _layout_needed = Bool(True) #------------------------------------------------------------------------ # Abstract methods #------------------------------------------------------------------------ def _do_layout(self): """ Called by do_layout() to do an actual layout call; it bypasses some additional logic to handle null bounds and setting **_layout_needed**. """ pass def _draw_component(self, gc, view_bounds=None, mode="normal"): """ Renders the component. Subclasses must implement this method to actually render themselves. Note: This method is used only by the "old" drawing calls. """ pass def _draw_selection(self, gc, view_bounds=None, mode="normal"): """ Renders a selected subset of a component's data. This method is used by some subclasses. The notion of selection doesn't necessarily apply to all subclasses of PlotComponent, but it applies to enough of them that it is defined as one of the default draw methods. """ pass #------------------------------------------------------------------------ # Public methods #------------------------------------------------------------------------ def __init__(self, **traits): # The 'padding' trait sets 4 individual traits in bulk. Make sure that # it gets set first before other explicit padding traits get set so they # may override the bulk default. padding = traits.pop('padding', None) padding_traits = {} for name in traits.keys(): # Use .keys() so we can modify the dict during iteration safely. if name in ['padding_top', 'padding_bottom', 'padding_left', 'padding_right']: padding_traits[name] = traits.pop(name) if traits.has_key("container"): # After the component is otherwise configured, make sure our # container gets notified of our being added to it. container = traits.pop("container") super(Component,self).__init__(**traits) self._set_padding_traits(padding, padding_traits) container.add(self) else: super(Component,self).__init__(**traits) self._set_padding_traits(padding, padding_traits) return def draw(self, gc, view_bounds=None, mode="default"): """ Draws the plot component. Parameters ---------- gc : Kiva GraphicsContext The graphics context to draw the component on view_bounds : 4-tuple of integers (x, y, width, height) of the area to draw mode : string The drawing mode to use; can be one of: 'normal' Normal, antialiased, high-quality rendering 'overlay' The plot component is being rendered over something else, so it renders more quickly, and possibly omits rendering its background and certain tools 'interactive' The plot component is being asked to render in direct response to realtime user interaction, and needs to make its best effort to render as fast as possible, even if there is an aesthetic cost. """ if self.layout_needed: self.do_layout() self._draw(gc, view_bounds, mode) return def draw_select_box(self, gc, position, bounds, width, dash, inset, color, bgcolor, marker_size): """ Renders a selection box around the component. Subclasses can implement this utility method to render a selection box around themselves. To avoid burdening subclasses with various selection-box related traits that they might never use, this method takes all of its required data as input parameters. Parameters ---------- gc : Kiva GraphicsContext The graphics context to draw on. position : (x, y) The position of the selection region. bounds : (width, height) The size of the selection region. width : integer The width of the selection box border dash : float array An array of floating point values specifying the lengths of on and off painting pattern for dashed lines. inset : integer Amount by which the selection box is inset on each side within the selection region. color : 3-tuple of floats between 0.0 and 1.0 The R, G, and B values of the selection border color. bgcolor : 3-tuple of floats between 0.0 and 1.0 The R, G, and B values of the selection background. marker_size : integer Size, in pixels, of "handle" markers on the selection box """ with gc: gc.set_line_width(width) gc.set_antialias(False) x,y = position x += inset y += inset width, height = bounds width -= 2*inset height -= 2*inset rect = (x, y, width, height) gc.set_stroke_color(bgcolor) gc.set_line_dash(None) gc.draw_rect(rect, STROKE) gc.set_stroke_color(color) gc.set_line_dash(dash) gc.draw_rect(rect, STROKE) if marker_size > 0: gc.set_fill_color(bgcolor) half_y = y + height/2.0 y2 = y + height half_x = x + width/2.0 x2 = x + width marker_positions = ((x,y), (x,half_y), (x,y2), (half_x,y), (half_x,y2), (x2,y), (x2, half_y), (x2,y2)) gc.set_line_dash(None) gc.set_line_width(1.0) for pos in marker_positions: gc.rect(pos[0]-marker_size/2.0, pos[1]-marker_size/2.0, marker_size, marker_size) gc.draw_path() return def get_absolute_coords(self, *coords): """ Given coordinates relative to this component's origin, returns the "absolute" coordinates in the frame of the top-level parent Window enclosing this component's ancestor containers. Can be called in two ways: get_absolute_coords(x, y) get_absolute_coords( (x,y) ) Returns a tuple (x,y) representing the new coordinates. """ if self.container is not None: offset_x, offset_y = \ self.container.get_absolute_coords(*self.position) else: offset_x, offset_y = self.position return (offset_x + coords[0], offset_y + coords[1]) def get_relative_coords(self, *coords): """ Given absolute coordinates (where the origin is the top-left corner of the frame in the top-level parent Window) return coordinates relative to this component's origin. Can be called in two ways: get_relative_coords(x, y) get_relative_coords( (x,y) ) Returns a tuple (x,y) representing the new coordinates. """ if self.container is not None: offset_x, offset_y = \ self.container.get_relative_coords(*self.position) else: offset_x, offset_y = self.position return (coords[0] - offset_x, coords[1] - offset_y) def request_redraw(self): """ Requests that the component redraw itself. Usually this means asking its parent for a repaint. """ for view in self.viewports: view.request_redraw() self._request_redraw() return def invalidate_draw(self, damaged_regions=None, self_relative=False): """ Invalidates any backbuffer that may exist, and notifies our parents and viewports of any damaged regions. Call this method whenever a component's internal state changes such that it must be redrawn on the next draw() call.""" self.draw_valid = False if damaged_regions is None: damaged_regions = self._default_damaged_regions() if self_relative: damaged_regions = [[region[0] + self.x, region[1] + self.y, region[2], region[3]] for region in damaged_regions] for view in self.viewports: view.invalidate_draw(damaged_regions=damaged_regions, self_relative=True, view_relative=True) if self.container is not None: self.container.invalidate_draw(damaged_regions=damaged_regions, self_relative=True) if self._window is not None: self._window.invalidate_draw(damaged_regions=damaged_regions, self_relative=True) return def invalidate_and_redraw(self): """Convenience method to invalidate our contents and request redraw""" self.invalidate_draw() self.request_redraw() def is_in(self, x, y): # A basic implementation of is_in(); subclasses should provide their # own if they are more accurate/faster/shinier. if self.padding_accepts_focus: bounds = self.outer_bounds pos = self.outer_position else: bounds = self.bounds pos = self.position return (x >= pos[0]) and (x < pos[0] + bounds[0]) and \ (y >= pos[1]) and (y < pos[1] + bounds[1]) def cleanup(self, window): """When a window viewing or containing a component is destroyed, cleanup is called on the component to give it the opportunity to delete any transient state it may have (such as backbuffers).""" return def set_outer_position(self, ndx, val): """ Since self.outer_position is a property whose value is determined by other (primary) attributes, it cannot return a mutable type. This method allows generic (i.e. orientation-independent) code to set the value of self.outer_position[0] or self.outer_position[1]. """ if ndx == 0: self.outer_x = val else: self.outer_y = val return def set_outer_bounds(self, ndx, val): """ Since self.outer_bounds is a property whose value is determined by other (primary) attributes, it cannot return a mutable type. This method allows generic (i.e. orientation-independent) code to set the value of self.outer_bounds[0] or self.outer_bounds[1]. """ if ndx == 0: self.outer_width = val else: self.outer_height = val return #------------------------------------------------------------------------ # Layout-related concrete methods #------------------------------------------------------------------------ def do_layout(self, size=None, force=False): """ Tells this component to do layout at a given size. Parameters ---------- size : (width, height) Size at which to lay out the component; either or both values can be 0. If it is None, then the component lays itself out using **bounds**. force : Boolean Whether to force a layout operation. If False, the component does a layout on itself only if **_layout_needed** is True. The method always does layout on any underlays or overlays it has, even if *force* is False. """ if self.layout_needed or force: if size is not None: self.bounds = size self._do_layout() self._layout_needed = False for underlay in self.underlays: if underlay.visible or underlay.invisible_layout: underlay.do_layout() for overlay in self.overlays: if overlay.visible or overlay.invisible_layout: overlay.do_layout() return def get_preferred_size(self): """ Returns the size (width,height) that is preferred for this component When called on a component that does not contain other components, this method just returns the component bounds. If the component is resizable and can draw into any size, the method returns a size that is visually appropriate. (The component's actual bounds are determined by its container's do_layout() method.) """ if self.fixed_preferred_size is not None: return self.fixed_preferred_size else: size = [0,0] outer_bounds = self.outer_bounds if "h" not in self.resizable: size[0] = outer_bounds[0] if "v" not in self.resizable: size[1] = outer_bounds[1] return size #------------------------------------------------------------------------ # Protected methods #------------------------------------------------------------------------ def _set_padding_traits(self, padding, padding_traits): """ Set the bulk padding trait and all of the others in the correct order. Parameters ---------- padding : None, int or list of ints The bulk padding. padding_traits : dict mapping str to int The specific padding traits. """ if padding is not None: self.trait_set(padding=padding) self.trait_set(**padding_traits) def _request_redraw(self): if self.container is not None: self.container.request_redraw() elif self._window: self._window.redraw() return def _default_damaged_regions(self): """Returns the default damaged regions for this Component. This consists of the current position/bounds, and the last drawn position/bounds""" return [list(self.outer_position) + list(self.outer_bounds), list(self.drawn_outer_position) + list(self.drawn_outer_bounds)] def _draw(self, gc, view_bounds=None, mode="default"): """ Draws the component, paying attention to **draw_order**, including overlays, underlays, and the like. This method is the main draw handling logic in plot components. The reason for implementing _draw() instead of overriding the top-level draw() method is that the Enable base classes may do things in draw() that mustn't be interfered with (e.g., the Viewable mix-in). """ if not self.visible: return if self.layout_needed: self.do_layout() self.drawn_outer_position = list(self.outer_position[:]) self.drawn_outer_bounds = list(self.outer_bounds[:]) # OpenGL-based graphics-contexts have a `gl_init()` method. We # test for this to avoid having to import the OpenGL # GraphicsContext just to do an isinstance() check. is_gl = hasattr(gc, 'gl_init') if self.use_backbuffer and (not is_gl): if self.backbuffer_padding: x, y = self.outer_position width, height = self.outer_bounds else: x, y = self.position width, height = self.bounds if not self.draw_valid: # get a reference to the GraphicsContext class from the object GraphicsContext = gc.__class__ if hasattr(GraphicsContext, 'create_from_gc'): # For some backends, such as the mac, a much more efficient # backbuffer can be created from the window gc. bb = GraphicsContext.create_from_gc(gc, (int(width), int(height))) else: bb = GraphicsContext((int(width), int(height))) # if not fill_padding, then we have to fill the backbuffer # with the window color. This is the only way I've found that # it works- perhaps if we had better blend support we could set # the alpha to 0, but for now doing so causes the backbuffer's # background to be white if not self.fill_padding: with bb: bb.set_antialias(False) bb.set_fill_color(self.window.bgcolor_) bb.draw_rect((x, y, width, height), FILL) # Fixme: should there be a +1 here? bb.translate_ctm(-x+0.5, -y+0.5) # There are a couple of strategies we could use here, but we # have to do something about view_bounds. This is because # if we only partially render the object into the backbuffer, # we will have problems if we then render with different view # bounds. for layer in self.draw_order: if layer != "overlay": self._dispatch_draw(layer, bb, view_bounds, mode) self._backbuffer = bb self.draw_valid = True # Blit the backbuffer and then draw the overlay on top gc.draw_image(self._backbuffer, (x, y, width, height)) self._dispatch_draw("overlay", gc, view_bounds, mode) else: for layer in self.draw_order: self._dispatch_draw(layer, gc, view_bounds, mode) return def _dispatch_draw(self, layer, gc, view_bounds, mode): """ Renders the named *layer* of this component. This method can be used by container classes that group many components together and want them to draw cooperatively. The container iterates through its components and asks them to draw only certain layers. """ # Don't render the selection layer if use_selection is false. This # is mostly for backwards compatibility. if layer == "selection" and not self.use_selection: return if self.layout_needed: self.do_layout() handler = getattr(self, "_draw_" + layer, None) if handler: handler(gc, view_bounds, mode) return def _draw_border(self, gc, view_bounds=None, mode="default", force_draw=False): """ Utility method to draw the borders around this component The *force_draw* parameter forces the method to draw the border; if it is false, the border is drawn only when **overlay_border** is True. """ if not self.border_visible: return if self.overlay_border or force_draw: if self.inset_border: self._draw_inset_border(gc, view_bounds, mode) else: border_width = self.border_width with gc: gc.set_line_width(border_width) gc.set_line_dash(self.border_dash_) gc.set_stroke_color(self.border_color_) gc.draw_rect((self.x-border_width/2.0, self.y-border_width/2.0, self.width+2*border_width-1, self.height+2*border_width-1), STROKE) def _draw_inset_border(self, gc, view_bounds=None, mode="default"): """ Draws the border of a component. Unlike the default Enable border, this one is drawn on the inside of the plot instead of around it. """ if not self.border_visible: return border_width = self.border_width with gc: gc.set_line_width(border_width) gc.set_line_dash(self.border_dash_) gc.set_stroke_color(self.border_color_) gc.set_antialias(0) gc.draw_rect((self.x+border_width/2.0-0.5, self.y+border_width/2.0-0.5, self.width-border_width/2.0, self.height-border_width/2.0), STROKE) #------------------------------------------------------------------------ # Protected methods for subclasses to implement #------------------------------------------------------------------------ def _draw_background(self, gc, view_bounds=None, mode="default"): """ Draws the background layer of a component. """ if self.bgcolor not in ("clear", "transparent", "none"): if self.fill_padding: r = tuple(self.outer_position) + \ (self.outer_width-1, self.outer_height-1) else: r = tuple(self.position) + (self.width-1, self.height-1) with gc: gc.set_antialias(False) gc.set_fill_color(self.bgcolor_) gc.draw_rect(r, FILL) # Call the enable _draw_border routine if not self.overlay_border and self.border_visible: # Tell _draw_border to ignore the self.overlay_border self._draw_border(gc, view_bounds, mode, force_draw=True) return def _draw_overlay(self, gc, view_bounds=None, mode="normal"): """ Draws the overlay layer of a component. """ for overlay in self.overlays: if overlay.visible: overlay.overlay(self, gc, view_bounds, mode) return def _draw_underlay(self, gc, view_bounds=None, mode="normal"): """ Draws the underlay layer of a component. """ for underlay in self.underlays: # This method call looks funny but it's correct - underlays are # just overlays drawn at a different time in the rendering loop. if underlay.visible: underlay.overlay(self, gc, view_bounds, mode) return def _get_visible_border(self): """ Helper function to return the amount of border, if visible """ if self.border_visible: if self.inset_border: return 0 else: return self.border_width else: return 0 #------------------------------------------------------------------------ # Tool-related methods and event dispatch #------------------------------------------------------------------------ def dispatch(self, event, suffix): """ Dispatches a mouse event based on the current event state. Parameters ---------- event : an Enable MouseEvent A mouse event. suffix : string The name of the mouse event as a suffix to the event state name, e.g. "_left_down" or "_window_enter". """ # This hasattr check is necessary to ensure compatibility with Chaco # components. if not getattr(self, "use_draw_order", True): self._old_dispatch(event, suffix) else: self._new_dispatch(event, suffix) return def _new_dispatch(self, event, suffix): """ Dispatches a mouse event If the component has a **controller**, the method dispatches the event to it, and returns. Otherwise, the following objects get a chance to handle the event: 1. The component's active tool, if any. 2. Any overlays, in reverse order that they were added and are drawn. 3. The component itself. 4. Any underlays, in reverse order that they were added and are drawn. 5. Any listener tools. If any object in this sequence handles the event, the method returns without proceeding any further through the sequence. If nothing handles the event, the method simply returns. """ # Maintain compatibility with .controller for now if self.controller is not None: self.controller.dispatch(event, suffix) return if self._active_tool is not None: self._active_tool.dispatch(event, suffix) if event.handled: return # Dispatch to overlays in reverse of draw/added order for overlay in self.overlays[::-1]: overlay.dispatch(event, suffix) if event.handled: break if not event.handled: self._dispatch_stateful_event(event, suffix) if not event.handled: # Dispatch to underlays in reverse of draw/added order for underlay in self.underlays[::-1]: underlay.dispatch(event, suffix) if event.handled: break # Now that everyone who might veto/handle the event has had a chance # to receive it, dispatch it to our list of listener tools. if not event.handled: for tool in self.tools: tool.dispatch(event, suffix) return def _old_dispatch(self, event, suffix): """ Dispatches a mouse event. If the component has a **controller**, the method dispatches the event to it and returns. Otherwise, the following objects get a chance to handle the event: 1. The component's active tool, if any. 2. Any listener tools. 3. The component itself. If any object in this sequence handles the event, the method returns without proceeding any further through the sequence. If nothing handles the event, the method simply returns. """ if self.controller is not None: self.controller.dispatch(event, suffix) return if self._active_tool is not None: self._active_tool.dispatch(event, suffix) if event.handled: return for tool in self.tools: tool.dispatch(event, suffix) if event.handled: return if not event.handled: self._dispatch_to_enable(event, suffix) return def _get_active_tool(self): return self._active_tool def _set_active_tool(self, tool): # Deactivate the existing active tool old = self._active_tool if old == tool: return self._active_tool = tool if old is not None: old.deactivate(self) if tool is not None and hasattr(tool, "_activate"): tool._activate() self.invalidate_and_redraw() return def _get_layout_needed(self): return self._layout_needed def _tools_items_changed(self): self.invalidate_and_redraw() #------------------------------------------------------------------------ # Event handlers #------------------------------------------------------------------------ def _id_default(self): """ Generate a random UUID for the ID. """ # The first 32bits is plenty. return uuid4().hex[:8] def _aspect_ratio_changed(self, old, new): if new is not None: self._enforce_aspect_ratio() def _enforce_aspect_ratio(self, notify=True): """ This method adjusts the width and/or height of the component so that the new width and height match the aspect ratio. It uses the current width and height as a bounding box and finds the largest rectangle of the desired aspect ratio that will fit. If **notify** is True, then fires trait events for bounds and position changing. """ ratio = self.aspect_ratio old_w, old_h = self.bounds if ratio is None: return elif ratio == 0: self.width = 0 return elif old_h == 0: return elif int(old_w) == int(ratio * old_h): return old_aspect = old_w / float(old_h) new_pos = None if ratio > old_aspect: # desired rectangle is wider than bounding box, so use the width # and compute a smaller height new_w = old_w new_h = new_w / ratio if self.auto_center: new_pos = self.position[:] new_pos[1] += (old_h - new_h) / 2.0 else: # desired rectangle is taller than bounding box, so use the height # and compute a smaller width new_h = old_h new_w = new_h * ratio if self.auto_center: new_pos = self.position[:] new_pos[0] += (old_w - new_w) / 2.0 self.set(bounds=[new_w, new_h], trait_change_notify=notify) if new_pos: self.set(position=new_pos, trait_change_notify=notify) return def _bounds_changed(self, old, new): self._enforce_aspect_ratio(notify=True) if self.container is not None: self.container._component_bounds_changed(self) return def _bounds_items_changed(self, event): self._enforce_aspect_ratio(notify=True) if self.container is not None: self.container._component_bounds_changed(self) return def _container_changed(self, old, new): # We don't notify our container of this change b/c the # caller who changed our .container should take care of that. if new is None: self.position = [0,0] def _position_changed(self, *args): if self.container is not None: self.container._component_position_changed(self) def _position_items_changed(self, *args): if self.container is not None: self.container._component_position_changed(self) def _visible_changed(self, old, new): if new: self._layout_needed = True def _get_window(self): if self._window is not None: return self._window elif self.container is not None: return self.container.window else: return None def _set_window(self, win): self._window = win #------------------------------------------------------------------------ # Position and padding setters and getters #------------------------------------------------------------------------ def _get_x(self): return self.position[0] def _set_x(self, val): self.position[0] = val def _get_y(self): return self.position[1] def _set_y(self, val): self.position[1] = val def _get_padding(self): return [self.padding_left, self.padding_right, self.padding_top, self.padding_bottom] def _set_padding(self, val): old_padding = self.padding if type(val) == int: self.padding_left = self.padding_right = \ self.padding_top = self.padding_bottom = val self.trait_property_changed("padding", old_padding, [val]*4) else: # assume padding is some sort of array type if len(val) != 4: raise RuntimeError("Padding must be a 4-element sequence " "type or an int. Instead, got" + str(val)) self.padding_left = val[0] self.padding_right = val[1] self.padding_top = val[2] self.padding_bottom = val[3] self.trait_property_changed("padding", old_padding, val) return def _get_hpadding(self): return 2*self._get_visible_border() + self.padding_right + \ self.padding_left def _get_vpadding(self): return 2*self._get_visible_border() + self.padding_bottom + \ self.padding_top #------------------------------------------------------------------------ # Outer position setters and getters #------------------------------------------------------------------------ def _get_outer_position(self): border = self._get_visible_border() pos = self.position return (pos[0] - self.padding_left - border, pos[1] - self.padding_bottom - border) def _set_outer_position(self, new_pos): border = self._get_visible_border() self.position = [new_pos[0] + self.padding_left + border, new_pos[1] + self.padding_bottom + border] def _get_outer_x(self): return self.x - self.padding_left - self._get_visible_border() def _set_outer_x(self, val): self.position[0] = val + self.padding_left + self._get_visible_border() def _get_outer_x2(self): return self.x2 + self.padding_right + self._get_visible_border() def _set_outer_x2(self, val): self.x2 = val - self.padding_right - self._get_visible_border() def _get_outer_y(self): return self.y - self.padding_bottom - self._get_visible_border() def _set_outer_y(self, val): self.position[1] = val + self.padding_bottom + \ self._get_visible_border() def _get_outer_y2(self): return self.y2 + self.padding_top + self._get_visible_border() def _set_outer_y2(self, val): self.y2 = val - self.padding_top - self._get_visible_border() #------------------------------------------------------------------------ # Outer bounds setters and getters #------------------------------------------------------------------------ def _get_outer_bounds(self): bounds = self.bounds return (bounds[0] + self.hpadding, bounds[1] + self.vpadding) def _set_outer_bounds(self, bounds): self.bounds = [bounds[0] - self.hpadding, bounds[1] - self.vpadding] def _get_outer_width(self): return self.outer_bounds[0] def _set_outer_width(self, width): self.bounds[0] = width - self.hpadding def _get_outer_height(self): return self.outer_bounds[1] def _set_outer_height(self, height): self.bounds[1] = height - self.vpadding # EOF enthought-chaco2-4.5.1.orig/enable/compiled_path.py0000644000175000017500000000151312516137326021310 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # # Author: Enthought, Inc. # Description: #------------------------------------------------------------------------------ # Import the toolkit specific version. from toolkit import toolkit_object CompiledPath = toolkit_object('CompiledPath') #### EOF ###################################################################### enthought-chaco2-4.5.1.orig/enable/abstract_overlay.py0000644000175000017500000000641512516137326022052 0ustar varunvarun""" Abstract base class for overlays. This class is primarily used so that tools can easily distinguish between items underneath them. """ from traits.api import Instance from component import Component class AbstractOverlay(Component): """ The base class for overlays and underlays of the area. The only default additional feature of an overlay is that it implements an overlay() drawing method that overlays this component on top of another, without the components necessarily having an object containment-ownership relationship. """ # The component that this object overlays. This can be None. By default, if # this object is called to draw(), it tries to render onto this component. component = Instance(Component) # The default layer that this component draws into. draw_layer = "overlay" # The background color (overrides PlotComponent). # Typically, an overlay does not render a background. bgcolor = "transparent" #---------------------------------------------------------------------- # Abstract methods (to be implemented by subclasses) #---------------------------------------------------------------------- def overlay(self, other_component, gc, view_bounds=None, mode="normal"): """ Draws this component overlaid on another component. """ # Subclasses should implement this method. pass def _do_layout(self, component=None): """ Called by do_layout() to do an actual layout call; it bypasses some additional logic to handle null bounds and setting **_layout_needed**. """ pass #---------------------------------------------------------------------- # Concrete methods / reimplementations of Component methods #---------------------------------------------------------------------- def __init__(self, component=None, *args, **kw): if component is not None: self.component = component super(AbstractOverlay, self).__init__(*args, **kw) def do_layout(self, size=None, force=False, component=None): """ Tells this component to do a layout at a given size. This differs from the superclass Component.do_layout() in that it accepts an optional **component** argument. """ if self.layout_needed or force: if size is not None: self.bounds = size self._do_layout(component) self._layout_needed = False for underlay in self.underlays: if underlay.visible or underlay.invisible_layout: underlay.do_layout(component) for overlay in self.overlays: if overlay.visible or overlay.invisible_layout: overlay.do_layout(component) return def _draw(self, gc, view_bounds=None, mode="normal"): """ Draws the component, paying attention to **draw_order**. Overrides Component. """ if self.component is not None: self.overlay(self.component, gc, view_bounds, mode) return def _request_redraw(self): """ Overrides Enable Component. """ if self.component is not None: self.component.request_redraw() super(AbstractOverlay, self)._request_redraw() return # EOF enthought-chaco2-4.5.1.orig/enable/stacked_layout.py0000644000175000017500000001341512516137326021517 0ustar varunvarun""" Routines for stacked layout of components in a container """ # TODO: stolen from Chaco PlotContainers, should change their classes to use def stacked_preferred_size(container, components=None): """ Returns the size (width,height) that is preferred for this component. Overrides Component. """ if container.fixed_preferred_size is not None: container._cached_preferred_size = container.fixed_preferred_size return container.fixed_preferred_size #if container.resizable == "": # container._cached_preferred_size = container.outer_bounds[:] # return container.outer_bounds if components is None: components = container.components ndx = container.stack_index other_ndx = 1 - ndx no_visible_components = True total_size = 0 max_other_size = 0 for component in components: if not container._should_layout(component): continue no_visible_components = False pref_size = component.get_preferred_size() total_size += pref_size[ndx] + container.spacing #print container, component, total_size if pref_size[other_ndx] > max_other_size: max_other_size = pref_size[other_ndx] if total_size >= container.spacing: total_size -= container.spacing if (container.stack_dimension not in container.resizable) and \ (container.stack_dimension not in container.fit_components): total_size = container.bounds[ndx] elif no_visible_components or (total_size == 0): total_size = container.default_size[ndx] if (container.other_dimension not in container.resizable) and \ (container.other_dimension not in container.fit_components): max_other_size = container.bounds[other_ndx] elif no_visible_components or (max_other_size == 0): max_other_size = container.default_size[other_ndx] if ndx == 0: container._cached_preferred_size = (total_size + container.hpadding, max_other_size + container.vpadding) else: container._cached_preferred_size = (max_other_size + container.hpadding, total_size + container.vpadding) return container._cached_preferred_size def stack_layout(container, components, align): """ Helper method that does the actual work of layout. """ size = list(container.bounds) if container.fit_components != "": container.get_preferred_size() if "h" in container.fit_components: size[0] = container._cached_preferred_size[0] - container.hpadding if "v" in container.fit_components: size[1] = container._cached_preferred_size[1] - container.vpadding ndx = container.stack_index other_ndx = 1 - ndx other_dim = container.other_dimension # Assign sizes of non-resizable components, and compute the total size # used by them (along the stack dimension). total_fixed_size = 0 resizable_components = [] size_prefs = {} total_resizable_size = 0 for component in components: if not container._should_layout(component): continue if container.stack_dimension not in component.resizable: total_fixed_size += component.outer_bounds[ndx] else: preferred_size = component.get_preferred_size() size_prefs[component] = preferred_size total_resizable_size += preferred_size[ndx] resizable_components.append(component) new_bounds_dict = {} # Assign sizes of all the resizable components along the stack dimension if resizable_components: space = container.spacing * (len(container.components) - 1) avail_size = size[ndx] - total_fixed_size - space if total_resizable_size > 0: scale = avail_size / float(total_resizable_size) for component in resizable_components: tmp = list(component.outer_bounds) tmp[ndx] = int(size_prefs[component][ndx] * scale) new_bounds_dict[component] = tmp else: each_size = int(avail_size / len(resizable_components)) for component in resizable_components: tmp = list(component.outer_bounds) tmp[ndx] = each_size new_bounds_dict[component] = tmp # Loop over all the components, assigning position and computing the # size in the other dimension and its position. cur_pos = 0 for component in components: if not container._should_layout(component): continue position = list(component.outer_position) position[ndx] = cur_pos bounds = new_bounds_dict.get(component, list(component.outer_bounds)) cur_pos += bounds[ndx] + container.spacing if (bounds[other_ndx] > size[other_ndx]) or \ (other_dim in component.resizable): # If the component is resizable in the other dimension or it exceeds the # container bounds, set it to the maximum size of the container #component.set_outer_position(other_ndx, 0) #component.set_outer_bounds(other_ndx, size[other_ndx]) position[other_ndx] = 0 bounds[other_ndx] = size[other_ndx] else: #component.set_outer_position(other_ndx, 0) #old_coord = component.outer_position[other_ndx] position[other_ndx] = 0 if align == "min": pass elif align == "max": position[other_ndx] = size[other_ndx] - bounds[other_ndx] elif align == "center": position[other_ndx] = (size[other_ndx] - bounds[other_ndx]) / 2.0 component.outer_position = position component.outer_bounds = bounds component.do_layout() return enthought-chaco2-4.5.1.orig/enable/primitives/0000755000175000017500000000000012516137725020324 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/primitives/line.py0000644000175000017500000000727712516137326021637 0ustar varunvarun""" A line segment component. """ from __future__ import with_statement from numpy import array, resize # Enthought library imports. from kiva.constants import FILL, FILL_STROKE, STROKE from traits.api import Any, Event, Float, List, Trait, Bool # Local imports. from enable.api import border_size_trait, Component from enable.colors import ColorTrait class Line(Component): """A line segment component""" # Event fired when the points are no longer updating. # PZW: there seems to be a missing defn here; investigate. # An event to indicate that the point list has changed updated = Event # The color of the line. line_color = ColorTrait("black") # The dash pattern for the line. line_dash = Any # The width of the line. line_width = Trait(1, border_size_trait) # The points that make up this polygon. points = List # List of Tuples # The color of each vertex. vertex_color = ColorTrait("black") # The size of each vertex. vertex_size = Float(3.0) # Whether to draw the path closed, with a line back to the first point close_path = Bool(True) #-------------------------------------------------------------------------- # 'Line' interface #-------------------------------------------------------------------------- def reset(self): "Reset the polygon to the initial state" self.points = [] self.event_state = 'normal' self.updated = self return #-------------------------------------------------------------------------- # 'Component' interface #-------------------------------------------------------------------------- def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): "Draw this line in the specified graphics context" if len(self.points) > 1: with gc: # Set the drawing parameters. gc.set_stroke_color(self.line_color_) gc.set_line_dash(self.line_dash) gc.set_line_width(self.line_width) # Draw the path as lines. gc.begin_path() offset_points = [(x, y) for x, y in self.points ] offset_points = resize(array(offset_points), (len(self.points),2)) gc.lines(offset_points) if self.close_path: gc.close_path() gc.draw_path(STROKE) if len(self.points) > 0: with gc: # Draw the vertices. self._draw_points(gc) return #-------------------------------------------------------------------------- # Private interface #-------------------------------------------------------------------------- def _draw_points(self, gc): "Draw the points of the line" # Shortcut out if we would draw transparently. if self.vertex_color_[3] != 0: with gc: gc.set_fill_color(self.vertex_color_) gc.set_line_dash(None) offset_points = [(x, y) for x, y in self.points ] offset_points = resize(array(offset_points), (len(self.points),2)) offset = self.vertex_size / 2.0 if hasattr(gc, 'draw_path_at_points'): path = gc.get_empty_path() path.rect( -offset, -offset, self.vertex_size, self.vertex_size) gc.draw_path_at_points(offset_points, path, FILL_STROKE) else: for x, y in offset_points: gc.draw_rect((x-offset, y-offset, self.vertex_size, self.vertex_size), FILL) return enthought-chaco2-4.5.1.orig/enable/primitives/polygon.py0000644000175000017500000001474112516137326022371 0ustar varunvarun"""A filled polygon component""" # Major package imports. from numpy import array # Enthought library imports. from kiva.constants import EOF_FILL_STROKE, FILL, FILL_STROKE from kiva.agg import points_in_polygon from traits.api import Any, Event, Float, HasTraits, Instance, List, \ Property, Trait, Tuple from traitsui.api import Group, View # Local imports. from enable.api import border_size_trait, Component from enable.colors import ColorTrait class PolygonModel(HasTraits): """ The data model for a Polygon. """ # The points that make up the vertices of this polygon. points = List(Tuple) def reset(self): self.points = [] return class Polygon(Component): """ A filled polygon component. """ #-------------------------------------------------------------------------- # Trait definitions. #-------------------------------------------------------------------------- # The background color of this polygon. background_color = ColorTrait("white") # The color of the border of this polygon. border_color = ColorTrait("black") # The dash pattern to use for this polygon. border_dash = Any # The thickness of the border of this polygon. border_size = Trait(1, border_size_trait) # Event fired when the polygon is "complete". complete = Event # The rule to use to determine the inside of the polygon. inside_rule = Trait('winding', {'winding':FILL_STROKE, 'oddeven':EOF_FILL_STROKE }) # The points that make up this polygon. model = Instance(PolygonModel, ()) # Convenience property to access the model's points. points = Property # The color of each vertex. vertex_color = ColorTrait("black") # The size of each vertex. vertex_size = Float(3.0) traits_view = View(Group('', id = 'component'), Group('', id = 'links'), Group('background_color', '_', 'border_color', '_', 'border_size', id = 'Box', style = 'custom')) colorchip_map = {'color': 'color', 'alt_color': 'border_color'} #-------------------------------------------------------------------------- # Traits property accessors #-------------------------------------------------------------------------- def _get_points(self): return self.model.points #-------------------------------------------------------------------------- # 'Polygon' interface #-------------------------------------------------------------------------- def reset(self): "Reset the polygon to the initial state" self.model.reset() self.event_state = 'normal' return #-------------------------------------------------------------------------- # 'Component' interface #-------------------------------------------------------------------------- def _draw_mainlayer(self, gc, view_bounds=None, mode="normal"): "Draw the component in the specified graphics context" self._draw_closed(gc) return #-------------------------------------------------------------------------- # Protected interface #-------------------------------------------------------------------------- def _is_in(self, point): """ Test if the point (an x, y tuple) is within this polygonal region. To perform the test, we use the winding number inclusion algorithm, referenced in the comp.graphics.algorithms FAQ (http://www.faqs.org/faqs/graphics/algorithms-faq/) and described in detail here: http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm """ point_array = array((point,)) vertices = array(self.model.points) winding = self.inside_rule == 'winding' result = points_in_polygon(point_array, vertices, winding) return result[0] #-------------------------------------------------------------------------- # Private interface #-------------------------------------------------------------------------- def _draw_closed(self, gc): "Draw this polygon as a closed polygon" if len(self.model.points) > 2: # Set the drawing parameters. gc.set_fill_color(self.background_color_) gc.set_stroke_color(self.border_color_) gc.set_line_width(self.border_size) gc.set_line_dash(self.border_dash) # Draw the path. gc.begin_path() gc.move_to(self.model.points[0][0] - self.x, self.model.points[0][1] + self.y) offset_points = [(x - self.x, y + self.y) for x, y in self.model.points] gc.lines(offset_points) gc.close_path() gc.draw_path(self.inside_rule_) # Draw the vertices. self._draw_vertices(gc) return def _draw_open ( self, gc ): "Draw this polygon as an open polygon" if len(self.model.points) > 2: # Set the drawing parameters. gc.set_fill_color( self.background_color_ ) gc.set_stroke_color( self.border_color_ ) gc.set_line_width( self.border_size ) gc.set_line_dash( self.border_dash ) # Draw the path. gc.begin_path() gc.move_to(self.model.points[0][0] - self.x, self.model.points[0][1] + self.y) offset_points = [(x - self.x, y + self.y) for x, y in self.model.points ] gc.lines(offset_points) gc.draw_path(self.inside_rule_) # Draw the vertices. self._draw_vertices(gc) return def _draw_vertices(self, gc): "Draw the vertices of the polygon." gc.set_fill_color(self.vertex_color_) gc.set_line_dash(None) offset = self.vertex_size / 2.0 offset_points = [(x + self.x, y + self.y) for x, y in self.model.points] if hasattr(gc, 'draw_path_at_points'): path = gc.get_empty_path() path.rect(-offset, -offset, self.vertex_size, self.vertex_size) gc.draw_path_at_points(offset_points, path, FILL_STROKE) else: for x, y in offset_points: gc.draw_rect((x - offset, y - offset, self.vertex_size, self.vertex_size), FILL) return # EOF enthought-chaco2-4.5.1.orig/enable/primitives/__init__.py0000644000175000017500000000004712516137326022433 0ustar varunvarun""" Drawing primitives for Enable """ enthought-chaco2-4.5.1.orig/enable/primitives/shape.py0000644000175000017500000001232412516137326021775 0ustar varunvarun""" The base class for moveable shapes. """ # Standard library imports. import math # Enthought library imports. from enable.colors import ColorTrait from enable.component import Component from enable.enable_traits import Pointer from kiva.constants import MODERN from kiva.fonttools import Font from traits.api import Float, Property, Str, Tuple class Shape(Component): """ The base class for moveable shapes. """ #### 'Component' interface ################################################ # The background color of this component. bgcolor = 'transparent' #### 'Shape' interface #################################################### # The coordinates of the center of the shape. center = Property(Tuple) # The fill color. fill_color = ColorTrait # The pointer for the 'normal' event state. normal_pointer = Pointer('arrow') # The pointer for the 'moving' event state. moving_pointer = Pointer('hand') # The text color. text_color = ColorTrait # The text displayed in the shape. text = Str #### 'Private' interface ################################################## # The difference between the location of a mouse-click and the component's # origin. _offset_x = Float _offset_y = Float ########################################################################### # 'Interactor' interface ########################################################################### def normal_key_pressed(self, event): """ Event handler. """ print 'normal_key_pressed', event.character return def normal_left_down(self, event): """ Event handler. """ if self.is_in(event.x, event.y): self.event_state = 'moving' event.window.mouse_owner = self event.window.set_pointer(self.moving_pointer) self._offset_x = event.x - self.x self._offset_y = event.y - self.y # move this shape to the top of the z order. The components are # drawn in order, so the last one will be drawn on top siblings = self.container.components if len(siblings) > 1: siblings.remove(self) siblings.append(self) return def moving_mouse_move(self, event): """ Event handler. """ top = event.y + self._offset_y bottom = event.y - self._offset_y left = event.x - self._offset_x right = event.x + self._offset_x # Keep the shape fully in the container if bottom < 0: bottom = 0 elif top > self.container.height: bottom = self.container.height - self.height if left < 0: left = 0 elif right > self.container.width: left = self.container.width - self.width self.position = [left, bottom] self.request_redraw() return def moving_left_up(self, event): """ Event handler. """ self.event_state = 'normal' event.window.set_pointer(self.normal_pointer) event.window.mouse_owner = None self.request_redraw() return def moving_mouse_leave(self, event): """ Event handler. """ self.moving_left_up(event) return ########################################################################### # 'Shape' interface ########################################################################### def _get_center(self): """ Property getter. """ dx, dy = self.bounds ox, oy = self.position cx = ox + dx/2 cy = oy + dy/2 return cx, cy def _text_default(self): """ Trait initializer. """ return type(self).__name__ ########################################################################### # Protected 'Shape' interface ########################################################################### def _distance_between(self, (x1, y1), (x2, y2)): """ Return the distance between two points. """ return math.sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)) def _draw_text(self, gc): """ Draw the shape's text. """ if len(self.text) > 0: gc.set_fill_color(self._get_text_color(self.event_state)) gc.set_font(Font(family=MODERN, size=16)) tx, ty, tw, th = gc.get_text_extent(self.text) dx, dy = self.bounds x, y = self.position gc.set_text_position(x+(dx-tw)/2, y+(dy-th)/2) gc.show_text(self.text) return def _get_fill_color(self, event_state): """ Return the fill color based on the event state. """ if event_state == 'normal': fill_color = self.fill_color_ else: r, g, b, a = self.fill_color_ fill_color = (r, g, b, 0.5) return fill_color def _get_text_color(self, event_state): """ Return the text color based on the event state. """ if event_state == 'normal': text_color = self.text_color_ else: r, g, b, a = self.text_color_ text_color = (r, g, b, 0.5) return text_color #### EOF ###################################################################### enthought-chaco2-4.5.1.orig/enable/primitives/image.py0000644000175000017500000000451112516137326021756 0ustar varunvarun""" Defines the Image component class. """ from __future__ import absolute_import # Enthought library imports from traits.api import Array, Bool, Enum, Instance, Property, cached_property # Local imports from enable.component import Component from kiva.image import GraphicsContext class Image(Component): """ Component that displays a static image This is extremely simple right now. By default it will draw the array into the entire region occupied by the component, stretching or shrinking as needed. By default the bounds are set to the width and height of the data array, and we provide the same information to constraints-based layout with the layout_size_hint trait. """ #: the image data as an array data = Array(shape=(None, None, (3,4)), dtype='uint8') #: the format of the image data (eg. RGB vs. RGBA) format = Property(Enum('rgb24', 'rgba32'), depends_on='data') #: the size-hint for constraints-based layout layout_size_hint = Property(data, depends_on='data') #: the image as an Image GC _image = Property(Instance(GraphicsContext), depends_on='data') @classmethod def from_file(cls, filename, **traits): from PIL import Image from numpy import asarray data = asarray(Image.open(filename)) return cls(data=data, **traits) def __init__(self, data, **traits): # the default bounds are the size of the image traits.setdefault('bounds', data.shape[1::-1]) super(Image, self).__init__(data=data, **traits) def _draw_mainlayer(self, gc, view_bounds=None, mode="normal"): """ Draws the image. """ with gc: gc.draw_image(self._image, (self.x, self.y, self.width, self.height)) @cached_property def _get_format(self): if self.data.shape[-1] == 3: return 'rgb24' elif self.data.shape[-1] == 4: return 'rgba32' else: raise ValueError('Data array not correct shape') @cached_property def _get_layout_size_hint(self): return self.data.shape[1::-1] @cached_property def _get__image(self): if not self.data.flags['C_CONTIGUOUS']: data = self.data.copy() else: data = self.data image_gc = GraphicsContext(data, pix_format=self.format) return image_gc enthought-chaco2-4.5.1.orig/enable/primitives/api.py0000644000175000017500000000017712516137326021451 0ustar varunvarun from annotater import Annotater from box import Box from line import Line from polygon import Polygon from shape import Shape enthought-chaco2-4.5.1.orig/enable/primitives/annotater.py0000644000175000017500000000520112516137326022664 0ustar varunvarun""" Define an Annotater component that allows a user to annotate an underlying component """ from __future__ import with_statement from traits.api import Event, Trait, TraitPrefixList from traitsui.api import Group, View from enable.api import Component from enable.colors import ColorTrait class Annotater(Component): color = ColorTrait((0.0, 0.0, 0.0, 0.2 )) style = Trait("rectangular", TraitPrefixList(["rectangular", 'freehand'])) annotation = Event traits_view = View(Group('', id = 'component'), Group('', id = 'links'), Group('color', 'style', id = 'annotater', style = 'custom')) #--------------------------------------------------------------------------- # Mouse event handlers #--------------------------------------------------------------------------- def _left_down_changed(self, event): event.handled = True self.window.mouse_owner = self self._cur_x, self._cur_y = event.x, event.y self._start_x, self._start_y = event.x, event.y return def _left_up_changed(self, event): event.handled = True self.window.mouse_owner = None if self.xy_in_bounds(event): self.annotation = (min(self._start_x, event.x), min(self._start_y, event.y), abs(self._start_x - event.x), abs(self._start_y - event.y)) self._start_x = self._start_y = self._cur_x = self._cur_y = None self.redraw() return def _mouse_move_changed(self, event): event.handled = True if self._start_x is not None: x = max(min(event.x, self.right - 1.0), self.x) y = max(min(event.y, self.top - 1.0), self.y) if (x != self._cur_x) or (y != self._cur_y): self._cur_x, self._cur_y = x, y self.redraw() return #--------------------------------------------------------------------------- # "Component" interface #--------------------------------------------------------------------------- def _draw (self, gc): "Draw the contents of the control" if self._start_x is not None: with gc: gc.set_fill_color(self.color_) gc.begin_path() gc.rect(min(self._start_x, self._cur_x), min(self._start_y, self._cur_y), abs(self._start_x - self._cur_x), abs(self._start_y - self._cur_y)) gc.fill_path() return # EOF enthought-chaco2-4.5.1.orig/enable/primitives/box.py0000644000175000017500000000253712516137326021472 0ustar varunvarun""" Define a simple filled box component. """ from __future__ import with_statement # Parent package imports from enable.api import border_size_trait, Component, transparent_color from enable.colors import ColorTrait from kiva.constants import FILL, STROKE class Box(Component): color = ColorTrait("white") border_color = ColorTrait("black") border_size = border_size_trait def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): "Draw the box background in a specified graphics context" # Set up all the control variables for quick access: bs = self.border_size bsd = bs + bs bsh = bs / 2.0 x, y = self.position dx, dy = self.bounds with gc: # Fill the background region (if required); color = self.color_ if color is not transparent_color: gc.set_fill_color(color) gc.draw_rect((x + bs, y + bs, dx - bsd, dy - bsd), FILL) # Draw the border (if required): if bs > 0: border_color = self.border_color_ if border_color is not transparent_color: gc.set_stroke_color(border_color) gc.set_line_width(bs) gc.draw_rect((x + bsh, y + bsh, dx - bs, dy - bs), STROKE) return # EOF enthought-chaco2-4.5.1.orig/enable/text_field_style.py0000644000175000017500000000215512516137326022052 0ustar varunvarun# Enthought library imports from traits.api import HasTraits, Int, Bool from kiva.trait_defs.api import KivaFont from enable.colors import ColorTrait class TextFieldStyle(HasTraits): """ This class holds style settings for rendering an EnableTextField. fixme: See docstring on EnableBoxStyle """ # The color of the text text_color = ColorTrait((0,0,0,1.0)) # The font for the text (must be monospaced!) font = KivaFont("Courier 12") # The color of highlighted text highlight_color = ColorTrait((.65,0,0,1.0)) # The background color of highlighted items highlight_bgcolor = ColorTrait("lightgray") # The font for flagged text (must be monospaced!) highlight_font = KivaFont("Courier 14 bold") # The number of pixels between each line line_spacing = Int(3) # Space to offset text from the widget's border text_offset = Int(5) # Cursor properties cursor_color = ColorTrait((0,0,0,1)) cursor_width = Int(2) # Drawing properties border_visible = Bool(False) border_color = ColorTrait((0,0,0,1)) bgcolor = ColorTrait((1,1,1,1)) enthought-chaco2-4.5.1.orig/enable/null/0000755000175000017500000000000012516137725017103 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/null/__init__.py0000644000175000017500000000000012516137326021177 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/null/image.py0000644000175000017500000000140612516137326020535 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ from kiva.agg import CompiledPath, GraphicsContextArray as GraphicsContext class NativeScrollBar(object): pass class Window(object): pass def font_metrics_provider(): return GraphicsContext((1, 1)) enthought-chaco2-4.5.1.orig/enable/null/ps.py0000644000175000017500000000147512516137326020103 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ from kiva.ps import CompiledPath, PSGC as GraphicsContext class NativeScrollBar(object): pass class Window(object): pass def font_metrics_provider(): from kiva.fonttools import Font gc = GraphicsContext((1, 1)) gc.set_font(Font()) return gc enthought-chaco2-4.5.1.orig/enable/null/qpainter.py0000644000175000017500000000131012516137326021270 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ from kiva.qpainter import CompiledPath, GraphicsContext, font_metrics_provider class NativeScrollBar(object): pass class Window(object): passenthought-chaco2-4.5.1.orig/enable/null/svg.py0000644000175000017500000000130412516137326020247 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ from kiva.svg import CompiledPath, GraphicsContext, font_metrics_provider class NativeScrollBar(object): pass class Window(object): pass enthought-chaco2-4.5.1.orig/enable/null/quartz.py0000644000175000017500000000360312516137326021002 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ import numpy as np from kiva.fonttools import Font from kiva.quartz import ABCGI class NativeScrollBar(object): pass class Window(object): pass CompiledPath = ABCGI.CGMutablePath class GraphicsContext(ABCGI.CGLayerContext): def __init__(self, size_or_array, *args, **kwds): gc = kwds.pop('window_gc', None) if not gc: # Create a tiny base context to spawn the CGLayerContext from. # We are better off making our Layer from the window gc since # the data formats will match and so it will be faster to draw the # layer. gc = ABCGI.CGBitmapContext((1,1)) if isinstance(size_or_array, np.ndarray): # Initialize the layer with an image. image = ABCGI.CGImage(size_or_array) width = image.width height = image.height else: # No initialization. image = None width, height = size_or_array super(GraphicsContext, self).__init__((width, height), gc, *args, **kwds) if image is not None: self.draw_image(image) @classmethod def create_from_gc(klass, gc, size_or_array, *args, **kwds): return klass(size_or_array, gc, *args, **kwds) def font_metrics_provider(): gc = GraphicsContext((1, 1)) gc.set_font(Font()) return gc enthought-chaco2-4.5.1.orig/enable/null/pdf.py0000644000175000017500000000204512516137326020224 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ from kiva.pdf import CompiledPath, GraphicsContext class NativeScrollBar(object): pass class Window(object): pass def font_metrics_provider(): from reportlab.pdfgen.canvas import Canvas from reportlab.lib.pagesizes import letter from kiva.fonttools import Font # a file will not be created unless save() is called on the context pdf_canvas = Canvas(filename='enable_tmp.pdf', pagesize=letter) gc = GraphicsContext(pdf_canvas) gc.set_font(Font()) return gc enthought-chaco2-4.5.1.orig/enable/null/cairo.py0000644000175000017500000000130612516137326020547 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ from kiva.cairo import CompiledPath, GraphicsContext, font_metrics_provider class NativeScrollBar(object): pass class Window(object): pass enthought-chaco2-4.5.1.orig/enable/abstract_window.py0000644000175000017500000005377412516137326021712 0ustar varunvarun # Major library imports from numpy import dot # Enthought library imports from traits.api import Any, Bool, Event, HasTraits, Instance, \ Property, Trait, Tuple, List # Local relative imports from base import bounds_to_coordinates, does_disjoint_intersect_coordinates, \ union_bounds from component import Component from interactor import Interactor from container import Container from colors import ColorTrait def Alias(name): return Property(lambda obj: getattr(obj, name), lambda obj, val: setattr(obj, name, val)) class AbstractWindow(HasTraits): # The top-level component that this window houses component = Instance(Component) # A reference to the nested component that has focus. This is part of the # manual mechanism for determining keyboard focus. focus_owner = Instance(Interactor) # If set, this is the component to which all mouse events are passed, # bypassing the normal event propagation mechanism. mouse_owner = Instance(Interactor) # The transform to apply to mouse event positions to put them into the # relative coordinates of the mouse_owner component. mouse_owner_transform = Any() # When a component captures the mouse, it can optionally store a # dispatch order for events (until it releases the mouse). mouse_owner_dispatch_history = Trait(None, None, List) # The background window of the window. The entire window first gets # painted with this color before the component gets to draw. bgcolor = ColorTrait("sys_window") # Unfortunately, for a while, there was a naming inconsistency and the # background color trait named "bg_color". This is still provided for # backwards compatibility but should not be used in new code. bg_color = Alias("bgcolor") alt_pressed = Bool(False) ctrl_pressed = Bool(False) shift_pressed = Bool(False) # A container that gets drawn after & on top of the main component, and # which receives events first. overlay = Instance(Container) # When the underlying toolkit control gets resized, this event gets set # to the new size of the window, expressed as a tuple (dx, dy). resized = Event # Whether to enable damaged region handling use_damaged_region = Bool(False) # The previous component that handled an event. Used to generate # mouse_enter and mouse_leave events. Right now this can only be # None, self.component, or self.overlay. _prev_event_handler = Instance(Component) # (dx, dy) integer size of the Window. _size = Trait(None, Tuple) # The regions to update upon redraw _update_region = Any #--------------------------------------------------------------------------- # Abstract methods that must be implemented by concrete subclasses #--------------------------------------------------------------------------- def set_drag_result(self, result): """ Sets the result that should be returned to the system from the handling of the current drag operation. Valid result values are: "error", "none", "copy", "move", "link", "cancel". These have the meanings associated with their WX equivalents. """ raise NotImplementedError def _capture_mouse(self): "Capture all future mouse events" raise NotImplementedError def _release_mouse(self): "Release the mouse capture" raise NotImplementedError def _create_key_event(self, event): "Convert a GUI toolkit key event into a KeyEvent" raise NotImplementedError def _create_mouse_event(self, event): "Convert a GUI toolkit mouse event into a MouseEvent" raise NotImplementedError def _redraw(self, coordinates=None): """ Request a redraw of the window, within just the (x,y,w,h) coordinates (if provided), or over the entire window if coordinates is None. """ raise NotImplementedError def _get_control_size(self): "Get the size of the underlying toolkit control" raise NotImplementedError def _create_gc(self, size, pix_format = "bgr24"): """ Create a Kiva graphics context of a specified size. This method only gets called when the size of the window itself has changed. To perform pre-draw initialization every time in the paint loop, use _init_gc(). """ raise NotImplementedError def _init_gc(self): """ Gives a GC a chance to initialize itself before components perform layout and draw. This is called every time through the paint loop. """ gc = self._gc if self._update_region == [] or not self.use_damaged_region: self._update_region = None if self._update_region is None: gc.clear(self.bgcolor_) else: # Fixme: should use clip_to_rects update_union = reduce(union_bounds, self._update_region) gc.clip_to_rect(*update_union) return def _window_paint(self, event): "Do a GUI toolkit specific screen update" raise NotImplementedError def set_pointer(self, pointer): "Sets the current cursor shape" raise NotImplementedError def set_timer_interval(self, component, interval): "Set up or cancel a timer for a specified component" raise NotImplementedError def _set_focus(self): "Sets this window to have keyboard focus" raise NotImplementedError def screen_to_window(self, x, y): "Returns local window coordinates for given global screen coordinates" raise NotImplementedError def get_pointer_position(self): "Returns the current pointer position in local window coordinates" raise NotImplementedError #------------------------------------------------------------------------ # Public methods #------------------------------------------------------------------------ def __init__(self, **traits): self._scroll_origin = (0.0, 0.0) self._update_region = None self._gc = None self._pointer_owner = None HasTraits.__init__(self, **traits) # Create a default component (if necessary): if self.component is None: self.component = Container() return def _component_changed(self, old, new): if old is not None: old.on_trait_change(self.component_bounds_changed, 'bounds', remove=True) old.window = None if new is None: self.component = Container() return new.window = self # If possible, size the new component according to the size of the # toolkit control size = self._get_control_size() if (size is not None) and hasattr(self.component, "bounds"): new.on_trait_change(self.component_bounds_changed, 'bounds') if getattr(self.component, "fit_window", False): self.component.outer_position = [0,0] self.component.outer_bounds = list(size) elif hasattr(self.component, "resizable"): if "h" in self.component.resizable: self.component.outer_x = 0 self.component.outer_width = size[0] if "v" in self.component.resizable: self.component.outer_y = 0 self.component.outer_height = size[1] self._update_region = None self.redraw() return def component_bounds_changed(self, bounds): """ Dynamic trait listener that handles our component changing its size; bounds is a length-2 list of [width, height]. """ self.invalidate_draw() pass def set_mouse_owner(self, mouse_owner, transform=None, history=None): "Handle the 'mouse_owner' being changed" if mouse_owner is None: self._release_mouse() self.mouse_owner = None self.mouse_owner_transform = None self.mouse_owner_dispatch_history = None else: self._capture_mouse() self.mouse_owner = mouse_owner self.mouse_owner_transform = transform self.mouse_owner_dispatch_history = history return def invalidate_draw(self, damaged_regions=None, self_relative=False): if damaged_regions is not None and self._update_region is not None: self._update_region += damaged_regions else: self._update_region = None # print damaged_regions #--------------------------------------------------------------------------- # Generic keyboard event handler: #--------------------------------------------------------------------------- def _handle_key_event(self, event_type, event): """ **event** should be a toolkit-specific opaque object that will be passed in to the backend's _create_key_event() method. It can be None if the the toolkit lacks a native "key event" object. Returns True if the event has been handled within the Enable object hierarchy, or False otherwise. """ # Generate the Enable event key_event = self._create_key_event(event_type, event) if key_event is None: return False self.shift_pressed = key_event.shift_down self.alt_pressed = key_event.alt_down self.control_pressed = key_event.control_down # Dispatch the event to the correct component mouse_owner = self.mouse_owner if mouse_owner is not None: history = self.mouse_owner_dispatch_history if history is not None and len(history) > 0: # Assemble all the transforms transforms = [c.get_event_transform() for c in history] total_transform = reduce(dot, transforms[::-1]) key_event.push_transform(total_transform) elif self.mouse_owner_transform is not None: key_event.push_transform(self.mouse_owner_transform) mouse_owner.dispatch(key_event, event_type) else: # Normal event handling loop if (not key_event.handled) and (self.component is not None): if self.component.is_in(key_event.x, key_event.y): # Fire the actual event self.component.dispatch(key_event, event_type) return key_event.handled #--------------------------------------------------------------------------- # Generic mouse event handler: #--------------------------------------------------------------------------- def _handle_mouse_event(self, event_name, event, set_focus=False): """ **event** should be a toolkit-specific opaque object that will be passed in to the backend's _create_mouse_event() method. It can be None if the the toolkit lacks a native "mouse event" object. Returns True if the event has been handled within the Enable object hierarchy, or False otherwise. """ if self._size is None: # PZW: Hack! # We need to handle the cases when the window hasn't been painted yet, but # it's gotten a mouse event. In such a case, we just ignore the mouse event. # If the window has been painted, then _size will have some sensible value. return False mouse_event = self._create_mouse_event(event) # if no mouse event generated for some reason, return if mouse_event is None: return False mouse_owner = self.mouse_owner if mouse_owner is not None: # A mouse_owner has grabbed the mouse. Check to see if we need to # compose a net transform by querying each of the objects in the # dispatch history in turn, or if we can just apply a saved top-level # transform. history = self.mouse_owner_dispatch_history if history is not None and len(history) > 0: # Assemble all the transforms transforms = [c.get_event_transform() for c in history] total_transform = reduce(dot, transforms[::-1]) mouse_event.push_transform(total_transform) elif self.mouse_owner_transform is not None: mouse_event.push_transform(self.mouse_owner_transform) mouse_owner.dispatch(mouse_event, event_name) self._pointer_owner = mouse_owner else: # Normal event handling loop if self.overlay is not None: # TODO: implement this... pass if (not mouse_event.handled) and (self.component is not None): # Test to see if we need to generate a mouse_leave event if self._prev_event_handler: if not self._prev_event_handler.is_in(mouse_event.x, mouse_event.y): self._prev_event_handler.dispatch(mouse_event, "pre_mouse_leave") mouse_event.handled = False self._prev_event_handler.dispatch(mouse_event, "mouse_leave") self._prev_event_handler = None if self.component.is_in(mouse_event.x, mouse_event.y): # Test to see if we need to generate a mouse_enter event if self._prev_event_handler != self.component: self._prev_event_handler = self.component self.component.dispatch(mouse_event, "pre_mouse_enter") mouse_event.handled = False self.component.dispatch(mouse_event, "mouse_enter") # Fire the actual event self.component.dispatch(mouse_event, "pre_" + event_name) mouse_event.handled = False self.component.dispatch(mouse_event, event_name) # If this event requires setting the keyboard focus, set the first # component under the mouse pointer that accepts focus as the new focus # owner (otherwise, nobody owns the focus): if set_focus: # If the mouse event was a click, then we set the toolkit's # focus to ourselves if mouse_event.left_down or mouse_event.middle_down or \ mouse_event.right_down or mouse_event.mouse_wheel != 0: self._set_focus() if (self.component is not None) and (self.component.accepts_focus): if self.focus_owner is None: self.focus_owner = self.component else: pass return mouse_event.handled #--------------------------------------------------------------------------- # Generic drag event handler: #--------------------------------------------------------------------------- def _handle_drag_event(self, event_name, event, set_focus=False): """ **event** should be a toolkit-specific opaque object that will be passed in to the backend's _create_drag_event() method. It can be None if the the toolkit lacks a native "drag event" object. Returns True if the event has been handled within the Enable object hierarchy, or False otherwise. """ if self._size is None: # PZW: Hack! # We need to handle the cases when the window hasn't been painted yet, but # it's gotten a mouse event. In such a case, we just ignore the mouse event. # If the window has been painted, then _size will have some sensible value. return False drag_event = self._create_drag_event(event) # if no mouse event generated for some reason, return if drag_event is None: return False if self.component is not None: # Test to see if we need to generate a drag_leave event if self._prev_event_handler: if not self._prev_event_handler.is_in(drag_event.x, drag_event.y): self._prev_event_handler.dispatch(drag_event, "pre_drag_leave") drag_event.handled = False self._prev_event_handler.dispatch(drag_event, "drag_leave") self._prev_event_handler = None if self.component.is_in(drag_event.x, drag_event.y): # Test to see if we need to generate a mouse_enter event if self._prev_event_handler != self.component: self._prev_event_handler = self.component self.component.dispatch(drag_event, "pre_drag_enter") drag_event.handled = False self.component.dispatch(drag_event, "drag_enter") # Fire the actual event self.component.dispatch(drag_event, "pre_" + event_name) drag_event.handled = False self.component.dispatch(drag_event, event_name) return drag_event.handled def set_tooltip(self, components): "Set the window's tooltip (if necessary)" raise NotImplementedError def redraw(self): """ Requests that the window be redrawn. """ self._redraw() return def cleanup(self): """ Clean up after ourselves. """ if self.component is not None: self.component.cleanup(self) self.component.parent = None self.component.window = None self.component = None self.control = None if self._gc is not None : self._gc.window = None self._gc = None def _needs_redraw(self, bounds): "Determine if a specified region intersects the update region" return does_disjoint_intersect_coordinates( self._update_region, bounds_to_coordinates( bounds ) ) def _paint(self, event=None): """ This method is called directly by the UI toolkit's callback mechanism on the paint event. """ if self.control is None: # the window has gone away, but let the window implementation # handle the event as needed self._window_paint(event) return # Create a new GC if necessary size = self._get_control_size() if (self._size != tuple(size)) or (self._gc is None): self._size = tuple(size) self._gc = self._create_gc(size) # Always give the GC a chance to initialize self._init_gc() # Layout components and draw if hasattr(self.component, "do_layout"): self.component.do_layout() gc = self._gc self.component.draw(gc, view_bounds=(0, 0, size[0], size[1])) # damaged_regions = draw_result['damaged_regions'] # FIXME: consolidate damaged regions if necessary if not self.use_damaged_region: self._update_region = None # Perform a paint of the GC to the window (only necessary on backends # that render to an off-screen buffer) self._window_paint(event) self._update_region = [] return def __getstate__(self): attribs = ("component", "bgcolor", "overlay", "_scroll_origin") state = {} for attrib in attribs: state[attrib] = getattr(self, attrib) return state #--------------------------------------------------------------------------- # Wire up the mouse event handlers #--------------------------------------------------------------------------- def _on_left_down ( self, event ): self._handle_mouse_event( 'left_down', event, set_focus = True ) def _on_left_up ( self, event ): self._handle_mouse_event( 'left_up', event ) def _on_left_dclick ( self, event ): self._handle_mouse_event( 'left_dclick', event ) def _on_right_down ( self, event ): self._handle_mouse_event( 'right_down', event, set_focus = True ) def _on_right_up ( self, event ): self._handle_mouse_event( 'right_up', event ) def _on_right_dclick ( self, event ): self._handle_mouse_event( 'right_dclick', event ) def _on_middle_down ( self, event ): self._handle_mouse_event( 'middle_down', event ) def _on_middle_up ( self, event ): self._handle_mouse_event( 'middle_up', event ) def _on_middle_dclick ( self, event ): self._handle_mouse_event( 'middle_dclick', event ) def _on_mouse_move ( self, event ): self._handle_mouse_event( 'mouse_move', event, 1 ) def _on_mouse_wheel ( self, event ): self._handle_mouse_event( 'mouse_wheel', event ) def _on_mouse_enter ( self, event ): self._handle_mouse_event( 'mouse_enter', event ) def _on_mouse_leave ( self, event ): self._handle_mouse_event( 'mouse_leave', event, -1 ) # Additional event handlers that are not part of normal Interactors def _on_window_enter(self, event): # TODO: implement this to generate a mouse_leave on self.component pass def _on_window_leave(self, event): if self._size is None: # PZW: Hack! # We need to handle the cases when the window hasn't been painted yet, but # it's gotten a mouse event. In such a case, we just ignore the mouse event. # If the window has been painted, then _size will have some sensible value. self._prev_event_handler = None if self._prev_event_handler: mouse_event = self._create_mouse_event(event) self._prev_event_handler.dispatch(mouse_event, "mouse_leave") self._prev_event_handler = None return #--------------------------------------------------------------------------- # Wire up the keyboard event handlers #--------------------------------------------------------------------------- def _on_key_pressed(self, event): self._handle_key_event('key_pressed', event) def _on_key_released(self, event): self._handle_key_event('key_released', event) def _on_character(self, event): self._handle_key_event('character', event) enthought-chaco2-4.5.1.orig/enable/tools/0000755000175000017500000000000012516137725017271 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tools/apptools/0000755000175000017500000000000012516137725021132 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tools/apptools/resize_command_tool.py0000644000175000017500000000603412516137326025540 0ustar varunvarun# # (C) Copyright 2015 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in # LICENSE.txt # """ ResizeCommandTool ================= A CommandTool that uses AppTools' undo/redo infrastructure to create undoable resize commands. """ from __future__ import (division, absolute_import, print_function, unicode_literals) from traits.api import Bool, Tuple from enable.tools.resize_tool import ResizeTool from .command_tool import BaseCommandTool from .commands import ResizeCommand class ResizeCommandTool(ResizeTool, BaseCommandTool): """ Resize tool which pushes ResizeCommands onto a CommandStack This tool pushes a single ResizeCommand onto its CommandStack at the end of the drag operation. If the drag is cancelled, then no command is issued, and no commands are issued during the drag operation. """ #------------------------------------------------------------------------- # 'ResizeCommandTool' interface #------------------------------------------------------------------------- #: Whether or not subsequent moves can be merged with this one. mergeable = Bool #: The initial component position. _initial_rectangle = Tuple(0, 0, 0, 0) #------------------------------------------------------------------------- # 'DragTool' interface #------------------------------------------------------------------------- def drag_start(self, event): if self.component is not None: # we need to save the initial position to give to the Command self._initial_rectangle = tuple(self.component.position + self.component.bounds) result = super(ResizeCommandTool, self).drag_start(event) return result def drag_end(self, event): """ End the drag operation, issuing a ResizeCommands """ if self.component is not None: command = self.command( component=self.component, new_rectangle=tuple(self.component.position + self.component.bounds), previous_rectangle=self._initial_rectangle, final=True) self.command_stack.push(command) event.handled = True return super(ResizeCommandTool, self).drag_end(event) return True def drag_cancel(self, event): """ Restore the component's position if the drag is cancelled. A drag is usually cancelled by receiving a mouse_leave event when `end_drag_on_leave` is True, or by the user pressing any of the `cancel_keys`. """ if self.component is not None: self.component.position = list(self._initial_rectangle) event.handled = True return True #------------------------------------------------------------------------- # Trait handlers #------------------------------------------------------------------------- def _command_default(self): return ResizeCommand enthought-chaco2-4.5.1.orig/enable/tools/apptools/command_tool.py0000644000175000017500000000253612516137326024162 0ustar varunvarun# # (C) Copyright 2015 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in # LICENSE.txt # """ Command Tools ============= This module provides classes for tools that work with Apptools' Undo/Redo Command stack. """ from __future__ import (division, absolute_import, print_function, unicode_literals) from apptools.undo.api import ICommandStack, IUndoManager from traits.api import Callable, Instance from enable.base_tool import BaseTool class BaseCommandTool(BaseTool): """ A tool which can push commands onto a command stack This is a base class for all tools that want to be able to issue undoable commands. """ # The command that the tool creates in response to user action. command = Callable # The command stack to push to. command_stack = Instance(ICommandStack) class BaseUndoTool(BaseCommandTool): """ A tool with access to an UndoManager This is a base class for all tools that want to be able to access undo and redo functionality. """ # The undo manager undo_manager = Instance(IUndoManager) def undo(self): """ Call undo on the UndoManager """ self.undo_manager.undo() def redo(self): """ Call redo on the UndoManager """ self.undo_manager.redo() enthought-chaco2-4.5.1.orig/enable/tools/apptools/__init__.py0000644000175000017500000000000012516137326023226 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tools/apptools/api.py0000644000175000017500000000165612516137326022262 0ustar varunvarun# # (C) Copyright 2015 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in # LICENSE.txt # """ Enable Apptools Integration =========================== Apptools (https://github.com/enthought/apptools) is a library of useful code for building GUI applications. It includes code for features like preferences, undo/redo support, and seelction management. The code in this sub-package helps applications interface with the functionality provided by Apptools, but is optional from the point of view of the Enable codebase as a whole. """ from __future__ import absolute_import # Support for Undo/Redo with Enable from .commands import ComponentCommand, MoveCommand, ResizeCommand from .command_tool import BaseCommandTool, BaseUndoTool from .move_command_tool import MoveCommandTool from .resize_command_tool import ResizeCommandTool from .undo_tool import UndoTool enthought-chaco2-4.5.1.orig/enable/tools/apptools/move_command_tool.py0000644000175000017500000000537412516137326025213 0ustar varunvarun# # (C) Copyright 2015 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in # LICENSE.txt # """ MoveCommandTool =============== A MoveTool that uses AppTools' undo/redo infrastructure to create undoable move commands. """ from __future__ import (division, absolute_import, print_function, unicode_literals) from traits.api import Bool, Tuple from enable.tools.move_tool import MoveTool from .command_tool import BaseCommandTool from .commands import MoveCommand class MoveCommandTool(MoveTool, BaseCommandTool): """ Move tool which pushes MoveCommands onto a CommandStack This tool pushes a single MoveCommands onto its CommandStack at the end of the drag operation. If the drag is cancelled, then no command is issued, and no commands are issued during the drag operation. """ #------------------------------------------------------------------------- # 'MoveCommandTool' interface #------------------------------------------------------------------------- #: Whether or not subsequent moves can be merged with this one. mergeable = Bool #: The initial component position. _initial_position = Tuple(0, 0) #------------------------------------------------------------------------- # 'DragTool' interface #------------------------------------------------------------------------- def drag_start(self, event): if self.component: # we need to save the initial position to give to the Command self._initial_position = tuple(self.component.position) return super(MoveCommandTool, self).drag_start(event) def drag_end(self, event): """ End the drag operation, issuing a MoveCommands """ if self.component: command = self.command( component=self.component, previous_position=self._initial_position, new_position=tuple(self.component.position), mergeable=self.mergeable) self.command_stack.push(command) event.handled = True def drag_cancel(self, event): """ Restore the component's position if the drag is cancelled. A drag is usually cancelled by receiving a mouse_leave event when `end_drag_on_leave` is True, or by the user pressing any of the `cancel_keys`. """ if self.component: self.component.position = list(self._initial_position) event.handled = True #------------------------------------------------------------------------- # Trait handlers #------------------------------------------------------------------------- def _command_default(self): return MoveCommand enthought-chaco2-4.5.1.orig/enable/tools/apptools/commands.py0000644000175000017500000002142512516137326023306 0ustar varunvarun# # (C) Copyright 2015 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in # LICENSE.txt # """ Enable Commands =============== This module provides :py:class:`apptools.undo.abstract_command.AbstractCommand` subclasses for common component manipulations, such as moving, resizing and setting attribute values. """ from __future__ import (division, absolute_import, print_function, unicode_literals) from apptools.undo.api import AbstractCommand from traits.api import Bool, Instance, Tuple, Unicode from traits.util.camel_case import camel_case_to_words from enable.component import Component class ComponentCommand(AbstractCommand): """ Abstract command which operates on a Component """ #: The component the command is being performed on. component = Instance(Component) #: An appropriate name for the component that can be used by the command. #: The default is the class name, split into words. component_name = Unicode def __init__(self, component, **traits): super(ComponentCommand, self).__init__(component=component, **traits) #------------------------------------------------------------------------- # traits handlers #------------------------------------------------------------------------- def _component_name_default(self): if self.component is not None: return camel_case_to_words(self.component.__class__.__name__) return '' class ResizeCommand(ComponentCommand): """ Command for resizing a component This handles the logic of moving a component and merging successive moves. This class provides ``_change_rectangle`` and ``_merge_data`` methods that subclasses can override to change the reszie behaviour in a uniform way for undo and redo operations. Parameters ---------- component : Component instance The component being moved. new_rectangle : tuple of (x, y, w, h) The rectangle representing the new position and bounds. previous_rectangle : tuple of (x, y, w, h) The rectangle representing the previous position and bounds. **traits : Any other trait values that need to be passed in at creation time. The ``new_rectangle`` argument is the same as the ``data`` trait on the class. If both are provided, the ``new_rectangle`` value is used. """ #: The new rectangle of the component as a tuple (x, y, width, height). data = Tuple #: The old rectangle of the component as a tuple (x, y, width, height). previous_rectangle = Tuple #: whether additional resizes can be merged or if the resize is finished. mergeable = Bool def __init__(self, component, new_rectangle=None, previous_rectangle=None, **traits): if previous_rectangle is None: previous_rectangle = tuple(component.position)+tuple(component.bounds) if new_rectangle is None: if 'data' in traits: data = traits.pop('data') else: raise TypeError("ResizeCommand __init__ method requires " "'new_rectangle' argument.") else: data = new_rectangle super(ResizeCommand, self).__init__( component=component, data=data, previous_rectangle=previous_rectangle, **traits) @classmethod def move_command(cls, component, new_position, previous_position=None, **traits): """ Factory that creates a ResizeCommand implementing a move operation This allows a MoveTool to create move commands that can be easily merged with resize commands. """ bounds = tuple(component.bounds) new_rectangle = new_position + bounds if previous_position is not None: previous_rectangle = previous_position + bounds else: previous_rectangle = None return cls( component=component, new_rectangle=new_rectangle, previous_rectangle=previous_rectangle, **traits) #------------------------------------------------------------------------- # AbstractCommand interface #------------------------------------------------------------------------- def merge(self, other): if self.mergeable and isinstance(other, self.__class__) and \ other.component == self.component: return self._merge_data(other) return super(ResizeCommand, self).merge(other) def do(self): if self.previous_rectangle == (): self.previous_rectangle = tuple(self.component.position + self.component.bounds) self.redo() def redo(self): self._change_rectangle(self.data) def undo(self): self._change_rectangle(self.previous_rectangle) #------------------------------------------------------------------------- # Private interface #------------------------------------------------------------------------- def _change_rectangle(self, rectangle): x, y, w, h = rectangle self.component.position = [x, y] self.component.bounds = [w, h] self.component._layout_needed = True self.component.request_redraw() def _merge_data(self, other): self.data = other.data self.mergeable = other.mergeable return True #------------------------------------------------------------------------- # traits handlers #------------------------------------------------------------------------- def _name_default(self): return "Resize "+self.component_name class MoveCommand(ComponentCommand): """ A command that moves a component This handles the logic of moving a component and merging successive moves. This class provides ``_change_position`` and ``_merge_data`` methods that subclasses can override to change the move behaviour in a uniform way for undo and redo operations. Parameters ---------- component : Component instance The component being moved. new_position : tuple of (x, y) The tuple representing the new position. previous_position : tuple of (x, y) The tuple representing the previous position. **traits : Any other trait values that need to be passed in at creation time. The ``new_position`` argument is the same as the ``data`` trait on the class. If both are provided, the ``new_position`` value is used. """ #: The new position of the component as a tuple (x, y). data = Tuple #: The old position of the component as a tuple (x, y). previous_position = Tuple #: whether additional moves can be merged or if the move is finished. mergeable = Bool def __init__(self, component, new_position=None, previous_position=None, **traits): if previous_position is None: previous_position = component.position if new_position is None: if 'data' in traits: data = traits.pop('data') else: raise TypeError("MoveCommand __init__ method requires " "'new_position' argument.") else: data = new_position super(MoveCommand, self).__init__( component=component, data=data, previous_position=previous_position, **traits) #------------------------------------------------------------------------- # AbstractCommand interface #------------------------------------------------------------------------- def do(self): self.redo() def redo(self): self._change_position(self.data) def undo(self): self._change_position(self.previous_position) def merge(self, other): if self.mergeable and isinstance(other, self.__class__) and \ other.component == self.component: return self._merge_data(other) return super(MoveCommand, self).merge(other) #------------------------------------------------------------------------- # Private interface #------------------------------------------------------------------------- def _change_position(self, position): self.component.position = list(position) self.component._layout_needed = True self.component.request_redraw() def _merge_data(self, other): self.data = other.data self.mergeable = other.mergeable return True #------------------------------------------------------------------------- # traits handlers #------------------------------------------------------------------------- def _name_default(self): return "Move "+self.component_name enthought-chaco2-4.5.1.orig/enable/tools/apptools/undo_tool.py0000644000175000017500000000274212516137326023510 0ustar varunvarun# # (C) Copyright 2015 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in # LICENSE.txt # """ UndoTool ======== Tool that triggers undo or redo when keys are pressed. """ from __future__ import (division, absolute_import, print_function, unicode_literals) # Enthought library imports from traits.api import Instance, List # Local library imports from enable.base_tool import KeySpec from .command_tool import BaseUndoTool # default undo/redo/clear key specifications ctrl_z = KeySpec('z', 'control') ctrl_shift_z = KeySpec('z', 'control', 'shift') class UndoTool(BaseUndoTool): """ Tool that triggers undo or redo when keys are pressed """ #: the key sequences which trigger undo actions undo_keys = List(Instance(KeySpec), [ctrl_z]) #: the key sequences which trigger redo actions redo_keys = List(Instance(KeySpec), [ctrl_shift_z]) def normal_key_pressed(self, event): """ Respond to key presses which match either the undo or redo keys """ if self.undo_manager is not None: for key in self.undo_keys: if key.match(event): self.undo_manager.undo() event.handled = True return for key in self.redo_keys: if key.match(event): self.undo_manager.redo() event.handled = True return enthought-chaco2-4.5.1.orig/enable/tools/button_tool.py0000644000175000017500000000644612516137326022222 0ustar varunvarun# # (C) Copyright 2015 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in # LICENSE.txt # """ ButtonTool ========== A simple tool that responds to mouse clicks. """ from traits.api import Bool, Event from enable.base_tool import BaseTool class ButtonTool(BaseTool): """ A button tool This tool allows any component to act like either a push button or a toggle button (such as a checkbox) with appropriate traits listeners. Components which use this class can listen to the ``clicked`` event or listen to the ``checked`` state, depending on whether they want "push button" or "check box" style behaviour. Components may also want to listen to the ``down`` attribute to change the way that they are drawn in response to the mouse position, for example by highlighting the component. """ #------------------------------------------------------------------------- # 'ButtonTool' interface #------------------------------------------------------------------------- #: Event fired when button is clicked clicked = Event #: Is the button toggled? checked = Bool(False) #: Is the mouse button pressed down in the clickable region down = Bool(False) #: whether or not the button can be pressed. enabled = Bool(True) #: whether or not the button can be toggled (eg. checkbox or radio button). togglable = Bool(False) def is_clickable(self, x, y): """ Is the (x,y) position in a region that responds to clicks. Used by the tool to determine when to start a click and when the button should be considered pressed down (this controls the state of the ``down`` trait). """ return self.component.is_in(x, y) def click(self): """ Perform a click, toggling if needed, and firing the clicked event This doesn't change the state of the ``down`` trait. """ if self.togglable: self.toggle() self.clicked = True def toggle(self): """ Toggle the state of the button. This does not fire the clicked event. Default is to invert the checked state, but subclasses could implement move complex cycling of toggle states. """ self.checked = not self.checked #------------------------------------------------------------------------- # 'BaseTool' stateful event handlers #------------------------------------------------------------------------- def normal_left_down(self, event): if self.enabled and self.is_clickable(event.x, event.y): event.window.mouse_owner = self self.down = True self.event_state = 'pressed' self.component.active_tool = self event.handled = True def pressed_mouse_move(self, event): self.down = self.is_clickable(event.x, event.y) def pressed_mouse_leave(self, event): self.down = False def pressed_mouse_enter(self, event): self.down = self.is_clickable(event.x, event.y) def pressed_left_up(self, event): if self.down: self.click() event.handled = True event.window.mouse_owner = None self.down = False self.event_state = "normal" enthought-chaco2-4.5.1.orig/enable/tools/base_drop_tool.py0000644000175000017500000000716212516137326022641 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2014, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ """ Abstract base class for tools that handle drag and drop """ from __future__ import absolute_import, print_function, division from traits.api import Enum from enable.base_tool import BaseTool class BaseDropTool(BaseTool): """ Abstract base class for tools that handle drag and drop """ default_drag_result = Enum("copy", "move", "link", "cancel", "error", "none") def normal_drag_over(self, event): """ Handle dragging over the component """ if event.handled: return try: result = self.get_drag_result((event.x, event.y), event.obj) if result is not None: event.window.set_drag_result(result) event.handled = True except Exception: event.window.set_drag_result("error") raise def normal_dropped_on(self, event): if event.handled: return position = (event.x, event.y) if self.accept_drop(position, event.obj): self.handle_drop(position, event.obj) event.handled = True def get_drag_result(self, position, obj): """ The type of drag that will happen By default, if the dragged objects are available this method calls accept_drop() and returns "none" if the result is False, otherwise it returns the value of default_drag_result. Parameters ---------- position : The coordinates of the drag over event obj : any The object(s) being dragged, if available. Some backends (such as Wx) may not be able to provide the object being dragged, in which case `obj` will be `None`. Returns ------- Either None, if the drop should be ignored by this tool and not handled, or one of the keys of DRAG_RESULTS_MAP: "none", "copy, "move", "link", "cancel" or "error". """ if obj is not None: # if we have the object, see if we can accept if not self.accept_drop(position, obj): return None return self.default_drag_result def accept_drop(self, position, obj): """ Whether or not to accept the drop Subclasses should override this method. Parameters ---------- position : The coordinates of the drag over event obj : any The object(s) being dragged, if available. Some backends (such as Wx) may not be able to provide the object being dragged, in which case `obj` will be `None`. Returns ------- True if the drop should be accepted, False otherwise. """ raise NotImplementedError def handle_drop(self, position, obj): """ Handle objects being dropped on the component Subclasses should override this method. Parameters ---------- position : The coordinates of the drag over event obj : any The object(s) being dragged. """ raise NotImplementedError enthought-chaco2-4.5.1.orig/enable/tools/__init__.py0000644000175000017500000000000012516137326021365 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tools/base_zoom_tool.py0000644000175000017500000000540512516137326022657 0ustar varunvarun""" Defines the base class for various types of zoom tools. """ from numpy import allclose, inf # Enthought library imports from traits.api import Enum, Float, HasTraits class BaseZoomTool(HasTraits): """ Defines traits and methods to actually perform the logic of zooming onto a plot. """ # If the tool only applies to a particular axis, this attribute is used to # determine which range to use. axis = Enum("x", "y") # The maximum ratio between the original data space bounds and the zoomed-in # data space bounds. If None, then there is no limit (not advisable!). max_zoom_in_factor = Float(1e5, allow_none=True) # The maximum ratio between the zoomed-out data space bounds and the original # bounds. If None, then there is no limit. max_zoom_out_factor = Float(1e5, allow_none=True) def _zoom_limit_reached(self, orig_position, orig_bounds, new_position, new_bounds): """ Returns True if the new low and high exceed the maximum zoom limits """ if orig_bounds == inf: # There isn't really a good way to handle the case when the # original bounds were infinite, since any finite zoom # range will certainly exceed whatever zoom factor is set. # In this case, we just allow unbounded levels of zoom. return False if allclose(orig_bounds, 0.0): return True if allclose(new_bounds, 0.0): return True if (new_bounds / orig_bounds) > self.max_zoom_out_factor or \ (orig_bounds / new_bounds) > self.max_zoom_in_factor: return True return False #------------------------------------------------------------------------ # Utility methods for computing axes, coordinates, etc. #------------------------------------------------------------------------ def _get_range_index(self): """ Returns the index into the view_position and view_bounds depending on value of self.axis. """ if self.axis == 'x': return 0 else: return 1 def _get_axis_coord(self, event, axis="x"): """ Returns the coordinate of the event along the axis of interest to the tool (or along the orthogonal axis, if axis="value"). """ event_pos = (event.x, event.y) if axis == "x": return event_pos[ self._determine_axis() ] else: return event_pos[ 1 - self._determine_axis() ] def _determine_axis(self): """ Determines whether the index of the coordinate along the axis of interest is the first or second element of an (x,y) coordinate tuple. """ if self.axis == "x": return 0 else: return 1 # EOF enthought-chaco2-4.5.1.orig/enable/tools/api.py0000644000175000017500000000047712516137326020421 0ustar varunvarunfrom drag_tool import DragTool from hover_tool import HoverTool from move_tool import MoveTool from resize_tool import ResizeTool from traits_tool import TraitsTool from viewport_pan_tool import ViewportPanTool from viewport_zoom_tool import ViewportZoomTool from value_drag_tool import ValueDragTool, AttributeDragToolenthought-chaco2-4.5.1.orig/enable/tools/toolbars/0000755000175000017500000000000012516137725021116 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tools/toolbars/toolbar_buttons.py0000644000175000017500000001041612516137326024707 0ustar varunvarun from __future__ import with_statement # Enthought library imports from enable.api import ColorTrait, Component from enable.font_metrics_provider import font_metrics_provider from kiva.trait_defs.kiva_font_trait import KivaFont from traits.api import Bool, Enum, Instance, Int, Property, Str, Tuple class Button(Component): color = ColorTrait((0.6, 0.6, 0.6, 1.0)) down_color = ColorTrait("gray") border_color = ColorTrait((0.4, 0.4, 0.4, 1.0)) # important for rendering rounded buttons properly, since the default for # the Component parent class is 'white' bgcolor = "clear" label = Str label_font = KivaFont("modern 11 bold") label_color = ColorTrait("white") label_shadow = ColorTrait("gray") shadow_text = Bool(True) label_padding = Int(5) height = Int(20) button_state = Enum("up", "down") end_radius = Int(10) # Default size of the button if no label is present bounds=[32,32] # Cached value of the measured sizes of self.label _text_extents = Tuple def perform(self, event): """ Called when the button is depressed. 'event' is the Enable mouse event that triggered this call. """ pass def _draw_mainlayer(self, gc, view_bounds, mode="default"): if self.button_state == "up": self.draw_up(gc, view_bounds) else: self.draw_down(gc, view_bounds) return def draw_up(self, gc, view_bounds): with gc: gc.set_fill_color(self.color_) self._draw_actual_button(gc) return def draw_down(self, gc, view_bounds): with gc: gc.set_fill_color(self.down_color_) self._draw_actual_button(gc) return def _draw_actual_button(self, gc): gc.set_stroke_color(self.border_color_) gc.begin_path() gc.move_to(self.x + self.end_radius, self.y) gc.arc_to(self.x + self.width, self.y, self.x + self.width, self.y + self.end_radius, self.end_radius) gc.arc_to(self.x + self.width, self.y + self.height, self.x + self.width - self.end_radius, self.y + self.height, self.end_radius) gc.arc_to(self.x, self.y + self.height, self.x, self.y, self.end_radius) gc.arc_to(self.x, self.y, self.x + self.width + self.end_radius, self.y, self.end_radius) gc.draw_path() self._draw_label(gc) def _draw_label(self, gc): if self.label != "": if self._text_extents is None or len(self._text_extents) == 0: self._recompute_font_metrics() x,y,w,h = self._text_extents gc.set_font(self.label_font) text_offset = 0.0 if self.shadow_text: # Draw shadow text gc.set_fill_color(self.label_shadow_) x_pos = self.x + (self.width-w-x)/2 + 0.5 y_pos = self.y + (self.height-h-y)/2 - 0.5 gc.show_text_at_point(self.label, x_pos, y_pos) text_offset = 0.5 # Draw foreground text to button gc.set_fill_color(self.label_color_) x_pos = self.x + (self.width-w-x)/2 - text_offset y_pos = self.y + (self.height-h-y)/2 + text_offset gc.show_text_at_point(self.label, x_pos, y_pos) return def normal_left_down(self, event): self.button_state = "down" self.request_redraw() event.handled = True return def normal_left_up(self, event): self.button_state = "up" self.request_redraw() self.perform(event) event.handled = True return def _recompute_font_metrics(self): if self.label != "": metrics = font_metrics_provider() metrics.set_font(self.label_font) self._text_extents = metrics.get_text_extent(self.label) def _label_font_changed(self, old, new): self._recompute_font_metrics() def _label_changed(self, old, new): self._recompute_font_metrics() class SampleButtonButton(Button): label = Str('Sample Button') def perform(self, event): print "this button is a sample" return enthought-chaco2-4.5.1.orig/enable/tools/toolbars/viewport_toolbar.py0000644000175000017500000000703312516137326025071 0ustar varunvarun from __future__ import with_statement # Library imports # Enthought Library imports from enable.api import AbstractOverlay, Container, ColorTrait from enable.font_metrics_provider import font_metrics_provider from traits.api import Enum, Bool, Float, Int, Type, List # Local imports from toolbar_buttons import Button class ViewportToolbar(Container, AbstractOverlay): """ ViewportToolbar is a toolbar that is attached to the top of a viewport on the block canvas. """ button_spacing = Int(5) button_vposition = Int(6) always_on = Bool(True) toolbar_height = Float(30.0) order = Enum("left-to-right", "right-to-left") buttons = List(Type(Button)) # Override default values for inherited traits auto_size = False bgcolor = ColorTrait((0.5, 0.5, 0.5, 0.25)) def __init__(self, component=None, *args, **kw): # self.component should be a CanvasViewport self.component = component for buttontype in self.buttons: self.add_button(buttontype()) super(ViewportToolbar, self).__init__(*args, **kw) def _do_layout(self, component=None): if component is None: component = self.component if component is not None: self.x = component.x # FIXME: Adding 2 to the self.y because there is a tiny gap # at the top of the toolbar where components from the block # canvas show through. self.y = component.y2 - self.toolbar_height + 2 self.height = self.toolbar_height self.width = component.width metrics = font_metrics_provider() if self.order == "right-to-left": last_button_position = self.width - self.button_spacing for b in self.components: x, y, w, h = metrics.get_text_extent(b.label) b.width = w + 2*b.label_padding b.x = last_button_position - b.width b.y = self.button_vposition last_button_position -= b.width + self.button_spacing*2 else: last_button_position = 0 for b in self.components: x, y, w, h = metrics.get_text_extent(b.label) b.width = w + 2*b.label_padding b.x = self.button_spacing + last_button_position b.y = self.button_vposition last_button_position += b.width + self.button_spacing*2 def overlay(self, other_component, gc, view_bounds=None, mode="normal"): c = other_component self.do_layout(component=c) with gc: gc.clip_to_rect(c.x, c.y, c.width, c.height) Container._draw(self, gc, view_bounds) return def add_button(self, button): self.add(button) button.toolbar_overlay = self self._layout_needed = True return class HoverToolbar(ViewportToolbar): # This is sort of a hack to make the container handle events like a plain # container. We also want this overlay to be "opaque", so that events # inside it don't continue propagating. def _dispatch_stateful_event(self, event, suffix): Container._dispatch_stateful_event(self, event, suffix) if not event.handled: if self.is_in(event.x, event.y): event.handled = True return def _container_handle_mouse_event(self, event, suffix): if not self.is_in(event.x, event.y) and self.component.auto_hide: self.component.remove_toolbar() self.component.request_redraw() return enthought-chaco2-4.5.1.orig/enable/tools/toolbars/__init__.py0000644000175000017500000000000012516137326023212 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tools/traits_tool.py0000644000175000017500000000675112516137326022214 0ustar varunvarun""" Defines the TraitsTool and Fifo classes, and get_nested_components function. """ # Enthought library imports from enable.base_tool import BaseTool from enable.container import Container class Fifo: """ Slightly-modified version of the Fifo class from the Python cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/68436 """ def __init__(self): self.nextin = 0 self.nextout = 0 self.data = {} def append(self, value): self.data[self.nextin] = value self.nextin += 1 def extend(self, values): if len(values) > 0: for i,val in enumerate(values): self.data[i+self.nextin] = val self.nextin += i+1 def isempty(self): return self.nextout >= self.nextin def pop(self): value = self.data[self.nextout] del self.data[self.nextout] self.nextout += 1 return value def get_nested_components(container): """ Returns a list of fundamental plotting components from a container with nested containers. Performs a breadth-first search of the containment hierarchy. Each element in the returned list is a tuple (component, (x,y)) where (x,y) is the coordinate frame offset of the component from the top-level container. """ components = [] worklist = Fifo() worklist.append((container, (0,0))) while 1: item, offset = worklist.pop() if isinstance(item, Container): new_offset = (offset[0]+item.x, offset[1]+item.y) for c in item.components: worklist.append((c, new_offset)) if worklist.isempty(): break return components class TraitsTool(BaseTool): """ Tool to edit the traits of whatever Enable component happens to be clicked. Handles containers and canvases so that they get edited only if their background regions are clicked. """ # This tool does not have a visual representation (overrides BaseTool). draw_mode = "none" # This tool is not visible (overrides BaseTool). visible = False def normal_left_dclick(self, event): """ Handles the left mouse button being double-clicked when the tool is in the 'normal' state. If the event occurred on this tool's component (or any contained component of that component), the method opens a Traits UI view on the component that was double-clicked, setting the tool as the active tool for the duration of the view. """ x = event.x y = event.y # First determine what component or components we are going to hittest # on. If our component is a container, then we add its non-container # components to the list of candidates. candidates = [] component = self.component if isinstance(component, Container): candidates = get_nested_components(self.component) else: # We don't support clicking on unrecognized components return # Hittest against all the candidate and take the first one item = None for candidate, offset in candidates: if candidate.is_in(x-offset[0], y-offset[1]): item = candidate break if item: self.component.active_tool = self item.edit_traits(kind="livemodal") event.handled = True self.component.active_tool = None item.request_redraw() return # EOF enthought-chaco2-4.5.1.orig/enable/tools/drag_tool.py0000644000175000017500000001656512516137326021627 0ustar varunvarun""" Defines the base DragTool class. """ # Enthought library imports from traits.api import Bool, Enum, Tuple, Property, cached_property, List, Str from enable.base_tool import BaseTool, KeySpec class DragTool(BaseTool): """ Base class for tools that are activated by a drag operation. This tool insulates the drag operation from double clicks and the like, and gracefully manages the transition into and out of drag mode. """ # The mouse button used for this drag operation. drag_button = Enum("left", "right") # End the drag operation if the mouse leaves the associated component? end_drag_on_leave = Bool(True) # These keys, if pressed during drag, cause the drag operation to reset. cancel_keys = List(Str, ["Esc"]) # The position of the initial mouse click that started the drag. # Typically, tools that move things around use this # position to do hit-testing to determine what object to "pick up". mouse_down_position = Tuple(0.0, 0.0) # The modifier key that must be used to activate the tool. modifier_key = Enum("none", "shift", "alt", "control") # Whether or not to capture the mouse during the drag operation. In # general this is a good idea. capture_mouse = Bool(True) #------------------------------------------------------------------------ # Private traits used by DragTool #------------------------------------------------------------------------ # The possible states of this tool. _drag_state = Enum("nondrag", "dragging") # Records whether a mouse_down event has been received while in # "nondrag" state. This is a safety check to prevent the tool from # suddenly getting mouse focus while the mouse button is down (either from # window_enter or programmatically) and erroneously # initiating a drag. _mouse_down_received = Bool(False) # private property to hold the current list of KeySpec instances of the # cancel keys _cancel_keys = Property(List(KeySpec), depends_on='cancel_keys') #------------------------------------------------------------------------ # Interface for subclasses #------------------------------------------------------------------------ def is_draggable(self, x, y): """ Returns whether the (x,y) position is in a region that is OK to drag. Used by the tool to determine when to start a drag. """ return True def drag_start(self, event): """ Called when the drag operation starts. The *event* parameter is the mouse event that established the drag operation; its **x** and **y** attributes correspond to the current location of the mouse, and not to the position of the mouse when the initial left_down or right_down event happened. """ pass def dragging(self, event): """ This method is called for every mouse_move event that the tool receives while the user is dragging the mouse. It is recommended that subclasses do most of their work in this method. """ pass def drag_cancel(self, event): """ Called when the drag is cancelled. A drag is usually cancelled by receiving a mouse_leave event when end_drag_on_leave is True, or by the user pressing any of the **cancel_keys**. """ pass def drag_end(self, event): """ Called when a mouse event causes the drag operation to end. """ pass #------------------------------------------------------------------------ # Private methods for handling drag #------------------------------------------------------------------------ def _dispatch_stateful_event(self, event, suffix): # We intercept a lot of the basic events and re-map them if # necessary. "consume" indicates whether or not we should pass # the event to the subclass's handlers. consume = False if suffix == self.drag_button + "_down": consume = self._drag_button_down(event) elif suffix == self.drag_button + "_up": consume = self._drag_button_up(event) elif suffix == "mouse_move": consume = self._drag_mouse_move(event) elif suffix == "mouse_leave": consume = self._drag_mouse_leave(event) elif suffix == "mouse_enter": consume = self._drag_mouse_enter(event) elif suffix == "key_pressed": consume = self._drag_cancel_keypressed(event) if not consume: BaseTool._dispatch_stateful_event(self, event, suffix) else: event.handled = True return def _cancel_drag(self, event): self._drag_state = "nondrag" outcome = self.drag_cancel(event) self._mouse_down_received = False if event.window.mouse_owner == self: event.window.set_mouse_owner(None) return outcome def _drag_cancel_keypressed(self, event): if self._drag_state != "nondrag" and \ any(map(lambda x: x.match(event), self._cancel_keys)): return self._cancel_drag(event) else: return False def _drag_mouse_move(self, event): state = self._drag_state button_down = getattr(event, self.drag_button + "_down") if state == "nondrag": if button_down and self._mouse_down_received and \ self.is_draggable(*self.mouse_down_position): self._drag_state = "dragging" if self.capture_mouse: event.window.set_mouse_owner( self, transform=event.net_transform(), history=event.dispatch_history) self.drag_start(event) return self._drag_mouse_move(event) return False elif state == "dragging": if button_down: return self.dragging(event) else: return self._drag_button_up(event) # If we don't invoke the subclass drag handler, then don't consume the # event. return False def _drag_button_down(self, event): if self._drag_state == "nondrag": self.mouse_down_position = (event.x, event.y) self._mouse_down_received = True return False def _drag_button_up(self, event): self._mouse_down_received = False state = self._drag_state if event.window.mouse_owner == self: event.window.set_mouse_owner(None) if state == "dragging": self._drag_state = "nondrag" return self.drag_end(event) # If we don't invoke the subclass drag handler, then don't consume the # event. return False def _drag_mouse_leave(self, event): if self.end_drag_on_leave and self._drag_state == "dragging": return self._cancel_drag(event) return False def _drag_mouse_enter(self, event): state = self._drag_state if state == "nondrag": pass elif state == "dragging": pass return False #------------------------------------------------------------------------ # Private methods for trait getter/setters #------------------------------------------------------------------------ @cached_property def _get__cancel_keys(self): return [KeySpec(key) for key in self.cancel_keys] # EOF enthought-chaco2-4.5.1.orig/enable/tools/move_tool.py0000644000175000017500000000325612516137326021651 0ustar varunvarun from traits.api import Bool, Enum, Tuple from drag_tool import DragTool class MoveTool(DragTool): """ Generic tool for moving a component's position relative to its container """ drag_button = Enum("left", "right") # Should the moved component be raised to the top of its container's # list of components? This is only recommended for overlaying containers # and canvases, but generally those are the only ones in which the # MoveTool will be useful. auto_raise = Bool(True) # The last cursor position we saw; used during drag to compute deltas _prev_pos = Tuple(0, 0) def is_draggable(self, x, y): if self.component: c = self.component return (c.x <= x <= c.x2) and (c.y <= y <= c.y2) else: return False def drag_start(self, event): if self.component: self._prev_pos = (event.x, event.y) self.component._layout_needed = True if self.auto_raise: # Push the component to the top of its container's list self.component.container.raise_component(self.component) event.window.set_mouse_owner(self, event.net_transform()) event.handled = True return def dragging(self, event): if self.component: dx = event.x - self._prev_pos[0] dy = event.y - self._prev_pos[1] pos = self.component.position self.component.position = [pos[0] + dx, pos[1] + dy] self.component._layout_needed = True self.component.request_redraw() self._prev_pos = (event.x, event.y) event.handled = True return enthought-chaco2-4.5.1.orig/enable/tools/pyface/0000755000175000017500000000000012516137725020540 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tools/pyface/__init__.py0000644000175000017500000000000012516137326022634 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tools/pyface/context_menu_tool.py0000644000175000017500000000441712516137326024662 0ustar varunvarun# # (C) Copyright 2012 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in # LICENSE.txt # """ This is a minimum example for adding a context menu to plot. """ from pyface.action.api import MenuManager, ActionController from traits.api import Instance, Any from enable.base_tool import BaseTool class EnableActionController(ActionController): """ An action controller that keeps a reference to the enable event that triggered the action. """ #: the enable event which triggered the popup menu enable_event = Any def perform(self, action, event): """ Control an action invocation We make the original enable event available to the action by adding it to the pyface event. """ event.enable_event = self.enable_event return action.perform(event) class ContextMenuTool(BaseTool): """ Pops up a context menu when the component receives a right click """ #: the pyface action MenuManager instance menu_manager = Instance(MenuManager) #: an optional ActionController controller = Instance(ActionController) def normal_right_down(self, event): """ Handles the right mouse button being pressed. """ if self.menu_manager is not None: if self.is_showable(event.x, event.y): self.show_menu(event) event.handled = True def is_showable(self, x, y): """ Returns whether the (x, y) position is OK for showing the menu By default checks that the point is in the component. Subclasses can override to provide more refined hit-testing. """ return self.component.is_in(x, y) def show_menu(self, event): """ Create the toolkit menu and show it This method also makes the enable event available to the controller. """ controller = self.controller if controller is None: controller = self.menu_manager.controller if controller is None: controller = EnableActionController(enable_event=event) else: controller.enable_event = event menu = self.menu_manager.create_menu(event.window.control, controller) menu.show() enthought-chaco2-4.5.1.orig/enable/tools/value_drag_tool.py0000644000175000017500000002073212516137326023012 0ustar varunvarun# # (C) Copyright 2012 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in # LICENSE.txt # """ Value Drag Tools ================ This module contains tools to handle simple dragging interactions where the drag operation has a direct effect on some underlying value. This can potentially be used as the basis for many different interactions, """ from traits.api import Str, Float, Set, Enum, Bool, Tuple, Dict, Event, Any, Either from .drag_tool import DragTool keys = set(['shift', 'alt', 'control']) class IdentityMapper(object): def map_data(self, screen): return screen def map_screen(self, data): return data identity_mapper = IdentityMapper() class ValueDragTool(DragTool): """ Abstract tool for modifying a value as the mouse is dragged The tool allows the use of an x_mapper and y_mapper to map between screen coordinates and more abstract data coordinates. These mappers must be objects with a map_data() method that maps a component-space coordinate to a data-space coordinate. Chaco mappers satisfy the required API, and the tool will look for 'x_mapper' and 'y_mapper' attributes on the component to use as the defaults, facilitating interoperability with Chaco plots. Failing that, a simple identity mapper is provided which does nothing. Coordinates are given relative to the component. Subclasses of this tool need to supply get_value() and set_delta() methods. The get_value method returns the current underlying value, while the set_delta method takes the current mapped x and y deltas from the original position, and sets the underlying value appropriately. The object stores the original value at the start of the operation as the original_value attribute. """ #: set of modifier keys that must be down to invoke the tool modifier_keys = Set(Enum(*keys)) #: mapper that maps from horizontal screen coordinate to data coordinate x_mapper = Any #: mapper that maps from vertical screen coordinate to data coordinate y_mapper = Any #: start point of the drag in component coordinates original_screen_point = Tuple(Float, Float) #: start point of the drag in data coordinates original_data_point = Tuple(Any, Any) #: initial underlying value original_value = Any #: new_value event for inspector overlay new_value = Event(Dict) #: visibility for inspector overlay visible = Bool(False) def get_value(self): """ Return the current value that is being modified """ pass def set_delta(self, value, delta_x, delta_y): """ Set the value that is being modified This function should modify the underlying value based on the provided delta_x and delta_y in data coordinates. These deltas are total displacement from the original location, not incremental. The value parameter is the original value at the point where the drag started. """ pass # Drag tool API def drag_start(self, event): self.original_screen_point = (event.x, event.y) data_x = self.x_mapper.map_data(event.x) data_y = self.y_mapper.map_data(event.y) self.original_data_point = (data_x, data_y) self.original_value = self.get_value() self.visible = True return True def dragging(self, event): position = event.current_pointer_position() delta_x = self.x_mapper.map_data(position[0]) - self.original_data_point[0] delta_y = self.y_mapper.map_data(position[1]) - self.original_data_point[1] self.set_delta(self.original_value, delta_x, delta_y) return True def drag_end(self, event): event.window.set_pointer("arrow") self.visible = False return True def _drag_button_down(self, event): # override button down to handle modifier keys correctly if not event.handled and self._drag_state == "nondrag": key_states = dict((key, key in self.modifier_keys) for key in keys) if not all(getattr(event, key+'_down') == state for key, state in key_states.items()): return False self.mouse_down_position = (event.x, event.y) if not self.is_draggable(*self.mouse_down_position): self._mouse_down_recieved = False return False self._mouse_down_received = True return True return False # traits default handlers def _x_mapper_default(self): # if the component has an x_mapper, try to use it by default return getattr(self.component, 'x_mapper', identity_mapper) def _y_mapper_default(self): # if the component has an x_mapper, try to use it by default return getattr(self.component, 'y_mapper', identity_mapper) class AttributeDragTool(ValueDragTool): """ Tool which modifies a model's attributes as it drags This is designed to cover the simplest of drag cases where the drag is modifying one or two numerical attributes on an underlying model. To use, simply provide the model object and the attributes that you want to be changed by the drag. If only one attribute is required, the other can be left as an empty string. """ #: the model object which has the attributes we are modifying model = Any #: the name of the attributes that is modified by horizontal motion x_attr = Str #: the name of the attributes that is modified by vertical motion y_attr = Str #: max and min values for x value x_bounds = Tuple(Either(Float, Str, None), Either(Float, Str, None)) #: max and min values for y value y_bounds = Tuple(Either(Float,Str, None), Either(Float, Str, None)) x_name = Str y_name = Str # ValueDragTool API def get_value(self): """ Get the current value of the attributes Returns a 2-tuple of (x, y) values. If either x_attr or y_attr is the empty string, then the corresponding component of the tuple is None. """ x_value = None y_value = None if self.x_attr: x_value = getattr(self.model, self.x_attr) if self.y_attr: y_value = getattr(self.model, self.y_attr) return (x_value, y_value) def set_delta(self, value, delta_x, delta_y): """ Set the current value of the attributes Set the underlying attribute values based upon the starting value and the provided deltas. The values are simply set to the sum of the appropriate coordinate and the delta. If either x_attr or y_attr is the empty string, then the corresponding component of is ignored. Note that setting x and y are two separate operations, and so will fire two trait notification events. """ inspector_value = {} if self.x_attr: x_value = value[0] + delta_x if self.x_bounds[0] is not None: if isinstance(self.x_bounds[0], basestring): m = getattr(self.model, self.x_bounds[0]) else: m = self.x_bounds[0] x_value = max(x_value, m) if self.x_bounds[1] is not None: if isinstance(self.x_bounds[1], basestring): M = getattr(self.model, self.x_bounds[1]) else: M = self.x_bounds[1] x_value = min(x_value, M) setattr(self.model, self.x_attr, x_value) inspector_value[self.x_name] = x_value if self.y_attr: y_value = value[1] + delta_y if self.y_bounds[0] is not None: if isinstance(self.y_bounds[0], basestring): m = getattr(self.model, self.y_bounds[0]) else: m = self.y_bounds[0] y_value = max(y_value, m) if self.y_bounds[1] is not None: if isinstance(self.y_bounds[1], basestring): M = getattr(self.model, self.y_bounds[1]) else: M = self.y_bounds[1] y_value = min(y_value, M) setattr(self.model, self.y_attr, y_value) inspector_value[self.y_name] = y_value self.new_value = inspector_value def _x_name_default(self): return self.x_attr.replace('_', ' ').capitalize() def _y_name_default(self): return self.y_attr.replace('_', ' ').capitalize() enthought-chaco2-4.5.1.orig/enable/tools/hover_tool.py0000644000175000017500000001221012516137326022014 0ustar varunvarun""" Tool to detect when the user hovers over a specific part of an underlying components. """ from __future__ import absolute_import # Enthought library imports from enable.base_tool import BaseTool from traits.etsconfig.api import ETSConfig from pyface.toolkit import toolkit_object from traits.api import Any, Callable, Enum, Float, Int # Define a toolkit-specific function for determining the global mouse position if ETSConfig.toolkit == 'wx': import wx def GetGlobalMousePosition(): pos = wx.GetMousePosition() if isinstance(pos, tuple): return pos elif hasattr(pos, "x") and hasattr(pos, "y"): return (pos.x, pos.y) else: raise RuntimeError("Unable to determine mouse position") elif ETSConfig.toolkit == 'qt4': from pyface.qt import QtGui def GetGlobalMousePosition(): pos = QtGui.QCursor.pos() return (pos.x(), pos.y()) else: def GetGlobalMousePosition(): raise NotImplementedError, "GetGlobalMousePosition is not defined for" \ "toolkit '%s'." % ETSConfig.toolkit class HoverTool(BaseTool): """ Tool to detect when the user hovers over a certain area on a component. The type of area to detect can be configured by the 'area_type' and 'bounds' traits. Users of the class should either set the 'callback' attribute, or subclass and override on_hover(). """ # Defines the part of the component that the hover tool will listen area_type = Enum("top", "bottom", "left", "right", "borders", # borders "UL", "UR", "LL", "LR", "corners") # corners # The width/height of the border or corner area. (Corners are assumed to # be square.) area = Float(35.0) # The number of milliseconds that the user has to keep the mouse within # the hover threshold before a hover is triggered. hover_delay = Int(500) # Controls the mouse sensitivity; if the mouse moves less than the # threshold amount in X or Y, then the hover timer is not reset. hover_threshold = Int(5) # The action to perform when the hover activates. This can be used # instead of subclassing and overriding on_hover(). # If cb_param is not None, then the callback gets passed it as # its single parameter. callback = Callable # An optional parameter that gets passed to the callback. cb_param = Any #------------------------------------------------------------------------- # Private traits #------------------------------------------------------------------------- # A tuple (x,y) of the mouse position (in global coordinate) when we set the timer _start_xy = Any # The timer _timer = Any #------------------------------------------------------------------------- # Public methods #------------------------------------------------------------------------- def on_hover(self): """ This gets called when all the conditions of the hover action have been met, and the tool determines that the mouse is, in fact, hovering over a target region on the component. By default, this method call self.callback (if one is configured). """ if self.callback is not None: if self.cb_param is not None: self.callback(self.cb_param) else: self.callback() def normal_mouse_move(self, event): if self._is_in(event.x, event.y): # update xy and restart the timer self._start_xy = GetGlobalMousePosition() self.restart_hover_timer(event) else: if self._timer: self._timer.Stop() def restart_hover_timer(self, event): if self._timer is None: self._create_timer(event) else: self._timer.Start() def on_timer(self): position = GetGlobalMousePosition() diffx = abs(position[0] - self._start_xy[0]) diffy = abs(position[1] - self._start_xy[1]) if (diffx < self.hover_threshold) and (diffy < self.hover_threshold): self.on_hover() self._timer.Stop() #------------------------------------------------------------------------- # Private methods #------------------------------------------------------------------------- def _is_in(self, x, y): """ Returns True if local coordinates (x,y) is inside our hover region """ area_type = self.area_type.lower() c = self.component t = (c.y2 - y <= self.area) b = (y - c.y <= self.area) r = (c.x2 - x <= self.area) l = (x - c.x <= self.area) if area_type in ("top", "bottom", "left", "right"): return locals()[area_type[0]] elif area_type.lower() in ("ul", "ur", "ll", "lr"): u = t return locals()[area_type[0]] and locals()[area_type[1]] elif area_type == "corners": return (t | b) & (l | r) elif area_type == "borders": return any((t, b, r, l)) def _create_timer(self, event): klass = toolkit_object("timer.timer:Timer") self._timer = klass(self.hover_delay, self.on_timer) enthought-chaco2-4.5.1.orig/enable/tools/tool_history_mixin.py0000644000175000017500000001115312516137326023603 0ustar varunvarun""" Defines the ToolHistoryMixin class. """ from traits.api import HasTraits, Instance, Int, List from enable.base_tool import KeySpec class ToolHistoryMixin(HasTraits): """ A mix-in class for tools to maintain a tool state history and to move backwards and forwards through that history stack. This mix-in listens for keypressed events; to handle keypresses in a subclass, call self._history_handle_key(event) to have this mix-in properly process the event. """ # Key to go to the original or start state in the history. reset_state_key = Instance(KeySpec, args=("Esc",)) # Key to go to the previous state in the history. prev_state_key = Instance(KeySpec, args=("Left", "control")) # Key to go to the next state in the history. next_state_key = Instance(KeySpec, args=("Right", "control")) # The state stack. _history = List # The current index into _history _history_index = Int #------------------------------------------------------------------------ # Abstract methods that subclasses must implement to handle keypresses #------------------------------------------------------------------------ def _next_state_pressed(self): """ Called when the tool needs to advance to the next state in the stack. The **_history_index** will have already been set to the index corresponding to the next state. """ pass def _prev_state_pressed(self): """ Called when the tool needs to advance to the previous state in the stack. The **_history_index** will have already been set to the index corresponding to the previous state. """ pass def _reset_state_pressed(self): """ Called when the tool needs to reset its history. The history index will have already been set to 0. """ pass #------------------------------------------------------------------------ # Protected methods for subclasses to use #------------------------------------------------------------------------ def _current_state(self): """ Returns the current history state. """ return self._history[self._history_index] def _reset_state(self, state): """ Clears the history stack and sets the first or original state in the history to *state*. """ self._history = [state] self._history_index = 0 return def _append_state(self, state, set_index=True): """ Clears the history after the current **_history_index**, and appends the given state to the history. If *set_index* is True, the method sets the **_history_index** to match the new, truncated history. If it is False, the history index is unchanged. """ new_history = self._history[:self._history_index+1] + [state] self._history = new_history if set_index: self._history_index = len(self._history) - 1 return def _pop_state(self): """ Pops the most last state off the history stack. If the history index points to the end of the stack, then it is adjusted; otherwise, the index is unaffected. If the stack is empty, the method raises an IndexError. Returns the popped state. """ if len(self._history) == 0: raise IndexError("Unable to pop empty history stack.") if self._history_index == len(self._history) - 1: self._history_index -= 1 return self._history.pop() #------------------------------------------------------------------------ # Private methods / event handlers #------------------------------------------------------------------------ def normal_key_pressed(self, event): """ Handles a key being pressed, and takes appropriate action if it is one of the history keys defined for this class. """ self._history_handle_key(event) return def _history_handle_key(self, event): if self.reset_state_key.match(event): self._history_index = 0 self._reset_state_pressed() event.handled = True elif self.prev_state_key.match(event): if self._history_index > 0: self._history_index -= 1 self._prev_state_pressed() event.handled = True elif self.next_state_key.match(event): if self._history_index <= len(self._history) - 2: self._history_index += 1 self._next_state_pressed() event.handled = True else: return # EOF enthought-chaco2-4.5.1.orig/enable/tools/viewport_zoom_tool.py0000644000175000017500000002517612516137326023633 0ustar varunvarun""" Defines the SimpleZoom class. """ from numpy import inf # Enthought library imports from traits.api import Bool, Enum, Float, Instance, Int, List, \ Trait, Tuple # Enable imports from enable.base_tool import KeySpec from enable.colors import ColorTrait from enable.abstract_overlay import AbstractOverlay from base_zoom_tool import BaseZoomTool from tool_history_mixin import ToolHistoryMixin class ViewportZoomTool(AbstractOverlay, ToolHistoryMixin, BaseZoomTool): """ Selects a range along the index or value axis. The user left-click-drags to select a region to zoom in. Certain keyboard keys are mapped to performing zoom actions as well. Implements a basic "zoom stack" so the user move go backwards and forwards through previous zoom regions. """ # The selection mode: # # range: # Select a range across a single index or value axis. # box: # Perform a "box" selection on two axes. tool_mode = Enum("range", "box") #Enum("box", "range") # Is the tool always "on"? If True, left-clicking always initiates # a zoom operation; if False, the user must press a key to enter zoom mode. always_on = Bool(False) #------------------------------------------------------------------------- # Zoom control #------------------------------------------------------------------------- # The axis to which the selection made by this tool is perpendicular. This # only applies in 'range' mode. axis = Enum("x", "y") #------------------------------------------------------------------------- # Interaction control #------------------------------------------------------------------------- # Enable the mousewheel for zooming? enable_wheel = Bool(True) # The mouse button that initiates the drag. drag_button = Enum("left", "right") # Conversion ratio from wheel steps to zoom factors. wheel_zoom_step = Float(.25) # The key press to enter zoom mode, if **always_on** is False. Has no effect # if **always_on** is True. enter_zoom_key = Instance(KeySpec, args=("z",)) # The key press to leave zoom mode, if **always_on** is False. Has no effect # if **always_on** is True. exit_zoom_key = Instance(KeySpec, args=("z",)) # Disable the tool after the zoom is completed? disable_on_complete = Bool(True) # The minimum amount of screen space the user must select in order for # the tool to actually take effect. minimum_screen_delta = Int(10) # The most that this tool will zoom in on the target. Since zoom is the # ratio of the original bounds to the new bounds, a max_zoom value of 2.0 # would make the tool stop once it had zoomed into a region half the size # of the original bounds. max_zoom = Float(inf) # The most that this tool will zoom out from the target. For example, # a min_zoom of 0.2 would prevent the tool from showing a view zoomed # out more than 5 times from the original bounds. min_zoom = Float(-inf) #------------------------------------------------------------------------- # Appearance properties (for Box mode) #------------------------------------------------------------------------- # The pointer to use when drawing a zoom box. pointer = "magnifier" # The color of the selection box. color = ColorTrait("lightskyblue") # The alpha value to apply to **color** when filling in the selection # region. Because it is almost certainly useless to have an opaque zoom # rectangle, but it's also extremely useful to be able to use the normal # named colors from Enable, this attribute allows the specification of a # separate alpha value that replaces the alpha value of **color** at draw # time. alpha = Trait(0.4, None, Float) # The color of the outside selection rectangle. border_color = ColorTrait("dodgerblue") # The thickness of selection rectangle border. border_size = Int(1) # The possible event states of this zoom tool. event_state = Enum("normal", "selecting") #------------------------------------------------------------------------ # Key mappings #------------------------------------------------------------------------ # The key that cancels the zoom and resets the view to the original defaults. cancel_zoom_key = Instance(KeySpec, args=("Esc",)) #------------------------------------------------------------------------ # Private traits #------------------------------------------------------------------------ # If **always_on** is False, this attribute indicates whether the tool # is currently enabled. _enabled = Bool(False) # the original numerical screen ranges _orig_position = Trait(None, List, Float) _orig_bounds = Trait(None, List, Float) # The (x,y) screen point where the mouse went down. _screen_start = Trait(None, None, Tuple) # The (x,,y) screen point of the last seen mouse move event. _screen_end = Trait(None, None, Tuple) def __init__(self, component=None, *args, **kw): # Support AbstractController-style constructors so that this can be # handed in the component it will be overlaying in the constructor # without using kwargs. self.component = component super(ViewportZoomTool, self).__init__(*args, **kw) self._reset_state_to_current() if self.tool_mode == "range": i = self._get_range_index() self._orig_position = self.component.view_position[i] self._orig_bounds = self.component.view_bounds[i] else: self._orig_position = self.component.view_position self._orig_bounds = self.component.view_bounds return def enable(self, event=None): """ Provides a programmatic way to enable this tool, if **always_on** is False. Calling this method has the same effect as if the user pressed the **enter_zoom_key**. """ if self.component.active_tool != self: self.component.active_tool = self self._enabled = True if event and event.window: event.window.set_pointer(self.pointer) return def disable(self, event=None): """ Provides a programmatic way to enable this tool, if **always_on** is False. Calling this method has the same effect as if the user pressed the **exit_zoom_key**. """ self.reset() self._enabled = False if self.component.active_tool == self: self.component.active_tool = None if event and event.window: event.window.set_pointer("arrow") return def reset(self, event=None): """ Resets the tool to normal state, with no start or end position. """ self.event_state = "normal" self._screen_start = None self._screen_end = None def deactivate(self, component): """ Called when this is no longer the active tool. """ # Required as part of the AbstractController interface. return self.disable() def normal_left_down(self, event): """ Handles the left mouse button being pressed while the tool is in the 'normal' state. If the tool is enabled or always on, it starts selecting. """ if self.always_on or self._enabled: # we need to make sure that there isn't another active tool that we will # interfere with. if self.drag_button == "left": self._start_select(event) return def normal_right_down(self, event): """ Handles the right mouse button being pressed while the tool is in the 'normal' state. If the tool is enabled or always on, it starts selecting. """ if self.always_on or self._enabled: if self.drag_button == "right": self._start_select(event) return def normal_mouse_wheel(self, event): """ Handles the mouse wheel being used when the tool is in the 'normal' state. Scrolling the wheel "up" zooms in; scrolling it "down" zooms out. self.component is the viewport self.component.component is the canvas """ if self.enable_wheel and event.mouse_wheel != 0: position = self.component.view_position scale = self.component.zoom transformed_x = event.x / scale + position[0] transformed_y = event.y / scale + position[1] # Calculate zoom if event.mouse_wheel < 0: zoom = 1.0 / (1.0 + 0.5 * self.wheel_zoom_step) new_zoom = self.component.zoom * zoom elif event.mouse_wheel > 0: zoom = 1.0 + 0.5 * self.wheel_zoom_step new_zoom = self.component.zoom * zoom if new_zoom < self.min_zoom: new_zoom = self.min_zoom zoom = new_zoom / self.component.zoom elif new_zoom > self.max_zoom: new_zoom = self.max_zoom zoom = new_zoom / self.component.zoom self.component.zoom = new_zoom x_pos = transformed_x - (transformed_x - position[0]) / zoom y_pos = transformed_y - (transformed_y - position[1]) / zoom self.component.set(view_position=[x_pos, y_pos], trait_change_notify=False) bounds = self.component.view_bounds self.component.view_bounds = [bounds[0] / zoom , bounds[1] / zoom] event.handled = True self.component.request_redraw() return def _component_changed(self): self._reset_state_to_current() return #------------------------------------------------------------------------ # Implementation of PlotComponent interface #------------------------------------------------------------------------ def _activate(self): """ Called by PlotComponent to set this as the active tool. """ self.enable() #------------------------------------------------------------------------ # implementations of abstract methods on ToolHistoryMixin #------------------------------------------------------------------------ def _reset_state_to_current(self): """ Clears the tool history, and sets the current state to be the first state in the history. """ if self.tool_mode == "range": i = self._get_range_index() self._reset_state((self.component.view_position[i], self.component.view_bounds[i])) else: self._reset_state((self.component.view_position, self.component.view_bounds)) # EOF enthought-chaco2-4.5.1.orig/enable/tools/viewport_pan_tool.py0000644000175000017500000000774712516137326023431 0ustar varunvarun""" Defines the PanTool class. """ # Enthought library imports from enable.enable_traits import Pointer from traits.api import Bool, Enum, Float, Tuple from drag_tool import DragTool class ViewportPanTool(DragTool): """ A tool that enables the user to pan around a viewport by clicking a mouse button and dragging. """ # The cursor to use when panning. drag_pointer = Pointer("hand") # Scaling factor on the panning "speed". speed = Float(1.0) # The modifier key that, if depressed when the drag is initiated, constrains # the panning to happen in the only direction of largest initial motion. # It is possible to permanently restrict this tool to always drag along one # direction. To do so, set constrain=True, constrain_key=None, and # constrain_direction to the desired direction. constrain_key = Enum(None, "shift", "control", "alt") # Constrain the panning to one direction? constrain = Bool(False) # The direction of constrained draw. A value of None means that the user # has initiated the drag and pressed the constrain_key, but hasn't moved # the mouse yet; the magnitude of the components of the next mouse_move # event will determine the constrain_direction. constrain_direction = Enum(None, "x", "y") # (x,y) of the point where the mouse button was pressed. _original_xy = Tuple # Data coordinates of **_original_xy**. This may be either (index,value) # or (value,index) depending on the component's orientation. _original_data = Tuple # Was constrain=True triggered by the **contrain_key**? If False, it was # set programmatically. _auto_constrain = Bool(False) #------------------------------------------------------------------------ # Inherited BaseTool traits #------------------------------------------------------------------------ # The tool is not visible (overrides BaseTool). visible = False def drag_start(self, event): self._original_xy = (event.x, event.y) if self.constrain_key is not None: if getattr(event, self.constrain_key + "_down"): self.constrain = True self._auto_constrain = True self.constrain_direction = None event.window.set_pointer(self.drag_pointer) event.window.set_mouse_owner(self, event.net_transform()) event.handled = True return def dragging(self, event): """ Handles the mouse being moved when the tool is in the 'panning' state. """ if self._auto_constrain and self.constrain_direction is None: # Determine the constraint direction if abs(event.x - self._original_xy[0]) > abs(event.y - self._original_xy[1]): self.constrain_direction = "x" else: self.constrain_direction = "y" new_position = self.component.view_position[:] for direction, ndx in [("x", 0), ("y", 1)]: if self.constrain and self.constrain_direction != direction: continue origpos = self._original_xy[ndx] eventpos = getattr(event, direction) delta = self.speed * (eventpos - origpos) if self.component.enable_zoom: delta /= self.component.zoom new_position[ndx] -= delta if self.constrain: self.component.view_position[self.constrain_direction] = \ new_position[self.constrain_direction] else: self.component.view_position = new_position event.handled = True self._original_xy = (event.x, event.y) self.component.request_redraw() return def drag_end(self, event): if self._auto_constrain: self.constrain = False self.constrain_direction = None event.window.set_pointer("arrow") if event.window.mouse_owner == self: event.window.set_mouse_owner(None) event.handled = True return # EOF enthought-chaco2-4.5.1.orig/enable/tools/resize_tool.py0000644000175000017500000001024012516137326022173 0ustar varunvarun from traits.api import Bool, Enum, Int, Set from ..enable_traits import bounds_trait from .value_drag_tool import ValueDragTool hotspot_trait = Enum("top", "left", "right", "bottom", "top left", "top right", "bottom left", "bottom right") class ResizeTool(ValueDragTool): """ Generic tool for resizing a component """ # Should the resized component be raised to the top of its container's # list of components? This is only recommended for overlaying containers # and canvases, but generally those are the only ones in which the # ResizeTool will be useful. auto_raise = Bool(True) #: the hotspots which are active for this tool hotspots = Set(hotspot_trait) #: the distance in pixels from a hotspot required to register a hit threshhold = Int(10) #: the minimum bounds that we can resize to minimum_bounds = bounds_trait #: the hotspot that started the drag _selected_hotspot = hotspot_trait # 'ValueDragTool' Interface ############################################## def get_value(self): if self.component is not None: c = self.component return c.position[:], c.bounds[:] def set_delta(self, value, delta_x, delta_y): if self.component is not None: c = self.component position, bounds = value x, y = position width, height = bounds min_width, min_height = self.minimum_bounds edges = self._selected_hotspot.split() if 'left' in edges: if delta_x >= width-min_width: delta_x = width-min_width c.x = x+delta_x c.width = width-delta_x if 'right' in edges: if delta_x <= -width+min_width: delta_x = -width+min_width c.width = width+delta_x if 'bottom' in edges: if delta_y >= height-min_height: delta_y = height-min_height c.y = y+delta_y c.height = height-delta_y if 'top' in edges: if delta_y <= -height+min_height: delta_y = -height+min_height c.height = height+delta_y c._layout_needed = True c.request_redraw() # 'DragTool' Interface ################################################### def is_draggable(self, x, y): return self._find_hotspot(x, y) in self.hotspots def drag_start(self, event): if self.component is not None: self._selected_hotspot = self._find_hotspot(event.x, event.y) super(ResizeTool, self).drag_start(event) self.component._layout_needed = True if self.auto_raise: # Push the component to the top of its container's list self.component.container.raise_component(self.component) event.window.set_mouse_owner(self, event.net_transform()) event.handled = True return True # Private Interface ###################################################### def _find_hotspot(self, x, y): hotspot = [] if self.component is not None: c = self.component v_threshhold = min(self.threshhold, c.height/2.0) if c.y <= y <= c.y+v_threshhold: hotspot.append('bottom') elif c.y2+1-v_threshhold <= y <= c.y2+1: hotspot.append('top') elif y < c.y or y > c.y2+1: return '' h_threshhold = min(self.threshhold, c.width/2.0) if c.x <= x <= c.x+h_threshhold: hotspot.append('left') elif c.x2+1-h_threshhold <= x <= c.x2+1: hotspot.append('right') elif x < c.x or x > c.x2+1: return '' return ' '.join(hotspot) # Traits Handlers ######################################################## def _hotspots_default(self): return set(["top", "left", "right", "bottom", "top left", "top right", "bottom left", "bottom right"]) def _minimum_bounds_default(self): return [self.threshhold*2, self.threshhold*2] enthought-chaco2-4.5.1.orig/enable/base_tool.py0000644000175000017500000001334012516137326020450 0ustar varunvarun""" Defines the base class for all Chaco tools. See docs/event_handling.txt for an overview of how event handling works in Chaco. """ # Enthought library imports from traits.api import Bool, Enum, Instance # Local relative imports from component import Component from interactor import Interactor class KeySpec(object): """ Creates a key specification to facilitate tools interacting with the keyboard. A tool can declare either a class attribute:: magic_key = KeySpec("Right", "control", ignore=['shift']) or a trait:: magic_key = Instance(KeySpec, args=("Right", "control"), kw={'ignore': ['shift']}) and then check to see if the key was pressed by calling:: if self.magic_key.match(event): # do stuff... The names of the keys come from Enable, so both examples above are specifying the user pressing Ctrl + Right_arrow with Alt not pressed and Shift either pressed or not. """ def __init__(self, key, *modifiers, **kwmods): """ Creates this key spec with the given modifiers. """ self.key = key mods = set(m.lower() for m in modifiers) self.alt = "alt" in mods self.shift = "shift" in mods self.control = "control" in mods ignore = kwmods.get('ignore', []) self.ignore = set(m.lower() for m in ignore) def match(self, event): """ Returns True if the given Enable key_pressed event matches this key specification. """ return (self.key == getattr(event, 'character',None)) and \ ('alt' in self.ignore or self.alt == event.alt_down) and \ ('control' in self.ignore or self.control == event.control_down) and \ ('shift' in self.ignore or self.shift == event.shift_down) class BaseTool(Interactor): """ The base class for Chaco tools. Tools are not Enable components, but they can draw. They do not participate in layout, but are instead attached to a Component, which dispatches methods to the tool and calls the tools' draw() method. See docs/event_handling.txt for more information on how tools are structured. """ # The component that this tool is attached to. component = Instance(Component) # Is this tool's visual representation visible? For passive inspector-type # tools, this is a constant value set in the class definition; # for stateful or modal tools, the tool's listener sets this attribute. visible = Bool(False) # How the tool draws on top of its component. This, in conjuction with a # a tool's status on the component, is used by the component to determine # how to render itself. In general, the meanings of the draw modes are: # # normal: # The appearance of part of the component is modified such that # the component is redrawn even if it has not otherwise # received any indication that its previous rendering is invalid. # The tool controls its own drawing loop, and calls out to this # tool after it is done drawing itself. # overlay: # The component needs to be drawn, but can be drawn after all # of the background and foreground elements in the component. # Furthermore, the tool renders correctly regardless # of how the component renders itself (e.g., via a cached image). # The overlay gets full control of the rendering loop, and must # explicitly call the component's _draw() method; otherwise the # component does not render. # none: # The tool does not have a visual representation that the component # needs to render. draw_mode = Enum("none", "overlay", "normal") #------------------------------------------------------------------------ # Concrete methods #------------------------------------------------------------------------ def __init__(self, component=None, **kwtraits): if "component" in kwtraits: component = kwtraits["component"] super(BaseTool, self).__init__(**kwtraits) self.component = component return def dispatch(self, event, suffix): """ Dispatches a mouse event based on the current event state. Overrides enable.Interactor. """ self._dispatch_stateful_event(event, suffix) return def _dispatch_stateful_event(self, event, suffix): # Override the default enable.Interactor behavior of automatically # setting the event.handled if a handler is found. (Without this # level of manual control, we could never support multiple listeners.) handler = getattr(self, self.event_state + "_" + suffix, None) if handler is not None: handler(event) return #------------------------------------------------------------------------ # Abstract methods that subclasses should implement #------------------------------------------------------------------------ def draw(self, gc, view_bounds=None): """ Draws this tool on a graphics context. It is assumed that the graphics context has a coordinate transform that matches the origin of its component. (For containers, this is just the origin; for components, it is the origin of their containers.) """ pass def _activate(self): """ Called by a Component when this becomes the active tool. """ pass def _deactivate(self): """ Called by a Component when this is no longer the active tool. """ pass def deactivate(self, component=None): """ Handles this component no longer being the active tool. """ # Compatibility with new AbstractController interface self._deactivate() return enthought-chaco2-4.5.1.orig/enable/api.py0000644000175000017500000000451212516137326017253 0ustar varunvarun""" Enable is an interactive graphical component framework built on top of Kiva. See https://www.enthought.com/enthought/wiki/EnableProject """ # Major package imports # TODO - Add basic comments for the names being imported from base and enable_traits from base import IDroppedOnHandler, TOP, VCENTER, BOTTOM, LEFT, HCENTER, RIGHT, \ TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT, str_to_font, \ empty_rectangle, intersect_bounds from enable_traits import basic_sequence_types, sequence_types, pointer_shapes, \ CURSOR_X, CURSOR_Y, cursor_styles, border_size_editor, font_trait, \ bounds_trait, ComponentMinSize, ComponentMaxSize, Pointer, cursor_style_trait, \ spacing_trait, padding_trait, margin_trait, border_size_trait, \ TimeInterval, Stretch, NoStretch, LineStyle, LineStyleEditor from colors import color_table, transparent_color, ColorTrait, black_color_trait, \ white_color_trait, transparent_color_trait, ColorEditorFactory from markers import MarkerTrait, marker_trait, MarkerNameDict, marker_names, \ SquareMarker, CircleMarker, TriangleMarker, Inverted_TriangleMarker, \ PlusMarker, CrossMarker, DiamondMarker, DotMarker, PixelMarker, \ CustomMarker, AbstractMarker from events import drag_event_trait, key_event_trait, mouse_event_trait, \ BasicEvent, BlobEvent, BlobFrameEvent, DragEvent, KeyEvent, MouseEvent from interactor import Interactor from base_tool import BaseTool, KeySpec from abstract_overlay import AbstractOverlay from canvas import Canvas from component import Component from container import Container from coordinate_box import CoordinateBox from component_editor import ComponentEditor from constraints_container import ConstraintsContainer from overlay_container import OverlayContainer # Breaks code that does not use numpy from label import Label from graphics_context import GraphicsContextEnable, ImageGraphicsContextEnable # Old Enable classes and widgets from abstract_window import AbstractWindow from native_scrollbar import NativeScrollBar from compass import Compass from scrolled import Scrolled from slider import Slider from text_field_style import TextFieldStyle from text_field import TextField from text_field_grid import TextFieldGrid from viewport import Viewport from window import Window from primitives.api import Annotater, Box, Line, Polygon enthought-chaco2-4.5.1.orig/enable/trait_defs/0000755000175000017500000000000012516137725020255 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/trait_defs/__init__.py0000644000175000017500000000007712516137326022367 0ustar varunvarun# Copyright (c) 2007 by Enthought, Inc. # All rights reserved. enthought-chaco2-4.5.1.orig/enable/trait_defs/api.py0000644000175000017500000000005112516137326021371 0ustar varunvarunfrom rgba_color_trait import RGBAColor enthought-chaco2-4.5.1.orig/enable/trait_defs/ui/0000755000175000017500000000000012516137725020672 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/trait_defs/ui/__init__.py0000644000175000017500000000007712516137326023004 0ustar varunvarun# Copyright (c) 2007 by Enthought, Inc. # All rights reserved. enthought-chaco2-4.5.1.orig/enable/trait_defs/ui/api.py0000644000175000017500000000005612516137326022013 0ustar varunvarunfrom rgba_color_editor import RGBAColorEditor enthought-chaco2-4.5.1.orig/enable/trait_defs/ui/wx/0000755000175000017500000000000012516137725021330 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/trait_defs/ui/wx/__init__.py0000644000175000017500000000007712516137326023442 0ustar varunvarun# Copyright (c) 2007 by Enthought, Inc. # All rights reserved. enthought-chaco2-4.5.1.orig/enable/trait_defs/ui/wx/enable_rgba_color_editor.py0000644000175000017500000001704312516137326026671 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2005-2007 Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # #------------------------------------------------------------------------------ """ Defines the Enable-based implementation of the various RGBA color editors and the color editor factory. """ #------------------------------------------------------------------------------- # Imports: #------------------------------------------------------------------------------- import wx from enable import ColorPicker from enable.wx import Window from kiva.trait_defs.kiva_font_trait import KivaFont from traits.api import Bool, Enum, Str from traitsui.api import View from traitsui.wx.editor import Editor from traitsui.wx.helper import position_window from .rgba_color_editor import ToolkitEditorFactory as EditorFactory #------------------------------------------------------------------------------- # Constants: #------------------------------------------------------------------------------- # Color used for background of color picker WindowColor = ( 236 / 255.0, 233 / 255.0, 216 / 255.0, 1.0 ) #------------------------------------------------------------------------------- # Trait definitions: #------------------------------------------------------------------------------- # Possible styles of color editors EditorStyle = Enum( 'simple', 'custom' ) #------------------------------------------------------------------------------- # 'ToolkitEditorFactory' class: #------------------------------------------------------------------------------- class ToolkitEditorFactory ( EditorFactory ): """ wxPython editor factory for Enable RGBA color editors. """ #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- # Should the color be updated automatically? auto_set = Bool(True) # Initial color space mode mode = Enum( 'rgb', 'hsv', 'hsv2', 'hsv3', cols = 2 ) # Should the alpha channel be edited? edit_alpha = Bool(True) # Text to display in the color well text = Str( '%R' ) # Font to use when displaying text font = KivaFont( 'modern 10' ) #--------------------------------------------------------------------------- # Traits view definition: #--------------------------------------------------------------------------- traits_view = View( [ [ 'mapped{Is the value mapped?}', 'auto_set{Should the value be set while dragging a slider?}', 'edit_alpha{Should the alpha channel be edited?}', '|[Options]>' ], [ 'mode{Inital mode}@', '|[Color Space]' ], [ 'text', 'font@', '|[Color well]' ] ] ) #--------------------------------------------------------------------------- # 'Editor' factory methods: #--------------------------------------------------------------------------- def simple_editor ( self, ui, object, name, description, parent ): return ColorEditor( parent, factory = self, ui = ui, object = object, name = name, description = description, style = 'simple' ) def custom_editor ( self, ui, object, name, description, parent ): return ColorEditor( parent, factory = self, ui = ui, object = object, name = name, description = description, style = 'custom' ) #------------------------------------------------------------------------------- # 'ColorEditor' class: #------------------------------------------------------------------------------- class ColorEditor ( Editor ): """ Editor for RGBA colors, which displays an Enable color picker. """ #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- # Style of editor style = Enum( 'simple', 'custom' ) #--------------------------------------------------------------------------- # Finishes initializing the editor by creating the underlying toolkit # widget: #--------------------------------------------------------------------------- def init ( self, parent ): """ Finishes initializing the editor by creating the underlying toolkit widget. """ factory = self.factory picker = ColorPicker( color = factory.get_color( self ), bg_color = WindowColor, style = self.style, auto_set = factory.auto_set, mode = factory.mode, edit_alpha = factory.edit_alpha, text = factory.text, font = factory.font ) window = Window( parent, component = picker ) self.control = window.control self._picker = picker self.control.SetSize( ( picker.min_width, picker.min_height ) ) picker.on_trait_change( self.popup_editor, 'clicked', dispatch = 'ui' ) picker.on_trait_change( self.update_object, 'color', dispatch = 'ui' ) #--------------------------------------------------------------------------- # Invokes the pop-up editor for an object trait: #--------------------------------------------------------------------------- def popup_editor ( self, event ): """ Invokes the pop-up editor for an object trait. """ color_data = wx.ColourData() color_data.SetColour( self.factory.to_wx_color( self ) ) color_data.SetChooseFull( True ) dialog = wx.ColourDialog( self.control, color_data ) position_window(dialog, self.control) if dialog.ShowModal() == wx.ID_OK: self.value = self.factory.from_wx_color( dialog.GetColourData().GetColour() ) dialog.Destroy() #--------------------------------------------------------------------------- # Updates the object trait when a color swatch is clicked: #--------------------------------------------------------------------------- def update_object ( self, event ): """ Updates the object trait when a color swatch is clicked. """ self.value = self._picker.color #--------------------------------------------------------------------------- # Updates the editor when the object trait changes external to the editor: #--------------------------------------------------------------------------- def update_editor ( self ): """ Updates the editor when the object trait changes externally to the editor. """ self._picker.color = self.value def EnableRGBAColorEditor ( *args, **traits ): return ToolkitEditorFactory( *args, **traits ) enthought-chaco2-4.5.1.orig/enable/trait_defs/ui/wx/rgba_color_editor.py0000644000175000017500000004625012516137326025365 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2005-2007 by Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # #------------------------------------------------------------------------------ """ Defines the various RGBA color editors and the color editor factory, for the wxPython user interface toolkit. """ import wx from enable.colors import color_table from traits.api import Bool from traits.trait_base import SequenceTypes from traitsui.api import View from traitsui.wx.editor import Editor from traitsui.editor_factory import EditorFactory from traitsui.wx.editor_factory import ReadonlyEditor from traitsui.wx.helper import position_window #------------------------------------------------------------------------------- # Constants: #------------------------------------------------------------------------------- # Standard color samples: color_choices = ( 0, 51, 102, 153, 204, 255 ) color_samples = [ None ] * 216 i = 0 for r in color_choices: for g in color_choices: for b in color_choices: color_samples[i] = wx.Colour( r, g, b ) i += 1 #------------------------------------------------------------------------------- # 'ToolkitEditorFactory' class: #------------------------------------------------------------------------------- class ToolkitEditorFactory ( EditorFactory ): """ wxPython editor factory for RGBA color editors. """ #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- # Is the underlying color trait mapped? mapped = Bool(True) #--------------------------------------------------------------------------- # Traits view definition: #--------------------------------------------------------------------------- traits_view = View( [ 'mapped{Is the value mapped?}', '|[]>' ] ) #--------------------------------------------------------------------------- # 'Editor' factory methods: #--------------------------------------------------------------------------- def simple_editor ( self, ui, object, name, description, parent ): return SimpleColorEditor( parent, factory = self, ui = ui, object = object, name = name, description = description) def custom_editor ( self, ui, object, name, description, parent ): return CustomColorEditor( parent, factory = self, ui = ui, object = object, name = name, description = description ) def text_editor ( self, ui, object, name, description, parent ): return TextColorEditor( parent, factory = self, ui = ui, object = object, name = name, description = description ) def readonly_editor ( self, ui, object, name, description, parent ): return ReadonlyColorEditor( parent, factory = self, ui = ui, object = object, name = name, description = description ) #--------------------------------------------------------------------------- # Gets the object trait color: #--------------------------------------------------------------------------- def get_color ( self, editor ): """ Gets the object trait color. """ if self.mapped: return getattr( editor.object, editor.name + '_' ) return getattr( editor.object, editor.name ) #--------------------------------------------------------------------------- # Gets the wxPython color equivalent of the object trait: #--------------------------------------------------------------------------- def to_wx_color ( self, editor ): """ Gets the wxPython color equivalent of the object trait. """ r, g, b, a = self.get_color( editor ) return wx.Colour( int( r * 255.0 ) , int( g * 255.0 ), int( b * 255.0 ) ) #--------------------------------------------------------------------------- # Gets the application equivalent of a wxPython value: #--------------------------------------------------------------------------- def from_wx_color ( self, color ): """ Gets the application equivalent of a wxPython color value. """ return ( color.Red() / 255.0, color.Green() / 255.0, color.Blue() / 255.0, 1.0 ) #--------------------------------------------------------------------------- # Returns the text representation of a specified color value: #--------------------------------------------------------------------------- def str_color ( self, color ): """ Returns the text representation of a specified color value. """ if type( color ) in SequenceTypes: return "(%d,%d,%d,%d)" % ( int( color[0] * 255.0 ), int( color[1] * 255.0 ), int( color[2] * 255.0 ), int( color[3] * 255.0 ) ) return color #------------------------------------------------------------------------------- # 'SimpleColorEditor' class: #------------------------------------------------------------------------------- class SimpleColorEditor ( Editor ): """ Simple style of editor for RGBA colors, which displays a text field containing the string representation of the color value, and whose background color is the selected color. Clicking in the text field opens a dialog box to select a color value. """ #--------------------------------------------------------------------------- # Finishes initializing the editor by creating the underlying toolkit # widget: #--------------------------------------------------------------------------- def init ( self, parent ): """ Finishes initializing the editor by creating the underlying toolkit widget. """ from enable.api import Label from enable.wx_backend import Window window = Window( parent, component = Label( '', border_size = 1, font = 'modern 9' ) ) self._swatch = window.component self.control = window.control self.control.SetSize( ( 110, 20 ) ) window.component.on_trait_change( self.popup_editor, 'left_up', dispatch = 'ui' ) #--------------------------------------------------------------------------- # Invokes the pop-up editor for an object trait: #--------------------------------------------------------------------------- def popup_editor ( self, event ): """ Invokes the pop-up editor for an object trait. """ if not hasattr( self.control, 'is_custom' ): self._popup_dialog = ColorDialog( self ) else: update_handler = self.control.update_handler if update_handler is not None: update_handler( False ) color_data = wx.ColourData() color_data.SetColour( self.factory.to_wx_color( self ) ) color_data.SetChooseFull( True ) dialog = wx.ColourDialog( self.control, color_data ) position_window(dialog, parent=self.control) if dialog.ShowModal() == wx.ID_OK: self.value = self.factory.from_wx_color( dialog.GetColourData().GetColour() ) self.update_editor() dialog.Destroy() if update_handler is not None: update_handler( True ) #--------------------------------------------------------------------------- # Updates the object trait when a color swatch is clicked: #--------------------------------------------------------------------------- def update_object_from_swatch ( self, event ): """ Updates the object trait when a color swatch is clicked. """ control = event.GetEventObject() r, g, b, a = self.factory.from_wx_color( control.GetBackgroundColour() ) self.value = ( r, g, b, self.factory.get_color( self )[3] ) self.update_editor() #--------------------------------------------------------------------------- # Updates the object trait when the alpha channel slider is scrolled: #--------------------------------------------------------------------------- def update_object_from_scroll ( self, event ): """ Updates the object trait when the alpha channel slider is scrolled. """ control = event.GetEventObject() r, g, b, a = self.factory.get_color( self ) self.value = ( r, g, b, (100 - control.GetValue()) / 100.0 ) self.update_editor() #--------------------------------------------------------------------------- # Updates the editor when the object trait changes external to the editor: #--------------------------------------------------------------------------- def update_editor ( self ): """ Updates the editor when the object trait changes externally to the editor. """ alpha = self.factory.get_color( self )[3] self._swatch.text = self.str_value if self._slider is not None: self._slider.SetValue( 100 - int( alpha * 100.0 ) ) set_color( self ) #--------------------------------------------------------------------------- # Returns the text representation of a specified color value: #--------------------------------------------------------------------------- def string_value ( self, color ): """ Returns the text representation of a specified color value. """ return self.factory.str_color( color ) #------------------------------------------------------------------------------- # 'CustomColorEditor' class: #------------------------------------------------------------------------------- class CustomColorEditor ( SimpleColorEditor ): """ Custom style of editor for RGBA colors, which displays a large color swatch with the selected color, a set of color chips of other possible colors, and a vertical slider for the alpha value. """ #--------------------------------------------------------------------------- # Finishes initializing the editor by creating the underlying toolkit # widget: #--------------------------------------------------------------------------- def init ( self, parent ): """ Finishes initializing the editor by creating the underlying toolkit widget. """ self.control = color_editor_for( self, parent ) #--------------------------------------------------------------------------- # Disposes of the contents of an editor: #--------------------------------------------------------------------------- def dispose ( self ): """ Disposes of the contents of an editor. """ self.control._swatch_editor.dispose() super( CustomColorEditor, self ).dispose() #--------------------------------------------------------------------------- # Updates the editor when the object trait changes external to the editor: #--------------------------------------------------------------------------- def update_editor ( self ): """ Updates the editor when the object trait changes externally to the editor. """ pass #------------------------------------------------------------------------------- # 'TextColorEditor' class: #------------------------------------------------------------------------------- class TextColorEditor ( SimpleColorEditor ): """ Text style of RGBA color editor, identical to the simple style. """ pass #------------------------------------------------------------------------------- # 'ReadonlyColorEditor' class: #------------------------------------------------------------------------------- class ReadonlyColorEditor ( ReadonlyEditor ): """ Read-only style of RGBA color editor, which displays a read-only text field containing the string representation of the color value, and whose background color is the selected color. """ #--------------------------------------------------------------------------- # Finishes initializing the editor by creating the underlying toolkit # widget: #--------------------------------------------------------------------------- def init ( self, parent ): """ Finishes initializing the editor by creating the underlying toolkit widget. """ from enable.api import Label from enable.wx_backend import Window window = Window( parent, component = Label( '', border_size = 1, font = 'modern 9' ) ) self._swatch = window.component self.control = window.control self.control.SetSize( ( 110, 20 ) ) #--------------------------------------------------------------------------- # Returns the text representation of a specified color value: #--------------------------------------------------------------------------- def string_value ( self, color ): """ Returns the text representation of a specified color value. """ return self.factory.str_color( color ) #--------------------------------------------------------------------------- # Updates the editor when the object trait changes external to the editor: #--------------------------------------------------------------------------- def update_editor ( self ): """ Updates the editor when the object trait changes externally to the editor. """ self._swatch.text = self.str_value set_color( self ) #------------------------------------------------------------------------------- # Sets the color of the specified editor's color control: #------------------------------------------------------------------------------- def set_color ( editor ): """ Sets the color of the specified color control. """ color = editor.factory.get_color( editor ) control = editor._swatch control.bg_color = color if ((color[0] > 0.75) or (color[1] > 0.75) or (color[2] > 0.75)): control.color = color_table["black"] else: control.color = color_table["white"] #---------------------------------------------------------------------------- # Creates a custom color editor panel for a specified editor: #---------------------------------------------------------------------------- def color_editor_for ( editor, parent, update_handler = None ): """ Creates a custom color editor panel for a specified editor. """ # Create a panel to hold all of the buttons: panel = wx.Panel( parent, -1 ) sizer = wx.BoxSizer( wx.HORIZONTAL ) panel._swatch_editor = swatch_editor = editor.factory.simple_editor( editor.ui, editor.object, editor.name, editor.description, panel ) swatch_editor.prepare( panel ) control = swatch_editor.control control.is_custom = True control.update_handler = update_handler control.SetSize( wx.Size( 110, 72 ) ) sizer.Add( control, 1, wx.EXPAND | wx.RIGHT, 4 ) # Add all of the color choice buttons: sizer2 = wx.GridSizer( 0, 12, 0, 0 ) for i in range( len( color_samples ) ): control = wx.Button( panel, -1, '', size = wx.Size( 18, 18 ) ) control.SetBackgroundColour( color_samples[i] ) control.update_handler = update_handler wx.EVT_BUTTON( panel, control.GetId(), swatch_editor.update_object_from_swatch ) sizer2.Add( control ) editor.set_tooltip( control ) sizer.Add( sizer2 ) alpha = editor.factory.get_color( editor )[3] swatch_editor._slider = slider = wx.Slider( panel, -1, 100 - int( alpha * 100.0 ), 0, 100, size = wx.Size( 20, 40 ), style = wx.SL_VERTICAL | wx.SL_AUTOTICKS ) slider.SetTickFreq( 10, 1 ) slider.SetPageSize( 10 ) slider.SetLineSize( 1 ) wx.EVT_SCROLL( slider, swatch_editor.update_object_from_scroll ) sizer.Add( slider, 0, wx.EXPAND | wx.LEFT, 6 ) # Set-up the layout: panel.SetSizerAndFit( sizer ) # Return the panel as the result: return panel #------------------------------------------------------------------------------- # 'ColorDialog' class: #------------------------------------------------------------------------------- class ColorDialog ( wx.Frame ): """ Dialog box for selecting a color value. """ #--------------------------------------------------------------------------- # Initializes the object: #--------------------------------------------------------------------------- def __init__ ( self, editor ): """ Initializes the object. """ wx.Frame.__init__( self, editor.control, -1, '', style = wx.SIMPLE_BORDER ) wx.EVT_ACTIVATE( self, self._on_close_dialog ) self._closed = False self._closeable = True panel = color_editor_for( editor, self, self._close_dialog ) self._swatch_editor = panel._swatch_editor sizer = wx.BoxSizer( wx.VERTICAL ) sizer.Add( panel ) self.SetSizerAndFit( sizer ) position_window(self, parent=editor.control) self.Show() #--------------------------------------------------------------------------- # Closes the dialog: #--------------------------------------------------------------------------- def _on_close_dialog ( self, event, rc = False ): """ Closes the dialog. """ if not event.GetActive(): self._close_dialog() #--------------------------------------------------------------------------- # Closes the dialog: #--------------------------------------------------------------------------- def _close_dialog ( self, closeable = None ): """ Closes the dialog. """ if closeable is not None: self._closeable = closeable if self._closeable and (not self._closed): self._closed = True self._swatch_editor.dispose() self.Destroy() def RGBAColorEditor ( *args, **traits ): return ToolkitEditorFactory( *args, **traits ) enthought-chaco2-4.5.1.orig/enable/trait_defs/ui/qt4/0000755000175000017500000000000012516137725021402 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/trait_defs/ui/qt4/__init__.py0000644000175000017500000000007712516137326023514 0ustar varunvarun# Copyright (c) 2007 by Enthought, Inc. # All rights reserved. enthought-chaco2-4.5.1.orig/enable/trait_defs/ui/qt4/rgba_color_editor.py0000644000175000017500000000525312516137326025435 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2009 by Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # #------------------------------------------------------------------------------ """ Defines the various RGBA color editors and the color editor factory, for the Qt4 user interface toolkit. """ #------------------------------------------------------------------------------- # Imports: #------------------------------------------------------------------------------- from pyface.qt import QtGui from traits.trait_base \ import SequenceTypes # Note: The ToolkitEditorFactory class imported from color_editor is a # subclass of the abstract ToolkitEditorFactory class # (in traitsui.api) with qt4-specific methods defined. # We need to override the implementations of the qt4-specific methods here. from traitsui.qt4.color_editor \ import ToolkitEditorFactory as BaseColorToolkitEditorFactory #------------------------------------------------------------------------------- # The PyQt4 ToolkitEditorFactory class: #------------------------------------------------------------------------------- class ToolkitEditorFactory(BaseColorToolkitEditorFactory): def to_qt4_color(self, editor): """ Gets the PyQt color equivalent of the object trait. """ try: color = getattr(editor.object, editor.name + '_') except AttributeError: color = getattr(editor.object, editor.name) if type(color) in SequenceTypes: c = QtGui.QColor() c.setRgbF(color[0], color[1], color[2], color[3]) else: c = QtGui.QColor(color) return c def from_qt4_color(self, color): """ Gets the application equivalent of a PyQt value. """ return(color.redF(), color.greenF(), color.blueF(), color.alphaF()) def str_color(self, color): """ Returns the text representation of a specified color value. """ if type(color) in SequenceTypes: return "(%d,%d,%d,%d)" % (int(color[0] * 255.0), int(color[1] * 255.0), int(color[2] * 255.0), int(color[3] * 255.0)) return color def RGBAColorEditor(*args, **traits): return ToolkitEditorFactory(*args, **traits) enthought-chaco2-4.5.1.orig/enable/trait_defs/ui/rgba_color_editor.py0000644000175000017500000000037112516137326024721 0ustar varunvarunfrom traits.etsconfig.api import ETSConfig if ETSConfig.toolkit == 'wx': from .wx.rgba_color_editor import RGBAColorEditor elif ETSConfig.toolkit == 'qt4': from .qt4.rgba_color_editor import RGBAColorEditor else: RGBAColorEditor = None enthought-chaco2-4.5.1.orig/enable/trait_defs/rgba_color_trait.py0000644000175000017500000001067512516137326024151 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2005-2007 by Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # #------------------------------------------------------------------------------ """ Trait definition for an RGBA-based color, which is either: * A tuple of the form (*red*,*green*,*blue*,*alpha*), where each component is in the range from 0.0 to 1.0 * An integer which in hexadecimal is of the form 0xAARRGGBB, where AA is alpha, RR is red, GG is green, and BB is blue. """ from traits.etsconfig.api import ETSConfig from traits.api import Trait, TraitError, TraitFactory from traits.trait_base import SequenceTypes from .ui.api import RGBAColorEditor if ETSConfig.toolkit == 'wx': from traitsui.wx.color_trait import standard_colors def rgba_color(color): return ( color.Red() / 255.0, color.Green() / 255.0, color.Blue() / 255.0, 1.0 ) elif ETSConfig.toolkit == 'qt4': from traitsui.qt4.color_trait import standard_colors def rgba_color(color): return ( color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0, 1.0 ) else: from traitsui.null.color_trait import standard_colors def rgba_color(color): return (((color >> 16) & 0xFF) / 255.0, ((color >> 8) & 0xFF) / 255.0, (color & 0xFF) / 255.0 ) #------------------------------------------------------------------------------- # Convert a value into an Enable/Kiva color: #------------------------------------------------------------------------------- def convert_to_color ( object, name, value ): """ Converts a value to an Enable or Kiva color. """ if ((type( value ) in SequenceTypes) and (len( value ) == 4) and (0.0 <= value[0] <= 1.0) and (0.0 <= value[1] <= 1.0) and (0.0 <= value[2] <= 1.0) and (0.0 <= value[3] <= 1.0)): return value if type( value ) is int: result = ( ((value >> 24) & 0xFF) / 255.0, ((value >> 16) & 0xFF) / 255.0, ((value >> 8) & 0xFF) / 255.0, (value & 0xFF) / 255.0 ) return result raise TraitError convert_to_color.info = ('a tuple of the form (red,green,blue,alpha), where ' 'each component is in the range from 0.0 to 1.0, or ' 'an integer which in hex is of the form 0xAARRGGBB, ' 'where AA is alpha, RR is red, GG is green, and BB is ' 'blue') #------------------------------------------------------------------------------- # Standard colors: #------------------------------------------------------------------------------- # RGBA versions of standard colors rgba_standard_colors = {} for name, color in standard_colors.items(): rgba_standard_colors[ name ] = rgba_color(color) rgba_standard_colors[ 'clear' ] = ( 0, 0, 0, 0 ) #------------------------------------------------------------------------------- # Define Enable/Kiva specific color traits: #------------------------------------------------------------------------------- def RGBAColorFunc(*args, **metadata): """ Returns a trait whose value must be a GUI toolkit-specific RGBA-based color. Description ----------- For wxPython, the returned trait accepts any of the following values: * A tuple of the form (*r*, *g*, *b*, *a*), in which *r*, *g*, *b*, and *a* represent red, green, blue, and alpha values, respectively, and are floats in the range from 0.0 to 1.0 * An integer whose hexadecimal form is 0x*AARRGGBB*, where *AA* is the alpha (transparency) value, *RR* is the red value, *GG* is the green value, and *BB* is the blue value Default Value ------------- For wxPython, (1.0, 1.0, 1.0, 1.0) (that is, opaque white) """ tmp_trait = Trait( 'white', convert_to_color, rgba_standard_colors, editor = RGBAColorEditor ) return tmp_trait(*args, **metadata) RGBAColorTrait = TraitFactory( RGBAColorFunc ) RGBAColor = RGBAColorTrait enthought-chaco2-4.5.1.orig/enable/wx/0000755000175000017500000000000012516137725016567 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/wx/__init__.py0000644000175000017500000000000012516137326020663 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/wx/scrollbar.py0000644000175000017500000002705212516137326021127 0ustar varunvarun""" Define a standard horizontal and vertical Enable scrollbar component that wraps the standard WX one. """ # Major library imports import wx from types import ListType, TupleType # Enthought Imports from traits.api import Property, Trait, TraitError, \ Any, Enum, Bool, Int from enable.component import Component def valid_range(object, name, value): "Verify that a set of range values for a scrollbar is valid" try: if (type(value) in (TupleType, ListType)) and (len(value) == 4): low, high, page_size, line_size = value if high < low: low, high = high, low elif high == low: high = low + 1.0 page_size = max(min(page_size, high - low), 0.0) line_size = max(min(line_size, page_size), 0.0) return (float(low), float(high), float(page_size), float(line_size)) except: raise raise TraitError valid_range.info = 'a (low,high,page_size,line_size) range tuple' def valid_scroll_position(object, name, value): "Verify that a specified scroll bar position is valid" try: low, high, page_size, line_size = object.range if value > high - page_size: value = high - page_size elif value < low: value = low return value except: raise raise TraitError class NativeScrollBar(Component): "An Enable scrollbar component that wraps/embeds the standard WX scrollbar" #------------------------------------------------------------------------ # Public Traits #------------------------------------------------------------------------ # The current position of the scroll bar. This must be within the range # (self.low, self.high) scroll_position = Trait( 0.0, valid_scroll_position ) # A tuple (low, high, page_size, line_size). Can be accessed using # convenience properties (see below). Low and High refer to the conceptual # bounds of the region represented by the full scroll bar. Note that # the maximum value of scroll_position is actually (high - page_size), and # not just the value of high. range = Trait( ( 0.0, 100.0, 10.0, 1.0 ), valid_range ) # The orientation of the scrollbar orientation = Trait("horizontal", "vertical") # The location of y=0 origin = Trait('bottom', 'top') # Determines if the scroll bar should be visible and respond to events enabled = Bool(True) # The scroll increment associated with a single mouse wheel increment mouse_wheel_speed = Int(3) # Expose scroll_position, low, high, page_size as properties low = Property high = Property page_size = Property line_size = Property # This represents the state of the mouse button on the scrollbar thumb. # External classes can monitor this to detect when the user starts and # finishes interacting with this scrollbar via the scrollbar thumb. mouse_thumb = Enum("up", "down") #------------------------------------------------------------------------ # Private Traits #------------------------------------------------------------------------ _control = Any(None) _last_widget_x = Int(0) _last_widget_y = Int(0) _last_widget_height = Int(0) _last_widget_width = Int(0) # Indicates whether or not the widget needs to be re-drawn after being # repositioned and resized _widget_moved = Bool(True) # Set to True if something else has updated the scroll position and # the widget needs to redraw. This is not set to True if the widget # gets updated via user mouse interaction, since WX is then responsible # for updating the scrollbar. _scroll_updated = Bool(True) #------------------------------------------------------------------------ # Public Methods #------------------------------------------------------------------------ def destroy(self): """ Destroy the native widget associated with this component. """ if self._control: self._control.Destroy() return #------------------------------------------------------------------------ # Protected methods #------------------------------------------------------------------------ def __del__(self): self.destroy() return def _get_abs_coords(self, x, y): return self.container.get_absolute_coords(x, y) def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): x_pos, y_pos = self.position x_size, y_size = self.bounds wx_xpos, wx_ypos = self._get_abs_coords(x_pos, y_pos+y_size-1) # We have to do this flip_y business because wx and enable use opposite # coordinate systems, and enable defines the component's position as its # lower left corner, while wx defines it as the upper left corner. window = getattr(gc, "window", None) if window is None: return wx_ypos = window._flip_y(wx_ypos) low, high, page_size, line_size = self.range wxpos, wxthumbsize, wxrange = \ self._enable_to_wx_spec(self.range + (self.scroll_position,)) if not self._control: self._create_control(window, wxpos, wxthumbsize, wxrange) if self._widget_moved: if (self._last_widget_x != wx_xpos) or (self._last_widget_y != wx_ypos): self._control.SetPosition(wx.Point(wx_xpos, wx_ypos)) controlsize = self._control.GetSize() if x_size != controlsize[0] or y_size != controlsize[1]: self._control.SetSize(wx.Size(x_size, y_size)) if self._scroll_updated: self._control.SetScrollbar(wxpos, wxthumbsize, wxrange, wxthumbsize, True) self._last_widget_x = int(wx_xpos) self._last_widget_y = int(wx_ypos) self._last_widget_width = int(x_size) self._last_widget_height = int(y_size) self._scroll_updated = False self._widget_moved = False return def _create_control(self, window, wxpos, wxthumbsize, wxrange): if self.orientation == 'horizontal': wxstyle = wx.HORIZONTAL else: wxstyle = wx.VERTICAL self._control = wx.ScrollBar(window.control, style=wxstyle) self._control.SetScrollbar(wxpos, wxthumbsize, wxrange, wxthumbsize, True) wx.EVT_SCROLL(self._control, self._wx_scroll_handler) wx.EVT_SET_FOCUS(self._control, self._yield_focus) wx.EVT_SCROLL_THUMBTRACK(self._control, self._thumbtrack) wx.EVT_SCROLL_THUMBRELEASE(self._control, self._thumbreleased) wx.EVT_SIZE(self._control, self._control_resized) #------------------------------------------------------------------------ # WX Event handlers #------------------------------------------------------------------------ def _thumbtrack(self, event): self.mouse_thumb = "down" self._wx_scroll_handler(event) def _thumbreleased(self, event): self.mouse_thumb = "up" self._wx_scroll_handler(event) def _control_resized(self, event): self._widget_moved = True self.request_redraw() def _yield_focus(self, event): """ Yields focus to our window, when we acquire focus via user interaction. """ window = event.GetWindow() if window: window.SetFocus() return def _wx_scroll_handler(self, event): """Handle wx scroll events""" # If the user moved the scrollbar, set the scroll position, but don't # tell wx to move the scrollbar. Doing so causes jerkiness self.scroll_position = self._wx_to_enable_pos(self._control.GetThumbPosition()) return def _enable_to_wx_spec(self, enable_spec): """ Return the WX equivalent of an enable scroll bar specification from a tuple of (low, high, page_size, line_size, position). Returns (position, thumbsize, range) """ low, high, page_size, line_size, position = enable_spec if self.origin == 'bottom' and self.orientation == 'vertical': position = (high-page_size) - position + 1 if line_size == 0.0: return (0, high-low, high-low) else: return [int(round(x)) for x in ((position-low)/line_size, page_size/line_size, (high-low)/line_size)] def _wx_to_enable_pos(self, pos): """ Translate the position that the Wx scrollbar returns into the position we store internally. The difference is that we have a high and a low and a line size, while wx assumes low is 0 and line size is 1. """ low, high, page_size, line_size = self.range enablepos = pos * line_size # If we're a veritcal scrollbar with a bottom origin, flip # the coordinates, since in WX the origin is always the top. if self.origin == 'bottom' and self.orientation == 'vertical': enablepos = (high - low - page_size) - enablepos enablepos += low return enablepos #------------------------------------------------------------------------ # Basic trait event handlers #------------------------------------------------------------------------ def _range_changed(self): low, high, page_size, line_size = self.range self.scroll_position = max(min(self.scroll_position, high-page_size), low) self._scroll_updated = True self.request_redraw() return def _range_items_changed(self): self._range_changed() return def _mouse_wheel_changed(self, event): event.handled = True self.scroll_position += (event.mouse_wheel * self.range[3] * self.mouse_wheel_speed) return def _scroll_position_changed(self): self._scroll_updated = True self.request_redraw() return def _bounds_changed(self, old, new): super(NativeScrollBar, self)._bounds_changed(old, new) self._widget_moved = True self.request_redraw() def _bounds_items_changed(self, event): super(NativeScrollBar, self)._bounds_items_changed(event) self._widget_moved = True self.request_redraw() def _position_changed(self, old, new): super(NativeScrollBar, self)._position_changed(old, new) self._widget_moved = True self.request_redraw() def _position_items_changed(self, event): super(NativeScrollBar, self)._position_items_changed(event) self._widget_moved = True self.request_redraw() #------------------------------------------------------------------------ # Property getters and setters #------------------------------------------------------------------------ def _get_low(self): return self.range[0] def _set_low(self, low): ignore, high, page_size, line_size = self.range self._scroll_updated = True self.range = (low, high, page_size, line_size) def _get_high(self): return self.range[1] def _set_high(self, high): low, ignore, page_size, line_size = self.range self._scroll_updated = True self.range = (low, high, page_size, line_size) def _get_page_size(self): return self.range[2] def _set_page_size(self, page_size): low, high, ignore, line_size = self.range self._scroll_updated = True self.range = (low, high, page_size, line_size) def _get_line_size(self): return self.range[3] def _set_line_size(self, line_size): low, high, page_size, ignore = self.range self._scroll_updated = True self.range = (low, high, page_size, line_size) # EOF enthought-chaco2-4.5.1.orig/enable/wx/image.py0000644000175000017500000000506712516137326020230 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ import numpy as np import sys import wx from kiva.agg import CompiledPath, GraphicsContextSystem as GraphicsContext from base_window import BaseWindow from scrollbar import NativeScrollBar def _wx_bitmap_from_buffer(buf, width, height): """ Given a pixel buffer in ARGB order, return a WX bitmap object with the pixels in BGRA order. """ arr = np.frombuffer(buf, dtype=np.uint8).reshape((width, height, 4)) copy = np.zeros_like(arr) copy[...,0::4] = arr[...,2::4] copy[...,1::4] = arr[...,1::4] copy[...,2::4] = arr[...,0::4] copy[...,3::4] = arr[...,3::4] return wx.BitmapFromBufferRGBA(width, height, np.ravel(copy)) class Window(BaseWindow): def _create_gc(self, size, pix_format="bgra32"): "Create a Kiva graphics context of a specified size" # We have to set bottom_up=0 or otherwise the PixelMap will # appear upside down when blitting. Note that this is not the # case on Windows. bottom_up = 0 if sys.platform != 'win32' else 1 gc = GraphicsContext((size[0]+1, size[1]+1), pix_format = pix_format, bottom_up = bottom_up) gc.translate_ctm(0.5, 0.5) return gc def _window_paint(self, event): "Do a GUI toolkit specific screen update" if self.control is None: event.Skip() return control = self.control pixel_map = self._gc.pixel_map wdc = control._dc = wx.PaintDC(control) if hasattr(pixel_map, 'draw_to_wxwindow'): pixel_map.draw_to_wxwindow(control, 0, 0) else: # This should just be the Mac OS X code path bmp = _wx_bitmap_from_buffer(pixel_map.convert_to_argb32string(), self._gc.width(), self._gc.height()) wdc.DrawBitmap(bmp, 0, 0) control._dc = None return def font_metrics_provider(): from kiva.fonttools import Font gc = GraphicsContext((1, 1)) gc.set_font(Font()) return gc # EOF enthought-chaco2-4.5.1.orig/enable/wx/gl.py0000644000175000017500000000427212516137326017545 0ustar varunvarunimport wx import pyglet pyglet.options['shadow_window'] = False from wx.glcanvas import GLCanvas from traits.api import Instance from kiva.gl import CompiledPath, GraphicsContext from base_window import BaseWindow from scrollbar import NativeScrollBar class Window(BaseWindow): control = Instance(GLCanvas) def __init__(self, *args, **kw): super(Window, self).__init__(*args, **kw) # If we are using the GL backend, we will need to have a pyglet # GL context self._pyglet_gl_context = None self._gc = None def _create_control(self, parent, wid, pos = wx.DefaultPosition, size = wx.DefaultSize): return GLCanvas(parent, wid, pos, size, style=wx.CLIP_CHILDREN|wx.WANTS_CHARS) def _create_gc(self, size, pix_format=None): """ Create a GraphicsContext instance. """ gc = GraphicsContext((size[0]+1,size[1]+1)) if self._pyglet_gl_context is None: from pyglet.gl import Context self._pyglet_gl_context = Context() gc.gl_init() gc.translate_ctm(0.5, 0.5) return gc def _init_gc(self): """ Gives the GC a chance to initialize itself before components perform layout and draw. This is called every time through the paint loop. """ dc = wx.PaintDC(self.control) self._pyglet_gl_context.set_current() self.control.SetCurrent() super(Window, self)._init_gc() def _paint(self, event=None): """ Paint the contents of the window. """ if self.control is None: event.Skip() return size = self._get_control_size() self._size = tuple(size) self._gc = self._create_gc(size) self._init_gc() if hasattr(self.component, "do_layout"): self.component.do_layout() self._gc.clear(self.bgcolor_) self.component.draw(self._gc, view_bounds=(0, 0, size[0], size[1])) self._update_region = [] self.control.SwapBuffers() def font_metrics_provider(): from kiva.fonttools import Font gc = GraphicsContext((1, 1)) gc.set_font(Font()) return gc # EOF enthought-chaco2-4.5.1.orig/enable/wx/quartz.py0000644000175000017500000000661012516137326020467 0ustar varunvarun""" Defines the concrete top-level Enable 'Window' class for the wxPython GUI toolkit, based on the Quartz kiva backend for OS X. """ # Major library imports. import numpy as np import wx # Enthought library imports. from kiva.fonttools import Font from kiva.quartz import get_macport, ABCGI # Local imports. from base_window import BaseWindow from scrollbar import NativeScrollBar CompiledPath = ABCGI.CGMutablePath class GraphicsContext(ABCGI.CGLayerContext): def __init__(self, size_or_array, *args, **kwds): gc = kwds.pop('window_gc', None) if not gc: # Create a tiny base context to spawn the CGLayerContext from. # We are better off making our Layer from the window gc since # the data formats will match and so it will be faster to draw the # layer. gc = ABCGI.CGBitmapContext((1,1)) if isinstance(size_or_array, np.ndarray): # Initialize the layer with an image. image = ABCGI.CGImage(size_or_array) width = image.width height = image.height else: # No initialization. image = None width, height = size_or_array super(GraphicsContext, self).__init__((width, height), gc, *args, **kwds) if image is not None: self.draw_image(image) @classmethod def create_from_gc(klass, gc, size_or_array, *args, **kwds): return klass(size_or_array, window_gc=gc, *args, **kwds) class _WindowGraphicsContext(ABCGI.CGContextInABox): def __init__(self, *args, **kwds): super(_WindowGraphicsContext, self).__init__(*args, **kwds) self._begun = False def begin(self): if self._begun: return self.save_state() self.translate_ctm(0, self.height()) self.scale_ctm(1.0, -1.0) self._begun = True def end(self): if self._begun: self.restore_state() self._begun = False @staticmethod def create_from_gc(gc, size_or_array, *args, **kwds): return GraphicsContext(size_or_array, window_gc=gc, *args, **kwds) class Window(BaseWindow): """ An Enable Window for wxPython GUIs on OS X. """ #### 'BaseWindow' interface ################################################ def _create_gc(self, size, pix_format="bgra32"): self.dc = wx.ClientDC(self.control) gc = _WindowGraphicsContext(self.dc.GetSizeTuple(), get_macport(self.dc)) gc.begin() return gc def _window_paint(self, event): self.dc = None self._gc = None # force a new gc to be created for the next paint() #### 'AbstractWindow' interface ############################################ def _paint(self, event=None): size = self._get_control_size() if (self._size != tuple(size)) or (self._gc is None): self._gc = self._create_gc(size) self._size = tuple(size) gc = self._gc gc.begin() gc.clear(self.bgcolor_) if hasattr(self.component, "do_layout"): self.component.do_layout() self.component.draw(gc, view_bounds=(0, 0, size[0], size[1])) self._window_paint(event) gc.end() return def font_metrics_provider(): gc = GraphicsContext((1, 1)) gc.set_font(Font()) return gc #### EOF ####################################################################### enthought-chaco2-4.5.1.orig/enable/wx/base_window.py0000644000175000017500000004612212516137326021444 0ustar varunvarun""" Defines the concrete top-level Enable 'Window' class for the wxPython GUI toolkit, based on the kiva agg driver. """ from __future__ import absolute_import import sys import time import wx from traits.api import Any, Instance, Trait from traitsui.wx.menu import MakeMenu # Relative imports from enable.events import MouseEvent, KeyEvent, DragEvent from enable.abstract_window import AbstractWindow from .constants import DRAG_RESULTS_MAP, POINTER_MAP, KEY_MAP try: from pyface.wx.drag_and_drop import clipboard, PythonDropTarget except ImportError: clipboard = None PythonDropTarget = None #------------------------------------------------------------------------------- # Constants: #------------------------------------------------------------------------------- # Number of pixels to scroll at a time: scroll_incr = 16 # Reusable instance to avoid constructor/destructor overhead: wx_rect = wx.Rect( 0, 0, 0, 0 ) # Default 'fake' start event for wxPython based drag operations: default_start_event = MouseEvent() # To conserve system resources, there is only one 'timer' per program: system_timer = None class EnableTimer ( wx.Timer ): """ This class maintains a 'work list' of scheduled components, where each item in the list has the form: [ component, interval, timer_pop_time ] """ def __init__ ( self ): wx.Timer.__init__( self ) self._work_list = [] return def schedule ( self, component, interval ): "Schedule a timer event for a specified component" work_list = self._work_list if len( work_list ) == 0: self.Start( 5, oneShot=False ) for i, item in enumerate( work_list ): if component is item[0]: del work_list[i] break self.reschedule( component, interval ) return def reschedule ( self, component, interval ): "Reshedule a recurring timer event for a component" pop_time = time.time() + interval new_item = [ component, interval, pop_time ] work_list = self._work_list for i, item in enumerate( work_list ): if pop_time < item[2]: work_list.insert( i, new_item ) break else: work_list.append( new_item ) return def cancel ( self, component ): "Cancel any pending timer events for a component" work_list = self._work_list for i, item in enumerate( work_list ): if component is item[0]: del work_list[i] if len( work_list ) == 0: self.Stop() break return (len( work_list ) != 0) def Notify ( self ): "Handle a timer 'pop' event; used for performance testing purposes" now = time.time() work_list = self._work_list n = len( work_list ) i = 0 while (i < n) and (now >= work_list[i][2]): i += 1 if i > 0: reschedule = work_list[:i] del work_list[:i] for component, interval, ignore in reschedule: self.reschedule( component, interval ) component.timer = True return class LessSuckyDropTarget(PythonDropTarget): """ The sole purpose of this class is to override the implementation of OnDragOver() in the parent class to NOT short-circuit return the 'default_drag_result' if the drop_source is None. (The parent class implementation basically means that everything looks like it's OK to drop, and the DnD handler doesn't ever get a chance to intercept or veto.) """ def OnDragOver(self, x, y, default_drag_result): # This is a cut-and-paste job of the parent class implementation. # Please refer to its comments. if clipboard.drop_source is not None and \ not clipboard.drop_source.allow_move: default_drag_result = wx.DragCopy if hasattr(self.handler, 'wx_drag_over'): drag_result = self.handler.wx_drag_over( x, y, clipboard.data, default_drag_result ) else: drag_result = default_drag_result return drag_result class BaseWindow(AbstractWindow): # Screen scroll increment amount: scroll_incr = ( wx.SystemSettings_GetMetric( wx.SYS_SCREEN_Y ) or 768 ) / 20 # Width/Height of standard scrollbars: scrollbar_dx = wx.SystemSettings_GetMetric( wx.SYS_VSCROLL_X ) scrollbar_dy = wx.SystemSettings_GetMetric( wx.SYS_HSCROLL_Y ) _cursor_color = Any # PZW: figure out the correct type for this... # Reference to the actual wxPython window: control = Instance(wx.Window) # This is set by downstream components to notify us of whether or not # the current drag operation should return DragCopy, DragMove, or DragNone. _drag_result = Any def __init__(self, parent, wid=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, **traits): AbstractWindow.__init__(self, **traits) self._timer = None self._mouse_captured = False # Due to wx wonkiness, we don't reliably get cursor position from # a wx KeyEvent. Thus, we manually keep track of when we last saw # the mouse and use that information instead. These coordinates are # in the wx coordinate space, i.e. pre-self._flip_y(). self._last_mouse_pos = (0, 0) # Create the delegate: self.control = control = self._create_control(parent, wid, pos, size) # Set up the 'erase background' event handler: wx.EVT_ERASE_BACKGROUND( control, self._on_erase_background ) # Set up the 'paint' event handler: wx.EVT_PAINT( control, self._paint ) wx.EVT_SIZE( control, self._on_size ) # Set up mouse event handlers: wx.EVT_LEFT_DOWN( control, self._on_left_down ) wx.EVT_LEFT_UP( control, self._on_left_up ) wx.EVT_LEFT_DCLICK( control, self._on_left_dclick ) wx.EVT_MIDDLE_DOWN( control, self._on_middle_down ) wx.EVT_MIDDLE_UP( control, self._on_middle_up ) wx.EVT_MIDDLE_DCLICK( control, self._on_middle_dclick ) wx.EVT_RIGHT_DOWN( control, self._on_right_down ) wx.EVT_RIGHT_UP( control, self._on_right_up ) wx.EVT_RIGHT_DCLICK( control, self._on_right_dclick ) wx.EVT_MOTION( control, self._on_mouse_move ) wx.EVT_ENTER_WINDOW( control, self._on_window_enter ) wx.EVT_LEAVE_WINDOW( control, self._on_window_leave ) wx.EVT_MOUSEWHEEL( control, self._on_mouse_wheel ) # Handle key up/down events: wx.EVT_KEY_DOWN( control, self._on_key_pressed ) wx.EVT_KEY_UP( control, self._on_key_released ) wx.EVT_CHAR( control, self._on_character ) # Attempt to allow wxPython drag and drop events to be mapped to # Enable drag events: # Handle window close and cleanup wx.EVT_WINDOW_DESTROY(control, self._on_close) if PythonDropTarget is not None: control.SetDropTarget( LessSuckyDropTarget( self ) ) self._drag_over = [] # In some cases, on the Mac at least, we never get an initial EVT_SIZE # since the initial size is correct. Because of this we call _on_size # here to initialize our bounds. self._on_size(None) return def _create_control(self, parent, wid, pos = wx.DefaultPosition, size = wx.DefaultSize): return wx.Window(parent, wid, pos, size, style = wx.CLIP_CHILDREN | wx.WANTS_CHARS) def _on_close(self, event): # Might be scrollbars or other native components under # us that are generating this event if event.GetWindow() == self.control: self._gc = None wx.EVT_ERASE_BACKGROUND(self.control, None) wx.EVT_PAINT(self.control, None) wx.EVT_SIZE(self.control, None) wx.EVT_LEFT_DOWN(self.control, None) wx.EVT_LEFT_UP(self.control, None) wx.EVT_LEFT_DCLICK(self.control, None) wx.EVT_MIDDLE_DOWN(self.control, None) wx.EVT_MIDDLE_UP(self.control, None) wx.EVT_MIDDLE_DCLICK(self.control, None) wx.EVT_RIGHT_DOWN(self.control, None) wx.EVT_RIGHT_UP(self.control, None) wx.EVT_RIGHT_DCLICK(self.control, None) wx.EVT_MOTION(self.control, None) wx.EVT_ENTER_WINDOW(self.control, None) wx.EVT_LEAVE_WINDOW(self.control, None) wx.EVT_MOUSEWHEEL(self.control, None) wx.EVT_KEY_DOWN(self.control, None) wx.EVT_KEY_UP(self.control, None) wx.EVT_CHAR(self.control, None) wx.EVT_WINDOW_DESTROY(self.control, None) self.control.SetDropTarget(None) self.control = None self.component.cleanup(self) self.component.parent = None self.component.window = None self.component = None return def _flip_y ( self, y ): "Convert from a Kiva to a wxPython y coordinate" return int( self._size[1] - 1 - y ) def _on_erase_background ( self, event ): pass def _on_size ( self, event ): dx, dy = self.control.GetSizeTuple() # do nothing if the new and old sizes are the same if (self.component.outer_width, self.component.outer_height) == (dx, dy): return self.resized = (dx, dy) if getattr(self.component, "fit_window", False): self.component.outer_position = [0,0] self.component.outer_bounds = [dx, dy] elif hasattr(self.component, "resizable"): if "h" in self.component.resizable: self.component.outer_x = 0 self.component.outer_width = dx if "v" in self.component.resizable: self.component.outer_y = 0 self.component.outer_height = dy self.control.Refresh() return def _capture_mouse ( self ): "Capture all future mouse events" if not self._mouse_captured: self._mouse_captured = True self.control.CaptureMouse() return def _release_mouse ( self ): "Release the mouse capture" if self._mouse_captured: self._mouse_captured = False self.control.ReleaseMouse() return def _on_key_pressed(self, event): handled = self._handle_key_event('key_pressed', event) if not handled: event.Skip() def _on_key_released(self, event): handled = self._handle_key_event('key_released', event) if not handled: event.Skip() def _create_key_event(self, event_type, event): """ Convert a GUI toolkit keyboard event into a KeyEvent. """ if self.focus_owner is None: focus_owner = self.component else: focus_owner = self.focus_owner if focus_owner is not None: if event_type == 'character': key = unichr(event.GetUniChar()) if not key: return None else: key_code = event.GetKeyCode() if key_code in KEY_MAP: key = KEY_MAP.get(key_code) else: key = unichr(event.GetUniChar()).lower() # Use the last-seen mouse coordinates instead of GetX/GetY due # to wx bug. x, y = self._last_mouse_pos # Someday when wx does this properly, we can use these instead: # x = event.GetX() # y = event.GetY() return KeyEvent( event_type = event_type, character = key, alt_down = event.AltDown(), control_down = event.ControlDown(), shift_down = event.ShiftDown(), x = x, y = self._flip_y(y), event = event, window = self) else: event.Skip() return None def _create_mouse_event ( self, event ): "Convert a GUI toolkit mouse event into a MouseEvent" if event is not None: x = event.GetX() y = event.GetY() self._last_mouse_pos = (x, y) mouse_wheel = ((event.GetLinesPerAction() * event.GetWheelRotation()) / (event.GetWheelDelta() or 1)) # Note: The following code fixes a bug in wxPython that returns # 'mouse_wheel' events in screen coordinates, rather than window # coordinates: if float(wx.VERSION_STRING[:3]) < 2.8: if mouse_wheel != 0 and sys.platform == "win32": x, y = self.control.ScreenToClientXY( x, y ) return MouseEvent( x = x, y = self._flip_y( y ), alt_down = event.AltDown(), control_down = event.ControlDown(), shift_down = event.ShiftDown(), left_down = event.LeftIsDown(), middle_down = event.MiddleIsDown(), right_down = event.RightIsDown(), mouse_wheel = mouse_wheel, window = self ) # If no event specified, make one up: x, y = wx.GetMousePosition() x, y = self.control.ScreenToClientXY( x, y ) self._last_mouse_pos = (x, y) return MouseEvent( x = x, y = self._flip_y( y ), alt_down = self.alt_pressed, control_down = self.ctrl_pressed, shift_down = self.shift_pressed, left_down = False, middle_down = False, right_down = False, mouse_wheel = 0, window = self) def _create_gc(self, size, pix_format=None): "Create a Kiva graphics context of a specified size" raise NotImplementedError def _redraw(self, coordinates=None): "Request a redraw of the window" if coordinates is None: if self.control: self.control.Refresh(False) else: xl, yb, xr, yt = coordinates rect = wx_rect rect.SetX( int( xl ) ) rect.SetY( int( self._flip_y( yt - 1 ) ) ) rect.SetWidth( int( xr - xl ) ) rect.SetHeight( int( yt - yb ) ) if self.control: self.control.Refresh(False, rect) return def _get_control_size ( self ): "Get the size of the underlying toolkit control" result = None if self.control: result = self.control.GetSizeTuple() return result def _window_paint ( self, event): "Do a GUI toolkit specific screen update" raise NotImplementedError def set_pointer ( self, pointer ): "Set the current pointer (i.e. cursor) shape" ptr = POINTER_MAP[ pointer ] if type( ptr ) is int: POINTER_MAP[ pointer ] = ptr = wx.StockCursor( ptr ) self.control.SetCursor( ptr ) return def set_tooltip ( self, tooltip ): "Set the current tooltip for the window" wx.ToolTip_Enable( False ) self.control.SetToolTip( wx.ToolTip( tooltip ) ) wx.ToolTip_Enable( True ) return def set_timer_interval ( self, component, interval ): """ Set up or cancel a timer for a specified component. To cancel the timer, set interval=None """ global system_timer if interval is None: if ((system_timer is not None) and (not system_timer.cancel( component ))): system_timer = None else: if system_timer is None: system_timer = EnableTimer() system_timer.schedule( component, interval ) return def _set_focus ( self ): "Sets the keyboard focus to this window" self.control.SetFocus() return def screen_to_window(self, x, y): pt = wx.Point(x,y) x,y = self.control.ScreenToClient(pt) y = self._flip_y(y) return x,y def get_pointer_position(self): "Returns the current pointer position in local window coordinates" pos = wx.GetMousePosition() return self.screen_to_window(pos.x, pos.y) def set_drag_result(self, result): if result not in DRAG_RESULTS_MAP: raise RuntimeError, "Unknown drag result '%s'" % result self._drag_result = DRAG_RESULTS_MAP[result] return def wx_dropped_on ( self, x, y, drag_object, drop_result ): "Handle wxPython drag and drop events" # Process the 'dropped_on' event for the object(s) it was dropped on: y = self._flip_y(y) drag_event = DragEvent(x=x, y=y, obj=drag_object, window=self) self._drag_result = wx.DragNone if self.component.is_in(x, y): self.component.dispatch(drag_event, "dropped_on") # If a downstream component wants to express that it handled the return self._drag_result def wx_drag_over ( self, x, y, drag_object, drag_result ): y = self._flip_y( y ) drag_over_event = DragEvent( x = x, y = y, x0 = 0.0, y0 = 0.0, copy = drag_result != wx.DragMove, obj = drag_object, start_event = default_start_event, window = self ) # By default, don't indicate that we can be dropped on. It is up # to the component to set this correctly. self._drag_result = wx.DragNone if self.component.is_in(x, y): self.component.dispatch(drag_over_event, "drag_over") return self._drag_result def wx_drag_leave ( self, drag_object ): drag_leave_event = DragEvent( x = 0.0, y = 0.0, x0 = 0.0, y0 = 0.0, copy = False, obj = drag_object, start_event = default_start_event, window = self ) self.component.dispatch(drag_leave_event, "drag_leave") return def create_menu ( self, menu_definition, owner ): "Create a wxMenu from a string description" return MakeMenu( menu_definition, owner, True, self.control ) def popup_menu ( self, menu, x, y ): "Pop-up a wxMenu at a specified location" self.control.PopupMenuXY( menu.menu, int(x), int( self._flip_y(y) ) ) return # EOF enthought-chaco2-4.5.1.orig/enable/wx/constants.py0000644000175000017500000000642112516137326021155 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ from __future__ import absolute_import import warnings import wx from ..toolkit_constants import pointer_names, key_names DRAG_RESULTS_MAP = { "error": wx.DragError, "none": wx.DragNone, "copy": wx.DragCopy, "move": wx.DragMove, "link": wx.DragLink, "cancel": wx.DragCancel } # Map from pointer shape name to pointer shapes: pointer_shapes = [ wx.CURSOR_ARROW, wx.CURSOR_ARROWWAIT, wx.CURSOR_BLANK, wx.CURSOR_BULLSEYE, wx.CURSOR_CHAR, wx.CURSOR_CROSS, wx.CURSOR_HAND, wx.CURSOR_IBEAM, wx.CURSOR_LEFT_BUTTON, wx.CURSOR_MAGNIFIER, wx.CURSOR_MIDDLE_BUTTON, wx.CURSOR_NO_ENTRY, wx.CURSOR_PAINT_BRUSH, wx.CURSOR_PENCIL, wx.CURSOR_POINT_LEFT, wx.CURSOR_POINT_RIGHT, wx.CURSOR_QUESTION_ARROW, wx.CURSOR_RIGHT_ARROW, wx.CURSOR_RIGHT_BUTTON, wx.CURSOR_SIZENS, wx.CURSOR_SIZENESW, wx.CURSOR_SIZENWSE, wx.CURSOR_SIZEWE, wx.CURSOR_SIZEWE, wx.CURSOR_SIZENS, wx.CURSOR_SIZENWSE, wx.CURSOR_SIZENESW, wx.CURSOR_SIZING, wx.CURSOR_SPRAYCAN, wx.CURSOR_WAIT, wx.CURSOR_WATCH, ] if len(pointer_names) != len(pointer_shapes): warnings.warn("The WX toolkit backend pointer map is out of sync!") POINTER_MAP = dict(zip(pointer_names, pointer_shapes)) # Map from wxPython special key names into Enable key names: key_symbols = [ wx.WXK_ADD, wx.WXK_BACK, wx.WXK_CANCEL, wx.WXK_CAPITAL, wx.WXK_CLEAR, wx.WXK_CONTROL, wx.WXK_DECIMAL, wx.WXK_DELETE, wx.WXK_DIVIDE, wx.WXK_DOWN, wx.WXK_END, wx.WXK_RETURN, wx.WXK_NUMPAD_ENTER, wx.WXK_ESCAPE, wx.WXK_EXECUTE, wx.WXK_F1, wx.WXK_F10, wx.WXK_F11, wx.WXK_F12, wx.WXK_F13, wx.WXK_F14, wx.WXK_F15, wx.WXK_F16, wx.WXK_F17, wx.WXK_F18, wx.WXK_F19, wx.WXK_F2, wx.WXK_F20, wx.WXK_F21, wx.WXK_F22, wx.WXK_F23, wx.WXK_F24, wx.WXK_F3, wx.WXK_F4, wx.WXK_F5, wx.WXK_F6, wx.WXK_F7, wx.WXK_F8, wx.WXK_F9, wx.WXK_HELP, wx.WXK_HOME, wx.WXK_INSERT, wx.WXK_LEFT, wx.WXK_MENU, wx.WXK_MULTIPLY, wx.WXK_NUMLOCK, wx.WXK_NUMPAD0, wx.WXK_NUMPAD1, wx.WXK_NUMPAD2, wx.WXK_NUMPAD3, wx.WXK_NUMPAD4, wx.WXK_NUMPAD5, wx.WXK_NUMPAD6, wx.WXK_NUMPAD7, wx.WXK_NUMPAD8, wx.WXK_NUMPAD9, wx.WXK_NEXT, wx.WXK_PRIOR, wx.WXK_PAUSE, wx.WXK_PRINT, wx.WXK_RIGHT, wx.WXK_SCROLL, wx.WXK_SELECT, wx.WXK_SHIFT, wx.WXK_SUBTRACT, wx.WXK_TAB, wx.WXK_UP, wx.WXK_ALT, ] if len(key_symbols) != len(key_names): warnings.warn("The WX toolkit backend keymap is out of sync!") KEY_MAP = dict(zip(key_symbols, key_names)) enthought-chaco2-4.5.1.orig/enable/wx/cairo.py0000644000175000017500000000326012516137326020234 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ import wx from kiva.cairo import CompiledPath, GraphicsContext, font_metrics_provider from base_window import BaseWindow from scrollbar import NativeScrollBar class Window(BaseWindow): def _create_gc(self, size, pix_format="bgra32"): "Create a Kiva graphics context of a specified size" gc = GraphicsContext((size[0]+1, size[1]+1)) gc.translate_ctm(0.5, 0.5) return gc def _window_paint(self, event): "Do a GUI toolkit specific screen update" if self.control is None: event.Skip() return control = self.control pixel_map = self._gc.pixel_map wdc = control._dc = wx.PaintDC(control) self._update_region = None if self._update_region is not None: update_bounds = reduce(union_bounds, self._update_region) pixel_map.draw_to_wxwindow(control, int(update_bounds[0]), int(update_bounds[1]), width=int(update_bounds[2]), height=int(update_bounds[3])) else: pixel_map.draw_to_wxwindow(control, 0, 0) control._dc = None return # EOF enthought-chaco2-4.5.1.orig/enable/toolkit.py0000644000175000017500000000373612516137326020176 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2007, Riverbank Computing Limited # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # #------------------------------------------------------------------------------ # Standard library imports. import sys from traceback import format_exception_only # Enthought library imports. from traits.etsconfig.api import ETSConfig # This is set to the api module path for the selected backend. _toolkit_backend = None def _init_toolkit(): """ Initialise the current toolkit. """ if not ETSConfig.toolkit: # Force Traits to decide on its toolkit if it hasn't already from traitsui.toolkit import toolkit as traits_toolkit traits_toolkit() # Import the selected backend backend = 'enable.%s.%s' % (ETSConfig.toolkit, ETSConfig.kiva_backend) try: __import__(backend) except ImportError, SystemExit: t, v, _tb = sys.exc_info() raise ImportError, "Unable to import the %s backend for the %s " \ "toolkit (reason: %s)." % (ETSConfig.kiva_backend, ETSConfig.toolkit, format_exception_only(t, v)) # Save the imported toolkit module. global _toolkit_backend _toolkit_backend = backend # Do this once then disappear. _init_toolkit() del _init_toolkit def toolkit_object(name): """ Return the toolkit specific object with the given name. """ try: be_obj = getattr(sys.modules[_toolkit_backend], name) except AttributeError: raise NotImplementedError("the %s.%s enable backend doesn't implement %s" % (ETSConfig.toolkit, ETSConfig.kiva_backend, name)) return be_obj enthought-chaco2-4.5.1.orig/enable/overlay_container.py0000644000175000017500000000133012516137326022220 0ustar varunvarun from container import Container from simple_layout import simple_container_get_preferred_size, \ simple_container_do_layout class OverlayContainer(Container): """ A container that stretches all its components to fit within its space. All of its components must therefore be resizable. """ def get_preferred_size(self, components=None): """ Returns the size (width,height) that is preferred for this component. Overrides PlotComponent """ return simple_container_get_preferred_size(self, components=components) def _do_layout(self): """ Actually performs a layout (called by do_layout()). """ simple_container_do_layout(self) return enthought-chaco2-4.5.1.orig/enable/window.py0000644000175000017500000000147712516137326020020 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2005, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # # Author: Enthought, Inc. # Description: #------------------------------------------------------------------------------ # Import the toolkit specific version. from toolkit import toolkit_object Window = toolkit_object('Window') #### EOF ###################################################################### enthought-chaco2-4.5.1.orig/enable/controls.py0000644000175000017500000005371212516137326020353 0ustar varunvarun#------------------------------------------------------------------------------- # # Define standard Enable 'control' components, like text/image labels, # push buttons, radio buttons, check boxes, and so on. # # Written by: David C. Morrill # # Date: 10/10/2003 # # (c) Copyright 2003 by Enthought, Inc. # # Classes defined: Label # RadioButton # CheckBox # #------------------------------------------------------------------------------- from __future__ import with_statement # Major library imports import os.path # Enthought library imports from enable.colors import ColorTrait from traits.api import Bool, Delegate, HasTraits, Str, Trait, \ TraitPrefixList from traitsui.api import View, Group # Local relative imports from component import Component from base import LEFT, RIGHT, TOP, BOTTOM, HCENTER, VCENTER, EMBOSSED, ENGRAVED, \ transparent_color, xy_in_bounds, add_rectangles from enable_traits import spacing_trait, padding_trait, margin_trait,\ border_size_trait, image_trait from enable_traits import position_trait, font_trait, engraving_trait from radio_group import RadioStyle, RadioGroup #------------------------------------------------------------------------------- # Constants: #------------------------------------------------------------------------------- empty_text_info = ( 0, 0, 0, 0 ) LEFT_OR_RIGHT = LEFT | RIGHT TOP_OR_BOTTOM = TOP | BOTTOM orientation_trait = Trait( 'text', TraitPrefixList( [ 'text', 'component' ] ) ) class LabelTraits ( HasTraits ): text = Str font = font_trait text_position = position_trait("left") color = ColorTrait("black") shadow_color = ColorTrait("white") style = engraving_trait image = image_trait image_position = position_trait("left") image_orientation = orientation_trait spacing_height = spacing_trait spacing_width = spacing_trait padding_left = padding_trait padding_right = padding_trait padding_top = padding_trait padding_bottom = padding_trait margin_left = margin_trait margin_right = margin_trait margin_top = margin_trait margin_bottom = margin_trait border_size = border_size_trait border_color = ColorTrait("black") bg_color = ColorTrait("clear") enabled = Bool(True) selected = Bool(False) #--------------------------------------------------------------------------- # Trait view definitions: #--------------------------------------------------------------------------- traits_view = View( Group( 'enabled', 'selected', id = 'component' ), Group( 'text', ' ', 'font', ' ', 'color', ' ', 'shadow_color', ' ', 'style', id = 'text', style = 'custom' ), Group( 'bg_color{Background Color}', '_', 'border_color', '_', 'border_size', id = 'border', style = 'custom' ), Group( 'text_position', '_', 'image_position', '_', 'image_orientation', ' ', 'image', id = 'position', style = 'custom' ), Group( 'spacing_height', 'spacing_width', '_', 'padding_left', 'padding_right', 'padding_top', 'padding_bottom', '_', 'margin_left', 'margin_right', 'margin_top', 'margin_bottom', id = 'margin' ) ) default_label_traits = LabelTraits() #------------------------------------------------------------------------------- # 'Label' class: #------------------------------------------------------------------------------- LabelTraitDelegate = Delegate( 'delegate', redraw = True ) LayoutLabelTraitDelegate = LabelTraitDelegate( layout = True ) LabelContentDelegate = LayoutLabelTraitDelegate( content = True ) class Label ( Component ): #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- delegate = Trait( default_label_traits ) text = LabelContentDelegate font = LabelContentDelegate text_position = LayoutLabelTraitDelegate color = LabelTraitDelegate shadow_color = LabelTraitDelegate style = LabelTraitDelegate image = LayoutLabelTraitDelegate image_position = LayoutLabelTraitDelegate image_orientation = LayoutLabelTraitDelegate spacing_height = LayoutLabelTraitDelegate spacing_width = LayoutLabelTraitDelegate padding_left = LayoutLabelTraitDelegate padding_right = LayoutLabelTraitDelegate padding_top = LayoutLabelTraitDelegate padding_bottom = LayoutLabelTraitDelegate margin_left = LayoutLabelTraitDelegate margin_right = LayoutLabelTraitDelegate margin_top = LayoutLabelTraitDelegate margin_bottom = LayoutLabelTraitDelegate border_size = LayoutLabelTraitDelegate border_color = LabelTraitDelegate bg_color = LabelTraitDelegate enabled = LabelTraitDelegate selected = LabelTraitDelegate #--------------------------------------------------------------------------- # Trait view definitions: #--------------------------------------------------------------------------- traits_view = View( Group( '', 'enabled', 'selected', id = 'component' ), Group( '', 'delegate', id = 'links' ), Group( 'text', ' ', 'font', ' ', 'color', ' ', 'shadow_color', ' ', 'style', id = 'text', style = 'custom' ), Group( 'bg_color{Background Color}', '_', 'border_color', '_', 'border_size', id = 'border', style = 'custom' ), Group( 'text_position', '_', 'image_position', '_', 'image_orientation', ' ', 'image', id = 'position', style = 'custom' ), Group( 'spacing_height', 'spacing_width', '_', 'padding_left', 'padding_right', 'padding_top', 'padding_bottom', '_', 'margin_left', 'margin_right', 'margin_top', 'margin_bottom', id = 'margin' ) ) colorchip_map = { 'fg_color': 'color', 'bg_color': 'bg_color', 'shadow_color': 'shadow_color', 'alt_color': 'border_color' } #--------------------------------------------------------------------------- # Initialize the object: #--------------------------------------------------------------------------- def __init__ ( self, text = '', **traits ): self.text = text Component.__init__( self, **traits ) #--------------------------------------------------------------------------- # Handle any trait being modified: #--------------------------------------------------------------------------- def _anytrait_changed ( self, name, old, new ): trait = self.trait( name ) if trait.content: self.update_text() if trait.redraw: if trait.layout: self.layout() self.redraw() #--------------------------------------------------------------------------- # Return the components that contain a specified (x,y) point: #--------------------------------------------------------------------------- def _components_at ( self, x, y ): if self._in_margins( x, y ): return [ self ] return [] #--------------------------------------------------------------------------- # Return whether not a specified point is inside the component margins: #--------------------------------------------------------------------------- def _in_margins ( self, x, y ): ml = self.margin_left mb = self.margin_bottom return xy_in_bounds( x, y, add_rectangles( self.bounds, ( ml, mb, -(self.margin_right + ml), -(self.margin_top + mb) ) ) ) #--------------------------------------------------------------------------- # Update any information related to the text content of the control: #--------------------------------------------------------------------------- def update_text ( self ): text = self.text if text == '': self._text = [] self._tdx = [] self._max_tdx = self._tdy = 0 else: self._text = _text = text.split( '\n' ) gc = self.gc_temp() gc.set_font( self.font ) max_tdx = 0 self._tdx = _tdx = [ 0 ] * len( _text ) for i, text in enumerate( _text ): tdx, tdy, descent, leading = gc.get_full_text_extent( text ) tdy += descent + 5 max_tdx = max( max_tdx, tdx ) _tdx[i] = tdx self._max_tdx = max_tdx self._tdy = tdy #--------------------------------------------------------------------------- # Layout and compute the minimum size of the control: #--------------------------------------------------------------------------- def layout ( self ): sdx = self.spacing_width sdy = self.spacing_height n = len( self._text ) if n == 0: tdx = tdy = sdx = sdy = 0 else: tdx = self._max_tdx tdy = self._tdy * n image = self._image if image is not None: idx = image.width() idy = image.height() else: idx = idy = sdx = sdy = 0 image_position = self.image_position_ if image_position & LEFT_OR_RIGHT: itdx = tdx + sdx + idx if image_position & LEFT: ix = 0 tx = idx + sdx else: tx = 0 ix = tdx + sdx else: itdx = max( tdx, idx ) ix = (itdx - idx) / 2.0 tx = (itdx - tdx) / 2.0 if image_position & TOP_OR_BOTTOM: itdy = tdy + sdy + idy if image_position & TOP: iy = tdy + sdy ty = 0 else: iy = 0 ty = idy + sdy else: itdy = max( tdy, idy ) iy = (itdy - idy) / 2.0 ty = (itdy - tdy) / 2.0 bs = 2 * self.border_size self.min_width = itdx + (self.margin_left + self.margin_right + self.padding_left + self.padding_right + bs) self.min_height = itdy + (self.margin_top + self.margin_bottom + self.padding_top + self.padding_bottom + bs) self._info = ( ix, iy, idx, idy, tx, ty, tdx, self._tdy, itdx, itdy ) #--------------------------------------------------------------------------- # Draw the contents of the control: #--------------------------------------------------------------------------- def _draw ( self, gc, view_bounds, mode): # Set up all the control variables for quick access: ml = self.margin_left mr = self.margin_right mt = self.margin_top mb = self.margin_bottom pl = self.padding_left pr = self.padding_right pt = self.padding_top pb = self.padding_bottom bs = self.border_size bsd = bs + bs bsh = bs / 2.0 x, y, dx, dy = self.bounds ix, iy, idx, idy, tx, ty, tdx, tdy, itdx, itdy = self._info # Fill the background region (if required); bg_color = self.bg_color_ if bg_color is not transparent_color: with gc: gc.set_fill_color( bg_color ) gc.begin_path() gc.rect( x + ml + bs, y + mb + bs, dx - ml - mr - bsd, dy - mb - mt - bsd ) gc.fill_path() # Draw the border (if required): if bs > 0: border_color = self.border_color_ if border_color is not transparent_color: with gc: gc.set_stroke_color( border_color ) gc.set_line_width( bs ) gc.begin_path() gc.rect( x + ml + bsh, y + mb + bsh, dx - ml - mr - bs, dy - mb - mt - bs ) gc.stroke_path() # Calculate the origin of the image/text box: text_position = self.text_position_ if self.image_orientation == 'text': # Handle the 'image relative to text' case: if text_position & RIGHT: itx = x + dx - mr - bs - pr - itdx else: itx = x + ml + bs + pl if text_position & HCENTER: itx += (dx - ml - mr - bsd - pl - pr - itdx) / 2.0 if text_position & TOP: ity = y + dy - mt - bs - pt - itdy else: ity = y + mb + bs + pb if text_position & VCENTER: ity += (dy - mb - mt - bsd - pb - pt - itdy) / 2.0 else: # Handle the 'image relative to component' case: itx = ity = 0.0 if text_position & RIGHT: tx = x + dx - mr - bs - pr - tdx else: tx = x + ml + bs + pl if text_position & HCENTER: tx += (dx - ml - mr - bsd - pl - pr - tdx) / 2.0 if text_position & TOP: ty = y + dy - mt - bs - pt - tdy else: ty = y + mb + bs + pb if text_position & VCENTER: ty += (dy - mb - mt - bsd - pb - pt - tdy) / 2.0 image_position = self.image_position_ if image_position & RIGHT: ix = x + dx - mr - bs - pr - idx else: ix = x + ml + bs + pl if image_position & HCENTER: ix += (dx - ml - mr - bsd - pl - pr - idx) / 2.0 if image_position & TOP: iy = y + dy - mt - bs - pt - idy else: iy = y + mb + bs + pb if image_position & VCENTER: iy += (dy - mb - mt - bsd - pb - pt - idy) / 2.0 with gc: # Draw the image (if required): image = self._image if image is not None: gc.draw_image( image, ( itx + ix, ity + iy, idx, idy ) ) # Draw the text (if required): gc.set_font( self.font ) _text = self._text _tdx = self._tdx tx += itx ty += ity + tdy * len( _text ) style = self.style_ shadow_color = self.shadow_color_ text_color = self.color_ for i, text in enumerate( _text ): ty -= tdy _tx = tx if text_position & RIGHT: _tx += tdx - _tdx[i] elif text_position & HCENTER: _tx += (tdx - _tdx[i]) / 2.0 # Draw the 'shadow' text, if requested: if (style != 0) and (shadow_color is not transparent_color): if style == EMBOSSED: gc.set_fill_color( shadow_color ) gc.set_text_position( _tx - 1.0, ty + 1.0 ) elif style == ENGRAVED: gc.set_fill_color( shadow_color ) gc.set_text_position( _tx + 1.0, ty - 1.0 ) else: gc.set_fill_color( shadow_color ) gc.set_text_position( _tx + 2.0, ty - 2.0 ) gc.show_text( text ) # Draw the normal text: gc.set_fill_color( text_color ) gc.set_text_position( _tx, ty ) gc.show_text( text ) #-- Pickling Protocol ---------------------------------------------------------- def __getstate__ ( self ): dict = self.__dict__.copy() try: del dict[ '_image' ] except: pass return dict def __setstate__ ( self, state ): self.__dict__.update( state ) self.image = self.image #------------------------------------------------------------------------------- # 'CheckBox' class: #------------------------------------------------------------------------------- class CheckBox ( Label ): #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- image_base = Str( '=checkbox' ) #--------------------------------------------------------------------------- # Trait editor definition: #--------------------------------------------------------------------------- position = Group( '', 'image_base' ) #--------------------------------------------------------------------------- # Initialize the object: #--------------------------------------------------------------------------- def __init__ ( self, text = '', **traits ): Label.__init__( self, text, **traits ) self._select_image() #--------------------------------------------------------------------------- # Select the correct image to display: #--------------------------------------------------------------------------- def _select_image ( self, *suffixes ): if len( suffixes ) == 0: suffixes = [ self._suffix() ] base, ext = os.path.splitext( self.image_base ) for suffix in suffixes: image = '%s%s%s' % ( base, suffix, ext ) if self.image_for( image ) is not None: self.image = image break #--------------------------------------------------------------------------- # Select the image suffix based on the current selection state: #--------------------------------------------------------------------------- def _suffix ( self ): return [ '', '_on' ][ self.selected ] #--------------------------------------------------------------------------- # Set the selection state of the component: #--------------------------------------------------------------------------- def _select ( self ): self.selected = not self.selected #--------------------------------------------------------------------------- # Handle the 'selected' status of the checkbox being changed: #--------------------------------------------------------------------------- def _selected_changed ( self ): base = self._suffix() self._select_image( base + [ '', '_over'][ self._over == True ], base ) #--------------------------------------------------------------------------- # Handle mouse events: #--------------------------------------------------------------------------- def _left_down_changed ( self, event ): event.handled = True if self._in_margins( event.x, event.y ): event.window.mouse_owner = self base = self._suffix() self._select_image( base + '_down', base ) self._down = True def _left_dclick_changed ( self, event ): self._left_down_changed( event ) def _left_up_changed ( self, event ): event.handled = True event.window.mouse_owner = self._down = None if self._in_margins( event.x, event.y ): self._select() def _mouse_move_changed ( self, event ): event.handled = True self._over = self._in_margins( event.x, event.y ) if self._over: event.window.mouse_owner = self base = self._suffix() self._select_image( base + [ '_over', '_down' ][ self._down is not None ], base ) else: if self._down is None: event.window.mouse_owner = None self._select_image() #------------------------------------------------------------------------------- # 'RadioButton' class: #------------------------------------------------------------------------------- class Radio ( CheckBox, RadioStyle ): #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- image_base = Str( '=radio' ) #--------------------------------------------------------------------------- # Set the selection state of the component: #--------------------------------------------------------------------------- def _select ( self ): self.selected = True #--------------------------------------------------------------------------- # Handle the container the component belongs to being changed: #--------------------------------------------------------------------------- def _container_changed ( self, old, new ): CheckBox._container_changed( self ) if self.radio_group is old.radio_group: self.radio_group = None if self.radio_group is None: if new.radio_group is None: new.radio_group = RadioGroup() new.radio_group.add( self ) #--------------------------------------------------------------------------- # Handle the 'selected' status of the checkbox being changed: #--------------------------------------------------------------------------- def _selected_changed ( self ): CheckBox._selected_changed( self ) if self.selected: self.radio_group.selection = self enthought-chaco2-4.5.1.orig/enable/label.py0000644000175000017500000002002312516137326017554 0ustar varunvarun""" Defines the Label class. """ from __future__ import with_statement # Major library imports from math import pi from numpy import asarray # Enthought library imports from kiva.constants import FILL, STROKE from kiva.trait_defs.kiva_font_trait import KivaFont from traits.api import Bool, Enum, Float, HasTraits, Int, \ List, Str # Local, relative imports from colors import black_color_trait, transparent_color_trait from component import Component class Label(Component): """ A text label """ # The label text. Carriage returns (\n) are always connverted into # line breaks. text = Str # The angle of rotation of the label. Only multiples of 90 are supported. rotate_angle = Float(0) # The color of the label text. color = black_color_trait # The background color of the label. bgcolor = transparent_color_trait # The width of the label border. If it is 0, then it is not shown. border_width = Int(0) # The color of the border. border_color = black_color_trait # The font of the label text. font = KivaFont("modern 10") # Number of pixels of margin around the label, for both X and Y dimensions. margin = Int(2) # Number of pixels of spacing between lines of text. line_spacing = Int(5) # The horizontal placement of text within the bounds of the label hjustify = Enum("left", "center", "right") # The vertical placement of text within the bounds of the label vjustify = Enum("bottom", "center", "top") # By default, labels are not resizable resizable = "" #------------------------------------------------------------------------ # Private traits #------------------------------------------------------------------------ _bounding_box = List() _position_cache_valid = Bool(False) def __init__(self, text = "", **kwtraits): if 'text' not in kwtraits: kwtraits['text'] = text HasTraits.__init__(self, **kwtraits) self._bounding_box = [0,0] return def _calc_line_positions(self, gc): if not self._position_cache_valid: with gc: gc.set_font(self.font) # The bottommost line starts at postion (0,0). x_pos = [] y_pos = [] self._bounding_box = [0,0] margin = self.margin prev_y_pos = margin prev_y_height = -self.line_spacing max_width = 0 for line in self.text.split("\n")[::-1]: if line != "": (width, height, descent, leading) = gc.get_full_text_extent(line) if width > max_width: max_width = width new_y_pos = prev_y_pos + prev_y_height - descent + self.line_spacing else: # For blank lines, we use the height of the previous line, if there # is one. The width is 0. leading = 0 if prev_y_height != -self.line_spacing: new_y_pos = prev_y_pos + prev_y_height + self.line_spacing height = prev_y_height else: new_y_pos = prev_y_pos height = 0 x_pos.append(-leading + margin) y_pos.append(new_y_pos) prev_y_pos = new_y_pos prev_y_height = height width = max_width + 2*margin + 2*self.border_width height = prev_y_pos + prev_y_height + margin + 2*self.border_width self._bounding_box = [width, height] if self.hjustify == "left": x_pos = x_pos[::-1] else: x_pos = asarray(x_pos[::-1], dtype=float) if self.hjustify == "center": x_pos += (self.width - width) / 2.0 elif self.hjustify == "right": x_pos += self.width - width self._line_xpos = x_pos if self.vjustify == "bottom": y_pos = y_pos[::-1] else: y_pos = asarray(y_pos[::-1], dtype=float) if self.vjustify == "center": y_pos += (self.height - height) / 2.0 elif self.vjustify == "top": y_pos += self.height - height self._line_ypos = y_pos self._position_cache_valid = True return def get_width_height(self, gc): """ Returns the width and height of the label, in the rotated frame of reference. """ self._calc_line_positions(gc) width, height = self._bounding_box return width, height def get_bounding_box(self, gc): """ Returns a rectangular bounding box for the Label as (width,height). """ # FIXME: Need to deal with non 90 deg rotations width, height = self.get_width_height(gc) if self.rotate_angle in (90.0, 270.0): return (height, width) elif self.rotate_angle in (0.0, 180.0): return (width, height) else: raise NotImplementedError def get_bounding_poly(self, gc): """ Returns a list [(x0,y0), (x1,y1),...] of tuples representing a polygon that bounds the label. """ raise NotImplementedError def _draw_mainlayer(self, gc, view_bounds=None, mode="normal"): """ Draws the label. This method assumes the graphics context has been translated to the correct position such that the origin is at the lower left-hand corner of this text label's box. """ # For this version we're not supporting rotated text. # temp modified for only one line self._calc_line_positions(gc) with gc: gc.translate_ctm(*self.position) # Draw border and fill background width, height = self._bounding_box if self.bgcolor != "transparent": gc.set_fill_color(self.bgcolor_) gc.draw_rect((0, 0, width, height), FILL) if self.border_width > 0: gc.set_stroke_color(self.border_color_) gc.set_line_width(self.border_width) border_offset = (self.border_width-1)/2.0 gc.draw_rect((border_offset, border_offset, width-2*border_offset, height-2*border_offset), STROKE) gc.set_fill_color(self.color_) gc.set_stroke_color(self.color_) gc.set_font(self.font) if self.font.size<=8.0: gc.set_antialias(0) else: gc.set_antialias(1) gc.rotate_ctm(pi/180.0*self.rotate_angle) #margin = self.margin lines = self.text.split("\n") gc.translate_ctm(self.border_width, self.border_width) width, height = self.get_width_height(gc) for i, line in enumerate(lines): if line == "": continue if self.rotate_angle==90. or self.rotate_angle==270.: x_offset = round(self._line_ypos[i]) # this should really be "... - height/2" but # that looks wrong y_offset = round(self._line_xpos[i] - height) else: x_offset = round(self._line_xpos[i]) y_offset = round(self._line_ypos[i]) gc.set_text_position(0, 0) gc.translate_ctm(x_offset, y_offset) gc.show_text(line) gc.translate_ctm(-x_offset, -y_offset) return def _font_changed(self): self._position_cache_valid = False def _margin_changed(self): self._position_cache_valid = False def _text_changed(self): self._position_cache_valid = False def _rotate_angle_changed(self): self._position_cache_valid = False enthought-chaco2-4.5.1.orig/enable/gadgets/0000755000175000017500000000000012516137725017547 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/gadgets/__init__.py0000644000175000017500000000000012516137326021643 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/gadgets/vu_meter.py0000644000175000017500000002465512516137326021760 0ustar varunvarun import math from traits.api import Float, Property, List, Str, Range from enable.api import Component from kiva.trait_defs.kiva_font_trait import KivaFont from kiva import affine def percent_to_db(percent): if percent == 0.0: db = float('-inf') else: db = 20 * math.log10(percent / 100.0) return db def db_to_percent(db): percent = math.pow(10, db / 20.0 + 2) return percent class VUMeter(Component): # Value expressed in dB db = Property(Float) # Value expressed as a percent. percent = Range(low=0.0) # The maximum value to be display in the VU Meter, expressed as a percent. max_percent = Float(150.0) # Angle (in degrees) from a horizontal line through the hinge of the # needle to the edge of the meter axis. angle = Float(45.0) # Values of the percentage-based ticks; these are drawn and labeled along # the bottom of the curve axis. percent_ticks = List(range(0, 101, 20)) # Text to write in the middle of the VU Meter. text = Str("VU") # Font used to draw `text`. text_font = KivaFont("modern 48") # Font for the db tick labels. db_tick_font = KivaFont("modern 16") # Font for the percent tick labels. percent_tick_font = KivaFont("modern 12") # beta is the fraction of the of needle that is "hidden". # beta == 0 puts the hinge point of the needle on the bottom # edge of the window. Values that result in a decent looking # meter are 0 < beta < .65. # XXX needs a better name! _beta = Float(0.3) # _outer_radial_margin is the radial extent beyond the circular axis # to include in calculations of the space required for the meter. # This allows room for the ticks and labels. _outer_radial_margin = Float(60.0) # The angle (in radians) of the span of the curve axis. _phi = Property(Float, depends_on=['angle']) # This is the radius of the circular axis (in screen coordinates). _axis_radius = Property(Float, depends_on=['_phi', 'width', 'height']) #--------------------------------------------------------------------- # Trait Property methods #--------------------------------------------------------------------- def _get_db(self): db = percent_to_db(self.percent) return db def _set_db(self, value): self.percent = db_to_percent(value) def _get__phi(self): phi = math.pi * (180.0 - 2 * self.angle) / 180.0 return phi def _get__axis_radius(self): M = self._outer_radial_margin beta = self._beta w = self.width h = self.height phi = self._phi R1 = w / (2 * math.sin(phi / 2)) - M R2 = (h - M) / (1 - beta * math.cos(phi / 2)) R = min(R1, R2) return R #--------------------------------------------------------------------- # Trait change handlers #--------------------------------------------------------------------- def _anytrait_changed(self): self.request_redraw() #--------------------------------------------------------------------- # Component API #--------------------------------------------------------------------- def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): beta = self._beta phi = self._phi w = self.width M = self._outer_radial_margin R = self._axis_radius # (ox, oy) is the position of the "hinge point" of the needle # (i.e. the center of rotation). For beta > ~0, oy is negative, # so this point is below the visible region. ox = self.x + self.width // 2 oy = -beta * R * math.cos(phi / 2) + 1 left_theta = math.radians(180 - self.angle) right_theta = math.radians(self.angle) # The angle of the 100% position. nominal_theta = self._percent_to_theta(100.0) # The color of the axis for percent > 100. red = (0.8, 0, 0) with gc: gc.set_antialias(True) # Draw everything relative to the center of the circles. gc.translate_ctm(ox, oy) # Draw the primary ticks and tick labels on the curved axis. gc.set_fill_color((0, 0, 0)) gc.set_font(self.db_tick_font) for db in [-20, -10, -7, -5, -3, -2, -1, 0, 1, 2, 3]: db_percent = db_to_percent(db) theta = self._percent_to_theta(db_percent) x1 = R * math.cos(theta) y1 = R * math.sin(theta) x2 = (R + 0.3 * M) * math.cos(theta) y2 = (R + 0.3 * M) * math.sin(theta) gc.set_line_width(2.5) gc.move_to(x1, y1) gc.line_to(x2, y2) gc.stroke_path() text = str(db) if db > 0: text = '+' + text self._draw_rotated_label(gc, text, theta, R + 0.4 * M) # Draw the secondary ticks on the curve axis. for db in [-15, -9, -8, -6, -4, -0.5, 0.5]: ##db_percent = 100 * math.pow(10.0, db / 20.0) db_percent = db_to_percent(db) theta = self._percent_to_theta(db_percent) x1 = R * math.cos(theta) y1 = R * math.sin(theta) x2 = (R + 0.2 * M) * math.cos(theta) y2 = (R + 0.2 * M) * math.sin(theta) gc.set_line_width(1.0) gc.move_to(x1, y1) gc.line_to(x2, y2) gc.stroke_path() # Draw the percent ticks and label on the bottom of the # curved axis. gc.set_font(self.percent_tick_font) gc.set_fill_color((0.5, 0.5, 0.5)) gc.set_stroke_color((0.5, 0.5, 0.5)) percents = self.percent_ticks for tick_percent in percents: theta = self._percent_to_theta(tick_percent) x1 = (R - 0.15 * M) * math.cos(theta) y1 = (R - 0.15 * M) * math.sin(theta) x2 = R * math.cos(theta) y2 = R * math.sin(theta) gc.set_line_width(2.0) gc.move_to(x1, y1) gc.line_to(x2, y2) gc.stroke_path() text = str(tick_percent) if tick_percent == percents[-1]: text = text + "%" self._draw_rotated_label(gc, text, theta, R - 0.3 * M) if self.text: gc.set_font(self.text_font) tx, ty, tw, th = gc.get_text_extent(self.text) gc.set_fill_color((0, 0, 0, 0.25)) gc.set_text_matrix(affine.affine_from_rotation(0)) gc.set_text_position(-0.5 * tw, (0.75 * beta + 0.25) * R) gc.show_text(self.text) # Draw the red curved axis. gc.set_stroke_color(red) w = 10 gc.set_line_width(w) gc.arc(0, 0, R + 0.5 * w - 1, right_theta, nominal_theta) gc.stroke_path() # Draw the black curved axis. w = 4 gc.set_line_width(w) gc.set_stroke_color((0, 0, 0)) gc.arc(0, 0, R + 0.5 * w - 1, nominal_theta, left_theta) gc.stroke_path() # Draw the filled arc at the bottom. gc.set_line_width(2) gc.set_stroke_color((0, 0, 0)) gc.arc(0, 0, beta * R, math.radians(self.angle), math.radians(180 - self.angle)) gc.stroke_path() gc.set_fill_color((0, 0, 0, 0.25)) gc.arc(0, 0, beta * R, math.radians(self.angle), math.radians(180 - self.angle)) gc.fill_path() # Draw the needle. percent = self.percent # If percent exceeds max_percent, the needle is drawn at max_percent. if percent > self.max_percent: percent = self.max_percent needle_theta = self._percent_to_theta(percent) gc.rotate_ctm(needle_theta - 0.5 * math.pi) self._draw_vertical_needle(gc) #--------------------------------------------------------------------- # Private methods #--------------------------------------------------------------------- def _draw_vertical_needle(self, gc): """ Draw the needle of the meter, pointing straight up. """ beta = self._beta R = self._axis_radius end_y = beta * R blob_y = R - 0.6 * self._outer_radial_margin tip_y = R + 0.2 * self._outer_radial_margin lw = 5 with gc: gc.set_alpha(1) gc.set_fill_color((0, 0, 0)) # Draw the needle from the bottom to the blob. gc.set_line_width(lw) gc.move_to(0, end_y) gc.line_to(0, blob_y) gc.stroke_path() # Draw the thin part of the needle from the blob to the tip. gc.move_to(lw, blob_y) control_y = blob_y + 0.25 * (tip_y - blob_y) gc.quad_curve_to( 0.2 * lw, control_y, 0, tip_y) gc.quad_curve_to(-0.2 * lw, control_y, -lw, blob_y) gc.line_to(lw, blob_y) gc.fill_path() # Draw the blob on the needle. gc.arc(0, blob_y, 6.0, 0, 2 * math.pi) gc.fill_path() def _draw_rotated_label(self, gc, text, theta, radius): tx, ty, tw, th = gc.get_text_extent(text) rr = math.sqrt(radius ** 2 + (0.5 * tw) ** 2) dtheta = math.atan2(0.5 * tw, radius) text_theta = theta + dtheta x = rr * math.cos(text_theta) y = rr * math.sin(text_theta) rot_theta = theta - 0.5 * math.pi with gc: gc.set_text_matrix(affine.affine_from_rotation(rot_theta)) gc.set_text_position(x, y) gc.show_text(text) def _percent_to_theta(self, percent): """ Convert percent to the angle theta, in radians. theta is the angle of the needle measured counterclockwise from the horizontal (i.e. the traditional angle of polar coordinates). """ angle = (self.angle + (180.0 - 2 * self.angle) * (self.max_percent - percent) / self.max_percent) theta = math.radians(angle) return theta def _db_to_theta(self, db): """ Convert db to the angle theta, in radians. """ percent = db_to_percent(db) theta = self._percent_to_theta(percent) return theta enthought-chaco2-4.5.1.orig/enable/kiva_graphics_context.py0000644000175000017500000000152112516137326023055 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # # Author: Enthought, Inc. # Description: #------------------------------------------------------------------------------ # Import the toolkit specific version. from toolkit import toolkit_object GraphicsContext = toolkit_object('GraphicsContext') #### EOF ###################################################################### enthought-chaco2-4.5.1.orig/enable/canvas.py0000644000175000017500000001562512516137326017764 0ustar varunvarun""" Defines the enable Canvas class """ from __future__ import with_statement # Enthought library imports from traits.api import Bool, Trait, Tuple, List from kiva.constants import FILL # Local relative imports from component import Component from container import Container class Canvas(Container): """ An infinite canvas with components on it. It can optionally be given a "view region" which will be used as the notional bounds of the canvas in all operations that require bounds. A Canvas can be nested inside another container, but usually a viewport is more appropriate. Note: A Canvas has infinite bounds, but its .bounds attribute is overloaded to be something more meaningful, namely, the bounding box of its child components and the optional view area of the viewport that is looking at it. (TODO: add support for multiple viewports.) """ # This optional tuple of (x,y,x2,y2) allows viewports to inform the canvas of # the "region of interest" that it should use when computing its notional # bounds for clipping and event handling purposes. If this trait is None, # then the canvas really does behave as if it has no bounds. view_bounds = Trait(None, None, Tuple) # The (x,y) position of the lower-left corner of the rectangle corresponding # to the dimensions in self.bounds. Unlike self.position, this position is # in the canvas's space, and not in the coordinate space of the parent. bounds_offset = List draw_axes = Bool(False) #------------------------------------------------------------------------ # Inherited traits #------------------------------------------------------------------------ # Use the auto-size/fit_components mechanism to ensure that the bounding # box around our inner components gets updated properly. auto_size = True fit_components = "hv" # The following traits are ignored, but we set them to sensible values. fit_window = False resizable = "hv" #------------------------------------------------------------------------ # Protected traits #------------------------------------------------------------------------ # The (x, y, x2, y2) coordinates of the bounding box of the components # in our inner coordinate space _bounding_box = Tuple((0,0,100,100)) def compact(self): """ Wraps the superclass method to also take into account the view bounds (if they are present """ self._bounding_box = self._calc_bounding_box() self._view_bounds_changed() def is_in(self, x, y): return True def remove(self, *components): """ Removes components from this container """ needs_compact = False for component in components: if component in self._components: component.container = None self._components.remove(component) else: raise RuntimeError, "Unable to remove component from container." # Check to see if we need to compact. x, y, x2, y2 = self._bounding_box if (component.outer_x2 == x2-x) or \ (component.outer_y2 == y2-y) or \ (component.x == 0) or (component.y == 0): needs_compact = True if needs_compact: self.compact() self.invalidate_draw() def draw(self, gc, view_bounds=None, mode="normal"): if self.view_bounds is None: self.view_bounds = view_bounds super(Canvas, self).draw(gc, view_bounds, mode) #------------------------------------------------------------------------ # Protected methods #------------------------------------------------------------------------ def _should_compact(self): if self.auto_size: if self.view_bounds is not None: llx, lly = self.view_bounds[:2] else: llx = lly = 0 for component in self.components: if (component.outer_x2 >= self.width) or \ (component.outer_y2 >= self.height) or \ (component.outer_x < llx) or (component.outer_y < lly): return True else: return False def _draw_background(self, gc, view_bounds=None, mode="default"): if self.bgcolor not in ("clear", "transparent", "none"): if self.view_bounds is not None: x, y, x2, y2 = self.view_bounds else: x, y, x2, y2 = self._bounding_box r = (x, y, x2-x+1, y2-y+1) with gc: gc.set_antialias(False) gc.set_fill_color(self.bgcolor_) gc.draw_rect(r, FILL) # Call the enable _draw_border routine if not self.overlay_border and self.border_visible: # Tell _draw_border to ignore the self.overlay_border self._draw_border(gc, view_bounds, mode, force_draw=True) return def _draw_underlay(self, gc, view_bounds=None, mode="default"): if self.draw_axes: x, y, x2, y2 = self.view_bounds if (x <= 0 <= x2) or (y <= 0 <= y2): with gc: gc.set_stroke_color((0,0,0,1)) gc.set_line_width(1.0) gc.move_to(0, y) gc.line_to(0, y2) gc.move_to(x, 0) gc.line_to(x2, 0) gc.stroke_path() super(Container, self)._draw_underlay(gc, view_bounds, mode) def _transform_view_bounds(self, view_bounds): # Overload the parent class's implementation to skip visibility test if view_bounds: v = view_bounds new_bounds = (v[0]-self.x, v[1]-self.y, v[2], v[3]) else: new_bounds = None return new_bounds #------------------------------------------------------------------------ # Event handlers #------------------------------------------------------------------------ def _bounds_offset_default(self): return [0,0] def _view_bounds_changed(self): llx, lly, urx, ury = self._bounding_box if self.view_bounds is not None: x, y, x2, y2 = self.view_bounds llx = min(llx, x) lly = min(lly, y) urx = max(urx, x2) ury = max(ury, y2) self.bounds_offset = [llx, lly] self.bounds = [urx - llx + 1, ury - lly + 1] # Override Container.bounds_changed so that _layout_needed is not # set. Containers need to invalidate layout because they act as # sizers, but the Canvas is unbounded and thus does not need to # invalidate layout. def _bounds_changed(self, old, new): Component._bounds_changed(self, old, new) self.invalidate_draw() def _bounds_items_changed(self, event): Component._bounds_items_changed(self, event) self.invalidate_draw() enthought-chaco2-4.5.1.orig/enable/render_controllers.py0000644000175000017500000000642012516137326022407 0ustar varunvarun # Enthought library imports from traits.api import HasTraits class AbstractRenderController(HasTraits): def draw(self, component, gc, view_bounds=None, mode="normal"): raise NotImplementedError class RenderController(AbstractRenderController): """ The default Enable render controller for components """ # The default list of available layers. LAYERS = ["background", "image", "underlay", "component", "overlay", "border"] def draw(self, component, gc, view_bounds=None, mode="normal"): if component.visible: for layer in self.LAYERS: func = getattr(component, "_draw_" + layer, None) if func: func(gc, view_bounds, mode) return class OldEnableRenderController(AbstractRenderController): """ Performs rendering of components and containers in the default way that Enable used to, prior to the encapsulation of rendering in RenderControllers. Note that containers have a default implementation of _draw() that in turn calls _draw_container(), which is pass-through in the base class. """ def draw(self, component, gc, view_bounds=None, mode="normal"): component._draw_background(gc, view_bounds, mode) component._draw(gc, view_bounds, mode) component._draw_border(gc, view_bounds, mode) return class OldChacoRenderController(AbstractRenderController): """ Performs render the way that it was done before the draw_order changes were implemented. This has the name Chaco in it because this functionality used to be in Chaco; however, with configurable rendering now in Enable, this class resides in the Enable package, and will eventually be deprecated. """ def draw(self, component, gc, view_bounds=None, mode="normal"): if component.visible: # Determine if the component has an active tool and if # we need to transfer execution to it tool = component._active_tool if tool is not None and tool.draw_mode == "overlay": tool.draw(gc, view_bounds) else: if component.use_backbuffer: if mode == "overlay": # Since kiva currently doesn't support blend modes, # if we have to draw in overlay mode, we have to draw # normally. self._do_draw(component, gc, view_bounds, mode) component._backbuffer = None component.invalidate_draw() if not self.draw_valid: from kiva_graphics_context import GraphicsContext bb = GraphicsContext(tuple(map(int, component.bounds))) bb.translate_ctm(-component.x, -component.y) self._do_draw(component, bb, view_bounds=None, mode=mode) component._backbufer = bb component.draw_valid = True gc.draw_imge(component._backbuffer, component.position + component.bounds) else: self._do_draw(component, gc, view_bounds, mode) return def _do_draw(self, component, gc, view_bounds=None, mode="normal"): pass enthought-chaco2-4.5.1.orig/enable/radio_group.py0000644000175000017500000000667512516137326021030 0ustar varunvarun#------------------------------------------------------------------------------- # # Define support classes for implementing 'radio button' style components. # # Written by: David C. Morrill # # Date: 10/01/2003 # # (c) Copyright 2003 by Enthought, Inc. # #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- # Imports: #------------------------------------------------------------------------------- from traits.api import HasPrivateTraits, Trait #------------------------------------------------------------------------------- # Trait definitions: #------------------------------------------------------------------------------- # ARadioGroup = Instance( 'RadioGroup' ) #------------------------------------------------------------------------------- # 'RadioStyle' class: #------------------------------------------------------------------------------- class RadioStyle ( HasPrivateTraits ): #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- # radio_group = ARadioGroup #--------------------------------------------------------------------------- # Handle the group the radio style component belongs to being changed: #--------------------------------------------------------------------------- def _group_changed ( self, old, new ): if old is not None: old.remove( self ) if new is not None: new.add( self ) #------------------------------------------------------------------------------- # 'RadioGroup' class: #------------------------------------------------------------------------------- class RadioGroup ( HasPrivateTraits ): #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- # selection = Instance( RadioStyle ) selection = Trait(None, RadioStyle) #--------------------------------------------------------------------------- # Handle elements being added to the group: #--------------------------------------------------------------------------- def add ( self, *components ): for component in components: component.radio_group = self if component.selected and (self.selection is not component): if self.selection is not None: component.selected = False else: self.selection = component #--------------------------------------------------------------------------- # Handle components being removed from the group: #--------------------------------------------------------------------------- def remove ( self, *components ): for component in components: if component is self.selection: self.selection is None break #--------------------------------------------------------------------------- # Handle the selection being changed: #--------------------------------------------------------------------------- def _selection_changed ( self, old, new ): if old is not None: old.selected = False radio_group_trait = Trait(None, RadioGroup) RadioStyle.add_class_trait('radio_group', radio_group_trait) enthought-chaco2-4.5.1.orig/enable/gl_graphics_context.py0000644000175000017500000000041512516137326022526 0ustar varunvarun from kiva.gl import GraphicsContext from graphics_context import GraphicsContextEnable class GLGraphicsContextEnable(GraphicsContextEnable, GraphicsContext): """ This class just binds the GraphicsContextEnable to a Kiva GL graphics context. """ pass enthought-chaco2-4.5.1.orig/enable/vtk_backend/0000755000175000017500000000000012516137725020404 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/vtk_backend/__init__.py0000644000175000017500000000000012516137326022500 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/vtk_backend/vtk_window.py0000644000175000017500000004757712516137326023172 0ustar varunvarunimport warnings from tvtk.api import tvtk from tvtk import messenger from traits.api import HasTraits, Any, Callable, Property, Instance, \ Bool, Enum, Int, on_trait_change from numpy import arange, zeros, ascontiguousarray, reshape, uint8, any from enable.api import AbstractWindow, MouseEvent, KeyEvent, \ CoordinateBox from enable.graphics_context import ImageGraphicsContextEnable # Local imports. from constants import KEY_MAP class EnableVTKWindow(AbstractWindow, CoordinateBox): # The render window we will be drawing into # TODO: Eventually when we move to using the Picker, we will change # from observing the RenderWindowInteractor control = Instance(tvtk.RenderWindowInteractor) # A callable that will be called to request a render. If this # is None then we will call render on the control. request_render = Callable # If events don't get handled by anything in Enable, do they get passed # through to the underlying VTK InteractorStyle? # # This defaults to False because for opaque objects and backgrounds event # pass-through can be surprising. However, it can be useful in the cases # when a transparent Enable container or collection of objects overlays # a VTK window. event_passthrough = Bool(False) #------------------------------------------------------------------------ # Layout traits #------------------------------------------------------------------------ # If we are resizable in a dimension, then when the screen resizes, # we will stretch to maintain the amount of empty space between us # and the closest border of the screen. resizable = Enum("hv", "h", "v", "") # The amount of space to put on the left side padding_left = Int(0) # The amount of space to put on the right side padding_right = Int(0) # The amount of space to put on top padding_top = Int(0) # The amount of space to put below padding_bottom = Int(0) # This property allows a way to set the padding in bulk. It can either be # set to a single Int (which sets padding on all sides) or a tuple/list of # 4 Ints representing the left, right, top, bottom padding amounts. When # it is read, this property always returns the padding as a list of four # elements even if they are all the same. padding = Property # Readonly property expressing the total amount of horizontal padding hpadding = Property # Readonly property expressing the total amount of vertical padding vpadding = Property _layout_needed = Bool(False) #------------------------------------------------------------------------ # VTK pipeline objects for rendering and event handling #------------------------------------------------------------------------ # The tvtk.InteractorStyle() object we use interactor_style = Any() # This is the renderer that we create renderer = Any() # The VTK ImageData object that hosts the data from our GC's # bmp_array. _vtk_image_data = Any() # The TVTK ImageMapper and Actor2D that render our _gc _mapper = Any() _actor2d = Any() #------------------------------------------------------------------------ # Private traits for keeping track of mouse state #------------------------------------------------------------------------ # The amount of wheel motion during the previous wheel event _wheel_amount = Int(0) _left_down = Bool(False) _middle_down = Bool(False) _right_down = Bool(False) #------------------------------------------------------------------------ # Private traits for managing redraw #------------------------------------------------------------------------ _redraw_needed = Bool(True) # Flag to keep from recursing in _vtk_render_event _rendering = Bool(False) def __init__(self, render_window_interactor, renderer, istyle_class=tvtk.InteractorStyle, **traits): AbstractWindow.__init__(self, **traits) self.control = render_window_interactor self.renderer = renderer rwi = render_window_interactor rwi.interactor_style = istyle_class() istyle = rwi.interactor_style self._add_observer(istyle, "LeftButtonPressEvent", self._vtk_mouse_button_event) self._add_observer(istyle, "LeftButtonReleaseEvent", self._vtk_mouse_button_event) self._add_observer(istyle, "MiddleButtonPressEvent", self._vtk_mouse_button_event) self._add_observer(istyle, "MiddleButtonReleaseEvent", self._vtk_mouse_button_event) self._add_observer(istyle, "RightButtonPressEvent", self._vtk_mouse_button_event) self._add_observer(istyle, "RightButtonReleaseEvent", self._vtk_mouse_button_event) self._add_observer(istyle, "MouseMoveEvent", self._vtk_mouse_move) self._add_observer(istyle, "MouseWheelForwardEvent", self._vtk_mouse_wheel) self._add_observer(istyle, "MouseWheelBackwardEvent", self._vtk_mouse_wheel) self._add_observer(istyle, "KeyPressEvent", self._on_key_pressed) self._add_observer(istyle, "KeyReleaseEvent", self._on_key_released) self._add_observer(istyle, "CharEvent", self._on_character) # We want _vtk_render_event to be called before rendering, so we # observe the StartEvent on the RenderWindow. self._add_observer(rwi.render_window, "StartEvent", self._vtk_render_event) self._add_observer(istyle, "ExposeEvent", self._vtk_expose_event) self.interactor_style = istyle self._actor2d = tvtk.Actor2D() self.renderer.add_actor(self._actor2d) self._mapper = tvtk.ImageMapper() self._mapper.color_window = 255 self._mapper.color_level = 255/2.0 self._actor2d.mapper = self._mapper #self._size = tuple(self._get_control_size()) self._size = [0,0] self._redraw_needed = True self._layout_needed = True #self._gc = self._create_gc(self._size) rwi.initialize() #if self.component is not None: # self._paint() def _add_observer(self, obj, event, cb): """ Adds a vtk observer using messenger to avoid generating uncollectable objects. """ obj.add_observer(event, messenger.send) messenger.connect(tvtk.to_vtk(obj), event, cb) def _vtk_render_event(self, vtk_obj, eventname): """ Redraw the Enable window, if needed. """ if not self._rendering: self._rendering = True try: if self._size != self._get_control_size(): self._layout_needed = True if self._redraw_needed or self._layout_needed: self._paint() finally: self._rendering = False def _vtk_expose_event(self, vtk_obj, eventname): #print "Good gods! A VTK ExposeEvent!" pass def _pass_event_to_vtk(self, vtk_obj, eventname): """ Method to dispatch a particular event name to the appropriate method on the vtkInteractorStyle instance """ if "Button" in eventname: meth_name = "On" if "Left" in eventname: meth_name += "LeftButton" elif "Right" in eventname: meth_name += "RightButton" elif "Middle" in eventname: meth_name += "MiddleButton" if "Press" in eventname: meth_name += "Down" elif "Release" in eventname: meth_name += "Up" elif "MouseWheel" in eventname: meth_name = "OnMouseWheel" if "Forward" in eventname: meth_name += "Forward" else: meth_name += "Backward" elif "Key" in eventname: meth_name = "OnKey" if "Press" in eventname: meth_name += "Press" else: meth_name += "Release" elif "Char" in eventname: meth_name = "OnChar" elif eventname == "MouseMoveEvent": meth_name = "OnMouseMove" meth = getattr(vtk_obj, meth_name, None) if meth is not None: meth() else: warnings.warn("Unable to pass through mouse event '%s' to vtkInteractionStyle" % eventname) return def _vtk_mouse_button_event(self, vtk_obj, eventname): """ Dispatces to self._handle_mouse_event """ # Check to see if the event falls within the window x, y = self.control.event_position if not (self.x <= x <= self.x2 and self.y <= y <= self.y2): return self._pass_event_to_vtk(vtk_obj, eventname) button_map = dict(Left="left", Right="right", Middle="middle") action_map = dict(Press="down", Release="up") if eventname.startswith("Left"): button = "left" elif eventname.startswith("Right"): button = "right" elif eventname.startswith("Middle"): button = "middle" else: # Unable to figure out the appropriate method to dispatch to warnings.warn("Unable to create event for", eventname) return if "Press" in eventname: action = "down" setattr(self, "_%s_down"%button, True) elif "Release" in eventname: action = "up" setattr(self, "_%s_down"%button, False) else: # Unable to figure out the appropriate method to dispatch to warnings.warn("Unable to create event for", eventname) return event_name = button + "_" + action handled = self._handle_mouse_event(event_name, action) if self.event_passthrough and not handled: self._pass_event_to_vtk(vtk_obj, eventname) def _vtk_mouse_move(self, vtk_obj, eventname): x, y = self.control.event_position if not (self.x <= x <= self.x2 and self.y <= y <= self.y2): return self._pass_event_to_vtk(vtk_obj, eventname) handled = self._handle_mouse_event("mouse_move", "move") if self.event_passthrough and not handled: self._pass_event_to_vtk(vtk_obj, eventname) def _vtk_mouse_wheel(self, vtk_obj, eventname): x, y = self.control.event_position if not (self.x <= x <= self.x2 and self.y <= y <= self.y2): return self._pass_event_to_vtk(vtk_obj, eventname) if "Forward" in eventname: self._wheel_amount = 1 else: self._wheel_amount = -1 handled = self._handle_mouse_event("mouse_wheel", "wheel") if self.event_passthrough and not handled: self._pass_event_to_vtk(vtk_obj, eventname) def _create_key_event(self, vtk_event, event_type): focus_owner = self.focus_owner if focus_owner is None: focus_owner = self.component if focus_owner is None: return self._pass_event_to_vtk(vtk_obj, eventname) if event_type == 'character': key = unicode(self.control.key_sym) else: key = KEY_MAP.get(self.control.key_sym, None) if key is None: key = unicode(self.control.key_sym) if not key: return x, y = self.control.event_position return KeyEvent(event_type = event_type, character=key, x=x, y=y, alt_down=bool(self.control.alt_key), shift_down=bool(self.control.shift_key), control_down=bool(self.control.control_key), event=eventname, window=self.control) def _create_mouse_event(self, event_string): """ Returns an enable.MouseEvent that reflects the VTK mouse event. **event_string** is just a string: "up", "down", "move", or "wheel". It is set in _vtk_mouse_button_event. """ # VTK gives us no event object, so we query the interactor # for additional event state. rwi = self.control x, y = rwi.event_position # Offset the event appropriately given our bounds x -= self.padding_left y -= self.padding_bottom wheel = 0 if event_string in ("up", "down"): pass elif event_string == "move": pass elif event_string == "wheel": wheel = self._wheel_amount # Reset the wheel amount for next time self._wheel_amount = 0 tmp = MouseEvent(x = x, y = y, alt_down = bool(rwi.alt_key), control_down = bool(rwi.control_key), shift_down = bool(rwi.shift_key), left_down = self._left_down, right_down = self._right_down, middle_down = self._middle_down, mouse_wheel = wheel, window = self) return tmp def _get_control_size(self): if self.control is not None: return tuple(self.control.size) else: return (0,0) def _redraw(self, coordinates=None): " Called by the contained component to request a redraw " self._redraw_needed = True if self._actor2d is not None: self._paint() def _on_size(self): pass def _layout(self, size): """ Given a size, set the proper location and bounds of the actor and mapper inside our RenderWindow. """ if self.component is None: return self._size = size self.position = [self.padding_left, self.padding_bottom] if "h" in self.resizable: new_width = size[0] - (self.position[0] + self.padding_right) if new_width < 0: self.bounds[0] = 0 else: self.bounds[0] = new_width if "v" in self.resizable: new_height = size[1] - (self.position[1] + self.padding_top) if new_height < 0: self.bounds[1] = 0 else: self.bounds[1] = new_height comp = self.component dx, dy = size if getattr(comp, "fit_window", False): comp.outer_position = [0,0] comp.outer_bounds = [dx, dy] elif hasattr(comp, "resizable"): if "h" in comp.resizable: comp.outer_x = 0 comp.outer_width = dx if "v" in comp.resizable: comp.outer_y = 0 comp.outer_height = dy comp.do_layout(force=True) # Invalidate the GC and the draw flag self._gc = None self._redraw_needed = True self._layout_needed = False def _create_gc(self, size, pix_format="rgba32"): # Add 1 to each dimension because Kiva uses 0.5 to refer to the center of # a pixel. width = size[0] + 1 height = size[1] + 1 gc = ImageGraphicsContextEnable((width, height), pix_format = pix_format, window=self ) gc.translate_ctm(0.5, 0.5) gc.clear((0,0,0,0)) imagedata_dimensions = (width, height, 1) if self._vtk_image_data is None or any(self._vtk_image_data.dimensions != imagedata_dimensions): sz = (width, height, 4) img = tvtk.ImageData() img.whole_extent = (0, width-1, 0, height-1, 0, 0) # note the transposed height and width for VTK (row, column, depth) img.dimensions = imagedata_dimensions # create a 2d view of the array. This is a bit superfluous because # the GC should be blank at this point in time, but we need to hand # the ImageData something. try: ary = ascontiguousarray(gc.bmp_array[::-1, :, :4]) ary_2d = reshape(ary, (width * height, 4)) img.point_data.scalars = ary_2d except: return self._gc if self._vtk_image_data is not None: # Just for safety, drop the reference to the previous bmp_array # so we don't leak it self._vtk_image_data.point_data.scalars = None self._actor2d.width = width self._actor2d.height = height self._mapper.input = img self._vtk_image_data = img return gc def _paint(self, event=None): control_size = self._get_control_size() size = list(control_size) if self._layout_needed or (size != self._size): self._layout(size) if not self._redraw_needed: return if self._gc is None: self._gc = self._create_gc(self.bounds) # Always give the GC a chance to initialize self._init_gc() # Layout components and draw if hasattr(self.component, "do_layout"): self.component.do_layout() self.component.draw(self._gc, view_bounds=(0, 0, size[0], size[1])) # Now transform the image and render it into VTK width, height = self.component.outer_bounds width += 1 height += 1 try: ary = ascontiguousarray(self._gc.bmp_array[::-1, :, :4]) ary_2d = reshape(ary, (width * height, 4)) except Exception, e: warnings.warn("Error reshaping array of shape %s to width and height of (%d, %d)" % (str(ary.shape), width, height)) return # Make sure we paint to the right location on the mapper self._vtk_image_data.point_data.scalars = ary_2d self._vtk_image_data.modified() #self._window_paint(event) if self.request_render is not None: self.request_render() else: self.control.render() self._redraw_needed = False def _set_focus(self): #print "set_focus unimplemented" pass def _capture_mouse(self): #print "Capture mouse unimplemented" pass def _release_mouse(self): #print "Release mouse unimplemented" pass def screen_to_window(self, x, y): pass def set_pointer(self, pointer): pass def _set_tooltip(self, tooltip): pass #------------------------------------------------------------------------ # Trait property setters/getters #------------------------------------------------------------------------ def _get_padding(self): return [self.padding_left, self.padding_right, self.padding_top, self.padding_bottom] def _set_padding(self, val): old_padding = self.padding if type(val) == int: self.padding_left = self.padding_right = \ self.padding_top = self.padding_bottom = val self.trait_property_changed("padding", old_padding, [val]*4) else: # assume padding is some sort of array type if len(val) != 4: raise RuntimeError, "Padding must be a 4-element sequence type or an int. Instead, got" + str(val) self.padding_left = val[0] self.padding_right = val[1] self.padding_top = val[2] self.padding_bottom = val[3] self.trait_property_changed("padding", old_padding, val) return def _get_hpadding(self): return 2*self._get_visible_border() + self.padding_right + \ self.padding_left def _get_vpadding(self): return 2*self._get_visible_border() + self.padding_bottom + \ self.padding_top #------------------------------------------------------------------------ # Trait event handlers #------------------------------------------------------------------------ @on_trait_change("position,position_items") def _pos_bounds_changed(self): if self._actor2d is not None: self._actor2d.position = self.position self._redraw_needed @on_trait_change("bounds,bounds_items") def _bounds_changed(self): if self._actor2d is not None: self._actor2d.width = self.width self._actor2d.height = self.height self._redraw_needed = True self._layout_needed = True enthought-chaco2-4.5.1.orig/enable/vtk_backend/constants.py0000644000175000017500000000143712516137326022774 0ustar varunvarun# Map from VTK to enable key names KEY_MAP = { "Esc": "Esc", "Tab": "Tab", "Backtab": "Backtab", "Backspace": "Backspace", "Return": "Enter", "Enter": "Enter", "Insert": "Insert", "Delete": "Delete", "Pause": "Pause", "Print": "Print", "Sysreq": "Sysreq", "Clear": "Clear", "Home": "Home", "End": "End", "Left": "Left", "Up": "Up", "Right": "Right", "Down": "Down", "Prior": "Page Up", "Next": "Page Down", "Meta": "Meta", "Caps_Lock": "Caps Lock", "Num_Lock": "Num Lock", "Scroll_Lock": "Scroll Lock", "F1": "F1", "F2": "F2", "F3": "F3", "F4": "F4", "F5": "F5", "F6": "F6", "F7": "F7", "F8": "F8", "F9": "F9", "F10": "F10", "F11": "F11", "F12": "F12", } enthought-chaco2-4.5.1.orig/enable/viewable.py0000644000175000017500000000147512516137326020305 0ustar varunvarun # Enthought library imports from traits.api import HasTraits class Viewable(HasTraits): """ Mixin class for Components which want to support being rendered by multiple viewports. """ #------------------------------------------------------------------------ # Public methods #------------------------------------------------------------------------ def request_redraw(self): # This overrides the default Component request_redraw by asking # all of the views to redraw themselves. return def draw(self, gc, view_bounds=None, mode="default"): if len(self.viewports) > 0: for view in self.viewports: view.draw(gc, view_bounds, mode) else: super(Viewable, self).draw(gc, view_bounds, mode) return # EOF enthought-chaco2-4.5.1.orig/enable/drag.py0000644000175000017500000002232212516137326017416 0ustar varunvarun#------------------------------------------------------------------------------- # # Define the classes used to support the Enable package 'drag' functionality. # # Written by: David C. Morrill # # Date: 09/22/2003 # # (c) Copyright 2003 by Enthought, Inc. # # Classes defined: DragHandler # #------------------------------------------------------------------------------- from base import add_rectangles, intersect_coordinates, send_event_to, \ bounds_to_coordinates from events import DragEvent from interactor import Interactor #------------------------------------------------------------------------------- # 'DragHandler' class: #------------------------------------------------------------------------------- class DragHandler ( Interactor ): #--------------------------------------------------------------------------- # Initialize the object: #--------------------------------------------------------------------------- def init ( self, components, bounds_rect, drag_root, drag_bounds_rect, drag_copy, drag_event, start_event ): self.components = components[:] self.bounds_rect = bounds_rect self.drag_root = drag_root self.drag_bounds_rect = self.drag_bounds_rect_start = drag_bounds_rect self.drag_copy = drag_copy self.drag_event = drag_event self.start_event = start_event self.drag_x = self.start_x = start_event.x self.drag_y = self.start_y = start_event.y self.window = components[0].window self.drag_over = [] self.on_trait_change( self.drag_done, drag_event ) #--------------------------------------------------------------------------- # Handle the mouse moving while dragging: #--------------------------------------------------------------------------- def _mouse_move_changed ( self, event ): # Get the current drag location: x = event.x y = event.y # If the mouse did not actually move, then ignore the event: if (x == self.drag_x) and (y == self.drag_y): return # Save the new position: self.drag_x = x self.drag_y = y # Calculate the distance moved from the original starting point: dx = x - self.start_x dy = y - self.start_y # Calculate the new drag bounds: xl, yb, xr, yt = add_rectangles( self.drag_bounds_rect_start, ( dx, dy, dx, dy ) ) # Adjust the new drag location if it is not completely within the drag # bounds. Exit if the result is the same as the previous location: if self.bounds_rect is not None: bxl, byb, bxr, byt = self.bounds_rect if xl < bxl: xr += bxl - xl xl = bxl elif xr > bxr: xl -= xr - bxr xr = bxr if yb < byb: yt += byb - yb yb = byb elif yt > byt: yb -= yt - byt yt = byt x = xl - self.drag_bounds_rect[0] + self.drag_x y = yb - self.drag_bounds_rect[1] + self.drag_y # If the new drag bounds is the same as the last one, nothing changed: drag_bounds_rect = bounds_to_coordinates( self.drag_validate( event, ( xl, yb, xr - xl, yt - yb ) ) ) if drag_bounds_rect == self.drag_bounds_rect: return # Update the drag bounds and current drag location: self.drag_bounds_rect = drag_bounds_rect # Notify each drag component of its new drag location: dx = drag_bounds_rect[0] - self.drag_bounds_rect_start[0] dy = drag_bounds_rect[1] - self.drag_bounds_rect_start[1] for component in self.components: cx, cy = component.location() component.dragged = DragEvent( x = cx + dx, y = cy + dy, x0 = self.start_x, y0 = self.start_y, copy = self.drag_copy, components = self.components, start_event = self.start_event, window = event.window ) # Process the 'drag_over' events for any objects being dragged over: drag_over_event = DragEvent( x = x, y = y, x0 = self.start_x, y0 = self.start_y, copy = self.drag_copy, components = self.components, start_event = self.start_event, window = event.window ) new_drag_over = [] cur_drag_over = self.drag_over for component in self.drag_root.components_at( x, y ): new_drag_over.append( component ) if component in cur_drag_over: cur_drag_over.remove( component ) component.drag_over = drag_over_event else: component.drag_enter = drag_over_event for component in cur_drag_over: component.drag_leave = drag_over_event self.drag_over = new_drag_over # Tell the Enable window where the drag is now: self.window.set_drag_bounds_rect( drag_bounds_rect ) #--------------------------------------------------------------------------- # Validate the proposed new drag location (by default, just accept it): #--------------------------------------------------------------------------- def drag_validate ( self, event, drag_bounds ): return drag_bounds #--------------------------------------------------------------------------- # Handle the user releasing the original drag button: #--------------------------------------------------------------------------- def drag_done ( self, event ): components = self.components drag_copy = self.drag_copy start_event = self.start_event # 'Unhook' the drag done notification handler: self.on_trait_change( self.drag_done, self.drag_event, remove = True ) # Compute the new drag bounds: x = event.x y = event.y dx = x - self.start_x dy = y - self.start_y xl, yb, xr, yt = add_rectangles( self.drag_bounds_rect_start, ( dx, dy, dx, dy ) ) drag_bounds_rect = bounds_to_coordinates( self.drag_validate( event, ( xl, yb, xr - xl, yt - yb ) ) ) # If the new bounds are not within the drag area, use the last drag # location: if ((self.bounds_rect is not None) and (intersect_coordinates( self.bounds_rect, drag_bounds_rect ) != drag_bounds_rect)): drag_bounds_rect = self.drag_bounds_rect # Notify each dragged component where it was dropped: dx = drag_bounds_rect[0] - self.drag_bounds_rect_start[0] dy = drag_bounds_rect[1] - self.drag_bounds_rect_start[1] for component in components: cx, cy = component.location() component.dropped = DragEvent( x = cx + dx, y = cy + dy, x0 = self.start_x, y0 = self.start_y, copy = drag_copy, components = components, start_event = start_event, window = event.window ) # Process the 'dropped_on' event for the object(s) it was dropped on: components_at = self.drag_root.components_at( x, y ) drag_event = DragEvent( x = self.start_x + dx, y = self.start_y + dy, x0 = self.start_x, y0 = self.start_y, copy = drag_copy, components = components, start_event = start_event, window = event.window ) index = send_event_to( components_at, 'dropped_on', drag_event ) # Send all the runner-ups a 'drag_leave' consolation prize: drag_over = self.drag_over for component in components_at[ 0: index ]: if component in drag_over: component.drag_leave = drag_event # Make sure all of the dragged components are drawable again: if not drag_copy: for component in components: component._drawable = True # Redraw the window to clean-up any drag artifacts: self.window.redraw() # Finally, release any references we have been using: self.components[:] = [] self.drag_over = self.drag_root = self.window = None enthought-chaco2-4.5.1.orig/enable/markers.py0000644000175000017500000002307712516137326020155 0ustar varunvarun""" Defines markers classes, used by a variety of renderers. """ # Major library imports from numpy import array, pi # Enthought library imports from traits.api import HasTraits, Bool, Instance, Trait from traitsui.api import EnumEditor from kiva.constants import STROKE, FILL_STROKE, \ SQUARE_MARKER, DIAMOND_MARKER, CIRCLE_MARKER, \ CROSS_MARKER, TRIANGLE_MARKER, \ INVERTED_TRIANGLE_MARKER, PLUS_MARKER, DOT_MARKER, \ PIXEL_MARKER, NO_MARKER # Local imports from compiled_path import CompiledPath class AbstractMarker(HasTraits): """ Abstract class for markers. """ # How this marker is to be stroked (from kiva.constants). # Since this needs to be a class variable, it can't be a trait. draw_mode = STROKE #draw_mode = Enum(FILL, EOF_FILL, STROKE, FILL_STROKE, EOF_FILL_STROKE) # The kiva marker type (from kiva.constants). kiva_marker = NO_MARKER # Close the path object after drawing this marker? close_path = Bool(True) # Render the marker antialiased? Some # markers render faster and look better if they are not anti-aliased.. antialias = Bool(True) def add_to_path(self, path, size): """ Adds this marker's representation to *path*, scaled appropriately for *size*. Parameters ---------- path : GraphicsContext The target for drawing the marker. size : number Size of the marker, in pixels """ if self.close_path: self._add_to_path(path, size) path.close_path() else: self._add_to_path(path, size) def get_compiled_path(self, size): """ Returns a compiled path object that represents this marker, scaled appropriately for *size*. """ raise NotImplementedError def _add_to_path(self, path, size): # subclasses must implement this method raise NotImplementedError class SquareMarker(AbstractMarker): """ A marker that is a square. """ # How this marker is to be stroked. (Overrides AbstractMarker.) draw_mode = FILL_STROKE # The Kiva marker type. (Overrides AbstractMarker.) kiva_marker = SQUARE_MARKER # Do not render anti-aliased. (Overrides AbstractMarker.) antialias = False def _add_to_path(self, path, size): path.rect(-size, -size, size * 2, size * 2) class DiamondMarker(AbstractMarker): """ A marker that is a diamond. """ # How this marker is to be stroked. (Overrides AbstractMarker.) draw_mode = FILL_STROKE # The Kiva marker type. (Overrides AbstractMarker.) kiva_marker = DIAMOND_MARKER # Do not render anti-aliased. (Overrides AbstractMarker.) antialias = False def _add_to_path(self, path, size): path.lines(array(((0, -size), (-size, 0), (0, size), (size, 0)))) class CircleMarker(AbstractMarker): """ A marker that is a circle. """ # How this marker is to be stroked. (Overrides AbstractMarker.) draw_mode = FILL_STROKE # The Kiva marker type. (Overrides AbstractMarker.) kiva_marker = CIRCLE_MARKER # Array of points in a circle circle_points = array([[ 1. , 0. ], [ 0.966, 0.259], [ 0.866, 0.5 ], [ 0.707, 0.707], [ 0.5 , 0.866], [ 0.259, 0.966], [ 0. , 1. ], [-0.259, 0.966], [-0.5 , 0.866], [-0.707, 0.707], [-0.866, 0.5 ], [-0.966, 0.259], [-1. , 0. ], [-0.966, -0.259], [-0.866, -0.5 ], [-0.707, -0.707], [-0.5 , -0.866], [-0.259, -0.966], [ 0. , -1. ], [ 0.259, -0.966], [ 0.5 , -0.866], [ 0.707, -0.707], [ 0.866, -0.5 ], [ 0.966, -0.259], [ 1. , 0. ]]) def _add_to_path(self, path, size): if size <= 5: pts = self.circle_points[::3] * size elif size <= 10: pts = self.circle_points[::2] * size else: pts = self.circle_points * size path.lines(pts) class TriangleMarker(AbstractMarker): """ A marker that is a triangle with one apex pointing up. """ # How this marker is to be stroked. (Overrides AbstractMarker.) draw_mode = FILL_STROKE # The Kiva marker type. (Overrides AbstractMarker.) kiva_marker = TRIANGLE_MARKER # Do not render anti-aliased. (Overrides AbstractMarker.) antialias = False def _add_to_path(self, path, size): path.lines(array(((-size, -size), (size, -size), (0, 0.732 * size)))) class Inverted_TriangleMarker(AbstractMarker): """ A marker that is a triangle with one apex pointing down. """ # How this marker is to be stroked. (Overrides AbstractMarker.) draw_mode = FILL_STROKE # The Kiva marker type. (Overrides AbstractMarker.) kiva_marker = INVERTED_TRIANGLE_MARKER # Do not render anti-aliased. (Overrides AbstractMarker.) antialias = False def _add_to_path(self, path, size): path.lines(array(((-size, size), (size, size), (0, -0.732 * size)))) class PlusMarker(AbstractMarker): """ A marker that is a plus-sign. """ # How this marker is to be stroked. (Overrides AbstractMarker.) draw_mode = STROKE # The Kiva marker type. (Overrides AbstractMarker.) kiva_marker = PLUS_MARKER # Do not render anti-aliased. (Overrides AbstractMarker.) antialias = False def _add_to_path(self, path, size): path.move_to(0, -size) path.line_to(0, size) path.move_to(-size, 0) path.line_to(size, 0) class CrossMarker(AbstractMarker): """ A marker that is an X. """ # How this marker is to be stroked. (Overrides AbstractMarker.) draw_mode = STROKE # The Kiva marker type. (Overrides AbstractMarker.) kiva_marker = CROSS_MARKER # Do not render anti-aliased. (Overrides AbstractMarker.) antialias = False def _add_to_path(self, path, size): path.move_to(-size, -size) path.line_to(size, size) path.move_to(size, -size) path.line_to(-size, size) class DotMarker(AbstractMarker): """ A marker that is a dot. """ # How this marker is to be stroked. (Overrides AbstractMarker.) draw_mode = FILL_STROKE # The Kiva marker type. (Overrides AbstractMarker.) kiva_marker = DOT_MARKER def _add_to_path(self, path, size): path.arc(0, 0, size, 0, 2 * pi) class PixelMarker(AbstractMarker): """ A marker that is a pixel. """ # How this marker is to be stroked. (Overrides AbstractMarker.) draw_mode = STROKE # The Kiva marker type. (Overrides AbstractMarker.) kiva_marker = PIXEL_MARKER # Do not render anti-aliased. (Overrides AbstractMarker.) antialias = False def _add_to_path(self, path, size): # It's impossible to emulate a true Pixel Marker in a vector # system, so we just draw a sub-pixel square 1.0 unit across. path.rect(-0.5, -0.5, 1.0, 1.0) class CustomMarker(AbstractMarker): """ A marker that is a custom shape. """ # How this marker is to be stroked. (Overrides AbstractMarker.) draw_mode = STROKE # The Kiva marker type. (Overrides AbstractMarker.) kiva_marker = NO_MARKER # The custom path that represents this marker. path = Instance(CompiledPath) # Automatically scale **path** based on the input size parameter? # If False, then the path does not respond to the 'size' parameter! scale_path = Bool(True) def _add_to_path(self, path, size): if self.scale_path: path.save_ctm() path.scale_ctm(size) path.add_path(path) if self.scale_path: path.restore_ctm() def get_compiled_path(self, size): """ Returns a path instance. If **scale_path** is True, then the returned path is a new compiled path that is scaled based on *size*. If **scaled_path** is False, then this method just returns the current **path**. """ if self.scale_path: newpath = CompiledPath() newpath.scale_ctm(size) newpath.add_path(self.path) return newpath else: return self.path # String names for marker types. marker_names = ("square", "circle", "triangle", "inverted_triangle", "plus", "cross", "diamond", "dot", "pixel") # Mapping of marker string names to classes. MarkerNameDict = {"square": SquareMarker, "circle": CircleMarker, "triangle": TriangleMarker, "inverted_triangle": Inverted_TriangleMarker, "plus": PlusMarker, "cross": CrossMarker, "diamond": DiamondMarker, "dot": DotMarker, "pixel": PixelMarker, "custom": CustomMarker} # A mapped trait that allows string naming of marker classes. MarkerTrait = Trait("square", MarkerNameDict, editor=EnumEditor(values=marker_names)) marker_trait = MarkerTrait enthought-chaco2-4.5.1.orig/enable/events.py0000644000175000017500000002006312516137326020005 0ustar varunvarun""" Define the event objects and traits used by Enable components. For a list of all the possible event suffixes, see interactor.py. """ # Major library imports from numpy import array, dot # Enthought imports from kiva import affine from traits.api import (Any, Bool, Float, HasTraits, Int, Event, List, ReadOnly) class BasicEvent(HasTraits): x = Float y = Float # True if the event has been handled. handled = Bool(False) # The AbstractWindow instance through/from which this event was fired. # Can be None. window = Any # (x,y) position stack; initialized to an empty list _pos_stack = List( () ) # Affine transform stack; initialized to an empty list _transform_stack = List( () ) # This is a list of objects that have transformed the event's # coordinates. This can be used to recreate the dispatch path # that the event took. dispatch_history = List() def push_transform(self, transform, caller=None): """ Saves the current transform in a stack and sets the given transform to be the active one. """ x, y = dot(array((self.x, self.y, 1)), transform)[:2] self._pos_stack.append((self.x, self.y)) self._transform_stack.append(transform) self.x = x self.y = y if caller is not None: self.dispatch_history.append(caller) return def pop(self, count=1, caller=None): """ Restores a previous position of the event. If **count** is provided, then pops **count** elements off of the event stack. """ for i in range(count-1): self._pos_stack.pop() self._transform_stack.pop() self.x, self.y = self._pos_stack.pop() self._transform_stack.pop() if caller is not None: if caller == self.dispatch_history[-1]: self.dispatch_history.pop() return def offset_xy(self, origin_x, origin_y, caller=None): """ Shifts this event to be in the coordinate frame whose origin, specified in the event's coordinate frame, is (origin_x, origin_y). Basically, a component calls event.offset_xy(\*self.position) to shift the event into its own coordinate frame. """ self.push_transform(affine.affine_from_translation(-origin_x, -origin_y)) if caller is not None: self.dispatch_history.append(caller) return def scale_xy(self, scale_x, scale_y, caller=None): """ Scales the event to be in the scale specified. A component calls event.scale_xy(scale) to scale the event into its own coordinate frame when the ctm has been scaled. This operation is used for zooming. """ # Note that the meaning of scale_x and scale_y for Enable # is the inverted from the meaning for Kiva.affine. # TODO: Fix this discrepancy. self.push_transform(affine.affine_from_scale(1/scale_x, 1/scale_y)) if caller is not None: self.dispatch_history.append(caller) return def net_transform(self): """ Returns a single transformation (currently only (dx,dy)) that reflects the total amount of change from the original coordinates to the current offset coordinates stored in self.x and self.y. """ if len(self._transform_stack) == 0: return affine.affine_identity() else: return reduce(dot, self._transform_stack[::-1]) def current_pointer_position(self): """ Returns the current pointer position in the transformed coordinates """ window_pos = self.window.get_pointer_position() return tuple(dot(array(window_pos + (1,)), self.net_transform())[:2]) def __repr__(self): s = '%s(x=%r, y=%r, handled=%r)' % (self.__class__.__name__, self.x, self.y, self.handled) return s class MouseEvent(BasicEvent): alt_down = ReadOnly control_down = ReadOnly shift_down = ReadOnly left_down = ReadOnly middle_down = ReadOnly right_down = ReadOnly mouse_wheel = ReadOnly mouse_event_trait = Event(MouseEvent) class DragEvent(BasicEvent): """ A system UI drag-and-drop operation. This is not the same as a DragTool event. """ x0 = Float y0 = Float copy = ReadOnly obj = ReadOnly start_event = ReadOnly def __repr__(self): s = ('%s(x=%r, y=%r, x0=%r, y0=%r, handled=%r)' % (self.__class__.__name__, self.x, self.y, self.x0, self.y0, self.handled)) return s drag_event_trait = Event(DragEvent) class KeyEvent(BasicEvent): event_type = ReadOnly # one of 'key_pressed', 'key_released' or 'character' # 'character' is a single unicode character or is a string describing the # high-bit and control characters. (See module enable.toolkit_constants) # depending on the event type, it may represent the physical key pressed, # or the text that was generated by a keystroke character = ReadOnly alt_down = ReadOnly control_down = ReadOnly shift_down = ReadOnly event = ReadOnly # XXX the underlying toolkit's event object, remove? def __repr__(self): s = ('%s(event_type=%r, character=%r, alt_down=%r, control_down=%r, shift_down=%r, handled=%r)' % (self.__class__.__name__, self.event_type, self.character, self.alt_down, self.control_down, self.shift_down, self.handled)) return s key_event_trait = Event( KeyEvent ) class BlobEvent(BasicEvent): """ Represent a single pointer event from a multi-pointer event system. Will be used with events: blob_down blob_move blob_up """ # The ID of the pointer. bid = Int(-1) # If a blob_move event, then these will be the coordinates of the blob at # the previous frame. x0 = Float(0.0) y0 = Float(0.0) def push_transform(self, transform, caller=None): """ Saves the current transform in a stack and sets the given transform to be the active one. This will also adjust x0 and y0. """ x, y = dot(array((self.x, self.y, 1)), transform)[:2] self._pos_stack.append((self.x, self.y)) self._transform_stack.append(transform) self.x = x self.y = y x0, y0 = dot(array((self.x0, self.y0, 1)), transform)[:2] self.x0 = x0 self.y0 = y0 if caller is not None: self.dispatch_history.append(caller) def __repr__(self): s = '%s(bid=%r, x=%r, y=%r, x0=%r, y0=%r, handled=%r)' % (self.__class__.__name__, self.bid, self.x, self.y, self.x0, self.y0, self.handled) return s blob_event_trait = Event(BlobEvent) class BlobFrameEvent(BasicEvent): """ Represent the framing events for a multi-pointer event system. Will be used with events: blob_frame_begin blob_frame_end These can be used to synchronize the effects of multiple pointers. The position traits are meaningless. These events will get passed down through all components. Also, no component should mark it as handled. The event must be dispatched through whether the component takes action based on it or not. NOTE: Frames without any blob events may or may not generate BlobFrameEvents. """ # The ID number of the frame. This is generally implemented as a counter. # Adjacent frames should have different frame IDs, but it is permitted for # the counter to wrap around eventually or for the Enable application to # disconnect and reconnect to a multi-pointer system and have the counter # reset to 0. fid = Int(-1) # The timestamp of the frame in seconds from an unspecified origin. t = Float(0.0) # Never mark this event as handled. Let every component respond to it. #handled = ReadOnly(False) def __repr__(self): s = '%s(fid=%r, t=%r)' % (self.__class__.__name__, self.fid, self.t) return s blob_frame_event_trait = Event(BlobFrameEvent) # EOF enthought-chaco2-4.5.1.orig/enable/container.py0000644000175000017500000006107212516137326020470 0ustar varunvarun""" Defines the basic Container class """ from __future__ import with_statement # Major library imports import warnings # Enthought library imports from kiva import affine from traits.api import Any, Bool, Enum, HasTraits, Instance, List, \ Property, Tuple # Local, relative imports from base import empty_rectangle, intersect_bounds from component import Component from events import BlobEvent, BlobFrameEvent, DragEvent, MouseEvent class Container(Component): """ A Container is a logical container that holds other Components within it and provides an origin for Components to position themselves. Containers can be "nested" (although "overlayed" is probably a better term). If auto_size is True, the container will automatically update its bounds to enclose all of the components handed to it, so that a container's bounds serve as abounding box (although not necessarily a minimal bounding box) of its contained components. """ # The list of components within this frame components = Property # List(Component) # Whether or not the container should automatically maximize itself to # fit inside the Window, if this is a top-level container. # # NOTE: the way that a Container determines that it's a top-level window is # that someone has explicitly set its .window attribute. If you need to do # this for some other reason, you may want to turn fit_window off. fit_window = Bool(True) # If true, the container get events before its children. Otherwise, it # gets them afterwards. intercept_events = Bool(True) # Dimensions in which this container can resize to fit its components. # This trait only applies to dimensions that are also resizable; if the # container is not resizable in a certain dimension, then fit_components # has no effect. # # Also, note that the container does not *automatically* resize itself # based on the value of this trait. Rather, this trait determines # what value is reported in get_preferred_size(); it is up to the parent # of this container to make sure that it is allocated the size that it # needs by setting its bounds appropriately. # # TODO: Merge resizable and this into a single trait? Or have a separate # "fit" flag for each dimension in the **resizable** trait? # TODO: This trait is used in layout methods of various Container # subclasses in Chaco. We need to move those containers into # Enable. fit_components = Enum("", "h", "v", "hv") # Whether or not the container should auto-size itself to fit all of its # components. # Note: This trait is still used, but will be eventually removed in favor # of **fit_components**. auto_size = Bool(False) # The default size of this container if it is empty. default_size = Tuple(0, 0) # The layers that the container will draw first, so that they appear # under the component layers of the same name. container_under_layers = Tuple("background", "image", "underlay", "mainlayer") #------------------------------------------------------------------------ # Private traits #------------------------------------------------------------------------ # Shadow trait for self.components _components = List # List(Component) # Set of components that last handled a mouse event. We keep track of # this so that we can generate mouse_enter and mouse_leave events of # our own. _prev_event_handlers = Instance( set, () ) # This container can render itself in a different mode than what it asks of # its contained components. This attribute stores the rendering mode that # this container requests of its children when it does a _draw(). If the # attribute is set to "default", then whatever mode is handed in to _draw() # is used. _children_draw_mode = Enum("default", "normal", "overlay", "interactive") #------------------------------------------------------------------------ # Public methods #------------------------------------------------------------------------ def __init__(self, *components, **traits): Component.__init__(self, **traits) for component in components: self.add(component) if "bounds" in traits.keys() and "auto_size" not in traits.keys(): self.auto_size = False if 'intercept_events' in traits: warnings.warn("'intercept_events' is a deprecated trait", warnings.DeprecationWarning) return def add(self, *components): """ Adds components to this container """ for component in components: if component.container is not None: component.container.remove(component) component.container = self self._components.extend(components) # Expand our bounds if necessary if self._should_compact(): self.compact() self.invalidate_draw() def remove(self, *components): """ Removes components from this container """ for component in components: if component in self._components: component.container = None self._components.remove(component) else: raise RuntimeError, "Unable to remove component from container." # Check to see if we need to compact. if self.auto_size: if (component.outer_x2 == self.width) or \ (component.outer_y2 == self.height) or \ (component.x == 0) or (component.y == 0): self.compact() self.invalidate_draw() def insert(self, index, component): "Inserts a component into a specific position in the components list" if component.container is not None: component.container.remove(component) component.container = self self._components.insert(index, component) self.invalidate_draw() def components_at(self, x, y): """ Returns a list of the components underneath the given point (given in the parent coordinate frame of this container). """ result = [] if self.is_in(x,y): xprime = x - self.position[0] yprime = y - self.position[1] for component in self._components[::-1]: if component.is_in(xprime, yprime): result.append(component) return result def raise_component(self, component): """ Raises the indicated component to the top of the Z-order """ c = self._components ndx = c.index(component) if len(c) > 1 and ndx != len(c) - 1: self._components = c[:ndx] + c[ndx+1:] + [component] return def lower_component(self, component): """ Puts the indicated component to the very bottom of the Z-order """ raise NotImplementedError def cleanup(self, window): """When a window viewing or containing a component is destroyed, cleanup is called on the component to give it the opportunity to delete any transient state it may have (such as backbuffers).""" if self._components: for component in self._components: component.cleanup(window) return def compact(self): """ Causes this container to update its bounds to be a compact bounding box of its components. This may cause the container to recalculate and adjust its position relative to its parent container (and adjust the positions of all of its contained components accordingly). """ # Loop over our components and determine the bounding box of all of # the components. ll_x, ll_y, ur_x, ur_y = self._calc_bounding_box() if len(self._components) > 0: # Update our position and the positions of all of our components, # but do it quietly for component in self._components: component.set(position = [component.x-ll_x, component.y-ll_y], trait_change_notify = False) # Change our position (in our parent's coordinate frame) and # update our bounds self.position = [self.x + ll_x, self.y + ll_y] self.bounds = [ur_x - ll_x, ur_y - ll_y] return #------------------------------------------------------------------------ # Protected methods #------------------------------------------------------------------------ def _calc_bounding_box(self): """ Returns a 4-tuple (x,y,x2,y2) of the bounding box of all our contained components. Expressed as coordinates in our local coordinate frame. """ if len(self._components) == 0: return (0.0, 0.0, 0.0, 0.0) else: comp = self._components[0] ll_x = comp.outer_x ll_y = comp.outer_y ur_x = comp.outer_x2 ur_y = comp.outer_y2 for component in self._components[1:]: if component.x < ll_x: ll_x = component.x if component.x2 > ur_x: ur_x = component.x2 if component.y < ll_y: ll_y = component.y if component.y2 > ur_y: ur_y = component.y2 return (ll_x, ll_y, ur_x, ur_y) def _dispatch_draw(self, layer, gc, view_bounds, mode): """ Renders the named *layer* of this component. """ new_bounds = self._transform_view_bounds(view_bounds) if new_bounds == empty_rectangle: return if self.layout_needed: self.do_layout() # Give the container a chance to draw first for the layers that are # considered "under" or "at" the main layer level if layer in self.container_under_layers: my_handler = getattr(self, "_draw_container_" + layer, None) if my_handler: my_handler(gc, view_bounds, mode) # Now transform coordinates and draw the children visible_components = self._get_visible_components(new_bounds) if visible_components: with gc: gc.translate_ctm(*self.position) for component in visible_components: if component.unified_draw: # Plot containers that want unified_draw only get # called if their draw_layer matches the current layer # we're rendering if component.draw_layer == layer: component._draw(gc, new_bounds, mode) else: component._dispatch_draw(layer, gc, new_bounds, mode) # The container's annotation and overlay layers draw over those of # its components. # FIXME: This needs to be abstracted so that when subclasses override # the draw_order list, these are pulled from the subclass list instead # of hardcoded here. if layer in ("annotation", "overlay", "border"): my_handler = getattr(self, "_draw_container_" + layer, None) if my_handler: my_handler(gc, view_bounds, mode) return def _draw_container(self, gc, mode="default"): "Draw the container background in a specified graphics context" pass def _draw_container_background(self, gc, view_bounds=None, mode="normal"): self._draw_background(gc, view_bounds, mode) def _draw_container_overlay(self, gc, view_bounds=None, mode="normal"): self._draw_overlay(gc, view_bounds, mode) def _draw_container_underlay(self, gc, view_bounds=None, mode="normal"): self._draw_underlay(gc, view_bounds, mode) def _draw_container_border(self, gc, view_bounds=None, mode="normal"): self._draw_border(gc, view_bounds, mode) def _get_visible_components(self, bounds): """ Returns a list of this plot's children that are in the bounds. """ if bounds is None: return [c for c in self.components if c.visible] visible_components = [] for component in self.components: if not component.visible: continue tmp = intersect_bounds(component.outer_position + component.outer_bounds, bounds) if tmp != empty_rectangle: visible_components.append(component) return visible_components def _should_layout(self, component): """ Returns True if it is appropriate for the container to lay out the component; False if not. """ if not component or \ (not component.visible and not component.invisible_layout): return False else: return True def _should_compact(self): """ Returns True if the container needs to call compact(). Subclasses can overload this method as needed. """ if self.auto_size: width = self.width height = self.height for component in self.components: x, y = component.outer_position x2 = component.outer_x2 y2 = component.outer_y2 if (x2 >= width) or (y2 >= height) or (x < 0) or (y < 0): return True else: return False def _transform_view_bounds(self, view_bounds): """ Transforms the given view bounds into our local space and computes a new region that can be handed off to our children. Returns a 4-tuple of the new position+bounds, or None (if None was passed in), or the value of empty_rectangle (from enable.base) if the intersection resulted in a null region. """ if view_bounds: # Check if we are visible tmp = intersect_bounds(self.position + self.bounds, view_bounds) if tmp == empty_rectangle: return empty_rectangle # Compute new_bounds, which is the view_bounds transformed into # our coordinate space v = view_bounds new_bounds = (v[0]-self.x, v[1]-self.y, v[2], v[3]) else: new_bounds = None return new_bounds def _component_bounds_changed(self, component): "Called by contained objects when their bounds change" # For now, just punt and call compact() if self.auto_size: self.compact() def _component_position_changed(self, component): "Called by contained objects when their position changes" # For now, just punt and call compact() if self.auto_size: self.compact() #------------------------------------------------------------------------ # Deprecated interface #------------------------------------------------------------------------ def _draw_overlays(self, gc, view_bounds=None, mode="normal"): """ Method for backward compatability with old drawing scheme. """ warnings.warn("Containter._draw_overlays is deprecated.") for component in self.overlays: component.overlay(component, gc, view_bounds, mode) return #------------------------------------------------------------------------ # Property setters & getters #------------------------------------------------------------------------ def _get_components(self): return self._components def _get_layout_needed(self): # Override the parent implementation to take into account whether any # of our contained components need layout. if self._layout_needed: return True else: for c in self.components: if c.layout_needed: return True else: return False #------------------------------------------------------------------------ # Interactor interface #------------------------------------------------------------------------ def normal_mouse_leave(self, event): event.push_transform(self.get_event_transform(event), caller=self) for component in self._prev_event_handlers: component.dispatch(event, "mouse_leave") self._prev_event_handlers = set() event.pop(caller=self) def _container_handle_mouse_event(self, event, suffix): """ This method allows the container to handle a mouse event before its children get to see it. Once the event gets handled, its .handled should be set to True, and contained components will not be called with the event. """ #super(Container, self)._dispatch_stateful_event(event, suffix) Component._dispatch_stateful_event(self, event, suffix) def get_event_transform(self, event=None, suffix=""): return affine.affine_from_translation(-self.x, -self.y) def _dispatch_stateful_event(self, event, suffix): """ Dispatches a mouse event based on the current event_state. Overrides the default Interactor._dispatch_stateful_event by adding some default behavior to send all events to our contained children. "suffix" is the name of the mouse event as a suffix to the event state name, e.g. "_left_down" or "_window_enter". """ if not event.handled: if isinstance(event, BlobFrameEvent): # This kind of event does not have a meaningful location. Just # let all of the child components see it. for component in self._components[::-1]: component.dispatch(event, suffix) return components = self.components_at(event.x, event.y) # Translate the event's location to be relative to this container event.push_transform(self.get_event_transform(event, suffix), caller=self) try: new_component_set = set(components) # For "real" mouse events (i.e., not pre_mouse_* events), # notify the previous listening components of a mouse or # drag leave if not suffix.startswith("pre_"): components_left = self._prev_event_handlers - new_component_set if components_left: leave_event = None if isinstance(event, MouseEvent): leave_event = event leave_suffix = "mouse_leave" elif isinstance(event, DragEvent): leave_event = event leave_suffix = "drag_leave" elif isinstance(event, (BlobEvent, BlobFrameEvent)): # Do not generate a 'leave' event. pass else: # TODO: think of a better way to handle this rare case? leave_event = MouseEvent(x=event.x, y=event.y, window=event.window) leave_suffix = "mouse_leave" if leave_event is not None: for component in components_left: component.dispatch(leave_event, "pre_" + leave_suffix) component.dispatch(leave_event, leave_suffix) event.handled = False # Notify new components of a mouse enter, if the event is # not a mouse_leave or a drag_leave if suffix not in ("mouse_leave", "drag_leave"): components_entered = \ new_component_set - self._prev_event_handlers if components_entered: enter_event = None if isinstance(event, MouseEvent): enter_event = event enter_suffix = "mouse_enter" elif isinstance(event, DragEvent): enter_event = event enter_suffix = "drag_enter" elif isinstance(event, (BlobEvent, BlobFrameEvent)): # Do not generate an 'enter' event. pass if enter_event: for component in components_entered: component.dispatch(enter_event, "pre_" + enter_suffix) component.dispatch(enter_event, enter_suffix) event.handled = False # Handle the actual event # Only add event handlers to the list of previous event handlers # if they actually receive the event (and the event is not a # pre_* event. if not suffix.startswith("pre_"): self._prev_event_handlers = set() for component in components: component.dispatch(event, suffix) if not suffix.startswith("pre_"): self._prev_event_handlers.add(component) if event.handled: break finally: event.pop(caller=self) if not event.handled: self._container_handle_mouse_event(event, suffix) return #------------------------------------------------------------------------ # Event handlers #------------------------------------------------------------------------ def _auto_size_changed(self, old, new): # For safety, re-compute our bounds if new == True: self.compact() else: pass return def _window_resized(self, newsize): if newsize is not None: self.bounds = [newsize[0]-self.x, newsize[1]-self.y] #FIXME: Need a _window_changed to remove this handler if the window changes def _fit_window_changed(self, old, new): if self._window is not None: if not self.fit_window: self._window.on_trait_change(self._window_resized, "resized", remove=True) else: self._window.on_trait_change(self._window_resized, "resized") return def _bounds_changed(self, old, new): # crappy... calling our parent's handler seems like a common traits # event handling problem super(Container, self)._bounds_changed(old, new) self._layout_needed = True self.invalidate_draw() def _bounds_items_changed(self, event): super(Container, self)._bounds_items_changed(event) self._layout_needed = True self.invalidate_draw() def _bgcolor_changed(self): self.invalidate_draw() self.request_redraw() def __components_items_changed(self, event): self._layout_needed = True def __components_changed(self, event): self._layout_needed = True self.invalidate_draw() #------------------------------------------------------------------------- # Old / deprecated draw methods; here for backwards compatibility #------------------------------------------------------------------------- def _draw_component(self, gc, view_bounds=None, mode="normal"): """ Draws the component. This method is preserved for backwards compatibility. Overrides the implementation in Component. """ with gc: gc.set_antialias(False) self._draw_container(gc, mode) self._draw_background(gc, view_bounds, mode) self._draw_underlay(gc, view_bounds, mode) self._draw_children(gc, view_bounds, mode) #This was children_draw_mode self._draw_overlays(gc, view_bounds, mode) return def _draw_children(self, gc, view_bounds=None, mode="normal"): new_bounds = self._transform_view_bounds(view_bounds) if new_bounds == empty_rectangle: return with gc: gc.set_antialias(False) gc.translate_ctm(*self.position) for component in self.components: if new_bounds: tmp = intersect_bounds(component.outer_position + component.outer_bounds, new_bounds) if tmp == empty_rectangle: continue with gc: component.draw(gc, new_bounds, mode) return enthought-chaco2-4.5.1.orig/enable/compass.py0000644000175000017500000001533412516137326020153 0ustar varunvarun from __future__ import with_statement from numpy import array, pi # Enthought library imports from traits.api import Bool, Enum, Float, Int # Local, relative imports from component import Component from colors import ColorTrait class Compass(Component): """ A compass with triangles at the 4 cardinal directions. The center of the compass of triangles is the center of the widget. """ # Which triangle was clicked clicked = Enum(None, "n", "e", "s", "w", "c") # Whether or not to allow clicks on the center enable_center = Bool(False) #------------------------------------------------------------------------ # Shape and layout #------------------------------------------------------------------------ # The length of the triangle from tip to base triangle_length = Int(11) # The width of the base of the triangle triangle_width = Int(8) # Overall scaling factor for the triangle. Note that this also scales # the outline width. scale = Float(1.0) # The distance from the center of the widget to the center of each triangle # (halfway along its length, not the orthocenter). spacing = Int(12) #------------------------------------------------------------------------ # Appearance Traits #------------------------------------------------------------------------ # The line color of the triangles color = ColorTrait("black") # The line width of the triangles line_width = Int(2) # The triangle fill color when the mouse has not been clicked fill_color = ColorTrait("none") # The fill color of the triangle that the user has clicked on clicked_color = ColorTrait("lightgray") # Override the inherited **event_state** attribute event_state = Enum("normal", "clicked") #------------------------------------------------------------------------ # Stub methods for subclasses #------------------------------------------------------------------------ def mouse_down(self, arrow): """ Called when the mouse is first pressed inside one of the triangles. This gets called after self.clicked is set. Parameters ========== arrow: "n", "e", "s", "w" indicates which arrow was pressed """ pass def mouse_up(self): """ Called when the mouse is released. This gets called after self.clicked is unset. """ pass #------------------------------------------------------------------------ # Event handling methods #------------------------------------------------------------------------ def normal_left_down(self, event): # Determine which arrow was clicked; use a rectangular approximation. x = event.x - (self.x + self.width / 2) y = event.y - (self.y + self.height / 2) half_length = self.triangle_length / 2 * self.scale half_width = self.triangle_width / 2 * self.scale offset = self.spacing * self.scale # Create dict mapping direction to (x, y, x2, y2) near = offset - half_length far = offset + half_length rects = { "n": array((-half_width, near, half_width, far)), "e": array((near, -half_width, far, half_width)), "s": array((-half_width, -far, half_width, -near)), "w": array((-far, -half_width, -near, half_width)) } if self.enable_center: rects["c"] = array((-near, -near, near, near)) for direction, rect in rects.items(): if (rect[0] <= x <= rect[2]) and (rect[1] <= y <= rect[3]): self.event_state = "clicked" self.clicked = direction self.mouse_down(direction) self.request_redraw() break event.handled = True return def normal_left_dclick(self, event): return self.normal_left_down(event) def clicked_left_up(self, event): self.event_state = "normal" self.clicked = None event.handled = True self.mouse_up() self.request_redraw() def clicked_mouse_leave(self, event): self.clicked_left_up(event) #------------------------------------------------------------------------ # Rendering methods #------------------------------------------------------------------------ def get_preferred_size(self): # Since we can compute our preferred size from the size of the # arrows and the spacing, we can return a sensible preferred # size, so override the default implementation in Component. if self.fixed_preferred_size is not None: return self.fixed_preferred_size else: extent = self.scale * 2 * (self.spacing + self.triangle_length/2) return [extent + self.hpadding, extent + self.vpadding] def _draw_mainlayer(self, gc, view_bounds=None, mode="normal"): with gc: gc.set_stroke_color(self.color_) gc.set_line_width(self.line_width) gc.translate_ctm(self.x + self.width/2, self.y + self.height/2) s = self.spacing points_and_angles = [ ("n", (0, s), 0), ("e", (s, 0), -pi/2), ("s", (0, -s), pi), ("w", (-s, 0), pi/2) ] gc.scale_ctm(self.scale, self.scale) for dir, (dx,dy), angle in points_and_angles: if self.event_state == "clicked" and self.clicked == dir: gc.set_fill_color(self.clicked_color_) else: gc.set_fill_color(self.fill_color_) gc.translate_ctm(dx, dy) gc.rotate_ctm(angle) half_height = self.triangle_length / 2 half_width = self.triangle_width / 2 gc.begin_path() gc.lines( [(-half_width, -half_height), (0, half_height), (half_width, -half_height), (-half_width, -half_height), (0, half_height)] ) gc.draw_path() gc.rotate_ctm(-angle) gc.translate_ctm(-dx, -dy) if self.event_state == "clicked" and self.clicked == 'c': # Fill in the center gc.set_fill_color(self.clicked_color_) half_width = self.triangle_width / 2 gc.begin_path() gc.lines( [(-half_width, -half_width), (half_width, -half_height), (half_width, half_width), (-half_width, half_width), (-half_width, -half_width)] ) gc.draw_path() enthought-chaco2-4.5.1.orig/enable/text_field.py0000644000175000017500000005146312516137326020640 0ustar varunvarun from __future__ import with_statement # Standard library imports from math import floor, sqrt from bisect import insort_left # Enthought library imports from traits.api import (Bool, Int, Event, Instance, Any, Property, List, DelegatesTo) # Local, relative imports from component import Component from font_metrics_provider import font_metrics_provider from text_field_style import TextFieldStyle StyleDelegate = DelegatesTo("_style") class TextField(Component): """ A basic text entry field for Enable. fixme: Requires monospaced fonts. """ #------------------------------------------------------------------------ # Public traits #------------------------------------------------------------------------ # The text to be edited text = Property(depends_on=['_text_changed']) # Events that get fired on certain keypresses accept = Event cancel = Event # Are multiple lines of text allowed? multiline = Bool(False) # The object to use to measure text extents metrics = Any char_w = Any char_h = Any # Is this text field editable? can_edit = Bool(True) #------------------------------------------------------------------------ # Delegates for style #------------------------------------------------------------------------ text_color = StyleDelegate font = StyleDelegate line_spacing = StyleDelegate text_offset = StyleDelegate cursor_color = StyleDelegate cursor_width = StyleDelegate border_visible = StyleDelegate border_color = StyleDelegate bgcolor = StyleDelegate #------------------------------------------------------------------------ # Protected traits #------------------------------------------------------------------------ # The style information used in drawing _style = Instance(TextFieldStyle, ()) # The max width/height of the displayed text in characters _text_width = Property(depends_on=['_style', 'height'], cached='_height_cache') _text_height = Property(depends_on=['_style', 'width'], cached='_width_cache') # The x-y position of the cursor in the text _cursor_pos = List(Int) _old_cursor_pos = List(Int) _desired_cursor_x = Int # The text as an x-y grid, the shadow property for 'text' _text = List(List) _text_changed = Event # The text that is actually displayed in the editor, and its shadow values _draw_text = Property __draw_text = List(List) _draw_text_xstart = Int _draw_text_ystart = Int # Whether or not to draw the cursor (is mouse over box?) _draw_cursor = Bool(False) # fixme: Shouldn't traits initialize these on its own? # fixme again: I moved these out of __init__ because they weren't accessible # from the _get__text_height and _get__text_width methods. Not sure if this # is the right fix (dmartin) _width_cache = None _height_cache = None #------------------------------------------------------------------------ # Public methods #------------------------------------------------------------------------ def __init__(self, **traits): # This will be overriden if 'text' is provided as a trait, but it # must be initialized if not self._text = [ [] ] # Initialize internal tracking variables self.reset() super(TextField, self).__init__(**traits) if self.metrics is None: self.metrics = font_metrics_provider() # Initialize border/bg colors self.__style_changed() # If this can't be editted and no width has been set, make sure # that is wide enough to display the text. if not self.can_edit and self.width == 0: x, y, width, height = self.metrics.get_text_extent(self.text) offset = 2*self._style.text_offset self.width = width + offset #------------------------------------------------------------------------ # Interactor interface #------------------------------------------------------------------------ def normal_mouse_enter(self, event): if not self.can_edit: return event.window.set_pointer('ibeam') self.request_redraw() event.handled = True def normal_mouse_leave(self, event): if not self.can_edit: return event.window.set_pointer('arrow') self.request_redraw() event.handled = True def normal_left_down(self, event): if not self.can_edit: return self.event_state = "cursor" self._acquire_focus(event.window) event.handled = True # Transform pixel coordinates to text coordinates char_width, char_height = self.metrics.get_text_extent("T")[2:] char_height += self._style.line_spacing event_x = event.x - self.x - self._style.text_offset event_y = self.y2 - event.y - self._style.text_offset if self.multiline: y = int(round(event_y / char_height)) - 1 else: y = 0 x = int(round(event_x / char_width)) # Clip x and y so that they are with text bounds, then place the cursor y = min(max(y, 0), len(self.__draw_text)-1) x = min(max(x, 0), len(self.__draw_text[y])) self._old_cursor_pos = self._cursor_pos self._cursor_pos = [ self._draw_text_ystart + y, self._draw_text_xstart + x ] def cursor_left_up(self, event): if not self.can_edit: return # Reset event state self.event_state = "normal" event.handled = True self.request_redraw() def normal_character(self, event): "Actual text that we want to add to the buffer as-is." # XXX need to filter unprintables that are not handled in key_pressed if not self.can_edit: return # Save for bookkeeping purposes self._old_cursor_pos = self._cursor_pos y, x = self._cursor_pos self._text[y].insert(x, event.character) self._cursor_pos[1] += 1 self._desired_cursor_x = self._cursor_pos[1] self._text_changed = True event.handled = True self.invalidate_draw() self.request_redraw() def normal_key_pressed(self, event): "Special character handling" if not self.can_edit: return # Save for bookkeeping purposes self._old_cursor_pos = self._cursor_pos if event.character == "Backspace": # Normal delete if self._cursor_pos[1] > 0: del self._text[self._cursor_pos[0]][self._cursor_pos[1]-1] self._cursor_pos[1] -= 1 self._desired_cursor_x = self._cursor_pos[1] self._text_changed = True # Delete at the beginning of a line elif self._cursor_pos[0] - 1 >= 0: index = self._cursor_pos[0] - 1 old_line_len = len(self._text[index]) self._text[index] += self._text[index+1] del self._text[index+1] del self.__draw_text[index+1-self._draw_text_xstart] self._cursor_pos[0] -= 1 self._cursor_pos[1] = old_line_len self._desired_cursor_x = self._cursor_pos[1] self._text_changed = True elif event.character == "Delete": # Normal delete if self._cursor_pos[1] < len(self._text[self._cursor_pos[0]]): del self._text[self._cursor_pos[0]][self._cursor_pos[1]] self._desired_cursor_x = self._cursor_pos[1] self._text_changed = True # Delete at the end of a line elif self._cursor_pos[0] + 1 < len(self._text): index = self._cursor_pos[0] old_line_len = len(self._text[index]) self._text[index] += self._text[index+1] del self._text[index+1] del self.__draw_text[index+1-self._draw_text_xstart] self._desired_cursor_x = self._cursor_pos[1] self._text_changed = True # Cursor movement elif event.character == "Left": self._cursor_pos[1] -= 1 if self._cursor_pos[1] < 0: self._cursor_pos[0] -= 1 if self._cursor_pos[0] < 0: self._cursor_pos = [ 0, 0 ] else: self._cursor_pos[1] = len(self._text[self._cursor_pos[0]]) self._desired_cursor_x = self._cursor_pos[1] elif event.character == "Right": self._cursor_pos[1] += 1 if self._cursor_pos[1] > len(self._text[self._cursor_pos[0]]): self._cursor_pos[0] += 1 if self._cursor_pos[0] > len(self._text)-1: self._cursor_pos[0] -= 1 self._cursor_pos[1] -= 1 else: self._cursor_pos[1] = 0 self._desired_cursor_x = self._cursor_pos[1] elif event.character == "Up": self._cursor_pos[0] -= 1 if self._cursor_pos[0] < 0: self._cursor_pos[0] = 0 else: self._cursor_pos[1] = min(len(self._text[self._cursor_pos[0]]), self._desired_cursor_x) elif event.character == "Down": self._cursor_pos[0] += 1 if self._cursor_pos[0] >= len(self._text): self._cursor_pos[0] = len(self._text) - 1 else: self._cursor_pos[1] = min(len(self._text[self._cursor_pos[0]]), self._desired_cursor_x) elif event.character == "Home": self._cursor_pos[1] = 0 self._desired_cursor_x = self._cursor_pos[1] elif event.character == "End": self._cursor_pos[1] = len(self._text[self._cursor_pos[0]]) self._desired_cursor_x = self._cursor_pos[1] # Special characters elif event.character == "Tab": y, x = self._cursor_pos self._text[y] = self._text[y][:x] + [" "]*4 + self._text[y][x:] self._cursor_pos[1] += 4 self._desired_cursor_x = self._cursor_pos[1] self._text_changed = True elif event.character == "Enter": if self.multiline: line = self._cursor_pos[0] self._text.insert(line+1, self._text[line][self._cursor_pos[1]:]) self._text[line] = self._text[line][:self._cursor_pos[1]] self._cursor_pos[0] += 1 self._cursor_pos[1] = 0 self._desired_cursor_x = self._cursor_pos[1] self._text_changed = True else: self.accept = event elif event.character == "Escape": self.cancel = event elif len(event.character) == 1: # XXX normal keypress, so let it go through return event.handled = True self.invalidate_draw() self.request_redraw() #------------------------------------------------------------------------ # Component interface #------------------------------------------------------------------------ def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): with gc: # Draw the text gc.set_font(self._style.font) gc.set_fill_color(self._style.text_color) char_w, char_h = self.metrics.get_text_extent("T")[2:4] char_h += self._style.line_spacing lines = [ "".join(ln) for ln in self._draw_text ] for i, line in enumerate(lines): x = self.x + self._style.text_offset if i > 0: y_offset = (i+1) * char_h - self._style.line_spacing else: y_offset = char_h - self._style.line_spacing y = self.y2 - y_offset - self._style.text_offset # Show text at the same scale as the graphics context ctm = gc.get_ctm() if hasattr(ctm, "__len__") and len(ctm) == 6: scale = sqrt( (ctm[0]+ctm[1]) * (ctm[0]+ctm[1]) / 2.0 + \ (ctm[2]+ctm[3]) * (ctm[2]+ctm[3]) / 2.0 ) elif hasattr(gc, "get_ctm_scale"): scale = gc.get_ctm_scale() else: raise RuntimeError("Unable to get scale from GC.") x *= scale y *= scale gc.show_text_at_point(line, x, y) if self._draw_cursor: j, i = self._cursor_pos j -= self._draw_text_ystart i -= self._draw_text_xstart x_offset = self.metrics.get_text_extent(lines[j][:i])[2] y_offset = char_h * j y = self.y2 - y_offset - self._style.text_offset if not self.multiline: char_h -= float(self._style.line_spacing)*.5 gc.set_line_width(self._style.cursor_width) gc.set_stroke_color(self._style.cursor_color) gc.begin_path() x_position = self.x + x_offset + self._style.text_offset gc.move_to(x_position, y) gc.line_to(x_position, y - char_h) gc.stroke_path() #------------------------------------------------------------------------ # TextField interface #------------------------------------------------------------------------ def reset(self): """ Resets the text field. This involes reseting cursor position, text position, etc. """ self._cursor_pos = [ 0, 0 ] self._old_cursor_pos = [ 0, 0 ] self.__draw_text = [ [] ] def _scroll_horz(self, num): """ Horizontally scrolls all the text that is being drawn by 'num' characters. If num is negative, scrolls left. If num is positive, scrolls right. """ self._draw_text_xstart += num self._realign_horz() def _realign_horz(self): """ Realign all the text being drawn such that the first character being drawn in each line is the one at index '_draw_text_xstart.' """ for i in xrange(len(self.__draw_text)): line = self._text[self._draw_text_ystart + i] self.__draw_text[i] = self._clip_line(line, self._draw_text_xstart) def _scroll_vert(self, num): """ Vertically scrolls all the text that is being drawn by 'num' lines. If num is negative, scrolls up. If num is positive, scrolls down. """ x, y = self._draw_text_xstart, self._draw_text_ystart if num < 0: self.__draw_text = self.__draw_text[:num] lines = [ self._clip_line(line, x) for line in self._text[y+num:y] ] self.__draw_text = lines + self.__draw_text elif num > 0: self.__draw_text = self.__draw_text[num:] y += self._text_height lines = [ self._clip_line(line, x) for line in self._text[y:y+num] ] self.__draw_text.extend(lines) self._draw_text_ystart += num def _clip_line(self, text, index, start=True): """ Return 'text' clipped beginning at 'index' if 'start' is True or ending at 'index' if 'start' is False. """ box_width = self.width - 2*self._style.text_offset total_width = 0. end_index = 1 for t in text: w, h = self.metrics.get_text_extent(t)[2:4] total_width = total_width + w if total_width <= box_width: end_index = end_index + 1 else: break if start: return text[index:min(index+end_index-1, len(text))] else: return text[max(0, index-end_index):index] def _refresh_viewed_line(self, line): """ Updates the appropriate line in __draw_text with the text at 'line'. """ new_text = self._clip_line(self._text[line], self._draw_text_xstart) index = line - self._draw_text_ystart if index == len(self.__draw_text): self.__draw_text.append(new_text) else: self.__draw_text[index] = new_text def _acquire_focus(self, window): self._draw_cursor = True window.focus_owner = self window.on_trait_change(self._focus_owner_changed, "focus_owner") self.request_redraw() def _focus_owner_changed(self, obj, name, old, new): if old == self and new != self: obj.on_trait_change(self._focus_owner_changed, "focus_owner", remove=True) self._draw_cursor = False self.request_redraw() #------------------------------------------------------------------------ # Property getters/setters and trait event handlers #------------------------------------------------------------------------ def _get_text(self): return "\n".join([ "".join(line) for line in self._text ]) def _set_text(self, val): if val == "": self._text = [ [] ] else: self._text = [ list(line) for line in val.splitlines() ] self.reset() self.request_redraw() def _get__draw_text(self): # Rebuilding from scratch if self.__draw_text == [ [] ]: if self.multiline: self.__draw_text = [] self._draw_text_xstart, self._draw_text_ystart = 0, 0 end = min(len(self._text), self._text_height) for i in xrange(self._draw_text_ystart, end): line = self._clip_line(self._text[i], 0) self.__draw_text.append(line) else: self.__draw_text = [ self._clip_line(self._text[0], 0) ] # Updating only the things that need updating else: # Scroll if necessary depending on where cursor moved # Adjust up if self._cursor_pos[0] < self._draw_text_ystart: self._scroll_vert(-1) # Adjust down elif (self._cursor_pos[0] - self._draw_text_ystart >= self._text_height): self._scroll_vert(1) # Adjust left line = self._text[self._cursor_pos[0]] chars_before_start = len(line[:self._draw_text_xstart]) chars_after_start = len(line[self._draw_text_xstart:]) if self._cursor_pos[1] < self._draw_text_xstart: if chars_before_start <= self._text_width: self._draw_text_xstart = 0 self._realign_horz() else: self._scroll_horz(-self._text_width) if (self._draw_text_xstart > 0 and chars_after_start+1 < self._text_width): self._scroll_horz(-1) # Adjust right num_chars = self._cursor_pos[1] - self._draw_text_xstart if num_chars >= self._text_width: self._scroll_horz(num_chars - self._text_width + 1) # Replace text at cursor location if self._old_cursor_pos[0] < self._cursor_pos[0]: # A line has been created by an enter event self._refresh_viewed_line(self._old_cursor_pos[0]) self._refresh_viewed_line(self._cursor_pos[0]) return self.__draw_text def _get__text_width(self): if self._width_cache is None: if self.metrics is not None: char_width = self.metrics.get_text_extent("T")[2] width = self.width - 2*self._style.text_offset self._width_cache = int(floor(width/char_width)) return self._width_cache def _get__text_height(self): if self.multiline: if self._height_cache is None: if self.metrics is not None: char_height = self.metrics.get_text_extent("T")[3] height = self.height - 2*self._style.text_offset line_height = char_height + self._style.line_spacing self._height_cache = int(floor(height / line_height)) return self._height_cache else: return 1 def __style_changed(self): """ Bg/border color is inherited from the style, so update it when the style changes. The height of a line also depends on style. """ self.bgcolor = self._style.bgcolor self.border_visible = self._style.border_visible self.border_color = self._style.border_color self.metrics.set_font(self._style.font) # FIXME!! The height being passed in gets over-written here #if not self.multiline: # self.height = (self.metrics.get_text_extent("T")[3] + # self._style.text_offset*2) self.request_redraw() enthought-chaco2-4.5.1.orig/enable/font_metrics_provider.py0000644000175000017500000000153512516137326023112 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! # # Author: Enthought, Inc. # Description: #------------------------------------------------------------------------------ # Import the toolkit specific version. from toolkit import toolkit_object font_metrics_provider = toolkit_object('font_metrics_provider') #### EOF ###################################################################### enthought-chaco2-4.5.1.orig/enable/interactor.py0000644000175000017500000000675612516137326020670 0ustar varunvarun""" Defines the Interactor class """ # Enthought library imports from kiva.affine import affine_identity from traits.api import Any, Bool, HasTraits, List, Property, Str, Trait # Local relative imports from enable_traits import cursor_style_trait, Pointer from enable.colors import ColorTrait class Interactor(HasTraits): """ The base class of any Enable object that receives keyboard and mouse events. Adds the notion of "state" which determines which set of event handler methods get called. The default state is "normal", so a "left_down" event would be dispatched by calling:: self.normal_left_down(event) The event suffixes are: - left_down - left_up - left_dclick - right_down - right_up - right_dclick - middle_down - middle_up - middle_dclick - mouse_move - mouse_wheel - mouse_enter - mouse_leave - key_pressed - key_released - character - dropped_on - drag_over - drag_enter - drag_leave """ # Name of the object's event state. Used as a prefix when looking up # which set of event handlers should be used for MouseEvents and KeyEvents. # Subclasses should override this with an enumeration of their possible # states. event_state = Str("normal") # The cursor shape that should be displayed when this interactor is "active" pointer = Pointer # The "tooltip" to display if a user mouse-overs this interactor tooltip = Trait(None, None, Str) # The cursor "style" to use cursor_style = cursor_style_trait # The color of the cursor... # PZW: Figure out the right type for this.. cursor_color = ColorTrait # Whether or not the interactor accepts keyboard focus accepts_focus = Bool(True) # The tools that are registered as listeners. tools = List # The tool that is currently active. active_tool = Property # If True, then marks events as "handled" if there is a handler function # defined. This makes it easy to write simple components that respond # to events, but more complex tools will probably want this turned off. auto_handle_event = Bool(True) # Shadow trait for the **active_tool** property. Must be an instance of # BaseTool or one of its subclasses. _active_tool = Any def dispatch(self, event, suffix): """ Public method for sending mouse/keyboard events to this interactor. Subclasses may override this to customize the public dispatch behavior. Parameters ========== event : enable.BaseEvent instance The event to dispach suffix : string The type of event that occurred. See class docstring for the list of possible suffixes. """ self._dispatch_stateful_event(event, suffix) def get_event_transform(self, event=None, suffix=""): """ Returns the 3x3 transformation matrix that this interactor will apply to the event (if any). """ return affine_identity() def _dispatch_stateful_event(self, event, suffix): """ Protected method to dispatch a mouse or keyboard based on the current event_state. Subclasses can call this from within customized event handling logic in dispatch(). """ handler = getattr(self, self.event_state + "_" + suffix, None) if handler is not None: handler(event) if self.auto_handle_event: event.handled = True return # EOF enthought-chaco2-4.5.1.orig/enable/text_grid.py0000644000175000017500000002346212516137326020500 0ustar varunvarun""" TextGrid is a text grid widget that is meant to be used with Numpy. """ from __future__ import with_statement # Major library imports from numpy import arange, array, dstack, repeat, newaxis # Enthought library imports from traits.api import Any, Array, Bool, Int, List, Property, \ Trait, Tuple, on_trait_change from kiva.trait_defs.kiva_font_trait import KivaFont # Relative imports from component import Component from colors import black_color_trait, ColorTrait from enable_traits import LineStyle from font_metrics_provider import font_metrics_provider class TextGrid(Component): """ A 2D grid of string values """ # A 2D array of strings string_array = Array # The cell size can be set to a tuple (w,h) or to "auto". cell_size = Property #------------------------------------------------------------------------ # Appereance traits #------------------------------------------------------------------------ # The font to use for the text of the grid font = KivaFont("modern 14") # The color of the text text_color = black_color_trait # The padding around each cell cell_padding = Int(5) # The thickness of the border between cells cell_border_width = Int(1) # The color of the border between cells cell_border_color = black_color_trait # The dash style of the border between cells cell_border_style = LineStyle("solid") # Text color of highlighted items highlight_color = ColorTrait("red") # Cell background color of highlighted items highlight_bgcolor = ColorTrait("lightgray") # A list of tuples of the (i,j) of selected cells selected_cells = List #------------------------------------------------------------------------ # Private traits #------------------------------------------------------------------------ # Are our cached extent values still valid? _cache_valid = Bool(False) # The maximum width and height of all cells, as a tuple (w,h) _cached_cell_size = Tuple # The maximum (leading, descent) of all the text strings (positive value) _text_offset = Array # An array NxMx2 of the x,y positions of the lower-left coordinates of # each cell _cached_cell_coords = Array # "auto" or a tuple _cell_size = Trait("auto", Any) #------------------------------------------------------------------------ # Public methods #------------------------------------------------------------------------ def __init__(self, **kwtraits): super(Component, self).__init__(**kwtraits) self.selected_cells = [] return #------------------------------------------------------------------------ # AbstractComponent interface #------------------------------------------------------------------------ def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): text_color = self.text_color_ highlight_color = self.highlight_color_ highlight_bgcolor = self.highlight_bgcolor_ padding = self.cell_padding border_width = self.cell_border_width with gc: gc.set_stroke_color(text_color) gc.set_fill_color(text_color) gc.set_font(self.font) gc.set_text_position(0,0) width, height = self._get_actual_cell_size() numrows, numcols = self.string_array.shape # draw selected backgrounds # XXX should this be in the background layer? for j, row in enumerate(self.string_array): for i, text in enumerate(row): if (i,j) in self.selected_cells: gc.set_fill_color(highlight_bgcolor) ll_x, ll_y = self._cached_cell_coords[i,j+1] # render this a bit big, but covered by border gc.rect(ll_x, ll_y, width+2*padding + border_width, height+2*padding + border_width) gc.fill_path() gc.set_fill_color(text_color) self._draw_grid_lines(gc) for j, row in enumerate(self.string_array): for i, text in enumerate(row): x,y = self._cached_cell_coords[i,j+1] + self._text_offset + \ padding + border_width/2.0 if (i,j) in self.selected_cells: gc.set_fill_color(highlight_color) gc.set_stroke_color(highlight_color) gc.set_text_position(x, y) gc.show_text(text) gc.set_stroke_color(text_color) gc.set_fill_color(text_color) else: gc.set_text_position(x, y) gc.show_text(text) return #------------------------------------------------------------------------ # Private methods #------------------------------------------------------------------------ def _draw_grid_lines(self, gc): gc.set_stroke_color(self.cell_border_color_) gc.set_line_dash(self.cell_border_style_) gc.set_line_width(self.cell_border_width) # Skip the leftmost and bottommost cell coords (since Y axis is reversed, # the bottommost coord is the last one) x_points = self._cached_cell_coords[:,0,0] y_points = self._cached_cell_coords[0,:,1] for x in x_points: gc.move_to(x, self.y) gc.line_to(x, self.y+self.height) gc.stroke_path() for y in y_points: gc.move_to(self.x, y) gc.line_to(self.x+self.width, y) gc.stroke_path() return def _compute_cell_sizes(self): if not self._cache_valid: gc = font_metrics_provider() max_w = 0 max_h = 0 min_l = 0 min_d = 0 for text in self.string_array.ravel(): gc.set_font(self.font) l, d, w, h = gc.get_text_extent(text) if -l+w > max_w: max_w = -l+w if -d+h > max_h: max_h = -d+h if l < min_l: min_l = l if d < min_d: min_d = d self._cached_cell_size = (max_w, max_h) self._text_offset = array([-min_l, -min_d]) self._cache_valid = True return def _compute_positions(self): if self.string_array is None or len(self.string_array.shape) != 2: return width, height = self._get_actual_cell_size() numrows, numcols = self.string_array.shape cell_width = width + 2*self.cell_padding + self.cell_border_width cell_height = height + 2*self.cell_padding + self.cell_border_width x_points = arange(numcols+1) * cell_width + self.cell_border_width/2.0 + self.x y_points = arange(numrows+1) * cell_height + self.cell_border_width/2.0 + self.y tmp = dstack((repeat(x_points[:,newaxis], numrows+1, axis=1), repeat(y_points[:,newaxis].T, numcols+1, axis=0))) # We have to reverse the y-axis (e.g. the 0th row needs to be at the # highest y-position). self._cached_cell_coords = tmp[:,::-1] return def _update_bounds(self): if self.string_array is not None and len(self.string_array.shape) == 2: rows, cols = self.string_array.shape margin = 2*self.cell_padding + self.cell_border_width width, height = self._get_actual_cell_size() self.bounds = [ cols * (width + margin) + self.cell_border_width, rows * (height + margin) + self.cell_border_width ] else: self.bounds = [0,0] def _get_actual_cell_size(self): if self._cell_size == "auto": if not self._cache_valid: self._compute_cell_sizes() return self._cached_cell_size else: if not self._cache_valid: # actually computing the text offset self._compute_cell_sizes() return self._cell_size #------------------------------------------------------------------------ # Event handlers #------------------------------------------------------------------------ def normal_left_down(self, event): self.selected_cells = [self._get_index_for_xy(event.x, event.y)] self.request_redraw() def _get_index_for_xy(self, x, y): width, height = array(self._get_actual_cell_size()) + 2*self.cell_padding \ + self.cell_border_width numrows, numcols = self.string_array.shape i = int((x - self.padding_left) / width) j = numrows - (int((y - self.padding_bottom)/ height) + 1) shape = self.string_array.shape if 0 <= i < shape[1] and 0 <= j < shape[0]: return i,j else: return None #------------------------------------------------------------------------ # Trait events, property setters and getters #------------------------------------------------------------------------ def _string_array_changed(self, old, new): if self._cell_size == "auto": self._cache_valid = False self._compute_cell_sizes() self._compute_positions() self._update_bounds() @on_trait_change('cell_border_width,cell_padding') def cell_properties_changed(self): self._compute_positions() self._update_bounds() def _set_cell_size(self, newsize): self._cell_size = newsize if newsize == "auto": self._compute_cell_sizes() self._compute_positions() self._update_bounds() def _get_cell_size(self): return self._cell_size # EOF enthought-chaco2-4.5.1.orig/enable/qt4/0000755000175000017500000000000012516137725016641 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/qt4/__init__.py0000644000175000017500000000000012516137326020735 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/qt4/scrollbar.py0000644000175000017500000002326712516137326021205 0ustar varunvarun""" Define a standard horizontal and vertical Enable scrollbar component that wraps the standard Qt one. """ from types import ListType, TupleType from pyface.qt import QtCore, QtGui from traits.api import Any, Bool, Enum, Float, Int, Property, Trait, TraitError from enable.component import Component def valid_range(object, name, value): """ Verify that a set of range values for a scrollbar is valid. """ try: if (type(value) in (TupleType, ListType)) and (len(value) == 4): low, high, page_size, line_size = value if high < low: low, high = high, low elif high == low: high = low + 1.0 page_size = max(min(page_size, high - low), 0.0) line_size = max(min(line_size, page_size), 0.0) return (float(low), float(high), float(page_size), float(line_size)) except: raise raise TraitError valid_range.info = 'a (low,high,page_size,line_size) range tuple' def valid_scroll_position(object, name, value): """ Verify that a specified scroll bar position is valid. """ try: low, high, page_size, line_size = object.range x = max(min(float(value), high - page_size), low) return x except: raise raise TraitError class QResizableScrollBar(QtGui.QScrollBar): resized = QtCore.Signal() def resizeEvent(self, event): super(QResizableScrollBar, self).resizeEvent(event) self.resized.emit() class NativeScrollBar(Component): "An Enable scrollbar component that wraps/embeds the native Qt scrollbar" #------------------------------------------------------------------------ # Public Traits #------------------------------------------------------------------------ # The current position of the scroll bar. This must be within the range # (self.low, self.high) scroll_position = Trait( 0.0, valid_scroll_position ) # A tuple (low, high, page_size, line_size). Can be accessed using # convenience properties (see below). range = Trait( ( 0.0, 100.0, 10.0, 1.0 ), valid_range ) # The orientation of the scrollbar orientation = Trait("horizontal", "vertical") # Is y=0 at the top or bottom? origin = Trait('bottom', 'top') # Determines if the scroll bar should be visible and respond to events enabled = Bool(True) # The scroll increment associated with a single mouse wheel increment mouse_wheel_speed = Int(3) # Expose scroll_position, low, high, page_size as properties low = Property high = Property page_size = Property line_size = Property # This represents the state of the mouse button on the scrollbar thumb. # External classes can monitor this to detect when the user starts and # finishes interacting with this scrollbar via the scrollbar thumb. mouse_thumb = Enum("up", "down") #------------------------------------------------------------------------ # Private Traits #------------------------------------------------------------------------ _control = Any _clean = Bool(False) _last_widget_x = Float(0) _last_widget_y = Float(0) _last_widget_height = Float(0) _last_widget_width = Float(0) # Indicates whether or not the widget needs to be re-drawn after being # repositioned and resized _widget_moved = Bool(True) # Set to True if something else has updated the scroll position and # the widget needs to redraw. This is not set to True if the widget # gets updated via user mouse interaction, since Qt is then responsible # for updating the scrollbar. _scroll_updated = Bool(True) def destroy(self): """ Destroy the native widget associated with this component. """ if self._control is not None: self._control.hide() self._control.deleteLater() return def __del__(self): # Pray that we do not participate in a cycle. self.destroy() def _get_abs_coords(self, x, y): return self.container.get_absolute_coords(x, y) def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): x_pos, y_pos = self.position x_size, y_size = map(int, self.bounds) qt_xpos, qt_ypos = self._get_abs_coords(x_pos, y_pos+y_size-1) # We have to do this flip_y business because Qt and enable use opposite # coordinate systems, and enable defines the component's position as its # lower left corner, while Qt defines it as the upper left corner. window = self.window if window is None: return qt_ypos = window._flip_y(qt_ypos) qt_xpos = int(qt_xpos) qt_ypos = int(qt_ypos) if not self._control: self._create_control(window, self.range, self.scroll_position) if self._widget_moved: if (self._last_widget_x != qt_xpos) or (self._last_widget_y != qt_ypos): self._control.move(qt_xpos, qt_ypos) controlsize = self._control.size() if x_size != controlsize.width() or y_size != controlsize.height(): self._control.resize(x_size, y_size) if self._scroll_updated: self._update_control(self.range, self.scroll_position) #self._control.raise_() self._last_widget_x = qt_xpos self._last_widget_y = qt_ypos self._last_widget_width = x_size self._last_widget_height = y_size self._scroll_updated = False self._widget_moved = False def _create_control(self, window, enable_range, value): qt_orientation = dict( horizontal=QtCore.Qt.Horizontal, vertical=QtCore.Qt.Vertical, )[self.orientation] self._control = QResizableScrollBar(qt_orientation, window.control) self._update_control(enable_range, value) self._control.valueChanged.connect(self._update_enable_pos) self._control.sliderPressed.connect(self._on_slider_pressed) self._control.sliderReleased.connect(self._on_slider_released) self._control.resized.connect(self._control_resized) self._control.setVisible(True) def _update_control(self, enable_range, value): minimum, maximum, page_size, line_size = enable_range self._control.setMinimum(minimum) # The maximum value of a QScrollBar is the maximum position of the # scroll bar, not the document length. We need to subtract the length # of the scroll bar itself. self._control.setMaximum(maximum-page_size) self._control.setValue(value) self._control.setPageStep(page_size) self._control.setSingleStep(line_size) #------------------------------------------------------------------------ # Qt Event handlers #------------------------------------------------------------------------ def _update_enable_pos(self, value): self.scroll_position = value def _on_slider_pressed(self): self.mouse_thumb = "down" def _on_slider_released(self): self.mouse_thumb = "up" def _control_resized(self): self._widget_moved = True self.request_redraw() #------------------------------------------------------------------------ # Basic trait event handlers #------------------------------------------------------------------------ def _range_changed(self): low, high, page_size, line_size = self.range self.scroll_position = max(min(self.scroll_position, high-page_size), low) self._scroll_updated = True self.request_redraw() return def _range_items_changed(self): self._range_changed() return def _mouse_wheel_changed(self, event): # FIXME: convert to Qt. event.handled = True self.scroll_position += (event.mouse_wheel * self.range[3] * self.mouse_wheel_speed) return def _scroll_position_changed(self): self._scroll_updated = True self.request_redraw() return def _bounds_changed(self, old, new): super(NativeScrollBar, self)._bounds_changed(old, new) self._widget_moved = True self.request_redraw() def _bounds_items_changed(self, event): super(NativeScrollBar, self)._bounds_items_changed(event) self._widget_moved = True self.request_redraw() def _position_changed(self, old, new): super(NativeScrollBar, self)._position_changed(old, new) self._widget_moved = True self.request_redraw() def _position_items_changed(self, event): super(NativeScrollBar, self)._position_items_changed(event) self._widget_moved = True self.request_redraw() #------------------------------------------------------------------------ # Property getters and setters #------------------------------------------------------------------------ def _get_low(self): return self.range[0] def _set_low(self, low): ignore, high, page_size, line_size = self.range self._clean = False self.range =(low, high, page_size, line_size) def _get_high(self): return self.range[1] def _set_high(self, high): low, ignore, page_size, line_size = self.range self._clean = False self.range =(low, high, page_size, line_size) def _get_page_size(self): return self.range[2] def _set_page_size(self, page_size): low, high, ignore, line_size = self.range self._clean = False self.range =(low, high, page_size, line_size) def _get_line_size(self): return self.range[3] def _set_line_size(self, line_size): low, high, page_size, ignore = self.range self._clean = False self.range =(low, high, page_size, line_size) enthought-chaco2-4.5.1.orig/enable/qt4/image.py0000644000175000017500000000323512516137326020275 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ from pyface.qt import QtCore, QtGui from kiva.agg import CompiledPath, GraphicsContextSystem as GraphicsContext from base_window import BaseWindow from scrollbar import NativeScrollBar class Window(BaseWindow): def _create_gc(self, size, pix_format="bgra32"): gc = GraphicsContext((size[0]+1, size[1]+1), pix_format=pix_format, # We have to set bottom_up=0 or otherwise the PixelMap will # appear upside down in the QImage. bottom_up = 0) gc.translate_ctm(0.5, 0.5) return gc def _window_paint(self, event): if self.control is None: return # self._gc is an image context w = self._gc.width() h = self._gc.height() data = self._gc.pixel_map.convert_to_argb32string() image = QtGui.QImage(data, w, h, QtGui.QImage.Format_ARGB32) rect = QtCore.QRect(0,0,w,h) painter = QtGui.QPainter(self.control) painter.drawImage(rect, image) def font_metrics_provider(): from kiva.fonttools import Font gc = GraphicsContext((1, 1)) gc.set_font(Font()) return gc enthought-chaco2-4.5.1.orig/enable/qt4/gl.py0000644000175000017500000000407012516137326017613 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ import pyglet pyglet.options['shadow_window'] = False from traits.api import Bool, Instance from kiva.gl import CompiledPath, GraphicsContext from base_window import BaseGLWindow from scrollbar import NativeScrollBar class Window(BaseGLWindow): def _create_gc(self, size, pix_format=None): """ Create a GraphicsContext instance. """ from pyglet.gl import Context gc = GraphicsContext((size[0]+1, size[1]+1)) self._pyglet_gl_context = Context() gc.gl_init() gc.translate_ctm(0.5, 0.5) return gc def _init_gc(self): """ Gives the GC a chance to initialize itself before components perform layout and draw. This is called every time through the paint loop. """ self._pyglet_gl_context.set_current() self.control.makeCurrent() super(Window, self)._init_gc() def _paint(self, event=None): """ Paint the contents of the window. """ if self.control is None: return size = self._get_control_size() self._size = tuple(size) self._gc = self._create_gc(size) self._init_gc() if hasattr(self.component, "do_layout"): self.component.do_layout() self._gc.clear(self.bgcolor_) self.component.draw(self._gc, view_bounds=(0, 0, size[0], size[1])) self._update_region = [] def font_metrics_provider(): from kiva.fonttools import Font gc = GraphicsContext((1, 1)) gc.set_font(Font()) return gc # EOF enthought-chaco2-4.5.1.orig/enable/qt4/qpainter.py0000644000175000017500000000177512516137326021045 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ from kiva.qpainter import CompiledPath, GraphicsContext, font_metrics_provider from base_window import BaseWindow from scrollbar import NativeScrollBar class Window(BaseWindow): def _create_gc(self, size, pix_format=None): gc = GraphicsContext((size[0]+1, size[1]+1), parent=self.control) gc.translate_ctm(0.5, 0.5) return gc def _window_paint(self, event): # get rid of the GC after drawing self._gc = None enthought-chaco2-4.5.1.orig/enable/qt4/quartz.py0000644000175000017500000000740012516137326020537 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2012, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ import numpy as np from kiva.fonttools import Font from kiva.quartz import get_mac_context, ABCGI from base_window import BaseWindow from scrollbar import NativeScrollBar CompiledPath = ABCGI.CGMutablePath class GraphicsContext(ABCGI.CGLayerContext): def __init__(self, size_or_array, *args, **kwds): gc = kwds.pop('window_gc', None) if not gc: # Create a tiny base context to spawn the CGLayerContext from. # We are better off making our Layer from the window gc since # the data formats will match and so it will be faster to draw the # layer. gc = ABCGI.CGBitmapContext((1,1)) if isinstance(size_or_array, np.ndarray): # Initialize the layer with an image. image = ABCGI.CGImage(size_or_array) width = image.width height = image.height else: # No initialization. image = None width, height = size_or_array super(GraphicsContext, self).__init__((width, height), gc, *args, **kwds) if image is not None: self.draw_image(image) @classmethod def create_from_gc(klass, gc, size_or_array, *args, **kwds): return klass(size_or_array, window_gc=gc, *args, **kwds) class _WindowGraphicsContext(ABCGI.CGContextInABox): def __init__(self, *args, **kwds): super(_WindowGraphicsContext, self).__init__(*args, **kwds) self._begun = False def begin(self): if self._begun: return self.save_state() self.translate_ctm(0, self.height()) self.scale_ctm(1.0, -1.0) self._begun = True def end(self): if self._begun: self.restore_state() self._begun = False @staticmethod def create_from_gc(gc, size_or_array, *args, **kwds): return GraphicsContext(size_or_array, window_gc=gc, *args, **kwds) class Window(BaseWindow): """ An Enable Window for Qt GUIs on OS X. """ #### 'BaseWindow' interface ################################################ def _create_gc(self, size, pix_format=None): if hasattr(self.control, 'winId'): # From the Qt 4.7 Documentation: # "On Mac OS X, the type returned depends on which framework Qt was # linked against. If Qt is using Carbon, the {WId} is actually # an HIViewRef. If Qt is using Cocoa, {WId} is a pointer to # an NSView." # get_mac_context() only works on Cocoa. self.dc = get_mac_context(self.control.winId()) if self.dc: gc = _WindowGraphicsContext(size, self.dc) gc.begin() return gc raise NotImplementedError("Only Qt built against Cocoa is supported") def _window_paint(self, event): # Make sure end() is called so that the window's GC is not left in an # odd state. self._gc.end() # Force a new gc to be created for the next paint() self._gc = None self.dc = None def font_metrics_provider(): gc = GraphicsContext((1, 1)) gc.set_font(Font()) return gc #### EOF ####################################################################### enthought-chaco2-4.5.1.orig/enable/qt4/base_window.py0000644000175000017500000004366712516137326021531 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2008, Riverbank Computing Limited # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license. # # Author: Riverbank Computing Limited # Description: # # In an e-mail to enthought-dev on 2008.09.12 at 2:49 AM CDT, Phil Thompson said: # The advantage is that all of the PyQt code in ETS can now be re-licensed to # use the BSD - and I hereby give my permission for that to be done. It's # been on my list of things to do. #------------------------------------------------------------------------------ # Qt imports. from pyface.qt import QtCore, QtGui, QtOpenGL # Enthought library imports. from enable.abstract_window import AbstractWindow from enable.events import KeyEvent, MouseEvent, DragEvent from traits.api import Instance # Local imports. from constants import BUTTON_NAME_MAP, KEY_MAP, POINTER_MAP, DRAG_RESULTS_MAP class _QtWindowHandler(object): def __init__(self, qt_window, enable_window): self._enable_window = enable_window pos = qt_window.mapFromGlobal(QtGui.QCursor.pos()) self.last_mouse_pos = (pos.x(), pos.y()) self.in_paint_event = False qt_window.setAutoFillBackground(True) qt_window.setFocusPolicy(QtCore.Qt.WheelFocus) qt_window.setMouseTracking(True) qt_window.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) def closeEvent(self, event): self._enable_window.cleanup() self._enable_window = None def paintEvent(self, event): self.in_paint_event = True self._enable_window._paint(event) self.in_paint_event = False def resizeEvent(self, event): dx = event.size().width() dy = event.size().height() component = self._enable_window.component self._enable_window.resized = (dx, dy) if hasattr(component, "fit_window") and component.fit_window: component.outer_position = [0, 0] component.outer_bounds = [dx, dy] elif hasattr(component, "resizable"): if "h" in component.resizable: component.outer_x = 0 component.outer_width = dx if "v" in component.resizable: component.outer_y = 0 component.outer_height = dy #------------------------------------------------------------------------ # Qt Keyboard event handlers #------------------------------------------------------------------------ def keyPressEvent(self, event): if self._enable_window: if not self._enable_window._on_key_pressed(event): # for consistency with wx, we only generate character events if key_pressed not handled self._enable_window._on_character(event) def keyReleaseEvent(self, event): if self._enable_window: self._enable_window._on_key_released(event) #------------------------------------------------------------------------ # Qt Mouse event handlers #------------------------------------------------------------------------ def enterEvent(self, event): if self._enable_window: self._enable_window._handle_mouse_event("mouse_enter", event) def leaveEvent(self, event): if self._enable_window: self._enable_window._handle_mouse_event("mouse_leave", event) def mouseDoubleClickEvent(self, event): if self._enable_window: name = BUTTON_NAME_MAP[event.button()] self._enable_window._handle_mouse_event(name + "_dclick", event) def mouseMoveEvent(self, event): if self._enable_window: self._enable_window._handle_mouse_event("mouse_move", event) def mousePressEvent(self, event): if self._enable_window: name = BUTTON_NAME_MAP[event.button()] self._enable_window._handle_mouse_event(name + "_down", event) def mouseReleaseEvent(self, event): if self._enable_window: name = BUTTON_NAME_MAP[event.button()] self._enable_window._handle_mouse_event(name + "_up", event) def wheelEvent(self, event): if self._enable_window: self._enable_window._handle_mouse_event("mouse_wheel", event) def sizeHint(self, qt_size_hint): """ Combine the Qt and enable size hints. Combine the size hint coming from the Qt component (usually -1, -1) with the preferred size of the enable component and the size of the enable window. The combined size hint is - the Qt size hint if larger than 0 - the maximum of the plot's preferred size and the window size (component-wise) E.g., if qt size hint = (-1, -1) component preferred size = (500, 200) size of enable window = (400, 400) the final size hint will be (500, 400) """ preferred_size = self._enable_window.component.get_preferred_size() q_size = self._enable_window.control.size() window_size = (q_size.width(), q_size.height()) if qt_size_hint.width() < 0: width = max(preferred_size[0], window_size[0]) qt_size_hint.setWidth(width) if qt_size_hint.height() < 0: height = max(preferred_size[1], window_size[1]) qt_size_hint.setHeight(height) return qt_size_hint #------------------------------------------------------------------------ # Qt Drag and drop event handlers #------------------------------------------------------------------------ def dragEnterEvent(self, event): if self._enable_window: self._enable_window._drag_result = QtCore.Qt.IgnoreAction self._enable_window._handle_drag_event('drag_over', event) event.setDropAction(self._enable_window._drag_result) event.accept() def dragLeaveEvent(self, event): if self._enable_window: self._enable_window._handle_drag_event('drag_leave', event) def dragMoveEvent(self, event): if self._enable_window: self._enable_window._drag_result = QtCore.Qt.IgnoreAction self._enable_window._handle_drag_event('drag_over', event) event.setDropAction(self._enable_window._drag_result) event.accept() def dropEvent(self, event): if self._enable_window: self._enable_window._drag_result = event.proposedAction() self._enable_window._handle_drag_event('dropped_on', event) event.setDropAction(self._enable_window._drag_result) event.accept() class _QtWindow(QtGui.QWidget): """ The Qt widget that implements the enable control. """ def __init__(self, parent, enable_window): super(_QtWindow, self).__init__(parent) self.setAcceptDrops(True) self.handler = _QtWindowHandler(self, enable_window) def closeEvent(self, event): self.handler.closeEvent(event) return super(_QtWindow, self).closeEvent(event) def paintEvent(self, event): self.handler.paintEvent(event) def resizeEvent(self, event): self.handler.resizeEvent(event) def keyPressEvent(self, event): self.handler.keyPressEvent(event) def keyReleaseEvent(self, event): self.handler.keyReleaseEvent(event) def enterEvent(self, event): self.handler.enterEvent(event) def leaveEvent(self, event): self.handler.leaveEvent(event) def mouseDoubleClickEvent(self, event): self.handler.mouseDoubleClickEvent(event) def mouseMoveEvent(self, event): self.handler.mouseMoveEvent(event) def mousePressEvent(self, event): self.handler.mousePressEvent(event) def mouseReleaseEvent(self, event): self.handler.mouseReleaseEvent(event) def wheelEvent(self, event): self.handler.wheelEvent(event) def dragEnterEvent(self, event): self.handler.dragEnterEvent(event) def dragLeaveEvent(self, event): self.handler.dragLeaveEvent(event) def dragMoveEvent(self, event): self.handler.dragMoveEvent(event) def dropEvent(self, event): self.handler.dropEvent(event) def sizeHint(self): qt_size_hint = super(_QtWindow, self).sizeHint() return self.handler.sizeHint(qt_size_hint) class _QtGLWindow(QtOpenGL.QGLWidget): def __init__(self, parent, enable_window): super(_QtGLWindow, self).__init__(parent) self.handler = _QtWindowHandler(self, enable_window) def closeEvent(self, event): self.handler.closeEvent(event) return super(_QtGLWindow, self).closeEvent(event) def paintEvent(self, event): super(_QtGLWindow, self).paintEvent(event) self.handler.paintEvent(event) def resizeEvent(self, event): super(_QtGLWindow, self).resizeEvent(event) self.handler.resizeEvent(event) def keyPressEvent(self, event): self.handler.keyPressEvent(event) def keyReleaseEvent(self, event): self.handler.keyReleaseEvent(event) def enterEvent(self, event): self.handler.enterEvent(event) def leaveEvent(self, event): self.handler.leaveEvent(event) def mouseDoubleClickEvent(self, event): self.handler.mouseDoubleClickEvent(event) def mouseMoveEvent(self, event): self.handler.mouseMoveEvent(event) def mousePressEvent(self, event): self.handler.mousePressEvent(event) def mouseReleaseEvent(self, event): self.handler.mouseReleaseEvent(event) def wheelEvent(self, event): self.handler.wheelEvent(event) def dragEnterEvent(self, event): self.handler.dragEnterEvent(event) def dragLeaveEvent(self, event): self.handler.dragLeaveEvent(event) def dragMoveEvent(self, event): self.handler.dragMoveEvent(event) def dropEvent(self, event): self.handler.dropEvent(event) # TODO: by symmetry this belongs here, but we need to test it #def sizeHint(self): # qt_size_hint = super(_QtGLWindow, self).sizeHint() # return self.handler.sizeHint(qt_size_hint) class _Window(AbstractWindow): control = Instance(QtGui.QWidget) def __init__(self, parent, wid=-1, pos=None, size=None, **traits): AbstractWindow.__init__(self, **traits) self._mouse_captured = False if isinstance(parent, QtGui.QLayout): parent = parent.parentWidget() self.control = self._create_control(parent, self) if pos is not None: self.control.move(*pos) if size is not None: self.control.resize(*size) #------------------------------------------------------------------------ # Implementations of abstract methods in AbstractWindow #------------------------------------------------------------------------ def set_drag_result(self, result): if result not in DRAG_RESULTS_MAP: raise RuntimeError("Unknown drag result '%s'" % result) self._drag_result = DRAG_RESULTS_MAP[result] return def _capture_mouse ( self ): "Capture all future mouse events" # Nothing needed with Qt. pass def _release_mouse ( self ): "Release the mouse capture" # Nothing needed with Qt. pass def _create_key_event(self, event_type, event): focus_owner = self.focus_owner if focus_owner is None: focus_owner = self.component if focus_owner is None: event.ignore() return None if event_type == 'character': key = unicode(event.text()) else: # Convert the keypress to a standard enable key if possible, otherwise # to text. key_code = event.key() key = KEY_MAP.get(key_code) if key is None: key = unichr(key_code).lower() if not key: return None # Use the last-seen mouse position as the coordinates of this event. x, y = self.control.handler.last_mouse_pos modifiers = event.modifiers() return KeyEvent(event_type=event_type, character=key, x=x, y=self._flip_y(y), alt_down=bool(modifiers & QtCore.Qt.AltModifier), shift_down=bool(modifiers & QtCore.Qt.ShiftModifier), control_down=bool(modifiers & QtCore.Qt.ControlModifier), event=event, window=self) def _create_mouse_event(self, event): # If the control no longer exists, don't send mouse event if self.control is None: return None # If the event (if there is one) doesn't contain the mouse position, # modifiers and buttons then get sensible defaults. try: x = event.x() y = event.y() modifiers = event.modifiers() buttons = event.buttons() except AttributeError: pos = self.control.mapFromGlobal(QtGui.QCursor.pos()) x = pos.x() y = pos.y() modifiers = 0 buttons = 0 self.control.handler.last_mouse_pos = (x, y) # A bit crap, because AbstractWindow was written with wx in mind, and # we treat wheel events like mouse events. if isinstance(event, QtGui.QWheelEvent): delta = event.delta() degrees_per_step = 15.0 mouse_wheel = delta / float(8 * degrees_per_step) else: mouse_wheel = 0 return MouseEvent(x=x, y=self._flip_y(y), mouse_wheel=mouse_wheel, alt_down=bool(modifiers & QtCore.Qt.AltModifier), shift_down=bool(modifiers & QtCore.Qt.ShiftModifier), control_down=bool(modifiers & QtCore.Qt.ControlModifier), left_down=bool(buttons & QtCore.Qt.LeftButton), middle_down=bool(buttons & QtCore.Qt.MidButton), right_down=bool(buttons & QtCore.Qt.RightButton), window=self) def _create_drag_event(self, event): # If the control no longer exists, don't send mouse event if self.control is None: return None # If the event (if there is one) doesn't contain the mouse position, # modifiers and buttons then get sensible defaults. try: x = event.x() y = event.y() except AttributeError: pos = self.control.mapFromGlobal(QtGui.QCursor.pos()) x = pos.x() y = pos.y() self.control.handler.last_mouse_pos = (x, y) # extract an object from the event, if we can try: mimedata = event.mimeData() copy = event.proposedAction() == QtCore.Qt.CopyAction except AttributeError: # this is a DragLeave event return DragEvent(x=x, y=self._flip_y(y), obj=None, copy=False, window=self, mimedata=None) try: from traitsui.qt4.clipboard import PyMimeData except ImportError: # traitsui isn't available, just make mimedata available on event obj = None else: mimedata = PyMimeData.coerce(mimedata) obj = mimedata.instance() if obj is None: files = mimedata.localPaths() if files: try: # try to extract file info from mimedata # XXX this is for compatibility with what wx does from apptools.io.api import File obj = [File(path=path) for path in files] except ImportError: pass return DragEvent(x=x, y=self._flip_y(y), obj=obj, copy=copy, window=self, mimedata=mimedata) def _redraw(self, coordinates=None): if self.control: if self.control.handler.in_paint_event: # Code further up the stack is behaving badly and calling # request_redraw() inside drawing code. return if coordinates is None: self.control.update() else: self.control.update(*coordinates) def _get_control_size(self): if self.control: return (self.control.width(), self.control.height()) return None def _create_gc(self, size, pix_format="bgra32"): raise NotImplementedError def _window_paint(self, event): raise NotImplementedError def set_pointer(self, pointer): self.control.setCursor(POINTER_MAP[pointer]) def _set_timer_interval(self, component, interval): # FIXME raise NotImplementedError def set_tooltip(self, tooltip): self.control.setToolTip(tooltip) def _set_focus(self): self.control.setFocus() def _on_key_pressed(self, event): return self._handle_key_event('key_pressed', event) def get_pointer_position(self): pos = self.control.mapFromGlobal(QtGui.QCursor.pos()) x = pos.x() y = self._flip_y(pos.y()) return x, y #------------------------------------------------------------------------ # Private methods #------------------------------------------------------------------------ def _flip_y(self, y): "Converts between a Kiva and a Qt y coordinate" return int(self._size[1] - y - 1) class BaseGLWindow(_Window): # The toolkit control control = Instance(_QtGLWindow) def _create_control(self, parent, enable_window): """ Create the toolkit control. """ return _QtGLWindow(parent, enable_window) class BaseWindow(_Window): # The toolkit control control = Instance(_QtWindow) def _create_control(self, parent, enable_window): """ Create the toolkit control. """ return _QtWindow(parent, enable_window) enthought-chaco2-4.5.1.orig/enable/qt4/constants.py0000644000175000017500000001076712516137326021237 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ from __future__ import absolute_import import warnings from pyface.qt import QtCore from ..toolkit_constants import key_names, pointer_names DRAG_RESULTS_MAP = { "error": QtCore.Qt.IgnoreAction, "none": QtCore.Qt.IgnoreAction, "copy": QtCore.Qt.CopyAction, "move": QtCore.Qt.MoveAction, "link": QtCore.Qt.LinkAction, "cancel": QtCore.Qt.IgnoreAction } BUTTON_NAME_MAP = { QtCore.Qt.LeftButton: "left", QtCore.Qt.RightButton: "right", QtCore.Qt.MidButton: "middle", } # TODO: Create bitmap cursor for the following: # arrow wait # bullseye # char # magnifier # paint brush # pencil # point left # point right # right arrow # spray can pointer_shapes = [ QtCore.Qt.ArrowCursor, QtCore.Qt.BusyCursor, QtCore.Qt.BlankCursor, QtCore.Qt.CrossCursor, QtCore.Qt.IBeamCursor, QtCore.Qt.CrossCursor, QtCore.Qt.PointingHandCursor, QtCore.Qt.IBeamCursor, QtCore.Qt.ArrowCursor, QtCore.Qt.CrossCursor, QtCore.Qt.ArrowCursor, QtCore.Qt.ForbiddenCursor, QtCore.Qt.ArrowCursor, QtCore.Qt.CrossCursor, QtCore.Qt.ArrowCursor, QtCore.Qt.ArrowCursor, QtCore.Qt.WhatsThisCursor, QtCore.Qt.ArrowCursor, QtCore.Qt.ArrowCursor, QtCore.Qt.SizeVerCursor, QtCore.Qt.SizeBDiagCursor, QtCore.Qt.SizeFDiagCursor, QtCore.Qt.SizeHorCursor, QtCore.Qt.SizeHorCursor, QtCore.Qt.SizeVerCursor, QtCore.Qt.SizeFDiagCursor, QtCore.Qt.SizeBDiagCursor, QtCore.Qt.SizeAllCursor, QtCore.Qt.CrossCursor, QtCore.Qt.WaitCursor, QtCore.Qt.BusyCursor, ] if len(pointer_names) != len(pointer_shapes): warnings.warn("The Qt4 toolkit backend pointer map is out of sync!") POINTER_MAP = dict(zip(pointer_names, pointer_shapes)) KEY_MAP = { QtCore.Qt.Key_Backspace: 'Backspace', QtCore.Qt.Key_Cancel: 'Cancel', QtCore.Qt.Key_CapsLock: 'Capital', QtCore.Qt.Key_Clear: 'Clear', QtCore.Qt.Key_Control: 'Control', QtCore.Qt.Key_Delete: 'Delete', QtCore.Qt.Key_Down: 'Down', QtCore.Qt.Key_End: 'End', QtCore.Qt.Key_Return: 'Enter', QtCore.Qt.Key_Enter: 'Enter', QtCore.Qt.Key_Escape: 'Esc', QtCore.Qt.Key_Execute: 'Execute', QtCore.Qt.Key_F1: 'F1', QtCore.Qt.Key_F10: 'F10', QtCore.Qt.Key_F11: 'F11', QtCore.Qt.Key_F12: 'F12', QtCore.Qt.Key_F13: 'F13', QtCore.Qt.Key_F14: 'F14', QtCore.Qt.Key_F15: 'F15', QtCore.Qt.Key_F16: 'F16', QtCore.Qt.Key_F17: 'F17', QtCore.Qt.Key_F18: 'F18', QtCore.Qt.Key_F19: 'F19', QtCore.Qt.Key_F2: 'F2', QtCore.Qt.Key_F20: 'F20', QtCore.Qt.Key_F21: 'F21', QtCore.Qt.Key_F22: 'F22', QtCore.Qt.Key_F23: 'F23', QtCore.Qt.Key_F24: 'F24', QtCore.Qt.Key_F3: 'F3', QtCore.Qt.Key_F4: 'F4', QtCore.Qt.Key_F5: 'F5', QtCore.Qt.Key_F6: 'F6', QtCore.Qt.Key_F7: 'F7', QtCore.Qt.Key_F8: 'F8', QtCore.Qt.Key_F9: 'F9', QtCore.Qt.Key_Help: 'Help', QtCore.Qt.Key_Home: 'Home', QtCore.Qt.Key_Insert: 'Insert', QtCore.Qt.Key_Left: 'Left', QtCore.Qt.Key_Meta: 'Menu', QtCore.Qt.Key_Asterisk: 'Multiply', QtCore.Qt.Key_NumLock: 'Num Lock', QtCore.Qt.Key_PageDown: 'Page Down', QtCore.Qt.Key_PageUp: 'Page Up', QtCore.Qt.Key_Pause: 'Pause', QtCore.Qt.Key_Print: 'Print', QtCore.Qt.Key_Right: 'Right', QtCore.Qt.Key_ScrollLock: 'Scroll Lock', QtCore.Qt.Key_Select: 'Select', QtCore.Qt.Key_Shift: 'Shift', QtCore.Qt.Key_Tab: 'Tab', QtCore.Qt.Key_Up: 'Up', QtCore.Qt.Key_Alt: 'Alt', } # Add all of the other keys registered by Qt. # This should work for both PySide and PyQt4. for enum_name in dir(QtCore.Qt): if enum_name.startswith('Key_'): enum = getattr(QtCore.Qt, enum_name) # Ignore everything in latin-1 as we just want the unichr() conversion. if enum <= 255 or enum in KEY_MAP: continue key_name = enum_name[len('Key_'):] KEY_MAP[enum] = key_name enthought-chaco2-4.5.1.orig/enable/qt4/cairo.py0000644000175000017500000000254512516137326020313 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ from pyface.qt import QtCore, QtGui from kiva.cairo import CompiledPath, GraphicsContext, font_metrics_provider from base_window import BaseWindow from scrollbar import NativeScrollBar class Window(BaseWindow): def _create_gc(self, size, pix_format="bgra32"): gc = GraphicsContext((size[0]+1, size[1]+1)) gc.translate_ctm(0.5, 0.5) return gc def _window_paint(self, event): if self.control is None: return # self._gc is an image context w = self._gc.width() h = self._gc.height() data = self._gc.pixel_map.convert_to_argbarray() image = QtGui.QImage(data, w, h, QtGui.QImage.Format_ARGB32) rect = QtCore.QRect(0,0,w,h) painter = QtGui.QPainter(self.control) painter.drawImage(rect, image) # EOF enthought-chaco2-4.5.1.orig/enable/savage/0000755000175000017500000000000012516137725017377 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/__init__.py0000644000175000017500000000053712516137326021512 0ustar varunvarun#----------------------------------------------------------------------------- # # Copyright (c) 2008 by Enthought, Inc. # All rights reserved. # #----------------------------------------------------------------------------- """ A rendering toolkit for scalable vector graphics (SVG). Part of the Enable project of the Enthought Tool Suite. """ enthought-chaco2-4.5.1.orig/enable/savage/trait_defs/0000755000175000017500000000000012516137725021523 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/trait_defs/__init__.py0000644000175000017500000000000012516137326023617 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/0000755000175000017500000000000012516137725022140 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/__init__.py0000644000175000017500000000000012516137326024234 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/svg_button_editor.py0000644000175000017500000000635212516137326026255 0ustar varunvarun#------------------------------------------------------------------------------ # # Copyright (c) 2009, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! # #------------------------------------------------------------------------------ """ Traits UI button editor for SVG images. """ #------------------------------------------------------------------------------- # Imports: #------------------------------------------------------------------------------- from enable.savage.trait_defs.ui.toolkit import toolkit_object from traits.api import Bool, Enum, Int, Property, Range, Str, Any from traitsui.api import View from traitsui.basic_editor_factory import BasicEditorFactory from traitsui.ui_traits import AView #------------------------------------------------------------------------------- # 'SVGEditor' editor factory class: #------------------------------------------------------------------------------- class SVGButtonEditor(BasicEditorFactory): # The editor class to be created klass = Property # Value to set when the button is clicked value = Property label = Str filename = Str # Extra padding to add to both the left and the right sides width_padding = Range( 0, 31, 3 ) # Extra padding to add to both the top and the bottom sides height_padding = Range( 0, 31, 3 ) # Presentation style style = Enum( 'button', 'radio', 'toolbar', 'checkbox' ) # Orientation of the text relative to the image orientation = Enum( 'vertical', 'horizontal' ) # The optional view to display when the button is clicked: view = AView width = Int(32) height = Int(32) tooltip = Str toggle = Bool(True) # the toggle state displayed toggle_state = Bool(False) # a file holding the image to display when toggled toggle_filename = Any toggle_label = Str toggle_tooltip = Str traits_view = View( [ 'value', '|[]' ] ) #--------------------------------------------------------------------------- # object API #--------------------------------------------------------------------------- def __init__ ( self, **traits ): self._value = 0 super( SVGButtonEditor, self ).__init__( **traits) #--------------------------------------------------------------------------- # Traits properties #--------------------------------------------------------------------------- def _get_klass(self): """ Returns the toolkit-specific editor class to be instantiated. """ return toolkit_object('svg_button_editor:SVGButtonEditor') def _get_value ( self ): return self._value def _set_value ( self, value ): self._value = value if isinstance(value, basestring): try: self._value = int( value ) except: try: self._value = float( value ) except: pass enthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/api.py0000644000175000017500000000160612516137326023263 0ustar varunvarun#------------------------------------------------------------------------------ # # Copyright (c) 2009, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! # # Author: Evan Patterson # Date: 06/24/2009 # #------------------------------------------------------------------------------ """ Exports the symbols defined by the savage.traits.ui package. """ #------------------------------------------------------------------------------- # Imports: #------------------------------------------------------------------------------- from svg_editor import SVGEditor enthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/wx/0000755000175000017500000000000012516137725022576 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/wx/__init__.py0000644000175000017500000000000012516137326024672 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/wx/svg_button_editor.py0000644000175000017500000002222612516137326026711 0ustar varunvarun#------------------------------------------------------------------------------ # # Copyright (c) 2009, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! # #------------------------------------------------------------------------------ """ Traits UI button editor for SVG images. """ # Standard library imports import copy import sys import xml.etree.cElementTree as etree import os.path # System library imports import wx # ETS imports from enable.savage.svg.document import SVGDocument from enable.savage.svg.backends.wx.renderer import Renderer from traits.api import Instance from traitsui.wx.constants import WindowColor from traitsui.wx.editor import Editor # Local imports from wx_render_panel import RenderPanel class ButtonRenderPanel(RenderPanel): def __init__(self, parent, button, padding=(8,8)): self.button = button self.document = button.document self.state = 'up' self.toggle_document = button.toggle_document self.toggle_state = button.factory.toggle_state self.padding = padding super(ButtonRenderPanel, self).__init__(parent, document=self.document) def DoGetBestSize(self): label = self.button.factory.label if len(label): dc = wx.ScreenDC() dc.SetFont(wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)) label_size = dc.GetTextExtent(label) else: label_size = (0, 0) width = max(self.button.factory.width, label_size[0]) height = self.button.factory.height + label_size[1] return wx.Size(width + self.padding[0], height + self.padding[1]) def GetBackgroundColour(self): bgcolor = copy.copy(WindowColor) if self.state == 'down': red, green, blue = bgcolor.Get() red -= 15 green -= 15 blue -= 15 bgcolor.Set(red, green, blue, 255) return bgcolor def OnPaint(self, evt): dc = wx.BufferedPaintDC(self) dc.SetBackground(wx.Brush(self.GetBackgroundColour())) dc.Clear() dc.SetFont(wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)) gc = wx.GraphicsContext_Create(dc) if self.toggle_state and self.button.factory.toggle and \ not self.button.factory.toggle_filename: self._draw_toggle(gc) # Put the icon in the middle of the alotted space. If the text is wider # than the icon, then the best_size will be wider, in which case we # want to put the icon in a little bit more towards the center, # otherwise, the icon will be drawn starting after the left padding. best_size = self.DoGetBestSize() x_offset = (best_size.width - self.button.factory.width)/2.0 y_offset = self.padding[1] / 2.0 gc.Translate(x_offset, y_offset) gc.Scale(float(self.zoom_x) / 100, float(self.zoom_y) / 100) if self.toggle_state and self.button.factory.toggle and \ self.button.factory.toggle_filename: self.toggle_document.render(gc) label_text = self.button.factory.toggle_label else: self.document.render(gc) label_text = self.button.factory.label # Reset the translation and zoom, then draw the text at an offset # based on the text width. There is a minor gotcha for supporting # multiple platforms here, Translate and DrawText behave differently # on different platforms. # It would be nice is a cross platform library actually worked the # same across platforms... text_width = dc.GetTextExtent(label_text)[0] text_x = (best_size.width - text_width)/2.0 text_y = self.button.factory.height gc.Scale(100/float(self.zoom_x), 100/float(self.zoom_y)) if sys.platform == 'darwin': gc.Translate(-x_offset + text_x, -y_offset + text_y) dc.DrawText(label_text, 0, 0) else: gc.Translate(-x_offset, -y_offset) dc.DrawText(label_text, text_x, text_y) if not self.button.enabled: self._draw_disable_mask(gc) def OnLeftDown(self, evt): # if the button is supposed to toggle, set the toggle_state # to the opposite of what it currently is if self.button.factory.toggle: self.toggle_state = not self.toggle_state if self.toggle_state: tooltip = wx.ToolTip(self.button.factory.toggle_tooltip) else: tooltip = wx.ToolTip(self.button.factory.tooltip) self.button.control.SetToolTip(tooltip) self.state = 'down' evt.Skip() self.Refresh() def OnLeftUp(self, evt): self.state = 'up' self.button.update_editor() evt.Skip() self.Refresh() def OnEnterWindow(self, evt): self.hover = True self.Refresh() def OnLeaveWindow(self, evt): self.hover = False self.Refresh() def OnWheel(self, evt): pass def _draw_disable_mask(self, gc): """ Draws a mask using the background color with the alpha set to about 33% """ best_size = self.DoGetBestSize() path = gc.CreatePath() path.AddRectangle(0, 0, best_size.width, best_size.height) bgcolor = self.GetBackgroundColour() bgcolor.Set(bgcolor.red, bgcolor.green, bgcolor.blue, 175) gc.SetBrush(wx.Brush(bgcolor)) gc.FillPath(path) def _draw_toggle(self, gc): # the toggle doc and button doc may not be the same # size, so calculate the scaling factor. Byt using the padding # to lie about the size of the toggle button, we can grow the # toggle a bit to use some of the padding. This is good for icons # which use all of their available space zoom_scale_x = float(self.zoom_x) / 100 zoom_scale_y = float(self.zoom_y) / 100 doc_size = self.document.getSize() toggle_doc_size = self.toggle_document.getSize() w_scale = zoom_scale_x * doc_size[0] / (toggle_doc_size[0]-self.padding[0]-1) h_scale = zoom_scale_y * doc_size[1] / (toggle_doc_size[1]-self.padding[1]-1) # move to the center of the allotted area best_size = self.DoGetBestSize() x_offset = (best_size.width - self.button.factory.width)/2.0 y_offset = self.padding[1] / 2.0 gc.Translate(x_offset, y_offset) # Now scale the gc and render gc.Scale(w_scale, h_scale) self.toggle_document.render(gc) # And return the scaling factor back to what it originally was # and return to the origial location gc.Scale(1/w_scale, 1/h_scale) gc.Translate(-x_offset, -y_offset) class SVGButtonEditor ( Editor ): """ Traits UI 'display only' image editor. """ document = Instance(SVGDocument) toggle_document = Instance(SVGDocument) #--------------------------------------------------------------------------- # Editor API #--------------------------------------------------------------------------- def init ( self, parent ): """ Finishes initializing the editor by creating the underlying toolkit widget. """ self.document = SVGDocument.createFromFile(self.factory.filename, renderer=Renderer) # load the button toggle document which will be displayed when the # button is toggled. if self.factory.toggle_filename: self.toggle_document = SVGDocument.createFromFile(self.factory.toggle_filename, renderer=Renderer) else: tree = etree.parse(os.path.join(os.path.dirname(__file__), 'data', 'button_toggle.svg')) self.toggle_document = SVGDocument(tree.getroot(), renderer=Renderer) padding = (self.factory.width_padding, self.factory.height_padding) self.control = ButtonRenderPanel( parent, self, padding=padding ) if self.factory.tooltip != '': self.control.SetToolTip(wx.ToolTip(self.factory.tooltip)) svg_w, svg_h = self.control.GetBestSize() self.control.zoom_x /= float(svg_w) / self.factory.width self.control.zoom_y /= float(svg_h) / self.factory.height self.control.Refresh() def prepare ( self, parent ): """ Finishes setting up the editor. This differs from the base class in that self.update_editor() is not called at the end, which would fire an event. """ name = self.extended_name if name != 'None': self.context_object.on_trait_change( self._update_editor, name, dispatch = 'ui' ) self.init( parent ) self._sync_values() def update_editor ( self ): """ Updates the editor when the object trait changes externally to the editor. """ factory = self.factory self.value = factory.value enthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/wx/kiva_render_panel.py0000644000175000017500000000310712516137326026616 0ustar varunvarunimport wx from enable.savage.svg.backends.kiva import renderer from enable.savage.svg.document import SVGDocument from enable.api import Container, Window from traits.api import Instance, Float class KivaContainer(Container): document = Instance(SVGDocument) zoom = Float(100.0) def draw(self, gc, view_bounds=None, mode="default"): gc.clear() if not self.document: gc.show_text_at_point("No Document", 20, 20) return with gc: # SVG origin is upper right with y positive is down. argh. # Set up the transforms to fix this up. gc.translate_ctm(0, gc.height()) # zoom percentage scale = float(self.zoom) / 100.0 gc.scale_ctm(scale, -scale) self.document.render(gc) class RenderPanel(wx.Window): def __init__(self, parent, document=None): super(RenderPanel, self).__init__(parent) self.document = document if self.document is not None: self.document.renderer = renderer self.container = KivaContainer(document=self.document) size = wx.Size(200,200) if document is not None: size = document.getSize() self._window = Window( parent=self, size=size, component=self.container ) self.control = self._window.control self._parent = parent self.SetBackgroundColour([int(255*c) for c in self.container.bgcolor_]) def GetBestSize(self): if not self.document: return (-1,-1) return self.document.getSize() enthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/wx/svg_editor.py0000644000175000017500000000521112516137326025311 0ustar varunvarun#------------------------------------------------------------------------------- # # Copyright (c) 2008, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! # # Author: Bryce Hendrix # Date: 08/06/2008 # #------------------------------------------------------------------------------- """ Traits UI 'display only' SVG editor. """ #------------------------------------------------------------------------------- # Imports: #------------------------------------------------------------------------------- from traitsui.wx.editor import Editor from enable.savage.svg.backends.wx.renderer import Renderer as WxRenderer from enable.savage.svg.backends.kiva.renderer import Renderer as KivaRenderer from kiva_render_panel import RenderPanel as KivaRenderPanel from wx_render_panel import RenderPanel as WxRenderPanel #------------------------------------------------------------------------------- # 'SVGEditor' class: #------------------------------------------------------------------------------- class SVGEditor(Editor): """ Traits UI 'display only' SVG editor. """ scrollable = True #--------------------------------------------------------------------------- # Finishes initializing the editor by creating the underlying toolkit # widget: #--------------------------------------------------------------------------- def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ document = self.value # TODO: the document should not know about the renderer, this should # be an attribute of the editor if document.renderer == WxRenderer: self.control = WxRenderPanel(parent, document=document) else: self.control = KivaRenderPanel(parent, document=document) #--------------------------------------------------------------------------- # Updates the editor when the object trait changes external to the editor: #--------------------------------------------------------------------------- def update_editor(self): """ Updates the editor when the object trait changes externally to the editor. """ if self.control.document != self.value: self.control.document = self.value self.control.Refresh() enthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/wx/wx_render_panel.py0000644000175000017500000000472712516137326026333 0ustar varunvarunimport time import wx from enable.savage.svg.backends.wx import renderer from traitsui.wx.constants import WindowColor class RenderPanel(wx.PyPanel): def __init__(self, parent, document=None): wx.PyPanel.__init__(self, parent) self.lastRender = None self.document = document self.zoom_x = 100 self.zoom_y = 100 self.offset = wx.Point(0,0) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_MOUSEWHEEL, self.OnWheel) self.Bind(wx.EVT_MOTION, self.OnMotion) self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) self.Bind(wx.EVT_MIDDLE_UP, self.OnMiddleClick) self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterWindow) self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveWindow) def OnPaint(self, evt): start = time.time() dc = wx.BufferedPaintDC(self) dc.SetBackground(wx.Brush(self.GetBackgroundColour())) dc.Clear() if not self.document: dc.DrawText("No Document", 20, 20) return gc = wx.GraphicsContext_Create(dc) gc.Translate(*self.offset) gc.Scale(float(self.zoom_x) / 100, float(self.zoom_y) / 100) self.document.render(gc) self.lastRender = time.time() - start def GetBackgroundColour(self): return WindowColor def GetBestSize(self): if not self.document: return (-1,-1) return wx.Size(*(self.document.getSize())) def OnWheel(self, evt): delta = (evt.m_wheelRotation / evt.m_wheelDelta) * 10 self.zoom_x += delta self.zoom_y += delta self.Refresh() def OnLeftDown(self, evt): self.SetCursor(wx.StockCursor(wx.CURSOR_HAND)) self.CaptureMouse() self.offsetFrom = evt.GetPosition() evt.Skip() def OnLeftUp(self, evt): if self.HasCapture(): self.ReleaseMouse() self.SetCursor(wx.NullCursor) evt.Skip() def OnMotion(self, evt): if not self.HasCapture(): return self.offset += (evt.GetPosition() - self.offsetFrom) self.offsetFrom = evt.GetPosition() self.Refresh() def OnMiddleClick(self, evt): self.offset = wx.Point(0,0) self.zoom_x = 100 self.zoom_y = 100 self.Refresh() def OnEnterWindow(self, evt): pass def OnLeaveWindow(self, evt): pass enthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/wx/data/0000755000175000017500000000000012516137725023507 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/wx/data/button_toggle.svg0000644000175000017500000000506512516137326027107 0ustar varunvarun image/svg+xml enthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/toolkit.py0000644000175000017500000000446012516137326024200 0ustar varunvarun#------------------------------------------------------------------------------- # # Copyright (c) 2009, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! # #------------------------------------------------------------------------------- # Standard library imports import sys # ETS imports from traits.etsconfig.api import ETSConfig def _init_toolkit(): """ Initialise the current toolkit. """ # Force Traits to decide on its toolkit if it hasn't already from traitsui.toolkit import toolkit as traits_toolkit traits_toolkit() # Import the selected backend backend = 'enable.savage.trait_defs.ui.%s' % ETSConfig.toolkit try: __import__(backend) except ImportError, SystemExit: raise ImportError, "Unable to import a Savage backend for the %s " \ "toolkit." % ETSConfig.toolkit # Save the imported toolkit module. global _toolkit_backend _toolkit_backend = backend # Do this once then disappear. _init_toolkit() del _init_toolkit def toolkit_object(name, raise_exceptions=False): """ Return the toolkit specific object with the given name. The name consists of the relative module path and the object name separated by a colon. """ mname, oname = name.split(':') class Unimplemented (object): """ This is returned if an object isn't implemented by the selected toolkit. It raises an exception if it is ever instantiated. """ def __init__(self, *args, **kwargs): raise NotImplementedError("The %s Savage backend doesn't implement" "%s" % (ETSConfig.toolkit, oname)) be_obj = Unimplemented be_mname = _toolkit_backend + '.' + mname try: __import__(be_mname) try: be_obj = getattr(sys.modules[be_mname], oname) except AttributeError, e: if raise_exceptions: raise e except ImportError, e: if raise_exceptions: raise e return be_obj enthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/qt4/0000755000175000017500000000000012516137725022650 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/qt4/__init__.py0000644000175000017500000000000012516137326024744 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/qt4/svg_button_editor.py0000644000175000017500000001067512516137326026770 0ustar varunvarun#------------------------------------------------------------------------------- # # Copyright (c) 2008, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! # # Author: Evan Patterson # Date: 06/24/2000 # #------------------------------------------------------------------------------- """ Traits UI button editor for SVG images. """ #------------------------------------------------------------------------------- # Imports: #------------------------------------------------------------------------------- import os.path from traits.api import Bool, Any, Str from traitsui.qt4.editor import Editor from pyface.qt import QtCore, QtGui # add the Qt's installed dir plugins to the library path so the iconengines # plugin will be found: qt_plugins_dir = os.path.join(os.path.dirname(QtCore.__file__), 'plugins') QtCore.QCoreApplication.addLibraryPath(qt_plugins_dir) #------------------------------------------------------------------------------- # 'SVGButtonEditor' class: #------------------------------------------------------------------------------- class SVGButtonEditor(Editor): icon = Any toggled_icon = Any toggle_label = Str toggle_tooltip = Str toggle_state = Bool #--------------------------------------------------------------------------- # Editor interface #--------------------------------------------------------------------------- def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ self.icon = QtGui.QIcon(self.factory.filename) if self.factory.toggle_filename: self.toggled_icon = QtGui.QIcon(self.factory.toggle_filename) if self.factory.toggle_label != '': self.toggle_label = self.factory.toggle_label else: self.toggle_label = self.factory.label if self.factory.toggle_tooltip != '': self.toggle_tooltip = self.factory.toggle_tooltip else: self.toggle_tooltip = self.factory.tooltip control = self.control = QtGui.QToolButton() control.setAutoRaise(True) control.setIcon(self.icon) control.setText(self.factory.label) control.setIconSize(QtCore.QSize(self.factory.width, self.factory.height)) if self.factory.label: control.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon) else: control.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly) if self.factory.toggle: control.setCheckable(True) control.toggled.connect(self._toggle_button) QtCore.QObject.connect(control, QtCore.SIGNAL('clicked()'), self.update_object) if self.factory.tooltip: control.setToolTip(self.factory.tooltip) else: self.set_tooltip() def prepare(self, parent): """ Finishes setting up the editor. This differs from the base class in that self.update_editor() is not called at the end, which would fire an event. """ name = self.extended_name if name != 'None': self.context_object.on_trait_change(self._update_editor, name, dispatch = 'ui') self.init(parent) self._sync_values() def update_object (self): """ Handles the user clicking the button by setting the factory value on the object. """ self.value = self.factory.value def update_editor(self): """ Updates the editor when the object trait changes externally to the editor. """ pass def _toggle_button(self): self.toggle_state = not self.toggle_state if self.toggle_state and self.toggled_icon: self.control.setIcon(self.toggled_icon) self.control.setText(self.toggle_label) self.control.setToolTip(self.toggle_tooltip) elif not self.toggle_state and self.toggled_icon: self.control.setIcon(self.icon) self.control.setText(self.factory.label) self.control.setToolTip(self.factory.tooltip) enthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/qt4/svg_editor.py0000644000175000017500000000455412516137326025374 0ustar varunvarun#------------------------------------------------------------------------------ # # Copyright (c) 2009, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! # # Author: Evan Patterson # Date: 06/24/2009 # #------------------------------------------------------------------------------ """ Traits UI 'display only' SVG editor. """ #------------------------------------------------------------------------------- # Imports: #------------------------------------------------------------------------------- from cStringIO import StringIO from xml.etree.cElementTree import ElementTree from enable.savage.svg.document import SVGDocument from traitsui.qt4.editor import Editor from pyface.qt import QtCore, QtSvg #------------------------------------------------------------------------------- # 'SVGEditor' class: #------------------------------------------------------------------------------- class SVGEditor(Editor): """ Traits UI 'display only' SVG editor. """ scrollable = True #--------------------------------------------------------------------------- # Finishes initializing the editor by creating the underlying toolkit # widget: #--------------------------------------------------------------------------- def init(self, parent): """ Finishes initializing the editor by creating the underlying toolkit widget. """ self.control = QtSvg.QSvgWidget() #--------------------------------------------------------------------------- # Updates the editor when the object trait changes external to the editor: #--------------------------------------------------------------------------- def update_editor(self): """ Updates the editor when the object trait changes externally to the editor. """ value = self.value if isinstance(value, SVGDocument): string_io = StringIO() ElementTree(value.tree).write(string_io) value = string_io.getvalue() self.control.load(QtCore.QByteArray(value)) enthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/svg_button.py0000644000175000017500000000712112516137326024702 0ustar varunvarun#------------------------------------------------------------------------------ # # Copyright (c) 2009, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! # #------------------------------------------------------------------------------ # ETS imports from traits.api import Event # Local imports from svg_button_editor import SVGButtonEditor class SVGButton ( Event ): """ Defines a trait whose UI editor is a button. """ def __init__ ( self, label = '', filename = None, tooltip = '', toggle=False, toggle_state=False, toggle_filename=None, toggle_label='', toggle_tooltip='', width = 32, height = 32, orientation = 'vertical', width_padding = 4, height_padding = 1, view = None, **metadata ): """ Returns a trait event whose editor is a button. Parameters ---------- label : string The label for the button filename : string Path to SVG file to be displayed on the button orientation : one of: 'horizontal', 'vertical' The orientation of the label relative to the image width_padding : integer between 0 and 31 Extra padding (in pixels) added to the left and right sides of the button height_padding : integer between 0 and 31 Extra padding (in pixels) added to the top and bottom of the button tooltip : string What to display when the mouse hovers over the button. An empty string implies no tooltip toggle : boolean Whether the button is a toggle with 2 states, or a regular button with 1 state toggle_filename : string Path to SVG file to be displayed on the button toggle_label: Label to display when button is in toggled state toggle_tooltip: Tooltip to display when button is in toggled state Default Value ------------- No default value because events do not store values. """ self.editor = SVGButtonEditor( label = label, filename = filename, tooltip = tooltip, toggle = toggle, toggle_state = toggle_state, toggle_filename= toggle_filename, toggle_tooltip = toggle_tooltip, toggle_label = toggle_label, orientation = orientation, width_padding = width_padding, height_padding = height_padding, width = width, height = height, view = view ) super( SVGButton, self ).__init__( **metadata ) enthought-chaco2-4.5.1.orig/enable/savage/trait_defs/ui/svg_editor.py0000644000175000017500000000267412516137326024665 0ustar varunvarun#------------------------------------------------------------------------------ # # Copyright (c) 2009, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! # # Author: Evan Patterson # Date: 06/24/2009 # #------------------------------------------------------------------------------ """ Traits UI 'display only' SVG editor. """ #------------------------------------------------------------------------------- # Imports: #------------------------------------------------------------------------------- from enable.savage.trait_defs.ui.toolkit import toolkit_object from traits.api import Property from traitsui.basic_editor_factory import BasicEditorFactory #------------------------------------------------------------------------------- # 'SVGEditor' editor factory class: #------------------------------------------------------------------------------- class SVGEditor(BasicEditorFactory): # The editor class to be created: klass = Property def _get_klass(self): """ Returns the toolkit-specific editor class to be instantiated. """ return toolkit_object('svg_editor:SVGEditor') enthought-chaco2-4.5.1.orig/enable/savage/compliance/0000755000175000017500000000000012516137725021511 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/compliance/images/0000755000175000017500000000000012516137725022756 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/compliance/images/default.png0000644000175000017500000002133712516137326025113 0ustar varunvarun‰PNG  IHDR€à5ÑÜä pHYs  šœ IDATxœíÝyUõðá/4Á ­,Í.ƒËTŒ‘hp0nCbŒ£!¢“ÂÑRŒŽEœ¤fDSET4Q‚QT0Û¸ÍR€Æ jÔÁ- ¢ ¢”Uiixÿð¥‹Û·^é†ïóTu•÷Ü{Ïýqª=÷Ó÷Üó;-¶nݺ5H£eS€ÝK$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É´jêÀ67nŒ5kÖÄš5kbýúõqÀDÇŽ£¬¬,Zµò– e¯û¿iÙ²eñÌ3Ï-?þøã£[·nõZ÷k¯½/¿üråí-ZÄ9çœS¯uR;åååñÈ#ÄÒ¥Kã­·ÞŠeË–ÅæÍ›ãßøFœþùM=<¨4k֬ظqcž[RRݺu‹ž={F—.]¢eËÚ¬ÙÓöƒ¯¼òJ<ùä“ñôÓOÇ믿¾Ãǵoß>>÷¹ÏÅé§ŸÇ|´nݺ^¯ ™íu¸hÑ¢øéOZ´|Þ¼y1iÒ¤z­û…^ˆÉ“'WÞ.))€»Ñ²eËbüøñ±xñâ¢ûÖ­[×#‚›:uj¬ZµªÞëiݺuôìÙ3¾õ­oÅàÁƒkôœ=e?¸pá¸ýöÛ ‚rgÖ¬YO=õT<õÔSQZZƒŽáÇGçÎëôúYšï¾ð 1{öì¦u´nݺ1bDµñ{³òòòX¼xqŒ?>®¹æšxóÍ7ë¼®æ²,//‰'Æe—]Vãø«êÃ?Œ3fÄÅ_sæÌiàÂÞ/MFDLž<Ù'E{¨Ù³gdž ª½oŸ}öÙÍ£¦1þü¸øâ‹ëMM¿üðÃã_þå_bæÌ™;|LëÖ­£k׮ѫW¯hß¾ý.×7a„˜2eJCöj{Ý!àY·n]L™2%¾ûÝï6õP¨¥ ÜnÓ¦MŒ;6¾ð…/Äg?ûÙ&Ô\‡bРA»|ܦM›býúõñÞ{ïÅ¢E‹bëÖ­÷WTTÄøÃ˜:uj´iÓ¦ÖãhÊýà|£FŠ%K–Ý×¶mÛ8óÌ3㤓NŠÃ;,Z´hQy_yyy¬\¹2^~ùåxøá‡«=ð›ßü&ºuë_ÿú×õß{‹TñÈ#ÄßÿýßÇQGÕÔC¡V¬XQp{àÀqüñÇ7Ñh ö<ðÀøÎw¾S«ç¬]»6î¿ÿþøÕ¯~U°üÝwß)S¦ÄÕW_]§±4Õ~ð‡?üaµñwÎ9çÄE]û￵ÏkݺuôèÑ#zôè_ùÊW⥗^Š[n¹¥h]·Þzkôë×/z÷îÝ(ㇽIªCÀÛÜtÓMñÉ'Ÿ4õ0¨…>ø àvÏž=›h$°û´k×.FŒW^yeÑ}ÿýßÿË—/¯óºw÷~𡇊'Ÿ|²`YIII\wÝu1jÔ¨Æ_uŽ:ꨘ4iRtÐAË·lÙ÷Þ{oC öz)ðÈ#,¸ýÖ[oůýë& a¿ýökê!Ànóo|£ÚC›µ9)ª)÷ƒË—/ŸýìgEËo¸á†8õÔSë´ÎvíÚŤI“¢{÷îËŸ|òÉX´hQÖ ™¤À+¯¼2JKK –ý⿈eË–5ш¨/ó‘ÍÑG]´¬ºÃ©;Ò”ûÁûï¿?6oÞ\°ìÜsÏN8¡^ëíСCµó>úè£õZ/dâ;€:tˆoûÛqã7V.+//I“&ÅM7Ý´ÛÆQQQùË_âé§ŸŽwß}7V¯^›6mŠvíÚEÇŽã裎/~ñ‹Ñ®]»FËÚµk vÈíÚµ+˜eÿý÷ßùóçÇâÅ‹cݺuqæ™gFÿþýw¹ÞÍ›7ÇK/½¯¾új¬^½:Ö¯_íÛ·.]ºÄa‡GqDƒŒÿ3ŸùLž×ãÛ“¶åêÕ«cË–-•·;tèP0Éð–-[âÅ_Œ Äûï¿6lˆ¶mÛF§NbÀ€q衇Öú5·Ù´iS<÷Üsñì³ÏÆÊ•+cÍš5QZZÝ»wîÝ»ÇAÇw\”””Ôù5v×ï_Sèׯ_Ѳ¥K—ÖøùMµ\¿~}Ìš5«`YçÎcĈ ²þSN9%&Ož\0éöóÏ?ß ë†½YŠŒˆøêW¿sæÌ)˜>aþüùñè£Æi§Ö¨¯½eË–˜5kVÜ}÷ݱzõê>nÖ¬YQRRC† iôÉM¿÷½ïÅ«¯¾Zy{òäÉѯ_¿Øºukü×ýWüüç?/Ø¡öíÛw§ÑòÁĽ÷Þ³gÏŽ?üp‡ëÞ½{ 2$†ºÓ³wÿûßÇ÷¿ÿýÊÛÛGKDÄĉ Þ´Î;ï¼¾¡4ôø¶×Ü·åö.¹ä’‚ßÁ‡z(ÊÊÊ¢¢¢"xà¸ÿþûwú;zÈ!‡Ä˜1câðïÑëED|òÉ'ñÀÄ}÷ÝWí•1æÏŸ_ùßx`\xá…qê©§Öêê¹Íš‹Î;G›6m ¶aÕ“£v¥)öƒ3gÎŒM›6,;묳lú¦}÷Ý7N9唘1cFå²×_=Ö®]»[þ˜†=UŠCÀŸ^®h̘1EŸMž<¹èƒ†´víÚøçþç¸ñÆwúƺMEEE̘1#†sçÎm´qíèµÇ·Þzk­.aõÄOÄ·¾õ­x衇vúæñéÙ‹S§N‹.ºh§¥oݺ5¶lÙRùSÝý•?Õ=¦1Ç·+Íi[îÊŠ+âŠ+®ˆ)S¦ìòwtÉ’%1jÔ¨øßÿýß­{åÊ•q饗Eð޼óÎ;1a„øö·¿]ãíÖÛ¬)¬[·®h›xàµZGSìŸ{ۭZµŠ3Ï<³A_c̘11wîÜ‚ñ;—&#¢òrJÛ[³fMÜqÇòz+W®Œ‘#GÆ+¯¼Ríý­[·Ž²²²j?éøøãcüøñ»íKÚ[·no¼1üñZ=oæÌ™1nܸZO,»|ùò=zt£ÏàßãÛ“¶å{ï½W_}u,\¸°ÆÏ©¨¨ˆ›o¾y—W¤X¶lY\yå•;®¼¼<î½÷Þ7n\µë-//±cÇÆÊ•+ –÷ìÙ3†  ˆŽ;ÆÆãí·ßŽùóçÇ´iÓ ^cΜ9qä‘GÆ×¾öµj_£©¶YS™7o^ѲC9¤NëÚ]ûÁE‹þÝþÿ[ é¤ ÀÏ|æ31f̘9rdÁò›o¾9î¼ó΂/ï×Ç/ùË¢OUŽ8âˆøÑ~T%%%ѯ_¿èׯ_ <8Æ_p(ë?øAuÔQqÀ4ÈØªóðÃWþw¯^½âòË/Þ½{ïð5W­ZUôæ[ZZ×\sMœ|òÉË=öØ8öØc#"âî»ïŽéÓ§WÞWQQ7ÞxcÜwß}Û¾K—.Ñ¥K—ÊÛU¿?Ù¿ÿFqcogšÛ¶Ü™mñ×¾}û˜0aBÑ›ó¡‡gœqF 80ÆŽ[p¨ýüc|òÉ'Õžs×]w}buâ‰'Æõ×__p÷~ûí}ûö¾}ûÆ AƒbôèÑÑx×]wÅ™gžYpUˆmãnªmÖüñxðÁ –•––Öù¤–ݵ¬nšš¾}û6ȺúIux›#<2Î:묂eK–,‰ßüæ7 ²þuëÖÅ/ùË‚eýû÷‰'îrþºĵ×^[°lÆ ñÐC5ÈØv¤¢¢"""Î>ûì˜=¾üå/M,Z[3gÎ,8”1räÈ_·sРAqì±ÇƳÏ>[¹ìᇎáÇ×kŠŒ]éß¿\uÕU»|ܪU«â·¿ýmÁ²¡C‡ÖøòK^xa¼ð ñâ‹/V.›3gÎõÕVsßž´-/¸à‚L0dȸ뮻 –½÷Þ{E›1cFeo3jÔ¨}ªô¥/})Ž8âˆøóŸÿ\¹ì¥—^*8ÔÙ¶Y]¬X±"¦M›¶ËÇmذ!V¬X+V¬ˆE‹mˈO¥ÿÃ?üC½ÇÔ˜ûÁˆê°ê\„;³lÙ²‚ý`m”••ÕèÚËUÚ,--ï|ç;ßa*//[n¹%~üã×kÝU?M8ì°Ãj}mÊSN9¥`Ç÷ÁÄk¯½Öh‡OZ¶l£FªÑcgÍšU0ï]Û¶m‹>UÙ•¯}íkoÀ ,ˆ 6ľûî[«õ4ÇñíIÛ²cÇŽqî¹çÖèuÊÊÊ¢k×®ñ׿þµrYu'_T=±âC©Ñ¼‡Û 8° _|ñÅ8ûì³+o7õ6««•+WÆ=÷ÜSïõpÀqíµ×6ÈaÚÆÜFÔ?-Z?ùÉOêôÚ‡~¸„Hyx›AƒÅñÇ_°ìÙgŸßýîwu^çÚµk‹Nü¨îN»r 'íà·Ÿ»«¡õíÛ7zõêU£ÇV>£oß¾µžÓkÛw²¶©¨¨(˜K¯>šz|{Ò¶4hP­^¯mÛ¶·«àš5kâwÞ)X6pàÀ¯?âÓOÇWùó•¯|¥àþ¦ÞfMiÀ€qÏ=÷4艱ܦê QtE i¤Àˆˆ«®ºªèÐìm·Ý¶ËùÄv¤ê”_üâk½žÒÒÒ‚“ ">½vgc9øàƒkô¸Í›7Ç‚ –õéÓ§Ö¯·ÿþûGÇŽ –ÕçÂöÛ4‡ñíIÛ²¶óÈUýkÕ¯:T7åÑ—¾ô¥Z½F‡âä“O®üÙ>ÖšÃ6ÛÝöÙgŸèÝ»wŒ92&NœØ(ß¡kèýà6ûï¿ѲÚN^ 4Ž´‡€·éܹs\z饇V¯^wÞyg\}õÕµ^_Õëj–””D‡ê4¶öíÛ|šRÝᔆRÝ4*ÕY±bEÑ_õ¯¾újÜ~ûíµ~Íí§»‰ˆ¢)Cê¢9ŒoOÚ–µ9EgãVUÝueâ»dÛ4‡mVW]»vsÎ9§F-))‰îÝ»ÇÁ]»vÝåv¯¯†ÞnS]nÿ‚]éÕ«W\qÅ5zìOú裟^üÏÿüOœ~ú鵺äUDͦ_VVVç7ªN–Ú˜XÓkëVwµ€çž{®h¶ÿºøøã뽎æ0¾=i[6Ô帶©îßÔ“þ6‡mVW:uŠo~ó›úõÑûÁmª~e ¢vŸöìÙ³ÆP-\¸° «>P(ý!àˆO¿´íµ×„ÚÖ­[ãæ›o®õ÷Uª¾A5äõ|kzqcªíjã“O>©÷:šûø¶×ÆÚÐg•W=d¸ß~û5èüzÍa›í­r?¸MÕÃìw¸17`oäÀÿïÐCaÆÌß÷úë¯Ç<çŸ~×SõóõùÂóûï¿_p»!¥ÕUuÁгgÏ¢w]ÔõPùöšûø¶·'µ¦ªþ›:0÷ÆmÖœ4Ô~p›ê&ª®îk ¡6‡–X`øðá1wîÜ‚ïÝM›6-N>ùäèÚµkÖÑ£G‚Ûõùk·9`ußé¹ôÒKýRu5ÕÜÇ·½=i¬5Uõ÷ýúõ±iÓ¦;Ô¼7n³æ¦!öƒÛtîÜ9ºuëVp‚Í+¯¼o¼ñFzè¡ 6æU«V5ZXÂÞÊ!àíì³Ï>qÍ5×,ûøããÖ[o­ñ:ªžU¹fÍš¢3%kbóæÍ“³FDtëÖ­ÖëihÕ]y 9íx›ûø¶·'µ¦ª`Dõ“E×Õ޸͚›†ØnïóŸÿ|Ѳ†¼ÚHD]ãØ5Xžð…8ãŒ3 –=ýôÓ1wîÜ=¿º7Àªó¢ÕÄüùó ®»Qû);C—.]Ц©:ïaSjîãÛÞž4Öšú›¿ù›¢eï¾ûn­Ö1wîÜ:thåÏøñã+ïÛ·YsTßýàöN9唢e=öXƒžuýÀ4غ X+®¸¢èìµÛn»->úè£]>·S§NE×;5kV­ÇðØcÜnÓ¦M­¿4†–-[}¯çå—_.ŠÕ]ùë_ÿçŸ~œwÞyqÞyçŰaÃbÕªU{ýø¶·'µ¦:wî\ôû_õ²m»òÛßþ6Þ{ï½ÊŸ¿ýÛ¿­¼ooÜfÍU}öƒÛ0`@vØaË***ìúæO>ùd,\¸°AÖ™Àj´mÛ6®¼òÊ‚eï¿ÿ~vX-Z´(š¥Ö¬Y±aÆ¿þ¦M›âøCÁ²sÎ9§Á§ì¨«ªWQX¶lY<ñĵZÇÔ©Scùòå•×<-++k° n›ûø¶·'µ&Z´h'œpBÁ²¹sçÖø ÍuëÖ]ûõ¸ãŽ+¸½·m³æª>ûÁª.¸à‚¢eÿùŸÿYp9¾ºxóÍ7ã?øA½ÖY À8í´ÓbÀ€˪Nq±£y¦.»ì²‚Û}ôQ­všwÞyglܸ±òv›6mbèС5~~c2dHÑ¿øÅ/j<ïÖk¯½>úhÁ²SO=5Íø¶·'µ¦.¹ä’‚³uËËËã?þã?jôÜ[n¹¥à;³íÛ·/ºŽö޸͚«úì·wÒI']º¼¼<þõ_ÿµÚ«'ÕÄã?×\sM¯V²jÕªX¹reÁd"wâšk®©Ó§n}úô‰ÓO?½`ÙÔ©ScÚ´i»|î´iÓâÁ,Xöõ¯½A'Ó­¯}÷ݷ芋/Žë¯¿~—Ÿt¾üòËqÝu×,ëܹsœvÚiiÆ·½=i¬5uà]ÿúW¿úÕ.ÿ|ðÁøýï_°ì´ÓN+º ÆÞ¸Íš³ºî·×²eË7n\ÑT;6lˆ‘#GÆO~ò“‡Ü’%KâꫯŽqãÆÌ”PÛ9WGŒßüæ7 ~ ÓÀìD·nÝâŸþéŸâŽ;î¨õs/¹ä’˜;wnÁ§÷ÜsO¼ûî»ñÕ¯~5z÷î]9±ó† bÁ‚ñôÓO}R¸Ï>ûİaÃê÷iÇÿû¿ÿ+¸.ëþð‡xûí·ãòË/Þ½{Wîì7oÞo½õV<öØcñë_ÿºàûZ%%%1nܸZ_’lOßž:Öš>|x<òÈ#ŸdßsÏ=ñÎ;ïÄI'ýúõ‹²²²øè£â7ÞˆûèÐoŸ>}â’K.Ùáú÷¶mÖ\Õg?¸½²²²7n\Œ=:****—oÙ²%~øá˜1cF}ôÑ1pàÀèÑ£G´k×.JKKcåÊ•ñæ›oÆ[o½K—.矾àù'žxb\~ùåñÿøõ#d"waèСñØcÅâÅ‹kõ¼Î;Çe—]?ýéO –Ïž=;fÏž-Z´ˆƒ:(Z¶lK–,©ö0JIIIŒ;¶Y}ú·M«V­büøñ1jÔ¨‚ X—.]ßýîw#âÓ‰uÛ¶mo¿ýö'ľôÒKë|™©=y|{êXkª]»vñ½ï}/n¸á†‚7ë9sæÄœ9s"âÓëïèSŸÒÒÒø÷ÿ÷¢J¶Ù·YsV×ý`UGuTÜtÓMqà 7MsU^^Ï<óL<óÌ3µZçàÁƒãºë®‹V­ZE÷îÝk}Ö9dåð.´jÕ*ÆŒ-[Ö~S{î¹1zôèj/ä¾uëÖXºti¼ñÆÕÆßg?ûÙ;vlœxâ‰u÷îйsç˜= ´Ëxh×®]Œ5*¦OŸ^ã7ò½q›5WõÙVÕ¾}û˜0aBL™2%X«ç–••ŰaÃâî»ïŽsÏ=·àl5×bkMO£Þ/^O=õTüùÏŽÕ«WǺuë¢M›6Ñ®]»èÔ©SsÌ1qÜqÇí±ÓQlذ!ž{î¹øãÿË–-‹Õ«WGëÖ­£S§NÑ©S§8øàƒãË_þr“ýûšûøöÔ±ÖÔÚµkcÞ¼y±dÉ’XµjUlÙ²%<ðÀèÑ£GôèÑ#úôéSù½ØºØ·Yk×®çŸ>žþùX¾|y¬Y³&>øàƒØo¿ý¢¬¬,:vì;vŒþýûÇ€üÓ‘HÆ!`€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2KÕ”]…IDAT ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHF$#’€É@€d @2 ŒHæÿîµaœë6 IEND®B`‚enthought-chaco2-4.5.1.orig/enable/savage/compliance/__init__.py0000644000175000017500000000000012516137326023605 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/compliance/comparator.py0000644000175000017500000003556712516137326024247 0ustar varunvarun#!/usr/bin/env python # -*- coding: UTF-8 -*- """ Compare the output of various Kiva SVG implementations against other renderers. """ from cStringIO import StringIO import glob import logging import os import pstats import sys from xml.etree import cElementTree as ET import warnings import Image import numpy as np from enable.api import Component from enable.component_editor import ComponentEditor from traits.api import (Any, Button, Dict, HasTraits, HTML, Instance, List, Property, Str, on_trait_change) from traitsui import api as tui from enable.savage.svg import document from enable.savage.trait_defs.ui.svg_editor import SVGEditor from enable.savage.svg.backends.wx.renderer import Renderer as WxRenderer from enable.savage.svg.backends.kiva.renderer import Renderer as KivaRenderer from crosshair import Crosshair, MultiController from profile_this import ProfileThis from sike import Sike from svg_component import ImageComponent, SVGComponent from xml_view import xml_to_tree, xml_tree_editor logger = logging.getLogger() this_dir = os.path.abspath(os.path.dirname(__file__)) class ComponentTrait(Instance): """ Convenience trait for Enable Components. """ def __init__(self, **kwds): kwds.setdefault('klass', Component) super(ComponentTrait, self).__init__(**kwds) def create_editor(self): return ComponentEditor() def normalize_text(text): """ Utility to normalize the whitespace in text. This is used in order to prevent wx's HTML widget from overzealously trying to interpret the whitespace as indicating preformatted text. """ return ' '.join(text.strip().split()) def activate_tool(component, tool): """ Add and activate an overlay tool. """ component.tools.append(tool) component.overlays.append(tool) component.active_tool = tool return tool class Comparator(HasTraits): """ The main application. """ #### Configuration traits ################################################## # The root directory of the test suite. suitedir = Str() # Mapping of SVG basenames to their reference PNGs. Use None if there is no # reference PNG. svg_png = Dict() # The list of SVG file names. svg_files = List() # The name of the default PNG file to display when no reference PNG exists. default_png = Str(os.path.join(this_dir, 'images/default.png')) #### State traits ########################################################## # The currently selected SVG file. current_file = Str() abs_current_file = Property(depends_on=['current_file']) # The current XML ElementTree root Element and its XMLTree view model. current_xml = Any() current_xml_view = Any() # The profilers. profile_this = Instance(ProfileThis, args=()) #### GUI traits ############################################################ # The text showing the current mouse coordinates over any of the components. mouse_coords = Property(Str, depends_on=['ch_controller.svg_coords']) # Move forward and backward through the list of SVG files. move_forward = Button('>>') move_backward = Button('<<') # The description of the test. description = HTML() document = Instance(document.SVGDocument) # The components to view. kiva_component = ComponentTrait(klass=SVGComponent) ref_component = ComponentTrait(klass=ImageComponent, args=()) ch_controller = Instance(MultiController) # The profiler views. parsing_sike = Instance(Sike, args=()) drawing_sike = Instance(Sike, args=()) wx_doc_sike = Instance(Sike, args=()) kiva_doc_sike= Instance(Sike, args=()) traits_view = tui.View( tui.Tabbed( tui.VGroup( tui.HGroup( tui.Item('current_file', editor=tui.EnumEditor(name='svg_files'), style='simple', width=1.0, show_label=False), tui.Item('move_backward', show_label=False, enabled_when="svg_files.index(current_file) != 0"), tui.Item('move_forward', show_label=False, enabled_when="svg_files.index(current_file) != len(svg_files)-1"), ), tui.VSplit( tui.HSplit( tui.Item('description', label='Description', show_label=False), tui.Item('current_xml_view', editor=xml_tree_editor, show_label=False), ), tui.HSplit( tui.Item('document', editor=SVGEditor(), show_label=False), tui.Item('kiva_component', show_label=False), tui.Item('ref_component', show_label=False), # TODO: tui.Item('agg_component', show_label=False), ), ), label='SVG', ), tui.Item('parsing_sike', style='custom', show_label=False, label='Parsing Profile'), tui.Item('drawing_sike', style='custom', show_label=False, label='Kiva Drawing Profile'), tui.Item('wx_doc_sike', style='custom', show_label=False, label='Creating WX document'), tui.Item('kiva_doc_sike', style='custom', show_label=False, label='Creating WX document'), ), width=1280, height=768, resizable=True, statusbar='mouse_coords', title='SVG Comparator', ) def __init__(self, **traits): super(Comparator, self).__init__(**traits) kiva_ch = activate_tool(self.kiva_component, Crosshair(self.kiva_component)) ref_ch = activate_tool(self.ref_component, Crosshair(self.ref_component)) self.ch_controller = MultiController(kiva_ch, ref_ch) @classmethod def fromsuitedir(cls, dirname, **traits): """ Find all SVG files and their related reference PNG files under a directory. This assumes that the SVGs are located under /svg/ and the related PNGs under /png/ and that there are no subdirectories. """ dirname = os.path.abspath(dirname) svgs = glob.glob(os.path.join(dirname, 'svg', '*.svg')) pngdir = os.path.join(dirname, 'png') d = {} for svg in svgs: png = None base = os.path.splitext(os.path.basename(svg))[0] for prefix in ('full-', 'basic-', 'tiny-', ''): fn = os.path.join(pngdir, prefix+base+'.png') if os.path.exists(fn): png = os.path.basename(fn) break d[os.path.basename(svg)] = png svgs = sorted(d) x = cls(suitedir=dirname, svg_png=d, svg_files=svgs, **traits) x.current_file = svgs[0] return x def display_reference_png(self, filename): """ Read the image file and shove its data into the display component. """ img = Image.open(filename) arr = np.array(img) self.ref_component.image = arr def display_test_description(self): """ Extract the test description for display. """ html = ET.Element('html') title = self.current_xml.find('.//{http://www.w3.org/2000/svg}title') if title is not None: title_text = title.text else: title_text = os.path.splitext(self.current_file)[0] p = ET.SubElement(html, 'p') b = ET.SubElement(p, 'b') b.text = 'Title: ' b.tail = title_text desc_text = None version_text = None desc = self.current_xml.find('.//{http://www.w3.org/2000/svg}desc') if desc is not None: desc_text = desc.text else: testcase = self.current_xml.find('.//{http://www.w3.org/2000/02/svg/testsuite/description/}SVGTestCase') if testcase is not None: desc_text = testcase.get('desc', None) version_text = testcase.get('version', None) if desc_text is not None: p = ET.SubElement(html, 'p') b = ET.SubElement(p, 'b') b.text = 'Description: ' b.tail = normalize_text(desc_text) if version_text is None: script = self.current_xml.find('.//{http://www.w3.org/2000/02/svg/testsuite/description/}OperatorScript') if script is not None: version_text = script.get('version', None) if version_text is not None: p = ET.SubElement(html, 'p') b = ET.SubElement(p, 'b') b.text = 'Version: ' b.tail = version_text paras = self.current_xml.findall('.//{http://www.w3.org/2000/02/svg/testsuite/description/}Paragraph') if len(paras) > 0: div = ET.SubElement(html, 'div') for para in paras: p = ET.SubElement(div, 'p') p.text = normalize_text(para.text) # Copy over any children elements like . p[:] = para[:] tree = ET.ElementTree(html) f = StringIO() tree.write(f) text = f.getvalue() self.description = text def locate_file(self, name, kind): """ Find the location of the given file in the suite. Parameters ---------- name : str Path of the file relative to the suitedir. kind : either 'svg' or 'png' The kind of file. Returns ------- path : str The full path to the file. """ return os.path.join(self.suitedir, kind, name) def _kiva_component_default(self): return SVGComponent(profile_this=self.profile_this) def _move_backward_fired(self): idx = self.svg_files.index(self.current_file) idx = max(idx-1, 0) self.current_file = self.svg_files[idx] def _move_forward_fired(self): idx = self.svg_files.index(self.current_file) idx = min(idx+1, len(self.svg_files)-1) self.current_file = self.svg_files[idx] def _get_abs_current_file(self): return self.locate_file(self.current_file, 'svg') def _current_file_changed(self, new): # Reset the warnings filters. While it's good to only get 1 warning per # file, we want to get the same warning again if a new file issues it. warnings.resetwarnings() self.profile_this.start('Parsing') self.current_xml = ET.parse(self.abs_current_file).getroot() self.current_xml_view = xml_to_tree(self.current_xml) resources = document.ResourceGetter.fromfilename(self.abs_current_file) self.profile_this.stop() try: self.profile_this.start('Creating WX document') self.document = document.SVGDocument(self.current_xml, resources=resources, renderer=WxRenderer) except: logger.exception('Error parsing document %s', new) self.document = None self.profile_this.stop() try: self.profile_this.start('Creating Kiva document') self.kiva_component.document = document.SVGDocument(self.current_xml, resources=resources, renderer=KivaRenderer) except Exception, e: logger.exception('Error parsing document %s', new) self.kiva_component.document self.profile_this.stop() png_file = self.svg_png.get(new, None) if png_file is None: png_file = self.default_png else: png_file = self.locate_file(png_file, 'png') self.display_test_description() self.display_reference_png(png_file) def _get_mouse_coords(self): if self.ch_controller is None: return '' else: return '%1.3g %1.3g' % self.ch_controller.svg_coords @on_trait_change('profile_this:profile_ended') def _update_profiling(self, new): if new is not None: name, p = new stats = pstats.Stats(p) if name == 'Parsing': self.parsing_sike.stats = stats elif name == 'Drawing': self.drawing_sike.stats = stats elif name == 'Creating WX document': self.wx_doc_sike.stats = stats elif name == 'Creating Kiva document': self.kiva_doc_sike.stats = stats class OpenClipartComparator(Comparator): """ Locate SVG files and PNGs in directories laid out like the OpenClipart packages. """ @classmethod def fromsuitedir(cls, dirname, **traits): """ Load SVG and reference PNGs from an OpenClipart directory. """ dirname = os.path.abspath(dirname) def remove_prefix(path, dirname=dirname): if path.startswith(dirname + os.path.sep): path = path[len(dirname)+1:] return path svg_png = {} for d, dirs, files in os.walk(dirname): for fn in files: fn = os.path.join(d, fn) base, ext = os.path.splitext(fn) if ext == '.svg': png = os.path.join(d, base+'.png') if os.path.exists(png): png = remove_prefix(png) else: png = None svg = remove_prefix(fn) svg_png[svg] = png svgs = sorted(svg_png) x = cls(suitedir=dirname, svg_png=svg_png, svg_files=svgs, **traits) x.current_file = svgs[0] return x def locate_file(self, name, kind): return os.path.join(self.suitedir, name) def main(): import argparse parser = argparse.ArgumentParser() parser.add_argument('--openclipart', action='store_true', help="The suite is in OpenClipart layout rather than the SVG test suite layout.") parser.add_argument('--suitedir', nargs='?', default=os.path.join(this_dir, 'w3c_svg_11'), help="The directory with the test suite. [default: %(default)s]") args = parser.parse_args() logging.basicConfig(stream=sys.stdout) if args.openclipart: klass = OpenClipartComparator else: klass = Comparator if os.path.isfile(args.suitedir): # We were given a single SVG file. if args.openclipart: suitedir, svg = os.path.split(args.suitedir) else: svgdir, svg = os.path.split(args.suitedir) suitedir = os.path.split(svgdir)[0] c = klass(suitedir=suitedir) png = os.path.splitext(svg)[0] + '.png' if not os.path.exists(c.locate_file(png, 'png')): png = None c.svg_png = {svg: png} c.svg_files = [svg] c.current_file = svg else: c = klass.fromsuitedir(args.suitedir) c.configure_traits() if __name__ == '__main__': main() enthought-chaco2-4.5.1.orig/enable/savage/compliance/profile_this.py0000644000175000017500000000221612516137326024550 0ustar varunvarunfrom cProfile import Profile from traits.api import Any, Dict, Event, HasTraits, Str class ProfileThis(HasTraits): """ Control profiling of different parts of the code. """ # Mapping of str name to Profile instance. profilers = Dict() # The active Profile instance. active_profile = Any() active_profile_name = Str() # An event with the profiler just ending. profile_ended = Event() def start(self, name): """ Start a particular profile. """ if self.active_profile is None: if name not in self.profilers: self.profilers[name] = Profile() self.active_profile = self.profilers[name] self.active_profile_name = name self.active_profile.clear() self.active_profile.enable() def stop(self): """ Stop the running profile. """ if self.active_profile is not None: p = self.active_profile name = self.active_profile_name p.disable() self.active_profile = None self.active_profile_name = '' self.profile_ended = (name, p) enthought-chaco2-4.5.1.orig/enable/savage/compliance/drawer.py0000644000175000017500000000666112516137326023355 0ustar varunvarunimport svg import wx import wx.py.shell import wx.aui import wx.grid class PathGrid(wx.grid.Grid): def __init__(self, parent, pathOps): super(PathGrid, self).__init__(parent) self.CreateGrid(100,10) firstColAttr = wx.grid.GridCellAttr() choices = sorted(pathOps.keys()) firstColAttr.SetEditor(wx.grid.GridCellChoiceEditor(choices)) self.SetColMinimalWidth(0,140) self.SetColAttr(0, firstColAttr) class PathPanel(wx.Panel): ctx = None path = None def __init__(self, parent, contextSource): super(PathPanel, self).__init__(parent, style=wx.FULL_REPAINT_ON_RESIZE) self.contextSource = contextSource self.Bind(wx.EVT_PAINT, self.OnPaint) def GetContext(self): self.ctx = self.contextSource(self) def SetPath(self, path): self.ctx = self.contextSource(self) self.path = path self.Update() self.Refresh() def OnPaint(self, evt): dc = wx.PaintDC(self) self.GetContext() if not (self.ctx and self.path): return self.ctx.DrawPath(self.path) class DrawFrame(wx.Frame): def __init__(self, parent, *args, **kwargs): wx.Frame.__init__(self, parent, *args, **kwargs) self.pathOps = dict((k,v) for (k,v) in wx.GraphicsPath.__dict__.iteritems() if k.startswith("Add")) self.pathOps["CloseSubpath"] = wx.GraphicsPath.CloseSubpath self.pathOps["MoveToPoint"] = wx.GraphicsPath.MoveToPoint self.pathOps[""] = None self._mgr = wx.aui.AuiManager() self._mgr.SetManagedWindow(self) self.panel = PathPanel(self, self.CreateContext) self.locals = { "wx":wx, "frame":self, "panel":self.panel, "context":None } self.nb = wx.aui.AuiNotebook(self) self.shell = wx.py.shell.Shell(self.nb, locals = self.locals) self.grid = PathGrid(self.nb, self.pathOps) self.nb.AddPage(self.shell, "Shell") self.nb.AddPage(self.grid, "Path", True) self._mgr.AddPane(self.nb, wx.aui.AuiPaneInfo().Bottom().CaptionVisible(False).BestSize((-1,300)) ) self._mgr.AddPane(self.panel, wx.aui.AuiPaneInfo().CenterPane()) self._mgr.Update() wx.CallAfter(self.panel.GetContext) #wx.CallAfter(self.shell.SetFocus) self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnPathChange) def CreateContext(self, target): ctx = wx.GraphicsContext_Create(target) ctx.SetPen(wx.BLACK_PEN) ctx.SetBrush(wx.RED_BRUSH) self.locals["context"] = ctx return ctx def OnPathChange(self, evt): path = wx.GraphicsRenderer_GetDefaultRenderer().CreatePath() self.FillPath(path) self.panel.SetPath(path) def FillPath(self, path): for row in xrange(100): #~ print row, operation = self.grid.GetCellValue(row, 0) if not operation: return #~ print operation, args = [] for col in xrange(1,20): v = self.grid.GetCellValue(row, col) if not v: break args.append(float(v)) self.pathOps[operation](path, *args) #~ print args if __name__ == '__main__': app = wx.App(False) frame = DrawFrame(None, size=(800,600)) frame.Centre() frame.Show() app.MainLoop() enthought-chaco2-4.5.1.orig/enable/savage/compliance/viewer.py0000644000175000017500000002050112516137326023357 0ustar varunvarunimport os import time from cStringIO import StringIO import xml.etree.cElementTree as etree import wx import wx.aui import enable.savage.svg.document as document from enable.savage.trait_defs.ui.wx.wx_render_panel import RenderPanel class ReferencePanel(wx.Panel): def __init__(self, parent, bmp): super(ReferencePanel, self).__init__(parent) self.bmp = bmp self.Bind(wx.EVT_PAINT, self.OnPaint) def OnPaint(self, evt): dc = wx.PaintDC(self) if self.bmp: dc.DrawBitmap(self.bmp, 0, 0) else: dc.DrawText("No image available", 30, 30) class ProfileResults(wx.TextCtrl): def __init__(self, parent): super(ProfileResults, self).__init__(parent, style=wx.TE_MULTILINE) self.SetFont(wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, face="Courier New")) def SetResults(self, results): if results is None: self.SetValue("") return buf = StringIO() results.stream = buf results.strip_dirs() results.sort_stats(-1) results.print_stats() self.SetValue(buf.getvalue()) class XMLTree(wx.TreeCtrl): """ wxTreeCtrl that displays an ElementTree """ def __init__(self, parent, tree=None): wx.TreeCtrl.__init__(self, parent) if tree: self.updateTree(tree) def updateTree(self, tree): self.DeleteAllItems() self.tree = tree self.addElementToTree(self.tree.getroot(), None) self.SetPyData(self.GetRootItem(), self.tree.getroot()) self.Expand(self.GetRootItem()) def addElementToTree(self, element, node): """ Recursively adds an element to the tree. element is the element being added, node is the parent node. If node is None, then the element is the root. """ if node is None: node = self.AddRoot(element.tag) else: if element.text and element.text.strip(): txt = element.tag + ':' + element.text else: txt = element.tag node = self.AppendItem(node, txt) self.SetPyData(node, element) #children for child in element.getchildren(): self.addElementToTree(child, node) #attributes for key, value in element.items(): item = self.AppendItem(node, "%s:%s"%(key,value)) self.SetPyData(item, element) class ViewFrame(wx.Frame): #status bar cell locations SCROLL_OFFSET = 0 FILE = 1 LOAD_TIME = 2 RENDER_TIME = 3 def __init__(self, parent): wx.Frame.__init__(self, parent, style=wx.DEFAULT_FRAME_STYLE | wx.CLIP_CHILDREN) self._mgr = wx.aui.AuiManager() self._mgr.SetManagedWindow(self) self.wrap = wx.Panel(self) self.profileLoading = True self.tree = XMLTree(self, None) self.profileResults = ProfileResults(self) self.render = RenderPanel(self.wrap) self.reference = ReferencePanel(self.wrap, None) sz = wx.BoxSizer(wx.HORIZONTAL) sz.Add(self.render, 1, wx.EXPAND|wx.RIGHT, 1) sz.Add(self.reference, 1, wx.EXPAND|wx.LEFT, 1) self.wrap.SetSizer(sz) self.SetMenuBar(self.makeMenus()) self.SetToolBar(self.makeToolBar()) self._mgr.AddPane( self.tree, wx.aui.AuiPaneInfo(). Top(). CloseButton(False). Layer(1). Caption("XML Tree"). MinSize(self.tree.GetBestSize()), "XML TREE" ) self._mgr.AddPane( self.profileResults, wx.aui.AuiPaneInfo(). Top(). CloseButton(False). Layer(1). Caption("PROFILE RESULTS"). MinSize(self.tree.GetBestSize()), "PROFILE RESULTS" ) self._mgr.AddPane( self.wrap, wx.aui.AuiPaneInfo().CentrePane().Caption("SVG Rendering"), "VIEWER" ) self.CreateStatusBar(5) self.SetSize((800,600)) self._mgr.Update() self.Bind(wx.EVT_MENU, self.OnOpenFile, id=wx.ID_OPEN) def OnProfileLoading(evt): self.profileLoading = bool(evt.Checked()) self.Bind(wx.EVT_MENU, OnProfileLoading, id=wx.ID_FORWARD) self.Bind(wx.EVT_MENU, self.Reload, id=wx.ID_REFRESH) self.Bind(wx.EVT_MENU, lambda x:self.Destroy(), id=wx.ID_EXIT) self.Bind(wx.EVT_CHOICE, self.OnChooseFile) self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnTreeSelectionChange) self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateUI) self.filePicker.SetSelection(self.filePicker.FindString('shapes-rect-01-t')) self.OnChooseFile(None) def makeMenus(self): fileMenu = wx.Menu() mi = wx.MenuItem(fileMenu, wx.ID_FORWARD, "Profile loading", kind=wx.ITEM_CHECK) fileMenu.AppendItem(mi) fileMenu.Append(wx.ID_OPEN, "&Open") fileMenu.Append(wx.ID_REFRESH, "&Reload Current File\tF5") fileMenu.AppendSeparator() fileMenu.Append(wx.ID_EXIT, "E&xit") mb = wx.MenuBar() mb.Append(fileMenu, "&File") return mb def makeToolBar(self): tb = wx.ToolBar(self, style=wx.TB_FLAT) self.filePicker = wx.Choice(tb, choices=self.getFileList()) tb.AddControl(self.filePicker) tb.Realize() return tb def getFileList(self): #look for the test files in the w3c dir files = os.listdir(self.getSVGDir()) splitted = map(os.path.splitext, files) return sorted(fname for fname, ext in splitted) def getSVGDir(self): dir = os.path.dirname(__file__) dir = os.path.join(dir, "w3c_svg_11", "svg") return dir def getPNGDir(self): dir = os.path.dirname(__file__) dir = os.path.join(dir, "w3c_svg_11", "png") return dir def Reload(self, evt): self.openFile(self.currentFile) def openFile(self, filenameOrBuffer): start = time.time() tree = etree.parse(filenameOrBuffer) try: if self.profileLoading: import cProfile p = cProfile.Profile() p.enable() self.document = document.SVGDocument(tree.getroot()) if self.profileLoading: import pstats p.disable() results = pstats.Stats(p) self.profileResults.SetResults(results) else: self.profileResults.SetResults(None) self.render.document = self.document except: #pdb.set_trace() import traceback self.render.document = None traceback.print_exc() amount = time.time() - start self.tree.updateTree(tree) self.SetStatusText("Loaded in %2f seconds" % amount, self.LOAD_TIME) self.SetStatusText(filenameOrBuffer) self.currentFile = filenameOrBuffer self.Refresh() def OnChooseFile(self, evt): fname = self.filePicker.GetString(self.filePicker.GetSelection()) if fname == '': return svg = os.path.join(self.getSVGDir(), fname+'.svg') self.openFile(svg) png = os.path.join(self.getPNGDir(), 'full-'+fname+'.png') if os.path.isfile(png): self.reference.bmp = wx.Bitmap(png) else: self.reference.bmp = None def OnOpenFile(self, evt): dlg = wx.FileDialog(self) if dlg.ShowModal() == wx.ID_OK: self.openFile(dlg.GetPath()) self.reference.bmp = None def OnTreeSelectionChange(self, evt): item = self.tree.GetSelection() element = self.tree.GetItemPyData(item) if element is None: return path = self.document.paths[element] print path def OnUpdateUI(self, evt): if self.render.lastRender is not None: self.SetStatusText("Rendered in %2f seconds" % self.render.lastRender, self.RENDER_TIME) if evt.Id == wx.ID_FORWARD: evt.Checked = self.profileLoading if __name__ == '__main__': try: import psyco psyco.full() except: pass app = wx.App(0) f = ViewFrame(None) f.Show() app.MainLoop() enthought-chaco2-4.5.1.orig/enable/savage/compliance/svg_component.py0000644000175000017500000000566012516137326024750 0ustar varunvarun""" An Enable component to render SVG documents. """ import sys import time from enable.api import Component from traits.api import Any, Array, Bool, Float from kiva.fonttools import Font if sys.platform == 'win32': now = time.clock else: now = time.time class SVGComponent(Component): """ An Enable component to render SVG documents. """ # The SVGDocument. document = Any() # The number of seconds it took to do the last draw. last_render = Float() # The profile manager. profile_this = Any() should_profile = Bool(False) def _draw_mainlayer(self, gc, view_bounds=None, mode='default'): if self.should_profile and self.profile_this is not None: # Only profile the first draw. self.should_profile = False self.profile_this.start('Drawing') start = now() gc.clear() width, height = self.bounds gc.save_state() if self.document is None: # fixme: The Mac backend doesn't accept style/width as non-integers # in set_font, but does for select_font... if sys.platform == 'darwin': gc.select_font("Helvetica", 36) else: gc.set_font(Font("Helvetica", 36)) gc.show_text_at_point("Could not parse document.", 20, height-56) gc.restore_state() if self.profile_this is not None: self.profile_this.stop() return try: # SVG origin is upper right with y positive is down. # Set up the transforms to fix this up. # FIXME: if the rendering stage fails, all subsequent renders are vertically flipped gc.translate_ctm(0, height) # TODO: bother with zoom? # TODO: inspect the view bounds and scale to the shape of the # component? scale = 1.0 gc.scale_ctm(scale, -scale) self.document.render(gc) self.last_render = now() - start finally: gc.restore_state() if self.profile_this is not None: self.profile_this.stop() def _document_changed(self): self.should_profile = True self.invalidate_and_redraw() class ImageComponent(Component): """ Simple component that just renders an RGB(A) array in the upper left hand corner of the component. """ # The RGB(A) data. image = Array() def _draw_mainlayer(self, gc, view_bounds=None, mode='default'): gc.clear() if len(self.image.shape) != 3: # No image. return gc.save_state() try: width, height = self.bounds img_height, img_width = self.image.shape[:2] gc.draw_image(self.image, (0.0,height-img_height,img_width,img_height)) finally: gc.restore_state() def _image_changed(self): self.invalidate_and_redraw() enthought-chaco2-4.5.1.orig/enable/savage/compliance/crosshair.py0000644000175000017500000000660712516137326024066 0ustar varunvarun""" Cross-hair tool for measuring SVG rendering results. """ from enable.api import BaseTool, ColorTrait, LineStyle from traits.api import Bool, Float, HasTraits, List, Tuple, on_trait_change class Crosshair(BaseTool): """ Display a crosshair at the given SVG coordinates. This will do the appropriate transformations in order to map Enable coordinates to SVG coordinates. """ svg_coords = Tuple(Float, Float) line_color = ColorTrait('black') line_width = Float(1.0) line_style = LineStyle("solid") # Whether the mouse is currently inside the component or not. mouse_in = Bool(False) visible = True draw_mode = 'overlay' def draw(self, gc, view_bounds=None): """ Draws this tool on a graphics context. It is assumed that the graphics context has a coordinate transform that matches the origin of its component. (For containers, this is just the origin; for components, it is the origin of their containers.) """ if not self.mouse_in: return # Convert from SVG coordinates to Enable coordinates. h = self.component.height x, y0 = self.svg_coords y = h - y0 gc.save_state() try: gc.set_stroke_color(self.line_color_) gc.set_line_width(self.line_width) gc.set_line_dash(self.line_style_) gc.move_to(self.component.x, y+0.5) gc.line_to(self.component.x2, y+0.5) gc.move_to(x-0.5, self.component.y) gc.line_to(x-0.5, self.component.y2) gc.stroke_path() finally: gc.restore_state() def overlay(self, component, gc, view_bounds=None, mode="normal"): """ Draws this component overlaid on a graphics context. """ self.draw(gc, view_bounds) def do_layout(self, *args, **kw): pass def normal_mouse_enter(self, event): self.mouse_in = True def normal_mouse_leave(self, event): self.mouse_in = False def normal_mouse_move(self, event): """ Handles the mouse being moved. """ if self.component is None: return # Map the Enable coordinates of the event to SVG coordinates. h = self.component.height y = h - event.y self.svg_coords = event.x, y event.handled = True @on_trait_change('svg_coords,mouse_in') def ensure_redraw(self): if self.component is not None: self.component.invalidate_and_redraw() class MultiController(HasTraits): """ Keep multiple Crosshairs in sync. """ svg_coords = Tuple(Float, Float) mouse_in = Bool(False) crosshairs = List() def __init__(self, *crosshairs, **traits): super(MultiController, self).__init__(**traits) for ch in crosshairs: self.add(ch) def add(self, crosshair): """ Synch a new Crosshair. """ if crosshair not in self.crosshairs: self.sync_trait('svg_coords', crosshair) self.sync_trait('mouse_in', crosshair) self.crosshairs.append(crosshair) def remove(self, crosshair): """ Unsynch a recorded Crosshair. """ if crosshair in self.crosshairs: self.sync_trait('svg_coords', crosshair, remove=True) self.sync_trait('mouse_in', crosshair, remove=True) self.crosshairs.append(crosshair) enthought-chaco2-4.5.1.orig/enable/savage/compliance/xml_view.py0000644000175000017500000000662212516137326023720 0ustar varunvarun#!/usr/bin/env python # -*- coding: UTF-8 -*- """ Traits UI tools for viewing the XML tree of SVG files. """ from traits.api import HasTraits, List, Property, Str from traitsui import api as tui known_namespaces = { '{http://www.w3.org/2000/svg}': 'svg', '{http://www.w3.org/2000/02/svg/testsuite/description/}': 'testcase', '{http://www.w3.org/1999/xlink}': 'xlink', '{http://www.w3.org/XML/1998/namespace}': 'xml', '{http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd}': 'sodipodi', '{http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd}': 'sodipodi', '{http://purl.org/dc/elements/1.1/}': 'dc', '{http://web.resource.org/cc/}': 'cc', '{http://www.w3.org/1999/02/22-rdf-syntax-ns#}': 'rdf', '{http://www.inkscape.org/namespaces/inkscape}': 'inkscape', '{http://ns.adobe.com/AdobeIllustrator/10.0/}': 'adobei', '{http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/}': 'adobea', '{http://ns.adobe.com/Graphs/1.0/}': 'graphs', '{http://ns.adobe.com/Extensibility/1.0/}': 'adobex', } def normalize_name(name): """ Normalize XML names to abbreviate namespaces. """ for ns in known_namespaces: if name.startswith(ns): name = '%s:%s' % (known_namespaces[ns], name[len(ns):]) return name class Attribute(HasTraits): """ View model for an XML attribute. """ name = Str() value = Str() label = Property() def _get_label(self): return '%s : %s' % (normalize_name(self.name), self.value) class Element(HasTraits): """ View model for an XML element. """ tag = Str() children = List() attributes = List(Attribute) text = Str() label = Property() kids = Property() def _get_label(self): return normalize_name(self.tag) def _get_kids(self): kids = self.children + self.attributes if self.text: kids.append(Attribute(value=self.text)) return kids def xml_to_tree(root): """ Convert an ElementTree Element to the view models for viewing in the TreeEditor. """ element = Element(tag=root.tag) if root.text is not None: element.text = root.text.strip() for name in sorted(root.keys()): element.attributes.append(Attribute(name=name, value=root.get(name))) for child in root: element.children.append(xml_to_tree(child)) return element xml_tree_editor = tui.TreeEditor( nodes = [ tui.TreeNode( node_for = [Element], children = 'kids', label = 'label', menu = False, ), tui.TreeNode( node_for = [Attribute], children = '', label = 'label', menu = False, ) ], editable = False, show_icons = False, ) class XMLTree(tui.ModelView): """ Handler for viewing XML trees. """ traits_view = tui.View( tui.Item('model', editor=xml_tree_editor, show_label=False), width=1024, height=768, resizable=True, ) @classmethod def fromxml(cls, root, **traits): return cls(model=xml_to_tree(root), **traits) def main(): from xml.etree import cElementTree as ET import argparse parser = argparse.ArgumentParser() parser.add_argument('file') args = parser.parse_args() xml = ET.parse(args.file).getroot() t = XMLTree.fromxml(xml) t.configure_traits() if __name__ == '__main__': main() enthought-chaco2-4.5.1.orig/enable/savage/compliance/sike.py0000644000175000017500000002727212516137326023025 0ustar varunvarun#!/usr/bin/env python # -*- coding: UTF-8 -*- from collections import defaultdict import os import pstats from traits.api import (Any, Bool, Constant, Dict, Event, Float, HasTraits, Instance, Int, List, Property, Str, on_trait_change) from traitsui import api as tui from traitsui.tabular_adapter import TabularAdapter class SuperTuple(tuple): """ Generic super-tuple using pre-defined attribute names. """ __names__ = [] def __new__(cls, *args, **kwds): self = tuple.__new__(cls, *args, **kwds) for i, attr in enumerate(cls.__names__): setattr(self, attr, self[i]) return self class Subrecord(SuperTuple): """ The records referring to the calls a function makes. """ __names__ = ['file_line_name', 'ncalls', 'nonrec_calls', 'inline_time', 'cum_time'] @property def file(self): return self[0][0] @property def line(self): return self[0][1] @property def func_name(self): return self[0][2] class Record(Subrecord): """ The top-level profiling record of a function. """ __names__ = ['file_line_name', 'ncalls', 'nonrec_calls', 'inline_time', 'cum_time', 'callers'] profile_columns = [ ('# Calls', 'ncalls'), ('# Nonrec', 'nonrec_calls'), ('Self Time', 'inline_time'), ('Cum. Time', 'cum_time'), ('Name', 'func_name'), ('Line', 'line'), ('File', 'file'), ] class ProfileAdapter(TabularAdapter): """ Display profiling records in a TabularEditor. """ columns = profile_columns # Whether filenames should only be displayed as basenames or not. basenames = Bool(True, update=True) # Whether times should be shown as percentages or not. percentages = Bool(True, update=True) # The total time to use for calculating percentages. total_time = Float(1.0, update=True) ncalls_width = Constant(55) nonrec_calls_width = Constant(55) inline_time_width = Constant(75) cum_time_width = Constant(75) func_name_width = Constant(200) line_width = Constant(50) ncalls_alignment = Constant('right') nonrec_calls_alignment = Constant('right') inline_time_alignment = Constant('right') cum_time_alignment = Constant('right') line_alignment = Constant('right') file_text = Property(Str) inline_time_text = Property(Str) cum_time_text = Property(Str) def _get_file_text(self): fn = self.item.file_line_name[0] if self.basenames and fn != '~': fn = os.path.basename(fn) return fn def _get_inline_time_text(self): if self.percentages: return '%2.3f' % (self.item.inline_time * 100.0 / self.total_time) else: return str(self.item.inline_time) def _get_cum_time_text(self): if self.percentages: return '%2.3f' % (self.item.cum_time * 100.0 / self.total_time) else: return str(self.item.cum_time) def get_profile_editor(adapter): return tui.TabularEditor( adapter=adapter, editable=False, operations=[], selected='selected_record', column_clicked='column_clicked', dclicked='dclicked', ) class ProfileResults(HasTraits): """ Display profiling results. """ # The sorted list of Records that mirrors this dictionary. records = List() selected_record = Any() dclicked = Event() column_clicked = Event() # The total time in seconds for the set of records. total_time = Float(1.0) # The column name to sort on. sort_key = Str('inline_time') sort_ascending = Bool(False) adapter = Instance(ProfileAdapter) basenames = Bool(True) percentages = Bool(True) def trait_view(self, name=None, view_element=None): if name or view_element is not None: return super(ProfileResults, self).trait_view(name=name, view_element=view_element) view = tui.View( tui.Group( tui.Item('total_time', style='readonly'), ), tui.Item('records', editor=get_profile_editor(self.adapter), show_label=False), width=1024, height=768, resizable=True, ) return view def sorter(self, record): """ Return the appropriate sort key for sorting the records. """ return getattr(record, self.sort_key) def sort_records(self, records): """ Resort the records according to the current settings. """ records = sorted(records, key=self.sorter) if not self.sort_ascending: records = records[::-1] return records def _adapter_default(self): return ProfileAdapter(basenames=self.basenames, percentages=self.percentages, total_time=self.total_time) @on_trait_change('total_time,percentages,basenames') def _adapter_traits_changed(self, object, name, old, new): setattr(self.adapter, name, new) @on_trait_change('sort_key,sort_ascending') def _resort(self): self.records = self.sort_records(self.records) def _column_clicked_changed(self, new): if new is None: return if isinstance(new.column, int): key = profile_columns[new.column][1] else: key = new.column if key == self.sort_key: # Just flip the order. self.sort_ascending = not self.sort_ascending else: self.trait_set(sort_ascending=False, sort_key=key) class SillyStatsWrapper(object): """ Wrap any object with a .stats attribute or a .stats dictionary such that it can be passed to a Stats() constructor. """ def __init__(self, obj=None): if obj is None: self.stats = {} elif isinstance(obj, dict): self.stats = obj elif isinstance(obj, basestring): # Load from a file. self.stats = pstats.Stats(obj) elif hasattr(obj, 'stats'): self.stats = obj.stats elif hasattr(obj, 'create_stats'): obj.create_stats() self.stats = obj.stats else: raise TypeError("don't know how to fake a Stats with %r" % (obj,)) def create_stats(self): pass @classmethod def getstats(cls, obj=None): self = cls(obj) return pstats.Stats(self) class Sike(HasTraits): """ Tie several profile-related widgets together. Sike is like Gotcha, only less mature. """ # The main pstats.Stats() object providing the data. stats = Any() # The main results and the subcalls. main_results = Instance(ProfileResults, args=()) caller_results = Instance(ProfileResults, args=()) callee_results = Instance(ProfileResults, args=()) # The records have list of callers. Invert this to give a map from function # to callee. callee_map = Dict() # Map from the (file, lineno, name) tuple to the record. record_map = Dict() #### GUI traits ############################################################ basenames = Bool(True) percentages = Bool(True) filename = Str() line = Int(1) code = Str() traits_view = tui.View( tui.VGroup( tui.HGroup( tui.Item('basenames'), tui.Item('percentages'), ), tui.HGroup( tui.UItem('main_results'), tui.VGroup( tui.Label('Callees'), tui.UItem('callee_results'), tui.Label('Callers'), tui.UItem('caller_results'), tui.UItem('filename', style='readonly'), tui.UItem('code', editor=tui.CodeEditor(line='line')), ), style='custom', ), ), width=1024, height=768, resizable=True, title='Profiling results', ) @classmethod def fromstats(cls, stats, **traits): """ Instantiate an Sike from a Stats object, Stats.stats dictionary, or Profile object, or a filename of the saved Stats data. """ stats = SillyStatsWrapper.getstats(stats) self = cls(stats=stats, **traits) self._refresh_stats() return self def add_stats(self, stats): """ Add new statistics. """ stats = SillyStatsWrapper.getstats(stats) self.stats.add(stats) self._refresh_stats() def records_from_stats(self, stats): """ Create a list of records from a stats dictionary. """ records = [] for file_line_name, (ncalls, nonrec_calls, inline_time, cum_time, calls) in stats.items(): newcalls = [] for sub_file_line_name, sub_call in calls.items(): newcalls.append(Subrecord((sub_file_line_name,) + sub_call)) records.append(Record((file_line_name, ncalls, nonrec_calls, inline_time, cum_time, newcalls))) return records def get_callee_map(self, records): """ Create a callee map. """ callees = defaultdict(list) for record in records: for caller in record.callers: callees[caller.file_line_name].append( Subrecord((record.file_line_name,)+caller[1:])) return callees @on_trait_change('percentages,basenames') def _adapter_traits_changed(self, object, name, old, new): for obj in [self.main_results, self.callee_results, self.caller_results]: setattr(obj, name, new) @on_trait_change('main_results:selected_record') def update_sub_results(self, new): if new is None: return self.caller_results.total_time = new.cum_time self.caller_results.records = new.callers self.callee_results._resort() self.caller_results.selected_record = self.caller_results.activated_record = None self.callee_results.total_time = new.cum_time self.callee_results.records = self.callee_map.get(new.file_line_name, []) self.callee_results._resort() self.callee_results.selected_record = self.callee_results.activated_record = None filename, line, name = new.file_line_name if os.path.exists(filename): with open(filename, 'ru') as f: code = f.read() self.code = code self.filename = filename self.line = line else: self.trait_set( code = '', filename = '', line = 1, ) @on_trait_change('caller_results:dclicked,' 'callee_results:dclicked') def goto_record(self, new): if new is None: return if new.item.file_line_name in self.record_map: record = self.record_map[new.item.file_line_name] self.main_results.selected_record = record @on_trait_change('stats') def _refresh_stats(self): """ Refresh the records from the stored Stats object. """ self.main_results.records = self.main_results.sort_records( self.records_from_stats(self.stats.stats)) self.callee_map = self.get_callee_map(self.main_results.records) self.record_map = {} total_time = 0.0 for record in self.main_results.records: self.record_map[record.file_line_name] = record total_time += record.inline_time self.main_results.total_time = total_time def main(): import argparse parser = argparse.ArgumentParser() parser.add_argument('file') args = parser.parse_args() stats = pstats.Stats(args.file) app = Sike.fromstats(stats) app.configure_traits() if __name__ == '__main__': main() enthought-chaco2-4.5.1.orig/enable/savage/svg/0000755000175000017500000000000012516137725020176 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/svg/svg_extras.py0000644000175000017500000001222612516137326022735 0ustar varunvarun""" Extra math for implementing SVG on top of Kiva. """ import sys from math import acos, sin, cos, hypot, ceil, sqrt, radians, degrees import warnings def bezier_arc(x1,y1, x2,y2, start_angle=0, extent=90): """ Compute a cubic Bezier approximation of an elliptical arc. (x1, y1) and (x2, y2) are the corners of the enclosing rectangle. The coordinate system has coordinates that increase to the right and down. Angles, measured in degress, start with 0 to the right (the positive X axis) and increase counter-clockwise. The arc extends from start_angle to start_angle+extent. I.e. start_angle=0 and extent=180 yields an openside-down semi-circle. The resulting coordinates are of the form (x1,y1, x2,y2, x3,y3, x4,y4) such that the curve goes from (x1, y1) to (x4, y4) with (x2, y2) and (x3, y3) as their respective Bezier control points. """ x1,y1, x2,y2 = min(x1,x2), max(y1,y2), max(x1,x2), min(y1,y2) if abs(extent) <= 90: frag_angle = float(extent) nfrag = 1 else: nfrag = int(ceil(abs(extent)/90.)) if nfrag == 0: warnings.warn('Invalid value for extent: %r' % extent) return [] frag_angle = float(extent) / nfrag x_cen = (x1+x2)/2. y_cen = (y1+y2)/2. rx = (x2-x1)/2. ry = (y2-y1)/2. half_angle = radians(frag_angle) / 2 kappa = abs(4. / 3. * (1. - cos(half_angle)) / sin(half_angle)) if frag_angle < 0: sign = -1 else: sign = 1 point_list = [] for i in range(nfrag): theta0 = radians(start_angle + i*frag_angle) theta1 = radians(start_angle + (i+1)*frag_angle) c0 = cos(theta0) c1 = cos(theta1) s0 = sin(theta0) s1 = sin(theta1) if frag_angle > 0: signed_kappa = -kappa else: signed_kappa = kappa point_list.append((x_cen + rx * c0, y_cen - ry * s0, x_cen + rx * (c0 + signed_kappa * s0), y_cen - ry * (s0 - signed_kappa * c0), x_cen + rx * (c1 - signed_kappa * s1), y_cen - ry * (s1 + signed_kappa * c1), x_cen + rx * c1, y_cen - ry * s1)) return point_list def angle(x1,y1, x2,y2): """ The angle in degrees between two vectors. """ sign = 1.0 usign = (x1*y2 - y1*x2) if usign < 0: sign = -1.0 num = x1*x2 + y1*y2 den = hypot(x1,y1) * hypot(x2,y2) ratio = min(max(num/den, -1.0), 1.0) return sign * degrees(acos(ratio)) def transform_from_local(xp,yp,cphi,sphi,mx,my): """ Transform from the local frame to absolute space. """ x = xp * cphi - yp * sphi + mx y = xp * sphi + yp * cphi + my return (x,y) def elliptical_arc_to(path, rx, ry, phi, large_arc_flag, sweep_flag, x1, y1, x2, y2): """ Add an elliptical arc to the kiva CompiledPath by approximating it with Bezier curves or a line segment. Algorithm taken from the SVG 1.1 Implementation Notes: http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes """ # Basic normalization. rx = abs(rx) ry = abs(ry) phi = phi % 360 # Check for certain special cases. if x1==x2 and y1==y2: # Omit the arc. # x1 and y1 can obviously remain the same for the next segment. return [] if rx == 0 or ry == 0: # Line segment. path.line_to(x2,y2) return [] rphi = radians(phi) cphi = cos(rphi) sphi = sin(rphi) # Step 1: Rotate to the local coordinates. dx = 0.5*(x1 - x2) dy = 0.5*(y1 - y2) x1p = cphi * dx + sphi * dy y1p = -sphi * dx + cphi * dy # Ensure that rx and ry are large enough to have a unique solution. lam = (x1p/rx)**2 + (y1p/ry)**2 if lam > 1.0: scale = sqrt(lam) rx *= scale ry *= scale # Step 2: Solve for the center in the local coordinates. num = max((rx*ry)**2 - (rx*y1p)**2 - (ry*x1p)**2, 0.0) den = ((rx*y1p)**2 + (ry*x1p)**2) a = sqrt(num / den) cxp = a * rx*y1p/ry cyp = -a * ry*x1p/rx if large_arc_flag == sweep_flag: cxp = -cxp cyp = -cyp # Step 3: Transform back. mx = 0.5*(x1+x2) my = 0.5*(y1+y2) # Step 4: Compute the start angle and the angular extent of the arc. # Note that theta1 is local to the phi-rotated coordinate space. dx = (x1p-cxp) / rx dy = (y1p-cyp) / ry dx2 = (-x1p-cxp) / rx dy2 = (-y1p-cyp) / ry theta1 = angle(1,0,dx,dy) dtheta = angle(dx,dy,dx2,dy2) if not sweep_flag and dtheta > 0: dtheta -= 360 elif sweep_flag and dtheta < 0: dtheta += 360 # Step 5: Break it apart into Bezier arcs. arcs = [] control_points = bezier_arc(cxp-rx,cyp-ry,cxp+rx,cyp+ry, theta1, dtheta) for x1p,y1p, x2p,y2p, x3p,y3p, x4p,y4p in control_points: # Transform them back to asbolute space. args = ( transform_from_local(x2p,y2p,cphi,sphi,mx,my) + transform_from_local(x3p,y3p,cphi,sphi,mx,my) + transform_from_local(x4p,y4p,cphi,sphi,mx,my) ) arcs.append(args) return arcs enthought-chaco2-4.5.1.orig/enable/savage/svg/backends/0000755000175000017500000000000012516137725021750 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/svg/backends/__init__.py0000644000175000017500000000000012516137326024044 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/svg/backends/kiva/0000755000175000017500000000000012516137725022702 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/svg/backends/kiva/__init__.py0000644000175000017500000000000012516137326024776 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/svg/backends/kiva/renderer.py0000644000175000017500000004324712516137326025071 0ustar varunvarunfrom math import sqrt, pi import sys import warnings import numpy as np from enable.compiled_path import CompiledPath as KivaCompiledPath from kiva import affine, constants, fonttools from kiva.fonttools import Font from enable.savage.svg import svg_extras from enable.savage.svg.backends.null.null_renderer import NullRenderer, AbstractGradientBrush # Get the Canvas class for drawing on... def _GetCurrentPoint(gc): total_vertices = gc.total_vertices() if total_vertices == 0: return (0.0, 0.0) return gc.vertex(total_vertices-1)[0] class CompiledPath(KivaCompiledPath): AddPath = KivaCompiledPath.add_path AddRectangle = KivaCompiledPath.rect MoveToPoint = KivaCompiledPath.move_to AddLineToPoint = KivaCompiledPath.line_to CloseSubpath = KivaCompiledPath.close_path if hasattr(KivaCompiledPath, 'get_current_point'): GetCurrentPoint = KivaCompiledPath.get_current_point else: GetCurrentPoint = _GetCurrentPoint AddQuadCurveToPoint = KivaCompiledPath.quad_curve_to def AddCurveToPoint(self, ctrl1, ctrl2, endpoint): self.curve_to(ctrl1[0], ctrl1[1], ctrl2[0], ctrl2[1], endpoint[0], endpoint[1]) def AddEllipticalArcTo(self, x, y, w, h, theta0, dtheta, phi=0): for i, (x1,y1, x2,y2, x3,y3, x4,y4) in enumerate(svg_extras.bezier_arc( x, y, x+w, y+h, theta0, dtheta)): self.curve_to(x2,y2, x3,y3, x4,y4) def elliptical_arc_to(self, rx, ry, phi, large_arc_flag, sweep_flag, x2, y2): if sys.platform == 'darwin': x1, y1 = self.get_current_point() else: def _get_current_point(path): total_vertices = path.total_vertices() if total_vertices == 0: return (0.0, 0.0) return path.vertex(total_vertices-1)[0] x1, y1 = _get_current_point(self) arcs = svg_extras.elliptical_arc_to(self, rx, ry, phi, large_arc_flag, sweep_flag, x1, y1, x2, y2) for arc in arcs: self.curve_to(*arc) def AddCircle(self, x, y, r): self.arc(x, y, r, 0.0, 2*pi) def AddEllipse(self, cx,cy, rx,ry): for i, (x1,y1, x2,y2, x3,y3, x4,y4) in enumerate(svg_extras.bezier_arc( cx-rx, cy-ry, cx+rx, cy+ry, 0, 360)): if i == 0: self.move_to(x1,y1) self.curve_to(x2,y2, x3,y3, x4,y4) def AddRoundedRectangleEx(self, x, y, w, h, rx, ry): #origin self.move_to(x+rx, y) self.line_to(x+w-rx, y) #top right cx = rx * 2 cy = ry * 2 self.AddEllipticalArcTo( x+w-cx, y, cx, cy, 270, 90, ) self.AddLineToPoint(x+w, y+h-ry) #top left self.AddEllipticalArcTo( x+w-cx, y+h-cy, cx, cy, 0, 90, ) self.line_to(x+rx, y+h) #bottom left self.AddEllipticalArcTo( x, y+h-cy, cx, cy, 90, 90, ) self.line_to(x, y+ry) #bottom right self.AddEllipticalArcTo( x, y, cx, cy, 180, 90, ) self.close_path() class Pen(object): def __init__(self, color): # fixme: what format is the color passed in? int or float self.color = color self.cap = constants.CAP_BUTT self.join = constants.JOIN_MITER self.width = 1 self.dasharray = None self.dashoffset = 0.0 def SetCap(self, cap): self.cap = cap def SetJoin(self, join): self.join = join def SetWidth(self, width): self.width = width def SetDash(self, dasharray, dashoffset=0.0): self.dasharray = dasharray self.dashoffset = dashoffset def set_on_gc(self, gc): """ Set the appropriate properties on the GraphicsContext. """ # fixme: Should the pen affect text as well? # fixme: How about line style, thickness, etc. # translate from 0-255 to 0-1 values. color = tuple([x/255.0 for x in self.color]) gc.set_stroke_color(color) gc.set_line_join(self.join) gc.set_line_cap(self.cap) gc.set_line_width(self.width) if self.dasharray is not None: gc.set_line_dash(self.dasharray, self.dashoffset) class ColorBrush(object): def __init__(self, color): # fixme: what format is the color passed in? int or float self.color = color # fixme: This was needed for a font setting in document. # Fix this and remove. self.Colour = self.color def __repr__(self): return 'ColorBrush(%r)' % (self.color,) def IsOk(self): return True def set_on_gc(self, gc): """ Set the appropriate properties on the GraphicsContext. """ # translate from 0-255 to 0-1 values. try: color = tuple([x/255.0 for x in list(self.color)]) except: color = (0,0,0,1) gc.set_fill_color(color) class LinearGradientBrush(AbstractGradientBrush): """ A Brush representing a linear gradient. """ def __init__(self, x1,y1, x2,y2, stops, spreadMethod='pad', transforms=[], units='userSpaceOnUse'): self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 self.stops = stops self.spreadMethod = spreadMethod self.transforms = transforms self.units = units def __repr__(self): return ('LinearGradientBrush(%r,%r, %r,%r, %r, spreadMethod=%r, ' 'transforms=%r, units=%r)' % (self.x1,self.y1, self.x2,self.y2, self.stops, self.spreadMethod, self.transforms, self.units)) def set_on_gc(self, gc, bbox=None): # Apply transforms if self.transforms is not None: for func, f_args in self.transforms: if isinstance(f_args, tuple): func(gc, *f_args) else: func(gc, f_args) x1 = self.x1 x2 = self.x2 y1 = self.y1 y2 = self.y2 if sys.platform == 'darwin': if self.spreadMethod != 'pad': warnings.warn("spreadMethod %r is not supported. Using 'pad'" % self.spreadMethod) if bbox is not None: gc.clip_to_rect(*bbox) else: if self.units == 'objectBoundingBox' and bbox is not None: x1 = (bbox[2] + bbox[0])*x1 y1 = (bbox[3] + bbox[1])*y1 x2 = (bbox[2] + bbox[0])*x2 y2 = (bbox[3] + bbox[1])*y2 self.bbox_transform(gc, bbox) stops = np.transpose(self.stops) gc.linear_gradient(x1, y1, x2, y2, stops, self.spreadMethod, self.units) class RadialGradientBrush(AbstractGradientBrush): """ A Brush representing a radial gradient. """ def __init__(self, cx,cy, r, stops, fx=None,fy=None, spreadMethod='pad', transforms=[], units='userSpaceOnUse'): self.cx = cx self.cy = cy self.r = r self.stops = stops if fx is None: fx = self.cx self.fx = fx if fy is None: fy = self.cy self.fy = fy self.spreadMethod = spreadMethod self.transforms = transforms self.units = units def __repr__(self): return ('RadialGradientBrush(%r,%r, %r, %r, fx=%r,fy=%r, ' 'spreadMethod=%r, transforms=%r, units=%r)' % (self.cx,self.cy, self.r, self.stops, self.fx,self.fy, self.spreadMethod, self.transforms, self.units)) def set_on_gc(self, gc, bbox=None): if self.transforms is not None: for func, f_args in self.transforms: if isinstance(f_args, tuple): func(gc, *f_args) else: func(gc, f_args) cx = self.cx cy = self.cy r = self.r fx = self.fx fy = self.fy if sys.platform == 'darwin': if self.spreadMethod != 'pad': warnings.warn("spreadMethod %r is not supported. Using 'pad'" % self.spreadMethod) if bbox is not None: gc.clip_to_rect(*bbox) else: if self.units == 'objectBoundingBox' and bbox is not None: cx = (bbox[2] + bbox[0])*cx cy = (bbox[3] + bbox[1])*cy fx = (bbox[2] + bbox[0])*fx fy = (bbox[3] + bbox[1])*fy r *= np.sqrt((bbox[2] - bbox[0])**2 + (bbox[3] - bbox[1])**2) self.bbox_transform(gc, bbox) stops = np.transpose(self.stops) gc.radial_gradient(cx, cy, r, fx, fy, stops, self.spreadMethod, self.units) def font_style(font): """ Return a string for the font style of a given font. fixme: Shouldn't the backends handle this? """ if font.style == 'italic' and font.weight == 'bold': style = 'bold italic' elif font.style == 'italic': style = 'italic' elif font.weight== 'bold': style = 'bold' elif font.style in [0, 'regular','normal']: style = 'regular' else: print "Font style '%s' and weight: '%s' not known." \ " Using style='regular'" % (font.style, font.weight) style = 'regular' return style class Renderer(NullRenderer): # fimxe: Shouldn't this just be the GraphicsContext? NullBrush = None NullGraphicsBrush = None NullPen = None TransparentPen = Pen((1.0, 1.0, 1.0, 0.0)) caps = { 'butt':constants.CAP_BUTT, 'round':constants.CAP_ROUND, 'square':constants.CAP_SQUARE } joins = { 'miter':constants.JOIN_MITER, 'round':constants.JOIN_ROUND, 'bevel':constants.JOIN_BEVEL } fill_rules = {'nonzero':constants.FILL, 'evenodd': constants.EOF_FILL} def __init__(self): pass @classmethod def concatTransform(cls, gc, matrix): return gc.concat_ctm(matrix) @classmethod def createAffineMatrix(cls, a,b,c,d,x,y): # FIXME: should we create a 6x1 or 3x3 matrix??? return (a,b,c,d,x,y) # return affine.affine_from_values(a,b,c,d,x,y) @classmethod def createBrush(cls, color_tuple): return ColorBrush(color_tuple) @classmethod def createNativePen(cls, pen): # fixme: Not really sure what to do here... #return wx.GraphicsRenderer_GetDefaultRenderer().CreatePen(pen) return pen @classmethod def createPen(cls, color_tuple): return Pen(color_tuple) @classmethod def createLinearGradientBrush(cls, x1,y1,x2,y2, stops, spreadMethod='pad', transforms=[], units='userSpaceOnUse'): return LinearGradientBrush(x1,y1,x2,y2,stops, spreadMethod, transforms, units) @classmethod def createRadialGradientBrush(cls, cx,cy, r, stops, fx=None,fy=None, spreadMethod='pad', transforms=[], units='userSpaceOnUse'): return RadialGradientBrush(cx,cy, r, stops, fx,fy, spreadMethod, transforms, units) @classmethod def getCurrentPoint(cls, path): return path.GetCurrentPoint() @classmethod def getFont(cls, font_name='Arial'): kiva_style = constants.NORMAL if '-' in font_name: font_name, style = font_name.split('-', 2) style = style.lower() if 'bold' in style: kiva_style += constants.BOLD if 'italic' in style: kiva_style += constants.ITALIC return Font(font_name, style=kiva_style) @classmethod def makeMatrix(cls, *args): raise NotImplemented() @classmethod def makePath(cls): return CompiledPath() @classmethod def popState(cls, gc): return gc.restore_state() @classmethod def pushState(cls, gc): return gc.save_state() @classmethod def setFontSize(cls, font, size): # Agg expects only integer fonts font.size = int(size) return font @classmethod def setFontStyle(cls, font, style): if isinstance(style, basestring): if style not in fonttools.font.font_styles: warnings.warn('font style "%s" not supported' % style) else: font.style = fonttools.font.font_styles[style] else: font.style = style @classmethod def setFontWeight(cls, font, weight): if isinstance(weight, basestring): if weight not in fonttools.font.font_weights: warnings.warn('font weight "%s" not supported' % weight) else: font.weight = fonttools.font.font_weights[weight] else: font.weight = weight @classmethod def setFont(cls, gc, font, brush): color = tuple([c/255.0 for c in getattr(brush, 'color', (0,0,0))]) # text color is controlled by stroke instead of fill color in kiva. gc.set_stroke_color(color) try: # fixme: The Mac backend doesn't accept style/width as non-integers # in set_font, but does for select_font... if sys.platform == 'darwin': style = font_style(font) gc.select_font(font.face_name, font.size, style=style) else: gc.set_font(font) except ValueError: warnings.warn("failed to find set '%s'. Using Arial" % font.face_name) if sys.platform == 'darwin': style = font_style(font) gc.select_font('Arial', font.size, style) else: gc.set_font(font) @classmethod def setBrush(cls, gc, brush): if brush is Renderer.NullBrush: #fixme: What do I do in this case? Seem pass else: brush.set_on_gc(gc) @classmethod def setPen(cls, gc, pen): pen.set_on_gc(gc) @classmethod def setPenDash(cls, pen, dasharray, offset): pen.SetDash(dasharray, offset) @classmethod def strokePath(cls, gc, path): # fixme: Do we need to clear the path first? gc.add_path(path) return gc.stroke_path() @classmethod def fillPath(cls, gc, path, mode): # fixme: Do we need to clear the path first? gc.add_path(path) return gc.draw_path(mode) @classmethod def gradientPath(cls, gc, path, brush): gc.save_state() gc.add_path(path) gc.clip() if hasattr(path, 'get_bounding_box'): bbox = path.get_bounding_box() else: bbox = [np.inf, np.inf, -np.inf, -np.inf] for i in range(path.total_vertices()): vertex = path.vertex(i) bbox[0] = min(bbox[0], vertex[0][0]) bbox[1] = min(bbox[1], vertex[0][1]) bbox[2] = max(bbox[2], vertex[0][0]) bbox[3] = max(bbox[3], vertex[0][1]) brush.set_on_gc(gc, bbox=bbox) gc.close_path() gc.fill_path() gc.restore_state() @classmethod def clipPath(cls, gc, path): gc.add_path(path) return gc.clip() @classmethod def translate(cls, gc, *args): return gc.translate_ctm(*args) @classmethod def rotate(cls, gc, angle): return gc.rotate_ctm(angle) @classmethod def scale(cls, gc, sx, sy): return gc.scale_ctm(sx, sy) @classmethod def GetTextExtent(cls, gc, text): x, y, w, h = gc.get_text_extent(text) return w, h @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. fixme: Handle gradients...? """ gc.save_state() try: color = tuple([c/255.0 for c in getattr(brush, 'color', (0,0,0))]) # Setting stroke instead of fill color because that is # what kiva uses. gc.set_stroke_color(color) # PDF (our API) has the origin in the lower left. # SVG (what we are rendering) has the origin in the upper right. # The ctm (our API) has been set up with a scaling and translation to # draw as if the upper right is the origin and positive is down so # that the SVG will render correctly. This works great accept for # text which will render up side down. To fix this, we set the # text transform matrix to have y going up so the text is rendered # upright. But since, +y is now *up*, we need to draw at -y. # fixme: There is something wrong with the text matrix. The following # commands don't work and I would expect them to. #text_matrix = affine.affine_from_values(1,0,0,-1,x,-y) #gc.set_text_matrix(text_matrix) #gc.show_text_at_point(text, 0, 0) if anchor != 'start': tx, ty, tw, th = gc.get_text_extent(text) if anchor == 'middle': x -= tw/2.0 elif anchor == 'end': x -= tw gc.scale_ctm(1.0, -1.0) gc.show_text_at_point(text, x, -y) finally: gc.restore_state() @classmethod def DrawImage(cls, gc, image, x, y, width, height): rect = (x, y, width, height) gc.save_state() gc.translate_ctm(x, y+height) gc.scale_ctm(1.0, -1.0) gc.draw_image(image, (0,0,width,height)) gc.restore_state() enthought-chaco2-4.5.1.orig/enable/savage/svg/backends/null/0000755000175000017500000000000012516137725022722 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/svg/backends/null/null_renderer.py0000644000175000017500000000740512516137326026137 0ustar varunvarunimport 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() enthought-chaco2-4.5.1.orig/enable/savage/svg/backends/null/__init__.py0000644000175000017500000000000012516137326025016 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/svg/backends/wx/0000755000175000017500000000000012516137725022406 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/svg/backends/wx/__init__.py0000644000175000017500000000310412516137326024512 0ustar varunvarun""" """ import math import wx from enable.savage.svg import svg_extras def elliptical_arc_to(self, rx, ry, phi, large_arc_flag, sweep_flag, x2, y2): x1, y1 = self.GetCurrentPoint() arcs = svg_extras.elliptical_arc_to(self, rx, ry, phi, large_arc_flag, sweep_flag, x1, y1, x2, y2) for arc in arcs: path = wx.GraphicsRenderer_GetDefaultRenderer().CreatePath() path.MoveToPoint(x1, y1) path.AddCurveToPoint(*arc) self.AddPath(path) x1, y1 = self.GetCurrentPoint() self.MoveToPoint(x1, y1) self.CloseSubpath() def AddEllipticalArc(self, x, y, width, height, theta, dtheta, clockwise=False): """ Draws an arc of an ellipse within bounding rect (x,y,w,h) from startArc to endArc (in degrees, relative to the horizontal line of the eclipse)""" # compute the cubic bezier and add that to the path by calling AddCurveToPoint sub_paths = svg_extras.bezier_arc(x, y, x+width, y+height, theta, dtheta) for sub_path in sub_paths: x1,y1, cx1, cy1, cx2, cy2, x2,y2 = sub_path path = wx.GraphicsRenderer_GetDefaultRenderer().CreatePath() path.MoveToPoint(x1, y1) path.AddCurveToPoint(cx1, cy1, cx2, cy2, x2, y2) self.AddPath(path) self.MoveToPoint(path.GetCurrentPoint()) self.CloseSubpath() if not hasattr(wx.GraphicsPath, "AddEllipticalArcTo"): wx.GraphicsPath.AddEllipticalArcTo = AddEllipticalArc wx.GraphicsPath.elliptical_arc_to = elliptical_arc_to del AddEllipticalArc enthought-chaco2-4.5.1.orig/enable/savage/svg/backends/wx/renderer.py0000644000175000017500000001516312516137326024571 0ustar varunvarunimport copy import numpy import warnings import wx from enable.savage.svg.backends.null.null_renderer import NullRenderer def _fixup_path_methods(path): def _new_add_rounded_rectangle(self, x, y, w, h, rx, ry): r = numpy.sqrt(rx*rx + ry*ry) self.AddRoundedRectangle(x, y, w, h, r) path.__class__.AddRoundedRectangleEx = _new_add_rounded_rectangle 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 gc.concat_ctm(((w, 0, 0), (0, h, 0), (x0, y0, 1))) class Renderer(NullRenderer): NullBrush = wx.NullBrush NullGraphicsBrush = wx.NullGraphicsBrush NullPen = wx.NullPen TransparentPen = wx.TRANSPARENT_PEN caps = { 'butt':wx.CAP_BUTT, 'round':wx.CAP_ROUND, 'square':wx.CAP_PROJECTING } joins = { 'miter':wx.JOIN_MITER, 'round':wx.JOIN_ROUND, 'bevel':wx.JOIN_BEVEL } fill_rules = {'nonzero':wx.WINDING_RULE, 'evenodd': wx.ODDEVEN_RULE} def __init__(self): pass @staticmethod def concatTransform(*args): return wx.GraphicsContext.ConcatTransform(*args) @staticmethod def createAffineMatrix(a,b,c,d,x,y): return wx.GraphicsRenderer_GetDefaultRenderer().CreateMatrix(a,b,c,d,x,y) @staticmethod def createBrush(color_tuple): return wx.Brush(wx.Colour(*color_tuple)) @staticmethod def createNativePen(pen): return wx.GraphicsRenderer_GetDefaultRenderer().CreatePen(pen) @staticmethod def createPen(color_tuple): return wx.Pen(wx.Colour(*color_tuple)) @staticmethod def createLinearGradientBrush(x1,y1,x2,y2, stops, spreadMethod='pad', transforms=None, units='userSpaceOnUse'): stops = numpy.transpose(stops) if len(stops) > 2: warnings.warn("Wx only supports 2 gradient stops, but %d were specified" % len(stops)) def convert_stop(stop): offset, red, green, blue, opacity = stop color = wx.Colour(red*255, green*255, blue*255, opacity*255) return offset, color start_offset, start_color = convert_stop(stops[0]) end_offset, end_color = convert_stop(stops[1]) wx_renderer = wx.GraphicsRenderer.GetDefaultRenderer() return wx_renderer.CreateLinearGradientBrush(x1, y1, x2, y2, start_color, end_color) @staticmethod def createRadialGradientBrush(cx,cy, r, stops, fx=None,fy=None, spreadMethod='pad', transforms=None, units='userSpaceOnUse'): stops = numpy.transpose(stops) if len(stops) > 2: warnings.warn("Wx only supports 2 gradient stops, but %d were specified" % len(stops)) def convert_stop(stop): offset, red, green, blue, opacity = stop color = wx.Colour(red*255, green*255, blue*255, opacity*255) return offset, color start_offset, start_color = convert_stop(stops[0]) end_offset, end_color = convert_stop(stops[-1]) if fx is None: fx = cx if fy is None: fy = cy wx_renderer = wx.GraphicsRenderer.GetDefaultRenderer() return wx_renderer.CreateRadialGradientBrush(fx, fy, cx, cy, r, start_color, end_color) @staticmethod def fillPath(*args): return wx.GraphicsContext.FillPath(*args) @staticmethod def getCurrentPoint(path): return path.GetCurrentPoint().Get() @staticmethod def getFont(font_name=wx.SYS_DEFAULT_GUI_FONT): return wx.SystemSettings.GetFont(font_name) @staticmethod def makeMatrix(*args): return wx.GraphicsRenderer_GetDefaultRenderer().CreateMatrix(*args) @staticmethod def makePath(): path = wx.GraphicsRenderer_GetDefaultRenderer().CreatePath() _fixup_path_methods(path) return path @staticmethod def popState(*args): return wx.GraphicsContext.PopState(*args) @staticmethod def pushState(state): return wx.GraphicsContext.PushState(state) @staticmethod def rotate(dc, angle): return dc.Rotate(angle) @staticmethod def scale(*args): return wx.GraphicsContext.Scale(*args) @staticmethod def setBrush(*args): wx.GraphicsContext.SetBrush(*args) @staticmethod def setFontSize(font, size): if '__WXMSW__' in wx.PlatformInfo: i = int(size) font.SetPixelSize((i, i)) else: font.SetPointSize(int(size)) return font @classmethod def setFontStyle(cls, font, style): font.style = style @classmethod def setFontWeight(cls, font, weight): font.weight = weight @staticmethod def setPen(*args): wx.GraphicsContext.SetPen(*args) @staticmethod def setPenDash(pen, dasharray, offset): pen.SetDashes(dasharray) @staticmethod def setFont(context, font, brush): return context.SetFont(font, brush.Colour) @staticmethod def strokePath(*args): return wx.GraphicsContext.StrokePath(*args) @staticmethod def clipPath(gc, path): rect = path.GetBox() region = wx.Region(rect.x, rect.y, rect.width, rect.height) gc.ClipRegion(region) @staticmethod def translate(*args): return wx.GraphicsContext.Translate(*args) @staticmethod def DrawText(context, text, x, y, brush=NullGraphicsBrush, anchor='start'): #SVG spec appears to originate text from the bottom #rather than the top as with our API. This function #will measure and then re-orient the text as needed. w, h = context.GetTextExtent(text) if anchor != 'start': if anchor == 'middle': x -= w/2.0 elif anchor == 'end': x -= w y -= h context.DrawText(text, x, y) @staticmethod def DrawImage(context, image, x, y, width, height): # ignore the width & height provided width = image.shape[1] height = image.shape[0] if image.shape[2] == 3: bmp = wx.BitmapFromBuffer(width, height, image.flatten()) else: bmp = wx.BitmapFromBufferRGBA(width, height, image.flatten()) context.DrawBitmap(bmp, x, y, width, height) enthought-chaco2-4.5.1.orig/enable/savage/svg/__init__.py0000644000175000017500000000000012516137326022272 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/svg/attributes.py0000644000175000017500000000255312516137326022740 0ustar varunvarun""" Parsers for specific attributes """ import urlparse from pyparsing import (Literal, Optional, oneOf, Group, StringEnd, Combine, Word, alphas, hexnums, CaselessLiteral, SkipTo ) from css.colour import colourValue import string ##Paint values none = CaselessLiteral("none").setParseAction(lambda t: ["NONE", ()]) currentColor = CaselessLiteral("currentColor").setParseAction(lambda t: ["CURRENTCOLOR", ()]) def parsePossibleURL(t): possibleURL, fallback = t[0] return [urlparse.urlsplit(possibleURL), fallback] #Normal color declaration colorDeclaration = none | currentColor | colourValue urlEnd = ( Literal(")").suppress() + Optional(Group(colorDeclaration), default=()) + StringEnd() ) url = ( CaselessLiteral("URL") + Literal("(").suppress()+ Group(SkipTo(urlEnd, include=True).setParseAction(parsePossibleURL)) ) #paint value will parse into a (type, details) tuple. #For none and currentColor, the details tuple will be the empty tuple #for CSS color declarations, it will be (type, (R,G,B)) #for URLs, it will be ("URL", ((url tuple), fallback)) #The url tuple will be as returned by urlparse.urlsplit, and can be #an empty tuple if the parser has an error #The fallback will be another (type, details) tuple as a parsed #colorDeclaration, but may be the empty tuple if it is not present paintValue = url | colorDeclaration enthought-chaco2-4.5.1.orig/enable/savage/svg/css/0000755000175000017500000000000012516137725020766 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/svg/css/values.py0000644000175000017500000000245512516137326022642 0ustar varunvarun""" Parser for various kinds of CSS values as per CSS2 spec section 4.3 """ from pyparsing import Word, Combine, Optional, Literal, oneOf, CaselessLiteral, StringEnd, OneOrMore def asInt(s,l,t): return int(t[0]) def asFloat(s,l,t): return float(t[0]) def asFloatOrInt(s,l,t): """ Return an int if possible, otherwise a float""" v = t[0] try: return int(v) except ValueError: return float(v) integer = Word("0123456789").setParseAction(asInt) number = Combine( Optional(Word("0123456789")) + Literal(".") + Word("01234567890") | integer ) number.setName('number') sign = oneOf("+ -") signedNumber = Combine(Optional(sign) + number).setParseAction(asFloat) lengthValue = Combine(Optional(sign) + number).setParseAction(asFloatOrInt) lengthValue.setName('lengthValue') lengthUnit = oneOf(['em', 'ex', 'px', 'pt', 'in', 'cm', 'mm', 'pc', '%'], caseless=True) #the spec says that the unit is only optional for a 0 length, but #there are just too many places where a default is permitted. #TODO: Maybe should use a ctor like optional to let clients declare it? length = lengthValue + Optional(lengthUnit, default=None) + StringEnd() length.leaveWhitespace() #set the parse action aftward so it doesn't "infect" the parsers that build on it number.setParseAction(asFloat) enthought-chaco2-4.5.1.orig/enable/savage/svg/css/colour.py0000644000175000017500000001702212516137326022642 0ustar varunvarun""" Parsing for CSS colour values. Supported formats: * hex literal short: #fff * hex literal long: #fafafa * rgb bytes: rgb(255,100,0) * rgb percent: rgb(100%,100%,0%) * named color: black """ import string import urlparse from pyparsing import nums, Literal, Optional, oneOf, Group, StringEnd, Combine, Word, alphas, hexnums from enable.savage.svg.pathdata import number, sign number = number.copy() integerConstant = Word(nums+"+-").setParseAction(lambda t:int(t[0])) #rgb format parser comma = Literal(",").suppress() def clampColourByte(val): val = int(val) return min(max(0,val), 255) def clampColourPerc(val): val = float(val) return min(max(0,val), 100) def parseColorPerc(token): val = token[0] val = clampColourPerc(val) #normalize to bytes return int(255 * (val / 100.0)) colorByte = Optional(sign) + integerConstant.setParseAction(lambda t: clampColourByte(t[0])) colorPerc = number.setParseAction(parseColorPerc) + Literal("%").suppress() rgb = ( Literal("rgb(").setParseAction(lambda t: "RGB") + ( #integer constants, ie 255,255,255 Group(colorByte + comma + colorByte + comma + colorByte) ^ #percentage values, ie 100%, 50% Group(colorPerc + comma + colorPerc + comma + colorPerc) ) + Literal(")").suppress() + StringEnd() ) def parseShortHex(t): return tuple(int(x*2, 16) for x in t[0]) doubleHex = Word(hexnums, exact=2).setParseAction(lambda t: int(t[0], 16)) hexLiteral = (Literal("#").setParseAction(lambda t: "RGB") + ( Group(doubleHex + doubleHex + doubleHex) | Word(hexnums, exact=3).setParseAction(parseShortHex) ) + StringEnd() ) def parseNamedColour(t): try: return ["RGB", NamedColours[t[0].lower()]] except KeyError: return ["RGB", (0,0,0)] namedColour = Word(alphas).setParseAction(parseNamedColour) colourValue = rgb | hexLiteral | namedColour ##constants NamedColours = { #~ #html named colours #~ "black":(0,0,0), #~ "silver": (0xc0, 0xc0, 0xc0, 255), #~ "gray": (0x80, 0x80, 0x80), #~ "white":(255,255,255), #~ "maroon":(0x80, 0, 0), #~ "red":(0xff, 0, 0), #~ "purple":(0x80, 0, 0x80), #~ "fuchsia":(0xff, 0, 0xff), #~ "green": (0, 0x80, 0), #~ "lime": (0, 0xff, 0), #~ "olive": (0x80, 0x80, 00), #~ "yellow":(0xff, 0xff, 00), #~ "navy": (0, 0, 0x80), #~ "blue": (0, 0, 0xff), #~ "teal": (0, 0x80, 0x80), #~ "aqua": (0, 0xff, 0xff), #expanded named colors from SVG spc 'aliceblue' : (240, 248, 255) , 'antiquewhite' : (250, 235, 215) , 'aqua' : ( 0, 255, 255) , 'aquamarine' : (127, 255, 212) , 'azure' : (240, 255, 255) , 'beige' : (245, 245, 220) , 'bisque' : (255, 228, 196) , 'black' : ( 0, 0, 0) , 'blanchedalmond' : (255, 235, 205) , 'blue' : ( 0, 0, 255) , 'blueviolet' : (138, 43, 226) , 'brown' : (165, 42, 42) , 'burlywood' : (222, 184, 135) , 'cadetblue' : ( 95, 158, 160) , 'chartreuse' : (127, 255, 0) , 'chocolate' : (210, 105, 30) , 'coral' : (255, 127, 80) , 'cornflowerblue' : (100, 149, 237) , 'cornsilk' : (255, 248, 220) , 'crimson' : (220, 20, 60) , 'cyan' : ( 0, 255, 255) , 'darkblue' : ( 0, 0, 139) , 'darkcyan' : ( 0, 139, 139) , 'darkgoldenrod' : (184, 134, 11) , 'darkgray' : (169, 169, 169) , 'darkgreen' : ( 0, 100, 0) , 'darkgrey' : (169, 169, 169) , 'darkkhaki' : (189, 183, 107) , 'darkmagenta' : (139, 0, 139) , 'darkolivegreen' : ( 85, 107, 47) , 'darkorange' : (255, 140, 0) , 'darkorchid' : (153, 50, 204) , 'darkred' : (139, 0, 0) , 'darksalmon' : (233, 150, 122) , 'darkseagreen' : (143, 188, 143) , 'darkslateblue' : ( 72, 61, 139) , 'darkslategray' : ( 47, 79, 79) , 'darkslategrey' : ( 47, 79, 79) , 'darkturquoise' : ( 0, 206, 209) , 'darkviolet' : (148, 0, 211) , 'deeppink' : (255, 20, 147) , 'deepskyblue' : ( 0, 191, 255) , 'dimgray' : (105, 105, 105) , 'dimgrey' : (105, 105, 105) , 'dodgerblue' : ( 30, 144, 255) , 'firebrick' : (178, 34, 34) , 'floralwhite' : (255, 250, 240) , 'forestgreen' : ( 34, 139, 34) , 'fuchsia' : (255, 0, 255) , 'gainsboro' : (220, 220, 220) , 'ghostwhite' : (248, 248, 255) , 'gold' : (255, 215, 0) , 'goldenrod' : (218, 165, 32) , 'gray' : (128, 128, 128) , 'grey' : (128, 128, 128) , 'green' : ( 0, 128, 0) , 'greenyellow' : (173, 255, 47) , 'honeydew' : (240, 255, 240) , 'hotpink' : (255, 105, 180) , 'indianred' : (205, 92, 92) , 'indigo' : ( 75, 0, 130) , 'ivory' : (255, 255, 240) , 'khaki' : (240, 230, 140) , 'lavender' : (230, 230, 250) , 'lavenderblush' : (255, 240, 245) , 'lawngreen' : (124, 252, 0) , 'lemonchiffon' : (255, 250, 205) , 'lightblue' : (173, 216, 230) , 'lightcoral' : (240, 128, 128) , 'lightcyan' : (224, 255, 255) , 'lightgoldenrodyellow' : (250, 250, 210) , 'lightgray' : (211, 211, 211) , 'lightgreen' : (144, 238, 144) , 'lightgrey' : (211, 211, 211) , 'lightpink' : (255, 182, 193) , 'lightsalmon' : (255, 160, 122) , 'lightseagreen' : ( 32, 178, 170) , 'lightskyblue' : (135, 206, 250) , 'lightslategray' : (119, 136, 153) , 'lightslategrey' : (119, 136, 153) , 'lightsteelblue' : (176, 196, 222) , 'lightyellow' : (255, 255, 224) , 'lime' : ( 0, 255, 0) , 'limegreen' : ( 50, 205, 50) , 'linen' : (250, 240, 230) , 'magenta' : (255, 0, 255) , 'maroon' : (128, 0, 0) , 'mediumaquamarine' : (102, 205, 170) , 'mediumblue' : ( 0, 0, 205) , 'mediumorchid' : (186, 85, 211) , 'mediumpurple' : (147, 112, 219) , 'mediumseagreen' : ( 60, 179, 113) , 'mediumslateblue' : (123, 104, 238) , 'mediumspringgreen' : ( 0, 250, 154) , 'mediumturquoise' : ( 72, 209, 204) , 'mediumvioletred' : (199, 21, 133) , 'midnightblue' : ( 25, 25, 112) , 'mintcream' : (245, 255, 250) , 'mistyrose' : (255, 228, 225) , 'moccasin' : (255, 228, 181) , 'navajowhite' : (255, 222, 173) , 'navy' : ( 0, 0, 128) , 'oldlace' : (253, 245, 230) , 'olive' : (128, 128, 0) , 'olivedrab' : (107, 142, 35) , 'orange' : (255, 165, 0) , 'orangered' : (255, 69, 0) , 'orchid' : (218, 112, 214) , 'palegoldenrod' : (238, 232, 170) , 'palegreen' : (152, 251, 152) , 'paleturquoise' : (175, 238, 238) , 'palevioletred' : (219, 112, 147) , 'papayawhip' : (255, 239, 213) , 'peachpuff' : (255, 218, 185) , 'peru' : (205, 133, 63) , 'pink' : (255, 192, 203) , 'plum' : (221, 160, 221) , 'powderblue' : (176, 224, 230) , 'purple' : (128, 0, 128) , 'red' : (255, 0, 0) , 'rosybrown' : (188, 143, 143) , 'royalblue' : ( 65, 105, 225) , 'saddlebrown' : (139, 69, 19) , 'salmon' : (250, 128, 114) , 'sandybrown' : (244, 164, 96) , 'seagreen' : ( 46, 139, 87) , 'seashell' : (255, 245, 238) , 'sienna' : (160, 82, 45) , 'silver' : (192, 192, 192) , 'skyblue' : (135, 206, 235) , 'slateblue' : (106, 90, 205) , 'slategray' : (112, 128, 144) , 'slategrey' : (112, 128, 144) , 'snow' : (255, 250, 250) , 'springgreen' : ( 0, 255, 127) , 'steelblue' : ( 70, 130, 180) , 'tan' : (210, 180, 140) , 'teal' : ( 0, 128, 128) , 'thistle' : (216, 191, 216) , 'tomato' : (255, 99, 71) , 'turquoise' : ( 64, 224, 208) , 'violet' : (238, 130, 238) , 'wheat' : (245, 222, 179) , 'white' : (255, 255, 255) , 'whitesmoke' : (245, 245, 245) , 'yellow' : (255, 255, 0) , 'yellowgreen' : (154, 205, 50) , } enthought-chaco2-4.5.1.orig/enable/savage/svg/css/atrule.py0000644000175000017500000000021612516137326022630 0ustar varunvarun""" CSS at-rules""" from pyparsing import Literal, Combine from identifier import identifier atkeyword = Combine(Literal("@") + identifier) enthought-chaco2-4.5.1.orig/enable/savage/svg/css/__init__.py0000644000175000017500000000010312516137326023066 0ustar varunvarunfrom transform import transformList from inline import inlineStyle enthought-chaco2-4.5.1.orig/enable/savage/svg/css/inline.py0000644000175000017500000000037212516137326022615 0ustar varunvarun""" Parser for inline CSS in style attributes """ def inlineStyle(styleString): if len(styleString) == 0: return {} styles = styleString.split(";") rv = dict(style.split(":") for style in styles if len(style) != 0) return rv enthought-chaco2-4.5.1.orig/enable/savage/svg/css/identifier.py0000644000175000017500000000212612516137326023460 0ustar varunvarun""" Parse CSS identifiers. More complicated than it sounds""" from pyparsing import Word, Literal, Regex, Combine, Optional, White, oneOf, ZeroOrMore import string import re class White(White): """ Customize whitespace to match the CSS spec values""" def __init__(self, ws=" \t\r\n\f", min=1, max=0, exact=0): super(White, self).__init__(ws, min, max, exact) escaped = ( Literal("\\").suppress() + #chr(20)-chr(126) + chr(128)-unichr(sys.maxunicode) Regex(u"[\u0020-\u007e\u0080-\uffff]", re.IGNORECASE) ) def convertToUnicode(t): return unichr(int(t[0], 16)) hex_unicode = ( Literal("\\").suppress() + Regex("[0-9a-f]{1,6}", re.IGNORECASE) + Optional(White(exact=1)).suppress() ).setParseAction(convertToUnicode) escape = hex_unicode | escaped #any unicode literal outside the 0-127 ascii range nonascii = Regex(u"[^\u0000-\u007f]") #single character for starting an identifier. nmstart = Regex(u"[A-Z]", re.IGNORECASE) | nonascii | escape nmchar = Regex(u"[0-9A-Z-]", re.IGNORECASE) | nonascii | escape identifier = Combine(nmstart + ZeroOrMore(nmchar)) enthought-chaco2-4.5.1.orig/enable/savage/svg/css/block.py0000644000175000017500000000014612516137326022430 0ustar varunvarun""" CSS blocks """ from pyparsing import nestedExpr block = nestedExpr(opener="{", closer="}") enthought-chaco2-4.5.1.orig/enable/savage/svg/css/transform.py0000644000175000017500000000241312516137326023350 0ustar varunvarun""" Parsing for CSS and CSS-style values, such as transform and filter attributes. """ from pyparsing import (Literal, Word, CaselessLiteral, Optional, Combine, Forward, ZeroOrMore, nums, oneOf, Group, delimitedList) #some shared definitions from pathdata from enable.savage.svg.pathdata import number, maybeComma paren = Literal("(").suppress() cparen = Literal(")").suppress() def Parenthised(exp): return Group(paren + exp + cparen) skewY = Literal("skewY") + Parenthised(number) skewX = Literal("skewX") + Parenthised(number) rotate = Literal("rotate") + Parenthised( number + Optional(maybeComma + number + maybeComma + number) ) scale = Literal("scale") + Parenthised( number + Optional(maybeComma + number) ) translate = Literal("translate") + Parenthised( number + Optional(maybeComma + number) ) matrix = Literal("matrix") + Parenthised( #there's got to be a better way to write this number + maybeComma + number + maybeComma + number + maybeComma + number + maybeComma + number + maybeComma + number ) transform = (skewY | skewX | rotate | scale | translate | matrix) transformList = delimitedList(Group(transform), delim=maybeComma) if __name__ == '__main__': from tests.test_css import * unittest.main() enthought-chaco2-4.5.1.orig/enable/savage/svg/svg_regex.py0000644000175000017500000002074512516137326022546 0ustar varunvarun""" Small hand-written recursive descent parser for SVG data. In [1]: from svg_regex import svg_parser In [3]: svg_parser.parse('M 10,20 30,40V50 60 70') Out[3]: [('M', [(10.0, 20.0), (30.0, 40.0)]), ('V', [50.0, 60.0, 70.0])] In [4]: svg_parser.parse('M 0.6051.5') # An edge case Out[4]: [('M', [(0.60509999999999997, 0.5)])] In [5]: svg_parser.parse('M 100-200') # Another edge case Out[5]: [('M', [(100.0, -200.0)])] """ import re # Sentinel. class _EOF(object): def __repr__(self): return 'EOF' EOF = _EOF() lexicon = [ ('float', r'[-\+]?(?:(?:[0-9]*\.[0-9]+)|(?:[0-9]+\.?))(?:[Ee][-\+]?[0-9]+)?'), ('int', r'[-\+]?[0-9]+'), ('command', r'[AaCcHhLlMmQqSsTtVvZz]'), ] class Lexer(object): """ Break SVG path data into tokens. The SVG spec requires that tokens are greedy. This lexer relies on Python's regexes defaulting to greediness. This style of implementation was inspired by this article: http://www.gooli.org/blog/a-simple-lexer-in-python/ """ def __init__(self, lexicon): self.lexicon = lexicon parts = [] for name, regex in lexicon: parts.append('(?P<%s>%s)' % (name, regex)) self.regex_string = '|'.join(parts) self.regex = re.compile(self.regex_string) def lex(self, text): """ Yield (token_type, str_data) tokens. The last token will be (EOF, None) where EOF is the singleton object defined in this module. """ for match in self.regex.finditer(text): for name, _ in self.lexicon: m = match.group(name) if m is not None: yield (name, m) break yield (EOF, None) svg_lexer = Lexer(lexicon) class SVGPathParser(object): """ Parse SVG data into a list of commands. Each distinct command will take the form of a tuple (command, data). The `command` is just the character string that starts the command group in the data, so 'M' for absolute moveto, 'm' for relative moveto, 'Z' for closepath, etc. The kind of data it carries with it depends on the command. For 'Z' (closepath), it's just None. The others are lists of individual argument groups. Multiple elements in these lists usually mean to repeat the command. The notable exception is 'M' (moveto) where only the first element is truly a moveto. The remainder are implicit linetos. See the SVG documentation for the interpretation of the individual elements for each command. The main method is `parse(text)`. It can only consume actual strings, not filelike objects or iterators. """ def __init__(self, lexer=svg_lexer): self.lexer = lexer self.command_dispatch = { 'Z': self.rule_closepath, 'z': self.rule_closepath, 'M': self.rule_moveto_or_lineto, 'm': self.rule_moveto_or_lineto, 'L': self.rule_moveto_or_lineto, 'l': self.rule_moveto_or_lineto, 'H': self.rule_orthogonal_lineto, 'h': self.rule_orthogonal_lineto, 'V': self.rule_orthogonal_lineto, 'v': self.rule_orthogonal_lineto, 'C': self.rule_curveto3, 'c': self.rule_curveto3, 'S': self.rule_curveto2, 's': self.rule_curveto2, 'Q': self.rule_curveto2, 'q': self.rule_curveto2, 'T': self.rule_curveto1, 't': self.rule_curveto1, 'A': self.rule_elliptical_arc, 'a': self.rule_elliptical_arc, } self.number_tokens = set(['int', 'float']) def parse(self, text): """ Parse a string of SVG data. """ next = self.lexer.lex(text).next token = next() return self.rule_svg_path(next, token) def rule_svg_path(self, next, token): commands = [] while token[0] is not EOF: if token[0] != 'command': raise SyntaxError("expecting a command; got %r" % (token,)) rule = self.command_dispatch[token[1]] command_group, token = rule(next, token) commands.append(command_group) return commands def rule_closepath(self, next, token): command = token[1] token = next() return (command, None), token def rule_moveto_or_lineto(self, next, token): command = token[1] token = next() coordinates = [] while token[0] in self.number_tokens: pair, token = self.rule_coordinate_pair(next, token) coordinates.append(pair) return (command, coordinates), token def rule_orthogonal_lineto(self, next, token): command = token[1] token = next() coordinates = [] while token[0] in self.number_tokens: coord, token = self.rule_coordinate(next, token) coordinates.append(coord) return (command, coordinates), token def rule_curveto3(self, next, token): command = token[1] token = next() coordinates = [] while token[0] in self.number_tokens: pair1, token = self.rule_coordinate_pair(next, token) pair2, token = self.rule_coordinate_pair(next, token) pair3, token = self.rule_coordinate_pair(next, token) coordinates.append((pair1, pair2, pair3)) return (command, coordinates), token def rule_curveto2(self, next, token): command = token[1] token = next() coordinates = [] while token[0] in self.number_tokens: pair1, token = self.rule_coordinate_pair(next, token) pair2, token = self.rule_coordinate_pair(next, token) coordinates.append((pair1, pair2)) return (command, coordinates), token def rule_curveto1(self, next, token): command = token[1] token = next() coordinates = [] while token[0] in self.number_tokens: pair1, token = self.rule_coordinate_pair(next, token) coordinates.append(pair1) return (command, coordinates), token def rule_elliptical_arc(self, next, token): command = token[1] token = next() arguments = [] while token[0] in self.number_tokens: rx = float(token[1]) if rx < 0.0: raise SyntaxError("expecting a nonnegative number; got %r" % (token,)) token = next() if token[0] not in self.number_tokens: raise SyntaxError("expecting a number; got %r" % (token,)) ry = float(token[1]) if ry < 0.0: raise SyntaxError("expecting a nonnegative number; got %r" % (token,)) token = next() if token[0] not in self.number_tokens: raise SyntaxError("expecting a number; got %r" % (token,)) axis_rotation = float(token[1]) token = next() if token[1] not in ('0', '1'): raise SyntaxError("expecting a boolean flag; got %r" % (token,)) large_arc_flag = bool(int(token[1])) token = next() if token[1] not in ('0', '1'): raise SyntaxError("expecting a boolean flag; got %r" % (token,)) sweep_flag = bool(int(token[1])) token = next() if token[0] not in self.number_tokens: raise SyntaxError("expecting a number; got %r" % (token,)) x = float(token[1]) token = next() if token[0] not in self.number_tokens: raise SyntaxError("expecting a number; got %r" % (token,)) y = float(token[1]) token = next() arguments.append(((rx,ry), axis_rotation, large_arc_flag, sweep_flag, (x,y))) return (command, arguments), token def rule_coordinate(self, next, token): if token[0] not in self.number_tokens: raise SyntaxError("expecting a number; got %r" % (token,)) x = float(token[1]) token = next() return x, token def rule_coordinate_pair(self, next, token): # Inline these since this rule is so common. if token[0] not in self.number_tokens: raise SyntaxError("expecting a number; got %r" % (token,)) x = float(token[1]) token = next() if token[0] not in self.number_tokens: raise SyntaxError("expecting a number; got %r" % (token,)) y = float(token[1]) token = next() return (x,y), token svg_parser = SVGPathParser() enthought-chaco2-4.5.1.orig/enable/savage/svg/pathdata.py0000644000175000017500000001607212516137326022341 0ustar varunvarun""" SVG path data parser Usage:: steps = svg.parseString(pathdata) for command, arguments in steps: pass """ from pyparsing import (ParserElement, Literal, Word, CaselessLiteral, Optional, Combine, Forward, ZeroOrMore, nums, oneOf, Group, ParseException, OneOrMore) #ParserElement.enablePackrat() def Command(char): """ Case insensitive but case preserving""" return CaselessPreservingLiteral(char) def Arguments(token): return Group(token) class CaselessPreservingLiteral(CaselessLiteral): """ Like CaselessLiteral, but returns the match as found instead of as defined. """ def __init__( self, matchString ): super(CaselessPreservingLiteral,self).__init__( matchString.upper() ) self.name = "'%s'" % matchString self.errmsg = "Expected " + self.name def parseImpl( self, instring, loc, doActions=True ): test = instring[ loc:loc+self.matchLen ] if test.upper() == self.match: return loc+self.matchLen, test #~ raise ParseException( instring, loc, self.errmsg ) raise ParseException(instring, loc, self.errmsg, self) def Sequence(token): """ A sequence of the token""" return OneOrMore(token+maybeComma) digit_sequence = Word(nums) sign = oneOf("+ -") def convertToFloat(s, loc, toks): try: return float(toks[0]) except: raise ParseException(loc, "invalid float format %s"%toks[0]) exponent = CaselessLiteral("e")+Optional(sign)+Word(nums) #note that almost all these fields are optional, #and this can match almost anything. We rely on Pythons built-in #float() function to clear out invalid values - loosely matching like this #speeds up parsing quite a lot floatingPointConstant = Combine( Optional(sign) + Optional(Word(nums)) + Optional(Literal(".") + Optional(Word(nums)))+ Optional(exponent) ) floatingPointConstant.setParseAction(convertToFloat) number = floatingPointConstant #same as FP constant but don't allow a - sign nonnegativeNumber = Combine( Optional(Word(nums)) + Optional(Literal(".") + Optional(Word(nums)))+ Optional(exponent) ) nonnegativeNumber.setParseAction(convertToFloat) coordinate = number #comma or whitespace can seperate values all over the place in SVG maybeComma = Optional(Literal(',')).suppress() coordinateSequence = Sequence(coordinate) coordinatePair = (coordinate + maybeComma + coordinate).setParseAction(lambda t: tuple(t)) coordinatePairSequence = Sequence(coordinatePair) coordinatePairPair = coordinatePair + maybeComma + coordinatePair coordinatePairPairSequence = Sequence(Group(coordinatePairPair)) coordinatePairTriple = coordinatePair + maybeComma + coordinatePair + maybeComma + coordinatePair coordinatePairTripleSequence = Sequence(Group(coordinatePairTriple)) #commands lineTo = Group(Command("L") + Arguments(coordinatePairSequence)) moveTo = Group(Command("M") + Arguments(coordinatePairSequence)) closePath = Group(Command("Z")).setParseAction(lambda t: ('Z', (None,))) flag = oneOf("1 0").setParseAction(lambda t: bool(int((t[0])))) arcRadius = ( nonnegativeNumber + maybeComma + #rx nonnegativeNumber #ry ).setParseAction(lambda t: tuple(t)) arcFlags = (flag + maybeComma + flag).setParseAction(lambda t: tuple(t)) ellipticalArcArgument = Group( arcRadius + maybeComma + #rx, ry number + maybeComma +#rotation arcFlags + #large-arc-flag, sweep-flag coordinatePair #(x,y) ) ellipticalArc = Group(Command("A") + Arguments(Sequence(ellipticalArcArgument))) smoothQuadraticBezierCurveto = Group(Command("T") + Arguments(coordinatePairSequence)) quadraticBezierCurveto = Group(Command("Q") + Arguments(coordinatePairPairSequence)) smoothCurve = Group(Command("S") + Arguments(coordinatePairPairSequence)) curve = Group(Command("C") + Arguments(coordinatePairTripleSequence)) horizontalLine = Group(Command("H") + Arguments(coordinateSequence)) verticalLine = Group(Command("V") + Arguments(coordinateSequence)) drawToCommand = ( lineTo | moveTo | closePath | ellipticalArc | smoothQuadraticBezierCurveto | quadraticBezierCurveto | smoothCurve | curve | horizontalLine | verticalLine ) #~ number.debug = True moveToDrawToCommands = moveTo + ZeroOrMore(drawToCommand) svg = ZeroOrMore(moveToDrawToCommands) svg.keepTabs = True def profile(): import cProfile p = cProfile.Profile() p.enable() ptest() ptest() ptest() p.disable() p.print_stats() bpath = """M204.33 139.83 C196.33 133.33 206.68 132.82 206.58 132.58 C192.33 97.08 169.35 81.41 167.58 80.58 C162.12 78.02 159.48 78.26 160.45 76.97 C161.41 75.68 167.72 79.72 168.58 80.33 C193.83 98.33 207.58 132.33 207.58 132.33 C207.58 132.33 209.33 133.33 209.58 132.58 C219.58 103.08 239.58 87.58 246.33 81.33 C253.08 75.08 256.63 74.47 247.33 81.58 C218.58 103.58 210.34 132.23 210.83 132.33 C222.33 134.83 211.33 140.33 211.83 139.83 C214.85 136.81 214.83 145.83 214.83 145.83 C214.83 145.83 231.83 110.83 298.33 66.33 C302.43 63.59 445.83 -14.67 395.83 80.83 C393.24 85.79 375.83 105.83 375.83 105.83 C375.83 105.83 377.33 114.33 371.33 121.33 C370.3 122.53 367.83 134.33 361.83 140.83 C360.14 142.67 361.81 139.25 361.83 140.83 C362.33 170.83 337.76 170.17 339.33 170.33 C348.83 171.33 350.19 183.66 350.33 183.83 C355.83 190.33 353.83 191.83 355.83 194.83 C366.63 211.02 355.24 210.05 356.83 212.83 C360.83 219.83 355.99 222.72 357.33 224.83 C360.83 230.33 354.75 233.84 354.83 235.33 C355.33 243.83 349.67 240.73 349.83 244.33 C350.33 255.33 346.33 250.83 343.83 254.83 C336.33 266.83 333.46 262.38 332.83 263.83 C329.83 270.83 325.81 269.15 324.33 270.83 C320.83 274.83 317.33 274.83 315.83 276.33 C308.83 283.33 304.86 278.39 303.83 278.83 C287.83 285.83 280.33 280.17 277.83 280.33 C270.33 280.83 271.48 279.67 269.33 277.83 C237.83 250.83 219.33 211.83 215.83 206.83 C214.4 204.79 211.35 193.12 212.33 195.83 C214.33 201.33 213.33 250.33 207.83 250.33 C202.33 250.33 201.83 204.33 205.33 195.83 C206.43 193.16 204.4 203.72 201.79 206.83 C196.33 213.33 179.5 250.83 147.59 277.83 C145.42 279.67 146.58 280.83 138.98 280.33 C136.46 280.17 128.85 285.83 112.65 278.83 C111.61 278.39 107.58 283.33 100.49 276.33 C98.97 274.83 95.43 274.83 91.88 270.83 C90.39 269.15 86.31 270.83 83.27 263.83 C82.64 262.38 79.73 266.83 72.13 254.83 C69.6 250.83 65.54 255.33 66.05 244.33 C66.22 240.73 60.48 243.83 60.99 235.33 C61.08 233.84 54.91 230.33 58.45 224.83 C59.81 222.72 54.91 219.83 58.96 212.83 C60.57 210.05 49.04 211.02 59.97 194.83 C62 191.83 59.97 190.33 65.54 183.83 C65.69 183.66 67.06 171.33 76.69 170.33 C78.28 170.17 53.39 170.83 53.9 140.83 C53.92 139.25 55.61 142.67 53.9 140.83 C47.82 134.33 45.32 122.53 44.27 121.33 C38.19 114.33 39.71 105.83 39.71 105.83 C39.71 105.83 22.08 85.79 19.46 80.83 C-31.19 -14.67 114.07 63.59 118.22 66.33 C185.58 110.83 202 145.83 202 145.83 C202 145.83 202.36 143.28 203 141.83 C203.64 140.39 204.56 140.02 204.33 139.83 z""" def ptest(): svg.parseString(bpath) if __name__ == '__main__': #~ from tests.test_pathdata import * #~ unittest.main() profile() enthought-chaco2-4.5.1.orig/enable/savage/svg/tests/0000755000175000017500000000000012516137725021340 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/svg/tests/test_attributes.py0000644000175000017500000000306412516137326025137 0ustar varunvarunimport unittest import enable.savage.svg.attributes as a from css.test_color import TestValueParser class TestURLParser(unittest.TestCase): parser = a.url def testURL(self): self.assertEqual( self.parser.parseString("url(#someGradient)").asList(), ["URL", [('', '', '', '', "someGradient"), ()]] ) def testURLWithFallback(self): self.assertEqual( self.parser.parseString("url(someGradient) red").asList(), ["URL", [('', '', "someGradient", '', ''), ['RGB', (255,0,0)]]] ) def testEmptyURLWithFallback(self): self.assertEqual( self.parser.parseString("url() red").asList(), ["URL", [('', '', '', '', ''), ['RGB', (255,0,0)]]] ) def testEmptyURL(self): self.assertEqual( self.parser.parseString("url()").asList(), ["URL", [('', '', '', '', ''), ()]] ) def testxPointerURL(self): self.assertEqual( self.parser.parseString("url(#xpointer(idsomeGradient))").asList(), ["URL", [('', '', '', '', "xpointer(idsomeGradient)"), ()]] ) class TestPaintValueURL(TestURLParser): parser = a.paintValue class TestPaintValue(TestValueParser): parser = a.paintValue def testNone(self): self.assertEqual( self.parser.parseString("none").asList(), ["NONE", ()] ) def testCurrentColor(self): self.assertEqual( self.parser.parseString("currentColor").asList(), ["CURRENTCOLOR", ()] ) enthought-chaco2-4.5.1.orig/enable/savage/svg/tests/__init__.py0000644000175000017500000000000012516137326023434 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/svg/tests/css/0000755000175000017500000000000012516137725022130 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/svg/tests/css/test_identifier.py0000644000175000017500000000556612516137326025674 0ustar varunvarunimport unittest import string import sys from pyparsing import ParseException, Regex, StringEnd import enable.savage.svg.css.identifier as identifier class TestEscaped(unittest.TestCase): def testEscapedSpecialChar(self): for char in string.punctuation: self.assertEqual( identifier.escaped.parseString("\\"+char)[0], char ) def testEscapeDoesntMatchHexChars(self): return for char in string.hexdigits: self.assertRaises( ParseException, identifier.escaped.parseString, "\\"+char ) class TestHexUnicode(unittest.TestCase): parser = (identifier.hex_unicode.copy() + Regex(".+") + StringEnd()).leaveWhitespace() def testUnicodeConversion(self): self.assertEqual( u"&", identifier.hex_unicode.parseString(r"\000026")[0] ) self.assertEqual( u"&", identifier.hex_unicode.parseString(r"\26")[0] ) def testDoesntEatMoreThan6Chars(self): self.assertEqual( [u"&", "B"], list(self.parser.parseString(r"\000026B")) ) def testConsumesFinalSpaceWith6Chars(self): self.assertEqual( [u"&", "B"], list(self.parser.parseString(r"\000026 B")) ) def testConsumesFinalSpaceWithShortChars(self): self.assertEqual( [u"&", "B"], list(self.parser.parseString(r"\26 B")) ) def testDoesntConsumeMoreThanOneSpace(self): self.assertEqual( [u"&", " B"], list(self.parser.parseString(r"\26 B")) ) class TestEscape(unittest.TestCase): def testEscapeValues(self): self.assertEqual(u"&", identifier.escape.parseString(r"\26")[0]) self.assertEqual(u'\x81', identifier.escape.parseString("\\" + unichr(129))[0]) self.assertEqual(u"~", identifier.escape.parseString(r'\~')[0]) class TestNonAscii(unittest.TestCase): def testNoMatchInAsciiRange(self): for c in map(unichr, range(128)): self.assertRaises( ParseException, identifier.nonascii.parseString, c ) def testMatchesOutsideAsciiRange(self): for c in map(unichr, xrange(128, sys.maxunicode+1)): self.assertEqual( c, identifier.nonascii.parseString(c)[0] ) class TestNmstart(unittest.TestCase): def testNmstartValues(self): self.assertRaises( ParseException, identifier.nmstart.parseString, "0" ) class TestIdentifier(unittest.TestCase): def testValidIdentifiers(self): for ident in ["import","color", "border-left"]: self.assertEqual( ident, identifier.identifier.parseString(ident)[0] ) enthought-chaco2-4.5.1.orig/enable/savage/svg/tests/css/__init__.py0000644000175000017500000000000012516137326024224 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/savage/svg/tests/css/test_atrule.py0000644000175000017500000000054312516137326025034 0ustar varunvarunimport unittest import string import sys from pyparsing import ParseException import enable.savage.svg.css.atrule as atrule class TestAtKeyword(unittest.TestCase): def testValidKeywords(self): for kw in ["@import", "@page",]: self.assertEqual( kw, atrule.atkeyword.parseString(kw)[0] ) enthought-chaco2-4.5.1.orig/enable/savage/svg/tests/css/test_color.py0000644000175000017500000000401512516137326024654 0ustar varunvarunimport unittest from pyparsing import ParseException import enable.savage.svg.css.colour as colour class testColourValueClamping(unittest.TestCase): def testByte(self): self.assertEqual( 100, colour.clampColourByte(100) ) self.assertEqual( 0, colour.clampColourByte(-100) ) self.assertEqual( 255, colour.clampColourByte(300) ) class TestRGBParsing(unittest.TestCase): parser = colour.rgb def testRGBByte(self): self.assertEqual( self.parser.parseString("rgb(300,45,100)").asList(), ["RGB", [255,45,100]] ) def testRGBPerc(self): self.assertEqual( self.parser.parseString("rgb(100%,0%,0.1%)").asList(), ["RGB", [255,0,0]] ) class TestHexParsing(unittest.TestCase): parser = colour.hexLiteral def testHexLiteralShort(self): self.assertEqual( self.parser.parseString("#fab").asList(), ["RGB", (0xff, 0xaa, 0xbb)] ) def testHexLiteralLong(self): self.assertEqual( self.parser.parseString("#f0a1b2").asList(), ["RGB", [0xf0, 0xa1, 0xb2]] ) def testHexLiteralBroken(self): badstrings = [ "#fab0","#fab0102d", "#gab" ] for string in badstrings: self.assertRaises( ParseException, self.parser.parseString, string ) class TestNamedColours(unittest.TestCase): parser = colour.namedColour def testNamedColour(self): self.assertEqual( self.parser.parseString("fuchsia").asList(), ["RGB", (0xff, 0, 0xff)] ) def testNamedColourLookupCaseInsensitive(self): self.assertEqual( self.parser.parseString("fuchsia").asList(), self.parser.parseString("FUCHSIA").asList(), ) class TestValueParser(TestNamedColours, TestHexParsing, TestRGBParsing): parser = colour.colourValue enthought-chaco2-4.5.1.orig/enable/savage/svg/tests/css/test_block.py0000644000175000017500000000100412516137326024623 0ustar varunvarunimport unittest from enable.savage.svg.css import block class TestBlockParsing(unittest.TestCase): def testBlock(self): """ Not a valid CSS statement, but a valid block This tests some abuses of quoting and escaping See http://www.w3.org/TR/REC-CSS2/syndata.html Section 4.1.6 """ self.assertEqual( [["causta:", '"}"', "+", "(", ["7"], "*", "'\\''", ")"]], block.block.parseString(r"""{ causta: "}" + ({7} * '\'') }""").asList() ) enthought-chaco2-4.5.1.orig/enable/savage/svg/tests/css/test_transform.py0000644000175000017500000000424112516137326025552 0ustar varunvarunimport unittest from pyparsing import ParseException from enable.savage.svg.css.transform import * #list of tuples: parser, string, result transformTestsGood = [ (skewY, "skewY(10)", ["skewY", [10]]), (skewX, "skewX(10)", ["skewX", [10]]), (rotate, "rotate(90)", ["rotate", [90]]), (rotate, "rotate(90, 10 10)", ["rotate", [90,10,10]]), (scale, 'scale(.2, .2)', ["scale", [0.2, 0.2]]) ] #parse, string - exception is always ParseException transformTestsError = [ (skewY, "skewY 10"), (skewX, "skewX (45"), (rotate, "rotate"), ] class TestTransformParser(unittest.TestCase): def testTransformList(self): self.assertEqual( transformList.parseString( "matrix(1,2,3,4,5,6) translate(-10), scale(23, 45.9)" ).asList(), [ ["matrix", [1,2,3,4,5,6]], ["translate", [-10]], ["scale", [23, 45.9]] ] ) def testTransformGood(self): for parser, string, result in transformTestsGood: self.assertEqual( transform.parseString(string).asList(), result ) def testTransformError(self): for parser, string in transformTestsError: self.assertRaises( ParseException, transform.parseString, string ) def testPartsGood(self): for parser, string, result in transformTestsGood: self.assertEqual( parser.parseString(string).asList(), result ) def testPartsError(self): for parser, string in transformTestsError: self.assertRaises( ParseException, parser.parseString, string ) def testMatrixTransform(self): src = "matrix(0.966764,0.000000,0.000000,1.062970,-8.322865,-4.427016)" expected = [[ 'matrix', [0.966764, 0.0, 0.0, 1.062970, -8.322865, -4.427016] ]] self.assertEqual( transformList.parseString(src).asList(), expected ) enthought-chaco2-4.5.1.orig/enable/savage/svg/tests/css/test_values.py0000644000175000017500000000404312516137326025036 0ustar varunvarunimport unittest from pyparsing import ParseException import enable.savage.svg.css.values as values class FailTest(Exception): pass class ParseTester(object): def testValidValues(self): #~ self.parser.debug = True try: for string, expected in self.valid: self.assertEqual(expected, self.parser.parseString(string)[0]) except ParseException: raise FailTest("expected %r to be valid" % string) class TestInteger(unittest.TestCase, ParseTester): parser = values.integer valid = [(x, int(x)) for x in ["01", "1"]] class TestNumber(unittest.TestCase, ParseTester): parser = values.number valid = [(x, float(x)) for x in ["1.1", "2.3", ".3535"]] valid += TestInteger.valid class TestSignedNumber(unittest.TestCase, ParseTester): parser = values.signedNumber valid = [(x, float(x)) for x in ["+1.1", "-2.3"]] valid += TestNumber.valid class TestLengthUnit(unittest.TestCase, ParseTester): parser = values.lengthUnit valid = [(x,x.lower()) for x in ["em", "ex", "px", "PX", "EX", "EM", "%"]] class TestLength(unittest.TestCase): parser = values.length valid = [ ("1.2em", (1.2, "em")), ("0", (0, None)), ("10045px", (10045, "px")), ("300%", (300, "%")), ] def testValidValues(self): for string, expected in self.valid: #~ print string, expected got = self.parser.parseString(string) self.assertEqual(expected, tuple(got)) def testIntegersIfPossible(self): results = self.parser.parseString("100px")[0] self.assertTrue(isinstance(results, int)) def testNoSpaceBetweenValueAndUnit(self): """ CSS spec section 4.3.2 requires that the length identifier immediately follow the value """ self.assertRaises( ParseException, self.parser.parseString, "300 %" ) self.assertRaises( ParseException, self.parser.parseString, "300 px" ) enthought-chaco2-4.5.1.orig/enable/savage/svg/tests/test_pathdata.py0000644000175000017500000001214112516137326024533 0ustar varunvarunimport unittest from pyparsing import ParseException from enable.savage.svg.pathdata import * class TestNumber(unittest.TestCase): parser = number valid = ['1.e10', '1e2', '1e+4', '1e-10','1.', '1.0', '0.1', '.2'] invalid = ['e10', '.', 'f', ''] def testValid(self): for num in self.valid: self.assertEqual( float(num), self.parser.parseString(num)[0] ) def testInvalid(self): for num in self.invalid: self.assertRaises( ParseException, lambda: self.parser.parseString(num) ) class TestNumberSequence(unittest.TestCase): def testFloatsWithNoSpacing(self): self.assertEqual( [0.4, 0.4], list(Sequence(number).parseString("0.4.4")) ) class TestCoords(unittest.TestCase): def testCoordPair(self): self.assertEqual( coordinatePair.parseString('100 100')[0], (100.0, 100.0) ) self.assertEqual( coordinatePair.parseString('100,2E7')[0], (100,2e7) ) def testCoordPairWithMinus(self): self.assertEqual( coordinatePair.parseString('100-100')[0], (100.0, -100.0) ) def testCoordPairWithPlus(self): self.assertEqual( coordinatePair.parseString('100+100')[0], (100.0, 100.0) ) def testCoordPairWithPlusAndExponent(self): self.assertEqual( coordinatePair.parseString('100+1e+2')[0], (100.0, 100.0) ) def testNotAPair(self): self.assertRaises( ParseException, coordinatePair.parseString, "100" ) self def testNoSpacing(self): self.assertEqual( coordinatePair.parseString("-1.1.1")[0], (-1.1, 0.1) ) class TestMoveTo(unittest.TestCase): def testSimple(self): self.assertEqual( moveTo.parseString("M 100 100").asList()[0], ["M", [(100.0, 100.0)]] ) def testLonger(self): self.assertEqual( moveTo.parseString("m 100 100 94 1e7").asList()[0], ["m", [(100.0, 100.0), (94, 1e7)]] ) def testLine(self): self.assertEqual( lineTo.parseString("l 300 100").asList()[0], ["l", [(300.0, 100.0)]] ) def testHorizonal(self): self.assertEqual( horizontalLine.parseString("H 100 5 20").asList()[0], ["H", [100.0, 5.0, 20.0]] ) def testVertical(self): self.assertEqual( verticalLine.parseString("V 100 5 20").asList()[0], ["V", [100.0, 5.0, 20.0]] ) class TestEllipticalArc(unittest.TestCase): def testParse(self): self.assertEqual( ellipticalArc.parseString("a25,25 -30 0,1 50,-25").asList()[0], ["a", [[(25.0, 25.0), -30.0, (False,True), (50.0, -25.0)]]] ) def testExtraArgs(self): self.assertEqual( ellipticalArc.parseString("a25,25 -30 0,1 50,-25, 10, 10").asList()[0], ["a", [[(25.0, 25.0), -30.0, (False,True), (50.0, -25.0)]]] ) class TestSmoothQuadraticBezierCurveto(unittest.TestCase): def testParse(self): self.assertEqual( smoothQuadraticBezierCurveto.parseString("t1000,300").asList()[0], ["t", [(1000.0, 300.0)]] ) class TestQuadraticBezierCurveto(unittest.TestCase): def testParse(self): self.assertEqual( quadraticBezierCurveto.parseString("Q1000,300 200 5").asList()[0], ["Q", [ [(1000.0, 300.0), (200.0,5.0)] ] ] ) class TestCurve(unittest.TestCase): def testParse(self): self.assertEqual( curve.parseString("C 100 200 300 400 500 600 100 200 300 400 500 600").asList()[0], ["C", [ [(100.0,200.0), (300.0,400.0), (500.0, 600.0)], [(100.0,200.0), (300.0,400.0), (500.0, 600.0)] ] ] ) class TestClosePath(unittest.TestCase): def testParse(self): self.assertEqual( closePath.parseString('Z').asList()[0], ("Z", (None,)) ) class TestSVG(unittest.TestCase): def testParse(self): path = 'M 100 100 L 300 100 L 200 300 z a 100,100 -4 0,1 25 25 z T300 1000 t40, 50 h4 42 2 2,1v1,1,1 Z Q 34,10 1 1' r = svg.parseString(path).asList() expected = [ ["M", [(100,100)]], ["L", [(300, 100)]], ["L", [(200, 300)]], ("Z", (None,)), ["a", [[(100,100),-4, (False, True), (25, 25)]]], ("Z", (None,)), ["T", [(300,1000)]], ["t", [(40, 50)]], ["h", [4,42, 2, 2, 1]], ["v", [1, 1, 1]], ("Z", (None,)), ["Q", [[(34, 10), (1, 1)]]] ] self.assertEqual( len(r), len(expected) ) for a, b in zip(expected, r): self.assertEqual( a, b ) enthought-chaco2-4.5.1.orig/enable/savage/svg/tests/test_document.py0000644000175000017500000000563712516137326024577 0ustar varunvarunimport unittest import enable.savage.svg.document as document import xml.etree.cElementTree as etree from cStringIO import StringIO from enable.savage.svg.backends.kiva.renderer import Renderer as KivaRenderer minimalSVG = etree.parse(StringIO(r""" """)) class TestBrushFromColourValue(unittest.TestCase): def setUp(self): self.document = document.SVGDocument(minimalSVG.getroot(), renderer=KivaRenderer()) self.stateStack = [{}] def testNone(self): self.document.state["fill"] = 'none' self.assertEqual( self.document.getBrushFromState(), None ) def testCurrentColour(self): self.document.state["fill"] = 'currentColor' self.document.state["color"] = "rgb(100,100,100)" self.assertEqual( self.document.getBrushFromState().color, (100, 100, 100, 255) ) def testCurrentColourNull(self): self.document.state["fill"] = 'currentColor' self.assertEqual( self.document.getBrushFromState(), None ) def testOpacity(self): self.document.state["fill"] = 'rgb(255,100,10)' self.document.state["fill-opacity"] = 0.5 self.assertEqual( self.document.getBrushFromState().color[-1], 127.5 ) def testOpacityClampHigh(self): self.document.state["fill"] = 'rgb(255,100,10)' self.document.state["fill-opacity"] = 5 self.assertEqual( self.document.getBrushFromState().color[-1], 255 ) def testOpacityClampLow(self): self.document.state["fill"] = 'rgb(255,100,10)' self.document.state["fill-opacity"] = -100 self.assertEqual( self.document.getBrushFromState().color[-1], 0 ) def testURLFallback(self): self.document.state["fill"] = "url(http://google.com) red" self.assertEqual( self.document.getBrushFromState().color, (255, 0, 0, 255) ) class TestValueToPixels(unittest.TestCase): """ Make sure that CSS length values get converted correctly to pixels""" def testDefault(self): got = document.valueToPixels("12") self.assertEqual(got, 12) def testPointConversion(self): got = document.valueToPixels('14pt') self.assertEqual(got, 14) def testInchConversion(self): got = document.valueToPixels('2in') self.assertEqual(got, 144) def testCentimeterConversion(self): got = document.valueToPixels('2cm') self.assertAlmostEqual(got, 56.7, places=1) def testMillimeterConversion(self): got = document.valueToPixels('2mm') self.assertAlmostEqual(got, 5.67, places=2) enthought-chaco2-4.5.1.orig/enable/savage/svg/document.py0000644000175000017500000011577512516137326022403 0ustar varunvarun""" SVGDocument """ from cStringIO import StringIO import warnings import math from functools import wraps import os import urllib import urlparse from xml.etree import cElementTree as ET try: from xml.etree.cElementTree import ParseError except ImportError: # ParseError doesn't exist in Python 2.6 and SyntaxError is raised instead ParseError = SyntaxError import numpy import css from css.colour import colourValue from css import values from attributes import paintValue from svg_regex import svg_parser from enable.savage.svg.backends.null.null_renderer import NullRenderer, AbstractGradientBrush class XMLNS(object): """ Utility object for dealing the namespaced names quoted the way ElementTree requires. """ def __init__(self, url): self.__url = url def __getattr__(self, attr): return self[attr] def __getitem__(self, key): return '{%s}%s' % (self.__url, key) XLink = XMLNS('http://www.w3.org/1999/xlink') XML = XMLNS('http://www.w3.org/XML/1998/namespace') SVG = XMLNS('http://www.w3.org/2000/svg') def normalize_href(href): """ Normalize an href to remove url(...) and xpointer(id(...)) extraneous bits. Parameters ---------- href : str Returns ------- uri : str A URI (or maybe a file system path) to the resource. fragment : str The normalized #fragment, if any """ if href.startswith('url(') and href.endswith(')'): href = href[4:-1] scheme, netloc, path, params, query, fragment = urlparse.urlparse(href) # Normalize xpointer(id(...)) references. if fragment.startswith('xpointer(id(') and fragment.endswith('))'): # FIXME: whitespace? fragment = fragment[12:-2] uri = urlparse.urlunparse((scheme, netloc, path, params, query, '')) return uri, fragment def attrAsFloat(node, attr, defaultValue="0"): val = node.get(attr, defaultValue) #TODO: process stuff like "inherit" by walking back up the nodes #fast path optimization - if it's a valid float, don't #try to parse it. try: return float(val) except ValueError: return valueToPixels(val) def fractionalValue(value): """ Parse a string consisting of a float in the range [0..1] or a percentage as a float number in the range [0..1]. """ if value.endswith('%'): return float(value[:-1]) / 100.0 else: return float(value) units_to_px = { 'in': 72, 'pc': 12, 'cm': 72.0/2.54, 'mm': 72.0/25.4, 'px': 1, 'pt': 1, } def valueToPixels(val, defaultUnits="px"): # This pretends that 1px == 1pt. For our purposes, that's fine since we # don't actually care about px. The name of the function is bad. # TODO: refactor in order to handle relative percentages and em and ex. # TODO: manage default units from pyparsing import ParseException input = val if val.endswith('%'): # TODO: this is one of those relative values we need to fix. return float(val[:-1]) / 100.0 try: val, unit = values.length.parseString(val) except ParseException: import pdb;pdb.set_trace() print 'valueToPixels(%r, %r)' % (val, defaultUnits) raise val *= units_to_px.get(unit, 1) return val def pathHandler(func): """decorator for methods which return a path operation Creates the path they will fill, and generates the path operations for the node """ @wraps(func) def inner(self, node): #brush = self.getBrushFromState() #pen = self.getPenFromState() #if not (brush or pen): # return None, [] path = self.renderer.makePath() results = func(self, node, path) ops = [ (self.renderer.pushState, ()), ] # the results willbe None, unless the path has something which affects # the render stack, such as clipping if results != None: cpath, cops = results path = cpath ops = cops + ops ops.extend(self.createTransformOpsFromNode(node)) ops.extend(self.generatePathOps(path)) ops.append( (self.renderer.popState, ()) ) return path, ops return inner class ResourceGetter(object): """ Simple context for getting relative-pathed resources. """ def __init__(self, dirname=None): if dirname is None: dirname = os.getcwd() self.dirname = dirname @classmethod def fromfilename(cls, filename): """ Use the directory containing this file as the base directory. """ dirname = os.path.abspath(os.path.dirname(filename)) return cls(dirname) def newbase(self, dirname): """ Return a new ResourceGetter using a new base directory found relative to this one. """ dirname = os.path.abspath(os.path.join(self.dirname, dirname)) return self.__class__(dirname) def resolve(self, path): """ Resolve a path and the associated opener function against this context. """ scheme, netloc, path_part, _, _, _ = urlparse.urlparse(path) if scheme not in ('', 'file'): # Plain URI. Pass it back. # Read the data and stuff it in a StringIO in order to satisfy # functions that need a functioning seek() and stuff. return path, lambda uri: StringIO(urllib.urlopen(uri).read()) path = os.path.abspath(os.path.join(self.dirname, path_part)) return path, lambda fn: open(fn, 'rb') def open_svg(self, path): """ Resolve and read an SVG file into an Element. """ path, open = self.resolve(path) f = open(path) tree = ET.parse(f) element = tree.getroot() return element def open_image(self, path): """ Resolve and read an image into an appropriate object for the renderer. """ path, open = self.resolve(path) fin = open(path) import Image import numpy pil_img = Image.open(fin) if pil_img.mode not in ('RGB', 'RGBA'): pil_img = pil_img.convert('RGBA') img = numpy.fromstring(pil_img.tostring(), numpy.uint8) shape = (pil_img.size[1],pil_img.size[0],len(pil_img.mode)) img.shape = shape return img class SVGDocument(object): def __init__(self, element, resources=None, renderer=NullRenderer): """ Create an SVG document from an ElementTree node. FIXME: this is really wrong that the doc must know about the renderer """ self.renderer = renderer self.lastControl = None self.brushCache = {} self.penCache = {} self.handlers = { SVG.svg: self.addGroupToDocument, SVG.a: self.addGroupToDocument, SVG.g: self.addGroupToDocument, SVG.symbol: self.addGroupToDocument, SVG.use: self.addUseToDocument, SVG.switch: self.addSwitchToDocument, SVG.image: self.addImageToDocument, SVG.rect: self.addRectToDocument, SVG.circle: self.addCircleToDocument, SVG.ellipse: self.addEllipseToDocument, SVG.line: self.addLineToDocument, SVG.polyline: self.addPolyLineToDocument, SVG.polygon: self.addPolygonToDocument, SVG.path: self.addPathDataToDocument, SVG.text: self.addTextToDocument } assert element.tag == SVG.svg, 'Not an SVG fragment' if resources is None: resources = ResourceGetter() self.resources = resources self.tree = element # Mapping of (URI, XML id) pairs to elements. '' is the URI for local # resources. Use self.update(findIDs(element), uri) for adding elements # from other URIs. self.idmap = self.findIDs(element) self.paths = {} self.stateStack = [{}] self.clippingStack = [] path, ops = self.processElement(element) self.ops = ops @classmethod def createFromFile(cls, filename, renderer): if not os.path.exists(filename): raise IOError('No such file: ' + filename) tree = ET.parse(filename) root = tree.getroot() resources = ResourceGetter(os.path.dirname(filename)) return cls(root, resources, renderer) def getSize(self): width = -1 width_node = self.tree.get('width') if width_node is not None: if width_node.endswith('cm'): # assumes dpi of 72 width = int(float(width_node.split('cm')[0])*72/2.54) else: # omit 'px' if it was specified width=int(float(width_node.split('px')[0])) height = -1 height_node = self.tree.get('height') if height_node is not None: if height_node.endswith('cm'): # assumes dpi of 72 height = int(float(height_node.split('cm')[0])*72/2.54) else: # omit 'px' if it was specified height=int(float(height_node.split('px')[0])) return (width, height) def findIDs(self, element, uri=''): """ Iterate through the tree under an element and record all elements which specify an id attribute. The root element is given the ID '' in addition to whatever id= attribute it may be given. """ idmap = {} for e in element.getiterator(): id = e.get('id', None) if id is not None: idmap[(uri, id)] = e idmap[(uri, '')] = element return idmap def dereference(self, href, resources=None): """ Find the element specified by the give href. Parameters ---------- href : str The reference pointing to the desired element. Forms like 'url(uri#theid)' and 'uri#xpointer(id(theid))' will be normalized to pull out just the uri and theid. resources : ResourceGetter, optional The ResourceGetter to use. If not provided, the one attached to the SVGDocument is used. This is useful when silly test suites like to test annoying XLink features. FIXME: xml:base is inheritable. Returns ------- element : Element Raises ------ KeyError : If the element is not found. """ uri, fragment = normalize_href(href) if uri and (uri, fragment) not in self.idmap: # Record all of the IDed elements in the referenced document. if resources is None: resources = self.resources element = resources.open_svg(uri) self.idmap.update(self.findIDs(element, uri)) return self.idmap[(uri, fragment)] @property def state(self): """ Retrieve the current state, without popping""" return self.stateStack[-1] def getLocalState(self, element, state=None): """ Get the state local to an element. """ if state is None: state = self.state current = dict(state) element_items = [(k,v) for (k,v) in element.items() if v != 'inherit'] current.update(element_items) style_items = [(k,v) for (k,v) in css.inlineStyle(element.get("style", "")).items() if v != 'inherit'] current.update(style_items) return current def processElement(self, element): """ Process one element of the XML tree. Returns the path representing the node, and an operation list for drawing the node. Parent nodes should return a path (for hittesting), but no draw operations """ current = self.getLocalState(element) self.stateStack.append(current) handler = self.handlers.get(element.tag, lambda *any: (None, None)) path, ops = handler(element) self.paths[element] = path self.stateStack.pop() return path, ops def createTransformOpsFromNode(self, node, attribute='transform'): """ Returns an oplist for transformations. This applies to a node, not the current state because the transform stack is saved in the graphics context. This oplist does *not* include the push/pop state commands """ ops = [] transform = node.get(attribute, None) #todo: replace this with a mapping list if transform: for transform, args in css.transformList.parseString(transform): if transform == 'scale': if len(args) == 1: x = y = args[0] else: x, y = args ops.append( (self.renderer.scale, (x, y)) ) if transform == 'translate': if len(args) == 1: x = args[0] y = 0 else: x, y = args ops.append( (self.renderer.translate, (x, y)) ) if transform == 'rotate': if len(args) == 3: angle, cx, cy = args angle = math.radians(angle) ops.extend([ (self.renderer.translate, (cx, cy)), (self.renderer.rotate, (angle,)), (self.renderer.translate, (-cx, -cy)), ]) else: angle = args[0] angle = math.radians(angle) ops.append( (self.renderer.rotate, (angle,)) ) if transform == 'matrix': matrix = self.renderer.createAffineMatrix( *args ) ops.append( (self.renderer.concatTransform, (matrix,)) ) if transform == 'skewX': matrix = self.renderer.createAffineMatrix( 1,0,math.tan(math.radians(args[0])),1,0,0 ) ops.append( (self.renderer.concatTransform, (matrix,)) ) if transform == 'skewY': matrix = self.renderer.createAffineMatrix( 1,math.tan(math.radians(args[0])),0,1,0,0 ) ops.append( (self.renderer.concatTransform, (matrix,)) ) return ops def createTransformOpsFromXY(self, node): """ On some nodes, x and y attributes cause a translation of the coordinate system. """ ops = [] # Now process x,y attributes. Per 7.6 of the SVG1.1 spec, these are # interpreted after transform=. x = attrAsFloat(node, 'x') y = attrAsFloat(node, 'y') if x != 0.0 or y != 0.0: ops.append( (self.renderer.translate, (x,y)) ) return ops def addGroupToDocument(self, node): """ For parent elements: push on a state, then process all child elements """ ops = [ (self.renderer.pushState, ()) ] path = self.renderer.makePath() ops.extend(self.createTransformOpsFromNode(node)) ops.extend(self.createTransformOpsFromXY(node)) for child in node.getchildren(): cpath, cops = self.processElement(child) if cpath: path.AddPath(cpath) if cops: ops.extend(cops) ops.append( (self.renderer.popState, ()) ) return path, ops def addUseToDocument(self, node): """ Add a tag to the document. """ # FIXME: width,height? # FIXME: this could lead to circular references in erroneous documents. # It would be nice to raise an exception in this case. href = node.get(XLink.href, None) if href is None: # Links to nothing. return None, [] base = self.state.get(XML.base, None) if base is not None: resources = self.resources.newbase(base) else: resources = self.resources try: element = self.dereference(href, resources) except (OSError, IOError), e: # SVG file cannot be found. warnings.warn("Could not find SVG file %s. %s: %s" % (href, e.__class__.__name__, e)) return None, [] ops = [ (self.renderer.pushState, ()) ] path = self.renderer.makePath() ops.extend(self.createTransformOpsFromNode(node)) ops.extend(self.createTransformOpsFromXY(node)) cpath, cops = self.processElement(element) if cpath: path.AddPath(cpath) if cops: ops.extend(cops) ops.append( (self.renderer.popState, ()) ) return path, ops def addSwitchToDocument(self, node): """ Process a tag. """ for child in node: if child.get('requiredExtensions') is None: # This renderer does not support any extensions. Pick the first # item that works. This allows us to read SVG files made with # Adobe Illustrator. They embed the SVG content in a # along with an encoded representation in AI format. The encoded # non-SVG bit has a requiredExtensions= attribute. # FIXME: other tests? return self.processElement(child) return None, None def addImageToDocument(self, node): """ Add an tag to the document. """ href = node.get(XLink.href, None) if href is None: # Links to nothing. return None, [] base = self.state.get(XML.base, None) if base is not None: resources = self.resources.newbase(base) else: resources = self.resources uri, fragment = normalize_href(href) if uri.endswith('.svg') and not uri.startswith('data:'): # FIXME: Pretend it's a . return self.addUseToDocument(node) try: image = resources.open_image(uri) except (OSError, IOError), e: # Image cannot be found. warnings.warn("Could not find image file %s. %s: %s" % (uri[:100], e.__class__.__name__, str(e)[:100])) return None, [] ops = [ (self.renderer.pushState, ()), ] ops.extend(self.createTransformOpsFromNode(node)) if type(image).__name__ == 'Element': # FIXME: bad API. Bad typecheck since ET.Element is a factory # function, not a type. # This is an SVG file, not an image. imgpath, imgops = self.processElement(image) ops.extend(imgops) ops.append( (self.renderer.popState, ()) ) return imgpath, ops x = attrAsFloat(node, 'x') y = attrAsFloat(node, 'y') width = attrAsFloat(node, 'width') height = attrAsFloat(node, 'height') if width == 0.0 or height == 0.0: return None, [] ops.extend([ (self.renderer.DrawImage, (image, x, y, width, height)), (self.renderer.popState, ()), ]) return None, ops def getFontFromState(self): font = self.renderer.getFont() family = self.state.get("font-family") #print 'family', family if family: #print "setting font", family font.face_name = family style = self.state.get("font-style") if style: self.renderer.setFontStyle(font, style) weight = self.state.get("font-weight") if weight: self.renderer.setFontWeight(font, weight) size = self.state.get("font-size") # TODO: properly handle inheritance. if size and size != 'inherit': val, unit = values.length.parseString(size) self.renderer.setFontSize(font, val) # fixme: Handle text-decoration for line-through and underline. # These are probably done externally using drawing commands. return font def addTextToDocument(self, node): # TODO: these attributes can actually be lists of numbers. text-text-04-t.svg x, y = [attrAsFloat(node, attr) for attr in ('x', 'y')] font = self.getFontFromState() brush = self.getBrushFromState() if not (brush and hasattr(brush, 'IsOk') and brush.IsOk()): black_tuple = (255,255,255,255) brush = self.renderer.createBrush(black_tuple) #print "using black brush" # TODO: handle , and . # TODO: handle xml:space="preserve"? The following more or less # corresponds to xml:space="default". if node.text: text = ' '.join(node.text.split()) else: text = '' if text is None: return None, [] text_anchor = self.state.get('text-anchor', 'start') ops = [ (self.renderer.pushState, ()), ] ops.extend(self.createTransformOpsFromNode(node)) ops.extend([ (self.renderer.setFont, (font, brush)), (self.renderer.DrawText, (text, x, y, brush, text_anchor)), (self.renderer.popState, ()), ]) return None, ops @pathHandler def addRectToDocument(self, node, path): x, y, w, h = (attrAsFloat(node, attr) for attr in ['x', 'y', 'width', 'height']) rx = node.get('rx') ry = node.get('ry') ops = [] if 'clip-path' in node.keys(): element = self.dereference(node.get('clip-path')) ops = [ (self.renderer.pushState, ()), ] clip_path = self.renderer.makePath() ops.extend(self.createTransformOpsFromNode(element)) ops.extend(self.generatePathOps(clip_path)) for child in element.getchildren(): cpath, cops = self.processElement(child) if cpath: clip_path.AddPath(cpath) ops.append((self.renderer.clipPath, (clip_path,))) path.AddPath(clip_path) if cops: ops.extend(cops) ops.append( (self.renderer.popState, ()) ) if not (w and h): path.MoveToPoint(x,y) #keep the current point correct return if rx or ry: if rx and ry: rx, ry = float(rx), float(ry) elif rx: rx = ry = float(rx) elif ry: rx = ry = float(ry) #value clamping as per spec section 9.2 rx = min(rx, w/2) ry = min(ry, h/2) path.AddRoundedRectangleEx(x, y, w, h, rx, ry) else: if len(self.clippingStack) > 0: self.renderer.clipPath() else: path.AddRectangle( x, y, w, h ) return path, ops @pathHandler def addCircleToDocument(self, node, path): cx, cy, r = [attrAsFloat(node, attr) for attr in ('cx', 'cy', 'r')] path.AddCircle(cx, cy, r) @pathHandler def addEllipseToDocument(self, node, path): cx, cy, rx, ry = [float(node.get(attr, 0)) for attr in ('cx', 'cy', 'rx', 'ry')] #cx, cy are centerpoint. #rx, ry are radius. if rx <= 0 or ry <= 0: return path.AddEllipse(cx, cy, rx, ry) @pathHandler def addLineToDocument(self, node, path): x1, y1, x2, y2 = [attrAsFloat(node, attr) for attr in ('x1', 'y1', 'x2', 'y2')] path.MoveToPoint(x1, y1) path.AddLineToPoint(x2, y2) @pathHandler def addPolyLineToDocument(self, node, path): #translate to pathdata and render that data = "M " + node.get("points") self.addPathDataToPath(data, path) @pathHandler def addPolygonToDocument(self, node, path): #translate to pathdata and render that points = node.get("points") if points is not None: data = "M " + points + " Z" self.addPathDataToPath(data, path) @pathHandler def addPathDataToDocument(self, node, path): self.addPathDataToPath(node.get('d', ''), path) def addPathDataToPath(self, data, path): self.lastControl = None self.lastControlQ = None self.firstPoints = [] def normalizeStrokes(parseResults): """ The data comes from the parser in the form of (command, [list of arguments]). We translate that to [(command, args[0]), (command, args[1])] via a generator. M is special cased because its subsequent arguments become linetos. """ for command, arguments in parseResults: if not arguments: yield (command, ()) else: arguments = iter(arguments) if command == 'm': yield (command, arguments.next()) command = "l" elif command == "M": yield (command, arguments.next()) command = "L" for arg in arguments: yield (command, arg) try: parsed = svg_parser.parse(data) except SyntaxError, e: print 'SyntaxError: %s' % e print 'data = %r' % data else: for stroke in normalizeStrokes(parsed): self.addStrokeToPath(path, stroke) def generatePathOps(self, path): """ Look at the current state and generate the draw operations (fill, stroke, neither) for the path. """ ops = [] brush = self.getBrushFromState(path) fillRule = self.state.get('fill-rule', 'nonzero') fr = self.renderer.fill_rules.get(fillRule) if brush is not None: if isinstance(brush, AbstractGradientBrush): ops.extend([ (self.renderer.gradientPath, (path, brush)), ]) else: ops.extend([ (self.renderer.setBrush, (brush,)), (self.renderer.fillPath, (path, fr)), ]) pen = self.getPenFromState() if pen is not None: ops.extend([ (self.renderer.setPen, (pen,)), (self.renderer.strokePath, (path,)), ]) return ops def getPenFromState(self): pencolour = self.state.get('stroke', 'none') if pencolour == 'currentColor': pencolour = self.state.get('color', 'none') if pencolour == 'transparent': return self.renderer.TransparentPen if pencolour == 'none': return self.renderer.NullPen type, value = colourValue.parseString(pencolour) if type == 'URL': warnings.warn("Color servers for stroking not implemented") return self.renderer.NullPen else: if value[:3] == (-1, -1, -1): return self.renderer.NullPen pen = self.renderer.createPen(value) width = self.state.get('stroke-width') if width: width, units = values.length.parseString(width) pen.SetWidth(width) stroke_dasharray = self.state.get('stroke-dasharray', 'none') if stroke_dasharray != 'none': stroke_dasharray = map(valueToPixels, stroke_dasharray.replace(',', ' ').split()) if len(stroke_dasharray) % 2: # Repeat to get an even array. stroke_dasharray = stroke_dasharray * 2 stroke_dashoffset = valueToPixels(self.state.get('stroke-dashoffset', '0')) self.renderer.setPenDash(pen, stroke_dasharray, stroke_dashoffset) pen.SetCap(self.renderer.caps.get(self.state.get('stroke-linecap', None), self.renderer.caps['butt'])) pen.SetJoin(self.renderer.joins.get(self.state.get('stroke-linejoin', None), self.renderer.joins['miter'])) return self.renderer.createNativePen(pen) def parseStops(self, element): """ Parse the color stops from a gradient definition. """ stops = [] gradient_state = self.getLocalState(element) for stop in element: if stop.tag != SVG.stop: warnings.warn("Skipping non- element <%s> in <%s>" % (stop.tag, element.tag)) continue stopstate = self.getLocalState(stop, gradient_state) offset = fractionalValue(stop.get('offset')) offset = max(min(offset, 1.0), 0.0) default_opacity = '1' color = stopstate.get('stop-color', 'black') if color in ['inherit', 'currentColor']: # Try looking up in the gradient element itself. # FIXME: Look farther up? color = stopstate.get('color', 'black') elif color == 'none': color = 'black' default_opacity = '0' type, color = colourValue.parseString(color) if type == 'URL': warnings.warn("Color servers for gradients not implemented") elif color[:3] == (-1, -1, -1): # FIXME: is this right? color = (0.0, 0.0, 0.0, 0.0) opacity = stopstate.get('stop-opacity', default_opacity) if opacity == 'inherit': # FIXME: what value to inherit? opacity = '1' opacity = float(opacity) row = (offset, color[0]/255., color[1]/255., color[2]/255., opacity) stops.append(row) stops.sort() if len(stops) == 0: return numpy.array([]) if stops[0][0] > 0.0: stops.insert(0, (0.0,) + stops[0][1:]) if stops[-1][0] < 1.0: stops.append((1.0,) + stops[-1][1:]) return numpy.transpose(stops) def getBrushFromState(self, path=None): brushcolour = self.state.get('fill', 'black').strip() type, details = paintValue.parseString(brushcolour) if type == "URL": url, fallback = details url = urlparse.urlunsplit(url) try: element = self.dereference(url) except ParseError: element = None if element is None: if fallback: type, details = fallback else: r, g, b, = 0, 0, 0 else: # The referencing tag controls the kind of gradient. Mostly, # it's just the stops that are pulled from the referenced # gradient tag. element_tag = element.tag if element_tag not in (SVG.linearGradient, SVG.radialGradient): if '}' in element_tag: element_tag[element_tag.find('}')+1:] warnings.warn("<%s> not implemented" % element_tag) return self.renderer.NullBrush href = element.get(XLink.href, None) seen = set([element]) # The attributes on the referencing element override those on the # referenced element. state = dict(element.items()) while href is not None: # Gradient is a reference. element = self.dereference(href) if element in seen: # FIXME: if they are loaded from another file, will element # identity work correctly? raise ValueError("Element referred to by %r is a " "circular reference." % href) seen.add(element) #new_state = dict(element.items()) #new_state.update(state) #state = new_state href = element.get(XLink.href, None) spreadMethod = state.get('spreadMethod', 'pad') transforms = self.createTransformOpsFromNode(state, 'gradientTransform') if not transforms: transforms = [] units = state.get('gradientUnits', 'objectBoundingBox') stops = self.parseStops(element) if stops.size == 0: return self.renderer.NullBrush if element_tag == SVG.linearGradient: x1 = attrAsFloat(state, 'x1', '0%') y1 = attrAsFloat(state, 'y1', '0%') x2 = attrAsFloat(state, 'x2', '100%') y2 = attrAsFloat(state, 'y2', '0%') return self.renderer.createLinearGradientBrush(x1,y1,x2,y2, stops, spreadMethod=spreadMethod, transforms=transforms, units=units) elif element_tag == SVG.radialGradient: cx = attrAsFloat(state, 'cx', '50%') cy = attrAsFloat(state, 'cy', '50%') r = attrAsFloat(state, 'r', '50%') fx = attrAsFloat(state, 'fx', state.get('cx', '50%')) fy = attrAsFloat(state, 'fy', state.get('cy', '50%')) return self.renderer.createRadialGradientBrush(cx,cy, r, stops, fx,fy, spreadMethod=spreadMethod, transforms=transforms, units=units) else: #invlid gradient specified return self.renderer.NullBrush r,g,b = 0,0,0 if type == 'CURRENTCOLOR': type, details = paintValue.parseString(self.state.get('color', 'none')) if type == 'RGB': r,g,b = details elif type == "NONE": #print 'returning null brush' return self.renderer.NullBrush opacity = self.state.get('fill-opacity', self.state.get('opacity', '1')) opacity = float(opacity) opacity = min(max(opacity, 0.0), 1.0) a = 255 * opacity #using try/except block instead of #just setdefault because the brush and colour would #be created every time anyway in order to pass them, #defeating the purpose of the cache try: brush = self.brushCache[(r,g,b,a)] except KeyError: brush = self.brushCache.setdefault((r,g,b,a), self.renderer.createBrush((r,g,b,a))) return brush def addStrokeToPath(self, path, stroke): """ Given a stroke from a path command (in the form (command, arguments)) create the path commands that represent it. TODO: break out into (yet another) class/module, especially so we can get O(1) dispatch on type? """ type, arg = stroke relative = False if type == type.lower(): relative = True #ox, oy = path.GetCurrentPoint().Get() ox, oy = path.GetCurrentPoint() else: ox = oy = 0 def normalizePoint(arg): x, y = arg return x+ox, y+oy def reflectPoint(point, relativeTo): x, y = point a, b = relativeTo return ((a*2)-x), ((b*2)-y) type = type.upper() if type == 'M': pt = normalizePoint(arg) self.firstPoints.append(pt) path.MoveToPoint(*pt) elif type == 'L': pt = normalizePoint(arg) path.AddLineToPoint(*pt) elif type == 'C': #control1, control2, endpoint = arg control1, control2, endpoint = map( normalizePoint, arg ) self.lastControl = control2 path.AddCurveToPoint( control1, control2, endpoint ) #~ cp = path.GetCurrentPoint() #~ path.AddCircle(c1x, c1y, 5) #~ path.AddCircle(c2x, c2y, 3) #~ path.AddCircle(x,y, 7) #~ path.MoveToPoint(cp) #~ print "C", control1, control2, endpoint elif type == 'S': #control2, endpoint = arg control2, endpoint = map( normalizePoint, arg ) if self.lastControl: control1 = reflectPoint(self.lastControl, path.GetCurrentPoint()) else: control1 = path.GetCurrentPoint() #~ print "S", self.lastControl,":",control1, control2, endpoint self.lastControl = control2 path.AddCurveToPoint( control1, control2, endpoint ) elif type == "Q": (cx, cy), (x,y) = map(normalizePoint, arg) self.lastControlQ = (cx, cy) path.AddQuadCurveToPoint(cx, cy, x, y) elif type == "T": x, y, = normalizePoint(arg) if self.lastControlQ: cx, cy = reflectPoint(self.lastControlQ, path.GetCurrentPoint()) else: cx, cy = path.GetCurrentPoint() self.lastControlQ = (cx, cy) path.AddQuadCurveToPoint(cx, cy, x, y) elif type == "V": _, y = normalizePoint((0, arg)) x, _ = path.GetCurrentPoint() path.AddLineToPoint(x,y) elif type == "H": x, _ = normalizePoint((arg, 0)) _, y = path.GetCurrentPoint() path.AddLineToPoint(x,y) elif type == "A": ( (rx, ry), #radii of ellipse angle, #angle of rotation on the ellipse in degrees large_arc_flag, sweep_flag, #arc and stroke angle flags (x2, y2) #endpoint on the arc ) = arg x2, y2 = normalizePoint((x2,y2)) path.elliptical_arc_to(rx, ry, angle, large_arc_flag, sweep_flag, x2, y2) elif type == 'Z': #~ Bugginess: #~ CloseSubpath() doesn't change the #~ current point, as SVG spec requires. #~ However, manually moving to the endpoint afterward opens a new subpath #~ and (apparently) messes with stroked but not filled paths. #~ This is possibly a bug in GDI+? #~ Manually closing the path via AddLineTo gives incorrect line join #~ results #~ Manually closing the path *and* calling CloseSubpath() appears #~ to give correct results on win32 #pt = self.firstPoints.pop() #path.AddLineToPoint(*pt) path.CloseSubpath() def render(self, context): if not hasattr(self, "ops"): return for op, args in self.ops: #print op, context, args op(context, *args) if __name__ == '__main__': from tests.test_document import TestBrushFromColourValue, TestValueToPixels, unittest unittest.main() enthought-chaco2-4.5.1.orig/enable/constraints_container.py0000644000175000017500000004000212516137326023105 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2013, Enthought, Inc. # All rights reserved. #------------------------------------------------------------------------------ from collections import deque # traits imports from traits.api import Any, Bool, Callable, Dict, Either, Instance, List, \ Property # local imports from container import Container from coordinate_box import CoordinateBox, get_from_constraints_namespace from layout.layout_helpers import expand_constraints from layout.layout_manager import LayoutManager from layout.utils import add_symbolic_contents_constraints class ConstraintsContainer(Container): """ A Container which lays out its child components using a constraints-based layout solver. """ # A read-only symbolic object that represents the left boundary of # the component contents_left = Property(fget=get_from_constraints_namespace) # A read-only symbolic object that represents the right boundary # of the component contents_right = Property(fget=get_from_constraints_namespace) # A read-only symbolic object that represents the bottom boundary # of the component contents_bottom = Property(fget=get_from_constraints_namespace) # A read-only symbolic object that represents the top boundary of # the component contents_top = Property(fget=get_from_constraints_namespace) # A read-only symbolic object that represents the width of the # component contents_width = Property(fget=get_from_constraints_namespace) # A read-only symbolic object that represents the height of the # component contents_height = Property(fget=get_from_constraints_namespace) # A read-only symbolic object that represents the vertical center # of the component contents_v_center = Property(fget=get_from_constraints_namespace) # A read-only symbolic object that represents the horizontal # center of the component contents_h_center = Property(fget=get_from_constraints_namespace) # The layout constraints for this container. # This can either be a list or a callable. If it is a callable, it will be # called with a single argument, the ConstraintsContainer, and be expected # to return a list of constraints. layout_constraints = Either(List, Callable) # A boolean which indicates whether or not to allow the layout # ownership of this container to be transferred to an ancestor. # This is False by default, which means that every container # get its own layout solver. This improves speed and reduces # memory use (by keeping a solver's internal tableaux small) # but at the cost of not being able to share constraints # across Container boundaries. This flag must be explicitly # marked as True to enable sharing. share_layout = Bool(False) # Sharing related private traits _owns_layout = Bool(True) _layout_owner = Any # The contents box constraints for this container _contents_constraints = Property # The user-specified layout constraints, with layout helpers expanded _layout_constraints = Property # A dictionary of components added to this container _component_map = Dict # The kiwi solver _layout_manager = Instance(LayoutManager, allow_none=True) _offset_table = List _layout_table = List #------------------------------------------------------------------------ # Public methods #------------------------------------------------------------------------ def do_layout(self, size=None, force=False): """ Make sure child components get a chance to refresh their layout. """ for component in self.components: component.do_layout(size=size, force=force) def refresh(self): """ Re-run the constraints solver in response to a resize or constraints modification. """ if self._owns_layout: if self._layout_manager is None: return mgr_layout = self._layout_manager.layout offset_table = self._offset_table width_var = self.layout_width height_var = self.layout_height width, height = self.bounds def layout(): running_index = 1 for offset_index, item in self._layout_table: dx, dy = offset_table[offset_index] nx, ny = item.left.value(), item.bottom.value() item.position = (nx - dx, ny - dy) item.bounds = (item.layout_width.value(), item.layout_height.value()) offset_table[running_index] = (nx, ny) running_index += 1 mgr_layout(layout, width_var, height_var, (width, height)) self.invalidate_draw() else: self._layout_owner.refresh() def relayout(self): """ Explicitly regenerate the container's constraints and refresh the layout. """ if not self.share_layout: self._init_layout() self.refresh() elif self._layout_owner is not None: self._layout_owner.relayout() #------------------------------------------------------------------------ # Layout Sharing #------------------------------------------------------------------------ def transfer_layout_ownership(self, owner): """ A method which can be called by other components in the hierarchy to gain ownership responsibility for the layout of the children of this container. By default, the transfer is allowed and is the mechanism which allows constraints to cross widget boundaries. Subclasses should reimplement this method if different behavior is desired. Parameters ---------- owner : ConstraintsContainer The container which has taken ownership responsibility for laying out the children of this component. All relayout and refresh requests will be forwarded to this component. Returns ------- results : bool True if the transfer was allowed, False otherwise. """ if not self.share_layout: return False self._owns_layout = False self._layout_owner = owner self._layout_manager = None return True def will_transfer(self): """ Whether or not the container expects to transfer its layout ownership to its parent. This method is predictive in nature and exists so that layout managers are not senslessly created during the bottom-up layout initialization pass. It is declared public so that subclasses can override the behavior if necessary. """ cls = ConstraintsContainer if self.share_layout: if self.container and isinstance(self.container, cls): return True return False #------------------------------------------------------------------------ # Traits methods #------------------------------------------------------------------------ def _bounds_changed(self, old, new): """ Run the solver when the container's bounds change. """ super(ConstraintsContainer, self)._bounds_changed(old, new) self.refresh() def _layout_constraints_changed(self): """ Refresh the layout when the user constraints change. """ self.relayout() def _get__contents_constraints(self): """ Return the constraints which define the content box of this container. """ add_symbolic_contents_constraints(self._constraints_vars) return [self.contents_left == self.left, self.contents_bottom == self.bottom, self.contents_right == self.left + self.layout_width, self.contents_top == self.bottom + self.layout_height, ] def _get__layout_constraints(self): """ React to changes of the user controlled constraints. """ if self.layout_constraints is None: return [] if callable(self.layout_constraints): new = self.layout_constraints(self) else: new = self.layout_constraints # Expand any layout helpers return [cns for cns in expand_constraints(self, new)] def __components_items_changed(self, event): """ Make sure components that are added can be used with constraints. """ # Remove stale components from the map for item in event.removed: item.on_trait_change(self._component_size_hint_changed, 'layout_size_hint', remove=True) del self._component_map[item.id] # Check the added components self._check_and_add_components(event.added) def __components_changed(self, new): """ Make sure components that are added can be used with constraints. """ # Clear the component maps for key, item in self._component_map.iteritems(): item.on_trait_change(self._component_size_hint_changed, 'layout_size_hint', remove=True) self._component_map = {} # Check the new components self._check_and_add_components(new) def _component_size_hint_changed(self): """ Refresh the size hint contraints for a child component """ self.relayout() #------------------------------------------------------------------------ # Protected methods #------------------------------------------------------------------------ def _build_layout_table(self): """ Build the layout and offset tables for this container. A layout table is a pair of flat lists which hold the required objects for laying out the child widgets of this container. The flat table is built in advance (and rebuilt if and when the tree structure changes) so that it's not necessary to perform an expensive tree traversal to layout the children on every resize event. Returns ------- result : (list, list) The offset table and layout table to use during a resize event. """ # The offset table is a list of (dx, dy) tuples which are the # x, y offsets of children expressed in the coordinates of the # layout owner container. This owner container may be different # from the parent of the widget, and so the delta offset must # be subtracted from the computed geometry values during layout. # The offset table is updated during a layout pass in breadth # first order. # # The layout table is a flat list of (idx, updater) tuples. The # idx is an index into the offset table where the given child # can find the offset to use for its layout. The updater is a # callable provided by the widget which accepts the dx, dy # offset and will update the layout geometry of the widget. zero_offset = (0, 0) offset_table = [zero_offset] layout_table = [] queue = deque((0, child) for child in self._component_map.itervalues()) # Micro-optimization: pre-fetch bound methods and store globals # as locals. This method is not on the code path of a resize # event, but it is on the code path of a relayout. If there # are many children, the queue could potentially grow large. push_offset = offset_table.append push_item = layout_table.append push = queue.append pop = queue.popleft CoordinateBox_ = CoordinateBox Container_ = ConstraintsContainer isinst = isinstance # The queue yields the items in the tree in breadth-first order # starting with the immediate children of this container. If a # given child is a container that will share its layout, then # the children of that container are added to the queue to be # added to the layout table. running_index = 0 while queue: offset_index, item = pop() if isinst(item, CoordinateBox_): push_item((offset_index, item)) push_offset(zero_offset) running_index += 1 if isinst(item, Container_): if item.transfer_layout_ownership(self): for child in item._component_map.itervalues(): push((running_index, child)) return offset_table, layout_table def _check_and_add_components(self, components): """ Make sure components can be used with constraints. """ for item in components: key = item.id if len(key) == 0: msg = "Components added to a {0} must have a valid 'id' trait." name = type(self).__name__ raise ValueError(msg.format(name)) elif key in self._component_map: msg = "A Component with id '{0}' has already been added." raise ValueError(msg.format(key)) elif key == self.id: msg = "Can't add a Component with the same id as its parent." raise ValueError(msg) self._component_map[key] = item item.on_trait_change(self._component_size_hint_changed, 'layout_size_hint') # Update the layout self.relayout() def _generate_constraints(self, layout_table): """ Creates the list of kiwi Constraint objects for the widgets for which this container owns the layout. This method walks over the items in the given layout table and aggregates their constraints into a single list of kiwi Constraint objects which can be given to the layout manager. Parameters ---------- layout_table : list The layout table created by a call to _build_layout_table. Returns ------- result : list The list of kiwi Constraint instances to pass to the layout manager. """ user_cns = self._layout_constraints user_cns_extend = user_cns.extend # The list of raw kiwi constraints which will be returned # from this method to be added to the kiwi solver. raw_cns = self._hard_constraints + self._contents_constraints raw_cns_extend = raw_cns.extend isinst = isinstance Container_ = ConstraintsContainer # The first element in a layout table item is its offset index # which is not relevant to constraints generation. for _, child in layout_table: raw_cns_extend(child._hard_constraints) if isinst(child, Container_): if child.transfer_layout_ownership(self): user_cns_extend(child._layout_constraints) raw_cns_extend(child._contents_constraints) else: raw_cns_extend(child._size_constraints) else: raw_cns_extend(child._size_constraints) return raw_cns + user_cns def _init_layout(self): """ Initializes the layout for the container. """ # Layout ownership can only be transferred *after* this init # layout method is called, since layout occurs bottom up. So, # we only initialize a layout manager if we are not going to # transfer ownership at some point. if not self.will_transfer(): offset_table, layout_table = self._build_layout_table() cns = self._generate_constraints(layout_table) # Initializing the layout manager can fail if the objective # function is unbounded. We let that failure occur so it can # be logged. Nothing is stored until it succeeds. manager = LayoutManager() manager.initialize(cns) self._offset_table = offset_table self._layout_table = layout_table self._layout_manager = manager enthought-chaco2-4.5.1.orig/enable/viewport.py0000644000175000017500000003015512516137326020363 0ustar varunvarun""" Defines a Viewport which renders sub-areas of components """ from __future__ import with_statement # Standard library imports from numpy import array, dot # Enthought library traits from enable.tools.viewport_zoom_tool import ViewportZoomTool from enable.simple_layout import simple_container_get_preferred_size, \ simple_container_do_layout from traits.api import (Bool, Delegate, Float, Instance, Enum, List, Any, on_trait_change) from kiva import affine # Local relative imports from enable_traits import bounds_trait, coordinate_trait from base import empty_rectangle, intersect_bounds from component import Component from container import Container from canvas import Canvas class Viewport(Component): """ A "window" or "view" into a sub-region of another component. """ # The component we are viewing component = Instance(Component) # The position of our viewport into our component (in the component's # coordinate space) view_position = coordinate_trait # The bounds of our viewport in the space of our component view_bounds = bounds_trait # Whether or not this viewport should stay constrained to the bounds # of the viewed component # TODO: Implement this stay_inside = Bool(False) # Enable Zoom interaction enable_zoom = Bool(False) # The zoom tool zoom_tool = Instance(ViewportZoomTool) # Zoom scaling factor for this viewport - Ratio of old bounds to new bounds. # Zoom less than 1.0 means we are zoomed out, and more than 1.0 means # we are zoomed in. Zoom should always be positive and nonzero. zoom = Float(1.0) # Whether to initiate layout on the viewed component. This is necessary # if the component is only viewed through viewports, in which case one # of the viewports must lay it out or bounds must be set explicitly # on the component. initiate_layout = Bool(False) min_zoom = Delegate('zoom_tool', modify=True) max_zoom = Delegate('zoom_tool', modify=True) _component_preferred_size = Any(None) #------------------------------------------------------------------------ # Public methods #------------------------------------------------------------------------ def __init__(self, **traits): Component.__init__(self, **traits) self._update_component_view_bounds() if 'zoom_tool' not in traits: self.zoom_tool = ViewportZoomTool(self) if self.enable_zoom: self._enable_zoom_changed(False, True) return def components_at(self, x, y, add_containers = False): """ Returns the list of components inside the viewport at the given (x,y) in the viewport's native coordinate space (not in the space of the component it is viewing). Although Viewports are not containers, they support this method. """ if self.is_in(x, y): if self.component is not None: # Transform (scale + translate) the incoming X and Y # coordinates from our coordinate system into the coordinate # system of the component we are viewing. x_trans, y_trans = self.viewport_to_component(x, y) if isinstance(self.component, Container): return self.component.components_at(x_trans, y_trans) elif self.component.is_in(x_trans, y_trans): return [self.component] else: return [] else: return [] def invalidate_draw(self, damaged_regions=None, self_relative=False, view_relative=False): if view_relative and damaged_regions: damaged_regions = [[region[0] - self.view_position[0], region[1] - self.view_position[1], region[2], region[3]] for region in damaged_regions] super(Viewport, self).invalidate_draw(damaged_regions=damaged_regions, self_relative=self_relative) return def cleanup(self, window): """When a window viewing or containing a component is destroyed, cleanup is called on the component to give it the opportunity to delete any transient state it may have (such as backbuffers).""" if self.component: self.component.cleanup(window) def get_preferred_size(self): """If we're initiating layout, act like an OverlayPlotContainer, otherwise do the normal component action""" if self.initiate_layout: self._component_preferred_size = simple_container_get_preferred_size(self, components=[container]) return self._component_preferred_size else: return super(Viewport, self).get_preferred_size() def viewport_to_component(self, x, y): """ Given a coordinate X and Y in the viewport's coordinate system, returns and X and Y in the coordinate system of the viewed component. """ transform = self.get_event_transform() return dot(array([x,y,1]), transform)[:2] def component_to_viewport(self, x, y): """ Given a coordinate X and Y in the viewed component's coordinate system, returns a coordinate in the coordinate system of the Viewport. """ vx, vy = self.view_position ox, oy = self.outer_position newx = (x - vx) * self.zoom + ox newy = (y - vx) * self.zoom + oy return (newx, newy) def get_event_transform(self, event=None, suffix=""): transform = affine.affine_identity() if isinstance(self.component, Component): # If we have zoom enabled, scale events. Since affine transforms # multiply from the left, we build up the transform from the # inside of the viewport outwards. if self.enable_zoom and self.zoom != 1.0: transform = affine.translate(transform, *self.view_position) transform = affine.scale(transform, 1/self.zoom, 1/self.zoom) transform = affine.translate(transform, -self.outer_position[0], -self.outer_position[1]) else: x_offset = self.view_position[0] - self.outer_position[0] y_offset = self.view_position[1] - self.outer_position[1] transform = affine.translate(transform, x_offset, y_offset) return transform #------------------------------------------------------------------------ # Component interface #------------------------------------------------------------------------ def _draw_mainlayer(self, gc, view_bounds=None, mode="normal"): # For now, ViewPort ignores the view_bounds that are passed in... # Long term, it should be intersected with the view_position to # compute a new view_bounds to pass in to our component. if self.component is not None: x, y = self.position view_x, view_y = self.view_position with gc: # Clip in the viewport's space (screen space). This ensures # that the half-pixel offsets we us are actually screen pixels, # and it's easier/more accurate than transforming the clip # rectangle down into the component's space (especially if zoom # is involved). gc.clip_to_rect(x-0.5, y-0.5, self.width+1, self.height+1) # There is a two-step transformation from the viewport's "outer" # coordinates into the coordinates space of the viewed component: # scaling, followed by a translation. if self.enable_zoom: if self.zoom != 0: gc.scale_ctm(self.zoom, self.zoom) gc.translate_ctm(x/self.zoom - view_x, y/self.zoom - view_y) else: raise RuntimeError("Viewport zoomed out too far.") else: gc.translate_ctm(x - view_x, y - view_y) # Now transform the passed-in view_bounds; this is not the same thing as # self.view_bounds! if view_bounds: # Find the intersection rectangle of the viewport with the view_bounds, # and transform this into the component's space. clipped_view = intersect_bounds(self.position + self.bounds, view_bounds) if clipped_view != empty_rectangle: # clipped_view and self.position are in the space of our parent # container. we know that self.position -> view_x,view_y # in the coordinate space of our component. So, find the # vector from self.position to clipped_view, then add this to # view_x and view_y to generate the transformed coordinates # of clipped_view in our component's space. offset = array(clipped_view[:2]) - array(self.position) new_bounds = ((offset[0]/self.zoom + view_x), (offset[1]/self.zoom + view_y), clipped_view[2] / self.zoom, clipped_view[3] / self.zoom) self.component.draw(gc, new_bounds, mode=mode) return def _do_layout(self): if self.initiate_layout: self.component.bounds = list(self.component.get_preferred_size()) self.component.do_layout() else: super(Viewport, self)._do_layout() return def _dispatch_stateful_event(self, event, suffix): if isinstance(self.component, Component): transform = self.get_event_transform(event, suffix) event.push_transform(transform, caller=self) try: self.component.dispatch(event, suffix) finally: event.pop(caller=self) return #------------------------------------------------------------------------ # Event handlers #------------------------------------------------------------------------ def _enable_zoom_changed(self, old, new): """ Add or remove the zoom tool overlay depending whether or not zoom is enabled. """ if self.zoom_tool is None: return if self.enable_zoom: if not self.zoom_tool in self.tools: self.tools.append(self.zoom_tool) else: if self.zoom_tool in self.tools: self.tools.remove(self.zoom_tool) def _update_component_view_bounds(self): """ Updates the optional .view_bounds trait on our component; mostly used for Canvas objects. """ if isinstance(self.component, Canvas): llx, lly = self.view_position self.component.view_bounds = (llx, lly, llx + self.view_bounds[0]-1, lly + self.view_bounds[1]-1) return def _component_changed(self, old, new): if (old is not None) and (self in old.viewports): old.viewports.remove(self) if (new is not None) and (self not in new.viewports): new.viewports.append(self) self._update_component_view_bounds() return def _bounds_changed(self, old, new): Component._bounds_changed(self, old, new) self.set(view_bounds = [new[0]/self.zoom, new[1]/self.zoom], trait_change_notify=False) self._update_component_view_bounds() return def _bounds_items_changed(self, event): return self._bounds_changed(None, self.bounds) @on_trait_change("view_bounds,view_position") def _handle_view_box_changed(self): self._update_component_view_bounds() def _get_position(self): return self.view_position def _get_bounds(self): return self.view_bounds # EOF enthought-chaco2-4.5.1.orig/enable/example_canvas.py0000644000175000017500000000267112516137326021474 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ """ A suitable replacement for the old Canvas class in Kiva. """ from enable.api import Component, Window class _DummyComponent(Component): def __init__(self, draw_func, *args, **kwargs): super(_DummyComponent, self).__init__(*args, **kwargs) self._draw_func = draw_func def __del__(self): self._draw_func = None def draw(self, gc, **kwargs): """ Call our wrapped draw function. """ self._draw_func(gc) class Canvas(Window): def __init__(self): # Create a component that wraps our do_draw method self.component = _DummyComponent(self.do_draw) # call our base class super(Window, self).__init__(None) def do_draw(self, gc): """ Method to be implemented by subclasses to actually perform various GC drawing commands before the GC is blitted into the screen. """ pass enthought-chaco2-4.5.1.orig/enable/testing.py0000644000175000017500000004534112516137326020164 0ustar varunvarun# Copyright (c) 2008-2013 by Enthought, Inc. # All rights reserved. from mock import Mock from enable.abstract_window import AbstractWindow from enable.events import MouseEvent, KeyEvent, DragEvent from kiva.testing import KivaTestAssistant class _MockWindow(AbstractWindow): # FIXME: for some reason I cannot replace these functions with a Mock def _get_control_size(self): return 0, 0 def _redraw(self, coordinates=None): pass _drag_result = None def set_drag_result(self, result): self._drag_result = result class EnableTestAssistant(KivaTestAssistant): """ Mixin helper for enable/chaco components. """ def press_move_release(self, interactor, points, window=None, alt_down=False, control_down=False, shift_down=False): """ Simulate the action of left click pressing, dragging and releasing the mouse. Parameters ---------- interactor : enable interactor object This is object where the mouse events will be dispatched to. points : A list of x,y tuple The x,y positions of the three event sections. The first tuple will be sent with a left-down event and the last will be sent with a left-up. All the other events in the list will be sent using a mouse-move event. window : AbstractWindow, optional The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used. alt_down : boolean, optional The button is pressed while `alt` is down. Default value is False. control_down : boolean, optional The button is pressed while `control` is down. Default value is False. shift_down : boolean, optional The button is pressed while `shift` is down. Default value is False. """ x, y = points[0] window = self.create_mock_window() if window is None else window self.mouse_down(interactor, x, y, 'left', window=window, alt_down=alt_down, control_down=control_down, shift_down=shift_down) for x, y in points[1:-1]: self.mouse_move(interactor, x, y, window=window, alt_down=alt_down, control_down=control_down, shift_down=shift_down) x, y = points[-1] self.mouse_up(interactor, x, y, 'left', window=window, alt_down=alt_down, control_down=control_down, shift_down=shift_down) def create_mock_window(self): """ Creates a Mock class that behaves as an enable Abstract Window. Returns ------- window : Mock A mock class instance of an abstract window. """ window = _MockWindow() window._capture_mouse = Mock() window.set_pointer = Mock() window._release_mouse = Mock() window._redraw = Mock() window.control = Mock() window.control.set_pointer = Mock() window.get_pointer_position = Mock() return window def create_key_press(self, key, window=None, alt_down=False, control_down=False, shift_down=False): """ Creates a KeyEvent for the given Key. Parameters ---------- key : string The key of the event window : AbstractWindow, optional The enable AbstractWindow to associate with the event. Default is to create a mock class instance. alt_down : boolean, optional The key is pressed while `alt` is down. Default value is False. control_down : boolean, optional The key is pressed while `control` is down. Default value is False. shift_down : boolean, optional The key is pressed while `shift` is down. Default value is False. Returns ------- key_event : KeyEvent The enable KEyEvent instance of the desired event ready to be passed to an enable Interactor. """ key_event = KeyEvent(character=key, event_type='key_pressed', alt_down=alt_down, control_down=control_down, shift_down=shift_down) if window is None: key_event.window = self.create_mock_window() else: key_event.window = window return key_event def create_mouse_event(self, **kwargs): """ Creates a MouseEvent() with the specified attributes. """ # provide defaults for all key shift states event_attributes = { # key shift states 'alt_down': False, 'control_down': False, 'shift_down': False, } event_attributes.update(**kwargs) event = MouseEvent(**event_attributes) return event def create_drag_event(self, **kwargs): """ Creates a DragEvent() with the specified attributes. """ event = DragEvent(**kwargs) return event def mouse_down(self, interactor, x, y, button='left', window=None, alt_down=False, control_down=False, shift_down=False): """ Send a mouse button down event to the interactor. Parameters ---------- interactor : Interactor The interactor (or subclass) where to dispatch the event. x : float The x coordinates of the mouse position y : float The y coordinates of the mouse position button : {'left', 'right'}, optional The mouse button for which to simulate a press (down) action. window : AbstractWindow, optional The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used. alt_down : boolean, optional The button is pressed while `alt` is down. Default value is False. control_down : boolean, optional The button is pressed while `control` is down. Default value is False. shift_down : boolean, optional The button is pressed while `shift` is down. Default value is False. Returns ------- event : MouseEvent The event instance after it has be processed by the `interactor`. """ window = self.create_mock_window() if window is None else window event_attributes = {'x': x, 'y': y, 'alt_down': alt_down, 'control_down': control_down, 'shift_down': shift_down, '{0}_down'.format(button): True, 'window': window} event = self.create_mouse_event(**event_attributes) self._mouse_event_dispatch(interactor, event, '{0}_down'.format(button)) return event def mouse_move(self, interactor, x, y, window=None, alt_down=False, control_down=False, shift_down=False): """ Send a mouse move event to the interactor. Parameters ---------- interactor : Interactor The interactor (or subclass) where to dispatch the event. x : float The x coordinates of the mouse position y : float The y coordinates of the mouse position window : AbstractWindow, optional The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used. alt_down : boolean, optional The button is pressed while `alt` is down. Default value is False. control_down : boolean, optional The button is pressed while `control` is down. Default value is False. shift_down : boolean, optional The button is pressed while `shift` is down. Default value is False. Returns ------- event : MouseEvent The event instance after it has be processed by the `interactor`. """ window = self.create_mock_window() if window is None else window event = self.create_mouse_event(x=x, y=y, window=window, alt_down=alt_down, control_down=control_down, shift_down=shift_down) window.get_pointer_position.return_value = (x, y) self._mouse_event_dispatch(interactor, event, 'mouse_move') return event def mouse_up(self, interactor, x, y, button='left', window=None, alt_down=False, control_down=False, shift_down=False): """ Send a mouse button up event to the interactor. Parameters ---------- interactor : Interactor The interactor (or subclass) where to dispatch the event. x : float The x coordinates of the mouse position y : float The y coordinates of the mouse position button : {'left', 'right'}, optional The mouse button for which to simulate a release (up) action. window : AbstractWindow, optional The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used. alt_down : boolean, optional The button is pressed while `alt` is down. Default value is False. control_down : boolean, optional The button is pressed while `control` is down. Default value is False. shift_down : boolean, optional The button is pressed while `shift` is down. Default value is False. Returns ------- event : MouseEvent The event instance after it has be processed by the `interactor`. """ window = self.create_mock_window() if window is None else window event = self.create_mouse_event(x=x, y=y, window=window, alt_down=alt_down, control_down=control_down, shift_down=shift_down) self._mouse_event_dispatch(interactor, event, '{0}_up'.format(button)) return event def mouse_leave(self, interactor, x, y, window=None, alt_down=False, control_down=False, shift_down=False): """ Send a mouse leave event to the interactor. Parameters ---------- interactor : Interactor The interactor (or subclass) where to dispatch the event. x : float The x coordinates of the mouse position y : float The y coordinates of the mouse position window : AbstractWindow, optional The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used. alt_down : boolean, optional The button is pressed while `alt` is down. Default value is False. control_down : boolean, optional The button is pressed while `control` is down. Default value is False. shift_down : boolean, optional The button is pressed while `shift` is down. Default value is False. Returns ------- event : MouseEvent The event instance after it has be processed by the `interactor`. """ window = self.create_mock_window() if window is None else window event = self.create_mouse_event(x=x, y=y, window=window, alt_down=alt_down, control_down=control_down, shift_down=shift_down) self._mouse_event_dispatch(interactor, event, 'mouse_leave') return event def mouse_enter(self, interactor, x, y, window=None, alt_down=False, control_down=False, shift_down=False): """ Send a mouse enter event to the interactor. Parameters ---------- interactor : Interactor The interactor (or subclass) where to dispatch the event. x : float The x coordinates of the mouse position y : float The y coordinates of the mouse position window : AbstractWindow, optional The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used. alt_down : boolean, optional The button is pressed while `alt` is down. Default value is False. control_down : boolean, optional The button is pressed while `control` is down. Default value is False. shift_down : boolean, optional The button is pressed while `shift` is down. Default value is False. Returns ------- event : MouseEvent The event instance after it has be processed by the `interactor`. """ window = self.create_mock_window() if window is None else window event = self.create_mouse_event(x=x, y=y, window=window, alt_down=alt_down, control_down=control_down, shift_down=shift_down) self._mouse_event_dispatch(interactor, event, 'mouse_enter') return event def send_key(self, interactor, key, window=None): """ Sent a key press event to the interactor. Parameters ---------- interactor : Interactor The interactor (or subclass) where to dispatch the event. key : string The key press to simulate. window : AbstractWindow, optional The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a focus owner then that interactor is used. Returns ------- event : KeyEvent The event instance after it has be processed by the `interactor`. """ window = self.create_mock_window() if window is None else window event = self.create_key_press(key, window=window) self._key_event_dispatch(interactor, event) return event def send_drag_over(self, interactor, x, y, obj, window=None): """ Sent a drag_over event to the interactor. Parameters ---------- interactor : Interactor The interactor (or subclass) where to dispatch the event. x : float The x coordinates of the mouse position y : float The y coordinates of the mouse position obj : object The object(s) being dragged or dropped window : AbstractWindow, optional The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used. Returns ------- event : KeyEvent The event instance after it has be processed by the `interactor`. """ window = self.create_mock_window() if window is None else window event = self.create_drag_event(x=x, y=y, obj=obj, window=window) self._drag_event_dispatch(interactor, event, "drag_over") return event def send_dropped_on(self, interactor, x, y, obj, window=None): """ Sent a dropped_on event to the interactor. Parameters ---------- interactor : Interactor The interactor (or subclass) where to dispatch the event. x : float The x coordinates of the mouse position y : float The y coordinates of the mouse position obj : object The object(s) being dragged or dropped window : AbstractWindow, optional The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used. Returns ------- event : KeyEvent The event instance after it has be processed by the `interactor`. """ window = self.create_mock_window() if window is None else window event = self.create_drag_event(x=x, y=y, obj=obj, window=window) self._drag_event_dispatch(interactor, event, "dropped_on") return event def send_drag_leave(self, interactor, x, y, window=None): """ Sent a drag_leave event to the interactor. Parameters ---------- interactor : Interactor The interactor (or subclass) where to dispatch the event. x : float The x coordinates of the mouse position y : float The y coordinates of the mouse position window : AbstractWindow, optional The enable AbstractWindow to associate with the event. Default is to create a mock class instance. If the window has a mouse owner then that interactor is used. Returns ------- event : KeyEvent The event instance after it has be processed by the `interactor`. """ window = self.create_mock_window() if window is None else window event = self.create_drag_event(x=x, y=y, window=window) self._drag_event_dispatch(interactor, event, "drag_leave") return event def _mouse_event_dispatch(self, interactor, event, suffix): mouse_owner = event.window.mouse_owner if mouse_owner is None: interactor.dispatch(event, suffix) else: mouse_owner.dispatch(event, suffix) def _key_event_dispatch(self, interactor, event): focus_owner = event.window.focus_owner if focus_owner is None: interactor.dispatch(event, 'key_pressed') else: focus_owner.dispatch(event, 'key_pressed') def _drag_event_dispatch(self, interactor, event, suffix): interactor.dispatch(event, suffix) enthought-chaco2-4.5.1.orig/enable/images.zip0000644000175000017500000005506512516137326020132 0ustar varunvarunPK]r]/$´Ð@¸¼ checkbox.pngë ðsçå’âb``àõôp Ñ ÌÁ$ÿvk)ÎÈb¾Ã Ìx<E P0ÏÓÅ1¤bNï)o®Ö b–Ýš¸»ÇC…e¡ƒÀËä´Ìf9f½C’óÚ¶îq;¥çò}Ò&ù㎚+·ÎRË=“³¶ð\ݽø(±p9ÛÛ.>ù{®œŸ¢Ì—‚®KÚ/ׯ)ðÒ¼xXó¹ÿòOZë1‡Í«gÞ8EéÐfOW?—uN MPKxr]/‚GÂÆcheckbox_down.pngë ðsçå’âb``àõôp Ñ ÌÁ$ÿvk)ÎÈb¾Ã Ìx<E P°ÂÓÅ1¤bNï)_.‡¶îšÖ›¤—Šh²ñìiœÏÈ©¨â©2éÍk§7ê—¶¹ ¨þäwœ’.·lå­mϬؒÃ$,<ß<?ýâëÚ¥ëz2g¾®²ðMvä_žºîÅÃ-kymçôí]Ü~¹òË—‚]çåüþ<T\ÄwhŠêð+B¨#J³.+©¿±§IEND®B`‚PK ‡r]/è1Wppcheckbox_on_over.png‰PNG  IHDR ý‰s+ pHYsÃÃÇo¨d"IDATxœÏ¿KÃ@ðþ!]î?„ýºwÕÑ¡P·B\ºÁI\¢KÅ⢦ ­†RjèP*D”h¡gîÇË].w”âPxÛûð}ß—Ë—ë‹L._®§?é÷]]Ê·–|9Ûb´%Æ»âi/6 [Õî_¶Ä»#žÁ·´û¼’‘KÈocŒ§qŒ)%œ3d#žÂ@ß•‘+'·œ3JÉ,B6¯'àoj÷q!'÷ÈFŠ„l$‚&ôkÚ…ÇòëF-fç F;Ü«hÉèÚ¬ ¢”p¯ÂÜRæÔwsIª+sK¬]Ì\2°’aÃ43ã)k©SÈôÖ¡[ßJÆû"hªN*‰:z¾¬·Æ;+¼³ ½ è׿=[ÊÜ"ó¶‘8ä£_IEND®B`‚PKlr]/¾já checkbox_over.pngë ðsçå’âb``àõôp Ñ ÌÁ$ÿvk)ÎÈb¾Ã Ìx<E Pp¿§‹cHÅœä œ9 l†'XÌþü/ø÷ÿvòÿøw¿¾§œÝÿ»øß½7?«×>=ÿt–½¸WÝü“ÿj•$—ñ­_ï¾8áUXÕççý†×/ÜÏ×êpÕÑçкw'Ö3×”~þgïÍæØ»ŒûçWÛ.x¥whÕ»çqýówÏM|µnëŸ1@¹¼çó­ßåö^—·üîù·a¥`{Ž­ËÛ}µ?7- ôCAÓ¾GjžöÛfþ½‘ÄÜ~±ÿ,[@éË2?«ˆ³Rê@¯0xºú¹¬sJhPK š^c/·Zv•• radio.png‰PNG  IHDR rëä|bKGDÿÿÿ ½§“ pHYs  šœ5IDATxÚ•Ò=kÂPàûWùKAˆK'qî#œÄµK8(J"ŠPB."Ø€‹`SSäÁ‚üH­µòvj[ª¡Ã;œ‡Ã=ç%ȱ<æC3)DIŸÈC”h&…Ç||ï;=š¶N‘*¨¨´,¸ÕNé¢NÑ´ü@MÛp{ÝxÀtú Æ^0›1Ìç3,¯hX’9õ‰Ç|p‚|ÁËeƒÁ 2<æƒh&Eª ^ëõa¸A¦TƒfRQRPiY±`»}C»?‚() |"wâÆ‚Ýî«M>‘&U;½X°ß ;G“4“"]ÔcÁáð‰l¹ý鸽†å\ÝǧóöŽwJæTtxÜÜéç;ýND¦TC»?Âj¢;#[®ÿˆÿfï ‡N*ë—øj,IEND®B`‚PK š^c/xIJ*––radio_down.png‰PNG  IHDR rëä|bKGDÿÿÿ ½§“ pHYs  šœ6IDATxÚ•ÒÏKÂ`ðý+ƒý1ýƒåÙ‹t/ÂØí  !Û`âEC·Á;ЗëÇÁ-JFôŽ"Šþ†o‡1­HG‡žÃûááyž/€I_Dc˜Ä‡$ëàD’¬Ã$>"ãû¿Uá̰‚¾XC¥e€¸Ô.rå&XA3ð9ó;{ûÐŽàºÇ8[ð<‚‹ó1‚Å í¾¾ÔXA&¢1XAÙn®Ïpw‰ŽMÀ "ƒ1‰¾XÛ – ÀL‰]j%YXÕa` ‘:ÌJJ l äŠ3d¦È 6¦üö 3ýa;ìá…÷ðþxÞç}Ü*šŠfàD|!üŠfP4-ÞÎyªçå k lj¥r‰Ó‹4‹ë‡ˆrUÏñRõ¾Ÿ»ÄÏuîîÊÜß[<>V¨Õh4j¨ú5ó+QЦ…(?šÍ¶ÝDKåå EÓBP4ƒ…5ÅÌêâ·1f/gØÏïQ­Whµl:6K'(šàD8N¤<…øm ù÷Óú$GcìdÃt:mç™Dæ ‚ ùB”Ê%o¥Ù˦ôI¾ŸC<ÛÅqžévìVÉ(^¤=ûù=¾3ýÂð¯!Âémº]‡^ï…äUa ¤h‹ë‡žéj½ÂN6Œ´%ÎlS·Ÿèõ^è÷û,ož <¹×Sõkl»é™vWrd¶ðz=÷Oó+Q´TþSàÇjìõO±´qB"sƒÝj“¼*°¼yöïDüoöþµùF"dIEND®B`‚PK š^c/²kradio_on_down.png‰PNG  IHDR rëä|bKGDÿÿÿ ½§“ pHYs  šœ§IDATxÚ•’ÍJa†ç„^@”º/t'X„º,dD×n¤[q#|$-‰‚6hj'íˆ*æ¾ÐŒ§“´.2H*‰Ø0gPÄÒkxº3¶¥.º8pçá=ï9¯(ay~€)ë$…A,‘&) LYÇó~Ÿ‹š²ã¢j)âsËèëydeŸ•üÓ k¨ZвãòTv\ž¿\$óö=•ÊVÛ–|ýbá6ÙØ-Ÿ_@ÅóT-u/ð­Õà¼}ÂfI¢j)À’¾$š ¼Ýí÷v27qŽúÑw†ÚNŠf ./Ñ<‹ážÏc×®º¡“Ü(ŽÞÇt|²}Sç{™½Y…qœÓ(õrû¾DÝÜô};ðó½NN‘XœŒ2›Æ= àâõ{@DœúÉéo#Ĺ(úîχè;CLÇ'{7â¿Ýû³%EóÜÑIEND®B`‚PKz[p/u¬MÄËsb_hmid_over.pngë ðsçå’âb``àõôp Ò ¶ Ìv\µ H±%y»»0üÁ{—OŠpxD30ðaÆ©Ú|Ò Õž.Ž!·’+¾¼³—;òA^?!¢ø½QT¥«áŠò’±Õ}M–^8Ü+þÿÿŸ¿ýS]<Î[vµ¶HõùÿºU,å_ñçÿ¡Çÿ‹û’Ô%ÏÙþêg7œSùC^rnUCÓ…Ã57=E\4Ž=ËßÛÂÎȰ•㸪2Ûêå@k<]ý\Ö9%4PK ä–n/j‘cÔ   sb_hpad.png‰PNG  IHDR 3>9« pHYsÃÃÇo¨d¼IDATxœµÔM‚0†á¹ÿ%<„ÊN „Ÿ hSÂ\êFea§ÑEw3~$.Ú<ë÷kÒ¤t¿]£¢OäCÛn²ö…lêÑ€š‰…ztHiÑ€ÚÉ õä ¼­;ýUYîD•õÒ•##?:ÖWÖÇ(Œ—,´ðÈ?:ÆÆÓÞ8á`²îñò¥3f0Ý8˜²ž…ôèõ‰Ý h×;!Å’þèN@y÷vÝIHw‚ø¿é*¹DõQ]1bL/IEND®B`‚PKœ–n/j¾äyíî sb_hright.pngë ðsçå’âb``àõôp Ò,@,ÈÁ$K;f1)ÎÈb¾Ã Ìx<E Pp§‹cHÅœÒó¶ÜM¬¾·‡{៥×ìí6C>ZUÜ·åE™çJµìÓºÜ!~ÍBŽ,é•Ó[–xëÍ``pþ;c‰å̺Žx†)ž.q’6¬ÂY×¾õň!v›²¹Ž®>û…Ħkþ'¨îÛ ü¹:øìwnåËlØ/H{nj *6b`ôöþâ 2–—}­¨Ü—æŸô«ìÝ›Ùöù:ñk¾¦&¿-º•ÁÓÕÏeSBPK3\p/—X|®üÿsb_hright_down.pngë ðsçå’âb``àõôp Ò,@,ÈÁ$K;f1)¶$ow†ÿ ¸`ïòÉ@ÎÈb¾# Ì8U›O(8ßÓÅ1¤âVéùóÜdŽ|/Ÿ§#2ýl¿J²íÛ†Ô¨þùž'㢃¦0³çž?’d½¢¿YÝ2`þé×ßþ¨øÍÚ·OøúŒ"Þùºó¶ü›vK9ЄaÓU³Þ­÷$U§œ“Õf™p16ióþž“â³/ÉaÝð4seõÄYÎ¥O'Zí?Ãà0ïgÈfå›iïSKÓ+yò9_ÖØÆäÞ«[»liêœÂ›NeðtõsYç”ÐPKX[p/‚;Ñ4îòsb_hright_over.pngë ðsçå’âb``àõôp Ò,@,ÈÁ$K;f1)¶$ow†ÿ ¸`ïòÉ@ÎÈb¾# Ì8U›O(8ÉÓÅ1¤âVí9[®C-ß?ðT½§0õ¬‹#g†0¿‚Rdžõ޳M™ß5EEì3ëæh28{ùLÄqu&†µ_Þû{šœRz³tÅËs R…j®¾ù|«bÊÂ…xV¼á7›®ÿ$=þCóÑ“ïY´„sm•éݺ0“ÉäñV©\†E/î×úöcU­Ø^µètíôÕæjÎë~ç;tƒ§«ŸË:§„&PK,—n/lOª  sb_htrack.pngë ðsçå’âb``àõôp Ò @,ÈÁ$í,W)ÎÈb¾Ã Ìx<E P0ÈÓÅ1¤bÎÝ«y xX/îÿŸ2E¤Gq¢¬P²jRWö„¸ú§/o˜OY#6eØ”;~SfÅkؾu[Yî¬Ù¶Xäbà)T¶.þ3?m [T'° þã^Q®ßç9EMgðtõsYç”ÐPKX\p/·´L™ÙÜsb_hpad_down.pngë ðsçå’âb``àõôp Ò @,ÈÁ$í,W)¶$ow†ÿ ¸`ïòÉ@ÎÈb¾# Ì8U›O(XãéâRqkëC¾¦—‹7w[$5²HL<¥Ábòé¨nCôf+Ï?^Hå}T[¾ÿn†Ì½e_Œç…%×±hû£$‡)»8-wð/zó3UÊ-ÓXÙý„݆rîÏ SîØküðj¦ôâ_|ŽfÏœðuæÅoWfoª¿¼"Ã÷/ãL)‘?¶ß.ÄÀàéêç²Î)¡ PK[p/î7[ ªsb_hpad_over.pngë ðsçå’âb``àõôp Ò @,ÈÁ$í,W)¶$ow†ÿ ¸`ïòÉ@ÎÈb¾# Ì8U›O(èåéâRq+¹âË;{_ÁÃõRÌm¦Ïÿ]1¼Sñqþ²Œ+MŽ ·>ÿŸÙÕÖÈ*.÷¹f’Å÷ •3Û‚ñb÷˜ÌÝÿUÈW!mÂî7ÓÒŽÝšÊàéêç²Î)¡ PK ÷•n/Ô9Ëzëësb_vbottom.png‰PNG  IHDRçC… pHYsÃÃÇo¨dIDATxœË± Â0@Ñ|¸ºˆÐÉ¥\¬HmÚ­ZBb)“`‹:ÕQ‡&Z…4<ÁÅÅËY/’œ.:Võ»ÊÑÊåˆr[á2a3aSÞÇeŸ”6-îàG{ôyŽÍ+&-f:aæ 3™^ÑÇ’˜0×uÓÀ:? Éé4:ÁÍ7É)’œÞZã-êq †¾øâ×h¦&òÂóU?%§oH'ªýiòÉíIEND®B`‚PKà[p/4ˆ¬+sb_vbottom_down.pngë ðsçå’âb``àõôp Ò‚@ÌÂÁ$Ÿ‹8·)¶$ow†ÿ ¸`ïòÉ@ÎÈb¾# Ì8U›O(¸ÈÓÅ1¤âVïi{î&‰†¿\ Ò ô]îÁ²H¦q¥JÇ.÷z;G5A“çÕ¼…EÌXtumÿ\k÷è¸1{šÛÁM¯Ÿz|ëñ¬§·ÎN­­qgÆÆMJe›Tç·Ú7Ù1+ñojËTÁ°äÿf_^\“£œ´ë¦0gÒ$™ûŸ­îfqTáØaÿòÑ…T×Û÷¶¾y~\ó÷š%WÖíQé0_qséÙÍ5zþ@×2xºú¹¬sJhPKÐZp/|•¬Ùëîsb_vbottom_over.pngë ðsçå’âb``àõôp Ò‚@ÌÂÁ$Ÿ‹8·)¶$ow†ÿ ¸`ïòÉ@ÎÈb¾# Ì8U›O(ØçéâRq«÷ôF®&††‡Õ²:ïXéÊ"ØÓõ†QII°ïÔe¯¬W„>-’úßÖÔ6­nßWñcL®LÞèÉÿ”Œ]œ¦>ÅQr SÁâÞ ûדÔ|&¼Òöán’¨ïÜî Ùð²F»'UBöÇú‹k¶äªö,Ýk;çã¾÷ËcÃËï| ?š­î™Oßõß—·]åN\·î7?Ó6M Ë<]ý\Ö9%4PK ,–n/-L›_ÎÎ sb_vmid.png‰PNG  IHDR Ý"õ pHYsÃÃÇo¨d€IDATxœÅÍK Â@EÑì÷àí„8léP?m®Â‰Äzm9o#™)ÜéåÇ™Yµ¹‘(”DI¤'á#–{”½–ÖíÅ̦îPdÏùúÊHt2{dý×YÐ=0H†œˆù®{ºõ—gÐy~åhA`x†g|:oÉ{²ÓÙUIEND®B`‚PKð[p/[oéësb_vmid_down.pngë ðsçå’âb``àõôp Ò‚@ÌÅÁ$ïÊ)}RlIÞî. ÿApÁÞå“"œ‘Å |G@˜qª6Ÿ4P°ÛÓÅ1¤âÖѳ¹4<Ü·ëËK…ˆ#“«YXß.0ùvÏáŸ^_ÞEß'z'v÷Ú.öïësïyý»;|6{ÇýzôÃÈ£Ñ`ÍìÙ×LÓ«ý¼½tϖǹ|z5ÇåüËo¯êy.å”öJ]Ÿ©ské×»æ0¯îšR»úíüå—_V¶ñ)0ZÆykcÙŸ×5Œê6“ì¿”¿è,OW?—uN MPKçZp/¹%U »Ãsb_vmid_over.pngë ðsçå’âb``àõôp Ò‚@ÌÅÁ$ïÊ)}RlIÞî. ÿApÁÞå“"œ‘Å |G@˜qª6Ÿ4P0ÙÓÅ1¤âVrÅ—wÿàúœßõY¹v}“éÒ³ùWÿìácþÿë-¿ƒä>oKr¸üù¹¾•ÒšçǺÿ÷-Zܸ5ýéËÿ×ç=ÞòüJóÿårâË„ÚåÖ|¸à¬_=!YXnyFCË‚c?&ÌŽ6ZÇàéêç²Î)¡ PKH–n/Ûåâ– sb_vpad.pngë ðsçå’âb``àõôp Ò‚@¬ÀÁ$«5Y–)ÎÈb¾Ã Ìx<E PÐßÓÅ1¤bÎÛÓŽ|¬îýò[xhÓ¤4'ŽSGldYýäKü}ÿ_k±0ÃÝ/]³î¨eEڮ<(xåá¸ÇY…ëêLÞ V€AÝ<þuuek‚g ýÍàéêç²Î)¡ PK Ý•n/e8íí sb_vtop.png‰PNG  IHDRçC… pHYsÃÃÇo¨dŸIDATxœËA ‚@ÐÐ"²Ì±²Iq˜ÑI, •@¡E3Ñùß߯ôöo¦CèoJ°™Œˆª7ˆ¼¤?†-:[t{ÞYAkíÆÿ.Ïíâôɪžˆêú9‘CùïÕ¨JÊÅxŠ˜—†ˆ\™Mgíµ,Ö,Ñ,ÖnŒnŒ‡+:8l%\6ý†ˆæ«ðJ¶ÜX¥¼{IEND®B`‚PKÆ[p/~AƒÊsb_vtop_down.pngë ðsçå’âb``àõôp Ò‚@ÌÂÁ$Ÿ‹8·)¶$ow†ÿ ¸`ïòÉ@ÎÈb¾# Ì8U›O(¸ÌÓÅ1¤âVïéÓ\MïEkìì°œæ›(>aŽG¦ÙÚ;[ n͘µVHðÐLvާù ù/<¼=¯íAfdÝÃ÷,þÒMËv¹Ö¾=Qýj«šhXf–O­gê²h‡iª_•×׿Ü/µ¾RÆïâ„J)GOt¹ß^¾§“íôs~†ö¿ZÞœÿKÑðEºkq3W3WЇ7>Vsó³b%sC)_Ý¿ŸKø|ô\t1ƒ§«ŸË:§„&PK¹Zp/þñz…ÛÞsb_vtop_over.pngë ðsçå’âb``àõôp Ò‚@ÌÂÁ$Ÿ‹8·)¶$ow†ÿ ¸`ïòÉ@ÎÈb¾# Ì8U›O(XçéâRq«÷ô^®C ÷ý÷îè^ À2G–ëÒ¤AK:r'ßZ¡X ü0fÓŽÊš×®·>ÿûP/Vé-ã2öÌóû’¯+d§œÝ¦r®³¸%©8aî…3 ×f}Xbû]ü³ð[I™æÇ{Xîö^ ’haò8\Ñò¨âïÅ[ R”oJÌ›ºf߯Ý÷*¼g*]Âàéêç²Î)¡ PK—n/U#¢£Š‘ sb_vtrack.pngë ðsçå’âb``àõôp Ò‚@¬ÀÁ$«5Y–)ÎÈb¾Ã Ìx<E PÐÙÓÅ1¤bÎÛÓy(ð°8|»?™oŽÂl‰ÏLN·¦¯Û«bš­}­keIõ¾»²yº DçÇ?z?+ùvJÉÿ^¸ßhƒ§«ŸË:§„&PK\p/…Ä_Üßsb_vpad_down.pngë ðsçå’âb``àõôp Ò‚@¬ÀÁ$«5Y–)¶$ow†ÿ ¸`ïòÉ@ÎÈb¾# Ì8U›O(XïéâRqëíi[®f †€óëÔ;š—d°™Šp±N^˜d’þá9Ç]¡íAŸ–~(}q+Ràó7ñÜoœs¹g=,½Ú—}~ëúcü¯¿:ÈOàš¾Mo·´‹Î‘VásŽ~û¦\úgkñp΋#%{9n¯¸Ï¸n¡œmð‘ |%Kj'ß>÷œ[PY„5Væþe S<]ý\Ö9%4PK[p/=qxû¼Ãsb_vpad_over.pngë ðsçå’âb``àõôp Ò‚@¬ÀÁ$«5Y–)¶$ow†ÿ ¸`ïòÉ@ÎÈb¾# Ì8U›O(˜ìéâRqëíiG. ‡Äïû[æm.åp®¿¤ÙØÖ«mÃ=«•YãçkÝûÓ[™p\>·Å8¯ÜùÈÚSó™„ ˜&„×.{¦¬v÷dL)÷[ëÕŸ¹ƒÍx>Vª'Û^ ¾’g®Î¾ëP¦Yáb u ž®~.뜚PK c•n/´v]äff sb_adown.png‰PNG  IHDR´Э pHYsÃÃÇo¨dIDATxœÓÝnÚ0ð¾ Á{´»Ø„´è=\ mªV 0> ¢´N‚Á(ëX5&MÛ¤BšøïÂwµþGÖùéX–ΙKQ’ÄâÅÇ¥èÌ¥H±ù ôl/L »$lã åì›vPGaí.(›»ûM$„xøºN }€õÃbsp×0þ’ÐebÏäqsƒ‰UËBŒ>­Rc{Ñbsðaü9‘Ý–æLBÇÚp'„è:‹Ô ÜPNÀK°<°<@S®Sh“D¦CâÎÐB(Æ45:}¦+ «Äž'hÆeÚ$Ñ0¨˜k4 Ò¼o»©é’// “ÍÉ9m’¨˜«˜g²9YHSl±Ô´œ½åA&›“¹aü†ñáÇsÍÙ ! õ¿¦iò=ÿ³cÝ ¼¹êø'æ#Ú›S9¶þ„×q\·|!D¾>Ir·7˜³4GPqʼnk(81×ý½NÁ`Ðg‰1c ™lNs¡É 6†2á%;VÐéœF aÐ)ÜL¸>} ]Æ› c^ñò_[‘bžš«žßt"•ð‰;$n“HñæUÌ+NtmE%VÌíÉ,Ÿ›·O-k«Z¾LËÚÖPPCAí”[¿2ØÎ÷BˆRovæRÔw¿¿pJƒoé.üzò¯zëKeþö÷¦È. î«üä<ÏÎóì¢àʼ.Î.+«ŸÛХ肶ˉh7IEND®B`‚PK Zp/?«rY¬¬sb_adown_down.png‰PNG  IHDR´ЭbKGDÿÿÿ ½§“ pHYsÄÄ•+LIDATxÚÓooÒ@Àñ½A^o`Tb‹â6Pë:Áu¡ÒòçVfKÙŒ¡[&›-Y8G š¹HïzW¦Æd9´Ãðl—ï£Ë}î—\rsÐÝÜü¥w^ÐÍAkD)Ý;d6ëéájÂx±6XŽ™áW}vÅXäúOž"ÆÃ¥¾¶cRJ¿}¿ôLfs0ÿÏÇq`3I;”Älʎʈ“'¡¥¤Zûm‡Rzöeè™õôp>Žo0ìP³y›SŸG|Å ˆ(*£úé„RúþÄð̪hÜ_# ßb6oó:‰iDР Á„…"äjœ:”Rýð³gž æ‚€`3Àfs^' 'KX,!7¡]SØëyf9f“8$cŸ?Û$n’J$•øüaQE¢ê͵®gØ#”Ä>ØÍ5¯‹“éN¦ ë'Jiªrk¹>—u¢Ygz(¡þ¿"·C@ÕÚ=qf 5¹¬ã6=êV¨áB + Ti;”R¹ÒñÌBÄäáá²ÈÈe'W% ¢í[[­ë`MNB\Ú‹È烪ª–Ò@ÛŸ`µ õÖìœO NB<@BŠ U”)Ã:|×@Û‡ðÙÕìõ£Ys/tÁIH(B±„2;p£•Òö-wB³7î|ýY:"3o`^ý©ãZ›ì¶·Z›lµ®·Z×åÖD?vJMÒ¿úE)UÎç 5úØûqÇ 6GÞ_°°£\Æõ~$Á‚n0Õ{,w¹ËÈÝ`ªç¶Îã¥á˜ü†ÖèÒ§›åë§s‘IEND®B`‚PK èYp/”uÑòsb_adown_over.png‰PNG  IHDR´ЭbKGDÿÿÿ ½§“ pHYsÄÄ•+-IDATxÚ•ÓïOÓ@pþÁýKˆ{c|å_ Yü•e?”•F;Fb‰È ©´£èJ{×Ö–‘±™¼çîñEËtïôò}ñärŸ<÷\r—]ÿg ú‰Èì_¬î†rÝ/}8Ÿ[õf—½éw®Tu¦½g²›]pÏ“­ým׉Íênȇˆ—€CoˆÎ´úâø Û]0|P)H²ˆÍoVläº?Dì ì\ǧ͞h‡ÐÀðAó@¥0]%ˆø^9ŠM©vu nö„Ù'\ó@uoBafÉFÄùõÃØ¼X9ó†èÑê‹“.¢ºÐ¤\!¬Iy“òÈ̬´b3»ìÑ'}‘H¦£>­@(„)„%’騈Œ´¤ÇFª:fO$’é(­@´Ñp`´£ÍS¨h±™Zô¢ûüÍFuéj™œì¶Cˆ2:ú8°E¡°H1W¹™'³à>´»qF`Ó…(uò23J®æáÃaÀŒÉô^wBÜ pÃák&dÞŽ›‡¯œ&åš-_hÐ:ð%à;!nwĦ „ÕL–-[cæÁÜiÃ…0•‚J¡I¹â°…O„mX¬f²Ú˔ͱ7ø¬ž?-[ÅŠ%Ul©bK²]¬Xy™äe’“íÌòdÞªï!bi͘¸ìzëá?~„×Ïâ¿põóúå¹Wþ~÷ù×ÛÅVª §rúdVŸÌê©‚ž*è·òwŠÆýÒéÕ/ô;¿š‰ÑE×ú>IEND®B`‚PK •n/§ºcc sb_aleft.png‰PNG  IHDR´Э pHYsÃÃÇo¨dIDATxœ•ÒÏoÓ0ÀqÿƒüüŒ‰ÇÝ·Ã$Ðĺ¦ÕÚ$ý¡.k6'™Ý´NKÚ®Œ2Q$“Ö4Í?÷qð´Ž`}eùòÑ“¥GnW›wå{}»CˆBú׈RþωBJqq á5øqÞd0kñ¬ÁÒKÍ`]÷ÓšU/ÒcwuµÈñúëœ bx ó›ÉbÍ¡ÿE…3àSŦà¥;G@“–— bïÓŒ ¢ç“Å&¾þgŧÊ+/†gÏ߸Cp8Ú!4Ya_®±L"v£LO`SðbÐ@×àJ×äEó2ADÃDl‡÷á øLùcEGò)°XLÚ lÚ|hD[;ûÑ˽Á‹=¡ÛÙt¯F»åÙÏe…ô7lxË*œôÕIEND®B`‚PK XZp/&>Ållsb_aleft_down.png‰PNG  IHDR´ЭbKGDÿÿÿ ½§“ pHYsÄÄ•+ IDATxÚ•ÒÍnÚ@Àñ}Á>Dߣé¡U¥>@îÉ!R«¨ ØæCÄÁ‰?²‹a 5PšÒ*U)ãØ;Ëô°QHoÍê˜ËO£‘–¬–ó—F¤Ìñ%oµœD\¬ ¸/Ê:ý´¤M–ÖiR§‰îok^rë¤ho¾-2D¼ý9#ˆÜÂì÷n¼Ø…3èýÁØDÒ x#éD‚šÁrñûuJÑ‹²ñbÝAï»dé¤Á«×ìØ,­47o6ˆØôÇ;aª6Ð ¸( ª3©j°¼q#¢f "¶‚‡` l*½‘t†â90)T˜L Ê|®‡›,¥ ã6T¨jԠ̉Π"êþÖÀ‹ä¸àâ‚‹*{L1Óß âñ9'ˆXóg(TO¬ùÌT™¨RaøñÞh×[‹ƒ=|쉙!”»B¥ùyÅIñè¼OñìrÛ ÀâpÉ¥5k°g5•™(x¹æÄ{óÅJL ­.ú¢ÕƒVš\(Pí‰rWoÄ™›iö3sÚŽk~f0Ñ`yƒåu–]¡wó*e*J~væf'-Ùëý=“»‡ÚÕ½î® 7VéîZw×'©8IÙÙhWq©³Ým±Ð’Ëð×ÿêBg¾ZÎÉò>>mϵÑÇOÑû~p¾=ê¿9⪃ãPõîdxXšþY§«åü/¡Ñ~ŽIEND®B`‚PK "Zp/])·j}}sb_aleft_over.png‰PNG  IHDR´ЭbKGDÿÿÿ ½§“ pHYsÄÄ•+IDATxÚ•ÒÝOÓPÇñþƒþ&ÆÝ¯ü 4Æ·,°)+Œ$:&vŒðãLD6–‘Á6ŠN ´ç´…¾82:2ƒ}N^tÙðNN¾ÏÍ'OžäHçû¦I¸áëŽ`ïè×ʶ¯”Üìç³™{zÉž\´&-¹`NÌÛ¯klÎ|>Ë6÷<†eJV¶}ôs‚Âîüï =ˆŽ.ÐîêR“¬j?t €Rrû@Á¹‚y =ˆ´ntëöã¶OmT—6Õ9M€OÕC @¶xoà=¡u ®nÑ NS €Ùµ À›åS»«=ˆŽ;â:¨qQea‹±™ZnI¦—lÞ,øgC•…q.â!6òBS L­é]‚–µ¼¨lR\Ìâ{Òù†`bÞ>!ÛõÄ®'†¬ÌI.#“œ³T—ÚAC¶ÓÁ†Eq%ƒR 0žoIže­†MªKžP}Rý«øØô°nŠU’¯™§ïÌ ›ZnÔp¨áЮ'b°åD­³°¨…c9}džÌœ”5ª²°Î©Î©ÆEÕ +–(súÊÂu=,jañ0Læ´Ñ=ßêg/sz&¯ËyCβbdòzFÑS K)l\1’Ø‹Y½´s »ªJkûþÿê÷_N{#]ü¾z»Êæ~>xýý^¦•H7ãÍ;cƒéf"ݼ›Ú¿ŸQeO.þ 8õ/Дø¹ZyIEND®B`‚PK ¥•n/ýcc sb_aright.png‰PNG  IHDR´Э pHYsÃÃÇo¨dIDATxœ•ÒÍnÚ@Àq¿`"ïÑôÐ*R ÷ä©UÔ üA,bp²¶³‹ak 4¥Q©Tµ•‚1޽³™ÔS³ú]ÿšÝÕ(a@^J‘²À—œ0 ".þ@p ^œ÷†Y'ÈÎYfÒÔ¤©æ¯[^Ú Yý*=sV7‹o¿ÍD naþóq²x ç0ø*ƒ°©¤SðƒĉÀæÐf…î&ˆØÿ9éÌÔñ»÷ñÛc¾w¾>¾:䥽£°ôæ8:¨Î~-³0 æË2=V¢IEND®B`‚PK Zp/„–wwsb_aright_down.png‰PNG  IHDR´ЭbKGDÿÿÿ ½§“ pHYsÄÄ•+IDATxÚ•ÒËnÚ@€a¿`"ïÑtÑ*R ûd©UÔ |!18ñ%3ƸJSA¥ª c{Îätá( ®šÑ·ýufFGZ.f¯% ‘ãkÎr1“q¾ÿÜ(ëôÓ–Ÿ^ÒT'‰NÅÛ4ܤf§Õ›äÂZ›gˆx÷s*!¢ÓßO£ùS0…ÞáO€Žƒ;vÄ­LMš«NŒˆÝ¯ Ý(ÍŸ¢{è}t,Ü¡ØÛ?´Cn Àb`20|h’\»]#â¥7’±¤Å2'‚½ýÂáƒNE¡IóæmŒˆ²9Ñðý Љp‡Â¹ò—L# ®ÐÍ'=ñ’¦d dNôL§â%kP W /šS…Iˆ¨x'7…+Æ ÿdš·FÄ““ñ‹½±°Ël_U§¼Nyä5'FÄãZ_BDùfc2°ÂgíÁöb•./È^^µ“msÞÞ>˜ ÚLìNÐh0¨öà‚ò’›ËöΜÏf¢0|¸ês£Fööu& ê=^éò‹[~îd²µÓœµâ†—©”7iÞ¤¹N3µË•n^'¼BxÙËάd§ekµýƒñýcãúAqVªg¥8«ªTí¤b¯åë¸ÜY ï7ˆXj…R;øõÿK]êÌ–‹™´xˆÏZÓ#yøácôþ”œoûoŽYáà$(¼; Ê“?«t¹˜ý«ðÑ JU IEND®B`‚PK vZp/‘¦õ¶……sb_aright_over.png‰PNG  IHDR´ЭbKGDÿÿÿ ½§“ pHYsÄÄ•+%IDATxÚ•ÒÝOÓPÇñþƒü$ÆÝ¯ü 4Ä·,lSW"ItLì€ðãLD7–áB7ŠN ´ç´…¾82:2ƒ}N^ñJO>·ßv°0Âø°+»â*kpQgQƒ‹I3¹Ü–L-9¼/Xë½Km8­ÆEEu%¼Ð’Èó–Þ‹%Ú~œø+KöÉ•T @F±;]§tT-ªZ´É)7ÇdJm @zÖÖ<êt/íÃ}6lJTLÊ*lØ<,تCšG{¾¸>a»‹Z€Më–XÕ)ýöZóà•ÕàBu¨íŪKªK#£c_ü¸à³oش΢²asú¨ªSEMNMN .êVT³E•ÓG­QYÊûQº¨oð©yò¤häK†\2å’)+f¾dä#«°¬Â2Š™~ÃÏ•íc…UMZÛ þýS¿þpÜ]éìçÅËUv·øýÎó¯·òíT®•Ê´nŒ_JåZ©\ëfv÷v^»W8:û…~èþè¡Ñ^»Ù™=IEND®B`‚PK 8•n/ÍäI¦qq sb_aup.png‰PNG  IHDR´Э pHYsÃÃÇo¨d#IDATxœÓÁnÚ@༠Á{$=´BêäN‘ZE ÁP06`ƒ“µ]Öv ”¦4*•ª¶R0Ʊw6ÛƒÝ4ܲúûé4EBdòÅÏ£èÀ£HJ¹þôœ0M“Mú$éâ¸ãîT'n¡¤y_XÛÏëTJyûmUz «Ÿóõ£·‚ÉWA—@™ r+“AdšI)ÇŸ–…qÂt¾~ ï`òEä¿í,,&ƒBgúÍVJÙwç…yIÞ€`‡`‡€|nPè‘§G²ÞM$¥TL¿0} K KáÌ 8 x©\é¡cÐ0×1èró¾ë¦O¼×=P4'pAxÍÉ´ßóÁŒu …Ë)7&`L Ï¸Ê =á1¿¸áçvªXûæl©nªÞ#Yd]’jcÞÆ¼yÝMÏí´†’ºµÙÛÁâîA½ºïØÍŽòtìMÅM7ÐV¹Šê£Íìn'¥¬ ‚¢¡÷ã…‡P}/ná÷}t6X+³·ïÂ7§ìèÄ{UVÙa•xy^ŸÇõå¯MâQô¥¡ËK’BµIEND®B`‚PK ÏYp/´ØÙ±±sb_aup_down.png‰PNG  IHDR´ЭbKGDÿÿÿ ½§“ pHYsÄÄ•+QIDATxÚÓÑOÚ@ÀqÿAþþ¶‘ŬlÌ‘mukd´@OТ@A@‘MãÐA41椅-Î=Ì»ë]ë¶,1·‡V6Þ¼|îá>ù%—ü¦ÝÞþa÷>ަ1Æv™Árz¸¸b¼ZDbføMŸ_0f…þ³Æ“yãñ\¿X3c_¿]z&³1˜~M¦ã$°L¸¤J>eE,ÈXñ\Ò -‘ŽÍ;ý<ôÌrz8'·„V(Køœ%hXÌa1‡ãkX8ªàƉÃ{wlxf1a<\¢™W Ÿ³DÆŠT*"©ˆV4$å‘póÄfŒéŸ<óR2g$‹ŸuDúüád‰$JØMÊ#׬íö<‰™Á$ )$¢:± êó‡ÝäM°›kÀv×3ü‚J’ˆêDTg ÜÔŠ)£L5ŽÆXªzgf…¾ ÚQÕ?])ñ=[£ wŽí ÃEMá?êPHãÕÚ?¦5qµc3Æ”ê™gfæMPPŸ?,*¤±´IÕª­”mŸ?¼Þ¤Å=XißL˜o 2Ò^"ÀR:u¨5ñÖGTï ½=9çÑsC±°”G ' 8SFë ´ÙÄ[èý)lõ®õÃIó t!ÈXÊ£D gjh½´&.îAwB«w}öåGéNüyõ»~D¶;t§c»mwh¥}Siߔێ~d—Z´õ“1VØ?ŸBpô¡÷ýž‹Ph¼]€ÄÖö/ãz>wÁƒn0Õ{ªœqJ—SºÁTÏmœÇKÃkú ÁÑ_Öð›³ý…fIEND®B`‚PK µYp/v‚ã%™™sb_aup_over.png‰PNG  IHDR´ЭbKGDÿÿÿ ½§“ pHYsÄÄ•+9IDATxÚ•ÓßOÓPpþÁýKˆ{1>ùheÙe%‚‘DÇÄŽG`"2hF í(ZÒÞÛ^X[JÆff°çöøÐîMo¾÷sÏ='9cÃÿ9ƒ~w,6{GçËÛ¾Øt+ŸÎf–Ùô"›üàu{bž½üœýt–lìyˆh9vb–·}Ž8D¼ôBdC´¢ÙŽ.Q@sA¦ ˆ"¶¿›‰›î±a÷*¹mô"ÝÝÍ…La²Nñ£t˜˜Jã,®@ÜèEF/:>ç Ù¹…© gWójé” Ñ¢ÙŽ~ðT:+;Ц\"a›ò6å±™Zê$fz‘Ñ'ý(.’JgãH$Ü¢\"¡DÂØ jb„ºmô"³fn@œ– 1‹û)Õ”ÄL̳›/ÅéxÑ߬EA¨[#¦ :º[A÷Aóa×»}bƒBiž"b¡vÝOnÎÑ\ÐH¥³z>×|Ø pÝT:»î@Ó‚¢HFÌ“Š£0Ð\8ð¸æƒæCç<Ú pËÇ ×l¾b@îý¨yüÆnS®0踑Ò¥ »ßòq³­;°F†æ«æˆy4sÒ2@"¡LA¦Ð¦\²Ã…/$\3Æ6Ã\Õ™ÁWùìyÕ,×L¡f 5K­rÍ,Ф(’‚håÞ‘g³fsç++ÚØEÀV÷ý\„·ŸO“]¸üuõz…<¨þ¸ÿòÛÝr'SR3u<¯ŽçÕLIÍ”Ô;Åý{eíaåäò7úÝ?pâÑ€[$¿IEND®B`‚PK y–n/÷y>íí sb_hleft.png‰PNG  IHDRuˆš pHYsÃÃÇo¨dŸIDATxœe‰Ë ‚Pÿ÷‰¡EdÙÂÊLQŽZbe˜„ nÌD=ǯMEà0›a(ÏâŸ$Dƒ/ É9 ùD/ yôè4¯%º_Ÿ“Nó[°qªCÄ?gÅ*û&TOôbiUìÊ×GAæfi]„âò^L—~3›€Ñ®T\.Y-nŸ «‘Ì–I-ï Ù(PžÅizWí`0vÞ븀°»¯¾IEND®B`‚PK \p/uQõsb_hleft_down.pngë ðsçå’âb``àõôp Ò,@,ÈÁ$K;f1)¶$ow†ÿ ¸`ïòÉ@ÎÈb¾# Ì8U›O(¸ÜÓÅ1¤âVî¹³Ü dŽ|ÿ_÷ÉK%þ™í3M8}š`fºæŽŒÙô›WOFqí/¼À·ÉNOçèîóOKO8~§@„…¿F‰áÓ¯™¹Ñž‰î F¦É[.*RcX¹KsåòueÊ ³.éÛþõcxêdùýÿ‘õ›¹ “Ï>ÕOÝl’ºç™pCÆÍý’æß9ZŒ‹ÃfÄÜ¿‰w·……À>¥þÇoÞøíoë_¦Ìç˪"ö8Ü:™ÁÓÕÏeSBPK/[p/i—ÄFÙßsb_hleft_over.pngë ðsçå’âb``àõôp Ò,@,ÈÁ$K;f1)¶$ow†ÿ ¸`ïòÉ@ÎÈb¾# Ì8U›O(XïéâRq«ôœ!w“ƒLÛÇÿßÿ ]¬`i*nî.\éÙár-¶2ª‚5WÉÆ7Ý{ïžÓùÕG*ž¶0ôox=y‹c&‹‡ô»üU|Œf¦oµô ínËÕ%Í-®*(àØpëoó¥+¶3yWXmqlHuJ»'° 'ÐjKíê¿ÅçÔ~ ŠÊ‘Ýýþh ½5Ð) ž®~.뜚PK º–n/Öb4…ÙÙ sb_hmid.png‰PNG  IHDR kAª² pHYsÃÃÇo¨d‹IDATxœ…ÑA Â0…áwz¯PÐTì²R‰J•Z2x—fc•âŒÕ‹ Ú$|¼Í?»À_/xG–»»¶° –X«h°g„װľÿ®%Ɔ^¾³|øÝš$•×n:;AÕÉT®Ò¹l¥l%ˇïvÁ¢8°6?І¢aÍ4O «ýM3Û@êÇfæñ½¶y‰*IEND®B`‚PKF\p/îF‰ãñôsb_hmid_down.pngë ðsçå’âb``àõôp Ò ¶ Ìv\µ H±%y»»0üÁ{—OŠpxD30ðaÆ©Ú|Ò@Á)ž.Ž!·Z/žåjri{øþÚiíí EÄ[9¿8KXú„+dp›ëÝŽô>8s‰™Þ9Å9–6{fçW~¨³Õý°UîØ¢n§Ù[„¯Vnö0ó9¥°o{äÕ«ömÌÚª¶Úê¼þiÍdz®26É_âXqÙ¹xFÖu!]¡·?Sïkk?Ïm¼¹pá2±ß³f½‘¸~¼©8ï#sú¦Éw-§Û§ÝÇàéêç²Î)¡ PK ]r]/$´Ð@¸¼ checkbox.pngPK xr]/‚GÂÆ âcheckbox_down.pngPK ‚r]/`v¦]àâ Ócheckbox_on.pngPK r]/dó<ëúú àcheckbox_on_down.pngPK ‡r]/è1Wpp checkbox_on_over.pngPK lr]/¾já  ®checkbox_over.pngPK š^c/·Zv•• äradio.pngPK š^c/xIJ*––  radio_down.pngPK ›^c/391   b radio_on.pngPK š^c/²k — radio_on_down.pngPK š^c/ žùDD Íradio_on_over.pngPK š^c/isøø @radio_over.pngPK z[p/u¬MÄË dsb_hmid_over.pngPK ä–n/j‘cÔ   Vsb_hpad.pngPK œ–n/j¾äyíî ‰sb_hright.pngPK 3\p/—X|®üÿ ¡sb_hright_down.pngPK X[p/‚;Ñ4îò Ísb_hright_over.pngPK ,—n/lOª  ësb_htrack.pngPK X\p/·´L™ÙÜ ³sb_hpad_down.pngPK [p/î7[ ª ºsb_hpad_over.pngPK ÷•n/Ô9Ëzëë ˆsb_vbottom.pngPK à[p/4ˆ¬+ Ÿsb_vbottom_down.pngPK ÐZp/|•¬Ùëî Ñsb_vbottom_over.pngPK ,–n/-L›_ÎÎ ísb_vmid.pngPK ð[p/[oéë äsb_vmid_down.pngPK çZp/¹%U »Ã û sb_vmid_over.pngPK H–n/Ûåâ– ä!sb_vpad.pngPK Ý•n/e8íí £"sb_vtop.pngPK Æ[p/~AƒÊ ¹#sb_vtop_down.pngPK ¹Zp/þñz…ÛÞ é$sb_vtop_over.pngPK —n/U#¢£Š‘ ò%sb_vtrack.pngPK \p/…Ä_Üß §&sb_vpad_down.pngPK [p/=qxû¼Ã ±'sb_vpad_over.pngPK c•n/´v]äff ›(sb_adown.pngPK Zp/?«rY¬¬ ++sb_adown_down.pngPK èYp/”uÑò .sb_adown_over.pngPK •n/§ºcc Â0sb_aleft.pngPK XZp/&>Åll O3sb_aleft_down.pngPK "Zp/])·j}} ê5sb_aleft_over.pngPK ¥•n/ýcc –8sb_aright.pngPK Zp/„–ww $;sb_aright_down.pngPK vZp/‘¦õ¶…… Ë=sb_aright_over.pngPK 8•n/ÍäI¦qq €@sb_aup.pngPK ÏYp/´ØÙ±± Csb_aup_down.pngPK µYp/v‚ã%™™ ÷Esb_aup_over.pngPK y–n/÷y>íí ½Hsb_hleft.pngPK  \p/uQõ ÔIsb_hleft_down.pngPK /[p/i—ÄFÙß Ksb_hleft_over.pngPK º–n/Öb4…ÙÙ Lsb_hmid.pngPK F\p/îF‰ãñô Msb_hmid_down.pngPK22í 2Nenthought-chaco2-4.5.1.orig/enable/_version.py0000644000175000017500000000026312516137724020327 0ustar varunvarun# THIS FILE IS GENERATED FROM ENABLE SETUP.PY version = '4.5.1' full_version = '4.5.1' git_revision = 'Unknown' is_released = True if not is_released: version = full_version enthought-chaco2-4.5.1.orig/enable/tests/0000755000175000017500000000000012516137725017273 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tests/coordinate_box_test_case.py0000644000175000017500000000205612516137326024676 0ustar varunvarunimport unittest from enable.api import CoordinateBox class CoordinateBoxTestCase(unittest.TestCase): def check_position(self): c = CoordinateBox(bounds=[50.0, 50.0]) self.assert_(c.position[0] == c.x) self.assert_(c.position[1] == c.y) self.assert_(c.x == 0.0) self.assert_(c.y == 0.0) return def check_bounds(self): c = CoordinateBox(bounds=[50.0, 60.0]) self.assert_(c.width == c.bounds[0]) self.assert_(c.height == c.bounds[1]) self.assert_(c.bounds[0] == 50.0) self.assert_(c.bounds[1] == 60.0) self.assert_(c.x2 == 49.0) self.assert_(c.y2 == 59.0) return def check_is_in(self): c = CoordinateBox(x=10, y=20) c.width=100 c.height=100 self.assert_(c.is_in(10, 20)) self.assert_(c.is_in(100, 100)) self.assert_(c.is_in(15, 50)) self.assert_(not c.is_in(0, 0)) self.assert_(not c.is_in(10, 10)) return if __name__ == "__main__": import nose nose.main() # EOF enthought-chaco2-4.5.1.orig/enable/tests/component_test_case.py0000644000175000017500000000512112516137326023675 0ustar varunvarunimport unittest from enable.api import Component class ComponentTestCase(unittest.TestCase): def test_position(self): c = Component(bounds=[50.0, 50.0]) self.assert_(c.position[0] == c.x) self.assert_(c.position[1] == c.y) self.assert_(c.x == 0.0) self.assert_(c.y == 0.0) return def test_bounds(self): c = Component(bounds=[50.0, 60.0]) self.assert_(c.width == c.bounds[0]) self.assert_(c.height == c.bounds[1]) self.assert_(c.bounds[0] == 50.0) self.assert_(c.bounds[1] == 60.0) self.assert_(c.x2 == c.x + 50.0 - 1) self.assert_(c.y2 == c.y + 60.0 - 1) return def test_get_outer_position(self): c = Component(bounds=[50.0, 60.0], padding=10, border_visible=False) self.assert_(c.outer_x == -10) self.assert_(c.outer_y == -10) self.assert_(c.outer_position[0] == -10) self.assert_(c.outer_position[1] == -10) self.assert_(c.outer_x2 == 59) self.assert_(c.outer_y2 == 69) self.assert_(c.outer_width == 70) self.assert_(c.outer_height == 80) self.assert_(c.outer_bounds[0] == 70) self.assert_(c.outer_bounds[1] == 80) return def test_set_outer_position(self): c = Component(bounds=[50.0, 60.0], padding=10, border_visible=False) # Test setting various things c.outer_position = [0,0] self.assert_(c.outer_x == 0) self.assert_(c.outer_y == 0) self.assert_(c.x == 10) self.assert_(c.y == 10) self.assert_(c.outer_x2 == 69) self.assert_(c.outer_y2 == 79) c.outer_x = 10 self.assert_(c.x == 20) self.assert_(c.outer_x2 == 79) c.outer_x2 = 99 self.assert_(c.outer_x2 == 99) self.assert_(c.outer_x == 30) self.assert_(c.x2 == 89) self.assert_(c.x == 40) c.outer_y2 = 99 self.assert_(c.outer_y2 == 99) self.assert_(c.outer_y == 20) self.assert_(c.y2 == 89) self.assert_(c.y == 30) return def test_border(self): c = Component(bounds=[50.0, 60.0], position=[20, 20], padding=10, border_visible=True, border_width=1) self.assert_(c.outer_x == 10) self.assert_(c.outer_y == 10) self.assert_(c.outer_bounds[0] == 70) self.assert_(c.outer_bounds[1] == 80) return def check_container(self): c = Component() self.assert_(c.container is None) return if __name__ == "__main__": import nose nose.main() # EOF enthought-chaco2-4.5.1.orig/enable/tests/constraints_container_test_case.py0000644000175000017500000002072612516137326026314 0ustar varunvarunimport unittest from enable.api import ConstraintsContainer, Component from enable.layout.api import hbox, vbox, align, spacer, grid from enable.layout.layout_helpers import DefaultSpacing from enable.layout.layout_manager import LayoutManager from enable.layout.geometry import Rect, Box, Pos, Size, RectF, BoxF, PosF, \ SizeF class ConstraintsContainerTestCase(unittest.TestCase): def setUp(self): self.container = ConstraintsContainer(bounds=[100.0, 100.0]) self.c1 = Component() self.c2 = Component() self.container.add(self.c1) self.container.add(self.c2) def test_equal_size(self): """ Test alignment of widths and heights. """ self.container.layout_constraints = [ self.c1.layout_width == 10, self.c2.layout_width == 10, self.c1.layout_height == 10, self.c2.layout_height == 10 ] self.assert_(self.c1.bounds == self.c2.bounds) def test_hbox_order(self): """ Test the order of components in an hbox. """ self.container.layout_constraints = [ hbox(self.c1, self.c2) ] dx = self.c2.position[0] - self.c1.position[0] self.assert_(dx > 0) def test_vbox_order(self): """ Test the order of components in a vbox. """ self.container.layout_constraints = [ vbox(self.c1, self.c2) ] dy = self.c2.position[1] - self.c1.position[1] self.assert_(dy < 0) def test_alignment_vertical(self): """ Test alignment of components vertically with constraints. """ self.container.layout_constraints = [ self.c1.layout_height == 10, self.c2.layout_height == 10, align('v_center', self.container, self.c1, self.c2) ] pos1 = self.c1.position bound1 = self.c1.bounds pos2 = self.c2.position bound2 = self.c2.bounds self.assert_(pos1[1] + bound1[1] / 2 == self.container.bounds[1] / 2) self.assert_(pos2[1] + bound2[1] / 2 == self.container.bounds[1] / 2) def test_alignment_horizontal(self): """ Test alignment of components horizontally with constraints. """ self.container.layout_constraints = [ self.c1.layout_width == 10, self.c2.layout_width == 10, align('h_center', self.container, self.c1, self.c2) ] pos1 = self.c1.position bound1 = self.c1.bounds pos2 = self.c2.position bound2 = self.c2.bounds self.assert_(pos1[0] + bound1[0] / 2 == self.container.bounds[0] / 2) self.assert_(pos2[0] + bound2[0] / 2 == self.container.bounds[0] / 2) def test_constraint_function(self): """ Test using a function to create constraints. """ cns = [ hbox(self.c1, self.c2), align('layout_width', self.c1, self.c2) ] def get_constraints(container): return cns self.container.layout_constraints = get_constraints self.assert_(self.c1.bounds[0] == self.c2.bounds[0]) def test_invalid_layout(self): """ Make sure proper exceptions are thrown with an invalid layout. """ self.assertRaises(TypeError, setattr, self.container.layout_constraints, [hbox(self.c1, spacer, spacer)]) def test_grid_layout(self): """ Test the grid layout helper. """ c3 = Component() c4 = Component() self.container.add(c3) self.container.add(c4) self.container.layout_constraints = [ grid([self.c1, self.c2], [c3, c4]), align('layout_width', self.c1, self.c2, c3, c4), align('layout_height', self.c1, self.c2, c3, c4) ] space = DefaultSpacing.ABUTMENT c2_pos = [self.c1.position[0] + self.c1.bounds[0] + space, self.c1.position[1]] self.assert_(self.c2.position == c2_pos) def test_invalid_grid_layout(self): """ Test an invalid grid layout. """ self.assertRaises(TypeError, setattr, self.container.layout_constraints, [grid([self.c1, spacer])]) def test_constraint_strength(self): """ Test the strength of constraints. """ self.container.layout_constraints = [ (self.c1.layout_width == 10) | 'weak', (self.c1.layout_width == 20) | 'strong' ] self.assert_(self.c1.bounds[0] == 20) def test_share_layout(self): """ Test sharing layouts with a child container. """ self.child_container = ConstraintsContainer(bounds=[50, 50]) c3 = Component() self.child_container.add(c3) self.container.add(self.child_container) self.container.layout_constraints = [ hbox(self.c1, self.c2, c3), align('layout_width', self.c1, self.c2, c3) ] self.assert_(self.c1.bounds[0] == self.c2.bounds[0] != c3.bounds[0]) self.child_container.share_layout = True self.container.relayout() self.assert_(self.c1.bounds[0] == self.c2.bounds[0] == c3.bounds[0]) def test_layout_manager_initialize(self): """ Ensure that a layout manager can only be initialized once. """ manager = self.container._layout_manager self.assertRaises(RuntimeError, manager.initialize, []) def test_layout_manager_replace_constraints(self): """ Test replacing constraints in the layout manager. """ manager = LayoutManager() cns = hbox(self.c1, self.c2).get_constraints(self.container) new_cns = vbox(self.c1, self.c2).get_constraints(self.container) self.assertRaises(RuntimeError, manager.replace_constraints, cns[0], new_cns[0]) manager.initialize(cns) manager.replace_constraints(cns, new_cns) self.assert_(not manager._solver.hasConstraint(cns[0])) self.assert_(manager._solver.hasConstraint(new_cns[0])) def test_layout_manager_max_size(self): """ Test the max_size method of the LayoutManager. """ manager = self.container._layout_manager max_size = manager.get_max_size(self.container.layout_width, self.container.layout_height) self.assert_(max_size == (-1, -1)) class GeometryTestCase(unittest.TestCase): def test_rect(self): """ Test the Rect class. """ rect = Rect(10, 20, 60, 40) self.assert_(rect.box == Box(20, 70, 60, 10)) self.assert_(rect.pos == Pos(10, 20)) self.assert_(rect.size == Size(60, 40)) def test_rect_f(self): """ Test the RectF class. """ rect_f = RectF(10.5, 20.5, 60.5, 40.5) self.assert_(rect_f.box == BoxF(20.5, 71.0, 61.0, 10.5)) self.assert_(rect_f.pos == PosF(10.5, 20.5)) self.assert_(rect_f.size == SizeF(60.5, 40.5)) def test_box(self): """ Test the Box class. """ box = Box(20, 70, 60, 10) self.assert_(box == Box((20, 70, 60, 10))) self.assert_(box.rect == Rect(10, 20, 60, 40)) self.assert_(box.pos == Pos(10, 20)) self.assert_(box.size == Size(60, 40)) def test_box_f(self): """ Test the BoxF class. """ box_f = BoxF(20.5, 71.0, 61.0, 10.5) self.assert_(box_f == BoxF((20.5, 71.0, 61.0, 10.5))) self.assert_(box_f.rect == RectF(10.5, 20.5, 60.5, 40.5)) self.assert_(box_f.pos == PosF(10.5, 20.5)) self.assert_(box_f.size == SizeF(60.5, 40.5)) def test_pos(self): """ Test the Pos class. """ pos = Pos(10, 20) self.assert_(pos.x == 10) self.assert_(pos.y == 20) def test_pos_f(self): """ Test the PosF class. """ pos_f = PosF(10.5, 20.5) self.assert_(pos_f.x == 10.5) self.assert_(pos_f.y == 20.5) def test_size(self): """ Test the Size class. """ size = Size(40, 20) self.assert_(size == Size((40, 20))) self.assert_(size.width == 40) self.assert_(size.height == 20) def test_size_f(self): """ Test the SizeF class. """ size_f = SizeF(40.5, 20.5) self.assert_(size_f == SizeF((40.5, 20.5))) self.assert_(size_f.width == 40.5) self.assert_(size_f.height == 20.5) if __name__ == '__main__': unittest.main() enthought-chaco2-4.5.1.orig/enable/tests/event_transform_test_case.py0000644000175000017500000001415412516137326025115 0ustar varunvarun # Standard library imports import copy import unittest # Enthought library imports from traits.api import Any, Tuple # Enable imports from enable.api import BasicEvent, Canvas, Component, Container, \ Viewport, AbstractWindow class EnableUnitTest(unittest.TestCase): def assert_dims(self, obj, **dims): """ checks that each of the named dimensions of the object are a certain value. e.g. assert_dims(component, x=5.0, y=7.0). """ for dim, val in dims.items(): self.assert_( getattr(obj, dim) == val ) return class TestComponent(Component): """ A component used for testing event handling. Most notably, it saves a copy of the last event it received. """ # Make some nice default bounds bounds = [10, 10] last_event = Any def _dispatch_stateful_event(self, event, suffix): super(TestComponent, self)._dispatch_stateful_event(event, suffix) self.last_event = copy.copy(event) class TestContainer(Container): last_event = Any def _dispatch_stateful_event(self, event, suffix): super(TestContainer, self)._dispatch_stateful_event(event, suffix) self.last_event = copy.copy(event) class TestCanvas(Canvas): last_event = Any def _dispatch_stateful_event(self, event, suffix): super(TestCanvas, self)._dispatch_stateful_event(event, suffix) self.last_event = copy.copy(event) class DummyWindow(AbstractWindow): """ A stubbed-out subclass of AbstractWindow that passes on most virtual methods instead of raising an exception. """ def _capture_mouse(self): pass def _release_mouse(self): pass def _create_mouse_event(self, event): return event def _redraw(self, *args, **kw): pass def _get_control_size(self): return self._size def _create_gc(self, *args, **kw): pass def _window_paint(self, event): pass def set_pointer(self, pointer): pass def _set_timer_interval(self, component, interval): pass def _set_focus(self): pass def screen_to_window(self, x, y): return (x,y) class EventTransformTestCase(EnableUnitTest): def test_simple_container(self): """ Tests event handling of nested containers """ comp = TestComponent(position=[50,50]) inner_container = TestContainer(bounds=[100.0, 100.0], position=[50,50]) inner_container.add(comp) outer_container = TestContainer(bounds=[200,200]) outer_container.add(inner_container) event = BasicEvent(x=105, y=105) outer_container.dispatch(event, "left_down") self.assert_(comp.last_event.x == 55) self.assert_(comp.last_event.y == 55) self.assert_(inner_container.last_event.x == 105) self.assert_(inner_container.last_event.y == 105) return def test_viewport_container(self): """ Tests event handling of viewports (scaling and translation) """ comp = TestComponent(position=[20,20]) container = TestContainer(bounds=[100,100], position=[50,50]) container.add(comp) viewport = Viewport(component=container, bounds=[400,400], position=[30,30]) # Test unscaled event event = BasicEvent(x=105, y=105) viewport.dispatch(event, "left_down") self.assert_(container.last_event.x == 75) self.assert_(container.last_event.y == 75) self.assert_(comp.last_event.x == 25) self.assert_(comp.last_event.y == 25) # Translate the viewport's view_position container.last_event = None comp.last_event = None viewport.view_position = [-10,-10] event = BasicEvent(x=115, y=115) viewport.dispatch(event, "left_down") self.assert_(container.last_event.x == 75) self.assert_(container.last_event.y == 75) self.assert_(comp.last_event.x == 25) self.assert_(comp.last_event.y == 25) # Do a zoom container.last_event = None comp.last_event = None # Zoom in by a factor of 2, so view an area that is 200x200. viewport.zoom = 2.0 viewport.enable_zoom = True viewport.view_position = [-50, -50] viewport.view_bounds = [200, 200] event = BasicEvent(x=280, y=280) viewport.dispatch(event, "left_down") self.assert_(container.last_event.x == 75) self.assert_(container.last_event.y == 75) self.assert_(comp.last_event.x == 25) self.assert_(comp.last_event.y == 25) return def test_mouse_capture(self): """ Tests saving the event's net_transform as well as the dispatch history when capturing a mouse and dispatching subsequent events. """ class MouseCapturingComponent(TestComponent): captured_event_pos = Tuple def normal_left_down(self, event): self.captured_event_pos = (event.x, event.y) event.window.set_mouse_owner(self, event.net_transform()) comp = MouseCapturingComponent(position=[20,20]) container = TestContainer(bounds=[100,100], position=[50,50]) container.add(comp) viewport = Viewport(component=container, bounds=[400,400], position=[30,30], fit_window=False, resizable="") window = DummyWindow(_size=(500,500)) window.component = viewport # Create the first event (to trigger the mouse capture) event = BasicEvent(x=105, y=105, window=window) window._handle_mouse_event("left_down", event) self.assert_(window.mouse_owner == comp) # Create the second event event = BasicEvent(x=107, y=107, window=window) old_pos = comp.captured_event_pos window._handle_mouse_event("left_down", event) new_pos = comp.captured_event_pos self.assert_(new_pos[0] == old_pos[0] + 2) self.assert_(new_pos[1] == old_pos[1] + 2) return if __name__ == "__main__": import nose nose.main() # EOF enthought-chaco2-4.5.1.orig/enable/tests/__init__.py0000644000175000017500000000000112516137326021370 0ustar varunvarun enthought-chaco2-4.5.1.orig/enable/tests/resize_tool_test.py0000644000175000017500000001272512516137326023246 0ustar varunvarunimport unittest from traits.api import Int from enable.testing import EnableTestAssistant from enable.component import Component from enable.tools.resize_tool import ResizeTool class DragToolTestCase(unittest.TestCase): def setUp(self): self.component = Component(position=[50, 50], bounds=[100, 100], padding=10) self.tool = ResizeTool(component=self.component) def test_find_hotspots(self): points_and_results = [ # corners and edges ([50, 50], 'bottom left'), ([50, 100], 'left'), ([50, 150], 'top left'), ([100, 50], 'bottom'), ([100, 100], ''), ([100, 150], 'top'), ([150, 50], 'bottom right'), ([150, 100], 'right'), ([150, 150], 'top right'), # just inside threshhold ([60, 60], 'bottom left'), ([60, 100], 'left'), ([60, 140], 'top left'), ([100, 50], 'bottom'), ([100, 140], 'top'), ([140, 60], 'bottom right'), ([140, 100], 'right'), ([140, 140], 'top right'), # just outside box ([49, 49], ''), ([49, 50], ''), ([50, 49], ''), ([49, 100], ''), ([49, 151], ''), ([50, 151], ''), ([49, 150], ''), ([100, 49], ''), ([100, 151], ''), ([151, 49], ''), ([150, 49], ''), ([151, 50], ''), ([151, 100], ''), ([151, 151], ''), ([150, 151], ''), ([151, 150], ''), # just outside threshhold ([61, 61], ''), ([60, 61], 'left'), ([61, 60], 'bottom'), ([61, 100], ''), ([61, 139], ''), ([60, 139], 'left'), ([61, 140], 'top'), ([100, 61], ''), ([100, 139], ''), ([139, 61], ''), ([140, 61], 'right'), ([139, 60], 'bottom'), ([139, 100], ''), ([139, 139], ''), ([140, 139], 'right'), ([139, 140], 'top'), ] for (x, y), result in points_and_results: value = self.tool._find_hotspot(x, y) self.assertEqual(value, result, "Failed at (%f, %f): expected %s, got %s" % (x, y, result, value)) def test_set_delta_left(self): self.tool._selected_hotspot = 'left' value = (self.component.position[:], self.component.bounds[:]) deltas_and_results = [ ([10, 10], ([60, 50], [90, 100])), ([-10, 10], ([40, 50], [110, 100])), ([10, -10], ([60, 50], [90, 100])), ([-10, -10], ([40, 50], [110, 100])), ([90, 10], ([130, 50], [20, 100])), ([80, 10], ([130, 50], [20, 100])), ([79, 10], ([129, 50], [21, 100])), ] for (x, y), (position, bounds) in deltas_and_results: self.tool.set_delta(value, x, y) self.assertEqual(self.component.position, position) self.assertEqual(self.component.bounds, bounds) def test_set_delta_right(self): self.tool._selected_hotspot = 'right' value = (self.component.position[:], self.component.bounds[:]) deltas_and_results = [ ([10, 10], ([50, 50], [110, 100])), ([-10, 10], ([50, 50], [90, 100])), ([10, -10], ([50, 50], [110, 100])), ([-10, -10], ([50, 50], [90, 100])), ([-90, 10], ([50, 50], [20, 100])), ([-80, 10], ([50, 50], [20, 100])), ([-79, 10], ([50, 50], [21, 100])), ] for (x, y), (position, bounds) in deltas_and_results: self.tool.set_delta(value, x, y) self.assertEqual(self.component.position, position) self.assertEqual(self.component.bounds, bounds) def test_set_delta_bottom(self): self.tool._selected_hotspot = 'bottom' value = (self.component.position[:], self.component.bounds[:]) deltas_and_results = [ ([10, 10], ([50, 60], [100, 90])), ([-10, 10], ([50, 60], [100, 90])), ([10, -10], ([50, 40], [100, 110])), ([-10, -10], ([50, 40], [100, 110])), ([10, 90], ([50, 130], [100, 20])), ([10, 80], ([50, 130], [100, 20])), ([10, 79], ([50, 129], [100, 21])), ] for (x, y), (position, bounds) in deltas_and_results: self.tool.set_delta(value, x, y) self.assertEqual(self.component.position, position) self.assertEqual(self.component.bounds, bounds) def test_set_delta_top(self): self.tool._selected_hotspot = 'top' value = (self.component.position[:], self.component.bounds[:]) deltas_and_results = [ ([10, 10], ([50, 50], [100, 110])), ([-10, 10], ([50, 50], [100, 110])), ([10, -10], ([50, 50], [100, 90])), ([-10, -10], ([50, 50], [100, 90])), ([10, -90], ([50, 50], [100, 20])), ([10, -80], ([50, 50], [100, 20])), ([10, -79], ([50, 50], [100, 21])), ] for (x, y), (position, bounds) in deltas_and_results: self.tool.set_delta(value, x, y) self.assertEqual(self.component.position, position) self.assertEqual(self.component.bounds, bounds) if __name__ == '__main__': unittest.main() enthought-chaco2-4.5.1.orig/enable/tests/primitives/0000755000175000017500000000000012516137725021466 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tests/primitives/__init__.py0000644000175000017500000000000012516137326023562 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tests/primitives/test_image.py0000644000175000017500000001231112516137326024154 0ustar varunvarun""" Tests for the Image component """ import os import sys if sys.version_info[:2] == (2, 6): import unittest2 as unittest else: import unittest import numpy as np from numpy.testing import assert_array_equal from pkg_resources import resource_filename from kiva.image import GraphicsContext from traits.api import TraitError from traits.testing.unittest_tools import UnittestTools from enable.primitives.image import Image data_dir = resource_filename('enable.tests.primitives', 'data') class ImageTest(unittest.TestCase, UnittestTools): def setUp(self): self.data = np.empty(shape=(128, 256, 4), dtype='uint8') self.data[:, :, 0] = np.arange(256) self.data[:, :, 1] = np.arange(128)[:, np.newaxis] self.data[:, :, 2] = np.arange(256)[::-1] self.data[:, :, 3] = np.arange(128)[::-1, np.newaxis] self.image_24 = Image(self.data[..., :3]) self.image_32 = Image(self.data) def test_fromfile_png_rgb(self): # basic smoke test - assume that kiva.image does the right thing path = os.path.join(data_dir, 'PngSuite', 'basn2c08.png') image = Image.from_file(path) self.assertEqual(image.data.shape, (32, 32, 3)) self.assertEqual(image.format, 'rgb24') def test_fromfile_png_rgba(self): # basic smoke test - assume that kiva.image does the right thing path = os.path.join(data_dir, 'PngSuite', 'basi6a08.png') image = Image.from_file(path) self.assertEqual(image.data.shape, (32, 32, 4)) self.assertEqual(image.format, 'rgba32') def test_init_bad_shape(self): data = np.zeros(shape=(256, 256), dtype='uint8') with self.assertRaises(TraitError): Image(data=data) def test_init_bad_dtype(self): data = np.array(['red']*65536).reshape(128, 128, 4) with self.assertRaises(TraitError): Image(data=data) def test_set_bad_shape(self): data = np.zeros(shape=(256, 256), dtype='uint8') with self.assertRaises(TraitError): self.image_32.data = data def test_set_bad_dtype(self): data = np.array(['red']*65536).reshape(128, 128, 4) with self.assertRaises(TraitError): self.image_32.data = data def test_format(self): self.assertEqual(self.image_24.format, 'rgb24') self.assertEqual(self.image_32.format, 'rgba32') def test_format_change(self): image = self.image_24 with self.assertTraitChanges(image, 'format'): image.data = self.data self.assertEqual(self.image_24.format, 'rgba32') def test_bounds_default(self): self.assertEqual(self.image_24.bounds, [256, 128]) self.assertEqual(self.image_32.bounds, [256, 128]) def test_bounds_overrride(self): image = Image(self.data, bounds=[200, 100]) self.assertEqual(image.bounds, [200, 100]) def test_size_hint(self): self.assertEqual(self.image_24.layout_size_hint, (256, 128)) self.assertEqual(self.image_32.layout_size_hint, (256, 128)) def test_size_hint_change(self): data = np.zeros(shape=(256, 128, 3), dtype='uint8') image = self.image_24 with self.assertTraitChanges(image, 'layout_size_hint'): image.data = data self.assertEqual(self.image_24.layout_size_hint, (128, 256)) def test_image_gc_24(self): # this is non-contiguous, because data comes from slice image_gc = self.image_24._image assert_array_equal(image_gc.bmp_array, self.data[..., :3]) def test_image_gc_32(self): # this is contiguous image_gc = self.image_32._image assert_array_equal(image_gc.bmp_array, self.data) def test_draw_24(self): gc = GraphicsContext((256, 128), pix_format='rgba32') self.image_24.draw(gc) # if test is failing, uncomment this line to see what is drawn #gc.save('test_image_draw_24.png') # smoke test: image isn't all white assert_array_equal(gc.bmp_array[..., :3], self.data[..., :3]) def test_draw_32(self): gc = GraphicsContext((256, 128), pix_format='rgba32') self.image_32.draw(gc) # if test is failing, uncommetn this line to see what is drawn #gc.save('test_image_draw_32.png') # smoke test: image isn't all white # XXX actually compute what it should look like with alpha transfer white_image = np.ones(shape=(256, 128, 4), dtype='uint8')*255 self.assertFalse(np.array_equal(white_image, gc.bmp_array)) def test_draw_stretched(self): gc = GraphicsContext((256, 256), pix_format='rgba32') self.image_32.bounds = [128, 258] self.image_32.position = [128, 0] self.image_32.draw(gc) # if test is failing, uncommetn this line to see what is drawn #gc.save('test_image_draw_stretched.png') # smoke test: image isn't all white # XXX actually compute what it should look like with alpha transfer white_image = np.ones(shape=(256, 256, 4), dtype='uint8')*255 self.assertFalse(np.array_equal(white_image, gc.bmp_array)) # left half of the image *should* be white assert_array_equal(gc.bmp_array[:, :128, :], white_image[:, :128, :]) enthought-chaco2-4.5.1.orig/enable/tests/primitives/data/0000755000175000017500000000000012516137725022377 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tests/primitives/data/PngSuite/0000755000175000017500000000000012516137725024135 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tests/primitives/data/PngSuite/basi6a08.png0000644000175000017500000000055112516137326026156 0ustar varunvarun‰PNG  IHDR }JbgAMA† 1è–_ IDATxœÅ•ANÃ0EŸ¥A¸»²fA¸›†‹MÁÁÁE*q *eØ@Õ”AüHÉŠâ|?'ãäd€G`ì 9»âc:1Ⓣääê{ý¿=šk€ ¸ŸÖµSÏ˰gž–c×. ’“·3{Ÿ˜ŒÆ_m è/—N Ú@Ð-~'ù.l¿ÆMðü1¦! jÑ  ò¼ò DÇ µh œœùã™Ï=F`¨u@]š`а^-å^%x zRhàb!â9š«:XF/¸hü.䋱 Þ×Òlä¿Y ¹¬PtìP΀ÚW(å3ðÎmYµ›Ëêm Ï€ª²êu(¨×© P:Ÿ‚JSôiNsBIEND®B`‚enthought-chaco2-4.5.1.orig/enable/tests/primitives/data/PngSuite/basn2c08.png0000644000175000017500000000022112516137326026153 0ustar varunvarun‰PNG  IHDR üí£gAMA† 1è–_HIDATxœíÕÁ 0 @…ì‘ý·r;D+ô¡øÎá+´ ;€ ø íä}Lx@J‡„(ð t8#©@»pw£À‚±ù^@ÏKIEND®B`‚enthought-chaco2-4.5.1.orig/enable/tests/tools/0000755000175000017500000000000012516137725020433 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tests/tools/apptools/0000755000175000017500000000000012516137725022274 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tests/tools/apptools/move_command_tool_test_case.py0000644000175000017500000001277212516137326030407 0ustar varunvarun# # (C) Copyright 2015 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in # LICENSE.txt # """ Test case for MoveCommandTool """ from __future__ import (division, absolute_import, print_function, unicode_literals) # Third party library imports from mock import MagicMock # Enthought library imports from apptools.undo.api import CommandStack from traits.testing.unittest_tools import UnittestTools, unittest # Local library imports from enable.component import Component from enable.container import Container from enable.testing import EnableTestAssistant from enable.tools.apptools.commands import MoveCommand, ResizeCommand from enable.tools.apptools.move_command_tool import MoveCommandTool class MoveCommandToolTestCase(unittest.TestCase, EnableTestAssistant, UnittestTools): def setUp(self): self.command_stack = CommandStack() self.command_stack.push = MagicMock() self.component = Component(position=[50, 50], bounds=[100, 100]) self.container = Container() self.container.add(self.component) self.tool = MoveCommandTool(component=self.component, command_stack=self.command_stack) self.component.tools.append(self.tool) def test_drag_component(self): window = self.create_mock_window() # start the mouse drag mouse_down_event = self.mouse_down(self.component, 145, 145, window=window) self.assertTrue(self.tool._mouse_down_received) # start moving the mouse mouse_move_event = self.mouse_move(self.component, 145, 145, window=window) self.assertTrue(mouse_move_event.handled) # move the mouse to the final location mouse_move_event = self.mouse_move(self.component, 195, 95, window=window) self.assertTrue(mouse_move_event.handled) # release the mouse, ending the drag mouse_up_event = self.mouse_up(self.component, 195, 95, window=window) self.assertTrue(mouse_up_event.handled) # check if a MoveCommand was pushed onto the stack args, kwargs = self.command_stack.push.call_args self.assertIsNotNone(args) self.assertEqual(len(args), 1) self.assertIsInstance(args[0], MoveCommand) command = args[0] # check that the MoveCommand has right parameters self.assertEqual(command.data, (100, 0)) self.assertEqual(command.previous_position, (50, 50)) self.assertFalse(command.mergeable) self.assertEqual(command.component, self.component) def test_drag_cancel(self): window = self.create_mock_window() # start the mouse drag mouse_down_event = self.mouse_down(self.component, 145, 145, window=window) # could be a click, not a drag, I guess? self.assertFalse(mouse_down_event.handled) self.assertTrue(self.tool._mouse_down_received) # start moving the mouse mouse_move_event = self.mouse_move(self.component, 145, 145, window=window) self.assertTrue(mouse_move_event.handled) # move the mouse to the final location mouse_move_event = self.mouse_move(self.component, 195, 95, window=window) self.assertTrue(mouse_move_event.handled) # send an escape to cancel the event escape_event = self.send_key(self.component, 'Esc', window=window) self.assertTrue(escape_event.handled) # release the mouse, ending the drag mouse_up_event = self.mouse_up(self.component, 195, 95, window=window) self.assertFalse(mouse_up_event.handled) # check if a MoveCommand was pushed onto the stack self.assertFalse(self.command_stack.push.called) def test_drag_resize_move_command(self): self.tool.command = ResizeCommand.move_command window = self.create_mock_window() # start the mouse drag mouse_down_event = self.mouse_down(self.component, 145, 145, window=window) self.assertTrue(self.tool._mouse_down_received) # start moving the mouse mouse_move_event = self.mouse_move(self.component, 145, 145, window=window) self.assertTrue(mouse_move_event.handled) # move the mouse to the final location mouse_move_event = self.mouse_move(self.component, 195, 95, window=window) self.assertTrue(mouse_move_event.handled) # release the mouse, ending the drag mouse_up_event = self.mouse_up(self.component, 195, 95, window=window) self.assertTrue(mouse_up_event.handled) # check if a ResizeCommand was pushed onto the stack args, kwargs = self.command_stack.push.call_args self.assertIsNotNone(args) self.assertEqual(len(args), 1) self.assertIsInstance(args[0], ResizeCommand) command = args[0] # check that the ResizeCommand has right parameters self.assertEqual(command.data, (100, 0, 100, 100)) self.assertEqual(command.previous_rectangle, (50, 50, 100, 100)) self.assertFalse(command.mergeable) self.assertEqual(command.component, self.component) enthought-chaco2-4.5.1.orig/enable/tests/tools/apptools/__init__.py0000644000175000017500000000000012516137326024370 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tests/tools/apptools/undo_tool_test_case.py0000644000175000017500000000555712516137326026713 0ustar varunvarun# # (C) Copyright 2015 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in # LICENSE.txt # """ Tests for Commands that work with Components """ from __future__ import (division, absolute_import, print_function, unicode_literals) # Third party library imports from mock import MagicMock # Enthought library imports from apptools.undo.api import UndoManager from traits.testing.unittest_tools import UnittestTools, unittest # Local library imports from enable.base_tool import KeySpec from enable.component import Component from enable.testing import EnableTestAssistant from enable.tools.apptools.undo_tool import UndoTool class UndoToolTestCase(unittest.TestCase, EnableTestAssistant, UnittestTools): def setUp(self): self.undo_manager = UndoManager() self.undo_manager.undo = MagicMock() self.undo_manager.redo = MagicMock() self.component = Component() self.tool = UndoTool(component=self.component, undo_manager=self.undo_manager) self.component.tools.append(self.tool) def test_undo_key_press(self): key_event = self.create_key_press('z', control_down=True) self.component.dispatch(key_event, 'key_pressed') self.assertTrue(self.undo_manager.undo.called) self.assertFalse(self.undo_manager.redo.called) self.assertTrue(key_event.handled) def test_redo_key_press(self): key_event = self.create_key_press('z', control_down=True, shift_down=True) self.component.dispatch(key_event, 'key_pressed') self.assertTrue(key_event.handled) self.assertFalse(self.undo_manager.undo.called) self.assertTrue(self.undo_manager.redo.called) def test_other_key_press(self): key_event = self.create_key_press('z') self.component.dispatch(key_event, 'key_pressed') self.assertFalse(self.undo_manager.undo.called) self.assertFalse(self.undo_manager.redo.called) self.assertFalse(key_event.handled) def test_undo_key_press_non_default(self): self.tool.undo_keys = [KeySpec('Left', 'control')] key_event = self.create_key_press('Left', control_down=True) self.component.dispatch(key_event, 'key_pressed') self.assertTrue(self.undo_manager.undo.called) self.assertFalse(self.undo_manager.redo.called) self.assertTrue(key_event.handled) def test_redo_key_press_non_default(self): self.tool.redo_keys = [KeySpec('Right', 'control')] key_event = self.create_key_press('Right', control_down=True) self.component.dispatch(key_event, 'key_pressed') self.assertTrue(key_event.handled) self.assertFalse(self.undo_manager.undo.called) self.assertTrue(self.undo_manager.redo.called) enthought-chaco2-4.5.1.orig/enable/tests/tools/apptools/resize_command_tool_test_case.py0000644000175000017500000001002512516137326030727 0ustar varunvarun# # (C) Copyright 2015 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in # LICENSE.txt # """ Test case for ResizeCommandTool """ from __future__ import (division, absolute_import, print_function, unicode_literals) # Third party library imports from mock import MagicMock # Enthought library imports from apptools.undo.api import CommandStack from traits.testing.unittest_tools import UnittestTools, unittest # Local library imports from enable.component import Component from enable.container import Container from enable.testing import EnableTestAssistant from enable.tools.apptools.commands import ResizeCommand from enable.tools.apptools.resize_command_tool import ResizeCommandTool class ResizeCommandToolTestCase(unittest.TestCase, EnableTestAssistant, UnittestTools): def setUp(self): self.command_stack = CommandStack() self.command_stack.push = MagicMock() self.component = Component(position=[50, 50], bounds=[100, 100]) self.container = Container() self.container.add(self.component) self.tool = ResizeCommandTool(component=self.component, command_stack=self.command_stack) self.component.tools.append(self.tool) def test_drag_component(self): window = self.create_mock_window() # start the mouse drag mouse_down_event = self.mouse_down(self.component, 145, 145, window=window) self.assertTrue(mouse_down_event.handled) self.assertTrue(self.tool._mouse_down_received) # start moving the mouse mouse_move_event = self.mouse_move(self.component, 145, 145, window=window) self.assertTrue(mouse_move_event.handled) # move the mouse to the final location mouse_move_event = self.mouse_move(self.component, 195, 95, window=window) self.assertTrue(mouse_move_event.handled) # release the mouse, ending the drag mouse_up_event = self.mouse_up(self.component, 195, 95, window=window) self.assertTrue(mouse_up_event.handled) # check if a ResizeCommand was pushed onto the stack args, kwargs = self.command_stack.push.call_args self.assertIsNotNone(args) self.assertEqual(len(args), 1) self.assertIsInstance(args[0], ResizeCommand) command = args[0] # check that the ResizeCommand has right parameters self.assertEqual(command.data, (50, 50, 150, 50)) self.assertEqual(command.previous_rectangle, (50, 50, 100, 100)) self.assertFalse(command.mergeable) self.assertEqual(command.component, self.component) def test_drag_cancel(self): window = self.create_mock_window() # start the mouse drag mouse_down_event = self.mouse_down(self.component, 145, 145, window=window) self.assertTrue(mouse_down_event.handled) self.assertTrue(self.tool._mouse_down_received) # start moving the mouse mouse_move_event = self.mouse_move(self.component, 145, 145, window=window) self.assertTrue(mouse_move_event.handled) # move the mouse to the final location mouse_move_event = self.mouse_move(self.component, 195, 95, window=window) self.assertTrue(mouse_move_event.handled) # send an escape to cancel the event escape_event = self.send_key(self.component, 'Esc', window=window) self.assertTrue(escape_event.handled) # release the mouse, ending the drag mouse_up_event = self.mouse_up(self.component, 195, 95, window=window) self.assertFalse(mouse_up_event.handled) # check if a ResizeCommand was pushed onto the stack self.assertFalse(self.command_stack.push.called) enthought-chaco2-4.5.1.orig/enable/tests/tools/apptools/commands_test_case.py0000644000175000017500000002647012516137326026507 0ustar varunvarun# # (C) Copyright 2015 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in # LICENSE.txt # """ Tests for Commands that work with Components """ from __future__ import (division, absolute_import, print_function, unicode_literals) # Third party library imports from mock import MagicMock # Enthought library imports from traits.testing.unittest_tools import UnittestTools, unittest # Local library imports from enable.component import Component from enable.testing import EnableTestAssistant from enable.tools.apptools.commands import ( ComponentCommand, MoveCommand, ResizeCommand) class ComponentCommandTest(unittest.TestCase, EnableTestAssistant, UnittestTools): def setUp(self): self.component = Component() self.command = ComponentCommand(component=self.component) def test_name_default(self): self.assertEqual(self.command.component_name, 'Component') def test_name_empty(self): self.command.component = None self.assertEqual(self.command.component_name, '') class ResizeCommandTest(unittest.TestCase, EnableTestAssistant, UnittestTools): def setUp(self): self.component = Component(position=[50, 50], bounds=[100, 100]) self.component.request_redraw = MagicMock() self.command = ResizeCommand(self.component, (25, 25, 150, 150), (50, 50, 100, 100)) def test_name_default(self): self.assertEqual(self.command.name, 'Resize Component') def test_name_alternate_component_name(self): self.command.component_name = 'My Component' self.assertEqual(self.command.name, 'Resize My Component') def test_do(self): command = self.command with self.assertMultiTraitChanges([self.component], ['position', 'bounds'], []): command.do() self.assertEqual(self.component.position, [25, 25]) self.assertEqual(self.component.bounds, [150, 150]) self.assertTrue(self.component.request_redraw.called) def test_do_no_previous_rectangle(self): command = ResizeCommand(self.component, (25, 25, 150, 150)) self.assertEqual(command.previous_rectangle, (50, 50, 100, 100)) def test_do_no_new_position(self): with self.assertRaises(TypeError): ResizeCommand(self.component, previous_rectangle=(50, 50, 100, 100)) def test_do_no_new_position_with_data(self): command = ResizeCommand(self.component, previous_rectangle=(50, 50, 100, 100), data=(25, 25, 150, 150)) self.assertEqual(command.data, (25, 25, 150, 150)) def test_do_no_new_position_no_previous_position_with_data(self): command = ResizeCommand(self.component, data=(25, 25, 150, 150)) self.assertEqual(command.data, (25, 25, 150, 150)) self.assertEqual(command.previous_rectangle, (50, 50, 100, 100)) def test_move_command(self): command = ResizeCommand.move_command(self.component, (25, 25), (50, 50)) self.assertEqual(command.data, (25, 25, 100, 100)) self.assertEqual(command.previous_rectangle, (50, 50, 100, 100)) def test_move_command_no_previous_position(self): command = ResizeCommand.move_command(self.component, (25, 25)) self.assertEqual(command.data, (25, 25, 100, 100)) self.assertEqual(command.previous_rectangle, (50, 50, 100, 100)) def test_undo(self): command = self.command command.do() with self.assertMultiTraitChanges([self.component], ['position', 'bounds'], []): command.undo() self.assertEqual(self.component.position, [50, 50]) self.assertEqual(self.component.bounds, [100, 100]) self.assertTrue(self.component.request_redraw.called) def test_redo(self): command = self.command command.do() command.undo() with self.assertMultiTraitChanges([self.component], ['position', 'bounds'], []): command.redo() self.assertEqual(self.component.position, [25, 25]) self.assertEqual(self.component.bounds, [150, 150]) self.assertTrue(self.component.request_redraw.called) def test_merge(self): command = self.command command.mergeable = True other_command = ResizeCommand(component=self.component, data=(0, 0, 200, 200), previous_rectangle=(50, 50, 100, 100)) with self.assertTraitChanges(command, 'data'): merged = command.merge(other_command) self.assertTrue(merged) self.assertEqual(command.data, (0, 0, 200, 200)) self.assertFalse(command.mergeable) def test_merge_other_mergeable(self): command = self.command command.mergeable = True other_command = ResizeCommand(component=self.component, mergeable=True, data=(0, 0, 200, 200), previous_rectangle=(50, 50, 100, 100)) with self.assertTraitChanges(command, 'data'): merged = command.merge(other_command) self.assertTrue(merged) self.assertEqual(command.data, (0, 0, 200, 200)) self.assertTrue(command.mergeable) def test_merge_unmergeable(self): command = self.command other_command = ResizeCommand(component=self.component, data=(0, 0, 200, 200), previous_rectangle=(50, 50, 100, 100)) with self.assertTraitDoesNotChange(command, 'data'): merged = command.merge(other_command) self.assertFalse(merged) self.assertEqual(command.data, (25, 25, 150, 150)) def test_merge_wrong_component(self): command = self.command command.mergeable = True other_component = Component() other_command = ResizeCommand(component=other_component, data=(0, 0, 200, 200), previous_rectangle=(50, 50, 100, 100)) with self.assertTraitDoesNotChange(command, 'data'): merged = command.merge(other_command) self.assertFalse(merged) self.assertEqual(command.data, (25, 25, 150, 150)) def test_merge_wrong_class(self): command = self.command command.mergeable = True other_command = ComponentCommand(component=self.component) with self.assertTraitDoesNotChange(command, 'data'): merged = command.merge(other_command) self.assertFalse(merged) self.assertEqual(command.data, (25, 25, 150, 150)) class MoveCommandTest(unittest.TestCase, EnableTestAssistant, UnittestTools): def setUp(self): self.component = Component(position=[50, 50], bounds=[100, 100]) self.component.request_redraw = MagicMock() self.command = MoveCommand(self.component, (25, 25), (50, 50)) def test_name_default(self): self.assertEqual(self.command.name, 'Move Component') def test_name_alternate_component_name(self): self.command.component_name = 'My Component' self.assertEqual(self.command.name, 'Move My Component') def test_do(self): command = self.command with self.assertTraitChanges(self.component, 'position', count=1): command.do() self.assertEqual(self.component.position, [25, 25]) self.assertTrue(self.component.request_redraw.called) def test_do_no_previous_position(self): command = MoveCommand(self.component, (25, 25)) self.assertEqual(command.previous_position, (50, 50)) def test_do_no_new_position(self): with self.assertRaises(TypeError): MoveCommand(self.component, previous_position=(50, 50)) def test_do_no_new_position_with_data(self): command = MoveCommand(self.component, previous_position=(50, 50), data=(25, 25)) self.assertEqual(command.data, (25, 25)) def test_do_no_new_position_no_previous_position_with_data(self): command = MoveCommand(self.component, data=(25, 25)) self.assertEqual(command.data, (25, 25)) self.assertEqual(command.previous_position, (50, 50)) def test_undo(self): command = self.command command.do() with self.assertTraitChanges(self.component, 'position', count=1): command.undo() self.assertEqual(self.component.position, [50, 50]) self.assertTrue(self.component.request_redraw.called) def test_redo(self): command = self.command command.do() command.undo() with self.assertTraitChanges(self.component, 'position', count=1): command.redo() self.assertEqual(self.component.position, [25, 25]) self.assertTrue(self.component.request_redraw.called) def test_merge(self): command = self.command command.mergeable = True other_command = MoveCommand(component=self.component, data=(0, 0), previous_position=(50, 50)) with self.assertTraitChanges(command, 'data'): merged = command.merge(other_command) self.assertTrue(merged) self.assertEqual(command.data, (0, 0)) self.assertFalse(command.mergeable) def test_merge_other_mergeable(self): command = self.command command.mergeable = True other_command = MoveCommand(component=self.component, mergeable=True, data=(0, 0), previous_position=(50, 50)) with self.assertTraitChanges(command, 'data'): merged = command.merge(other_command) self.assertTrue(merged) self.assertEqual(command.data, (0, 0)) self.assertTrue(command.mergeable) def test_merge_unmergeable(self): command = self.command other_command = MoveCommand(component=self.component, data=(0, 0), previous_position=(50, 50)) with self.assertTraitDoesNotChange(command, 'data'): merged = command.merge(other_command) self.assertFalse(merged) self.assertEqual(command.data, (25, 25)) def test_merge_wrong_component(self): command = self.command command.mergeable = True other_component = Component() other_command = MoveCommand(component=other_component, data=(0, 0), previous_position=(50, 50)) with self.assertTraitDoesNotChange(command, 'data'): merged = command.merge(other_command) self.assertFalse(merged) self.assertEqual(command.data, (25, 25)) def test_merge_wrong_class(self): command = self.command command.mergeable = True other_command = ComponentCommand(component=self.component) with self.assertTraitDoesNotChange(command, 'data'): merged = command.merge(other_command) self.assertFalse(merged) self.assertEqual(command.data, (25, 25)) enthought-chaco2-4.5.1.orig/enable/tests/tools/__init__.py0000644000175000017500000000000012516137326022527 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/tests/tools/button_tool_test_case.py0000644000175000017500000002576512516137326025423 0ustar varunvarun# # (C) Copyright 2015 Enthought, Inc., Austin, TX # All right reserved. # # This file is open source software distributed according to the terms in # LICENSE.txt # from __future__ import (absolute_import, division, print_function, unicode_literals) from traits.testing.unittest_tools import UnittestTools, unittest from enable.component import Component from enable.testing import EnableTestAssistant from enable.tools.button_tool import ButtonTool class ButtonToolTestCase(EnableTestAssistant, UnittestTools, unittest.TestCase): def setUp(self): self.component = Component(position=[50, 50], bounds=[100, 100]) self.tool = ButtonTool(component=self.component) self.component.tools.append(self.tool) def test_click_function(self): tool = self.tool with self.assertTraitDoesNotChange(tool, 'down'): with self.assertTraitChanges(tool, 'clicked', count=1): with self.assertTraitDoesNotChange(tool, 'checked'): tool.click() def test_click_function_togglable(self): tool = self.tool tool.togglable = True with self.assertTraitDoesNotChange(tool, 'down'): with self.assertTraitChanges(tool, 'clicked', count=1): with self.assertTraitChanges(tool, 'checked', count=1): tool.click() self.assertTrue(tool.checked) def test_toggle_function_untogglable(self): tool = self.tool with self.assertTraitDoesNotChange(tool, 'down'): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitChanges(tool, 'checked'): tool.toggle() self.assertTrue(tool.checked) def test_toggle_function(self): tool = self.tool tool.togglable = True with self.assertTraitDoesNotChange(tool, 'down'): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitChanges(tool, 'checked', count=1): tool.toggle() self.assertTrue(tool.checked) def test_toggle_function_checked(self): tool = self.tool tool.togglable = True tool.checked = True with self.assertTraitDoesNotChange(tool, 'down'): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitChanges(tool, 'checked', count=1): tool.toggle() self.assertFalse(tool.checked) def test_basic_click(self): window = self.create_mock_window() component = self.component tool = self.tool with self.assertTraitChanges(tool, 'down', count=1): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitDoesNotChange(tool, 'checked'): event = self.mouse_down(component, 100, 100, window=window) self.assertTrue(event.handled) self.assertTrue(tool.event_state, 'pressed') self.assertTrue(tool.down) self.assertFalse(tool.checked) with self.assertTraitChanges(tool, 'down', count=1): with self.assertTraitChanges(tool, 'clicked', count=1): with self.assertTraitDoesNotChange(tool, 'checked'): event = self.mouse_up(self.component, 100, 100, window=window) self.assertTrue(event.handled) self.assertTrue(tool.event_state, 'normal') self.assertFalse(tool.down) self.assertFalse(tool.checked) def test_basic_toggle(self): window = self.create_mock_window() component = self.component tool = self.tool tool.togglable = True with self.assertTraitChanges(tool, 'down', count=1): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitDoesNotChange(tool, 'checked'): event = self.mouse_down(component, 100, 100, window=window) self.assertTrue(event.handled) self.assertTrue(tool.event_state, 'pressed') self.assertTrue(tool.down) self.assertFalse(tool.checked) with self.assertTraitChanges(tool, 'down', count=1): with self.assertTraitChanges(tool, 'clicked', count=1): with self.assertTraitChanges(tool, 'checked', count=1): event = self.mouse_up(self.component, 100, 100, window=window) self.assertTrue(event.handled) self.assertTrue(tool.event_state, 'normal') self.assertFalse(tool.down) self.assertTrue(tool.checked) def test_basic_toggle_checked(self): window = self.create_mock_window() component = self.component tool = self.tool tool.togglable = True tool.checked = True with self.assertTraitChanges(tool, 'down', count=1): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitDoesNotChange(tool, 'checked'): event = self.mouse_down(component, 100, 100, window=window) self.assertTrue(event.handled) self.assertTrue(tool.event_state, 'pressed') self.assertTrue(tool.down) self.assertTrue(tool.checked) with self.assertTraitChanges(tool, 'down', count=1): with self.assertTraitChanges(tool, 'clicked', count=1): with self.assertTraitChanges(tool, 'checked', count=1): event = self.mouse_up(self.component, 100, 100, window=window) self.assertTrue(event.handled) self.assertTrue(tool.event_state, 'normal') self.assertFalse(tool.down) self.assertFalse(tool.checked) def test_basic_click_disabled(self): window = self.create_mock_window() component = self.component tool = self.tool tool.enabled = False with self.assertTraitDoesNotChange(tool, 'down'): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitDoesNotChange(tool, 'checked'): event = self.mouse_down(component, 100, 100, window=window) self.assertFalse(event.handled) self.assertTrue(tool.event_state, 'normal') self.assertFalse(tool.down) self.assertFalse(tool.checked) with self.assertTraitDoesNotChange(tool, 'down'): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitDoesNotChange(tool, 'checked'): event = self.mouse_up(self.component, 100, 100, window=window) self.assertFalse(event.handled) self.assertTrue(tool.event_state, 'normal') self.assertFalse(tool.down) self.assertFalse(tool.checked) def test_click_drag(self): window = self.create_mock_window() component = self.component tool = self.tool with self.assertTraitChanges(tool, 'down', count=1): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitDoesNotChange(tool, 'checked'): event = self.mouse_down(component, 100, 100, window=window) self.assertTrue(event.handled) self.assertTrue(tool.event_state, 'pressed') self.assertTrue(tool.down) self.assertFalse(tool.checked) # move mouse out of component with self.assertTraitChanges(tool, 'down', count=1): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitDoesNotChange(tool, 'checked'): event = self.mouse_move(self.component, 25, 25, window=window) self.assertFalse(event.handled) self.assertTrue(tool.event_state, 'pressed') self.assertFalse(tool.down) self.assertFalse(tool.checked) # move mouse into component with self.assertTraitChanges(tool, 'down', count=1): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitDoesNotChange(tool, 'checked'): event = self.mouse_move(self.component, 100, 100, window=window) self.assertFalse(event.handled) self.assertTrue(tool.event_state, 'pressed') self.assertTrue(tool.down) self.assertFalse(tool.checked) # move mouse out of component with self.assertTraitChanges(tool, 'down', count=1): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitDoesNotChange(tool, 'checked'): event = self.mouse_move(self.component, 200, 200, window=window) self.assertFalse(event.handled) self.assertTrue(tool.event_state, 'pressed') self.assertFalse(tool.down) self.assertFalse(tool.checked) # release button with self.assertTraitDoesNotChange(tool, 'down'): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitDoesNotChange(tool, 'checked'): event = self.mouse_up(self.component, 200, 200, window=window) self.assertFalse(event.handled) self.assertTrue(tool.event_state, 'normal') self.assertFalse(tool.down) self.assertFalse(tool.checked) def test_click_mouse_leave(self): window = self.create_mock_window() component = self.component tool = self.tool with self.assertTraitChanges(tool, 'down', count=1): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitDoesNotChange(tool, 'checked'): event = self.mouse_down(component, 100, 100, window=window) self.assertTrue(event.handled) self.assertTrue(tool.event_state, 'pressed') self.assertTrue(tool.down) self.assertFalse(tool.checked) # move mouse out of component with self.assertTraitChanges(tool, 'down', count=1): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitDoesNotChange(tool, 'checked'): event = self.mouse_leave(self.component, 25, 25, window=window) self.assertFalse(event.handled) self.assertTrue(tool.event_state, 'pressed') self.assertFalse(tool.down) self.assertFalse(tool.checked) # move mouse into component with self.assertTraitChanges(tool, 'down', count=1): with self.assertTraitDoesNotChange(tool, 'clicked'): with self.assertTraitDoesNotChange(tool, 'checked'): event = self.mouse_enter(self.component, 100, 100, window=window) self.assertFalse(event.handled) self.assertTrue(tool.event_state, 'pressed') self.assertTrue(tool.down) self.assertFalse(tool.checked) enthought-chaco2-4.5.1.orig/enable/tests/viewport_test_case.py0000644000175000017500000000214712516137326023557 0ustar varunvarunimport unittest from enable.api import Component, Container, Viewport class ViewportTestCase(unittest.TestCase): def test_basic_viewport(self): container = Container(bounds=[100.0, 100.0]) component = Component(bounds=[50.0, 50.0], position=[5.0, 5.0]) container.add(component) view = Viewport(component=container, view_position=[10.0, 10.0], view_bounds=[50.0, 50.0], position=[0,0], bounds=[50,50]) self.assert_(view.components_at(0.0, 0.0)[0] == component) self.assert_(view.components_at(44.9, 0.0)[0] == component) self.assert_(view.components_at(0.0, 44.9)[0] == component) self.assert_(view.components_at(44.9, 44.9)[0] == component) self.assert_(view.components_at(46.0, 45.0) == []) self.assert_(view.components_at(46.0, 0.0) == []) self.assert_(view.components_at(45.0, 46.0) == []) self.assert_(view.components_at(0.0, 46.0) == []) return if __name__ == "__main__": import nose nose.main() # EOF enthought-chaco2-4.5.1.orig/enable/tests/test_component_editor.py0000644000175000017500000000347612516137326024263 0ustar varunvarun""" Test the interaction between traitsui and enable's ComponentEditor. """ from enable.component_editor import ComponentEditor from traits.has_traits import HasTraits from traits.trait_types import Any from traitsui.item import Item from traitsui.view import View from traitsui.tests._tools import * class _ComponentDialog(HasTraits): """ View containing an item with ComponentEditor. """ thing = Any traits_view = View( Item('thing', editor=ComponentEditor(), show_label=False), resizable = True ) ITEM_WIDTH, ITEM_HEIGHT = 700, 200 class _ComponentDialogWithSize(HasTraits): """ View containing an item with ComponentEditor and given size. """ thing = Any traits_view = View( Item('thing', editor=ComponentEditor(), show_label=False, width=ITEM_WIDTH, height=ITEM_HEIGHT), resizable = True ) @skip_if_null def test_initial_component(): # BUG: the initial size of an Item with ComponentEditor is zero # in the Qt backend dialog = _ComponentDialog() ui = dialog.edit_traits() size = get_dialog_size(ui.control) nose.tools.assert_greater(size[0], 0) nose.tools.assert_greater(size[1], 0) @skip_if_null def test_initial_component_with_item_size(): # BEH: the initial component size should respect the size of the dialog = _ComponentDialogWithSize() ui = dialog.edit_traits() size = get_dialog_size(ui.control) # leave a few pixel of margin for wx nose.tools.assert_greater(size[0], ITEM_WIDTH-1) nose.tools.assert_less(size[0], ITEM_WIDTH+30) nose.tools.assert_greater(size[1], ITEM_HEIGHT-1) nose.tools.assert_less(size[1], ITEM_HEIGHT+30) if __name__ == '__main__': # Executing the file opens the dialog for manual testing vw = _ComponentDialogWithSize() vw.configure_traits() enthought-chaco2-4.5.1.orig/enable/tests/kiva_graphics_context_test_case.py0000644000175000017500000000137512516137326026260 0ustar varunvarun import numpy as np import unittest from enable.kiva_graphics_context import GraphicsContext class TestGCErrors(unittest.TestCase): """Test some cases where a ValueError should be raised.""" def test_bad_image_size(self): arr = np.array([[1, 2], [3, 4]], dtype=np.uint8) gc = GraphicsContext((50, 50)) # The draw_image methods expects its first argument # to be a 3D whose last dimension has length 3 or 4. # Passing in arr should raise a value error. self.assertRaises(ValueError, gc.draw_image, arr) # Pass in a 3D array, but with an invalid size in the last dimension. self.assertRaises(ValueError, gc.draw_image, arr.reshape(2, 2, 1)) if __name__ == "__main__": unittest.main() enthought-chaco2-4.5.1.orig/enable/tests/drop_tool_test.py0000644000175000017500000000446612516137326022714 0ustar varunvarunimport unittest from enable.testing import EnableTestAssistant from enable.tools.base_drop_tool import BaseDropTool class DummyTool(BaseDropTool): def accept_drop(self, position, obj): """ Simple rule which allows testing of different cases We accept the drop if x > y """ x, y = position return x > y def handle_drop(self, position, obj): # remember the data for checking later self.position = position self.obj = obj class DropToolTestCase(EnableTestAssistant, unittest.TestCase): def setUp(self): self.tool = DummyTool() def test_get_drag_result_accept(self): result = self.tool.get_drag_result((50, 100), 'object') self.assertEqual(result, None) def test_get_drag_result_reject(self): result = self.tool.get_drag_result((50, 100), 'object') self.assertEqual(result, None) def test_get_drag_result_accept_None(self): # if object is None, have to accept to support Wx result = self.tool.get_drag_result((50, 100), None) self.assertEqual(result, 'copy') def test_drag_over_accept(self): event = self.send_drag_over(self.tool, 100, 50, 'object') self.assertEqual(event.window._drag_result, 'copy') self.assertTrue(event.handled) def test_drag_over_reject(self): event = self.send_drag_over(self.tool, 50, 100, 'object') self.assertEqual(event.window._drag_result, None) self.assertFalse(event.handled) def test_drag_over_accept_None(self): # if object is None, have to accept to support Wx event = self.send_drag_over(self.tool, 50, 100, None) self.assertEqual(event.window._drag_result, 'copy') self.assertTrue(event.handled) def test_drag_leave(self): # we don't attempt to handle these event = self.send_drag_leave(self.tool, 100, 50) self.assertFalse(event.handled) def test_dropped_on_accept(self): event = self.send_dropped_on(self.tool, 100, 50, 'object') self.assertTrue(event.handled) self.assertEqual(self.tool.position, (100, 50)) self.assertEqual(self.tool.obj, 'object') def test_dropped_on_rejected(self): event = self.send_dropped_on(self.tool, 50, 100, 'object') self.assertFalse(event.handled) enthought-chaco2-4.5.1.orig/enable/tests/container_test_case.py0000644000175000017500000000562012516137326023661 0ustar varunvarunimport unittest from enable.api import Component, Container class EnableUnitTest(unittest.TestCase): def assert_dims(self, obj, **dims): """ checks that each of the named dimensions of the object are a certain value. e.g. assert_dims(component, x=5.0, y=7.0). """ for dim, val in dims.items(): self.assert_( getattr(obj, dim) == val ) return class ContainerTestCase(EnableUnitTest): def create_simple_components(self): "Returns a container with 3 items in it; used by several tests." c1 = Component(bounds=[5.0, 10.0]) c2 = Component(bounds=[6.0, 10.0]) c3 = Component(bounds=[7.0, 10.0]) container = Container(bounds=[100.0, 100.0]) container.add(c1) c1.position = [20, 10] container.add(c2) c2.position = [40, 10] container.add(c3) c3.position = [60, 10] return container def test_add_remove(self): container = self.create_simple_components() self.assert_(len(container.components) == 3) components = container.components container.remove(components[0]) container.remove(components[0]) container.remove(components[0]) self.assert_(len(container.components) == 0) return def test_position(self): container = self.create_simple_components() components = container.components self.assert_(components[0].position == [20,10]) self.assert_(components[1].position == [40,10]) self.assert_(components[2].position == [60,10]) return def test_position_bounds(self): container = Container(bounds=[100.0, 100.0]) self.assert_dims(container, x=0.0, y=0.0, width=100.0, height=100.0) return def test_auto_size(self): container = Container(bounds=[100.0, 100.0]) self.assert_(container.auto_size == False) # Add some components c1 = Component(position=[10.0, 10.0], bounds=[50.0, 60.0]) c2 = Component(position=[15.0, 15.0], bounds=[10.0, 10.0]) container.add(c1) container.add(c2) self.assert_dims(container, x=0.0, y=0.0, width=100.0, height=100.0) # Turn on auto-sizing container.auto_size = True self.assert_dims(container, x=10.0, y=10.0, width=49.0, height=59.0) # Check that the components' positions changed appropriately self.assert_dims(c1, x=0.0, y=0.0) self.assert_dims(c2, x=5.0, y=5.0) # Move the second component c2.position = [100.0, 100.0] self.assert_dims(container, x=10.0, y=10.0, width=109.0, height=109.0) self.assert_dims(c2, x=100.0, y=100.0) # Delete the second component container.remove(c2) self.assert_dims(container, x=10.0, y=10.0, width=49.0, height=59.0) return if __name__ == "__main__": import nose nose.main() # EOF enthought-chaco2-4.5.1.orig/enable/tests/drag_tool_test_case.py0000644000175000017500000000501412516137326023646 0ustar varunvarunimport unittest from traits.api import Int from enable.testing import EnableTestAssistant from enable.tools.drag_tool import DragTool class DummyTool(DragTool): canceled = Int def drag_cancel(self, event): self.canceled += 1 return True class DragToolTestCase(EnableTestAssistant, unittest.TestCase): def setUp(self): self.tool = DummyTool() def test_default_cancel_key(self): tool = self.tool tool._drag_state = 'dragging' # force dragging state event = self.send_key(tool, 'Esc') self.assertEqual(tool.canceled, 1) self.assertTrue(event.handled) def test_multiple_cancel_keys(self): tool = self.tool tool._drag_state = 'dragging' # force dragging state tool.cancel_keys = ['a', 'Left'] event = self.send_key(tool, 'Esc') self.assertEqual(tool.canceled, 0) self.assertFalse(event.handled) tool._drag_state = 'dragging' # force dragging state event = self.send_key(tool, 'a') self.assertEqual(tool.canceled, 1) self.assertTrue(event.handled) tool._drag_state = 'dragging' # force dragging state event = self.send_key(tool, 'Left') self.assertEqual(tool.canceled, 2) self.assertTrue(event.handled) def test_other_key_pressed(self): tool = self.tool tool._drag_state = 'dragging' # force dragging state event = self.send_key(tool, 'Left') self.assertEqual(tool.canceled, 0) self.assertFalse(event.handled) def test_mouse_leave_drag_state(self): # When end_drag_on_leave is true then the drag_cancel is called # and the _drag_state will be 'nondrag' tool = self.tool tool.end_drag_on_leave = True tool._drag_state = 'dragging' # force dragging state event = self.mouse_leave(interactor=tool, x=0, y=0) self.assertEqual(tool.canceled, 1) self.assertEqual(tool._drag_state, 'nondrag') self.assertTrue(event.handled) # When end_drag_on_leave is false then the drag_cancel is not called # (i.e. counter is not increased) and the _drag_state will still # be 'dragging' tool.end_drag_on_leave = False tool._drag_state = 'dragging' # force dragging state event = self.mouse_leave(interactor=tool, x=0, y=0) self.assertEqual(tool.canceled, 1) self.assertEqual(tool._drag_state, 'dragging') self.assertFalse(event.handled) if __name__ == '__main__': unittest.main() enthought-chaco2-4.5.1.orig/enable/drag_resize.py0000644000175000017500000001336412516137326021005 0ustar varunvarun#------------------------------------------------------------------------------- # # Define the classes used to support the Enable package 'drag_resize' # functionality. # # Written by: David C. Morrill # # Date: 02/04/2004 # # (c) Copyright 2004 by Enthought, Inc. # # Classes defined: DragResizeHandler # #------------------------------------------------------------------------------- from base import bounds_to_coordinates, TOP, BOTTOM, LEFT, RIGHT from interactor import Interactor from traits.api import Any #------------------------------------------------------------------------------- # 'DragResizeHandler' class: #------------------------------------------------------------------------------- class DragResizeHandler ( Interactor ): #--------------------------------------------------------------------------- # Trait definitions: #--------------------------------------------------------------------------- # User-supplied drag event validation function: drag_validate = Any #--------------------------------------------------------------------------- # Initialize the object: #--------------------------------------------------------------------------- def init( self, component, bounds_rect, anchor, unconstrain, drag_event, start_event ): self.component = component self.bounds_rect = bounds_rect self.anchor = anchor self.unconstrain = unconstrain self.drag_event = drag_event self.start_event = start_event self.drag_x = self.start_x = start_event.x self.drag_y = self.start_y = start_event.y # Get the coordinates of the anchor point: xl, yb, xr, yt = bounds_to_coordinates( component.bounds ) if (anchor & LEFT) != 0: self.anchor_x = xl self.float_x = xr else: self.anchor_x = xr self.float_x = xl if (anchor & BOTTOM) != 0: self.anchor_y = yb self.float_y = yt else: self.anchor_y = yt self.float_y = yb # Set up the drag termination handler: self.on_trait_change( self.drag_done, drag_event ) #--------------------------------------------------------------------------- # Handle the mouse moving while resizing: #--------------------------------------------------------------------------- def _mouse_move_changed ( self, event ): # Get the current drag location: x = event.x y = event.y # If the mouse did not actually move, then ignore the event: if (x == self.drag_x) and (y == self.drag_y): return # Save the new position: self.drag_x = x self.drag_y = y # Calculate the new 'floating' point: unconstrain = self.unconstrain ax, ay = self.anchor_x, self.anchor_y nx, ny = self.float_x, self.float_y if (unconstrain & (LEFT | RIGHT)) != 0: nx = self.float_x + x - self.start_x if nx > ax: if (unconstrain & RIGHT) == 0: nx = ax elif nx < ax: if (unconstrain & LEFT) == 0: nx = ax if (unconstrain & (TOP | BOTTOM)) != 0: ny = self.float_y + y - self.start_y if ny > ay: if (unconstrain & TOP) == 0: ny = ay elif ny < ay: if (unconstrain & BOTTOM) == 0: ny = ay # Make sure the new point is inside the drag bounds (if required): if self.bounds_rect is not None: bxl, byb, bxr, byt = self.bounds_rect nx = max( min( nx, bxr ), bxl ) ny = max( min( ny, byt ), byb ) # Calculate the new size of the component and make sure that it meets # the min and max size requirements for the component: component = self.component mindx, maxdx = component.min_width, component.max_width mindy, maxdy = component.min_height, component.max_height ndx, ndy = abs( nx - ax ) + 1, abs( ny - ay ) + 1 if ndx > maxdx: if nx > ax: nx = ax + maxdx else: nx = ax - maxdx elif ndx < mindx: if nx < ax: nx = ax - mindx elif (nx > ax) or ((unconstrain & RIGHT) != 0): nx = ax + mindx else: nx = ax - mindx if ndy > maxdy: if ny > ay: ny = ay + maxdy else: ny = ay - maxdy elif ndy < mindy: if ny < ay: ny = ay - mindy elif (ny > ay) or ((unconstrain & TOP) != 0): ny = ay + mindy else: ny = ay - mindy # Update the bounds of the component: bounds = ( min( nx, ax ), min( ny, ay ), abs( nx - ax ) + 1, abs( ny - ay ) + 1 ) if self.drag_validate is not None: bounds = self.drag_validate( event, bounds ) if bounds != component.bounds: component.bounds = bounds # Tell the 'paint' routine we are doing a drag resize operation: event.window.drag_resize_update() #--------------------------------------------------------------------------- # Handle the user releasing the original drag button: #--------------------------------------------------------------------------- def drag_done ( self, event ): # 'Unhook' the drag done notification handler: self.on_trait_change( self.drag_done, self.drag_event, remove = True ) # Inform the component that the resize operation is complete: self.component.resized = True enthought-chaco2-4.5.1.orig/enable/scrolled.py0000644000175000017500000005206412516137326020316 0ustar varunvarun from __future__ import with_statement # Enthought library imports from traits.api import Bool, Instance, Int, Any, Float # Local, relative imports from base import intersect_bounds, empty_rectangle from colors import ColorTrait from component import Component from container import Container from viewport import Viewport from native_scrollbar import NativeScrollBar class Scrolled(Container): """ A Scrolled acts like a viewport with scrollbars for positioning the view position. Rather than subclassing from viewport, it delegates to one. """ # The component that we are viewing component = Instance(Component) # The viewport onto our component viewport_component = Instance(Viewport) # Inside padding is a background drawn area between the edges or scrollbars # and the scrolled area/left component. inside_padding_width = Int(5) # The inside border is a border drawn on the inner edge of the inside # padding area to highlight the viewport. inside_border_color = ColorTrait("black") inside_border_width = Int(0) # The background color to use for filling in the padding area. bgcolor = ColorTrait("white") # Should the horizontal scrollbar be shown? horiz_scrollbar = Bool(True) # Should the vertical scrollbar be shown? vert_scrollbar = Bool(True) # Should the scrollbars always be shown? always_show_sb = Bool(False) # Should the mouse wheel scroll the viewport? mousewheel_scroll = Bool(True) # Should the viewport update continuously as the scrollbar is dragged, # or only when drag terminates (i.e. the user releases the mouse button) continuous_drag_update = Bool(True) # Override the default value of this inherited trait auto_size = False #--------------------------------------------------------------------------- # Traits for support of geophysics plotting #--------------------------------------------------------------------------- # An alternate vertical scroll bar to control this Scrolled, instead of the # default one that lives outside the scrolled region. alternate_vsb = Instance(Component) # The size of the left border space leftborder = Float(0) # A component to lay out to the left of the viewport area (e.g. a depth # scale track) leftcomponent = Any #--------------------------------------------------------------------------- # Private traits #--------------------------------------------------------------------------- _vsb = Instance(NativeScrollBar) _hsb = Instance(NativeScrollBar) # Stores the last horizontal and vertical scroll positions to avoid # multiple updates in update_from_viewport() _last_hsb_pos = Float(0.0) _last_vsb_pos = Float(0.0) # Whether or not the viewport region is "locked" from updating via # freeze_scroll_bounds() _sb_bounds_frozen = Bool(False) # Records if the horizontal scroll position has been updated while the # Scrolled has been frozen _hscroll_position_updated = Bool(False) # Records if the vertical scroll position has been updated while the # Scrolled has been frozen _vscroll_position_updated = Bool(False) # Whether or not to the scroll bars should cause an event # update to fire on the viewport's view_position. This is used to # prevent redundant events when update_from_viewport() updates the # scrollbar position. _hsb_generates_events = Bool(True) _vsb_generates_events = Bool(True) #--------------------------------------------------------------------------- # Scrolled interface #--------------------------------------------------------------------------- def __init__(self, component, **traits): self.component = component Container.__init__( self, **traits ) self._viewport_component_changed() return def update_bounds(self): self._layout_needed = True if self._hsb is not None: self._hsb._widget_moved = True if self._vsb is not None: self._vsb._widget_moved = True return def sb_height(self): """ Returns the standard scroll bar height """ # Perhaps a placeholder -- not sure if there's a way to get the standard # width or height of a wx scrollbar -- you can set them to whatever you want. return 15 def sb_width(self): """ Returns the standard scroll bar width """ return 15 def freeze_scroll_bounds(self): """ Prevents the scroll bounds on the scrollbar from updating until unfreeze_scroll_bounds() is called. This is useful on components with view-dependent bounds; when the user is interacting with the scrollbar or the viewport, this prevents the scrollbar from resizing underneath them. """ if not self.continuous_drag_update: self._sb_bounds_frozen = True def unfreeze_scroll_bounds(self): """ Allows the scroll bounds to be updated by various trait changes. See freeze_scroll_bounds(). """ self._sb_bounds_frozen = False if self._hscroll_position_updated: self._handle_horizontal_scroll(self._hsb.scroll_position) self._hscroll_position_updated = False if self._vscroll_position_updated: self._handle_vertical_scroll(self._vsb.scroll_position) self._vscroll_position_updated = False self.update_from_viewport() self.request_redraw() #--------------------------------------------------------------------------- # Trait event handlers #--------------------------------------------------------------------------- def _compute_ranges(self): """ Returns the range_x and range_y tuples based on our component and our viewport_component's bounds. """ comp = self.component viewport = self.viewport_component offset = getattr(comp, "bounds_offset", (0,0)) ranges = [] for ndx in (0,1): scrollrange = float(comp.bounds[ndx] - viewport.view_bounds[ndx]) if round(scrollrange/20.0) > 0.0: ticksize = scrollrange/round(scrollrange/20.0) else: ticksize = 1 ranges.append( (offset[ndx], offset[ndx] + comp.bounds[ndx], viewport.view_bounds[ndx], ticksize) ) return ranges def update_from_viewport(self): """ Repositions the scrollbars based on the current position/bounds of viewport_component. """ if self._sb_bounds_frozen: return x, y = self.viewport_component.view_position range_x, range_y = self._compute_ranges() modify_hsb = (self._hsb and x != self._last_hsb_pos) modify_vsb = (self._vsb and y != self._last_vsb_pos) if modify_hsb and modify_vsb: self._hsb_generates_events = False else: self._hsb_generates_events = True if modify_hsb: self._hsb.range = range_x self._hsb.scroll_position = x self._last_hsb_pos = x if modify_vsb: self._vsb.range = range_y self._vsb.scroll_position = y self._last_vsb_pos = y if not self._hsb_generates_events: self._hsb_generates_events = True return def _layout_and_draw(self): self._layout_needed = True self.request_redraw() def _component_position_changed(self, component): self._layout_needed = True return def _bounds_changed_for_component(self): self._layout_needed = True self.update_from_viewport() self.request_redraw() return def _bounds_items_changed_for_component(self): self.update_from_viewport() return def _position_changed_for_component(self): self.update_from_viewport() return def _position_items_changed_for_component(self): self.update_from_viewport() return def _view_bounds_changed_for_viewport_component(self): self.update_from_viewport() return def _view_bounds_items_changed_for_viewport_component(self): self.update_from_viewport() return def _view_position_changed_for_viewport_component(self): self.update_from_viewport() return def _view_position_items_changed_for_viewport_component(self): self.update_from_viewport() return def _component_bounds_items_handler(self, object, new): if new.added != new.removed: self.update_bounds() def _component_bounds_handler(self, object, name, old, new): if old == None or new == None or old[0] != new[0] or old[1] != new[1]: self.update_bounds() return def _component_changed ( self, old, new ): if old is not None: old.on_trait_change(self._component_bounds_handler, 'bounds', remove=True) old.on_trait_change(self._component_bounds_items_handler, 'bounds_items', remove=True) if new is None: self.component = Container() else: if self.viewport_component: self.viewport_component.component = new new.container = self new.on_trait_change(self._component_bounds_handler, 'bounds') new.on_trait_change(self._component_bounds_items_handler, 'bounds_items') self._layout_needed = True return def _bgcolor_changed ( self ): self._layout_and_draw() def _inside_border_color_changed ( self ): self._layout_and_draw() def _inside_border_width_changed ( self ): self._layout_and_draw() def _inside_padding_width_changed(self): self._layout_needed = True self.request_redraw() def _viewport_component_changed(self): if self.viewport_component is None: self.viewport_component = Viewport() self.viewport_component.component = self.component self.viewport_component.view_position = [0,0] self.viewport_component.view_bounds = self.bounds self.add(self.viewport_component) def _alternate_vsb_changed(self, old, new): self._component_update(old, new) return def _leftcomponent_changed(self, old, new): self._component_update(old, new) return def _component_update(self, old, new): """ Generic function to manage adding and removing components """ if old is not None: self.remove(old) if new is not None: self.add(new) return def _bounds_changed ( self, old, new ): Component._bounds_changed( self, old, new ) self.update_bounds() return def _bounds_items_changed(self, event): Component._bounds_items_changed(self, event) self.update_bounds() return #--------------------------------------------------------------------------- # Protected methods #--------------------------------------------------------------------------- def _do_layout ( self ): """ This is explicitly called by _draw(). """ self.viewport_component.do_layout() # Window is composed of border + scrollbar + canvas in each direction. # To compute the overall geometry, first calculate whether component.x # + the border fits in the x size of the window. # If not, add sb, and decrease the y size of the window by the height of # the scrollbar. # Now, check whether component.y + the border is greater than the remaining # y size of the window. If it is not, add a scrollbar and decrease the x size # of the window by the scrollbar width, and perform the first check again. if not self._layout_needed: return padding = self.inside_padding_width scrl_x_size, scrl_y_size = self.bounds cont_x_size, cont_y_size = self.component.bounds # available_x and available_y are the currently available size for the # viewport available_x = scrl_x_size - 2*padding - self.leftborder available_y = scrl_y_size - 2*padding # Figure out which scrollbars we will need need_x_scrollbar = self.horiz_scrollbar and \ ((available_x < cont_x_size) or self.always_show_sb) need_y_scrollbar = (self.vert_scrollbar and \ ((available_y < cont_y_size) or self.always_show_sb)) or \ self.alternate_vsb if need_x_scrollbar: available_y -= self.sb_height() if need_y_scrollbar: available_x -= self.sb_width() if (available_x < cont_x_size) and \ (not need_x_scrollbar) and self.horiz_scrollbar: available_y -= self.sb_height() need_x_scrollbar = True # Put the viewport in the right position self.viewport_component.outer_bounds = [available_x, available_y] container_y_pos = padding if need_x_scrollbar: container_y_pos += self.sb_height() self.viewport_component.outer_position = [padding + self.leftborder, container_y_pos] range_x, range_y = self._compute_ranges() # Create, destroy, or set the attributes of the horizontal scrollbar if need_x_scrollbar: bounds = [available_x, self.sb_height()] hsb_position = [padding + self.leftborder, 0] if not self._hsb: self._hsb = NativeScrollBar(orientation = 'horizontal', bounds=bounds, position=hsb_position, range=range_x, enabled=False, ) self._hsb.on_trait_change(self._handle_horizontal_scroll, 'scroll_position') self._hsb.on_trait_change(self._mouse_thumb_changed, 'mouse_thumb') self.add(self._hsb) else: self._hsb.range = range_x self._hsb.bounds = bounds self._hsb.position = hsb_position elif self._hsb is not None: self._hsb = self._release_sb(self._hsb) if not hasattr(self.component, "bounds_offset"): self.viewport_component.view_position[0] = 0 else: # We don't need to render the horizontal scrollbar, and we don't # have one to update, either. pass # Create, destroy, or set the attributes of the vertical scrollbar if self.alternate_vsb: self.alternate_vsb.bounds = [self.sb_width(), available_y] self.alternate_vsb.position = [2*padding + available_x + self.leftborder, container_y_pos] if need_y_scrollbar and (not self.alternate_vsb): bounds = [self.sb_width(), available_y] vsb_position = [2*padding + available_x + self.leftborder, container_y_pos] if not self._vsb: self._vsb = NativeScrollBar(orientation = 'vertical', bounds=bounds, position=vsb_position, range=range_y ) self._vsb.on_trait_change(self._handle_vertical_scroll, 'scroll_position') self._vsb.on_trait_change(self._mouse_thumb_changed, 'mouse_thumb') self.add(self._vsb) else: self._vsb.bounds = bounds self._vsb.position = vsb_position self._vsb.range = range_y elif self._vsb: self._vsb = self._release_sb(self._vsb) if not hasattr(self.component, "bounds_offset"): self.viewport_component.view_position[1] = 0 else: # We don't need to render the vertical scrollbar, and we don't # have one to update, either. pass self._layout_needed = False return def _release_sb ( self, sb ): if sb is not None: if sb == self._vsb: sb.on_trait_change( self._handle_vertical_scroll, 'scroll_position', remove = True ) if sb == self._hsb: sb.on_trait_change(self._handle_horizontal_scroll, 'scroll_position', remove=True) self.remove(sb) # We shouldn't have to do this, but I'm not sure why the object # isn't getting garbage collected. # It must be held by another object, but which one? sb.destroy() return None def _handle_horizontal_scroll(self, position): if self._sb_bounds_frozen: self._hscroll_position_updated = True return c = self.component viewport = self.viewport_component offsetx = getattr(c, "bounds_offset", [0,0])[0] if (position + viewport.view_bounds[0] <= c.bounds[0] + offsetx): if self._hsb_generates_events: viewport.view_position[0] = position else: viewport.set(view_position=[position, viewport.view_position[1]], trait_change_notify=False) return def _handle_vertical_scroll(self, position): if self._sb_bounds_frozen: self._vscroll_position_updated = True return c = self.component viewport = self.viewport_component offsety = getattr(c, "bounds_offset", [0,0])[1] if (position + viewport.view_bounds[1] <= c.bounds[1] + offsety): if self._vsb_generates_events: viewport.view_position[1] = position else: viewport.set(view_position=[viewport.view_position[0], position], trait_change_notify=False) return def _mouse_thumb_changed(self, object, attrname, event): if event == "down" and not self.continuous_drag_update: self.freeze_scroll_bounds() else: self.unfreeze_scroll_bounds() def _draw(self, gc, view_bounds=None, mode="default"): if self.layout_needed: self._do_layout() with gc: self._draw_container(gc, mode) self._draw_inside_border(gc, view_bounds, mode) dx, dy = self.bounds x,y = self.position if view_bounds: tmp = intersect_bounds((x,y,dx,dy), view_bounds) if (tmp is empty_rectangle): new_bounds = tmp else: new_bounds = (tmp[0]-x, tmp[1]-y, tmp[2], tmp[3]) else: new_bounds = view_bounds if new_bounds is not empty_rectangle: for component in self.components: if component is not None: with gc: gc.translate_ctm(*self.position) component.draw(gc, new_bounds, mode) def _draw_inside_border(self, gc, view_bounds=None, mode="default"): width_adjustment = self.inside_border_width/2 left_edge = self.x+1 + self.inside_padding_width - width_adjustment right_edge = self.x + self.viewport_component.x2+2 + width_adjustment bottom_edge = self.viewport_component.y+1 - width_adjustment top_edge = self.viewport_component.y2 + width_adjustment with gc: gc.set_stroke_color(self.inside_border_color_) gc.set_line_width(self.inside_border_width) gc.rect(left_edge, bottom_edge, right_edge-left_edge, top_edge-bottom_edge) gc.stroke_path() #--------------------------------------------------------------------------- # Mouse event handlers #--------------------------------------------------------------------------- def _container_handle_mouse_event(self, event, suffix): """ Implement a container-level dispatch hook that intercepts mousewheel events. (Without this, our components would automatically get handed the event.) """ if self.mousewheel_scroll and suffix == "mouse_wheel": if self.alternate_vsb: self.alternate_vsb._mouse_wheel_changed(event) elif self._vsb: self._vsb._mouse_wheel_changed(event) event.handled = True return #--------------------------------------------------------------------------- # Persistence #--------------------------------------------------------------------------- def __getstate__(self): state = super(Scrolled,self).__getstate__() for key in ['alternate_vsb', '_vsb', '_hsb', ]: if state.has_key(key): del state[key] return state ### EOF enthought-chaco2-4.5.1.orig/enable/pyglet_backend/0000755000175000017500000000000012516137725021104 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable/pyglet_backend/pyglet_app.py0000644000175000017500000000104312516137326023615 0ustar varunvarun""" In other backends, we expect the UI toolkit to have a main loop running external to Enable. As of Pyglet 1.1, a new Pyglet App object was introduced which handles running a main loop and efficiently dispatching to windows and event handlers, so the former Enable PygletApp object is no longer needed, and this file is just a stub for backwards compatibility. """ import pyglet __all__ = ["get_app", "PygletApp"] def get_app(): """ Returns a reference to the current running Pyglet App """ return pyglet.app PygletApp = pyglet.app enthought-chaco2-4.5.1.orig/enable/pyglet_backend/__init__.py0000644000175000017500000000000012516137326023200 0ustar varunvarunenthought-chaco2-4.5.1.orig/enable/pyglet_backend/api.py0000644000175000017500000000015512516137326022225 0ustar varunvarun from window import Window # from scrollbar import NativeScrollBar class NativeScrollBar(object): pass enthought-chaco2-4.5.1.orig/enable/pyglet_backend/window.py0000644000175000017500000004712712516137326022775 0ustar varunvarun""" Defines the concrete top-level Enable 'Window' class for the Pyglet framework. Uses the Kiva GL backend. """ import warnings # Pyglet imports import pyglet from pyglet import gl, window from pyglet.window import key # Enthought library imports from traits.api import Any, Bool # Enable imports from enable.events import MouseEvent, KeyEvent from enable.graphics_context import GraphicsContextEnable from enable.abstract_window import AbstractWindow # local, relative imports from constants import ASCII_CONTROL_KEYS, KEY_MAP, \ POINTER_MAP, TEXT_KEYS class PygletMouseEvent(object): """ Because Pyglet doesn't have a native mouse event object, we use this to encapsulate all the possible state when we receive any mouse- related event. """ def __init__(self, x, y, dx=0, dy=0, buttons=0, modifiers=None, scroll_x=0, scroll_y=0): """ **buttons** is a list of buttons """ self.x = x self.y = y self.dx = dx self.dy = dy self.modifiers = modifiers self.buttons = buttons self.scroll_x = scroll_x self.scroll_y = scroll_y if modifiers is not None: self.shift_pressed = bool(modifiers & key.MOD_SHIFT) self.ctrl_pressed = bool(modifiers & key.MOD_CTRL) self.alt_pressed = bool(modifiers & key.MOD_ALT) else: self.shift_pressed = self.ctrl_pressed = self.alt_pressed = False return class PygletWindow(window.Window): """ Mix-in class that, when combined with a Pyglet event dispatcher of some sort, will allow pyglet events to propagate down to Enable. The target class should have an attribute named **enable_window** that is a reference to the instance of a subclass of AbstractWindow. """ VALID_CTOR_KWARGS = ("width", "height", "caption", "resizable", "style", "fullscreen", "visible", "vsync", "display", "screen", "config", "context") def __init__(self, enable_window, **kwargs): """ PygletWindow needs a reference to the Enable window; other arguments are passed through directly to the pyglet.Window constructor. """ self.enable_window = enable_window # This indicates whether or not we should call the Enable window to # draw. If this flag is False, then the draw() method just passes. self._dirty = True #for key in kwargs: # if key not in PygletWindow.VALID_CTOR_KWARGS: # kwargs.pop(key) super(PygletWindow, self).__init__(**kwargs) # use a KeyStateHandler to remember the keyboard state. This # is useful since Pyglet separates the notion of keyboard state # and character events, and we need to access keyboard state # from the on_text handler method. self.key_state = key.KeyStateHandler() self.push_handlers(self.key_state) #------------------------------------------------------------------------- # Public methods # These are not inherited from/part of the pyglet.window.Window interface #------------------------------------------------------------------------- def on_draw(self): "Called by the mainloop to perform the actual draw" if self._dirty: self.enable_window._paint() self._dirty = False def request_redraw(self, coordinates=None): """ Called by **self.enable_window** to request a redraw **coordinates** is a tuple (x,y,w,h) of a specific sub-region to redraw. """ # TODO: Support the **coordinates** argument, perhaps using a direct # call to glScissor() self._dirty = True #------------------------------------------------------------------------- # Key/text handling #------------------------------------------------------------------------- def on_key_press(self, symbol, modifiers): # use the bare tuple as the event return self._on_key_pressed((symbol, modifiers)) def on_key_release(self, symbol, modifiers): return self._on_key_released((symbol, modifiers)) def on_text(self, text): self._on_character(text) def _create_key_event(self, event_type, event): if self.enable_window.focus_owner is None: focus_owner = self.enable_window.component else: focus_owner = self.enable_window.focus_owner if focus_owner is None: return if event_type == 'character': key = event if not key: return None else: key_code = event[0] if key_code in KEY_MAP: key = KEY_MAP.get(key_code) else: key = key_code return KeyEvent( event_type = event_type, character = key, alt_down = keys[key.LALT] | keys[key.RALT], control_down = keys[key.LCTRL] | keys[key.RCTRL], shift_down = keys[key.LSHIFT] | keys[key.RSHIFT], x = self._mouse_x, y = self._mouse_y, window = self.enable_window) def on_text_motion(self, motion): # TODO: See notes. pass def on_text_motion_select(self, motion): # TODO: See notes. pass #------------------------------------------------------------------------- # Mouse handling #------------------------------------------------------------------------- def on_mouse_motion(self, x, y, dx, dy): event = PygletMouseEvent(x, y, dx, dy) self.enable_window._handle_mouse_event("mouse_move", event, set_focus=False) def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers): # TODO: Determine the difference between this and on_mouse_motion; # confirm that the correct buttons in **buttons** are down. event = PygletMouseEvent(x, y, dx, dy, buttons=buttons, modifiers=modifiers) self.enable_window._handle_mouse_event("mouse_move", event, set_focus=False) def on_mouse_press(self, x, y, button, modifiers): return self._on_mouse_updown(x, y, button, modifiers, "down") def on_mouse_release(self, x, y, button, modifiers): return self._on_mouse_updown(x, y, button, modifiers, "up") def _on_mouse_updown(self, x, y, button, modifiers, which="down"): event = PygletMouseEvent(x, y, buttons=button, modifiers=modifiers) mouse = pyglet.window.mouse if button == mouse.LEFT: name = "left" elif button == mouse.MIDDLE: name = "middle" elif button == mouse.RIGHT: name = "right" else: raise RuntimeError("Unknown mouse button state in _on_mouse_updown()") self.enable_window._handle_mouse_event(name+"_"+which, event, set_focus=False) # TODO: Confirm that we should consume mouse press/release events return True def on_mouse_scroll(self, x, y, scroll_x, scroll_y): # TODO: Handle scroll_x event = PygletMouseEvent(x, y, scroll_x=scroll_x, scroll_y=scroll_y) self.enable_window._handle_mouse_event("mouse_wheel", event, set_focus=False) def on_mouse_enter(self, x, y): event = PygletMouseEvent(x, y) self.enable_window._handle_mouse_event("mouse_enter", event, set_focus=False) def on_mouse_leave(self, x, y): event = PygletMouseEvent(x, y) self.enable_window._handle_mouse_event("mouse_leave", event, set_focus=False) #------------------------------------------------------------------------- # Window #------------------------------------------------------------------------- def on_resize(self, width, height): self._dirty = True self.enable_window.resized = (width, height) def on_close(self): pass def on_expose(self): pass def on_move(self, x, y): """The window was moved. x is the distance from the left edge of the screen to the left edge of the window. y is the distance from the top edge of the screen to the top edge of the window. """ pass def on_activate(self): """ The window was activated. """ self._dirty = True def on_deactivate(self): """ The window lost focus. """ pass def on_show(self): """ The window was shown. """ self._dirty = True def on_hide(self): """ The window was minimized or hidden. """ pass #------------------------------------------------------------------------- # GL context stuff - see the pyglet.window.Window documentation on these # methods #------------------------------------------------------------------------- def on_context_lost(self): pass def on_context_state_lost(self): pass class Window(AbstractWindow): # If this is True, then the screen is configured for full-screen # antialiasing. This can be noticeably slower, however. enable_antialias = Bool(True) _cursor_color = Any # PZW: figure out the correct type for this... # This is set by downstream components to notify us of whether or not # the current drag operation should return DragCopy, DragMove, or DragNone. _drag_result = Any def __init__(self, parent=None, id=-1, pos=None, size=None, config=None, fullscreen=False, resizable=True, vsync=True, **traits): """ **parent** is an unneeded argument with the pyglet backend, but we need to preserve compatibility with other AbstractWindow subclasses. """ # TODO: Fix fact that other backends' Window classes use positional # arguments self.control = None AbstractWindow.__init__(self, **traits) self._mouse_captured = False # Due to wx wonkiness, we don't reliably get cursor position from # a wx KeyEvent. Thus, we manually keep track of when we last saw # the mouse and use that information instead. These coordinates are # in the wx coordinate space, i.e. pre-self._flip_y(). self._last_mouse_pos = (0, 0) # Try to get antialiasing, both for quality rendering and for # reproducible results. For example, line widths are measured in the # X or Y directions rather than perpendicular to the line unless if # antialiasing is enabled. display = window.get_platform().get_default_display() screen = display.get_default_screen() if config is None: if self.enable_antialias: template_config = gl.Config(double_buffer=True, sample_buffers=True, samples=4) else: template_config = gl.Config(double_buffer=False) try: config = screen.get_best_config(template_config) except window.NoSuchConfigException: # Rats. No antialiasing. config = screen.get_best_config(gl.Config(double_buffer=True)) # Create the underlying control. kwds = dict(config=config, fullscreen=fullscreen, resizable=resizable, vsync=vsync) if size is not None and not fullscreen: kwds['width'], kwds['height'] = size self.control = PygletWindow(enable_window=self, **kwds) if pos is not None: self.control.set_location(*pos) return def _flip_y(self, y): """ Convert from a Kiva to a Pyglet y-coordinate. Since pyglet uses the same convention as Kiva, this is a no-op. """ return y def _on_erase_background(self, event): pass def _resized_changed(self, event): self._size = (self.control.width, self.control.height) width, height = self._size component = self.component if hasattr(component, "fit_window") and component.fit_window: component.outer_position = [0,0] component.outer_bounds = [width, height] elif hasattr(component, "resizable"): if "h" in component.resizable: component.outer_x = 0 component.outer_width = width if "v" in component.resizable: component.outer_y = 0 component.outer_height = height return def _capture_mouse(self): "Capture all future mouse events" # TODO: Figure out how to do mouse capture. # Pyglet's Window class has a set_mouse_exclusive() mode, but this # makes the cursur invisible as well. It really is more of a # full-screen "Game Mode", and not designed for mouse capture in a # traditional GUI toolkit sense. #if not self._mouse_captured: # self.control.set_mouse_exclusive(True) # self._mouse_captured = True pass def _release_mouse(self): "Release the mouse capture" #if self._mouse_captured: # self._mouse_captured = False # self.control.set_mouse_exclusive(False) pass def _create_mouse_event(self, event): """ Convert a Pyglet mouse event into an Enable MouseEvent. Since Pyglet doesn't actually have a mouse event object like WX or Qt, PygletWindow actually does most of the work of creating an Enable MouseEvent when various things happen, and calls AbstractWindow._handle_mouse_event with that object. _handle_mouse_event() then calls this method with that object. AbstractWindow._on_window_leave() also calls this method. """ if event is not None: x = event.x y = event.y self._last_mouse_pos = (x, y) mouse = pyglet.window.mouse buttons = event.buttons if buttons is None: buttons = 0 return MouseEvent( x = x, y = y, alt_down = event.alt_pressed, control_down = event.ctrl_pressed, shift_down = event.shift_pressed, left_down = bool(mouse.LEFT & buttons), middle_down = bool(mouse.MIDDLE & buttons), right_down = bool(mouse.RIGHT & buttons), mouse_wheel = event.scroll_y, window = self) else: # If no event specified, make one up: x = self.control._mouse_x y = self.control._mouse_y self._last_mouse_pos = (x, y) return MouseEvent( x = x, y = y, alt_down = event.alt_pressed, control_down = event.ctrl_pressed, shift_down = event.shift_pressed, left_down = False, middle_down = False, right_down = False, mouse_wheel = 0, window = self) def _create_gc(self, size, pix_format = "rgba32"): "Create a Kiva graphics context of a specified size." # Unlike the vector-based Agg and Quartz GraphicsContexts which place # pixel coordinates at the lower-left corner, the Pyglet backend is # raster-based and places coordinates at the center of pixels. gc = GraphicsContextEnable((size[0]+1, size[1]+1), window=self) gc.translate_ctm(0.5, 0.5) gc.gl_init() return gc def _init_gc(self): #gc = self._gc #gc.gl_init() pass def _redraw(self, coordinates=None): "Request a redraw of the window" if self.control is not None: self.control.request_redraw(coordinates) def _get_control_size(self): "Get the size of the underlying toolkit control" if self.control is not None: return (self.control.width, self.control.height) else: return None def set_pointer(self, pointer): "Set the current pointer (i.e. cursor) shape" if pointer == "blank": self.control.set_mouse_visible(False) elif pointer in POINTER_MAP: self.control.set_mouse_visible(True) cursor = self.control.get_system_mouse_cursor(POINTER_MAP[pointer]) self.control.set_mouse_cursor(cursor) else: warnings.warn("Unable to set mouse pointer '%s' in" "Enable's Pyglet backend." % pointer) cursor = self.control.get_system_mouse_cursor(POINTER_MAP["arrow"]) self.control.set_mouse_cursor(cursor) return def set_timer_interval(self, component, interval): """ Set up or cancel a timer for a specified component. To cancel the timer, set interval=None. """ raise NotImplementedError("set_timer_interval() not implemented yet in Pyglet backend.") def _set_focus(self): """ Sets the keyboard focus to this window. Since Pyglet is not a windowing system, there are not other windows we might lose focus to; the entire application has focus or it doesn't. This attempts to make the application regain focus. """ self.control.activate() #------------------------------------------------------------------------- # Unnecessary methods but provided for compatibility #------------------------------------------------------------------------- def _paint(self, event=None): # Override the base class _paint() method because we need to call # _create_gc() each time *before* self.component draws. size = self._get_control_size() self._size = tuple(size) self._gc = self._create_gc(size) self.control.clear() gc = self._gc if hasattr(self.component, "do_layout"): self.component.do_layout() gc.clear(self.bgcolor_) self.component.draw(gc, view_bounds=(0, 0, size[0], size[1])) self._update_region = [] #self.control.flip() return def _window_paint(self, event): "Do a backend-specific screen update" # We don't actually have to do anything here, and our implementation # of _paint() doesn't even call this method. # # In other backends where the self.component.draw(gc) call just renders # onto an in-screen GraphicsContext, this method is used to do a # platform-specific blit. In the case of Pyglet, the component.draw() # method executes immediately on the current OpenGL context, so there # is no additional step needed here. pass def screen_to_window(self, x, y): """ Convert screen coordinates with the origin at the upper-left-hand corner to local pyglet window coordinates. """ x0, y0 = self.control.get_location() x -= x0 y -= y0 y = self.control.height - y return (x,y) #------------------------------------------------------------------------- # Unimplemented or unimplementable methods in Pyglet # (These are mostly due to the fact that it is an access layer to GL and # not a full GUI toolkit.) #------------------------------------------------------------------------- def set_tooltip(self, tooltip): "Set the current tooltip for the window" raise NotImplementedError("No equivalent for set_tooltip() in Pyglet.") def create_menu(self, menu_definition, owner): "Create a Menu from a string description" raise NotImplementedError("create_menu() is not implemented in Pyglet backend.") def popup_menu(self, menu, x, y): "Pop-up a Menu at a specified location" raise NotImplementedError("popup_menu() is not implemented in Pyglet backend.") enthought-chaco2-4.5.1.orig/enable/pyglet_backend/constants.py0000644000175000017500000001077612516137326023502 0ustar varunvarun from pyglet.window import BaseWindow as win from pyglet.window import key from pyglet.window import mouse BUTTON_NAME_MAP = { mouse.LEFT : "Left", mouse.RIGHT : "Right", mouse.MIDDLE : "Middle", } POINTER_MAP = { "arrow" : win.CURSOR_DEFAULT, "arrow wait" : win.CURSOR_WAIT, "char" : win.CURSOR_TEXT, "cross" : win.CURSOR_CROSSHAIR, "hand" : win.CURSOR_HAND, "ibeam" : win.CURSOR_TEXT, "no entry" : win.CURSOR_NO, "question arrow" : win.CURSOR_HELP, # The following directions are not reversed; they have different # meanings between Enable and Pyglet. Enable's 'left' and 'right' # designation refer to which border is being sized, whereas Pyglet's # means which direction the arrow points. "size top" : win.CURSOR_SIZE_DOWN, "size bottom" : win.CURSOR_SIZE_UP, "size left" : win.CURSOR_SIZE_RIGHT, "size right" : win.CURSOR_SIZE_LEFT, "size top right" : win.CURSOR_SIZE_DOWN, "size bottom left" : win.CURSOR_SIZE_DOWN, "size top left" : win.CURSOR_SIZE_DOWN, "size bottom right" : win.CURSOR_SIZE_DOWN, "sizing" : win.CURSOR_SIZE, "wait" : win.CURSOR_WAIT, "watch" : win.CURSOR_WAIT, "arrow wait" : win.CURSOR_WAIT_ARROW, # No good translation for these; we'll have to trap them # in set_pointer() or use a custom image. "bullseye" : win.CURSOR_DEFAULT, "left button" : win.CURSOR_DEFAULT, "middle button" : win.CURSOR_DEFAULT, "right button" : win.CURSOR_DEFAULT, "magnifier" : win.CURSOR_DEFAULT, "paint brush" : win.CURSOR_DEFAULT, "pencil" : win.CURSOR_DEFAULT, "point left" : win.CURSOR_DEFAULT, "point right" : win.CURSOR_DEFAULT, "spray can" : win.CURSOR_DEFAULT, } # Since Pyglet has both on_key_press and on_text events, and it's not # entirely clear if certain keys generate both events, we maintain an # empirical list of keys in the KEY_MAP that also generate on_text # events. (Generally, entries in the KEY_MAP are used to map unprintable # or control characters, so by default we would expect them not to # generate on_text events.) TEXT_KEYS = ( key.RETURN, key.ENTER, key.NUM_0, key.NUM_1, key.NUM_2, key.NUM_3, key.NUM_4, key.NUM_5, key.NUM_6, key.NUM_7, key.NUM_8, key.NUM_9, key.NUM_DECIMAL, key.NUM_ADD, key.NUM_MULTIPLY, key.NUM_SUBTRACT, key.NUM_DIVIDE, ) ASCII_CONTROL_KEYS = { 8: "Backspace", 9: "Tab", 13: "Enter", 27: "Esc", } KEY_MAP = { key.BACKSPACE : "Backspace", key.TAB : "Tab", key.RETURN : "Enter", key.ESCAPE : "Esc", key.DELETE : "Delete", key.ENTER : "Enter", key.PAUSE : "Pause", key.NUMLOCK : "Num Lock", key.SCROLLLOCK : "Scroll Lock", key.MINUS : "Subtract", key.LEFT : "Left", key.RIGHT : "Right", key.UP : "Up", key.DOWN : "Down", key.HOME : "Home", key.END : "End", key.PAGEUP : "Page Up", key.PAGEDOWN : "Page Down", key.EXECUTE : "Execute", key.PRINT : "Print", key.SELECT : "Select", key.INSERT : "Insert", key.CANCEL : "Cancel", key.BREAK : "Break", key.HELP : "Help", key.NUM_0 : "Numpad 0", key.NUM_1 : "Numpad 1", key.NUM_2 : "Numpad 2", key.NUM_3 : "Numpad 3", key.NUM_4 : "Numpad 4", key.NUM_5 : "Numpad 5", key.NUM_6 : "Numpad 6", key.NUM_7 : "Numpad 7", key.NUM_8 : "Numpad 8", key.NUM_9 : "Numpad 9", key.NUM_DOWN : "Down", key.NUM_UP : "Up", key.NUM_LEFT : "Left", key.NUM_RIGHT : "Right", key.NUM_HOME : "Home", key.NUM_END : "End", key.NUM_PAGE_UP : "Page Up", key.NUM_PAGE_DOWN : "Page Down", key.NUM_ENTER : "Enter", key.NUM_INSERT : "Insert", key.NUM_DELETE : "Delete", key.NUM_DECIMAL : ".", key.NUM_ADD : "+", key.NUM_MULTIPLY : "*", key.NUM_SUBTRACT : "-", key.NUM_DIVIDE : "/", key.LSHIFT : "Shift", key.RSHIFT : "Shift", key.LCTRL : "Control", key.RCTRL : "Control", key.LMETA : "Meta", key.RMETA : "Meta", key.LALT : "Alt", key.RALT : "Alt", key.LWINDOWS : "Windows", key.RWINDOWS : "Windows", key.LCOMMAND : "Command", key.RCOMMAND : "Command", key.LOPTION : "Option", key.ROPTION : "Option", key.F1 : "F1", key.F2 : "F2", key.F3 : "F3", key.F4 : "F4", key.F5 : "F5", key.F6 : "F6", key.F7 : "F7", key.F8 : "F8", key.F9 : "F9", key.F10 : "F10", key.F11 : "F11", key.F12 : "F12", key.F13 : "F13", key.F14 : "F14", key.F15 : "F15", key.F16 : "F16", } enthought-chaco2-4.5.1.orig/enable/toolkit_constants.py0000644000175000017500000000450312516137326022263 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2011, Enthought, Inc. # All rights reserved. # # This software is provided without warranty under the terms of the BSD # license included in enthought/LICENSE.txt and may be redistributed only # under the conditions described in the aforementioned license. The license # is also available online at http://www.enthought.com/licenses/BSD.txt # Thanks for using Enthought open source! #------------------------------------------------------------------------------ """ Pointer and Key names for enable. Note that when these lists change, corresponding lists in each of the toolkit backends need to be changed as well. A warning will be printed when the enable.window module is imported if the current toolkit's mapping is a different length than a list given here. """ # Mouse pointer names pointer_names = [ 'arrow', 'arrow wait', 'blank', 'bullseye', 'char', 'cross', 'hand', 'ibeam', 'left button', 'magnifier', 'middle button', 'no entry', 'paint brush', 'pencil', 'point left', 'point right', 'question arrow', 'right arrow', 'right button', 'size bottom', 'size bottom left', 'size bottom right', 'size left', 'size right', 'size top', 'size top left', 'size top right', 'sizing', 'spray can', 'wait', 'watch', ] # Keyboard key names key_names = [ 'Add', 'Backspace', 'Cancel', 'Capital', 'Clear', 'Control', 'Decimal', 'Delete', 'Divide', 'Down', 'End', 'Enter', 'Enter', 'Esc', 'Execute', 'F1', 'F10', 'F11', 'F12', 'F13', 'F14', 'F15', 'F16', 'F17', 'F18', 'F19', 'F2', 'F20', 'F21', 'F22', 'F23', 'F24', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'Help', 'Home', 'Insert', 'Left', 'Menu', 'Multiply', 'Num Lock', 'Numpad 0', 'Numpad 1', 'Numpad 2', 'Numpad 3', 'Numpad 4', 'Numpad 5', 'Numpad 6', 'Numpad 7', 'Numpad 8', 'Numpad 9', 'Page Down', 'Page Up', 'Pause', 'Print', 'Right', 'Scroll Lock', 'Select', 'Shift', 'Subtract', 'Tab', 'Up', 'Alt', ] enthought-chaco2-4.5.1.orig/enable/stacked_container.py0000644000175000017500000000604712516137326022167 0ustar varunvarun""" Containers which lay out their components horizontally or vertically """ from traits.api import Enum, Float from container import Container from stacked_layout import stacked_preferred_size, stack_layout class StackedContainer(Container): """ Base class for stacked containers """ # The dimension along which to stack components that are added to # this container. stack_dimension = Enum("h", "v") # The "other" dimension, i.e., the dual of the stack dimension. other_dimension = Enum("v", "h") # The index into obj.position and obj.bounds that corresponds to # **stack_dimension**. This is a class-level and not an instance-level # attribute. It must be 0 or 1. stack_index = 0 # The amount of space to put between components. spacing = Float(0.0) def get_preferred_size(self, components=None): return stacked_preferred_size(self, components) class HStackedContainer(StackedContainer): """ A container that stacks components horizontally. """ # Overrides StackedPlotContainer. stack_dimension = "h" # Overrides StackedPlotContainer. other_dimension = "v" # Overrides StackedPlotContainer. stack_index = 0 # VPlotContainer attributes # The horizontal alignment of objects that don't span the full width. halign = Enum("bottom", "top", "center") # The order in which components in the plot container are laid out. stack_order = Enum("left_to_right", "right_to_left") def _do_layout(self): """ Actually performs a layout (called by do_layout()). """ if self.stack_order == "left_to_right": components = self.components else: components = self.components[::-1] if self.halign == "bottom": align = "min" elif self.halign == "center": align = "center" else: align = "max" #import pdb; pdb.set_trace() return stack_layout(self, components, align) class VStackedContainer(StackedContainer): """ A container that stacks components vertically. """ # Overrides StackedPlotContainer. stack_dimension = "v" # Overrides StackedPlotContainer. other_dimension = "h" # Overrides StackedPlotContainer. stack_index = 1 # VPlotContainer attributes # The horizontal alignment of objects that don't span the full width. halign = Enum("left", "right", "center") # The order in which components in the plot container are laid out. stack_order = Enum("bottom_to_top", "top_to_bottom") def _do_layout(self): """ Actually performs a layout (called by do_layout()). """ if self.stack_order == "bottom_to_top": components = self.components else: components = self.components[::-1] if self.halign == "left": align = "min" elif self.halign == "center": align = "center" else: align = "max" #import pdb; pdb.set_trace() return stack_layout(self, components, align) enthought-chaco2-4.5.1.orig/enable.egg-info/0000755000175000017500000000000012516137725017623 5ustar varunvarunenthought-chaco2-4.5.1.orig/enable.egg-info/requires.txt0000644000175000017500000000004112516137725022216 0ustar varunvarunnumpy traits traitsui PIL pyface enthought-chaco2-4.5.1.orig/enable.egg-info/not-zip-safe0000644000175000017500000000000112516137725022051 0ustar varunvarun enthought-chaco2-4.5.1.orig/enable.egg-info/top_level.txt0000644000175000017500000000001412516137725022350 0ustar varunvarunenable kiva enthought-chaco2-4.5.1.orig/enable.egg-info/SOURCES.txt0000644000175000017500000012613712516137725021521 0ustar varunvarunMANIFEST.in README.rst setup.py enable/__init__.py enable/_version.py enable/abstract_overlay.py enable/abstract_window.py enable/api.py enable/base.py enable/base_tool.py enable/canvas.py enable/colors.py enable/compass.py enable/compiled_path.py enable/component.py enable/component_editor.py enable/constraints_container.py enable/container.py enable/controls.py enable/coordinate_box.py enable/drag.py enable/drag_resize.py enable/enable_traits.py enable/events.py enable/example_application.py enable/example_canvas.py enable/example_support.py enable/font_metrics_provider.py enable/gl_graphics_context.py enable/graphics_context.py enable/images.zip enable/interactor.py enable/kiva_graphics_context.py enable/label.py enable/markers.py enable/native_scrollbar.py enable/overlay_container.py enable/radio_group.py enable/render_controllers.py enable/scroll_handler.py enable/scrollbar.py enable/scrolled.py enable/simple_layout.py enable/slider.py enable/stacked_container.py enable/stacked_layout.py enable/testing.py enable/text_field.py enable/text_field_grid.py enable/text_field_style.py enable/text_grid.py enable/toolkit.py enable/toolkit_constants.py enable/viewable.py enable/viewport.py enable/window.py enable.egg-info/PKG-INFO enable.egg-info/SOURCES.txt enable.egg-info/dependency_links.txt enable.egg-info/not-zip-safe enable.egg-info/requires.txt enable.egg-info/top_level.txt enable/drawing/__init__.py enable/drawing/api.py enable/drawing/drag_box.py enable/drawing/drag_line.py enable/drawing/drag_polygon.py enable/drawing/drag_segment.py enable/drawing/drawing_canvas.py enable/drawing/drawing_tool.py enable/drawing/point_line.py enable/drawing/point_polygon.py enable/gadgets/__init__.py enable/gadgets/vu_meter.py enable/images/0_weight.gif enable/images/1_weight.gif enable/images/2_weight.gif enable/images/3_weight.gif enable/images/4_weight.gif enable/images/5_weight.gif enable/images/6_weight.gif enable/images/7_weight.gif enable/images/8_weight.gif enable/images/bottom_center_position.gif enable/images/bottom_left_position.gif enable/images/bottom_right_position.gif enable/images/center_align.gif enable/images/center_left_position.gif enable/images/center_position.gif enable/images/center_right_position.gif enable/images/image_LICENSE.txt enable/images/left_align.gif enable/images/right_align.gif enable/images/top_center_position.gif enable/images/top_left_position.gif enable/images/top_right_position.gif enable/layout/__init__.py enable/layout/ab_constrainable.py enable/layout/api.py enable/layout/constraints_namespace.py enable/layout/geometry.py enable/layout/layout_helpers.py enable/layout/layout_manager.py enable/layout/linear_symbolic.py enable/layout/utils.py enable/null/__init__.py enable/null/cairo.py enable/null/image.py enable/null/pdf.py enable/null/ps.py enable/null/qpainter.py enable/null/quartz.py enable/null/svg.py enable/primitives/__init__.py enable/primitives/annotater.py enable/primitives/api.py enable/primitives/box.py enable/primitives/image.py enable/primitives/line.py enable/primitives/polygon.py enable/primitives/shape.py enable/pyglet_backend/__init__.py enable/pyglet_backend/api.py enable/pyglet_backend/constants.py enable/pyglet_backend/pyglet_app.py enable/pyglet_backend/window.py enable/qt4/__init__.py enable/qt4/base_window.py enable/qt4/cairo.py enable/qt4/constants.py enable/qt4/gl.py enable/qt4/image.py enable/qt4/qpainter.py enable/qt4/quartz.py enable/qt4/scrollbar.py enable/savage/__init__.py enable/savage/compliance/__init__.py enable/savage/compliance/comparator.py enable/savage/compliance/crosshair.py enable/savage/compliance/drawer.py enable/savage/compliance/profile_this.py enable/savage/compliance/sike.py enable/savage/compliance/svg_component.py enable/savage/compliance/viewer.py enable/savage/compliance/xml_view.py enable/savage/compliance/images/default.png enable/savage/svg/__init__.py enable/savage/svg/attributes.py enable/savage/svg/document.py enable/savage/svg/pathdata.py enable/savage/svg/svg_extras.py enable/savage/svg/svg_regex.py enable/savage/svg/backends/__init__.py enable/savage/svg/backends/kiva/__init__.py enable/savage/svg/backends/kiva/renderer.py enable/savage/svg/backends/null/__init__.py enable/savage/svg/backends/null/null_renderer.py enable/savage/svg/backends/wx/__init__.py enable/savage/svg/backends/wx/renderer.py enable/savage/svg/css/__init__.py enable/savage/svg/css/atrule.py enable/savage/svg/css/block.py enable/savage/svg/css/colour.py enable/savage/svg/css/identifier.py enable/savage/svg/css/inline.py enable/savage/svg/css/transform.py enable/savage/svg/css/values.py enable/savage/svg/tests/__init__.py enable/savage/svg/tests/test_attributes.py enable/savage/svg/tests/test_document.py enable/savage/svg/tests/test_pathdata.py enable/savage/svg/tests/css/__init__.py enable/savage/svg/tests/css/test_atrule.py enable/savage/svg/tests/css/test_block.py enable/savage/svg/tests/css/test_color.py enable/savage/svg/tests/css/test_identifier.py enable/savage/svg/tests/css/test_transform.py enable/savage/svg/tests/css/test_values.py enable/savage/trait_defs/__init__.py enable/savage/trait_defs/ui/__init__.py enable/savage/trait_defs/ui/api.py enable/savage/trait_defs/ui/svg_button.py enable/savage/trait_defs/ui/svg_button_editor.py enable/savage/trait_defs/ui/svg_editor.py enable/savage/trait_defs/ui/toolkit.py enable/savage/trait_defs/ui/qt4/__init__.py enable/savage/trait_defs/ui/qt4/svg_button_editor.py enable/savage/trait_defs/ui/qt4/svg_editor.py enable/savage/trait_defs/ui/wx/__init__.py enable/savage/trait_defs/ui/wx/kiva_render_panel.py enable/savage/trait_defs/ui/wx/svg_button_editor.py enable/savage/trait_defs/ui/wx/svg_editor.py enable/savage/trait_defs/ui/wx/wx_render_panel.py enable/savage/trait_defs/ui/wx/data/button_toggle.svg enable/tests/__init__.py enable/tests/component_test_case.py enable/tests/constraints_container_test_case.py enable/tests/container_test_case.py enable/tests/coordinate_box_test_case.py enable/tests/drag_tool_test_case.py enable/tests/drop_tool_test.py enable/tests/event_transform_test_case.py enable/tests/kiva_graphics_context_test_case.py enable/tests/resize_tool_test.py enable/tests/test_component_editor.py enable/tests/viewport_test_case.py enable/tests/primitives/__init__.py enable/tests/primitives/test_image.py enable/tests/primitives/data/PngSuite/basi6a08.png enable/tests/primitives/data/PngSuite/basn2c08.png enable/tests/tools/__init__.py enable/tests/tools/button_tool_test_case.py enable/tests/tools/apptools/__init__.py enable/tests/tools/apptools/commands_test_case.py enable/tests/tools/apptools/move_command_tool_test_case.py enable/tests/tools/apptools/resize_command_tool_test_case.py enable/tests/tools/apptools/undo_tool_test_case.py enable/tools/__init__.py enable/tools/api.py enable/tools/base_drop_tool.py enable/tools/base_zoom_tool.py enable/tools/button_tool.py enable/tools/drag_tool.py enable/tools/hover_tool.py enable/tools/move_tool.py enable/tools/resize_tool.py enable/tools/tool_history_mixin.py enable/tools/traits_tool.py enable/tools/value_drag_tool.py enable/tools/viewport_pan_tool.py enable/tools/viewport_zoom_tool.py enable/tools/apptools/__init__.py enable/tools/apptools/api.py enable/tools/apptools/command_tool.py enable/tools/apptools/commands.py enable/tools/apptools/move_command_tool.py enable/tools/apptools/resize_command_tool.py enable/tools/apptools/undo_tool.py enable/tools/pyface/__init__.py enable/tools/pyface/context_menu_tool.py enable/tools/toolbars/__init__.py enable/tools/toolbars/toolbar_buttons.py enable/tools/toolbars/viewport_toolbar.py enable/trait_defs/__init__.py enable/trait_defs/api.py enable/trait_defs/rgba_color_trait.py enable/trait_defs/ui/__init__.py enable/trait_defs/ui/api.py enable/trait_defs/ui/rgba_color_editor.py enable/trait_defs/ui/qt4/__init__.py enable/trait_defs/ui/qt4/rgba_color_editor.py enable/trait_defs/ui/wx/__init__.py enable/trait_defs/ui/wx/enable_rgba_color_editor.py enable/trait_defs/ui/wx/rgba_color_editor.py enable/vtk_backend/__init__.py enable/vtk_backend/constants.py enable/vtk_backend/vtk_window.py enable/wx/__init__.py enable/wx/base_window.py enable/wx/cairo.py enable/wx/constants.py enable/wx/gl.py enable/wx/image.py enable/wx/quartz.py enable/wx/scrollbar.py kiva/__init__.py kiva/_fontdata.py kiva/_version.py kiva/abstract_graphics_context.py kiva/affine.py kiva/arc_conversion.py kiva/basecore2d.py kiva/cairo.py kiva/constants.py kiva/gl.py kiva/graphics_state.py kiva/image.py kiva/line_state.py kiva/pdf.py kiva/pdfmetrics.py kiva/ps.py kiva/qpainter.py kiva/setup.py kiva/svg.py kiva/testing.py kiva/agg/__init__.py kiva/agg/agg.i kiva/agg/setup.py kiva/agg/agg-24/ChangeLog kiva/agg/agg-24/Makefile kiva/agg/agg-24/Makefile.AmigaOS kiva/agg/agg-24/Makefile.am kiva/agg/agg-24/Makefile.in.BeOS kiva/agg/agg-24/Makefile.in.CYGWIN_NT-5.0 kiva/agg/agg-24/Makefile.in.CYGWIN_NT-5.1 kiva/agg/agg-24/Makefile.in.Darwin kiva/agg/agg-24/Makefile.in.Darwin.SDL kiva/agg/agg-24/Makefile.in.IRIX64 kiva/agg/agg-24/Makefile.in.Linux kiva/agg/agg-24/Makefile.in.Linux.SDL kiva/agg/agg-24/Makefile.in.MINGW32_NT-5.0 kiva/agg/agg-24/Makefile.in.MINGW32_NT-5.1 kiva/agg/agg-24/Makefile.in.SunOS kiva/agg/agg-24/authors kiva/agg/agg-24/autogen.sh kiva/agg/agg-24/configure.in kiva/agg/agg-24/copying kiva/agg/agg-24/distclean kiva/agg/agg-24/install kiva/agg/agg-24/libagg.m4 kiva/agg/agg-24/libagg.pc.in kiva/agg/agg-24/news kiva/agg/agg-24/readme kiva/agg/agg-24/font_freetype/Makefile.am kiva/agg/agg-24/font_freetype/agg_font_freetype.cpp kiva/agg/agg-24/font_freetype/agg_font_freetype.h kiva/agg/agg-24/font_win32_tt/Makefile.am kiva/agg/agg-24/font_win32_tt/agg_font_win32_tt.cpp kiva/agg/agg-24/font_win32_tt/agg_font_win32_tt.h kiva/agg/agg-24/include/Makefile.am kiva/agg/agg-24/include/agg_alpha_mask_u8.h kiva/agg/agg-24/include/agg_arc.h kiva/agg/agg-24/include/agg_array.h kiva/agg/agg-24/include/agg_arrowhead.h kiva/agg/agg-24/include/agg_basics.h kiva/agg/agg-24/include/agg_bezier_arc.h kiva/agg/agg-24/include/agg_bitset_iterator.h kiva/agg/agg-24/include/agg_bounding_rect.h kiva/agg/agg-24/include/agg_bspline.h kiva/agg/agg-24/include/agg_clip_liang_barsky.h kiva/agg/agg-24/include/agg_color_gray.h kiva/agg/agg-24/include/agg_color_rgba.h kiva/agg/agg-24/include/agg_config.h kiva/agg/agg-24/include/agg_conv_adaptor_vcgen.h kiva/agg/agg-24/include/agg_conv_adaptor_vpgen.h kiva/agg/agg-24/include/agg_conv_bspline.h kiva/agg/agg-24/include/agg_conv_clip_polygon.h kiva/agg/agg-24/include/agg_conv_clip_polyline.h kiva/agg/agg-24/include/agg_conv_close_polygon.h kiva/agg/agg-24/include/agg_conv_concat.h kiva/agg/agg-24/include/agg_conv_contour.h kiva/agg/agg-24/include/agg_conv_curve.h kiva/agg/agg-24/include/agg_conv_dash.h kiva/agg/agg-24/include/agg_conv_marker.h kiva/agg/agg-24/include/agg_conv_marker_adaptor.h kiva/agg/agg-24/include/agg_conv_segmentator.h kiva/agg/agg-24/include/agg_conv_shorten_path.h kiva/agg/agg-24/include/agg_conv_smooth_poly1.h kiva/agg/agg-24/include/agg_conv_stroke.h kiva/agg/agg-24/include/agg_conv_transform.h kiva/agg/agg-24/include/agg_conv_unclose_polygon.h kiva/agg/agg-24/include/agg_curves.h kiva/agg/agg-24/include/agg_dda_line.h kiva/agg/agg-24/include/agg_ellipse.h kiva/agg/agg-24/include/agg_ellipse_bresenham.h kiva/agg/agg-24/include/agg_embedded_raster_fonts.h kiva/agg/agg-24/include/agg_font_cache_manager.h kiva/agg/agg-24/include/agg_gamma_functions.h kiva/agg/agg-24/include/agg_gamma_lut.h kiva/agg/agg-24/include/agg_glyph_raster_bin.h kiva/agg/agg-24/include/agg_gsv_text.h kiva/agg/agg-24/include/agg_image_accessors.h kiva/agg/agg-24/include/agg_image_filters.h kiva/agg/agg-24/include/agg_line_aa_basics.h kiva/agg/agg-24/include/agg_math.h kiva/agg/agg-24/include/agg_math_stroke.h kiva/agg/agg-24/include/agg_path_length.h kiva/agg/agg-24/include/agg_path_storage.h kiva/agg/agg-24/include/agg_path_storage_integer.h kiva/agg/agg-24/include/agg_pattern_filters_rgba.h kiva/agg/agg-24/include/agg_pixfmt_amask_adaptor.h kiva/agg/agg-24/include/agg_pixfmt_gray.h kiva/agg/agg-24/include/agg_pixfmt_rgb.h kiva/agg/agg-24/include/agg_pixfmt_rgb_packed.h kiva/agg/agg-24/include/agg_pixfmt_rgba.h kiva/agg/agg-24/include/agg_rasterizer_cells_aa.h kiva/agg/agg-24/include/agg_rasterizer_compound_aa.h kiva/agg/agg-24/include/agg_rasterizer_outline.h kiva/agg/agg-24/include/agg_rasterizer_outline_aa.h kiva/agg/agg-24/include/agg_rasterizer_scanline_aa.h kiva/agg/agg-24/include/agg_rasterizer_sl_clip.h kiva/agg/agg-24/include/agg_renderer_base.h kiva/agg/agg-24/include/agg_renderer_markers.h kiva/agg/agg-24/include/agg_renderer_mclip.h kiva/agg/agg-24/include/agg_renderer_outline_aa.h kiva/agg/agg-24/include/agg_renderer_outline_image.h kiva/agg/agg-24/include/agg_renderer_primitives.h kiva/agg/agg-24/include/agg_renderer_raster_text.h kiva/agg/agg-24/include/agg_renderer_scanline.h kiva/agg/agg-24/include/agg_rendering_buffer.h kiva/agg/agg-24/include/agg_rendering_buffer_dynarow.h kiva/agg/agg-24/include/agg_rounded_rect.h kiva/agg/agg-24/include/agg_scanline_bin.h kiva/agg/agg-24/include/agg_scanline_boolean_algebra.h kiva/agg/agg-24/include/agg_scanline_p.h kiva/agg/agg-24/include/agg_scanline_storage_aa.h kiva/agg/agg-24/include/agg_scanline_storage_bin.h kiva/agg/agg-24/include/agg_scanline_u.h kiva/agg/agg-24/include/agg_shorten_path.h kiva/agg/agg-24/include/agg_simul_eq.h kiva/agg/agg-24/include/agg_span_allocator.h kiva/agg/agg-24/include/agg_span_converter.h kiva/agg/agg-24/include/agg_span_gouraud.h kiva/agg/agg-24/include/agg_span_gouraud_gray.h kiva/agg/agg-24/include/agg_span_gouraud_rgba.h kiva/agg/agg-24/include/agg_span_gradient.h kiva/agg/agg-24/include/agg_span_gradient_alpha.h kiva/agg/agg-24/include/agg_span_image_filter.h kiva/agg/agg-24/include/agg_span_image_filter_gray.h kiva/agg/agg-24/include/agg_span_image_filter_rgb.h kiva/agg/agg-24/include/agg_span_image_filter_rgba.h kiva/agg/agg-24/include/agg_span_interpolator_adaptor.h kiva/agg/agg-24/include/agg_span_interpolator_linear.h kiva/agg/agg-24/include/agg_span_interpolator_persp.h kiva/agg/agg-24/include/agg_span_interpolator_trans.h kiva/agg/agg-24/include/agg_span_pattern_gray.h kiva/agg/agg-24/include/agg_span_pattern_rgb.h kiva/agg/agg-24/include/agg_span_pattern_rgba.h kiva/agg/agg-24/include/agg_span_solid.h kiva/agg/agg-24/include/agg_span_subdiv_adaptor.h kiva/agg/agg-24/include/agg_trans_affine.h kiva/agg/agg-24/include/agg_trans_bilinear.h kiva/agg/agg-24/include/agg_trans_double_path.h kiva/agg/agg-24/include/agg_trans_lens.h kiva/agg/agg-24/include/agg_trans_perspective.h kiva/agg/agg-24/include/agg_trans_single_path.h kiva/agg/agg-24/include/agg_trans_viewport.h kiva/agg/agg-24/include/agg_trans_warp_magnifier.h kiva/agg/agg-24/include/agg_vcgen_bspline.h kiva/agg/agg-24/include/agg_vcgen_contour.h kiva/agg/agg-24/include/agg_vcgen_dash.h kiva/agg/agg-24/include/agg_vcgen_markers_term.h kiva/agg/agg-24/include/agg_vcgen_smooth_poly1.h kiva/agg/agg-24/include/agg_vcgen_stroke.h kiva/agg/agg-24/include/agg_vcgen_vertex_sequence.h kiva/agg/agg-24/include/agg_vertex_sequence.h kiva/agg/agg-24/include/agg_vpgen_clip_polygon.h kiva/agg/agg-24/include/agg_vpgen_clip_polyline.h kiva/agg/agg-24/include/agg_vpgen_segmentator.h kiva/agg/agg-24/include/ctrl/Makefile.am kiva/agg/agg-24/include/ctrl/agg_bezier_ctrl.h kiva/agg/agg-24/include/ctrl/agg_cbox_ctrl.h kiva/agg/agg-24/include/ctrl/agg_ctrl.h kiva/agg/agg-24/include/ctrl/agg_gamma_ctrl.h kiva/agg/agg-24/include/ctrl/agg_gamma_spline.h kiva/agg/agg-24/include/ctrl/agg_polygon_ctrl.h kiva/agg/agg-24/include/ctrl/agg_rbox_ctrl.h kiva/agg/agg-24/include/ctrl/agg_scale_ctrl.h kiva/agg/agg-24/include/ctrl/agg_slider_ctrl.h kiva/agg/agg-24/include/ctrl/agg_spline_ctrl.h kiva/agg/agg-24/include/platform/Makefile.am kiva/agg/agg-24/include/platform/agg_platform_support.h kiva/agg/agg-24/include/platform/mac/agg_mac_pmap.h kiva/agg/agg-24/include/platform/win32/agg_win32_bmp.h kiva/agg/agg-24/include/util/Makefile.am kiva/agg/agg-24/include/util/agg_color_conv.h kiva/agg/agg-24/include/util/agg_color_conv_rgb16.h kiva/agg/agg-24/include/util/agg_color_conv_rgb8.h kiva/agg/agg-24/src/ChangeLog kiva/agg/agg-24/src/Makefile kiva/agg/agg-24/src/Makefile.am kiva/agg/agg-24/src/agg_arc.cpp kiva/agg/agg-24/src/agg_arrowhead.cpp kiva/agg/agg-24/src/agg_bezier_arc.cpp kiva/agg/agg-24/src/agg_bspline.cpp kiva/agg/agg-24/src/agg_curves.cpp kiva/agg/agg-24/src/agg_embedded_raster_fonts.cpp kiva/agg/agg-24/src/agg_gsv_text.cpp kiva/agg/agg-24/src/agg_image_filters.cpp kiva/agg/agg-24/src/agg_line_aa_basics.cpp kiva/agg/agg-24/src/agg_line_profile_aa.cpp kiva/agg/agg-24/src/agg_rounded_rect.cpp kiva/agg/agg-24/src/agg_sqrt_tables.cpp kiva/agg/agg-24/src/agg_trans_affine.cpp kiva/agg/agg-24/src/agg_trans_double_path.cpp kiva/agg/agg-24/src/agg_trans_single_path.cpp kiva/agg/agg-24/src/agg_trans_warp_magnifier.cpp kiva/agg/agg-24/src/agg_vcgen_bspline.cpp kiva/agg/agg-24/src/agg_vcgen_contour.cpp kiva/agg/agg-24/src/agg_vcgen_dash.cpp kiva/agg/agg-24/src/agg_vcgen_markers_term.cpp kiva/agg/agg-24/src/agg_vcgen_smooth_poly1.cpp kiva/agg/agg-24/src/agg_vcgen_stroke.cpp kiva/agg/agg-24/src/agg_vpgen_clip_polygon.cpp kiva/agg/agg-24/src/agg_vpgen_clip_polyline.cpp kiva/agg/agg-24/src/agg_vpgen_segmentator.cpp kiva/agg/agg-24/src/authors kiva/agg/agg-24/src/autogen.sh kiva/agg/agg-24/src/configure.in kiva/agg/agg-24/src/copying kiva/agg/agg-24/src/install kiva/agg/agg-24/src/news kiva/agg/agg-24/src/readme kiva/agg/agg-24/src/ctrl/Makefile.am kiva/agg/agg-24/src/ctrl/agg_bezier_ctrl.cpp kiva/agg/agg-24/src/ctrl/agg_cbox_ctrl.cpp kiva/agg/agg-24/src/ctrl/agg_gamma_ctrl.cpp kiva/agg/agg-24/src/ctrl/agg_gamma_spline.cpp kiva/agg/agg-24/src/ctrl/agg_polygon_ctrl.cpp kiva/agg/agg-24/src/ctrl/agg_rbox_ctrl.cpp kiva/agg/agg-24/src/ctrl/agg_scale_ctrl.cpp kiva/agg/agg-24/src/ctrl/agg_slider_ctrl.cpp kiva/agg/agg-24/src/ctrl/agg_spline_ctrl.cpp kiva/agg/agg-24/src/platform/Makefile.am kiva/agg/agg-24/src/platform/AmigaOS/Makefile.am kiva/agg/agg-24/src/platform/AmigaOS/agg_platform_support.cpp kiva/agg/agg-24/src/platform/BeOS/Makefile.am kiva/agg/agg-24/src/platform/BeOS/agg_platform_support.cpp kiva/agg/agg-24/src/platform/X11/Makefile.am kiva/agg/agg-24/src/platform/X11/agg_platform_support.cpp kiva/agg/agg-24/src/platform/mac/Makefile.am kiva/agg/agg-24/src/platform/mac/agg_mac_pmap.cpp kiva/agg/agg-24/src/platform/mac/agg_platform_support.cpp kiva/agg/agg-24/src/platform/sdl/Makefile.am kiva/agg/agg-24/src/platform/sdl/agg_platform_support.cpp kiva/agg/agg-24/src/platform/win32/Makefile.am kiva/agg/agg-24/src/platform/win32/agg_platform_support.cpp kiva/agg/agg-24/src/platform/win32/agg_win32_bmp.cpp kiva/agg/freetype2/.gitignore kiva/agg/freetype2/Jamfile kiva/agg/freetype2/Jamrules kiva/agg/freetype2/Makefile kiva/agg/freetype2/README kiva/agg/freetype2/README.git kiva/agg/freetype2/README_Enthought_changes.txt kiva/agg/freetype2/autogen.sh kiva/agg/freetype2/config.mk kiva/agg/freetype2/configure kiva/agg/freetype2/modules.cfg kiva/agg/freetype2/version.sed kiva/agg/freetype2/vms_make.com kiva/agg/freetype2/devel/ft2build.h kiva/agg/freetype2/devel/ftoption.h kiva/agg/freetype2/docs/CUSTOMIZE kiva/agg/freetype2/docs/DEBUG kiva/agg/freetype2/docs/FTL.TXT kiva/agg/freetype2/docs/GPL.TXT kiva/agg/freetype2/docs/INSTALL kiva/agg/freetype2/docs/INSTALL.ANY kiva/agg/freetype2/docs/INSTALL.CROSS kiva/agg/freetype2/docs/INSTALL.GNU kiva/agg/freetype2/docs/INSTALL.MAC kiva/agg/freetype2/docs/INSTALL.UNIX kiva/agg/freetype2/docs/INSTALL.VMS kiva/agg/freetype2/docs/LICENSE.TXT kiva/agg/freetype2/docs/MAKEPP kiva/agg/freetype2/docs/PATENTS kiva/agg/freetype2/docs/PROBLEMS kiva/agg/freetype2/docs/TODO kiva/agg/freetype2/docs/TRUETYPE kiva/agg/freetype2/docs/UPGRADE.UNIX kiva/agg/freetype2/docs/VERSION.DLL kiva/agg/freetype2/docs/formats.txt kiva/agg/freetype2/docs/raster.txt kiva/agg/freetype2/docs/release kiva/agg/freetype2/include/ft2build.h kiva/agg/freetype2/include/freetype/freetype.h kiva/agg/freetype2/include/freetype/ftadvanc.h kiva/agg/freetype2/include/freetype/ftbbox.h kiva/agg/freetype2/include/freetype/ftbdf.h kiva/agg/freetype2/include/freetype/ftbitmap.h kiva/agg/freetype2/include/freetype/ftcache.h kiva/agg/freetype2/include/freetype/ftchapters.h kiva/agg/freetype2/include/freetype/ftcid.h kiva/agg/freetype2/include/freetype/fterrdef.h kiva/agg/freetype2/include/freetype/fterrors.h kiva/agg/freetype2/include/freetype/ftgasp.h kiva/agg/freetype2/include/freetype/ftglyph.h kiva/agg/freetype2/include/freetype/ftgxval.h kiva/agg/freetype2/include/freetype/ftgzip.h kiva/agg/freetype2/include/freetype/ftimage.h kiva/agg/freetype2/include/freetype/ftincrem.h kiva/agg/freetype2/include/freetype/ftlcdfil.h kiva/agg/freetype2/include/freetype/ftlist.h kiva/agg/freetype2/include/freetype/ftlzw.h kiva/agg/freetype2/include/freetype/ftmac.h kiva/agg/freetype2/include/freetype/ftmm.h kiva/agg/freetype2/include/freetype/ftmodapi.h kiva/agg/freetype2/include/freetype/ftmoderr.h kiva/agg/freetype2/include/freetype/ftotval.h kiva/agg/freetype2/include/freetype/ftoutln.h kiva/agg/freetype2/include/freetype/ftpfr.h kiva/agg/freetype2/include/freetype/ftrender.h kiva/agg/freetype2/include/freetype/ftsizes.h kiva/agg/freetype2/include/freetype/ftsnames.h kiva/agg/freetype2/include/freetype/ftstroke.h kiva/agg/freetype2/include/freetype/ftsynth.h kiva/agg/freetype2/include/freetype/ftsystem.h kiva/agg/freetype2/include/freetype/fttrigon.h kiva/agg/freetype2/include/freetype/fttypes.h kiva/agg/freetype2/include/freetype/ftwinfnt.h kiva/agg/freetype2/include/freetype/ftxf86.h kiva/agg/freetype2/include/freetype/t1tables.h kiva/agg/freetype2/include/freetype/ttnameid.h kiva/agg/freetype2/include/freetype/tttables.h kiva/agg/freetype2/include/freetype/tttags.h kiva/agg/freetype2/include/freetype/ttunpat.h kiva/agg/freetype2/include/freetype/config/ftconfig.h kiva/agg/freetype2/include/freetype/config/ftheader.h kiva/agg/freetype2/include/freetype/config/ftmodule.h kiva/agg/freetype2/include/freetype/config/ftoption.h kiva/agg/freetype2/include/freetype/config/ftstdlib.h kiva/agg/freetype2/include/freetype/internal/autohint.h kiva/agg/freetype2/include/freetype/internal/ftcalc.h kiva/agg/freetype2/include/freetype/internal/ftdebug.h kiva/agg/freetype2/include/freetype/internal/ftdriver.h kiva/agg/freetype2/include/freetype/internal/ftgloadr.h kiva/agg/freetype2/include/freetype/internal/ftmemory.h kiva/agg/freetype2/include/freetype/internal/ftobjs.h kiva/agg/freetype2/include/freetype/internal/ftpic.h kiva/agg/freetype2/include/freetype/internal/ftrfork.h kiva/agg/freetype2/include/freetype/internal/ftserv.h kiva/agg/freetype2/include/freetype/internal/ftstream.h kiva/agg/freetype2/include/freetype/internal/fttrace.h kiva/agg/freetype2/include/freetype/internal/ftvalid.h kiva/agg/freetype2/include/freetype/internal/internal.h kiva/agg/freetype2/include/freetype/internal/pcftypes.h kiva/agg/freetype2/include/freetype/internal/psaux.h kiva/agg/freetype2/include/freetype/internal/pshints.h kiva/agg/freetype2/include/freetype/internal/sfnt.h kiva/agg/freetype2/include/freetype/internal/t1types.h kiva/agg/freetype2/include/freetype/internal/tttypes.h kiva/agg/freetype2/include/freetype/internal/services/svbdf.h kiva/agg/freetype2/include/freetype/internal/services/svcid.h kiva/agg/freetype2/include/freetype/internal/services/svgldict.h kiva/agg/freetype2/include/freetype/internal/services/svgxval.h kiva/agg/freetype2/include/freetype/internal/services/svkern.h kiva/agg/freetype2/include/freetype/internal/services/svmm.h kiva/agg/freetype2/include/freetype/internal/services/svotval.h kiva/agg/freetype2/include/freetype/internal/services/svpfr.h kiva/agg/freetype2/include/freetype/internal/services/svpostnm.h kiva/agg/freetype2/include/freetype/internal/services/svpscmap.h kiva/agg/freetype2/include/freetype/internal/services/svpsinfo.h kiva/agg/freetype2/include/freetype/internal/services/svsfnt.h kiva/agg/freetype2/include/freetype/internal/services/svttcmap.h kiva/agg/freetype2/include/freetype/internal/services/svtteng.h kiva/agg/freetype2/include/freetype/internal/services/svttglyf.h kiva/agg/freetype2/include/freetype/internal/services/svwinfnt.h kiva/agg/freetype2/include/freetype/internal/services/svxf86nm.h kiva/agg/freetype2/objs/.gitignore kiva/agg/freetype2/objs/README kiva/agg/freetype2/objs/ftmodule.h kiva/agg/freetype2/src/Jamfile kiva/agg/freetype2/src/autofit/Jamfile kiva/agg/freetype2/src/autofit/afangles.c kiva/agg/freetype2/src/autofit/afangles.h kiva/agg/freetype2/src/autofit/afcjk.c kiva/agg/freetype2/src/autofit/afcjk.h kiva/agg/freetype2/src/autofit/afdummy.c kiva/agg/freetype2/src/autofit/afdummy.h kiva/agg/freetype2/src/autofit/aferrors.h kiva/agg/freetype2/src/autofit/afglobal.c kiva/agg/freetype2/src/autofit/afglobal.h kiva/agg/freetype2/src/autofit/afhints.c kiva/agg/freetype2/src/autofit/afhints.h kiva/agg/freetype2/src/autofit/afindic.c kiva/agg/freetype2/src/autofit/afindic.h kiva/agg/freetype2/src/autofit/aflatin.c kiva/agg/freetype2/src/autofit/aflatin.h kiva/agg/freetype2/src/autofit/aflatin2.c kiva/agg/freetype2/src/autofit/aflatin2.h kiva/agg/freetype2/src/autofit/afloader.c kiva/agg/freetype2/src/autofit/afloader.h kiva/agg/freetype2/src/autofit/afmodule.c kiva/agg/freetype2/src/autofit/afmodule.h kiva/agg/freetype2/src/autofit/afpic.c kiva/agg/freetype2/src/autofit/afpic.h kiva/agg/freetype2/src/autofit/aftypes.h kiva/agg/freetype2/src/autofit/afwarp.c kiva/agg/freetype2/src/autofit/afwarp.h kiva/agg/freetype2/src/autofit/autofit.c kiva/agg/freetype2/src/autofit/module.mk kiva/agg/freetype2/src/autofit/rules.mk kiva/agg/freetype2/src/base/Jamfile kiva/agg/freetype2/src/base/basepic.c kiva/agg/freetype2/src/base/basepic.h kiva/agg/freetype2/src/base/ftadvanc.c kiva/agg/freetype2/src/base/ftapi.c kiva/agg/freetype2/src/base/ftbase.c kiva/agg/freetype2/src/base/ftbase.h kiva/agg/freetype2/src/base/ftbbox.c kiva/agg/freetype2/src/base/ftbdf.c kiva/agg/freetype2/src/base/ftbitmap.c kiva/agg/freetype2/src/base/ftcalc.c kiva/agg/freetype2/src/base/ftcid.c kiva/agg/freetype2/src/base/ftdbgmem.c kiva/agg/freetype2/src/base/ftdebug.c kiva/agg/freetype2/src/base/ftfstype.c kiva/agg/freetype2/src/base/ftgasp.c kiva/agg/freetype2/src/base/ftgloadr.c kiva/agg/freetype2/src/base/ftglyph.c kiva/agg/freetype2/src/base/ftgxval.c kiva/agg/freetype2/src/base/ftinit.c kiva/agg/freetype2/src/base/ftlcdfil.c kiva/agg/freetype2/src/base/ftmac.c kiva/agg/freetype2/src/base/ftmm.c kiva/agg/freetype2/src/base/ftobjs.c kiva/agg/freetype2/src/base/ftotval.c kiva/agg/freetype2/src/base/ftoutln.c kiva/agg/freetype2/src/base/ftpatent.c kiva/agg/freetype2/src/base/ftpfr.c kiva/agg/freetype2/src/base/ftpic.c kiva/agg/freetype2/src/base/ftrfork.c kiva/agg/freetype2/src/base/ftsnames.c kiva/agg/freetype2/src/base/ftstream.c kiva/agg/freetype2/src/base/ftstroke.c kiva/agg/freetype2/src/base/ftsynth.c kiva/agg/freetype2/src/base/ftsystem.c kiva/agg/freetype2/src/base/fttrigon.c kiva/agg/freetype2/src/base/fttype1.c kiva/agg/freetype2/src/base/ftutil.c kiva/agg/freetype2/src/base/ftwinfnt.c kiva/agg/freetype2/src/base/ftxf86.c kiva/agg/freetype2/src/base/rules.mk kiva/agg/freetype2/src/bdf/Jamfile kiva/agg/freetype2/src/bdf/README kiva/agg/freetype2/src/bdf/bdf.c kiva/agg/freetype2/src/bdf/bdf.h kiva/agg/freetype2/src/bdf/bdfdrivr.c kiva/agg/freetype2/src/bdf/bdfdrivr.h kiva/agg/freetype2/src/bdf/bdferror.h kiva/agg/freetype2/src/bdf/bdflib.c kiva/agg/freetype2/src/bdf/module.mk kiva/agg/freetype2/src/bdf/rules.mk kiva/agg/freetype2/src/cache/Jamfile kiva/agg/freetype2/src/cache/ftcache.c kiva/agg/freetype2/src/cache/ftcbasic.c kiva/agg/freetype2/src/cache/ftccache.c kiva/agg/freetype2/src/cache/ftccache.h kiva/agg/freetype2/src/cache/ftccback.h kiva/agg/freetype2/src/cache/ftccmap.c kiva/agg/freetype2/src/cache/ftcerror.h kiva/agg/freetype2/src/cache/ftcglyph.c kiva/agg/freetype2/src/cache/ftcglyph.h kiva/agg/freetype2/src/cache/ftcimage.c kiva/agg/freetype2/src/cache/ftcimage.h kiva/agg/freetype2/src/cache/ftcmanag.c kiva/agg/freetype2/src/cache/ftcmanag.h kiva/agg/freetype2/src/cache/ftcmru.c kiva/agg/freetype2/src/cache/ftcmru.h kiva/agg/freetype2/src/cache/ftcsbits.c kiva/agg/freetype2/src/cache/ftcsbits.h kiva/agg/freetype2/src/cache/rules.mk kiva/agg/freetype2/src/cff/Jamfile kiva/agg/freetype2/src/cff/cff.c kiva/agg/freetype2/src/cff/cffcmap.c kiva/agg/freetype2/src/cff/cffcmap.h kiva/agg/freetype2/src/cff/cffdrivr.c kiva/agg/freetype2/src/cff/cffdrivr.h kiva/agg/freetype2/src/cff/cfferrs.h kiva/agg/freetype2/src/cff/cffgload.c kiva/agg/freetype2/src/cff/cffgload.h kiva/agg/freetype2/src/cff/cffload.c kiva/agg/freetype2/src/cff/cffload.h kiva/agg/freetype2/src/cff/cffobjs.c kiva/agg/freetype2/src/cff/cffobjs.h kiva/agg/freetype2/src/cff/cffparse.c kiva/agg/freetype2/src/cff/cffparse.h kiva/agg/freetype2/src/cff/cffpic.c kiva/agg/freetype2/src/cff/cffpic.h kiva/agg/freetype2/src/cff/cfftoken.h kiva/agg/freetype2/src/cff/cfftypes.h kiva/agg/freetype2/src/cff/module.mk kiva/agg/freetype2/src/cff/rules.mk kiva/agg/freetype2/src/cid/Jamfile kiva/agg/freetype2/src/cid/ciderrs.h kiva/agg/freetype2/src/cid/cidgload.c kiva/agg/freetype2/src/cid/cidgload.h kiva/agg/freetype2/src/cid/cidload.c kiva/agg/freetype2/src/cid/cidload.h kiva/agg/freetype2/src/cid/cidobjs.c kiva/agg/freetype2/src/cid/cidobjs.h kiva/agg/freetype2/src/cid/cidparse.c kiva/agg/freetype2/src/cid/cidparse.h kiva/agg/freetype2/src/cid/cidriver.c kiva/agg/freetype2/src/cid/cidriver.h kiva/agg/freetype2/src/cid/cidtoken.h kiva/agg/freetype2/src/cid/module.mk kiva/agg/freetype2/src/cid/rules.mk kiva/agg/freetype2/src/cid/type1cid.c kiva/agg/freetype2/src/gxvalid/Jamfile kiva/agg/freetype2/src/gxvalid/README kiva/agg/freetype2/src/gxvalid/gxvalid.c kiva/agg/freetype2/src/gxvalid/gxvalid.h kiva/agg/freetype2/src/gxvalid/gxvbsln.c kiva/agg/freetype2/src/gxvalid/gxvcommn.c kiva/agg/freetype2/src/gxvalid/gxvcommn.h kiva/agg/freetype2/src/gxvalid/gxverror.h kiva/agg/freetype2/src/gxvalid/gxvfeat.c kiva/agg/freetype2/src/gxvalid/gxvfeat.h kiva/agg/freetype2/src/gxvalid/gxvfgen.c kiva/agg/freetype2/src/gxvalid/gxvjust.c kiva/agg/freetype2/src/gxvalid/gxvkern.c kiva/agg/freetype2/src/gxvalid/gxvlcar.c kiva/agg/freetype2/src/gxvalid/gxvmod.c kiva/agg/freetype2/src/gxvalid/gxvmod.h kiva/agg/freetype2/src/gxvalid/gxvmort.c kiva/agg/freetype2/src/gxvalid/gxvmort.h kiva/agg/freetype2/src/gxvalid/gxvmort0.c kiva/agg/freetype2/src/gxvalid/gxvmort1.c kiva/agg/freetype2/src/gxvalid/gxvmort2.c kiva/agg/freetype2/src/gxvalid/gxvmort4.c kiva/agg/freetype2/src/gxvalid/gxvmort5.c kiva/agg/freetype2/src/gxvalid/gxvmorx.c kiva/agg/freetype2/src/gxvalid/gxvmorx.h kiva/agg/freetype2/src/gxvalid/gxvmorx0.c kiva/agg/freetype2/src/gxvalid/gxvmorx1.c kiva/agg/freetype2/src/gxvalid/gxvmorx2.c kiva/agg/freetype2/src/gxvalid/gxvmorx4.c kiva/agg/freetype2/src/gxvalid/gxvmorx5.c kiva/agg/freetype2/src/gxvalid/gxvopbd.c kiva/agg/freetype2/src/gxvalid/gxvprop.c kiva/agg/freetype2/src/gxvalid/gxvtrak.c kiva/agg/freetype2/src/gxvalid/module.mk kiva/agg/freetype2/src/gxvalid/rules.mk kiva/agg/freetype2/src/gzip/Jamfile kiva/agg/freetype2/src/gzip/adler32.c kiva/agg/freetype2/src/gzip/ftgzip.c kiva/agg/freetype2/src/gzip/infblock.c kiva/agg/freetype2/src/gzip/infblock.h kiva/agg/freetype2/src/gzip/infcodes.c kiva/agg/freetype2/src/gzip/infcodes.h kiva/agg/freetype2/src/gzip/inffixed.h kiva/agg/freetype2/src/gzip/inflate.c kiva/agg/freetype2/src/gzip/inftrees.c kiva/agg/freetype2/src/gzip/inftrees.h kiva/agg/freetype2/src/gzip/infutil.c kiva/agg/freetype2/src/gzip/infutil.h kiva/agg/freetype2/src/gzip/rules.mk kiva/agg/freetype2/src/gzip/zconf.h kiva/agg/freetype2/src/gzip/zlib.h kiva/agg/freetype2/src/gzip/zutil.c kiva/agg/freetype2/src/gzip/zutil.h kiva/agg/freetype2/src/lzw/Jamfile kiva/agg/freetype2/src/lzw/ftlzw.c kiva/agg/freetype2/src/lzw/ftzopen.c kiva/agg/freetype2/src/lzw/ftzopen.h kiva/agg/freetype2/src/lzw/rules.mk kiva/agg/freetype2/src/otvalid/Jamfile kiva/agg/freetype2/src/otvalid/module.mk kiva/agg/freetype2/src/otvalid/otvalid.c kiva/agg/freetype2/src/otvalid/otvalid.h kiva/agg/freetype2/src/otvalid/otvbase.c kiva/agg/freetype2/src/otvalid/otvcommn.c kiva/agg/freetype2/src/otvalid/otvcommn.h kiva/agg/freetype2/src/otvalid/otverror.h kiva/agg/freetype2/src/otvalid/otvgdef.c kiva/agg/freetype2/src/otvalid/otvgpos.c kiva/agg/freetype2/src/otvalid/otvgpos.h kiva/agg/freetype2/src/otvalid/otvgsub.c kiva/agg/freetype2/src/otvalid/otvjstf.c kiva/agg/freetype2/src/otvalid/otvmath.c kiva/agg/freetype2/src/otvalid/otvmod.c kiva/agg/freetype2/src/otvalid/otvmod.h kiva/agg/freetype2/src/otvalid/rules.mk kiva/agg/freetype2/src/pcf/Jamfile kiva/agg/freetype2/src/pcf/README kiva/agg/freetype2/src/pcf/module.mk kiva/agg/freetype2/src/pcf/pcf.c kiva/agg/freetype2/src/pcf/pcf.h kiva/agg/freetype2/src/pcf/pcfdrivr.c kiva/agg/freetype2/src/pcf/pcfdrivr.h kiva/agg/freetype2/src/pcf/pcferror.h kiva/agg/freetype2/src/pcf/pcfread.c kiva/agg/freetype2/src/pcf/pcfread.h kiva/agg/freetype2/src/pcf/pcfutil.c kiva/agg/freetype2/src/pcf/pcfutil.h kiva/agg/freetype2/src/pcf/rules.mk kiva/agg/freetype2/src/pfr/Jamfile kiva/agg/freetype2/src/pfr/module.mk kiva/agg/freetype2/src/pfr/pfr.c kiva/agg/freetype2/src/pfr/pfrcmap.c kiva/agg/freetype2/src/pfr/pfrcmap.h kiva/agg/freetype2/src/pfr/pfrdrivr.c kiva/agg/freetype2/src/pfr/pfrdrivr.h kiva/agg/freetype2/src/pfr/pfrerror.h kiva/agg/freetype2/src/pfr/pfrgload.c kiva/agg/freetype2/src/pfr/pfrgload.h kiva/agg/freetype2/src/pfr/pfrload.c kiva/agg/freetype2/src/pfr/pfrload.h kiva/agg/freetype2/src/pfr/pfrobjs.c kiva/agg/freetype2/src/pfr/pfrobjs.h kiva/agg/freetype2/src/pfr/pfrsbit.c kiva/agg/freetype2/src/pfr/pfrsbit.h kiva/agg/freetype2/src/pfr/pfrtypes.h kiva/agg/freetype2/src/pfr/rules.mk kiva/agg/freetype2/src/psaux/Jamfile kiva/agg/freetype2/src/psaux/afmparse.c kiva/agg/freetype2/src/psaux/afmparse.h kiva/agg/freetype2/src/psaux/module.mk kiva/agg/freetype2/src/psaux/psaux.c kiva/agg/freetype2/src/psaux/psauxerr.h kiva/agg/freetype2/src/psaux/psauxmod.c kiva/agg/freetype2/src/psaux/psauxmod.h kiva/agg/freetype2/src/psaux/psconv.c kiva/agg/freetype2/src/psaux/psconv.h kiva/agg/freetype2/src/psaux/psobjs.c kiva/agg/freetype2/src/psaux/psobjs.h kiva/agg/freetype2/src/psaux/rules.mk kiva/agg/freetype2/src/psaux/t1cmap.c kiva/agg/freetype2/src/psaux/t1cmap.h kiva/agg/freetype2/src/psaux/t1decode.c kiva/agg/freetype2/src/psaux/t1decode.h kiva/agg/freetype2/src/pshinter/Jamfile kiva/agg/freetype2/src/pshinter/module.mk kiva/agg/freetype2/src/pshinter/pshalgo.c kiva/agg/freetype2/src/pshinter/pshalgo.h kiva/agg/freetype2/src/pshinter/pshglob.c kiva/agg/freetype2/src/pshinter/pshglob.h kiva/agg/freetype2/src/pshinter/pshinter.c kiva/agg/freetype2/src/pshinter/pshmod.c kiva/agg/freetype2/src/pshinter/pshmod.h kiva/agg/freetype2/src/pshinter/pshnterr.h kiva/agg/freetype2/src/pshinter/pshpic.c kiva/agg/freetype2/src/pshinter/pshpic.h kiva/agg/freetype2/src/pshinter/pshrec.c kiva/agg/freetype2/src/pshinter/pshrec.h kiva/agg/freetype2/src/pshinter/rules.mk kiva/agg/freetype2/src/psnames/Jamfile kiva/agg/freetype2/src/psnames/module.mk kiva/agg/freetype2/src/psnames/psmodule.c kiva/agg/freetype2/src/psnames/psmodule.h kiva/agg/freetype2/src/psnames/psnamerr.h kiva/agg/freetype2/src/psnames/psnames.c kiva/agg/freetype2/src/psnames/pspic.c kiva/agg/freetype2/src/psnames/pspic.h kiva/agg/freetype2/src/psnames/pstables.h kiva/agg/freetype2/src/psnames/rules.mk kiva/agg/freetype2/src/raster/Jamfile kiva/agg/freetype2/src/raster/ftmisc.h kiva/agg/freetype2/src/raster/ftraster.c kiva/agg/freetype2/src/raster/ftraster.h kiva/agg/freetype2/src/raster/ftrend1.c kiva/agg/freetype2/src/raster/ftrend1.h kiva/agg/freetype2/src/raster/module.mk kiva/agg/freetype2/src/raster/raster.c kiva/agg/freetype2/src/raster/rasterrs.h kiva/agg/freetype2/src/raster/rastpic.c kiva/agg/freetype2/src/raster/rastpic.h kiva/agg/freetype2/src/raster/rules.mk kiva/agg/freetype2/src/sfnt/Jamfile kiva/agg/freetype2/src/sfnt/module.mk kiva/agg/freetype2/src/sfnt/rules.mk kiva/agg/freetype2/src/sfnt/sfdriver.c kiva/agg/freetype2/src/sfnt/sfdriver.h kiva/agg/freetype2/src/sfnt/sferrors.h kiva/agg/freetype2/src/sfnt/sfnt.c kiva/agg/freetype2/src/sfnt/sfntpic.c kiva/agg/freetype2/src/sfnt/sfntpic.h kiva/agg/freetype2/src/sfnt/sfobjs.c kiva/agg/freetype2/src/sfnt/sfobjs.h kiva/agg/freetype2/src/sfnt/ttbdf.c kiva/agg/freetype2/src/sfnt/ttbdf.h kiva/agg/freetype2/src/sfnt/ttcmap.c kiva/agg/freetype2/src/sfnt/ttcmap.h kiva/agg/freetype2/src/sfnt/ttcmapc.h kiva/agg/freetype2/src/sfnt/ttkern.c kiva/agg/freetype2/src/sfnt/ttkern.h kiva/agg/freetype2/src/sfnt/ttload.c kiva/agg/freetype2/src/sfnt/ttload.h kiva/agg/freetype2/src/sfnt/ttmtx.c kiva/agg/freetype2/src/sfnt/ttmtx.h kiva/agg/freetype2/src/sfnt/ttpost.c kiva/agg/freetype2/src/sfnt/ttpost.h kiva/agg/freetype2/src/sfnt/ttsbit.c kiva/agg/freetype2/src/sfnt/ttsbit.h kiva/agg/freetype2/src/sfnt/ttsbit0.c kiva/agg/freetype2/src/smooth/Jamfile kiva/agg/freetype2/src/smooth/ftgrays.c kiva/agg/freetype2/src/smooth/ftgrays.h kiva/agg/freetype2/src/smooth/ftsmerrs.h kiva/agg/freetype2/src/smooth/ftsmooth.c kiva/agg/freetype2/src/smooth/ftsmooth.h kiva/agg/freetype2/src/smooth/ftspic.c kiva/agg/freetype2/src/smooth/ftspic.h kiva/agg/freetype2/src/smooth/module.mk kiva/agg/freetype2/src/smooth/rules.mk kiva/agg/freetype2/src/smooth/smooth.c kiva/agg/freetype2/src/tools/Jamfile kiva/agg/freetype2/src/tools/apinames.c kiva/agg/freetype2/src/tools/chktrcmp.py kiva/agg/freetype2/src/tools/cordic.py kiva/agg/freetype2/src/tools/glnames.py kiva/agg/freetype2/src/tools/test_afm.c kiva/agg/freetype2/src/tools/test_bbox.c kiva/agg/freetype2/src/tools/test_trig.c kiva/agg/freetype2/src/tools/docmaker/.gitignore kiva/agg/freetype2/src/tools/docmaker/content.py kiva/agg/freetype2/src/tools/docmaker/docbeauty.py kiva/agg/freetype2/src/tools/docmaker/docmaker.py kiva/agg/freetype2/src/tools/docmaker/formatter.py kiva/agg/freetype2/src/tools/docmaker/sources.py kiva/agg/freetype2/src/tools/docmaker/tohtml.py kiva/agg/freetype2/src/tools/docmaker/utils.py kiva/agg/freetype2/src/tools/ftrandom/Makefile kiva/agg/freetype2/src/tools/ftrandom/README kiva/agg/freetype2/src/tools/ftrandom/ftrandom.c kiva/agg/freetype2/src/truetype/Jamfile kiva/agg/freetype2/src/truetype/module.mk kiva/agg/freetype2/src/truetype/rules.mk kiva/agg/freetype2/src/truetype/truetype.c kiva/agg/freetype2/src/truetype/ttdriver.c kiva/agg/freetype2/src/truetype/ttdriver.h kiva/agg/freetype2/src/truetype/tterrors.h kiva/agg/freetype2/src/truetype/ttgload.c kiva/agg/freetype2/src/truetype/ttgload.h kiva/agg/freetype2/src/truetype/ttgxvar.c kiva/agg/freetype2/src/truetype/ttgxvar.h kiva/agg/freetype2/src/truetype/ttinterp.c kiva/agg/freetype2/src/truetype/ttinterp.h kiva/agg/freetype2/src/truetype/ttobjs.c kiva/agg/freetype2/src/truetype/ttobjs.h kiva/agg/freetype2/src/truetype/ttpic.c kiva/agg/freetype2/src/truetype/ttpic.h kiva/agg/freetype2/src/truetype/ttpload.c kiva/agg/freetype2/src/truetype/ttpload.h kiva/agg/freetype2/src/type1/Jamfile kiva/agg/freetype2/src/type1/module.mk kiva/agg/freetype2/src/type1/rules.mk kiva/agg/freetype2/src/type1/t1afm.c kiva/agg/freetype2/src/type1/t1afm.h kiva/agg/freetype2/src/type1/t1driver.c kiva/agg/freetype2/src/type1/t1driver.h kiva/agg/freetype2/src/type1/t1errors.h kiva/agg/freetype2/src/type1/t1gload.c kiva/agg/freetype2/src/type1/t1gload.h kiva/agg/freetype2/src/type1/t1load.c kiva/agg/freetype2/src/type1/t1load.h kiva/agg/freetype2/src/type1/t1objs.c kiva/agg/freetype2/src/type1/t1objs.h kiva/agg/freetype2/src/type1/t1parse.c kiva/agg/freetype2/src/type1/t1parse.h kiva/agg/freetype2/src/type1/t1tokens.h kiva/agg/freetype2/src/type1/type1.c kiva/agg/freetype2/src/type42/Jamfile kiva/agg/freetype2/src/type42/module.mk kiva/agg/freetype2/src/type42/rules.mk kiva/agg/freetype2/src/type42/t42drivr.c kiva/agg/freetype2/src/type42/t42drivr.h kiva/agg/freetype2/src/type42/t42error.h kiva/agg/freetype2/src/type42/t42objs.c kiva/agg/freetype2/src/type42/t42objs.h kiva/agg/freetype2/src/type42/t42parse.c kiva/agg/freetype2/src/type42/t42parse.h kiva/agg/freetype2/src/type42/t42types.h kiva/agg/freetype2/src/type42/type42.c kiva/agg/freetype2/src/winfonts/Jamfile kiva/agg/freetype2/src/winfonts/fnterrs.h kiva/agg/freetype2/src/winfonts/module.mk kiva/agg/freetype2/src/winfonts/rules.mk kiva/agg/freetype2/src/winfonts/winfnt.c kiva/agg/freetype2/src/winfonts/winfnt.h kiva/agg/src/affine_matrix.i kiva/agg/src/agg_std_string.i kiva/agg/src/agg_typemaps.i kiva/agg/src/compiled_path.i kiva/agg/src/constants.i kiva/agg/src/dummy.cpp kiva/agg/src/font_type.i kiva/agg/src/gl_graphics_context.cpp kiva/agg/src/gl_graphics_context.h kiva/agg/src/graphics_context.i kiva/agg/src/hit_test.i kiva/agg/src/kiva.dsp kiva/agg/src/kiva.dsw kiva/agg/src/kiva.sln kiva/agg/src/kiva.vcproj kiva/agg/src/kiva_affine_helpers.cpp kiva/agg/src/kiva_affine_helpers.h kiva/agg/src/kiva_alpha_gamma.h kiva/agg/src/kiva_basics.h kiva/agg/src/kiva_compiled_path.cpp kiva/agg/src/kiva_compiled_path.h kiva/agg/src/kiva_constants.h kiva/agg/src/kiva_dash_type.h kiva/agg/src/kiva_exceptions.h kiva/agg/src/kiva_font_type.cpp kiva/agg/src/kiva_font_type.h kiva/agg/src/kiva_gradient.cpp kiva/agg/src/kiva_gradient.h kiva/agg/src/kiva_graphics_context.h kiva/agg/src/kiva_graphics_context_base.cpp kiva/agg/src/kiva_graphics_context_base.h kiva/agg/src/kiva_graphics_state.h kiva/agg/src/kiva_hit_test.cpp kiva/agg/src/kiva_hit_test.h kiva/agg/src/kiva_image_filters.h kiva/agg/src/kiva_pix_format.h kiva/agg/src/kiva_rect.cpp kiva/agg/src/kiva_rect.h kiva/agg/src/numeric.i kiva/agg/src/numeric_ext.i kiva/agg/src/readme.txt kiva/agg/src/rect.i kiva/agg/src/rgba.i kiva/agg/src/rgba_array.i kiva/agg/src/sequence_to_array.i kiva/agg/src/swig_questions.txt kiva/agg/src/todo.txt kiva/agg/src/tst_convert.py kiva/agg/src/gl/agg_bmp.cpp kiva/agg/src/gl/agg_bmp.h kiva/agg/src/gl/plat_support.i kiva/agg/src/gl_test/Lesson2.cpp kiva/agg/src/gl_test/Lesson2.h kiva/agg/src/gl_test/gl_test.cpp kiva/agg/src/gl_test/gl_test.vcproj kiva/agg/src/gtk1/agg_bmp.cpp kiva/agg/src/gtk1/agg_bmp.h kiva/agg/src/gtk1/agg_platform_specific.cpp kiva/agg/src/gtk1/agg_platform_specific.h kiva/agg/src/gtk1/plat_support.i kiva/agg/src/win32/agg_bmp.cpp kiva/agg/src/win32/agg_bmp.h kiva/agg/src/win32/agg_platform_specific.cpp kiva/agg/src/win32/agg_platform_specific.h kiva/agg/src/win32/plat_support.i kiva/agg/src/win32/wx_agg_debug/wx_agg_debug.dsp kiva/agg/src/win32/wx_agg_debug/wx_agg_debug.dsw kiva/agg/src/x11/agg_bmp.cpp kiva/agg/src/x11/agg_bmp.h kiva/agg/src/x11/agg_platform_specific.cpp kiva/agg/src/x11/agg_platform_specific.h kiva/agg/src/x11/plat_support.i kiva/fonttools/__init__.py kiva/fonttools/afm.py kiva/fonttools/font.py kiva/fonttools/font_manager.py kiva/fonttools/sstruct.py kiva/fonttools/fontTools/__init__.py kiva/fonttools/fontTools/misc/__init__.py kiva/fonttools/fontTools/misc/textTools.py kiva/fonttools/fontTools/ttLib/__init__.py kiva/fonttools/fontTools/ttLib/macUtils.py kiva/fonttools/fontTools/ttLib/sfnt.py kiva/fonttools/fontTools/ttLib/tables/DefaultTable.py kiva/fonttools/fontTools/ttLib/tables/__init__.py kiva/fonttools/fontTools/ttLib/tables/_n_a_m_e.py kiva/fonttools/misc/__init__.py kiva/fonttools/misc/textTools.py kiva/fonttools/tests/__init__.py kiva/fonttools/tests/test_sstruct.py kiva/quartz/__init__.py kiva/quartz/setup.py kiva/tests/__init__.py kiva/tests/affine_test_case.py kiva/tests/basecore2d_test_case.py kiva/tests/drawing_tester.py kiva/tests/dummy.py kiva/tests/test_agg_drawing.py kiva/tests/test_cairo_drawing.py kiva/tests/test_gl_drawing.py kiva/tests/test_kiva_test_assistant.py kiva/tests/test_macport.py kiva/tests/test_pdf_drawing.py kiva/tests/test_ps_drawing.py kiva/tests/test_qpainter_drawing.py kiva/tests/test_svg_drawing.py kiva/trait_defs/__init__.py kiva/trait_defs/api.py kiva/trait_defs/kiva_font_trait.py kiva/trait_defs/ui/__init__.py kiva/trait_defs/ui/wx/__init__.py kiva/trait_defs/ui/wx/kiva_font_editor.pyenthought-chaco2-4.5.1.orig/enable.egg-info/dependency_links.txt0000644000175000017500000000000112516137725023671 0ustar varunvarun enthought-chaco2-4.5.1.orig/enable.egg-info/PKG-INFO0000644000175000017500000001270712516137725020727 0ustar varunvarunMetadata-Version: 1.1 Name: enable Version: 4.5.1 Summary: low-level drawing and interaction Home-page: https://github.com/enthought/enable/ Author: ETS Developers Author-email: enthought-dev@enthought.com License: BSD Download-URL: https://github.com/enthought/enable/archive/4.5.1.tar.gz Description: ========================================= enable: low-level drawing and interaction ========================================= http://github.enthought.com/enable .. image:: https://travis-ci.org/enthought/enable.svg?branch=master :target: https://travis-ci.org/enthought/enable :alt: Build status .. image:: https://coveralls.io/repos/enthought/enable/badge.png :target: https://coveralls.io/r/enthought/enable :alt: Coverage status The Enable *project* provides two related multi-platform *packages* for drawing GUI objects. - **Enable**: An object drawing library that supports containment and event notification. - **Kiva**: A multi-platform DisplayPDF vector drawing engine. Enable ------ The Enable package is a multi-platform object drawing library built on top of Kiva. The core of Enable is a container/component model for drawing and event notification. The core concepts of Enable are: - Component - Container - Events (mouse, drag, and key events) Enable provides a high-level interface for creating GUI objects, while enabling a high level of control over user interaction. Enable is a supporting technology for the Chaco and BlockCanvas projects. Kiva ---- Kiva is a multi-platform DisplayPDF vector drawing engine that supports multiple output backends, including Windows, GTK, and Macintosh native windowing systems, a variety of raster image formats, PDF, and Postscript. DisplayPDF is more of a convention than an actual specification. It is a path-based drawing API based on a subset of the Adobe PDF specification. Besides basic vector drawing concepts such as paths, rects, line sytles, and the graphics state stack, it also supports pattern fills, antialiasing, and transparency. Perhaps the most popular implementation of DisplayPDF is Apple's Quartz 2-D graphics API in Mac OS X. Kiva Features ````````````` Kiva currently implements the following features: - paths and compiled paths; arcs, bezier curves, rectangles - graphics state stack - clip stack, disjoint rectangular clip regions - raster image blitting - arbitrary affine transforms of the graphics context - bevelled and mitered joins - line width, line dash - Freetype or native fonts - RGB, RGBA, or grayscale color depths - transparency Prerequisites ------------- You must have the following libraries installed before building the Enable/Kiva project: - `Setuptools `_ - `Numpy `_ - `SWIG `_ - (on Linux) X11-devel (development tools for X11) - (on Mac OS X) `Cython `_ Enable/Kiva also have the following requirements: .. rubric:: Runtime: - `Numpy `_ - `PIL `_ - `traits 4.5.0 `_ - `traitsui 4.4.0 `_ - `pyface 4.5.0 `_ .. rubric:: Optional: - `apptools 4.3.0 `_ - (Qt backend) `PySide `_ or `PyQt4 `_ - (WX backend) `WxPython version 2.8.11.0 `_ - (GL backend) `pyglet version 1.1.4 `_ - (GL backend) `pygarrayimage `_ - (SVG backend) `PyParsing `_ - (PDF backend) `ReportLab Toolkit version 3.1 `_ - (Cairo backend) `PyCairo 1.10.0 `_ - (Constrained layout) `kiwisolver `_ Platform: Windows Platform: Linux Platform: Mac OS-X Platform: Unix Platform: Solaris Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Science/Research Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: MacOS Classifier: Operating System :: Microsoft :: Windows Classifier: Operating System :: OS Independent Classifier: Operating System :: POSIX Classifier: Operating System :: Unix Classifier: Programming Language :: C Classifier: Programming Language :: Python Classifier: Topic :: Scientific/Engineering Classifier: Topic :: Software Development Classifier: Topic :: Software Development :: Libraries enthought-chaco2-4.5.1.orig/PKG-INFO0000644000175000017500000001270712516137726016010 0ustar varunvarunMetadata-Version: 1.1 Name: enable Version: 4.5.1 Summary: low-level drawing and interaction Home-page: https://github.com/enthought/enable/ Author: ETS Developers Author-email: enthought-dev@enthought.com License: BSD Download-URL: https://github.com/enthought/enable/archive/4.5.1.tar.gz Description: ========================================= enable: low-level drawing and interaction ========================================= http://github.enthought.com/enable .. image:: https://travis-ci.org/enthought/enable.svg?branch=master :target: https://travis-ci.org/enthought/enable :alt: Build status .. image:: https://coveralls.io/repos/enthought/enable/badge.png :target: https://coveralls.io/r/enthought/enable :alt: Coverage status The Enable *project* provides two related multi-platform *packages* for drawing GUI objects. - **Enable**: An object drawing library that supports containment and event notification. - **Kiva**: A multi-platform DisplayPDF vector drawing engine. Enable ------ The Enable package is a multi-platform object drawing library built on top of Kiva. The core of Enable is a container/component model for drawing and event notification. The core concepts of Enable are: - Component - Container - Events (mouse, drag, and key events) Enable provides a high-level interface for creating GUI objects, while enabling a high level of control over user interaction. Enable is a supporting technology for the Chaco and BlockCanvas projects. Kiva ---- Kiva is a multi-platform DisplayPDF vector drawing engine that supports multiple output backends, including Windows, GTK, and Macintosh native windowing systems, a variety of raster image formats, PDF, and Postscript. DisplayPDF is more of a convention than an actual specification. It is a path-based drawing API based on a subset of the Adobe PDF specification. Besides basic vector drawing concepts such as paths, rects, line sytles, and the graphics state stack, it also supports pattern fills, antialiasing, and transparency. Perhaps the most popular implementation of DisplayPDF is Apple's Quartz 2-D graphics API in Mac OS X. Kiva Features ````````````` Kiva currently implements the following features: - paths and compiled paths; arcs, bezier curves, rectangles - graphics state stack - clip stack, disjoint rectangular clip regions - raster image blitting - arbitrary affine transforms of the graphics context - bevelled and mitered joins - line width, line dash - Freetype or native fonts - RGB, RGBA, or grayscale color depths - transparency Prerequisites ------------- You must have the following libraries installed before building the Enable/Kiva project: - `Setuptools `_ - `Numpy `_ - `SWIG `_ - (on Linux) X11-devel (development tools for X11) - (on Mac OS X) `Cython `_ Enable/Kiva also have the following requirements: .. rubric:: Runtime: - `Numpy `_ - `PIL `_ - `traits 4.5.0 `_ - `traitsui 4.4.0 `_ - `pyface 4.5.0 `_ .. rubric:: Optional: - `apptools 4.3.0 `_ - (Qt backend) `PySide `_ or `PyQt4 `_ - (WX backend) `WxPython version 2.8.11.0 `_ - (GL backend) `pyglet version 1.1.4 `_ - (GL backend) `pygarrayimage `_ - (SVG backend) `PyParsing `_ - (PDF backend) `ReportLab Toolkit version 3.1 `_ - (Cairo backend) `PyCairo 1.10.0 `_ - (Constrained layout) `kiwisolver `_ Platform: Windows Platform: Linux Platform: Mac OS-X Platform: Unix Platform: Solaris Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Science/Research Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: MacOS Classifier: Operating System :: Microsoft :: Windows Classifier: Operating System :: OS Independent Classifier: Operating System :: POSIX Classifier: Operating System :: Unix Classifier: Programming Language :: C Classifier: Programming Language :: Python Classifier: Topic :: Scientific/Engineering Classifier: Topic :: Software Development Classifier: Topic :: Software Development :: Libraries