enthought-chaco2-4.1.0.orig/0000755000175000017500000000000011674464656014710 5ustar varunvarunenthought-chaco2-4.1.0.orig/examples/0000755000175000017500000000000011674463635016522 5ustar varunvarunenthought-chaco2-4.1.0.orig/examples/kiva/0000755000175000017500000000000011674463635017454 5ustar varunvarunenthought-chaco2-4.1.0.orig/examples/kiva/star1.py0000644000175000017500000000103611674463635021060 0ustar varunvarunfrom kiva.image import GraphicsContext from kiva import constants def add_star(gc): gc.begin_path() # star gc.move_to(-20,-30) gc.line_to(0,30) gc.line_to(20,-30) gc.line_to(-30,10) gc.line_to(30,10) gc.close_path() #line at top of star gc.move_to(-10,30) gc.line_to(10,30) gc = GraphicsContext((500,500)) gc.translate_ctm(250,300) add_star(gc) gc.draw_path() gc.translate_ctm(0,-100) add_star(gc) gc.set_fill_color((0.0,0.0,1.0)) gc.draw_path(constants.EOF_FILL_STROKE) gc.save("star1.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/pyglet_gl.py0000644000175000017500000000244711674463635022023 0ustar varunvarunfrom __future__ import with_statement from numpy import array from pyglet.window import key, Window try: from kiva.gl import GraphicsContext except ImportError, e: raise Exception(e) from kiva.constants import FILL, STROKE, FILL_STROKE class TestWindow(Window): """ Press Q or Escape to exit """ def __init__(self, *args, **kw): Window.__init__(self, *args, **kw) self.init_window() def init_window(self): self.gc = GraphicsContext(size=(self.width, self.height)) self.gc.gl_init() def on_key_press(self, symbol, modifiers): if symbol in (key.ESCAPE, key.Q): self.has_exit = True def draw(self): gc = self.gc with gc: gc.clear((0, 1, 0, 1)) gc.set_stroke_color((1,1,1,1)) gc.set_line_width(2) pts = array([[50, 50], [50,100], [100,100], [100,50]]) gc.begin_path() gc.lines(pts) gc.close_path() gc.draw_path(STROKE) gc.flush() def main(): win = TestWindow(width = 640, height=480) exit = False while not exit: win.switch_to() win.dispatch_events() win.clear() win.draw() win.flip() exit = win.has_exit if __name__ == "__main__": main() enthought-chaco2-4.1.0.orig/examples/kiva/simple.py0000644000175000017500000000046111674463635021320 0ustar varunvarunfrom kiva import constants from kiva.image import GraphicsContext gc = GraphicsContext((100,100)) gc.clear() gc.set_line_cap(constants.CAP_SQUARE) gc.set_line_join(constants.JOIN_MITER) gc.set_stroke_color((1,0,0)) gc.set_fill_color((0,0,1)) gc.rect(0, 0, 30, 30) gc.draw_path() gc.save("simple.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/pdf_arcs.py0000644000175000017500000000304611674463635021612 0ustar varunvarunfrom __future__ import with_statement from numpy import pi from reportlab.pdfgen.canvas import Canvas from reportlab.lib.pagesizes import letter from kiva.pdf import GraphicsContext def draw_ellipse(gc, x, y, major, minor, angle): """ Draws an ellipse given major and minor axis lengths. **angle** is the angle between the major axis and the X axis, in radians. """ with gc: gc.translate_ctm(x, y) ratio = float(major) / minor gc.rotate_ctm(angle) gc.scale_ctm(ratio, 1.0) gc.arc(0, 0, minor, 0.0, 2 * pi) gc.stroke_path() gc.move_to(-minor, 0) gc.line_to(minor, 0) gc.move_to(0, -minor) gc.line_to(0, minor) gc.stroke_path() def draw_round_rect(gc): """ Draws a black rect with round corners. """ w = 500 h = 500 r = max(1, min(w,h)/10) gc.set_line_width(2.0) gc.set_stroke_color((0.0, 0.0, 0.0, 1.0)) gc.move_to(w/3, h/2) gc.arc_to(w/3, 2*h/3, w/2, 2*h/3, r) gc.arc_to(2*w/3, 2*h/3, 2*w/3, h/2, r) gc.arc_to(2*w/3, h/3, w/2, h/3, r) gc.arc_to(w/3, h/3, w/3, h/2, r) gc.line_to(w/3, h/2) gc.stroke_path() canvas = Canvas(filename='arcs.pdf', pagesize=letter) gc = GraphicsContext(canvas) gc.set_alpha(0.3) gc.set_stroke_color((1.0,0.0,0.0)) gc.set_fill_color((0.0,1.0,0.0)) gc.rect(95, 95, 10, 10) gc.fill_path() draw_ellipse(gc, 100, 100, 35.0, 25.0, pi / 6) draw_round_rect(gc) gc.save() enthought-chaco2-4.1.0.orig/examples/kiva/.gitignore0000644000175000017500000000000611674463635021440 0ustar varunvarun*.bmp enthought-chaco2-4.1.0.orig/examples/kiva/sub_path.py0000644000175000017500000000172011674463635021633 0ustar varunvarun from numpy import array from kiva.image import GraphicsContext line_color = (0.0,0.0,0.0) fill_color = array((200.,184.,106.))/255. gc = GraphicsContext((900,900)) gc.rect(30,30,850,300) gc.set_fill_color(fill_color) gc.fill_path() gc.set_fill_color((0.,0.,0.,.4)) gc.translate_ctm(50,50) gc.move_to(10,10) gc.line_to(400,400) gc.move_to(410,10) gc.line_to(410,400) gc.line_to(710,400) gc.line_to(550,300) gc.line_to(710,200) gc.line_to(500,10) gc.close_path() gc.rect(750,10,390,390) gc.draw_path() gc.save("sub_path1.bmp") line_color = (0.0,0.0,0.0) fill_color = array((200.,184.,106.))/255. gc = GraphicsContext((900, 900)) gc.rect(30,30,850,300) gc.set_fill_color(fill_color) gc.fill_path() gc.set_fill_color((0.,0.,0.,.4)) gc.translate_ctm(50,50) gc.move_to(10,10) gc.line_to(400,400) gc.move_to(410,10) gc.line_to(410,400) gc.line_to(710,400) gc.curve_to(550,300,710,200,500,10) gc.close_path() gc.rect(650,10,390,390) gc.fill_path() gc.save("sub_path2.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/agg/0000755000175000017500000000000011674463635020212 5ustar varunvarunenthought-chaco2-4.1.0.orig/examples/kiva/agg/star1.py0000644000175000017500000000100111674463635021606 0ustar varunvarunimport kiva from kiva import agg def add_star(gc): gc.begin_path() # star gc.move_to(-20,-30) gc.line_to(0,30) gc.line_to(20,-30) gc.line_to(-30,10) gc.line_to(30,10) gc.close_path() #line at top of star gc.move_to(-10,30) gc.line_to(10,30) gc = agg.GraphicsContextArray((500,500)) gc.translate_ctm(250,300) add_star(gc) gc.draw_path() gc.translate_ctm(0,-100) add_star(gc) gc.set_fill_color((0.0,0.0,1.0)) gc.draw_path(kiva.EOF_FILL_STROKE) gc.save("star1.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/agg/star2.py0000644000175000017500000000123411674463635021617 0ustar varunvarunfrom __future__ import with_statement from math import pi from kiva import agg def add_star(gc): gc.begin_path() gc.move_to(-20,-30) gc.line_to(0,30) gc.line_to(20,-30) gc.line_to(-30,10) gc.line_to(30,10) gc.close_path() gc.move_to(-10,30) gc.line_to(10,30) gc = agg.GraphicsContextArray((500,500)) gc.set_alpha(0.3) gc.set_stroke_color((1.0,0.0,0.0)) gc.set_fill_color((0.0,1.0,0.0)) for i in range(0,600,5): with gc: gc.translate_ctm(i,i) gc.rotate_ctm(i*pi/180.) add_star(gc) gc.draw_path() gc.set_fill_color((0.5,0.5,0.5)) gc.rect(150,150,200,200) gc.fill_path() gc.save("star2.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/agg/finger1.gif0000644000175000017500000020446011674463635022242 0ustar varunvarunGIF89a  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~!,m;{ᣧ;zكGO>wcGSO=}4=#O?S<:CÎ<;lM>HK-؂/bKK1Lc2hcL-1䢋03,..BK*2K(K/)(R)KrK,e- 3 1Hy 3TL441-Rz!-B'I*Ȓ(@#|+|"XI' ,.R,K2i.L2!aI.`"/H#M3Hb\$b";<=3<:w=,?;ܻ;33cj-y +(11Kѻ20 40RK.0$_"X,vQ _8*FQ1SbL0^E ]02^ i|ΐF3_-T V"X)Z ^$Cň)0BBD&TF@XE+NPȄ(BY`,K/U"P,7VE)8AJlD%@̪'4 X",R1$':!;b(0B@J|GE1 El,Ƈ.!P/q~0ɫwzC; Z0cn#ך8Z,*RAO .eE.RN'n%EJ ZQ;0|Q Tį@LM -( "0g _@7|BE0 . A%T':QBVP!!Si#U"*vW4). O4S?#?x8+6AFPbh)j lD!*_ c8APռar=;cֺ]HK =џwT1LlB<*\1K$1+j1 TXp4Q !E/'XtI@E Oq[bE)*\.fv [0$D!M41Z-^10["(2qv(!a7<%" JH68 KDB8H5Ab? ZyyU`!`Jy| JxD,Q pL!`- lc8= I|X򮙔sc|G=\?#=wv…J\BC$krb]i'OD)H J&)XPt-L `2P2v1ZBPyZ*WbGbEʊьL|0v1\z'ЇB@8%BXN,% QH\0+f4W"xD(\ K0rD&0hNt P% M!2EG"䠆(0PH:H\r+%-=!?럷<҇>xl#EE+$ IT^P#*a6R̂U$N*LD`+ɓQOLB+Ɗ*SD )ڂu-bQ S:S ` `h"%Gb ΰ v t KOM` #P pQ6ig P  - P)%)0 P?mF p @{` D l ͧS jqpPF ,G  @cp e .C ~ M U Q0 0+t Y4yvFZd u9# W t "@ P P  ! h`n beL zP`ppnҒ$d4Vd&IplJ  8  Av0 9 Y(wxwߥwL (K5cSCm' HXBZ U XLٗe ph>W # VdFPq0 %׌0^@ h2 *LP 'E @CPr7 m @ Ђw` vwX% !p PvE Ơ -{y(4-;yV!4-woG@  " T ՚ 7pwEoF; 0msE蔍( phx e Xp xQi `v`N ,uL" N ( ΀17p 6 0f` N#Y 0HT&X $P  `f `H op"Q7`q@| 3P P -7;&V YIv=p ` p7 \DC P  E wPZCz`FPi @ G \#EB#$ ` 0 0 p P Py2`(wrzZMSs!O 3B Wp64 @E9 vp @ ~gEq 9wv tPs ieTnPPw@p@ fj E  `sIւzxa.&4V(){@ P v ?Z , 3 ` %s5H6'驮@ [p yI x 0 | uRI w3Sxsw N "]pWi25Oʷ1 &>0 H @p p \ S6 K4L0l@ivz 7PQBu}Zr` 7 up p.-;3Iwp{T.&4O "[9x!׍EC֢gr}@D "P̷ 0 ~r pAKp,p 9 0 b0ps W v˳{ q$WtJ~\p P pJhɧLޥ Ny{ $I3 DbMh r` Ej<6{$}`@RtK |Ff՝B P| Y$ $"8B_ {3. a ` : [ y xNh zi` ~^ ! qP 9 PQD ` z ;Pp Ӏ~0-P|}<-lP 1t =% hP'&δiV )`jh $ 7 r}  P`gE٣C3\s # 82p0D} M>*$pMk *p B Ťf_ K| N2 5 a pv`D \jpP8e  x ÕK  8RTO ݐ 0 '+ հ Yƒ@ {vh. ː 0E@`~0 }|) U XK 4t{' xrL"J @gPeD, 쭣Jr \CO#\? " >Rr@0rz0B㓛 ) @Aߕ#_r6`v[| t@A 6٤ 0 gǨ[mG9p5 ۰ ް ` n<\<P% `(S@ p47@w^Z@p fr j$0  f9 ^I d ^MF UZnɔ*VBueRLjAx94(#J4'L0}Rk'LУI0H"FhvKԢ;w Q=~Dj(DԉO ]z+צ=rQ*[RrEJ0bDu4j±K-\7nI;Ə|廷~W/^:mjĈO 5J&LNՉԪJuP,W\ՂJ*R0m UJ.[2Qʴ:)JJ% - u¥%KQEUդDRZ*+[hdH29EYdŗOL\VAŕTV$= >B dLYE\^Y7M<*d>G$!`zG#Ac>xC =yM"DQeR&GzBb0B`06S::M0@^\)DPGOxV"<7:J"2AhCRx<1<ȃPxKH;S Sf(_QFЄ] L-I[ЅcdkoxhhuhrwRwwpM"h0*Gĕ+JXHHhZKN0`ЅV8˱W(@tc`xɅ 'LhbX'*[-WeH\LJLaYT(X\x}\W``dJhC I+K?Y[F5DڨDE M8K@1n8P@8PKhK^WfH{jq͗2E[$TVȅ^]ba]FLKHI2фI>h51 _7@;hW85p=ȃDh?XM(? *U`>_TK] SX? 9B@=xXPjfa`nqlo̤;Gvh^Fo]N(*h-KzISd(%,RKѻQȩ"d`@%YPL0,jCpI0(MU8XPf`=c(WԣbDf`dg\xRWP_qA= >E=c0i|"ɵFHx, BP&L %3Oٶ86;p4؃H@|EMCbv*cF胔B8;tC9nRJoxr mu@DVdF~!ult ch=i3P^a[R`/^YȅU haa@%NxbHXkÄSg腖p_H`82T8gT0[eݳNOVK8yMYc[ BЇK <"\ srL#QvJ3ML+y1胛 @6X#E-Q UPBEQ(6(b;oM8Ylros;9@dv`dUJsjA2^AHH(R^A.ɰLjC1P}Yf[8HaA@Mb@YTep^NQ5zgOX8]060YO7L[Dr@Z`B;IG(rPhHNx,Kx7 b:քs@:(<:>P!U(B_Ȅo8r8tl8whw`S!j)cP  (]YSQLPzQfoU8iѵ%AY,Y8 e[@>苄A{YcY_QV Vx_JhRYHKWd__a8d`_8[j :T9EHmN@@PQ\HX Sh?`M*F(LpA=լ>pd=P895F"-IS>JhEI=YCrpuPrnuuP9-XxGN+ox脾)`AIJ$J[_J(t\mS_eiVjCV_;ckjhPTPP\`L[J;]зd@enc* Z=QmiϯXصa<U(x8Y"F0YP>D==h:";CxN@:@xیKBhŻI&V},?Fcp 4!26ЃAxZSKw(#+kI hL*äK4e锩Sp%*S TT¢UV_VY꘶e:iB3JuL%H^V!MUSJ*-c׮ZnrJUI?lقE+W.YX2&#Iw92UJ&QTyi%VE]*VIBD)3"N g)Jt(J*'>TOC2qtO#L­{7gЪ[g-3yk.^;yɛ_L*'RXJ%T&W>yDɑ#F0T)(̢0$(.I(L/Lċ+!"4x"$@/1IIHS1XB)D1% 1 ,ҋ0򊑥$He4b %|Q#K-J*4 &ZJBI$HBW'((b"L.v` &o4R%%SB$ ,8b z!ш-J&yM 5p 6 /׌uja;x<:"R|0R ( &'l)|C; [x|HCHI%ч" RЄ+j A)^! g/ ZN0("W\7C!\ j$6^VU|iDV}l0%q<b?Aqr}څ)vQ_H 1 JD'F1\B$Exx$-v%(B!)he7*t"Y_-m(p/@cG=E`XJ|BpzC,8(*ED٠`' P,nL,#`'K0'-*\D43p~ '2@C0t'09T, ,1-0#B8 -.B(,$&hB+./̊Q< F$`p)Ԃ/H1'BCp&TLPB*tB#*D-C/%P#]"d($BA$ a"h,܂}J,(C1B%,B,0#B+<9@+R.|Ѓ<=0R;<61ă:C:5@2R00OBf9T‘~Z%Tc"'-њ񂒢(BypT O%l'`I,H7\0,5:B/x3BDC8DCـXB3G;'63p;+]PO(Rt-C/BV-h~B#ġds" wbT#"B!<%t0"AOG, B% % B TFf3'1#!賍V(Bx*w4X5@g>x{ǎ\7oU Y3`ubK'KQQB;6Y2IWxiG$ye-er1eV%Kh!g<ɧzGy܁nclNRƘUjy%T6eT2QUJliWR EORQT%[nQ>Y]!]80VchC&cH`5PFS)w dhƘF1\G GlDؠ6 |6 ^F5qa#٨(aI(ދbъMh'X UBFP+P!S"x] K, e#&J F' P x*Z1LBad(F1 ]"%Va[x+:A =A{@2CP8/41 PEQB G$?qMm(qL|b`+ N@B-f Kb0.l0X,0L 9UNx$aaZp}1 ` (nn@#$4 el#P3f`ܸ4!j0s!:hE-\J0b-jRXb-R1 Ip"LxBu!`M(" *F?\@!pBT&VQ eȭE2XBpE [B )2=яCޘ31<`1HE/0*\Ax"^! I201! +/7QW\BR8Z8M(V Up0+d1BM%2L4" &N &(Qq[/8`@P$nA c$Jt i˜Ѕ+P T$+BD;F05X1"l`1 fE3za XF+* Rx < !(l* R+Q+rAQHE'Pc`D'NO"E%eqU|AE/rы0ܡЇ?ax4\ЂRcK4HE+01J0&"J(S6F* MxX(HsA#P!XAj6A>@>Ҏnf8a.(jAja;Z+2Gd! OljR.a :͑!HEfA*la<w`t.Aↈl! &aPAf,H*2a8O`a"0hx`!5ag&@:aO/JOm@T!ȇvxacafA;OG@?AءA H6h!2BC.F$:^b(v B^Љ(f,Ar8j-mALA&Ad!eXZD(TtAhA!A|Af1DagA^N!!~aV!lFah<Nb! %Z~,.AL!`!L! FTa #i댊+(4c!܀!@`ʅAfiRC(lpT(g@ڇ2-bDh!Ha@:`!tޏ"@A"KۼtXxa:0Pa[alo|x"aaAz'0C/$da1T 0o#H$r\PȷA a`&P! aƯ^9ad8a .">XGXq!  a(4nzbYŷ>)Wk AHb!Z @ 4[M~a&HtaZl0ar+cl!(A!,7!0a2!F&Bzj^vty$!LYzz!gH!+\d &aQ,P%AaҰi Hpxa!a8ID9:II@LƦ0M?h0RO!XDW"Pap4+Aa~-!!n,|@J^a XjA166N짿-0IT|Xa x6F,>!]jA26RNJa!ZEXe0\kliDn0JbO H" l7aKkR@\'Aǩ 4ABA,d).hA\ԋܕ xa~W!!d̈b!0N!!Sa224,(yM&aCfAh;!~4VTa\Hk"Р! OI`>v6AA0(_r /]DM!6uM:FB*;$j!3(\aZ!~Rh3<FAaf8a/aHx( YrT%aU!rp!AAAJ*a*a Af|o#Mk"9E`HO"$s̀ ``ADF@|DB"d ib<6xY w!ޡtpAvQ3KMataJ@D&(!ArR!m-!ܚG9<at!8~MD!n<@ D |AqaCxhA.!!FaRAb!0! `l1\y5`t!U!7 @EK V:A bl|c p2K!`A~= FAbCcD,Z X!vApx+՗XaTX!l"e6anA8-kBhB&I22A@aQWڠ xJ2#ia@0DpC}6@ A|!ab%M2ARi(H<ҒǞy͋grEjU.`f*T¤5+*%QlHTXxzV,TV 'GaBJ!FPLö%5oJvM!7w A-3(ѪiڂBA0Z,3hنZ+_NbԧM^l\hĉԬ]F]*ɔP:.TJ1W$]z$>}$hJv,)30 ϧ]JUڔi)T:u W,M2MJ J\¤*" $DH 2#=1t-ph"(0 N(E'G%" MToAV Q|&:Q*E"@0B MœT)Ub{' l$ &,AhH6 @| * iCPF)$aZ#b)2j`Ԡ6X>`'Ss*<@)H QXBDSJx"G7Zb9E)>@BP(TQ N"0Es P°!GBq'jVXH# sZy@(nѷ\|3Q0{C#5e(+,2 G,w)\G,(4"'N O0x*Da+NWb! mDC5 (D&nQBx,W,3JU\#ZEa IΈ4q i,#x3 gtc)RU 0%@!}8NSq(XȢP(2;P,j$* \ȺĽ M$X _pb,P!Z (VDl"'Lr H#F\ehE-=DzC,1 K8Ѓ" C.ь__p9.ҊVkRj+@S. -Ds ̐GP1Q EbE*@lx6bD}WKT! r  Sr BV @-@3ѕ a |v'P p Ù 0 @XB m -` * | @ / g @2 Xv jBP p > ڐ  W ` ` @ ٰ 0 (ߦ ׀ 5} p Da <` s %b@ 4   fv 0 & zYq} 0 )3 K#gbBA @ Q vqY@P  Jq XpBP  r P 1)VV > *W" $gPb Ͱ  sp  0 { z А&. R@ `1C r 0 p ΰS] tG d O^9 ` 5 & d 9B|p Ђ P Y P $ք  p @ ,` % P ` @|pBِ m /f * ǐ j Jp S P?t/ P jA " #^'|$ 0 " { x װ kmƀ  @} Ȑ;$ P ̀ 0 Ѱ 0 X € : p  UDZ` P %C) S` 0km0 0   (P2 5 C w @ Š& P p`` 8lp @ p ` 7 ̠ E pX  68 d  F`y1V  ͠ v p PPi l* p T= GJ0 ˰ ŰY00   =è Х S?g}d( ~ w`  ;# J G > !"K Mi. wP{*ڀ 0 P)  = b À # @ )\ 1ui @ *V 0 0  W e  0 LG< #F 6Q Re P[ G!M O|pw@ [@ ` Jv ˱p @ P e }d '0 t Aa 0 OK @ ̊ w0C @b75 ` @ \ V T 0 %.7o `gM -YDT cP @ p ~ +  ɠ `NR 1p} Y 0 `   ?/sL &[  z0y o` h ǀ B  n" N ʤF  ͥ20 ͐ |ڰ@ / e@b qIH`u0 R& (CzKӨR_0",\Žm:0WMBk׮^@uZ+TlS2\ș/^=z#X/T8:TA\:UJLT딩YpR*SMv 땧LLBv$Dp4`\)'U̖kڳ^ 拑MƆuZ6e0VMTPɬauj֫\tZ`ER0TLQDkze\@$Sx)fdVMD[JYJ:$JN%Q6჎NQFQ"dcV]ifM%SP %RcEXA&LbWj%ZHo5VF_xIZӥSjAf^ZAZz'{ah`~\jDXdeY%_^$N]R*1)]*F1%^%@tMlejI%PLaV$pŒPQFDRd$hdeS8%faEPATEDO^qœJ. XLQHb\&cpdD[I&W0ePXaQEOVQX\6]^)cNeYXqe9i[>VzчwfɅZ|M*$[n)\eNKi7[DJ0Y`rY%FMlad9M[T76XphE[JG`Dnna$S9FlyP2EkX$bq&QVfh GCTeSd f` Q0 W~ɦ7gfSxf E<IdxͩVl'e)1\`4$#L"З)\ T01P,[5F-T!5u2*Xix1f bhAzF0:#],{x'\Q f\($ &ZBЄ%NHbx/~ TtBH ]aۀE'*O\B84qâ) h[8! M̂0!" TʘF5vA F"ʀ4q]\*3I8bPXPB`/(Ff)hq Yb(-h! Jb#F [B`, P2-zQah"_Sd' ш]bRy+rxc<)D WָF6ы[آldL,nPE! Zxbj`PP0'RqM1a c,#(!daguȆ\!rb5 Lэ]Lb8*ؒOtF2Aglc1!_Dn'!R8CP, G b^b Fth)(Q Uȸ ^TqDgBA KbMs*B@t'hQ Jh* `.^ Wӫ.sA CDPx(PQ;C;ࡎlP,.HI2!eH)Pc¼ %ڂg0C"E2X\3-FA[Bk:/tAlL% J@x* Iذ(`! j ,44W"{ hLcǘ / =C+1 z185WZ1E+`B2*w X*E>! M&H.V1CS" Z-DVb8qB-- 0"^,xxP7QHCA)ĸE+Xg@Ct *R3`0CD`|u;*`F.2֮CD,l0ьDAE%\dH-QQT. e|h2_hE'E<6`WHϥD&jCRЍh7 [hb;5^Y("+ WPsp_RD!\ 8 "E/|QЃ#@`tE+bB8+V1щ/ *P1B 'VA f|a<[sCp4 Z:5pqMD  UhbBEv!B F+(QM{@,Q\"zdL eXn'z B8'` gA[\C(3 f+FaD.SXYH^QWhM h0@0aa`Q;d`E Ifa YmNA0c(0KPM4Q^@[*CJ`XHBpaAZh(Z:s;FPӅ1[H NJNX'kh?0vxw ^Hg@#VXeb`JhMnASx;0N>9+cS8KTP@DG(XHBHIS>oWZj5fXBkOUa`KkP޳Q(l؆jyRAl`hgPbFYȡ[P#4L4aPZXK[X`0F\`bPJ[h`3ZCSK>Zx[/tM<H؃IJ0QXLXYxX(GPK脟kX8b0z<)elh`PpF]X8LaeV_A W(rS`Y5]UpMaS@H`VO(NOX?v)@aH_C8hgzڠWZ[jH-i[H8nZf0Z rmkrc/9 M0bpl ZLPIb_f H:+R UhhX(KX@UR]XlLhE5SPRM T=(Pp`]NQY;_ _T+ЃxzrP⤆rhSG_ Z;хn\ 4PAW2`RZبYЄ@PP YH#Nxc#:Є`e`bMZ؃LFV0H!AR^gHEX\QMH?8kH`V`m qc c!dPhІmiaAhxY6K){؇y`ȅjvAhO`C\Nc\p.H \RSfh%@ȄzA(XVxI(:O…3›9Y*[8a\y/vwyHuhhr7TpUp_K Y_UX r+x1̀]Z`79dI`I  2J =xR5Y`F@L(kG\kkTlPY^_,+ڄT!5j5UocQhU@xŠHȅl[XEPY:ahPbxb@N@UafV/4Ψ^RPXXOq]IRpV0`bR^ 8xPtH)gg bW[bK4tуA1"3J(=]x,vכ?~<O$*A> Qm04a54^؃na 8a$`9ƻ n<6 G͠*L}UHKAK4b2D*aHbCp4֗ q\v(*]hB84AOE)8by['@/ RbD#4 PP'` KyBa#O"b2hJP ( NBP^;# wd{ρ [/^ [W[ع/1܄VP1gh"B4m`*LA,Ă#!B4(E&4%d.`O%p0&1$9 BP)A$(*$8xC50B#BM$B邠d%PF4؏*1l2x)_,t$BT*+0D (B^5)`BBUB*-)B,Ma&&B1x BBG(#B/+H!DB'!/,)T)X9hÝYD!5 1-0)lBՁ,` V12 C($$.¢ /!A20(8B0pC. B+D)ª( 2Bق58C)$0\-hB-LC5|"4<- TY%.$X$C*`B0l2B+#d\A(I/@1t$1Z. -\3o*{*uA/I,1?B1 Z-_&+,"%,%Y_-$+|2*ܥ-<BVBʽUX,*dXsW3C9X.ZB0*BmBHNBə¡p"@* 50N$@D)4x*Q A#BEC14B B(PG-,<2A\1C!x"B5Ă/d+!c4",80|+8CT*#`X0B @N 30X4 '\GU*1C6B' -0.h%))|)PB+y؂}B+-t%'*t#t " (%%8'ЂUi`,XlN%XB$Mc%t"-^+H({B,܁7H2\C86<,K/P,S+!5)Tz.(C†63@0%4BH0H"1(C1@P5y`B/xC6@&02h"5q"@,,1 xX:BC0lX"X0`5H4*4"|) 9PC+4B4%.LC2%@\B-+TnI!P(ěB)'0(&h(Ђ,D,ChB,B'$LB*)%\uB#pP+e&@*- h''QB$(,B8 5|3d1 3 B $RW D"$"1$K+c$!145#ȁT3$'P 1L,ܣMA"4H=rdDb*˩4B"(*0&!HL2 \3 C'/@(8@G>(0@C+<",X0,I4 $g15As '$FC/|,<#TB&,a,LC.5\/5TBb78C(.\C4C$-.-4M0_\B.4*ӅB=)ht*|(.],%*BB1؜ .B*6-0 T+%1&)*|$30L5/ SB)08‹+B!x (LX0’"('/(2%$fB#A+T)٤ hB((4B'#L¤/,zdB'W%x,U*<™+*X.C-93H,L# UXB`Bȁ 8*(B#0*BjtkX$PB)h2B!¦d̊2HBxBV A*(>A"B3x7pD=M2'\(4CjBV+HC.+)B+D7L3h)0B( +p#73x6h+w&"'$1bW/(.B0|-. /'X+ȭY%)QCJHݠB& l!)‡Ύ.'B--XC7$4 6^$.P,4B B+! d'  X) zJ*16ֵ081R-3x ¯T04-p!D+$#15B$BD0L0h[4.L'B-9B,X6C76@T:C*ʂ52%B6*T*2&4B&h24Q(`',(t-Q^.Bo&,&l)䂯B$`^B$@|!5C)tRB&x(/{$dBΧ#Eɂȁ6@73p6D/`+d.>AFXBH02t7P nl]/pAE0Mf1^\(I"PB,.r Nt$D+& `܄&qQ!D#B _D~pC$ /"8F7 QB3n;L1rajCx0q4L1 T(2YD/ W$4щDBՈ(`XCP 6z\tDAIhCT\E-v( R+QP"E) HH(4!Wb$E)Fq cb00K +xE*rQ BAqDԘ2 Yb#-TXbQЃDL-~ђVx!<_̢Vȥ#1Jn0GHbʈF)PVpP@ nAz!|avzeaGn"p[Ơ !B5j,(4Ϳp&!&@AnezB@t$JaLa |a2Al!PaH.AxYaA*%,a !!xKF~2\!EXatcvO.hZ,j &|aF?'ma!@h0&2(AFZ&.Ad! 4l*Haj@ j!jj!XADXA^haТ.Ay a0H^!rj"Ab6/r6+laI5q) Pt!2NT!AR nAAXA`an4a:J!#zO*$2t@)T!I\AlanAn(!l0宍dN-4.x 5GN!(qPP :*a= 1AX#JƌpAZ=! @A\!tXa>€:KJr+TfBxZ!T<m3!/!X$0l)\!{d(:O!a,n:AAHa+~j5TB!daNj!n@X@aLjd$6&aEa7bJ*'-zVgaBzaipA=0fha8Jd.f`Jh9l4Afa>R! L6;& Ġ!05&,T!eGFA\<ANx. vAFa~,iVATLefAra ] dl!plrUDt%A|8!Ar!,aja,a*!a*a!@' KEZJ D"aecgrArgaZza`4a.=F!g2>T U\l^!aXa~!9V.|X~L!L!|p2Fav*|~A$]3~MHEY!~pl'`!SqKI$4C[!anAzna`dU+(h!y2A$.Vi8„$a*aVa,Ax!X!z5\YkY!l3!\A6 (EhaA.a$fJ*!Za<}6WHN Bv6}A,۰b!?`A5|<HaptW"!$P(?tIuKE ua^Jjaç4b W@.|!HGFc V`} w4 b  b W|* 'tvW : ` - \   p L Ұ &f6 @ xd. P Ā ef! ` D6kW @;;[   P` @ *EbA /G Q @ ` D @G@ iPs p( @ Mt6 vH A5 )Z P PU S t ( | V n P @T  p$Y p y Ȱ ` WX 6֟p  p $' 0 5 Epy  p1 p C e ~p @VE 5II ` [!|: T k@ Os 0p(stpq 3)W 0/0 09hS ``P'p H@H ufxJ0 e oqY۰vNH% P%q# P l`  CT 86`a ! e_  93 ذ P ȫ · se pg 6t àF 8{X@PԞl){@ `0x 4# ^ ڠR 6J|E` 3>m:ɠ c@`  u Pp u` ɄX rA`57wϹp İ p!)x @-H  92hp o  0 z % 2W T{m  b͹ xw > У`e{ `~b ȉ?5 %  Zp} PP`֠ |qK!FP Eʰ: < kZ Qы  ͩ m @>: Ұ 6 P@ c=V ǐ=9$ݠo0A Y 0 pW\ 9L0GFƀ | |$. 겏-pm `!܉pp  T) Pw3w3U3w b  7 HEPܰ ˠt̾ fպ 3 wն `O&G3= A yD[Vwv,T u Dx nQ @P 0 @ (u p 2k  ɰ Յp x0 ` P p Ii Ѱ ' ] p zBL@ wL o0Up1 !(`Ò0Y px  ]]|% ; }2{rW< / 0s כBjP ZP|0  R .  Te ZrP uQMѓc@Vѵ -Ѱ  3Òf:{A A Z  p ; 0ʻPج ` 7 ۰ p 9  `9 |pV'`T0 @ l Pf࢖ `<9 9< eFr ,r f{μp ːp fD' P@/5 @2F` r K ͠ D $Pp p y0 eA J. €c@ + $ Ql)^Šm#M-TT2V4c,%,b`Ɋ%ױeЄITVx )[hTi.`|z) Gz5U\~R%H4 "LZeW1`n 6^t3VE{B ԥHhZE*U_SL/\@q*kXR'RT2J21c|RUP@UT -\!E+,Z<'ʴ8of45mݪ5t+c/[d4 Ue׺ \5d$UY,H .N@2&nN&ᄖfX%Vd[jiEQbbbѐP4A^9V8\`iZqF\:1$IT^bqEaB^veQDJaĒSNWzv)8)&ZnR0KqQ>N8!ŕVr&]h˥\tEW^Vpo+N09%Z2YP{f^xAMLu ]xM1EODoΑI^oŕR\iiÌEV@EMzd[YF`FE$p %HLŗci`ZL`1b`$J`geE69Ŗ_%I6]vTeGebxE`h9%\bm*j a *V Kdp!qC0╨4$N0ޠW gԂx%I+8 ODgl+\APpJE/T 4X0nHKt1pEZSQl`D'T c#@6^E0 ]"5Q-)J˓\t+bAS8"+: B(["DKbN"T8oFJ = x bL8lcɐ1]`B3 \?]ZPWPxLOH$.OJfNxFpڱIp3HȄrGXX \aoІ۸^b("_#lw8lu n t@:hfcP\PJSPft(i0YB؃E`dYWn`OdiOF YI?PUSPʻlrBBpK=/]P?H2AVM܅pSJX?D`qDX(#ʅy?9bHdQhWXQ[OhIH8$ɪNBHHO0<Sܐb4Lȅc@elvhlxlp7r(q(qlřt4dQpOig[C`^ihkCF[0zRV+хQ`B`J\F@O8ݠC?(I"6!i[H6O8EF؄A1˅ 7A({?0A`F1_b R C;ݛX"Zϙs9W|V=R(.^R9^X Nr'3g/2KRQ(-P0M`m*l0kȞU*jnP;=jh\BRjph3+-UJ([l@P8] M[g@ YaUN`@aJOOT޼NPqFpHB(M }1ЀDC>INK ek\"$i5I6fxVJY82q(Vp\A vic7_GB2'[@*VZ.`Q`xiXjJML`uÆ=r+QI/;z[h]8_#,ru\NU@>\kxfc0N0X>cT_0Sԩ[*ht_SGɅK] Z"@95څM J8B:8BEHNXjy YhGN;e`Tc=A^1MYNiaP`QAQȅ;]…b% )bdB JQ eW]egde{^]``LMdD_TO1O@ fۅTbSfHU`9EVFxmdNP3l5 KHPh[؅${D0- AiQEpC H8A G0JH#8:`[ TbЅ](- O[h4q4q fUeYKZ!i<Sa?ȃ=;Kij8qhXK\P*bj1^VCM [^H*ĽlkaѫMpj2Z`@V Z؅h u򹄆P`H)M8LB!=n1=~Ԧ莥. F@(DxD@Mp~7alFP@ M`^c0X΄0Qc b & hGFC9ed^`h1"MWXQX@jxqIptІmkoȆixffL9SYHgh^؛`O`V`ji0UJXcP=bd`_SٳPJسMM5CLC >!=EPD@JܠVTF@>SDH4\4df䅇;)Wg86a!"CH ۅRiuZP xS8Å/h)dH*鄖4_dqSm%dp@f@js@F}f9F1eo g $\@ÄJo+?\pk,FN"xM\>XftټvMF<CxB@ЌLLOX _zVH0kKP5i_{#ߐ1] L9ɢR_Rڈ#ÞۀhnjmQXVid\xhjHhVL뻯RO[d*i`ӄO C鄂dpElq0e tO djPbYъ)M.Pfn(f`9c_8Z=28LURgkh /DG`I3}cC洅d R&fhpQ?&T`s}:̄nCnX0ub1:]M響@CHB0FxGSHhFxT\&qsr`؅ FU(Ud@WxvD)\(-mT!'sbx0Rp PC؃=XfiZtj r0m徭+w^gl|ےgІl@VI@Phρ b7͒Sh,"g@kXWRA[Z[JE ,J MO89slo$KP V4M Y,n2^_AQ>Z P*jJ\2hZwBYQD(qimHSLHmtpdjqln߫cxGQr7o<G tXG-Vsa? SblJ0/ބN?z`)rO 7ǩƁC@gc5JVFm%kI2ICFQ*TT;Ǎ_t ƪT,ZNZ-a *VL"E\Nl+^tʵ AUNZe+W(M0q)!]e{ ib"V,2cp,7kΩ7.\7nݼ獛o}#gZy*kW1fΚUM[hvZ8jUPVu2ɐ:ũ 7 AEI)Rh+Ƌ(N$ %*T+WҢK'N^*³'R;&!z$hB x*;XTE,R,& F8pC4J(X)Т.ӌ3K. +,'." 2(Ҋ*)xJ'rWT"$hB+R4M+̒ #LbJR 4ڀL01l4L4x:ی#5<')Ս6 Ë-bJ+<4,I 4d&#̒/0s6t#`)IJ 1l"`R'J-bI8 *I+aI'4rm#}$ &(* +;5 *%2BK,R 2 0C.s"s-"(VX‰8(IWArK-2 $,I"rLll4͔"!bb . * +1  7c6DS+!r(ܲL6l6L 2((D0PS3(C&%24 *(.i"D (]+زR) +>&I$qG{GBD%"K+ -(:d .R(1-0L.|* 1H 0""L1..lIe82(BU"'lR9mI :q ]6э$c^Lb F\|A [C/b1_H7db&Na `.6 kD1v O/e(x&!>UC(*H "CH#(!Vb%2 HT"0 "U&6AByȃxG8"..F2Y|. ]rX.ȔEx[BFuVXBӅ_a(X@M)H-,! ]-5Q ]T< iL#x4phCpF4bĊVB0,z fh 1_I)8[#{7 0@(LHqBʘ5ы. cB(HQŮ* C,bD'Kpp%2qH`d&@`©j.1 #1b$2?CEs!]Ӆ+PQE.b 2BOfQV^:9cgX5^.rd T4vFofc/ qhƚld{J84(sG! "2C!0p1 hd҆7qhQO![" `q fLpj&2uy(H-vM"x2n!_ED)ZO"{D ML81KPh$@I Prc&X CɹD$̹LT@7!e$W'](duaMXӯ0g!e9v_E)HaT*~$ `'&E<" #@, EּQu<1k0x(8! 1Q*+! r4:DX ΅0+jT#n@-xⱠrLE3! ;x2 Vdb'3Vx'qKTx-1GLb%Jdb!$H8*O\TIphW$փZbp0 V"hZ`̲ f@e8J"&j KXBfrE>!J8-@J PDȅpø2q\+Dq FWh4sq00j&H(4zqQ-r[L2Q \,0|QRX2XCr3AH  D$[> CHlɉXkщI<"PְG,hk!17ŋn!W e `Z8/!*DTԜ%11qb(PWъX@LPuE-!؇b!>)%+Ԙ,JAB)Q0C!5`78`6B@һ.le6a58-*BKK9x3(m/,B\+-/B& "#\&|&&p%T%& ,B$i"d#l&(hB7LC5HCEGJȩ..0 b-%*-,4!,%(*\脂 B&&GD"H'AGi@a5 ñB, 1̆95]4Î%,(-K-B1lk . IDF6hCt8tC4ae4`CF?C)|OB-Т/%PBp·(lB1-`Y&lů RS@>ZZ$CאM^9*O-\| 0D3H-B7Ѐ$ #""T:{ h$XG J'„+4. L{%C#]E/SP5du@641h E6,C/ĂH-ChMi!-3)M,&8mTL KN %([M(] fQ&<"HBa'T%܂/j3C6TA#`Y, .UР/tT1*,PB[/C^aZQ"'D &!}(dB*>4 1CBG95plCmC9:Lx3=qW04s43a5946107<7p@El4l߮-CVL,SFJ 0bV(,aɞ5[6,'H2]diT_=c6LX_hTO@Q)Tbrj[r9JQ&AڴV.]rj//s%3F,X0X-K2b~/^prpūV[PѺ%ʒ(L&T2RN TR)W\)L*D"V^AEO:%&І-i/caQ&3^dAŔUb%WfVFdORAE dOL)ESX%S>LX1fe&j„]e檹k[Pa/U8\jEdcmғ-sqgn 'n&hU]Y|A`l aiY`d)W#Z|P>M@1EdA]N,MXYEQ\aLXHE'JQM"qdMB2SPDJZXFdM4R(PB"X'pfgA&iIh˄`z1%MTiK8a$HHsJ^E^IFSO$H:ADFM֖"|%dr'q9rѭKuFfg[9io1^^9Wyh|)~E!Lj)EDY&[T!!daR^EZ)&KeWZR$N*_NP bB-Ä͎2VBh#$cE/x"^2)\̩,H)tX!C'^q"ŸXnC"( B#RA BHE. KREe$(3䒋c1vQ"7 Y,P-T a_n<K`D)l1 ZK6Fb gHxB؋YE.bV5/ 7B,x(D" Hdh-`q!XT/da^רF5e@0HKguЀF6QmXQ#:od#YF~`$Ck12it;1vttנ2C7 E+O!b*Rq XȂx2p V˝$E/8`8lB0."D&$Q\3,X #IE &H¹p*vc6 zxxzыZj"E- X2/х-l<O*~!8*bڌ $4f lT*4 _ I(@qXP此am8w4`"Nq\C:X~ gE(XQ]4(.$P) S8h7`FqaRp] J$bh[#JG,LZ9sGpt#5lDC/s" \uŬhbϬ8EUWQ[Ŝɤ!r`#k_ѧXȢ?+pr \+LQX ֐7+g4puA R0(a,88[~8M C#Ѱ2v^*vi`ì,DbYCLyWy@,(t8E0J N`D@o8#P3آlh`. O]n뛗bk!H/93|`Fa@!v:H\^a7AAWҼ XAA8GԄ!!!T@ơaan+`QfW"~OTP\ f`eBAP2A!!<2G`AAa!z!ZLABjO2h"tZ!ܬ8%a 0a4LA|iBApA j!)d!Na"EԢ7d6A#)T! 1aF*AzfHR~ia1da`a@*,Ls!r/ȁ"0 !ޞVN=LRLG֨H5!.0!n&bϦxbna DNf,bjdH~Іa- ! Ƞ Ԡ 4!ʯ*GK!.J!!7̆HyN^!p(Q@3`A@TRIda]v! '8틺+ Rj!hxVahuRPx,(PDʡf-ra`be8Ala~A.$%BAɷd2a6%B! aAPȢ4   0 O< Na$cH˴a滨!B pp!ix!/p!+ N+f(Rm"6\"2W" !* u2~u6*t"xR)\^Aʁ&222N-3>|t ̀ $a|aLƠ J PSzxd3Y~+ta\|JboA]A!^4CazjC̲GkF0ƒ A! AA`!aӂCwԁ!Kmt(bjhn(  ``!c2re<쮆$ɲ>L0$An4R [!AzlM|[ خ7hX7b;27Bbj>K$@ ;0IxD4`^""oG2r6gXr!|Pj)"V0(jEJ&2*  |! ` T\qYA`8>)0hF)NwP7aCa`!ušHˡ1x#ﲁpr/ !`yazJa׮hcyazDT.aH,앏:X%:Pk5\KE|=&aaTC!g^oZ.aXpw6&kvhnl^ ^"&'FAhA(~hLv's0!`{{YCeJƁt!u!!s@PaH(B^K{1BB4<\/WYїe@~*& < hx! Prוax̰_aA89vaaT2𛨡xDž6vGLtBpF19XB!,ee x6|_0](9a)mF+W<!hXsHg|#Y؁AVHTaBv.SBlv!+&6!ba(U@a ,z2/$ c8h=9h4a:abXfjV-W,Wrv-f| MZ4lԁvX1eˆ,6pΕ#WΜ9o֞8v؞aS&l 5mВuU<1DdҬ]۷lʂx3c^.^H[zu-]ͼ ]pc]i\:5Kv"EIeU Z.\pb+P 4XC.B )yL14CMe1LB,%`"'I,H5" 2 -\a(ymA 0AK4qE 8 78 -g503܈M1@)MX|34D15M3 xCZ]7 hB(,A L Pa ^L;enthought-chaco2-4.1.0.orig/examples/kiva/agg/simple.py0000644000175000017500000000110511674463635022052 0ustar varunvarunfrom kiva import agg from kiva import constants gc = agg.GraphicsContextArray((100,100)) #gc.bmp_array[:5,:5] = (128,128,128,128) gc.set_stroke_color((1,0,0)) #gc.move_to(0,0) #gc.line_to(100,100) #gc.stroke_path() #print gc.bmp_array[:6,:6,0] gc.set_fill_color((0,0,1)) #gc.rect(0,0,5,5) gc.rect(0.5,0.5,5.0,5.0) gc.draw_path() print gc.bmp_array[:7,:7,0] gc.clear() gc.set_line_cap(constants.CAP_SQUARE) gc.set_line_join(constants.JOIN_MITER) gc.set_fill_color((0,0,1)) #gc.rect(0,0,5,5) gc.rect(0.5,0.5,5.0,5.0) gc.draw_path() print gc.bmp_array[:7,:7,0] #gc.save("pr.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/agg/image_LICENSE.txt0000644000175000017500000000064611674463635023205 0ustar varunvarun serengeti.jpg: Wikipedia; This image has been released into the public domain by its author, Rick marin. This applies worldwide.\ finger1.gif: Wikipedia; This work is in the public domain in the United States because it is a work of the United States Federal Government under the terms of Title 17, Chapter 1, Section 105 of the US Code. finger2.gif: Enthought modification of finger1.gif enthought-chaco2-4.1.0.orig/examples/kiva/agg/sub_path.py0000644000175000017500000000172611674463635022377 0ustar varunvarunimport numpy from kiva import agg line_color = (0.0,0.0,0.0) fill_color = numpy.array((200.,184.,106.))/255. gc = agg.GraphicsContextArray((1600,1600)) gc.rect(30,30,1200,300) gc.set_fill_color(fill_color) gc.fill_path() gc.set_fill_color((0.,0.,0.,.4)) gc.translate_ctm(50,50) gc.move_to(10,10) gc.line_to(400,400) gc.move_to(410,10) gc.line_to(410,400) gc.line_to(710,400) gc.line_to(550,300) gc.line_to(710,200) gc.line_to(500,10) gc.close_path() gc.rect(750,10,390,390) gc.draw_path() gc.save("sub_path1.bmp") line_color = (0.0,0.0,0.0) fill_color = numpy.array((200.,184.,106.))/255. gc = agg.GraphicsContextArray((1600,1600)) gc.rect(30,30,1200,300) gc.set_fill_color(fill_color) gc.fill_path() gc.set_fill_color((0.,0.,0.,.4)) gc.translate_ctm(50,50) gc.move_to(10,10) gc.line_to(400,400) gc.move_to(410,10) gc.line_to(410,400) gc.line_to(710,400) gc.curve_to(550,300,710,200,500,10) gc.close_path() gc.rect(650,10,390,390) gc.fill_path() gc.save("sub_path2.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/agg/polygon_hit_test.py0000644000175000017500000000311611674463635024157 0ustar varunvarunimport numpy from kiva import agg poly = numpy.array((( 0.0, 0.0), (10.0, 0.0), (10.0, 10.0), ( 0.0, 10.0))) print agg.point_in_polygon(-1,-1,poly) print agg.point_in_polygon(0.0,0.0,poly) print agg.point_in_polygon(5,5,poly) print agg.point_in_polygon(10,10,poly) print agg.point_in_polygon(15,15,poly) pts = numpy.array(((-1.0, -1.0), ( 0.1, 0.0), ( 0.0, 0.1), ( 0.0, 0.0), ( 5.0, 5.0), ( 10.0, 10.0), ( 15.0, 15.0))) results = agg.points_in_polygon(pts, poly) print results pts = numpy.random.random_sample((20000, 2))*12.5-2.5 import time t1 = time.clock() results = agg.points_in_polygon(pts, poly) t2 = time.clock() print 'points_in_polygon() for %d pts in %d point polygon (sec): %f' % \ (len(pts), len(poly), t2-t1) print pts[:5] print results[:5] poly = numpy.array((( 0.0, 0.0), ( 2.0, 0.0), ( 5.0, 0.0), ( 7.5, 0.0), (10.0, 0.0), (10.0, 2.5), (10.0, 5.0), (10.0, 7.5), (10.0, 10.0), ( 7.5, 10.0), ( 5.0, 10.0), ( 2.5, 10.0), ( 0.0, 10.0))) t1 = time.clock() results = agg.points_in_polygon(pts, poly) t2 = time.clock() print 'points_in_polygon() for %d pts in %d point polygon (sec): %f' % \ (len(pts), len(poly), t2-t1) print pts[:5] print results[:5] enthought-chaco2-4.1.0.orig/examples/kiva/agg/text_ex.py0000644000175000017500000000326111674463635022246 0ustar varunvarunfrom __future__ import with_statement import time from kiva.fonttools import Font from kiva.constants import MODERN from kiva.agg import AffineMatrix, GraphicsContextArray gc = GraphicsContextArray((200,200)) font = Font(family=MODERN) #print font.size font.size=8 gc.set_font(font) t1 = time.clock() # consecutive printing of text. with gc: gc.set_antialias(False) gc.set_fill_color((0,1,0)) gc.translate_ctm(50,50) gc.rotate_ctm(3.1416/4) gc.show_text("hello") gc.translate_ctm(-50,-50) gc.set_text_matrix(AffineMatrix()) gc.set_fill_color((0,1,1)) gc.show_text("hello") t2 = time.clock() print 'aliased:', t2 - t1 gc.save("text_aliased.bmp") gc = GraphicsContextArray((200,200)) font = Font(family=MODERN) #print font.size font.size=8 gc.set_font(font) t1 = time.clock() with gc: gc.set_antialias(True) gc.set_fill_color((0,1,0)) gc.translate_ctm(50,50) gc.rotate_ctm(3.1416/4) gc.show_text("hello") gc.translate_ctm(-50,-50) gc.set_text_matrix(AffineMatrix()) gc.set_fill_color((0,1,1)) gc.show_text("hello") t2 = time.clock() print 'antialiased:', t2 - t1 gc.save("text_antialiased.bmp") """ with gc: gc.set_fill_color((0,1,0)) gc.rotate_ctm(-45) gc.show_text_at_point("hello") gc.set_fill_color((0,1,1)) gc.show_text("hello") with gc: gc.translate_ctm(80,-3) gc.show_text("hello") with gc: gc.set_fill_color((0,1,0)) gc.translate_ctm(50,50) gc.show_text("hello") with gc: gc.set_fill_color((0,1,0)) gc.translate_ctm(50,50) gc.rotate_ctm(3.1416/4) gc.show_text("hello") gc.set_fill_color((1,0,0)) gc.show_text("hello") """ gc.save("text_antiliased.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/agg/rect.py0000644000175000017500000000020611674463635021517 0ustar varunvarunfrom kiva import agg gc = agg.GraphicsContextArray((500,500)) gc.clear() gc.rect(100,100,300,300) gc.draw_path() gc.save("rect.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/agg/simple_clip.py0000644000175000017500000000211111674463635023057 0ustar varunvarunimport time from kiva import agg samples = 1 pt = (250, 250) sz = (100, 100) transparent = (1,1,1,0.) gc_img = agg.GraphicsContextArray((500,500)) #gc_img.clear(transparent) # clear isn't working... gc_img.bmp_array[:] = (255,255,255,0) gc_img.set_fill_color((1,0,0,.5)) gc_img.set_stroke_color((0,0,1)) gc_img.rect(pt[0],pt[1],sz[0],sz[1]) gc_img.draw_path() gc_main = agg.GraphicsContextArray((500,500)) gc_main.set_fill_color((0,0,1,.5)) gc_main.set_stroke_color((0,1,0)) gc_main.rect(300,300,100,100) gc_main.draw_path() gc_main.clip_to_rect(pt[0],pt[1],sz[0],sz[1]) t1 = time.clock() for i in range(samples): gc_main.draw_image(gc_img) t2 = time.clock() print 'with clip', t2 - t1 gc_main.save("with_clip.bmp") #gc_main.clear(transparent) gc_main.bmp_array[:] = (255,255,255,255) gc_main.clear_clip_path() gc_main.set_fill_color((0,0,1,.5)) gc_main.set_stroke_color((0,1,0)) gc_main.rect(300,300,100,100) gc_main.draw_path() t1 = time.clock() for i in range(samples): gc_main.draw_image(gc_img) t2 = time.clock() print 'without clip', t2 - t1 gc_main.save("without_clip.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/agg/simple2.py0000644000175000017500000000035211674463635022137 0ustar varunvarunfrom kiva import agg gc = agg.GraphicsContextArray((500,500)) gc.rect(100,100,300,300) gc.draw_path() gc.save("rect.bmp") # directly manipulate the underlying # Numeric array. gc.bmp_array[:100,:100] = 255 * .5 gc.save("rect2.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/agg/dash.py0000644000175000017500000000124311674463635021503 0ustar varunvarunimport time from numpy import array from kiva import agg import kiva def dash(sz=(1000,1000)): gc = agg.GraphicsContextArray(sz) gc.set_fill_color((1.0,0.0,0.0,0.1)) gc.set_stroke_color((0.0,1.0,0.0,0.6)) width = 10 gc.set_line_width(10) phase = width * 2.5; pattern = width * array((5,5)) gc.set_line_dash(pattern,phase) gc.set_line_cap(kiva.CAP_BUTT) t1 = time.clock() gc.move_to(10,10) gc.line_to(sz[0]-10,sz[1]-10) gc.line_to(10,sz[1]-10) gc.close_path() gc.draw_path() t2 = time.clock() gc.save("dash.bmp") tot_time = t2 - t1 print 'time:', tot_time if __name__ == "__main__": dash() enthought-chaco2-4.1.0.orig/examples/kiva/agg/star.py0000644000175000017500000000131311674463635021533 0ustar varunvarunfrom __future__ import with_statement from math import pi from kiva import agg def add_star(gc): gc.begin_path() gc.move_to(-20,-30) gc.line_to(0,30) gc.line_to(20,-30) gc.line_to(-30,10) gc.line_to(30,10) gc.close_path() gc.move_to(-10,30) gc.line_to(10,30) gc = agg.GraphicsContextArray((500,500)) with gc: gc.set_alpha(0.3) gc.set_stroke_color((1.0,0.0,0.0)) gc.set_fill_color((0.0,1.0,0.0)) for i in range(0,600,5): with gc: gc.translate_ctm(i,i) gc.rotate_ctm(i*pi/180.) add_star(gc) gc.draw_path() gc.set_fill_color((0.5,0.5,0.5,0.4)) gc.rect(150,150,200,200) gc.fill_path() gc.save("star.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/agg/star_path.py0000644000175000017500000000570611674463635022561 0ustar varunvarunfrom __future__ import with_statement from math import sin, cos, pi from numpy import array, arange import kiva from kiva import agg def draw_circle(gc,radius=2): gc.begin_path() angle = 0 gc.move_to(radius*cos(angle), radius*sin(angle)) for angle in arange(pi/4.,2*pi,pi/4.): gc.line_to(radius*cos(angle), radius*sin(angle)) gc.close_path() gc.fill_path() star_points = [(-20,-30), (0, 30), (20,-30), (-30,10), (30,10), (-20,-30)] ring_point = (0,35) ring_radius = 5 #fill_color = array((1.0,0,0)) fill_color = array((200.,184.,106.))/255. point_color = array((.3,.3,.3)) line_color = point_color for i in range(len(star_points)+1): gc = agg.GraphicsContextArray((800,800)) gc.scale_ctm(8.0,8.0) gc.translate_ctm(50,50) # draw star gc.set_alpha(.5) x,y = star_points[0] gc.move_to(x,y) for x,y in star_points[1:]: gc.line_to(x,y) gc.close_path() gc.set_fill_color(fill_color) gc.get_fill_color() gc.fill_path() gc.set_alpha(.4) gc.set_stroke_color(line_color) gc.set_fill_color(line_color) gc.set_line_width(12) if i > 0: with gc: x,y = star_points[0] gc.translate_ctm(x,y) draw_circle(gc) if i > 1: points = star_points[:i] with gc: x,y = points[0] gc.move_to(x,y) for x,y in points[1:]: gc.line_to(x,y) gc.stroke_path() """ for x,y in points: with gc: gc.translate_ctm(x,y) draw_circle(gc) """ gc.save("star_path%d.bmp" % i) # draw star line_color = (0.0,0.0,0.0) gc = agg.GraphicsContextArray((800,800)) gc.scale_ctm(8.0,8.0) gc.translate_ctm(50,50) print 'line color:', line_color print 'fill color:', fill_color gc.set_stroke_color(line_color) gc.set_fill_color(fill_color) gc.set_line_width(12) x,y = star_points[0] gc.move_to(x,y) for x,y in star_points[1:]: gc.line_to(x,y) gc.close_path() gc.set_fill_color(fill_color) gc.get_fill_color() gc.draw_path() gc.save("star_path7.bmp") # draw star gc = agg.GraphicsContextArray((1700,400)) line_color = (0.0,0.0,0.0) gc.scale_ctm(4.0,4.0) offsets = array(((0,0),(80,0),(160,0),(240,0),(320,0))) modes = [agg.FILL, agg.EOF_FILL, agg.STROKE, agg.FILL_STROKE, agg.EOF_FILL_STROKE] pairs = zip(modes, offsets) center = array((50,50)) for mode, offset in pairs: with gc: xo,yo = center+offset gc.translate_ctm(xo,yo) print 'line color:', line_color print 'fill color:', fill_color gc.set_stroke_color(line_color) gc.set_fill_color(fill_color) gc.set_line_width(12) x,y = star_points[0] gc.move_to(x,y) for x,y in star_points[1:]: gc.line_to(x,y) gc.close_path() gc.set_fill_color(fill_color) gc.get_fill_color() gc.draw_path(mode) gc.save("star_path8.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/agg/conv.py0000644000175000017500000000075011674463635021533 0ustar varunvarunimport sys from kiva import agg gc = agg.GraphicsContextArray((100,100)) gc.move_to(0,0) gc.line_to(100,100) gc.stroke_path() gc.save("bob.bmp") gc.save("bob.jpg") gc.convert_pixel_format("rgb24") gc.save("bob1.bmp") if sys.platform == "win32": from kiva.agg import GraphicsContextSystem gc = GraphicsContextSystem((100,100)) gc.move_to(0,0) gc.line_to(100,100) gc.stroke_path() gc.save("bob2.bmp") gc.convert_pixel_format("rgb24") gc.save("bob3.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/agg/benchmark.py0000644000175000017500000001361311674463635022522 0ustar varunvarun""" Benchmarks Agg rendering times. """ from __future__ import with_statement import time from scipy import stats, array, shape, arange, transpose, sin, cos from kiva import agg import kiva def benchmark_real_time(cycles=10,n_pts=1000,sz=(1000,1000)): """ Render a sin wave to the screen repeatedly. Clears the screen between each rendering. """ print 'realtime:', width,height = sz pts = zeros((n_pts,2),Float) x = pts[:,0] y = pts[:,1] interval = width / float(n_pts) x[:] = arange(0,width,interval) t1 = time.clock() gc = agg.GraphicsContextBitmap(sz) for i in range(cycles): y[:] = height/2. + height/2. * sin(x*2*pi/width+i*interval) #gc.clear() gc.lines(pts) gc.stroke_path() #agg.write_bmp_rgb24("sin%d.bmp" % i,gc.bitmap) t2 = time.clock() tot_time = t2 - t1 print 'tot,per cycle:', tot_time, tot_time/cycles return def benchmark_compiled_path(cycles=10,n_pts=1000,sz=(1000,1000)): """ Render a sin wave to a compiled_path then display it repeatedly. """ width,height = sz pts = zeros((n_pts,2),Float) x = pts[:,0] y = pts[:,1] interval = width / float(n_pts) x[:] = arange(0,width,interval) y[:] = height/2. + height/2. * sin(x*2*pi/n_pts) path = agg.CompiledPath() path.lines(pts) #path.move_to(pts[0,0],pts[0,1]) #for x,y in pts[1:]: # path.line_to(x,y) t1 = time.clock() gc = agg.GraphicsContextBitmap(sz) for i in range(cycles): #gc.clear() gc.add_path(path) gc.stroke_path() t2 = time.clock() tot_time = t2 - t1 print 'tot,per cycle:', tot_time, tot_time/cycles return def benchmark_draw_path_flags(cycles=10,n_pts=1000,sz=(1000,1000)): print 'realtime:', width,height = sz pts = zeros((n_pts,2),Float) x = pts[:,0] y = pts[:,1] interval = width / float(n_pts) x[:] = arange(0,width,interval) flags = [kiva.FILL, kiva.EOF_FILL, kiva.STROKE, kiva.FILL_STROKE, kiva.EOF_FILL_STROKE] for flag in flags: t1 = time.clock() for i in range(cycles): gc = agg.GraphicsContextBitmap(sz) y[:] = height/2. + height/2. * sin(x*2*pi/width+i*interval) gc.lines(pts) gc.draw_path(flag) t2 = time.clock() agg.write_bmp_rgb24("draw_path%d.bmp" % flag,gc.bitmap) tot_time = t2 - t1 print 'tot,per cycle:', tot_time, tot_time/cycles return def star_array(size=40): half_size = size * .5 tenth_size = size * .1 star_pts = [ array((tenth_size,0)), array((half_size,size - tenth_size)), array((size - tenth_size, 0)), array((0,half_size)), array((size,half_size)), array((tenth_size,0)), ] return array(star_pts) def circle_array(size=5): x = arange(0,6.3,.1) pts = transpose(array((cos(x), sin(x)))).copy()*size/2. return pts def star_path_gen(size = 40): star_path = agg.CompiledPath() #spts = circle_array() spts = star_array() #star_path.lines(spts) star_path.move_to(spts[0][0],spts[0][1]) for x,y in spts: star_path.line_to(x,y) star_path.close_path() return star_path def benchmark_individual_symbols(n_pts=1000,sz=(1000,1000)): "Draws some stars" width,height = sz pts = stats.norm.rvs(size=(n_pts,2)) * array(sz)/8.0 + array(sz)/2.0 print pts[5,:] print shape(pts) star_path = star_path_gen() gc = agg.GraphicsContextArray(sz) gc.set_fill_color((1.0,0.0,0.0,0.1)) gc.set_stroke_color((0.0,1.0,0.0,0.6)) t1 = time.clock() for x,y in pts: with gc: gc.translate_ctm(x,y) gc.add_path(star_path) gc.draw_path() t2 = time.clock() gc.save("benchmark_symbols1.bmp") tot_time = t2 - t1 print 'star count, tot,per shape:', n_pts, tot_time, tot_time / n_pts return def benchmark_rect(n_pts=1000,sz=(1000,1000)): "Draws a number of randomly-placed renctangles." width,height = sz pts = stats.norm.rvs(size=(n_pts,2)) * array(sz)/8. + array(sz)/2. print pts[5,:] print shape(pts) gc = agg.GraphicsContextArray(sz) gc.set_fill_color((1.0,0.0,0.0,0.1)) gc.set_stroke_color((0.0,1.0,0.0,0.6)) t1 = time.clock() for x,y in pts: with gc: gc.translate_ctm(x,y) gc.rect(-2.5,-2.5,5,5) gc.draw_path() t2 = time.clock() gc.save("benchmark_rect.bmp") tot_time = t2 - t1 print 'rect count, tot,per shape:', n_pts, tot_time, tot_time / n_pts return def benchmark_symbols_all_at_once(n_pts=1000,sz=(1000,1000)): """ Renders all the symbols. """ width,height = sz pts = stats.norm.rvs(size=(n_pts,2)) * array(sz)/8. + array(sz)/2. star_path = agg.CompiledPath() star_path.lines(circle_array()) gc = agg.GraphicsContextArray(sz) gc.set_fill_color((1.0,0.0,0.0,0.1)) gc.set_stroke_color((0.0,1.0,0.0,0.6)) path = agg.CompiledPath() t1 = time.clock() for x,y in pts: path.save_ctm() path.translate_ctm(x,y) path.add_path(star_path) path.restore_ctm() gc.add_path(path) t2 = time.clock() gc.draw_path() t3 = time.clock() gc.save("benchmark_symbols2.bmp") build_path_time = t2 - t1 render_path_time = t3 - t2 tot_time = t3 - t1 print 'star count, tot,building path, rendering path:', n_pts, \ tot_time, build_path_time,render_path_time return if __name__ == '__main__': #sz = (1000,1000) sz = (500,500) n_pts = 1000 #benchmark_real_time(n_pts = n_pts, sz = sz) #benchmark_compiled_path(n_pts = n_pts, sz=sz) benchmark_individual_symbols(n_pts = n_pts, sz=sz) benchmark_rect(n_pts = n_pts, sz=sz) benchmark_symbols_all_at_once(n_pts = n_pts, sz=sz) #benchmark_draw_path_flags(n_pts = n_pts, sz=sz) # EOF enthought-chaco2-4.1.0.orig/examples/kiva/agg/finger2.gif0000644000175000017500000016532711674463635022253 0ustar varunvarunGIF89a       !#%*,& 28!.#, #4)6%:+<%3 *5 ,; '8 1>1> +62<#,-B.I,A2E9F5K:M4C 6J Y>R 5CR8E#ANAVD[I^BT EZ J] IVANCTFZJ\ESL\GWQ] FaLcNiMc Ke QfSlYnQf Tk Yn XdVq[t^yWp \s ^y WxNbNbOhReUkYnRdVjZmXe]s_y]rWqOpavc|i~`w c| i~ jwavd{have{i~r~IZ#IV$Td"[l"Xi'^r"]s*Qd(bu#ez"i~$fz*gy+hx2fjnf k n gqsyq r y u{|v { ~ fknglnqsypsyv{~wz~m"m(q#t#u*v){#|+y$x6}4o2~E  ##,*+$9433;:;+#,%###+,+$+3<275(6,,CKCFUBGI!!VCREATOR: XV Version 3.10a Rev: 12/29/94 (PNG patch 1.2) Quality = 75, Smoothing = 0 ,Aꆯ7n߶[m!8QW} K7wڝMs͠xU+W.qԝG1SmC7-ڴԐٛfȄQ3RPŊ<†(D <#@B +tB@$=ńPx =Rᥗm`$@$eP7c;j)o̡$saz჏VXQR!P $sr 5X ߩ,ɑ  x§ޭjh*JPp0>ChRX1mgbJ!*bYh(@o,N +PL)oB"$Hz8;f%Fmpn0żn23$Lv #0V HbUHn`DD X'Ea@J(аb4'(! v,EP`6@:ʉ2b@#QbR<" WS7$b֏h'耆L( Y)B(LE274d%E*5"5UENby(N@`xV6 kULEM-`-A gU .ZkDa K<@o<ቌZ,]R3Yh$-@`f~s-\@h/dё 4B d @'M]pUѽxoN$ mߛ6au]`Nt\Tuy]nT". RH3FQ&$BĨ'x Рxf ȶ-Tx9_,`O°.Yo{S ciaʉ+hA B>.|-qhj.8 7d 6pb nBxJ#5s6D '8PVY@ EuTG}V|o' fQ|WQP\,cgt``| 6#g ͠ `{ rs0 (pk@P F5zj#p `z$+Fv6fzDjWGYkjUcwW\ |jqrq`|\ `~c-}r腤{n|س^ps~k~Olvuv|   @qr-"=& ' Rh5Tu 5an4HZYI P dz {W ` I c{W ,yE h66 5 @F&*Ab6PMez5hr[q0|kO`vmYO0|rrfs-djvrm/gow^j jh'hR oG}׆hMR`qxYvW5Չ,Es`v˂"lYċ = `ZR ` f 4>0=#+68G& @MG&$+8P6@-h ~\Efwj{r|"}Zq0Gps$rtW Ǒ4pxxF }<rsQT~}di52`Qt2.RY 0Gh3]<[`|ϲN@ 0 R" €4mP O C# 2  2i A=zLP@Q6H&"+!$-[ $F~)}0 ۧvnSkWPT5qZHjYQXY%Zg=Q,o\744@˕P|2K & v_[rE41""n@ mN<9m 2P f 0 2$ @HA mrij xL` r!  LgodԔd|١|ie5pQ>bes9GZ@( ij6Ǔ9QL}R }vYuq [b{bf(r'T]|s iPhS]jQh\@ȊE[QPg@ `I@ }29TK6%Q #T* @>q2XѶd (@B1  P` 2PF pwA*!|㸗D*0pj5 ~k4`hZ oiG[ k@i ktv0Zgi(`Vaq@gV`B)"d$FAh t fXXHq@ Đ< ˀb), @ tp&P "s#Q.o 1%磔=@  r0.D @ P 7M1@ 1 eS@E*6@@D#n𣙤NMUF]ipZRidD8s.QSHp (GB+#$#/R7B8gf[KAY@1o @m,h60 ~JHE']r@.W0#X WoT0[z %2  "V` /2= PA6 Yp Y?wzU Bqq)."}r4[D9vO%\fMP(P@TR@U >a#!ĵ;W`QsszIU` KqHHhV"S"U>Gj+gn h `UY7C/! .  [7nJ d>pWހ + L5Ȋ%YqP࿤uh7 q & !U" =ȵ"ϒPN-w`F'p!)Cs ?`F00 ^ ^._]`wBQ G[1Oe}*eڪ/e4am0 +]Ht\ ǐh 0)k@๚ !&N" bt R pϗ` ` p& ΢ .+J_pPI4 S8fd0n "ؠ̤KP@` FT˒.c̝_ThLI`P&&:7tpwX :z[PakA(2!aMPgRP#"= }. 7 R3B "x`m~ ,Β /8LJ2ZV i%T)4hذ ,X! HЀ(@p -xJ ,]%J%X:qiT,Y`ѲdI&K4irKPr%8Xʼn%);R`ѢNt8)vE*#,nfFi2*Pt$J%4hACm>Li$ &Rjyh.R$"(,P4KD]mڄ ըDZ27q`ژt]"Iv DPڸiJӥ]BS$Iқ6m@&3bJ&DаE H\ ' F@H2P ;XDb肳6: OB6bxrJ1p6h VF9O8=;0hc&h$j &z@Ob1 P'xb xXX`ab(h (H\/H(y hI6^"ENSĒE"M+ȌFZ)Ga I ya~PEKFL$QE޸DU=U$, s,0P!. I/}VbHpįXJQЋi@||Ly@Ƹ|FKF1: 1 E[D+h`]Z$E$LQHtP| H*m( Cc7D؅"&A6Lbyl MKlOR 0@$P` !܂!(ZzfDv( }YH 'EPy2)RQ#)AB@#F`̛A@ `Fm=Bh M,"P-(];)DA֛)J5pX'Ù& 0E`\!楉Ou -LB)FQ,7O0"Qٮmr*3%*=5 .\g@ek /*,L2P XJ8/#nDqMT5mnPiQȄ6H4hP  J W]uӉi֡eэ`^M$#_Nm1c8F0qpf:H/4 aL,V" J{ЂŀV[I9  ʠjEnY y 1=cXш+5qUVG0Sxd8m \hC,%tU h%F,`ЉFā3LtZ,,BZ 7 A xB@*@'UBCĈDd[]Li Q4>"2 TKq0]LSEb#WtIPB`$:,"hZ'4 0] o 6"؆>e8qfϦ]8CRR!4z. z1C P= M!SS…5Ѐ4#1 ) J!RdxK.P 6=x{5)30;՘m T17"⒰TI EXzGxHKxQPU_h_ЃJSh C7HLX"N3x Ѐ& Xp3}Se)Ђ  'G/07Ȃ QK:I:x'(+FhEjX9/Q8 H#֩H9-X?=P/-X!F9,LHZ脰 K0W̴XLI QLj7&P;_) 9/Ct1 (`(0J 4K7X'8 ؀ S҃hgX :,)&=.p &4X'$h50H9c%I`)Dlq Ɛ \>N K*x%,ra%XuqS8YlfhLD8Se(H b؅爬lJ!)DP븂FxƐIErȄHF0 pruj(hYX ȆD 8"ŠA .2>ӂ5xx &X<ȂG&[0xRVB-x.h:+H"J =tdS*+xZꂬY%JV@[x5D2(;ߙH؄K(d$k aphC!_Q!JTFx\RYR f< p}%,=@P*0( / YV ik..̨: FdPxDɃP)Cc+-/śؤ3ɛ[4-SX%0[ qhi +`T@EȊ9sJF^^؅*HLZ.ȄqXQHP7 X؏ < h( o0 (=}7fY5 ͒ k2ɂ$ N8X7@M5 'ꊌ%(X :THNj&ؾi:p:`By WOȃk;HQ:;H1 ҘEpLHU 4&=aI0 (F9 Hg`Ha +P MrŐI;Y4#hƆ L"oxV|S j)֙B$8 `%TNiF(.N(pkC -H 3QAH9#,4I6< H#Q.HPHH-334IBz 茜LXr҈M<*N/ ! YaPM` MhvEZ.M9Tp8Pb x2(o0gݢyȔ)8QB T+.84Ză? X s ~ $.?AP6UX;[ɝ`ӂOW@P KdY3ň`tyKDqM%i*ގ 4^M`_(ծTUUT=Q`Ȅ a`'J ͓G}`-sXy F( (F&꘧*P(b-H$۽)O+h pa; )P@'a0Vڮ׹40)Oǀ$)F<%Z 5Qhe]i=!۝+  )ZR<&Ek:VQeX,TPp H`%;QPM p x0(2I^*,I6Ȋ[xƀS0(NaPyŠ4[؂@Vp%P9j':C4N6:Sb-4&p+2R3HOw0Zʕ 58$fSH؊H0a+PghKx\mUXءD@aSH EX08#Ʉp_Ͳ\*O} _7xG .XS\Ђ:Hvc SRH$.Z~:0FW>`3ޮ: M$*ăA a Kn;`H<\%N)B+p0vPS1Җ7Ha _qKXQ3,X>C)H#p`iLhY ;ȞS8 NGhV 0.ЩqD y 5%uXK=&s)0+`ȈP5xpS(!Z4HWp5XȪb=cAYA!S cETT0O.`0B(hHfxRK!JP3yT|UbSy3p{1408؁#;odΑx]8 \M\#\HIY&X"dI2`HX^Dr3& 6d"L@W<Op+1F<N8 p -Ђq)BY^%펂J*)TaG#`uή\t]HE U=& 4 n[x@`<-`5`,"bɄŅXq!cJDsha V$re_C(0m~^@.2 I(BΐE_B.AmH\ V0 #@uvzh! h~%sjDTH "K$6 lA)t`N=3M7Ay*:A&ART00!]84 UC_Q*Pj`d\Ep yF!88, ɒݴ3MMLS ^H0D$ɸ߰brV*PPwnzDJ0xn$ v P#gm9^D2o8;lW >0b1 F[[  ~L7R:atcx 5!ɴhMq BK;3(Ă :hcĩe.14HYʄ]o`XE2l"X/@¥M%\Be)pB_"d#xM$|KL'| L @uTC8`(a`@ ll^ a`&| \q0$4'D܌UPTpP؅h pt B-BЀ*-B9@hA@Y L=q,-Xe,e5%mkElAP-DDDvIX/L/0l"A"X1B%TŒ0A'#`A*T2jË5lX7,W)@p5@ h@@MAPm m&}YXXN0B5ZrT}ǡTāB(`AY_#PPHV- hTN#\YM8XM@  %T@ kdGuthG1J|_\_]AX_H^mA[A@B1.NbV$":whA0bB%\ sO@F, __s@FB%BM}ME %*ϘNtB hAa-2,X쓲Ā 6@H8@H@@k+A@T(xG(d'LBv2 `nBtU`#T&Fj)dpdNΩB-ԁ*A$Ax* \p @Ɛ ,@p 0,(Ldw(b{dzi%T]>ǐ)XDB+TB $0́g )#t|B|' (F3 -<h CH@  Ap2^5AAl &͘t^tB)lr,CPXI< Da@ƴ@(!\,\S8A+X RAF Ӥ +2F"dJ;B@+DlBԶ/b1@?V"XE3|-PB|a>A-gX<]7Th0\0T` A,A'<͟fMB,,j 2" 1B.5B\s<1LR C(C Vp8̀lA-A| p e<N1srJO4㔕8\ x\-}tA'p|N_B3$L@0 U%0Bh! M4BBMspfFmAn^8 m @ acXnapAC>EA,4+4$W\(\roLJ̀xB'h A8kLo5V7jt l%F-hLCnuvCmt]2wDȷ+aޟ W $"`%E̤$NqLB*B)T&PBN5'pUF +X|HJ'dGAdRsQBE3 EAA+ӹ 0Gh~t؁)XIrɀh+,ku 'ЂsPd'#tP)@iktPEL -(*g@ď\*hI5B_TrDBA#T3ζHB/ KFLgb(BE-i)d+X(SͭXOWY`BD!}|!$ H`+(S2ɞN4Ox:=#\A3Jֵ'ā @hA 9 Τ ȶ0plAXP#cM0x#`&b+t4B0$@20O蠍*[ȀoXG0r`2uQh`eK&LP" &ܬc[y 11(Lhő8`UVE8N`z7Fd,h@^"5z0S (`O8EEH &zhG8&50hXkTBHx (pCFh-%(e(.h x V.  PWtimbMXh), Fbb=ID,Q%L <I(N"-|(b*d"QPE)?!r8hjh h)FN`VN*)\7X"$7@X8 /P[@`^N&@kD,QI QN%8x,FH F* HxQ |(lCF#FF6e6d.[O7Fi |Ȍ E"2 <@=DZ Etwi nHE#p-`d ' _B>N,@.T Zhzp\A X1  0b8adR(bh%ED >S i >+D-NA 9A!Ҙt6 Mx· 6x|ζK5 # :h 4)%D Qz"c Si;CQ>( Ta \I9<`$]  4!B,h:LD!q:8GD:0 &P y04x`8!<Ѐ-0Ab"]H_1)#@",QB 742Jx .EF #0aE6<%\E2 ^i&keH0@ @Φ"H f-\A vԠ e .Ё;*pX&R,״h#BaG +_l$%HH*X0a]HYxLvαV> =& GiJ\ `7l@n@KHN@\C̲IGnġK,pb^,ɲS @]* (Vc ٪)j@UHxT!ܡ 0[u,|RТA ` 5x j5 hu+Df#op)@A2lD9l(Bտ7B$~Q It 01.!EX"`O`K NB"]VƈPtjK^Lt0PP@SIY/4 zƓ8vC "H( HA* Tb zA#wtg l!h:` lЀ `` Ы t^:(X dy@-AU2AcZa(n$FEM]8@`è D#f| bРX @.. ^耋I :#HFca+BX /!%"fHa`B.!.!GXj`0*=}@X(," ab#P7r@ |Ö`F g| xV$ X 3@-&Mg}` `!@da hႲ uR(õ$^A 4 bZa [VVrqf` L0`4HlX[:f ,'PIt̮~a脲`cXO>jF`Fdgr (O`P j㱖 CnT*cb/@Z^؀ @ @$J5m$@ ] H&{t:fFV,Z s2KI 6 tcV%h3H&Z TY{C38 j ,?Ѡr `-& _@ _Y f&O$ @(U X&VC* xr$B l|}Rs&$ $!M t` h@   aPAX!qb, x RE_fkoa` j"@bd` h`9JԂ,GUةDhU% U "A:(W"+ hz 4<AT:!# `HPU_9]Q @  Ҡj dh ML(-$3:fg:(2 . pRHj҄ XHdA@1ߠrlAz a` `J('CƋX2crhN|˄އ `X$'AKYIFW J_U[P|d!bl{`&쵄`at[f9`. kjjx jEV\FY+ Ҷ@ǖ4G@(a£r +rG.QAr|29<"<T x@aiH* 6%% THȗCc]:Fgc$vE+z,1T*jX f! r X b`x <`jbNa Y FFE4Na0YNR_-R!r |'~b\Aֶr $lFa9`8K#tm@`d3{h{@tb rLXnzD!"TN*cXBd9RADA @e72[1d˛S3ä6"%Ʒq_ l]j U{yɍE%nH:R `C 4ZlĐ}I*L Qbs^h(V82l B& t́`T6 @T`Ġ : ~x|$^O_fHLV@#EXD%KE0mJQ<:'LUf#&=Zr ŤE%\hE P:2M`A%%2fq) Az0˕-lq„N(SHFJ&n@ 7)#0f"4 PEQQQ0%J6hhBjŬhuBcNWx` D]9SŇt0` T!K>̘-P|jQzӅ )ZdBk7YXrmDRqEJ7-#r <2 +ALL,Q,Pb'X0Cvt"v3DA tDQUyh! 3Ѐ /0L CFOnJK`O)u!=eI/dA(̵K)']xҊ`9 %TPoqUnG=I<,1Z ̠cbGņlDnĕX"yMHRXK-R q\1%d#i'vCvN& "f8!QA+h$;ij8PAf - v to Nu?5MBV0d 1:Eb%hQ"RX \p@ P :\ skVA xT r (@ ! a*P@%GbC =S v #w  B)PTH xЂ4'p6EqRTP"LnHEx0 ha8|P Jy@K.@KXR9-a 2Cst Z0bWY+ h'̀OZ`LA /dħ]8p࿶5qE0 ()"p *p@3`> dNT LA͠pvNB* "T(A N JHm$8'hȂ#F~D ph= gqޞ: #aUJBW4Mlq ,tX0ZBQ@F{A 3@ .|&bZp(/=VT%C+4IY(!T}ՋA,> PŤZZEJ':%Ǣ[A„.Tyk>. D@0xX&6[ L P:dvhPHD+ UqAGi-x81D3,|R0sB* fъuX 4` BuB 5r~?3%QڬG:"P.sp6'Ʊ G4S(X-pK 0Bҏֈ7VyQ @MO]ibji;h3[ԹΝr Hy.!&*-x?{b2f&*wM#d\.ħ%aOBNTw B wB T6 $#"[ [fABO`=FU[@t > 0,T% ,/J OK,uP&!$CWb-@wy*1%# '|>PV`:4`Iu 0O `D;(QKP zba*M e&4ZU Pb*P E0 iW 馇@&]+NPj3p oTP==2yP+=fpH0;5(YUp`PwPNw2v@FT ;jP]-`8e<0,*2 !%_0 %r SCx k-P 0V*aaM] ˑHj0cP`hv1@fL RP[sC3E@ 4pZLpQ$t^AXZuDCnPUP j mPHg 'tT I'0\B) c@6#'/TpK)~k VJ2Wnq} #X`FR <](!rX@ >\ *nY0P"[@$ (OPI=*+~P.$ŰX 7BRr!T!Cytda0v `sB3!Q^%] + D~0 s6IG8lJ* @[D@/=ZHr3 (0Ng tRUr6N7Rb[` @t QP AJ.P0 xp` kp ';Rh %Hl$+0}Ė>PbIClE }PBPueErx^ȴ>Wqa=P v %P[]`&㡍XҀ4؆5,q0pWg6@. \Cyr eRBcލGǍU lBo-ij:zT= w07< r/?kL>/'_*`x>Ht843`@w\R[Tp@!t =vf2( n#qX f"@ m"%(m$yebzu P|Pm"AF'wq7(T1*> #Rp⦍M`BtIQ` Y <SQ" %WG xҞP, 02Հ30(/-#$3s"Ptg "Sݳ? R0e̕Wa?.GDiWʂH Ji J` \A)@O `C@p6P \KP4D*iׄ4Bo] 0*Е.A iw$> E'@`Xw` ZxP = CVG'nDtPApCO pvS;!/ qЊ\` }*Qn P%JmOW\YKt9H>Lm@Ekbb̑ VmP(O &FWXfQ/Z` Km Gp2(s1 S-!ϖ nO=jX *k0<JP D-0

0£E;:5R2E](ʔM,8AY%(`C'[DF Q<5 E Oq,Au+Gi *U|0AB.@hPAƉb@щI.T*Β=bB 40jtUMp4jT.3Z@$SQP , \蠷I PB2%NPEEXb! +,="B%'[!N8k X\ᡃ 7!)&Q b4ศNpC0~ &fJ6DN!Q`ΛRA^ PNS. 7BYO.^)D T (@ Z<;0h(D顃0#Q(i1x` 7B 9hA&P EXPM Ey)8-4 O&)x TRʧFa ;G5k5"`ځ&:`EՃE`Bn2R`M8`a Ԃ:)+sP]X.Z\ ;T*a ^ N@ yU8F4e |Eh,XL`" X6t*4^ (8`&‹0Sl. |ד/GJ,D$ RaRdžG N 0a D1jƐnXD+PU!2XB#haP#>B>h*XayEPE2y ct` 'Qp@h j 84B S-P谊F q`P#S+`?m= {yiPP!gA41V4 lHE09/PB$2SZk<-h)8f .0LK G MXРcT@&08 X\F0F\M%2<&3@AR f$hF9:E\ >E PT+B ?p\Q_jhth`YqE'/1E|UHhZ;#P.J(0a X-R;($\x&$ izЄQRXj$-H2)q@ԁՔtX!FP =4',IsJمH-а>1#ռA@/p2eN%Ѓ #@'M={@Z| $! @XDZW$dL,CbӃ:aN E>UO`8 Ta (p?*ĤʰM;h`A!bAජ|QCVHrCTr@Qt?ÁP= MFq4ܣHР"8U!>؂40A}]p*l'`#m>D@@A A $! a z6"&!\<Ȃ%16L(.tl0HOx".esX3p Gtu*@H@+Ȱ`6Mx@< nXB=;0Y 48 6 9u 𹰂l ڀ OBT0$XؐuP:СvP$N"0x#LbPp1` oO@=)@:pX00 # 88-71ya(( @Y(-p 4YO!0SB,XnrF8`"-:"$ь&;ټx[ZA0Cz[X4@ hLЄˆ108ҰͣTI%(@7Hh-(O@>ReP`rpb((' 5>X@_-0Yǩ0ʄg[83H 8P-X,0S .+PG .)"S뒝FQN!A 9O)bIpVK A) 䰈B4do[XXy'3 Ox<O@.4 S"EP^'10zc(DZ1S I)XV:HUȂ/Xpfӿ;3S`8RcgbXh,F8 (C8P8 &0,)8g.PHx+;P '`J8 \,(PIB&`Q,h`-F. xڹ4=R.(6x؆8[@'7%Ph(ŘWF\yf8+JE9>;mtJpmFgJGzx8O,0T}KN0/̐,㓃5QV[;`a:vFIE6X(@ Ux&?XpfOpFYh!z[n:%ps :8%i[  T7&p: 3/n{! 4ub1cƌj&UKHFh6g`6@p"A؟>x +`P'DMD7hNEPDE8i4>wm܀%ZhmHP:aKP45PqV2+Ȅ8f<|Q! h!R2P.Auܸ ]&hz,C?XA6͡ȈK:m3*p ;5R悃il9!hVR)Ȃ6xE߁^Jhy9P;`T@7p%S,j: $P*Ŵր6R^X8+:Z΃/RyP'i6':cF%:&'8Тzb K:cƚQhѣ 'ER`ͣF\xPYNM0-O=|2e \광eUHqc(8>zX'L&ms RR 2H %B`hp 'FN)%8T|,i%Q"7Rvh+OWfXSP\ң/(uZD-#rbZÌNva4BA!:yBJ*=LM*Qr8 )REDPPq-tA *nBo=E#dwG1 %P,E[0vؑX02'\dZ8<@_[HSQK M]4Di@G3 09Fȁ_ M$"EPEA-vhVP-,Q'(T K Q,`)B*FtQ t@E'tl3 E{>փ#tE'(tу ,4EVpіhV -DYtE'XeV3 _PN,q4p'Db 0A]\!d]B 6TL*dq 4PD CCNVr > 'PЃwAAGGծ=DaGSLTQ-R +Y, T6 t ACD1x 230 21JS," &HqEkԄRU8'Fvr@P=XEmGYPh&Q/qE"- =2@ P̀o( MD` f Fr-h 9JĂ#R'H 9rX|pa[b! pr)pV 9BĂ YStS x9Ah 蠅&M0\)b:8 p-Fp1PL A |#(Q+ PD*8 nBDCQA8f #V F\u7B,jQ# :,l!;KB^Ј64HY'lq@AA2 g?@ hE"ׄM LT((4, mYM T > T" 4'R%&Т3PA @ ZT!'n"z! Yl@A)0dQ]z0(,bU:Dp!chpSh 60(0f9*PiQ\Wf 0! o(gV24"X2 P!vp*$`dԼ`BW`7@A+l c` JD ,@- =~2P 0sXP#4)Tț76u!#DB!?A;5x"*QhZL4PAᆙ&oꠅ-U->;0:ԁh H"*  XlQ0>*))PP 0KPM>'8&4A`N)0dB"q!\jp Ѕ { Ր'pQObbD꽠.Ljx d@(P<p$( @p6hd-tP(=i:Q;5 ZBPjTC ~UP )%@baӅ0x!^A]P-# `H@xPNH mπ|0t yp` LfA@ 4`auLP2^ tM`E)&Z*4q0!^}H!ph|巙Z"IC).=$8B3xLeJF6Z F0cJH"l9Jz[ KE,P%pu B#ቔVE+0`h2'L-@Pjk,rXM7oA [hže 7:!B|Ƅj3EÀ0 X2P[x-PTQPB|3 8aNf)L,YB3]H0щXĢ ]p*(щ$"P#pR؂:  `fȅT+ Uhs&BqDh 4|ZpQbA@p`08D@c!`HA`BN)C-'ZvRqmSB'Fq"V cP,a1@*Z6tg]GALV45bTE9H NR(4숨*DE.@u7K/q0Kb8.J<AwU/!@26 p]t( hh `6 Ư i?ŧN bbAy` ΢ڬ *Ƅe> %r @@ 'OdB"!' H\ !* v DaTFlM ڀ >-4؂ p,i */`m\.j  !'6F NAfe`ij ^@JFV@&m(!rj\j!j a | {m  `0҄ ;vZ<&T  ~Q R O&ZcplGbib3 Z&f#= Bp(3l vH !MbI34.b"3S\ 4rPnSA*bFm\e J(`:Nb`f j S !=U̠eુb`6 p".ۂ \r l ڌƠs?lfD5J :"*O2KA F `R0, ,81n}@ 2B x fn#(`b P.@ ":hHpb@§3t"h<Ơ @@wq`h@͠. N ~@A( `Ž`4iD(@2 ^ H T3@x ~E?)|Ff*ZAA3,sٚfAB`'"6 0L䍛;R ` RYT~ Ho!@Wr,s@BzD _Wi @ N` ~ x @` RnF J"3DhF!e-o#3:!4qUú&v6TAe&|g@ D @ , :nEC)3+h*dO xg@$'Lww!4w F @Y05 LY f"@tv>)-_tDBx: 0Ly ) `NFNCSzKE3\g)"Ar4!rW@ bY-+g|&,0i\7E*|=ƄV`֛DL&4E&젋\yQ Bm| 4 Bf ,Np!" 9)G !Bbּz*:phXyk-DCJ'SxPbƔB ME <\Ӆ =ԸåLz,Y"+Xjt* MhlReK=PLPѢ<|0ōÊ%hT+T/O4&RM5T\eI&Z8Z(W츁M,P 4LAeK}g*RJg TLS'O:Q !(X0#"0jԘ՞isU4A*4Q`DP@Ap -!KtX% LEX41 ЅRf8nL\¤ PhDG'pDQ3 U'2D"m#rMV#`PāZPUƃ iX`I#M`F"!PTQ]#dE(yTQGYCpG,QqQ*!c0B ?xZ!P0pp PS-Б l0A @Ud)-[ 'nl)xEt͉[Z(nuXtKD'p0 e,_te P@[8  .vA j q@hL LJi%v<'K`!(z^YUb 'q(F"(%dqE4…]&XtpG(nAW8\]j%UoVAO6*d\h 2,хtX4aD,|EhCSB.`A ZA,p8%bBp%wYMWP.L^Y/ Y/~'l a @!0LH45&t@`  A WћP+E'~ƴBs#FLK%za^@: [BQ"&>B I%1 9!BNTO|@+HAٸP *K)hf:MC4Nt^EҲ>]`Dc~Ӆ, ZM(aI%PSĢNгj,p O+ف KZ! Uֆ$2PA`#P ~@AU# 5̪'@E DptaR[+  E U 2J1;HPDcIP_#J%* REAu 1jl@>! PP3OL`W!HJՁX(8-s3({/r6k5,W<ϡ%%ra X& 7ԁ -P4 " 0 L`*SU,&0$A;X;K b 4@ *a4kM(D ]"(M `H@B%{t"]+@bKxCT4B2R M," hDU!H  f` iLɴJZ] Kؠ, ڿffak,f.r(%ẹHwp 3qŁa%.ɑ'8aB=BG8 D@/BEdpcuO (! &"k>WN!BOkD+X!a4cHTB EE+6 ]UH]*b"Oy \/ O#RMgz,Iz0 ‹ d`E(&{ d6R ܁bpMD#z >i~0`$SXr^`NG@NGՙ PCe +Ā:|]DT}Cٵz!g7oBꅌ;EX QbxQ8lP;f'C ^wx`R-h,C >Q@J)ƅ Qj-ʂ0k(VA©8i 'v։,Q)8ajD  pb̗14DY ' >*p‰P P'm@؂5xԋʕA { bp8 <=J:D$(EXp"DEYʻ(uFRDVqR(cup  ޠHP[vlZA g8rBTTrrkM:/2 pka[WL!)SGxp*pC"?4Erv@tPx?ae@=P#R` ؀X,(]TmT4S  ! J'/ZuB0VA6 P/TL]I0X(Y` ɠ 4%Ejo0 P 0 @ @5op X(QLq>np &K0AMA3Ax@0hP$/d\LrӶ4#lP@MH)P AdX0t9 &AcNA;'p "ƂCAӅ?y `PR=p?'p@sx 8*S4| n51qQt xY0 m@ IGnuo`"+OPZЌ YRtK#EK5 Q02M,i#I#)Ud "Uo' ai RQOe)q.*)B:L=W90KBV$bM:"5W`%+'lZЁ9V@+Y/BW4UY5F4W@AU k0 UL9 RpQLe Mi I 0 UBaK`E #Wq#K`akiHOHln'Ba `$Gt y ^!p`8e8k2y0 jX1*DK RWp;/"` 1cc(Q(R]R0 '31ЄI~2U(E$9P3 )+ ?FTqK,OY6Ld=P[F`6Z )5/nh;yq;UЊ]/%>.a atG,@Dq008ւODB{upB& -A' nЇ^ o  %Z=fPZ4-$0]G2 R@ qP2p Vr*\*F'4 oP (Pv/4Pl%[n mzYƶv 6#AuE=.fPZpvG"b [T f@00 Ep(4KB?%P.pE]EʍO@Z 3,7kPrbPj Xs ?Ǔ IUqu9u 0rPr* .E![`Jp z@ܰD ,0DS P~4RwV4'!V>%сbD2{M;!l7t Y7^ _uI, e p ojm` 8#o$:EX%GB uЁqCOhlH)W "Rm ?Upf!%w7cz2`Du Iɨ;\% F/0FdRQh(U 4s)_V]`` ]YU K)qoС HP "S(Yml QjDaRpt 8oyngkPxzAEkOs;pTV ] U@FpH"GBrzU׆E8mDfqt nh|qDFA8ĕ qѻpPQfGA0v0G u!1, R1NѿSp/Ep>P C 0 0̥֙X0RLL ƓLԶul0hķ%&5f MLaH\@Uc6Y@:H p!! ZNx 9~aBo"D 5)5Jpp7* wPq\Gd !  @MGf!< Pp#4_6bZOo]8)U i((wU@YB{3]`&&Zj{k@ j!j1L*(G?%` Am=΂~vL )u T pQ;*?w ?+=`[2!.  070yUq9}+@ rcy؊7}/r "=qh.qT,ӥ/Z1TQ_l@& c v!k%(߽k8tƲi6O]t*sAP Pc t98j #bBK{RdFGE!5!rP;/΅D #}' @E0p0/*-df`a4P?~qd ,q1 =jؠb5UHeI-Ph$Ȕ1y@a1C'*u@-t`iE(QZ7&ҢDAƍWEWdroDQQVeHA˔%4h,i%QH\1'cظ1 #˓3c 1x Ec8t/&wxSF8`dXJ#[X::,` Ӛ PdMy-7Ȣ,KJQڪ,9+`´,^GpCJhC tމNd 6p)B[ /}x 01z`ն 7C)x+ Ƙ#8hQl Diñ<  ::K)8@;[[hA |k*Z !H1PC0ԛR:@V 0C;Ђ 8끅E:JԨ4ܨs5ڌ" M2*Uyë,") (lGK2ĒEZd+r۠+H EyN:zXPlqE Ĥ ÎCC '|X=&B(آՐʍQN88ԍ9369ˢ.QH#6T4l*1!b9 {@1PpR 6`! 3NDa5(T(1.M%L0\ocxCeV|,LϢ BJ$dDK^BҺ"(HhyoB 6eѸm&c /ȉ2ꁊӨC+m5.S<8:!J h,(T(0h" Ba рA,$ T 0xYTXfdG:? Q<$BT<D? 0C!>AkZpL@+X ~: = Za [`PEXBYOkUҺ&XaKӄ*:MX"H0h2\Swh@PA ЄìLagV*D'3` V҄-8& yB81PKR#)TvC 0x#!9j`$ 0 ƂN B Z8+| c <>tZ0 1F0   z/X$a* a!{9AB *t$H#JЈN-zCR 9ġ5>h/]EQ#"S#b#UD pt`*SI1QL5 P hhӄFq~eHU@"Zhp Z@<"`A>p H`@6@RAG4 (V ßN%$@00$ ŽA &F*DmMG Č^w,|OT/  TyC>S3f%P 2w@A0ST.A kpL$B\ pDS` >@bʣE\P%Dak Z L ;Nّ=BHÂS 0H #1S{*a agc]KAp,BrpC8-T_): `N4622(n3 UWS"9%X";E87:XĆG"'tzcTZ‚@/KT1Ma%;\ KЈSB)d1:BwX|mCu61ܰL|6j;/0)*=x0 w(@ 9H!*t+Bel2 ˙"F؏A9̉a Ev67Hi]jl6 )W4KJBDa?bFs"DfVM\eafD@2RX͚T((@!(%=f"Va y N|7,S@8fXAV`p{GV<|J;Z|@g+#)t8zBQ,T,xJ/d"YC,b/1O 17DED&X#rf4oQ$/8ER) V`AV9WK`CV%OtB*` kHC40q3M(8!QZ ^t+jjLK!=zCZ EL&}/r2)"2" Ў@@1 %81Ӣ+ ('8* ;v#ՠ*؂) c2#879`UP 7p5rI5$E FQP8Zj}h@X* '8bL@O3OWX -j{/JՈ, Ii@ '9 "($ "x Dr ؛p:) :-Т[@ԐB`MMLۓ 9.خGxJ㱂&%zL8'5٢)AHAPRNHC'>1`'5p4@2gS )NXY;VI7b )8?\ZBDH:85A"p pp/9p5 p'CΠ04TX8UV 7 >ZP p( N*#B#Hȕ#؃ #(281P ȁf@ Is5P52Qʌ51@qْzF8)9z/Q<9`YF⥤  Y%F`Hӂ" )K", r$`腋RYr-Vs=ca9GapXD̃l03HΈ= .HT%SP:a :4 X*Q4 AĘl:Oڹ*Ȭ<(*r!<,eAQ"2(ߵX֐X/H'쑈˞%F/K 5 ;޴%.bi"4+9cH i8Z6Flz'(c0K9Ռ0*.+NXN$KA:7hEP.;یrа{BXEdU4`4YfQ)R([8N2>?I 9Rh&(-ְ!icN!⨼Q4lWY[/4 2ь'~FK%ӂ .l#HnThOP .b Df K\T+#2$N DP, ][O4j&H-MT'Ђs1 ,)(VY\.V,B)uI`)Q+0 {.Ra5Fm<@dra*)TUlxQp @  -&ʷ 8Yވ LH›ЀFԔ y,q">8Е'فj` gek1 qX581̇22`80 0Aj`U J Th)lP XR8R6P1za,| >h] k.4hJ Y.8V v3pC)02P1(00Ck|$AH]s;C  6`k"H">8hʁ)  \`/ pNiיM&[(A0#f-:gyU,y֑e` ;0?N;OaEQX 6$0E 4@I%QP1&K0^EMrZq:bKS ?An`p-@ ,4EVv|e]wuq` .HY 8 l AB-'9 -`2 tJZJPAcT8!T|J4i 6A阄7xrNf "v0(,t W8pd`oDv8CxCޠ^D&M%VRK^`5%b84a + V# UʒlNB *fD'1ÉQt:\0"&s2Sۂu|jFCMi,L o,%  K]`)']7 K ^% B``#,EV hUpp%k^pc"{"\53 ƟiAmJyP#V 5?LH?(͍2^p*sFnq" 3o cDc;F T07`y*ДbHR#.cEKZ&trEB_&*ay@:ҩ@ DF֥ LD؇qAhx g B |A ,]@ P} @Lν(<'qBp긋Xj14,$h)A0nP1@ q ԅ | Dy FFs)WF VTK A=QQpQ,Ό A@ ̔r YRύxY@@ ]WQV)d*2=W!&A ~|Ar }р ~N 8# p727zB(Ԑ'T#pAaqF$rtQ(F1XL@[YDց tWl | H ҳՈ5Zx=W`TA @%R= `dB"Lԥԡߋ a$ $B0EZ e_4]ҩH Ȍ\AfIuFJ=GؠP׈$r+B0"(*d®\rP@/@/@H|08փ8_T@R P@@ l@+8 Rh^\ZQ@*6|}~K_a A< %@W@uYE! A @ L$t.d\]hLBn@A"XB&0Bt=RlR!* LEKπ<:>䃤K:>>x7\6h03<;M5L2L={C=DC4ԃ==;enthought-chaco2-4.1.0.orig/examples/kiva/agg/compiled_path.py0000644000175000017500000000075011674463635023376 0ustar varunvarunfrom numpy import array from kiva.image import GraphicsContext, CompiledPath from kiva.constants import STROKE, FILL_STROKE cross = CompiledPath() cross.scale_ctm(10.0, 10.0) lines = array([(0,1),(0,2),(1,2),(1,3),(2,3),(2,2),(3,2),(3,1),(2,1), (2,0),(1,0),(1,1), (0,1)]) cross.lines(lines) gc = GraphicsContext((400,400)) gc.set_stroke_color((1,0,0,1)) gc.draw_path_at_points(array([(50,50), (200,50), (50,200), (200,200)]), cross, STROKE) gc.save("compiled_path.png") enthought-chaco2-4.1.0.orig/examples/kiva/agg/serengeti.jpg0000644000175000017500000015755311674463635022721 0ustar varunvarunJFIFExifMM*C  !"$"$C";!1A"Qa2q#B3R$brC&!1AQ"aq#2 ?\} J1ɫe9錍r*FC VSPXꚏ[*#*,I2F?րQWC(|}99؃+V,9"0lg, )h@/x9<^Y(:Jz,qRt(᳾j{ƨ⤁Qa0;׻2ga.^z +mN!׾}58L+V2+ %O$fdcjUڤ #S, %nH_V]`(qFoU=eq闷+P^pjL@؜}>jR2(Ch &VY z8<j3G/cqVКJjH˰ۚ& 210PSrX+՚1񫊕TLR1n)ly0z I sCT`Kb=rj-4G ^VuQpj+vs[!hd7÷j5qViAyCsUWpjɲAƙt؝ƺPNƮQci۽xq* }>er:0)/erU1+ C' HaGf\P65]v+As|Usi42$\^KXȢ oz[TdXYfPjܬJOcbIU@:ѐQ35boN e"YƧ^^)gHYt&26@-^1_51)j̑1U Lrvj&68όV-SUxI}${FOI{Hple_L.6kxC0:BK`Efە4ί^39sdkך-oVrNkR;"8.}E*[)Hfӝ@g8!}!2I_V3 9ޫ14&9&oj&ƻNw1B,G P0}_0&aLhf@ w#ZExr1温S^51k)X)&D) W_VMO c\:ݶfI0|\]p`w4{*9V+y=ԡ20Of73-2F!Bu<NocrccIMZ#A*GhJT/ӿgbܚߎҮ5x5]3 FRp+RR19ΣⳚIBԻ;)e3HaY7JdFY?j)";n <֘$L ($e>-Ջ,\U̲kՎWEc=Ԓ9*% Cv}Cf{sB;H Wo'.6lzaw\7UX vq4 dn+u9fljk{WMmwAmhn[zq$bѣ: G2IT^k`*{b/F3yaHڌ3֞ꑡd-ƫ4"%cK$DufSiT, *~keQ Q <_8D*nͻ$߃Bv&{~ʸY<E:3d96q)q"AiA!)7~4C hSFSEfv7%ލ ,pF>jtKДlZ u87սF7Pc)X!u#*> A䨏4ZaA!< N Z*Jf>Ԁd$H,i=-ȢǏ ܂IsJ b ^TT\)LC>q^b0'rA*Td6XY]mw], 5uHQÕHzVW%UpNMx\P0Wܲ@4,= 4@@~y4՘6!i)#9Wʜ1qw(DW¸ރ.C\Cvf r=[[_.Vƛ c\_IGBDku.,R0h܆)\]W9IދEQ+u.w#H1oձPiZj?a5{3jtG? ؞&K+(B{\,jY6۩H-.^ܐIEP <Ƈl^U9C)rI׋qM?P|1KKU J8UP[I^h ejk0I} x>o s>ڪA'MU2(.9ު 8mNPǽJǐ22*Z3jA4hdXH~ʨ?:W*5՟(MtjF#ӧ5f}jD&i-%0 ֋  IbeHYci؝\J4 Hg NF yޯ4hTP=տ:BBLoHtI975CӢ4dqFXB"{X?A<Ҥn.ɦ4;v/EiV76 g\f5`W$a%1Kie W$#XH5afE8'QK( T&2q* ` OC#AbL#ū2r8cz(#V0^Xj)v ?zY5 Q85tpWqj>JdVc#ѵVs#lTr*T6K~R}X‘ABPǜQy漤`xAJ2g\I&) )T WpW;m\QYMB#}G>"#-zr͝.>k&VDg-JR0⳦ tzFГۜ|zTx3V8trKdd][f[I$Y\RU]DgSrj $SwﱭLu+-n!N@քK%C,c+EeH'|~+_z|+K$q?sOGT}<[٢$F!}➃LJ.9&IeQQwhfs݆Mԫ`32*b O""gNԟf 3v-h6ug]_f=<`Hy?1L`[1a!^sA3.psԾwD@&rG&)4ւ3 Q()t6Xx|2k8d3DF|VsǢܬpLBŒ69[)v@hZUMDtODdzEzYm֗NW#\)'vK[K(pC (33vPpO3Z q@W!5% gl=iIs=I䙚BN9FPO< J"SRgkI#}f5iqYv=BYV(@&V0{~i:"1d9j 5UcRKHa O#ڦ2ݿQxɃng,HmFd**[Q!-Fl,Iը8>a`c`&YTjPNxpu++l?8flw Q 2LcSHƜoAr% LOѕ#r;`13\(F9ܑE( 2Ah JQ!=c fVnR[.9Er4l[OFU9-R)YmC(®]3]1JƼ]C>ߚO@JӞ֓|—vr4ϣV@(ɠ.AbԉZ{yc`2l ;fPAHn0˾<pK;m*`bge7#YCg wfҊJ|⤲L8ʴf5Q!m# $4S+d-7![pHUXgr(94sr,ddOUI`c qK[iF7j OVi&h!fd y1!<̝37$Ѣ{b{jy ӤQ]t6IG`Aу4f d9/0`T`yQʸ#fsu9djsF PY2ru~ )ٸPvXÖ؜qOJEϹd!{)Iڡ;];n\9^KYo W :-Xq_20"s ҫ=~^vsWq˒7>uR;ÙIWU@޺ޑvϥxn}<+\W֎$ki*G%vYct Ϸ"b TZ ˺glmKQ*nd,rBg čխ9rkhnq͘M 4Qw"FQa:ߜsm᳝g{W,8ޯog3KqX(0O$ CӑȷJ`+D dT;/rk]Ey< %fW+9$$< 8w\VUڰ gո{!fWYYF7數T@}=)1[Ku3dQ uee`vZn:*+6"C 4Fpp fБy gs?0HE& >ΜmvL͌ c9ezqkM$I%o1H%eGpGG7RHF7r{hE8XGϊ^V᜷1{ #cu 7V|\V}ṑIRt(\X3S5Bl[Ѯ$N!`ڷ)ej)YJ@@C 1R=\ږbڵTd۴Wm%qMۇvGSut$̉(` e7KL5)sB[{(٬-e^c@k4 tI~T)q7%ɝ=Чm_:ȃJmHD`_=Fy(1۱I܁LFTA. n&TmL S8PUJ7⫉FbWAV^<tFW;b$b䢶=x# )PDV 4i"4fӂWrC7U9='kј# 7:[נI2Sr<[؊(X ƑݩU MI O02y(^!#2>Ԭ- Ăs@6y4r0H":3E+qCޅq(Ac;l┹9KFu3 18fS/RGWlF,;dAT10i esb9U٭x}q TߚϚIa;bw:ӃǃVi*>͢E>sWHĎCAҪw{b5^ B! @>wg 1rHl g泟Z]_G"I-\/ۯ8PZaP7ZelAx%A%26o55ڸ)[mXU$KɫJc?xUT4jݴ4b2u{Էicwڪ|im3j#lzc NU+w%Wt[ )3}Iju'|V-p z~ ePwg9W fPN n[$T:ӭ}uգ8dB$OR?ֳjTycĎӼMlY4M4=2!Љzn*I%`gJhIo1IrtxtƸ+3!gAvϦY0+r uAT,b^Ԍ8û-"+ ZCL@4ن+?֍rxY..Ue~?qk!HELkKr<ޣWٳgR I5%SpOʱμS7 9!F3ҿ RLKu]#I'N9autz+X'Lvކ=qnX9GnQ}醸 .2Jmlr)Y:J=궝9SS:vhNZ2vQcFpn) Ώ0Zx;HE\!g՝YVbq욕5E65+m$ ޓ⌁$" 1C ^90[X#?憥J}v,ɝ*ӨsӖ84aQ!$P. #F6vF9~M9g([I+D:p}Fus*&7,BkS#mM:r)'XhѸ JTF:5661ez۴9Ъsc;*Ky чyTKd!ѐ#+j$ibE8 'I Oxhm8+LUIj@ pv#8>(R띪/K)" #Y  FoSpȨTi$ I*f$=ʆbޅwd$sj9:YePK*ⷦFkz*qjЀFA zۻm?oJR#Fkz͖H# Dm*: b8\q7=Ul76*у! #QflR1 &d2c9khQ RUCi^F3YOѥFcLQ@lL]H^9\GѥA#N$S:)ujޮ)Li:t9޹49; ͣ&q HzZGtr@r4Oq'x ?8z=©XHy; $R.<5hTnq%摒 nr0@!~4ݘ&4G,qAc$'uX#ՑiY[Fޗ~' VN?z4֘=3f"KڷnzlRp\MNy iLˈny㊦7O@< PcfVp٪SK($t KA v3ݎIVY_"GЈV=+51s>xmJ61;+ Q%HڰbmI:\RktVZ-r7żSHryֽc##R\.H4Zwi\ByGcNk,@ś8Ӟ)^Hb6tS&50E-,$fx>#(։qvaD%"d9*IQ;s,SdX!QsAAmq+I6OEGMyvbZq^n90I+?lG" I$QB B6>c*,ii"͓|Uv /hA1&8%R3`矚NGm_1Oo++ Imi@H0 ^+~uHnOk z>+6v5Bx[g#yT8ҫ4'cy4$j۹+Ȼ.5#*Mz8e4j\}2Rv pcU"ƾ8X.ɓTnOW$>{Vo&VGBJMDW+Krkf.Kh;ӫu<{鬳ERum&&RToFI@3 5.LVG P0؜R\`N G/l.f0OF5WqoV2K3P0hCRy)uP[$r7;RuWrۅ FChRoe1Id6oL}@7ba(052JR_妝c\2^3PsI݇'܅P"y{' ^ip p +EJ9N/JV%#!Qq}VX`~kJ(oIi˅yЀ}12Eǂ){.a¨2@9h:jwKqJX$q4zD>4wtr |E['[J6>>kǻ jSMNj]q ؏Jsՠw#qEI$eV6ŵ<%2T(4P碱DrLA 8Z;;rvaS[Za@5k\1aE<nʑD@#j#-I~(/jf^v͖ ~'TL9R$.A_$|~, TrX`ct QEc:R%i $+7ڡ-P6׃Cd#z4e۶> kyUf]ԃ<\T+sE?hIر!q$g!X3gD;%WX┺c*9 #?کLL`Z4ڳ$ߐ >k!epnRFTF,RID |m IY?S2:W[52.P{3Gp'8⢓ZY},3dފoq΄d_A'riΝO+5MRy6n>I` [YQԹ\\8\H0 AH׎cu;f!B"D R&@VU@8AiDX!MJ_ۃ&[sPgHcMNVDV` {Ϲ8,[%qU?&ۺ(0.| It{VYaw Aᦶ?PɧOǽ5-!Y W 9;ɴ)ZIKǧV|ƒ,Ju`!V57/؜dgn(0El$\|((kf_<IW8 >=g&HBN)gϧ!~([Rr )ޓI\TUs!9`w:}sbqx|2[2\¡Lbcۃ\}GU/pOYDe>TbѴceXm",1w0ۂGƻ3d,=vcv\8Oq" Afʸ;OgbN2soڸC1swrϡ g'j#|PXH/#b@.-҂yjʾgl+FrJKs95r-*ѕk`ٳ[$x A4301dQEṊ1+r3ME1$G@?z'<12~i!(qB{*!heXk&c10(UbB}41!tH{i#uT#c)z*J56-{u "WGpCG[{vi"0:Y۴1ayh w#:mM`bcw fWe0XZ+eYnM_ug7yh+F"3#:\7OƜH@}XK>*:㾊29Gby9UUNQ ~bi%CP=. r*#-N#')|gaCf*/Qg[%vNC PQB~ ,L꒣:)ےMYxw@A+O18A*Sѥ4/pp@9LЇ>wΐWOTL ޙ*'kV7f57#ޘDKNeF>}IEaK(FoC:@Km$$ެoNnSi[{[ F[˩j|74sܯ`K O(9 O'gs&V'V$ieNQ2[ C7Vc28_mUзlNhG,Jpԡ&&*LH5axg5~.0G"_CZ>6Xb{j[FDbscs+Dսg a3Ekp#W1oIP Vrĕ8we$ І$dA15e*OiT6*Uv6̳`9{S" 3ɦXzZN8\ ᵍ,˺3YKIc֤O"sީ,lMU`$Ό ӥDe477hsܝzwȤ ku5v&"%:phroi9Եi g37IE.Pڎvj w2T㚽J2 8ߧw`j{k[`@|' 2Ux+@lJdps0`HepFJdɯR 8";eNKЉ}S8η.,4gc6/$g_GYR9런m?^0‡P a2FKvt Hwp$wyKc#|ڐA7+s9#v,:w#`v;:=4&d 5Lur}@%0Kv0_0$Q|]<I9@?Y1,GF `5v*oNeƄ( yUG{jiZA,l0$h c5 haV2ͤoj#Ri\\.>jHۍ, 8l022`FNF FH5~IC=n67Jbx&Y94^usWYHGީ2MX89e^2pQ'6쪤jA6>igmUR X&i''Te'%7Ⓤ][_Ӵit* psDVo]pI Ӥ+nqEXVO89¶pj"vT(,4uVU%}ꨏČ6d᝔ -@X\)gzNW9WJ+nNE\*\cڥvP*$HFT́8:P-:(t ȥ4r!<T0 *9>+E$KEax!٤~cX.EIƑmVْmA&B m[tHJ Re7$H[Ϛf9[cJd+?]؜v1mK~qNnXD9J L \lxn:1f1Ln62e'2Fuy>u%=,0"-|i$'4Fl:Alg%j%U #EhEw&<:sm1t(-m *7C12e4BAomN yRb$S$6[E|zXOWE`;PH(lAŖu?9,(p>SNAiY gzc#c)ѓ2Ȥlr(Y24+#Fq b6@91aTYHeVFϓ@eҫXqZ)KN2А4!㍩WM63B[Sc+jN'R 8x̌IqDK{q" -*ߨb[ #;x~+%bolWV'W[ig٨b0̄WC1UVvpR)oRۏj oa(e9d}-> ' i*q4^lʜSQ  ^@cg1B&9~)`t 4DJꌊoGv8iH椐GyHI4J>h,Ϩ u(" DRi`3P5222"`N G\ERj M1b@Pؑz%m\,*d)88jx/!tRQ<(2䒪-1CP;܎1KhiQKy!v'pXbE}G2h=J IƒH3;#F2s[wWc# Ӎ5kxTPr4L.Qlj4 WB5F5eYʊU]n_YӤ YtIČT@yF9.K1l1**j\*!E9hЬ9g$l+;4+ӻ#28D< a?MB~|`76]rLcGm{nMuׂkgq[k޵x 5gBC:rOV>= f vX=1I(6W$uid \ ?5#?ѻamsK%ٗ*$lکih#b+`u`QL+7wb/qo'pv"5y)T;V$k02qM:ݓ$1RCa'k(u~M"8?<-uVl$fvM+={(Y&ƒ?J bnN…WX8"Ĵj{czʹhd'soRz}9Xc 99 WEZ~yH䈼Nّ 7{W&di{k&@ߦ.ʲ #f cں?;+AHȦK'#!GA/qXpkܱٔ; WvV%w`m!o4H J9֤@'j$3#Rc*GWb$ǞJ؜oUrFa*gnށɂoe)"F"!bBEdYP" Ձ nY%8\I[Q'O#&| {ѣiK#%F*@ ;9&I$]rSo(2^PɗN+2D(/:`Apw1dRBN>qOE sfMYI>٪K`"Fˏ&J,Ѡir5[א<=31 )g_[8F9od*n-\QV*Vc[ QYf߷#<= NN$8 PH%o5 slIXǡl֓HgcMhKaͳ>q`$UW9W]4h + i^L]J nJņq!IaX\\\K0(+b# F攣Zdc2Fvbv9kn;Wm429rX"Ax#5Ne8ӟcF7B Z*|q1 U2 X.vZzuI$nЌmI-hL$dgneV8QQlotB/k$͐5LWqR(\GuJFҢ?K\zh!{ztDC:88mӗPO'kKG6w :sUe*d8w7&wQ<Opjw:M`N.5`ac`|y: 7@=ZNNqug #f [^%TK+]^;K?hh+s5"T$GAҚ.fYwy?;4D=Zrx^}'dkQlxGG陠bxU'JxĖupM've&<0}Ahu4:-fF 4r QRFsƺ+G84;=`VLm\+d |ԁH ז99Pk-J] sV՝J]6(@՝ ܣoP>i5^at\PW&)mտգD"3B@f38NѰm^Ia_HlI 2qf CPqC{DHgp*T겟@Vx1,hɨwQ XFxC!WA |VlW3@ݏ ^* eU6$I&0+HmMqIcIR6☇!TJ]j}&RVb+ Qe9W@\iP49{`12iR&XJbkFi=+ 4q ORI($QvՉ$)[A"A*^m(ďleW؊[#ΐ4?Glի Jׄ(@(NTjGu;k-744%(bRsٶ򔈓pK<PA^0FRq;"~=)A#V㍳~X`bc\LU@[4rX Ӵ'mۻ"de ')$ueFYk2;9cF;[O%|TZ6>;|.6(uh-b^vio.Ƭ*~hVΒN㊅=6PE#ptES',sFl0ym- Q9>[m_ܕl}JdR2Q o.sMs="cme|9Fڵ"/+I&>73X>? B1 ?5hp *AƍXo${Pl`#E/$5nU"nR͖x.nKNЪ`4cKoc^p2% 4?5HDA '*mS=<)+#;)U~hK ;sC4K&NW1 CqT%Üᨱ)A!ӨaNwBʄ#RlP6Q雍2#4Al* ̟{Hm(BP)`mgrw j4V&N.c'4K[z݆E2exϹd0[ko `*j4K J✼[FdOjgDl |{Q@!^. 9.3P6)>Ɖk,A]XXth,\7.Y zi)F-a61DA?;VK!F6XFFF3A{ YBڶ8PvxvPV] \vm-w)a,,=D=a Y.24?N1&cM%H>)ьwK$ D^ʲ2HPuy?SV,~Qc:N=Ƚ~nT`m~i:we"Fl.w*6A&9s?Qa)IvoS*er//-MI|g?6ù'|xtM#n3ʊ_%ԟ纝Ou%0`jI+aoRΒ+Nak(dE] ̱*+>EqCz4AY~qWW++?ڊ6'l0NơGA(FoZK6yGQgmT L3ǿ&U N67-:.ɕDc4Vv H(!Qa(ɒ7>Q-VMh[}5PK";!؁W@L7ܐ(pzF@DdT9l {Rv: rD9;yWHF4jѭK3.?GYs W\mWHԍ{ 6AXmM$ƇN}@X16Cg担w B jP6 n( A1 [f?ųup,(2(C7't01]CZ%d}|U̚TEm @D0\ h"}:.078Z1FjC5C F@mb[X.6q!g;B`{e:C~ ٞE$e\yګiE1#ޖ)䒸Tz|큶)ho gu3T>;vh43/-\ـ%@rq|ֽ}ޅ,1DCzI9ڝf l}LP|EnK$g$MYFF ~EO-հ Ie'$DFNGGen+R<`er7Ѿfi}#l\@̸f"ĥ@<`@)HR#'|"0qM#Rr$ie}Cڎɒ<RAO٪H °o M:A |FhvD lIl)ӝROXլnDW>(kC7|uDgC :uոT$dpڞ);)0IuXeJA1XNXB[#mjzI`ǣ};5˗c>h [?lz4F N> $,uYgoVsEbBiϏWXDzd* 4(ABt+"aYGy*F.푕RfU?͜mJERJ{˸,y.^+!#T=)$"TVYy홙tHiӞqAYc@/H >~j!0*cf>I[)vϚ st*?huxcT|P "268ڹmfɅx5h"]8m[K丸ǤP,ܗ1`$\\_amcA|ιow qq`޸Bd[Ȑnd!j?$:2AGLtvnzyVlw EoXO@vWO铫GYv}N Jw#8ҟFj= [;-ZUF?Dkk*:<z.dj?@0\@ WֱJDîKygdr1]?KXa4Z@9"fgyG&ŕiELlJ,uUXsX ]'Q kخ%n޹ ,n;u1n~~EXǧTsCD"-3~) !1Sbʼn^ZD y\Du4X"L۟4CW=g$.#yPT7=;{k(c"ƒ?B=Aw[6TLiծ9 $ !EV4"e-@[p cea*ieFB?4)Ra0% n8`\ , 6lb"RhXĞMeR } %z۟4# Դ(nIH85,wtʷ)"F ם "d>EWhtV/C3El*)1nvwS(}joP馎3h"X?UzX_\{ZrZ21<:}#\4IjGU=u%: EeҨv$2$n?ޒN}"jWsVԝ#K4@,`I0u-eDQq⺻"?JopwmD-p@%cְtK#g=C}ͣCR`Kk޹]QzyGF(8#>Mk3l[Lo=rcJNJb-c.@]|rZMD?W ֊bNd<R脨ż7hո(?s]n.t)F }BC h.Cy83: 49t͂_f3D~hLrP;T~iNq+۞"7ُqd2IN6Ǎ^0VŒ $C#z)NIGJH+;`z;Spi4:&̶q6mn[Ducbr yBH I qE{wt")$.n \'`ȨB`=BDu%NJ?L:9d PepAjˬ ΓTH\:8XqFfTzME.'ۣ(`~M3qVOiSIVE-I_0<\q#iP8#ޭbHw&db{QX'(QTS!m,0A*Jzl& , m $XƾS72 yUfN'cWv 3v%(FRZm j#\ @/aV 2yҭF}ͼE,Da)P'P0;6 #9n?x&}HVgЌ|J+,`)"4*H>8~ܻy>EM2=Yiʈ#rO>!Bףww.RI-c:~ȯrvԸ+"C*J,%v4ݙWB/;)g{} G2YV>v["6`2qx.:UW`>?t?mnkeqO~鑛KH+4/Аk?Tqj5niQGк tn]U]ߦ5)epIӀ'Vim!&)1O$:0ŅFs[MM~'lեmv$ob4 2Uk =Ӵv>Kl.eҬy%!Xu|޳@ j;l`(u(q+9̰FhB+kIՄp6(:SF¬'S@7 T3;f#2)Oi5rڗ#lJdE`3NJjV#^@'漚2p c8kwv L3ilc *@cȖ(dAwԕV4R3F;Lt%rtyMrŕ@'RdaFcHc(JK/x{(k3g↛U!~1%Im 2|gPS2$Ѯ*.]h`0M$sI# xX];f J=mRgڰ28.UĤ9V#%crVȔztO} ~?Um:5 t\`Ӗl,rxȮL! G9]!L`g~ky*5-u_i>;ȭY Uf2ba&w"cho!tnwx Jun?N 䵷nOOdXLM0dm[WK\'p%#t]R;_ZW>9`icV8k}|j#şQIu8&bI8ki6 ,ɣZR1䮕ny 0OBCBZ/Fg=ի'lb3V3Dpw&M1oVVH<āW=|K\WEla_F;` Z: k|r-8?"o%WVP2Ze.$y<t,ٟNG9Ps\5l:-N 4Z2K<<,ÀS$r0F((%1NޓǏFK50KcKs){JUn 'zז$A ˞yhG$JNP`)(Q5.2tgΡY˿l K$# @B3gҥ}y,d 3'EI*r}_o=K'8< I+"3Bڵn QBV]:ĠrXI'MC.!PG$A9ևN^u1r]9ls]2ztFl\$'o5fM ˕qm1f8)VεzmqqY5QvPBJ,e'W@* ƿ)i{ocEPI|R9`1h `8ˀ vړ1aG$YVǟmFj; 2pAE*ɑԷ$HLx *oJue;PIg S iʼ%sFqTNphq7xB)$3)$x5iz@q6 X8CcQܝ4mh4HޝjVE9isf471@0Pt(ISD}RlH1b6# VVVʄ׎3)}RTƑSm C>gO[S4(c}q1 Zs}9nUݖ:+;˕TI+A57[*E`46&"t$jQR* q`HV4RHsSWj&HHi?9Q:PHUEYa*:0P}":J>|U{u#ޗ"`zBQ43댺sH,BhwUot&ՇH͖!d9Pm9\zI,c w] yJkg=$ET9-HM;Y.&F7^[j';zBV(cgZ1nF)Zd[{8cɒ@9d{UtNЌl(# :N|S!K ƒƫ&֜kJ>kv&ic>׳YYqWC07mN[/su5S_B^2-ϕs -Ȓ(9'I!@U/-#wgaoS*R51XjVhrxߍ5x.帲3ڱ*H|U"ؖU.2 5`#1I+;cJ2vJCdc(2Bޗf!Uڋd8~*lb q6VUݛ\.95ϧbtauH TM[8`c1rE^ $^œ9/K@G3WbG:moZ2rJ&fk(FFje%9liN@C^üVd#@ټbQbN HM@sY\PɾtRl8RHCBDms4%Sz`FAޘfCA飅 pLe7$wz;!;?e6W7%Y4TGc5# $ia $YQd6=[8:t+ymg"+S`[XMS?b; YUR;9|iQ5 ,tQlZRpr= u$r mqA7#(eH>wLY,C7۝~s}(tNW"; EgS! ĐA8whWQ }-~BVl'Z*gp,]>k77 6ⲡ}^YF j&Բ탤@̳P>+-/c}$c9y` yKw$x#4d:j;pLM%\.~*y'K?Pc{-{V3P &c {flxa2yh%oAiGq\NgUp;eI+5Z@U;K(sTuh4.uSR1QQFw;T}T{/*sA=ȤC @5F8փc1`١< rPsyAαIrj]U5Sb2Ih$M. :A-T0K"d\xtz f}Qx<=d}dzռޑI#*S78 s>1p>lCe9$P`7'(3̌4Q7lm4kԖ@aIc8sEܡrgYY9lыHK*\ډڧ%%v9旴 7Q:5ʂJcN_m&B;|R@"A3\z6?j-H (*=ǽ K+ѸUW֗ 9#C3 nE-`y"D2X|V?_ؐ)OWIt$ ȞFЛD[V}I1,aF՟b + ;bWؼmL`dvͽZHƐq[ciǦ%d,u?o0CjMX\ɡ-9A90Fac3;誀`P< "t p{R B |*9*$U! z .cĀT#lEJ'k7Lb0d8i:s6Nk-#/]}KXIcveQ&VfٔF0NI]^"iuE1NڇvǿԀ(] urT<p#r Z23C[v?5{ܤR#Tlz|= *.“N64%;hut r6+n-#Dwnvi#աX؜d"31 H(I7SmtX%xՑ:~&fWRjo`ҝkŷղ I$iӱ~|ìHc Z6V! P04$k˦Vgl94ˌ we,ʲ;H P}#~LmSE&8R0 ޸n\u x ngEfrŚ8%FLqiӏdF}ȭ˫rEM1&AJu n뮖WJE;,elTVf4vWW(F(ngٷRJXHXjB .$e;{Zk+!z,6# OFk3Q̺jM4=Ab5x`Jqi&HiAyԺr);N\ z8ږ81:1W4V  ԷjBd@$Y0A w0vOBʊyjknmW$^@4O+tAm/cl]u?(ZFf а;ب8ZƒH,A j}؀K$&攸ku!$dYq"l=C8`h6ǛWp*GT]%e8,Nޘ\}м[CKr4I@%fPӐ0ا/-3>(+epF ZPt7ޜs cԼQ*ȱ T6хfed1V.bb 8QldrG΢ɓqUōw4R7*NI b\i~|yڍqF#vն9'&Ϲg`Um fӷ":V?LJ뛴j9$^uTe䃌)1W;; Krq0uA$lN``jҹ ʪ$(d\0@qZ[*fFLj᦮EBr7oj[*R$T42Gp>℁Vѓ 8#l+eW ϴmjtr9&u*BIShvI1eSNvޜaj,gDՐO1[ʿcRG~t $qN nfl,aS?k {ךeC)]ۼ3HV^!U(-m巊"wFuk<+tl`1ϲ v/c5x75_-%dC9WRt _;ȎP cھգfֱ:?"[K$=+H:ܶ3qsKC {"Cw2?q] !u1Hڱ+u`2ƪ$HXas$Ɋ($ơnf3Ʃp""Xv'{D+#捵fiϰLvZAiK{h&7k`V{ZNRI,q1~ۦ:2<7v lKuNoY X ݈"(\/'sف滟7VFInygEcGjJ4ꕵxkk6Cώ$iŽ#F>)BHR;n|'ОHV`DRr&d'rkmb)nus|̲eg5Yoo4VRFHݿ5Ѯ.9r r+GY8*a"ȯ!qZ)DZfT{vі|ھ rN6{;c`Pcz$EC){W?7Tv9#*Yb88y7 0SVv  ld!|* $e>0޹!-&MƓA53[clcV8­$L8rUg949`' ׹ yjU+D,h iTw } DNۼcSb=J*@̑A:g\oO#KIucifd>15f@>eFGhb*K)GExBxb]f5ffgD ;cicKr|Q-3"r8]F,qL" hФ>*Gv'Cj+$H*40ؚK Hhk5 d&d m6\& W MRh]]^- &8`3+hM&2T7iѾl0ոT:댿pO۩};>iQ,\NğWwWBI.$9Ӑ)I*8C #Gʷijѭ`d}$jOha$=FMdJa #cWH'bzYlY[P5hThVli .+c#[vvSMiZ̋;dnTy41z3Qy5iŰ\W<)0DeF3Kr!* 5st &A/>E]fS@Nc*q5/HI1$jFs#bBm{󝳜jIX[nJ0!`!:55fH9 x4- 4%C=iG$F5 Ҩw;C=IlR4K8H5D|DE~TK*vm`s)nxS`1hu;j<%nj0Doq}8fq+VQêo\MAu% xX|q] Ekڎ12dU)P׬~BU$\:8.KZ$)-OTuޡ)/zH<Uzz"m@ڰڑ#c)>F1Ϲwqkdm%FH4.pZF`M>]}v6'S6wq 0ı,o\H[Sw,Pz4R˸M>A$Յ3edjxn)q'VDHS,t|z;Yju ʇsQQ䕊T޷ hfowIN5Sr >QF!c#2 fR+-i{N5D#ey4u@mJYI>k,K݀єQNUⶠGsI%8Wݾ>1 B(YIoǽZ{qr%q4C0(PT揰Bazұk' ڔ!:Ρ8͹@˃.) A8@0$i\+40뷺S*@pD@p=whb='ҟ& o@'s[l϶IW3/بs9J\/8g*UݶçYP~N[MSPy :k3H.9 =Vb]$Y1iIY>ݺ3<2δ?^N5p5 w +.1ֺr%l~(t jzg3o=&Xp͑磒 VW<~+?/c,w9,aH6O0_(a7&LޜϊKg!YQ. Iԯ+J͚)ۓK$J#>+!6`o%ĉ*Us΁M-Z[$6\ 8c*f:]WFE516UE;U%fȑP6-\PXD!9j4mr2a9TA 8Cheʟtc:f)ls)^ qwR\e1G#FncMSz9.К-*J+4yU^gS#7⧳+;&W;Snr1D;ṻw+c+>di;P9h$ebcb}Hpp;s^o828{%ɍgq&Sn$vbNozԛ֠1sFFʩ<.M[h0,ZFI}+>4ЫdRp3hv\,lB'>5/MV:X@#KsVnޙ N k\ic!"o)U 5g&2\U\ZClL4yjN0v5h8Sp3Rk*{NVԡxdV0} {Uͳp[b+bc0X#>k9rc-*"%6"tFK0Hwf0Y;ՠ^;Np8J3}5lPOh,{kdf1XLW%8]Ru9XvM,ԐwJlJQT2HF }jh>$rp@Ż 3]є8ު3>J<7R ipD\3qⵍݠRG*OY? a@4vJ9ae۳'Ai'Vw'<fOPVjڏ+PN}S]li',OxFL]FxsM;;Hj>Ս-E:7;B[tWKzL`Von@Ta Z  V[~0ϣBex˂Sb0JjùէoF鋙>#o]SO"s>Ւ@*'cg$?mT1¶4UG ]q2 >E20W-#\Ig۹,dn:C32 Ǐޞ2}ExUL H>#FpC(557I!̉8$nӄS;].%63,ddVֱ:4er/$Ip+Fqxj,s/ G@N}͝)4' OJknBJ%.*_<抷6RWW."9 2 l(e(Iu840H2gp}H\1v8>ŠjuBY]_ޒi1RmYF2rKl+ֱ+Va0kJHF;{C[`"+(gnд|ߏzKLApHFec#4`>1BTLZfF`ܐI @%I\*㴯 QF 3롞rWGުT N ?ڪ!f8dm#d4Glq5XFA 9nz@GilqFN4:*p=KOie *l~䏨94U$VH[;p6!P) ߟ"!Q jlxF*,|WGFwa*%фIYFO,=G6OV- e,%x'~i{La˶J3LL>8s4 l+I2uBRnYP&j2GYN)9!AߌQKh5+>kXfuĆ'tsBGt} f2ƵO R6KA3Xa&i!2ʖh$Ca96lR@8=B;!R|cE l}@ԓn$G><28#iYFn([9$hϟHDkOLGh[H&U]ETf(dcSR+B[2S9;iۈ!vlFJs┻xy`Ga21RGlj(2@\mLOcj^܃L,Q䜬nMaVjw-ΡEJ)ȑw5qD;iH' L\&E,7)4AVer킪pH9HS?r3 &Uav4SW .p$QɻD\wbcKslG%G$SvI&Gp) Y-I{c(r;oU}H" hJey'JwܒwzPkEF =b I@00M%l^鲊5w5Z.Ѷ"cbҩadt|'Ą!0r@5[MT\>H'NV.j@I 2B5utI"ӃMC]L0-ʹFC~(Rژ7̷ u|b6<_SJpE^UX`251zIqC\rDF*~*6)Z9N޳uؔv=pe.eRW˦ `I;*b.ujmW{̐t ٗ50ZN5xsǽ K'ir"kXHu[W hTc%$)2K 0KHAȥNH8K{l'K*+ՠoᵬۯ7?T.=+(2 Vь8(|y8DWg8YmE= qH\."KD1;YtR G1{lDͳ1]16RlhƜcaM_ '1c?&Gbʥ(xح%F6ے LE,U:| V?rN~tk=r[!gx|e.0lji6l3|WuX^d|\>+:}o#*@5i+Iʑ^n܅fCӝM&18:\3ErDR}}:r6ڪ+tfWQL 7elȪ >+-І@4bI |bL#/I-Q6 cNOޱdV1TE [F̜$rg5D?[(Iҏ-彫P_nxXDhӤc V\pl۵b5v{ |mIub UNHS҉y1 D>9N͆\.0j $+FhDNFޕuyOZz ОQ93H#Tl|%/EX@ F<@Uc=XH dN㍏o nd->?D:kru퇍YڼPGTjB~Qh9`mp)b8Dzv$1>6Ha -$ 8;{o2"UVHK⌖HN5͔,+ch[VF8fi Z<wݑw# O;oD6.`i@v󸧉g8R eXU1wG4'lTfKRmH&,D…4u;EpYi}KU(͓",?d5ޙu)5hfDԍ$l2OM D$rhΡ>n&2agAX'mկ buPJ P&E|N鹔% V5W6pfus#[6MZygO1ewK{V9Ll %kd @ sk5o `z|gSniIz6%Wok\ۭF8؊<͙; m)o%tarPt6Ѿs^e9` 8ژX!hDjcfˌ=-/"K-Dka%}$xc_4PFyĩ `7 >(}O]' V)`SC;dg?v@.8 ל~ԸŻr |7bFR8`A-4<Ҥgim4$H Ov#E5SQšv5#;HTQo< N"r6'o-$hFd -.JE|d!lfRAirόbX wNDG,9Yt9XXYym'7ϵ=fѮ;0ƥ+ jt,4SLMxĸW޴G] :IItWC~'Rd5mXNJr0FDtfY}{N؅dQ́{j)hI1qӹh֯!`{]gaS8G$;gKzwRqFuD7tnDo>n 6U-%Խ85wi^``xCr5qV*ȮPǃN1}2o2&0P&WV$އȄ6Lɯ%_TjԚHf\(D_,o]o 7Ce5I &ʌqTҪ )l䱅;Oȑ jdCЮJ=ZьAh*5.|0iڐ+PU >߁U*rucu?ګ f@Q'pԤq*Xi洕fg+w1ɝlNIџo扰 .zm!W#=5](Y^2}'mx;0@T7ކcU[xI&M8/"bA/-+sC_j7եǁR1 nv4ݬAu#^*D :9=<3D-n)Ses7H'~\jMǠKD8S,1JА5JJ%lFS*lmϖ J)ku` \S;2i؂[ ѝӭed[ b7"kp8FM9&_K<`9$`Dʁ 4(hzI$`RD% pڔ BDd ?P$lЇ07"1Zr}L&W 4G#ՠt=ԹpqI>cW0H@:qjWw vlF8⥡`͠N@>i+uhH)5y3Fr $bpHʞvU׫a>ƍNxeFG $JޭZ>FQ8ޒF@FJP" "$%\AV=$$UeDn~<դ$ýJ4,psQONܴsSW#F%F]SaT;PlJ]%-#fLy.p?< $~9F&{1\AcʬmUڻa)jUzhrբ*;Ξv9TBOZvmeU:O> s]ןfoȍ[C}G8SʙP5mvWYH:} ;\]KgTK0qX(8Zc#$ *kvs 2$@G!DeNq|Udtm{bR9PhwiX6pmb'%}*;O7-]c~sڝuƱTёpq V麒gP[VHYFq+=fwiCD$TrKB{tB]T"׭.@Vxo8)UA'sgQoO wkc3 D'JWSLph;bN-6[4$д8G]$;TU.FrFz^yK՟ מY.@PA`'>i%IqCT#5w#2{T( 1 `7%IdZg880fNʒP\!m,p@. YK-IEѰWb>A$ SA?j1X$Jgm5bw`,/ pqη-tT)cD$ )!>$F GoCA J_4(r@Wm(֓ ڊ |\)sެ1{,:W8oh-[ږ23INѶq;J0$F(RҊKAS#inڋ`0^wgJՔe-(ơMqid+&#?5[&A1UilLb&B4[5 U 10sC,n>j$%4}yɣ̹ ;I%F(m8<]"ʬf IIUT9pIXBS1ձP?jyG.1FH,uWpH:NB Bǵ6,Q?J*'`(R%8Z<sQ5hIm r݇w~HVH$6EXJW ĥx7*3}-E"ܳ2ҷ*c:66K8'$l$`DJ:5t[br!@αx$ŧA.[#}VMRC DmAי{q ahR_,q┐Hu+ \Zz4eZ׍h*z͟QdU6FGK"{{{Q݊2zҡJYOW9Ru,CWfh6#EQl#'R'JX h:b3擔B N9Gk1~7iΜM.+`e 9c) ۖ?މrUQI-`-}Xv*M=wVY+֗!Ľv#`ݔiƇ$&mw"1uAqȫ(yF0E-ptP,գ-h;)+]E88x4Aa a܅L@ ަX[pj9N[&пXAs5j/85"#F WGlSi<6kh"I\ 2vf)_PZpY0 \AHVp |l64psZ2fOOwPt&^ V >+7tOvͦ;xL;_02M&y.Nsq O襾(Ac*'Uݒ q:ugGtءvq߻RѯmȌT;oXr7ػw1lHr/Ӽ !8;g\+kK)\ZP\Z$FÆfe4H%}C}j4q\Cp]hLl]᱊ [˕bm^*(# 8$ybEUCڛ%#,n 68#=KH32qI" H gc;j>%kgmZr.HfYR]},& (`>}JIⳝB敷xQYRObvIbըy,WJ42Bԧ OI`y?I_)SH-۲ObE0ƃij.пbE0f`U?p4P+ F]jHӖ)TNC$gi7:>qT]Z@y"U9:yDrY?Sh # 2(.R|yG08/#s341wq?4t7Z4C), j#I\NJ!"26 7/z:4d eBC$ G+HE{3HCd=lf0_ʺB#@iu4٦ (R^wd'V )K] 2 ;k,J0Ԕ˒IHOfE 0Pn#h`' fM+4IE(?BWi$|Q!FmD2(M9j.J8]IE Pv#)O H8lB8ITL0@|nhXD޶%mqQ2 3#.]N ' o%}H4SNqBFX3T/ɠi!F斖OUPǜ (~3 vWɕN `HR`4[f,(Tp1O6}>њTljSK 22 Z-aIKVh̚#?3*hG'튬C&Ml>ڜߣ-gn⑌L$}n5r3k4q4̦;JE ڪc7(- ae=u INr౸Eyv8⚴΢~(|ƢU#H#;*HHeFfTB(M Шq#$ ;L)221@HG"4lu2>j^Oo )S|ѡ{e*ny?*L<*jD~<#s( .`wF+ƥK1F(jR Qlh\lGf9]Mb:ϧl WcN#qWtΦ.D #GM2iGC|f# `ތ_`zSPJSzhȁ<|^7Wv$L]^ƝL+lATi hx\vUIw:DT&F,Ԩ ۊnhO1(#Q)tvLIRtqi^9 >6ǜoiGpvվƝ0L陇ܹolRueEL!`9V9\!Vle-GpI=cێkSp<N1dmJUldg4.7 hvoza$"$u{cH"L/xnq:*HWړ[KDĢ67ȦŌ`V"m4oPHx n2J+{h@4*Cm0fFRcMvH\޽Cn\vЀrAdSq ʂ^E[6$b"1CӺUTrIn(Di ,Ѩ;o_R9Ī8UdB#` -VYZbB;*dA9AeX`Rc:8uJ^}ۍ%ocw;(C&+j_PFH\,d&8 g+ﱥ#Vc>}O3 Qn.4*֨LNv>h1($ j{ҲQp0NޝBxT A"c)Ă-8m⚎sp)V;m#f]DdQr昏xr7<ӶYX6,3Bӡv4–ޝDFT1x,9`u8HیWFsېQU{Iz!*Hm^w4[\n99Vd򬒄 xޙZ.;LpϨ[HGQq旞I LS!@iZE)!ܷnmqVf̌4Նp (˦6]CjkXT9kd&R2I_4$2?ג9b+jӦKzrg#(8@"0lWdh\4HcNQ ohY$RkxԨ=^jd,08;ӗ6FeOvðN;Z10+;^$-9Wԯr)@$;:LpT1\6K R61JO JA%C{{VVT..zNhil)SGb-ܒomctSGԤ`޾$PF[Vu{1J erV6yu(ߜxY1$/G[GjXoE6ZX}~fgq!h2E*}iK$r$Aq@h6Kuc"U3lj ӏGZBc?5o* D`Ԗ)%E 3u>AP3 Q!)ʼn"$H;ri&Pd#11.h$k1ED)j!'~+NM/jLazKd"͌gމ1Ue3xWٴ+%sf..JƭRX;f4ВI@kvpy<`Nw+cph7N͍k9;oLAl@Q0ǜaajQzVc!99X* C Q%I$%wѺP[$ 0?qCa@`k5$gIp]V"5H1=n]#"gm!G 9#s[GFFk>& '~Gt9YUudCaI!^CIc}PВE̚2!sQ‰CiUF#qzy1j|MDv0K'-1C:c^nbxA, zWHdyC$dc#D?n:4Vtm4廞䋟G o4 '^<`d7݋g1i#[ٳ(ܱLMEIF"0+hR&$Ij)/{бYw$ZJ oEiSvh7sB=${յH^{;S>t]Б{KyRX$M 1qq ]#Э 9#Te%E<Yϊb̊J*,XT 2*#)N"Rc"FIWhV&AJ&GVPsW5yч]hUdeu =3&_7Pݱ,2IQ -' sQ#jm88- _RV\{#aٰWsH,@ @%J_H+29-H@gyVzStb #VAhov8UK9tIjco=f1Wl={5tBN794*KoosFHP ?9;zVayNqWDe\Vl$<~k6hB9xX#Fh7Cun)0,Rp$*a$jsVVfЭU]8?Ut6XJ niyhv*23 SƬOOS9y$2clTJo>2G:>¾iH2@ʡ$gZH^YU@z;<Am$h,.Eg*ڋmovDƨ5;N#$)o(|9uFz-o 8Tp#BI y# l epÚ$=THpr8ۊ;l=mV6:B#nݏeC!qzTqj>k=6ML7njb?Zw# 'KuUAa.enthought-chaco2-4.1.0.orig/examples/kiva/agg/lion.py0000644000175000017500000000145711674463635021534 0ustar varunvarunimport time import sys from kiva import agg if sys.platform == 'win32': now = time.clock else: now = time.time from lion_data import get_lion def main(): sz = (1000,1000) t1 = now() path_and_color, size, center = get_lion() t2 = now() print t2 - t1 gc = agg.GraphicsContextArray(sz) t1 = now() gc.translate_ctm(sz[0]/2.,sz[1]/2.) Nimages = 90 for i in range(Nimages): for path,color in path_and_color: gc.begin_path() gc.add_path(path) gc.set_fill_color(color) gc.set_alpha(0.3) gc.fill_path() gc.rotate_ctm(1) t2 = now() print 'total time, sec/image, img/sec:', t2 - t1, (t2-t1)/Nimages, Nimages/(t2-t1) gc.save('lion.bmp') if __name__ == "__main__": main() # EOF enthought-chaco2-4.1.0.orig/examples/kiva/agg/lion_data.py0000644000175000017500000005551311674463635022527 0ustar varunvarun""" Defines a function to return a vector image of a cartoon lion. This module relies on Agg solely for CompiledPath support. (Lion path data is copied from from Agg.) """ from numpy import amax, amin, array, dtype from enable.compiled_path import CompiledPath lion_string = """ f2cc99 M 69,18 L 82,8 L 99,3 L 118,5 L 135,12 L 149,21 L 156,13 L 165,9 L 177,13 L 183,28 L 180,50 L 164,91 L 155,107 L 154,114 L 151,121 L 141,127 L 139,136 L 155,206 L 157,251 L 126,342 L 133,357 L 128,376 L 83,376 L 75,368 L 67,350 L 61,350 L 53,369 L 4,369 L 2,361 L 5,354 L 12,342 L 16,321 L 4,257 L 4,244 L 7,218 L 9,179 L 26,127 L 43,93 L 32,77 L 30,70 L 24,67 L 16,49 L 17,35 L 18,23 L 30,12 L 40,7 L 53,7 L 62,12 L 69,18 L 69,18 L 69,18 e5b27f M 142,79 L 136,74 L 138,82 L 133,78 L 133,84 L 127,78 L 128,85 L 124,80 L 125,87 L 119,82 L 119,90 L 125,99 L 125,96 L 128,100 L 128,94 L 131,98 L 132,93 L 135,97 L 136,93 L 138,97 L 139,94 L 141,98 L 143,94 L 144,85 L 142,79 L 142,79 L 142,79 eb8080 M 127,101 L 132,100 L 137,99 L 144,101 L 143,105 L 135,110 L 127,101 L 127,101 L 127,101 f2cc99 M 178,229 L 157,248 L 139,296 L 126,349 L 137,356 L 158,357 L 183,342 L 212,332 L 235,288 L 235,261 L 228,252 L 212,250 L 188,251 L 178,229 L 178,229 L 178,229 9c826b M 56,229 L 48,241 L 48,250 L 57,281 L 63,325 L 71,338 L 81,315 L 76,321 L 79,311 L 83,301 L 75,308 L 80,298 L 73,303 L 76,296 L 71,298 L 74,292 L 69,293 L 74,284 L 78,278 L 71,278 L 74,274 L 68,273 L 70,268 L 66,267 L 68,261 L 60,266 L 62,259 L 65,253 L 57,258 L 59,251 L 55,254 L 55,248 L 60,237 L 54,240 L 58,234 L 54,236 L 56,229 L 56,229 L 56,229 M 74,363 L 79,368 L 81,368 L 85,362 L 89,363 L 92,370 L 96,373 L 101,372 L 108,361 L 110,371 L 113,373 L 116,371 L 120,358 L 122,363 L 123,371 L 126,371 L 129,367 L 132,357 L 135,361 L 130,376 L 127,377 L 94,378 L 84,376 L 76,371 L 74,363 L 74,363 L 74,363 M 212,250 L 219,251 L 228,258 L 236,270 L 235,287 L 225,304 L 205,332 L 177,343 L 171,352 L 158,357 L 166,352 L 168,346 L 168,339 L 165,333 L 155,327 L 155,323 L 161,320 L 165,316 L 169,316 L 167,312 L 171,313 L 168,308 L 173,309 L 170,306 L 177,306 L 175,308 L 177,311 L 174,311 L 176,316 L 171,315 L 174,319 L 168,320 L 168,323 L 175,327 L 179,332 L 183,326 L 184,332 L 189,323 L 190,328 L 194,320 L 194,325 L 199,316 L 201,320 L 204,313 L 206,316 L 208,310 L 211,305 L 219,298 L 226,288 L 229,279 L 228,266 L 224,259 L 217,253 L 212,250 L 212,250 L 212,250 M 151,205 L 151,238 L 149,252 L 141,268 L 128,282 L 121,301 L 130,300 L 126,313 L 118,324 L 116,337 L 120,346 L 133,352 L 133,340 L 137,333 L 145,329 L 156,327 L 153,319 L 153,291 L 157,271 L 170,259 L 178,277 L 193,250 L 174,216 L 151,205 L 151,205 L 151,205 M 78,127 L 90,142 L 95,155 L 108,164 L 125,167 L 139,175 L 150,206 L 152,191 L 141,140 L 121,148 L 100,136 L 78,127 L 78,127 L 78,127 M 21,58 L 35,63 L 38,68 L 32,69 L 42,74 L 40,79 L 47,80 L 54,83 L 45,94 L 34,81 L 32,73 L 24,66 L 21,58 L 21,58 L 21,58 M 71,34 L 67,34 L 66,27 L 59,24 L 54,17 L 48,17 L 39,22 L 30,26 L 28,31 L 31,39 L 38,46 L 29,45 L 36,54 L 41,61 L 41,70 L 50,69 L 54,71 L 55,58 L 67,52 L 76,43 L 76,39 L 68,44 L 71,34 L 71,34 L 71,34 M 139,74 L 141,83 L 143,89 L 144,104 L 148,104 L 155,106 L 154,86 L 157,77 L 155,72 L 150,77 L 144,77 L 139,74 L 139,74 L 139,74 M 105,44 L 102,53 L 108,58 L 111,62 L 112,55 L 105,44 L 105,44 L 105,44 M 141,48 L 141,54 L 144,58 L 139,62 L 137,66 L 136,59 L 137,52 L 141,48 L 141,48 L 141,48 M 98,135 L 104,130 L 105,134 L 108,132 L 108,135 L 112,134 L 113,137 L 116,136 L 116,139 L 119,139 L 124,141 L 128,140 L 133,138 L 140,133 L 139,140 L 126,146 L 104,144 L 98,135 L 98,135 L 98,135 M 97,116 L 103,119 L 103,116 L 111,118 L 116,117 L 122,114 L 127,107 L 135,111 L 142,107 L 141,114 L 145,118 L 149,121 L 145,125 L 140,124 L 127,121 L 113,125 L 100,124 L 97,116 L 97,116 L 97,116 M 147,33 L 152,35 L 157,34 L 153,31 L 160,31 L 156,28 L 161,28 L 159,24 L 163,25 L 163,21 L 165,22 L 170,23 L 167,17 L 172,21 L 174,18 L 175,23 L 176,22 L 177,28 L 177,33 L 174,37 L 176,39 L 174,44 L 171,49 L 168,53 L 164,57 L 159,68 L 156,70 L 154,60 L 150,51 L 146,43 L 144,35 L 147,33 L 147,33 L 147,33 M 85,72 L 89,74 L 93,75 L 100,76 L 105,75 L 102,79 L 94,79 L 88,76 L 85,72 L 85,72 L 85,72 M 86,214 L 79,221 L 76,232 L 82,225 L 78,239 L 82,234 L 78,245 L 81,243 L 79,255 L 84,250 L 84,267 L 87,254 L 90,271 L 90,257 L 95,271 L 93,256 L 95,249 L 92,252 L 93,243 L 89,253 L 89,241 L 86,250 L 87,236 L 83,245 L 87,231 L 82,231 L 90,219 L 84,221 L 86,214 L 86,214 L 86,214 ffcc7f M 93,68 L 96,72 L 100,73 L 106,72 L 108,66 L 105,63 L 100,62 L 93,68 L 93,68 L 93,68 M 144,64 L 142,68 L 142,73 L 146,74 L 150,73 L 154,64 L 149,62 L 144,64 L 144,64 L 144,64 9c826b M 57,91 L 42,111 L 52,105 L 41,117 L 53,112 L 46,120 L 53,116 L 50,124 L 57,119 L 55,127 L 61,122 L 60,130 L 67,126 L 66,134 L 71,129 L 72,136 L 77,130 L 76,137 L 80,133 L 82,138 L 86,135 L 96,135 L 94,129 L 86,124 L 83,117 L 77,123 L 79,117 L 73,120 L 75,112 L 68,116 L 71,111 L 65,114 L 69,107 L 63,110 L 68,102 L 61,107 L 66,98 L 61,103 L 63,97 L 57,99 L 57,91 L 57,91 L 57,91 M 83,79 L 76,79 L 67,82 L 75,83 L 65,88 L 76,87 L 65,92 L 76,91 L 68,96 L 77,95 L 70,99 L 80,98 L 72,104 L 80,102 L 76,108 L 85,103 L 92,101 L 87,98 L 93,96 L 86,94 L 91,93 L 85,91 L 93,89 L 99,89 L 105,93 L 107,85 L 102,82 L 92,80 L 83,79 L 83,79 L 83,79 M 109,77 L 111,83 L 109,89 L 113,94 L 117,90 L 117,81 L 114,78 L 109,77 L 109,77 L 109,77 M 122,128 L 127,126 L 134,127 L 136,129 L 134,130 L 130,128 L 124,129 L 122,128 L 122,128 L 122,128 M 78,27 L 82,32 L 80,33 L 82,36 L 78,37 L 82,40 L 78,42 L 81,46 L 76,47 L 78,49 L 74,50 L 82,52 L 87,50 L 83,48 L 91,46 L 86,45 L 91,42 L 88,40 L 92,37 L 86,34 L 90,31 L 86,29 L 89,26 L 78,27 L 78,27 L 78,27 M 82,17 L 92,20 L 79,21 L 90,25 L 81,25 L 94,28 L 93,26 L 101,30 L 101,26 L 107,33 L 108,28 L 111,40 L 113,34 L 115,45 L 117,39 L 119,54 L 121,46 L 124,58 L 126,47 L 129,59 L 130,49 L 134,58 L 133,44 L 137,48 L 133,37 L 137,40 L 133,32 L 126,20 L 135,26 L 132,19 L 138,23 L 135,17 L 142,18 L 132,11 L 116,6 L 94,6 L 78,11 L 92,12 L 80,14 L 90,16 L 82,17 L 82,17 L 82,17 M 142,234 L 132,227 L 124,223 L 115,220 L 110,225 L 118,224 L 127,229 L 135,236 L 122,234 L 115,237 L 113,242 L 121,238 L 139,243 L 121,245 L 111,254 L 95,254 L 102,244 L 104,235 L 110,229 L 100,231 L 104,224 L 113,216 L 122,215 L 132,217 L 141,224 L 145,230 L 149,240 L 142,234 L 142,234 L 142,234 M 115,252 L 125,248 L 137,249 L 143,258 L 134,255 L 125,254 L 115,252 L 115,252 L 115,252 M 114,212 L 130,213 L 140,219 L 147,225 L 144,214 L 137,209 L 128,207 L 114,212 L 114,212 L 114,212 M 102,263 L 108,258 L 117,257 L 131,258 L 116,260 L 109,265 L 102,263 L 102,263 L 102,263 M 51,241 L 35,224 L 40,238 L 23,224 L 31,242 L 19,239 L 28,247 L 17,246 L 25,250 L 37,254 L 39,263 L 44,271 L 47,294 L 48,317 L 51,328 L 60,351 L 60,323 L 53,262 L 47,246 L 51,241 L 51,241 L 51,241 M 2,364 L 9,367 L 14,366 L 18,355 L 20,364 L 26,366 L 31,357 L 35,364 L 39,364 L 42,357 L 47,363 L 53,360 L 59,357 L 54,369 L 7,373 L 2,364 L 2,364 L 2,364 M 7,349 L 19,345 L 25,339 L 18,341 L 23,333 L 28,326 L 23,326 L 27,320 L 23,316 L 25,311 L 20,298 L 15,277 L 12,264 L 9,249 L 10,223 L 3,248 L 5,261 L 15,307 L 17,326 L 11,343 L 7,349 L 7,349 L 7,349 M 11,226 L 15,231 L 25,236 L 18,227 L 11,226 L 11,226 L 11,226 M 13,214 L 19,217 L 32,227 L 23,214 L 16,208 L 15,190 L 24,148 L 31,121 L 24,137 L 14,170 L 8,189 L 13,214 L 13,214 L 13,214 M 202,254 L 195,258 L 199,260 L 193,263 L 197,263 L 190,268 L 196,268 L 191,273 L 188,282 L 200,272 L 194,272 L 201,266 L 197,265 L 204,262 L 200,258 L 204,256 L 202,254 L 202,254 L 202,254 845433 M 151,213 L 165,212 L 179,225 L 189,246 L 187,262 L 179,275 L 176,263 L 177,247 L 171,233 L 163,230 L 165,251 L 157,264 L 146,298 L 145,321 L 133,326 L 143,285 L 154,260 L 153,240 L 151,213 L 151,213 L 151,213 M 91,132 L 95,145 L 97,154 L 104,148 L 107,155 L 109,150 L 111,158 L 115,152 L 118,159 L 120,153 L 125,161 L 126,155 L 133,164 L 132,154 L 137,163 L 137,152 L 142,163 L 147,186 L 152,192 L 148,167 L 141,143 L 124,145 L 105,143 L 91,132 L 91,132 L 91,132 9c826b M 31,57 L 23,52 L 26,51 L 20,44 L 23,42 L 21,36 L 22,29 L 25,23 L 24,32 L 30,43 L 26,41 L 30,50 L 26,48 L 31,57 L 31,57 L 31,57 M 147,21 L 149,28 L 155,21 L 161,16 L 167,14 L 175,15 L 173,11 L 161,9 L 147,21 L 147,21 L 147,21 M 181,39 L 175,51 L 169,57 L 171,65 L 165,68 L 165,75 L 160,76 L 162,91 L 171,71 L 180,51 L 181,39 L 181,39 L 181,39 M 132,346 L 139,348 L 141,346 L 142,341 L 147,342 L 143,355 L 133,350 L 132,346 L 132,346 L 132,346 M 146,355 L 151,352 L 155,348 L 157,343 L 160,349 L 151,356 L 147,357 L 146,355 L 146,355 L 146,355 M 99,266 L 100,281 L 94,305 L 86,322 L 78,332 L 72,346 L 73,331 L 91,291 L 99,266 L 99,266 L 99,266 M 20,347 L 32,342 L 45,340 L 54,345 L 45,350 L 42,353 L 38,350 L 31,353 L 29,356 L 23,350 L 19,353 L 15,349 L 20,347 L 20,347 L 20,347 M 78,344 L 86,344 L 92,349 L 88,358 L 84,352 L 78,344 L 78,344 L 78,344 M 93,347 L 104,344 L 117,345 L 124,354 L 121,357 L 116,351 L 112,351 L 108,355 L 102,351 L 93,347 L 93,347 L 93,347 000000 M 105,12 L 111,18 L 113,24 L 113,29 L 119,34 L 116,23 L 112,16 L 105,12 L 105,12 L 105,12 M 122,27 L 125,34 L 127,43 L 128,34 L 125,29 L 122,27 L 122,27 L 122,27 M 115,13 L 122,19 L 122,15 L 113,10 L 115,13 L 115,13 L 115,13 ffe5b2 M 116,172 L 107,182 L 98,193 L 98,183 L 90,199 L 89,189 L 84,207 L 88,206 L 87,215 L 95,206 L 93,219 L 91,230 L 98,216 L 97,226 L 104,214 L 112,209 L 104,208 L 113,202 L 126,200 L 139,207 L 132,198 L 142,203 L 134,192 L 142,195 L 134,187 L 140,185 L 130,181 L 136,177 L 126,177 L 125,171 L 116,180 L 116,172 L 116,172 L 116,172 M 74,220 L 67,230 L 67,221 L 59,235 L 63,233 L 60,248 L 70,232 L 65,249 L 71,243 L 67,256 L 73,250 L 69,262 L 73,259 L 71,267 L 76,262 L 72,271 L 78,270 L 76,275 L 82,274 L 78,290 L 86,279 L 86,289 L 92,274 L 88,275 L 87,264 L 82,270 L 82,258 L 77,257 L 78,247 L 73,246 L 77,233 L 72,236 L 74,220 L 74,220 L 74,220 M 133,230 L 147,242 L 148,250 L 145,254 L 138,247 L 129,246 L 142,245 L 138,241 L 128,237 L 137,238 L 133,230 L 133,230 L 133,230 M 133,261 L 125,261 L 116,263 L 111,267 L 125,265 L 133,261 L 133,261 L 133,261 M 121,271 L 109,273 L 103,279 L 99,305 L 92,316 L 85,327 L 83,335 L 89,340 L 97,341 L 94,336 L 101,336 L 96,331 L 103,330 L 97,327 L 108,325 L 99,322 L 109,321 L 100,318 L 110,317 L 105,314 L 110,312 L 107,310 L 113,308 L 105,306 L 114,303 L 105,301 L 115,298 L 107,295 L 115,294 L 108,293 L 117,291 L 109,289 L 117,286 L 109,286 L 118,283 L 112,281 L 118,279 L 114,278 L 119,276 L 115,274 L 121,271 L 121,271 L 121,271 M 79,364 L 74,359 L 74,353 L 76,347 L 80,351 L 83,356 L 82,360 L 79,364 L 79,364 L 79,364 M 91,363 L 93,356 L 97,353 L 103,355 L 105,360 L 103,366 L 99,371 L 94,368 L 91,363 L 91,363 L 91,363 M 110,355 L 114,353 L 118,357 L 117,363 L 113,369 L 111,362 L 110,355 L 110,355 L 110,355 M 126,354 L 123,358 L 124,367 L 126,369 L 129,361 L 129,357 L 126,354 L 126,354 L 126,354 M 30,154 L 24,166 L 20,182 L 23,194 L 29,208 L 37,218 L 41,210 L 41,223 L 46,214 L 46,227 L 52,216 L 52,227 L 61,216 L 59,225 L 68,213 L 73,219 L 70,207 L 77,212 L 69,200 L 77,202 L 70,194 L 78,197 L 68,187 L 76,182 L 64,182 L 58,175 L 58,185 L 53,177 L 50,186 L 46,171 L 44,182 L 39,167 L 36,172 L 36,162 L 30,166 L 30,154 L 30,154 L 30,154 M 44,130 L 41,137 L 45,136 L 43,150 L 48,142 L 48,157 L 53,150 L 52,164 L 60,156 L 61,169 L 64,165 L 66,175 L 70,167 L 74,176 L 77,168 L 80,183 L 85,172 L 90,182 L 93,174 L 98,181 L 99,173 L 104,175 L 105,169 L 114,168 L 102,163 L 95,157 L 94,166 L 90,154 L 87,162 L 82,149 L 75,159 L 72,148 L 68,155 L 67,143 L 62,148 L 62,138 L 58,145 L 56,133 L 52,142 L 52,128 L 49,134 L 47,125 L 44,130 L 44,130 L 44,130 M 13,216 L 19,219 L 36,231 L 22,223 L 16,222 L 22,227 L 12,224 L 13,220 L 16,220 L 13,216 L 13,216 L 13,216 M 10,231 L 14,236 L 25,239 L 27,237 L 19,234 L 10,231 L 10,231 L 10,231 M 9,245 L 14,242 L 25,245 L 13,245 L 9,245 L 9,245 L 9,245 M 33,255 L 26,253 L 18,254 L 25,256 L 18,258 L 27,260 L 18,263 L 27,265 L 19,267 L 29,270 L 21,272 L 29,276 L 21,278 L 30,281 L 22,283 L 31,287 L 24,288 L 32,292 L 23,293 L 34,298 L 26,299 L 37,303 L 32,305 L 39,309 L 33,309 L 39,314 L 34,314 L 40,318 L 34,317 L 40,321 L 34,321 L 41,326 L 33,326 L 40,330 L 33,332 L 39,333 L 33,337 L 42,337 L 54,341 L 49,337 L 52,335 L 47,330 L 50,330 L 45,325 L 49,325 L 45,321 L 48,321 L 45,316 L 46,306 L 45,286 L 43,274 L 36,261 L 33,255 L 33,255 L 33,255 M 7,358 L 9,351 L 14,351 L 17,359 L 11,364 L 7,358 L 7,358 L 7,358 M 44,354 L 49,351 L 52,355 L 49,361 L 44,354 L 44,354 L 44,354 M 32,357 L 37,353 L 40,358 L 36,361 L 32,357 L 32,357 L 32,357 M 139,334 L 145,330 L 154,330 L 158,334 L 154,341 L 152,348 L 145,350 L 149,340 L 147,336 L 141,339 L 139,345 L 136,342 L 136,339 L 139,334 L 139,334 L 139,334 M 208,259 L 215,259 L 212,255 L 220,259 L 224,263 L 225,274 L 224,283 L 220,292 L 208,300 L 206,308 L 203,304 L 199,315 L 197,309 L 195,318 L 193,313 L 190,322 L 190,316 L 185,325 L 182,318 L 180,325 L 172,321 L 178,320 L 176,313 L 186,312 L 180,307 L 188,307 L 184,303 L 191,302 L 186,299 L 195,294 L 187,290 L 197,288 L 192,286 L 201,283 L 194,280 L 203,277 L 198,275 L 207,271 L 200,269 L 209,265 L 204,265 L 212,262 L 208,259 L 208,259 L 208,259 M 106,126 L 106,131 L 109,132 L 111,134 L 115,132 L 115,135 L 119,133 L 118,137 L 123,137 L 128,137 L 133,134 L 136,130 L 136,127 L 132,124 L 118,128 L 112,128 L 106,126 L 106,126 L 106,126 M 107,114 L 101,110 L 98,102 L 105,97 L 111,98 L 119,102 L 121,108 L 118,112 L 113,115 L 107,114 L 107,114 L 107,114 M 148,106 L 145,110 L 146,116 L 150,118 L 152,111 L 151,107 L 148,106 L 148,106 L 148,106 M 80,55 L 70,52 L 75,58 L 63,57 L 72,61 L 57,61 L 67,66 L 57,67 L 62,69 L 54,71 L 61,73 L 54,77 L 63,78 L 53,85 L 60,84 L 56,90 L 69,84 L 63,82 L 75,76 L 70,75 L 77,72 L 72,71 L 78,69 L 72,66 L 81,67 L 78,64 L 82,63 L 80,60 L 86,62 L 80,55 L 80,55 L 80,55 M 87,56 L 91,52 L 96,50 L 102,56 L 98,56 L 92,60 L 87,56 L 87,56 L 87,56 M 85,68 L 89,73 L 98,76 L 106,74 L 96,73 L 91,70 L 85,68 L 85,68 L 85,68 M 115,57 L 114,64 L 111,64 L 115,75 L 122,81 L 122,74 L 126,79 L 126,74 L 131,78 L 130,72 L 133,77 L 131,68 L 126,61 L 119,57 L 115,57 L 115,57 L 115,57 M 145,48 L 143,53 L 147,59 L 151,59 L 150,55 L 145,48 L 145,48 L 145,48 M 26,22 L 34,15 L 43,10 L 52,10 L 59,16 L 47,15 L 32,22 L 26,22 L 26,22 L 26,22 M 160,19 L 152,26 L 149,34 L 154,33 L 152,30 L 157,30 L 155,26 L 158,27 L 157,23 L 161,23 L 160,19 L 160,19 L 160,19 000000 M 98,117 L 105,122 L 109,122 L 105,117 L 113,120 L 121,120 L 130,112 L 128,108 L 123,103 L 123,99 L 128,101 L 132,106 L 135,109 L 142,105 L 142,101 L 145,101 L 145,91 L 148,101 L 145,105 L 136,112 L 135,116 L 143,124 L 148,120 L 150,122 L 142,128 L 133,122 L 121,125 L 112,126 L 103,125 L 100,129 L 96,124 L 98,117 L 98,117 L 98,117 M 146,118 L 152,118 L 152,115 L 149,115 L 146,118 L 146,118 L 146,118 M 148,112 L 154,111 L 154,109 L 149,109 L 148,112 L 148,112 L 148,112 M 106,112 L 108,115 L 114,116 L 118,114 L 106,112 L 106,112 L 106,112 M 108,108 L 111,110 L 116,110 L 119,108 L 108,108 L 108,108 L 108,108 M 106,104 L 109,105 L 117,106 L 115,104 L 106,104 L 106,104 L 106,104 M 50,25 L 41,26 L 34,33 L 39,43 L 49,58 L 36,51 L 47,68 L 55,69 L 54,59 L 61,57 L 74,46 L 60,52 L 67,42 L 57,48 L 61,40 L 54,45 L 60,36 L 59,29 L 48,38 L 52,30 L 47,32 L 50,25 L 50,25 L 50,25 M 147,34 L 152,41 L 155,49 L 161,53 L 157,47 L 164,47 L 158,43 L 168,44 L 159,40 L 164,37 L 169,37 L 164,33 L 169,34 L 165,28 L 170,30 L 170,25 L 173,29 L 175,27 L 176,32 L 173,36 L 175,39 L 172,42 L 172,46 L 168,49 L 170,55 L 162,57 L 158,63 L 155,58 L 153,50 L 149,46 L 147,34 L 147,34 L 147,34 M 155,71 L 159,80 L 157,93 L 157,102 L 155,108 L 150,101 L 149,93 L 154,101 L 152,91 L 151,83 L 155,79 L 155,71 L 155,71 L 155,71 M 112,78 L 115,81 L 114,91 L 112,87 L 113,82 L 112,78 L 112,78 L 112,78 M 78,28 L 64,17 L 58,11 L 47,9 L 36,10 L 28,16 L 21,26 L 18,41 L 20,51 L 23,61 L 33,65 L 28,68 L 37,74 L 36,81 L 43,87 L 48,90 L 43,100 L 40,98 L 39,90 L 31,80 L 30,72 L 22,71 L 17,61 L 14,46 L 16,28 L 23,17 L 33,9 L 45,6 L 54,6 L 65,12 L 78,28 L 78,28 L 78,28 M 67,18 L 76,9 L 87,5 L 101,2 L 118,3 L 135,8 L 149,20 L 149,26 L 144,19 L 132,12 L 121,9 L 105,7 L 89,8 L 76,14 L 70,20 L 67,18 L 67,18 L 67,18 M 56,98 L 48,106 L 56,103 L 47,112 L 56,110 L 52,115 L 57,113 L 52,121 L 62,115 L 58,123 L 65,119 L 63,125 L 69,121 L 68,127 L 74,125 L 74,129 L 79,128 L 83,132 L 94,135 L 93,129 L 85,127 L 81,122 L 76,126 L 75,121 L 71,124 L 71,117 L 66,121 L 66,117 L 62,117 L 64,112 L 60,113 L 60,110 L 57,111 L 61,105 L 57,107 L 60,101 L 55,102 L 56,98 L 56,98 L 56,98 M 101,132 L 103,138 L 106,134 L 106,139 L 112,136 L 111,142 L 115,139 L 114,143 L 119,142 L 125,145 L 131,142 L 135,138 L 140,134 L 140,129 L 143,135 L 145,149 L 150,171 L 149,184 L 145,165 L 141,150 L 136,147 L 132,151 L 131,149 L 126,152 L 125,150 L 121,152 L 117,148 L 111,152 L 110,148 L 105,149 L 104,145 L 98,150 L 96,138 L 94,132 L 94,130 L 98,132 L 101,132 L 101,132 L 101,132 M 41,94 L 32,110 L 23,132 L 12,163 L 6,190 L 7,217 L 5,236 L 3,247 L 9,230 L 12,211 L 12,185 L 18,160 L 26,134 L 35,110 L 43,99 L 41,94 L 41,94 L 41,94 M 32,246 L 41,250 L 50,257 L 52,267 L 53,295 L 53,323 L 59,350 L 54,363 L 51,365 L 44,366 L 42,360 L 40,372 L 54,372 L 59,366 L 62,353 L 71,352 L 75,335 L 73,330 L 66,318 L 68,302 L 64,294 L 67,288 L 63,286 L 63,279 L 59,275 L 58,267 L 56,262 L 50,247 L 42,235 L 44,246 L 32,236 L 35,244 L 32,246 L 32,246 L 32,246 M 134,324 L 146,320 L 159,322 L 173,327 L 179,337 L 179,349 L 172,355 L 158,357 L 170,350 L 174,343 L 170,333 L 163,328 L 152,326 L 134,329 L 134,324 L 134,324 L 134,324 M 173,339 L 183,334 L 184,338 L 191,329 L 194,332 L 199,323 L 202,325 L 206,318 L 209,320 L 213,309 L 221,303 L 228,296 L 232,289 L 234,279 L 233,269 L 230,262 L 225,256 L 219,253 L 208,252 L 198,252 L 210,249 L 223,250 L 232,257 L 237,265 L 238,277 L 238,291 L 232,305 L 221,323 L 218,335 L 212,342 L 200,349 L 178,348 L 173,339 L 173,339 L 173,339 M 165,296 L 158,301 L 156,310 L 156,323 L 162,324 L 159,318 L 162,308 L 162,304 L 165,296 L 165,296 L 165,296 M 99,252 L 105,244 L 107,234 L 115,228 L 121,228 L 131,235 L 122,233 L 113,235 L 109,246 L 121,239 L 133,243 L 121,243 L 110,251 L 99,252 L 99,252 L 99,252 M 117,252 L 124,247 L 134,249 L 136,253 L 126,252 L 117,252 L 117,252 L 117,252 M 117,218 L 132,224 L 144,233 L 140,225 L 132,219 L 117,218 L 117,218 L 117,218 M 122,212 L 134,214 L 143,221 L 141,213 L 132,210 L 122,212 L 122,212 L 122,212 M 69,352 L 70,363 L 76,373 L 86,378 L 97,379 L 108,379 L 120,377 L 128,378 L 132,373 L 135,361 L 133,358 L 132,366 L 127,375 L 121,374 L 121,362 L 119,367 L 117,374 L 110,376 L 110,362 L 107,357 L 106,371 L 104,375 L 97,376 L 90,375 L 90,368 L 86,362 L 83,364 L 86,369 L 85,373 L 78,370 L 73,362 L 71,351 L 69,352 L 69,352 L 69,352 M 100,360 L 96,363 L 99,369 L 102,364 L 100,360 L 100,360 L 100,360 M 115,360 L 112,363 L 114,369 L 117,364 L 115,360 L 115,360 L 115,360 M 127,362 L 125,364 L 126,369 L 128,365 L 127,362 L 127,362 L 127,362 M 5,255 L 7,276 L 11,304 L 15,320 L 13,334 L 6,348 L 2,353 L 0,363 L 5,372 L 12,374 L 25,372 L 38,372 L 44,369 L 42,367 L 36,368 L 31,369 L 30,360 L 27,368 L 20,370 L 16,361 L 15,368 L 10,369 L 3,366 L 3,359 L 6,352 L 11,348 L 17,331 L 19,316 L 12,291 L 9,274 L 5,255 L 5,255 L 5,255 M 10,358 L 7,362 L 10,366 L 11,362 L 10,358 L 10,358 L 10,358 M 25,357 L 22,360 L 24,366 L 27,360 L 25,357 L 25,357 L 25,357 M 37,357 L 34,361 L 36,365 L 38,361 L 37,357 L 37,357 L 37,357 M 49,356 L 46,359 L 47,364 L 50,360 L 49,356 L 49,356 L 49,356 M 130,101 L 132,102 L 135,101 L 139,102 L 143,103 L 142,101 L 137,100 L 133,100 L 130,101 L 130,101 L 130,101 M 106,48 L 105,52 L 108,56 L 109,52 L 106,48 L 106,48 L 106,48 M 139,52 L 139,56 L 140,60 L 142,58 L 141,56 L 139,52 L 139,52 L 139,52 M 25,349 L 29,351 L 30,355 L 33,350 L 37,348 L 42,351 L 45,347 L 49,345 L 44,343 L 36,345 L 25,349 L 25,349 L 25,349 M 98,347 L 105,351 L 107,354 L 109,349 L 115,349 L 120,353 L 118,349 L 113,346 L 104,346 L 98,347 L 98,347 L 98,347 M 83,348 L 87,352 L 87,357 L 89,351 L 87,348 L 83,348 L 83,348 L 83,348 M 155,107 L 163,107 L 170,107 L 186,108 L 175,109 L 155,109 L 155,107 L 155,107 L 155,107 M 153,114 L 162,113 L 175,112 L 192,114 L 173,114 L 154,115 L 153,114 L 153,114 L 153,114 M 152,118 L 164,120 L 180,123 L 197,129 L 169,123 L 151,120 L 152,118 L 152,118 L 152,118 M 68,109 L 87,106 L 107,106 L 106,108 L 88,108 L 68,109 L 68,109 L 68,109 M 105,111 L 95,112 L 79,114 L 71,116 L 85,115 L 102,113 L 105,111 L 105,111 L 105,111 M 108,101 L 98,99 L 87,99 L 78,99 L 93,100 L 105,102 L 108,101 L 108,101 L 108,101 M 85,63 L 91,63 L 97,60 L 104,60 L 108,62 L 111,69 L 112,75 L 110,74 L 108,71 L 103,73 L 106,69 L 105,65 L 103,64 L 103,67 L 102,70 L 99,70 L 97,66 L 94,67 L 97,72 L 88,67 L 84,66 L 85,63 L 85,63 L 85,63 M 140,74 L 141,66 L 144,61 L 150,61 L 156,62 L 153,70 L 150,73 L 152,65 L 150,65 L 151,68 L 149,71 L 146,71 L 144,66 L 143,70 L 143,74 L 140,74 L 140,74 L 140,74 M 146,20 L 156,11 L 163,9 L 172,9 L 178,14 L 182,18 L 184,32 L 182,42 L 182,52 L 177,58 L 176,67 L 171,76 L 165,90 L 157,105 L 160,92 L 164,85 L 168,78 L 167,73 L 173,66 L 172,62 L 175,59 L 174,55 L 177,53 L 180,46 L 181,29 L 179,21 L 173,13 L 166,11 L 159,13 L 153,18 L 148,23 L 146,20 L 146,20 L 146,20 M 150,187 L 148,211 L 150,233 L 153,247 L 148,267 L 135,283 L 125,299 L 136,292 L 131,313 L 122,328 L 122,345 L 129,352 L 133,359 L 133,367 L 137,359 L 148,356 L 140,350 L 131,347 L 129,340 L 132,332 L 140,328 L 137,322 L 140,304 L 154,265 L 157,244 L 155,223 L 161,220 L 175,229 L 186,247 L 185,260 L 176,275 L 178,287 L 185,277 L 188,261 L 196,253 L 189,236 L 174,213 L 150,187 L 150,187 L 150,187 M 147,338 L 142,341 L 143,345 L 141,354 L 147,343 L 147,338 L 147,338 L 147,338 M 157,342 L 156,349 L 150,356 L 157,353 L 163,346 L 162,342 L 157,342 L 157,342 L 157,342 M 99,265 L 96,284 L 92,299 L 73,339 L 73,333 L 87,300 L 99,265 L 99,265 L 99,265 """ def build_paths(lion_string): mins=[] maxs=[] colors = [] paths = [] lines = lion_string.split('\n') for line in lines: fields = line.split() if len(fields) == 0: pass elif len(fields) == 1: hex_color = fields[0] r = int(hex_color[:2],16)/255. g = int(hex_color[2:4],16)/255. b = int(hex_color[4:6],16)/255. colors.append(array((r,g,b,1.0))) paths.append(CompiledPath()) path = paths[-1] else: fields = array(fields,'O') cmd = fields[::2] pts = map(lambda x: array(eval(x), dtype=float), fields[1::2]) mins.append(amin(pts,axis=0)) maxs.append(amax(pts,axis=0)) path_def = zip (cmd,pts) for cmd, pt in path_def: pt[0] -= 119 pt[1] -= 190.5 if cmd == 'M': path.move_to(pt[0],pt[1]) if cmd == 'L': path.line_to(pt[0],pt[1]) min_pt = amin(array(mins),axis=0) max_pt = amax(array(maxs),axis=0) sz = max_pt - min_pt center = min_pt + sz/2.0 return zip(paths, colors), sz, center def get_lion(): """get_lion() -> path_and_color, size, center path_and_color: [(path,color), ...] size: [width, height] center: [x, y] """ return build_paths(lion_string) # EOF enthought-chaco2-4.1.0.orig/examples/kiva/dummy.py0000644000175000017500000001465111674463635021170 0ustar varunvarunfrom __future__ import with_statement from enable.kiva_graphics_context import GraphicsContext from kiva import affine, agg, constants from kiva.fonttools import Font # Do some basic drawing tests and write the results out to PNG 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 = agg.rotation_matrix(PI/6) gc.set_text_matrix(txtRot) gc.show_text("Hello") txtRot.invert() gc.set_text_matrix(txtRot) gc.show_text("inverted") if __name__ == "__main__": tests = ((test_clip_stack, "clip_stack.png"), (test_arc_to, "arc_to.png"), (test_handling_text, "handling_text.png")) for test_func, filename in tests: img = GraphicsContext((800, 600)) img.clear(white) test_func(img) img.save(filename) enthought-chaco2-4.1.0.orig/examples/kiva/rect.py0000644000175000017500000000024111674463635020760 0ustar varunvarunfrom enable.kiva_graphics_context import GraphicsContext gc = GraphicsContext((500,500)) gc.clear() gc.rect(100,100,300,300) gc.draw_path() gc.save("rect.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/simple_clip.py0000644000175000017500000000211211674463635022322 0ustar varunvarunimport time from kiva.image import GraphicsContext samples = 1 pt = (250, 250) sz = (100, 100) transparent = (1,1,1,0.) gc_img = GraphicsContext((500,500)) #gc_img.clear(transparent) # clear isn't working... gc_img.bmp_array[:] = (255,255,255,0) gc_img.set_fill_color((1,0,0,.5)) gc_img.set_stroke_color((0,0,1)) gc_img.rect(pt[0],pt[1],sz[0],sz[1]) gc_img.draw_path() gc_main = GraphicsContext((500,500)) gc_main.set_fill_color((0,0,1,.5)) gc_main.set_stroke_color((0,1,0)) gc_main.rect(300,300,100,100) gc_main.draw_path() gc_main.clip_to_rect(pt[0],pt[1],sz[0],sz[1]) t1 = time.clock() for i in range(samples): gc_main.draw_image(gc_img) t2 = time.clock() print 'with clip', t2 - t1 gc_main.save("with_clip.bmp") #gc_main.clear(transparent) gc_main.bmp_array[:] = (255,255,255,255) gc_main.clear_clip_path() gc_main.set_fill_color((0,0,1,.5)) gc_main.set_stroke_color((0,1,0)) gc_main.rect(300,300,100,100) gc_main.draw_path() t1 = time.clock() for i in range(samples): gc_main.draw_image(gc_img) t2 = time.clock() print 'without clip', t2 - t1 gc_main.save("without_clip.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/simple2.py0000644000175000017500000000052011674463635021376 0ustar varunvarunfrom kiva.image import GraphicsContext gc = GraphicsContext((500,500)) gc.set_fill_color( (1, 0, 0) ) gc.rect(100,100,300,300) gc.draw_path() gc.save("simple2_pre.bmp") # directly manipulate the underlying Numeric array. # The color tuple is expressed as BGRA. gc.bmp_array[:100,:100] = (139, 60, 71, 255) gc.save("simple2_post.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/dash.py0000644000175000017500000000130511674463635020744 0ustar varunvarunimport time import numpy from kiva import constants from kiva.agg import GraphicsContextArray def dash(sz=(1000,1000)): gc = GraphicsContextArray(sz) gc.set_fill_color((1.0,0.0,0.0,0.1)) gc.set_stroke_color((0.0,1.0,0.0,0.6)) width = 10 gc.set_line_width(10) phase = width * 2.5; pattern = width * numpy.array((5,5)) gc.set_line_dash(pattern,phase) gc.set_line_cap(constants.CAP_BUTT) t1 = time.clock() gc.move_to(10,10) gc.line_to(sz[0]-10,sz[1]-10) gc.line_to(10,sz[1]-10) gc.close_path() gc.draw_path() t2 = time.clock() gc.save("dash.bmp") tot_time = t2 - t1 print 'time:', tot_time if __name__ == "__main__": dash() enthought-chaco2-4.1.0.orig/examples/kiva/star.py0000644000175000017500000000132511674463635021000 0ustar varunvarunfrom __future__ import with_statement from scipy import pi from kiva.image import GraphicsContext def add_star(gc): gc.begin_path() gc.move_to(-20,-30) gc.line_to(0,30) gc.line_to(20,-30) gc.line_to(-30,10) gc.line_to(30,10) gc.close_path() gc.move_to(-10,30) gc.line_to(10,30) gc = GraphicsContext((500,500)) with gc: gc.set_alpha(0.3) gc.set_stroke_color((1.0,0.0,0.0)) gc.set_fill_color((0.0,1.0,0.0)) for i in range(0,600,5): with gc: gc.translate_ctm(i,i) gc.rotate_ctm(i*pi/180.) add_star(gc) gc.draw_path() gc.set_fill_color((0.5,0.5,0.5,0.4)) gc.rect(150,150,200,200) gc.fill_path() gc.save("star.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/ui_text.py0000644000175000017500000000661111674463635021513 0ustar varunvarunfrom __future__ import with_statement from enable.api import Component, ComponentEditor from traits.api import HasTraits, Instance from traitsui.api import Item, View def glyph_a(gc): gc.move_to(28.47, 6.45) gc.quad_curve_to(21.58, 1.12, 19.82, 0.29) gc.quad_curve_to(17.19, -0.93, 14.21, -0.93) gc.quad_curve_to(9.57, -0.93, 6.57, 2.25) gc.quad_curve_to(3.56, 5.42, 3.56, 10.60) gc.quad_curve_to(3.56, 13.87, 5.03, 16.26) gc.quad_curve_to(7.03, 19.58, 11.99, 22.51) gc.quad_curve_to(16.94, 25.44, 28.47, 29.64) gc.line_to(28.47, 31.40) gc.quad_curve_to(28.47, 38.09, 26.34, 40.58) gc.quad_curve_to(24.22, 43.07, 20.17, 43.07) gc.quad_curve_to(17.09, 43.07, 15.28, 41.41) gc.quad_curve_to(13.43, 39.75, 13.43, 37.60) gc.line_to(13.53, 34.77) gc.quad_curve_to(13.53, 32.52, 12.38, 31.30) gc.quad_curve_to(11.23, 30.08, 9.38, 30.08) gc.quad_curve_to(7.57, 30.08, 6.42, 31.35) gc.quad_curve_to(5.27, 32.62, 5.27, 34.81) gc.quad_curve_to(5.27, 39.01, 9.57, 42.53) gc.quad_curve_to(13.87, 46.04, 21.63, 46.04) gc.quad_curve_to(27.59, 46.04, 31.40, 44.04) gc.quad_curve_to(34.28, 42.53, 35.64, 39.31) gc.quad_curve_to(36.52, 37.21, 36.52, 30.71) gc.line_to(36.52, 15.53) gc.quad_curve_to(36.52, 9.13, 36.77, 7.69) gc.quad_curve_to(37.01, 6.25, 37.57, 5.76) gc.quad_curve_to(38.13, 5.27, 38.87, 5.27) gc.quad_curve_to(39.65, 5.27, 40.23, 5.62) gc.quad_curve_to(41.26, 6.25, 44.19, 9.18) gc.line_to(44.19, 6.45) gc.quad_curve_to(38.72, -0.88, 33.74, -0.88) gc.quad_curve_to(31.35, -0.88, 29.93, 0.78) gc.quad_curve_to(28.52, 2.44, 28.47, 6.45) gc.close_path() gc.move_to(28.47, 9.62) gc.line_to(28.47, 26.66) gc.quad_curve_to(21.09, 23.73, 18.95, 22.51) gc.quad_curve_to(15.09, 20.36, 13.43, 18.02) gc.quad_curve_to(11.77, 15.67, 11.77, 12.89) gc.quad_curve_to(11.77, 9.38, 13.87, 7.06) gc.quad_curve_to(15.97, 4.74, 18.70, 4.74) gc.quad_curve_to(22.41, 4.74, 28.47, 9.62) gc.close_path() class MyCanvas(Component): def draw(self, gc, **kwargs): w,h = gc.width(), gc.height() gc.move_to(0,0) gc.line_to(w,h) gc.set_stroke_color((1,0,0)) gc.stroke_path() gc.move_to(0,h) gc.line_to(w,0) gc.set_stroke_color((0,1,0)) gc.stroke_path() gc.rect(0,0,w,h) gc.set_stroke_color((0,0,0,.5)) gc.set_line_width(20) gc.stroke_path() gc.set_fill_color((0,0,1,0.0)) gc.rect(0,0,w,h) gc.draw_path() gc.set_line_width(1) gc.translate_ctm(w/2.0,h/2.0) with gc: gc.scale_ctm(2.0,2.0) glyph_a(gc) gc.stroke_path() gc.translate_ctm(0,-20) gc.scale_ctm(2.0,2.0) glyph_a(gc) gc.set_fill_color((0,0,1,1.0)) gc.fill_path() class Demo(HasTraits): canvas = Instance(Component) traits_view = View(Item('canvas', editor=ComponentEditor(bgcolor="lightgray"), show_label=False, width=500, height=500), resizable=True, title="Gradient Example") def _canvas_default(self): return MyCanvas() if __name__ == "__main__": Demo().configure_traits() enthought-chaco2-4.1.0.orig/examples/kiva/star_path.py0000644000175000017500000000537111674463635022021 0ustar varunvarunfrom __future__ import with_statement from numpy import cos, sin, arange, pi, array from kiva.image import GraphicsContext from kiva.constants import * def draw_circle(gc,radius=2): gc.begin_path() angle = 0 gc.move_to(radius*cos(angle), radius*sin(angle)) for angle in arange(pi/4.,2*pi,pi/4.): gc.line_to(radius*cos(angle), radius*sin(angle)) gc.close_path() gc.fill_path() star_points = [(-20,-30), (0, 30), (20,-30), (-30,10), (30,10), (-20,-30)] ring_point = (0,35) ring_radius = 5 fill_color = array((200.,184.,106.))/255. point_color = array((.3,.3,.3)) line_color = point_color for i in range(len(star_points)+1): gc = GraphicsContext((800,800)) gc.scale_ctm(8.0,8.0) gc.translate_ctm(50,50) # draw star gc.set_alpha(.5) x,y = star_points[0] gc.move_to(x,y) for x,y in star_points[1:]: gc.line_to(x,y) gc.close_path() gc.set_fill_color(fill_color) gc.get_fill_color() gc.fill_path() gc.set_alpha(.4) gc.set_stroke_color(line_color) gc.set_fill_color(line_color) gc.set_line_width(12) if i > 0: with gc: x,y = star_points[0] gc.translate_ctm(x,y) draw_circle(gc) if i > 1: points = star_points[:i] with gc: x,y = points[0] gc.move_to(x,y) for x,y in points[1:]: gc.line_to(x,y) gc.stroke_path() """ for x,y in points: with gc: gc.translate_ctm(x,y) draw_circle(gc) """ gc.save("star_path%d.bmp" % i) # draw star line_color = (0.0,0.0,0.0) gc = GraphicsContext((800,800)) gc.scale_ctm(8.0,8.0) gc.translate_ctm(50,50) gc.set_stroke_color(line_color) gc.set_fill_color(fill_color) gc.set_line_width(12) x,y = star_points[0] gc.move_to(x,y) for x,y in star_points[1:]: gc.line_to(x,y) gc.close_path() gc.set_fill_color(fill_color) gc.get_fill_color() gc.draw_path() gc.save("star_path7.bmp") # draw star gc = GraphicsContext((1700,400)) line_color = (0.0,0.0,0.0) gc.scale_ctm(4.0,4.0) offsets = array(((0,0),(80,0),(160,0),(240,0),(320,0))) modes = [FILL, EOF_FILL, STROKE, FILL_STROKE, EOF_FILL_STROKE] pairs = zip(modes, offsets) center = array((50,50)) for mode, offset in pairs: with gc: xo,yo = center+offset gc.translate_ctm(xo,yo) gc.set_stroke_color(line_color) gc.set_fill_color(fill_color) gc.set_line_width(12) x,y = star_points[0] gc.move_to(x,y) for x,y in star_points[1:]: gc.line_to(x,y) gc.close_path() gc.set_fill_color(fill_color) gc.get_fill_color() gc.draw_path(mode) gc.save("star_path8.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/ellipse.py0000644000175000017500000000156011674463635021465 0ustar varunvarunfrom __future__ import with_statement from scipy import pi from kiva.image import GraphicsContext def draw_ellipse(gc, x, y, major, minor, angle): """ Draws an ellipse given major and minor axis lengths. **angle** is the angle between the major axis and the X axis, in radians. """ with gc: gc.translate_ctm(x, y) ratio = float(major) / minor gc.rotate_ctm(angle) gc.scale_ctm(ratio, 1.0) gc.arc(0, 0, minor, 0.0, 2 * pi) gc.stroke_path() gc.move_to(-minor, 0) gc.line_to(minor, 0) gc.move_to(0, -minor) gc.line_to(0, minor) gc.stroke_path() gc = GraphicsContext((300,300)) gc.set_alpha(0.3) gc.set_stroke_color((1.0,0.0,0.0)) gc.set_fill_color((0.0,1.0,0.0)) gc.rect(95, 95, 10, 10) gc.fill_path() draw_ellipse(gc, 100, 100, 35.0, 25.0, pi / 6) gc.save("ellipse.bmp") enthought-chaco2-4.1.0.orig/examples/kiva/gradient.py0000644000175000017500000000513611674463635021630 0ustar varunvarunfrom numpy import array, pi from os.path import splitext from enable.kiva_graphics_context import GraphicsContext from kiva.fonttools import Font from kiva import constants def draw(gc): # colors are 5 doubles: offset, red, green, blue, alpha starting_color = array([0.0, 1.0, 1.0, 1.0, 1.0]) ending_color = array([1.0, 0.0, 0.0, 0.0, 1.0]) gc.clear() # diagonal with gc: gc.rect(50,25,150,100) gc.linear_gradient(50,25,150,125, array([starting_color, ending_color]), "pad") gc.draw_path(constants.FILL) # vertical top to bottom with gc: gc.rect(50,150,150,50) gc.linear_gradient(0,200, 0,150, array([starting_color, ending_color]), "pad") gc.draw_path(constants.FILL) # horizontal left to right with gc: gc.rect(50,200,150,50) gc.linear_gradient(50,0, 150,0, array([starting_color, ending_color]), "pad") gc.draw_path(constants.FILL) # vertical bottom to top with gc: gc.rect(50,275,150,50) gc.linear_gradient(0,275, 0,325, array([starting_color, ending_color]), "pad") gc.draw_path(constants.FILL) # horizontal right to left with gc: gc.rect(50,325,150,50) gc.linear_gradient(200,0, 100,0, array([starting_color, ending_color]), "pad") gc.draw_path(constants.FILL) # radial with gc: gc.arc(325, 75, 50, 0.0, 2*pi) gc.radial_gradient(325, 75, 50, 325, 75, array([starting_color, ending_color]), "pad") gc.draw_path(constants.FILL) # radial with focal point in upper left with gc: gc.arc(325, 200, 50, 0.0, 2*pi) gc.radial_gradient(325, 200, 50, 300, 225, array([starting_color, ending_color]), "pad") gc.draw_path(constants.FILL) # radial with focal point in bottom right with gc: gc.arc(325, 325, 50, 0.0, 2*pi) gc.radial_gradient(325, 325, 50, 350, 300, array([starting_color, ending_color]), "pad") gc.draw_path(constants.FILL) return def main(): gc = GraphicsContext((500, 500)) gc.scale_ctm(1.25, 1.25) draw(gc) gc.save(splitext(__file__)[0]+'.png', file_format='png') if __name__ == '__main__': main() enthought-chaco2-4.1.0.orig/examples/kiva/qt4_simple.py0000644000175000017500000000316511674463635022114 0ustar varunvarun# This is PyQt specific so force the toolkit selection. from traits.etsconfig.api import ETSConfig ETSConfig.toolkit = 'qt4.qpainter' from numpy import array import sys try: from pyface.qt import QtGui except ImportError: raise Exception('PyQt4 needs to be installed to run this example') from enable.example_canvas import Canvas class MyCanvas(Canvas): def do_draw(self, gc): w = gc.width() h = gc.height() # Draw a red gradient filled box with green border gc.rect(w/4, h/4, w/2, h/2) gc.set_line_width(5.0) gc.set_stroke_color((0.0, 1.0, 0.0, 1.0)) start = array([0.0, 1.0, 0.0, 0.0, 1.0]) end = array([1.0, 1.0, 1.0, 1.0, 1.0]) gc.radial_gradient(w/4, h/4, 200, w/4+100, h/4+100, array([start, end]), 'reflect') gc.draw_path() # draw a black rect with rounded corners r = max(1, min(w,h)/10) gc.set_line_width(2.0) gc.set_stroke_color((0.0, 0.0, 0.0, 1.0)) gc.move_to(w/3, h/2) gc.arc_to(w/3, 2*h/3, w/2, 2*h/3, r) gc.arc_to(2*w/3, 2*h/3, 2*w/3, h/2, r) gc.arc_to(2*w/3, h/3, w/2, h/3, r) gc.arc_to(w/3, h/3, w/3, h/2, r) gc.line_to(w/3, h/2) gc.stroke_path() return if __name__ == "__main__": app = QtGui.QApplication(sys.argv) w = MyCanvas() w.control.resize(500, 500) w.control.setWindowTitle("Simple Kiva.qt4 example") w.control.show() app.exec_() enthought-chaco2-4.1.0.orig/examples/kiva/ui_gradient.py0000644000175000017500000000572411674463635022330 0ustar varunvarunfrom __future__ import with_statement import numpy as np from enable.api import Component, ComponentEditor from traits.api import HasTraits, Instance from traitsui.api import Item, View class MyCanvas(Component): def draw(self, gc, **kwargs): w,h = gc.width(), gc.height() # colors are 5 doubles: offset, red, green, blue, alpha starting_color = np.array([0.0, 1.0, 1.0, 1.0, 1.0]) ending_color = np.array([1.0, 0.0, 0.0, 0.0, 1.0]) gc.clear() # radial reflected background with gc: gc.rect(0, 0, w, h) start = np.array([0.0, 1.0, 0.0, 0.0, 1.0]) end = np.array([1.0, 1.0, 1.0, 1.0, 1.0]) gc.radial_gradient(w/4, h/4, 200, w/4+100, h/4+100, np.array([start, end]), 'reflect') gc.fill_path() # diagonal with gc: gc.rect(50,25,150,100) gc.linear_gradient(0,0,1,1, np.array([starting_color, ending_color]), "pad", 'objectBoundingBox') gc.fill_path() # vertical with gc: gc.rect(50,150,150,100) gc.linear_gradient(50,150,50,250, np.array([starting_color, ending_color]), "pad", 'userSpaceOnUse') gc.fill_path() # horizontal with gc: gc.rect(50,275,150,100) gc.linear_gradient(0,0,1,0, np.array([starting_color, ending_color]), "pad", 'objectBoundingBox') gc.fill_path() # radial with gc: gc.arc(325, 75, 50, 0.0, 2*np.pi) gc.radial_gradient(325, 75, 50, 325, 75, np.array([starting_color, ending_color]), "pad", 'userSpaceOnUse') gc.fill_path() # radial with focal point in upper left with gc: gc.arc(325, 200, 50, 0.0, 2*np.pi) gc.radial_gradient(0.5, 0.5, 0.5, 0.25, 0.75, np.array([starting_color, ending_color]), "pad", 'objectBoundingBox') gc.fill_path() # radial with focal point in bottom right with gc: gc.arc(325, 325, 50, 0.0, 2*np.pi) gc.radial_gradient(325, 325, 50, 350, 300, np.array([starting_color, ending_color]), "pad", 'userSpaceOnUse') gc.fill_path() return class Demo(HasTraits): canvas = Instance(Component) traits_view = View(Item('canvas', editor=ComponentEditor(bgcolor="lightgray"), show_label=False, width=500, height=500), resizable=True, title="Gradient Example") def _canvas_default(self): return MyCanvas() if __name__ == "__main__": Demo().configure_traits() enthought-chaco2-4.1.0.orig/examples/kiva/compiled_path.py0000644000175000017500000000142311674463635022636 0ustar varunvarun# CompiledPath should always be imported from the same backend as the # GC you are using. In this case, we are using the image GraphicsContext # so we can save to disk when we're done, so we grab the CompiledPath # from there as well. from kiva.image import GraphicsContext, CompiledPath from kiva.constants import STROKE star_points = [(-20,-30), (0, 30), (20,-30), (-30,10), (30,10), (-20,-30)] path = CompiledPath() path.move_to(*star_points[0]) for pt in star_points[1:]: path.line_to(*pt) locs = [(100,100), (100,300), (100,500), (200,100), (200,300), (200,500)] gc = GraphicsContext((300,600)) gc.set_stroke_color((0,0,1,1)) gc.draw_path_at_points(locs, path, STROKE) gc.save("compiled_path.png") enthought-chaco2-4.1.0.orig/examples/enable/0000755000175000017500000000000011674463635017750 5ustar varunvarunenthought-chaco2-4.1.0.orig/examples/enable/slider_example.py0000644000175000017500000000156711674463635023330 0ustar varunvarun from enable.api import OverlayContainer, Slider, Window from enable.example_support import demo_main, DemoFrame class MyFrame(DemoFrame): def _create_window(self): slider = Slider() slider.set_slider_pixels(10) slider.slider_thickness = 5 slider.set_endcap_percent(0.1) slider.min = 0 slider.max = 100 slider.value = 40 slider.padding = 25 slider.slider = "cross" slider.orientation = "h" slider.num_ticks = 4 slider.set_tick_percent(0.05) container = OverlayContainer() container.add(slider) slider.on_trait_change(self.val_changed, "value") self.slider = slider return Window(self, component=container) def val_changed(self): print self.slider.value if __name__ == "__main__": demo_main(MyFrame, title="Slider example") enthought-chaco2-4.1.0.orig/examples/enable/text_field_demo.py0000644000175000017500000000166311674463635023463 0ustar varunvarun from enable.api import Container, TextField, Window from enable.example_support import DemoFrame, demo_main class MyFrame(DemoFrame): def _create_window(self): text_field = TextField(position=[25,100], width=200) text = "This a test with a text field\nthat has more text than\n" text += "can fit in it." text_field2 = TextField(position=[25,200], width=200, height=50, multiline=True, text=text, font="Courier New 14") text_field3 = TextField(position=[250,50], height=300, width=200, multiline=True, font="Courier New 14") container = Container(bounds=[800, 600], bgcolor='grey') container.add(text_field, text_field2, text_field3) return Window(self, -1, component=container) if __name__ == '__main__': demo_main(MyFrame, size=(800, 600)) enthought-chaco2-4.1.0.orig/examples/enable/latency_demo.py0000644000175000017500000000641411674463635022772 0ustar varunvarun""" Test to see what level of click latency is noticeable. """ from __future__ import with_statement import time import wx from traits.etsconfig.api import ETSConfig ETSConfig.toolkit = 'wx' from traits.api import Float from enable.api import (Component, Container, ColorTrait, black_color_trait, Window) from kiva.constants import SWISS from kiva.fonttools import Font font = Font(family=SWISS) class Box(Component): color = ColorTrait("red") delay = Float(0.50) def _draw_mainlayer(self, gc, view=None, mode="default"): if self.event_state == "clicked": print "waiting %0.4f seconds... " % self.delay, time.sleep(self.delay) print "done." with gc: gc.set_fill_color(self.color_) gc.rect(*(self.position + self.bounds)) gc.fill_path() else: with gc: gc.set_stroke_color(self.color_) gc.set_fill_color(self.color_) gc.set_line_width(1.0) gc.rect(*(self.position + self.bounds)) gc.stroke_path() gc.set_font(font) x,y = self.position dx,dy = self.bounds tx, ty, tdx, tdy = gc.get_text_extent(str(self.delay)) gc.set_text_position(x+dx/2-tdx/2, y+dy/2-tdy/2) gc.show_text(str(self.delay)) def normal_left_down(self, event): self.event_state = "clicked" event.handled = True self.request_redraw() def clicked_left_up(self, event): self.event_state = "normal" event.handled = True self.request_redraw() class MyContainer(Container): text_color = black_color_trait def _draw_container_mainlayer(self, gc, view_bounds=None, mode="default"): s = "Hold down the mouse button on the boxes." with gc: gc.set_font(font) gc.set_fill_color(self.text_color_) tx, ty, tdx, tdy = gc.get_text_extent(s) x,y = self.position dx,dy = self.bounds gc.set_text_position(x+dx/2-tdx/2, y+dy-tdy-20) gc.show_text(s) class EnableWindowFrame ( wx.Frame ): def __init__ ( self, component, *args, **kw ): wx.Frame.__init__( *(self,) + args, **kw ) sizer = wx.BoxSizer( wx.HORIZONTAL ) self.enable_window = Window( self, -1, component = component ) sizer.Add( self.enable_window.control, 1, wx.EXPAND ) self.SetSizer( sizer ) self.SetAutoLayout( True ) self.Show( True ) if __name__ == "__main__": app = wx.PySimpleApp() times_and_bounds = { 0.5 : (60,200,100,100), 0.33 : (240,200,100,100), 0.25: (60,50,100,100), 0.10: (240,50,100,100) } container = MyContainer(auto_size = False) for delay, bounds in times_and_bounds.items(): box = Box() container.add(box) box.position = list(bounds[:2]) box.bounds = list(bounds[2:]) box.delay = delay frame = EnableWindowFrame(container, None, -1, "Latency Test - Click a box", size=wx.Size(400,400)) app.SetTopWindow(frame) frame.Show(True) app.MainLoop() enthought-chaco2-4.1.0.orig/examples/enable/view_bounds_test.py0000644000175000017500000000530511674463635023710 0ustar varunvarun""" Demonstrates how clipping of objects occurs with the view_bounds parameter to draw(). """ from __future__ import with_statement from enable.example_support import DemoFrame, demo_main from enable.api import Container, Component, Scrolled, Window from enable.base import empty_rectangle, intersect_bounds class Box(Component): def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): with gc: gc.set_fill_color((1.0, 0.0, 0.0, 1.0)) dx, dy = self.bounds x, y = self.position gc.rect(x, y, dx, dy) gc.fill_path() return class VerboseContainer(Container): """ By default a container just doesn't draw contained components if they are outside its view_bounds. This subclass modifies the behavior to report what components are not being drawn and what their bounds are. """ fit_window = False def _draw_container_mainlayer(self, gc, view_bounds, mode="default"): with gc: gc.set_fill_color((1.0, 1.0, 1.0, 1.0)) gc.set_stroke_color((1.0, 1.0, 1.0, 1.0)) gc.rect(self.x, self.y, self.width, self.height) gc.fill_path() if view_bounds: v = view_bounds new_bounds = (v[0]-self.x, v[1]-self.y, v[2], v[3]) else: new_bounds = None with gc: gc.translate_ctm(*self.position) gc.set_stroke_color((0.0, 0.0, 0.0, 1.0)) for component in self._components: # See if the component is visible: tmp = intersect_bounds(component.position + component.bounds, new_bounds) if tmp == empty_rectangle: print "skipping component:", component.__class__.__name__, print "\tbounds:", component.position, component.bounds continue with gc: component.draw(gc, new_bounds, mode) class MyFrame(DemoFrame): def _create_window(self): container = VerboseContainer(auto_size=False, bounds = [800,800]) a = Box(bounds=[50.0,50.0], position=[50.0,50.0]) b = Box(bounds=[50.0,50.0], position=[200.0,50.0]) c = Box(bounds=[50.0,50.0], position=[50.0,200.0]) d = Box(bounds=[50.0,50.0], position=[200.0,200.0]) container.add(a) container.add(b) container.add(c) container.add(d) scr = Scrolled(container, bounds=[300,300], position=[50,50], fit_window=False) return Window(self, -1, component=scr) if __name__ == "__main__": demo_main(MyFrame, title="Use the scroll bars to show and hide components") # EOF enthought-chaco2-4.1.0.orig/examples/enable/basic_move.py0000644000175000017500000000453111674463635022434 0ustar varunvarun""" This allows a simple component to be moved around the screen. """ from __future__ import with_statement from enable.example_support import DemoFrame, demo_main from traits.api import Float, Tuple from enable.api import Component, Container, Pointer, Window class Box(Component): """ The box moves wherever the user clicks and drags. """ normal_pointer = Pointer("arrow") moving_pointer = Pointer("hand") offset_x = Float offset_y = Float fill_color = (0.8, 0.0, 0.1, 1.0) moving_color = (0.0, 0.8, 0.1, 1.0) resizable = "" def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): with gc: if self.event_state == "moving": gc.set_fill_color(self.moving_color) else: gc.set_fill_color(self.fill_color) dx, dy = self.bounds x, y = self.position gc.rect(x, y, dx, dy) gc.fill_path() # draw line around outer box gc.set_stroke_color((0,0,0,1)) gc.rect(self.outer_x, self.outer_y, self.outer_width, self.outer_height) gc.stroke_path() return def normal_key_pressed(self, event): print "Key:", event.character def normal_left_down(self, event): self.event_state = "moving" event.window.set_pointer(self.moving_pointer) event.window.set_mouse_owner(self, event.net_transform()) self.offset_x = event.x - self.x self.offset_y = event.y - self.y event.handled = True return def moving_mouse_move(self, event): self.position = [event.x-self.offset_x, event.y-self.offset_y] event.handled = True self.request_redraw() return def moving_left_up(self, event): self.event_state = "normal" event.window.set_pointer(self.normal_pointer) event.window.set_mouse_owner(None) event.handled = True self.request_redraw() return def moving_mouse_leave(self, event): self.moving_left_up(event) event.handled = True return class MyFrame(DemoFrame): def _create_window(self): box = Box(bounds=[100,100], position=[50,50], padding=15) return Window(self, -1, component=box) if __name__ == "__main__": demo_main(MyFrame, title="Click and drag to move the box") # EOF enthought-chaco2-4.1.0.orig/examples/enable/scrolled_demo.py0000644000175000017500000000764611674463635023152 0ustar varunvarun""" Similar to simple_drag_demo, put one circle inside a scrolled container """ from __future__ import with_statement from numpy import array from enable.example_support import DemoFrame, demo_main from enable.api import Component, Scrolled, Container, Container,\ Pointer, NativeScrollBar, Viewport, Window from traits.api import Array, Enum, Float, Instance, Trait, Tuple class Circle(Component): """ The circle moves with the mouse cursor but leaves a translucent version of itself in its original position until the mouse button is released. """ color = (0.0, 0.0, 1.0, 1.0) bgcolor = "none" normal_pointer = Pointer("arrow") moving_pointer = Pointer("hand") offset_x = Float offset_y = Float shadow_type = Enum("light", "dashed") shadow = Instance(Component) def __init__(self, **traits): Component.__init__(self, **traits) self.pointer = self.normal_pointer return def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): with gc: gc.set_fill_color(self.color) dx, dy = self.bounds x, y = self.position radius = min(dx/2.0, dy/2.0) gc.arc(x+dx/2.0, y+dy/2.0, radius, 0.0, 2*3.14159) gc.fill_path() return def normal_left_down(self, event): self.event_state = "moving" self.pointer = self.moving_pointer # Create our shadow if self.shadow_type == "light": klass = LightCircle else: klass = DashedCircle dx, dy = self.bounds self.shadow = klass(bounds=self.bounds, position=self.position, color=self.color) self.container.add(self.shadow) x, y = self.position self.offset_x = event.x - x self.offset_y = event.y - y return def moving_mouse_move(self, event): self.position = [event.x-self.offset_x, event.y-self.offset_y] self.request_redraw() return def moving_left_up(self, event): self.event_state = "normal" self.pointer = self.normal_pointer self.request_redraw() # Remove our shadow self.container.remove(self.shadow) return def moving_mouse_leave(self, event): self.moving_left_up(event) return class LightCircle(Component): color = Tuple bgcolor = "none" radius = Float(1.0) def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): with gc: gc.set_fill_color(self.color[0:3] + (self.color[3]*0.3,)) dx, dy = self.bounds x, y = self.position radius = min(dx/2.0, dy/2.0) gc.arc(x+dx/2.0, y+dy/2.0, radius, 0.0, 2*3.14159) gc.fill_path() return class DashedCircle(Component): color = Tuple bgcolor = "none" radius = Float(1.0) line_dash = array([2.0, 2.0]) def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): with gc: gc.set_fill_color(self.color) dx, dy = self.bounds x, y = self.position radius = min(dx/2.0, dy/2.0) gc.arc(x+dx/2.0, y+dy/2.0, radius, 0.0, 2*3.14159) gc.set_stroke_color(self.color[0:3] + (self.color[3]*0.8,)) gc.set_line_dash(self.line_dash) gc.stroke_path() return class MyFrame(DemoFrame): def _create_window(self): container = Container(bounds=[800,600], bgcolor="red", auto_size = False, fit_window=False) circle1 = Circle(bounds=[75,75], position=[100,100], shadow_type="dashed") container.add(circle1) scr = Scrolled(container, bounds=[200,200], position=[50,50], fit_window=False) return Window(self, -1, component=scr) if __name__ == "__main__": demo_main(MyFrame, title="Click and drag to move the circles") # EOF enthought-chaco2-4.1.0.orig/examples/enable/stacked_container_demo.py0000644000175000017500000000310711674463635025007 0ustar varunvarun from enable.example_support import DemoFrame, demo_main from enable.api import Container, Window, TextField from enable.stacked_container import VStackedContainer, HStackedContainer from enable.overlay_container import OverlayContainer class MyFrame(DemoFrame): def _create_window(self): stack = VStackedContainer(position=[0,0], bounds=[500,500], halign='center', valign='center', #border_visible=True, fit_components='hv', auto_size=True, stack_order='top_to_bottom', bgcolor='red') strings = ["apple", "banana", "cherry", "durian", "eggfruit", "fig", "grape", "honeydew"] for i, s in enumerate(strings): label = TextField(text=s, resizable='', bounds=[100+i*10,20], bgcolor='red', #border_visible=True, text_offset=1) number = TextField(text=str(i+1), resizable='', bgcolor='blue', #border_visible=True, text_offset=1, can_edit=False, bounds=[20,20]) row = HStackedContainer(fit_components='hv', auto_size=True, resizable='', valign='top', border_visible=True) row.add(number) row.add(label) stack.add(row) #print stack.components container = Container(position=[20,20], bounds=[500,500]) container.add(stack) container2 = Container(bounds=[600,600]) container2.add(container) return Window(self, -1, component=container2) if __name__ == "__main__": demo_main(MyFrame, size=[600,600]) enthought-chaco2-4.1.0.orig/examples/enable/zoomed_event_demo.py0000644000175000017500000000473611674463635024036 0ustar varunvarun from __future__ import with_statement from traits.api import Float from enable.api import AbstractOverlay, Canvas, Viewport, \ Window, ColorTrait, Scrolled, Container from enable.tools.api import ViewportPanTool from enable.example_support import demo_main, DemoFrame class EventTracer(AbstractOverlay): """ Draws a marker under the mouse cursor where an event is occurring. """ x = Float y = Float color = ColorTrait("red") size = Float(5) angle = Float(0.0) # angle in degrees def normal_mouse_move(self, event): self.x = event.x self.y = event.y self.component.request_redraw() def overlay(self, component, gc, view_bounds, mode): with gc: gc.translate_ctm(self.x, self.y) if self.angle != 0: gc.rotate_ctm(self.angle * 3.14159/180.) gc.set_stroke_color(self.color_) gc.set_line_width(1.0) gc.move_to(-self.size, 0) gc.line_to(self.size, 0) gc.move_to(0, -self.size) gc.line_to(0, self.size) gc.stroke_path() class MyFrame(DemoFrame): def _create_window(self): canvas = Canvas(bgcolor="lightsteelblue", draw_axes=True) canvas.overlays.append(EventTracer(canvas, color="green", size=8, angle=45.0)) viewport = Viewport(component=canvas, enable_zoom=True) viewport.view_position = [0,0] viewport.tools.append(ViewportPanTool(viewport, drag_button="right")) viewport.overlays.append(EventTracer(viewport)) if 1: scrolled = Scrolled(canvas, inside_padding_width = 0, mousewheel_scroll = False, viewport_component = viewport, always_show_sb = True, continuous_drag_update = True) return Window(self, -1, component=scrolled) elif 1: viewport.bounds = [300, 300] viewport.position = [10,10] container = Container(fit_window=True, auto_size=False, border_visible=True, border_color = "blue") container.padding = 20 container.add(viewport) return Window(self, -1, component=container) else: return Window(self, -1, component=viewport) if __name__ == "__main__": demo_main(MyFrame, title="Canvas example") enthought-chaco2-4.1.0.orig/examples/enable/deepfield.jpg0000644000175000017500000020707711674463635022410 0ustar varunvarunJFIFC   %# , #&')*)-0-(0%()(C   (((((((((((((((((((((((((((((((((((((((((((((((((((XX" W!1A"Qa2qB#R3bt$7Cu'456Vds%TrDSUe'!1AQa"2qB ?+#Sn`3R_H"DU2nYk+:8Ed0y"T NW ɓ.";b@)\"sDmCB~?Oj^3w#PF$$Tb8֚_ =n<}gu~̪Qڸ3 s6\rk^K7\ku7.iK ­s pjM$N⑀7 Ԛܭm kKK:GsS]\;*?_k;n zgzփljcr*qT"Is_9'09RoCIۜ Ib0@{}T{٭j6/ԱҹkmeXUqIͶHM% m L&aޒPwq1‡SI4Ζ\{HQK4O򤷙,DYޱnڹqd1PAh⪆ vwڅC99=h2s׊ `v~)V`fEPKIҿS{BhzRi[O{T¹$-21~t+۲KIr9GPg64V̖;v?&fv3ke'?D 1h`%ެ565]8K bUߒd*_E+E 9wi$3b(>1H6 #ޕ!݂0sKb9LT8M9?hB~1=8?0-CI3]"tZm3 33jX"{F|EuF jo-9gSm/l7f1G.i]LK-,J]_#kl :`[n Vzv{[l'\A&s`X f>*$܊tR0Gڟ"IqOV:[ϐ-'6ݴ}{][u&*gk޶-w6`Ts A3H:zQ+ '42b&0۴mGsH1R'!ڬ <Mŭ# D| Ir$Ulf PݷaS,"5,XdsH}F?mkKR۪NOބƕw(3)}տ? /gz6?'5av$߽)+vS\DwXx밙miOuyP}'պDv&^.4A爫:5zmUq6 㸪phnwkmi-=l;*4H@Y9cu S_yX*}2ZUsk.[GV]^kGV>fV*3B}MwO_pRmYhfŖ=-#+,6KyIB,dVYsHʫB@>53IҵLs?Ooc!FȚxkH=}J^:>o\n bGڄ&9-6F]Uo3@sۊ?:`Gi KwLT{aw>f]fVR3A{Tn/$g"vGo?ld7 T 3TFv14M%;x,AMT`7iaD1WEmߏP`.]RwzݸN]pAdc`r0s((*=Op (Tgk 8O:#w$M bosEsTxH1*j\rZ1M<(1{~@iҶ9h溯 X~ݲmZ|ֳDstr^$ҷlH/0gi EF>sUޙӦI PLQ)$l3L\1 oj&#aN=WH+Fi-# {[T>E=4F PbF@Yh0sV_w6DIT\2=: $Q匶Oa=7x@jƟK]Y1Au<U&B$|S-FfN&_^F`D[rI8kc-H2pi'hw, An縣Y(9RiJ#nԒDM;rLSv e_V?S[3s?5876bPfv2YWc0doQu:]2߿n>'Hx~;s[ oT~w:~MQڶ9nցٽCH“:h@p܇6瑁4uc_d%=D~{cTc5%$vg|?i&d;!T̍ Ӊ sRrA Aعfar^KD@4 2{ i%B q;W}*nP*@,I#pTX$V B 2Bcp5p&T?΅n?nH4[70Ȣ۵]M yGh &Gj!$ppTIľC FHLYɕ 'މ"Kp;SUC7{ $OHl v1s'p)<I!D7n?jcnBT(>y4 2H  ԖLa}[rKM;+޻~śnk #Q(ۆ\L7 OoޑgFdvߦ5Aڻr!apz [C-WPmIe -f؏\mk@15&㟢 bhy"$(0Rڰ ޘD O|Uٷ}o#^AO֎M=Mijm k^zԫI~(k7>15OwP$,NW?Nv@uj[$D\ /5a5DydX6qS'J8mT&,k:=U6z}Y1Sk]N N*@cp"G5 v 8"$W'F2X0yUBxmN-)K6ˎ =e\[kʃ;z}E-Ǵv슢E(H7$A0YZ鰏I'^g[[xڥ*jݑC `']% Y{е eKے3rvG"M誎ŸTM*3,Ȑ;&U6ˈT8 OI#=<;AWmpmݵC7D@PC 0&Ek(9+݂,@*@q9_KcHD"H'ޜi# cEhnp2"&c@"c ef=WMmK.va8X)_F#.HI]ZJhlb&J\.b F&@??oj8$xoR*k6؋,16 "`ļ Ґ>Y2=wk&;DI +m9, 1)m^W2:ljWiOQF8V+:k A)VpAUx 8D'}d ]` 8ޱ#'f(ZS*DQr 7 ;Jk%5m千帱08'/n;4g[cEc~\{$ Pg.*ބ v4Ջ 几q Z{r&dHY[4|=SVSƦm^;ګ8t$zp~๸P7%NK0VaWgw1`{:#"F `߽*ucKF y5\L =ĉ< aH{S3i{G4hcHnhJ~F۴3Gr[ A@ULLO{QrIz5bXVKn[[{̃HR{A' z &)n'ޓz˖?&fꍀn{MVV6nZ`.6L8j8Suتe>fO+9R6۹~krF{VU*3'a39.xBnHT׬ܴQiV)-ᅲrAJr}D?V1n$DwH 1ִx/#H009`mA2XzG -8%jKlOJ؃=Է]i.֮⡷uCTqTX-6HV - (?sCAM[3Ekt~ޫJ5ルXPpxB-BI'PKpwlxWuZK֘KH)*${̜ vINH;5݉GŔr>=m 5?NKcCysܪC qHU2N&8&zPQF)2xY='DڍEoj@FQZ[|<A㊄`'-7-Hdg晽E@K 3E2B'Iw^+{ٵhY>}swe7L>I;T6sJ;\2 f'[SާkTP;Ж"aVwGӃ)PP$n)Hg Xb*oV0Z:p36.`]B>Y >sEn&!NsB8TÖ=\\A$ [q8s#?a?$E\IȜ+b?"B++; go2T!Ns4UQ#{tJrGZtVݹșy5JZSHr LnzwX㏑N m1Mn)$i:o% ~I#`N=5|=+.Ρ5%VAkA~5kUe9|%HLV\꺾.k5Q}"xU*;{Sht Km1PH9""yh}$H=!M œLUᎉ+kYɵȒsO`t{K۷lrixuoћ:&pCX/s(zn~L0DǷ+yr(wAr'?̇bi(`|:[Q;''J]gbƕik1I6|BjU1?oZ.o2cjX p$rxv.\ *mI@'ʺv*e}xn7|Ja-NzOMb ?jqvo Pn썹Fm& L+#eP$JUߠF%Guc3*@';E-.=J^=O ¬AMSI4l^ Dʠ4Xl"1ڟ.V(T BAQN"ݧej.4H$ݸmapwvM^>c=u'xJWxP{z>#뚞ZWp1 ;AFgL$@3Bw,3zRStJ'ڬݹg}CKtn/mD 74fjPHv5Wᾗîuz%(?>ۺwF MTS~ 'r1Z=W.2طam*I=o%*LDOTފմ-s҄,AgIbA"#o@={Tpm"XBIs-Y;% mp F9w]AxI'h,[q0!!JY2'qEy98b%y'>ڥkmrψuV5:k V{ְpQ\j:[ [\ jmz*w,/З*?L!mVp1>L@7$ ;W(,nas*B2SH)CmB@pg=Nnm*;KqF[2{{X!0>ԒE0( J^. 2cE[W=Ѿ3y iHpFqI߰GdCsic`U&R$\DGh0S2kTY`9~jadOs$7IDDn岤gJF}І$w>a yq82j5[fjhYHmUl]Vfgd ŴR\A n\dp}ފJQaoWVυπ,v~~/ԣ|MFۍ>w \#Er1IV&2 gZC,H''m١em{nC3qRћmZT=T-{ vXVW *+>hi$<ϸ)8̟h2xiW3,q!+b99v8'>u6 0=O~ݭMZ{pw\d'lqڕZq+3wC=;"Tڎۑ' 3b.EF{JrBPǽ6U+HM$+P;{~Z*bP\`Ż Zh8AWvylL|Smx $_{WՔ&f5k77f[9QR]!qoI' H0{o\#Umb8-aIoCՁot9 {Q3;ydn%v`;̓CV H$ѝNԘkov٠ބn0Oju4Qy }[rH !vkFE]v֝Mhpp"iWA0Qv02w7;P6b gRsʀ O|2q*OzbT3OpՓH(4phC(3Y77oOC)m c=Nu]Zj ƀ@R[p*߼@'8 qm2>jkfn :-kzz|BLjQ đ4'[`>E!, fGwh=M_\vRf(ItmM)sdAaO.\cwW${_KZޞԮ !N?}q/A V_-G)'?'|?gax+_U}Z鴥aSSp3O^,urt!;:WΡ3F Ր\xdaɭ1dŠL0; j/v2Me䊗i@dyWM{g 'S{ZLyJ n` +PrmS2n۴Gib]*Ϊ"L{]%>HM ]CLFQC>k}@S}j1V!&qrXv!L%qsSA?3@z%&Ymz%C8Y{,A1QV1 :/V|;vjgͺ@1jZ  @<~ɵ=vEJT8RAܤ60>٢G`VF(]}8 XM $savm^q0Q83K2v&Sra וh!N?dڞ0X0 Iwy@"&x~l&)6ѥ})'Z5JNnj*Tq >W~'\WL_v)"V{ln  *Id'< ;m$K;,XT̐{֙ЃHPC4&9Vl\u`'5YW̘-hX򏙛}#$|ޟCJ.\WYPP'xSi$${Q,ZT^^kyN0O&*$GyP;r ػv'r;)g:+hH0 HL'O=Hu JD#O3yԿ1RZV@'=] 8H(I8CI\%o5=<*6ƛ]u]ߺNe떑&QCz'5ʿƥ|N^IFh+t^ڇ␚k($xP7}+`u#rֹrw `ԖWl?JIHF!A, @ 8ԗd[uF95i=;p˴rj+J(Y WLqYL!"J s(-aA}cdTp1O81 \;'&l1b}[BvmsҔF`%Mgi #ޒfGD 90 UcQr7}?Z̴R`REc1Q`F11QWК 0 V*gޞ  #*%nDrS2}"qMXVtR ll"R JJS sM]|`H1JC,m9Kq(McbFA3՛:D;Qj57H3CVEn{EEF ݅<&}ʂTM~RWl=\:7i[(;GN ;T-&U l+V0p 5/Uiƛ[0n\I |^kMB׮AvuOuwsOt0Qm?Dy-t1ٰ3WLj|].{Um2+j.d?pYp6>C.3Gɻt[L,gޘŗ/tvUgvUɽER*]eUb it`=Mr ˹`qޓTG󡴖T#A"JO A~!%}.Az`bx5l/|>Ƶ!c[ߡ=yE5{HsZ,at-Eۨ@Cc>UcYDAކWu7Oslں$s#P*߻x3kwx82}#jf6wtx`1tzYb:7jône`d"Mm\a r\S OkY~5Z|yZ Tl $e`9= zA{&UnVY, IeLJLާk:CՒ|u~[fqɪq;E1$&bf7 #Ja.*ĜT[tAh*Ict kV.Er02p#FAfLZ}jΨ)w3TF\{,az1P^9qO}6ۺi 8^] ^ПKlm+]~ ̑ޭi޶y\:{_0t6 no +ܗ `}J<˰g\PF>UU=&m7u nZ AtI'E37LG0j&= Y*&)[A(P3'B0mڧ^l8@ S~&G{Z3]6ǵAhww0xW~ɹu&WiP. 醌Vv a@xE1۔pjKvZCLX}EIĊBb>[K]>k=QDvUvR NOJ}R$jgfF6'k||P qHY<=C쁈&sLC#dA߭COfHneps6ofD%{xwN14!.K` / q*8+rOtk_7m! LD,Hl wY F p@@e GwꞒ\2Z\; 3Up><fiHN M\h9ۘ*ā| ?cJfE1pN)'vLn칩6ޮSkN!XcRX̚xz=]}ܖYK#;5E:}n7<ˈ [lC ";1p?1P2s<TZNH=OLz]FKzк7)hÏqYJe~խԼEԺK5چ}.ebjZ?51*AzAb&iiiV:U&QhV3gA1櫋4nʶ,\mEl}X>M,j-L!OX4 t}:Էy=\%wD]Iys0_Se=j` L*+U&KM0#&a}ޢYFGN܄o~HNGu 'hJ 4*GKzgNA.ʓVN\ի.F?JO4/F!6I1h)%΄pFc޷:}i/* ?qR_AV+*dD6OcJ('3[@FVȮCn)RK}[xuîkéMrހ1"K|w/WxfAjw25dܮI>Q~Gy}m ?L-Yb=\D]ʟhOz30#xS=շ&̜ȴͳ2G9w bװ%ߖEoz]@3R.EUmnz@;UnGWuZôT1K( KKwolVkDgRaYlr?nn'0aMU?_cq*gH{iQV+EQyS~~*Jfj%wwU,%ݽu%TEQh[Vu=&IǼQQCÓk$k}IA`4R ǰ ŻYV/3 u.ߘL1Y |ˌw_+ܹ 58Ts4FjҦ_WliF'l⩵;!6n<ԺҍU׸k~U<"ϼᤀ":vTK`\b;P/}Df VH8M$xL7E q"L#I~yHX$) k뭰wL*$ܻsnm-q$@uc?al$(11IXH`1)i5#ZJؼ7#ڨ5t-2 Wί+Ѯt1'I(קߴ.;J’{TʐO~⭻ w9l1l V9 ջt IoIkWn[xApsGbɺUQjoNCO0}}Wu({fsjWІkGϸϨ{$5uoC >qA=5@6u-}=†tEOsOamHjM~S\om}WXm $QXR w?):҉ L ݪ\_C,w}Aʋ(itw>/# Q$OU2i_#mP ޒ٠ض*DVf$4v.Tb[sJ[iۨHIN+2rcs|7#ۆT(OWm6/ Zm0}LcE-DW7'S rS5)%&@6Rx5XeޱHt>ݹp0,H\>S۾.PxI5V4\[7X@pR(DٚC2O+Rv3(RFddkd&dw;̕ci3 &~W3& hgV$"e >lJTt21%`|4pN۵Yr;~9̥pg {v1h0rI=Y`nڥr嫻Q\ڃkA3n;RZ+ e Gj `>Y+sR w<оHKh"P"qBJܱ(,Pcq4CEQ5;"{ ᷹ 9rN wv?#U$kK=b\-ږO4vtzHqbw?uVG(vm+~-E˶Ynj?$SqVkPrG/mJH5Xq.np\ Y1;yrR۷ @i,-{u$Oo2nj vLrLqSA}4h;XDp$?JiҰB3(# S[mf05%%Bw)XN@8W:m\uٽq  jiri^ w.[ ? s A#RQe(U2N{kMeݶH`"(`̀EI,4[cmeXv7n 4% ("&+P℺!gk-{nO#uNԽۊhXxRݔkw]n;pD{aBԀU $T+;*%b ;g)*wpARFCGozRcX Hdc$ϽX[W \E+1 J%T7T= c,BL[b Þ"j-j-@2x>n/i6![pE$!L&70މø4)\3*M -8ȧzhxiR |ӕ, 1cef?CsqQ `Nh@xꆴ~b~< #UaTpdfXɟFJL+A4dp Vi &E ց}mUZ%`ǥ kYvH''{֖ͻ ǷZGkUnC $S5ՒI`f3>E+Wqޙ3Z @[%- <i0 Ԕoi$S o U4۳'qdEle?AUP'lϽlDQC9+Gt.GAp'}vP7x`gAssz-|QoI={ Qv58, ڳ 2f͸k*Acii+ܾ>1mv$O8a ǟHs8&WSV Sm\cp?Y[k*#O$V\3ۜ9')JDOtT`9d -=#hS#%KX66A'_gC7ֲX=m`^Dӡ Ds7YķI@/8#HJv!G4@3:}6>o5*  n{TW&"4WU)( `rnU nL ;)m-n}fF 0Ŧ"='?j#{kIN6B0T1=k%Ηae- ^+d5$8n>iuZwQ>nMU+d*!9nx$S5$?QFdx^*1D _uz}JZK ]~ۥܸ*0?@Wj1+Ѓ1F=!$LW-hն\[ҕ{cH{]GS׮}AI5i/f/-i*n=9twRKyl[1Oj787 4q0x(09k]jߴZȍU*RK  "h !VS9}0= ՐvFhmH9m8&f  e&xH}SW._R׬wjzˁH?IcV5vC&3K^>$?'(#.4Kn2`z?GA ݽԺZ=C81k)IÞo@nޖ6z\Y+ nӽnA bA0jm j忦am' (QC=3mX$R[p-# r56?u Tkn#< aY9"H*{X[ձv~j^t4۶j$z= =?\;Kd~leY3&((WBMPnױFe"PX &I9_0$ %yJ@& Jkn(dU3f"r3VKQ$Ϊ18#U.ivZ]ާ;@Z`<*TmPBD㚅,/qdH*Αv =ꪬ-%Չ==[-!H?_kS{v\iB֡V^~-f&"KNEcr)ʂ 0s4O~ :P,7nѢ6ȭwo1;ĕ32-QzP"&TeϿOlڽۺEeDwfR]JM{W]FVo$UE躃w,@j. q;m%ĺm,?+nA7Qtt)qBI'opО Y}93Z=Wf`LtK[6nzJEf=_N7 L+{WѿȒqg]sĚ[OUƵ95P(J[Is$u^a_h#kojW..ތO'?&y<.9* n\djj|$}UX5g*^WS0KuՓLSPoߗh-m (2';h%H?j7m?Q8`Bm d> ciJ&-eJIAS BS2ެAG4!<-IIpm  ; #SpܸH,O& [C` gF3֮@jlk-;r&9 p;Jm^HɏRkZ bH?!B8j,}J|86vVQwPbEڀ(&j338w͹A+~+M6@9=l aNvpgw`6cwz(b`N[${FCLڬY@ 6 1OT BwفEo~v)__* 9(JN_V`'vX&ڼrjqoL~5@D ?h/${o*v9"'ѽʆZ$}C4JܱR\<wUm,[IzNhm\*\ڂg7l+i:v* շ5_T 9+GTPd"q418iѐŤA012@qD/[}T9 G 9hFB>H3*FY.rb*lLa WP~bJ'BIb*D%Hvyr 3Q94X18<ҩmk.^FmD93JΧz<'!{*ClVϖL,#wNbܐ1rMX|6ږС2I# Y]J}Y+zdQΛ‹/'[][- n>jl:\{7[X0j# q昆fc!9<Զ*@˲6ws?~+0oohSZFuGvU0p&&ب=?¬5-2;mnD+oiv0YJPVCgTP) 3ډV?PM `S^ =h|׻mo=AߵD{xF?4L4 O}K':,Mvf֞Y:3Dy q^egWݺI=_[-#|=3z( #sBnTsp{ 8QtEEn2Oi=J-چ!x8[FFηtr~3 R譋V$mn1V¤1 w]\=LCV1+YIvCW{۽gh. "bGRKgEj[4z~X-ݸ\Z@ &co1l&[slq#T F; ~$[:U#q3MH77#٫BШZfwh4@کcKf,PJxuZ""Es̻c0 12YKԯoXKl$ s@Dd/oGӷ@X(QsHx%;Q@ܸ&\9J(&>?'8# @a6[O#f6& @DQ*Kdm'8ăϤ=1cA>q"}( ;P瘘]Acl#q`A`Fxfq <X2Ot2k`cV+t;gl1U "&'A;d#+VRݹpbd4ռ:EЭP,ϰMb]Cj/ƸYbc=겘VL @5d dV3PiDJI8wH5-z3owc[k8z]f"3 ϱDOo6Q?O"7܊0U` X .qcS~*S_tI߫fF⋄8沮B̈ڳ]ĂHC=B$oЌ`D vW5/{ʷp.iBܙzp;{SA1Ikl4cim5+1Hαrۖ癯?.y$\-0}|g:Su|z[xxwP|EhK +0޳cSw4[Kkd_^mor:uO򮀔*~;WQּ7Gjt=jn|I*|gj<n&e8"sZsW4}6D G^!vUqBVr+ '#Q\12p]|vjTMWLAz첺rp7 jAqfڂeY0G9k& g A8.HI@Z ̬NDoQ!."hB~ tz7\֛Jo˱xzH1bV7Ar°~QnS0 *4=gF۵Ice)$ =E4lztzkz557ՈK!<@~=7IIY(P:1-'^ƮE\vnMй Cc"#<)$(84`̦d2Ns1LX{4pc\sUÇҫƘ86?<гzv8H `qDʼn(5$3H3|OPB<\";Sn@qL 8I[rkn}A!(k >BCjm[k4/\aEbJdT]2Py;,WQkF+Kp Hg ]'z*>sڢU& ?|)D#PAnޔ IDj&buo1OE|ӵߐ}йqc"~j"A>1D \š)"RpV6'3L!KLPLǹFf=Kurۈf3L`RXkkE:)XK vc|Uuw@Tm&%F NGz $W2^`Xs <b=48&#>Zc/B~-%aI\eѾu$5*fn5cԹڡDVH&Ȕ*kLIkYD(nneI ) t v(ŷB2jYT88Ѯ!1}P&0qEn[J/XT3YC ݏ`8UXǽYvqqT NV}*#sRi1Bfc{LDۖsRKvW$jbı<g>w.TP F$3"x0V dl9۶1f_] OlƋ^rLڰNB™5!jZRQǮ[Dšx]>!uΙԮo0=Ǹ5H3JpG$O9 b\qCɂoTjNi pޠJ8 ]w#&9\[KJ/%v, k4460#0V Żv@̃rKKyn2]O]w4z{MkhԢT5[U(X.Ȗ{V-ɡ\270F?P ?Py @\~bi'l!JfRHM{^?-W]ko..דkX={lL~}Ռ)PNr>GHUgx3ړ~iGYg )تg5z.˶EjIO[Z۵A 1hw2ǧLMS;[=]sMSƫgi%hԡb [" DA6T @''M BC'FC‹x8yNx +*a"XiA{_Q{V۵mibj; ڬ eӶM(F)"R\G4?+j]%.!nٙR2&tA-1鄅 h>f>0)VAi ,3M4vi* Th$1B#ę)'&)0r}Qm44pcD{$oVFy"_U`jn[ =)g$?[I& } QA=ho67ay5 WbHㆃsM0Vd)D;QD$ʴ!&?Jx[9h@\IE%IR tu%m?EB.O:vk-^R`Lz=F4r"ʄxva w!ب*&j[+oYsl>TwWl֯A d8,\+ ?ʬn[K-y8T2 5[2DISnYiP\9`4ѱH!dg5"~\7yR֦ rѼHbDQb0s)%=(JIkp#~jƄ6Wm5ZLޤ 'ƢQFMCt过ue/_p,zA$ 6DH`HhgTޠG=7ZM^S-#pW313J(xfҥp30dǵ8>{I6t*[Kh..g 0ڠSnDÈRAsRtߕ|j|ۮi Qƒ1b`*fGL_u4R27DZbH`J~ԷAeeUMv Đ{Q,&ՇpxiQSe8MnC)Oju"ے$ )` TFs f۶G|TUu,CK1IU=~*/YCv4U螬5: &%q3RdRDLw!^gLm5m~<+:SNQD{I Ds\e뀀zYR0+5IyUftһ{W[.,{U㒞'Ro%WԠ9 dsWUm\d }&'f=(@M"2Qdy<6թ$To>͠;A$z,?:L fKh;-` o}[vN@FƗ%Ю˺RuP !у3IYZP9aҀFڔq2 c G֬l_*rW!fyӋ CK0,>LT qLKm*ER b~jXTN+KgV.El޻~)RdW,h Ų!0'=2tWt*mbl7cޣi1n>if@xaVjM|L, wST&&$8? X9E+EfSf͋ m& K;V:FΞrݕ"؜(*a`z@{BK goU]Zn Y>_+ڮ^ .n޼Աڪl=wqvrLGN("Dp?-9$ԁ -Oqdb Fژ%’uITPa`9PӮB5MLMIpXl+v{_ADD޴m/^سz[$Zg$jumڡ_c\!P$Bor=#23Ko3?) :;ϵ Ц+ f*W-ٵhpa*9TvҘ#?QSdc4/JQ9#R`$h!g\&`*$0Dّ85r_PtK^]z|[ϱ+vɞ$ ̫T}㗒4?B\t6t) eq@YlF%f6+]mZ7*""StO8#}gu.gQ+z;.(&+>Oac>-ifa'6S[`"O^ዽ.Ų%@h2:o~?yX8 kn]PȢ}10H*3xڻKVk6Va[WatڋDu<>wqfNoicbg^v/ȲA^"/M, чYɅRn#6HZ\ČʹR-i4mCM.ӈUMX|p9rz2-$NN~(1 g4DJ ZDlNMԗ@ P )9RmA,b=>ƨVF-qΣlGRV%GnP i=花.a0!1M64$F``fCym$[jZ;TL7kOZOMӭ:Uil w.MMch/ UEDza^J1Pm,3J}y9ͥ}* N;URF?J$"DF. q>CC)4Qh=3COon*c6&^ }3]^?We%A3\ݷdH0M.O&$TD.g{TM]6˽æsbIj!`[]icSgHٯ<o`+)IE[aZba@ğ~jP~_Rl܃ fw#*[LӵGG@( OuuMV۳kb-,*< m6s[=z~+o'u^)1Df@ px> q=|SOG$l ɶ1Pivӽ"H2buU!A [b;H47ഞ?֔l^q2B SJAf&iR`Nd}hNT'* .m#5!*%fL/7CI9 8!?ZăVQm'G6SvQVUOq(!DxL`Kjn*9@)kd[l"|;kOkږnw D 1T-1R8N FU4:}+Uy)"iN?g"R%tٷs,؞ >럌^K=3juKx+YGב,k~ PETD48Q*,#*] 08=P"HcVwkh*UpsM5LqD F&2M&x$Zq۸ }&s}<+{þ,tm[L+$W8 쿲DHp1qmQ/[kB9fHV1jkۑ̝+ nk$m5.| wk~9'hʚv}E-[=0m% qגVՍE GUZqnÕp!$کżVVt~Ka.' 3խ?v֒{L"kqaj''wAcI!fZ꺎Sp3IsTHV29iGa8La}t ,d%yxCmla pH4 UmuFaXuĬfgn''>j nZ'P3KwMummeCCk$3HRnbaڜYkQ6pR`cLib7}vӎ!/ٵ/`01\w.{ 7C&3&+^EFK|ơ-+!Z ޽QteX#|wX08?Z/ : pxHq:ҌաwooG 1|N[;a0޾~%1~ExE຋bep~9A]媦x,]m.mJ{M*XKH+kCS O3uԆp}_½_G)+8aoeK63S4Bʆ?0TȜ(]fKoz%?SO-y]5qRnp*Wʝ2;\R3O6;L8xxVGh%AĚ[rQo׉h.7)h0wOKj0yӆ;zv %@lq4J#R[_Fv[=9!\ @djUݐ-9 86}3N` '<4 9$njSfXU!~hv 'G Nօ^u:`mH$ҹt޺nlo 7BڬhulUrdޙqW[aݵH^ӓS+IУ]w=^Yބь$CL%sja=o3*ZtfMr]ܪ#QmW'13SX@C(%Ua@&'ZNF)aREgPs=t>du0h*4+h(w{*ݝ:=06O^?/#KͪzعuVʞ*[V)|FRqnw3lO;oRo7p .b=Z"2sXI-4?x nkhj1^7\giiUյ댠N?uQegqS㌗cvre&ݯ.0`M<'3rH1V)`+X‰dG,GDFLU',טћ4_=^݄ZvC A¯hتA+)f ]m&pTbGg 8jl/>nPO{P`hj49#楴۫(RNDޏb$YiG0Uk_Ԯ0]}" U[7!X2vCn1߽\v m OAP޷3M -ްHVm=6v[󔣂1`Rb#poM Ngpϱ8l%V# f#&]#DT{L ϗn 0ckD7tNIF;k; ev9]>t )Cqj U >bN#"c]VKxp$ I6{D"Qt^ջ Qޫ򠟤{qElYp$"A@Р2YTHfM dnv#x~jO]SW |⋶K>}&ΧN@ir$]CYo57uv5^ IDX1ޚT Pm/;#5 c8i,}Evڏ VDHmo,L?HT=b;Լӥ[wX2#k1:ÍVSia$s:+:G|djG##K oP$n^°M~ㄞޑͭNO{\TJ+IWԠ7-"s1=ڼOk:_v0{שxQѲ IGsJ1~ۋ=ĝpǸ=\}ϧ= KmY+^k ȶE9kVK~>|Fv:2.eنw~漷\Oyy'kWz=]APǸ^=zkzEv[i04N'4wv;-#h2GpU:h uN"n=#4D 9:Ѭ`,H;ѰpLhn&aW1&b^X}X᷌Z܌b?IuDdޣ$4LSSl$M4Tʆlb& dEa$9jM']u:^뵔(`=w/1E(vaڒ8JS 㰧m-[bět>S`Ub`}[GҖoZw{޾mmR{|WmHܭZGU(<˛1 )&?AGz{{C|=uܧCQD-Ie$gM`ZI%Uaju#Pfݲ b&=껴 \5*!}$ag,!$H~ҦF/Zt sK0O&"N H|eezLĬSm*#PIXcJؙ# 6>Z 7 ≚-{Ut5D388P]r11''ާ\ Zx${Ͻ,V6wD,-1_Ͷo[,}cyX#Z7%Iͽ5jzMFnrT[!UŗmN{noXzb'D .uBT!-3;2&KqQP@MfCXH#AT*GTԾGex=9쮪=`\#A"~P 0b`>RjxokAL?MsM#j#5x}?t6O,jkk&+ڻl4Wo'l~<9I:ScMk6<W_,]Bgxݥ:մ.]L nrE}X7ji޺Z@ȮR*s^|bW=GhONl0p"ީj\r.1I>).A*DH-ʬF?zb9N~i;yfi3NHڪ {TRtÔNX SKs,p*]vlj-(@-c޻‹umVKjkVzAqjWվZYVL 6SR 84$S<֝A* F[؊, 1Q,FBW,$qN=PA5޵TԺ}kWa#VhO,H2S&`kMoug6WlUr{BTk" #rDEV [xn^+y6mDb. ojZ]*Hggn%PnʣI'?ƘeHGjteqhԽx}X,&b#j{b8`TǷށHeF2c4 Ob]vhu=mmV{9

Om@˻,CqE "gz[9>ÁR\ns4L""X98I7nj]0kJ΃^&4(HI&e<פ~#uΗ[ 3ۈ-]lX>gVn&;A4$3ddFr RJWvF ޼.`(,I1P*" ԈےT?jZ[m6DVDzEYq"~hP=w[oW}=tGG5 'r`t`c2eO8ڷ_~So` V'zt]!Nֺǝymj|EX,sF "գr&ڥwƭYY1j~[ 7@=%YUI$AYvyG7̊(%X3)D|PZ'bH9fi[u\;dQe ݊ɎÝ0~P ƌ3TlkW0pG8uxH8+<w3?TkTb@n8׾:t[M˚u$ׇkW}vbQ/Ja $q_#xfaKlsiR# 'O0JJO l܎wWX'jإyQ@1$gd]*cSl Р?ƞ &X+eBNG"^ZU{T]ުx%AAVE]7EׯQ\lY;r~ϸ!B 2&ʨEuؖr,IPl4!M+N7% =KlO1 #z#)u_LzޡĈM0V2`;SM 9qGCQBsO"p Āh4WF?Q5Z;zd*mQ cTJ|RI*A0qBw1%& 4BF L-@5mmAQɧv#hڼ Vi@A'@()0IYQ[@l8R2ӌT PGJenQb?LS#if'' \$RH ed$O7Oa$ +10'BH'q)8l0T$Fn &D hV`Ǖh:]ۭ㨳rOHXQd)޹FIC!o,;Tj\ AH"'"HVT1${I;0d")ȁA~H$2aVG'ފd2yB@Y&{耱ao ?ƞCZv.[wpJ@Rg V8c>?ZbK[MŁMnj{6>ap@ H9ƅ'lLjzi݈ܠdSEIх peǸ#c;8$y^6vλIv~V-;`%i*.WrN95Fm xUY֏ D$Fnm\- P 兩x*߶Y;6;*#P%ADDyS#z;{k9[n˺17<0Ğ}Iv6^ʕ@Lb]|A+[xwKoL뼨EpgikAeTYPmo^{JWUjzQz->Xٮ9]y<):TJ<z e=#{w`h#n"$ JN@bI*h#'MbعyQ*'sLlRLNDA$ <8VݘQ *={FnnM{qd Hs.9hdaB FL-[ML 9h;!WB`1?ҍ%_m\[lwf(,`n$Qۉ7 2I3 *‹I벝ʨKiU1¬4o_MEy\n1P^Tr*$XCqbn(!!c U&`sG"e 0z5P}~s@[c Gj]{Մ2qrqmĖ"jJC ^N'5~7z.:pCnq\f,Xj.+;ᘈ3vA Sv9ӄ@ "vW, ̙lز- I͡ƨXػƥ;U>gKfo`$"HK .Օ/"I"pT8ZԵi ˗Ш ,}uP[vy@A)p~)ktP$nX݌qDLnGN†XlHމ\0$P; (wA!$߱cH4ګw,]IŘ3VlIɁ U0RM|EUe O]VG ,(!rj.X)vKӽ"JKOj^].śiq XktK*G޴u~#.^c i5tvv+xlf*13X[ROzG˻с=+>:E6L81B|Ur4چ'ڞ3ǿ~BTk}Y<Na~|JV8;1jHYA4} MŠ)XQNۘaDwIxZlf$ R3TT0 N)úܲ4doj6 D恊zU?Jki-kJ+ r//\fN 26&9mHRX,Pڵ1fǽ;쵊N$b j`e -<W!UPf354ĝ`;8 VK, RV,"sB&Oޥ6ȍaFb#яSZ> C|-AEapn^=WOz|۞"^B=rDLi78O0P94Z` dm|+{UND1' +&]1+'&A$BN8Ӳ 2CquP`bOO~q%MU'⫏v'*鎠CVZ-PrqUmz4032(ksyny[yⴼc֓=U/ZTT5ς*s#sާbQDŰ.sbLI LG_Ӛ>ʡ#je1؁B LNi'w45B ѴH S;7w1-܌OQ_i l pj0`gGd x+! cm4!b FwLSo<NIڄ!Dv@V )?(%} T'8S$E2FE1D" nMqhL]@%Y{JتcZlEm_bN{5DI*iP?I~$x>.xo]wMvP9l-뻃84vfh"*Su3Q, oj:۽.ֆŋ HSmW1}walA$'%Ḟ=U[j롉OڜH0;kO4PceZ["pMݴdIیrͶRGx<+]qC >Xn`~i8DKiMYo3E:rqv'?zߌ:^uehjo^pSZ:H&3mi+M&:ƧG:m +s<  UvC^w8W;z )v<ԤYX 8@8֜3^HP RfHsL>=D `'q L8 {{7ҝqq{vAA JݓziۦiHmVMd)bAs4I`j\}Б-ov]#VoS,pJ"~j|GzVX^Ԫ,*SBxg^scK)%Icf# @C2>.m`AV0Glm\abd3N#dı#6. T4J"#EYҦz-@_{UK`{LPժE,@rܜIp:sk,t-6 ~AsP%$~KN}d#HS'j2u=CK$G4 C%}$B 0cZ\D00u8*`J%T{cIb#(9+j (G1;#j@{|Két%K)evMR{Ԅ*A"IzU ?J<7zvr<랕.pܶ +>oZ}iөT)ϹMA_}'[nGݡ'kT'G.[ z.UƢ_-x=8 I2$/B=$?*6F[ %sSc&\%c-@47<+LNA"x_`D1b\L `!1 QŏiC__1 ɫz='Pn*r;H?z6Rd5'eSr@4 zHPe\ 2&3n3?zte&u4'EO-%}d80 Aڰy3đ09}x9_\E]mv7VI{SiIZ #E;KI{ +cu30ɞ*ZdESvvci}`񴟃QzwgPC=԰2 ѿep]zOO=&u&ڨTm ~zc;!b(E#,IS*![sLi^f@1GsQI1B= ngۊ$!I qR]f$VxP)35kE-F wOi(v d{m\fqB_qkpp N}JqR׺Q#q@5 i&Dbg?5L.:-m;$3?f\ HS%hh"oBU9KI@☱M-N3FBm;R۴}bNLd9 V$l޺=`IW۫ He"0e ;~;$ԻNd`>f.3f0ŧ Z 1WɎjdѶ >ծT >"L?AtiYf5ciydA{үaVLԜ bDpw8{U.Q~{l.,K.6Պ[m;IczڲRھ㜎4Mvd".mP\) 4aD 2?эS#C}$Ԗm 0&=j`0m5A sIej2R$%Wy$ .A"H 2ҡN5~x^zvmk5 4ZM ܺoBzuCH0 E0$1 AsZ=SGsM({$>?Z(T jjX;r'Rhz~J$ hfPAg>C)4; ș"e+*ǖ}3yȒ"f3"K*:) cB%A$I;^'֯S<Ћ# XG|T8e-6Ll@?0Îko½ R:g[ Uj?h=#\5C[!n۸ǵK+bOi^S8 `H?5s\hX-j| ovvڰjR=Gx}?tri!Hy8*#q't*.ͣ}slg8N3+YI`v7˙ ~Rkr>Wq#iD280LVI4s"2[ڝ.LOIqx;wn>n7=\~vbs1圓AUqiE%ڒCj]18KA F{S+eD+d&5oBǷp-`N;3Oچ<q y|Ę @?3mn^ GSh0n!RϬ&=>XT0'wR1XH $gڭhupӥIc[U2y8;{VgO=etc^?JUﲖГNdH VuvQ57OwӫW Ue81xj/;C,BUg7.Zc yRc-Ozۺm!["~?Z"82}1NҦÅ]1,UBϧh'М^Dp>ж;OB- _tӤQu߱U'$% 8e+2Ad朶U z63Em K6B )#{Ʃ6`;ͽ8/Dn>ʚmM=ۺ\Du! }~ߥU KpD O勾&LsTխi18L˷.H@D2dTX _DW6$⅕ІpI$A~k\^ $}v"]/zxץ C\gZ&; * in|Ӯ W^=6/D+ R&HyM}h[Ye.yQ-ueֻZ1. $& xTV`?)HLvbGzE@ AU`ĉ1*}Ai$1ӹ_hq0֮.[]5ʄ.,jwQVjM]b*hj'-*0n j& jH;>HA$N` 9e -Ҡ], wԖ|TaAADhBvǹq;f%y5d8l cq~iAyGoj12?x2)d=~8>b}WtWL @C TQ\ڞ;T6}I:ucylfљ?t~GGP]wUaz[Ua?Q _-&F2{U'TjB|rXg?} ܵVBIy6V2yJݷM>Qpet<&:'S?U8T$j7n 40=Z{몴n]a p6>w$( 3[ߡ)BaELZB9Pʓ&B4Ilҥ?Hu0>UA"^q6 ʩ*2x$qN(T Xc3-$[O5w/܅v9okkWSjݫ$Ls,&qԩ2Z@*tG~Oln&INn^zQ N9t𯹤@Sս}ʌĂ/?ymHfC:YKn*YpOjo&ˁqYv]HEo\\N8׉.~f % kW[Ȯ̥Di$'߸=dK'^Zfd%!*'hfooTV}',H"A8;ʒxL @9PCTB?zb}qA4TqC(IM+(UԮNgUaPݴЂ;vmDm'wˀ;vMP,u Kkuu7+mT@1 2=nT݆}dS p9T$b=-ޏ-Hpr$TdmOqNXH8cOV4t$nRp\[gڤ AyU];,Yt.zYp'?9FÍY&PW'iMCZj-mH!LM}j2,K`AG' 3Ma*>"He^KVvXuq ~j2"A[^h14awBH1aIAH%4 z'ޙ57,\]10.}ApI7qVuU\f#nU'v5LݓI`8$fM>x_Ol[[x/> x]!ǢMeZBp` ( O⯬a;oß'5x ưR=RVWukgs&{&`:Q2PbNFMO&Jcvퟁm6T,ijYunZTA&c5%xٰn;K؞(@҄d'+oŽ*ImmV[19 SZ%%ssv'ҡ#Iax9!fsUJ~W%&'E9p; +v}'p=fe@hxw^; KصzL{V~ <))34$ މhA HssW?&[ny"HC n9kjc¡$fw82r@3N~M XڝdJh"I?KkJ x<۶pl750a-"L {ghiO'@ILLjMMzo-PjzPThjW$>;+[V4tͬ}4yɁYPX$}^vede-DKq/YY[ H-HMq jedPǎjP7;7>r(-ܚ`@0 ;y]g{ҦSvR i{R<=Rq1nm[Ig0(6jn=?RgF0Em4htl_tuM;%| =py߹omeAmV-n;A$2 d'(s+23Ip{ыv,X $Ddve(fJ` A>P dQv9٥mA4Uǩ12LPFjͻ>b먪?W[$>SdH6Pne${M"'+6qO$zG*m(Ųͼ i?W/(t;Q#`i<;H1?z^d[Ʃ/4G>P5zȨ/m*ҘN`ڞ!Re %6mhݘ#,je0$H qK JB[>ĚyUX }Oy8m[kqOKG2/+.&3Е1j,dYE&5IbֵjbG?3Z7H?G:s?q3CHD} 1c"I`AhW*(Adu5`woQׁɁM>jg;b>iKxVp] ~dI{ d!zA%b29P t(2I QM{Eg*5Is4)`jޖnw1Oux$`+7|ǒ9LL<s@s.#I)0O}!C*A턊^ilٸbH?oS7 0>i$ Bcg P}EAHʒ$ޙT,5`F4A`fsR9Hiub";.ƕܧ';Q]p`ph|n$(8m8sU:gVw)i_[8M?wvXÞb_cOIm"ǗO&yRj$A]A@''CBj4V0>wI;Ij&$ MTP~RP0'j8$Ґ΃xyl\wOP[2f_z4ݼbQKH_*#[.ܿ~>*ݞJÝݣ*vWPd格0*G3r),k6uU{>(Ov5qYnhVblt47Ûc{ZxO[m7_j;Gܟj=GMFMy7bA=eH.W)\`i=^8xluz-5>OgDG=6A 2~Զ NQ F%g Ȭk +14/lSW:SՐo CCX)!m_ u:~b>]Hu6&L]y$Hm' cY}:'P85 NL?uJIv~<0$GzQrg3$yIj뎨\B5:MKOf% BuDB3J[SB]ڎmB;H޹`%B^itV(ܱݣl5ԷjIZ=} 5͍@򓫑0eFRdLH5tZ{ b$_CWkVTK`f[؊UT%3R¥,JA;6jF!' H`ȫnĝ Kl3d*D1 (%s II O4d cCk hgXLPX͢GӁ1ItYLL$>qO P`Lh0IлB`4fgdxv)1l)b(&(HI]CPvݕB^ w5-ۨvp8Z`d-ʰ2{sGh1WV5Xj4Ze:6{^L[շ{km}͞F~l6t[@0O7;ZEYdx0.ɐ @I}S?¡:]\|.A,rdVV:A4.)JI#lgS촕߿sQu_u;j+d+F`ZL}N\G늩FP?YDM M!N9GjP`^x4AO_dm֙3] />.uvɛ@Qz;ۺ]f;s?>R!Ĩ*7ew $JaPMkhEǺX"%?P#n:[^E>k+NN")ۿgME'] qO8OiK[ҫOj#iLÿiyd0bEX)Ѡ9!@Tݏ Az,4'ީlm#&(*K@`BwQI 2 Ӳ*a#Mƺf1dW*DF)\n+ZѥtuPcCtʰp}@"O*66* ؟ӼU;K45.Kyի2A+T\p89Y@ڭܵm``T t.\6ykد[\/@2k?Yk-Lyb`8"mn T1PJ7;@%Cg8~xSBO= ff x]:$&2AWޏ-_0e2S9wBurwTw_sUv7˳5Mo6-"5== ê4g{!Z !?ZǞ$]X!$oL0bۼDGNؔO#ڑ2Jcl=(Z&=:U m5ۻLI1L(}#WeͅUj%.86O6nTpfB7F޽;x;L֭t5=$~޼gjU7li 3QmBxQT,~/J6f̘ ]>4b€$KųqL幨rXdޏN-/$nb 3(>4EMՕ¬Q ۱O$N}'46vMJ `g rI'gޘDO4@DGV!I\6"A9#"H 8!'{RND%Rn $h@ fbgq-%eOl!.ÂQ)ROGȢߙS]͋gE~bغ y`zsȌ`wi#=)90xﻵ މy`8zݛX9=^yDk啎3߽݊Q}0Lh#To j^u F\SudMtcu]t]hH_.}\Zz@e hjm*yB]<-[uQسz; 7^Í/] R p FDWc~LJ.^[;mQNӴs*6ز! VX9'LLHיYQN#S4F~`w8dNA rGHKFiR{IgWInfླ.kŀHRJ/ӣ9E[9$8rFI1V5V^k[ Fj޷Ha`JƘnuSO=rb*KJܹrAD>uD>D9f=1cU7C:5ZUqn}CĽ"Jn'O.z56Zq#kK9?5b;R#'CIe Z3LY9PcڅNlYTLM>W$ @]Mek tm=1޷Lu'5ƖA[-V:TLO l#RH".DB=j#Aԅ@} rd @'vLjNK+t1߰`as5blVfYM/O*Ӵm#&jý8$ BY vS z;i6t-EixW*i9 6{S2ڊ.m-cMn/6 ?Jߴ q9&h+H9#e "#y*՝ Ho( Dg ګCNv- Fv6(#p2GրIRt7zAbK qBN+ n`u`Ðq0\Z[0խ|9Ԛ):M5Bs r`Pmj+Mjtm~?7, yEeT4ou~AgC^}-)m T{ 6]0ha L_CzK,,<yj{VnWtG{k(7b8[}tu.wOuw+/0n9s<@ ozUn: .nKZb'Fdcpい Ӆ$Q` cHMapIB(i" 3N"V?_(B)R <-[h8<TBO-R!卥%x(p sWI-XmRX`Acֳ{ݒQb`h<Ž-c5P$EM/cA$I]lہjqPܝM8\1I%G dzvr=#G[`9xg}/H/Si5gq?θnO#}kl{H0kc¾*~RͦbTocX ^g̷?ƔuD$ d8sl='-ܫ|zMb(d nd̘ɢav<cs Ȱ`Ć#NbO#Bn)Sl1`#,=CGu͝M@h'ZӖV[ZwO" Q 5<^߶%C8pjMmxCOkw坍bW SI)eIX7T >Ӭ->-/DrQͻ9'+(¹F=Q3f =Qt3ZNfL޵q)9~Ƨ>1KYk5wa.\1#f=F/`HNw~q̲!j|IA;*`$Y@Uی"$S~m/_$"EBTN2@ wi(]ÂG[{%pw4jBzLVnXAD"dci7} }ζ{M`LWu yjZ[DT.UVT8%Lrkl#"K#vKOv.f33A,dϽOg^vSrUOtWmdOPw@>y3 DTk`IMh*4?+|-iY0r?ҫX1NN*ޛz8$.XVu[]}O8沍O=,XgQpH8'q!eT `v;HjG+E$X$EQO⅃'onT!I"2)\3v(M{dP;=Wɏi&P)EU՝!@ܠ@"7LsU=rAڠNu OP䕌7Qյ!~gWgᎋc[,y)r0@e#wZ46[3e,~IcG$Rkفu}jkSקv'Ug(~n๻Vd*H1_5D}jeyH"$H?{'P[thfׇk]x]. OvޗOwrV,C+[z\eOOm-{E=#\◁:wCыf塿B?Z??hݛOeۉ?TcJǕt" w'c5QEEwWax,LF#Y7S)kCֳtఃOsn0i( mHڑF,w}5]NL==.ylFm7X@쟅|76֦’UW.$Mk+PiiKL 5Ȃfk޺Ե ˝(oOj}m,Lz({G4& SuV#4YI 'oqZ2ϥ 1+J.K,lLo`}?" މu,\a{ShؿsOe݆V?ucM[ZQp=d~i)~.FzwO[QzٶXWjdlargj5lԪ1x"M0Զгnޓ*= H}ܰkIn1?U]CҺE5Q}XZ-jW/=fqgx]o-sTTvڨ&TFt>:u$85Ϊ3)kYr݋>j|`܂*bһ*ѩ5F͵"ݑ.Yvݫ~UH0k赖m#Jls<~eʯ"iCf 9[P_s]*.{z,m -Qfk;Iծ,fI+V⧒BI;LMFY{IwM.YrNA5o.o5J.ӽU!A1]_]5><3b<;x_tvuމ:ei.YG k1_]tڻ K:kIq A zu]ZtgQlt&U]lRKYif'g,5R<[gD˾멤TZtH۶Ff%7iUTI$z#[tUUqW bEa`%n?hjޏIo뿨]m~Nj:,c=ZC5>X\[a-ZBzM~{UQ5V=NfwcdHҝOS]KIݽuQ1?+?b7n*\_ZxLh<7⎫oxsU~SsLWT m?ߌ:_Ҵn׺Zsp`ڀ<ρO7Zz24o|8+NcM[ֺxӨM m;ŰFx1$ &='S.Iޭ{NpW qO{G{W,޶ae>~ GVѦxsktݻmeR al^.X{7GqJr }ȷF=k?x{x GoktV/ uFK}׶,M<^]_OSQa+vޙX{+O==/7,ߵU^*B@nUVwQy vrpfU -.ޚK*`sjm)k_i`^}ۂ'A' :vWjQ {'{,:afv[O$My'S?t{Ku Iz U7e&ÞuauK~}%Ҋ{C/c5iho7vu}k8K꟭Li|Ab,۝F s$ 45?GU7.y' Vt~6߹\ v^iXw qӈ:w_| SMBkKm+b{>G~ tkό/Y|7/%۩ҳY~=@?z4<-/U(ڛVʠ7r r{X鈗7s[#$|ĝwUC{Okjth)"3^{_ t_u?xWqŕT鶮+%Πb3p=Q f;w/~=xV=2IUP+?cw9'Rlu[q.~}CEztZޡCp%*c92{(O`iοF/A!*q5juT6/WI`dpA''} ?:oDyo腆.H?7z?fG5?R@ *TR@ *TR@ *TR@ *TR@ *TR@ *TR@ *TR@ :gzG`mfΥLT:WR_jﹹvǒOsW=>MGAz~{kؑڕ*~/mYVSxO$ORAks_W,+}*)xUMe_"VxX#__7Xu/n3xF'jJk[NX]:xP gUV/x 6.H`'ҥ@bju)uơ\\'Zߊ~;oŽh:ZT⟎:}CĽF2{ZP}nQsOpAJ6S _Z&N:=Y='M_K4znr?QJvg _Q2(\gU}WTj5rSJR c{ovߕmgl1yJ6αoufUT8+wR4P=&5joi̭NUE*TdBc+%b=L&:]WYv/.P?[ޠ]SYy6.~0xY`ٽ⮢P;!iR ?񨽪sM׻y,OO5'XzVGQշTKmrAe>@*T?[]7_ܛ,TLiR]WKDJ4=7ĽWKmYeTTOQ_kjv,LOrj*TG񕎞 >&ɢK~J]K 'W-n۸-+L}*:ozvli|Sԅ.@, ax 3uE뤨*TkxŽuMcPȋ&L\Wju㛏q12I>Jv=;c];@=':XQT T{A">:SuPIf2IiRJ*TRJ*TRJ*TRJ*TRJ*TRJ*TRJ*TRJ*enthought-chaco2-4.1.0.orig/examples/enable/text_grid_demo.py0000644000175000017500000000112511674463635023316 0ustar varunvarun from numpy import array from enable.example_support import DemoFrame, demo_main from enable.api import Container, Window from enable.text_grid import TextGrid class MyFrame(DemoFrame): def _create_window(self): strings = array([["apple", "banana", "cherry", "durian"], ["eggfruit", "fig", "grape", "honeydew"]]) grid = TextGrid(string_array=strings) container = Container(bounds=[500,100]) container.add(grid) return Window(self, -1, component=container) if __name__ == "__main__": demo_main(MyFrame, size=[500,100]) enthought-chaco2-4.1.0.orig/examples/enable/shapes/0000755000175000017500000000000011674463635021233 5ustar varunvarunenthought-chaco2-4.1.0.orig/examples/enable/shapes/circle.py0000644000175000017500000000415311674463635023051 0ustar varunvarun""" A moveable circle shape. """ from __future__ import with_statement # Enthought library imports. from traits.api import Float from enable.primitives.shape import Shape class Circle(Shape): """ A moveable circle shape. """ #### 'Circle' interface ################################################### # The radius of the circle. radius = Float ########################################################################### # 'CoordinateBox' interface. ########################################################################### def _bounds_changed(self): """ Static trait change handler. """ w, h = self.bounds radius = min(w, h) / 2.0 return ########################################################################### # 'Component' interface. ########################################################################### def is_in(self, x, y): """ Return True if a point is considered to be 'in' the component. """ return self._distance_between(self.center, (x, y)) <= self.radius ########################################################################### # Protected 'Component' interface. ########################################################################### def _draw_mainlayer(self, gc, view_bounds=None, mode='default'): """ Draw the component. """ with gc: gc.set_fill_color(self._get_fill_color(self.event_state)) x, y = self.position gc.arc(x + self.radius, y + self.radius, self.radius, 0, 2*3.14159, False) gc.fill_path() # Draw the shape's text. self._draw_text(gc) return ########################################################################### # 'Circle' interface. ########################################################################### def _radius_changed(self): """ Static trait change handler. """ diameter = self.radius * 2 self.bounds = [diameter, diameter] return #### EOF ###################################################################### enthought-chaco2-4.1.0.orig/examples/enable/shapes/api.py0000644000175000017500000000016111674463635022354 0ustar varunvarunfrom box import Box from circle import Circle from shape import Shape from shape_container import ShapeContainer enthought-chaco2-4.1.0.orig/examples/enable/shapes/run.py0000644000175000017500000000353611674463635022420 0ustar varunvarun""" An example showing moveable shapes. """ # Enthought library imports. from enable.api import Container, Window from enable.example_support import DemoFrame, demo_main # Local imports from box import Box from circle import Circle class MyFrame(DemoFrame): """ The top-level frame. """ ########################################################################### # 'DemoFrame' interface. ########################################################################### def _create_window(self): """ Create an enable window. """ container = Container( auto_size=False, bgcolor='black', *self._create_shapes() ) return Window(self, component=container) ########################################################################### # Private interface. ########################################################################### def _create_shapes(self): """ Create some shapes. """ box1 = Box( bounds = [100, 100], position = [50, 50], fill_color = 'red', text = 'Box 1' ) box2 = Box( bounds = [100, 100], position = [150, 150], fill_color = 'green', text = 'Box 2' ) circle1 = Circle( radius = 50, position = [250,250], fill_color = 'blue', text = 'Circle 1' ) circle2 = Circle( radius = 50, position = [350,350], fill_color = 'yellow', text = 'Circle 2' ) return box1, box2, circle1, circle2 if __name__ == "__main__": demo_main(MyFrame, size=(500, 500), title="Click and drag the shapes") #### EOF ###################################################################### enthought-chaco2-4.1.0.orig/examples/enable/shapes/box.py0000644000175000017500000000152611674463635022401 0ustar varunvarun""" A moveable box shape. """ from __future__ import with_statement from enable.primitives.shape import Shape class Box(Shape): """ A moveable box shape. """ ########################################################################### # Protected 'Component' interface. ########################################################################### def _draw_mainlayer(self, gc, view_bounds=None, mode='default'): """ Draw the component. """ with gc: gc.set_fill_color(self._get_fill_color(self.event_state)) dx, dy = self.bounds x, y = self.position gc.rect(x, y, dx, dy) gc.fill_path() # Draw the shape's text. self._draw_text(gc) return #### EOF ###################################################################### enthought-chaco2-4.1.0.orig/examples/enable/scrolled_canvas_demo.py0000644000175000017500000000350311674463635024471 0ustar varunvarun from numpy import arange, array from enable.api import Canvas, Viewport, Window, Scrolled from enable.tools.api import ViewportPanTool from enable.primitives.api import Box from enable.example_support import demo_main, DemoFrame class MyFrame(DemoFrame): def _create_window(self): canvas = Canvas(bgcolor="lightsteelblue", draw_axes=True) boxgridsize = 8 boxsize = 50 spacing = boxsize * 2 offset = spacing / 2 origin_color = array([0.0, 0.0, 1.0]) x_color = array([0.0, 1.0, 0.0]) y_color = array([1.0, 0.0, 0.0]) for i in range(boxgridsize): for j in range(boxgridsize): color = tuple(x_color / (boxgridsize - 1) * i + \ y_color / (boxgridsize - 1) * j + \ origin_color) + (1.0,) box = Box(color=color, bounds=[boxsize, boxsize], resizable="") box.position= [i*spacing + offset - boxsize/2 + 0.5, j*spacing + offset - boxsize/2 + 0.5] canvas.add(box) viewport = Viewport(component=canvas, enable_zoom=True) viewport.view_position = [0,0] viewport.tools.append(ViewportPanTool(viewport)) # Uncomment the following to enforce limits on the zoom #viewport.min_zoom = 0.1 #viewport.max_zoom = 3.0 scrolled = Scrolled(canvas, fit_window = True, inside_padding_width = 0, mousewheel_scroll = False, viewport_component = viewport, always_show_sb = True, continuous_drag_update = True) return Window(self, -1, component=scrolled) if __name__ == "__main__": demo_main(MyFrame, title="Canvas example") enthought-chaco2-4.1.0.orig/examples/enable/basic_draw.py0000644000175000017500000000157511674463635022430 0ustar varunvarun""" This demonstrates the most basic drawing capabilities using Enable. A new component is created and added to a container. """ from __future__ import with_statement from enable.example_support import DemoFrame, demo_main from enable.api import Component, Container, Window class Box(Component): resizable = "" def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): with gc: gc.set_fill_color((1.0, 0.0, 0.0, 1.0)) dx, dy = self.bounds x, y = self.position gc.rect(x, y, dx, dy) gc.fill_path() class MyFrame(DemoFrame): def _create_window(self): box = Box(bounds=[100.0, 100.0], position=[50.0, 50.0]) container = Container(bounds=[500,500]) container.add(box) return Window(self, -1, component=container) if __name__ == "__main__": demo_main(MyFrame) # EOF enthought-chaco2-4.1.0.orig/examples/enable/scrollbar_demo.py0000644000175000017500000000433111674463635023312 0ustar varunvarun from enable.api import Component, Container, Label, \ NativeScrollBar, Window from enable.example_support import DemoFrame, demo_main class MyFrame(DemoFrame): def _create_window(self): label = Label(text="h:\nv:", font="modern 16", position=[20, 50], bounds=[100, 100], bgcolor = "red", color = "white", hjustify = "center", vjustify = "center") vscroll = NativeScrollBar(orientation = "vertical", bounds = [15, label.height], position = [label.x2, label.y], range = (0, 100.0, 10.0, 1.0), enabled = True) vscroll.on_trait_change(self._update_vscroll, "scroll_position") hscroll = NativeScrollBar(orientation = "horizontal", bounds = [label.width, 15], position = [label.x, label.y-15], range = (0, 100.0, 10.0, 1.0), enabled = True) hscroll.on_trait_change(self._update_hscroll, "scroll_position") container = Container(bounds=[200,200], border_visible=True, padding=15) container.add(label, hscroll, vscroll) container.on_trait_change(self._update_layout, "bounds") container.on_trait_change(self._update_layout, "bounds_items") self.label = label self.hscroll = hscroll self.vscroll = vscroll return Window(self, -1, component=container) def _update_hscroll(self): text = self.label.text.split("\n") text[0] = "h: " + str(self.hscroll.scroll_position) self.label.text = "\n".join(text) def _update_vscroll(self): text = self.label.text.split("\n") text[1] = "v: " + str(self.vscroll.scroll_position) self.label.text = "\n".join(text) def _update_layout(self): self.vscroll._widget_moved = True self.hscroll._widget_moved = True if __name__ == "__main__": demo_main(MyFrame, title="Scrollbar demo", size=(250,250)) enthought-chaco2-4.1.0.orig/examples/enable/component_demo.py0000644000175000017500000000247311674463635023336 0ustar varunvarunfrom __future__ import with_statement from enable.api import Component, ComponentEditor from traits.api import HasTraits, Instance from traitsui.api import Item, View class MyComponent(Component): def draw(self, gc, **kwargs): w,h = gc.width(), gc.height() gc.clear() # Draw a rounded rect just inside the bounds gc.set_line_width(2.0) gc.set_stroke_color((0.0, 0.0, 0.0, 1.0)) r = 15 b = 3 gc.move_to(b, h/2) gc.arc_to(b, h-b, w/2, h-b, r) gc.arc_to(w-b, h-b, w-b, h/2, r) gc.arc_to(w-b, b, w/2, b, r) gc.arc_to(b, b, b, h/2, r) gc.line_to(b, h/2) gc.stroke_path() return def normal_key_pressed(self, event): print "key pressed: ", event.character class Demo(HasTraits): canvas = Instance(Component) traits_view = View(Item('canvas', editor=ComponentEditor(bgcolor="lightgray"), show_label=False, width=200, height=200), resizable=True, title="Component Example") def _canvas_default(self): return MyComponent() if __name__ == "__main__": Demo().configure_traits() enthought-chaco2-4.1.0.orig/examples/enable/container_demo.py0000644000175000017500000000765511674463635023325 0ustar varunvarunfrom __future__ import with_statement from traits.etsconfig.api import ETSConfig ETSConfig.toolkit = 'wx' import wx from enable.api import ColorTrait, Window from chaco.api import * from chaco.tools.api import DragTool from kiva.fonttools import Font from kiva.trait_defs.kiva_font_trait import KivaFont from traits.api import Enum, Float, Int, Str, Tuple class Region(PlotComponent, DragTool): color = ColorTrait("lightblue") draw_layer = "plot" resizable = "" event_states = Enum("normal", "dragging") _offset = Tuple def __init__(self, color=None, **kw): super(Region, self).__init__(**kw) if color: self.color = color if not kw.has_key("bounds"): self.bounds = [100,100] def _draw_plot(self, gc, view_bounds=None, mode="normal"): with gc: gc.set_fill_color(self.color_) gc.rect(self.x, self.y, self.width, self.height) gc.fill_path() def drag_start(self, event): self._offset = (event.x - self.x, event.y - self.y) event.handled = True def dragging(self, event): self.position = [event.x - self._offset[0], event.y - self._offset[1]] event.handled = True self.request_redraw() class Overlay(AbstractOverlay): text = Str font = KivaFont("DEFAULT 16") alpha = Float(0.5) margin = Int(8) def __init__(self, text="", *args, **kw): super(Overlay, self).__init__(*args, **kw) self.text = text def overlay(self, component, gc, view_bounds=None, mode="normal"): with gc: gc.set_font(self.font) twidth, theight = gc.get_text_extent(self.text)[2:] tx = component.x + (component.width - twidth)/2.0 ty = component.y + (component.height - theight)/2.0 # Draw a small, light rectangle representing this overlay gc.set_fill_color((1.0,1.0,1.0,self.alpha)) gc.rect(tx-self.margin, ty-self.margin, twidth+2*self.margin, theight+2*self.margin) gc.fill_path() gc.set_text_position(tx, ty) gc.show_text(self.text) rect1 = Region("orchid", position=[50,50]) rect2 = Region("cornflowerblue", position=[200,50]) rect1.overlays.append(Overlay("One", component=rect1)) rect2.overlays.append(Overlay("Two", component=rect2)) container1 = OverlayPlotContainer(bounds=[400,400], resizable="") container1.add(rect1, rect2) container1.bgcolor = (0.60, 0.98, 0.60, 0.5) #"palegreen" rect3 = Region("purple", position=[50,50]) rect4 = Region("teal", position=[200,50]) rect3.overlays.append(Overlay("Three", component=rect3)) rect4.overlays.append(Overlay("Four", component=rect4)) container2 = OverlayPlotContainer(bounds=[400,400], resizable="") container2.add(rect3, rect4) container2.bgcolor = "navajowhite" container2.position = [200, 200] top_container = OverlayPlotContainer() top_container.add(container1, container2) #rect1.unified_draw = True #rect2.unified_draw = True class PlotFrame(wx.Frame): def __init__(self, *args, **kw): wx.Frame.__init__( *(self,) + args, **kw ) # Create the Enable Window object, and store a reference to it. # (This will be handy later.) The Window requires a WX parent object # as its first argument, so we just pass 'self'. self.plot_window = Window(self, component=top_container) # We'll create a default sizer to put our plot_window in. sizer = wx.BoxSizer(wx.HORIZONTAL) # Since Window is an Enable object, we need to get its corresponding # WX control. This is stored in its ".control" attribute. sizer.Add(self.plot_window.control, 1, wx.EXPAND) # More WX boilerplate. self.SetSizer(sizer) self.SetAutoLayout(True) self.Show(True) return if __name__ == "__main__": app = wx.PySimpleApp() frame = PlotFrame(None, size=(600,600)) app.MainLoop() enthought-chaco2-4.1.0.orig/examples/enable/filled_container_demo.py0000644000175000017500000001271511674463635024635 0ustar varunvarun""" Shows how to implement a simple drag operation with transitory visual side-effects that get cleaned up when the drag completes. There is a filled container that contains two filled circles, each of which has a different kind of "shadow" object that it dynamically adds to the container when the user clicks and drags the circle around. Because the shadow objects are "first-class" components in the filled container, and because containers default to auto-sizing around their components, the container stretches to the minimum bounding box of its components as the user drags the circles around. """ from __future__ import with_statement from numpy import array from enable.example_support import DemoFrame, demo_main from enable.api import Container, Component, Container, Pointer, str_to_font, Window from traits.api import Any, Array, Enum, Float, Instance, Trait, Tuple class MyFilledContainer(Container): fit_window = False border_width = 2 resizable = "" _font = Any def _draw_container_mainlayer(self, gc, view_bounds, mode="default"): 'Draws a filled container with the word "Container" in the center' if not self._font: self._font = str_to_font(None, None, "modern 10") with gc: gc.set_fill_color(self.bgcolor_) gc.rect(self.x, self.y, self.width, self.height) gc.draw_path() self._draw_border(gc) gc.set_font(self._font) gc.set_fill_color((1.0, 1.0, 1.0, 1.0)) tx, ty, tw, th = gc.get_text_extent("Container") tx = self.x + self.width/2.0 - tw/2.0 ty = self.y + self.height/2.0 - th/2.0 gc.show_text_at_point("Container", tx, ty) return class Circle(Component): """ The circle moves with the mouse cursor but leaves a translucent version of itself in its original position until the mouse button is released. """ color = (0.0, 0.0, 1.0, 1.0) bgcolor = "none" normal_pointer = Pointer("arrow") moving_pointer = Pointer("hand") prev_x = Float prev_y = Float shadow_type = Enum("light", "dashed") shadow = Instance(Component) resizable = "" def __init__(self, **traits): Component.__init__(self, **traits) self.pointer = self.normal_pointer return def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): with gc: gc.set_fill_color(self.color) dx, dy = self.bounds x, y = self.position radius = min(dx/2.0, dy/2.0) gc.arc(x+dx/2.0, y+dy/2.0, radius, 0.0, 2*3.14159) gc.fill_path() return def normal_left_down(self, event): self.event_state = "moving" self.pointer = self.moving_pointer event.window.set_mouse_owner(self, event.net_transform()) # Create our shadow if self.shadow_type == "light": klass = LightCircle else: klass = DashedCircle self.shadow = klass(bounds=self.bounds, position=self.position, color=(1.0, 1.0, 1.0, 1.0)) self.container.insert(0, self.shadow) x, y = self.position self.prev_x = event.x self.prev_y = event.y return def moving_mouse_move(self, event): self.position = [self.x + (event.x - self.prev_x), self.y + (event.y - self.prev_y)] self.prev_x = event.x self.prev_y = event.y self.request_redraw() return def moving_left_up(self, event): self.event_state = "normal" self.pointer = self.normal_pointer event.window.set_mouse_owner(None) event.window.redraw() # Remove our shadow self.container.remove(self.shadow) return def moving_mouse_leave(self, event): self.moving_left_up(event) return class LightCircle(Component): color = Tuple bgcolor = "none" radius = Float(1.0) resizable = "" def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): with gc: gc.set_fill_color(self.color[0:3] + (self.color[3]*0.3,)) dx, dy = self.bounds x, y = self.position radius = min(dx/2.0, dy/2.0) gc.arc(x+dx/2.0, y+dy/2.0, radius, 0.0, 2*3.14159) gc.fill_path() return class DashedCircle(Component): color = Tuple bgcolor = "none" radius = Float(1.0) line_dash = array([2.0, 2.0]) resizable = "" def _draw_mainlayer(self, gc, view_bounds=None, mode="default"): with gc: gc.set_fill_color(self.color) dx, dy = self.bounds x, y = self.position radius = min(dx/2.0, dy/2.0) gc.arc(x+dx/2.0, y+dy/2.0, radius, 0.0, 2*3.14159) gc.set_stroke_color(self.color[0:3] + (self.color[3]*0.8,)) gc.set_line_dash(self.line_dash) gc.stroke_path() return class MyFrame(DemoFrame): def _create_window(self): circle1 = Circle(bounds=[75,75], position=[50, 50], shadow_type="dashed") circle2 = Circle(bounds=[75,75], position=[200, 50], shadow_type="light") container = MyFilledContainer(bounds=[500,500], bgcolor=(0.2, 0.4, 0.3, 1.0)) container.auto_size = True container.add(circle1) container.add(circle2) return Window(self, -1, component=container) if __name__ == "__main__": demo_main(MyFrame, title="Click and drag to move the circles") # EOF enthought-chaco2-4.1.0.orig/examples/enable/canvas_demo.py0000644000175000017500000000134011674463635022577 0ustar varunvarun from enable.api import Canvas, Viewport, Window from enable.tools.api import ViewportPanTool from enable.primitives.api import Box from enable.example_support import demo_main, DemoFrame class MyFrame(DemoFrame): def _create_window(self): canvas = Canvas(bgcolor="lightsteelblue", draw_axes=True) from basic_move import Box box = Box(color="red", bounds=[50,50], resizable="") box.position= [75,75] canvas.add(box) viewport = Viewport(component=canvas) viewport.view_position = [0,0] viewport.tools.append(ViewportPanTool(viewport)) return Window(self, -1, component=viewport) if __name__ == "__main__": demo_main(MyFrame, title="Canvas example") enthought-chaco2-4.1.0.orig/examples/enable/vtk_example.py0000644000175000017500000000205011674463635022636 0ustar varunvarun import sys from tvtk.api import tvtk from mayavi import mlab from enable.vtk_backend.vtk_window import EnableVTKWindow def main(): from basic_move import Box from enable.api import Container container = Container() box = Box(bounds=[30,30], position=[20,20], padding=5) container.add(box) # Create the mlab test mesh and get references to various parts of the # VTK pipeline m = mlab.test_mesh() scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor # Create the Enable Window window = EnableVTKWindow(rwi, renderer, component=container, #istyle_class = tvtk.InteractorStyleSwitch, istyle_class = tvtk.InteractorStyle, resizable = "v", bounds = [100, 100], padding_top = 20, padding_bottom = 20, padding_left = 20, ) #rwi.render() #rwi.start() mlab.show() return window, render_window if __name__=="__main__": main() enthought-chaco2-4.1.0.orig/examples/enable/label_test.py0000644000175000017500000000076511674463635022450 0ustar varunvarun""" Small demo of the Label component. """ from enable.example_support import DemoFrame, demo_main from enable.label import Label from enable.api import Component, Container, Pointer, Window class MyFrame(DemoFrame): def _create_window(self): label = Label(bounds=[100, 50], position=[50,50], text="HELLO") label.bgcolor = "red" return Window(self, -1, component=label) if __name__ == "__main__": demo_main(MyFrame, title="Click and drag to move the box") # EOF enthought-chaco2-4.1.0.orig/examples/enable/compass_example.py0000644000175000017500000000114511674463635023503 0ustar varunvarun from enable.api import OverlayContainer, Compass, Window from enable.example_support import demo_main, DemoFrame class MyFrame(DemoFrame): def _create_window(self): compass = Compass(scale=2, color="blue", clicked_color="red") container = OverlayContainer() container.add(compass) compass.on_trait_change(self._arrow_printer, "clicked") self.compass = compass return Window(self, component=container) def _arrow_printer(self): print "Clicked:", self.compass.clicked if __name__ == "__main__": demo_main(MyFrame, title="Slider example") enthought-chaco2-4.1.0.orig/examples/enable/primitives_demo.py0000644000175000017500000000466711674463635023536 0ustar varunvarun""" This demo is a canvas that showcases some of the drawing primitives in Enable. """ from enable.example_support import DemoFrame, demo_main from enable.api import Box, Component, Container, Window from enable.drawing.api import DragLine, DragPolygon, DragSegment, \ DrawingTool, PointLine, PointPolygon, DrawingCanvas, ToolbarButton, \ DrawingCanvasToolbar from traits.api import Any, Delegate, Instance class ResetButton(ToolbarButton): def perform(self, event): if self.canvas and self.canvas.active_tool: self.canvas.active_tool.reset() self.canvas.request_redraw() return class ActivateButton(ToolbarButton): tool = Instance(DrawingTool) def perform(self, event): if not self.canvas or not self.tool: return else: self.canvas.activate(self.tool) self.canvas.request_redraw() return def _tool_changed(self, old, new): if new: new.reset() return class MyFrame(DemoFrame): def _create_window(self): canvas = DrawingCanvas(bounds=[500,500]) toolbar = DrawingCanvasToolbar(width=500, height=32, fit_window=False, bgcolor="lightgrey") canvas.toolbar = toolbar toolbar.canvas = canvas button1 = ResetButton(label="Reset", toolbar=toolbar, bounds=[50,24]) button2 = ActivateButton(tool=DragLine(container=canvas), label="Path", toolbar=toolbar, bounds=[50,24]) button3 = ActivateButton(tool=DragPolygon(background_color=(0,0,0.8,1), container=canvas), label="Poly", toolbar=toolbar, bounds=[50,24]) button4 = ActivateButton(tool=PointLine(container=canvas), label="Polyline", toolbar=toolbar, bounds=[70,24]) button5 = ActivateButton(tool=DragSegment(container=canvas), label="Line", toolbar=toolbar, bounds=[50,24]) button6 = ActivateButton(tool=PointPolygon(container=canvas), label="PointPoly", toolbar=toolbar, bounds=[80,24]) toolbar.add_button(button1) toolbar.add_button(button2) toolbar.add_button(button3) toolbar.add_button(button4) toolbar.add_button(button5) toolbar.add_button(button6) return Window(self, -1, component=canvas) if __name__ == "__main__": demo_main(MyFrame, size=[700,600]) # EOF enthought-chaco2-4.1.0.orig/examples/savage/0000755000175000017500000000000011674463635017770 5ustar varunvarunenthought-chaco2-4.1.0.orig/examples/savage/lion.svg0000644000175000017500000004362411674463635021463 0ustar varunvarun enthought-chaco2-4.1.0.orig/examples/savage/static_image.py0000644000175000017500000000250611674463635022776 0ustar varunvarunfrom enable.savage.svg.document import SVGDocument from enable.savage.trait_defs.ui.svg_editor import SVGEditor from traits.api import HasTraits, Instance from traitsui.api import Item, View class StaticImageExample(HasTraits): svg = Instance(SVGDocument) traits_view = View(Item('svg', editor=SVGEditor(), width=450, height=450, show_label=False), resizable=True, title="StaticImageExample") def __init__(self, filename, renderer, *args, **kw): super(StaticImageExample, self).__init__(*args, **kw) self.svg = SVGDocument.createFromFile(filename, renderer=renderer) if __name__ == "__main__": import os.path import sys if '--wx' in sys.argv: from enable.savage.svg.backends.wx.renderer import Renderer sys.argv.remove('--wx') elif '--kiva' in sys.argv: from enable.savage.svg.backends.kiva.renderer import Renderer sys.argv.remove('--kiva') else: from enable.savage.svg.backends.kiva.renderer import Renderer if len(sys.argv) > 1: StaticImageExample(sys.argv[1], Renderer).configure_traits() else: filename = os.path.join(os.path.dirname(__file__), 'lion.svg') StaticImageExample(filename, Renderer).configure_traits() enthought-chaco2-4.1.0.orig/examples/savage/edit-paste.svg0000644000175000017500000025706511674463635022567 0ustar varunvarun image/svg+xml enthought-chaco2-4.1.0.orig/examples/savage/button_demo.py0000644000175000017500000000260011674463635022657 0ustar varunvarunfrom copy import copy import os.path from enable.savage.trait_defs.ui.svg_button import SVGButton from traits.api import HasTraits, Str from traitsui.api import Item, View, HGroup button_size = (64, 64) class ButtonDemo(HasTraits): copy_button = SVGButton(label='Copy', filename=os.path.join(os.path.dirname(__file__), 'edit-copy.svg'), width=button_size[0], height=button_size[1]) paste_button = SVGButton(label='Paste', filename=os.path.join(os.path.dirname(__file__), 'edit-paste.svg'), width=button_size[0], height=button_size[1]) text = Str clipboard = Str traits_view = View(HGroup(Item('copy_button', show_label=False), Item('paste_button', show_label=False, enabled_when='len(clipboard)>0')), Item('text', width=200), title='SVG Button Demo') def _copy_button_fired(self, event): self.clipboard = copy(self.text) def _paste_button_fired(self, event): self.text += self.clipboard if __name__ == "__main__": example = ButtonDemo() example.configure_traits() enthought-chaco2-4.1.0.orig/examples/savage/edit-copy.svg0000644000175000017500000003470711674463635022421 0ustar varunvarun image/svg+xml enthought-chaco2-4.1.0.orig/examples/savage/toggle_demo.py0000644000175000017500000000124111674463635022625 0ustar varunvarunimport os from traits.api import HasTraits from traitsui.api import View, Item from enable.savage.trait_defs.ui.svg_button import SVGButton pause_icon = os.path.join(os.path.dirname(__file__), 'player_pause.svg') resume_icon = os.path.join(os.path.dirname(__file__), 'player_play.svg') class SVGDemo(HasTraits): pause = SVGButton('Pause', filename=pause_icon, toggle_filename=resume_icon, toggle_state=True, toggle_label='Resume', toggle_tooltip='Resume', tooltip='Pause', toggle=True) trait_view = View(Item('pause')) SVGDemo().configure_traits() enthought-chaco2-4.1.0.orig/examples/savage/button_toggle.svg0000644000175000017500000000506511674463635023373 0ustar varunvarun image/svg+xml enthought-chaco2-4.1.0.orig/examples/savage/buttons_on_canvas.py0000644000175000017500000001133311674463635024070 0ustar varunvarunfrom __future__ import with_statement import os.path import xml.etree.cElementTree as etree from enable.api import Container, Component, ComponentEditor, BaseTool from kiva.constants import MODERN from kiva.fonttools import Font from traits.api import Instance, Callable, List, Str, HasTraits, Enum from traitsui.api import View, Item from enable.savage.svg.document import SVGDocument from enable.savage.svg.backends.kiva.renderer import Renderer as KivaRenderer class CanvasButton(Component): document = Instance(SVGDocument) toggle_document = Instance(SVGDocument) label = Str() callback = Callable callback_args = List(Str) state = Enum('up', 'down') bounds = [64, 64] def __init__(self, filename, callback, callback_args, *args, **kw): super(CanvasButton, self).__init__(*args, **kw) self.document = self._load_svg_document(filename) # set the toggle doc if it wasn't passed in as a keyword arg if self.toggle_document is None: toggle_filename = os.path.join(os.path.dirname(__file__), 'button_toggle.svg') self.toggle_document = self._load_svg_document(toggle_filename) self.callback = callback self.callback_args = callback_args def draw(self, gc, view_bounds, mode): if self.state == 'down': self._draw_svg_document(gc, self.toggle_document) self._draw_svg_document(gc, self.document) if len(self.label) > 0: self._draw_label(gc) def _load_svg_document(self, filename): if not os.path.exists(filename): raise ValueError tree = etree.parse(filename) root = tree.getroot() return SVGDocument(root, renderer=KivaRenderer) def _draw_svg_document(self, gc, document): with gc: gc.translate_ctm(self.x, self.y+self.height) doc_size = document.getSize() gc.scale_ctm(self.width/float(doc_size[0]), -self.height/float(doc_size[1])) document.render(gc) def _draw_label(self, gc): with gc: font = Font(family=MODERN) gc.set_font(font) x, y, width, height = gc.get_text_extent(self.label) text_x = self.x + (self.width - width)/2.0 text_y = self.y - height gc.show_text(self.label, (text_x, text_y)) def perform(self): self.callback(*self.callback_args) class ButtonCanvas(Container): def draw(self, gc, view_bounds=None, mode="default"): for component in self.components: component.draw(gc, view_bounds, mode) def add_button(self, button): button.container = self self.components.append(button) class ButtonSelectionTool(BaseTool): """ Listens for double-clicks and tries to open a traits editor on the graph node under the mouse. """ def normal_left_down(self, event): for component in self.component.components: if isinstance(component, CanvasButton) \ and component.is_in(event.x, event.y): component.state = 'down' component.request_redraw() component.perform() break def normal_left_up(self, event): for component in self.component.components: if isinstance(component, CanvasButton): component.state = 'up' component.request_redraw() class ButtonCanvasView(HasTraits): canvas = Instance(Container) traits_view = View(Item('canvas', editor=ComponentEditor(), show_label=False), width=400, height=400, resizable=True) def __init__(self, *args, **kw): super(ButtonCanvasView, self).__init__(*args, **kw) self.add_buttons() def _canvas_default(self): """ default setter for _canvas """ container = ButtonCanvas() container.tools.append(ButtonSelectionTool(component=container)) return container def add_buttons(self): data_dir = os.path.dirname(__file__) self.canvas.add_button(CanvasButton(os.path.join(data_dir, 'edit-copy.svg'), self.do_copy, [], label="Copy", x=150, y=150,)) self.canvas.add_button(CanvasButton(os.path.join(data_dir, 'edit-paste.svg'), self.do_paste, [], label="Paste", x=250, y=150)) def do_copy(self): print "copying something" def do_paste(self): print "pasting something" if __name__ == "__main__": ButtonCanvasView().configure_traits() enthought-chaco2-4.1.0.orig/LICENSE.txt0000644000175000017500000000312011674463635016523 0ustar varunvarunThis software is OSI Certified Open Source Software. OSI Certified is a certification mark of the Open Source Initiative. Copyright (c) 2006, Enthought, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * 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. * Neither the name of Enthought, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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.1.0.orig/docs/0000755000175000017500000000000011674463635015634 5ustar varunvarunenthought-chaco2-4.1.0.orig/docs/source/0000755000175000017500000000000011674463635017134 5ustar varunvarunenthought-chaco2-4.1.0.orig/docs/source/index.rst0000644000175000017500000000017611674463635021001 0ustar varunvarunEnable Documentation ==================== .. toctree:: :maxdepth: 2 enable_concepts.rst kiva.rst * :ref:`search` enthought-chaco2-4.1.0.orig/docs/source/kiva.rst0000644000175000017500000002405211674463635020623 0ustar varunvarunKiva Interface Quick Reference ============================== This document is a summary of the classes and functions available in Kiva. More specifically, it describes some of the details of the kiva.agg backend, including enumerated types and helper classes. Types ----- Primitive types ~~~~~~~~~~~~~~~ The following conventions are used to describe input and output types: :color: Either a 3-tuple or 4-tuple. The represented color depends on the graphics context's pixel format. :rect: (origin_x, origin_y, width, height) :bool: an int that is 1 or 0 :point_array: an array/sequence of length-2 arrays, e.g. ((x,y), (x2,y2),...) :rect_array: an array/sequence of rects ((x,y,w,h), (x2,y2,w2,h2), ...) :color_stop_array: an array/sequence of color stops ((offset,r,g,b,a), (offset2,r2,g2,b2,a2), ...) where offset is some number between 0 and 1 inclusive and the entries are sorted from lowest offset to highest. AffineMatrix ~~~~~~~~~~~~ All of the following member functions modify the instance on which they are called: :__init__(v0, v1, v2, v3, v4, v5): also __init__() :reset(): Sets this matrix to the identity :multiply(`AffineMatrix`): multiples this matrix by another :invert(): sets this matrix to the inverse of itself :flip_x(): mirrors around X :flip_y(): mirrors around Y The rest of the member functions return information about the matrix. :scale() -> float: returns the average scale of this matrix :determinant() -> float: returns the determinant The following factory methods are available in the top-level "agg" namespace to create specific kinds of :class:`AffineMatrix` instances: **translation_matrix(float x, float x)** **rotation_matrix(float angle_in_radians)** **scaling_matrix(float x_scale, float y_scale)** **skewing_matrix(float x_shear, float y_shear)** FontType ~~~~~~~~ :__init__(name, size=12, family=0, style=0): constructs a :class:`FontType` instance :is_loaded() -> bool: returns True if a font was actually loaded CompiledPath ~~~~~~~~~~~~ Interface is the same as the `Path functions`_ in Graphics Context. Enumerations ~~~~~~~~~~~~ The following enumerations are represented by top-level constants in the "agg" namespace. They are fundamentally integers. Some of them also have dicts that map between their names and integer values :line_cap: CAP_BUTT, CAP_ROUND, CAP_SQUARE :line_join: JOIN_ROUND, JOIN_BEVEL, JOIN_MITER :draw_mode: FILL, EOF_FILL, STROKE, FILL_STROKE, EOF_FILL_STROKE :text_style: NORMAL, BOLD, ITALIC :text_draw_mode: TEXT_FILL, TEXT_INVISIBLE (currently unused) :pix_format: (NOTE: the strings in the dicts omit the ``pix_format_`` prefix) - dicts: pix_format_string_map, pix_format_enum_map - values: pix_format_gray8, pix_format_rgb555, pix_format_rgb565, pix_format_rgb24, pix_format_bgr24, pix_format_rgba32, pix_format_argb32, pix_format_abgr32, pix_format_bgra32 :interpolation: - dicts: interp_enum_map, interp_string_map - values: nearest, bilinear, bicubic, spline16, spline36, sinc64, sinc144, sinc256, blackman64, blackman100, blackman256 :marker: (NOTE: the strings in the dicts omit the ``marker_`` prefix) - dicts: marker_string_map, marker_enum_map - values: marker_circle, marker_cross, marker_crossed_circle, marker_dash, marker_diamond, marker_dot, marker_four_rays, marker_pixel, marker_semiellipse_down, marker_semiellipse_left, marker_x, marker_semiellipse_right, marker_semiellipse_up, marker_square, marker_triangle_down, marker_triangle_left, marker_triangle_right, marker_triangle_up path_cmd and path_flags are low-level Agg path attributes. See the Agg documentation for more information about them. We just pass them through in Kiva. :path_cmd: path_cmd_curve3, path_cmd_curve4, path_cmd_end_poly, path_cmd_line_to, path_cmd_mask, path_cmd_move_to, path_cmd_stop :path_flags: path_flags, path_flags_ccw, path_flags_close, path_flags_cw, path_flags_mask, path_flags_none Graphics Context ---------------- Construction ~~~~~~~~~~~~ :__init__(size, pix_format): Size is a tuple (width, height), pix_format is a string. State functions ~~~~~~~~~~~~~~~ :save_state(): :restore_state(): :set_stroke_color(color): :get_stroke_color() -> color: :set_line_width(float): :set_line_join(line_join): :set_line_cap(line_cap): :set_line_dash(array): array is an even-lengthed tuple of floats that represents the width of each dash and gap in the dash pattern. :set_fill_color(color): :get_fill_color() -> color: :linear_gradient(x1, y1, x2, y2, color_stop_array, spread_method, units): spread_method is one of the following strings: pad, reflect, repeat. units is one of the following strings: userSpaceOnUse, objectBoundingBox. This method modifies the current fill pattern. :radial_gradient(cx, cy, r, fx, fy, color_stop_array, spread_method, units): same arguments as linear gradient. The direction of the gradient is from the focus point to the center point. :set_alpha(float): :get_alpha() -> float: :set_antialias(bool): :get_antialias() -> bool: :set_miter_limit(float): :set_flatness(float): :get_image_interpolation() -> interpolation: :set_image_interpolation(interpolation): :translate_ctm(float x, float y): :rotate_ctm(float angle_in_radians): :concat_ctm(`AffineMatrix`_): :scale_ctm(float x_scale, float y_scale): :set_ctm(`AffineMatrix`_): :get_ctm() -> `AffineMatrix`_: Clipping functions ~~~~~~~~~~~~~~~~~~ :clip_to_rect(rect): :clip_to_rects(rect_array): :clip(): clips using the current path :even_odd_clip(): modifies the current clipping path using the even-odd rule to calculate the intersection of the current path and the current clipping path. Path functions ~~~~~~~~~~~~~~ :begin_path(): :close_path(): :get_empty_path() -> `CompiledPath`_: returns a blank :class:`CompiledPath` instance :add_path(`CompiledPath`_): :move_to(x, y): :line_to(x, y): :lines(point_array): :rect(x, y, w, h): :rects(rect_array): :curve_to(x1, y1, x2, y2, end_x, end_y): draws a cubic bezier curve with control points (x1,y1) and (x2,y2) that ends at point (end_x, end_y) :quad_curve_to(cp_x, cp_y, end_x, end_y): draws a quadratic bezier curve from the current point using control point (cp_x, cp_y) and ending at (end_x, end_y) :arc(x, y, radius, start_angle, end_angle, bool cw=false): draws a circular arc of the given radius, centered at (x,y) with angular span as indicated. 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). :arc_to(x1, y1, x2, y2, radius): 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). Drawing functions ~~~~~~~~~~~~~~~~~ :stroke_path(): :fill_path(): :eof_fill_path(): :draw_path(draw_mode=FILL_STROKE): :draw_rect(rect, draw_mode=FILL_STROKE): :draw_marker_at_points(point_array, int size, marker=marker_square): :draw_path_at_points(point_array, `CompiledPath`_, draw_mode): :draw_image(graphics_context img, rect=None): if rect is defined, then img is scaled and drawn into it. Otherwise, img is overlayed exactly on top of this graphics context Text functions ~~~~~~~~~~~~~~ :set_text_drawing_mode(text_draw_mode): :set_text_matrix(`AffineMatrix`_): :get_text_matrix() -> `AffineMatrix`_: :set_text_position(float x, float x): :get_text_position() -> (x, y): :show_text(string): :show_text_translate(string, float y, float y): :get_text_extent(string) -> (x,y,w,h): :get_full_text_extent(string) -> (w,h,x,y): deprecated. Order has been changed for backwards-compatibility with existing Enable. :select_font(name, size, style): :set_font(`FontType`_): :get_font() -> `FontType`_: :set_font_size(int): :set_character_spacing(): :get_character_spacing(): :set_text_drawing_mode(): :show_text_at_point(): Misc functions ~~~~~~~~~~~~~~ :width() -> int: :height() -> int: :stride() -> int: :bottom_up() -> bool: :format() -> pix_format: :flush(): Force all pending drawing operations to be rendered immediately. This only makes sense in window contexts, ie- the Mac Quartz backend. :synchronize(): A deferred version of flush(). Also only relevant in window contexts. :begin_page(): :end_page(): :clear_rect(rect): Clears a rect. Not available in PDF context. :convert_pixel_format(pix_format, bool inplace=0): :save(filename, file_format=None, pil_options=None): Save the GraphicsContext to a file. Output files are always saved in RGB or RGBA format; if this GC is not in one of these formats, it is automatically converted. If filename includes an extension, the image format is inferred from it. file_format is only required if the format can't be inferred from the filename (e.g. if you wanted to save a PNG file as a .dat or .bin). pil_options is a dict of format-specific options that are passed down to the PIL image file writer. If a writer doesn't recognize an option, it is silently ignored. If the image has an alpha channel and the specified output file format does not support alpha, the image is saved in rgb24 format. Functions that are currently stubbed out or not implemented ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :show_glyphs_at_point(): enthought-chaco2-4.1.0.orig/docs/source/enable_key_events.rst0000644000175000017500000001006111674463635023346 0ustar varunvarunEnable Keyboard Events ====================== Previous versions of Enable had just one keyboard event, a 'key_pressed' event. This event conflated which key(s) were physically being pressed with the text which should be generated by that keypress. All the underlying windowing/event systems have a way of distinguishing these two pieces of information, either by issuing separate events for each (Wx, Pyglet, Vtk), or by storing them as different attributes on the event object (Qt). In addition, there was no way to detect a key-up event. This is a comparatively minor use case, but potentially useful for doing things like toggling pointer states to indicate different mouse behaviour when modifiers keys are pressed. New Events ---------- key_pressed: We will keep the 'key_pressed' event. However the semantics will change so that it will keep track of the physical key being pressed rather than the text being entered. Thus pressing the 'a' key with the shift key down will result in an event with the 'character' attribute set to 'a', instead of 'A' as it would be now. The lower-case version of the character will be the canonical representation of the key, since that will cause minimal problems with existing event handlers in Enable and Chaco. The character mapping will be used as it is now to map special keys to standard strings (like right arrow generating the string 'right'). In addition, events will now be generated by pressing modifier keys by themselves (eg. pressing shift will generate an event). Most Chaco code will continue to use key_pressed as the primary event to listen to, it will just work more consistently than it did before. Some code may need to change to reflect the change in what the character attribute returns (XXX or we add a 'key' attribute and deprecate the 'character' attribute). On Wx this event will be generated by EVT_KEY_DOWN, on Qt, this event will be generated by keyPressEvent, but will access the 'key()' attribute rather than the 'text()' attribute. key_released: We will introduce a new 'key_released' event, which is essentially the mirror image of the 'key_pressed' event. On Wx this event will be generated by EVT_KEY_UP, on Qt, this event will be generated by keyReleaseEvent, but will access the 'key()' attribute rather than the 'text()' attribute. character: We will introduce a new 'character' event, which will hold the unicode characters, if any, that are generated by the key press event. It is possible that this event may also be generated by other mechanisms in the future, like pasting text. The event may hold multiple characters. This event will not be generated if the key_pressed event is handled. This is largely because this is the way that wx works, but it also makes a certain amount of sense from an interaction modelling point of view. This will never do key mapping to standard Enable names for non-printable characters: if there is no appropriate unicode representation, no event will be emitted. The handful of Enable widgets which expect actual text input will be changed to use the character event instead of the key_pressed event. On Wx this event will be generated by EVT_CHAR, on Qt, this event will be generated by keyPressEvent, but will access the 'text()' attribute rather than the 'key()' attribute. Why Three Events? ----------------- Qt's two-event model is generally nicer and cleaner, but adapting the other backends to use that model would require holding global state from EVT_KEY_DOWN (or its equivalent) to fold in to the Enable event generated from EVT_CHAR. This seems potentially fragile. The other alternative would be to try to work out from the EVT_KEY_DOWN what text would be generated, and that seems even more fragile. On the other hand, adapting Qt to a 3-event model is straightforward: on keyPressedEvent we generate a 'key_pressed' event, and if text() is non-empty, we subsequently also emit a 'character' event. enthought-chaco2-4.1.0.orig/docs/source/_static/0000755000175000017500000000000011674463635020562 5ustar varunvarunenthought-chaco2-4.1.0.orig/docs/source/_static/default.css0000644000175000017500000003231311674463635022722 0ustar varunvarun/** * Sphinx Doc Design */ body { font-family: 'Verdana', 'Helvetica', 'Arial', sans-serif; font-size: 100%; background-color: #333333; color: #000; margin: 0; padding: 0; } /* :::: LAYOUT :::: */ div.document { background-color: #24326e; } div.documentwrapper { float: left; width: 100%; } div.bodywrapper { margin: 0 0 0 230px; } div.body { background-color: white; padding: 0 20px 30px 20px; } div.sphinxsidebarwrapper { padding: 10px 5px 0 10px; } div.sphinxsidebar { float: left; width: 230px; margin-left: -100%; font-size: 90%; } p.logo { text-align: center; } div.clearer { clear: both; } div.footer { color: #fff; width: 100%; padding: 9px 0 9px 0; text-align: center; font-size: 75%; } div.footer a { color: #fff; text-decoration: underline; } div.related { background-color: #24326e; color: #fff; width: 100%; height: 30px; line-height: 30px; font-size: 90%; } div.related h3 { display: none; } div.related ul { margin: 0; padding: 0 0 0 10px; list-style: none; } div.related li { display: inline; } div.related li.right { float: right; margin-right: 5px; } div.related a { color: white; } /* ::: TOC :::: */ div.sphinxsidebar h3 { font-family: 'Verdana', 'Helvetica', 'Arial', sans-serif; color: #acafb3; font-size: 1.4em; font-weight: normal; margin: 0; padding: 0; } div.sphinxsidebar h4 { font-family: 'Verdana', 'Helvetica', 'Arial', sans-serif; color: #acafb3; font-size: 1.3em; font-weight: normal; margin: 5px 0 0 0; padding: 0; } div.sphinxsidebar p { color: white; } div.sphinxsidebar p.topless { margin: 5px 10px 10px 10px; } div.sphinxsidebar ul { margin: 10px; padding: 0; list-style: none; color: white; } div.sphinxsidebar ul ul, div.sphinxsidebar ul.want-points { margin-left: 20px; list-style: square; } div.sphinxsidebar ul ul { margin-top: 0; margin-bottom: 0; } div.sphinxsidebar a { color: #fff; } div.sphinxsidebar form { margin-top: 10px; } div.sphinxsidebar input { border: 1px solid #9bbde2; font-family: 'Verdana', 'Helvetica', 'Arial', sans-serif; font-size: 1em; } /* :::: MODULE CLOUD :::: */ div.modulecloud { margin: -5px 10px 5px 10px; padding: 10px; line-height: 160%; border: 1px solid #666666; background-color: #dddddd; } div.modulecloud a { padding: 0 5px 0 5px; } /* :::: SEARCH :::: */ ul.search { margin: 10px 0 0 20px; padding: 0; } ul.search li { padding: 5px 0 5px 20px; background-image: url(file.png); background-repeat: no-repeat; background-position: 0 7px; } ul.search li a { font-weight: bold; } ul.search li div.context { color: #666; margin: 2px 0 0 30px; text-align: left; } ul.keywordmatches li.goodmatch a { font-weight: bold; } /* :::: COMMON FORM STYLES :::: */ div.actions { padding: 5px 10px 5px 10px; border-top: 1px solid #598ec0; border-bottom: 1px solid #598ec0; background-color: #9bbde2; } form dl { color: #333; } form dt { clear: both; float: left; min-width: 110px; margin-right: 10px; padding-top: 2px; } input#homepage { display: none; } div.error { margin: 5px 20px 0 0; padding: 5px; border: 1px solid #db7d46; font-weight: bold; } /* :::: INLINE COMMENTS :::: */ div.inlinecomments { position: absolute; right: 20px; } div.inlinecomments a.bubble { display: block; float: right; background-image: url(style/comment.png); background-repeat: no-repeat; width: 25px; height: 25px; text-align: center; padding-top: 3px; font-size: 0.9em; line-height: 14px; font-weight: bold; color: black; } div.inlinecomments a.bubble span { display: none; } div.inlinecomments a.emptybubble { background-image: url(style/nocomment.png); } div.inlinecomments a.bubble:hover { background-image: url(style/hovercomment.png); text-decoration: none; color: #598ec0; } div.inlinecomments div.comments { float: right; margin: 25px 5px 0 0; max-width: 50em; min-width: 30em; border: 1px solid #598ec0; background-color: #9bbde2; z-index: 150; } div#comments { border: 1px solid #598ec0; margin-top: 20px; } div#comments div.nocomments { padding: 10px; font-weight: bold; } div.inlinecomments div.comments h3, div#comments h3 { margin: 0; padding: 0; background-color: #598ec0; color: white; border: none; padding: 3px; } div.inlinecomments div.comments div.actions { padding: 4px; margin: 0; border-top: none; } div#comments div.comment { margin: 10px; border: 1px solid #598ec0; } div.inlinecomments div.comment h4, div.commentwindow div.comment h4, div#comments div.comment h4 { margin: 10px 0 0 0; background-color: #2eabb0; color: white; border: none; padding: 1px 4px 1px 4px; } div#comments div.comment h4 { margin: 0; } div#comments div.comment h4 a { color: #9bbde2; } div.inlinecomments div.comment div.text, div.commentwindow div.comment div.text, div#comments div.comment div.text { margin: -5px 0 -5px 0; padding: 0 10px 0 10px; } div.inlinecomments div.comment div.meta, div.commentwindow div.comment div.meta, div#comments div.comment div.meta { text-align: right; padding: 2px 10px 2px 0; font-size: 95%; color: #598ec0; border-top: 1px solid #598ec0; background-color: #9bbde2; } div.commentwindow { position: absolute; width: 500px; border: 1px solid #598ec0; background-color: #9bbde2; display: none; z-index: 130; } div.commentwindow h3 { margin: 0; background-color: #598ec0; color: white; border: none; padding: 5px; font-size: 1.5em; cursor: pointer; } div.commentwindow div.actions { margin: 10px -10px 0 -10px; padding: 4px 10px 4px 10px; color: #598ec0; } div.commentwindow div.actions input { border: 1px solid #598ec0; background-color: white; color: #073d61; cursor: pointer; } div.commentwindow div.form { padding: 0 10px 0 10px; } div.commentwindow div.form input, div.commentwindow div.form textarea { border: 1px solid #598ec0; background-color: white; color: black; } div.commentwindow div.error { margin: 10px 5px 10px 5px; background-color: #fff2b0; display: none; } div.commentwindow div.form textarea { width: 99%; } div.commentwindow div.preview { margin: 10px 0 10px 0; background-color: ##9bbde2; padding: 0 1px 1px 25px; } div.commentwindow div.preview h4 { margin: 0 0 -5px -20px; padding: 4px 0 0 4px; color: white; font-size: 1.3em; } div.commentwindow div.preview div.comment { background-color: #f2fbfd; } div.commentwindow div.preview div.comment h4 { margin: 10px 0 0 0!important; padding: 1px 4px 1px 4px!important; font-size: 1.2em; } /* :::: SUGGEST CHANGES :::: */ div#suggest-changes-box input, div#suggest-changes-box textarea { border: 1px solid #666; background-color: white; color: black; } div#suggest-changes-box textarea { width: 99%; height: 400px; } /* :::: PREVIEW :::: */ div.preview { background-image: url(style/preview.png); padding: 0 20px 20px 20px; margin-bottom: 30px; } /* :::: INDEX PAGE :::: */ table.contentstable { width: 90%; } table.contentstable p.biglink { line-height: 150%; } a.biglink { font-size: 1.3em; } span.linkdescr { font-style: italic; padding-top: 5px; font-size: 90%; } /* :::: INDEX STYLES :::: */ table.indextable td { text-align: left; vertical-align: top; } table.indextable dl, table.indextable dd { margin-top: 0; margin-bottom: 0; } table.indextable tr.pcap { height: 10px; } table.indextable tr.cap { margin-top: 10px; background-color: #dddddd; } img.toggler { margin-right: 3px; margin-top: 3px; cursor: pointer; } form.pfform { margin: 10px 0 20px 0; } /* :::: GLOBAL STYLES :::: */ .docwarning { background-color: #fff2b0; padding: 10px; margin: 0 -20px 0 -20px; border-bottom: 1px solid #db7d46; } p.subhead { font-weight: bold; margin-top: 20px; } a { color: #24326e; text-decoration: none; } a:hover { text-decoration: underline; } div.body h1, div.body h2, div.body h3, div.body h4, div.body h5, div.body h6 { font-family: 'Verdana', 'Helvetica', 'Arial', sans-serif; background-color: #dddddd; font-weight: normal; color: #073d61; border-bottom: 1px solid #666; margin: 20px -20px 10px -20px; padding: 3px 0 3px 10px; } div.body h1 { margin-top: 0; font-size: 200%; } div.body h2 { font-size: 160%; } div.body h3 { font-size: 140%; } div.body h4 { font-size: 120%; } div.body h5 { font-size: 110%; } div.body h6 { font-size: 100%; } a.headerlink { color: #edaa1e; font-size: 0.8em; padding: 0 4px 0 4px; text-decoration: none; visibility: hidden; } h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, h4:hover > a.headerlink, h5:hover > a.headerlink, h6:hover > a.headerlink, dt:hover > a.headerlink { visibility: visible; } a.headerlink:hover { background-color: #edaa1e; color: white; } div.body p, div.body dd, div.body li { text-align: left; line-height: 130%; } div.body p.caption { text-align: inherit; } div.body td { text-align: left; } ul.fakelist { list-style: none; margin: 10px 0 10px 20px; padding: 0; } .field-list ul { padding-left: 1em; } .first { margin-top: 0 !important; } /* "Footnotes" heading */ p.rubric { margin-top: 30px; font-weight: bold; } /* "Topics" */ div.topic { background-color: #ddd; border: 1px solid #666; padding: 0 7px 0 7px; margin: 10px 0 10px 0; } p.topic-title { font-size: 1.1em; font-weight: bold; margin-top: 10px; } /* Admonitions */ div.admonition { margin-top: 10px; margin-bottom: 10px; padding: 7px; } div.admonition dt { font-weight: bold; } div.admonition dl { margin-bottom: 0; } div.admonition p { display: inline; } div.seealso { background-color: #fff2b0; border: 1px solid #edaa1e; } div.warning { background-color: #fff2b0; border: 1px solid ##db7d46; } div.note { background-color: #eee; border: 1px solid #666; } p.admonition-title { margin: 0px 10px 5px 0px; font-weight: bold; display: inline; } p.admonition-title:after { content: ":"; } div.body p.centered { text-align: center; margin-top: 25px; } table.docutils { border: 0; } table.docutils td, table.docutils th { padding: 1px 8px 1px 0; border-top: 0; border-left: 0; border-right: 0; border-bottom: 1px solid #a9a6a2; } table.field-list td, table.field-list th { border: 0 !important; } table.footnote td, table.footnote th { border: 0 !important; } .field-list ul { margin: 0; padding-left: 1em; } .field-list p { margin: 0; } dl { margin-bottom: 15px; clear: both; } dd p { margin-top: 0px; } dd ul, dd table { margin-bottom: 10px; } dd { margin-top: 3px; margin-bottom: 10px; margin-left: 30px; } .refcount { color: #24326e; } dt:target, .highlight { background-color: #edaa1e1; } dl.glossary dt { font-weight: bold; font-size: 1.1em; } th { text-align: left; padding-right: 5px; } pre { padding: 5px; background-color: #e6f3ff; color: #333; border: 1px solid #24326e; border-left: none; border-right: none; overflow: auto; } td.linenos pre { padding: 5px 0px; border: 0; background-color: transparent; color: #aaa; } table.highlighttable { margin-left: 0.5em; } table.highlighttable td { padding: 0 0.5em 0 0.5em; } tt { background-color: #ddd; padding: 0 1px 0 1px; font-size: 0.95em; } tt.descname { background-color: transparent; font-weight: bold; font-size: 1.2em; } tt.descclassname { background-color: transparent; } tt.xref, a tt { background-color: transparent; font-weight: bold; } .footnote:target { background-color: #fff2b0 } h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { background-color: transparent; } .optional { font-size: 1.3em; } .versionmodified { font-style: italic; } form.comment { margin: 0; padding: 10px 30px 10px 30px; background-color: #ddd; } form.comment h3 { background-color: #598ec0; color: white; margin: -10px -30px 10px -30px; padding: 5px; font-size: 1.4em; } form.comment input, form.comment textarea { border: 1px solid #ddd; padding: 2px; font-family: 'Verdana', 'Helvetica', 'Arial', sans-serif; font-size: 100%; } form.comment input[type="text"] { width: 240px; } form.comment textarea { width: 100%; height: 200px; margin-bottom: 10px; } .system-message { background-color: #edaa1e; padding: 5px; border: 3px solid red; } /* :::: PRINT :::: */ @media print { div.document, div.documentwrapper, div.bodywrapper { margin: 0; width : 100%; } div.sphinxsidebar, div.related, div.footer, div#comments div.new-comment-box, #top-link { display: none; } } enthought-chaco2-4.1.0.orig/docs/source/_static/e-logo-rev.png0000644000175000017500000000751111674463635023250 0ustar varunvarunPNG  IHDRoi*sRGB pHYs  tIMELIDATx]ktT>z\$m ȥ!TD jV|_CWph PT\"B$$6aIf9qfB%= By}; vo`!4ChVv[12 !HGiyg):QVd8SmsQAj2~~AH3qU:?!4[a6SRu ǎ7H'1"_Qq!JbBwx$I-S^QO>AO~( HAPU)=Ojjm+ v$~ئ"33zviJn[*.\v(/E1U`Ycֿ&y3g>=x$;GS@]d1YÓo"۾X6n8o2 ,c_܊U?y" "cdL5HfFj~}Q]H錩/Oxcq'~lӕ_ ţeW\| &cLMhdȶ9-՗ $ Θڳ9i˗>xa6>#E _h2$}앿"a\l߰0/"ޑҦ.*:UQyٕ~`:oYfxu? b)<̜>җ'rYgԾ6ngeSMkm>uv" Snhj ̌ry_ݚLM01@$(]vƏ{_{#&>4l|c.8~rK05bjԈm;14*:Ο3yK|ީT\> 8nd٤B]j맻]8#&[5TEUlu#u\/kk^6t=Zo`Ӌ-,R'*EP1#EQ DfsnlOYYYҨ!${G2yZ~\pN|olӋnϯBu-\$5˘TYgNR^\8gF{@|4Ņ0ov2֊^:j)D"zM En1]WfN@wǛ뿨k B|c!>8T'JԉaZxubOW~;c%dLynظedNSt~WX\f-pO',9UI21`xĥd  ,{ER"Z G 4PLq@$#15! G}\.-2kEfV=G15Q&ph!9Ce Cvj(# 5#GX:InHJZmڞU__(h݆' H7cHκ})"Db-&`i\eU?*YJ05 D S[GabDěrqEʪ9կm"4LwtGTدr{OPۿhj?:}"i b:/7yA@eK#$t13mj51K &^w !%PSSSֆlr{s^#w4DmQI S#3a@57Q; S#:į v4yR+A&P0j/))-&Z4S.[Z2d^!j8J01-j(T!05Q)"jԌ+@vpd"'4LuyC͉cv,@A1i_qLq|s4bvGz!U !KIQD1E3[1vI $00h6FL̙dnu˞?SScw\LGaʃcf-N]y/4u: c c PM18_h>4~h޽f l%&N^>?2=iC)9v!˜j>hN'N~(aİ}Wx+' u0?1sL _/>_nH ! x9zq@bzlLؘO_6Ac6~t=F&מc2\汋rh3.婓Jx`x^_>_mqKkj+-++Y.zw3TU+qܹ~M\_:pBI" D5 JcTubd!P%+~fz*EP]6R2;/uz] g,'Nd=C^n188D,dZ}W/)~ǎ/z~*0P]g*ݐ[{s]b76 $?`[퍘JTDDKŽ t "((}qqwZΦO11fZ XSXk71E~;{GbN#"k" r@4˗mrN"srLڀ?Vh?݁nw'?0l۶`bF4]2UU ;llgL bkx'ۄ&%QU#c*B{awE|DǶBhZ-f/wIENDB`enthought-chaco2-4.1.0.orig/docs/source/_static/et.ico0000644000175000017500000002362611674463635021677 0ustar varunvarun(f 00hvh F00( r5(H73iKD]ZZzols$jV4{H5Fg@Hg @' 9c]sE{c@Ec{bFQEPkG\ 1}m( @_-!p3%7)&[B<]VU~okWU#XW$iU$zu5{j6Yv1GWw"X f$I qJ QJ[JډJc4jJ5{J 1FJ qGI Q#W6 Q$j#XA${#h1IQ$j1< s4{A a5S Q}A\1J7|xp``?`8(0`W,"4(%p3%v>1IGF~QFja_~wtdFwG܆ h즋" ij""!zi"""!g""""ۆ"""""F얋""""""Gzޥ""""""Hi """"" ih s"""""  c"""""! R""""!|2"""!|{2""!|2"1"!5 y@y`"!""" 2""""G s"""""H b"""" i R""""!yR""""!qh2""""0i2""""GR"!z"""""hr"""r"""" """""FB""""#93"""""GB"""""62"""""hp"""""%""""" ht"""""#|"""""!"""""k """""""""""Y s"""""""""8 b"""""""&R"""""%2"""#|2"#k"Y?????( f-t1!j/#i1$n3$j2&r4&s4&s5&u5&]0'`1'^2'u5'v5'v6'x6';+(X2(_2(r4(u6(w7(x7(z7(y8(z8({8(P0)s7)z8){8)|9):*c5,i9-A1.R4.E3/W7/u=1x?2A97>;:{F:F?>{I>mH?DBAMDB~ODJHHOMLhSOQPPPQQSRRUTTaW\YXx_[c[]]]^^^b_^___dddpghhhmhkjijjjrksmnnnrpopppsssuttwwwyyy~{}}}t@4LhO\b$8PraKx_ *?VNdcpI 0M}Wfm:1n{|wFvu2!5yziAUSyxj?]GRryxj>E-BYyzk7l`, %3Jg~Z+DaT)9hzC&6Ooe" [q. *>;'#QX( <H/s=^( @m,6#>%D&K'O(R)P) Y+ q0!2%"`."8'#g1#4($l2%p3%q3%q4%0'&a0&r4&t5&u5&v5&e2'p4't4't5'u5'u6'v6'w6'x6'/)(r6(v6(x7(Y3)z8)v8*l6+2--m:-v;-w>1543Q93v@3lA7vC8;:9wF:><;N?<VA=?>>@??zK@AAAoJAFFF~SHbNIKKKnQKLLLrTMONNPNNZPQQQSRRVVUdXVXWWaWaX[ZZwa\d_^e^i_```iabbbedceedhhhphqh}mipijjjlkkplrlwmoooqpopppxqwrsssyvuwwwyyy{{}}}~~~ŻjjybO =iٙWa"HuihZ!.SWZ% 9bݫXxaBmnczq2 !*NwܐVr-% 3]wt\#%XzF' Dz:  EIv- N}I`')uHYH޾Hn65S|HJ' 9dH<%"DpHs0!.SDe(! ;g9pQ("GuM8b> .Uo0@m~1% KL  *Nwג7%%?4%% 3XжP& +_l,$ =g^/#AT($ ! 1>  )[4 #Ck,1{R(%+_f|xp``?`8(0`<5"=$H&/"S)m-*" -# X+ s0!b."o1"+%#h0#+%$l2$u3$p3%q3%q4%r4%+&&8)&V.&g2&r4&t4&t5&u5&.('O/'t5'u5'v5'u6'v6'q6(v7(y7(o7)}9),+*V2*g4*x9*:.,x;,/..70.C2.z=/211u=1l=2z@3666X?9:::}E:><<PB>~I>AAALAlKCODEEERFIIIUIUJKKK`OKMMMZPRRR\TS^TUUU_WaWYYYs_Zt`[`^^__^g_a``bbaccceeeofhggiiillksknmmpppxptsruuuxvxxxyyy}{y}z{{{|}}}~}~¿ȏՎV)IzEl~zEzEtgzE{=?bzEM+$0LqzE9!$ 8YzE5$CdzEc/$0LtzEW$$ :ZzEG$!Ce|?>$$0Ovo*R}u7$:Zc5 ?ac&!CeD $*JmN$$0R\%$ 4Rxf,! .eF <]v=)6u7!$EeږM'#(Tc-#0Ot׽a+ !AQ$# 8Yvh=$$6jB$ 1!!%Ty7!!!"A`&$6jQ&"%T@$Ay7!$6j`&!%SQ'$A?????enthought-chaco2-4.1.0.orig/docs/source/enable_concepts.rst0000644000175000017500000002745411674463635023026 0ustar varunvarunEnable Concepts =============== This document contains notes from a brain dump session by Peter Wang with Janet Swisher on March 19, 2008. It is notes rather than full explanations, which we hope to add later. Enable Component ---------------- :class:`Component` is the most important object in Enable, the center of everything. It represents a visual component. It both draws a screen object, and receives input for it (keyboard, mouse, and multitouch events). Basic traits of Component include: * :attr:`visible`: Whether it's visible * :attr:`invisible_layout`: Whether it uses space even when not visible (by default, invisible objects don't take up space in layout) Padding ~~~~~~~ Layout in Enable uses padding, similar to CSS. In Chaco, it's used for things around the edges of plot, like labels and tick marks that extend outside the main plot area. * :attr:`fill_padding`: Whether the background color fills the padding area as well as the main area of the component. * :attr:`padding_left` * :attr:`padding_right` * :attr:`padding_top` * :attr:`padding_bottom` * :attr:`padding`: Sets or gets all 4 padding size traits at once * :attr:`hpadding`: Read-only convenience property for the total amount of horizontal padding * :attr:`vpadding`: Read-only convenience property for the total amount of vertical padding * :attr:`padding_accepts_focus`: Whether the component responds to mouse events over the padding area Parent Classes ~~~~~~~~~~~~~~ :class:`Component` subclasses both :class:`CoordinateBox` (for drawing) and :class:`Interactor` (for input). :class:`CoordinateBox` has :attr:`position` and :attr:`bounds` traits, and some secondary attributes for convenience: :attr:`x`, :attr:`y`, :attr:`x2`, :attr:`y2`, :attr:`width`, :attr:`height`. :class:`Interactor` mixes in responses for event types. You can subclass one of these classes if you want only its capabilities. For example, if you want something that doesn't draw but does respond to events, subclass :class:`Interactor` (e.g., a tool). :class:`Interactor` defines common traits for screen interaction, including: * :attr:`pointer`: The cursor shape when the interactor is active * :attr:`event_state`: The object's event state, used for event dispatch Containers ~~~~~~~~~~ All components have a container. They can only have a single container. One component can't be contained by two objects. Whenever you request a component to redraw itself, it actually requests its container to redraw it, and a whole chain goes all the up to the top-level window. Top-level Window ~~~~~~~~~~~~~~~~ A component also has a reference to the top-level window. This window serves as a bridge between the OS and GUI toolkit. The :attr:`window` trait delegates all the way up the containment chain to the top-level component, which has an actual reference to the actual window. The reference to the window is useful because Chaco doesn't make calls directly to the GUI toolkit. Rather, it asks the window to do things for it, such as creating a context menu. Event Dispatch ~~~~~~~~~~~~~~ The key methods of :class:`Interactor` are :meth:`dispatch` and :meth:`\_dispatch_stateful_event`. There's a complex method resolution that occurs beween :class:`Interactor`, :class:`Component`, :class:`Container` (which is a subclass of :class:`Component`), and the Chaco-based subclasses of Enable :class:`Component` and :class:`Container`. When a component gets an event, it tries to handle it in a standard way, which is to dispatch to: 1. its active tool 2. its overlays 3. itself, so that any event handler methods on itself get called 4. its underlays 5. its listener tools That logic is in :class:`Component`, in the :meth:`\_new_dispatch` method, which is called from :meth:`Component.dispatch` (:meth:`\_old_dispatch` will be removed in 3.0). If any of these handlers sets event.handled to True, event propagation stops. If an event gets as far as the listener tools, then all of them get the event. (The notion of an active tool is not used in current code, just older client code. Experience has shown that the notion of a tool promoting itself to be the "active" tool isn't really useful, because usually the tools need to interact with each other. For newer tools, such as Pan, Zoom, or !DragZoom, when the user starts interacting with a tool, that tool calls capture_mouse() at the window level, and then all mouse events go to that tool, circumventing the entire dispatch() mechanism.) The event handlers that :class:`Component` dispatches to are of the form :samp:{event_state}{event_suffix}`, where *event_suffix* corresponds to the actual kind of event that happened, e.g., :obj:`left_down`, :obj:`left_up`, :obj:`left_dclick`, etc. Most objects default to having just a single event state, which is the "normal" event state. To make an Enable component that handled a left-click, you could subclass :class:`Component`, and implement :meth:`normal_left_down` or :meth:`normal_left_up`. The signature for handler methods is just one parameter, which is an event object that is an instance of (a subclass of) :class:`BasicEvent`. Some subclasses of :class:`BasicEvent` include :class:`MouseEvent`, :class:`DragEvent`, :class:`KeyEvent`, and :class:`BlobEvent` (for multitouch). It's fairly easy to extend this event system with new kinds of events and new suffixes (as was done for multitouch). A disadvantage is that you don't necessarily get feedback when you misspell an event handler method name in its definition. (This scheme is difficult to implement when the number of states and events gets large. There's nothing to tell you if you've forgotten to implement one of the possible combinations.) If an interactor transforms an event, then it has to return the full transformation that it applies to the event. When an event comes in, it has a reference to the GUI toolkit window that the event came from. Lots of code calls methods on :obj:`event.window` to get the window to do things, such as set a tooltip or create a context menu. That is the correct thing to do, because it's possible for there to be two windows showing the same underlying component, so responses to events in a window should only happen in that window. When the user generates an event, that event propagates down the containment stack and things happen in response; a draw or update doesn't actually happen until the next :meth:`paint`. By that time, the component no longer has a reference to the event or the event's window; instead it uses its own reference to the window, :obj:`self.window`. Coordinate Systems ~~~~~~~~~~~~~~~~~~ Every component has :attr:`x` and :attr:`y` traits from :class:`CoordinateBox`. These are positions relative to the component's parent container. When a container dispatches events, or loops over its children to draw, it transforms the coordinate system, so that as far as its children are concerned, the events are relative to the lower-left corner of the parent container. Objects don't have to be bounded, but they do have to have an origin. The component is going to give coordinates to the :class:`GraphicsContext` in its own coordinate system, and the container is responsible for offsetting the GC, and setting up the transform correctly. Likewise, when a component gets an event, it expects that event to be in the coordinate system of its parent container. (This introduces some complexity in trying to handle mouse event capture. If a tool or component captures the mouse, the top-level window has no idea what the coordinate system of that object is. It has to be able to ask an event, "give me your total transformation up to this point", and then apply that transformation to all subsequent events. Programmers using Chaco or Enable don't usually have to think about this, but the interactor does have to be able to do it. Containers implement this, so if you're just writing a standard component, you don't have to worry about it.) Viewports ~~~~~~~~~ A component can have a list of viewports, which are views onto the component. Currently, this is used for the canvas, and for geophysical plotting. You could use it for something like a magnifying-glass view of a portion of a component or plot without duplicating it. .. Recording timestamp: (0:23:52) Layout ~~~~~~ Containers are the sizers that do layout. Components within containers can declare that they are resizable, for example, but that doesn't matter if the container they are in doesn't do layout. The basic traits on :class:`Component` for layout are :attr:`resizable`, :attr:`aspect_ratio`, :attr:`auto_center`. For the :attr:`resizable` trait, you can specify which directions the component is resizable in. Components also have lists of overlays and underlays. You can get access to the actual bounds of the component, including its padding with the :samp:`outer_{name}` attributes. Those also take into account the thickness of any border around the component. Rendering ~~~~~~~~~ Every component can have several layers: * background * image (Chaco only, not Enable) * underlay * main layer (the actual component) * overlay These are defined by DEFAULT_DRAWING_ORDER, and stored in the :attr:`drawing_order` trait. Complexity arises when you have multiple components in a container: How do their layers affect each other? Do you want the "overlay" layer of a component to draw on top of all components? Do you want the "background" elements to be behind everything else? This is resolved by the :attr:`unified_draw` trait. If it is False (the default), the corresponding layers of all components are drawn in sequence. The container is responsible for calling the components to draw their layers in the correct sequence. If it is True, then all layers of the component are drawn in strict sequence. The point is the overall sequence at which a component with ``unified_draw==True`` is drawn is determined by its :attr:`draw_layer` trait, which by default is 'mainlayer'. For example, if you want a plot to act as an overlay, you could set ``unified_draw==True`` and ``draw_layer=='overlay'``. These values tell the container to render the component when it gets to the 'overlay' layer. Set :attr:`overlay_border` to True if you want the border to draw as part of the overlay; otherwise it draws as part of the background. By default, the border is drawn just inside the plot area; set :attr:`inset_border` to False to draw it just outside the plot area. Backbuffer ^^^^^^^^^^ A backbuffer provides the ability to render into an offscreen buffer, which is blitted on every draw, until it is invalidated. Various traits such as :attr:`use_backbuffer` and :attr:`backbuffer_padding` control the behavior of the backbuffer. A backbuffer is used for non-OpenGL backends, such as `agg` and on OS X. If :attr:`use_backbuffer` is False, a backbuffer is never used, even if a backbuffer is referenced by a component. Users typically subclass Chaco :class:`PlotComponent`, but may need features from Enable :class:`Component`. Enable Container ---------------- :class:`Container` is a subclass of Enable :class:`Component`. Containers can be nested. Containers are responsible for event dispatch, draw dispatch, and layout. Containers override a lot of Component methods, so that they behave more like containers than plain components do. .. Recording timestamp: (0:43:40) Examples -------- BasicDraw ~~~~~~~~~ Just draws a box. Subclasses :class:`Component`, and implements :meth:`\_draw_mainlayer`. Uses :class:`DemoFrame` and :func:`demo_main` boilerplate code to simplify the example code. BasicMove ~~~~~~~~~ Adds interaction. Has a more complex :meth:`\_draw_mainlayer`; defines an event handler. enthought-chaco2-4.1.0.orig/docs/source/conf.py0000644000175000017500000001304711674463635020440 0ustar varunvarun# -*- coding: utf-8 -*- # # Enable documentation build configuration file, created by # sphinx-quickstart on Mon Jul 21 22:01:37 2008. # # This file is execfile()d with the current directory set to its containing dir. # # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleable (module imports are okay, they're removed automatically). # # All configuration values have a default value; values that are commented out # serve to show the default value. import sys, os # If your extensions are in another directory, add it here. If the directory # is relative to the documentation root, use os.path.abspath to make it # absolute, like shown here. #sys.path.append(os.path.abspath('some/directory')) # General configuration # --------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General substitutions. project = 'enable' copyright = '2008-2011, Enthought' # The default replacements for |version| and |release|, also used in various # other places throughout the built documents. d = {} execfile(os.path.join('..', '..', 'enable', '__init__.py'), d) version = release = d['__version__'] # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build. #unused_docs = [] # List of directories, relative to source directories, that shouldn't be searched # for source files. #exclude_dirs = [] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # Options for HTML output # ----------------------- # The style sheet to use for HTML and HTML Help pages. A file of that name # must exist either in Sphinx' static/ path, or in one of the custom paths # given in html_static_path. html_style = 'default.css' # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (within the static path) to place at the top of # the sidebar. html_logo = "_static/e-logo-rev.png" # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. html_favicon = "et.ico" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_use_modindex = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, the reST sources are included in the HTML build as _sources/. #html_copy_source = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = '' # Output file base name for HTML help builder. htmlhelp_basename = 'Enabledoc' # Options for LaTeX output # ------------------------ # The paper size ('letter' or 'a4'). #latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). #latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, document class [howto/manual]). latex_documents = [ ('index', 'Enable.tex', 'Enable Documentation', 'Enthought', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # Additional stuff for the LaTeX preamble. #latex_preamble = '' # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_use_modindex = True enthought-chaco2-4.1.0.orig/docs/kiva/0000755000175000017500000000000011674463635016566 5ustar varunvarunenthought-chaco2-4.1.0.orig/docs/kiva/agg/0000755000175000017500000000000011674463635017324 5ustar varunvarunenthought-chaco2-4.1.0.orig/docs/kiva/agg/notes0000644000175000017500000001041311674463635020376 0ustar varunvarunnotes: * rename _kiva to _agg * cvs rm freetype/setup.py * build aggcore2d.py * Test graphics_state setting variables. * figure out method for a fast blit to wxPython. * figure out how we are going to (mix in) font stuff def select_font(self,face_name,size=12,style="regular",encoding=None): def set_font(self,font): def set_font_size(self,size): def set_character_spacing(self,spacing): WRAPPER DONE def set_text_drawing_mode(self, mode): WRAPPER DONE def set_text_position(self,x,y): def get_text_position(self): def set_text_matrix(self,ttm): WRAPPER DONE def get_text_matrix(self): def show_text(self,text): def device_show_text(self,text): def show_glyphs(self): def show_text_at_point(self): def show_glyphs_at_point(self): * implement these extra methods def stroke_rect(self,x,y,sx,sy): def stroke_rects(self,rects): def stroke_rect_with_width(self, x,y,sx, sy, width): def fill_rect(self,x,y,sx,sy): def fill_rects(self,rects): def clear_rect(self,x,y,sx,sy): * Should I add this one? def draw_rect(self, x,y,sx,sy, draw_mode) def draw_rects(self, rects, draw_mode) It would be very useful for drawing bar charts. Hmm. Probably a call to fill_rects followed by a draw_rects call would work here because they do not overlap. * Should we put the ptm_stack into another path if it is added with add_path? * expose the enum values. * setting the line_dash is probably more expensive than it should be because it always creates a new vector. We might work on having a way to pass in standard line dash types that have been cached. This is probably not worth the effort now. DONE * Support clipping to a rect. DONE * implement draw_path() DONE * figure why add_path doesn't appear to work correctly (I needed to fix add_path not transform the points in the passed in path_storage) DONE * why am I getting seg faults in some cases. DONE * why do rotations appear to be going the wrong direction? (The lion is just drawn upside down and this was an artifact of me flipping it) DONE 1. implement __del__ shouldn't agg declare destructors as virtual?? DONE 2. implement path additions to paths. DONE 3. Change compiled_path ptm methods to ctm. DONE 6. Clean up file structure kiva aggcore2d.py agg __init__.py compiled_path.py affine_matrix.py graphics_context_bitmap.py src compiled_path.h affine_matrix.h graphics_context_bitmap.h compiled_path_weave.py affine_matrix_weave.py graphics_context_bitmap_weave.py build_wrapper.py Notes on weave and boost: weave: 1. There are to many places that you have to edit code when making wrappers. They are: a. Actual C++ code (classes you are wrapping) b. weave wrapper function definitions c. the shadow class definitions 2. You still have to write way to much boiler plate code. We can fix some of this by refactoring the code, but without a C++ parser and at least a week of work, there isn't a real solution for this. 3. Shadow classes are nice because they allow you to insert code on the Python side of things, but they add quite a bit of call overhead. It would be nice to be able to set up methods that are bound directly to the class and work with the self pointer directly instead of the self.this pointer. This would get rid of the extra call overhead and get us back down to the call speed of boost. Allowing both approaches is nice. 4. You have to work some to make the classes you create safe as far as accepting the correct numeric array sizes etc. This could be fixed by defining an extra class that was recognized by weave that said what needed to be checked: array_check(nothing|typecode|rank|dim0...dimN|exact) 5. There needs to be an easier way to expose enumerated types through weave.enthought-chaco2-4.1.0.orig/docs/kiva/agg/interface.txt0000755000175000017500000002720711674463635022040 0ustar varunvarunKiva Interface Quick Reference (AGG backend) ========================================================================== This document is a summary of the classes and functions available in Kiva. More specifically, it describes some of the details of the kiva.agg backend, including enumerated types and helper classes. ------------------------------------------- Primitive types ------------------------------------------- The following conventions are used to describe input and output types: color: either a 3-tuple or 4-tuple; the represented color depends on the graphics context's pixel format rect: (origin_x, origin_y, width, height) bool: an int that is 1 or 0 affine_matrix: an AffineMatrix instance representing some type of coordinate transform. See /kiva/agg/src/kiva_affine_matrix.h point_array: an array/sequence of length-2 arrays, e.g. ((x,y), (x2,y2),...) rect_array: an array/sequence of rects: ((x,y,w,h), (x2,y2,w2,h2), ...) ------------------------------------------- Supporting types ------------------------------------------- AffineMatrix ------------ (kiva_affine_matrix.h and affine_matrix.i) All of the following member functions modify the instance on which they are called: __init__(v0, v1, v2, v3, v4, v5) or __init__() reset() # sets this matrix to the identity multiply(AffineMatrix) # multiples this matrix by another invert() # sets this matrix to the inverse of itself flip_x() # mirrors around X flip_y() # mirrors around Y scale() -> float # returns the average scale of this matrix determinant() -> float # returns the determinant The following factory methods are available in the top-level "agg" namespace to create specific kinds of AffineMatrix instances: translation_matrix(float X, float Y) rotation_matrix(float angle_in_radians) scaling_matrix(float x_scale, float y_scale) skewing_matrix(float x_shear, float y_shear) FontType ------------ (kiva_font_type.h and font_type.i) __init__(name, size=12) CompiledPath ------------ see kiva_compiled_path.h in /kiva/agg/src/; interface is very similar to "Path drawing" interface of Graphics Context ------------------------------------------- Enumerations - see also /kiva/agg/src/kiva_constants.h ------------------------------------------- The following enumerations are represented by top-level constants in the "agg" namespace. They are fundamentally integers. Some of them also have dicts that map between their names and integer values line_cap: CAP_BUTT, CAP_ROUND, CAP_SQUARE line_join: JOIN_ROUND, JOIN_BEVEL, JOIN_MITER draw_mode: FILL, EOF_FILL, STROKE, FILL_STROKE, EOF_FILL_STROKE text_style: NORMAL, BOLD, ITALIC text_draw_mode: TEXT_FILL, TEXT_INVISIBLE [this is currently unused] pix_format: dicts: pix_format_string_map, pix_format_enum_map values: pix_format_gray8, pix_format_rgb555, pix_format_rgb565, pix_format_rgb24, pix_format_bgr24, pix_format_rgba32, pix_format_argb32, pix_format_abgr32, pix_format_bgra32 (NOTE: the strings in the dicts omit the "pix_format_" prefix) interpolation: dicts: interp_enum_map, interp_string_map values: nearest, bilinear, bicubic, spline16, spline36, sinc64, sinc144, sinc256, blackman64, blackman100, blackman256 marker: dicts: marker_string_map, marker_enum_map values: marker_circle, marker_cross, marker_crossed_circle, marker_dash, marker_diamond, marker_dot, marker_four_rays, marker_pixel, marker_semiellipse_down, marker_semiellipse_left, marker_x, marker_semiellipse_right, marker_semiellipse_up, marker_square, marker_triangle_down, marker_triangle_left, marker_triangle_right, marker_triangle_up (NOTE: the strings in the dicts omit the "marker_" prefix) Path_cmd and path_flags are low-level Agg path attributes. See the Agg documentation for more information about them. We just pass them through in Kiva. path_cmd: path_cmd_curve3, path_cmd_curve4, path_cmd_end_poly, path_cmd_line_to path_cmd_mask, path_cmd_move_to, path_cmd_stop path_flags: path_flags, path_flags_ccw, path_flags_close, path_flags_cw, path_flags_mask, path_flags_none ************************************************* *** Graphics Context Reference *** ************************************************* ------------------------------------------- Construction ------------------------------------------- GraphicsContextArray(size, pix_format="rgba32") # size is a tuple (width, height) Image(filename) ------------------------------------------- Graphics state ------------------------------------------- save_state() restore_state() set_stroke_color(color) get_stroke_color() -> color set_line_width(float) set_line_join(line_join) set_line_cap(line_cap) set_line_dash(array) # array is an even-lengthed tuple of floats that represents # the width of each dash and gap in the dash pattern. set_fill_color(color) get_fill_color() -> color linear_gradient(x1, y1, x2, y2, stops, spread_method, units) radial_gradient(cx, cy, r, fx, fy, stops, spread_method, units) # The gradient methods modify the current fill color set_alpha(float) get_alpha() -> float set_antialias(bool) get_antialias() -> bool set_miter_limit(float) set_flatness(float) get_image_interpolation() -> interpolation set_image_interpolation(interpolation) translate_ctm(float x, float y) rotate_ctm(float angle_in_radians) concat_ctm(AffineMatrix) scale_ctm(float x_scale, float y_scale) set_ctm(AffineMatrix) get_ctm() -> AffineMatrix ------------------------------------------- Clipping functions ------------------------------------------- clip_to_rect(rect) clip_to_rects(rect_array) clip() # clips using the current path even_odd_clip() # modifies the current clipping path using the even-odd rule to # calculate the intersection of the current path and the current # clipping path. ------------------------------------------- Path construction functions ------------------------------------------- # All coordinates below are floating-point begin_path() close_path() get_empty_path() -> CompiledPath # returns a blank CompiledPath instance add_path(CompiledPath) move_to(x, y) line_to(x, y) lines(point_array) rect(x, y, w, h) rects(rect_array) curve_to(x1, y1, x2, y2, end_x, end_y) # draws a cubic bezier curve with control points (x1,y1) and (x2,y2) # that ends at point (end_x, end_y) quad_curve_to(cp_x, cp_y, end_x, end_y) # draws a quadratic bezier curve from the current point using # control point (cp_x, cp_y) and ending at (end_x, end_y) arc(x, y, radius, start_angle, end_angle, bool cw=false) # draws a circular arc of the given radius, centered at (x,y) # with angular span as indicated. 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). arc_to(x1, y1, x2, y2, radius) # from the comments in kiva_graphics_context_base.h: # 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). ------------------------------------------- Drawing functions ------------------------------------------- stroke_path() fill_path() eof_fill_path() draw_path(draw_mode=FILL_STROKE) draw_rect(rect, draw_mode=FILL_STROKE) draw_marker_at_points(point_array, int size, marker=marker_square) draw_path_at_points(point_array, CompiledPath, draw_mode) draw_image(graphics_context img, rect=None) # if rect is defined, then img is scaled and drawn into it; # otherwise, img is overlayed exactly on top of this graphics context ------------------------------------------- Text functions ------------------------------------------- set_text_drawing_mode(text_draw_mode) set_text_matrix(AffineMatrix) get_text_matrix() -> AffineMatrix set_text_position(float X, float Y) get_text_position() -> (X, Y) show_text(string) show_text_translate(string, float X, float Y) get_text_extent(string) -> (x,y,w,h) get_full_text_extent(string) -> (w,h,x,y) # deprecated; order has been changed for backwards-compatibility # with existing Enable select_font(name, size, style) set_font(FontType) get_font() -> FontType set_font_size(int) set_character_spacing() get_character_spacing() set_text_drawing_mode() show_text_at_point() ------------------------------------------- Misc functions ------------------------------------------- width() -> int height() -> int stride() -> int bottom_up() -> bool format() -> pix_format flush() # Force all pending drawing operations to be rendered immediately. # This only makes sense in window contexts, ie- the Mac Quartz backend. synchronize() # A deferred version of flush(). Also only relevant in window contexts. begin_page() end_page() clear_rect(rect) # Clears a rect. Not available in PDF context. convert_pixel_format(pix_format, bool inplace=0) save(filename, file_format=None, pil_options=None) # From the comments in graphics_context.i: # Save the GraphicsContext to a file. Output files are always # saved in RGB or RGBA format; if this GC is not in one of # these formats, it is automatically converted. # # If filename includes an extension, the image format is # inferred from it. file_format is only required if the # format can't be inferred from the filename (e.g. if you # wanted to save a PNG file as a .dat or .bin). # # pil_options is a dict of format-specific options that # are passed down to the PIL image file writer. If a writer # doesn't recognize an option, it is silently ignored. # # If the image has an alpha channel and the specified output # file format does not support alpha, the image is saved in # rgb24 format. ------------------------------------------- Functions that are currently stubbed out or not implemented ------------------------------------------- show_glyphs_at_point() enthought-chaco2-4.1.0.orig/docs/kiva/agg/antigrain_notes.doc0000644000175000017500000027600011674463635023204 0ustar varunvarunࡱ> E@ <bjbj "^26J111141LJL,2:X2X2X2X2k3k3k3YL[L[L[L[L[L[L$NRXPLk3g3k3k3k3LX2X2LEEEk3t X2X2YLEk3YLEEE:J,uKX22 U1>K YLL0L#KRPDPuKJJPZuKk3k3Ek3k3k3k3k3LLJJD"E(JJ"Anti-grain library notes. agg::rendering_buffer Before drawing anything, you must create a memory buffer to store the image you are drawing. There isn't anything fancy about the memory -- it can just be a raw memory buffer. However, agg requires you to attach this buffer to a class called agg::rendering_buffer found in agg_rendering_buffer.h that it uses in all of its rendering operations. There are some decent notes in the header about the nuances of the class. Most of the time, youll just use the attach method of the class: void attach(unsigned char* buf, unsigned width, unsigned height, int row_bytes); Allocating and deallocating buf is the users responsibility. Width and height specify the size of the image space you are drawing into. The argument row_bytes is used because in reality the row length in bytes does not obligatory correspond with the width of the image in pixels, i.e. it cannot be simply calculated as width_in_pixels * bytes_per_pixel. For example, it must be aligned to 4 bytes in Windows bitmaps. Besides, the value of row_bytes can be negative - it depends on the order of displaying the rendering buffer - from top to bottom or from bottom to top. In other words, if row_bytes > 0 the pointers to each row will start from the beginning of the buffer and increase. If it < 0, the pointers start from the end of the buffer and decrease. It gives you an additional degree of freedom. Method attach() can be called more than once. The execution time of it is very little. Example The following code illustrates how to connect an agg::rendering_buffer to a Numeric array using weave: # from Numeric import * import weave import os from glob import glob agg_path = "C:/wrk/agg2" agg_src = glob(os.path.join(agg_path,'src','*.cpp')) agg_include_dirs = [os.path.join(agg_path,'include')] agg_headers = [ '"agg_rendering_buffer.h"'] code = """ agg::rendering_buffer buf; buf.attach(ary, Nary[1], Nary[0], Nary[1]*Nary[2]); """ ary = zeros((4,4,3),typecode=UInt8) weave.inline(code,['ary'], sources = agg_src, headers = agg_headers, include_dirs = agg_include_dirs) # Note that we defined the array to have a typecode of UInt8 because anti-grain expects an unsigned char* array as the buffer. agg::renderer_xxx_yyy One of the Anti-grain renderer classes is in charge of drawing to an agg::rendering_buffer. There are a number of different rendering classes to support the various image pixel layouts possible such as rgb24, bgr24, rgba32, abgr32, etc. There are quite a view other variations supported. Renderers can also be either solid or gourmand. So, to render to a 32 bit image with red, green, blue, alpha pixels using a solid renderer, the renderer class to use is agg::renderer_bgra32_solid. Note that the layout of the memory buffer in the agg::rendering_buffer used should match that expected by the renderer class. Example # from Numeric import * import weave from agg_info import agg_build_info code = """ agg::rendering_buffer buf; width height row_bytes buf.attach(ary, Nary[1], Nary[0], Nary[1]*Nary[2]); agg::renderer_bgra32_solid rr(buf); agg::renderer_util util(buf); util.clear(agg::rgba(1.0,1.0,1.0)); """ ary = zeros((4,4,4),typecode=UInt8) weave.inline(code,['ary'], **agg_build_info) desired = ones((4,4,4),typecode=UInt8) * 255 desired[:,:,3] = 255 # set alpha plane. assert(ary == desired) # agg::path_storage Antigrain separates out the ideas of storage for the vertices in a path and the conversion of the vertices to something the rasterizer can render into a rendering_buffer. The agg::path_storage class has methods such as move_to, line_to, curve3, curve4, add_path, and add_poly for building a list of commands that define a path to be drawn. These guys are sorta like display lists in OpenGL in that you can build them once and save them for later execution. The following several paragraphs are extracted directly from the antigrain code comments in agg_path_storage.h. Before rendering we must collect and store the necessary number of vertices. There are different approaches that can be used such as a simple buffer in memory. But we also may want to perform different kinds of conversions, for example, affine transformations, clipping, making an outline, calculation of Minkowski sum, and so on. Many graphic libraries do that, but the sequence of these conversions is often hard coded, i.e., there's a number of settings such as set_rotate(), set_clip_box(), etc, which can be used or omitted, but anyway a particular vertex suffers all these conversions in the strictly defined order. Another approach is based on a number of functions or classes each of which performs only one kind of conversion (in fact, this is how the first approach looks inside). In this case we usually have to store intermediate results as vertex arrays or something on each step of the conversion. AGG allows you to construct any custom pipelines, but at the same time does not require the use of any intermediate storages. Not possible? Yes, it is possible with some exceptions which are not painful. A concept of rendering assumes creating a rasterizer object, then adding vertices into it, and finally render the filled polygon. The rasterizer has template method add_path which takes an abstract vertex source and "asks" it to give vertices one by one. This storage must support the interface of two methods: rewind() and vertex(). The latest method gives the rasterizer one vertex from the vertex source and returns special flag. When all vertices are given, method vertex() returns pathflag_stop. Such a concept allows you to avoid storing vertices anywhere, in case, for example, if you know the analytical representation of your figure and calculate vertices on demand. For example, we can easily write a class that produces a sine wave, but does not use any arrays. This class can be used as a source of vertices either directly or via some intermediate converters. The examples of such kind of classes you can find in file agg_curves.h. The main conclusion of it is: Any class that supports interface of two mentioned above methods can be used as a vertex source. There are two kinds of these classes - initial sources and intermediate converters. The latest require a pointer to a preceding source when being constructed. All these classes have prefix conv_. Classes path_storage, curve3, curve4 can be only initial sources. All converter classes are template ones, all initial sources are usually regular ones. Template mechanism are used because it gives us more freedom. All the vertex source class need to have is a two-method interface. These classes don't have to be derived from any particular base class, and, besides, it allows us to avoid using virtual calls which works much slower than regular calls (They make the processor pipeline to resynchronize because they are doubly indirect. BTW, pure C indirect calls, via a pointer to a function work almost as fast as direct ones, because they have only one level of indirection). Still, sometimes we have to use converters that have one common base class and their interface methods are virtual. There is such base class called pipe_conv. See agg_pipe_conv.h for details. In fact there's only wrappers that turn interface function into virtual. Every vertex source class has this wrapper. Filled Polygon Example If you render an agg::path_storage directly using a rasterizer, itll render a filled region. The following code renders a filled sine wave. If the last point isnt the same as the first one, it is automatically closed. # from Numeric import * import weave from agg_info import agg_build_info import windows_bmp code = """ agg::rendering_buffer buf; // width height row_bytes buf.attach(ary, Nary[1], Nary[0], Nary[1]*Nary[2]); agg::renderer_rgba32_solid ren(buf); agg::rasterizer ras; agg::renderer_util util(buf); agg::path_storage ps; util.clear(agg::rgba(1.0,1.0,1.0)); ps.remove_all(); ps.move_to(pts[0],pts[0+1]); for(int i=2; i < Npts[0]*2; i+=2) ps.line_to(pts[i],pts[i+1]); ras.add_path(ps); ren.attribute(agg::rgba(0.5,0.5,0.5,0.5)); ras.render(ren); """ M,N = 1000,1000 ary = zeros((M,N,4),typecode=UInt8) x = arange(0,2*pi,2*pi/P) y = (sin(x)+1)*M/2. pts = transpose(array((arange(len(x)),y))).copy() weave.inline(code,['ary','pts'], **agg_build_info) windows_bmp.write_bmp_24("draw_poly.bmp",ary) #  Figure  SEQ Figure \* ARABIC 1: A filled sinusoid generated by example . Line Example To render the outline of path instead of a filled polygon, you must convert the path using a agg::conv_polyline or an agg::conv_polygon class. Both classes render an outline, but the second will close the path automatically even if the end points of the path are not the same point. If you render an agg::path_storage directly using a rasterizer, itll render a filled region. The following code renders a filled sine wave. If the last point isnt the same as the first one, it is automatically closed. # from Numeric import * import weave from agg_info import agg_build_info import windows_bmp code = """ agg::rendering_buffer buf; // width height row_bytes buf.attach(ary, Nary[1], Nary[0], Nary[1]*Nary[2]); agg::renderer_rgba32_solid ren(buf); agg::rasterizer ras; agg::renderer_util util(buf); agg::path_storage ps; agg::conv_polyline path(ps); path.thickness(4.0); util.clear(agg::rgba(1.0,1.0,1.0)); ps.remove_all(); ps.move_to(pts[0],pts[0+1]); for(int i=2; i < Npts[0]*2; i+=2) ps.line_to(pts[i],pts[i+1]); ras.add_path(path); ren.attribute(agg::rgba(0.5,0.5,0.5,0.5)); ras.render(ren); """ M,N = 1000,1000 ary = zeros((M,N,4),typecode=UInt8) x = arange(0,2*pi,2*pi/P) y = (sin(x)+1)*M/2. pts = transpose(array((arange(len(x)),y))).copy() weave.inline(code,['ary','pts'], **agg_build_info) windows_bmp.write_bmp_24("draw_poly.bmp",ary) #  Figure  SEQ Figure \* ARABIC 1: Sinusoidal line generated by example . And the following slightly modified code will automatically closed path: # from Numeric import * import weave from agg_info import agg_build_info import windows_bmp code = """ agg::rendering_buffer buf; // width height row_bytes buf.attach(ary, Nary[1], Nary[0], Nary[1]*Nary[2]); agg::renderer_rgba32_solid ren(buf); agg::rasterizer ras; agg::renderer_util util(buf); agg::path_storage ps; agg::conv_polygon path(ps); path.thickness(4.0); util.clear(agg::rgba(1.0,1.0,1.0)); ps.remove_all(); ps.move_to(pts[0],pts[0+1]); for(int i=2; i < Npts[0]*2; i+=2) ps.line_to(pts[i],pts[i+1]); ras.add_path(path); ren.attribute(agg::rgba(0.5,0.5,0.5,0.5)); ras.render(ren); """ M,N = 1000,1000 ary = zeros((M,N,4),typecode=UInt8) x = arange(0,2*pi,2*pi/P) y = (sin(x)+1)*M/2. pts = transpose(array((arange(len(x)),y))).copy() weave.inline(code,['ary','pts'], **agg_build_info) windows_bmp.write_bmp_24("draw_poly.bmp",ary)  Figure  SEQ Figure \* ARABIC 1: Sinusoidal polygon outline generated by example . Constructing a kiva::path Notes: When testing the construction of rendering a path, it looks like about 33% of the time is in the path construction and 66% is in the actual rendering. We can therefore save 33% of the time if we can construct a path once and use it in any future re-draws. Also, I believe rendering aliased lines can cut the rendering time by at least 50%, so we have the potential to speed the rendering of lines up by a factor of 3.?? Questions: How do you turn off anti-aliasing during rendering? If we turn off anti-aliasing, will it speed up the rendering of lines? Creating paths with more than (approx) 32000 line_to calls causes a seg-fault. Should this be more graceful? Shouldnt the path_storage destructor be virtual? I need to think about rendering to a non-contiguous array, but that should be fairly easy also by specifying the correct row_bytes size. This will be important when rendering to a sub-section of an image. They should all be enumerated. Im not sure about the difference here. It should be discussed though. Why cant the renderer just have a clear() method? This seems cleaner than having to generate another object to do it. Note the absence of coordinate transforms in this list, so it doesnt support the PDF notion of having coordinate transforms impeded between path commands. We will have to add this in a kiva::path_stoarge object or something like that. 23) > H ^      ? K 2 ; U _ #STiov|_f )67Lӵӵӵӵ۪ha%*ha%*0J ha%*0Jha%* h chw$h+ghw$h57h!]h!]0Jh!]h c0Jh!]hE h ch c h c0Jh ch c0J h/#h/#h/#h c=23  ? \ y #gd!]gd[gd cgd/#gd/#gd c:<'] :hNOefgdEjgd[gd/#gd cgd+ggd!]LMNOef|168=?EGHM5:O)*bc!78@ҺҺҺҳүh1k h'jhra0J<OJQJUhB_h& hEjh[ huhu hu0Jhuhu0JhuhO0Jhu hO0JhO h/#0Jh/# ha%*0Jha%*jhu0J<U6)*5W8kv{!8ABTU(gdgd/#gdYgd/#gd cgd& gdEj@ABTU3:<CEKMSU]ck$q~56htv/7<Dÿùòîîh h0Jh h/h0Jh/h hUdZh/# hUdZ0Jh1 hUdZjhg;0J<U hg;0Jhg; h/#h/# h/#0J hYhYh/#hu h chEj:() 3"4"$$%%%%&&&&&'+','7'Y''''gdNgd[gd V gdgd[gdS] +!4!!!!!!"" """""""0%9%?%N%%%%%%%% & &&&'*'+'***************ʺh !hU!CJmHnHujh !hU!CJUh !hU!CJ h !CJhlNjhU!Uh7hfzhNh V hh h0JhhhIh[h h0Jh h7' (8(o((((((()P)t)))))) *'*;*m*******/+^gd !$a$gdU!gdN*.+/+<+=++++++m,~,:-;-.P/X/`/0401111111111111111116666구}yph !h!CJh!jah!U h3 CJ h +CJh !h3 CJmHnHujh !h3 CJUh !h3 CJh3 j)h3 Uhfzhq: hhYc) hYc)hYc) hYc)0JhYc)hYc)0JhhYc)h !hU!CJh !h7CJ)/+<+=+:-;-C-Y-f-------'.P.|....5/Q/Y/////0gdq:gdYc)gdYc)gdYc)0B0t0000000 1;1n1111111D2E2M2c2p22222gdfz^gd3 gdYc)$a$gdYgdYc)22313Z33334>4Z4b44444%5K5}55555556D6w666gdfz6666 77(7)70788889^99:::8;;<<< & Fgd/#gd c & Fgd %gd+Pzgd/#^gd!$a$gdYgdYc)6666666666 77'7(7)7888^99999::::::8;9;;;<<¾´°jh90JU huh9h9 h %0Jh#&Ih/#h %h!h+Pz hYc)h! h!CJh !h!CJmHnHuh !h!CJjh !h!CJU" 1h/ =!"#$%)Dd::d  C ,Adraw_poly#" `bG)('#r迵~{rY@kLiţƧ?٢GۻfGh\ч>Ce>?Qib^=&{μ=#/46 |÷X i=pKЖBbQCC~({#ô?Qfbߌ ZBlQ#cr0^n9A!_-*/="#E8,*3uE{ `k±iAM;Y.*|b\zN-ޤ:t ;W:BoiM[#朌;13 dzEf}ˆ "ڵ5[s#BYkݤ7\z̛^ghȹAuh* q2U4f :(–3Q+dC[/nzzv(vBx{;Wp΋brJ!t^WcGЫqxoz5vB(lCЫNEbz #\~izWMG襛1F\u^x*Ч4bE1jzy(LB/\ϝ%^ZŚz9(B/i 0!ᵞyQ`'Їq6;BF ;?}Az/"6,΋♑B胹\'U[E"< W?ك`o&gLBb\żB蓸>0V?'u^|'q>C؍쓸>sh:BHS{9O΋b̑g9>ql29u^o 9;W㻦 C?˫6uz{)ЗƎBOІ\;r =fO) ΋ܑY虼;oY9v^B_3GN:˯BVyQ< }o.ل-΋K=`&D% [$LNgS[#l6s-";/#Ggw!}X;͐Am7͐|譌nN3΋xd^i2zoI:Mw8DC\9qC_@ =%Z:E}1$~xeI5t߭Y~6 wk |3~6 {k1$z'?i$\Ӽ1$wosB!>+͚C =6 }EwY1֪ﲺeI(tÖR$w F;RyiI%#=,H|gf4Bo~3vx'?!vx'П!P&8OB#R~؈i$ǥCH_)1WƑCwH(Ck|G(>#}w>뉏:tqz8"Gq*՞yYxCjN+#{i뇽4sQ[㭡$OڗSI;AONV%[cϘU/w;cIt_ƒBߛn&%K" }A[0j`Uvyȼ$m-3>U_4;SkKI<(vP'FhB>B4{epl!Я:kI$oupf8B>&v 'QZ$<G(Eg3[!RkI:%_~JM" ? &/чtݗ%U:K*C%z)|Nءo (!Kr*C&zINȡ{$J'$Z9nW -'#Jν4kFPC?gyN(MfF 4Yyg֌fD/Յ!%Н^CJgY)%oYSJOJ\+B߳T&)Qen=7.wjN ,uYoݜX˲,߲9%п %=Z T` *MVc$1X Uq*n\U ,*ȪnU L93¬FjgJc^VB$*-L+A`Z E)Vk޴|q)Vk+l4*6݋k04ת6ɼp/eXfC?Z V ,:X ݉kxe`i2t')l4j`Ǭ+.FB&<34-'c  ݖ5M~Bo9+F34t`hi$MiDsܡϵWSKOJ^+CY\lG,v no-ugڭ[jdW5sKo[ZCV] .DtM3n:C&f:C_\3^\ R[oהuKm;1l GPW֜fB[s.~&]^j ؚRGVl%tG+6饆G֬K֬)kwZiM6TКt*ݡsT:Ng{g~8i5oRmq5om4Si" Э`Nh, ;& CrĦ s Ü;Յ~Pa* }C`0T{00nkw }E^vЭCbNE+$熘JBrʊ!ЭbN%[ڝ*Br;~8!XSAVvЭ܃cN[ڝCr;en kwJ=D{)7t+ YSjs;n(kw =P{)1tB܃eHJ =\{)+t+YSRP sU))5l0SJb ٦ab ٸ;en8kw=pӦCr;%~g}ZHvg[3B L<3dtw!C_Q3Ånkw ZE16 b0o&֔b0e0P>h}DBq1 zkIBqXvgп*(_4T@xf81bH3h{3̀O<^i }Y>X6 zbri(7C@ϊ'&AB|6 tT3@/C?UNlN5}~&؜kpbXo'ωe}sM?M|k }kU6Y=6G_&F/ 6g=M_i&NW&>BLFM6;!8Mmzbbhs蓂ՊѦܣ5wh1lcrצ٦rxpSjفᦧЧEM/f馇ЯkMK%n#CoMI%nS<WП %vό7>&؍o N|Hod7GBIf7Y%)ly0o"I7΃I p T#i81<DҰmy t%'<BReĹ7t%'Òe ap2Idƹ't%'dҌsw\KɄCظ;suܐsg\Kʆ!sHɜCظ+tG%!l#6ݑkqwȵ8CFj_%kw B0B㟟"=͹eYgٜ TE q])Z7B  WnHԩI/$&9W$W&]?9!YrOnH t9A?8!arwrH7ABύRvc؅mvwŐq9 {gڅE)ABWkJ ioo?(!uo !uOoDŽ1.:H{}od7=ge{G*HA?&ׄгtmAY"S^fZBӴɢ2e=SIg0Ɇl*<;#B֮C;1+|9+c)kfJ;vTv&V5 aV9ۗ@ Dy{<z޾ ߄#H蹳w-|A={N{g|䍵lgRA 6y3-s{(- &@ 6uma3ؤm &Ft 6aB&吮[䐮OB?{6M RV|Q(t~DOWB3Ii[Ti::ZD^ _"EB7HѥMkYYn =Ez^ }Ez.ZSHRKiD:Fj_rHLKmZi:ۑFZ䐖йq+t ;:!!BnHйIA9$йQA:sC" mK$ BrHĩy ŭyM!Xaйϼb0:Q PZ3* Lo+wsEoǛ)tNF{'tQBgXB tR@H;:Cv]+wM)m[)t#WB!b Y+w1yȡ{N9Ǎ:v؍){Y *T܅~VBa D?+wk@uìu.tJdVB1Ao.tcVB1!s.te>WBQs.te~WBqw.tg~WBq{.tz`WB{.tz`WBA.tzaWB!.tzbnr3 :{8Y 8)܅No݃1]=܅N9:ّXvNAo *m,܅NDSʚ7]lZf͛ ^Y gtִWBwBkNZhM:kM)YS-Sy5kd['tzAj tjZZ^ ~<[~NIB15gl357Nܚ^Ԥ,r:y# |\S> ,( C6ӟok7SS5Td&t-&l Zm [B^UW!oGЩz,tVxu{;=:}$}:۝P^&vN&Wɡo߹u.tp8: &lN13@4QuPt3$-h&t}( A8n>Kn#[j%tȖ\ ƴfX2VBg@z)K H8-v ʹ[Bg@"þiԖj0fqBgH/eX%,3+VSI7K q~83!Vm{%tv#ĪƵǕXvYJ nQZ,V ~bJUBgpV)[N~R˻SBgbeywJ cAY(F aɱ:gB''rΉ ŚV}:C [eN0V^\:% [EVJMBg8;NI ՘izΐ\rWQV JkY[n{ΰVoS*pZM:C{˲* }f> 9d{B'<,dH I%:rCۥ"Sj;$tJp!2] y Le?*tMV :e8gyNN[*)`KIne)wWSMc#tN:k-i KJn)ku5wGĎR8:aT ^UtsNY(UN|>n)͆PQս:9 ൦:VUFWCz]٭:,|:1UP^UwgN0y+}ռ.t!lVxcN> o)SkLkUxcNvPUSSTzYm:$|:9tV@NL>j)rQ]:%k- j)۶l_M:e;^mV*)Bt+JDΛ-}{W=:sbZUSug["tw"n?VGNۏz{7:qz&=*8GB'V۫uS ЉfzU2BR#H-CTR½:1srO^s7NED܋+9?n!tbt3NUq5 S':~̫ЩuU׽:tcB:{HmBTqV y:ABB^V}ЧЩС0sXߝ:Uwx#N|oЩK=eATF>J}vATɪX6jmj.[B'%+JwATZw:Iiͪo-}Ym tk;ؿ /uS9O{ t?~ NΥs ܅N]<Щz,tҴ)6BB$4qN-,߰}7n z?\~S[J_[H k/tjfЩ3/tքNK:_j7tNm΄~Ե:ٛȽ=wo hޝ6wN2?+/tjzs/Z]yS_K:uv^[k Ze{jsH]4WONNV }٫.tjN3^uS,OKE:u1l~϶BvW~5:9F~: n/Щx^ +_qӀ8:yj?.iiF(7:iF>opN#. R+-GB_s ZqNCuW[4$_5~iXP4iZiyrNcSN`.iNk9Η.tq¹BAiJiT;? ]4x:HWzHЅN/tӰd?xiXi^DžP AO C/ښ D F[vNZRR YWao<;K#0 R / ĦRam %t“*t-"t6GB'?ïB'8q>:9cC/~jf; +tBQla&tBvo;!_WVǽ YXb 58CU:ٛ0_C:'ЯB'4'u$ON"qB'Q|WB'h1l62B'sw>w˵:=h. Wy؝?e.tv4rG\I,܅NZkv].O]/=acyTFĠ5f1-܅N@n&g܅N,vB =SN|>k(tw8ZQ*#trr1l)t1?wNZ!u>7kB'{m ;LB'RɩB'^_ЅN4Zat_ЅN<6}!oЅN\xcu.MeNx=G܅N֛|=K'ts31>)#t⳻q^9w: |mE1_7B? |k󳸯ЉL]Yz_EŚЉa퇬> wv"/ЅN|9N*NjZj$ &ttTWKQ*tr4UOS.t[B'kX/%ҹЉi埽/'sj;_JR W1"tt8Z]?*tRQݻl#"tR*}η\DHB'zK?i6υNBvKފb%RNZ%_υN:.J{Jn"#tҰXN-ۅNJvJxm*RN.CB'YzeCWF褤?>32/IӁax]$d/WO(B'ԟ3:i49:9h}w:99y雔6:j?3ѳy.:ľu=?dl|(VǞolytׂ OIENDB`7Dd::X  C 4Adraw_sin_lineb6.ף_PN{6C*n6.ף_PN{PNG  IHDRz}$sRGBPLTEÒ5IDATxg[a>zCؖ$=}3ÄebKK tQۍ@e}h :#S0 7NI;9u_NM~F{t#)s\vfks5;xt钛_W[Qa.A}1t댟B-#]z{]Ylf9t^tǴۋl$ $wf{0|qO]*⇵m' 4ќi3 +^Qq?ܿ_ybKqn7fWLl 2$fZ7Uc/%.!U2JAНk)}k5} Zfyf4@,c[%2aA:1m-n6]7N1 r^{I;yu}ttwv{On /Ϥ/qtrA,Y-W)*k@^}?VÂ,C_.|6/8 7-;g䀠J?iz5ϦQ@,"@xAoG].Cp %tm 6:(kx*ts}8}nSCpt. Xiȩ^k?P[v[ӾEװ 9t[$!k{cqoč;5 c݆"n i rA 1GHx)7.㵘E E;_'3oSz1 Uk:OAЋ) z^eQIhS<nF͔%v%$'}AiHHA`>G:j| # ro3V~lUV~1`w}?DN:̩-?z}|Alѭ D|AO>Hc BM4;3Ѓy5WY4bO-!ŻXnDAߍx̧H 덚sNc9Dtn!7z]H͔G8D!ݬަ۪ 5 Ԡw0  +|}xdjpWOfEmpCйej!'5_@ '#9ʀЂnPO/aCAs'f#{^phogoCT3TD"FLSꀀ>4Eא*(e@8A7G9#[ ߩ!=ɳ<@HAqgEHAgXgt@HA_a; :\1SEPAo͋ wT8b@k5+<.褢sF@XR6UqP^}@;;ա>)yz" etqƿzB '%wu~i:Nt^K+`zr46zY>cjwsϤv|:z3>]Eۡp;~)p;[qp;^[q霳:>[qqAgU\J܎Ao*.S6ߠ#їtlVAOؠGנ^q܊KNG8?^Uk2c)t:ǜZ?~n)%q&p?Q /·c*'9-s ugASv2S0t> zR&r5~c=rH< (o]+tRH -30n n-MC]3 "eэf)YF͌~J/SY8 6(| :Kٽ0/Afvހ7A_qv<'Ao08:@|зYޕG(ÇYX9B;3g3[CW8R-~ۤ4Ke5A 9-} 6+.y~H 0$/+ 4*k !4.5pC .胜^$p2@ZwuSZ}V3uYW= XsB`Ls|d{G=TL<_pf uo1IQEQ!,|4 ‚~I h aAg<ʀ? BTXeEQ _x`U W "> RnSQ9RDWk8b>ٟPzsEk jǵ*J:y65GTyϨ]O.G-|1s.sUArw ʀrLl|WBAP醸Ӟ<e;a:+2`1J:{,\`Jv;`StyMwء (+5,n<e6n]w0۠mG) IzF wM]+;B'}M qqPZ tJ 5yI8e}ZJ y-<]/ϚdH2ɢDtz6tPuq(#lvV(%hsֶkv^׍(;4vF J%8tݠp4EcNi9ܢz.jփxN3,}ZE>k2^ПbASCF\;X :zpQtAN?L`)܅ G`)Kj|R:bЙKWb:J蚠rLKqG`%z~H$xUb2F|Iւ~2;l}RЙKvg(a%,Qx߅3s+ADFЙ ;/,0wR(>aƒ](<b] (8%b]$(6EbB]& :3wiȠ3R1wGA瞏X̵P\y#sw]fb1wGaAc.QT9I0fBAAg.g3shzG;Cj$R/}2 oПܰAsgꀜASF䪩 F3z~APh2 _Пg8\r] u@1sn;r}t R 3wZݑ7jS,}2 GZXʀA73ŒT~zBdKe:?jMQ+eZ zESj%݁L[5, uK1kjlQ*ԅZ {=s?T=u@ߨ3ɘTG>F6TsY~?F1Tݑ%GjL2sB2.5u@oC0.e@AoH.H:3ɼ\g}}SQQuF uŕ\+Lo8~T3|Bss7<.e@/rH :wn} g^WW]P_zi} uAgyTA_cOߦ%AKAL#ꀮAv^AoOTg'?i[Я9{AgP7)~9E]e= 4WxFנI_/`tn㄁[t̄tK˞%,  %lٚtJ1lp (Ӳ }8e@_rXr0LCKA`89 }FSs2A7G?]D]B!lt\ !SПC1}>e ? GC!u\ Co9r-0[@kRt29r-8Ǻ_ wGt*N2.5u l1CQ¢a۠ 9ᑢQ]z}/WPr/}p(5 MˊA773&jt̅z ۳ | :7tn=9`'7pqA_0r 8!`@?v)Hv.e CWr ڳ/۠jLk6r 5)GA(CAW8!lz'95 dA]yW(آ!Vx2T#dO k5&t<Q}S6JbB1¦0m9/D56E69Y/sfy9A;!u6[R,*'-߭!֠Ve;D>֥Nh K}A" zxlA7_D ~QXR2Dt}DikЙ4{ZALThkytPDE3HWE)48s` :_#rL3XN/.#41 }b :_B38Ei˛{TޙE:3301rJB3ؘ!6HLJf"QesT̲gld"bkrTd!D4!}XLzhvCP뵧w$=F44%F+AkFY*AGesuAR.-uYNc9R}`"q2`C̞-Ӌ:o)FA y'l L'Gdfz;'豢lFE 6|z4 ׉=Z4 =Z7j,0wizC#W 6lk!\;Aݾ5EzVuivB1F!eU+A`C7A؃nJ3@sLAل o!L{EcF3؀MJ :D?S$t3ssui :)5(Cԥ"0jh=S:H]رmG 9ua :xiRИOLW+3uYOU5"F)C𗕠G[?`_tu[/=vs!Bc+\K  z~,%]}'NosZ I[ظ 6u qqAѩqA?ZV t/}ovjOydW߷ :8!(tpCP:[% Lw|ZJA!eA;9 pC0~٣DA]ǧqC(n~#BСCs?n Iar^s ߙΨMaR Tq杠7 znx!}6Dv$ݯ>C|'5y-U_]t|meALJaY|CUCqߒnC:>qߺ6#kC|ح'A_eU[n!l '}3AGo0CWu :zSce2iQ_!lGݯA7=1oσ`Cҽtr-zĄq5\)z n4."AGJft:Shtpz<$(g/pzw"Gcw?msV{v% +'1AGI5hO%L:1FeɆd;xTfIaN}$9:,?ww\q!lh BI1p ycuSL!FZ07O:q H8R,8t_%"eKIB܄DAmb'ݶbz72 QAG&=[A㔭::YSg2ȧysܪ]dA][L[S iڛ z6 Sitt`zNSGY9!>O?IپCAttfA2s AGj]P}0%śE5 t]K=s&gHW ׅ@),Ao8 r :~@:H'̝wK%{Ug(&sw&#LfKБR})&/Se_3wnKu̝hb.r_3wnB! ϙ;AG %K?C:b.RwI :z(ܓ+ ;6;b;d?Lswq2*$聹8t]s0AG/݅ɲ#͸b.H.0wx=CswQ2u!3`K^=#A="6"5`D;&1wAG $kU )pfi} ^ƙ;AG*zJܻȸ# =wQjBtX]Kuf :lR#2gCY"AG*{%W፠ÚY5.[3w[ n-0ot8ep*YWaâ=woQNæA5ʦ(KSW :RWl=$ tXeu*uqER`-%HV1$ctXVvL\91s'HoUmʎ*jֿLБڍiI&U:VC:?|Oaߜk3U#k5晻;_t9 upJ~IQM5ڪ*fNч|+L:nu(~]Kя\~ن*hOя\sYHQd>,du&AG_r-FVzN@ї<[Q}ɵ)n@џ U>rЮ?7P&sxFD}Zz'*([>#vCy9$ׄvw<9AGqLʣY :Jg PFߕ:+'AG8*D<$3-J映XvtȖR/#Ul)>e.!H$e^fZ:r ]ƑVQ :yn(l,h\湈:s9t"ntd>QTAǻ4; p&YPCp:إŭ#ZǕ@7[,'tdC8 lAБQ kqM:2SFl׆#]}GEinMq8E-' YY~.r✠1OXQbZNttO4fuQ?CPĿ}%Ȯ%Ul_>잊]|#B =$aJi`Pˑ:rhq풠CY7M:` xq:re;N ܸFБ`QmJv:-81mov* |68͇ts)l0M"ȧ8/AGN t2:r2|Y[] : XtHQIБ.` UWB PVnt䦗γ y A8f}u(ƙHmA1Y-tH7˜nԡv$(;Dd0j\ꞥ _R% :"eoQr%([D+YP|#ؓ¢eAG!VO! Al5A}f>uHCCÂ-ͤ[Lg:,0fNCoR ?M[wΫ#z'0֧:bJ.A%˲*VA}N[q;nṱq;tX;ֆnRޭ8{XCy:v\w%^EaKͪ]**Yu2")i*Aef*~{ <tOZ UK=v;N:c:L|G:+WAG h^(rO&HOP7LU5W)C̕tRyC)}Ca*H~*AU%\Ds쓥 :sG/0 kĽ*YLwK]:,[O3w"?7{^':J28Or6 :|rZ:{2|Z+y;AG9Guh{'$e2V- tc:+N`t0Gi͛AG LW%r5$AGh)U :6Ԇ ~ {tcC[֦0{خ.%S|0 طFQcsLOc-Xj=! :Jwy$, $c .>oms:~*{_'(g~o﴿=AGyv"ޖnV8 :ӈ{%Zw̠%zv̩2eGno:\,CQ#w:2[z :",iFo]pTHtG\ (4so}rߑmN:8%6\{&ht`dǙVq uC1CZt8sx5hLL;:h}AQ:cs2~u7tI--z;˄ 廉esPAQ>e'uvgt(Z_AfT E','p0ݪfz.ݪt(%V ÉP9=ý-!wltϑ -q} v).Ñ]!KIV4'peTPkB!/#%m!pG@j:1m",á̀?zU!p's= :d#| jEP#> : YzS7tBHߗéj+*w1 :3Ħ_VD&pk4}fUMl9mC/}>qSܶDEѭ_e4!Cq0б-'#O p~-St8'q(l =aTE,:3+F]6y :U879KC1/2~}\+~%CB? 5DA!±9{C}z-bt`?[Pį"s=Az a>CM-ߘwbtsio :DI=fv tr9qȆK/Cm&aR14mCyz :1N)U}އA8;7ft(:'zrpi_+4t&g:/O!ip+=YAD09O͂]/zTtM}I!"yśM2]V:Adx~TC~B=/S^ZVz%׷S;DOޯXJ!]s\L=tHf&2'm!mQTfџJtf{az7wZ[LJˣBtv(rêyUw>ՑC4sQES oZܯ s@/MyT+zx>At:WGr^yzVDQ# )/!AG9)?K:q7 Dtx"Ys|A_A/N6]catXMw~>t_))ٛ:c:Mn_ī~ }A'ƽ5:=J+fʈr#t^wϟ;Rt|Et9Q^kߐqdq~i.;T5=e=jG1G[V;A8KP+OeOwԈO :feֈ7 :<'ѓel1uyݳSY:~U+mLfSz`Ӥ=d%9Gz眠?EjC$^ 10to/vΗܱFD9O} AGxN% Cq!%}jO&9AI7)xt~5fLˬ[9AI7wV,py19A\n*Ht/1',l-1 ##@@~A295 m0gCAWt*GG6cPe"\w`f͝~BK̊9t&94_+Idt#Ǧ Rerfqx"A=},\#Nrk,eu' 7m'ԁ,tV$+U=㜠#('3\_sm&L_lNӀ Cɩ3˩ɏ?^; uNdo?;0ޤ:'o9AGQ^ X!I:-]s0T+c<24sw}Po&InfhDP0RqAGDv+B^ tyè/IENDB`8Dd::X  C 4Adraw_sin_polyb38u1nʎF8an8u1nʎFPNG  IHDRz}$sRGBPLTEÒ6IDATxzۺa&w[n{6fd',Q$A|}8H`;{} R ħ/߲?ؗ~a=<:n4y8>:2&@0:o$mH|hY°A+GbO֎:G1?}dwr5QAGnoR6O]'3Zkv; Kn?b~_-wtds_,AwWrz4p39Yh=tc;ޚ{,6bkAНtZt\.3H@НwҒCPcZe?첵fqF+3b~\suxdiE3#|Qϼ]1g[kV uyfOzKnl \]ڒb :6P7k;F ze9OaZR# |򼺾g:zuY;hNك{:zgҗ^tY9Lz?AKܫo5r |Tuߏհ e//<^}=nԶF^k>rY?z)g_: %Fn/\^Xmt͋{ zSuVO[lTPol tEYk-;t"@xAm09׌tr}䪺p%/`NEPL޲ ݚ֍j_ě nȁ۲־wr#nYs]n 0@m8qWտaY!Gk)t =օr5xzEOg@O8μ) hNF z;`#,Tiukә/-5}q^xF]zECm s3w]^wГi}i]yT;_ٝEz~zkɗ;Vg[s܄iw2/f5%W_ w}'ͭfK]}e3 y\8=qGՀwe34| =[qҗ"gRU3@гy%V&DcAгoqNJ9~'UQV9b=Y^MD/wՓ #ZU 轺u缆fx|< @{wXn<{ .Oz 3InAŖ;Sb`waj6WK6o/Awƍw~C =悗?uS-@Sz z*>jT۱_=Mp?ȟ!zwrOkϪ{JɒʸOAO&gηAw>ZA? G:??>ҹ-HY:c[HAdztV#붵 &6 W+ٗ2ⶵj}+}5~2^c;!,Jh b & S. 9m}$o( 5'cK5=GR(;,'c'jGmЭ;G:dŒX-&HG|A6C*r_oʰCtA6#-z_wa؂~ qY~" 1|s;tm yS.ƣ S ]=i9pCDA_p._d!J~nU({n䁠Y[[SЏISw c}),_֖%觑EAկqV >Vu٪%;ѭ~K0~aޙ:̩-?>l>z[tk_Г'Uc,AA{{o~=f\! ǻX%~],In0rw#^,,-=(Qs={z,"֠kg[/HۍQFAua#7Szet]MMj,AAe{O} +|}xbjpWOz"6!lkj.z0I_|AAW: H+y6GZu+u6<{8-]Q@~G?o-u@PATgW3tDhA?'iSꀀ>j4Eנ)(e@8AZ-V͐7ID ̸Ez" ]:q B°T'eT*yqAB|Oۑc\Bo`qq['8gߌ! ަ)/ސ%c  d3BеN [NJ>!t WtWB{r46Y1vN;93έYK[ wЯhyй uй9sйގcu| :Rv<zUq)Y]D_iY=ajje_.↹NG8_ސ)eAc)t:ǜZ?~an)%q&p/(-r uNKrx,sfnPf TàWԀAOjD.] )<,rHh N',OfOhUv޺&ZfjF3) 3#׃~,Gju':s{bW:\; t8tvDv/Q+yܠ5$ CEYbnW,lgν'IO"\Eb! :+n z?gIS]!uJ]"gϾP8C30k8㦠Ƹ,WN8tiRw!:JsptsAO&!U49ip)׬(@zp(fLnRbQT8t>|l`ǂ~I h ǂW+xW+X ~".+Y{OH'XjkWZ^Q8)Penp%ڰ7p%tLG9ӞUSʀ\1cqcҤ< E#g]&s.A?8@xx '.ͦ(=[laCAWmlaCAgu5q:¶LPeٸfnakPTE3)]laCAOܧv"@VsPLNu@eA1#pZڶF]Ttm<~K-mm> +GBy(CV9m2^kJiߙ){QMЏ_K@Tt,贜(v':-'ʣ'8AU]Jޢ(:g%IOPf1zKۇީJyԱ,lF%ABhJ~HrѴ U}+e@Ag&Y]+sotDAiOyB e`1J:{,."g >(-yM:}Ptm|D &m登}FAf|y2kO3JX_e"tGAܐp6J ~R*0BiA!OelAYA〖%]r@KEX€r.˳&W$dQ"J ,ަ~UaJ :[uq(#wlPJZ X 4.;|9]-0sP`ނsASTJS4kKW%ZmzW)=R90wL\ua)]vgSJYN +AgX : (lcBйC\;:3w0wGAg(<E3swswtfNbbIQhЙiȠ3b=g1BqA)2swsw{f; :'19PPЙPP9Ci2wߣ A3ިd>H7/27lP/W}: g@Q.wN32s\0o4e@̚qtEu%s\Agqif[4oQ?e@0sw%sw Dm2wߧ ~3)d2 {u~Iv*s:u@栟!P,%m:_fMQ+Mi2 kfR+i; fKuG1kflQ*m7j2 [d~@w,sLA5g1VQd =T;歚 a3z[5Y~d$3w/$ͺ 3vv(f̛A{Л#fbU#R~} u.AgyTA_cOߦ%AKAu@ǠIw;tE7734-t 'y15r xIsDWW&0-Ag.!j;cйncy0c9,9,{Bx2,dF"5:m PAeA0}8e@_qXr0!u@_V0†>Ap7s2A#h=:A#זK(8 mΑkA96 sp##SsZX8 m^ȵp#Q\ ΖyKW)A#ׂs,uLп:SApIPņ;%,re  O%,OM'AJ k@FIhx[5zp1Qנe.Lz녃'n%*GK9!T@'7- rpC8ȁ/n9?  AܰKA´˻K[8!hݣ  7썃x TqA8Xᒃ~Q؃^Nr=f,)`ɂyoCA_5`jlۼs!7(8!{wo d4xF3#lw2tJ1&]WWڿFsx"tw9o3r<蜠yz@ yW)EXuizG)wguk/e2"PeRAk4[}A" zxlA/T"/^?R(~Hx,72Dt 6֠36{ZALThkytPDf]VE)48s` :_#rL3XN/hYc@ "Ť b]bI i_kbỦ )Ĩ;b[l).ě8bO}q.ĭ87L\W$ű8R\x8u "^ 6aeuˤw_eu$AL~Nz6,l:X"LA/zK^DrF/;zK^*dK/czAK\j=Pz}+^3%Uz+^{*c25Z'z ^w%_/1ѠqR-K %bjY3o/9$9/)^&m2U$A\i2ic2iq6ic2i2ɸ6妷zLN( 6.GQѭ=B46!}XLZzhVCP{OH=F44%F+AEkFY*AGesuARn;>]JR}`"qf!t> f7!t7}m zhM6&z5#`MkG,Y1C:圠J&u3!lMMc6 }EcՔ/?'jh l9#G֌K[|K#WlNkNU] z8Qp}m/B"[!T0선cЌCVW{lkSoGiJ3@sLAل !L{EcF3؀M7G3yrE!9eѹykt)3(C[;EСd54`0d ##Ǝ%-;f!4dF(em%葻~Gk5A@8녠nt.Sz?pڜKc} f#A޷EߖyKWt|%ۜ)C@ٔxGo=m3P'W!t\ ޫiHOPѮ/A說 v :ڏ uA9eUrtۧ?t |; r{:~sC8-r}D: ~pAWf| sn Jr8{7A5#d2nӼ3 :~"9 sM9ᕠ!2?^r$ُ>Cm& y-Ut|iaALJ[a.d%!l5/a[8oI!8ot1!l>[ⓠ9F|UԴ=A$G;tt'R?7o7AGwf,S?-w<*/=m:h{G¶G|e6FEypؠy:RxzĄq3\) jo޸Ett:F)\tp<$(k/pw"GcpU~evK/ +ғɤ47'G-L:z1cFeɆyv~tɌ&uD=:,ٻCro\q!lh7애ׁ3bzavSLT_:'Bot,"PKHR,#R.Y&$:I mrDБCDpq_E'fQw]7h:%ɞG]3wqנjrN%.{3o`?L{.0oAGn:wnҙ.AG~2w? nR?M3/S7~oR ::YfÞfFsw'-4s'!}g::seqNQxBIztt!1wwRwI :('AGG].Θ;1wwP+ ::c :` :` {:`;an;&˞B4㊹Ct 膹G}:bL@:,ؒAGW 6"5`D;&1wwG#38oV5t6s'HCE6C2 :ReEiܽFW3oA%peކ[ U`HБswᝠÚY3ĮC. :R6cl2TkѼ ә&AG:fSJ%M'DԡJ2s?!谩ߌ)P)W :R7l=I[pNaOCu0P'g[:[ Xw :Һ3l{e1tXV0:T8̝#U3Ҷ)CUvLWenHd^dҔúa3ԞC5L:3cm2Tc#&HƌyHVLo:J1:Tڔ~IQM3چ(CL7uXAf:&(g3P>Įtb4׭_da ?t5\dK:JYn>$IJ=yγ 8Hѓ\yVޠYoCћ-Q:zS26th1끞Ȫl :z$GtR9$Մv<9AGqL#WC=LA(AGϖBz$G={BwXbtKS."Il)EA :2XȖ-s AGGғ{ h!5rvGZEu'"!Hkq:s9stdArH"ntd"m(mkE L.,fqIܧvIBctdCHB~AG6״#{3 kZqm8 :2ڕ;—Ki9BQi3(=rEБ'Җ]OEEOБ r#i?Ѥv~A#C*2JБ]Kؾ|=y(V'AGv>?Mi{xIБÔӔb#tp6KtAfl\(t6;6t vq#ڔ7twWTq|mv. |68͇ts)l0M"ȧ8/AGN t2:rG,-Ю yX[C :\Qq$ke*|+AG!X[(+w7 :re,->%p︦8#M367(C1L1 = 0A v:aѕnKv&(,mP*IQe3<)C~K~.AGދ=W$Zɂ);AN=),Z֞_tb :gt*5T (67mm AG1N9X57=Bere#T :'(=}GᴓY,O:ƣ!MQ:Qz.6[tG lKQKy Hi{NQ vg';їtwntN(KQ9gat{F h "MYu0,:dap/A ( ggc{Q!AGJ:b{AGF̐=92E񏠣Xf 7E/tYDdWtx$$Wf (=-H7: vby1gx^-6$谅-he|@)AG2utNo"s;.d+p@KYx@Q_fRtJYJHQRu Ri~ʏ!(lls :{e AGLF[_g} %kD :*[ :Gk/ :*5w]3t6IYtTk4}ݕU.Ml9thAd_|PSܶ[b/î4P,~v A3䌃m9qt 'sq]tl =;4*Q'o.tToϱ y=^AGt\˜lqoAL:BMAဤf1/2m~n :\p-AK$ЙAnۛsg5tAVOza٧n-(,ps=A#d aucS :{[^;6<WH_K_ýr:\\J#WZ#W_A3%qOW4͋ttCw3{t8Db[}>3pTmvX.yGlStD{K'Gkι{Z[y7.B$b]kNC:r5qrd/1MOڎo~5 9)?0!p~f}܌rA{YOnN9m‹q}&>COetH?:=9Ew]Ej'{qDC= :V|YfS-A;#t]8[_QMG5 Ý"Odk28 t8kk_ :\wxqO&.ɻwޓU6tme3TfџJt8L/e7w]8پE \zTH:aU_սOu$pv4S7oNpyXwAKh:\):rgȳ"tARir} .susB$}0ݓ5O$k/k^=Y#ʼn0@Ӧ+i֏ 4n{Ek :A7d<[)gtB o]8p#Lzzd)AG +rE_L J{#/>U̲GM:2Vі#w|8#uYzG k,{]|ÝC2|,|stxFOoY/˺gtV™zMSz`Ӥ֜ު9'Ok`)I$}Nᭇ%M_ Io|kOD݇tD-YN`]g5[t <&&]S8nqtz5f̥[9AI;e+v<@rN᯦2`=K—%opa$Ղ?Zt Y}Vhn=N~{ZT6SPe"\of͝aBK]ꊻ9t&9/IOf Gcmݷsܕnb;B!97ZPVt'{} gg͂A>O[nhu!Kr \_կZ30? :r2fzT?k3a=' o&gsr篜\$gNN_MM~Yv ~;ݾM.&>m1'17KkpҸn9AGĸoepLwx t?ؗ~:"?){.&IENDB`@@@ Yc)NormalCJ_HaJmH sH tH Z@Z /# Heading 1$<@&5CJ KH OJQJ\^JaJ \@\ [ Heading 2$<@& 56CJOJQJ\]^JaJV@V Yc) Heading 3$<@&5CJOJQJ\^JaJDA@D Default Paragraph FontRi@R  Table Normal4 l4a (k@(No List6O6 c inline codeOJQJ4O4 ccode h^hOJQJB'@B uComment ReferenceCJaJ<@"< u Comment TextCJaJ@j!"@ uComment Subject5\H@BH u Balloon TextCJOJQJ^JaJ@"@@ U!Caption xx5CJ\aJ eric jonesL b 4eajeajeajeajeajhsesfesf"hsks84'^%23?\y#'] :hN O e f  ) * 5 W  8 k v { !8ABTU()34+,7Y 8 o (!P!t!!!!!! "'";"m"""""""/#<#=#:%;%C%Y%f%%%%%%%'&P&|&&&&5'Q'Y'''''(B(t((((((( );)n)))))))D*E*M*c*p******+1+Z++++,>,Z,b,,,,,%-K-}-------.D.w...... //(/)/0/00001^11222833440000000000000000000000000000000000000000000000O 0O 0O 0O 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00Bp0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B000000000000000000000000000000000000000000B0/# 0/#p0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#0/#00/0 0)/ 0)/000 00 00 00 00@0@0@0@0@00L4?\y:hN O e f ) * 5 { !A7;"m""":%;%C%Y%f%%%%%%%'&P&|&&&&5'Q'''''(B(t((((((( );)n))))))M*c*p******+1+Z++++,>,Z,b,,,,,%-K-}-------.D.w..... /4:00T"@0:00:00:00@0:00@0@0:00:00:00:0 0:00:00:00:00 @0:00:00@0@0@0@0@0:00X:00:00:00@0@0@0@0@0@0@0:0$0:0$0:0$00@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0:0M0:0M0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0:0t0:0t0@0 zzL@*6<#%').('/+026< "$&(*+,-<!""")))...4   l,b$H^:=2;U^Ti  #'7;GHY]ho*2:FNQ_f O d |    $   ( < Q R U z   - 1 2 5 ? I J S { ~ (+BSU^3:<CU]ckgphrv!+~bl09?N ( *>STW     3 6 ? Q d h i l v ! !!!!!!!"!#!3!=!B!C!W!c!d!f!{!!!!!!!!!!!"""R"X"Y"\"m"y"""""""####m$~$$$k%s%{%%%%%%%%%%&&&&r&u&v&y&&&&&&&&&&&&&&&''')'0'2'<'J'`'j'k't'''''''''''''''' (((#(/(I(V(W(`({(((((((((( )&)')*);)G)O)X)^)l)))u*}**********+++++|+++++++++++++++,,,, ,!,2,9,;,E,S,i,s,t,},,,,,,,,,,,,,,,----,-8-R-_-`-i-----------)./.0.3.D.P.X.a.g.u.../'/11111111112z22G3O3m444#KShpL;Hkn:Gu|  < Q h m - 2 ? J { ~ !(lsd/6dk>Sd i v ! !;!>!_!d!{!!!!!!!!""1"3";">"m"z"""##C%G%Y%_%f%j%%%%%&&>&C&W&q&&&&&+'0'<'K'`'k'''''''( (+(0(I(W({((((((((() ) );)H)))))M*Q*c*i*p*t*****++H+M+a+{++++,4,9,E,T,i,t,,,,,,,--4-9-R-`---------. ...D.Q...0012\3b3433333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333STq~""<#=##\$&P'X'`'1(4())) //)/112222244111124 eric joneszR*5[dRPt^`o(. ^`hH. pLp^p`LhH. @ @ ^@ `hH. ^`hH. L^`LhH. ^`hH. ^`hH. PLP^P`LhH.^`o(. ^`hH. pLp^p`LhH. @ @ ^@ `hH. ^`hH. L^`LhH. ^`hH. ^`hH. PLP^P`LhH.zR5[d                  32E1k Ou  V !U!/#w$c%Yc)a%*57q:w>#&INlNnRYUdZ!]ra c+Pz + !/& 3 9B_fz %'Q7g;+g[I#Ej 1 @11PH114p@UnknownG: Times New Roman5Symbol3& : Arial?5 z Courier New5& z!Tahoma"1hesfps&^v*Zv*Z!4d11 2QH ?QAnti-grain library notes eric jones eric jones  Oh+'0 ( D P \hpxAnti-grain library notes.nti eric joneslricric Normal.dotl eric jonesl38cMicrosoft Word 10.0@W@%@Fv*՜.+,0 hp   enthoughtnZ1 Anti-grain library notes Title  !"#$%&'()*+,-./123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}Root Entry FQData 0u1Table~PWordDocument"^SummaryInformation(DocumentSummaryInformation8CompObjj  FMicrosoft Word Document MSWordDocWord.Document.89qenthought-chaco2-4.1.0.orig/docs/CHANGES.txt0000644000175000017500000001402511674463635017447 0ustar varunvarunEnable 3.4.1 (March 3, 2011) ============================ Fixes ----- * Removed OnPaint method from KivaRenderPanel in savage. On Windows there were competing handlers for the paint event. The OnPaint method expected a certain order, which varied by Platform * QImage constructor args were changed to use QByteArray to match changes to PySide API changes in PySide RC1 Enable 3.4.0 (Jan 26, 2011) =========================== Enhancements ------------ * Major refactor of kiva backends to make setting the desired backend more resilient and flexible. * Added support for PySide * Qt backend no longer uses Agg internally, instead it uses QPainter. * Improved gradient support in Quartz backend * Improved cairo backend * Updated to use variation of rev 8713 of matplotlib font_manager.py Fixes ----- * Fixed cubic spline rendering in OpenGl backend * Fixed gradients using relative coordinates * Fixed object-space gradients Enable 3.3.2 (October 15, 2010) =============================== Enhancements ------------ * Context manager methods were added to the Kiva GraphicsContext class, so now, instead of this common pattern for a GraphicsContext gc: gc.save_state() try: # Do stuff with gc... except: gc.restore_state() one can do this:: with gc: # Do stuff with gc... * Stacked layout containers were added. * qt4_backend: Added Tony Yu's patch to better handling keypresses in Qt4 when modifier keys are pressed (r25644). * vtk_backend: Added John Wiggins patch which adds key bindings to EnableVTKWindow (r25796). * The Kiva backend for the Mac, implemented in ABCGI.pyx, is now processed with cython instead of pyrex. Fixes ----- * vtk_backend: Got rid of timer that was causing performance problems on the Mac by looking for the "StartEvent" on the RenderWindow to determine when we are about to do a vtk render. (r25605) * savage: Avoid the wx-specific FileInspector in Sike and use the CodeEditor directly. (r25742) * Exceptions were updated to use the new Exception classes in several places. Enable 3.3.1 (Feb 24, 2010) =============================== Enhancements ------------ * Added dimming mask to disabled buttons when using wx backend (r25405). * Added toggle_label and toggle_tooltip from Brad Buran's patch (r25414). * vtk_backend: Made _redraw call _paint to force an immediate draw. Added a request_render callable slot that will be called instead of self.control.render if set. This allows renders to be coordinated to avoid duplicate renders. (r25423) * Added option of making center section of compass clickable by setting "enable_center" to True. (r25492) * kiva agg backend: fixed minor issues causing compiler warnings (r25498) Fixes ----- * Fixed hover_tool so it imports correctly under the 'null' toolkit, as reported on mailing list (r25407). Enable 3.3.0 (Feb 24, 2010) =========================== Enhancements ------------ * Updated freetype to 2.3.12. This makes our text look prettier, and also fixes some compatibility issues with OS X 10.6. * Moved Shape from examples into enable.primitives * Improved ability to find the Qt SVG IconEngine for the SVGButtonEditor * Improved painting in Wx by as much as 30% * Added repeat and reflect gradient fill methods Fixes ----- * Fixed diamond marker to use the native Agg marker * Fixed drawing elliptical curves on OS X * Fixed scaling transforms affecting gradients * Fixed the "window" property on Enable components to recurse up their container hierarchy to return the default window associated with a component. * Viewports now correctly implement is_in() and components_at(), taking their own boundaries into account. * Removed explicit dependency on TraitsBackendWx in Enable * Fixing logic in enable.example_support, so that it no longer just uses wx if wxPython is installed, but rather looks at ETSConfig.toolkit. * Fixing some math in the computation of setting outer_x2 and outer_y2 attributes of components. One final note is that the "enable2" legacy backwards compatibility package will be removed by the next release. If you have any code that imports from "enable2" and the DeprecationWarnings haven't been sufficiently motivating thus far, please heed them and change your imports to use "enable"! Enable 3.2.0 (July 15th, 2009) ============================== enable Enhancements ----------------------------- * Added Slider and Compass widgets * Added an OverlayContainer (almost identical to the one in Chaco) * Added ImageGraphicsContextEnable class so that one can always import a Kiva Image backend-based GraphicsContextEnable * renaming marker_trait to MarkerTrait (the old name is still permitted forbackwards compatibility, but should be avoided) * Moved the scatter_markers module from Chaco to Enable, so that Enable components can use MarkerTrait * Added an experimental VTK backend for Enable, along with an example * Changed SVGButtonEditor toggle to draw a SVG under the button SVG instead of drawing a plain box * Added labels for SVGButton * Improving backbuffering performance on the Mac by creating the layer context from the window context instead of from a bitmap. * Adding a "fixed_preferred_size" trait to Components, so that relative size preferences can be expressed amongst different components in a container enable Fixes ---------------------- * Improved the backend selection to match the Traits UI backend unless ETSConfig.enable_toolkit is explicitly set * Fixed demo_main() in example_support.py so that it doesn't crash IPython * Fixed RGBAColorTrait so it can be used with the null toolkit * Changed the "sys_window" color to be the same as the Traits UI "WindowColor" constant * Fixed backend_cairo's get_text_extent() implementation to match other backends kiva Enhancements --------------------------- * Added basic gradients to Kiva kiva Fixes -------------------- * Fixed Python 2.6 datatype errors * Fixed memory leak as reported in ticket 1815 * The macport test is only run on Darwin systems * Removed deprecated calls to old numpy APIs enthought-chaco2-4.1.0.orig/docs/Makefile0000644000175000017500000000607411674463635017303 0ustar varunvarun# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " changes to make an overview of all changed/added/deprecated items" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: -rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/metasci.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/metasci.qhc" latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ "run these through (pdf)latex." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." enthought-chaco2-4.1.0.orig/image_LICENSE.txt0000644000175000017500000000531511674463635017675 0ustar varunvarunThe icons are mostly derived work from other icons. As such they are licensed accordingly to the original license: Project License File ---------------------------------------------------------------------------- Crystal Project LGPL image_LICENSE_CP.txt Eclipse Eclipse Public License image_LICENSE_Eclipse.txt Enthought BSD 3-Clause LICENSE.txt GV (Gael Varoquaux) Public Domain N/A NASA Public Domain N/A Nuvola LGPL image_LICENSE_Nuvola.txt OOo LGPL image_LICENSE_OOo.txt Rick Marin Public Domain N/A US Government Public Domain N/A Unless stated in this file, icons are the work of Enthought, and are released under a 3 clause BSD license. Files and original authors: ---------------------------------------------------------------------------- enable/images: 0_weight.gif | Enthought 1_weight.gif | Enthought 2_weight.gif | Enthought 3_weight.gif | Enthought 4_weight.gif | Enthought 5_weight.gif | Enthought 6_weight.gif | Enthought 7_weight.gif | Enthought 8_weight.gif | Enthought bottom_center_position.gif | Enthought bottom_left_position.gif | Enthought bottom_right_position.gif | Enthought center_align.gif | Enthought center_left_position.gif | Enthought center_position.gif | Enthought center_right_position.gif | Enthought left_align.gif | Enthought right_align.gif | Enthought top_center_position.gif | Enthought top_left_position.gif | Enthought top_right_position.gif | Enthought enable/image/images: colorchip.png | Enthought image.png | Enthought inspector.png | Crystal Project enable/savage/traits/ui/wx/data: button_toggle.svg | Enthought examples/enable: deepfield.jpg | NASA examples/savage: edit-copy.svg | Oxygen, CC 3.0 and GPL edit-paste.svg | Oxygen, CC 3.0 and GPL examples/kiva/agg/examples: serengeti.jpg | Rick Marin finger1.gif | US Government finger2.gif | US Government integrationtests/kiva/agg: doubleprom_soho_full.jpg | NASA enthought-chaco2-4.1.0.orig/README.rst0000644000175000017500000000457011674463635016401 0ustar varunvarun========================================= enable: low-level drawing and interaction ========================================= http://github.enthought.com/enable 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 or installing the Enable project: * `distribute `_ * `SWIG `_ * `Cython `_ * `Numpy `_ * `ReportLab Toolkit `_ for PDF backend support in Kiva. * (on Linux) X11-devel (development tools for X11) enthought-chaco2-4.1.0.orig/integrationtests/0000755000175000017500000000000011674463635020312 5ustar varunvarunenthought-chaco2-4.1.0.orig/integrationtests/kiva/0000755000175000017500000000000011674463635021244 5ustar varunvarunenthought-chaco2-4.1.0.orig/integrationtests/kiva/agg/0000755000175000017500000000000011674463635022002 5ustar varunvarunenthought-chaco2-4.1.0.orig/integrationtests/kiva/agg/doubleprom_soho_full.jpg0000644000175000017500000022525711674463635026743 0ustar varunvarunJFIFHCREATOR: XV Version 3.10a Rev: 12/29/94 Quality = 75, Smoothing = 0 C    $.' ",#(7),01444'9=82<.342C  2!!22222222222222222222222222222222222222222222222222" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?,rp(a.xޤz{3 1b<^`RR j:ta҂9J>vKj1AVOʂ2zNJ ^1Hc}qAa0 )GG~;RBcJ"LqG|J:c8a{Rʔ:с. KQ)zI<ѷږ4d&ΓqKF8,&:RGnւ>R vcA qKsKGz9 mғc֐(=( g.1ۭ/z.+ ڐQh N44tǭ/Ґi@F)0 /J;h%xҁYFRZL#`~;d!00s()HMnԇNi3l!QsN9Kdi)p@`MQ jb(1KZNJ_JLqS@)J\QI@Q@((wɷsi(i(QE8qKSi*Ml)FҌg8OӜRdӺjSZGҔJ\g=9i3/ҐC@ϥ8)(EH@2=(^RC@N F?*ZCQJizP(*`ץږc"tcJ&LюiQrF\RE.09zwJE%tz1E&3HE:qqF8 1EÔnc?%(F)ݨ@7bA,ъZZaaiu4 bSHE`i1NV`qIҝJИwqrzoQN\9D*))RcQq8x?ړ144;Rcތr(%p(;i)a1HG^irry4=hHn#zIڙ6txb64 ׽A2D#E.xP!(Sg^Q@Q@((((; I(ց8(g{iq(Np*:bNA_Cdn5aHszށ @mW)!(RBcK4c.(I sg-$ɣRVRQR !1KQ.:)!h8QEƢ\QpCB\P4 )q+f(;cu\v1O" 1Ô`< 1hFmm?c.1HEILdq8 &*@)1 ݴ1EÐaTp#qRM"qQIEqCIw!an)4)1O&))fE&9#!!qFiS"G(1ޓ8b{KCHjS׭%2␎z(&bPiE(Pp(Ji)(;@( &0hݞisPth>bFxǡE!E(AhLSZ@4NZB.){P)vEiR֝HڔPRHLb ۚQґI pN+ R@-D@)vҁNMFR(+EzmIF)\~̋ojLRq{1R(ZM6B7L-.)R⋍@4Zc iΝmr9m+R"#FjLPW./fGԛi Ӹʹmi\~f6ԀQ.?fGTx m?Rcw%a^);3oT~trFm"w3q#7rFci1~8ΝqGdF1N84G_Z:fS.#O= !#n84C¤ZiO9C֙Cqi1֔:fLf?ŽHJh=s)'z J(RRSry>Q@Q@pEZBP; RR)!R⒔R4B A֜)3H1;wZBc"tIM8 )iI \R"ZRN-!S&"Իx74Q pZQNsX@)i@Rٴ`3m.ڐ/xEOsؐmN 9$;xO(C֗1~Į%X0cp#<"ӆ}is%BS8QNHCLL EJ/e.m.pdi[H@p?m}Y81֪wc86p oc젧5t툚&^sTE%ᙟp-V:⧂ݾ\uQtE2NJh5 t.vRl`tH vS&S3tvSJՂ¸DLG8DVMRfRi6ԄRbM*b)iܗ2RNn$dqғ);U\f84jJm37R_NIfm #ސyD40}zqiނsy޼kSLi&3Kѐ3;!0sJOBB)vC(4;LJ)i()J(N!<҃fu+ K( H\ \RRI P(i (wZBK&H1\QN-!)qHP)إ娍Q\ESKZ7RZ8@)6kZ]qOEx^FzRl0.iiB6tFB H~r;|Vr)I/XkR @\[v 4R>Sk.0ݏDrKdf[hM~A5ǥZĀ`2MY Z=l׺9X|8edgr9ӋGylq`~1ڹ'-r}}Hl(HSV!€8%q!$qZF?K&e\F#\p1T[hzVžbU'eKJp3"8UY- w&pO5H&5,tFFTKA>=vO+,rD\vKvf7$Ѕ<_ig38Dð̸ bvHD ~^ONnhQY^5zҩ cQ2eM2Oji^*CL)Z)J\ݜSfڥ#R `3tJM""G42M TS3 DHzc483SH14U&e( b<)=:Rq=)44sN݅#CHaqiͫ dqH@<*qdИZo;SHd1IRqL)RĢ%RQYHLSRI;)S pi \QޝRh;)ԮkQKKHR1NMc(മZROh+( (SrFOEQzң6qڒ8`v\-2 ћjxX[֠K%f,Fr0Ekua_E8 ҋє*H6`Ei4b5R#ގ}h(f.R^7|+ 57ڞAK.oNQ%u.g;r'+ \31.GާMsnJ‡QT JI>ОaOz"6wBgoԀȇ?V^z/L?j{$T:rRYzD,A}P?J|"&tb7 ˈ `\=lKoV v5㑱(pG5$lOaUPoL#T7+!' 0F8%yrҜcn4HcXM6Xa=+؛q.B\aO\{R$cTG4)=\c{7J̒+kITJ'kh"P2OR:D% -s)Ln0#GbteidVj,PeYN;{, 5NR. $-eezHX3THy{ʮYTUķmuGp,khז b$S >dVѹ^rq?_"VAea-$JYI[ f)be'xZ6w{+!HxQ9EQ]^P1V*46_iYVŧnj6&RTR5W܄x5Q3/<e+*FFzgUgy Ժ|l.DƼ\2C<(fv;??.qz L>^tcZ:~gy PK'key(C})B'UgGX+H4hs_<4)h72@.y-G 51ר[ܗh93hbd:?ϵW%qjm(f$d辕N'Y )->OSeY.$QTVV295qqQiFEFYn7nQM]bdfprmp'P%!%v&h/Q +G+& Õ[-,`a}yCg:R{]/g(8ZUg3ޡV]X}MaC*&( 1fe N*0yeyzv*3 *V%+5iFzwЕ!}dYH7+ב{qu*y8彋dW;N\jAJV%d`rpkr-`tk{UVf )r~FOK@jmr@%βFsm*a&O#ӚuEЮ).dgpLc8RRi4l01j(>@G{kptCB21qbq krݳL68J+NPnٔ[I$pJՠ-eF g (y_n26sAf##?0GҵV.#(OXͱA:)[drk່]:YMhnA]Q$Ņæjk^d1- 2p|/m \"e0zV'hoSAe'z@) O"5-eOR Y. RUfuV,b8ʸ<20NJ s#m0qpjyfٍ8e"|9&,'MP30*zdʺ Qڹ8w[(U Cؤ"h8<U7V7 9k>H8Z[^*28@W 9+2r)jrVL2)ySUsN,*R*9&*Ve2) !s" 4jFTDFi0i{PGz8ci.0ztaT4ZLis#siւ949d7 OHqڣ6Zǥ.(@Y(iy"ږ~H88=)FsH!S,( Th@Hd8_Z߉'7fF)ߖ$JVت-'Է,6 -[LY[j!@kBmB,="\ OPIt2xɄ ckSr!T;Rox8e]t^f2s vZGsH#h jkXQ*1.[ʹ>Pk MvHڪ |77F(Si!`,YR ƅcB[\V2[nw$!6Dj?*w"D ޑVKu.hdFf T,}Kވ88sք>e۱*I@8}DٍAV jHlIG5 ui{$XݪX7ZqYJ(JgzQڡWNJД\trjm9b5sR2vB8Ul@8lUѝlEMk[VNu("my%pIaQqYW3]O*e4ۻ4k3'RPHҁeNgu.8B.㐍JV.{-꿦TTlLEk,pS*]סҳʼ1G:ucm̑g?ZvLђ;$mR (Qw08 3R@K}V|u Ԓ#,r8b /W90XMXc],|EbMk df.+:J1+ֺWpѕsBF*J.^#E!dO28ztfS.;Td{UUӽWa]d7!+L""´LYisSL#ii)Us$Rb41Us"9""ERf2*C֐je.*B9֐T0acO=x8柏ni{\n=iE8 4mfNGz1F)çfv$ E@tHc u#Tjx) (\sNҥROxj@*:a R*@VG5c0آ}*r&r>D;{5RdQ@\}xֻMLH#YdT}8d\t*s[̲HL`{g׊X'Ȍ.l)'O4$>\iʫ"# 0#o#kDem7*\$JECrMY2HLԮu€ir06$)_zI%vU\euһ*ҬZn̛U@eFB ;Q*ovuvT#hWs#}ꆡ$1/dzqRZ-‰JOa.S#pjFe>m&u~sʧaXz̦3Zʔyd(5vlJRM,h^VOA|Kwqpص( ~U$y( Z:V$kp#z~Ukg| MSq֬s9!mBǻ}+*Ѕ̖3.ǝ >J[vXsElBvcotV'oZ֝K%r:E1D_r3[\ y# sӡ+H\`}kWLKˉNѴ`Vu⹛LfI/.HшiXY[);=h$wd&$Z{̂lo#a]ٓbeS1VmBwҲ>EThrhX#3W=SumȚp슳G=+2}k*Vg")HMa OM:rNfrZ\$ut rRLSJ[5vk8A=l苅*9%ͪ"7"JpI䎔ۆH.25 \B+sS+pGZz+[d71\lTSL4Hp{4%K֒kun ӜR&StrK ҊQ[643.sj!!c:NHrmͽ%\曧1k$[hr)`"NN$+LTՙZAܧHZSv8F J;UJUNW{\ͪ:=Jڲ$ҋ"|sY b{J{e's܁ dj[2"Q{Tv,G1KgZfZu#DH2iå#D) X@H)EK5< hRO v*;8iLjU ,ŗNY݀y8 ){ t6%p|rp^ܲ\",s{J{' )һik6-1{dI!R3Uf8Y|́EcEUSޞыvnW_ׯz잀h2Z2r}?ςkbmȽ@=JvQ,wHSNZꅹTy 08'Zְ\@7RzVd2Mi4#;2zp^@3XqMtN.[ ՞DW*rKg=o+=}nmJO_jе̬6t?Zqq1=H~2HnXp#–R?+ҭ6B 8sM+{6eo5*3Z1CI}ue,=*$ &G\$Ve6dcVeVP5v9ϾjwjRz0A;aS3ǻ ڨ\5ŵҕ >7r19"VVԖg ?J!7.ڢu!c5)=+)I6D,Nc^sQy:x֗ 'ASiS+B >P#p 8G/6^FM=w}41falr>඘j+kQ/G[zU3$wpebk;\3㱉cYG%q{$s ~G5F5cϵG0}{W\%M(>t1mZ  =iQB Jp{WR)?t7mN{RD{*q޹wvhe VE"sQ[g|YU-+fx#T儌ụ2EEj zWLd'Sژf3*R8i҉ i)*9" 0sޤ#ژI$dcT)R9EHE4V$az#Daؿ~I)|iئ}:ӇZ1z \qE(4H\p3NqNjb:EX9Zbw`KIhRsܓuFSwųY$Y)hɦi<7 z; U\[urb$ OOzMld ĺY G"T,s5QBIfGys2FMv.#BWaJ_ƻ99ɩeBFhO^UМ}j줴v`n]Nq~SQA$"̼`6!-ṕf 3ڴl Y^A*{X5 u%7z1*T1}}jP@UoJo,kٱxcޮBaEJpNG=q8WiVom,S2Hccȧsެ\]I h:᷃VޖKQWo LV=' ssHOh8>вF>nr\93Myzs#HHsZv뱚FUVn5J cGqNԥh w>SNR['ku.˵v4;٫3%@asVy{@9tDY-oq0oU+ŕ܃Pqsc@~)EeXIc! qsZ1js[8 <ArK6 In EKsҒFvG=/CF 闓[˘&@h]&ZԧRMZH)ҬY8.q'^dUfVqUe$4{w`(`ךGt[^i;l1#iR9Jk$,zm Yes x]"s } J5 2%[{ Ι0xs5rZ7a*X) 9)T)*990G4XsO`F=Vy!sH4Lja$0a#aHHf{Ro8S6J`%9ABB❎&85H\SH)å#XE8SEwBMm8"$K6Eݷ`b]f\D:&][UD2eUOqt 1jXH'[J2]cemrWXkuRZƊ$MT{M-;b#5ux q* WGC! 67J(Yw"X_c27ʹȬSmt[(]7nBsXdZTdSObnn (°iGͱW2d TeWQ6.ƫi-}EW_)V).dIVb{'BsZc2[呷mWRGJ]4\/bs)+Ұ[C'Wd(иpzjf$E \=4-$Eݗha\;pdUBeO]v)̤mڄdq+OPEnMQӴ[ʋ3fO;Dv@Gj(=^9d{  *kMae Ht}Hmo"}VK{9NxCnm]؃ 53}Ek,if;=I8tX&%x=x(Gt%Ug+'I. Q.c^wJf c) AFry*/(NVU4bDnsr+7T z?6~USj"Է9YmLm>VJ!OmCڪ H=+5N< 9]GNrk:h Tf *0q(k1oNWBjfƩXTl+trM00TmZ#hc a֚գCsM>OR0E4iaHHi*CmHɡ)*M@((8 XH)Th*AL  ֐ ͳF+B#r8 [& @kօeR?iiڜyRq1N[KPyg1}kv6 "QW<8^Ko:2):{W1rK9Cs^@FGt #E maycЁrŰP+y"r99Jε7{D aϯҙm)9oֲm5?.,}8%:qNR]˽BxxO—(6:8Qc$z!":n "7kly>sSj6\or376I: MߕWn!3ek|Vn6AZ4Yݡ+&bIS\Vq$RIBguXI+0*RQRop2G\,i|g+ +R[k$KCi <0Om#>`=1PÞJH#p)19=jU ڝ A#瞵SM'ڢd6d꽥=nw qpdAu#/n6՛Z 2UmWuIߞ~^ T/7|>>NdD7"34. 6)mX8L*OO>.%06 "0 ޘ⦤[FL+^ڣaz;*1϶X:0 Oytn8x8=6!F) 3Ny_/6wy}2T󭶔@2Z-a•6V}AM6Zєgڣ3ӷ54) ݘ(>`?@G== 55'6G`YN3Ugj"wIF_Z.Ѥ*]¼+Bֺ {fg,B}щ,yB޲^N=kztlX[Я ^- 8]2X|J ݯu߼VLϕ .P[AFy Iz%à]ƥ)fd`裥MZ N>R͕w q;֍,pd=V>h]9EE?S*VuU ̷v4_wZXvy/USOfAq\R0^5f|S;Mk6,r[PV8EĘcl佽\$Vk5R n<ɑ*LV=H4 ɨCcbA=z\/(5л >\tH=fEGUU1JLiRq0+XW}>Gx ޵K5| Ҳ.~$(:5,D4{))+7 ԗD+pz⟨y .XF۽Ck2>սӰ02`Џz 걟M+pQٓ4 AݸM ' K\ Y 2j&*I)k2.tk\,yU94TeہOֱZ1oί͉fY0msZΩv玵V[n\[baڣRIQ%ԑ"xT!V k=vqj13 jbA늙M8U%+ȯ8ie"G)Ln@_Ȁ>LHԽ9s7N{lM\GR/4m ,[vwk$Rd%:zEMar)|2|'r*ėBkuPݷT7PNv6Wk=-:ݢӐYv6~QWJ eU>ed_eRCBwܗ 4`΄~aw5uS(2>$ȻPN1pp{u."7z(HaΛ*ʩvnzc7Dք$Tl*fVɜD,)*FڴG֧0r #iGzB1Z0IfU4KNSJo8S4SfO` fB f8K: R.jU\m] n ]FTfF76A槹6$9 mCW=t1r1Zw\nTp0:T-'j:Uudȸc+rR3o59~1'n?R$'+y,٦BNq]B%٤H(VMlUYNt}1P0¨·TqZb)mHGv9foq0:D#ݶCgVnl$viC}rR"ddhȬf9BMϚi[Os)%v5@9zg,Iecv 1n*u41pȸAjMgAqxS8oƴ,[E$b@Av;]јJ}Y:vf 2vg)ӡGp9;wy8穮}.X|3j7-6=G[ҩXԖ*m6V1L*OC]m2Iϟ :{'#j=F1 җ#&t29D03;unAGG곺RzmzMًf[tA_Uۭ%^.fry>QzKEcp{tocitH[$#&;۔2gtj~Oo£.m.psU.0>HSYqNm7.yl]ՠwT5fk k \'S\XYdN˞sV.|/|~4l.乏+jsY$mvj_ZcVǾO;X\k\XIq;""<UrI;'͂:ZHT"LR#) oݬ’ tVo eY gg3sO")ݒǿ)=9E5ub}VIb; sus$S֨Z/BoSR1\Q^M-?&:ޠN,nEy==;Sih$pG*s{0fp=p+g@2j6BBsw1)KY9k8qSR[+4+jX`9}j c59qש u ʧ9ZOVy2]]W@zfuSknȈ q#D0>U/ meƺ8HK I|L]BN"B SfetcG[JrGzZ Y֋iFk}k6F.ܜ|"XQ7.yvA94:黫g;9V4穫8: 2cֻi=v VdEֽZ2B fWb9*"&5HZ#b-p!2psZ)B3M"zOVy!STdií4f*:)*YGS4)¡x0 xZtyVҪک,c=ltV1VXs[a9n E+G5jxd,3tW@ʍyxaE2qֶ^?qSFSnU23I҇$(!vH!-9RBWTm_$^R3Kg=d̕g( tlj* g8U|}=}*&PIBpH=름9Ud%^hp9Nv8^I#y(FGE?dDʸ;[H<*+$/H݁+c eHœaZ_\2YI*Wmy3tmрm%8JƎH ':;iZJΣRcTVU8ʞTvU+:ʩzW'sֳZm 䓸Fkw.X%ѻXah6=ɸ+z<*c^{V zҧ(Q4I GCnzT2fK (]íT'.T;VJM#5wk>q 3Zos5l@%9lT JHF3]$n`Qx0>` U~懑cx$%/XyēKn #yCNXVAs#RCvs' {vlJzpIuOTҟqˉ r?h朢J"{P1zr+:5[>^+b(#VuӰ"5>h `b%0Wg:t ю90ZZzF;8}@ `q.9G]9UأtRvOpԡ W#<7c}-![[wjIrJƬ$ H\C/橧8v1֐$wytd*k,30pMVK%O}) 9ZM(fd^=+WR;@] z폥sa|b)84NCUyZdKQ]S\ .s-3:]cm%RKf@NX ~f& v^#tQZzHp w;RC3KE%g_-gH_}}kEO%icҹS>`I=⩥Ė<QO߷5n;+vf,2TqmʴEӛ Xlg#޷Avq95IquI4gH"QGZn)^m@g2@ |`āzu#5QXCFTz).`qsY1$=IZ1YNCUt9  ګ욘ߜi&sT\@&鎔 9%صyT :-~\crp2xW:tviuPJӰ;c87ǽ%֜g9plGZn-ܸ ڒեܙB2}LM5ɵ Tb9Dy0VBz-YlR#1qб8o%b{CBobiʳ\.㠫Kw x(^b0679p{Ҳe6ׂ8&kb(".U{K{Dk3͌\[riq9bJ6d’TgtI+&3 L*NUqXQ 7l3..vxd09?Zt\' Bxrs.i|܀sg֕ 4ө*TIbkce`|kxIrSBO%)u ZM23Bs>r (EݖjvlNVю[Xđ4͕9殝F)#D`2s8-%ShKa(_.MQ.G&Wk'+QTV[5Bc9`AZڍEh|CFw5TZR|wkZCl"sU~vH,tjާkq3sv5d},#':i8Kac|Z$`q Aqϵh,l>pTvzJЙQNW -ǔU񞆮]p9R21Y cl2H5<2=*"OaX^f湱=Y>OV5,HH ƎhTΩ(2nƚ#ucQ-TȎ8dGz1zm B6^[e`{WYmV@fp<ʼ\^8dG^zO"L?Yz$1XݎN*vm٣fvl`vFi'rL#^;1i') u21n'󧘍+|:xG'sOr֊8mYJ6IĤb.qsU [=\6\UI:q\[:Qj 6r8&)ޢK9k*=kޠEj;MֻP7<[h94cUc !$oZSҚj!3Jy&~Hb7RΘb)Sf*@*1Ҥ0 LZEfh%.ybMa0$E@tZ.3)A%V~0W;ՂQ ¯BTIuIY DQ8'#02(;W „梶s79T9zj3\DCRt.?y1“@5xx,+d}3VTauRЎ{V&c#$ _=k7>tn´&Z6 A\#sN5]ASMn.XV6t9I}qq-K"I6l`ҦS >BHR}iohYI =kFI1%$+ٹ-35fN7)v8zÅ^8B~^} يFm#IX8|#u,אY4/;)ʠc Daq\ }%#FPy<8Uku݄^3EgvkMbd1T`q_OjrHs֝E#_ROZ/i5fKV=3⹩vII<ϒPKvg֔5iFtZ^Vu9ק=j>3G;ׇR-{׎aVsԗW*[2MiRh!(ñ&`R`Ĩqxe될@pTdnY/VCZP腉7 M54R^6q~S7~vuGn0)SQY">J u6=?i$FŅ܉ d|˴uh[xeiL fIKtɭ6ܹ#IKVzN[CU4m *$LgUQ?6>);s3Y=H7r3;5A76/IijK-T8cU 4^I5 6 lEUF{j ZW8ll8NeKc3ȪiMzKCRBpFJdK4֢b>R ܊;-b3 fPHl05G%j3J\a穨ʑ.bNr?ZnB''u$* @p`ՙ;3"g)@ n FG'#³/n໘ keݒыy~.D0x {S8՚YUpŁ`zxb *9N)YaiFbϳx>kSR>0%WhnĚռޡ/:0l6 YbWK%jjЙvzֹ1TO5ڔ1R :9lr?\G$NӰtJ>cҬ&*lFdْUN.wG7mpZ203K4ﶭ^~@2-YHH*dWG=&a eY@8Uďv,dӐG5j}DC&Dϧ\G*DNHa  ݿ­z1"YV<-q26Ojҝܓ ظAS>jWpFӓXh1c KO%ܞGQXJi!GMԯoΡ\I) Vmmڏ5bM:դVWP=1.T|NJtrLrvX6O6*  hn!ZaL%yk*ټןrӧYŹ 2 "zzTҋH+FZ0Q)iL$c>ksO6u,di0ڬd#סꁰgYz8=jRRZǪ6Q@;wWVpn[{C2/U3@^qM1zt$lP^\|JeDL{272fDB]ʹn)j j;'5"8ﴚm,DUU95CaRݒ&sQܣ%NX`VBxYf.%:V.amc Je60UTRwBH{)JW<8Z˚(*[sI%c8C$l$/ҩݍ|t3$y1*ׯkZ(X7Iv8XJ߼9>q w0VEm'y,Q@m KER@3׭g\j zI6MsUdr㎵ܱl֭_-sfN޽hiVr>|c@5v' ABtгwlu;v2N;UTTZ踐Wy9sjul2IjZO2gZNҊu!}jHlQfAtF\d;2FKc<͸frf+д[_1|Ik as[ OS(%ϳImHջsp 1놖I('^&yXiټ~=ŔRJ mc Um/c,r~ƒʎP#?Җ.&@vp{KgkqdUE&dv xyH&ν9COn'!UFs|]ʱ̣ s[O9Gb=XZ*\r AݢF9u\:{дwv$)~sI{-D| ڵd})IYq;$xKF[@3\;ܒ[o2fHԖzɴdŠ67B1ha4j8F֭| Db{[bN$א"z'mJ?9`ʑjyf-@O3O($ڣݩΐ,7AZ.` 9Wl'D5Ȭ"Vª#8ԩ,#@쾕&24S nZbe\/YIz$I-)Y:HP+bGt;6VnlKbͻ>c7(sk?HIA/IRa"ɩ2fKtfRoQZ =s޽04+yXnj&9 ƣcNja58j1iҵ4cOLSM8`ƚoN=i1d=iR͢H:uz`*YGxHgT ڥNj%Wg#dV8bXTg Mm7h,J=)e!_aƤc2+V8 N}}k͝GM˖$ֱvѴfY71nA4V$pcc #:V0)]έZ*Vf&P r6MqZ @1o޹o3ִ:E;H6uu5Ɋ._Z%8 pG[b՛8򤑹&b͞[H7M~l@619Q3 >ɷ&dۏ8ܨ tGwb^/78ۀ08V8i}Mf`>IJ+~D҆ëuq֛=ê'*34. dN)ěi4W}˖sCg#7SE"g3 H<DQ|IoR| RU\ЮFEsWj2!`SVn/Y<s=+C nH`+x(ms/vi$֒-B ͎3W\1UtFuOZƝ6c[&͛?47 IA❭޻Z!y CX֚zČeoV,vv⛄DO$T; RѤ,x>NjB}pdŨ'hm{~u_iAbt ]" QT~TL~f# sI^[#qjAp&yG?ZFQoa+eٕr@yP} XSM"r@ⷍYt2ƇvG)9ȳKc%#UoBYEź1af5owuI uWv-6[h#%p23Z[[Ǚy\768c7hݒe,=Jڊz +!IB V]?k뙜(NaP{k4A Fs9R }Nb w08'5 A`)=* {qp3RmBE YƓ垑BHi-u&[aUK€`09qFmG¨Ep2?9`EoΟeG[\[ Db|k`ZY׭P#_^)`[h [PN%WW-;LI !թ 4îxV@b v;;mp*v2.t$MH̘,܊;0NgJ\oa  \ҤԖxda9]:eina&%H z g:7Gcoi3F̬c3D}3V̒oڢY"hFTЮZ-MDpXǽi][LI &~^sY`Wc?[ 3sO.^V,,B]R'$f3".Tu=bw#8sOG]&jJ9ARXwEc8zUxvW>4α=>.|O&6KU2^#sQ?JV<n9 cLj{ukDraqZ94M4!Fz`ӈ2hxuv)3H poH*EJPdS.3PJk)[jԁ{ôp#n׽y77-Bl ץf#b 3Sy@ּBGQ\Pa900鱳f9g+#ÏEN./:2ʪxtsERX$F }qT s?+#9]&tbԎ*ռ=0*dFиl}[{pd$W7Fnڳ']CXjMI8\O((})B VQ);ym";H#{&i(u9SukyqFYm'f, POJsψ\B1֭!~Vm,;LOKp &H.ͫH̪H]Ӯb=KKF)Iw{,BxP2[9wʓӿZupe'ld5 0ox>>@8ᦚ/zF6UM;O6qa卥o1wn>I*%~UV/q_jN< WIu{ms?_"Y[FmXsuFma夎d9"p5[dqs槸[ -zV V{TĨO\z֗hX{ ߐ)VHCrnSqYzɹLd<Lgj}knJÌ=Ebjot"!2AzbiH `ѱ=zOM0'OHbngj#v;~Շc0ﹲ{1ěDGCwTQ:rK *dxtDHen?ii7/(ʹ1,r^BaڧNh 3YBv1"TPGڭOE<{IROp9G?lѱcfI{-js\ Ҭci⏓oVJ%'gڢA+EX#=xqR~<$I1OQ:xY^G(X؊MQr?T9;ֵ8w}+¤%ZSܼБYQZny?Z6s)(2~;zTD*Z@uk5cLѬsJ샐nOde'bmdE4J9$Z60vj#; ZRH9#=}r1O<7oww`GZM"=e}Yr: O/i<\2GZOa q<K$k}؀n p) Tg^NPfڲ9:VQ8+֙ZIl@X {WXcQBOV-iԷr< k`ӧ bN~o ndgD+Yoěc^ ckf07_3U)Tv\<*qlAM#8 ի>ʬ6޸-IdeԩkJhRoW}~U7'S|. 0HN*羝-& !9jW\Rhg8֩\W)RWNLj^}:n6va[s[g%@T^?ƨwMmuE>␶c^"rSa(]VqjwjJ5GKh;Ir8nw$dE[wd9^[o%1q^ Fi## n(YhKο1S9d)L`g;ovGb*M_Wd;x6C^ODNJԵ7R#c ڲ4ՠ0L5Koe6[mx^;U)a59lz1Sb#6T|9#6[aS/F Θ}rַ>]vE>"NeCׯҒ淊H {ShSʉdn~x-^trFd?ZչrŪO/P;+ky cjv D,8`3rNzֺ)%i';cM682D |bІV9'֤e=zX:>hYS +HnqOB|mJX\]P kWqN?rOugm%"?ylJ 1X4$>Ox'CHF1=劺OQO{L$Khrfp8XvnW>OzڴHI3| dK=BB vJ(ꄳr;WCkjV1ֽ# I=+c)яrp/httnHq?'u*FwبdM.>`NrGJDzg'-02O98*l0%'Q3Oylby}Z$ 1=rAT_Y0RQy 㚊`݁%8zv5_GNJ#ͺQxϥ$2jB`tMnϜmi c JI9\In{RR Aۃ"K(*x5YJJ!M[}Dp-T)]nrb)V{Yg-M qXrLL$$};xShVv* GAEoWTG%: kVd_e%}nϱdGjFNqȧ^LfUXaָfzd*:~snIF6>qFyblt'$dgUV#=jץ2vCdӛ95lI2ysiGM4M5H琄M4N8Td48ꌛ)L8 b*>RCH5 &LRO\ M@R;)ŅozƩ+Tnuw4 s֭%6x=VR?ɌNZT5: }xW[_1fPO=1ElxzY`5)'Kw&QRV;,P"Jz|tīOGq9*|<5s4Rw9]F2)R0[=y]K#&4RG!yז'CszłDK2pjU!nɦ7m#),.dQސb 0}*c&I @7ϸzr)GkSxlA3S ["Y<To |6;P:u%֞tEH<|V͌ګNѕSgDMP~\u5iV[EJ:Zfo2)wT- %{CÚy-n<0 ֒]]. r9`{qʔ%)^Ir(́XgQ c7_Vgn秵Xx*<ԧ(I4^V)r1do5w޴MEBs}6Gk1A.X'- = v䧡< 45EpJT,8csZ7,v\dҴ#Uԫ4qY*"u9{T,B*1$'E#B~iTo{faA;% t;v'MfPNHǩ!y) O}kr󡚰conG7wu湫R@ s:Va.=H<@_V)6!j#͓޺}.D#e#5^C^gV&@Y@)+C ܞ7@Ni^TjcbHS+.b,7ZjOzG\ aMf'eAcpc(٫mɞ91[,qޭMP7=jgͭц{ꎣc&,lψYF瞝kVkm6h*XU.B4(zVcVT2zjOb^*Mʶzlx94/)J{{aظn ꕍ10s/{ۣtVu8?Ңc(Ojɖܦ<88[w0H$~HQ${3̤{~OnnHCd|JM Q*Kjj0$eF7ۭY؟rgH${ I?֪)^QΒ;qiمqSly$||tv]6aW{"REf_j䩢|ڱ1 ܺryTf2%zkY$p6ިAE|/ӗkrK@句gDLy GOj7H#$ [9]"{q1+K7Һˈ䟼?MpBۏ, ǧj,?1q9Q˦BhrJ׊%TvG.܎`R,L 7gt_bVg2BLg޵xs9d Kk+h;AGe N?Mr 2Fsګ۷m4arŬQ;n$@np!(??Ʃ#UFݸLk2Ib@0_=3م䒮m%Xhֲa}EW2($ڢTl kyrqޚh2#$;6@>$s uxG M<3,@Jp fOۮha2`4+tHGN+rW'8 tZ$Э"^bJĞI$6Fy5Zq4"e@X&u7|qJXŽl[ed3Y]*mk׎R9XI&@|XVywgLq0\'=VWiHXm?wRyɿr&3Ӛ.d`ev>{z@y#Hr9Yn\$ۚkw]cU */rJqn ȉEsso7hZʰ3޴fouMED 27'3YY4RH8FNI6TfScK%U7qҩnX?_duݰcT4_4*,d8[Z"lj&I#qpKቋr8hl$.8M6H»>poNҦUg fj'8{tP; hX9?1Zw#0HvY1l.vF HY.>yv*Q[/>4[[,:ӭ%"A2>2@?.Okn,dz}k;ެpy,& a}*\QRUOcT%zMݷw֡vڠ0s^!b,xj6]1ȚiݫDqcSƣ'6!58a<#LCMnғ-Td`I8U44? pA)(4N&ɏx4NŒR/,@{Tc9jN**5*zɣT`' k#@傩mXg8CUJ ozⲞ\ ҘI5i3r22k&kh{~bn*E8lH:WE2ĥl䤒WS›9_Yi/԰$R7Y":qS&i`kmkyq:.v;H*sSJ? X7H/ޯj7* ^GS\+H{B(=3\Y]n-p}OsӃS淽[nr)^@&FQd2푰P~̲Fa9Pn쁿R,[?OjWQ,:D:: <}%C$@3s~\ 6bLj˹IcОS:K*ΫbBV1uZ-irJYpuJ7vMkUX\]Ȏ_h d\ btH(ff,p=+jqsdKGvsl):jFhO4w}n(2*(P[`H]zUūܫn!YW+yWA"Ʉc/<֝KO:UKIjpYҷmĊWY/ U.-`[oޫySzDnm ŤFvL;s֥Dva[6]rr3ڰmV(r= rp6v3V\Gdt95^ܬ6]ZH^$bcuXj0daak!&~lt~qv|7>*+ yaF{U7T/ypIA5(8%~Gec3ʆNy:[ҹi#*—/Nr*FDg/OzJ>N().dxb]b݆q\6|$*7Xgjmzf[pr {~V# Ҿ ҽOm+- ǙɋTU#4B]~ pq%f+,P4'΅U!XpQ֮C)fL,(FOޟ B,#c[{}`͐AnmҲE>!EP8K%zcZAH95{lݜ4ݽ&o5JA Vi˜j0YfGDGuU-䮎C!CMÍ[h0*snc6,Ͽz87ʐY͹e]>pǜj̭w$R g]ӭydozR{%XD- :#Գ \Fsq246o9X ҵxac/ I\=kNQ 9ⲧ.XįmLحFbUQܺ5t Z B+ߥRJiQzT'Ȣ w/;}鴟ڍCp v]"$QKopVg vD*KSrH'%%r;UMD@XG|~x|aZִK6=뒝H(8ʙo` ^dnfiЍ~:T,rЀAG'X/vh&fDi!lm8f%TtRo`jЁɶ'շ':[b` n.4;V==]2)q 6m7ڣ]Ek|Rʹߺi 1ֱd<6o[Lp =O<ѼcZ?nbxi%9qURGYsyok)99FSJ)p8>ɬW%Kpfi6)GZa5aS4`ڽvY]"4rm2pq@;N#*bR~n"?`0Z%cn|bKdҧcr2Rk哆yksyق = Qd<7l%ZZL*G*%ǵ`Ʃ-j0h{tei9~iI+%=˙c@{69KfL?V5,0o-GQ)ol&xَTq%6-OBwo2 ǭWlPd8=䩎@qǶzRM v\i־]6OU)ܪZ{[qY`rx8, ϒDmn&#v}soo Z]aqp+v,zFa[I8  1cViShrQh-)8ⲩmg6 IR)rksiіDtd:CRDVτ+ҵV_W]n-t$6൴Hᢐs\ݜ7!WH34|`6PX{b,[犾~S.t`AytS}1ro#%jܛDA,#'PqO[yb.GJtG@qR2zLZ8ךPyIJhSzSGN֓5)G%(Iڜ 4SZoOZ`枼 t@sRB*@k6ujx֫㚕_hookG'+V W .pwEb0}esm$H/$`Rkvy?ʹ(ag ÞAtzl q*'98?p`tMp/ O1822M#1CSA3aו#9yf&>hH=ʋ l]! ,ks%7H!z`T2}XO-uKEiYZ G\O?Zc=1DPJZFHAH>PX9֑;8ޥ4ơJUWħӭkZPv:VFO2@cˑ@21n|Fk+Nm\B [^bڳe-y*I r$5i`( )<V~wan+{7/ϱ<DMrI*V;'*XuS\̱4C2zTjf 2-KBM")֙Y4dr䟮~-_u&AjkVy[u@LF3Vuo<JkŻ(*v[9T,Ve Z, t= lԎj=s@gnv MX쓪Ow΂D` X<ZϙϴZ}͓hn$80j[azcY;rd1]1;p:!=.*CY7PEG˯$1[ݪYl0l*77Xy!6@>Y>kK9bGO0e75i y2Z)AnĆM{0z_Is+(8NyI*IU塍pv^!Ki#v \w(H#OHp޾53/(u25v"m'=9+4y,2 榒ywR:UhDn/[v7I{/2>YIUu>[a޶n -g>dϦJB85Æ-n=՗6s;YX̬oԒJV`9C%ƛϵ)=i1Mg=hҙ Ҍ2I41!{S{})Ԛ8tLNϭIc nM(fɒPj0qR.q;s=*XsS ^׽?%x+i!.z`uL,08)ϪI\|Z+i8ҵ ]j-yw';{U+r0TlHn}ކ@WT(bZi&% =* ŕ%A:S%7b̯'pY硫qmnŃvQ&M0}jY\B%!֦vJװ.%!$7jͭŚB̓68cޮq>ٝ. ^b zJ$@|@'hxhspUT=EcJzmӢ c֥3#$G4j6sRX(1xi%լpGwʈNUwsӵS{}{5 *k\D'u+0p]Kc }=sskwU#_[ѱNI-tƣn 9`;H!Jvn˰^{}7lRO=*9S4e F 1T_+}B5duG+i嘪wV4Z >lH$3\~>V7(7@zR[%̅'i)JJ+_/=T>$lgTQZ_^ݻT)?6OLּ(d ˺ȬjJn)03$HJs=(< 8kCID'q'wP&Kgq!_R].WֶٕM, &r{d A9Vr%[Wֱi+ 7BSq) ;d#c=u(9iCX`yǽTR # 8@ *n#Fb|k7OBU1#"#6N番v.u=̱%'~57er;gh3moU'j]cw"oT)TB&F/ZI=z/GqD[| E(yʏ0#I:,KbvYAbx qHGIRGWLaU:g同YV_Ns9jOl‡̀}ja!3"U1T7:?{*y= 0U%j2NyօKHМ.8jmnH%U.moc_DDx8)V 7ވ7kB(%X qh7,k!9qqe+,${UJ:Moo1.ujƺ#A b^]=B U|\+x!ؚ+$m5;i*nDdC?TI}#y kY]KpɔhPp A7VIh ɞ0{$1a0Nrp(*&NO^i-rCg9}@T}}Ǹ m(aE~W j%hd{UX/Qd;~5 3 ?3TFih觀CHnfAg۾jH>ϵ<jHz)q[9Gpfi$ˀb|vV".`("m"O=xy+&ֻPq1'vFR)".r9Zvm̄`poJ`<8ZU(T[2.:{mB$)2:ƣIDXnՍup jGzk[] F:{Gި[دLq*Y֔K[3X9֨[Z$gi>WmAߡ42#̄jqI$:YiHȅ呚Kj! r&n7߯5im$^·AR4qT*@$UupxRKD40qYLv74s9SH1s]2&&Ƣ&9jJ FRH:WcSMNp V SS0={V;3{LG`뱻t5TnM;rd j㡕Uw{ O8g@k:êd)8zVE!nTd4>̝#4si7{N)F}hh})A4HGڑcGԠ⤴"h4H1ݪCjQNXbW1V5֭#&Hrpc#֨!ҁ%4"m͞q7ZkhzL}xNqR+ 2%MKGD$X ҦLUA'͛iWz+19+F\r`AZֳy'1\5u:7;?UPa<;t=m(&H؜C+dbuwDG)x|י_qq#Ej[ݓ1 a* 9&pÃ3RY(FPxX>N[e6O1t<4iHB!=dNTLG3ަFLm@Mm#ȌvY)o 늯jI 4CO.p}*ܬ BC(ޛ]GH=Ţ#=*ܑ]Û`85Zanr"- ӊ8"".$̣*+mwl)F26rTӞrڊxu/y1$h^\pV|!zo-r8kJ~Bs=$rOˏ[ΖCeP| 22:}7"nj*G9i(ƄPVJ<bS8C,&R>8{WD Cv=xy &{f#$?MNIrtӗ+ZfX\=[Ğa @AUsIUpmcvz1朆5f(Y ל5 F9$"H {UZ\ J~d|N1W-FsUefmߣV!ZO$c5Uwp1i3+\A7lsv؛QZH";R*Id竻StVP I6X>%tg!hpS)DF`iaIzbhFoF1]:;pi[,0'?EIwq˸rW>:.x$杁`(**{(0\2:q^qf$sL2RzUlٖC? %!( 1Ԋ#(p*ip#UkVR$qҪXh&]3}DdY|r} e){eˍUT *-38p9bRd3jkJGqY*vrTRڂ lbÑɧovRi7 F۞0ję`y9M\Zk8"LJlm~fYH6&:ɞ=M(;ִ{ebNgB@X7yjvS#\t囱dVi^ibyB8pA<-dQڋx;֪jҵf44.U;H#QTYI5l 6L0}k9 zяcPO29t0@8T BFˏj:3DJܓң',iX`p yZ@?nC"M:i(^cy~Q*5ky^ƴo@aC 3՛Z܅@WF zV-DnLJKTIf\C":\woҬ(&t~f^k\QY0JXdaB*[сTRSUy.Xng\i~;9jd,_jJ`(BMSʲ68,M`mg͒3W)+a7^d|0UQdZtK308%Sāg;#Prҹ^N#Z _ I%EcܥBxX5iWk|aXP~*+jl@olnFIgdsS^I8U@U<¯_[4$ k' k&E0嶜s*Vu1+̎fyV3=VD rҴ5cQՆӜ֜q:,3S}q8 Tjџ&cns Ag'jđ&`cRG Ȏ+٤gޜsxSN%2Ytaf>w>=%˒jyr)򍇊in..Z==j4)Wtm TriW"e0*KfU<թ )n_i8!]&@G9lQ 02Gm1\ ⠸2BޤtժB5,;юUt@Oc=lڄ TnLޓ )ϵA5J;fZ78֙qŘabԬ+gFS&{E%A'ߡ˸U z\ޣ#Ė?tsU$#HiNӟs֫j ϭvZ1H)i9ⲥd 6nb&i7Â"?;Vc g\iVvUQOݜqO]ԟx◿5:F5M0scQ0(Z?gԒy)>lS!jsҫbcQ UgVWL"C!cYJM#RiحI@SH'Iɠ4;PNJCTd؇'Hj7LN3)qҌLގqHN7{҂"$r;&$^a?*bA=pRՒòO'xQY-ߗN&1 GZx0=j.RzbsN5ș"i٨fh̓4MD 8"Q֤SP 8j$2 V OVq:RŨ܆8[pY Qfݞ֓bl(CxT7L \Wg+ 浴R8Ce" *-3&L;799U9BKvʪOi@-][ޤ$}Ef 1ҧHnJk5h {JW W\1*\apqjXnm1Y7y9n½3Ѫ5*n"'T# v=*k%B(QWv236уn+j2QL!-3:&j[XJ| j-GLh%#{TN{\FYeE poA>1.^H䌓¿#+8r~Ա Lۓ Xh Ѳ'$@Cb2FGZXQ7,⭠ %yCZ/C 6h32(I$]%ƚjn$e;Y]"L+-L_늚d1౫m@|2wpEY,vcp%vUʤ\UUkߚM9n*혖1I 2Hjg<-տ1 dNGvDoA=k2]IlyTUO,͹pݏO#R 'nf嘌⥖d% 2I'g4'W$IOݺWCy@Bpx4`?.~P}M-H,4AW !Uj֛5 38Hm7fطY$rMT ! ~g:wM9°9XV>Pj %gFi'! !i T׊kqO_JBri)0N:EqH={Qڗ^j1KIRt]@j"(1jENԫMobsRm *mj U zⳚۅ+-O*L5G}K1>#j 8SZXC #d*(Z= i]1jh8*;1Ԣx?ZE:5isRѬdKi,Ӂh3$OZsRRNDSP Yuә(4zx-"j|+?en+x55SL|@NG#K6 3[t'!Ҽ9 4`9*w=7.fcPj *䒸1OסxwSud'IvhcbMg׌UaH3*8"OUgqwc6t#:I16q@k`22)XeY>EU# =lq\/O.PsYmu [Zӎ0|J͞s'vA\g- yXrx0S_S fۜkAcьϡ9V0m\Oj3»rnk'uf - LR/%ZR/P1Ў#'V\F%>6dr&8 σӵPm"v ֩V՛ ⰲh%-3/ڥ{;{!oѨ?*Tk'(P@'1V(-$Kv FC ۚ} #[#^`Ǹ6L 3&85qxڙH#.GewiFxNZ&.. Hc9k#Eq8&n#p1V⠵F6*)Z;Eht+!]c0sɨ!]?5wh4b'I *꤇j[`tִ>I Kde)JQlgŸgT9!wIvp"Yj̱;GTʝ #+f0s]pOZhX' fזpwctjSV~v$|AmIٰ01V$!SJ̭aK``.F)p)'RmARDda< v+cU8jV' CJCqIFkC=)x4Tf؄cH}:PzsɠƌWg!VS'3<њfwA؊PLF{@Շh_79JE40t{qH2Ta@hȩ:"y&=hVyK"LqY[Suа)rT1US}jMY?RIWtT3;VcJqeOjhu)ƦJ$J(v}:Rҵ84NOU$ғ..pOU'l{(e/'jSR:pdE\PV{uAևF2=iԴkӃ`.&ѪYV&w_qNPDj&t J/z֋RU2I\@R->cǽrT[t)CcrqhkGV@SٮZ-cȵ椴W#W`:d|l4QOn뗋0;U9N[ 1F`;.jH9jҐ^iɲ@֩U$C^[{V,/mOvtV'ۛz;gbɤ-L'tdcRu75fh-M4!I搚B}*d:l歪i=je erepi* ␹NkebޢYy柺U4)skSDɑ')M"dy#*qڴJ,ˣ9MAMpFBXj+C̯/}OIBi?g3bzfA=I89i i:A9M'J:ёHzQ΂n3MQcE'=zPVӀf٠ސӰqڐ~{U楊MPg#/j搛/%9ZWӐk>9dO^tZ=L=hOɌND8e뚈B y7tm+*>3S($¢<NԻt6̾!^dcTg8k =]7QIIIЄEO)aT{SISTgt@_4ni'i~ЉTSԗmac~QRoHv~SQK9&Qn;\x<Ӂq 4A.V4S& CޥX̘58TMuWFQ5XwR, *]KUPjXIrQY[ޔ=Cb ^$9ǰ T$s\|RwjgPHdNo31>S5 )w}NadoH&Qz59WN W7O O7?fU!V}_\AtX{/Gա~ILsҳnZ~sor$sMi@OK<ʉz6IJ3Qsv:$ށ҃J).yF ;4RӁ5<҆4hH)EGvV-I p5Rƪh5eE 21F5 57RJdwsPERKU qKKRRPԻԻrU% FwjLZuG( T[Nĺ P޴rU&#f(-Ju4"7u4 RFRњ!niؗ2Lfv %̓4gfi7QasfɸQIE2(4P4R9&'wt`ddP:v?>R*y/.x+;ڜJfsAiq*z cJ7qJ$S0wQa4ugJV)IJZ4߉bԇ Ҏ0]V-HzQך7NX!]8bԬIz\+?4-Ȣ?9RRCKz9XqF, hzRj=ԻX1E$Q)jVqiu8M34f8Ih4$Qvi9sFi4W8iIOzi)fi؇1٣4i ~xu3u&h3Ini2{`s33FvaM&sIEr3744'"ջSScTl2՝=E(n3<44 rNHڱ1]biˌ֩} }MFy94n>S R8%5bEluRz>#r;PB$0W8uEͽjL zb3L O\ g9-ފ 3;QI~tNi9L(RvE&h(h)(;җ#&hQg"c^w{QГւQLHwp)ݿƘH.i1))r 4J_n{wZc֗G'4ZNȦgP~8i٨;b\ys+ Hwisڋ Hpn?Z,>a4ߝ.O(KfM.xa34,>aԤ'V)KA3ޗb.fiiswpBݸ>J6څͥUM`8`=X|Ȅ4Ju.yRҋ HpKڙ3b;:ZvAiȣ4Fi\a)AnsE;4f3E~i 7>EpS2M.h"s3EwQs) mM=sh>ܚ WsIMh=i\úgM!ޒ4(IHu曚?*㏥7<ړ?c&sH=(cRr TS*5e$\uO`k/$zp}uGE@zcj=T`cWÙ~Znsz#QszN߅2RBBzT>Ԟk\S*,RI IQSOcG<;RqE3+(ւh+m~&K6m.;@2ē7γ[[tꗖ\$kI#@Mvtм?_̉.t@Kcq~8#w^}ǂukoXLS4X0prz_ 6Cۨjͫj *ʻƾyXlmd4t{2"<0rG/2[ȄHg 'vLk낺YgCoݷvSӊ_ bׂ|_I5[8ⴰҒAH k⟊^345h2E{+cr wdZ$Js1-)܁ހ7>xR_3A-3Xe'\4FPa[Qy]x_Xn-.Mn6e *=w7Q \2ȈďG{Ӑ3\N[BsW'@|KREA?( Urg @uS|D[]bx4o.c9 qn,.~)ki_dwy9w>#G)zzLApsE+\5ke[xĵd31ZLd$y΅qoXh=|gb(a\NJGnju^{,eg &X;l͇] z߈7k|P-4/.h9^2xͤ埆4U/h^6ɩt26|xWηm?s3zQ [C"OAb:e5}[^nc_Z\n` QF-gT +,]w p^eI8#Gm[24=$ cyrX`42z=iE4@'Ahv)sip)s,>evxisL.Nhԇ~t`?-;$va ?Z\E)#4L)r@Lp4S3\p4fNi3EyA>NM0 7܌a ~󆅪IhdM"#>(Axľ.(VKmčcڀ 㿹oƞ!%"GVqK/Lj Ŗi][53QÞ?OD嵁DsAE_?ȚnwD]FO=  MK}w64vr#pNWzFsc>"|:>"ǗohUo@Z*ߧ54t{-.9 0 E?5u74ٴC^KY$H-ДPq3XNK׼ ,v9Pg8*TG_&S6Ii0đ1Ez=FpkO4=k&Ζ l쭏 '3p3w_?ښ~O.巽O3kZ[9fQ |K񇈬%ugXgjV6~QvȲ`Gj=f{cH,$ij1$$ޓ Dѯ7Pk{6 pE4G~L^ -c]Ե'.|-#Slkdym5{/<_JyеyDp2տx^)֯-;Včr3B_Gj=f&8)q޶(4_?֔(y&?4HzQ| S+_#u>kd~쎕ޔ|`?29V> ){Ek?i~LIG{2GK+Z>o2VjNk/{ev8n_ &VhkRw2.?/~`"'] N =100 t1 = time.clock() for i in range(N): for s in strs: #gc.translate_ctm(0,14) gc.show_text(s) t2 = time.clock() print print ' %d strings(total,per string):' % (N*10) print ' %f %f' % (t2-t1,((t2-t1)/(N*10))) gc.save('text2.bmp') import profile gc=agg.GraphicsContextArray((800,800)) #profile.run('main()') #main5(gc) #main5(gc) #main5(gc) #profile.run('main5(gc)') #main() #main2() #main3() #main4() main() #main2(gc) #main4(gc) #main5(gc) enthought-chaco2-4.1.0.orig/integrationtests/kiva/agg/image_test_case.py0000644000175000017500000003074311674463635025477 0ustar varunvarunimport time import os, sys import unittest import Image from numpy import alltrue, array, concatenate, dtype, fromstring, newaxis, \ pi, ravel, ones, zeros from kiva import agg from kiva.fonttools import Font # alpha blending is approximate in agg, so we allow some "slop" between # desired and actual results, allow channel differences of to 2. slop_allowed = 2 UInt8 = dtype('uint8') Int32 = dtype('int32') def save(img,file_name): """ This only saves the rgb channels of the image """ format = img.format() if format == "bgra32": size = img.bmp_array.shape[1],img.bmp_array.shape[0] bgr = img.bmp_array[:,:,:3] rgb = bgr[:,:,::-1].copy() st = rgb.tostring() pil_img = Image.fromstring("RGB",size,st) pil_img.save(file_name) else: raise NotImplementedError( "currently only supports writing out bgra32 images") def test_name(): f = sys._getframe() class_name = f.f_back.f_locals['self'].__class__.__name__.replace('test_','') method_name = f.f_back.f_code.co_name.replace('check_','') # !! make sure we delete f or the their are memory leaks that # !! result (gc's passed to save are not released) del f return '.'.join((class_name,method_name)) def sun(interpolation_scheme="simple"): pil_img = Image.open('doubleprom_soho_full.jpg') img = fromstring(pil_img.tostring(),UInt8) img.resize((pil_img.size[1],pil_img.size[0],3)) alpha = ones(pil_img.size,UInt8) * 255 img = concatenate((img[:,:,::-1],alpha[:,:,newaxis]),-1).copy() return agg.GraphicsContextArray(img,"bgra32", interpolation_scheme) def solid_bgra32(size,value = 0.0, alpha=1.0): img_array = zeros((size[1],size[0],4),UInt8) img_array[:,:,:-1] = array(value * 255,UInt8) img_array[:,:,-1] = array(alpha * 255,UInt8) return img_array def alpha_blend(src1,src2,alpha=1.0,ambient_alpha = 1.0): alpha_ary = src2[:,:,3]/255. * alpha * ambient_alpha res = src1[:,:,:] * (1-alpha_ary) + src2[:,:,:] * alpha_ary # alpha blending preserves the alpha mask channel of the destination (src1) res[:,:,-1] = src1[:,:,-1] return res.astype(Int32) def assert_equal(desired,actual): """ Only use for small arrays. """ try: assert alltrue (ravel(actual) == ravel(desired)) except AssertionError: size = sum(array(desired.shape)) if size < 10: diff = abs(ravel(actual.astype(Int32)) - ravel(desired.astype(Int32))) msg = '\n' msg+= 'desired: %s\n' % ravel(desired) msg+= 'actual: %s\n' % ravel(actual) msg+= 'abs diff: %s\n' % diff else: msg = "size: %d. To large to display" % size raise AssertionError(msg) def assert_close(desired,actual,diff_allowed=2): """ Only use for small arrays. """ try: # cast up so math doesn't underflow diff = abs(ravel(actual.astype(Int32)) - ravel(desired.astype(Int32))) assert alltrue(diff <= diff_allowed) except AssertionError: size = sum(array(desired.shape)) if size < 10: msg = '\n' msg+= 'desired: %s\n' % ravel(desired) msg+= 'actual: %s\n' % ravel(actual) msg+= 'abs diff: %s\n' % diff else: msg = "size: %d. To large to display" % size raise AssertionError(msg) #---------------------------------------------------------------------------- # Tests for various alpha blending cases # # These include setting an "ambient" alpha value as well as specifying an # image with an alpha channel. Because of the special casing, different # colors take different paths through the code. As a result, there are a # classes to check black, white, and gray images. #---------------------------------------------------------------------------- class test_alpha_black_image(unittest.TestCase): size = (1,1) color = 0.0 def test_simple(self): gc = agg.GraphicsContextArray(self.size,pix_format = "bgra32") desired = solid_bgra32(self.size,self.color) img = agg.GraphicsContextArray(desired, pix_format="bgra32") gc.draw_image(img) actual = gc.bmp_array # for alpha == 1, image should be exactly equal. assert_equal(desired,actual) def test_image_alpha(self): alpha = 0.5 gc = agg.GraphicsContextArray(self.size,pix_format = "bgra32") orig = solid_bgra32(self.size,self.color,alpha) img = agg.GraphicsContextArray(orig, pix_format="bgra32") gc.draw_image(img) actual = gc.bmp_array gc_background = solid_bgra32(self.size,1.0) orig = solid_bgra32(self.size,self.color,alpha) desired = alpha_blend(gc_background,orig) # also, the alpha channel of the image is not copied into the # desination graphics context, so we have to ignore alphas assert_close(desired[:,:,:-1],actual[:,:,:-1],diff_allowed=slop_allowed) def test_ambient_alpha(self): orig = solid_bgra32(self.size,self.color) img = agg.GraphicsContextArray(orig, pix_format="bgra32") gc = agg.GraphicsContextArray(self.size,pix_format = "bgra32") amb_alpha = 0.5 gc.set_alpha(amb_alpha) gc.draw_image(img) actual = gc.bmp_array gc_background = solid_bgra32(self.size,1.0) orig = solid_bgra32(self.size,self.color) desired = alpha_blend(gc_background,orig,ambient_alpha=amb_alpha) # alpha blending is approximate, allow channel differences of to 2. assert_close(desired,actual,diff_allowed=slop_allowed) def test_ambient_plus_image_alpha(self): amb_alpha = 0.5 img_alpha = 0.5 gc = agg.GraphicsContextArray(self.size,pix_format = "bgra32") orig = solid_bgra32(self.size,self.color,img_alpha) img = agg.GraphicsContextArray(orig, pix_format="bgra32") gc.set_alpha(amb_alpha) gc.draw_image(img) actual = gc.bmp_array gc_background = solid_bgra32(self.size,1.0) orig = solid_bgra32(self.size,self.color,img_alpha) desired = alpha_blend(gc_background,orig,ambient_alpha=amb_alpha) # alpha blending is approximate, allow channel differences of to 2. assert_close(desired,actual,diff_allowed=slop_allowed) class test_alpha_white_image(test_alpha_black_image): color = 1.0 class test_alpha_gray_image(test_alpha_black_image): color = 0.5 #---------------------------------------------------------------------------- # Test scaling based on "rect" argument to draw_image function. # # #---------------------------------------------------------------------------- class test_rect_scaling_image(unittest.TestCase): color = 0.0 def test_rect_scale(self): orig_sz= (10,10) img_ary = solid_bgra32(orig_sz,self.color) orig = agg.GraphicsContextArray(img_ary, pix_format="bgra32") sx,sy = 5,20 scaled_rect=(0,0,sx,sy) gc = agg.GraphicsContextArray((20,20),pix_format = "bgra32") gc.draw_image(orig,scaled_rect) actual = gc.bmp_array save(gc,test_name()+'.bmp') desired_sz= (sx,sy) img_ary = solid_bgra32(desired_sz,self.color) img = agg.GraphicsContextArray(img_ary, pix_format="bgra32") gc = agg.GraphicsContextArray((20,20),pix_format = "bgra32") gc.draw_image(img) desired = gc.bmp_array save(gc,test_name()+'2.bmp') assert_equal(desired,actual) def test_rect_scale_translate(self): orig_sz= (10,10) img_ary = solid_bgra32(orig_sz,self.color) orig = agg.GraphicsContextArray(img_ary, pix_format="bgra32") tx, ty = 5,10 sx,sy = 5,20 translate_scale_rect=(tx,ty,sx,sy) gc = agg.GraphicsContextArray((40,40),pix_format = "bgra32") gc.draw_image(orig,translate_scale_rect) actual = gc.bmp_array save(gc,test_name()+'.bmp') desired_sz= (sx,sy) img_ary = solid_bgra32(desired_sz,self.color) img = agg.GraphicsContextArray(img_ary, pix_format="bgra32") gc = agg.GraphicsContextArray((40,40),pix_format = "bgra32") gc.translate_ctm(tx,ty) gc.draw_image(img) desired = gc.bmp_array save(gc,test_name()+'2.bmp') assert_equal(desired,actual) #---------------------------------------------------------------------------- # Tests speed of various interpolation schemes # #---------------------------------------------------------------------------- class test_text_image(unittest.TestCase): def test_antialias(self): gc = agg.GraphicsContextArray((200,50),pix_format = "bgra32") gc.set_antialias(1) f = Font('modern') gc.set_font(f) gc.show_text("hello") save(gc,test_name()+'.bmp') def test_no_antialias(self): gc = agg.GraphicsContextArray((200,50),pix_format = "bgra32") f = Font('modern') gc.set_font(f) gc.set_antialias(0) gc.show_text("hello") save(gc,test_name()+'.bmp') def test_rotate(self): text = "hello" gc = agg.GraphicsContextArray((150,150),pix_format = "bgra32") f = Font('modern') gc.set_font(f) tx,ty,sx,sy = bbox = gc.get_text_extent(text) gc.translate_ctm(25,25) gc.rotate_ctm(pi/2.) gc.translate_ctm(0,-sy) #gc.show_text(text) gc.set_stroke_color([1,0,0]) gc.set_fill_color([.5,.5,.5]) gc.rect(tx,ty,sx,sy) gc.stroke_path() gc.show_text(text) save(gc,test_name()+'.bmp') class test_sun(unittest.TestCase): def generic_sun(self,scheme): img = sun(scheme) sz = array((img.width(),img.height())) scaled_sz = sz * .3 scaled_rect=(0,0,scaled_sz[0],scaled_sz[1]) gc = agg.GraphicsContextArray(tuple(scaled_sz),pix_format = "bgra32") gc.draw_image(img,scaled_rect) return gc def test_simple(self): gc = self.generic_sun("nearest") save(gc,test_name()+'.bmp') def test_bilinear(self): gc = self.generic_sun("bilinear") save(gc,test_name()+'.bmp') def test_bicubic(self): gc = self.generic_sun("bicubic") save(gc,test_name()+'.bmp') def test_spline16(self): gc = self.generic_sun("spline16") save(gc,test_name()+'.bmp') def test_spline36(self): gc = self.generic_sun("spline36") save(gc,test_name()+'.bmp') def test_sinc64(self): gc = self.generic_sun("sinc64") save(gc,test_name()+'.bmp') def test_sinc144(self): gc = self.generic_sun("sinc144") save(gc,test_name()+'.bmp') def test_sinc256(self): gc = self.generic_sun("sinc256") save(gc,test_name()+'.bmp') def test_blackman100(self): gc = self.generic_sun("blackman100") save(gc,test_name()+'.bmp') def test_blackman256(self): gc = self.generic_sun("blackman256") save(gc,test_name()+'.bmp') #---------------------------------------------------------------------------- # Tests speed of various interpolation schemes # # #---------------------------------------------------------------------------- class test_interpolation_image(unittest.TestCase): N = 10 size = (1000,1000) color = 0.0 def generic_timing(self,scheme,size,iters): gc = agg.GraphicsContextArray(size,pix_format = "bgra32") desired = solid_bgra32(size,self.color) img = agg.GraphicsContextArray(desired, pix_format="bgra32", interpolation=scheme) t1 = time.clock() for i in range(iters): gc.draw_image(img) t2 = time.clock() img_per_sec = iters/(t2-t1) print "'%s' interpolation -> img per sec: %4.2f" % (scheme, img_per_sec) return img_per_sec def test_simple_timing(self): scheme = "nearest" return self.generic_timing(scheme,self.size,self.N) def test_bilinear_timing(self): scheme = "bilinear" iters = self.N/2 # this is slower than simple, so use less iters return self.generic_timing(scheme,self.size,iters) def test_bicubic_timing(self): scheme = "bicubic" iters = self.N/2 # this is slower than simple, so use less iters return self.generic_timing(scheme,self.size,iters) def test_sinc144_timing(self): scheme = "sinc144" iters = self.N/2 # this is slower than simple, so use less iters return self.generic_timing(scheme,self.size,iters) if __name__ == "__main__": unittest.main() enthought-chaco2-4.1.0.orig/image_LICENSE_Nuvola.txt0000644000175000017500000005664511674463635021235 0ustar varunvarunGNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: * a) The modified work must itself be a software library. * b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. * c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. * d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: * a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) * b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. * c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. * d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. * e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: * a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. * b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. enthought-chaco2-4.1.0.orig/kiva/0000755000175000017500000000000011674464656015642 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/pdfmetrics.py0000644000175000017500000005143111674463636020355 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.1.0.orig/kiva/affine.py0000644000175000017500000002007011674463635017437 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, alltrue, 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): """ """ 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. """ m1 = ravel(IDENTITY) m2 = ravel(m) return alltrue(m1 == m2) # numarray return None for .flat... #return alltrue(IDENTITY.flat == m.flat) 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) # x_p = a*x+c*y+tx # y_p = b*x+d*y+ty res = zeros(pts.shape, float64) res[...,0] = a*x+c*y+tx res[...,1] = b*x+d*y+ty return res enthought-chaco2-4.1.0.orig/kiva/cairo.py0000644000175000017500000013111411674463636017307 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.1.0.orig/kiva/__init__.py0000644000175000017500000000165311674463635017754 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. """ 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.") enthought-chaco2-4.1.0.orig/kiva/tests/0000755000175000017500000000000011674463636017001 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/tests/macport_test.py0000755000175000017500000000231111674463636022057 0ustar varunvarun#!/usr/bin/env pythonw import sys 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) print "constructed frame" def OnPaint(self, evt): dc = wx.PaintDC(self) print "paintdc.this:", dc.this print "paintdc.macport:", get_macport(dc) print "memdc.this:", self.memdc.this print "memdc.macport:", get_macport(self.memdc) class MyApp(wx.App): def OnInit(self): w = SimpleWindow() return 1 app = MyApp(False) app.MainLoop() enthought-chaco2-4.1.0.orig/kiva/tests/basecore2d_test_case.py0000644000175000017500000004263611674463636023431 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_width, 1) gc.set_line_width(5) gc.save_state() gc.set_line_width(10) self.assertEqual(gc.state.line_width, 10) gc.restore_state() self.assertEqual(gc.state.line_width, 5) def test_state_line_join(self): gc = basecore2d.GraphicsContextBase() # defaults to JOIN_MITER self.assertEqual(gc.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_join, constants.JOIN_ROUND) gc.restore_state() self.assertEqual(gc.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_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_cap, constants.CAP_SQUARE) gc.restore_state() self.assertEqual(gc.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.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.is_dashed()) self.assertEqual(gc.state.line_dash[0], 0) self.assert_(alltrue(ravel(gc.state.line_dash[1] == array([3.0, 4.0])))) gc.restore_state() self.assert_(gc.state.is_dashed()) self.assertEqual(gc.state.line_dash[0], 2.0) self.assert_(alltrue(ravel(gc.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 None self.assertEqual(gc.state.flatness, None) gc.set_flatness(1.0) gc.save_state() gc.set_flatness(2.0) self.assertEqual(gc.state.flatness, 2.0) gc.restore_state() self.assertEqual(gc.state.flatness, 1.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_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_color == array([1, 1, 1, 1]))) gc.restore_state() self.assert_(alltrue(gc.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_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_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_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_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_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_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_width, 10) gc.restore_state() self.assertEqual(gc.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.1.0.orig/kiva/tests/affine_test_case.py0000644000175000017500000001530711674463636022643 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.1.0.orig/kiva/basecore2d.py0000644000175000017500000016107111674463636020230 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! #------------------------------------------------------------------------------ """ 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. """ import affine import copy from numpy import alltrue, array, asarray, float64, sometrue, shape,\ pi, concatenate import numpy as np from constants import * def exactly_equal(arr1,arr2): return shape(arr1)==shape(arr2) and alltrue(arr1==arr2) #-------------------------------------------------------------------- # Import and initialize freetype engine for rendering. # # !! Need to figure out how to set dpi intelligently #-------------------------------------------------------------------- #from enthought import freetype # freetype engine for text rendering. #ft_engine = freetype.FreeType(dpi=120.0) #-------------------------------------------------------------------- # 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_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 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 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. """ result = 0 #--------------------------------------------------------------------- # 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]) if (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): result = 1 return result def fill_equal(fill1,fill2): """ Currently fill just compares the two colors. """ return alltrue(fill1 == fill2) 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) 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. Fields ------ ctm context transform matrix 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. 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 not sure character_spacing spacing between drawing text characters text_drawing_mode style for drawing text: outline, fill, etc. 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 LineState.__init__( self, line_color, line_width, line_cap, line_join, line_dash ) #--------------------------------------------------------------------- # 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 = freetype.FontInfo( # freetype.default_font_info.default_font ) self.font = None 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 ), float64 ) self.antialias = 1 # What should this default to? self.miter_limit = 1.0 # Not so sure about this one either. self.flatness = None # I think this is the correct default. self.character_spacing = 0.0 # Should it be outline also? self.text_drawing_mode = TEXT_FILL self.alpha = 1.0 def copy(self): return copy.deepcopy(self) class GraphicsContextBase(object): """ Fields ------ state Current state of graphics context. state_stack Stack used to save graphics states path The drawing path. active_subpath The active drawing subpath I *think* this class needs to be sub-classed by every device type that handles graphics. This is so that set_line_width() and similar functions can do things like setting up a new pen in wxPython, etc. This stuff could also be stored in the GraphicsState, and there are probably performance benefits for doing so. Maybe graphics state is the device dependent object?? Time will tell. path and active_subpath will probably need to be optimized somehow. """ 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] # Used as memory cache for transforming points #self.transform_points_cache = array((2,1)) # 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() #---------------------------------------------------------------- # Save/Restore graphics state. #---------------------------------------------------------------- def save_state(self): """ Saves the current graphic's context state. Always pair this with a `restore_state()`. """ 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 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_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_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.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_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_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_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 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.state.flatness = 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. """ 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: #print 'begin' #print self.path_transform_indices #print len(self.active_subpath) #tf = take(array(self.active_subpath,object), # 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),float64) self.state.current_point = pt #pt = affine.transform_point(self.get_ctm(),orig) 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),float64) self.state.current_point = pt #pt = affine.transform_point(self.get_ctm(),orig) 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 #pts = affine.transform_points(self.get_ctm(),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 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_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 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_color[:3]= color self.state.line_color[3]= 1.0 else: self.state.line_color[:]= color def set_alpha(self,alpha): """ """ self.state.alpha = alpha #def set_gray_fill_color(self): # """ # """ # pass #def set_gray_stroke_color(self): # """ # """ # pass #def set_rgb_fill_color(self): # """ # """ # pass #def set_rgb_stroke_color(self): # """ # """ # pass #def cmyk_fill_color(self): # """ # """ # pass #def cmyk_stroke_color(self): # """ # """ # pass #---------------------------------------------------------------- # Drawing Images #---------------------------------------------------------------- def draw_image(self,img,rect=None): """ """ self.device_draw_image(img, rect) #---------------------------------------------------------------- # Drawing PDF documents #---------------------------------------------------------------- #def draw_pdf_document(self): # """ # """ # pass #------------------------------------------------------------------------- # 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.state.font = None def set_font(self,font): """ Set the font for the current graphics context. """ self.state.font = 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. """ return 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 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) # No longer uses knowledge that matrix has 3x3 representation #self.state.text_matrix[2,:2] = (x,y) def get_text_position(self): """ """ a,b,c,d,tx,ty = affine.affine_params(self.state.text_matrix) return tx,ty # No longer uses knowledge that matrix has 3x3 representation #return self.state.text_matrix[2,:2] 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) #------------------------------------------------------------------------ # 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 ##--------------------------------------------------------------------- ## The fill_color is used to specify text color in wxPython. ## If it is transparent, we don't do any painting. ##--------------------------------------------------------------------- #if is_fully_transparent( self.state.fill_color ): # return # ##--------------------------------------------------------------------- ## Set the text transformation matrix ## ## This requires the concatenation of the text and coordinate ## transform matrices ##--------------------------------------------------------------------- #ttm = self.get_text_matrix() #ctm = self.get_ctm() # not device_ctm!! #m = affine.concat( ctm, ttm ) #a, b, c, d, tx, ty = affine.affine_params( m ) #ft_engine.transform( ( a, b, c, d ) ) # ## Select the correct font into the freetype engine: #f = self.state.font #ft_engine.select_font( f.name, f.size, f.style, f.encoding ) #ft_engine.select_font( 'Arial', 10 ) ### TEMPORARY ### # ## Set antialiasing flag for freetype engine: #ft_engine.antialias( self.state.antialias ) # ## Render the text: ## ## The returned object is a freetype.Glyphs object that contains an ## array with the gray scale image, the bbox and some other info. #rendered_glyphs = ft_engine.render( text ) # ## Render the glyphs in a device specific manner: #self.device_draw_glyphs( rendered_glyphs, tx, ty ) # ## Advance the current text position by the width of the glyph string: #ttm = self.get_text_matrix() #a, b, c, d, tx, ty = affine.affine_params( ttm ) #tx += rendered_glyphs.width #self.state.text_matrix = affine.affine_from_values( a, b, c, d, tx, ty ) 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 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_color[3] old_fill_alpha = self.state.fill_color[3] if mode not in [STROKE, FILL_STROKE, EOF_FILL_STROKE]: self.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 #print 'in:',self.device_ctm self.device_update_line_state() self.device_update_fill_state() for subpath in self.path: # reset the current point for drawing. #self.current_point = array((0.,0.)) 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_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: #print 'scale:', args self.device_ctm = affine.scale(self.device_ctm,args[0],args[1]) elif func == ROTATE_CTM: #print 'rotate:', args self.device_ctm = affine.rotate(self.device_ctm,args[0]) elif func == TRANSLATE_CTM: #print 'translate:', args self.device_ctm = affine.translate(self.device_ctm,args[0],args[1]) elif func == CONCAT_CTM: #print 'concat' self.device_ctm = affine.concat(self.device_ctm,args[0]) elif func == LOAD_CTM: #print 'load' 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) #raise NotImplementedError("device_get_full_text_extent() is not implemented") #ttm = self.get_text_matrix() #ctm = self.get_ctm() # not device_ctm!! #m = affine.concat( ctm, ttm ) #ft_engine.transform( affine.affine_params( m )[0:4] ) #f = self.state.font ### TEMPORARY ### #ft_engine.select_font( f.name, f.size, f.style, f.encoding ) ### TEMPORARY ### ##ft_engine.select_font( 'Arial', 10 ) ### TEMPORARY ### #ft_engine.antialias( self.state.antialias ) #glyphs = ft_engine.render( textstring ) #dy, dx = shape( glyphs.img ) #return ( dx, dy, -glyphs.bbox[1], 0 ) #---------------------------------------------------------------- # Extra routines that aren't part of DisplayPDF # # Some access to font metrics are needed for laying out text. # Not sure how to handle this yet. The candidates below are # from Piddle. Perhaps there is another alternative? # #---------------------------------------------------------------- #def font_height(self): # '''Find the total height (ascent + descent) of the given font.''' # #return self.font_ascent() + self.font_descent() #def font_ascent(self): # '''Find the ascent (height above base) of the given font.''' # pass #def font_descent(self): # '''Find the descent (extent below base) of the given font.''' # extents = self.dc.GetFullTextExtent(' ', wx_font) # return extents[2] enthought-chaco2-4.1.0.orig/kiva/agg/0000755000175000017500000000000011745330621016357 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/build.bat0000644000175000017500000000036011674463635020162 0ustar varunvarunrmdir /s /q build\temp.win32-2.4\Release rmdir /s /q build\temp.win32-2.4\src del build\temp.win32-2.4\*.a del *.pyd del agg.py del agg_wrap.cpp python setup.py build_src build_clib --compiler=mingw32 build_ext --inplace --compiler=mingw32 enthought-chaco2-4.1.0.orig/kiva/agg/todo.txt0000644000175000017500000000762211674463636020112 0ustar varunvarun Constructor ----------- DONE *. GraphicsContextArray constructor should call the clear() method after construction if it allocates the underlying Numeric array. If the array is passed in, clear() should not be called. clear(), clear_rect(), clear_rects() ------------------------------------ *. Implement a clear_rect that takes a rect argument. Users can either specify an optional alpha value or a full color to be used when clearing the rectangle. If the color is RGB, then alpha is assumed to be 1.0. The default will clear the rect to white with an alpha value of 1 (i.e. (1,1,1,1)). The CTM is used to transform the input rects. Currently, the method will fail if their is any rotation to the ctm. *. Implement a clear_rects that takes a rect list. Otherwise, it behaves identically to clear_rect. *. The clear() method behaves identically to clear_rect, accept you don't need to pass in a rectangle. Instead to ?erase()? so that clear can stick with the clear_rect semantics. path creation methods --------------------- *. Implement arc and arc_to. path rendering -------------- *. Fix fill_path() to handle all the features currently handled in the stroke_path() pipeline. *. Fix draw_image() to handle all the features currently handled in the stroke_path() pipeline. Text ---- *. Implement show_text() natively in agg. Allow switch between native/freetype on "the fly". *. Implement a measure_text() method in the kiva interface that returns the height, width, and vertical and horizontal letting for a string. This is returned in user coordinates. Do we also have need to return the device coordinates boudning box for the text? Clipping -------- *. Implement clipping renderer in agg that can work with Dave's non-overlapping rectangles calculated in Python code). *. Re-implement algorithm for calculating non-overlapping rectangles down into kiva-agg C++ code. *. API call to get access to the list of rectangles. Or, and API to test whether a rectangle overlaps the list of rectangles. Dave needs this for high level clipping (to determine if a widget needs repainting). *. Build algorithm to create optimal non-overlapping rectangles set to use for rendering. Code Reorganization ------------------- *. Reorganize code base so that: a. Library is usable from C++ b. Python interface files are separated out of C++ code. c. Organize C++ code so that it is easier to work with. Group related methods together and try and work around having the graphics_context stuff spread out across 4 files (.h, .cpp files for graphics_context and graphics_context_base) *. Make an enthought branch with enable and kiva so that we can port the enable to kiva. Work on Dependent Libraries --------------------------- *. Port enable to new kiva backend. *. Port chaco to use compiled paths wherever possible. Other Features -------------- *. Draft Mode flag Not sure if we need this, but it might be nice to set this flag and ask kiva to use the fastest possible underlying paths at the expense of accuracy. This might be worth while for scroll or drag operations. *. Patterns -- repeated images *. Transparency layers *. Gradients *. Shadows *. Color spaces *. Mask arraays *. Arbitrary clip paths *. SVG reader/renderer. This would allow us to use SVG objects saved out of Graphics programs instead of bitmaps for our buttons/controls/etc. *. SSE optimizations. *. OpenGL optimizations. enthought-chaco2-4.1.0.orig/kiva/agg/src/0000755000175000017500000000000011674463636017164 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/src/tst_convert.py0000644000175000017500000000014511674463636022110 0ustar varunvarunimport agg q=agg.Image((10,10),pix_format="rgb24") q.convert_pixel_format("rgba32") print q.format() enthought-chaco2-4.1.0.orig/kiva/agg/src/kiva_affine_helpers.h0000644000175000017500000000073411674463636023325 0ustar varunvarun#ifndef KIVA_AFFINE_MATRIX_H #define KIVA_AFFINE_MATRIX_H #include "agg_trans_affine.h" namespace kiva { bool is_identity(agg::trans_affine& mat, double epsilon=1e-3); bool only_translation(agg::trans_affine& mat, double epsilon=1e-3); bool only_scale_and_translation(agg::trans_affine& mat, double epsilon=1e-3); void get_translation(agg::trans_affine& m, double* tx, double* ty); void get_scale(agg::trans_affine& m, double* dx, double* dy); } #endif enthought-chaco2-4.1.0.orig/kiva/agg/src/todo.txt0000644000175000017500000003024311674463636020674 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.1.0.orig/kiva/agg/src/gl_test/0000755000175000017500000000000011674463636020625 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/src/gl_test/Lesson2.cpp0000644000175000017500000003671011674463636022665 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.1.0.orig/kiva/agg/src/gl_test/Lesson2.h0000644000175000017500000000135011674463636022322 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.1.0.orig/kiva/agg/src/gl_test/gl_test.cpp0000644000175000017500000000333511674463636022776 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(agg::rgba(1.0, 0.0, 0.0)); gc.set_stroke_color(agg::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.1.0.orig/kiva/agg/src/gl_test/gl_test.vcproj0000644000175000017500000000732211674463636023517 0ustar varunvarun enthought-chaco2-4.1.0.orig/kiva/agg/src/kiva_font_type.cpp0000755000175000017500000000653611674463636022726 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.1.0.orig/kiva/agg/src/numeric_ext.i0000644000175000017500000000616211674463636021665 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.1.0.orig/kiva/agg/src/font_type.i0000644000175000017500000000410611674463636021346 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.1.0.orig/kiva/agg/src/constants.i0000644000175000017500000001203611674463636021354 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 & agg::path_cmd_mask; } inline unsigned path_flags(unsigned c) { return c & agg::path_flags_mask; } %} %include "agg_typemaps.i" %apply(kiva_enum_typemap) { agg::path_flags_e }; %apply(kiva_enum_typemap) { agg::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.1.0.orig/kiva/agg/src/kiva_rect.h0000755000175000017500000000707311674463636021316 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(agg::rect_i r) { *this = r; } inline rect_type(agg::rect_d r) { *this = r; } // conversion from agg::rect inline rect_type& operator=(agg::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=(agg::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 agg::rect inline operator agg::rect_i() const { return agg::rect_i(int(x), int(y), int(w), int(h)); } inline operator agg::rect_d() const { return agg::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.1.0.orig/kiva/agg/src/rgba_array.i0000644000175000017500000000475511674463636021462 0ustar varunvarun// -------------------------------------------------------------------------- // // Convert agg::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 agg::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_agg__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 agg::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.1.0.orig/kiva/agg/src/hit_test.i0000644000175000017500000000642611674463636021171 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.1.0.orig/kiva/agg/src/compiled_path.i0000644000175000017500000001107011674463636022145 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(agg::trans_affine&); void concat_ctm(agg::trans_affine& m); %rename(set_ctm_agg) set_ctm(agg::trans_affine&); void set_ctm(agg::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)) %} agg::trans_affine get_ctm(); void save_ctm(); void restore_ctm(); // methods from agg::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.1.0.orig/kiva/agg/src/gtk1/0000755000175000017500000000000011674463636020032 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/src/gtk1/agg_platform_specific.cpp0000644000175000017500000003036511674463636025054 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 agg { 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.1.0.orig/kiva/agg/src/gtk1/agg_bmp.h0000644000175000017500000000221711674463636021601 0ustar varunvarun// -*- c++ -*- #ifndef AGG_GTK1_BMP_INCLUDED #define AGG_GTK1_BMP_INCLUDED #include "Python.h" #include "gtk1/agg_platform_specific.h" namespace agg { 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; 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.1.0.orig/kiva/agg/src/gtk1/plat_support.i0000644000175000017500000000624011674463636022742 0ustar varunvarun// -*- c++ -*- %module plat_support %include numeric.i %{ #include "gtk1/agg_bmp.h" namespace agg { PyObject* pixel_map_as_unowned_array(agg::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 agg { 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(agg::pixel_map& pix_map); // clear the "permissive" unsigned typemap we are using. %typemap(in) unsigned; enthought-chaco2-4.1.0.orig/kiva/agg/src/gtk1/agg_bmp.cpp0000644000175000017500000000756411674463636022146 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 agg { //------------------------------------------------------------------------ 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 #include "agg_basics.h" #include "agg_rendering_buffer.h" namespace agg { 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.1.0.orig/kiva/agg/src/graphics_context.i0000644000175000017500000012241711674463636022711 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 {agg::rgba&}; %{ agg::rgba _clear_color = agg::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: msg = "2D arrays must use a format that is one byte per pixel" assert img_depth == 1, msg elif len(sh) == 3: msg = "Image depth and format are incompatible" assert img_depth == sh[2], 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(agg::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, agg::marker_e type = agg::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, agg::marker_e type=agg::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.1.0.orig/kiva/agg/src/x11/0000755000175000017500000000000011674463636017575 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/src/x11/agg_platform_specific.cpp0000644000175000017500000003135611674463636024620 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 agg { 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.1.0.orig/kiva/agg/src/x11/agg_bmp.h0000644000175000017500000000245211674463636021345 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 agg { 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.1.0.orig/kiva/agg/src/x11/plat_support.i0000644000175000017500000000666411674463636022517 0ustar varunvarun// -*- c++ -*- %module plat_support %include numeric.i %{ #include "x11/agg_bmp.h" namespace agg { PyObject* pixel_map_as_unowned_array(agg::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 agg { 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(agg::pixel_map& pix_map); // clear the "permissive" unsigned typemap we are using. %typemap(in) unsigned; enthought-chaco2-4.1.0.orig/kiva/agg/src/x11/agg_bmp.cpp0000644000175000017500000001413511674463636021701 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/src/x11/agg_platform_specific.h0000644000175000017500000000446011674463636024261 0ustar varunvarun// -*- c++ -*- #ifndef AGG_X11_SPECIFIC_INCLUDED #define AGG_X11_SPECIFIC_INCLUDED #include #include "agg_basics.h" #include "agg_rendering_buffer.h" namespace agg { 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.1.0.orig/kiva/agg/src/readme.txt0000644000175000017500000000524011674463636021163 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.1.0.orig/kiva/agg/src/gl_graphics_context.h0000644000175000017500000001336011674463636023366 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(agg::rgba value=agg::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, agg::marker_e type=agg::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.1.0.orig/kiva/agg/src/kiva_exceptions.h0000644000175000017500000000041211674463636022525 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.1.0.orig/kiva/agg/src/numeric.i0000644000175000017500000002561011674463636021004 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.1.0.orig/kiva/agg/src/kiva_gradient.cpp0000644000175000017500000000146011674463636022500 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.1.0.orig/kiva/agg/src/kiva.vcproj0000644000175000017500000010346311674463636021352 0ustar varunvarun enthought-chaco2-4.1.0.orig/kiva/agg/src/kiva_alpha_gamma.h0000644000175000017500000000065211674463636022601 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)); } agg::gamma_multiply m_alpha; agg::gamma_power m_gamma; }; } #endif enthought-chaco2-4.1.0.orig/kiva/agg/src/affine_matrix.i0000644000175000017500000001533511674463636022161 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. agg::trans_affine* trans_affine_rotation(double a) { return new agg::trans_affine(cos(a), sin(a), -sin(a), cos(a), 0.0, 0.0); } agg::trans_affine* trans_affine_scaling(double sx, double sy) { return new agg::trans_affine(sx, 0.0, 0.0, sy, 0.0, 0.0); } agg::trans_affine* trans_affine_translation(double tx, double ty) { return new agg::trans_affine(1.0, 0.0, 0.0, 1.0, tx, ty); } agg::trans_affine* trans_affine_skewing(double sx, double sy) { return new agg::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); agg::trans_affine* trans_affine_rotation(double a); %newobject trans_affine_scaling; %rename(scaling_matrix) trans_affine_scaling(double, double); agg::trans_affine* trans_affine_scaling(double sx, double sy); %newobject trans_affine_translation; %rename(translation_matrix) trans_affine_translation(double, double); agg::trans_affine* trans_affine_translation(double tx, double ty); %newobject trans_affine_skewing; %rename(skewing_matrix) trans_affine_skewing(double, double); agg::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 { agg::trans_affine* }; namespace agg { %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 agg::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__(agg::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.1.0.orig/kiva/agg/src/kiva_affine_helpers.cpp0000644000175000017500000000262711674463636023663 0ustar varunvarun#include "kiva_affine_helpers.h" #include #define f_eq(a,b) (fabs((a)-(b)) < epsilon) namespace kiva { bool is_identity(agg::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(agg::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(agg::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(agg::trans_affine& m, double* tx, double* ty) { double temp[6]; m.store_to(temp); *tx = temp[4]; *ty = temp[5]; } void get_scale(agg::trans_affine& m, double* dx, double* dy) { { double temp[6]; m.store_to(temp); *dx = temp[0]; *dy = temp[3]; } } } enthought-chaco2-4.1.0.orig/kiva/agg/src/kiva.sln0000644000175000017500000000257411674463636020644 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.1.0.orig/kiva/agg/src/win32/0000755000175000017500000000000011674463636020126 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/src/win32/agg_platform_specific.cpp0000644000175000017500000002267211674463636025152 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 agg { 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.1.0.orig/kiva/agg/src/win32/agg_bmp.h0000644000175000017500000000244111674463636021674 0ustar varunvarun// -*- c++ -*- #ifndef AGG_WIN32_BMP_INCLUDED #define AGG_WIN32_BMP_INCLUDED #include "Python.h" #include "win32/agg_platform_specific.h" namespace agg { 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.1.0.orig/kiva/agg/src/win32/plat_support.i0000644000175000017500000000724111674463636023040 0ustar varunvarun// -*- c++ -*- %module plat_support %include numeric.i %{ #include "win32/agg_bmp.h" namespace agg { PyObject* pixel_map_as_unowned_array(agg::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 agg { 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.1.0.orig/kiva/agg/src/win32/agg_bmp.cpp0000644000175000017500000001032411674463636022226 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/src/win32/wx_agg_debug/0000755000175000017500000000000011674463636022550 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/src/win32/wx_agg_debug/wx_agg_debug.dsw0000755000175000017500000000100611674463636025711 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.1.0.orig/kiva/agg/src/win32/wx_agg_debug/wx_agg_debug.dsp0000755000175000017500000001043511674463636025710 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.1.0.orig/kiva/agg/src/win32/agg_platform_specific.h0000644000175000017500000000503711674463636024613 0ustar varunvarun// -*- c++ -*- #ifndef AGG_WIN32_SPECIFIC_INCLUDED #define AGG_WIN32_SPECIFIC_INCLUDED #include #include "agg_basics.h" #include "agg_rendering_buffer.h" namespace agg { 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.1.0.orig/kiva/agg/src/swig_questions.txt0000644000175000017500000001475311674463636023022 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.1.0.orig/kiva/agg/src/agg_typemaps.i0000644000175000017500000002562111674463636022024 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 agg::marker_e, do the following // // %apply(kiva_enum_typemap) { agg::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); agg::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.1.0.orig/kiva/agg/src/kiva_pix_format.h0000644000175000017500000000617111674463636022524 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(agg::pixfmt_gray8 *msvc6_dummy = NULL) { return kiva::pix_format_gray8; } inline kiva::pix_format_e agg_pix_to_kiva(agg::pixfmt_rgb24 *msvc6_dummy = NULL) { return kiva::pix_format_rgb24; } inline kiva::pix_format_e agg_pix_to_kiva(agg::pixfmt_bgr24 *msvc6_dummy = NULL) { return kiva::pix_format_bgr24; } inline kiva::pix_format_e agg_pix_to_kiva(agg::pixfmt_bgra32 *msvc6_dummy = NULL) { return kiva::pix_format_bgra32; } inline kiva::pix_format_e agg_pix_to_kiva(agg::pixfmt_rgba32 *msvc6_dummy = NULL) { return kiva::pix_format_rgba32; } inline kiva::pix_format_e agg_pix_to_kiva(agg::pixfmt_argb32 *msvc6_dummy = NULL) { return kiva::pix_format_argb32; } inline kiva::pix_format_e agg_pix_to_kiva(agg::pixfmt_abgr32 *msvc6_dummy = NULL) { return kiva::pix_format_abgr32; } } #endif enthought-chaco2-4.1.0.orig/kiva/agg/src/gl/0000755000175000017500000000000011674463636017566 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/src/gl/agg_bmp.h0000644000175000017500000000461211674463636021336 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 agg { 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.1.0.orig/kiva/agg/src/gl/plat_support.i0000644000175000017500000000712411674463636022500 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 agg { PyObject* pixel_map_as_unowned_array(agg::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 agg { 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.1.0.orig/kiva/agg/src/gl/agg_bmp.cpp0000644000175000017500000001606011674463636021671 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/src/kiva.dsp0000644000175000017500000004743511674463636020643 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.1.0.orig/kiva/agg/src/rect.i0000644000175000017500000000166011674463636020276 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.1.0.orig/kiva/agg/src/kiva_compiled_path.h0000644000175000017500000001131211674463636023155 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 agg::path_storage { /*------------------------------------------------------------------- This extends the standard agg::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 agg::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? -------------------------------------------------------------------*/ agg::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(agg::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(agg::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(agg::trans_affine& m); void set_ctm(agg::trans_affine& m); agg::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.1.0.orig/kiva/agg/src/kiva_compiled_path.cpp0000644000175000017500000002064311674463636023517 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() { //agg::path_storage::remove_all(); // fix me: call to base:: to appease VC++6.0 this->base::remove_all(); this->_has_curves = false; //ptm = agg::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*agg::pi - sweep_angle); } agg::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 (!agg::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). agg::trans_affine_translation xform(-x1, -y1); double xform_angle = -atan2(y0-y1, x0-x1); if (!kiva::almost_equal(fmod(xform_angle, 2*agg::pi), 0.0)) { xform *= agg::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); agg::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(!agg::is_stop(cmd)) { this->_has_curves |= agg::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); } //{ // agg::conv_transform trans(p,ptm); // agg::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(agg::trans_affine& m) { this->ptm.premultiply(m); } void compiled_path::translate_ctm(double x, double y) { agg::trans_affine_translation m(x,y); this->_transform_ctm(m); } void compiled_path::rotate_ctm(double angle) { agg::trans_affine_rotation m(angle); this->_transform_ctm(m); } void compiled_path::scale_ctm(double sx, double sy) { agg::trans_affine_scaling m(sx,sy); this->_transform_ctm(m); } void compiled_path::concat_ctm(agg::trans_affine& m) { agg::trans_affine m_copy(m); this->_transform_ctm(m_copy); } void compiled_path::set_ctm(agg::trans_affine& m) { this->ptm = agg::trans_affine(m); } agg::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.1.0.orig/kiva/agg/src/kiva_graphics_context.h0000644000175000017500000016521411674463636023724 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 agg::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 agg::renderer_base renderer_base_type; typedef agg::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(agg::rgba value=agg::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, agg::marker_e type=agg::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, agg::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 { agg::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 { agg::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) { agg::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 agg::renderer_scanline_bin_solid renderer_bin_type; renderer_bin_type renderer(input_renderer); agg::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 agg::renderer_scanline_aa_solid renderer_aa_type; renderer_aa_type renderer(input_renderer); agg::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 agg::renderer_primitives primitives_renderer_type; typedef agg::rasterizer_outline rasterizer_type; primitives_renderer_type primitives_renderer(input_renderer); // set line color -- multiply by alpha if it is set. agg::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 agg::renderer_outline_aa outline_renderer_type; typedef agg::rasterizer_outline_aa rasterizer_type; // fix me: scale width by ctm agg::line_profile_aa profile(this->state.line_width, agg::gamma_none()); outline_renderer_type renderer(input_renderer, profile); // set line color -- multiply by alpha if it is set. agg::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) { agg::rasterizer_scanline_aa<> rasterizer; agg::conv_stroke stroked_path(input_path); // fix me: scale width by ctm stroked_path.width(this->state.line_width); // handle line cap agg::line_cap_e cap = agg::butt_cap; if (this->state.line_cap == CAP_ROUND) { cap = agg::round_cap; } else if (this->state.line_cap == CAP_BUTT) { cap = agg::butt_cap; } else if (this->state.line_cap == CAP_SQUARE) { cap = agg::square_cap; } stroked_path.line_cap(cap); // handle join agg::line_join_e join = agg::miter_join; if (this->state.line_join == JOIN_MITER) { join = agg::miter_join; } else if (this->state.line_join == JOIN_ROUND) { join = agg::round_join; } else if (this->state.line_join == JOIN_BEVEL) { join = agg::bevel_join; } stroked_path.line_join(join); // set line color -- multiply by alpha if it is set. agg::rgba color; color = this->state.line_color; color.a *= this->state.alpha; renderer.color(color); // render rasterizer.add_path(stroked_path); agg::render_scanlines(rasterizer, scanline, renderer); } //-------------------------------------------------------------------- // Fill Path Pipeline. // // See implementation_notes.txt for details. //-------------------------------------------------------------------- public: void fill_path() { this->_fill_path(agg::fill_non_zero); this->path.remove_all(); } public: void eof_fill_path() { this->_fill_path(agg::fill_even_odd); this->path.remove_all(); } private: void _fill_path(agg::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 { agg::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, agg::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); agg::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... agg::rasterizer_scanline_aa<> rasterizer; rasterizer.filling_rule(rule); rasterizer.add_path(clipped); if (this->state.gradient_fill.gradient_type == kiva::grad_none) { agg::scanline_u8 scanline; // fix me: we need to select the renderer in another method. agg::renderer_scanline_aa_solid< renderer_base_type > aa_renderer(this->renderer); // set fill color -- multiply by alpha if it is set. agg::rgba color; color = this->state.fill_color; color.a *= this->state.alpha; aa_renderer.color(color); // draw the filled path to the buffer agg::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, agg::trans_affine& img_mtx) { agg::path_storage img_outline = img.boundary_path(img_mtx); agg::rendering_buffer* src_buf = img.rendering_buffer_ptr(); agg::trans_affine inv_img_mtx = img_mtx; inv_img_mtx.invert(); agg::span_interpolator_linear<> interpolator(inv_img_mtx); agg::rgba back_color = agg::rgba(1,1,1,0); agg::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: { agg::image_filter_lut filter; switch (img.get_image_interpolation()) { case bicubic: filter.calculate(agg::image_filter_bicubic()); break; case spline16: filter.calculate(agg::image_filter_spline16()); break; case spline36: filter.calculate(agg::image_filter_spline36()); break; case sinc64: filter.calculate(agg::image_filter_sinc64()); break; case sinc144: filter.calculate(agg::image_filter_sinc144()); break; case sinc256: filter.calculate(agg::image_filter_sinc256()); break; case blackman64: filter.calculate(agg::image_filter_blackman64()); break; case blackman100: filter.calculate(agg::image_filter_blackman100()); break; case blackman256: filter.calculate(agg::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(agg::path_storage& img_outline, span_gen_type span_generator) { typedef agg::span_allocator span_alloc_type; span_alloc_type span_allocator; agg::scanline_u8 scanline; agg::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); agg::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; agg::scanline_p8 scanline; agg::renderer_scanline_aa_solid< renderer_base_type > aa_renderer(this->renderer); agg::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. agg::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(agg::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(agg::fill_non_zero); break; case EOF_FILL: this->_fill_path(agg::fill_even_odd); break; case STROKE: this->_stroke_path(); break; case FILL_STROKE: this->_fill_path(agg::fill_non_zero); this->_stroke_path(); break; case EOF_FILL_STROKE: this->_fill_path(agg::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; agg::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 ) { agg::renderer_primitives renderer(this->renderer); renderer.fill_color(this->get_fill_color()); // use transparency to indicate a 0 width line agg::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, agg::marker_e type) { int success = 0; agg::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!! agg::renderer_markers< renderer_base_type > m(this->renderer); m.fill_color(this->get_fill_color()); // use transparency to indicate an 0 width line agg::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. agg::rgba color; color = this->state.fill_color; color.a *= this->state.alpha; this->renderer.attribute(color); agg::trans_affine ctm = this->get_ctm(); // set the rasterizer filling rule if (mode & FILL) this->rasterizer.filling_rule(agg::fill_non_zero); else if (mode & EOF_FILL) this->rasterizer.filling_rule(agg::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 agg::glyph_raster_bin GlyphGeneratorType; typedef agg::renderer_scanline_aa_solid ScanlineRendererType; //GlyphGeneratorType glyphGen(0); ScanlineRendererType scanlineRenderer(this->renderer); const agg::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. agg::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) { agg::render_scanlines(font_manager->gray8_adaptor(), font_manager->gray8_scanline(), scanlineRenderer); } advance_x += glyph->advance_x; advance_y += glyph->advance_y; p++; } agg::trans_affine null_xform = agg::trans_affine_translation(0., 0.); font_engine->transform(null_xform); this->_release_font_manager(); agg::trans_affine trans = agg::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(); agg::trans_affine img_mtx = agg::trans_affine_scaling(sx,sy); img_mtx *= agg::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 { agg::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 { agg::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, agg::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.1.0.orig/kiva/agg/src/sequence_to_array.i0000644000175000017500000000175511674463636023056 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.1.0.orig/kiva/agg/src/gl_graphics_context.cpp0000644000175000017500000010233111674463636023716 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 agg::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. agg::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(agg::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 & agg::path_cmd_mask) { case agg::path_cmd_line_to: if (!first_vertex_drawn) { pointList.push_back(v0); first_vertex_drawn = true; } pointList.push_back(v); break; case agg::path_cmd_end_poly: // We shouldn't need to do anything because if this is a closed path // //if (command & agg::path_flags_close) // glVertex2f(x0, y0); break; case agg::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 agg::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 agg::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 agg::path_cmd_ubspline: break; // XXX: This case number is already used?? //case agg::path_cmd_mask: // break; // Unsupported // XXX: We need to have better error handling/reporting from the C++ // layer up to the Python layer. case agg::path_cmd_catrom: case agg::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. agg::rgba *line_color = &this->state.line_color; agg::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 agg::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 & agg::path_cmd_mask) == agg::path_cmd_curve3) || ((cmd & agg::path_cmd_mask) == agg::path_cmd_curve4) || ((cmd & agg::path_cmd_mask) == agg::path_cmd_line_to)) { if ((x0 == xf) && (y0 == yf)) polygon = true; break; } if ((cmd & agg::path_cmd_mask) == agg::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) { agg::rgba *line_color = &this->state.line_color; agg::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, agg::marker_e type) { agg::rgba *line_color = &this->state.line_color; agg::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 agg::marker_x: draw_x_marker(pts, Npts, size, draw_mode, x0, y0); break; case agg::marker_cross: draw_cross(pts, Npts, size, draw_mode, x0, y0); break; case agg::marker_dot: draw_dot(pts, Npts, size, draw_mode, x0, y0); break; case agg::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 agg::marker_square: draw_square(pts, Npts, size, draw_mode, x0, y0); break; case agg::marker_diamond: draw_diamond(pts, Npts, size, draw_mode, x0, y0); break; case agg::marker_crossed_circle: draw_crossed_circle(pts, Npts, size, draw_mode, x0, y0); break; case agg::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 agg::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 agg::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) { agg::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) { agg::rgba *line_color = &this->state.line_color; agg::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; agg::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.1.0.orig/kiva/agg/src/kiva_graphics_context_base.h0000644000175000017500000003232611674463636024713 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 agg::font_engine_freetype_int32 font_engine_type; #endif #ifdef KIVA_USE_WIN32 typedef agg::font_engine_win32_tt_int32 font_engine_type; #endif typedef agg::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. agg::trans_affine text_matrix; kiva::graphics_state state; std::stack state_stack; agg::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; agg::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(agg::rgba& value); agg::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(agg::rgba& value); // need get method for freetype renderer. // should I return a reference?? agg::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(agg::trans_affine& value); agg::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(agg::trans_affine& m); void set_ctm(agg::trans_affine& m); agg::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); agg::path_storage boundary_path(agg::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(agg::rgba value=agg::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, agg::marker_e type=agg::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.1.0.orig/kiva/agg/src/kiva_rect.cpp0000755000175000017500000002541711674463636021653 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.1.0.orig/kiva/agg/src/kiva_constants.h0000644000175000017500000001165211674463636022370 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.1.0.orig/kiva/agg/src/agg_std_string.i0000644000175000017500000000113211674463636022331 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.1.0.orig/kiva/agg/src/kiva_dash_type.h0000644000175000017500000000227211674463636022332 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.1.0.orig/kiva/agg/src/kiva_basics.h0000755000175000017500000000666611674463636021634 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.1.0.orig/kiva/agg/src/kiva_gradient.h0000644000175000017500000002464011674463636022152 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; agg::rgba8 color; gradient_stop(double offset, agg::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: agg::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, agg::rasterizer_scanline_aa<>* ras, agg::renderer_mclip* rbase) { if (this->gradient_type == kiva::grad_linear) { if (this->points[0].first == this->points[1].first) { agg::gradient_y grad_func; // apply the proper fill adapter based on the spread method if (this->spread_method == kiva::reflect) { agg::gradient_reflect_adaptor adaptor(grad_func); this->_apply(pixfmt, ras, rbase, adaptor); } else if (this->spread_method == kiva::repeat) { agg::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) { agg::gradient_x grad_func; // apply the proper fill adapter based on the spread method if (this->spread_method == kiva::reflect) { agg::gradient_reflect_adaptor adaptor(grad_func); this->_apply(pixfmt, ras, rbase, adaptor); } else if (this->spread_method == kiva::repeat) { agg::gradient_repeat_adaptor adaptor(grad_func); this->_apply(pixfmt, ras, rbase, adaptor); } else { this->_apply(pixfmt, ras, rbase, grad_func); } } else { agg::gradient_x grad_func; // apply the proper fill adapter based on the spread method if (this->spread_method == kiva::reflect) { agg::gradient_reflect_adaptor adaptor(grad_func); this->_apply(pixfmt, ras, rbase, adaptor); } else if (this->spread_method == kiva::repeat) { agg::gradient_repeat_adaptor adaptor(grad_func); this->_apply(pixfmt, ras, rbase, adaptor); } else { this->_apply(pixfmt, ras, rbase, grad_func); } } } else { agg::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) { agg::gradient_reflect_adaptor adaptor(grad_func); this->_apply(pixfmt, ras, rbase, adaptor); } else if (this->spread_method == kiva::repeat) { agg::gradient_repeat_adaptor adaptor(grad_func); this->_apply(pixfmt, ras, rbase, adaptor); } else { this->_apply(pixfmt, ras, rbase, grad_func); } } } void set_ctm(const agg::trans_affine& mtx) { this->affine_mtx = mtx; } protected: template void _apply(pixfmt_type pixfmt, agg::rasterizer_scanline_aa<>* ras, agg::renderer_mclip* rbase, gradient_func_type gradient_func) { typedef agg::renderer_mclip renderer_base_type; typedef agg::span_interpolator_linear<> interpolator_type; typedef agg::span_allocator span_allocator_type; typedef agg::pod_auto_array color_array_type; typedef agg::span_gradient span_gradient_type; typedef agg::renderer_scanline_aa renderer_gradient_type; agg::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 agg::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 *= agg::trans_affine_rotation(atan2(0.0, dy)); } else if (points[0].second == points[1].second) { // gradient_x. handle flips gradient_mtx *= agg::trans_affine_rotation(atan2(0.0, dx)); } else { // general case: arbitrary rotation gradient_mtx *= agg::trans_affine_rotation(atan2(dy, dx)); } } gradient_mtx *= agg::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); agg::render_scanlines(*ras, scanline, grad_renderer); } template void fill_color_array(Array& array) { // The agg::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; 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) && (offset <=1.0)) { array[i] = stop_it->color.gradient(next_it->color, (offset-stop_it->offset)/offset_range); i++; offset = i/double(array.size()); } } } }; } #endif enthought-chaco2-4.1.0.orig/kiva/agg/src/kiva_font_type.h0000644000175000017500000000267711674463636022372 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.1.0.orig/kiva/agg/src/kiva_hit_test.h0000644000175000017500000000123711674463636022175 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.1.0.orig/kiva/agg/src/kiva.dsw0000644000175000017500000000076611674463636020646 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.1.0.orig/kiva/agg/src/dummy.cpp0000644000175000017500000003713011674463636021027 0ustar varunvarun#include "agg_trans_affine.h" #include "kiva_graphics_context.h" #include "kiva_compiled_path.h" #include "kiva_hit_test.h" #include "kiva_font_type.h" #include "kiva_rect.h" #include // 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; } agg::rgba black(0.0, 0.0, 0.0); agg::rgba white(1.0, 1.0, 1.0); agg::rgba lightgray(0.2, 0.2, 0.2); agg::rgba red(1.0, 0.0, 0.0); agg::rgba green(0.0, 1.0, 0.0); agg::rgba blue(0.0, 0.0, 1.0); agg::rgba niceblue(0.411, 0.584, 0.843); typedef agg::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++) { agg::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(); agg::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(); //agg::trans_affine_translation txtTrans(200.0,150.0); agg::trans_affine_rotation txtRot(agg::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(); agg::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, agg::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.1.0.orig/kiva/agg/src/kiva_image_filters.h0000644000175000017500000000776611674463636023201 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 agg::span_interpolator_linear<> interpolator_type; template class image_filters { }; template<> class image_filters { public: typedef agg::image_accessor_clip source_type; typedef agg::span_image_filter_rgba_nn nearest_type; typedef agg::span_image_filter_rgba_bilinear bilinear_type; typedef agg::span_image_filter_rgba general_type; }; template<> class image_filters { public: typedef agg::image_accessor_clip source_type; typedef agg::span_image_filter_rgba_nn nearest_type; typedef agg::span_image_filter_rgba_bilinear bilinear_type; typedef agg::span_image_filter_rgba general_type; }; template<> class image_filters { public: typedef agg::image_accessor_clip source_type; typedef agg::span_image_filter_rgba_nn nearest_type; typedef agg::span_image_filter_rgba_bilinear bilinear_type; typedef agg::span_image_filter_rgba general_type; }; template<> class image_filters { public: typedef agg::image_accessor_clip source_type; typedef agg::span_image_filter_rgba_nn nearest_type; typedef agg::span_image_filter_rgba_bilinear bilinear_type; typedef agg::span_image_filter_rgba general_type; }; template<> class image_filters { public: typedef agg::image_accessor_clip source_type; typedef agg::span_image_filter_rgb_nn nearest_type; typedef agg::span_image_filter_rgb_bilinear bilinear_type; typedef agg::span_image_filter_rgb general_type; }; template<> class image_filters { public: typedef agg::image_accessor_clip source_type; typedef agg::span_image_filter_rgb_nn nearest_type; typedef agg::span_image_filter_rgb_bilinear bilinear_type; typedef agg::span_image_filter_rgb general_type; }; } #endif enthought-chaco2-4.1.0.orig/kiva/agg/src/rgba.i0000644000175000017500000000405511674463636020255 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 agg { %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 agg::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__(agg::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.1.0.orig/kiva/agg/src/kiva_hit_test.cpp0000644000175000017500000001043711674463636022532 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 #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 agg::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; agg::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(agg::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(agg::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.1.0.orig/kiva/agg/src/kiva_graphics_context_base.cpp0000755000175000017500000004116411674463636025251 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); } agg::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(agg::rgba& value) { this->state.line_color = value; } agg::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(agg::rgba& value) { this->state.fill_color = value; } agg::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]; agg::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(agg::trans_affine& value) { this->text_matrix = value; } agg::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(agg::trans_affine& m) { this->path.concat_ctm(m); } void graphics_context_base::set_ctm(agg::trans_affine& m) { this->path.set_ctm(m); } agg::trans_affine graphics_context_base::get_ctm() { return this->path.get_ctm(); } void graphics_context_base::get_freetype_text_matrix(double* out) { agg::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); } agg::path_storage graphics_context_base::boundary_path(agg::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. agg::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 agg::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 agg::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, agg::glyph_ren_agg_gray8); } else { font_engine->load_font(font->name.c_str(), 0, agg::glyph_ren_agg_gray8); } #endif #ifdef KIVA_USE_WIN32 font_engine->create_font(font->name, agg::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.1.0.orig/kiva/agg/__init__.py0000644000175000017500000000333711674463635020513 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" 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=1): assert type(size) is type(()),`size` width,height = size pixel_map = PixelMap(width,height, pix_format_string_map[pix_format], 255, 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.1.0.orig/kiva/agg/tests/0000755000175000017500000000000011674463636017537 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/tests/test_save.py0000644000175000017500000000246211674463636022112 0ustar varunvarunimport os import unittest from numpy import allclose, ravel import nose from kiva import agg # FIXME: # These tests are broken, and Peter promised to fix it at some point. class Test_Save(unittest.TestCase): format_output_map = { "rgb24": [255,255,255,255,255,255,255,0,0,255,0,0], "bgr24": [255,255,255,255,255,255,0,0,255,0,0,255], "rgba32": [255,255,255,255,255,255,255,255,255,0,0,255,255,0,0,255], "bgra32": [255,255,255,255,255,255,255,255,0,0,255,255,0,0,255,255] } def test_rgb24_format(self): self.do_check_format('rgb24') def test_bgr24_format(self): self.do_check_format('bgr24') def test_rgba32_format(self): self.do_check_format('rgba32') def test_bgra32_format(self): self.do_check_format('bgra32') def do_check_format(self,fmt): # FIXME: raise nose.SkipTest gc = agg.GraphicsContextArray((2,2), fmt) gc.set_stroke_color((1.0,0.0,0.0)) gc.move_to(0.0, 0.5) gc.line_to(2.0, 0.5) gc.stroke_path() gc.save(fmt + ".png") img = agg.Image(fmt + ".png") os.unlink(fmt + ".png") self.assertEqual(list(ravel(img.bmp_array)), self.format_output_map[fmt]) if __name__ == "__main__": unittest.main() enthought-chaco2-4.1.0.orig/kiva/agg/tests/join_stroke_path_test_case.py0000644000175000017500000001574711674463636025523 0ustar varunvarun""" Needed Tests Joins DONE 1. Each version same for all paths through aliased code. DONE 2. Each version same for all paths through antialiased code. Dashed Lines *. Should be tested for all versions of aliasing and all versions of join, cap. Clipping 1. Test that clip_to_rect is inclusive on lower end and exclusive on upper end. 2. Test that clip_to_rect behaves intelligently under ctm transforms. Note: There are numerous comments in code that refer to implementation details (outline, outline_aa, scanline_aa, etc.) from the C++ code. These are largely to help keep track of what paths have been tested. """ import unittest from numpy import array, alltrue, ravel from kiva.agg import GraphicsContextArray import kiva from test_utils import Utils class JoinStrokePathTestCase(unittest.TestCase, Utils): def helper(self, antialias, width, line_cap, line_join, size=(10,10)): gc = GraphicsContextArray(size, pix_format="rgb24") # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) # single horizontal line across bottom of buffer gc.move_to(1, 3) gc.line_to(7, 3) gc.line_to(7, 9) # Settings allow the faster outline path through C++ code gc. set_stroke_color((0.0, 0.0, 0.0)) # black gc.set_antialias(antialias) gc.set_line_width(width) gc.set_line_cap(line_cap) gc.set_line_join(line_join) gc.stroke_path() return gc def _test_alias_miter(self): """ fix me: This is producing aliased output. I am not sure what this array should look like exactly, so we just force it to fail right now and print out the results. """ antialias = False width = 3 line_cap = kiva.CAP_BUTT line_join = kiva.JOIN_MITER gc = self.helper(antialias, width, line_cap, line_join) actual = gc.bmp_array[:,:,0] assert 0, "join=miter, width=3, antialias=False\n%s" % actual #assert_arrays_equal(actual, desired) def _test_alias_bevel(self): """ fix me: This is producing a line width of 4 instead of 3. I am not sure what this array should look like exactly, so we just force it to fail right now and print out the results. """ antialias = False width = 3 line_cap = kiva.CAP_BUTT line_join = kiva.JOIN_BEVEL gc = self.helper(antialias, width, line_cap, line_join) actual = gc.bmp_array[:,:,0] assert 0, "join=bevel, width=3, antialias=False\n%s" % actual #assert_arrays_equal(actual, desired) def _test_alias_round(self): """ fix me: This is producing a line width of 4 instead of 3. Also, the corner doesn't look so round. I have checked that the scanline_aa renderer is setting the stroked_path.line_join() value to agg::round_join. I am not sure what this array should look like exactly, so we just force it to fail right now and print out the results. """ antialias = False width = 3 line_cap = kiva.CAP_BUTT line_join = kiva.JOIN_ROUND gc = self.helper(antialias, width, line_cap, line_join) actual = gc.bmp_array[:,:,0] assert 0, "join=round, width=3, antialias=False\n%s" % actual #assert_arrays_equal(actual, desired) def test_antialias_miter(self): """ fix me: How to make this pass on OS X and agg... """ antialias = True width = 3 line_cap = kiva.CAP_BUTT line_join = kiva.JOIN_MITER gc = self.helper(antialias, width, line_cap, line_join) actual = gc.bmp_array[:,:,0] desired = array([[255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 127, 0, 0, 127, 255], [255, 255, 255, 255, 255, 127, 0, 0, 127, 255], [255, 255, 255, 255, 255, 127, 0, 0, 127, 255], [255, 255, 255, 255, 255, 127, 0, 0, 127, 255], [255, 127, 127, 127, 127, 0, 0, 0, 127, 255], [255, 0, 0, 0, 0, 0, 0, 0, 127, 255], [255, 0, 0, 0, 0, 0, 0, 0, 127, 255], [255, 127, 127, 127, 127, 127, 127, 127, 191, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]]) self.assertRavelEqual(actual, desired) def test_antialias_bevel(self): antialias = True width = 3 line_cap = kiva.CAP_BUTT line_join = kiva.JOIN_BEVEL gc = self.helper(antialias, width, line_cap, line_join) actual = gc.bmp_array[:,:,0] desired = array([[255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 127, 0, 0, 127, 255], [255, 255, 255, 255, 255, 127, 0, 0, 127, 255], [255, 255, 255, 255, 255, 127, 0, 0, 127, 255], [255, 255, 255, 255, 255, 127, 0, 0, 127, 255], [255, 127, 127, 127, 127, 0, 0, 0, 127, 255], [255, 0, 0, 0, 0, 0, 0, 0, 127, 255], [255, 0, 0, 0, 0, 0, 0, 31, 223, 255], [255, 127, 127, 127, 127, 127, 127, 223, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]]) self.assertRavelEqual(actual, desired) def test_antialias_round(self): """ fix me: How to make this test work for multiple renderers? """ antialias = True width = 3 line_cap = kiva.CAP_BUTT line_join = kiva.JOIN_ROUND gc = self.helper(antialias, width, line_cap, line_join) actual = gc.bmp_array[:,:,0] desired = array([[255, 255, 255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 127, 0, 0, 127, 255], [255, 255, 255, 255, 255, 127, 0, 0, 127, 255], [255, 255, 255, 255, 255, 127, 0, 0, 127, 255], [255, 255, 255, 255, 255, 127, 0, 0, 127, 255], [255, 127, 127, 127, 127, 0, 0, 0, 127, 255], [255, 0, 0, 0, 0, 0, 0, 0, 127, 255], [255, 0, 0, 0, 0, 0, 0, 0, 180, 255], [255, 127, 127, 127, 127, 127, 127, 179, 253, 255], [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]]) self.assertRavelEqual(actual, desired) if __name__ == "__main__": unittest.main() enthought-chaco2-4.1.0.orig/kiva/agg/tests/gcmemtest.py0000755000175000017500000000204611674463636022106 0ustar varunvarun""" Test for memory leak in the wx image backend. """ import unittest, sys import gc as garbagecollector from kiva.image import GraphicsContext, GraphicsContextSystem from etsdevtools.debug.memusage import get_mem_usage class test_agg(unittest.TestCase): def check_agg_mem_leak(self): pre = get_mem_usage() gc = GraphicsContext((500,500)) del gc garbagecollector.collect() post = get_mem_usage() assert (pre == post) def check_wx_mem_leak(self): pre = get_mem_usage() gc = GraphicsContextSystem((500,500)) del gc garbagecollector.collect() post = get_mem_usage() assert (pre == post) def test_suite(level=1): suites = [] if level > 0: suites.append( unittest.makeSuite(test_agg,'check_') ) total_suite = unittest.TestSuite(suites) return total_suite def test(level=10): all_tests = test_suite(level) runner = unittest.TextTestRunner() runner.run(all_tests) return runner if __name__ == "__main__": test() enthought-chaco2-4.1.0.orig/kiva/agg/tests/test_graphics_context_system.py0000644000175000017500000000176411674463636026130 0ustar varunvarunimport unittest from kiva.agg import GraphicsContextSystem class GraphicsContextSystemTestCase(unittest.TestCase): def test_creation(self): """ Simply create and destroy multiple objects. This silly test crashed when we transitioned from Numeric 23.1 to 23.8. That problem is fixed now. """ for i in range(10): gc = GraphicsContextSystem((100,100), "rgba32") del gc #---------------------------------------------------------------------------- # test setup code. #---------------------------------------------------------------------------- def check_suite(level=1): suites = [] if level > 0: suites.append( unittest.makeSuite(GraphicsContextSystemTestCase,'test_') ) total_suite = unittest.TestSuite(suites) return total_suite def test(level=10): all_tests = check_suite(level) runner = unittest.TextTestRunner() runner.run(all_tests) return runner if __name__ == "__main__": test() enthought-chaco2-4.1.0.orig/kiva/agg/tests/rgba_test_case.py0000644000175000017500000000316211674463636023060 0ustar varunvarunimport unittest from numpy import array, ones from kiva import agg from test_utils import Utils class RgbaTestCase(unittest.TestCase, Utils): def test_init(self): m = agg.Rgba() def test_init1(self): m = agg.Rgba(.5,.5,.5) desired = array((.5,.5,.5,1.0)) self.assertRavelEqual(m.asarray(),desired) def test_init_from_array1(self): a = ones(3,'d') * .8 m = agg.Rgba(a) desired = ones(4,'d') * .8 desired[3] = 1.0 result = m.asarray() self.assertRavelEqual(result, desired) def test_init_from_array2(self): a = ones(4,'d') * .8 m = agg.Rgba(a) desired = ones(4,'d') * .8 result = m.asarray() self.assertRavelEqual(result, desired) def test_init_from_array3(self): a = ones(5,'d') try: m = agg.Rgba(a) except ValueError: pass # can't init from array that isn't 6 element. def test_init_from_array4(self): a = ones((2,3),'d') try: m = agg.Rgba(a) except ValueError: pass # can't init from array that isn't 1d. def test_gradient(self): first = agg.Rgba(0.,0.,0.,0.) second = agg.Rgba(1.,1.,1.,1.) actual = first.gradient(second,.5).asarray() desired = array((.5,.5,.5,.5)) self.assertRavelEqual(actual, desired) def test_pre(self): first = agg.Rgba(1.0,1.0,1.0,0.5) actual = first.premultiply().asarray() desired = array((.5,.5,.5,.5)) self.assertRavelEqual(actual, desired) if __name__ == "__main__": unittest.main() enthought-chaco2-4.1.0.orig/kiva/agg/tests/points_in_polygon_test_case.py0000644000175000017500000000740511674463636025722 0ustar varunvarunimport unittest from numpy import array, allclose from kiva import agg class TestPointsInPolygon(unittest.TestCase): def test_simple_points_in_polygon(self): polygon = array(((0.0, 0.0), (10.0, 0.0), (10.0, 10.0), (0.0, 10.0))) points = array(((-1.0, -1.0), (5.0, 5.0), (15.0, 15.0))) result = agg.points_in_polygon(points, polygon) self.assertTrue(allclose(array([0,1,0]), result)) return def test_asymmetric_points_in_polygon(self): polygon = array(((0.0, 0.0), (20.0, 0.0), (20.0, 10.0), (0.0, 10.0))) points = array(((5.0, 5.0), (10.0, 5.0), (15.0, 5.0))) result = agg.points_in_polygon(points, polygon) self.assertTrue(allclose(array([1,1,1]), result)) return def test_rectangle(self): vertices = array(((0,0), (0,10), (10,10), (10,0))) # Try the lower left. trial = array(((0,0),)) oe_result = agg.points_in_polygon(trial, vertices) w_result = agg.points_in_polygon(trial, vertices, True) self.assertEqual(0, oe_result[0], "Lower left corner not in polygon. OEF") self.assertEqual(1, w_result[0], "Lower left corner not in polygon. Winding") # Try the center. trial = array(((5,5),)) oe_result = agg.points_in_polygon(trial, vertices) w_result = agg.points_in_polygon(trial, vertices, True) self.assertEqual(1, oe_result[0], "Center not in polygon. OEF") self.assertEqual(1, w_result[0], "Center not in polygon. Winding") # Try the center. trial = array(((10,10),)) oe_result = agg.points_in_polygon(trial, vertices) w_result = agg.points_in_polygon(trial, vertices, True) self.assertEqual(1, oe_result[0], "Top-right in polygon. OEF") self.assertEqual(0, w_result[0], "Top-right in polygon. Winding") return def test_center_removed(self): # Tests a polygon which resembles the following: # # 9------8 # | | # | 3---+---------2 # | | | | # | 4---+----5 | # | | | | # | 7----6 | # | | # 0----------------1 # # Using the winding rule, the inner square containing the edge (3,4) # is inside the polygon, while using the odd-even rule, it is outside. # The inner square with containing the edge (5,6) is outside in both # cases. vertices = array(((0,0), (10, 0), (10, 8), (2, 8), (2, 6), (8, 6), (8, 2), (5, 2), (5, 10), (0, 10))) trial = array(((3,7),)) oe_result = agg.points_in_polygon(trial, vertices) w_result = agg.points_in_polygon(trial, vertices, True) self.assertEqual(0, oe_result[0], "Interior polygon inside: odd-even") self.assertEqual(1, w_result[0], "Interior polygon outside: winding") trial = array(((6,5),)) oe_result = agg.points_in_polygon(trial, vertices) w_result = agg.points_in_polygon(trial, vertices, True) self.assertEqual(0, oe_result[0], "Interior polygon inside: odd-even") self.assertEqual(0, w_result[0], "Interior polygon inside: winding") if __name__ == "__main__": unittest.main() #### EOF ###################################################################### enthought-chaco2-4.1.0.orig/kiva/agg/tests/unicode_font_test_case.py0000644000175000017500000000065111674463636024621 0ustar varunvarunimport unittest from kiva.agg import AggFontType, GraphicsContextArray from kiva.fonttools import Font class UnicodeTest(unittest.TestCase): def test_show_text_at_point(self): gc = GraphicsContextArray((100,100)) gc.set_font(Font()) gc.show_text_at_point(unicode('asdf'), 5,5) def test_agg_font_type(self): f = AggFontType(u"Arial") if __name__ == "__main__": unittest.main() enthought-chaco2-4.1.0.orig/kiva/agg/tests/test_utils.py0000644000175000017500000000025511674463636022312 0ustar varunvarunfrom numpy import alltrue, ravel class Utils(object): def assertRavelEqual(self, x, y): self.assert_(alltrue(ravel(x) == ravel(y)), "\n%s\n !=\n%s" % (x, y)) enthought-chaco2-4.1.0.orig/kiva/agg/tests/clip_to_rect_test_case.py0000644000175000017500000002741511674463636024622 0ustar varunvarun""" Needed Tests clip_to_rect() tests -------------------- DONE *. clip_to_rect is inclusive on lower end and exclusive on upper end. DONE *. clip_to_rect behaves intelligently under scaled ctm. DONE *. clip_to_rect intersects input rect with the existing clipping rect. DONE *. current rectangular clipping path is saved/restored to the stack when save_state/restore_state are called. DONE *. clip_to_rect clears current path. DONE *. clip_to_rect raises NotImplementedError under a rotated ctm. clip_to_rects() tests --------------------- DONE *. Test that clip_to_rects raises not implemented, or whatever. """ import unittest from numpy import array, transpose import nose from kiva.agg import GraphicsContextArray import kiva from test_utils import Utils class ClipToRectTestCase(unittest.TestCase, Utils): #------------------------------------------------------------------------ # Simple Clipping to a single rectangle. #------------------------------------------------------------------------ def clip_to_rect_helper(self, desired, scale, clip_rects): """ desired -- 2D array with a single channels expected byte pattern. scale -- used in scale_ctm() to change the ctm. clip_args -- passed in as *clip_args to clip_to_rect. """ shp = tuple(transpose(desired.shape)) gc = GraphicsContextArray(shp, pix_format="rgb24") gc.scale_ctm(scale, scale) # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) if isinstance(clip_rects, tuple): gc.clip_to_rect(*clip_rects) else: for rect in clip_rects: gc.clip_to_rect(*rect) gc.rect(0, 0, 4, 4) # These settings allow the fastest path. gc.set_fill_color((0.0, 0.0, 0.0)) # black gc.fill_path() # test a single color channel actual = gc.bmp_array[:,:,0] self.assertRavelEqual(desired, actual) def test_clip_to_rect_simple(self): desired = array([[255, 255, 255, 255], [255, 0, 0, 255], [255, 0, 0, 255], [255, 255, 255, 255]]) clip_rect = (1, 1, 2, 2) self.clip_to_rect_helper(desired, 1, clip_rect) def test_clip_to_rect_simple2(self): desired = array([[255, 255, 255, 255], [255, 255, 255, 255], [255, 0, 255, 255], [255, 255, 255, 255]]) clip_rect = (1, 1, 1, 1) self.clip_to_rect_helper(desired, 1, clip_rect) def test_clip_to_rect_negative(self): desired = array([[255, 255, 255, 255], [ 0, 0, 0, 255], [ 0, 0, 0, 255], [ 0, 0, 0, 255]]) clip_rect = (-1, -1, 4, 4) self.clip_to_rect_helper(desired, 1, clip_rect) def test_clip_to_rect_simple3(self): desired = array([[255, 255, 255, 255], [255, 0, 0, 255], [255, 0, 0, 255], [255, 255, 255, 255]]) clip_rect = (1, 1, 2.49, 2.49) self.clip_to_rect_helper(desired, 1, clip_rect) def test_clip_to_rect_simple4(self): desired = array([[255, 0, 0, 0], [255, 0, 0, 0], [255, 0, 0, 0], [255, 255, 255, 255]]) clip_rect = (1, 1, 2.5, 2.5) self.clip_to_rect_helper(desired, 1, clip_rect) def test_clip_to_rect_simple5(self): # This tests clipping with a larger rectangle desired = array([[255, 255, 255, 255], [255, 0, 0, 255], [255, 0, 0, 255], [255, 255, 255, 255]]) clip_rects = [(1, 1, 2, 2), (0, 0, 4, 4)] self.clip_to_rect_helper(desired, 1, clip_rects) def test_empty_clip_region(self): # This tests when the clipping region is clipped down to nothing. desired = array([[255, 255, 255, 255], [255, 255, 255, 255], [255, 255, 255, 255], [255, 255, 255, 255]]) clip_rects = [(1,1,4,4), (3,3,1,1), (1,1,1,1)] self.clip_to_rect_helper(desired, 1, clip_rects) def test_clip_to_rect_scaled(self): desired = array([[255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 0, 0, 0, 0, 255, 255], [255, 255, 0, 0, 0, 0, 255, 255], [255, 255, 0, 0, 0, 0, 255, 255], [255, 255, 0, 0, 0, 0, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255]]) clip_rect = (1, 1, 2, 2) self.clip_to_rect_helper(desired, 2.0, clip_rect) def test_clip_to_rect_scaled2(self): desired = array([[255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 0, 0, 0, 0, 0, 255], [255, 255, 0, 0, 0, 0, 0, 255], [255, 255, 0, 0, 0, 0, 0, 255], [255, 255, 0, 0, 0, 0, 0, 255], [255, 255, 0, 0, 0, 0, 0, 255], [255, 255, 255, 255, 255, 255, 255, 255], [255, 255, 255, 255, 255, 255, 255, 255]]) clip_rect = (1, 1, 2.25, 2.25) self.clip_to_rect_helper(desired, 2.0, clip_rect) def test_save_restore_clip_state(self): desired1 = array([[255, 255, 255, 255], [255, 0, 0, 255], [255, 0, 0, 255], [255, 255, 255, 255]]) desired2 = array([[255, 0, 0, 0], [255, 0, 0, 0], [255, 0, 0, 0], [255, 255, 255, 255]]) gc = GraphicsContextArray((4,4), pix_format="rgb24") gc.clear((1.0, 1.0, 1.0)) gc.set_fill_color((0.0, 0.0, 0.0)) gc.clip_to_rect(1, 1, 3, 3) gc.save_state() gc.clip_to_rect(1, 1, 2, 2) gc.rect(0, 0, 4, 4) gc.fill_path() actual1 = gc.bmp_array[:,:,0] self.assertRavelEqual(desired1, actual1) gc.restore_state() gc.rect(0, 0, 4, 4) gc.fill_path() actual2 = gc.bmp_array[:,:,0] self.assertRavelEqual(desired2, actual2) def test_clip_to_rect_rotated(self): # FIXME: test skipped # This test raises an exception currently because the # underlying library doesn't handle clipping to a rotated # rectangle. For now, we catch the the case with an # exception, so that people can't screw up. In the future, # we should actually support this functionality. raise nose.SkipTest gc = GraphicsContextArray((1,1), pix_format="rgb24") gc.rotate_ctm(1.0) self.failUnlessRaises(NotImplementedError, gc.clip_to_rect, 0, 0, 1, 1) #------------------------------------------------------------------------ # Successive Clipping of multiple rectangles. #------------------------------------------------------------------------ def successive_clip_helper(self, desired, scale, clip_rect1, clip_rect2): """ desired -- 2D array with a single channels expected byte pattern. scale -- used in scale_ctm() to change the ctm. clip_rect1 -- 1st clipping path. clip_rect2 -- 2nd clipping path. """ shp = tuple(transpose(desired.shape)) gc = GraphicsContextArray(shp, pix_format="rgb24") gc.scale_ctm(scale, scale) # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) gc.clip_to_rect(*clip_rect1) gc.clip_to_rect(*clip_rect2) gc.rect(0, 0, 4, 4) # These settings allow the fastest path. gc. set_fill_color((0.0, 0.0, 0.0)) # black gc.fill_path() # test a single color channel actual = gc.bmp_array[:,:,0] self.assertRavelEqual(desired, actual) def test_clip_successive_rects(self): desired = array([[255, 255, 255, 255], [255, 0, 0, 255], [255, 0, 0, 255], [255, 255, 255, 255]]) clip_rect1 = (1, 1, 20, 20) clip_rect2 = (0, 0, 3, 3) self.successive_clip_helper(desired, 1.0, clip_rect1, clip_rect2) def test_clip_successive_rects2(self): desired = array([[255, 255, 255, 255], [255, 0, 0, 255], [255, 0, 0, 255], [255, 255, 255, 255]]) clip_rect1 = (1, 1, 20, 20) clip_rect2 = (-1, -1, 4, 4) self.successive_clip_helper(desired, 1.0, clip_rect1, clip_rect2) #------------------------------------------------------------------------ # Save/Restore clipping path. #------------------------------------------------------------------------ def test_save_restore_clip_path(self): desired = array([[255, 255, 255, 255], [255, 0, 0, 255], [255, 0, 0, 255], [255, 255, 255, 255]]) # this is the clipping path we hope to see. clip_rect1 = (1, 1, 2, 2) # this will be a second path that will push/pop that should # never be seen. clip_rect2 = (1, 1, 1, 1) shp = tuple(transpose(desired.shape)) gc = GraphicsContextArray(shp, pix_format="rgb24") # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) gc.clip_to_rect(*clip_rect1) # push and then pop a path that shouldn't affect the drawing gc.save_state() gc.clip_to_rect(*clip_rect2) gc.restore_state() gc.rect(0, 0, 4, 4) # These settings allow the fastest path. gc. set_fill_color((0.0, 0.0, 0.0)) # black gc.fill_path() # test a single color channel actual = gc.bmp_array[:,:,0] self.assertRavelEqual(desired, actual) def test_reset_path(self): """ clip_to_rect() should clear the current path. This is to maintain compatibility with the version of kiva that sits on top of Apple's Quartz engine. """ desired = array([[255, 255, 0, 0], [255, 255, 0, 0], [255, 255, 0, 0], [255, 255, 0, 0]]) shp = tuple(transpose(desired.shape)) gc = GraphicsContextArray(shp, pix_format="rgb24") # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) gc.rect(0, 0, 2, 4) gc.clip_to_rect(0, 0, 4, 4) gc.rect(2, 0, 2, 4) # These settings allow the fastest path. gc. set_fill_color((0.0, 0.0, 0.0)) # black gc.fill_path() # test a single color channel actual = gc.bmp_array[:,:,0] self.assertRavelEqual(desired, actual) class ClipToRectsTestCase(unittest.TestCase): def test_not_implemented(self): """ fix me: Currently not implemented, so we just ensure that any call to it throws an exception. """ gc = GraphicsContextArray((1,1), pix_format="rgb24") gc.rotate_ctm(1.0) #self.failUnlessRaises(NotImplementedError, gc.clip_to_rects, [[0, 0, 1, 1]]) if __name__ == "__main__": unittest.main() enthought-chaco2-4.1.0.orig/kiva/agg/tests/affine_matrix_test_case.py0000644000175000017500000001042611674463636024762 0ustar varunvarunfrom math import pi import unittest from numpy import array, allclose, ones, alltrue from kiva import agg class AffineMatrixTestCase(unittest.TestCase): def test_init(self): m = agg.AffineMatrix() def test_init_from_array(self): a = ones(6,'d') m = agg.AffineMatrix(a) desired = ones(6,'d') result = m.asarray() assert(alltrue(result == desired)) def test_init_from_array1(self): a = ones(6,'D') try: m = agg.AffineMatrix(a) except NotImplementedError: pass # can't init from complex value. def test_init_from_array2(self): a = ones(7,'d') try: m = agg.AffineMatrix(a) except ValueError: pass # can't init from array that isn't 6 element. def test_init_from_array3(self): a = ones((2,3),'d') try: m = agg.AffineMatrix(a) except ValueError: pass # can't init from array that isn't 1d. def test_imul(self): a = agg.AffineMatrix((2.0,0,0,2.0,0,0)) a *= a actual = a desired = agg.AffineMatrix((4.0,0,0,4.0,0,0)) assert(alltrue(desired==actual)) def test_asarray(self): m = agg.AffineMatrix() result = m.asarray() desired = array((1.0,0.0,0.0,1.0,0.0,0.0)) assert(alltrue(result == desired)) def _test_zero_arg_transform(self,method, orig, desired): m = agg.AffineMatrix(orig) method(m) result = m.asarray() assert(alltrue(result == desired)) def test_flip_x(self): method = agg.AffineMatrix.flip_x orig = array((1.0,2.0,3.0,1.0,4.0,5.0)) desired = array([-1.,-2.,3.,1.,-4.,5.]) self._test_zero_arg_transform(method,orig,desired) def test_flip_y(self): method = agg.AffineMatrix.flip_y orig = array((1.0,2.0,3.0,1.0,4.0,5.0)) desired = array([ 1.,2.,-3.,-1.,4.,-5.]) self._test_zero_arg_transform(method,orig,desired) def test_reset(self): method = agg.AffineMatrix.reset orig = array((1.0,2.0,3.0,1.0,4.0,5.0)) desired = array([ 1.,0.,0.,1.,0.,0.]) self._test_zero_arg_transform(method,orig,desired) def test_multiply(self): orig = array((1.0,2.0,3.0,1.0,4.0,5.0)) desired = array([ 7.,4.,6.,7.,23.,18.]) m = agg.AffineMatrix(orig) other = agg.AffineMatrix(orig) m.multiply(other) result = m.asarray() assert(alltrue(result == desired)) def test_determinant(self): orig = array((1.0,2.0,3.0,1.0,4.0,5.0)) desired = -0.2 m = agg.AffineMatrix(orig) result = m.determinant() assert(alltrue(result == desired)) def test_invert(self): orig = agg.AffineMatrix((1.0,2.0,3.0,1.0,4.0,5.0)) orig.invert() actual = orig.asarray() desired = array([-0.2,0.4,0.6,-0.2,-2.2,-0.6]) assert(allclose(desired,actual)) def test_rotation_matrix(self): val = agg.rotation_matrix(pi/2.) desired = array([ 0.0,1.0,-1.0,0.0,0.0,0.0]) actual = val.asarray() assert(allclose(desired,actual)) def test_translation_matrix(self): val = agg.translation_matrix(2.0,3.0) desired = array([ 1.0,0.0,0.0,1.0,2.0,3.0]) actual = val.asarray() assert(allclose(desired,actual)) def test_scaling_matrix(self): val = agg.scaling_matrix(4.0,4.0) desired = array([ 4.0,0.0,0.0,4.0,0.0,0.0]) actual = val.asarray() assert(allclose(desired,actual)) def test_skewing_matrix(self): val = agg.skewing_matrix(pi/4.,pi/4.) desired = array([ 1.0,1.0,1.0,1.0,0.0,0.0]) actual = val.asarray() assert(allclose(desired,actual)) #---------------------------------------------------------------------------- # test setup code. #---------------------------------------------------------------------------- def test_suite(level=1): suites = [] if level > 0: suites.append( unittest.makeSuite(AffineMatrixTestCase,'test_') ) total_suite = unittest.TestSuite(suites) return total_suite def test(level=10): all_tests = test_suite(level) runner = unittest.TextTestRunner() runner.run(all_tests) return runner if __name__ == "__main__": test() enthought-chaco2-4.1.0.orig/kiva/agg/tests/compiled_path_test_case.py0000644000175000017500000002156511674463636024764 0ustar varunvarunimport unittest from numpy import array, alltrue, ravel, pi from kiva import agg from test_utils import Utils # UNCOMMENT THIS TO SEE THE IMPORT ISSUES FROM TICKET # https://svn.enthought.com/enthought/ticket/537 (agg causes python crash during unit tests) # #import sys #module_names = [ name for name in sys.modules.keys() if name.find('agg') >= 0] #module_names.sort() #for name in module_names: # print name, sys.modules[name] class TestCompiledPath(unittest.TestCase, Utils): def test_init(self): path = agg.CompiledPath() def test_save_restore_ctm0(self): path = agg.CompiledPath() path.save_ctm(); path.restore_ctm(); def test_save_restore_ctm1(self): path = agg.CompiledPath() m0 = agg.translation_matrix(10.0,10.0) path.set_ctm(m0) path.save_ctm() m1 = agg.translation_matrix(5.0,5.0) path.set_ctm(m1) m2 = path.get_ctm() self.assertRavelEqual(m1, m2) path.restore_ctm() m3 = path.get_ctm() self.assertRavelEqual(m0, m3) def test_translate_ctm(self): path = agg.CompiledPath() path.translate_ctm(2.0,2.0) actual = path.get_ctm() desired = agg.translation_matrix(2.0,2.0) self.assertRavelEqual(actual, desired) def test_scale_ctm(self): path = agg.CompiledPath() path.scale_ctm(2.0,2.0) actual = path.get_ctm() desired = agg.scaling_matrix(2.0,2.0) self.assertRavelEqual(actual, desired) def test_rotate_ctm(self): angle = pi/4. path = agg.CompiledPath() path.rotate_ctm(angle) actual = path.get_ctm() desired = agg.rotation_matrix(angle) self.assertRavelEqual(actual, desired) def test_concat_ctm(self): path = agg.CompiledPath() path.translate_ctm(2.0,2.0) m0 = agg.scaling_matrix(2.0,2.0) path.concat_ctm(m0) actual = path.get_ctm() # wrapper not working #m0 *= agg.translation_matrix(2.0,2.0) m0.multiply(agg.translation_matrix(2.0,2.0)) desired = m0 des = desired.asarray() act = actual.asarray() self.assertRavelEqual(actual, desired) def test_vertex(self): # !! should get this value from the agg enum value path = agg.CompiledPath() path.move_to(1.0,1.0) actual,actual_flag = path._vertex() desired = array((1.0,1.0)) desired_flag = 1 self.assertRavelEqual(actual,desired) self.assertRavelEqual(actual_flag,desired_flag) #check for end flag actual,actual_flag = path._vertex() desired_flag = 0 self.assertRavelEqual(actual_flag,desired_flag) def test_vertices(self): # !! should get this value from the agg enum value path = agg.CompiledPath() path.move_to(1.0,1.0) desired = array(((1.0,1.0,1.0,0.0), (0.0,0.0,0.0,0.0))) actual = path._vertices() self.assertRavelEqual(actual,desired) def test_rewind(self): # !! should get this value from the agg enum value path = agg.CompiledPath() path.move_to(1.0,1.0) actual,actual_flag = path._vertex() actual,actual_flag = path._vertex() path._rewind() actual,actual_flag = path._vertex() desired = array((1.0,1.0)) desired_flag = 1 self.assertRavelEqual(actual,desired) self.assertRavelEqual(actual_flag,desired_flag) def test_begin_path(self): path = agg.CompiledPath() path.move_to(1.0,1.0) path.begin_path() pt, flag = path._vertex() # !! should get this value from the agg enum value desired = 0 self.assertRavelEqual(flag,desired) def test_move_to(self): path = agg.CompiledPath() path.move_to(1.0,1.0) actual,flag = path._vertex() desired = array((1.0,1.0)) self.assertRavelEqual(actual,desired) def test_move_to1(self): """ Test that transforms are affecting move_to commands """ path = agg.CompiledPath() path.translate_ctm(1.0,1.0) path.move_to(1.0,1.0) actual,flag = path._vertex() desired = array((2.0,2.0)) self.assertRavelEqual(actual,desired) def test_quad_curve_to(self): path = agg.CompiledPath() ctrl = 1.0,1.0 to = 2.0,2.0 path.quad_curve_to(ctrl[0],ctrl[1],to[0],to[1]) actual_ctrl, flag = path._vertex() self.assertRavelEqual(actual_ctrl, ctrl) assert(flag == 3) actual_to, flag = path._vertex() assert(actual_to == to) assert(flag == 3) def test_curve_to(self): path = agg.CompiledPath() ctrl1 = 1.0,1.0 ctrl2 = 2.0,2.0 to = 3.0,3.0 path.curve_to(ctrl1[0],ctrl1[1],ctrl2[0],ctrl2[1],to[0],to[1]) actual_ctrl1, flag = path._vertex() assert(actual_ctrl1 == ctrl1) assert(flag == 4) actual_ctrl2, flag = path._vertex() assert(actual_ctrl2 == ctrl2) assert(flag == 4) actual_to, flag = path._vertex() assert(actual_to == to) assert(flag == 4) def test_add_path(self): path1 = agg.CompiledPath() path1.move_to(1.0,1.0) path1.translate_ctm(1.0,1.0) path1.line_to(2.0,2.0) #actually (3.0,3.0) path1.scale_ctm(2.0,2.0) path1.line_to(2.0,2.0) # actually (5.0,5.0) path2 = agg.CompiledPath() path2.move_to(1.0,1.0) path2.translate_ctm(1.0,1.0) path2.line_to(2.0,2.0) #actually (3.0,3.0) sub_path = agg.CompiledPath() sub_path.scale_ctm(2.0,2.0) sub_path.line_to(2.0,2.0) path2.add_path(sub_path) desired = path1._vertices() actual = path2._vertices() self.assertRavelEqual(actual, desired) desired = path1.get_ctm() actual = path2.get_ctm() self.assertRavelEqual(actual, desired) def base_helper_lines(self,lines): path = agg.CompiledPath() path.move_to(1.0,1.0) path.line_to(2.0,2.0) #actually (3.0,3.0) path.lines(lines) actual = path._vertices() desired = array(((1.0,1.0,agg.path_cmd_move_to, agg.path_flags_none), (2.0,2.0,agg.path_cmd_line_to, agg.path_flags_none), (3.0,3.0,agg.path_cmd_move_to, agg.path_flags_none), (4.0,4.0,agg.path_cmd_line_to, agg.path_flags_none), (0.0,0.0,agg.path_cmd_stop, agg.path_flags_none),)) #print 'desired:', desired #print 'actual:', actual self.assertRavelEqual(actual, desired) def test_lines_array(self): lines = array(((3.0,3.0), (4.0,4.0))) self.base_helper_lines(lines) def test_lines_list(self): lines = [[3.0,3.0], [4.0,4.0]] self.base_helper_lines(lines) def test_rect(self): path = agg.CompiledPath() path.rect(1.0,1.0,1.0,1.0) actual = path._vertices() desired = array(((1.0,1.0,agg.path_cmd_move_to, agg.path_flags_none), (1.0,2.0,agg.path_cmd_line_to, agg.path_flags_none), (2.0,2.0,agg.path_cmd_line_to, agg.path_flags_none), (2.0,1.0,agg.path_cmd_line_to, agg.path_flags_none), (0.0,0.0,agg.path_cmd_end_poly, agg.path_flags_close), (0.0,0.0,agg.path_cmd_stop, agg.path_flags_none),)) self.assertRavelEqual(actual, desired) def base_helper_rects(self,rects): path = agg.CompiledPath() path.rects(rects) actual = path._vertices() desired = array(((1.0,1.0,agg.path_cmd_move_to, agg.path_flags_none), (1.0,2.0,agg.path_cmd_line_to, agg.path_flags_none), (2.0,2.0,agg.path_cmd_line_to, agg.path_flags_none), (2.0,1.0,agg.path_cmd_line_to, agg.path_flags_none), (0.0,0.0,agg.path_cmd_end_poly, agg.path_flags_close), (2.0,2.0,agg.path_cmd_move_to, agg.path_flags_none), (2.0,3.0,agg.path_cmd_line_to, agg.path_flags_none), (3.0,3.0,agg.path_cmd_line_to, agg.path_flags_none), (3.0,2.0,agg.path_cmd_line_to, agg.path_flags_none), (0.0,0.0,agg.path_cmd_end_poly, agg.path_flags_close), (0.0,0.0,agg.path_cmd_stop, agg.path_flags_none),)) self.assertRavelEqual(actual, desired) def test_rects_array(self): rects = array(((1.0,1.0,1.0,1.0), (2.0,2.0,1.0,1.0))) self.base_helper_rects(rects) def test_rects_list(self): rects = [[1.0,1.0,1.0,1.0], [2.0,2.0,1.0,1.0]] self.base_helper_rects(rects) if __name__ == "__main__": unittest.main() enthought-chaco2-4.1.0.orig/kiva/agg/tests/stroke_path_test_case.py0000644000175000017500000004325611674463636024500 0ustar varunvarun""" Tasks ----- DONE *. Change all rect classes to use a sequence instead of 4 separate args *. Implement a clear_rect that takes a rect argument and a color. *. Rename the clear() method to ?erase()? so that clear can stick with the clear_rect semantics. *. Implement arc. *. Implement a clear_rects that takes a rect list and a color. *. Implement clipping to multiple rectangles. Needed Tests ------------ Coordinate system offset. DONE 1. Test that aliased line at zero puts full energy in last row of buffer. DONE 2. Test that antialiased line at zero puts half energy in last row of buffer. Aliased DONE 1. For simple line, test all paths through rendering pipeline. Antialiased DONE 1. For simple line, test all paths through rendering pipeline. Caps DONE 1. Each version same for all paths through aliased code. 2. Each version same for all paths through antialiased code. Joins (in join_stroke_path_test_case.py) DONE 1. Each version same for all paths through aliased code. DONE 2. Each version same for all paths through antialiased code. Dashed Lines *. Should be tested for all versions of aliasing and all versions of join, cap. Curved Lines DONE *. curve_to Note: There are numerous comments in code that refer to implementation details (outline, outline_aa, scanline_aa, etc.) from the C++ code. These are largely to help keep track of what paths have been tested. """ import unittest from numpy import array, alltrue, ravel from kiva.agg import GraphicsContextArray import kiva from test_utils import Utils class StrokePathTestCase(unittest.TestCase, Utils): def test_alias_width_one(self): """ The fastest path through the stroke path code is for aliased path with width=1. It is reasonably safe here not to worry with testing all the CAP/JOIN combinations because they are all rendered the same for this case. It is handled by the agg::rasterizer_outline and the agg::renderer_primitives classes in C++. Energy for an aliased horizontal line of width=1 falls within a single line of pixels. With y=0 for this line, the engine should paint a single row of zeros along the bottom edge of the bmp array. """ gc = GraphicsContextArray((3, 2), pix_format="rgb24") # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) # single horizontal line across bottom of buffer gc.move_to(0, 0) gc.line_to(3, 0) # These settings allow the fastest path. gc. set_stroke_color((0.0, 0.0, 0.0)) # black gc.set_antialias(False) gc.set_line_width(1) gc.stroke_path() # test a single color channel. desired = array(((255,255,255), ( 0, 0, 0))) actual = gc.bmp_array[:,:,0] self.assertRavelEqual(actual, desired) def test_alias_width_two_outline_aa(self): """ When width>1, alias text is drawn using a couple of different paths through the underlying C++ code. This test the faster of the two which uses the agg::rasterizer_outline_aa C++ code. It is only used when 2<=width<=10, and cap is ROUND or BUTT, and join is MITER The C++ classes used in the underlying C++ code for this is agg::rasterizer_outline_aa and agg::renderer_outline_aa """ gc = GraphicsContextArray((3, 2), pix_format="rgb24") # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) # single horizontal line across bottom of buffer gc.move_to(0, 0) gc.line_to(3, 0) # Settings allow the 2nd fastest path. gc. set_stroke_color((0.0, 0.0, 0.0)) # black gc.set_antialias(False) gc.set_line_width(2) gc.set_line_cap(kiva.CAP_ROUND) gc.set_line_join(kiva.JOIN_MITER) gc.stroke_path() # test a single color channel. desired = array(((255, 255, 255), ( 0, 0, 0))) actual = gc.bmp_array[:,:,0] self.assertRavelEqual(actual, desired) def test_alias_width_two_scanline_aa(self): """ When width > 1, alias text is drawn using a couple of different paths through the underlying C++ code. This test the slower of the two which uses the agg::rasterizer_scanline_aa C++ code. We've set the line join to bevel to trigger this path. """ gc = GraphicsContextArray((3, 2), pix_format="rgb24") # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) # single horizontal line across bottom of buffer gc.move_to(0, 0) gc.line_to(3, 0) # Settings allow the 2nd fastest path. gc. set_stroke_color((0.0, 0.0, 0.0)) # black gc.set_antialias(False) gc.set_line_width(2) gc.set_line_cap(kiva.CAP_ROUND) gc.set_line_join(kiva.JOIN_BEVEL) gc.stroke_path() # test a single color channel. desired = array(((255, 255, 255), ( 0, 0, 0))) actual = gc.bmp_array[:,:,0] self.assertRavelEqual(actual, desired) ######################################################################### # Cap Tests ######################################################################### def cap_equality_helper(self, antialias, width, line_cap, line_join, size=(6,6)): gc = GraphicsContextArray(size, pix_format="rgb24") # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) # single horizontal line across bottom of buffer gc.move_to(2, 3) gc.line_to(4, 3) # Settings allow the faster outline path through C++ code gc. set_stroke_color((0.0, 0.0, 0.0)) # black gc.set_antialias(antialias) gc.set_line_width(width) gc.set_line_cap(line_cap) gc.set_line_join(line_join) gc.stroke_path() return gc def test_alias_cap_round(self): """ Round caps should extend beyond the end of the line. We don't really test the shape here. To do this, a test of a wider line would be needed. fix me: This is rendering antialiased end points currently. """ gc = GraphicsContextArray((6,6), pix_format="rgb24") # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) # single horizontal line across bottom of buffer gc.move_to(2, 3) gc.line_to(4, 3) # Set up line gc. set_stroke_color((0.0, 0.0, 0.0)) # black gc.set_antialias(False) gc.set_line_width(2) gc.set_line_cap(kiva.CAP_ROUND) gc.set_line_join(kiva.JOIN_MITER) gc.stroke_path() desired = array(((255, 255, 255, 255, 255, 255), (255, 255, 255, 255, 255, 255), (255, 0, 0, 0, 0, 255), (255, 0, 0, 0, 0, 255), (255, 255, 255, 255, 255, 255), (255, 255, 255, 255, 255, 255))) actual = gc.bmp_array[:,:,0] self.assertRavelEqual(desired, actual) def test_alias_cap_round_equality(self): """ There are two paths that can generate aliased round capped lines. This tests that they generate equivalent results fix me: This test fails because the two rendering paths render the end caps differently. """ antialias = False width = 2 cap = kiva.CAP_ROUND # join=miter allows the faster outline path through C++ code. gc1 = self.cap_equality_helper(antialias, width, cap, kiva.JOIN_MITER) # join=bevel forces the scanline path through C++ code. gc2 = self.cap_equality_helper(antialias, width, cap, kiva.JOIN_BEVEL) # Instead of testing against a known desired value, we are simply # testing for equality... self.assertRavelEqual(gc1.bmp_array[:,:,0], gc2.bmp_array[:,:,0]) def test_alias_cap_square(self): """ Round caps should extend beyond the end of the line. by half the width of the line. fix me: This is rendering antialiased end points currently. """ gc = GraphicsContextArray((6,6), pix_format="rgb24") # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) # single horizontal line across bottom of buffer gc.move_to(2, 3) gc.line_to(4, 3) # Set up line gc. set_stroke_color((0.0, 0.0, 0.0)) # black gc.set_antialias(False) gc.set_line_width(2) gc.set_line_cap(kiva.CAP_SQUARE) gc.set_line_join(kiva.JOIN_MITER) gc.stroke_path() desired = array(((255, 255, 255, 255, 255, 255), (255, 255, 255, 255, 255, 255), (255, 255, 0, 0, 255, 255), (255, 255, 0, 0, 255, 255), (255, 255, 255, 255, 255, 255), (255, 255, 255, 255, 255, 255))) actual = gc.bmp_array[:,:,0] self.assertRavelEqual(desired, actual) def test_alias_cap_square(self): """ Square caps should extend beyond the end of the line. by half the width of the line. """ gc = GraphicsContextArray((6,6), pix_format="rgb24") # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) # single horizontal line across bottom of buffer gc.move_to(2, 3) gc.line_to(4, 3) # Set up line gc. set_stroke_color((0.0, 0.0, 0.0)) # black gc.set_antialias(False) gc.set_line_width(2) gc.set_line_cap(kiva.CAP_SQUARE) gc.set_line_join(kiva.JOIN_MITER) gc.stroke_path() desired = array(((255, 255, 255, 255, 255, 255), (255, 255, 255, 255, 255, 255), (255, 0, 0, 0, 0, 255), (255, 0, 0, 0, 0, 255), (255, 255, 255, 255, 255, 255), (255, 255, 255, 255, 255, 255))) actual = gc.bmp_array[:,:,0] self.assertRavelEqual(desired, actual) def test_alias_cap_butt_equality(self): """ There are two paths that can generate aliased butt capped lines. This tests that they generate equivalent results """ antialias = False width = 2 cap = kiva.CAP_BUTT # join=miter allows the faster outline path through C++ code. gc1 = self.cap_equality_helper(antialias, width, cap, kiva.JOIN_MITER) # join=bevel forces the scanline path through C++ code. gc2 = self.cap_equality_helper(antialias, width, cap, kiva.JOIN_BEVEL) # Instead of testing against a known desired value, we are simply # testing for equality... self.assertRavelEqual(gc1.bmp_array, gc2.bmp_array) def test_alias_cap_square(self): """ Square caps should extend beyond the end of the line. by half the width of the line. """ gc = GraphicsContextArray((6,6), pix_format="rgb24") # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) # single horizontal line across bottom of buffer gc.move_to(2, 3) gc.line_to(4, 3) # Set up line gc. set_stroke_color((0.0, 0.0, 0.0)) # black gc.set_antialias(False) gc.set_line_width(2) gc.set_line_cap(kiva.CAP_SQUARE) gc.set_line_join(kiva.JOIN_MITER) gc.stroke_path() desired = array(((255, 255, 255, 255, 255, 255), (255, 255, 255, 255, 255, 255), (255, 0, 0, 0, 0, 255), (255, 0, 0, 0, 0, 255), (255, 255, 255, 255, 255, 255), (255, 255, 255, 255, 255, 255))) actual = gc.bmp_array[:,:,0] self.assertRavelEqual(desired, actual) def test_alias_cap_square_equality(self): """ There are two paths that can generate aliased square capped lines. This tests that they generate equivalent results. """ antialias = False width = 2 cap = kiva.CAP_SQUARE # join=miter allows the faster outline path through C++ code. gc1 = self.cap_equality_helper(antialias, width, cap, kiva.JOIN_MITER) # join=bevel forces the scanline path through C++ code. gc2 = self.cap_equality_helper(antialias, width, cap, kiva.JOIN_BEVEL) # Instead of testing against a known desired value, we are simply # testing for equality... self.assertRavelEqual(gc1.bmp_array, gc2.bmp_array) def test_antialias_width_one(self): """ An anti-aliased horizontal line of width=1 has its energy centered between the bottom row of pixels and the next lower row of pixels (which is off the page). It dumps half its energy in each, so we end up with a single line of 127,127,127 pixel values in the last row of pixels. This particular set of flags is handled by the (fast) agg::rasterizer_outline_aa path through the C++ code. """ gc = GraphicsContextArray((3, 2), pix_format="rgb24") # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) # single horizontal line across bottom of buffer gc.move_to(0, 0) gc.line_to(3, 0) # Set up stroke gc. set_stroke_color((0.0, 0.0, 0.0)) # black gc.set_antialias(True) gc.set_line_width(1) gc.set_line_cap(kiva.CAP_BUTT) gc.set_line_join(kiva.JOIN_MITER) gc.stroke_path() # test a single color channel. desired = array(((255, 255, 255), (127, 127, 127))) actual = gc.bmp_array[:,:,0] self.assertRavelEqual(desired, actual) def test_antialias_width_slower_path(self): """ An anti-aliased horizontal line of width=1 has its energy centered between the bottom row of pixels and the next lower row of pixels (which is off the page). It dumps half its energy in each, so we end up with a single line of 127,127,127 pixel values in the last row of pixels. This particular set of flags is handled by the agg::rasterizer_scanline_aa path through the C++ code. """ gc = GraphicsContextArray((3, 2), pix_format="rgb24") # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) # single horizontal line across bottom of buffer gc.move_to(0, 0) gc.line_to(3, 0) # Set up stroke gc. set_stroke_color((0.0, 0.0, 0.0)) # black gc.set_antialias(True) gc.set_line_width(1) gc.set_line_cap(kiva.CAP_BUTT) gc.set_line_join(kiva.JOIN_BEVEL) gc.stroke_path() # test a single color channel. desired = array(((255, 255, 255), (127, 127, 127))) actual = gc.bmp_array[:,:,0] self.assertRavelEqual(desired, actual) def test_curve_to(self): """ curve_to conv_curve happens early in the agg rendering pipeline, so it isn't neccessary to test every combination of antialias, line_cap, line_join, etc. If it works for one, we should be in good shape for the others (until the implementation is changed of course...) """ gc = GraphicsContextArray((10, 10), pix_format="rgb24") # clear background to white values (255, 255, 255) gc.clear((1.0, 1.0, 1.0)) # single horizontal line across bottom of buffer x0, y0 = 1.0, 5.0 x1, y1 = 4.0, 9.0 x2, y2 = 6.0, 1.0 x3, y3 = 9.0, 5.0 gc.move_to(x0, y0) gc.curve_to(x1, y1, x2, y2, x3, y3); # Set up stroke gc. set_stroke_color((0.0, 0.0, 0.0)) # black gc.set_antialias(True) gc.set_line_width(1) gc.set_line_cap(kiva.CAP_BUTT) gc.set_line_join(kiva.JOIN_MITER) gc.stroke_path() gc. set_stroke_color((0.0, 1.0, 1.0)) gc.move_to(x0, y0) gc.line_to(x1, y1) gc.move_to(x2, y2) gc.line_to(x3, y3) gc.stroke_path() # test a single color channel. # note: This is a "screen capture" from running this # test. It looks right, but hasn't been check closely. desired = array([[255, 255, 255, 230, 255, 255, 255, 255, 255, 255], [255, 255, 231, 25, 212, 255, 255, 255, 255, 255], [255, 252, 65, 128, 255, 255, 255, 255, 255, 255], [255, 103, 26, 143, 229, 255, 255, 255, 255, 255], [179, 2, 115, 96, 23, 189, 255, 255, 204, 255], [255, 205, 255, 255, 189, 23, 97, 116, 2, 179], [255, 255, 255, 255, 255, 229, 142, 25, 103, 255], [255, 255, 255, 255, 255, 255, 127, 66, 252, 255], [255, 255, 255, 255, 255, 212, 26, 231, 255, 255], [255, 255, 255, 255, 255, 255, 231, 255, 255, 255]]) actual = gc.bmp_array[:,:,0] self.assertRavelEqual(desired, actual) if __name__ == "__main__": unittest.main() enthought-chaco2-4.1.0.orig/kiva/agg/tests/font_loading_test.py0000644000175000017500000000153411674463636023616 0ustar varunvarunfrom string import lowercase, uppercase import os import time from kiva.image import font_metrics_provider as FMP from kiva.fonttools import Font counts = (500,) strings = ("hello", ) # lowercase + uppercase) fonts = ( ("arial", 12), ) # ("times", 16), ("courier", 10) ) def test(): allmetrics = [] for count in counts: start = time.time() for i in range(count): metrics = FMP() for face, size in fonts: metrics.set_font(Font(face, size)) for s in strings: dims = metrics.get_text_extent(s) allmetrics.append(metrics) end = time.time() print "finished count=%d" % count print " total time:", end - start print " time/set_font:", (end-start) / float(count * len(fonts)) if __name__ == "__main__": test() enthought-chaco2-4.1.0.orig/kiva/agg/tests/graphics_context_test_case.py0000644000175000017500000003145411674463636025516 0ustar varunvarunfrom __future__ import with_statement import unittest from numpy import all, allclose, array, dtype, pi, ones from kiva import agg from kiva.fonttools import Font class GraphicsContextArrayTestCase(unittest.TestCase): def test_init(self): gc = agg.GraphicsContextArray((100,100)) def test_init_bmp_equal_to_clear_bmp(self): gc = agg.GraphicsContextArray((5,5)) gc2 = agg.GraphicsContextArray((5,5)) gc2.clear() self.assert_((gc.bmp_array == gc2.bmp_array).all()) def test_init_with_bmp_doesnt_clear(self): a = ones((5,5,4), dtype('uint8')) gc = agg.GraphicsContextArray(a, pix_format='rgba32') self.assert_((gc.bmp_array == a).all()) def test_save_restore_state(self): gc = agg.GraphicsContextArray((100,100)) gc.save_state() gc.restore_state() def test_save_restore_state_for_ctm(self): gc = agg.GraphicsContextArray((100,100)) m0 = agg.translation_matrix(10.0,10.0) gc.set_ctm(m0) gc.save_state() m1 = agg.translation_matrix(5.0,5.0) gc.set_ctm(m1) m2 = gc.get_ctm() self.assertEqual(tuple(m1), m2) gc.restore_state() m3 = gc.get_ctm() self.assertEqual(tuple(m0), m3) # !! Need some tests of other graphics state information on # !! save/restore state def test_save_restore_state_for_ttm(self): # The interesting thing here is that we are verifying # that the text transform matrix (TTM) is *not* saved # with the graphics state. gc = agg.GraphicsContextArray((100,100)) m0 = agg.translation_matrix(10.0,10.0) gc.set_text_matrix(m0) gc.save_state() gc.set_text_matrix(agg.translation_matrix(5.0,5.0)) gc.restore_state() m1 = gc.get_text_matrix() self.assertNotEqual(m1, m0) # !! Need some tests of other graphics state information on # !! save/restore state def test_context_manager(self): gc = agg.GraphicsContextArray((100,100)) # Set some values. gc.set_stroke_color((1,0,0,1)) gc.set_antialias(0) gc.set_alpha(0.25) with gc: # Change the values in the current context. gc.set_stroke_color((0,0,1,1)) self.assert_(all(gc.get_stroke_color() == (0,0,1,1))) gc.set_antialias(1) self.assertEqual(gc.get_antialias(), 1) gc.set_alpha(0.75) self.assertEqual(gc.get_alpha(), 0.75) # Verify that we are back to the previous settings. self.assert_(all(gc.get_stroke_color() == (1,0,0,1))) self.assertEqual(gc.get_antialias(), 0) self.assertEqual(gc.get_alpha(), 0.25) def test_context_manager_nested(self): gc = agg.GraphicsContextArray((100,100)) # Set some values. gc.set_stroke_color((1,0,0,1)) gc.set_antialias(0) gc.set_alpha(0.25) with gc: # Change the values in the current context. gc.set_stroke_color((0,0,1,1)) self.assert_(all(gc.get_stroke_color() == (0,0,1,1))) gc.set_antialias(1) self.assertEqual(gc.get_antialias(), 1) gc.set_alpha(0.75) self.assertEqual(gc.get_alpha(), 0.75) with gc: # Change the values in the current context. gc.set_stroke_color((1,0,1,1)) self.assert_(all(gc.get_stroke_color() == (1,0,1,1))) gc.set_antialias(0) self.assertEqual(gc.get_antialias(), 0) gc.set_alpha(1.0) self.assertEqual(gc.get_alpha(), 1.0) # Verify that we are back to the previous settings. self.assert_(all(gc.get_stroke_color() == (0,0,1,1))) self.assertEqual(gc.get_antialias(), 1) self.assertEqual(gc.get_alpha(), 0.75) # Verify that we are back to the previous settings. self.assert_(all(gc.get_stroke_color() == (1,0,0,1))) self.assertEqual(gc.get_antialias(), 0) self.assertEqual(gc.get_alpha(), 0.25) def test_translate_ctm(self): gc = agg.GraphicsContextArray((100, 100)) gc.translate_ctm(2.0, 2.0) actual = gc.get_ctm() desired = agg.translation_matrix(2.0, 2.0) self.assertEqual(actual, tuple(desired)) def test_scale_ctm(self): gc = agg.GraphicsContextArray((100,100)) gc.scale_ctm(2.0,2.0) actual = gc.get_ctm() desired = agg.scaling_matrix(2.0,2.0) self.assertEqual(actual, tuple(desired)) def test_rotate_ctm(self): gc = agg.GraphicsContextArray((100,100)) gc.rotate_ctm(pi/4.) actual = gc.get_ctm() desired = agg.rotation_matrix(pi/4.) self.assertEqual(actual, tuple(desired)) def test_concat_ctm(self): gc = agg.GraphicsContextArray((100,100)) gc.translate_ctm(2.0,2.0) m0 = agg.scaling_matrix(2.0,2.0) gc.concat_ctm(m0) actual = gc.get_ctm() m0.multiply(agg.translation_matrix(2.0,2.0)) desired = m0 self.assertEqual(actual, tuple(desired)) def test_begin_path(self): gc = agg.GraphicsContextArray((100,100)) gc.move_to(1.0,1.0) gc.begin_path() path = gc._get_path() pt, flag = path._vertex() # !! should get this value from the agg enum value desired = 0 self.assertEqual(flag, desired) def test_move_to(self): gc = agg.GraphicsContextArray((100, 100)) gc.move_to(1.0, 1.0) path = gc._get_path() actual, flag = path._vertex() desired = array((1.0, 1.0)) self.assert_(allclose(actual, desired)) def test_move_to1(self): gc = agg.GraphicsContextArray((100, 100)) gc.translate_ctm(1.0, 1.0) gc.move_to(1.0, 1.0) path = gc._get_path() actual, flag = path._vertex() desired = array((2.0, 2.0)) self.assert_(allclose(actual, desired)) def test_quad_curve_to(self): gc = agg.GraphicsContextArray((100, 100)) ctrl = 1.0, 1.0 to = 2.0, 2.0 gc.quad_curve_to(ctrl[0], ctrl[1], to[0], to[1]) path = gc._get_path() actual_ctrl, flag = path._vertex() self.assertEqual(actual_ctrl, ctrl) self.assertEqual(flag, 3) actual_to, flag = path._vertex() self.assertEqual(actual_to, to) self.assertEqual(flag, 3) def test_curve_to(self): gc = agg.GraphicsContextArray((100, 100)) ctrl1 = 1.0, 1.0 ctrl2 = 2.0, 2.0 to = 3.0, 3.0 gc.curve_to(ctrl1[0], ctrl1[1], ctrl2[0], ctrl2[1], to[0], to[1]) path = gc._get_path() actual_ctrl1, flag = path._vertex() self.assertEqual(actual_ctrl1, ctrl1) self.assertEqual(flag, 4) actual_ctrl2, flag = path._vertex() self.assertEqual(actual_ctrl2, ctrl2) self.assertEqual(flag, 4) actual_to, flag = path._vertex() self.assertEqual(actual_to, to) self.assertEqual(flag, 4) def test_add_path(self): path1 = agg.CompiledPath() path1.move_to(1.0,1.0) path1.translate_ctm(1.0,1.0) path1.line_to(2.0,2.0) #actually (3.0,3.0) path1.scale_ctm(2.0,2.0) path1.line_to(2.0,2.0) # actually (5.0,5.0) gc = agg.GraphicsContextArray((100,100)) gc.move_to(1.0,1.0) gc.translate_ctm(1.0,1.0) gc.line_to(2.0,2.0) #actually (3.0,3.0) sub_path = agg.CompiledPath() sub_path.scale_ctm(2.0,2.0) sub_path.line_to(2.0,2.0) gc.add_path(sub_path) path2 = gc._get_path() desired = path1._vertices() actual = path2._vertices() self.assert_(allclose(actual, desired)) desired = path1.get_ctm() actual = path2.get_ctm() self.assertEqual(actual, desired) def base_lines(self, lines): gc = agg.GraphicsContextArray((100, 100)) gc.move_to(1.0,1.0) gc.line_to(2.0,2.0) #actually (3.0,3.0) gc.lines(lines) actual = gc._get_path()._vertices() desired = array(((1.0,1.0,agg.path_cmd_move_to, agg.path_flags_none), (2.0,2.0,agg.path_cmd_line_to, agg.path_flags_none), (3.0,3.0,agg.path_cmd_move_to, agg.path_flags_none), (4.0,4.0,agg.path_cmd_line_to, agg.path_flags_none), (0.0,0.0,agg.path_cmd_stop, agg.path_flags_none),)) #print 'desired:', desired #print 'actual:', actual self.assert_(allclose(actual,desired)) def test_lines_array(self): lines = array(((3.0,3.0), (4.0,4.0))) self.base_lines(lines) def test_lines_list(self): lines = [[3.0,3.0], [4.0,4.0]] self.base_lines(lines) def base_rects(self,rects): gc = agg.GraphicsContextArray((100, 100)) gc.rects(rects) actual = gc._get_path()._vertices() desired = array(((1.0,1.0,agg.path_cmd_move_to, agg.path_flags_none), (1.0,2.0,agg.path_cmd_line_to, agg.path_flags_none), (2.0,2.0,agg.path_cmd_line_to, agg.path_flags_none), (2.0,1.0,agg.path_cmd_line_to, agg.path_flags_none), (0.0,0.0,agg.path_cmd_end_poly, agg.path_flags_close), (2.0,2.0,agg.path_cmd_move_to, agg.path_flags_none), (2.0,3.0,agg.path_cmd_line_to, agg.path_flags_none), (3.0,3.0,agg.path_cmd_line_to, agg.path_flags_none), (3.0,2.0,agg.path_cmd_line_to, agg.path_flags_none), (0.0,0.0,agg.path_cmd_end_poly, agg.path_flags_close), (0.0,0.0,agg.path_cmd_stop, agg.path_flags_none),)) self.assertTrue(allclose(actual,desired)) def test_rects_array(self): rects = array(((1.0,1.0,1.0,1.0), (2.0,2.0,1.0,1.0))) self.base_rects(rects) def test_rects_list(self): rects = [[1.0,1.0,1.0,1.0], [2.0,2.0,1.0,1.0]] self.base_rects(rects) def test_rect(self): gc = agg.GraphicsContextArray((100,100)) gc.rect(1.0,1.0,1.0,1.0) actual = gc._get_path()._vertices() desired = array(((1.0,1.0,agg.path_cmd_move_to, agg.path_flags_none), (1.0,2.0,agg.path_cmd_line_to, agg.path_flags_none), (2.0,2.0,agg.path_cmd_line_to, agg.path_flags_none), (2.0,1.0,agg.path_cmd_line_to, agg.path_flags_none), (0.0,0.0,agg.path_cmd_end_poly, agg.path_flags_close), (0.0,0.0,agg.path_cmd_stop, agg.path_flags_none),)) self.assertTrue(allclose(actual,desired)) def test_clip_to_rect(self): gc = agg.GraphicsContextArray((10,10)) gc.move_to(0,0) gc.line_to(10,10) gc.clip_to_rect(5,5,5,5) gc.stroke_path() #print 'clipping on' #print gc.bmp_array[:,:,0] # make sure nothing was drawn in the corner self.assertEqual(gc.bmp_array[-1,0,0], 255) def test_stroke_path(self): gc = agg.GraphicsContextArray((5,5)) gc.move_to(0,0) gc.line_to(5,5) gc.stroke_path() #print #print "stroke lower-left to upper-right:" #print gc.bmp_array[:,:,0] # assert the lower left and upper corner are the same, # and have something drawn in them. self.assertEqual(gc.bmp_array[-1,0,0], gc.bmp_array[0,-1,0]) self.assertNotEqual(gc.bmp_array[-1,0,0], 255) def test_set_get_text_position(self): #print 'testing text position' gc = agg.GraphicsContextArray((5,5)) gc.set_text_position(1,1) actual = gc.get_text_position() desired = (1,1) self.assertTrue(allclose(actual,desired)) def test_get_set_font(self): gc = agg.GraphicsContextArray((5,5)) font1 = Font('modern') gc.set_font(font1) font3 = gc.get_font() self.assertEqual(font1.face_name, font3.name) self.assertEqual(font1.size, font3.size) self.assertEqual(font1.family, font3.family) self.assertEqual(font1.style, font3.style) self.assertEqual(font1.encoding, font3.encoding) def test_set_line_dash_none(self): gc = agg.GraphicsContextArray((5,5)) gc.set_line_dash(None) # !! need to add an accessor to test result def test_set_line_dash_list(self): gc = agg.GraphicsContextArray((5,5)) gc.set_line_dash([2,3]) # !! need to add an accessor to test result def test_set_line_dash_2d_list(self): gc = agg.GraphicsContextArray((5,5)) try: gc.set_line_dash([[2,3],[2,3]]) except TypeError: pass if __name__ == "__main__": unittest.main() enthought-chaco2-4.1.0.orig/kiva/agg/implementation_notes.txt0000644000175000017500000000775611674463636023412 0ustar varunvarunStroke path pipeline -------------------- The stroke_path pipeline is made up of 8 functions. (geeze...) This strange stringing-together-of-functions is due to aggs template based render pipeline. Most of the functions are templatized on their input parameter type. Depending upon the steps needed in the render pipeline, the next function is called with a different input type. For example, one of the first steps in the process checks to see if a path has curves. If it doesn't, we don't need to do curve conversion. If it does, the conversion needs to occur. Normally, this would be done with a if/then to call a separate function. But agg does curve conversion through a template mechanism agg::conv_curve that adapts the input path type into a new path type that interprets curves correctly. Here is an example snippet of code: if (!this->path.has_curves()) { this->stroke_path_dash_conversion(this->path); } else { agg::conv_curve curved_path(this->path); this->stroke_path_dash_conversion(curved_path); } So, stroke_path_dash_conversion(curved_path) is called in either case. It is just called with the input path in one case, and the input path converted to a curved path in the second. Here is how the individual functions string together. 1. stroke_path() This one is the exposed API method. It does very little besides call _stroke_path and clean up the path at the end. 2. _stroke_path() Checks to see if the path has curves in it. If needed, curve conversion is inserted into the render pipeline. Otherwise, the step is by-passed for maximum speed. Either way, stroke_path_dash_conversion() is always the next method called. 3. template stroke_path_dash_conversion(path_type& input_path) If the line is dashed, dash conversion is inserted into the pipeline. Otherwise it is not. Either way, stroke_path_choose_clipping_renderer() is always the next method called. 4. template void stroke_path_choose_clipping_renderer(path_type& input_path) This will choose between single rect clipping, multi-rect-clipping and arbitrary path clipping in the future. fix me: Currently, only multi-rect-clipping is used. 5. template void stroke_path_choose_rasterizer(path_type& input_path, renderer_type& input_renderer) Depending on settings (aliasing, joins, caps, etc.), there are multiple different rasterizers to choose from -- each with different capabilities and efficiencies. This method calls the most efficient render function possible for the required settings. 6. Finally... One of the following functions is used to actually paint the pixels to the image. template void stroke_path_outline(path_type& input_path, renderer_type& input_renderer) The most efficient is the line_width=1 and aliased. It is much faster than the others. (Together now, "How much faster is it?"). fix me: Get answer. template void stroke_path_outline_aa(path_type& input_path, renderer_type& input_renderer) The second most efficient method outline rasterizer is used if the line width <= 10, the line cap is ROUND or BUTT and the join is MITER. template void stroke_path_scanline_aa(path_type& input_path, renderer_type& renderer, scanline_type& scanline) If line width > 10, cap is SQUARE or join is ROUND or BEVEL, this method is used. enthought-chaco2-4.1.0.orig/kiva/agg/agg-24/0000755000175000017500000000000011674463635017355 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/Makefile.in.MINGW32_NT-5.00000644000175000017500000000014311674463635023346 0ustar varunvarunAGGLIBS= -lagg AGGCXXFLAGS = -O3 CXX = g++ C = gcc #CXX = icc LIB = ar cr .PHONY : clean enthought-chaco2-4.1.0.orig/kiva/agg/agg-24/Makefile.AmigaOS0000644000175000017500000002722011674463635022277 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.1.0.orig/kiva/agg/agg-24/Makefile.in.Darwin.SDL0000644000175000017500000000033611674463635023270 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.1.0.orig/kiva/agg/agg-24/src/0000755000175000017500000000000011674463635020144 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/agg_sqrt_tables.cpp0000644000175000017500000002043111674463635024011 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 agg { 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.1.0.orig/kiva/agg/agg-24/src/agg_vcgen_smooth_poly1.cpp0000644000175000017500000001610111674463635025304 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/ctrl/0000755000175000017500000000000011674463635021110 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/ctrl/agg_slider_ctrl.cpp0000644000175000017500000002417111674463635024745 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/ctrl/agg_bezier_ctrl.cpp0000644000175000017500000002605511674463635024746 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/ctrl/agg_gamma_spline.cpp0000644000175000017500000000722011674463635025067 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/ctrl/Makefile.am0000644000175000017500000000061011674463635023141 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.1.0.orig/kiva/agg/agg-24/src/ctrl/agg_cbox_ctrl.cpp0000644000175000017500000001456511674463635024424 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/ctrl/agg_rbox_ctrl.cpp0000644000175000017500000002307711674463635024441 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/ctrl/agg_polygon_ctrl.cpp0000644000175000017500000002510711674463635025152 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 agg { 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.1.0.orig/kiva/agg/agg-24/src/ctrl/agg_gamma_ctrl.cpp0000644000175000017500000003332211674463635024543 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/ctrl/agg_spline_ctrl.cpp0000644000175000017500000002713611674463635024761 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/ctrl/agg_scale_ctrl.cpp0000644000175000017500000003333411674463635024553 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/install0000644000175000017500000000000011674463635021523 0ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/authors0000644000175000017500000000000011674463635021542 0ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/Makefile.am0000644000175000017500000000241311674463635022200 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.1.0.orig/kiva/agg/agg-24/src/agg_vpgen_clip_polygon.cpp0000644000175000017500000000745011674463635025371 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 agg { //------------------------------------------------------------------------ // 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.1.0.orig/kiva/agg/agg-24/src/autogen.sh0000644000175000017500000000047211674463635022145 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.1.0.orig/kiva/agg/agg-24/src/agg_bezier_arc.cpp0000644000175000017500000002131711674463635023577 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 agg { // 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.1.0.orig/kiva/agg/agg-24/src/readme0000644000175000017500000000032411674463635021323 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.1.0.orig/kiva/agg/agg-24/src/agg_rounded_rect.cpp0000644000175000017500000001236411674463635024151 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/agg_arc.cpp0000644000175000017500000000626311674463635022242 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/agg_vcgen_contour.cpp0000644000175000017500000001224511674463635024345 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/agg_embedded_raster_fonts.cpp0000644000175000017500000142631211674463635026021 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 agg { 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.1.0.orig/kiva/agg/agg-24/src/agg_trans_warp_magnifier.cpp0000644000175000017500000000322511674463635025671 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/ChangeLog0000644000175000017500000000000011674463635021704 0ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/copying0000644000175000017500000000070611674463635021542 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.1.0.orig/kiva/agg/agg-24/src/agg_arrowhead.cpp0000644000175000017500000000726011674463635023447 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/configure.in0000644000175000017500000000040311674463635022452 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.1.0.orig/kiva/agg/agg-24/src/agg_vcgen_dash.cpp0000644000175000017500000001621411674463635023573 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/agg_vpgen_clip_polyline.cpp0000644000175000017500000000474011674463635025534 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 agg { //---------------------------------------------------------------------------- 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.1.0.orig/kiva/agg/agg-24/src/agg_vpgen_segmentator.cpp0000644000175000017500000000374011674463635025221 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 agg { 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.1.0.orig/kiva/agg/agg-24/src/agg_vcgen_stroke.cpp0000644000175000017500000001600611674463635024162 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/agg_line_profile_aa.cpp0000644000175000017500000000711011674463635024575 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 agg { //--------------------------------------------------------------------- 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.1.0.orig/kiva/agg/agg-24/src/agg_vcgen_markers_term.cpp0000644000175000017500000000651311674463635025350 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/agg_gsv_text.cpp0000644000175000017500000010117211674463635023333 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 agg { 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.1.0.orig/kiva/agg/agg-24/src/news0000644000175000017500000000000011674463635021031 0ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/platform/0000755000175000017500000000000011674463635021770 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/platform/BeOS/0000755000175000017500000000000011674463635022560 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/platform/BeOS/Makefile.am0000644000175000017500000000004511674463635024613 0ustar varunvarunEXTRA_DIST=agg_platform_support.cpp enthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/platform/BeOS/agg_platform_support.cpp0000644000175000017500000010244311674463635027526 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, agg::platform_support* agg, agg::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 == agg::pix_format_bgra32) { DrawBitmap(fBitmap, updateRect, updateRect); } else { BBitmap* bitmap = new BBitmap(fBitmap->Bounds(), 0, B_RGBA32); agg::rendering_buffer rbuf_src; rbuf_src.attach((uint8*)fBitmap->Bits(), fBitmap->Bounds().IntegerWidth() + 1, fBitmap->Bounds().IntegerHeight() + 1, fFlipY ? -fBitmap->BytesPerRow() : fBitmap->BytesPerRow()); agg::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 agg::pix_format_rgb555: agg::color_conv(&rbuf_dst, &rbuf_src, agg::color_conv_rgb555_to_bgra32()); break; case agg::pix_format_rgb565: agg::color_conv(&rbuf_dst, &rbuf_src, agg::color_conv_rgb565_to_bgra32()); break; case agg::pix_format_rgb24: agg::color_conv(&rbuf_dst, &rbuf_src, agg::color_conv_rgb24_to_bgra32()); break; case agg::pix_format_bgr24: agg::color_conv(&rbuf_dst, &rbuf_src, agg::color_conv_bgr24_to_bgra32()); break; case agg::pix_format_rgba32: agg::color_conv(&rbuf_dst, &rbuf_src, agg::color_conv_rgba32_to_bgra32()); break; case agg::pix_format_argb32: agg::color_conv(&rbuf_dst, &rbuf_src, agg::color_conv_argb32_to_bgra32()); break; case agg::pix_format_abgr32: agg::color_conv(&rbuf_dst, &rbuf_src, agg::color_conv_abgr32_to_bgra32()); break; case agg::pix_format_bgra32: agg::color_conv(&rbuf_dst, &rbuf_src, agg::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(agg::platform_support::max_images - 1); fAGG->save_img(agg::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() & agg::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 |= agg::mouse_left; if (buttons & B_SECONDARY_MOUSE_BUTTON) flags |= agg::mouse_right; if (mods & B_SHIFT_KEY) flags |= agg::kbd_shift; if (mods & B_COMMAND_KEY) flags |= agg::kbd_ctrl; return flags; } private: BBitmap* fBitmap; uint8 fLastKeyDown; agg::platform_support* fAGG; agg::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, agg::platform_support* agg, agg::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(agg::platform_support* agg, int width, int height, agg::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 & agg::window_resize)) windowFlags |= B_NOT_RESIZABLE; return fWindow->Init(r, agg, format, flipY, windowFlags);; } AGGWindow* Window() const { return fWindow; } private: AGGWindow* fWindow; }; namespace agg { class platform_specific { public: platform_specific(agg::platform_support* agg, agg::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 < agg::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(); } agg::platform_support* fAGG; AGGApplication* fApp; agg::pix_format_e fFormat; bool fFlipY; bigtime_t fTimerStart; BBitmap* fImages[agg::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.1.0.orig/kiva/agg/agg-24/src/platform/Makefile.am0000644000175000017500000000005211674463635024021 0ustar varunvarunSUBDIRS = X11 sdl win32 AmigaOS BeOS mac enthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/platform/mac/0000755000175000017500000000000011674463635022530 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/platform/mac/Makefile.am0000644000175000017500000000055411674463635024570 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.1.0.orig/kiva/agg/agg-24/src/platform/mac/agg_platform_support.cpp0000644000175000017500000010621711674463635027501 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 agg { 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(agg::platform_support::max_images - 1); app->save_img(agg::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.1.0.orig/kiva/agg/agg-24/src/platform/mac/agg_mac_pmap.cpp0000644000175000017500000002135511674463635025635 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/platform/win32/0000755000175000017500000000000011674463635022732 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/platform/win32/Makefile.am0000644000175000017500000000061211674463635024765 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.1.0.orig/kiva/agg/agg-24/src/platform/win32/agg_win32_bmp.cpp0000644000175000017500000004621711674463635026066 0ustar varunvarun//---------------------------------------------------------------------------- // //---------------------------------------------------------------------------- // Contact: mcseemagg@yahoo.com //---------------------------------------------------------------------------- // // class pixel_map // //---------------------------------------------------------------------------- #include "platform/win32/agg_win32_bmp.h" #include "agg_basics.h" namespace agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/platform/win32/agg_platform_support.cpp0000644000175000017500000013707411674463635027710 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 agg { //------------------------------------------------------------------------ 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(agg::platform_support::max_images - 1); app->save_img(agg::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 agg { // 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) { agg::g_windows_instance = hInstance; agg::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)); agg::tokenizer cmd_line(" ", "\"' ", "\"'", '\\', agg::tokenizer::multiple); cmd_line.set_str(lpszCmdLine); int argc = 0; argv[argc++] = argv_ptr; *argv_ptr++ = 0; while(argc < 64) { agg::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.1.0.orig/kiva/agg/agg-24/src/platform/sdl/0000755000175000017500000000000011674463635022552 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/platform/sdl/Makefile.am0000644000175000017500000000045511674463635024612 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.1.0.orig/kiva/agg/agg-24/src/platform/sdl/agg_platform_support.cpp0000644000175000017500000005564411674463635027532 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/platform/AmigaOS/0000755000175000017500000000000011674463635023250 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/platform/AmigaOS/Makefile.am0000644000175000017500000000004511674463635025303 0ustar varunvarunEXTRA_DIST=agg_platform_support.cpp enthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/platform/AmigaOS/agg_platform_support.cpp0000644000175000017500000006150111674463635030215 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 agg { 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 & agg::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.1.0.orig/kiva/agg/agg-24/src/platform/X11/0000755000175000017500000000000011674463635022341 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/src/platform/X11/Makefile.am0000644000175000017500000000046611674463635024403 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.1.0.orig/kiva/agg/agg-24/src/platform/X11/agg_platform_support.cpp0000644000175000017500000014331611674463635027313 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/agg_curves.cpp0000644000175000017500000004361311674463635023004 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/Makefile0000644000175000017500000000237311674463635021611 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.1.0.orig/kiva/agg/agg-24/src/agg_bspline.cpp0000644000175000017500000001773711674463635023141 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/agg_vcgen_bspline.cpp0000644000175000017500000001527211674463635024313 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/agg_line_aa_basics.cpp0000644000175000017500000000610011674463635024377 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 agg { //------------------------------------------------------------------------- // 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.1.0.orig/kiva/agg/agg-24/src/agg_trans_single_path.cpp0000644000175000017500000001516211674463635025177 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/agg_trans_double_path.cpp0000644000175000017500000002032411674463635025164 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/src/agg_image_filters.cpp0000644000175000017500000000712711674463635024307 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 agg { //-------------------------------------------------------------------- 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.1.0.orig/kiva/agg/agg-24/src/agg_trans_affine.cpp0000644000175000017500000001436411674463635024135 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/install0000644000175000017500000000342311674463635020750 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.1.0.orig/kiva/agg/agg-24/authors0000644000175000017500000000012711674463635020765 0ustar varunvarunAnti-Grain Geometry - Version 2.4 Copyright (C) 2002-2005 Maxim Shemanarev (McSeem) enthought-chaco2-4.1.0.orig/kiva/agg/agg-24/Makefile.am0000644000175000017500000000115411674463635021412 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.1.0.orig/kiva/agg/agg-24/libagg.m40000644000175000017500000000165511674463635021053 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.1.0.orig/kiva/agg/agg-24/autogen.sh0000644000175000017500000000055511674463635021360 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.1.0.orig/kiva/agg/agg-24/readme0000644000175000017500000000402011674463635020531 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.1.0.orig/kiva/agg/agg-24/Makefile.in.IRIX640000644000175000017500000000012511674463635022344 0ustar varunvarunAGGLIBS= -lagg AGGCXXFLAGS = CXX = CC C = cc LIB = CC -ar -o .PHONY : clean enthought-chaco2-4.1.0.orig/kiva/agg/agg-24/Makefile.in.SunOS0000644000175000017500000000020411674463635022424 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.1.0.orig/kiva/agg/agg-24/Makefile.in.CYGWIN_NT-5.00000644000175000017500000000021111674463635023314 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.1.0.orig/kiva/agg/agg-24/include/0000755000175000017500000000000011674463635021000 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/include/agg_span_image_filter_gray.h0000644000175000017500000007364511674463635026500 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 agg { //==============================================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.1.0.orig/kiva/agg/agg-24/include/agg_image_accessors.h0000644000175000017500000003243211674463635025122 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 agg { //-----------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_conv_stroke.h0000644000175000017500000000622511674463635024330 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 agg { //-------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_rasterizer_outline.h0000644000175000017500000001045611674463635025726 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 agg { //======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_span_interpolator_adaptor.h0000644000175000017500000000526711674463635027256 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 agg { //===============================================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.1.0.orig/kiva/agg/agg-24/include/agg_path_storage.h0000644000175000017500000014020111674463635024445 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 agg { //----------------------------------------------------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 agg //{ // typedef path_base > > stl_path_storage; //} #endif enthought-chaco2-4.1.0.orig/kiva/agg/agg-24/include/agg_scanline_storage_aa.h0000644000175000017500000006511111674463635025754 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 agg { //----------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_span_allocator.h0000644000175000017500000000347711674463635025003 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 agg { //----------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_span_interpolator_trans.h0000644000175000017500000000620411674463635026743 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 agg { //=================================================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.1.0.orig/kiva/agg/agg-24/include/agg_shorten_path.h0000644000175000017500000000406211674463635024467 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 agg { //===========================================================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.1.0.orig/kiva/agg/agg-24/include/ctrl/0000755000175000017500000000000011674463635021744 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/include/ctrl/agg_scale_ctrl.h0000644000175000017500000001064311674463635025052 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/include/ctrl/agg_slider_ctrl.h0000644000175000017500000001134711674463635025247 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 agg { //--------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/ctrl/agg_cbox_ctrl.h0000644000175000017500000000722511674463635024720 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 agg { //----------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/ctrl/Makefile.am0000644000175000017500000000037111674463635024001 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.1.0.orig/kiva/agg/agg-24/include/ctrl/agg_bezier_ctrl.h0000644000175000017500000001452711674463635025250 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 agg { //--------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/ctrl/agg_rbox_ctrl.h0000644000175000017500000001104711674463635024734 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/include/ctrl/agg_gamma_ctrl.h0000644000175000017500000001436411674463635025051 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 agg { //------------------------------------------------------------------------ // 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 agg::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.1.0.orig/kiva/agg/agg-24/include/ctrl/agg_polygon_ctrl.h0000644000175000017500000001236611674463635025456 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 agg { 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.1.0.orig/kiva/agg/agg-24/include/ctrl/agg_gamma_spline.h0000644000175000017500000000741511674463635025376 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 agg { //------------------------------------------------------------------------ // 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 agg::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.1.0.orig/kiva/agg/agg-24/include/ctrl/agg_spline_ctrl.h0000644000175000017500000001336511674463635025261 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 agg { //------------------------------------------------------------------------ // 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.1.0.orig/kiva/agg/agg-24/include/ctrl/agg_ctrl.h0000644000175000017500000000757711674463635023717 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 agg { //--------------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_bezier_arc.h0000644000175000017500000001345611674463635024105 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 agg { //----------------------------------------------------------------------- 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.1.0.orig/kiva/agg/agg-24/include/agg_arc.h0000644000175000017500000000407411674463635022541 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 agg { //=====================================================================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.1.0.orig/kiva/agg/agg-24/include/agg_trans_single_path.h0000644000175000017500000000600711674463635025476 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 agg { // 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.1.0.orig/kiva/agg/agg-24/include/agg_vcgen_vertex_sequence.h0000644000175000017500000000757711674463635026376 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 agg { //===================================================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.1.0.orig/kiva/agg/agg-24/include/agg_rasterizer_compound_aa.h0000644000175000017500000004740411674463635026537 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 agg { //-----------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_pixfmt_rgba.h0000644000175000017500000032206011674463635024274 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 agg { //=========================================================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.1.0.orig/kiva/agg/agg-24/include/agg_pixfmt_amask_adaptor.h0000644000175000017500000001771411674463635026176 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 agg { //==================================================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.1.0.orig/kiva/agg/agg-24/include/agg_renderer_markers.h0000644000175000017500000010766011674463635025333 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 agg { //---------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_span_gouraud_gray.h0000644000175000017500000002050511674463635025502 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 agg { //=======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_ellipse.h0000644000175000017500000000727311674463635023435 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 agg { //----------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_conv_transform.h0000644000175000017500000000412211674463635025026 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 agg { //----------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_pattern_filters_rgba.h0000644000175000017500000001022511674463635026167 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 agg { //=======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_simul_eq.h0000644000175000017500000001006411674463635023606 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 agg { //=============================================================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.1.0.orig/kiva/agg/agg-24/include/agg_renderer_base.h0000644000175000017500000004530311674463635024574 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 agg { //-----------------------------------------------------------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 = agg::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 = agg::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 = agg::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.1.0.orig/kiva/agg/agg-24/include/Makefile.am0000644000175000017500000000705311674463635023041 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.1.0.orig/kiva/agg/agg-24/include/agg_span_converter.h0000644000175000017500000000372611674463635025027 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 agg { //----------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_rasterizer_cells_aa.h0000644000175000017500000005321311674463635026010 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 agg { //-----------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_gsv_text.h0000644000175000017500000001006011674463635023627 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 agg { //---------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_scanline_boolean_algebra.h0000644000175000017500000015522411674463635026750 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 agg { //-----------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_span_gouraud_rgba.h0000644000175000017500000002354311674463635025460 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 agg { //=======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_renderer_primitives.h0000644000175000017500000001752411674463635026061 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 agg { //-----------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_conv_adaptor_vpgen.h0000644000175000017500000001206511674463635025651 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 agg { //======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_renderer_mclip.h0000644000175000017500000002752711674463635024776 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 agg { //----------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_rasterizer_outline_aa.h0000644000175000017500000005150611674463635026370 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 agg { //------------------------------------------------------------------------- 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.1.0.orig/kiva/agg/agg-24/include/agg_vcgen_bspline.h0000644000175000017500000000421411674463635024606 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 agg { //==========================================================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.1.0.orig/kiva/agg/agg-24/include/agg_math_stroke.h0000644000175000017500000004274111674463635024317 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 agg { //-------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_color_rgba.h0000644000175000017500000006204211674463635024104 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 agg { // 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.1.0.orig/kiva/agg/agg-24/include/agg_pixfmt_gray.h0000644000175000017500000004603411674463635024327 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 agg { //============================================================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.1.0.orig/kiva/agg/agg-24/include/agg_span_image_filter.h0000644000175000017500000002122111674463635025435 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 agg { //-------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_trans_bilinear.h0000644000175000017500000001275011674463635024770 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 agg { //==========================================================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.1.0.orig/kiva/agg/agg-24/include/agg_span_image_filter_rgb.h0000644000175000017500000011123411674463635026273 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 agg { //===============================================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.1.0.orig/kiva/agg/agg-24/include/agg_vcgen_contour.h0000644000175000017500000000673211674463635024652 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 agg { //----------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_dda_line.h0000644000175000017500000002104411674463635023527 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 agg { //===================================================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.1.0.orig/kiva/agg/agg-24/include/agg_array.h0000644000175000017500000010211111674463635023101 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 agg { //-------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_vpgen_segmentator.h0000644000175000017500000000350611674463635025522 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 agg { //=======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_bspline.h0000644000175000017500000000523411674463635023427 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 agg { //----------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_gamma_lut.h0000644000175000017500000000675611674463635023753 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 agg { 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.1.0.orig/kiva/agg/agg-24/include/agg_arrowhead.h0000644000175000017500000000454311674463635023751 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 agg { //===============================================================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.1.0.orig/kiva/agg/agg-24/include/agg_renderer_scanline.h0000644000175000017500000006055511674463635025464 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 agg { //================================================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.1.0.orig/kiva/agg/agg-24/include/agg_config.h0000644000175000017500000000126111674463635023234 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.1.0.orig/kiva/agg/agg-24/include/agg_vcgen_stroke.h0000644000175000017500000000714211674463635024464 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 agg { //============================================================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.1.0.orig/kiva/agg/agg-24/include/agg_conv_contour.h0000644000175000017500000000565111674463635024514 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 agg { //-----------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_span_gradient_alpha.h0000644000175000017500000001171011674463635025752 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 agg { //======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_rendering_buffer.h0000644000175000017500000001257411674463635025306 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 agg { //==========================================================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.1.0.orig/kiva/agg/agg-24/include/agg_conv_marker.h0000644000175000017500000001106211674463635024275 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 agg { //-------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_scanline_storage_bin.h0000644000175000017500000004457611674463635026157 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 agg { //-----------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_conv_unclose_polygon.h0000644000175000017500000000332711674463635026240 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 agg { //====================================================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.1.0.orig/kiva/agg/agg-24/include/agg_span_gouraud.h0000644000175000017500000001341311674463635024460 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 agg { //============================================================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.1.0.orig/kiva/agg/agg-24/include/agg_conv_marker_adaptor.h0000644000175000017500000000356611674463635026021 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 agg { //=====================================================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.1.0.orig/kiva/agg/agg-24/include/agg_conv_shorten_path.h0000644000175000017500000000336611674463635025522 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 agg { //=======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_gamma_functions.h0000644000175000017500000000645711674463635025155 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 agg { //===============================================================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.1.0.orig/kiva/agg/agg-24/include/agg_path_storage_integer.h0000644000175000017500000002355511674463635026176 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 agg { //---------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_span_subdiv_adaptor.h0000644000175000017500000001154111674463635026020 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 agg { //=================================================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.1.0.orig/kiva/agg/agg-24/include/agg_vcgen_dash.h0000644000175000017500000000526011674463635024073 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 agg { //---------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_glyph_raster_bin.h0000644000175000017500000001165211674463635025327 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 agg { //========================================================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.1.0.orig/kiva/agg/agg-24/include/agg_image_filters.h0000644000175000017500000003574011674463635024612 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 agg { // 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.1.0.orig/kiva/agg/agg-24/include/agg_vpgen_clip_polygon.h0000644000175000017500000000470111674463635025666 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 agg { //======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_font_cache_manager.h0000644000175000017500000003505611674463635025563 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 agg { //---------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_span_solid.h0000644000175000017500000000333311674463635024124 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 agg { //--------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_span_pattern_rgb.h0000644000175000017500000000672111674463635025325 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 agg { //========================================================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.1.0.orig/kiva/agg/agg-24/include/agg_trans_warp_magnifier.h0000644000175000017500000000306111674463635026170 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 agg { //----------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_trans_affine.h0000644000175000017500000003635511674463635024442 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 agg { 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: // // agg::trans_affine m; // m *= agg::trans_affine_rotation(30.0 * 3.1415926 / 180.0); // m *= agg::trans_affine_scaling(2.0, 1.5); // m *= agg::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 *= agg::trans_affine_translation(-100.0, -100.0); // move to (0,0) // m *= agg::trans_affine_rotation(30.0 * 3.1415926 / 180.0); // rotate // m *= agg::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.1.0.orig/kiva/agg/agg-24/include/agg_math.h0000644000175000017500000003176611674463635022735 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 agg { //------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_bounding_rect.h0000644000175000017500000000716611674463635024623 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 agg { //-----------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_line_aa_basics.h0000644000175000017500000001541411674463635024710 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 agg { // 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.1.0.orig/kiva/agg/agg-24/include/agg_trans_viewport.h0000644000175000017500000002326111674463635025061 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 agg { 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.1.0.orig/kiva/agg/agg-24/include/agg_span_pattern_gray.h0000644000175000017500000000646111674463635025516 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 agg { //=======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_conv_close_polygon.h0000644000175000017500000000720411674463635025673 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 agg { //======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_conv_clip_polyline.h0000644000175000017500000000504311674463635025660 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 agg { //=======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_bitset_iterator.h0000644000175000017500000000270211674463635025173 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 agg { 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.1.0.orig/kiva/agg/agg-24/include/agg_basics.h0000644000175000017500000003743611674463635023250 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 agg { // 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 agg { //------------------------------------------------------------------------- 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 agg::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.1.0.orig/kiva/agg/agg-24/include/agg_embedded_raster_fonts.h0000644000175000017500000000423611674463635026316 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 agg { 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.1.0.orig/kiva/agg/agg-24/include/agg_span_interpolator_persp.h0000644000175000017500000003741411674463635026754 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 agg { //===========================================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.1.0.orig/kiva/agg/agg-24/include/agg_vpgen_clip_polyline.h0000644000175000017500000000453111674463635026033 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 agg { //======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_vertex_sequence.h0000644000175000017500000001234611674463635025202 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 agg { //----------------------------------------------------------vertex_sequence // Modified agg::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.1.0.orig/kiva/agg/agg-24/include/agg_scanline_bin.h0000644000175000017500000001751411674463635024423 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 agg { //=============================================================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.1.0.orig/kiva/agg/agg-24/include/agg_trans_double_path.h0000644000175000017500000001033611674463635025467 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 agg { // 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.1.0.orig/kiva/agg/agg-24/include/agg_pixfmt_rgb.h0000644000175000017500000006654011674463635024143 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 agg { //=====================================================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.1.0.orig/kiva/agg/agg-24/include/platform/0000755000175000017500000000000011674463635022624 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/include/platform/Makefile.am0000644000175000017500000000022611674463635024660 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.1.0.orig/kiva/agg/agg-24/include/platform/agg_platform_support.h0000644000175000017500000007237611674463635027252 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 agg { //----------------------------------------------------------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 agg::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, agg::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.1.0.orig/kiva/agg/agg-24/include/platform/mac/0000755000175000017500000000000011674463635023364 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/include/platform/mac/agg_mac_pmap.h0000644000175000017500000000531711674463635026136 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 agg { 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.1.0.orig/kiva/agg/agg-24/include/platform/win32/0000755000175000017500000000000011674463635023566 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/include/platform/win32/agg_win32_bmp.h0000644000175000017500000001023711674463635026360 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 agg { 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.1.0.orig/kiva/agg/agg-24/include/agg_scanline_u.h0000644000175000017500000004222411674463635024113 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 agg { //=============================================================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 scanline_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.1.0.orig/kiva/agg/agg-24/include/agg_renderer_outline_image.h0000644000175000017500000010640511674463635026504 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 agg { //========================================================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) { agg::dda2_line_interpolator li(0, lp.vertical ? (lp.dy << agg::line_subpixel_shift) : (lp.dx << agg::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.1.0.orig/kiva/agg/agg-24/include/agg_vcgen_markers_term.h0000644000175000017500000000403311674463635025644 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 agg { //======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_conv_concat.h0000644000175000017500000000440611674463635024267 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 agg { //=============================================================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.1.0.orig/kiva/agg/agg-24/include/util/0000755000175000017500000000000011674463635021755 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/include/util/agg_color_conv_rgb16.h0000644000175000017500000002535211674463635026117 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: // // agg::color_conv(dst, src, agg::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 agg { //-------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/util/Makefile.am0000644000175000017500000000017311674463635024012 0ustar varunvarunmyincludedir = $(includedir)/agg2/util myinclude_HEADERS = agg_color_conv.h agg_color_conv_rgb8.h agg_color_conv_rgb16.h enthought-chaco2-4.1.0.orig/kiva/agg/agg-24/include/util/agg_color_conv_rgb8.h0000644000175000017500000004355411674463635026044 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: // // agg::color_conv(dst, src, agg::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 agg { //-----------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/util/agg_color_conv.h0000644000175000017500000000470711674463635025117 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 agg { //--------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_span_gradient.h0000644000175000017500000003425111674463635024612 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 agg { 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.1.0.orig/kiva/agg/agg-24/include/agg_rendering_buffer_dynarow.h0000644000175000017500000001227711674463635027051 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 agg { //===============================================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.1.0.orig/kiva/agg/agg-24/include/agg_path_length.h0000644000175000017500000000366111674463635024272 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 agg { 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.1.0.orig/kiva/agg/agg-24/include/agg_pixfmt_rgb_packed.h0000644000175000017500000013352011674463635025443 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 agg { //=========================================================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.1.0.orig/kiva/agg/agg-24/include/agg_scanline_p.h0000644000175000017500000002506411674463635024111 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 agg { //=============================================================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.1.0.orig/kiva/agg/agg-24/include/agg_curves.h0000644000175000017500000005034611674463635023306 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 agg { // 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.1.0.orig/kiva/agg/agg-24/include/agg_span_image_filter_rgba.h0000644000175000017500000011454711674463635026446 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 agg { //==============================================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.1.0.orig/kiva/agg/agg-24/include/agg_conv_curve.h0000644000175000017500000001534211674463635024145 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 agg { //---------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_trans_perspective.h0000644000175000017500000001475211674463635025540 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 agg { //=======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_conv_dash.h0000644000175000017500000000432611674463635023740 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 agg { //---------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_trans_lens.h0000644000175000017500000000433011674463635024137 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 agg { 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.1.0.orig/kiva/agg/agg-24/include/agg_conv_smooth_poly1.h0000644000175000017500000000533311674463635025455 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 agg { //-------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_ellipse_bresenham.h0000644000175000017500000000560411674463635025455 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 agg { //------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_conv_clip_polygon.h0000644000175000017500000000502411674463635025513 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 agg { //=======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_renderer_raster_text.h0000644000175000017500000002143311674463635026224 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 agg { //==============================================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 agg::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.1.0.orig/kiva/agg/agg-24/include/agg_conv_bspline.h0000644000175000017500000000327311674463635024455 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 agg { //---------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_span_pattern_rgba.h0000644000175000017500000000657511674463635025475 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 agg { //======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_color_gray.h0000644000175000017500000003336311674463635024137 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 agg { //===================================================================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.1.0.orig/kiva/agg/agg-24/include/agg_conv_adaptor_vcgen.h0000644000175000017500000001177411674463635025642 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 agg { //------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_span_interpolator_linear.h0000644000175000017500000001723211674463635027071 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 agg { //================================================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.1.0.orig/kiva/agg/agg-24/include/agg_alpha_mask_u8.h0000644000175000017500000004505411674463635024513 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 agg { //===================================================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.1.0.orig/kiva/agg/agg-24/include/agg_clip_liang_barsky.h0000644000175000017500000002334711674463635025454 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 agg { //------------------------------------------------------------------------ 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.1.0.orig/kiva/agg/agg-24/include/agg_renderer_outline_aa.h0000644000175000017500000017767611674463635026025 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 agg { //===================================================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) { agg::dda2_line_interpolator li(0, lp.vertical ? (lp.dy << agg::line_subpixel_shift) : (lp.dx << agg::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; } 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.1.0.orig/kiva/agg/agg-24/include/agg_vcgen_smooth_poly1.h0000644000175000017500000000513411674463635025611 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 agg { //======================================================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.1.0.orig/kiva/agg/agg-24/include/agg_conv_segmentator.h0000644000175000017500000000336011674463635025346 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 agg { //========================================================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.1.0.orig/kiva/agg/agg-24/include/agg_rasterizer_scanline_aa.h0000644000175000017500000004220111674463635026475 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 agg { //-----------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_rounded_rect.h0000644000175000017500000000441511674463635024450 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 agg { //------------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/include/agg_rasterizer_sl_clip.h0000644000175000017500000003171011674463635025670 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 agg { //--------------------------------------------------------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.1.0.orig/kiva/agg/agg-24/Makefile.in.BeOS0000644000175000017500000000013011674463635022203 0ustar varunvarunAGGLIBS= -lagg AGGCXXFLAGS = -O1 CXX = g++ C = cc LIB = ar -cru .PHONY : clean enthought-chaco2-4.1.0.orig/kiva/agg/agg-24/ChangeLog0000644000175000017500000000003711674463635021127 0ustar varunvarunVisit http://antigrain.com/newsenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/copying0000644000175000017500000000505511674463635020755 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.1.0.orig/kiva/agg/agg-24/Makefile.in.Linux0000644000175000017500000000021111674463635022512 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.1.0.orig/kiva/agg/agg-24/Makefile.in.MINGW32_NT-5.10000644000175000017500000000014311674463635023347 0ustar varunvarunAGGLIBS= -lagg AGGCXXFLAGS = -O3 CXX = g++ C = gcc #CXX = icc LIB = ar cr .PHONY : clean enthought-chaco2-4.1.0.orig/kiva/agg/agg-24/configure.in0000644000175000017500000001175311674463635021675 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.1.0.orig/kiva/agg/agg-24/libagg.pc.in0000644000175000017500000000042511674463635021534 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.1.0.orig/kiva/agg/agg-24/distclean0000644000175000017500000000155011674463635021247 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.1.0.orig/kiva/agg/agg-24/news0000644000175000017500000000003711674463635020254 0ustar varunvarunVisit http://antigrain.com/newsenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/Makefile.in.Darwin0000644000175000017500000000021111674463635022637 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.1.0.orig/kiva/agg/agg-24/Makefile0000644000175000017500000000013611674463635021015 0ustar varunvarunall: lib src/libagg.a: cd src; make lib: src/libagg.a clean: cd src; make clean enthought-chaco2-4.1.0.orig/kiva/agg/agg-24/font_win32_tt/0000755000175000017500000000000011674463635022054 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/font_win32_tt/Makefile.am0000644000175000017500000000077711674463635024123 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.1.0.orig/kiva/agg/agg-24/font_win32_tt/agg_font_win32_tt.h0000644000175000017500000002236111674463635025546 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 agg { //-----------------------------------------------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 agg::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.1.0.orig/kiva/agg/agg-24/font_win32_tt/agg_font_win32_tt.cpp0000644000175000017500000010767211674463635026112 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 agg { //------------------------------------------------------------------------------ // // 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.1.0.orig/kiva/agg/agg-24/Makefile.in.Linux.SDL0000644000175000017500000000020611674463635023137 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.1.0.orig/kiva/agg/agg-24/Makefile.in.CYGWIN_NT-5.10000644000175000017500000000021111674463635023315 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.1.0.orig/kiva/agg/agg-24/font_freetype/0000755000175000017500000000000011674463635022226 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/agg/agg-24/font_freetype/Makefile.am0000644000175000017500000000055011674463635024262 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.1.0.orig/kiva/agg/agg-24/font_freetype/agg_font_freetype.cpp0000644000175000017500000012632011674463635026425 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 agg { //------------------------------------------------------------------------------ // // 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.1.0.orig/kiva/agg/agg-24/font_freetype/agg_font_freetype.h0000644000175000017500000002053511674463635026073 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 agg { //-----------------------------------------------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.1.0.orig/kiva/agg/setup.py0000644000175000017500000002215211674463636020111 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': 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 darwin_opengl_opts = dict( include_dirs = [ '/System/Library/Frameworks/%s.framework/Versions/A/Headers' % x for x in ['Carbon', 'ApplicationServices', 'OpenGL']], define_macros = [('__DARWIN__',None)], extra_link_args = ['-framework %s' % x for x in ['Carbon', 'ApplicationServices', 'OpenGL']] ) 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.1.0.orig/kiva/agg/agg.i0000644000175000017500000000274011674463635017307 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" %pythoncode { #---- testing ----# import sys import os def test(level=10): import unittest runner = unittest.TextTestRunner() runner.run(test_suite()) return runner def test_suite(level=1): # a bit of a mess right now import scipy_test.testing import agg agg_path = os.path.dirname(os.path.abspath(agg.__file__)) sys.path.insert(0,agg_path) sys.path.insert(0,os.path.join(agg_path,'tests')) suites = [] import test_affine_matrix suites.append( test_affine_matrix.test_suite(level=level) ) """ import test_font_type suites.append( test_font_type.test_suite(level=level) ) import test_rgba suites.append( test_rgba.test_suite(level=level) ) """ import test_compiled_path suites.append( test_compiled_path.test_suite(level=level) ) import test_graphics_context suites.append( test_graphics_context.test_suite(level=level) ) """ import test_image suites.append( test_image.test_suite(level=level) ) """ import unittest total_suite = unittest.TestSuite(suites) return total_suite if __name__ == "__main__": test(10) } enthought-chaco2-4.1.0.orig/kiva/gl.py0000644000175000017500000003677111674463636016631 0ustar varunvarun # 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.font import Text from pyglet.text import Label from pyglet.font import load as load_font from pyglet.font.base import Font as PygletFont from pyglet.graphics import Batch 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 GraphicsContextArray from agg import AggFontType from agg import Image 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: raise NotImplementedError("can't convert %r into a numpy array" % (img,)) 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 == BOLD or font.style == BOLD_ITALIC or font.weight == BOLD: bold = True if font.style == ITALIC or font.style == 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() x0 = xform[4] y0 = xform[5] 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.1.0.orig/kiva/trait_defs/0000755000175000017500000000000011674463636017763 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/trait_defs/kiva_font_trait.py0000644000175000017500000001341211674463636023521 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.1.0.orig/kiva/trait_defs/api.py0000644000175000017500000000004511674463636021105 0ustar varunvarunfrom kiva_font_trait import KivaFont enthought-chaco2-4.1.0.orig/kiva/trait_defs/__init__.py0000644000175000017500000000007711674463636022100 0ustar varunvarun# Copyright (c) 2007 by Enthought, Inc. # All rights reserved. enthought-chaco2-4.1.0.orig/kiva/trait_defs/ui/0000755000175000017500000000000011674463636020400 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/trait_defs/ui/__init__.py0000644000175000017500000000007711674463636022515 0ustar varunvarun# Copyright (c) 2007 by Enthought, Inc. # All rights reserved. enthought-chaco2-4.1.0.orig/kiva/trait_defs/ui/wx/0000755000175000017500000000000011674463636021036 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/trait_defs/ui/wx/__init__.py0000644000175000017500000000007711674463636023153 0ustar varunvarun# Copyright (c) 2007 by Enthought, Inc. # All rights reserved. enthought-chaco2-4.1.0.orig/kiva/trait_defs/ui/wx/kiva_font_editor.py0000644000175000017500000001217711674463636024746 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.1.0.orig/kiva/readme.txt0000644000175000017500000000277111674463636017644 0ustar varunvarun[Importing Kiva] To import kiva, you need to get the constants (which includes pen styles, cap styles, lines styles, etc.), the font stuff, and a backend. You can import these all together with a wildcard: from kiva import * If you prefer to get the constants by themselves, you can also do a: import kiva and this will allow you to refer to them as kiva.JOIN_MITER, kiva.CAP_ROUND, etc. If you don't wish to do a wildcard import, you can also just grab the following by themselves: from kiva import Font, CompiledPath, GraphicsContext, Canvas, CanvasWindow This will auto-detect what backend is appropriate based on the OS platform, available libraries, and the order of backends listed in the KIVA_WISHLIST environment variable. If this environment variable is not defined, then the default ordering of backends is in __init__.py. If you want to choose what backend gets used, you can do the following: from kiva.backend_ import GraphicsContext, Canvas, CanvasWindow is one of: image - in-memory GraphicsContext, uses Agg to raster, can save out to any PIL format wx - uses Agg to raster to a platform-dependent wx window wx_gl - uses Agg to raster into a platform-dependent wx.glcanvas gl - uses OpenGL module to draw into a GL window mac - calls Quartz drawing routines into an OS X window/GraphicsContext ps - PostScript file output svg - SVG file output pdf - PDF file output (uses ReportLab) enthought-chaco2-4.1.0.orig/kiva/ps.py0000644000175000017500000002062111674463636016634 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 import cStringIO from numpy import arange, ravel, pi # Local, relative Kiva imports import affine import basecore2d import constants from constants import FILL, STROKE, FILL_STROKE, EOF_FILL, EOF_FILL_STROKE # 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 = cStringIO.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'} _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 = cStringIO.StringIO() self._clipmap = {} self.clip_id = None 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): x,y = self.get_text_position() ttm = self.get_text_matrix() ctm = self.get_ctm() # not device_ctm!! m = affine.concat(ctm,ttm) tx,ty,sx,sy,angle = affine.trs_factor(m) angle = '"%3.3f"' % (angle / pi * 180.) height = self.get_full_text_extent(text)[1] self.contents.write('%3.3f %3.3f moveto\n' % (x,y)) 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('\n' % locals()) #self.contents.write('\n') #self._emit('text', contents=text, rotate=angle, kw={'font-family':repr(self.font.fontName), # 'font-size': '"'+ str(self.font_size) + '"'}) 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_fill_points(self, points, mode): 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 second_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') def device_stroke_points(self, points, mode): # handled by device_fill_points pass def device_set_clipping_path(self, x, y, width, height): self.contents.write('%3.3f %3.3f %3.3f %3.3f rectclip\n' % (x,y,width*2.,height*2.)) def device_destroy_clipping_path(self): self.contents.write('initclip\n') # 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 if __name__ == "__main__": if len(sys.argv) == 1: print "Usage: %s output_file (where output_file ends in .html or .svg" % sys.argv[0] raise SystemExit enthought-chaco2-4.1.0.orig/kiva/image.py0000644000175000017500000000320011674463636017266 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.1.0.orig/kiva/arc_conversion.py0000644000175000017500000000423211674463636021224 0ustar varunvarunfrom numpy import sqrt, dot, sin, dot, 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.1.0.orig/kiva/pdf.py0000644000175000017500000006371211674463636016773 0ustar varunvarun#------------------------------------------------------------------------------ # Copyright (c) 2005-2011, 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. """ # 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 import basecore2d import constants from constants import FILL, STROKE, EOF_FILL import 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(basecore2d.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 copy.copy(self.gc._currentMatrix) #---------------------------------------------------------------- # 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 basecore2d.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. """ #self.gc.save() 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) # msg = "clear_clip_path not implemented yet on PDF" # raise NotImplementedError, msg #---------------------------------------------------------------- # 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): """ """ raise NotImplementedError( "set_fill_color_space not implemented on PDF yet.") def set_stroke_color_space(self): """ """ raise NotImplementedError( "set_stroke_color_space not implemented on PDF yet.") def set_rendering_intent(self): """ """ raise NotImplementedError( "set_rendering_intent not implemented on PDF yet.") #---------------------------------------------------------------- # 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) #def set_gray_fill_color(self): # """ # """ # pass #def set_gray_stroke_color(self): # """ # """ # pass #def set_rgb_fill_color(self): # """ # """ # pass #def set_rgb_stroke_color(self): # """ # """ # pass #def cmyk_fill_color(self): # """ # """ # pass #def cmyk_stroke_color(self): # """ # """ # pass #---------------------------------------------------------------- # 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 == 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 PDF documents #---------------------------------------------------------------- #def draw_pdf_document(self): # """ # """ # pass #---------------------------------------------------------------- # 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 set_font_size(self,size): """ """ font = self.gc._fontname self.gc.setFont(font,size) def set_character_spacing(self): """ """ pass 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) #print "set text matrix", a,b,c,d,tx,ty self.gc._textMatrix=(a, b, c, d, tx, ty) #self.gc.CGContextGetTextMatrix(ttm) def get_text_matrix(self): """ temporarily not implemented. can perhaps get the _textmatrix object off of the canvas if we need to. """ a, b, c, d, tx, ty = self.gc._textMatrix #print "get text matrix", a,b,c,d,tx,ty return affine.affine_from_values(a, b, c, d, tx, ty) #self.gc.CGContextGetTextMatrix(self.gc) 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 #this call does not seem to work. returns zero #ascent=(reportlab.pdfbase.pdfmetrics.getFont(fontname).face.ascent) #this call does not seem to work. returns -1 #descent=(reportlab.pdfbase.pdfmetrics.getFont(fontname).face.descent) 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 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): """ """ raise NotImplementedError( "fill_rects not implemented on PDF yet.") def clear_rect(self,rect): """ """ raise NotImplementedError( "clear_rect not implemented on PDF yet.") 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.1.0.orig/kiva/svg.py0000644000175000017500000002714611674463636017022 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 import cStringIO from numpy import arange, ravel, pi # Local, relative Kiva imports import affine import basecore2d import constants from constants import FILL, FILL_STROKE, EOF_FILL_STROKE, EOF_FILL, STROKE def _strpoints(points): c = cStringIO.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'} # 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 = cStringIO.StringIO() self._clipmap = {} self.clip_id = None def render(self, format): assert format == 'svg' height, width = self.size contents = self.contents.getvalue().replace("\n' % locals()) self.contents.write('\n') self._emit('text', contents=text, transform='"rotate('+angle+')"', kw={'font-family':repr(self.font.fontName), 'font-size': '"'+ str(self.font_size) + '"'}) self.contents.write('\n') self.contents.write('\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_fill_points(self, points, mode): points = self._fixpoints(points) if mode in (FILL, FILL_STROKE, EOF_FILL_STROKE): fill = self._color(self.state.fill_color) else: fill = 'none' if mode in (STROKE, FILL_STROKE, EOF_FILL_STROKE): stroke = self._color(self.state.line_color) else: stroke = 'none' if mode in (EOF_FILL_STROKE, EOF_FILL): rule = 'evenodd' else: rule = 'nonzero' linecap = line_cap_map[self.state.line_cap] linejoin = line_join_map[self.state.line_join] dasharray = self._dasharray() width = '%3.3f' % self.state.line_width if self.clip_id: clip = '"url(#' + self.clip_id +')"' else: clip = None if mode == STROKE: opacity = '%1.3f' % self.state.line_color[-1] self._emit('polyline', points='"'+_strpoints(points)+'"', kw=default_filter({'clip-path': (clip, None)}), style=_mkstyle(default_filter({'opacity': (opacity, "1.000"), 'stroke': stroke, 'fill': 'none', 'stroke-width': (width, "1.000"), 'stroke-linejoin': (linejoin, 'miter'), 'stroke-linecap': (linecap, 'butt'), 'stroke-dasharray': (dasharray, 'none')}))) else: opacity = '%1.3f' % self.state.fill_color[-1] self._emit('polygon', points='"'+_strpoints(points)+'"', kw=default_filter({'clip-path': (clip, None)}), style=_mkstyle(default_filter({'opacity': (opacity, "1.000"), 'stroke-width': (width, "1.000"), 'fill': fill, 'fill-rule': rule, 'stroke': stroke, 'stroke-linejoin': (linejoin, 'miter'), 'stroke-linecap': (linecap, 'butt'), 'stroke-dasharray': (dasharray, 'none')}))) def device_stroke_points(self, points, mode): # handled by device_fill_points pass def _build(self, elname, **kw): x = '<' + elname + ' ' for k,v in kw.items(): if type(v) == type(0.0): v = '"%3.3f"' % v elif type(v) == type(0): v = '"%d"' % v else: v = '"%s"' % str(v) x += k + '=' + v + ' ' x += '/>\n' return x def device_set_clipping_path(self, x, y, width, height): ##x,y,width,height = map(lambda x: '"' + str(x) + '"', [x,y,width,height]) ##self._emit('rect', x=x, y=y, width=width, height=height, ## style=_mkstyle({'stroke-width': 5, ## 'fill':'none', ## 'stroke': 'green'})) ## ##return global _clip_counter self.clip_id = 'clip_%d' % _clip_counter _clip_counter += 1 x,y = self._fixpoints([[x,y]])[0] rect = self._build('rect', x=x, y=y, width=width, height=height) self._emit('clipPath', contents=rect, id='"'+self.clip_id + '"') def device_destroy_clipping_path(self): self.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('>\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 if __name__ == "__main__": if len(sys.argv) == 1: print "Usage: %s output_file (where output_file ends in .html or .svg" % sys.argv[0] raise SystemExit enthought-chaco2-4.1.0.orig/kiva/setup.py0000644000175000017500000000262311674463636017354 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.1.0.orig/kiva/qpainter.py0000644000175000017500000007116411674463636020045 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. """ # These are the symbols that a backend has to define. __all__ = ["CompiledPath", "Font", "font_metrics_provider", "GraphicsContext"] 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 arc_conversion import arc_to_tangent_points from fonttools import Font import constants 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.gc.device(), QtGui.QPixmap)): # An offscreen Qt kiva context pixmap = img.gc.device() width, height = pixmap.width(), pixmap.height() else: warnings.warn("Cannot render image of type '%r' into Qt4 context." % \ type(img)) 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.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() def font_metrics_provider(): """ Creates an object to be used for querying font metrics. """ return GraphicsContext((1,1)) enthought-chaco2-4.1.0.orig/kiva/_fontdata.py0000644000175000017500000016626311674463635020165 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.1.0.orig/kiva/quartz/0000755000175000017500000000000011674463636017165 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/quartz/__init__.py0000644000175000017500000000042211674463636021274 0ustar varunvarun# :Author: Robert Kern # :Copyright: 2004, Enthought, Inc. # :License: BSD Style from macport import get_macport as _get_macport def get_macport(dc): """ Returns the m_macPort of a wxDC (or child class) instance. """ return _get_macport(str(dc.this)) enthought-chaco2-4.1.0.orig/kiva/quartz/c_numpy.pxd0000644000175000017500000000702111674463636021354 0ustar varunvarun# :Author: Travis Oliphant cdef extern from "numpy/arrayobject.h": cdef enum NPY_TYPES: NPY_BOOL NPY_BYTE NPY_UBYTE NPY_SHORT NPY_USHORT NPY_INT NPY_UINT NPY_LONG NPY_ULONG NPY_LONGLONG NPY_ULONGLONG NPY_FLOAT NPY_DOUBLE NPY_LONGDOUBLE NPY_CFLOAT NPY_CDOUBLE NPY_CLONGDOUBLE NPY_OBJECT NPY_STRING NPY_UNICODE NPY_VOID NPY_NTYPES NPY_NOTYPE cdef enum requirements: NPY_CONTIGUOUS NPY_FORTRAN NPY_OWNDATA NPY_FORCECAST NPY_ENSURECOPY NPY_ENSUREARRAY NPY_ELEMENTSTRIDES NPY_ALIGNED NPY_NOTSWAPPED NPY_WRITEABLE NPY_UPDATEIFCOPY NPY_ARR_HAS_DESCR NPY_BEHAVED NPY_BEHAVED_NS NPY_CARRAY NPY_CARRAY_RO NPY_FARRAY NPY_FARRAY_RO NPY_DEFAULT NPY_IN_ARRAY NPY_OUT_ARRAY NPY_INOUT_ARRAY NPY_IN_FARRAY NPY_OUT_FARRAY NPY_INOUT_FARRAY NPY_UPDATE_ALL cdef enum defines: # Note: as of Pyrex 0.9.5, enums are type-checked more strictly, so this # can't be used as an integer. NPY_MAXDIMS ctypedef struct npy_cdouble: double real double imag ctypedef struct npy_cfloat: double real double imag ctypedef int npy_intp ctypedef extern class numpy.dtype [object PyArray_Descr]: cdef int type_num, elsize, alignment cdef char type, kind, byteorder, hasobject cdef object fields, typeobj ctypedef extern class numpy.ndarray [object PyArrayObject]: cdef char *data cdef int nd cdef npy_intp *dimensions cdef npy_intp *strides cdef object base cdef dtype descr cdef int flags ctypedef extern class numpy.flatiter [object PyArrayIterObject]: cdef int nd_m1 cdef npy_intp index, size cdef ndarray ao cdef char *dataptr ctypedef extern class numpy.broadcast [object PyArrayMultiIterObject]: cdef int numiter cdef npy_intp size, index cdef int nd # These next two should be arrays of [NPY_MAXITER], but that is # difficult to cleanly specify in Pyrex. Fortunately, it doesn't matter. cdef npy_intp *dimensions cdef void **iters object PyArray_ZEROS(int ndims, npy_intp* dims, NPY_TYPES type_num, int fortran) object PyArray_EMPTY(int ndims, npy_intp* dims, NPY_TYPES type_num, int fortran) dtype PyArray_DescrFromTypeNum(NPY_TYPES type_num) object PyArray_SimpleNew(int ndims, npy_intp* dims, NPY_TYPES type_num) int PyArray_Check(object obj) object PyArray_ContiguousFromAny(object obj, NPY_TYPES type, int mindim, int maxdim) npy_intp PyArray_SIZE(ndarray arr) npy_intp PyArray_NBYTES(ndarray arr) void *PyArray_DATA(ndarray arr) object PyArray_FromAny(object obj, dtype newtype, int mindim, int maxdim, int requirements, object context) object PyArray_FROMANY(object obj, NPY_TYPES type_num, int min, int max, int requirements) object PyArray_NewFromDescr(object subtype, dtype newtype, int nd, npy_intp* dims, npy_intp* strides, void* data, int flags, object parent) void* PyArray_GETPTR2(object obj, int i, int j) void PyArray_ITER_NEXT(flatiter it) void import_array() enthought-chaco2-4.1.0.orig/kiva/quartz/ATS.pxi0000644000175000017500000002755211674463636020351 0ustar varunvarun# :Author: Robert Kern # :Copyright: 2004, Enthought, Inc. # :License: BSD Style cdef extern from "ATSFont.h": ctypedef struct Float32Point: float x float y ctypedef unsigned long UInt32 ctypedef short SInt16 ctypedef UInt32 FMGeneration ctypedef SInt16 FMFontFamily ctypedef SInt16 FMFontStyle ctypedef SInt16 FMFontSize ctypedef UInt32 FMFont ctypedef struct FMFontFamilyInstance: FMFontFamily fontFamily FMFontStyle fontStyle ctypedef struct FMFontFamilyIterator: UInt32 reserved[16] ctypedef struct FMFontIterator: UInt32 reserved[16] ctypedef struct FMFontFamilyInstanceIterator: UInt32 reserved[16] cdef enum: kInvalidGeneration = 0 kInvalidFontFamily = -1 kInvalidFont = 0 cdef enum: kFMCurrentFilterFormat = 0 ctypedef UInt32 FMFilterSelector cdef enum: kFMFontTechnologyFilterSelector = 1 kFMFontContainerFilterSelector = 2 kFMGenerationFilterSelector = 3 kFMFontFamilyCallbackFilterSelector = 4 kFMFontCallbackFilterSelector = 5 kFMFontDirectoryFilterSelector = 6 #kFMTrueTypeFontTechnology = 'true' #kFMPostScriptFontTechnology = 'typ1' #struct FMFontDirectoryFilter: # SInt16 fontFolderDomain # UInt32 reserved[2] # #typedef struct FMFontDirectoryFilter FMFontDirectoryFilter #struct FMFilter: # UInt32 format # FMFilterSelector selector # union: # FourCharCode fontTechnologyFilter # FSSpec fontContainerFilter # FMGeneration generationFilter # FMFontFamilyCallbackFilterUPP fontFamilyCallbackFilter # FMFontCallbackFilterUPP fontCallbackFilter # FMFontDirectoryFilter fontDirectoryFilter # } filter # #typedef struct FMFilter FMFilter # ctypedef float Float32 ctypedef unsigned long OptionBits ctypedef unsigned short UInt16 ctypedef OptionBits ATSOptionFlags ctypedef UInt32 ATSGeneration ctypedef UInt32 ATSFontContainerRef ctypedef UInt32 ATSFontFamilyRef ctypedef UInt32 ATSFontRef ctypedef UInt16 ATSGlyphRef ctypedef Float32 ATSFontSize cdef enum: kATSGenerationUnspecified = 0 kATSFontContainerRefUnspecified = 0 kATSFontFamilyRefUnspecified = 0 kATSFontRefUnspecified = 0 ctypedef struct ATSFontMetrics: UInt32 version Float32 ascent Float32 descent Float32 leading Float32 avgAdvanceWidth Float32 maxAdvanceWidth Float32 minLeftSideBearing Float32 minRightSideBearing Float32 stemWidth Float32 stemHeight Float32 capHeight Float32 xHeight Float32 italicAngle Float32 underlinePosition Float32 underlineThickness cdef enum: kATSItalicQDSkew = 16384 # (1 << 16) / 4 kATSBoldQDStretch = 98304 # (1 << 16) * 3 / 2 kATSRadiansFactor = 1144 ctypedef UInt16 ATSCurveType cdef enum: kATSCubicCurveType = 0x0001 kATSQuadCurveType = 0x0002 kATSOtherCurveType = 0x0003 cdef enum: kATSDeletedGlyphcode = 0xFFFF ctypedef struct ATSUCurvePath: UInt32 vectors UInt32 controlBits[1] Float32Point vector[1] ctypedef struct ATSUCurvePaths: UInt32 contours ATSUCurvePath contour[1] ctypedef struct ATSGlyphIdealMetrics: Float32Point advance Float32Point sideBearing Float32Point otherSideBearing ctypedef struct ATSGlyphScreenMetrics: Float32Point deviceAdvance Float32Point topLeft UInt32 height UInt32 width Float32Point sideBearing Float32Point otherSideBearing ctypedef ATSGlyphRef GlyphID cdef enum: kATSOptionFlagsDefault = 0 kATSOptionFlagsComposeFontPostScriptName = 1 << 0 kATSOptionFlagsUseDataForkAsResourceFork = 1 << 8 kATSOptionFlagsUseResourceFork = 2 << 8 kATSOptionFlagsUseDataFork = 3 << 8 cdef enum: kATSIterationCompleted = -980 kATSInvalidFontFamilyAccess = -981 kATSInvalidFontAccess = -982 kATSIterationScopeModified = -983 kATSInvalidFontTableAccess = -984 kATSInvalidFontContainerAccess = -985 kATSInvalidGlyphAccess = -986 ctypedef long ATSFontContext cdef enum: kATSFontContextUnspecified = 0 kATSFontContextGlobal = 1 kATSFontContextLocal = 2 cdef enum: kATSOptionFlagsProcessSubdirectories = 0x00000001 << 6 kATSOptionFlagsDoNotNotify = 0x00000001 << 7 cdef enum: kATSOptionFlagsIterateByPrecedenceMask = 0x00000001 << 5 kATSOptionFlagsIterationScopeMask = 0x00000007 << 12 kATSOptionFlagsDefaultScope = 0x00000000 << 12 kATSOptionFlagsUnRestrictedScope = 0x00000001 << 12 kATSOptionFlagsRestrictedScope = 0x00000002 << 12 ctypedef long ATSFontFormat cdef enum: kATSFontFormatUnspecified = 0 ctypedef OSStatus (*ATSFontFamilyApplierFunction)(ATSFontFamilyRef iFamily, void *iRefCon) ctypedef OSStatus (*ATSFontApplierFunction)(ATSFontRef iFont, void *iRefCon) ctypedef void* ATSFontFamilyIterator ctypedef void* ATSFontIterator cdef enum: kATSFontFilterCurrentVersion = 0 ctypedef enum ATSFontFilterSelector: kATSFontFilterSelectorUnspecified = 0 kATSFontFilterSelectorGeneration = 3 kATSFontFilterSelectorFontFamily = 7 kATSFontFilterSelectorFontFamilyApplierFunction = 8 kATSFontFilterSelectorFontApplierFunction = 9 ctypedef union font_filter: ATSGeneration generationFilter ATSFontFamilyRef fontFamilyFilter ATSFontFamilyApplierFunction fontFamilyApplierFunctionFilter ATSFontApplierFunction fontApplierFunctionFilter ctypedef struct ATSFontFilter: UInt32 version ATSFontFilterSelector filterSelector font_filter filter ctypedef void* ATSFontNotificationRef ctypedef void* ATSFontNotificationInfoRef ctypedef enum ATSFontNotifyOption: kATSFontNotifyOptionDefault = 0 kATSFontNotifyOptionReceiveWhileSuspended = 1 << 0 ctypedef enum ATSFontNotifyAction: kATSFontNotifyActionFontsChanged = 1 kATSFontNotifyActionDirectoriesChanged = 2 ATSGeneration ATSGetGeneration() OSStatus ATSFontFamilyApplyFunction(ATSFontFamilyApplierFunction iFunction, void* iRefCon) OSStatus ATSFontFamilyIteratorCreate( ATSFontContext iContext, ATSFontFilter * iFilter, void * iRefCon, ATSOptionFlags iOptions, ATSFontFamilyIterator * ioIterator) OSStatus ATSFontFamilyIteratorRelease(ATSFontFamilyIterator * ioIterator) OSStatus ATSFontFamilyIteratorReset( ATSFontContext iContext, ATSFontFilter * iFilter, void * iRefCon, ATSOptionFlags iOptions, ATSFontFamilyIterator * ioIterator) OSStatus ATSFontFamilyIteratorNext( ATSFontFamilyIterator iIterator, ATSFontFamilyRef * oFamily) ATSFontFamilyRef ATSFontFamilyFindFromName( CFStringRef iName, ATSOptionFlags iOptions) ATSGeneration ATSFontFamilyGetGeneration(ATSFontFamilyRef iFamily) OSStatus ATSFontFamilyGetName( ATSFontFamilyRef iFamily, ATSOptionFlags iOptions, CFStringRef * oName) ctypedef UInt32 TextEncoding TextEncoding ATSFontFamilyGetEncoding(ATSFontFamilyRef iFamily) OSStatus ATSFontApplyFunction(ATSFontApplierFunction iFunction, void* iRefCon) OSStatus ATSFontIteratorCreate( ATSFontContext iContext, ATSFontFilter * iFilter, void * iRefCon, ATSOptionFlags iOptions, ATSFontIterator * ioIterator) OSStatus ATSFontIteratorRelease(ATSFontIterator * ioIterator) OSStatus ATSFontIteratorReset( ATSFontContext iContext, ATSFontFilter * iFilter, void * iRefCon, ATSOptionFlags iOptions, ATSFontIterator * ioIterator) OSStatus ATSFontIteratorNext( ATSFontIterator iIterator, ATSFontRef * oFont) ATSFontRef ATSFontFindFromName( CFStringRef iName, ATSOptionFlags iOptions) ATSFontRef ATSFontFindFromPostScriptName( CFStringRef iName, ATSOptionFlags iOptions) # OSStatus ATSFontFindFromContainer( # ATSFontContainerRef iContainer, # ATSOptionFlags iOptions, # ItemCount iCount, # ATSFontRef ioArray[], # ItemCount * oCount) # ATSGeneration ATSFontGetGeneration(ATSFontRef iFont) OSStatus ATSFontGetName( ATSFontRef iFont, ATSOptionFlags iOptions, CFStringRef * oName) OSStatus ATSFontGetPostScriptName( ATSFontRef iFont, ATSOptionFlags iOptions, CFStringRef * oName) # OSStatus ATSFontGetTableDirectory( # ATSFontRef iFont, # ByteCount iBufferSize, # void * ioBuffer, # ByteCount * oSize) # ctypedef char[4] FourCharCode # OSStatus ATSFontGetTable( # ATSFontRef iFont, # FourCharCode iTag, # ByteOffset iOffset, # ByteCount iBufferSize, # void * ioBuffer, # ByteCount * oSize) OSStatus ATSFontGetHorizontalMetrics( ATSFontRef iFont, ATSOptionFlags iOptions, ATSFontMetrics * oMetrics) OSStatus ATSFontGetVerticalMetrics( ATSFontRef iFont, ATSOptionFlags iOptions, ATSFontMetrics * oMetrics) ctypedef char ConstStr255Param[256] ATSFontFamilyRef ATSFontFamilyFindFromQuickDrawName(ConstStr255Param iName) ctypedef char Str255[256] OSStatus ATSFontFamilyGetQuickDrawName( ATSFontFamilyRef iFamily, Str255 oName) # OSStatus ATSFontGetFileSpecification( # ATSFontRef iFont, # FSSpec * oFile) # OSStatus ATSFontGetFontFamilyResource( # ATSFontRef iFont, # ByteCount iBufferSize, # void * ioBuffer, # ByteCount * oSize) # #ctypedef struct ATSFontQuerySourceContext: # UInt32 version # void * refCon # CFAllocatorRetainCallBack retain # CFAllocatorReleaseCallBack release # #ctypedef enum ATSFontQueryMessageID: # kATSQueryActivateFontMessage = 'atsa' cdef extern from "Fonts.h": OSStatus FMGetFontFamilyInstanceFromFont(FMFont iFont, FMFontFamily* oFontFamily, FMFontStyle* oStyle) ATSFontRef FMGetATSFontRefFromFont(FMFont iFont) FMFont FMGetFontFromATSFontRef(ATSFontRef iFont) cdef enum: normal = 0 bold = 1 italic = 2 underline = 4 outline = 8 shadow = 0x10 condense = 0x20 extend = 0x40 enthought-chaco2-4.1.0.orig/kiva/quartz/macport28.cpp0000644000175000017500000000466111674463636021517 0ustar varunvarun/* * macport.cpp * * Python extension to grab m_macPort out of a wxDC. * * This module itself doesn't really use any features of C++, but it links * against wx.h (which is definitely C++). */ #include "wx/wx.h" #include "Python.h" extern "C" { void initmacport(void); } /* This converts a string of hex digits into an unsigned long. It reads This code is a modified version of SWIG_UnpackData from weave/swigptr2.py, and which I believe originated from the SWIG sources. */ unsigned long hexstr_to_long(const char *c, char bytesize = 4) { unsigned long retval = 0; unsigned char *u = reinterpret_cast(&retval); const unsigned char *eu = u + bytesize; for (; u != eu; ++u) { register int d = *(c++); register unsigned char uu = 0; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); else return 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); else return 0; *u = uu; } return retval; } PyObject* get_macport(PyObject *self, PyObject *args) { const char err_string[] = "get_macport() requires a SWIG 'this' string."; // the string representing the address embedded in the SWIG this ptr char *dc_addr_str = NULL; int length = 0; int err = 0; wxDC *p_dc = NULL; wxGraphicsContext *p_gc = NULL; err = PyArg_ParseTuple(args, "s#", &dc_addr_str, &length); if (err != 1) { PyErr_SetString(PyExc_ValueError, err_string); return NULL; } else if (length < 10) { PyErr_SetString(PyExc_ValueError, err_string); return NULL; } else { p_dc = reinterpret_cast(hexstr_to_long(dc_addr_str+1, 4)); p_gc = reinterpret_cast(p_dc->GetGraphicsContext()); unsigned long tmp = reinterpret_cast(p_gc->GetNativeContext()); return Py_BuildValue("k", tmp); } } static PyMethodDef macport_methods[] = { {"get_macport", get_macport, METH_VARARGS, "get_macport(dc.this) -> Returns the pointer (as an unsigned long) of the CGContextRef of a wxDC.this SWIG pointer"}, {NULL, NULL} }; void initmacport(void) { Py_InitModule("macport", macport_methods); } enthought-chaco2-4.1.0.orig/kiva/quartz/Python.pxi0000644000175000017500000000276211674463636021177 0ustar varunvarun# :Author: Robert Kern # :Copyright: 2004, Enthought, Inc. # :License: BSD Style ctypedef void (*cobject_destr)(void *) cdef extern from "Python.h": ctypedef int size_t ctypedef int Py_ssize_t char* PyString_AsString(object string) object PyString_FromString(char* c_string) object PyString_FromStringAndSize(char* v, Py_ssize_t len) int PyString_AsStringAndSize(object obj, char **buffer, Py_ssize_t *length) int PyObject_AsCharBuffer(object obj, char **buffer, Py_ssize_t *buffer_len) int PyObject_AsReadBuffer(object obj, void **buffer, Py_ssize_t *buffer_len) int PyObject_CheckReadBuffer(object o) int PyObject_AsWriteBuffer(object obj, void **buffer, Py_ssize_t *buffer_len) void* PyMem_Malloc(size_t n) void* PyMem_Realloc(void* buf, size_t n) void PyMem_Free(void* buf) void Py_DECREF(object obj) void Py_XDECREF(object obj) void Py_INCREF(object obj) void Py_XINCREF(object obj) int PyUnicode_Check(ob) int PyString_Check(ob) ctypedef int Py_UNICODE Py_UNICODE *PyUnicode_AS_UNICODE(ob) int PyUnicode_GET_SIZE(ob) char *PyString_AS_STRING(ob) object PyCObject_FromVoidPtr(void* cobj, cobject_destr destr) void* PyCObject_AsVoidPtr(object self) cdef extern from "string.h": void *memcpy(void *s1, void *s2, int n) cdef extern from "math.h": double fabs(double x) cdef extern from "stdlib.h": void free(void *ptr) void *malloc(size_t size) void *realloc(void *ptr, size_t size) enthought-chaco2-4.1.0.orig/kiva/quartz/macport26.cpp0000644000175000017500000000443011674463636021507 0ustar varunvarun/* * macport.cpp * * Python extension to grab m_macPort out of a wxDC. * * This module itself doesn't really use any features of C++, but it links * against wx.h (which is definitely C++). */ #include "wx/wx.h" #include "Python.h" extern "C" { void initmacport(void); } /* This converts a string of hex digits into an unsigned long. It reads This code is a modified version of SWIG_UnpackData from weave/swigptr2.py, and which I believe originated from the SWIG sources. */ unsigned long hexstr_to_long(const char *c, char bytesize = 4) { unsigned long retval = 0; unsigned char *u = reinterpret_cast(&retval); const unsigned char *eu = u + bytesize; for (; u != eu; ++u) { register int d = *(c++); register unsigned char uu = 0; if ((d >= '0') && (d <= '9')) uu = ((d - '0') << 4); else if ((d >= 'a') && (d <= 'f')) uu = ((d - ('a'-10)) << 4); else return 0; d = *(c++); if ((d >= '0') && (d <= '9')) uu |= (d - '0'); else if ((d >= 'a') && (d <= 'f')) uu |= (d - ('a'-10)); else return 0; *u = uu; } return retval; } PyObject* get_macport(PyObject *self, PyObject *args) { const char err_string[] = "get_macport() requires a SWIG 'this' string."; // the string representing the address embedded in the SWIG this ptr char *dc_addr_str = NULL; int length = 0; int err = 0; wxDC *p_dc = NULL; err = PyArg_ParseTuple(args, "s#", &dc_addr_str, &length); if (err != 1) { PyErr_SetString(PyExc_ValueError, err_string); return NULL; } else if (length < 10) { PyErr_SetString(PyExc_ValueError, err_string); return NULL; } else { p_dc = reinterpret_cast(hexstr_to_long(dc_addr_str+1, 4)); unsigned long tmp = reinterpret_cast(p_dc->m_macPort); return Py_BuildValue("k", tmp); } } static PyMethodDef macport_methods[] = { {"get_macport", get_macport, METH_VARARGS, "get_macport(dc.this) -> Returns the mac port of a wxDC.this SWIG pointer"}, {NULL, NULL} }; void initmacport(void) { Py_InitModule("macport", macport_methods); } enthought-chaco2-4.1.0.orig/kiva/quartz/ATSUI.pxi0000644000175000017500000003452011674463636020600 0ustar varunvarun# :Author: Robert Kern # :Copyright: 2006, Enthought, Inc. # :License: BSD Style cdef extern from "ATSUnicode.h": #### Types ################################################################# ctypedef unsigned int ATSUFontID ctypedef void* ATSUTextLayout ctypedef void* ATSUStyle ctypedef void* ATSUFontFallbacks ctypedef int Fixed Fixed FloatToFixed(float x) float FixedToFloat(Fixed x) ctypedef unsigned short ATSUFontFeatureType ctypedef unsigned short ATSUFontFeatureSelector ctypedef int ATSUAttributeTag ctypedef enum: kATSULineWidthTag kATSULineRotationTag kATSULineDirectionTag kATSULineJustificationFactorTag kATSULineFlushFactorTag kATSULineBaselineValuesTag kATSULineLayoutOptionsTag kATSULineAscentTag kATSULineDescentTag kATSULineLangRegionTag kATSULineTextLocatorTag kATSULineTruncationTag kATSULineFontFallbacksTag kATSULineDecimalTabCharacterTag kATSULayoutOperationOverrideTag kATSULineHighlightCGColorTag kATSUMaxLineTag kATSULineLanguageTag kATSUCGContextTag kATSUQDBoldfaceTag kATSUQDItalicTag kATSUQDUnderlineTag kATSUQDCondensedTag kATSUQDExtendedTag kATSUFontTag kATSUSizeTag kATSUColorTag kATSULangRegionTag kATSUVerticalCharacterTag kATSUImposeWidthTag kATSUBeforeWithStreamShiftTag kATSUAfterWithStreamShiftTag kATSUCrossStreamShiftTag kATSUTrackingTag kATSUHangingInhibitFactorTag kATSUKerningInhibitFactorTag kATSUDecompositionFactorTag kATSUBaselineClassTag kATSUPriorityJustOverrideTag kATSUNoLigatureSplitTag kATSUNoCaretAngleTag kATSUSuppressCrossKerningTag kATSUNoOpticalAlignmentTag kATSUForceHangingTag kATSUNoSpecialJustificationTag kATSUStyleTextLocatorTag kATSUStyleRenderingOptionsTag kATSUAscentTag kATSUDescentTag kATSULeadingTag kATSUGlyphSelectorTag kATSURGBAlphaColorTag kATSUStyleUnderlineCountOptionTag kATSUStyleUnderlineColorOptionTag kATSUStyleStrikeThroughTag kATSUStyleStrikeThroughCountOptionTag kATSUStyleStrikeThroughColorOptionTag kATSUStyleDropShadowTag kATSUStyleDropShadowBlurOptionTag kATSUStyleDropShadowOffsetOptionTag kATSUStyleDropShadowColorOptionTag kATSUMaxStyleTag kATSULanguageTag kATSUMaxATSUITagValue ctypedef enum: kFontCopyrightName kFontFamilyName kFontStyleName kFontUniqueName kFontFullName kFontVersionName kFontPostscriptName kFontTrademarkName kFontManufacturerName kFontDesignerName kFontDescriptionName kFontVendorURLName kFontDesignerURLName kFontLicenseDescriptionName kFontLicenseInfoURLName kFontLastReservedName ctypedef enum: kFontNoPlatformCode kFontNoScriptCode kFontNoLanguageCode ctypedef void* ATSUAttributeValuePtr ctypedef void* ConstATSUAttributeValuePtr ctypedef struct ATSURGBAlphaColor: float red float green float blue float alpha #ctypedef int OSStatus ctypedef enum: kATSULeftToRightBaseDirection = 0 kATSURightToLeftBaseDirection = 1 ctypedef enum: kATSUStartAlignment = 0x00000000 kATSUEndAlignment = 0x40000000 kATSUCenterAlignment = 0x20000000 kATSUNoJustification = 0x00000000 kATSUFullJustification = 0x40000000 ctypedef enum: kATSUInvalidFontID = 0 ctypedef enum: kATSUUseLineControlWidth = 0x7FFFFFFF ctypedef enum: kATSUNoSelector = 0x0000FFFF ctypedef enum: kATSUFromTextBeginning #= (unsigned long)0xFFFFFFFF kATSUToTextEnd #= (unsigned long)0xFFFFFFFF kATSUFromPreviousLayout #= (unsigned long)0xFFFFFFFE kATSUFromFollowingLayout #= (unsigned long)0xFFFFFFFD ctypedef unsigned short ATSUFontFallbackMethod ctypedef enum: kATSUDefaultFontFallbacks kATSULastResortOnlyFallback kATSUSequentialFallbacksPreferred kATSUSequentialFallbacksExclusive ctypedef unsigned int ByteCount ctypedef unsigned int ItemCount ctypedef unsigned int* ConstUniCharArrayPtr ctypedef unsigned int UniCharArrayOffset ctypedef unsigned int UniCharCount #ctypedef int Boolean ctypedef void* Ptr #ctypedef unsigned int UInt32 #ctypedef unsigned short UInt16 ctypedef UInt32 FontNameCode ctypedef UInt32 FontPlatformCode ctypedef UInt32 FontScriptCode ctypedef UInt32 FontLanguageCode # ctypedef struct QDRect "Rect": # short top # short left # short bottom # short right ctypedef struct FixedPoint: Fixed x Fixed y ctypedef struct FixedRect: Fixed left Fixed top Fixed right Fixed bottom ctypedef struct ATSTrapezoid: FixedPoint upperLeft FixedPoint upperRight FixedPoint lowerRight FixedPoint lowerLeft ctypedef unsigned long FourCharCode ctypedef FourCharCode ATSUFontVariationAxis ctypedef Fixed ATSUFontVariationValue ctypedef Fixed ATSUTextMeasurement #### Objects ############################################################### OSStatus ATSUCreateStyle(ATSUStyle * oStyle) OSStatus ATSUCreateAndCopyStyle(ATSUStyle iStyle, ATSUStyle* oStyle) OSStatus ATSUDisposeStyle(ATSUStyle iStyle) OSStatus ATSUSetStyleRefCon(ATSUStyle iStyle, unsigned int iRefCon) OSStatus ATSUGetStyleRefCon(ATSUStyle iStyle, unsigned int* oRefCon) OSStatus ATSUClearStyle(ATSUStyle iStyle) OSStatus ATSUSetAttributes( ATSUStyle iStyle, unsigned int iAttributeCount, ATSUAttributeTag * iTag, ByteCount * iValueSize, ATSUAttributeValuePtr * iValue) OSStatus ATSUGetAttribute( ATSUStyle iStyle, ATSUAttributeTag iTag, ByteCount iExpectedValueSize, ATSUAttributeValuePtr oValue, ByteCount * oActualValueSize) OSStatus ATSUCreateTextLayout(ATSUTextLayout * oTextLayout) OSStatus ATSUCreateAndCopyTextLayout( ATSUTextLayout iTextLayout, ATSUTextLayout * oTextLayout) OSStatus ATSUGetLineControl( ATSUTextLayout iTextLayout, UniCharArrayOffset iLineStart, ATSUAttributeTag iTag, ByteCount iExpectedValueSize, ATSUAttributeValuePtr oValue, ByteCount * oActualValueSize) OSStatus ATSUCreateTextLayoutWithTextPtr( ConstUniCharArrayPtr iText, UniCharArrayOffset iTextOffset, UniCharCount iTextLength, UniCharCount iTextTotalLength, ItemCount iNumberOfRuns, UniCharCount * iRunLengths, ATSUStyle * iStyles, ATSUTextLayout * oTextLayout) OSStatus ATSUClearLayoutCache( ATSUTextLayout iTextLayout, UniCharArrayOffset iLineStart) OSStatus ATSUDisposeTextLayout(ATSUTextLayout iTextLayout) OSStatus ATSUSetTextPointerLocation( ATSUTextLayout iTextLayout, ConstUniCharArrayPtr iText, UniCharArrayOffset iTextOffset, UniCharCount iTextLength, UniCharCount iTextTotalLength) OSStatus ATSUGetTextLocation( ATSUTextLayout iTextLayout, void ** oText, int * oTextIsStoredInHandle, UniCharArrayOffset * oOffset, UniCharCount * oTextLength, UniCharCount * oTextTotalLength) OSStatus ATSUSetLayoutControls( ATSUTextLayout iTextLayout, ItemCount iAttributeCount, ATSUAttributeTag * iTag, ByteCount * iValueSize, ATSUAttributeValuePtr * iValue) OSStatus ATSUGetLayoutControl( ATSUTextLayout iTextLayout, ATSUAttributeTag iTag, ByteCount iExpectedValueSize, ATSUAttributeValuePtr oValue, ByteCount * oActualValueSize) OSStatus ATSUClearLayoutControls( ATSUTextLayout iTextLayout, ItemCount iTagCount, ATSUAttributeTag * iTag) OSStatus ATSUSetRunStyle( ATSUTextLayout iTextLayout, ATSUStyle iStyle, UniCharArrayOffset iRunStart, UniCharCount iRunLength) OSStatus ATSUGetRunStyle( ATSUTextLayout iTextLayout, UniCharArrayOffset iOffset, ATSUStyle * oStyle, UniCharArrayOffset * oRunStart, UniCharCount * oRunLength) OSStatus ATSUGetContinuousAttributes( ATSUTextLayout iTextLayout, UniCharArrayOffset iOffset, UniCharCount iLength, ATSUStyle oStyle) OSStatus ATSUCreateFontFallbacks(ATSUFontFallbacks * oFontFallback) OSStatus ATSUDisposeFontFallbacks(ATSUFontFallbacks iFontFallbacks) OSStatus ATSUSetObjFontFallbacks( ATSUFontFallbacks iFontFallbacks, ItemCount iFontFallbacksCount, ATSUFontID * iFonts, ATSUFontFallbackMethod iFontFallbackMethod) OSStatus ATSUGetObjFontFallbacks( ATSUFontFallbacks iFontFallbacks, ItemCount iMaxFontFallbacksCount, ATSUFontID * oFonts, ATSUFontFallbackMethod * oFontFallbackMethod, ItemCount * oActualFallbacksCount) OSStatus ATSUSetTransientFontMatching( ATSUTextLayout iTextLayout, Boolean iTransientFontMatching) #### Fonts ################################################################# OSStatus ATSUFontCount(ItemCount * oFontCount) OSStatus ATSUGetFontIDs( ATSUFontID * oFontIDs, ItemCount iArraySize, ItemCount * oFontCount) OSStatus ATSUCountFontNames( ATSUFontID iFontID, ItemCount * oFontNameCount) OSStatus ATSUGetIndFontName( ATSUFontID iFontID, ItemCount iFontNameIndex, ByteCount iMaximumNameLength, Ptr oName, ByteCount * oActualNameLength, FontNameCode * oFontNameCode, FontPlatformCode * oFontNamePlatform, FontScriptCode * oFontNameScript, FontLanguageCode * oFontNameLanguage) OSStatus ATSUFindFontName( ATSUFontID iFontID, FontNameCode iFontNameCode, FontPlatformCode iFontNamePlatform, FontScriptCode iFontNameScript, FontLanguageCode iFontNameLanguage, ByteCount iMaximumNameLength, Ptr oName, ByteCount * oActualNameLength, ItemCount * oFontNameIndex) OSStatus ATSUFindFontFromName( void * iName, ByteCount iNameLength, FontNameCode iFontNameCode, FontPlatformCode iFontNamePlatform, FontScriptCode iFontNameScript, FontLanguageCode iFontNameLanguage, ATSUFontID * oFontID) OSStatus ATSUCountFontInstances( ATSUFontID iFontID, ItemCount * oInstances) OSStatus ATSUGetFontInstance( ATSUFontID iFontID, ItemCount iFontInstanceIndex, ItemCount iMaximumVariations, ATSUFontVariationAxis * oAxes, ATSUFontVariationValue * oValues, ItemCount * oActualVariationCount) OSStatus ATSUGetFontInstanceNameCode( ATSUFontID iFontID, ItemCount iInstanceIndex, FontNameCode * oNameCode) #### Drawing ############################################################### OSStatus ATSUDrawText( ATSUTextLayout iTextLayout, UniCharArrayOffset iLineOffset, UniCharCount iLineLength, ATSUTextMeasurement iLocationX, ATSUTextMeasurement iLocationY) OSStatus ATSUGetUnjustifiedBounds( ATSUTextLayout iTextLayout, UniCharArrayOffset iLineStart, UniCharCount iLineLength, ATSUTextMeasurement * oTextBefore, ATSUTextMeasurement * oTextAfter, ATSUTextMeasurement * oAscent, ATSUTextMeasurement * oDescent) OSStatus ATSUMeasureTextImage( ATSUTextLayout iTextLayout, UniCharArrayOffset iLineOffset, UniCharCount iLineLength, ATSUTextMeasurement iLocationX, ATSUTextMeasurement iLocationY, QDRect * oTextImageRect) OSStatus ATSUGetGlyphBounds( ATSUTextLayout iTextLayout, ATSUTextMeasurement iTextBasePointX, ATSUTextMeasurement iTextBasePointY, UniCharArrayOffset iBoundsCharStart, UniCharCount iBoundsCharLength, UInt16 iTypeOfBounds, ItemCount iMaxNumberOfBounds, ATSTrapezoid * oGlyphBounds, ItemCount * oActualNumberOfBounds) OSStatus ATSUBatchBreakLines( ATSUTextLayout iTextLayout, UniCharArrayOffset iRangeStart, UniCharCount iRangeLength, ATSUTextMeasurement iLineWidth, ItemCount * oBreakCount) OSStatus ATSUBreakLine( ATSUTextLayout iTextLayout, UniCharArrayOffset iLineStart, ATSUTextMeasurement iLineWidth, Boolean iUseAsSoftLineBreak, UniCharArrayOffset * oLineBreak) OSStatus ATSUSetSoftLineBreak( ATSUTextLayout iTextLayout, UniCharArrayOffset iLineBreak) OSStatus ATSUGetSoftLineBreaks( ATSUTextLayout iTextLayout, UniCharArrayOffset iRangeStart, UniCharCount iRangeLength, ItemCount iMaximumBreaks, UniCharArrayOffset * oBreaks, ItemCount * oBreakCount) OSStatus ATSUClearSoftLineBreaks( ATSUTextLayout iTextLayout, UniCharArrayOffset iRangeStart, UniCharCount iRangeLength) #### EOF ####################################################################### enthought-chaco2-4.1.0.orig/kiva/quartz/CoreGraphics.pxi0000644000175000017500000005343611674463636022273 0ustar varunvarun# :Author: Robert Kern # :Copyright: 2004, Enthought, Inc. # :License: BSD Style cdef extern from "ApplicationServices/ApplicationServices.h": ctypedef void* CGContextRef ctypedef struct CGPoint: float x float y ctypedef struct CGSize: float width float height ctypedef struct CGRect: CGPoint origin CGSize size ctypedef struct CGAffineTransform: float a float b float c float d float tx float ty ctypedef enum CGBlendMode: kCGBlendModeNormal kCGBlendModeMultiply kCGBlendModeScreen kCGBlendModeOverlay kCGBlendModeDarken kCGBlendModeLighten kCGBlendModeColorDodge kCGBlendModeColorBurn kCGBlendModeSoftLight kCGBlendModeHardLight kCGBlendModeDifference kCGBlendModeExclusion kCGBlendModeHue kCGBlendModeSaturation kCGBlendModeColor kCGBlendModeLuminosity ctypedef enum CGLineCap: kCGLineCapButt kCGLineCapRound kCGLineCapSquare ctypedef enum CGLineJoin: kCGLineJoinMiter kCGLineJoinRound kCGLineJoinBevel ctypedef enum CGPathDrawingMode: kCGPathFill kCGPathEOFill kCGPathStroke kCGPathFillStroke kCGPathEOFillStroke ctypedef enum CGRectEdge: CGRectMinXEdge CGRectMinYEdge CGRectMaxXEdge CGRectMaxYEdge # CGContext management CGContextRef CGContextRetain(CGContextRef context) CGContextRef CGPDFContextCreateWithURL(CFURLRef url, CGRect * mediaBox, CFDictionaryRef auxiliaryInfo) void CGContextRelease(CGContextRef context) void CGContextFlush(CGContextRef context) void CGContextSynchronize(CGContextRef context) void CGContextBeginPage(CGContextRef context, CGRect* mediaBox) void CGContextEndPage(CGContextRef context) # User-space transformations void CGContextScaleCTM(CGContextRef context, float sx, float sy) void CGContextTranslateCTM(CGContextRef context, float tx, float ty) void CGContextRotateCTM(CGContextRef context, float angle) void CGContextConcatCTM(CGContextRef context, CGAffineTransform transform) CGAffineTransform CGContextGetCTM(CGContextRef context) # Saving and Restoring the Current Graphics State void CGContextSaveGState(CGContextRef context) void CGContextRestoreGState(CGContextRef context) # Changing the Current Graphics State void CGContextSetFlatness(CGContextRef context, float flatness) void CGContextSetLineCap(CGContextRef context, CGLineCap cap) void CGContextSetLineDash(CGContextRef context, float phase, float lengths[], size_t count) void CGContextSetLineJoin(CGContextRef context, CGLineJoin join) void CGContextSetLineWidth(CGContextRef context, float width) void CGContextSetMiterLimit(CGContextRef context, float limit) void CGContextSetPatternPhase(CGContextRef context, CGSize phase) void CGContextSetShouldAntialias(CGContextRef context, bool shouldAntialias) void CGContextSetShouldSmoothFonts(CGContextRef context, bool shouldSmoothFonts) void CGContextSetAllowsAntialiasing(CGContextRef context, bool allowsAntialiasing) # Constructing Paths void CGContextBeginPath(CGContextRef context) void CGContextMoveToPoint(CGContextRef context, float x, float y) void CGContextAddLineToPoint(CGContextRef context, float x, float y) void CGContextAddLines(CGContextRef context, CGPoint points[], size_t count) void CGContextAddCurveToPoint(CGContextRef context, float cp1x, float cp1y, float cp2x, float cp2y, float x, float y) void CGContextAddQuadCurveToPoint(CGContextRef context, float cpx, float cpy, float x, float y) void CGContextAddRect(CGContextRef context, CGRect rect) void CGContextAddRects(CGContextRef context, CGRect rects[], size_t count) void CGContextAddArc(CGContextRef context, float x, float y, float radius, float startAngle, float endAngle, int clockwise) void CGContextAddArcToPoint(CGContextRef context, float x1, float y1, float x2, float y2, float radius) void CGContextClosePath(CGContextRef context) void CGContextAddEllipseInRect(CGContextRef context, CGRect rect) # Painting Paths void CGContextDrawPath(CGContextRef context, CGPathDrawingMode mode) void CGContextStrokePath(CGContextRef context) void CGContextFillPath(CGContextRef context) void CGContextEOFillPath(CGContextRef context) void CGContextStrokeRect(CGContextRef context, CGRect rect) void CGContextStrokeRectWithWidth(CGContextRef context, CGRect rect, float width) void CGContextFillRect(CGContextRef context, CGRect rect) void CGContextFillRects(CGContextRef context, CGRect rects[], size_t count) void CGContextClearRect(CGContextRef context, CGRect rect) void CGContextReplacePathWithStrokedPath(CGContextRef c) void CGContextFillEllipseInRect(CGContextRef context, CGRect rect) void CGContextStrokeEllipseInRect(CGContextRef context, CGRect rect) void CGContextStrokeLineSegments(CGContextRef c, CGPoint points[], size_t count) # Querying Paths int CGContextIsPathEmpty(CGContextRef context) CGPoint CGContextGetPathCurrentPoint(CGContextRef context) CGRect CGContextGetPathBoundingBox(CGContextRef context) bool CGContextPathContainsPoint(CGContextRef context, CGPoint point, CGPathDrawingMode mode) # Modifying Clipping Paths void CGContextClip(CGContextRef context) void CGContextEOClip(CGContextRef context) void CGContextClipToRect(CGContextRef context, CGRect rect) void CGContextClipToRects(CGContextRef context, CGRect rects[], size_t count) #void CGContextClipToMask(CGContextRef c, CGRect rect, CGImageRef mask) CGRect CGContextGetClipBoundingBox(CGContextRef context) # Color Spaces ctypedef void* CGColorSpaceRef ctypedef enum CGColorRenderingIntent: kCGRenderingIntentDefault kCGRenderingIntentAbsoluteColorimetric kCGRenderingIntentRelativeColorimetric kCGRenderingIntentPerceptual kCGRenderingIntentSaturation ctypedef enum: kCGColorSpaceUserGray kCGColorSpaceUserRGB kCGColorSpaceUserCMYK ctypedef enum FakedEnums: kCGColorSpaceGenericGray kCGColorSpaceGenericRGB kCGColorSpaceGenericCMYK CGColorSpaceRef CGColorSpaceCreateDeviceGray() CGColorSpaceRef CGColorSpaceCreateDeviceRGB() CGColorSpaceRef CGColorSpaceCreateDeviceCMYK() CGColorSpaceRef CGColorSpaceCreateWithName(FakedEnums name) CGColorSpaceRef CGColorSpaceRetain(CGColorSpaceRef cs) int CGColorSpaceGetNumberOfComponents(CGColorSpaceRef cs) void CGColorSpaceRelease(CGColorSpaceRef cs) ctypedef void* CGColorRef # Color Settings - Partial CGColorRef CGColorCreate(CGColorSpaceRef colorspace, float components[]) # CGColorRef CGColorCreateWithPattern(CGColorSpaceRef colorspace, CGPatternRef pattern, float components[]) CGColorRef CGColorCreateCopy(CGColorRef color) CGColorRef CGColorCreateCopyWithAlpha(CGColorRef color, float alpha) CGColorRef CGColorRetain(CGColorRef color) void CGColorRelease(CGColorRef color) bool CGColorEqualToColor(CGColorRef color1, CGColorRef color2) size_t CGColorGetNumberOfComponents(CGColorRef color) float *CGColorGetComponents(CGColorRef color) float CGColorGetAlpha(CGColorRef color) CGColorSpaceRef CGColorGetColorSpace(CGColorRef color) # CGPatternRef CGColorGetPattern(CGColorRef color) void CGContextSetFillColorSpace(CGContextRef context, CGColorSpaceRef colorspace) void CGContextSetFillColor(CGContextRef context, float components[]) void CGContextSetStrokeColorSpace(CGContextRef context, CGColorSpaceRef colorspace) void CGContextSetStrokeColor(CGContextRef context, float components[]) void CGContextSetGrayFillColor(CGContextRef context, float gray, float alpha) void CGContextSetGrayStrokeColor(CGContextRef context, float gray, float alpha) void CGContextSetRGBFillColor(CGContextRef context, float red, float green, float blue, float alpha) void CGContextSetRGBStrokeColor(CGContextRef context, float red, float green, float blue, float alpha) void CGContextSetCMYKFillColor(CGContextRef context, float cyan, float magenta, float yellow, float black, float alpha) void CGContextSetCMYKStrokeColor(CGContextRef context, float cyan, float magenta, float yellow, float black, float alpha) void CGContextSetAlpha(CGContextRef context, float alpha) void CGContextSetRenderingIntent(CGContextRef context, CGColorRenderingIntent intent) void CGContextSetBlendMode(CGContextRef context, CGBlendMode mode) # Using ATS Fonts ctypedef void* CGFontRef ctypedef unsigned short CGFontIndex ctypedef CGFontIndex CGGlyph cdef enum: kCGFontIndexMax = ((1 << 16) - 2) kCGFontIndexInvalid = ((1 << 16) - 1) kCGGlyphMax = kCGFontIndexMax CGFontRef CGFontCreateWithPlatformFont(void *platformFontReference) CGFontRef CGFontRetain(CGFontRef font) void CGFontRelease(CGFontRef font) # Drawing Text ctypedef enum CGTextDrawingMode: kCGTextFill kCGTextStroke kCGTextFillStroke kCGTextInvisible kCGTextFillClip kCGTextStrokeClip kCGTextFillStrokeClip kCGTextClip ctypedef enum CGTextEncoding: kCGEncodingFontSpecific kCGEncodingMacRoman void CGContextSelectFont(CGContextRef context, char* name, float size, CGTextEncoding textEncoding) void CGContextSetFontSize(CGContextRef context, float size) void CGContextSetCharacterSpacing(CGContextRef context, float spacing) void CGContextSetTextDrawingMode(CGContextRef context, CGTextDrawingMode mode) void CGContextSetTextPosition(CGContextRef context, float x, float y) CGPoint CGContextGetTextPosition(CGContextRef context) void CGContextSetTextMatrix(CGContextRef context, CGAffineTransform transform) CGAffineTransform CGContextGetTextMatrix(CGContextRef context) void CGContextShowText(CGContextRef context, char* bytes, size_t length) void CGContextShowGlyphs(CGContextRef context, CGGlyph glyphs[], size_t count) void CGContextShowTextAtPoint(CGContextRef context, float x, float y, char* bytes, size_t length) void CGContextShowGlyphsAtPoint(CGContextRef context, float x, float y, CGGlyph g[], size_t count) void CGContextShowGlyphsWithAdvances(CGContextRef c, CGGlyph glyphs[], CGSize advances[], size_t count) # Quartz Data Providers ctypedef void* CGDataProviderRef CGDataProviderRef CGDataProviderCreateWithData(void* info, void* data, size_t size, void* callback) CGDataProviderRef CGDataProviderRetain(CGDataProviderRef provider) void CGDataProviderRelease(CGDataProviderRef provider) CGDataProviderRef CGDataProviderCreateWithURL(CFURLRef url) # Using Geometric Primitives CGPoint CGPointMake(float x, float y) CGSize CGSizeMake(float width, float height) CGRect CGRectMake(float x, float y, float width, float height) CGRect CGRectStandardize(CGRect rect) CGRect CGRectInset(CGRect rect, float dx, float dy) CGRect CGRectOffset(CGRect rect, float dx, float dy) CGRect CGRectIntegral(CGRect rect) CGRect CGRectUnion(CGRect r1, CGRect r2) CGRect CGRectIntersection(CGRect rect1, CGRect rect2) void CGRectDivide(CGRect rect, CGRect * slice, CGRect * remainder, float amount, CGRectEdge edge) # Getting Geometric Information float CGRectGetMinX(CGRect rect) float CGRectGetMidX(CGRect rect) float CGRectGetMaxX(CGRect rect) float CGRectGetMinY(CGRect rect) float CGRectGetMidY(CGRect rect) float CGRectGetMaxY(CGRect rect) float CGRectGetWidth(CGRect rect) float CGRectGetHeight(CGRect rect) int CGRectIsNull(CGRect rect) int CGRectIsEmpty(CGRect rect) int CGRectIntersectsRect(CGRect rect1, CGRect rect2) int CGRectContainsRect(CGRect rect1, CGRect rect2) int CGRectContainsPoint(CGRect rect, CGPoint point) int CGRectEqualToRect(CGRect rect1, CGRect rect2) int CGSizeEqualToSize(CGSize size1, CGSize size2) int CGPointEqualToPoint(CGPoint point1, CGPoint point2) # Affine Transformations CGAffineTransform CGAffineTransformIdentity CGAffineTransform CGAffineTransformMake(float a, float b, float c, float d, float tx, float ty) CGAffineTransform CGAffineTransformMakeTranslation(float tx, float ty) CGAffineTransform CGAffineTransformMakeScale(float sx, float sy) CGAffineTransform CGAffineTransformMakeRotation(float angle) CGAffineTransform CGAffineTransformTranslate(CGAffineTransform t, float tx, float ty) CGAffineTransform CGAffineTransformScale(CGAffineTransform t, float sx, float sy) CGAffineTransform CGAffineTransformRotate(CGAffineTransform t, float angle) CGAffineTransform CGAffineTransformInvert(CGAffineTransform t) CGAffineTransform CGAffineTransformConcat(CGAffineTransform t1, CGAffineTransform t2) CGPoint CGPointApplyAffineTransform(CGPoint point, CGAffineTransform t) CGSize CGSizeApplyAffineTransform(CGSize size, CGAffineTransform t) # Drawing Quartz Images ctypedef void* CGImageRef ctypedef enum CGImageAlphaInfo: kCGImageAlphaNone kCGImageAlphaPremultipliedLast kCGImageAlphaPremultipliedFirst kCGImageAlphaLast kCGImageAlphaFirst kCGImageAlphaNoneSkipLast kCGImageAlphaNoneSkipFirst kCGImageAlphaOnly ctypedef enum CGInterpolationQuality: kCGInterpolationDefault kCGInterpolationNone kCGInterpolationLow kCGInterpolationHigh CGImageRef CGImageCreate(size_t width, size_t height, size_t bitsPerComponent, size_t bitsPerPixel, size_t bytesPerRow, CGColorSpaceRef colorspace, CGImageAlphaInfo alphaInfo, CGDataProviderRef provider, float decode[], bool shouldInterpolate, CGColorRenderingIntent intent) CGImageRef CGImageMaskCreate(size_t width, size_t height, size_t bitsPerComponent, size_t bitsPerPixel, size_t bytesPerRow, CGDataProviderRef provider, float decode[], bool shouldInterpolate) CGImageRef CGImageCreateWithJPEGDataProvider(CGDataProviderRef source, float decode[], bool shouldInterpolate, CGColorRenderingIntent intent) CGImageRef CGImageCreateWithPNGDataProvider(CGDataProviderRef source, float decode[], bool shouldInterpolate, CGColorRenderingIntent intent) CGImageRef CGImageCreateCopyWithColorSpace(CGImageRef image, CGColorSpaceRef colorspace) CGImageRef CGImageRetain(CGImageRef image) void CGImageRelease(CGImageRef image) bool CGImageIsMask(CGImageRef image) size_t CGImageGetWidth(CGImageRef image) size_t CGImageGetHeight(CGImageRef image) size_t CGImageGetBitsPerComponent(CGImageRef image) size_t CGImageGetBitsPerPixel(CGImageRef image) size_t CGImageGetBytesPerRow(CGImageRef image) CGColorSpaceRef CGImageGetColorSpace(CGImageRef image) CGImageAlphaInfo CGImageGetAlphaInfo(CGImageRef image) CGDataProviderRef CGImageGetDataProvider(CGImageRef image) float *CGImageGetDecode(CGImageRef image) bool CGImageGetShouldInterpolate(CGImageRef image) CGColorRenderingIntent CGImageGetRenderingIntent(CGImageRef image) void CGContextDrawImage(CGContextRef context, CGRect rect, CGImageRef image) void CGContextSetInterpolationQuality(CGContextRef context, CGInterpolationQuality quality) # PDF ctypedef void* CGPDFDocumentRef CGPDFDocumentRef CGPDFDocumentCreateWithProvider(CGDataProviderRef provider) CGPDFDocumentRef CGPDFDocumentCreateWithURL(CFURLRef url) void CGPDFDocumentRelease(CGPDFDocumentRef document) bool CGPDFDocumentUnlockWithPassword(CGPDFDocumentRef document, char *password) void CGContextDrawPDFDocument(CGContextRef context, CGRect rect, CGPDFDocumentRef document, int page) size_t CGPDFDocumentGetNumberOfPages(CGPDFDocumentRef document) CGRect CGPDFDocumentGetMediaBox(CGPDFDocumentRef document, int page) CGRect CGPDFDocumentGetCropBox(CGPDFDocumentRef document, int page) CGRect CGPDFDocumentGetBleedBox(CGPDFDocumentRef document, int page) CGRect CGPDFDocumentGetTrimBox(CGPDFDocumentRef document, int page) CGRect CGPDFDocumentGetArtBox(CGPDFDocumentRef document, int page) int CGPDFDocumentGetRotationAngle(CGPDFDocumentRef document, int page) bool CGPDFDocumentAllowsCopying(CGPDFDocumentRef document) bool CGPDFDocumentAllowsPrinting(CGPDFDocumentRef document) bool CGPDFDocumentIsEncrypted(CGPDFDocumentRef document) bool CGPDFDocumentIsUnlocked(CGPDFDocumentRef document) # Bitmap Contexts CGContextRef CGBitmapContextCreate(void * data, size_t width, size_t height, size_t bitsPerComponent, size_t bytesPerRow, CGColorSpaceRef colorspace, CGImageAlphaInfo alphaInfo) CGImageAlphaInfo CGBitmapContextGetAlphaInfo(CGContextRef context) size_t CGBitmapContextGetBitsPerComponent(CGContextRef context) size_t CGBitmapContextGetBitsPerPixel(CGContextRef context) size_t CGBitmapContextGetBytesPerRow(CGContextRef context) CGColorSpaceRef CGBitmapContextGetColorSpace(CGContextRef context) void *CGBitmapContextGetData(CGContextRef context) size_t CGBitmapContextGetHeight(CGContextRef context) size_t CGBitmapContextGetWidth(CGContextRef context) # Path Handling ctypedef void* CGMutablePathRef ctypedef void* CGPathRef CGMutablePathRef CGPathCreateMutable() CGPathRef CGPathCreateCopy(CGPathRef path) CGMutablePathRef CGPathCreateMutableCopy(CGPathRef path) CGPathRef CGPathRetain(CGPathRef path) void CGPathRelease(CGPathRef path) bool CGPathEqualToPath(CGPathRef path1, CGPathRef path2) void CGPathMoveToPoint(CGMutablePathRef path, CGAffineTransform *m, float x, float y) void CGPathAddLineToPoint(CGMutablePathRef path, CGAffineTransform *m, float x, float y) void CGPathAddQuadCurveToPoint(CGMutablePathRef path, CGAffineTransform *m, float cpx, float cpy, float x, float y) void CGPathAddCurveToPoint(CGMutablePathRef path, CGAffineTransform *m, float cp1x, float cp1y, float cp2x, float cp2y, float x, float y) void CGPathCloseSubpath(CGMutablePathRef path) void CGPathAddRect(CGMutablePathRef path, CGAffineTransform *m, CGRect rect) void CGPathAddRects(CGMutablePathRef path, CGAffineTransform *m, CGRect rects[], size_t count) void CGPathAddLines(CGMutablePathRef path, CGAffineTransform *m, CGPoint points[], size_t count) void CGPathAddArc(CGMutablePathRef path, CGAffineTransform *m, float x, float y, float radius, float startAngle, float endAngle, bool clockwise) void CGPathAddArcToPoint(CGMutablePathRef path, CGAffineTransform *m, float x1, float y1, float x2, float y2, float radius) void CGPathAddPath(CGMutablePathRef path1, CGAffineTransform *m, CGPathRef path2) bool CGPathIsEmpty(CGPathRef path) bool CGPathIsRect(CGPathRef path, CGRect *rect) CGPoint CGPathGetCurrentPoint(CGPathRef path) CGRect CGPathGetBoundingBox(CGPathRef path) void CGContextAddPath(CGContextRef context, CGPathRef path) ctypedef enum CGPathElementType: kCGPathElementMoveToPoint, kCGPathElementAddLineToPoint, kCGPathElementAddQuadCurveToPoint, kCGPathElementAddCurveToPoint, kCGPathElementCloseSubpath ctypedef struct CGPathElement: CGPathElementType type CGPoint *points ctypedef void (*CGPathApplierFunction)(void *info, CGPathElement *element) void CGPathApply(CGPathRef path, void *info, CGPathApplierFunction function) CGContextRef CGGLContextCreate(void *glContext, CGSize size, CGColorSpaceRef colorspace) void CGGLContextUpdateViewportSize(CGContextRef context, CGSize size) ctypedef void* CGFunctionRef ctypedef void (*CGFunctionEvaluateCallback)(void *info, float *in_data, float *out) ctypedef void (*CGFunctionReleaseInfoCallback)(void *info) ctypedef struct CGFunctionCallbacks: unsigned int version CGFunctionEvaluateCallback evaluate CGFunctionReleaseInfoCallback releaseInfo CGFunctionRef CGFunctionCreate(void *info, size_t domainDimension, float *domain, size_t rangeDimension, float *range, CGFunctionCallbacks *callbacks) CGFunctionRef CGFunctionRetain(CGFunctionRef function) void CGFunctionRelease(CGFunctionRef function) ctypedef void* CGShadingRef CGShadingRef CGShadingCreateAxial(CGColorSpaceRef colorspace, CGPoint start, CGPoint end, CGFunctionRef function, bool extendStart, bool extendEnd) CGShadingRef CGShadingCreateRadial(CGColorSpaceRef colorspace, CGPoint start, float startRadius, CGPoint end, float endRadius, CGFunctionRef function, bool extendStart, bool extendEnd) CGShadingRef CGShadingRetain(CGShadingRef shading) void CGShadingRelease(CGShadingRef shading) void CGContextDrawShading(CGContextRef context, CGShadingRef shading) # Transparency Layers void CGContextBeginTransparencyLayer(CGContextRef context, CFDictionaryRef auxiliaryInfo) void CGContextEndTransparencyLayer(CGContextRef context) # CGLayers ctypedef void* CGLayerRef CGLayerRef CGLayerCreateWithContext(CGContextRef context, CGSize size, CFDictionaryRef auxiliaryInfo) CGLayerRef CGLayerRetain(CGLayerRef layer) void CGLayerRelease(CGLayerRef layer) CGSize CGLayerGetSize(CGLayerRef layer) CGContextRef CGLayerGetContext(CGLayerRef layer) void CGContextDrawLayerInRect(CGContextRef context, CGRect rect, CGLayerRef layer) void CGContextDrawLayerAtPoint(CGContextRef context, CGPoint point, CGLayerRef layer) CFTypeID CGLayerGetTypeID() CFTypeID CGContextGetTypeID() cdef CGRect CGRectMakeFromPython(object seq): return CGRectMake(seq[0], seq[1], seq[2], seq[3]) enthought-chaco2-4.1.0.orig/kiva/quartz/QuickDraw.pxi0000644000175000017500000000117011674463636021600 0ustar varunvarun# :Author: Robert Kern # :Copyright: 2004, Enthought, Inc. # :License: BSD Style cdef extern from "Quickdraw.h": ctypedef void* CGrafPtr ctypedef struct QDRect "Rect": short top short left short bottom short right OSStatus CreateCGContextForPort(CGrafPtr inPort, CGContextRef* outContext) OSStatus QDBeginCGContext(CGrafPtr inPort, CGContextRef* outContext) OSStatus QDEndCGContext(CGrafPtr inPort, CGContextRef* outContext) QDRect* GetPortBounds(CGrafPtr port, QDRect* rect) OSStatus SyncCGContextOriginWithPort(CGContextRef context, CGrafPtr port) enthought-chaco2-4.1.0.orig/kiva/quartz/setup.py0000644000175000017500000000714111674463636020702 0ustar varunvarun#!/usr/bin/env python import os 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 extra_link_args=[ '-Wl,-framework', '-Wl,CoreFoundation', '-Wl,-framework', '-Wl,ApplicationServices', '-Wl,-framework', '-Wl,Carbon', '-Wl,-framework', '-Wl,Foundation', ] include_dirs = ['/Developer/Headers/FlatCarbon'] config.add_extension('ATSFont', [generate_c_from_cython], include_dirs = include_dirs, extra_link_args = extra_link_args, depends=["ATSFont.pyx", "Python.pxi", "ATS.pxi", ], ) config.add_extension('ABCGI', [generate_c_from_cython], include_dirs = include_dirs, depends = ["ABCGI.pyx", "ATSUI.pxi", "Python.pxi", "numpy.pxi", "c_numpy.pxd", "CoreFoundation.pxi", "CoreGraphics.pxi", "QuickDraw.pxi", ] ) wx_info = get_info('wx') if wx_info: # Find the release number of wx. 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 if wx_release == '2.6': macport_cpp = config.paths('macport26.cpp')[0] else: macport_cpp = config.paths('macport28.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.1.0.orig/kiva/quartz/ATSFont.pyx0000644000175000017500000000742111674463636021211 0ustar varunvarun# :Author: Robert Kern # :Copyright: 2004, Enthought, Inc. # :License: BSD Style include "CoreFoundation.pxi" include "ATS.pxi" include "Python.pxi" cdef class ATSFont: cdef ATSFontRef ats_font cdef readonly object postscript_name def __init__(self, object postscript_name): cdef CFStringRef cf_ps_name cdef char* c_ps_name self.postscript_name = postscript_name postscript_name = postscript_name.encode('utf-8') c_ps_name = PyString_AsString(postscript_name) if c_ps_name == NULL: raise ValueError("could not decode %r as a UTF-8 encoded string" % postscript_name) cf_ps_name = CFStringCreateWithCString(NULL, c_ps_name, kCFStringEncodingUTF8) if cf_ps_name == NULL: raise ValueError("could not create CFString from %r" % postscript_name) self.ats_font = ATSFontFindFromPostScriptName(cf_ps_name, kATSOptionFlagsDefault) CFRelease(cf_ps_name) # if self.ats_font == 0: # raise ValueError("could not find font '%s'" % postscript_name) # Actually, I have no idea what the error result is def get_descent_ascent(self, object text): """ Get the descent and ascent font metrics for a given string of text. """ cdef ATSFontMetrics metrics cdef OSStatus status status = ATSFontGetVerticalMetrics(self.ats_font, 0, &metrics) return metrics.descent, metrics.ascent cdef OSStatus families_callback(ATSFontFamilyRef family, void* data): cdef CFStringRef cf_fam_name cdef OSStatus status cdef char* c_fam_name cdef char buf[256] cdef Boolean success status = ATSFontFamilyGetName(family, kATSOptionFlagsDefault, &cf_fam_name) family_list = data c_fam_name = CFStringGetCStringPtr(cf_fam_name, kCFStringEncodingMacRoman) if c_fam_name == NULL: success = CFStringGetCString(cf_fam_name, buf, 256, kCFStringEncodingMacRoman) family_list.append(buf) else: family_list.append(c_fam_name) CFRelease(cf_fam_name) return status cdef OSStatus styles_callback(ATSFontRef font, void* data): pass cdef class FontLookup: cdef readonly object cache cdef public object default_font def lookup_ps_name(self, name, style='regular'): cdef CFStringRef cf_name cdef ATSFontRef ats_font cdef OSStatus status style = style.title() if style == 'Regular': style = '' mac_name = ' '.join([name, style]).strip().encode('utf-8') cf_name = CFStringCreateWithCString(NULL, mac_name, kCFStringEncodingUTF8) ats_font = ATSFontFindFromName(cf_name, kATSOptionFlagsDefault) CFRelease(cf_name) if not ats_font: raise ValueError("could not find font %r" % mac_name) status = ATSFontGetPostScriptName(ats_font, kATSOptionFlagsDefault, &cf_name) if status != noErr: msg = "unknown error getting PostScript name for font %r"%mac_name raise RuntimeError(msg) ps_name = PyString_FromString(CFStringGetCStringPtr(cf_name, kCFStringEncodingMacRoman)) CFRelease(cf_name) return ps_name def lookup(self, name=None, style='regular'): ps_name = self.lookup_ps_name(name or self.default_font, style) return ATSFont(ps_name) def names(self): families = [] ATSFontFamilyApplyFunction(families_callback, families) families.sort() return families def styles(self, font_name): raise NotImplementedError def list_fonts(self): for name in self.names(): print name, self.styles(name) default_font_info = FontLookup() default_font_info.default_font = 'Helvetica' enthought-chaco2-4.1.0.orig/kiva/quartz/numpy.pxi0000644000175000017500000000165711674463636021070 0ustar varunvarun# :Author: Robert Kern # :Copyright: 2004, Enthought, Inc. # :License: BSD Style cdef extern from "numpy/oldnumeric.h": ctypedef enum PyArray_TYPES: PyArray_CHAR PyArray_UBYTE PyArray_SBYTE PyArray_SHORT PyArray_USHORT PyArray_INT PyArray_UINT PyArray_LONG PyArray_FLOAT PyArray_DOUBLE PyArray_CFLOAT PyArray_CDOUBLE PyArray_OBJECT PyArray_NTYPES PyArray_NOTYPE struct PyArray_Descr: int type_num, elsize char type ctypedef class numpy.ndarray [object PyArrayObject]: cdef char *data cdef int nd cdef int *dimensions cdef int *strides cdef object base cdef PyArray_Descr *descr cdef int flags ndarray PyArray_FromDims(int ndims, int* dims, int item_type) int PyArray_Free(object obj, char* data) void import_array() enthought-chaco2-4.1.0.orig/kiva/quartz/ABCGI.pyx0000644000175000017500000027450111674463636020545 0ustar varunvarun# :Author: Robert Kern # :Copyright: 2004, 2007, Enthought, Inc. # :License: BSD Style include "Python.pxi" include "CoreFoundation.pxi" include "CoreGraphics.pxi" include "QuickDraw.pxi" include "ATS.pxi" include "ATSUI.pxi" cimport c_numpy import os import warnings from ATSFont import default_font_info cdef extern from "math.h": double sqrt(double arg) int isnan(double arg) cdef CFURLRef url_from_filename(char* filename) except NULL: cdef CFStringRef filePath filePath = CFStringCreateWithCString(NULL, filename, kCFStringEncodingUTF8) if filePath == NULL: raise RuntimeError("could not create CFStringRef") cdef CFURLRef cfurl cfurl = CFURLCreateWithFileSystemPath(NULL, filePath, kCFURLPOSIXPathStyle, 0) CFRelease(filePath) if cfurl == NULL: raise RuntimeError("could not create a CFURLRef") return cfurl # Enumerations class LineCap: butt = kCGLineCapButt round = kCGLineCapRound square = kCGLineCapSquare class LineJoin: miter = kCGLineJoinMiter round = kCGLineJoinRound bevel = kCGLineJoinBevel class PathDrawingMode: fill = kCGPathFill eof_fill = kCGPathEOFill stroke = kCGPathStroke fill_stroke = kCGPathFillStroke eof_fill_stroke = kCGPathEOFillStroke class RectEdge: min_x_edge = CGRectMinXEdge min_y_edge = CGRectMinYEdge max_x_edge = CGRectMaxXEdge max_y_edge = CGRectMaxYEdge class ColorRenderingIntent: default = kCGRenderingIntentDefault absolute_colorimetric = kCGRenderingIntentAbsoluteColorimetric realative_colorimetric = kCGRenderingIntentRelativeColorimetric perceptual = kCGRenderingIntentPerceptual saturation = kCGRenderingIntentSaturation #class ColorSpaces: # gray = kCGColorSpaceUserGray # rgb = kCGColorSpaceUserRGB # cmyk = kCGColorSpaceUserCMYK class FontEnum: index_max = kCGFontIndexMax index_invalid = kCGFontIndexInvalid glyph_max = kCGGlyphMax class TextDrawingMode: fill = kCGTextFill stroke = kCGTextStroke fill_stroke = kCGTextFillStroke invisible = kCGTextInvisible fill_clip = kCGTextFillClip stroke_clip = kCGTextStrokeClip fill_stroke_clip = kCGTextFillStrokeClip clip = kCGTextClip class TextEncodings: font_specific = kCGEncodingFontSpecific mac_roman = kCGEncodingMacRoman class ImageAlphaInfo: none = kCGImageAlphaNone premultiplied_last = kCGImageAlphaPremultipliedLast premultiplied_first = kCGImageAlphaPremultipliedFirst last = kCGImageAlphaLast first = kCGImageAlphaFirst none_skip_last = kCGImageAlphaNoneSkipLast none_skip_first = kCGImageAlphaNoneSkipFirst only = kCGImageAlphaOnly class InterpolationQuality: default = kCGInterpolationDefault none = kCGInterpolationNone low = kCGInterpolationLow high = kCGInterpolationHigh class PathElementType: move_to = kCGPathElementMoveToPoint, line_to = kCGPathElementAddLineToPoint, quad_curve_to = kCGPathElementAddQuadCurveToPoint, curve_to = kCGPathElementAddCurveToPoint, close_path = kCGPathElementCloseSubpath class StringEncoding: mac_roman = kCFStringEncodingMacRoman windows_latin1 = kCFStringEncodingWindowsLatin1 iso_latin1 = kCFStringEncodingISOLatin1 nextstep_latin = kCFStringEncodingNextStepLatin ascii = kCFStringEncodingASCII unicode = kCFStringEncodingUnicode utf8 = kCFStringEncodingUTF8 nonlossy_ascii = kCFStringEncodingNonLossyASCII class URLPathStyle: posix = kCFURLPOSIXPathStyle hfs = kCFURLHFSPathStyle windows = kCFURLWindowsPathStyle c_numpy.import_array() import numpy from kiva import constants cap_style = {} cap_style[constants.CAP_ROUND] = kCGLineCapRound cap_style[constants.CAP_SQUARE] = kCGLineCapSquare cap_style[constants.CAP_BUTT] = kCGLineCapButt join_style = {} join_style[constants.JOIN_ROUND] = kCGLineJoinRound join_style[constants.JOIN_BEVEL] = kCGLineJoinBevel join_style[constants.JOIN_MITER] = kCGLineJoinMiter draw_modes = {} draw_modes[constants.FILL] = kCGPathFill draw_modes[constants.EOF_FILL] = kCGPathEOFill draw_modes[constants.STROKE] = kCGPathStroke draw_modes[constants.FILL_STROKE] = kCGPathFillStroke draw_modes[constants.EOF_FILL_STROKE] = kCGPathEOFillStroke text_modes = {} text_modes[constants.TEXT_FILL] = kCGTextFill text_modes[constants.TEXT_STROKE] = kCGTextStroke text_modes[constants.TEXT_FILL_STROKE] = kCGTextFillStroke text_modes[constants.TEXT_INVISIBLE] = kCGTextInvisible text_modes[constants.TEXT_FILL_CLIP] = kCGTextFillClip text_modes[constants.TEXT_STROKE_CLIP] = kCGTextStrokeClip text_modes[constants.TEXT_FILL_STROKE_CLIP] = kCGTextFillStrokeClip text_modes[constants.TEXT_CLIP] = kCGTextClip # this last one doesn't exist in Quartz text_modes[constants.TEXT_OUTLINE] = kCGTextStroke cdef class CGContext cdef class CGContextInABox(CGContext) cdef class CGImage cdef class CGPDFDocument cdef class Rect cdef class CGLayerContext(CGContextInABox) cdef class CGGLContext(CGContextInABox) cdef class CGBitmapContext(CGContext) cdef class CGPDFContext(CGContext) cdef class CGImageMask(CGImage) cdef class CGAffine cdef class CGMutablePath cdef class Shading cdef class ShadingFunction cdef class CGContext: cdef CGContextRef context cdef long can_release cdef object current_font cdef ATSUStyle current_style cdef CGAffineTransform text_matrix cdef object style_cache def __cinit__(self, *args, **kwds): self.context = NULL self.current_style = NULL self.can_release = 0 self.text_matrix = CGAffineTransformMake(1.0, 0.0, 0.0, 1.0, 0.0, 0.0) def __init__(self, long context, long can_release=0): self.context = context self.can_release = can_release self._setup_color_space() self._setup_fonts() def _setup_color_space(self): # setup an RGB color space cdef CGColorSpaceRef space space = CGColorSpaceCreateDeviceRGB() CGContextSetFillColorSpace(self.context, space) CGContextSetStrokeColorSpace(self.context, space) CGColorSpaceRelease(space) def _setup_fonts(self): self.style_cache = {} self.select_font("Helvetica", 12) CGContextSetShouldSmoothFonts(self.context, 1) CGContextSetShouldAntialias(self.context, 1) #---------------------------------------------------------------- # Coordinate Transform Matrix Manipulation #---------------------------------------------------------------- def scale_ctm(self, float sx, float 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 """ CGContextScaleCTM(self.context, sx, sy) def translate_ctm(self, float tx, float 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 """ CGContextTranslateCTM(self.context, tx, ty) def rotate_ctm(self, float angle): """ Rotates the coordinate space for drawing by the given angle. angle:float -- the angle, in radians, to rotate the coordinate system """ CGContextRotateCTM(self.context, angle) def concat_ctm(self, object transform): """ Concatenate the transform to current coordinate transform matrix. transform:affine_matrix -- the transform matrix to concatenate with the current coordinate matrix. """ cdef float a,b,c,d,tx,ty a,b,c,d,tx,ty = transform cdef CGAffineTransform atransform atransform = CGAffineTransformMake(a,b,c,d,tx,ty) CGContextConcatCTM(self.context, atransform) def get_ctm(self): """ Return the current coordinate transform matrix. """ cdef CGAffineTransform t t = CGContextGetCTM(self.context) return (t.a, t.b, t.c, t.d, t.tx, t.ty) def get_ctm_scale(self): """ Returns the average scaling factor of the transform matrix. This isn't really part of the GC interface, but it is a convenience method to make up for us not having full AffineMatrix support in the Mac backend. """ cdef CGAffineTransform t t = CGContextGetCTM(self.context) x = sqrt(2.0) / 2.0 * (t.a + t.b) y = sqrt(2.0) / 2.0 * (t.c + t.d) return sqrt(x*x + y*y) #---------------------------------------------------------------- # Save/Restore graphics state. #---------------------------------------------------------------- def save_state(self): """ Save the current graphic's context state. This should always be paired with a restore_state """ CGContextSaveGState(self.context) def restore_state(self): """ Restore the previous graphics state. """ CGContextRestoreGState(self.context) #---------------------------------------------------------------- # context manager interface #---------------------------------------------------------------- def __enter__(self): self.save_state() def __exit__(self, object type, object value, object traceback): self.restore_state() #---------------------------------------------------------------- # Manipulate graphics state attributes. #---------------------------------------------------------------- def set_antialias(self, bool value): """ Set/Unset antialiasing for bitmap graphics context. """ CGContextSetShouldAntialias(self.context, value) def set_line_width(self, float width): """ Set the line width for drawing width:float -- The new width for lines in user space units. """ CGContextSetLineWidth(self.context, width) def set_line_join(self, object 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) CGContextSetLineJoin(self.context, sjoin) def set_miter_limit(self, float 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. """ CGContextSetMiterLimit(self.context, limit) def set_line_cap(self, object 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) CGContextSetLineCap(self.context, scap) def set_line_dash(self, object lengths, float phase=0.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. """ cdef int n cdef int i cdef float *flengths if lengths is None: # No dash; solid line. CGContextSetLineDash(self.context, 0.0, NULL, 0) return else: n = len(lengths) flengths = PyMem_Malloc(n*sizeof(float)) if flengths == NULL: raise MemoryError("could not allocate %s floats" % n) for i from 0 <= i < n: flengths[i] = lengths[i] CGContextSetLineDash(self.context, phase, flengths, n) PyMem_Free(flengths) def set_flatness(self, float flatness): """ It is device dependent and therefore not recommended by the PDF documentation. """ CGContextSetFlatness(self.context, flatness) #---------------------------------------------------------------- # Sending drawing data to a device #---------------------------------------------------------------- def flush(self): """ Send all drawing data to the destination device. """ CGContextFlush(self.context) def synchronize(self): """ Prepares drawing data to be updated on a destination device. """ CGContextSynchronize(self.context) #---------------------------------------------------------------- # Page Definitions #---------------------------------------------------------------- def begin_page(self, media_box=None): """ Create a new page within the graphics context. """ cdef CGRect mbox cdef CGRect* mbox_ptr if media_box is not None: mbox = CGRectMakeFromPython(media_box) mbox_ptr = &mbox else: mbox_ptr = NULL CGContextBeginPage(self.context, mbox_ptr) def end_page(self): """ End drawing in the current page of the graphics context. """ CGContextEndPage(self.context) #---------------------------------------------------------------- # 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. """ CGContextBeginPath(self.context) def move_to(self, float x, float y): """ Start a new drawing subpath at place the current point at (x,y). """ CGContextMoveToPoint(self.context, x,y) def line_to(self, float x, float y): """ Add a line from the current point to the given point (x,y). The current point is moved to (x,y). """ CGContextAddLineToPoint(self.context, x,y) def lines(self, object points): """ Add a series of lines as a new subpath. Points is an Nx2 array of x,y pairs. current_point is moved to the last point in points """ cdef int n cdef int i cdef c_numpy.ndarray apoints cdef float x, y n = len(points) # Shortcut for the 0 and 1 point case if n < 2: return apoints = (numpy.asarray(points, dtype=numpy.float32)) if apoints.nd != 2 or apoints.dimensions[1] != 2: msg = "must pass array of 2-D points" raise ValueError(msg) x = (c_numpy.PyArray_GETPTR2(apoints, 0, 0))[0] y = (c_numpy.PyArray_GETPTR2(apoints, 0, 1))[0] CGContextMoveToPoint(self.context, x, y) for i from 1 <= i < n: x = (c_numpy.PyArray_GETPTR2(apoints, i, 0))[0] y = (c_numpy.PyArray_GETPTR2(apoints, i, 1))[0] CGContextAddLineToPoint(self.context, x, y) def line_set(self, object starts, object ends): """ Adds a series of disconnected line segments as a new subpath. starts and ends are Nx2 arrays of (x,y) pairs indicating the starting and ending points of each line segment. current_point is moved to the last point in ends """ cdef int n n = len(starts) if len(ends) < n: n = len(ends) cdef int i for i from 0 <= i < n: CGContextMoveToPoint(self.context, starts[i][0], starts[i][1]) CGContextAddLineToPoint(self.context, ends[i][0], ends[i][1]) def rect(self, float x, float y, float sx, float sy): """ Add a rectangle as a new subpath. """ CGContextAddRect(self.context, CGRectMake(x,y,sx,sy)) def rects(self, object rects): """ Add multiple rectangles as separate subpaths to the path. """ cdef int n n = len(rects) cdef int i for i from 0 <= i < n: CGContextAddRect(self.context, CGRectMakeFromPython(rects[i])) def close_path(self): """ Close the path of the current subpath. """ CGContextClosePath(self.context) def curve_to(self, float cp1x, float cp1y, float cp2x, float cp2y, float x, float y): """ """ CGContextAddCurveToPoint(self.context, cp1x, cp1y, cp2x, cp2y, x, y ) def quad_curve_to(self, float cpx, float cpy, float x, float y): """ """ CGContextAddQuadCurveToPoint(self.context, cpx, cpy, x, y) def arc(self, float x, float y, float radius, float start_angle, float end_angle, bool clockwise=False): """ """ CGContextAddArc(self.context, x, y, radius, start_angle, end_angle, clockwise) def arc_to(self, float x1, float y1, float x2, float y2, float radius): """ """ CGContextAddArcToPoint(self.context, x1, y1, x2, y2, radius) def add_path(self, CGMutablePath path not None): """ """ CGContextAddPath(self.context, path.path) #---------------------------------------------------------------- # Getting information on paths #---------------------------------------------------------------- def is_path_empty(self): """ Test to see if the current drawing path is empty """ return CGContextIsPathEmpty(self.context) def get_path_current_point(self): """ Return the current point from the graphics context. Note: This should be a tuple or array. """ cdef CGPoint result result = CGContextGetPathCurrentPoint(self.context) return result.x, result.y def get_path_bounding_box(self): """ should return a tuple or array instead of a strange object. """ cdef CGRect result result = CGContextGetPathBoundingBox(self.context) return (result.origin.x, result.origin.y, result.size.width, result.size.height) #---------------------------------------------------------------- # Clipping path manipulation #---------------------------------------------------------------- def clip(self): """ """ CGContextClip(self.context) def even_odd_clip(self): """ """ CGContextEOClip(self.context) def clip_to_rect(self, float x, float y, float width, float height): """ Clip context to the given rectangular region. """ CGContextClipToRect(self.context, CGRectMake(x,y,width,height)) def clip_to_rects(self, object rects): """ """ cdef int n n = len(rects) cdef int i cdef CGRect* cgrects cgrects = PyMem_Malloc(n*sizeof(CGRect)) if cgrects == NULL: raise MemoryError("could not allocate memory for CGRects") for i from 0 <= i < n: cgrects[i] = CGRectMakeFromPython(rects[i]) CGContextClipToRects(self.context, cgrects, n) PyMem_Free(cgrects) #---------------------------------------------------------------- # 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 Macintosh yet." raise NotImplementedError(msg) def set_stroke_color_space(self): """ """ msg = "set_stroke_color_space not implemented on Macintosh yet." raise NotImplementedError(msg) def set_rendering_intent(self, intent): """ """ CGContextSetRenderingIntent(self.context, intent) #---------------------------------------------------------------- # Color manipulation #---------------------------------------------------------------- def set_fill_color(self, object color): """ """ r,g,b = color[:3] try: a = color[3] except IndexError: a = 1.0 CGContextSetRGBFillColor(self.context, r, g, b, a) def set_stroke_color(self, object color): """ """ r,g,b = color[:3] try: a = color[3] except IndexError: a = 1.0 CGContextSetRGBStrokeColor(self.context, r, g, b, a) def set_alpha(self, float alpha): """ """ CGContextSetAlpha(self.context, alpha) #def set_gray_fill_color(self): # """ # """ # pass #def set_gray_stroke_color(self): # """ # """ # pass #def set_rgb_fill_color(self): # """ # """ # pass #def set_rgb_stroke_color(self): # """ # """ # pass #def cmyk_fill_color(self): # """ # """ # pass #def cmyk_stroke_color(self): # """ # """ # pass #---------------------------------------------------------------- # Drawing Images #---------------------------------------------------------------- def draw_image(self, object image, object rect=None): """ Draw an image or another CGContext onto a region. """ if rect is None: rect = (0, 0, self.width(), self.height()) if isinstance(image, numpy.ndarray): self._draw_cgimage(CGImage(image), rect) elif isinstance(image, CGImage): self._draw_cgimage(image, rect) elif hasattr(image, 'bmp_array'): self._draw_cgimage(CGImage(image.bmp_array), rect) elif isinstance(image, CGLayerContext): self._draw_cglayer(image, rect) else: raise TypeError("could not recognize image %r" % type(image)) def _draw_cgimage(self, CGImage image, object rect): """ Draw a CGImage into a region. """ CGContextDrawImage(self.context, CGRectMakeFromPython(rect), image.image) def _draw_cglayer(self, CGLayerContext layer, object rect): """ Draw a CGLayer into a region. """ CGContextDrawLayerInRect(self.context, CGRectMakeFromPython(rect), layer.layer) def set_interpolation_quality(self, quality): CGContextSetInterpolationQuality(self.context, quality) #---------------------------------------------------------------- # Drawing PDF documents #---------------------------------------------------------------- def draw_pdf_document(self, object rect, CGPDFDocument document not None, int page=1): """ rect:(x,y,width,height) -- rectangle to draw into document:CGPDFDocument -- PDF file to read from page=1:int -- page number of PDF file """ cdef CGRect cgrect cgrect = CGRectMakeFromPython(rect) CGContextDrawPDFDocument(self.context, cgrect, document.document, page) #---------------------------------------------------------------- # Drawing Text #---------------------------------------------------------------- def select_font(self, object name, float size, style='regular'): """ """ cdef ATSUStyle atsu_style key = (name, size, style) if key not in self.style_cache: font = default_font_info.lookup(name, style=style) self.current_font = font ps_name = font.postscript_name atsu_style = _create_atsu_style(ps_name, size) if atsu_style == NULL: raise RuntimeError("could not create style for font %r" % ps_name) self.style_cache[key] = PyCObject_FromVoidPtr(atsu_style, ATSUDisposeStyle) atsu_style = PyCObject_AsVoidPtr(self.style_cache[key]) self.current_style = atsu_style def set_font(self, font): """ Set the font for the current graphics context. I need to figure out this one. """ style = { constants.NORMAL: 'regular', constants.BOLD: 'bold', constants.ITALIC: 'italic', constants.BOLD_ITALIC: 'bold italic', }[font.weight | font.style] self.select_font(font.face_name, font.size, style=style) def set_font_size(self, float size): """ """ cdef ATSUAttributeTag attr_tag cdef ByteCount attr_size cdef ATSUAttributeValuePtr attr_value cdef Fixed fixed_size cdef OSStatus err if self.current_style == NULL: return attr_tag = kATSUSizeTag attr_size = sizeof(Fixed) fixed_size = FloatToFixed(size) attr_value = &fixed_size err = ATSUSetAttributes(self.current_style, 1, &attr_tag, &attr_size, &attr_value) if err: raise RuntimeError("could not set font size on current style") def set_character_spacing(self, float spacing): """ """ # XXX: This does not fit in with ATSUI, really. CGContextSetCharacterSpacing(self.context, spacing) def set_text_drawing_mode(self, object mode): """ """ try: cgmode = text_modes[mode] except KeyError: msg = "Invalid text drawing mode. See documentation for valid modes" raise ValueError(msg) CGContextSetTextDrawingMode(self.context, cgmode) def set_text_position(self, float x,float y): """ """ self.text_matrix.tx = x self.text_matrix.ty = y def get_text_position(self): """ """ return self.text_matrix.tx, self.text_matrix.ty def set_text_matrix(self, object ttm): """ """ cdef float a,b,c,d,tx,ty # Handle both matrices that this class returns and agg._AffineMatrix # instances. try: ((a, b, _), (c, d, _), (tx, ty, _)) = ttm except: a,b,c,d,tx,ty = ttm cdef CGAffineTransform transform transform = CGAffineTransformMake(a,b,c,d,tx,ty) self.text_matrix = transform def get_text_matrix(self): """ """ return ((self.text_matrix.a, self.text_matrix.b, 0.0), (self.text_matrix.c, self.text_matrix.d, 0.0), (self.text_matrix.tx,self.text_matrix.ty,1.0)) def get_text_extent(self, object text): """ Measure the space taken up by given text using the current font. """ cdef CGPoint start cdef CGPoint stop cdef ATSFontMetrics metrics cdef OSStatus status cdef ATSUTextLayout layout cdef double x1, x2, y1, y2 cdef ATSUTextMeasurement before, after, ascent, descent cdef ByteCount actual_size layout = NULL try: if not text: # ATSUGetUnjustifiedBounds does not handle empty strings. text = " " empty = True else: empty = False _create_atsu_layout(text, self.current_style, &layout) status = ATSUGetUnjustifiedBounds(layout, 0, len(text), &before, &after, &ascent, &descent) if status: raise RuntimeError("could not calculate font metrics") if empty: x1 = 0.0 x2 = 0.0 else: x1 = FixedToFloat(before) x2 = FixedToFloat(after) y1 = -FixedToFloat(descent) y2 = -y1 + FixedToFloat(ascent) finally: if layout != NULL: ATSUDisposeTextLayout(layout) return x1, y1, x2, y2 def get_full_text_extent(self, object text): """ Backwards compatibility API over .get_text_extent() for Enable. """ x1, y1, x2, y2 = self.get_text_extent(text) return x2, y2, y1, x1 def show_text(self, object text, object xy=None): """ Draw text on the device at current text position. This is also used for showing text at a particular point specified by xy == (x, y). """ cdef float x cdef float y cdef CGAffineTransform text_matrix cdef ATSUTextLayout layout if not text: # I don't think we can draw empty strings using the ATSU API. return if xy is None: x = 0.0 y = 0.0 else: x = xy[0] y = xy[1] self.save_state() try: CGContextConcatCTM(self.context, self.text_matrix) _create_atsu_layout(text, self.current_style, &layout) _set_cgcontext_for_layout(self.context, layout) ATSUDrawText(layout, 0, len(text), FloatToFixed(x), FloatToFixed(y)) finally: self.restore_state() if layout != NULL: ATSUDisposeTextLayout(layout) def show_text_at_point(self, object text, float x, float y): """ Draw text on the device at a given text position. """ self.show_text(text, (x, y)) def show_glyphs(self): """ """ msg = "show_glyphs not implemented on Macintosh yet." raise NotImplementedError(msg) #---------------------------------------------------------------- # Painting paths (drawing and filling contours) #---------------------------------------------------------------- def stroke_path(self): """ """ CGContextStrokePath(self.context) def fill_path(self): """ """ CGContextFillPath(self.context) def eof_fill_path(self): """ """ CGContextEOFillPath(self.context) def stroke_rect(self, object rect): """ """ CGContextStrokeRect(self.context, CGRectMakeFromPython(rect)) def stroke_rect_with_width(self, object rect, float width): """ """ CGContextStrokeRectWithWidth(self.context, CGRectMakeFromPython(rect), width) def fill_rect(self, object rect): """ """ CGContextFillRect(self.context, CGRectMakeFromPython(rect)) def fill_rects(self, object rects): """ """ cdef int n n = len(rects) cdef int i cdef CGRect* cgrects cgrects = PyMem_Malloc(n*sizeof(CGRect)) if cgrects == NULL: raise MemoryError("could not allocate memory for CGRects") for i from 0 <= i < n: cgrects[i] = CGRectMakeFromPython(rects[i]) CGContextFillRects(self.context, cgrects, n) def clear_rect(self, object rect): """ """ CGContextClearRect(self.context, CGRectMakeFromPython(rect)) def draw_path(self, object mode=constants.FILL_STROKE): """ Walk through all the drawing subpaths and draw each element. Each subpath is drawn separately. """ cg_mode = draw_modes[mode] CGContextDrawPath(self.context, cg_mode) def draw_rect(self, rect, object mode=constants.FILL_STROKE): """ Draw a rectangle with the given mode. """ self.save_state() CGContextBeginPath(self.context) CGContextAddRect(self.context, CGRectMakeFromPython(rect)) cg_mode = draw_modes[mode] CGContextDrawPath(self.context, cg_mode) self.restore_state() def get_empty_path(self): """ Return a path object that can be built up and then reused. """ return CGMutablePath() def draw_path_at_points(self, points, CGMutablePath marker not None, object mode=constants.FILL_STROKE): cdef int i cdef int n cdef c_numpy.ndarray apoints cdef float x, y apoints = (numpy.asarray(points, dtype=numpy.float32)) if apoints.nd != 2 or apoints.dimensions[1] != 2: msg = "must pass array of 2-D points" raise ValueError(msg) cg_mode = draw_modes[mode] n = len(points) for i from 0 <= i < n: x = (c_numpy.PyArray_GETPTR2(apoints, i, 0))[0] y = (c_numpy.PyArray_GETPTR2(apoints, i, 1))[0] CGContextSaveGState(self.context) CGContextTranslateCTM(self.context, x, y) CGContextAddPath(self.context, marker.path) CGContextDrawPath(self.context, cg_mode) CGContextRestoreGState(self.context) def linear_gradient(self, x1, y1, x2, y2, stops, spread_method, units='userSpaceOnUse'): cdef CGRect path_rect if units == 'objectBoundingBox': # transform from relative coordinates path_rect = CGContextGetPathBoundingBox(self.context) x1 = path_rect.origin.x + x1 * path_rect.size.width x2 = path_rect.origin.x + x2 * path_rect.size.width y1 = path_rect.origin.y + y1 * path_rect.size.height y2 = path_rect.origin.y + y2 * path_rect.size.height stops_list = stops.transpose().tolist() func = PiecewiseLinearColorFunction(stops_list) # Shadings fill the current clip path self.clip() if spread_method == 'pad' or spread_method == '': shading = AxialShading(func, (x1,y1), (x2,y2), extend_start=1, extend_end=1) self.draw_shading(shading) else: self.repeat_linear_shading(x1, y1, x2, y2, stops, spread_method, func) def repeat_linear_shading(self, x1, y1, x2, y2, stops, spread_method, ShadingFunction func not None): cdef CGRect clip_rect = CGContextGetClipBoundingBox(self.context) cdef double dirx, diry, slope cdef double startx, starty, endx, endy cdef int func_index = 0 if spread_method == 'reflect': # generate the mirrored color function stops_list = stops[::-1].transpose() stops_list[0] = 1-stops_list[0] funcs = [func, PiecewiseLinearColorFunction(stops_list.tolist())] else: funcs = [func, func] dirx, diry = x2-x1, y2-y1 startx, starty = x1, y1 endx, endy = x2, y2 if dirx == 0. and diry == 0.: slope = float('nan') diry = 100.0 elif diry == 0.: slope = 0. else: # perpendicular slope slope = -dirx/diry while _line_intersects_cgrect(startx, starty, slope, clip_rect): shading = AxialShading(funcs[func_index&1], (startx, starty), (endx, endy), extend_start=0, extend_end=0) self.draw_shading(shading) startx, starty = endx, endy endx, endy = endx+dirx, endy+diry func_index += 1 # reverse direction dirx, diry = x1-x2, y1-y2 startx, starty = x1+dirx, y1+diry endx, endy = x1, y1 func_index = 1 if dirx == 0. and diry == 0.: slope = float('nan') diry = 100.0 elif diry == 0.: slope = 0. else: # perpendicular slope slope = -dirx/diry while _line_intersects_cgrect(endx, endy, slope, clip_rect): shading = AxialShading(funcs[func_index&1], (startx, starty), (endx, endy), extend_start=0, extend_end=0) self.draw_shading(shading) endx, endy = startx, starty startx, starty = endx+dirx, endy+diry func_index += 1 def radial_gradient(self, cx, cy, r, fx, fy, stops, spread_method, units='userSpaceOnUse'): cdef CGRect path_rect if units == 'objectBoundingBox': # transform from relative coordinates path_rect = CGContextGetPathBoundingBox(self.context) r = r * path_rect.size.width cx = path_rect.origin.x + cx * path_rect.size.width fx = path_rect.origin.x + fx * path_rect.size.width cy = path_rect.origin.y + cy * path_rect.size.height fy = path_rect.origin.y + fy * path_rect.size.height stops_list = stops.transpose().tolist() func = PiecewiseLinearColorFunction(stops_list) # 12/11/2010 John Wiggins - In order to avoid a bug in Quartz, # the radius of a radial gradient must be greater than the distance # between the center and the focus. When input runs afoul of this bug, # the focus point will be moved towards the center so that the distance # is less than the radius. This matches the behavior of AGG. cdef double dx = fx-cx cdef double dy = fy-cy cdef double dist = sqrt(dx*dx + dy*dy) if r <= dist: newdist = r-0.001 fx = cx+newdist*dx/dist fy = cy+newdist*dy/dist # Shadings fill the current clip path self.clip() if spread_method == 'pad' or spread_method == '': shading = RadialShading(func, (fx, fy), 0.0, (cx, cy), r, extend_start=1, extend_end=1) self.draw_shading(shading) else: # 'reflect' and 'repeat' need to iterate self.repeat_radial_shading(cx, cy, r, fx, fy, stops, spread_method, func) def repeat_radial_shading(self, cx, cy, r, fx, fy, stops, spread_method, ShadingFunction func not None): cdef CGRect clip_rect = CGContextGetClipBoundingBox(self.context) cdef double rad = 0., dirx = 0., diry = 0. cdef double startx, starty, endx, endy cdef int func_index = 0 if spread_method == 'reflect': # generate the mirrored color function stops_list = stops[::-1].transpose() stops_list[0] = 1-stops_list[0] funcs = [func, PiecewiseLinearColorFunction(stops_list.tolist())] else: funcs = [func, func] dirx, diry = cx-fx, cy-fy startx, starty = fx,fy endx, endy = cx, cy while not _cgrect_within_circle(clip_rect, endx, endy, rad): shading = RadialShading(funcs[func_index & 1], (startx, starty), rad, (endx, endy), rad+r, extend_start=0, extend_end=0) self.draw_shading(shading) startx, starty = endx, endy endx, endy = endx+dirx, endy+diry rad += r func_index += 1 def draw_shading(self, Shading shading not None): CGContextDrawShading(self.context, shading.shading) #---------------------------------------------------------------- # Extra routines that aren't part of DisplayPDF # # Some access to font metrics are needed for laying out text. # Not sure how to handle this yet. The candidates below are # from Piddle. Perhaps there is another alternative? # #---------------------------------------------------------------- #def font_height(self): # '''Find the total height (ascent + descent) of the given font.''' # #return self.font_ascent() + self.font_descent() #def font_ascent(self): # '''Find the ascent (height above base) of the given font.''' # pass #def font_descent(self): # '''Find the descent (extent below base) of the given font.''' # extents = self.dc.GetFullTextExtent(' ', wx_font) # return extents[2] def __dealloc__(self): if self.context != NULL and self.can_release: CGContextRelease(self.context) self.context = NULL # The following are Quartz APIs not in Kiva def set_pattern_phase(self, float tx, float ty): """ tx,ty:floats -- A translation in user-space to apply to a pattern before it is drawn """ CGContextSetPatternPhase(self.context, CGSizeMake(tx, ty)) def set_should_smooth_fonts(self, bool value): """ value:bool -- specify whether to enable font smoothing or not """ CGContextSetShouldSmoothFonts(self.context, value) cdef class CGContextInABox(CGContext): """ A CGContext that knows its size. """ cdef readonly object size cdef readonly int _width cdef readonly int _height def __init__(self, object size, long context, long can_release=0, *args, **kwargs): self.context = context self.can_release = can_release self._width, self._height = size self._setup_color_space() self._setup_fonts() def clear(self, object clear_color=(1.0,1.0,1.0,1.0)): self.save_state() # Reset the transformation matrix back to the identity. CGContextConcatCTM(self.context, CGAffineTransformInvert(CGContextGetCTM(self.context))) self.set_fill_color(clear_color) CGContextFillRect(self.context, CGRectMake(0,0,self._width,self._height)) self.restore_state() def width(self): return self._width def height(self): return self._height cdef class CGLayerContext(CGContextInABox): cdef CGLayerRef layer cdef object gc def __init__(self, object size, CGContext gc not None, *args, **kwargs): self.gc = gc self.layer = CGLayerCreateWithContext(gc.context, CGSizeMake(size[0], size[1]), NULL) self.context = CGLayerGetContext(self.layer) self.size = size self._width, self._height = size self.can_release = 1 self._setup_color_space() self._setup_fonts() def __dealloc__(self): if self.layer != NULL: CGLayerRelease(self.layer) self.layer = NULL # The documentation doesn't say whether I need to release the # context derived from the layer or not. I believe that means # I don't. self.context = NULL self.gc = None def save(self, object filename, file_format=None, pil_options=None): """ Save the GraphicsContext to a file. Output files are always saved in RGB or RGBA format; if this GC is not in one of these formats, it is automatically converted. If filename includes an extension, the image format is inferred from it. file_format is only required if the format can't be inferred from the filename (e.g. if you wanted to save a PNG file as a .dat or .bin). filename may also be "file-like" object such as a StringIO, in which case a file_format must be supplied. pil_options is a dict of format-specific options that are passed down to the PIL image file writer. If a writer doesn't recognize an option, it is silently ignored. If the image has an alpha channel and the specified output file format does not support alpha, the image is saved in rgb24 format. """ cdef CGBitmapContext bmp # Create a CGBitmapContext from this layer, draw to it, then let it save # itself out. rect = (0, 0) + self.size bmp = CGBitmapContext(self.size) CGContextDrawLayerInRect(bmp.context, CGRectMakeFromPython(rect), self.layer) bmp.save(filename, file_format=file_format, pil_options=pil_options) cdef class CGContextFromSWIG(CGContext): def __init__(self, swig_obj): self.can_release = False ptr = int(swig_obj.this.split('_')[1], 16) CGContext.__init__(self, ptr) cdef class CGContextForPort(CGContextInABox): cdef readonly long port cdef readonly int _begun def __init__(self, long port): cdef OSStatus status # status = QDBeginCGContext(port, &(self.context)) # if status: # self.port = 0 # raise RuntimeError("QuickDraw could not make CGContext") self.context = NULL self.can_release = 0 self._begun = 0 self.port = port cdef QDRect r GetPortBounds(port, &r) self._width = r.right - r.left self._height = r.bottom - r.top self.size = (self._width, self._height) #self.begin() def begin(self): cdef OSStatus status cdef QDRect port_rect if not self._begun: status = QDBeginCGContext(self.port, &(self.context)) if status != noErr: raise RuntimeError("QuickDraw could not make CGContext") SyncCGContextOriginWithPort(self.context, self.port) self._setup_color_space() self._setup_fonts() #GetPortBounds(self.port, &port_rect) #CGContextTranslateCTM(self.context, 0, (port_rect.bottom - port_rect.top)) #CGContextScaleCTM(self.context, 1.0, -1.0) self._begun = 1 def end(self): if self.port and self.context is not NULL and self._begun: CGContextFlush(self.context) QDEndCGContext((self.port), &(self.context)) self._begun = 0 def clear(self, object clear_color=(1.0,1.0,1.0,1.0)): already_begun = self._begun self.begin() CGContextInABox.clear(self, clear_color) if not already_begun: self.end() def __dealloc__(self): self.end() #if self.port and self.context and self._begun: # QDEndCGContext((self.port), &(self.context)) #if self.context and self.can_release: # CGContextRelease(self.context) # self.context = NULL cdef class CGGLContext(CGContextInABox): cdef readonly long glcontext def __init__(self, long glcontext, int width, int height): if glcontext == 0: raise ValueError("Need a valid pointer") self.glcontext = glcontext self.context = CGGLContextCreate(glcontext, CGSizeMake(width, height), NULL) if self.context == NULL: raise RuntimeError("could not create CGGLContext") self.can_release = 1 self._width = width self._height = height self.size = (self._width, self._height) self._setup_color_space() self._setup_fonts() def resize(self, int width, int height): CGGLContextUpdateViewportSize(self.context, CGSizeMake(width, height)) self._width = width self._height = height self.size = (width, height) cdef class CGPDFContext(CGContext): cdef readonly char* filename cdef CGRect media_box def __init__(self, char* filename, rect=None): cdef CFURLRef cfurl cfurl = url_from_filename(filename) cdef CGRect cgrect cdef CGRect* cgrect_ptr if rect is None: cgrect = CGRectMake(0,0,612,792) cgrect_ptr = &cgrect else: cgrect = CGRectMakeFromPython(rect) cgrect_ptr = &cgrect self.context = CGPDFContextCreateWithURL(cfurl, cgrect_ptr, NULL) CFRelease(cfurl) self.filename = filename self.media_box = cgrect if self.context == NULL: raise RuntimeError("could not create CGPDFContext") self.can_release = 1 self._setup_color_space() self._setup_fonts() CGContextBeginPage(self.context, cgrect_ptr) def begin_page(self, media_box=None): cdef CGRect* box_ptr cdef CGRect box if media_box is None: box_ptr = &(self.media_box) else: box = CGRectMakeFromPython(media_box) box_ptr = &box CGContextBeginPage(self.context, box_ptr) def flush(self, end_page=True): if end_page: self.end_page() CGContextFlush(self.context) def begin_transparency_layer(self): CGContextBeginTransparencyLayer(self.context, NULL) def end_transparency_layer(self): CGContextEndTransparencyLayer(self.context) cdef class CGBitmapContext(CGContext): cdef void* data def __cinit__(self, *args, **kwds): self.data = NULL def __init__(self, object size_or_array, bool grey_scale=0, int bits_per_component=8, int bytes_per_row=-1, alpha_info=kCGImageAlphaPremultipliedLast): cdef int bits_per_pixel cdef CGColorSpaceRef colorspace cdef void* dataptr if hasattr(size_or_array, '__array_interface__'): # It's an array. arr = numpy.asarray(size_or_array, order='C') typestr = arr.dtype.str if typestr != '|u1': raise ValueError("expecting an array of unsigned bytes; got %r" % typestr) shape = arr.shape if len(shape) != 3 or shape[-1] not in (3, 4): raise ValueError("expecting a shape (width, height, depth) " "with depth either 3 or 4; got %r" % shape) height, width, depth = shape if depth == 3: # Need to add an alpha channel. alpha = numpy.empty((height, width), dtype=numpy.uint8) alpha.fill(255) arr = numpy.dstack([arr, alpha]) depth = 4 ptr, readonly = arr.__array_interface__['data'] dataptr = ptr else: # It's a size tuple. width, height = size_or_array arr = None if grey_scale: alpha_info = kCGImageAlphaNone bits_per_component = 8 bits_per_pixel = 8 colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericGray) elif bits_per_component == 5: alpha_info = kCGImageAlphaNoneSkipFirst bits_per_pixel = 16 colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB) elif bits_per_component == 8: if alpha_info not in (kCGImageAlphaNoneSkipFirst, kCGImageAlphaNoneSkipLast, kCGImageAlphaPremultipliedFirst, kCGImageAlphaPremultipliedLast, ): raise ValueError("not a valid alpha_info") bits_per_pixel = 32 colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB) else: raise ValueError("bits_per_component must be 5 or 8") cdef int min_bytes min_bytes = (width*bits_per_pixel + 7) / 8 if bytes_per_row < min_bytes: bytes_per_row = min_bytes self.data = PyMem_Malloc(height*bytes_per_row) if self.data == NULL: CGColorSpaceRelease(colorspace) raise MemoryError("could not allocate memory") if arr is not None: # Copy the data from the array. memcpy(self.data, dataptr, width*height*depth) self.context = CGBitmapContextCreate(self.data, width, height, bits_per_component, bytes_per_row, colorspace, alpha_info) CGColorSpaceRelease(colorspace) if self.context == NULL: raise RuntimeError("could not create CGBitmapContext") self.can_release = 1 self._setup_fonts() def __dealloc__(self): if self.context != NULL and self.can_release: CGContextRelease(self.context) self.context = NULL if self.data != NULL: # Hmm, this could be tricky if anything in Quartz retained a # reference to self.context PyMem_Free(self.data) self.data = NULL property alpha_info: def __get__(self): return CGBitmapContextGetAlphaInfo(self.context) property bits_per_component: def __get__(self): return CGBitmapContextGetBitsPerComponent(self.context) property bits_per_pixel: def __get__(self): return CGBitmapContextGetBitsPerPixel(self.context) property bytes_per_row: def __get__(self): return CGBitmapContextGetBytesPerRow(self.context) # property colorspace: # def __get__(self): # return CGBitmapContextGetColorSpace(self.context) def height(self): return CGBitmapContextGetHeight(self.context) def width(self): return CGBitmapContextGetWidth(self.context) def __getsegcount__(self, void* tmp): cdef int *lenp lenp = tmp if lenp != NULL: lenp[0] = self.height()*self.bytes_per_row return 1 def __getreadbuffer__(self, int segment, void** ptr): # ignore invalid segment; the caller can't mean anything but the only # segment available; we're all adults ptr[0] = self.data return self.height()*self.bytes_per_row def __getwritebuffer__(self, int segment, void** ptr): # ignore invalid segment; the caller can't mean anything but the only # segment available; we're all adults ptr[0] = self.data return self.height()*self.bytes_per_row def __getcharbuffer__(self, int segment, char** ptr): # ignore invalid segment; the caller can't mean anything but the only # segment available; we're all adults ptr[0] = (self.data) return self.height()*self.bytes_per_row def clear(self, object clear_color=(1.0, 1.0, 1.0, 1.0)): """Paint over the whole image with a solid color. """ self.save_state() # Reset the transformation matrix back to the identity. CGContextConcatCTM(self.context, CGAffineTransformInvert(CGContextGetCTM(self.context))) self.set_fill_color(clear_color) CGContextFillRect(self.context, CGRectMake(0, 0, self.width(), self.height())) self.restore_state() def save(self, object filename, file_format=None, pil_options=None): """ Save the GraphicsContext to a file. Output files are always saved in RGB or RGBA format; if this GC is not in one of these formats, it is automatically converted. If filename includes an extension, the image format is inferred from it. file_format is only required if the format can't be inferred from the filename (e.g. if you wanted to save a PNG file as a .dat or .bin). filename may also be "file-like" object such as a StringIO, in which case a file_format must be supplied. pil_options is a dict of format-specific options that are passed down to the PIL image file writer. If a writer doesn't recognize an option, it is silently ignored. If the image has an alpha channel and the specified output file format does not support alpha, the image is saved in rgb24 format. """ try: import Image except ImportError: raise ImportError("need PIL to save images") if self.bits_per_pixel == 32: if self.alpha_info == kCGImageAlphaPremultipliedLast: mode = 'RGBA' elif self.alpha_info == kCGImageAlphaPremultipliedFirst: mode = 'ARGB' else: raise ValueError("cannot save this pixel format") elif self.bits_per_pixel == 8: mode = 'L' else: raise ValueError("cannot save this pixel format") if file_format is None: file_format = '' img = Image.fromstring(mode, (self.width(), self.height()), self) if 'A' in mode: # Check the output format to see if it can handle an alpha channel. no_alpha_formats = ('jpg', 'bmp', 'eps', 'jpeg') if ((isinstance(filename, basestring) and os.path.splitext(filename)[1][1:] in no_alpha_formats) or (file_format.lower() in no_alpha_formats)): img = img.convert('RGB') img.save(filename, format=file_format, options=pil_options) cdef class CGImage: cdef CGImageRef image cdef void* data cdef readonly c_numpy.ndarray bmp_array def __cinit__(self, *args, **kwds): self.image = NULL property width: def __get__(self): return CGImageGetWidth(self.image) property height: def __get__(self): return CGImageGetHeight(self.image) property bits_per_component: def __get__(self): return CGImageGetBitsPerComponent(self.image) property bits_per_pixel: def __get__(self): return CGImageGetBitsPerPixel(self.image) property bytes_per_row: def __get__(self): return CGImageGetBytesPerRow(self.image) property alpha_info: def __get__(self): return CGImageGetAlphaInfo(self.image) property should_interpolate: def __get__(self): return CGImageGetShouldInterpolate(self.image) property is_mask: def __get__(self): return CGImageIsMask(self.image) def __init__(self, object size_or_array, bool grey_scale=0, int bits_per_component=8, int bytes_per_row=-1, alpha_info=kCGImageAlphaLast, int should_interpolate=1): cdef int bits_per_pixel cdef CGColorSpaceRef colorspace if hasattr(size_or_array, '__array_interface__'): # It's an array. arr = size_or_array typestr = arr.__array_interface__['typestr'] if typestr != '|u1': raise ValueError("expecting an array of unsigned bytes; got %r" % typestr) shape = arr.__array_interface__['shape'] if grey_scale: if (len(shape) == 3 and shape[-1] != 1) or (len(shape) != 2): raise ValueError("with grey_scale, expecting a shape " "(height, width) or (height, width, 1); got " "%r" % (shape,)) height, width = shape[:2] depth = 1 else: if len(shape) != 3 or shape[-1] not in (3, 4): raise ValueError("expecting a shape (height, width, depth) " "with depth either 3 or 4; got %r" % (shape,)) height, width, depth = shape if depth in (1, 3): alpha_info = kCGImageAlphaNone else: # Make a copy. arr = numpy.array(arr) alpha_info = kCGImageAlphaPremultipliedLast else: # It's a size tuple. width, height = size_or_array if grey_scale: lastdim = 1 alpha_info = kCGImageAlphaNone else: lastdim = 4 alpha_info = kCGImageAlphaPremultipliedLast arr = numpy.zeros((height, width, lastdim), dtype=numpy.uint8) self.bmp_array = arr Py_INCREF(self.bmp_array) self.data = c_numpy.PyArray_DATA(self.bmp_array) if grey_scale: alpha_info = kCGImageAlphaNone bits_per_component = 8 bits_per_pixel = 8 colorspace = CGColorSpaceCreateDeviceGray() elif bits_per_component == 5: alpha_info = kCGImageAlphaNoneSkipFirst bits_per_pixel = 16 colorspace = CGColorSpaceCreateDeviceRGB() elif bits_per_component == 8: if alpha_info in (kCGImageAlphaNoneSkipFirst, kCGImageAlphaNoneSkipLast, kCGImageAlphaPremultipliedFirst, kCGImageAlphaPremultipliedLast, kCGImageAlphaFirst, kCGImageAlphaLast, ): bits_per_pixel = 32 elif alpha_info == kCGImageAlphaNone: bits_per_pixel = 24 colorspace = CGColorSpaceCreateDeviceRGB() else: raise ValueError("bits_per_component must be 5 or 8") cdef int min_bytes min_bytes = (width*bits_per_pixel + 7) / 8 if bytes_per_row < min_bytes: bytes_per_row = min_bytes cdef CGDataProviderRef provider provider = CGDataProviderCreateWithData( NULL, self.data, c_numpy.PyArray_SIZE(self.bmp_array), NULL) if provider == NULL: raise RuntimeError("could not make provider") cdef CGColorSpaceRef space space = CGColorSpaceCreateDeviceRGB() self.image = CGImageCreate(width, height, bits_per_component, bits_per_pixel, bytes_per_row, space, alpha_info, provider, NULL, should_interpolate, kCGRenderingIntentDefault) CGColorSpaceRelease(space) CGDataProviderRelease(provider) if self.image == NULL: raise RuntimeError("could not make image") def __dealloc__(self): if self.image != NULL: CGImageRelease(self.image) self.image = NULL Py_XDECREF(self.bmp_array) cdef class CGImageFile(CGImage): def __init__(self, object image_or_filename, int should_interpolate=1): cdef int width, height, bits_per_component, bits_per_pixel, bytes_per_row cdef CGImageAlphaInfo alpha_info import Image import types if type(image_or_filename) is str: img = Image.open(image_or_filename) img.load() elif isinstance(image_or_filename, Image.Image): img = image_or_filename else: raise ValueError("need a PIL Image or a filename") width, height = img.size mode = img.mode if mode not in ["L", "RGB","RGBA"]: img = img.convert(mode="RGBA") mode = 'RGBA' bits_per_component = 8 if mode == 'RGB': bits_per_pixel = 24 alpha_info = kCGImageAlphaNone elif mode == 'RGBA': bits_per_pixel = 32 alpha_info = kCGImageAlphaPremultipliedLast elif mode == 'L': bits_per_pixel = 8 alpha_info = kCGImageAlphaNone bytes_per_row = (bits_per_pixel*width + 7)/ 8 cdef char* data cdef char* py_data cdef int dims[3] dims[0] = height dims[1] = width dims[2] = bits_per_pixel/bits_per_component self.bmp_array = c_numpy.PyArray_SimpleNew(3, &(dims[0]), c_numpy.NPY_UBYTE) data = self.bmp_array.data s = img.tostring() py_data = PyString_AsString(s) memcpy(data, py_data, len(s)) self.data = data cdef CGDataProviderRef provider provider = CGDataProviderCreateWithData( NULL, data, len(data), NULL) if provider == NULL: raise RuntimeError("could not make provider") cdef CGColorSpaceRef space space = CGColorSpaceCreateDeviceRGB() self.image = CGImageCreate(width, height, bits_per_component, bits_per_pixel, bytes_per_row, space, alpha_info, provider, NULL, should_interpolate, kCGRenderingIntentDefault) CGColorSpaceRelease(space) CGDataProviderRelease(provider) if self.image == NULL: raise RuntimeError("could not make image") def __dealloc__(self): if self.image != NULL: CGImageRelease(self.image) self.image = NULL Py_XDECREF(self.bmp_array) cdef class CGImageMask(CGImage): def __init__(self, char* data, int width, int height, int bits_per_component, int bits_per_pixel, int bytes_per_row, int should_interpolate=1): cdef CGDataProviderRef provider provider = CGDataProviderCreateWithData( NULL, data, len(data), NULL) if provider == NULL: raise RuntimeError("could not make provider") self.image = CGImageMaskCreate(width, height, bits_per_component, bits_per_pixel, bytes_per_row, provider, NULL, should_interpolate) CGDataProviderRelease(provider) if self.image == NULL: raise RuntimeError("could not make image") cdef class CGPDFDocument: cdef CGPDFDocumentRef document property number_of_pages: def __get__(self): return CGPDFDocumentGetNumberOfPages(self.document) property allows_copying: def __get__(self): return CGPDFDocumentAllowsCopying(self.document) property allows_printing: def __get__(self): return CGPDFDocumentAllowsPrinting(self.document) property is_encrypted: def __get__(self): return CGPDFDocumentIsEncrypted(self.document) property is_unlocked: def __get__(self): return CGPDFDocumentIsUnlocked(self.document) def __init__(self, char* filename): import os if not os.path.exists(filename) or not os.path.isfile(filename): raise ValueError("%s is not a file" % filename) cdef CFURLRef cfurl cfurl = url_from_filename(filename) self.document = CGPDFDocumentCreateWithURL(cfurl) CFRelease(cfurl) if self.document == NULL: raise RuntimeError("could not create CGPDFDocument") def unlock_with_password(self, char* password): return CGPDFDocumentUnlockWithPassword(self.document, password) def get_media_box(self, int page): cdef CGRect cgrect cgrect = CGPDFDocumentGetMediaBox(self.document, page) return (cgrect.origin.x, cgrect.origin.y, cgrect.size.width, cgrect.size.height) def get_crop_box(self, int page): cdef CGRect cgrect cgrect = CGPDFDocumentGetCropBox(self.document, page) return (cgrect.origin.x, cgrect.origin.y, cgrect.size.width, cgrect.size.height) def get_bleed_box(self, int page): cdef CGRect cgrect cgrect = CGPDFDocumentGetBleedBox(self.document, page) return (cgrect.origin.x, cgrect.origin.y, cgrect.size.width, cgrect.size.height) def get_trim_box(self, int page): cdef CGRect cgrect cgrect = CGPDFDocumentGetTrimBox(self.document, page) return (cgrect.origin.x, cgrect.origin.y, cgrect.size.width, cgrect.size.height) def get_art_box(self, int page): cdef CGRect cgrect cgrect = CGPDFDocumentGetArtBox(self.document, page) return (cgrect.origin.x, cgrect.origin.y, cgrect.size.width, cgrect.size.height) def get_rotation_angle(self, int page): cdef int angle angle = CGPDFDocumentGetRotationAngle(self.document, page) if angle == 0: raise ValueError("page %d does not exist" % page) def __dealloc__(self): if self.document != NULL: CGPDFDocumentRelease(self.document) self.document = NULL cdef CGDataProviderRef CGDataProviderFromFilename(char* string) except NULL: cdef CFURLRef cfurl cdef CGDataProviderRef result cfurl = url_from_filename(string) if cfurl == NULL: raise RuntimeError("could not create CFURLRef") result = CGDataProviderCreateWithURL(cfurl) CFRelease(cfurl) if result == NULL: raise RuntimeError("could not create CGDataProviderRef") return result cdef class CGAffine: cdef CGAffineTransform real_transform property a: def __get__(self): return self.real_transform.a def __set__(self, float value): self.real_transform.a = value property b: def __get__(self): return self.real_transform.b def __set__(self, float value): self.real_transform.b = value property c: def __get__(self): return self.real_transform.c def __set__(self, float value): self.real_transform.c = value property d: def __get__(self): return self.real_transform.d def __set__(self, float value): self.real_transform.d = value property tx: def __get__(self): return self.real_transform.tx def __set__(self, float value): self.real_transform.tx = value property ty: def __get__(self): return self.real_transform.ty def __set__(self, float value): self.real_transform.ty = value def __init__(self, float a=1.0, float b=0.0, float c=0.0, float d=1.0, float tx=0.0, float ty=0.0): self.real_transform = CGAffineTransformMake(a,b,c,d,tx,ty) def translate(self, float tx, float ty): self.real_transform = CGAffineTransformTranslate(self.real_transform, tx, ty) return self def rotate(self, float angle): self.real_transform = CGAffineTransformRotate(self.real_transform, angle) return self def scale(self, float sx, float sy): self.real_transform = CGAffineTransformScale(self.real_transform, sx, sy) return self def invert(self): self.real_transform = CGAffineTransformInvert(self.real_transform) return self def concat(self, CGAffine other not None): self.real_transform = CGAffineTransformConcat(self.real_transform, other.real_transform) return self def __mul__(CGAffine x not None, CGAffine y not None): cdef CGAffineTransform new_transform new_transform = CGAffineTransformConcat(x.real_transform, y.real_transform) new_affine = CGAffine() set_affine_transform(new_affine, new_transform) return new_affine cdef void init_from_cgaffinetransform(self, CGAffineTransform t): self.real_transform = t def __div__(CGAffine x not None, CGAffine y not None): cdef CGAffineTransform new_transform new_transform = CGAffineTransformInvert(y.real_transform) new_affine = CGAffine() set_affine_transform(new_affine, CGAffineTransformConcat(x.real_transform, new_transform)) return new_affine def apply_to_point(self, float x, float y): cdef CGPoint oldpoint oldpoint = CGPointMake(x, y) cdef CGPoint newpoint newpoint = CGPointApplyAffineTransform(oldpoint, self.real_transform) return newpoint.x, newpoint.y def apply_to_size(self, float width, float height): cdef CGSize oldsize oldsize = CGSizeMake(width, height) cdef CGSize newsize newsize = CGSizeApplyAffineTransform(oldsize, self.real_transform) return newsize.width, newsize.height def __repr__(self): return "CGAffine(%r, %r, %r, %r, %r, %r)" % (self.a, self.b, self.c, self.d, self.tx, self.ty) def as_matrix(self): return ((self.a, self.b, 0.0), (self.c, self.d, 0.0), (self.tx,self.ty,1.0)) cdef set_affine_transform(CGAffine t, CGAffineTransform newt): t.init_from_cgaffinetransform(newt) ##cdef class Point: ## cdef CGPoint real_point ## ## property x: ## def __get__(self): ## return self.real_point.x ## def __set__(self, float value): ## self.real_point.x = value ## ## property y: ## def __get__(self): ## return self.real_point.y ## def __set__(self, float value): ## self.real_point.y = value ## ## def __init__(self, float x, float y): ## self.real_point = CGPointMake(x, y) ## ## def apply_transform(self, CGAffine transform not None): ## self.real_point = CGPointApplyTransform(self.real_point, ## transform.real_transform) cdef class Rect: cdef CGRect real_rect property x: def __get__(self): return self.real_rect.origin.x def __set__(self, float value): self.real_rect.origin.x = value property y: def __get__(self): return self.real_rect.origin.y def __set__(self, float value): self.real_rect.origin.y = value property width: def __get__(self): return self.real_rect.size.width def __set__(self, float value): self.real_rect.size.width = value property height: def __get__(self): return self.real_rect.size.height def __set__(self, float value): self.real_rect.size.height = value property min_x: def __get__(self): return CGRectGetMinX(self.real_rect) property max_x: def __get__(self): return CGRectGetMaxX(self.real_rect) property min_y: def __get__(self): return CGRectGetMinY(self.real_rect) property max_y: def __get__(self): return CGRectGetMaxY(self.real_rect) property mid_x: def __get__(self): return CGRectGetMidX(self.real_rect) property mid_y: def __get__(self): return CGRectGetMidY(self.real_rect) property is_null: def __get__(self): return CGRectIsNull(self.real_rect) property is_empty: def __get__(self): return CGRectIsEmpty(self. real_rect) def __init__(self, float x=0.0, float y=0.0, float width=0.0, float height=0.0): self.real_rect = CGRectMake(x,y,width,height) def intersects(self, Rect other not None): return CGRectIntersectsRect(self.real_rect, other.real_rect) def contains_rect(self, Rect other not None): return CGRectContainsRect(self.real_rect, other.real_rect) def contains_point(self, float x, float y): return CGRectContainsPoint(self.real_rect, CGPointMake(x,y)) def __richcmp__(Rect x not None, Rect y not None, int op): if op == 2: return CGRectEqualToRect(x.real_rect, y.real_rect) elif op == 3: return not CGRectEqualToRect(x.real_rect, y.real_rect) else: raise NotImplementedError("only (in)equality can be tested") def standardize(self): self.real_rect = CGRectStandardize(self.real_rect) return self def inset(self, float x, float y): cdef CGRect new_rect new_rect = CGRectInset(self.real_rect, x, y) rect = Rect() set_rect(rect, new_rect) return rect def offset(self, float x, float y): cdef CGRect new_rect new_rect = CGRectOffset(self.real_rect, x, y) rect = Rect() set_rect(rect, new_rect) return rect def integral(self): self.real_rect = CGRectIntegral(self.real_rect) return self def __add__(Rect x not None, Rect y not None): cdef CGRect new_rect new_rect = CGRectUnion(x.real_rect, y.real_rect) rect = Rect() set_rect(rect, new_rect) return rect def union(self, Rect other not None): cdef CGRect new_rect new_rect = CGRectUnion(self.real_rect, other.real_rect) rect = Rect() set_rect(rect, new_rect) return rect def intersection(self, Rect other not None): cdef CGRect new_rect new_rect = CGRectIntersection(self.real_rect, other.real_rect) rect = Rect() set_rect(rect, new_rect) return rect def divide(self, float amount, edge): cdef CGRect slice cdef CGRect remainder CGRectDivide(self.real_rect, &slice, &remainder, amount, edge) pyslice = Rect() set_rect(pyslice, slice) pyrem = Rect() set_rect(pyrem, remainder) return pyslice, pyrem cdef init_from_cgrect(self, CGRect cgrect): self.real_rect = cgrect def __repr__(self): return "Rect(%r, %r, %r, %r)" % (self.x, self.y, self.width, self.height) cdef set_rect(Rect pyrect, CGRect cgrect): pyrect.init_from_cgrect(cgrect) cdef class CGMutablePath: cdef CGMutablePathRef path def __init__(self, CGMutablePath path=None): if path is not None: self.path = CGPathCreateMutableCopy(path.path) else: self.path = CGPathCreateMutable() def begin_path(self): return def move_to(self, float x, float y, CGAffine transform=None): cdef CGAffineTransform *ptr ptr = NULL if transform is not None: ptr = &(transform.real_transform) CGPathMoveToPoint(self.path, ptr, x, y) def arc(self, float x, float y, float r, float startAngle, float endAngle, bool clockwise=False, CGAffine transform=None): cdef CGAffineTransform *ptr ptr = NULL if transform is not None: ptr = &(transform.real_transform) CGPathAddArc(self.path, ptr, x, y, r, startAngle, endAngle, clockwise) def arc_to(self, float x1, float y1, float x2, float y2, float r, CGAffine transform=None): cdef CGAffineTransform *ptr ptr = NULL if transform is not None: ptr = &(transform.real_transform) CGPathAddArcToPoint(self.path, ptr, x1,y1, x2,y2, r) def curve_to(self, float cx1, float cy1, float cx2, float cy2, float x, float y, CGAffine transform=None): cdef CGAffineTransform *ptr ptr = NULL if transform is not None: ptr = &(transform.real_transform) CGPathAddCurveToPoint(self.path, ptr, cx1, cy1, cx2, cy2, x, y) def line_to(self, float x, float y, CGAffine transform=None): cdef CGAffineTransform *ptr ptr = NULL if transform is not None: ptr = &(transform.real_transform) CGPathAddLineToPoint(self.path, ptr, x, y) def lines(self, points, CGAffine transform=None): cdef CGAffineTransform *ptr ptr = NULL if transform is not None: ptr = &(transform.real_transform) cdef int n n = len(points) cdef int i CGPathMoveToPoint(self.path, ptr, points[0][0], points[0][1]) for i from 1 <= i < n: CGPathAddLineToPoint(self.path, ptr, points[i][0], points[i][1]) def add_path(self, CGMutablePath other_path not None, CGAffine transform=None): cdef CGAffineTransform *ptr ptr = NULL if transform is not None: ptr = &(transform.real_transform) CGPathAddPath(self.path, ptr, other_path.path) def quad_curve_to(self, float cx, float cy, float x, float y, CGAffine transform=None): cdef CGAffineTransform *ptr ptr = NULL if transform is not None: ptr = &(transform.real_transform) CGPathAddQuadCurveToPoint(self.path, ptr, cx, cy, x, y) def rect(self, float x, float y, float sx, float sy, CGAffine transform=None): cdef CGAffineTransform *ptr ptr = NULL if transform is not None: ptr = &(transform.real_transform) CGPathAddRect(self.path, ptr, CGRectMake(x,y,sx,sy)) def rects(self, rects, CGAffine transform=None): cdef CGAffineTransform *ptr ptr = NULL if transform is not None: ptr = &(transform.real_transform) cdef int n n = len(rects) cdef int i for i from 0 <= i < n: CGPathAddRect(self.path, ptr, CGRectMakeFromPython(rects[i])) def close_path(self): CGPathCloseSubpath(self.path) def is_empty(self): return CGPathIsEmpty(self.path) def get_current_point(self): cdef CGPoint point point = CGPathGetCurrentPoint(self.path) return point.x, point.y def get_bounding_box(self): cdef CGRect rect rect = CGPathGetBoundingBox(self.path) return (rect.origin.x, rect.origin.y, rect.size.width, rect.size.height) def __richcmp__(CGMutablePath x not None, CGMutablePath y not None, int op): if op == 2: # testing for equality return CGPathEqualToPath(x.path, y.path) elif op == 3: # testing for inequality return not CGPathEqualToPath(x.path, y.path) else: raise NotImplementedError("only (in)equality tests are allowed") def __dealloc__(self): if self.path != NULL: CGPathRelease(self.path) self.path = NULL cdef class _Markers: def get_marker(self, int marker_type, float size=1.0): """ Return the CGMutablePath corresponding to the given marker enumeration. Marker.get_marker(marker_type, size=1.0) Parameters ---------- marker_type : int One of the enumerated marker types in kiva.constants. size : float, optional The linear size in points of the marker. Some markers (e.g. dot) ignore this. Returns ------- path : CGMutablePath """ if marker_type == constants.NO_MARKER: return CGMutablePath() elif marker_type == constants.SQUARE_MARKER: return self.square(size) elif marker_type == constants.DIAMOND_MARKER: return self.diamond(size) elif marker_type == constants.CIRCLE_MARKER: return self.circle(size) elif marker_type == constants.CROSSED_CIRCLE_MARKER: raise NotImplementedError elif marker_type == constants.CROSS_MARKER: return self.cross(size) elif marker_type == constants.TRIANGLE_MARKER: raise NotImplementedError elif marker_type == constants.INVERTED_TRIANGLE_MARKER: raise NotImplementedError elif marker_type == constants.PLUS_MARKER: raise NotImplementedError elif marker_type == constants.DOT_MARKER: raise NotImplementedError elif marker_type == constants.PIXEL_MARKER: raise NotImplementedError def square(self, float size): cdef float half half = size / 2 m = CGMutablePath() m.rect(-half,-half,size,size) return m def diamond(self, float size): cdef float half half = size / 2 m = CGMutablePath() m.move_to(0.0, -half) m.line_to(-half, 0.0) m.line_to(0.0, half) m.line_to(half, 0.0) m.close_path() return m def x(self, float size): cdef float half half = size / 2 m = CGMutablePath() m.move_to(-half,-half) m.line_to(half,half) m.move_to(-half,half) m.line_to(half,-half) return m def cross(self, float size): cdef float half half = size / 2 m = CGMutablePath() m.move_to(0.0, -half) m.line_to(0.0, half) m.move_to(-half, 0.0) m.line_to(half, 0.0) return m def dot(self): m = CGMutablePath() m.rect(-0.5,-0.5,1.0,1.0) return m def circle(self, float size): cdef float half half = size / 2 m = CGMutablePath() m.arc(0.0, 0.0, half, 0.0, 6.2831853071795862, 1) return m Markers = _Markers() cdef class ShadingFunction: cdef CGFunctionRef function cdef void _setup_function(self, CGFunctionEvaluateCallback callback): cdef int i cdef CGFunctionCallbacks callbacks callbacks.version = 0 callbacks.releaseInfo = NULL callbacks.evaluate = callback cdef float domain_bounds[2] cdef float range_bounds[8] domain_bounds[0] = 0.0 domain_bounds[1] = 1.0 for i from 0 <= i < 4: range_bounds[2*i] = 0.0 range_bounds[2*i+1] = 1.0 self.function = CGFunctionCreate(self, 1, domain_bounds, 4, range_bounds, &callbacks) if self.function == NULL: raise RuntimeError("could not make CGFunctionRef") cdef void shading_callback(object self, float* in_data, float* out_data): cdef int i out = self(in_data[0]) for i from 0 <= i < self.n_dims: out_data[i] = out[i] cdef class Shading: cdef CGShadingRef shading cdef public object function cdef int n_dims def __init__(self, ShadingFunction func not None): raise NotImplementedError("use AxialShading or RadialShading") def __dealloc__(self): if self.shading != NULL: CGShadingRelease(self.shading) cdef class AxialShading(Shading): def __init__(self, ShadingFunction func not None, object start, object end, int extend_start=0, int extend_end=0): self.n_dims = 4 cdef CGPoint start_point, end_point start_point = CGPointMake(start[0], start[1]) end_point = CGPointMake(end[0], end[1]) self.function = func cdef CGColorSpaceRef space space = CGColorSpaceCreateDeviceRGB() self.shading = CGShadingCreateAxial(space, start_point, end_point, func.function, extend_start, extend_end) CGColorSpaceRelease(space) if self.shading == NULL: raise RuntimeError("could not make CGShadingRef") cdef class RadialShading(Shading): def __init__(self, ShadingFunction func not None, object start, float start_radius, object end, float end_radius, int extend_start=0, int extend_end=0): self.n_dims = 4 cdef CGPoint start_point, end_point start_point = CGPointMake(start[0], start[1]) end_point = CGPointMake(end[0], end[1]) self.function = func cdef CGColorSpaceRef space space = CGColorSpaceCreateDeviceRGB() self.shading = CGShadingCreateRadial(space, start_point, start_radius, end_point, end_radius, func.function, extend_start, extend_end) CGColorSpaceRelease(space) if self.shading == NULL: raise RuntimeError("could not make CGShadingRef") cdef void safe_free(void* mem): if mem != NULL: PyMem_Free(mem) cdef class PiecewiseLinearColorFunction(ShadingFunction): cdef int num_stops cdef float* stops cdef float* red cdef float* green cdef float* blue cdef float* alpha def __init__(self, object stop_colors): cdef c_numpy.ndarray stop_array cdef int i stop_colors = numpy.array(stop_colors).astype(numpy.float32) if not (4 <= stop_colors.shape[0] <= 5) or len(stop_colors.shape) != 2: raise ValueError("need array [stops, red, green, blue[, alpha]]") if stop_colors[0,0] != 0.0 or stop_colors[0,-1] != 1.0: raise ValueError("stops need to start with 0.0 and end with 1.0") if not numpy.greater_equal(numpy.diff(stop_colors[0]), 0.0).all(): raise ValueError("stops must be sorted and unique") self.num_stops = stop_colors.shape[1] self.stops = PyMem_Malloc(sizeof(float)*self.num_stops) self.red = PyMem_Malloc(sizeof(float)*self.num_stops) self.green = PyMem_Malloc(sizeof(float)*self.num_stops) self.blue = PyMem_Malloc(sizeof(float)*self.num_stops) self.alpha = PyMem_Malloc(sizeof(float)*self.num_stops) has_alpha = stop_colors.shape[0] == 5 for i from 0 <= i < self.num_stops: self.stops[i] = stop_colors[0,i] self.red[i] = stop_colors[1,i] self.green[i] = stop_colors[2,i] self.blue[i] = stop_colors[3,i] if has_alpha: self.alpha[i] = stop_colors[4,i] else: self.alpha[i] = 1.0 self._setup_function(piecewise_callback) def dump(self): cdef int i print 'PiecewiseLinearColorFunction' print ' num_stops = %i' % self.num_stops print ' stops = ', for i from 0 <= i < self.num_stops: print self.stops[i], print print ' red = ', for i from 0 <= i < self.num_stops: print self.red[i], print print ' green = ', for i from 0 <= i < self.num_stops: print self.green[i], print print ' blue = ', for i from 0 <= i < self.num_stops: print self.blue[i], print print ' alpha = ', for i from 0 <= i < self.num_stops: print self.alpha[i], print def __dealloc__(self): safe_free(self.stops) safe_free(self.red) safe_free(self.green) safe_free(self.blue) safe_free(self.alpha) cdef int bisect_left(PiecewiseLinearColorFunction self, float t): cdef int lo, hi, mid cdef float stop hi = self.num_stops lo = 0 while lo < hi: mid = (lo + hi)/2 stop = self.stops[mid] if t < stop: hi = mid else: lo = mid + 1 return lo cdef void piecewise_callback(void* obj, float* t, float* out): cdef int i cdef float eps cdef PiecewiseLinearColorFunction self self = obj eps = 1e-6 if fabs(t[0]) < eps: out[0] = self.red[0] out[1] = self.green[0] out[2] = self.blue[0] out[3] = self.alpha[0] return if fabs(t[0] - 1.0) < eps: i = self.num_stops - 1 out[0] = self.red[i] out[1] = self.green[i] out[2] = self.blue[i] out[3] = self.alpha[i] return i = bisect_left(self, t[0]) cdef float f, g, dx dx = self.stops[i] - self.stops[i-1] if dx > eps: f = (t[0]-self.stops[i-1])/dx else: f = 1.0 g = 1.0 - f out[0] = f*self.red[i] + g*self.red[i-1] out[1] = f*self.green[i] + g*self.green[i-1] out[2] = f*self.blue[i] + g*self.blue[i-1] out[3] = f*self.alpha[i] + g*self.alpha[i-1] cdef double _point_distance(double x1, double y1, double x2, double y2): cdef double dx = x1-x2 cdef double dy = y1-y2 return sqrt(dx*dx+dy*dy) cdef bool _cgrect_within_circle(CGRect rect, double cx, double cy, double rad): cdef double d1 = _point_distance(cx,cy, rect.origin.x, rect.origin.y) cdef double d2 = _point_distance(cx,cy, rect.origin.x+rect.size.width, rect.origin.y) cdef double d3 = _point_distance(cx,cy, rect.origin.x+rect.size.width, rect.origin.y+rect.size.height) cdef double d4 = _point_distance(cx,cy, rect.origin.x, rect.origin.y+rect.size.height) return (d1c_ps_name, len(postscript_name), kFontPostscriptName, kFontNoPlatformCode, kFontNoScriptCode, kFontNoLanguageCode, &atsu_font) if err: return NULL # Set the ATSU font in the attribute arrays. attr_tags[0] = kATSUFontTag attr_sizes[0] = sizeof(ATSUFontID) attr_values[0] = &atsu_font # Set the font size in the attribute arrays. attr_tags[1] = kATSUSizeTag attr_sizes[1] = sizeof(Fixed) attr_values[1] = &atsu_size # Create the ATSU style. err = ATSUCreateStyle(&atsu_style) if err: if atsu_style != NULL: ATSUDisposeStyle(atsu_style) return NULL # Set the style attributes. err = ATSUSetAttributes(atsu_style, 2, attr_tags, attr_sizes, attr_values) if err: if atsu_style != NULL: ATSUDisposeStyle(atsu_style) return NULL return atsu_style cdef object _create_atsu_layout(object the_string, ATSUStyle style, ATSUTextLayout* layout): cdef ATSUTextLayout atsu_layout cdef CFIndex text_length cdef OSStatus err cdef UniChar *uni_buffer cdef CFRange uni_range cdef CFStringRef cf_string cdef char* c_string layout[0] = atsu_layout = NULL if len(the_string) == 0: return err = noErr the_string = the_string.encode('utf-8') c_string = PyString_AsString(the_string) cf_string = CFStringCreateWithCString(NULL, c_string, kCFStringEncodingUTF8) text_length = CFStringGetLength(cf_string) # Extract the Unicode data from the CFStringRef. uni_range = CFRangeMake(0, text_length) uni_buffer = PyMem_Malloc(text_length * sizeof(UniChar)) if uni_buffer == NULL: raise MemoryError("could not allocate %d bytes of memory" % (text_length * sizeof(UniChar))) CFStringGetCharacters(cf_string, uni_range, uni_buffer) # Create the ATSUI layout. err = ATSUCreateTextLayoutWithTextPtr(uni_buffer, 0, text_length, text_length, 1, &text_length, &style, &atsu_layout) if err: PyMem_Free(uni_buffer) raise RuntimeError("could not create an ATSUI layout") layout[0] = atsu_layout return cdef object _set_cgcontext_for_layout(CGContextRef context, ATSUTextLayout layout): cdef ATSUAttributeTag tag cdef ByteCount size cdef ATSUAttributeValuePtr value cdef OSStatus err tag = kATSUCGContextTag size = sizeof(CGContextRef) value = &context err = ATSUSetLayoutControls(layout, 1, &tag, &size, &value) if err: raise RuntimeError("could not assign the CGContextRef to the ATSUTextLayout") return #### EOF ####################################################################### enthought-chaco2-4.1.0.orig/kiva/quartz/CoreFoundation.pxi0000644000175000017500000000351011674463636022625 0ustar varunvarun# :Author: Robert Kern # :Copyright: 2004, Enthought, Inc. # :License: BSD Style cdef extern from "CoreFoundation/CoreFoundation.h": ctypedef int OSStatus cdef enum: noErr ctypedef enum CFStringEncoding: kCFStringEncodingMacRoman = 0 kCFStringEncodingWindowsLatin1 = 0x0500 kCFStringEncodingISOLatin1 = 0x0201 kCFStringEncodingNextStepLatin = 0x0B01 kCFStringEncodingASCII = 0x0600 kCFStringEncodingUnicode = 0x0100 kCFStringEncodingUTF8 = 0x08000100 kCFStringEncodingNonLossyASCII = 0x0BFF ctypedef unsigned char UInt8 ctypedef unsigned short UniChar ctypedef int bool ctypedef bool Boolean ctypedef void* CFTypeRef ctypedef unsigned int CFTypeID ctypedef CFTypeRef CFStringRef ctypedef unsigned int CFIndex ctypedef struct CFRange: CFIndex location CFIndex length CFRange CFRangeMake(CFIndex location, CFIndex length) CFStringRef CFStringCreateWithCString(void* alloc, char* cStr, CFStringEncoding encoding) char* CFStringGetCStringPtr(CFStringRef string, CFStringEncoding encoding) Boolean CFStringGetCString(CFStringRef theString, char* buffer, CFIndex bufferSize, CFStringEncoding encoding) void CFRelease(CFTypeRef cf) CFIndex CFStringGetLength(CFStringRef theString) void CFStringGetCharacters(CFStringRef theString, CFRange range, UniChar *buffer) ctypedef enum CFURLPathStyle: kCFURLPOSIXPathStyle = 0 kCFURLHFSPathStyle = 1 kCFURLWindowsPathStyle = 2 ctypedef CFTypeRef CFURLRef CFURLRef CFURLCreateWithFileSystemPath(void* allocator, CFStringRef filePath, CFURLPathStyle pathStyle, bool isDirectory) void CFShow(CFTypeRef cf) CFTypeID CFGetTypeID(CFTypeRef cf) ctypedef CFTypeRef CFDictionaryRef enthought-chaco2-4.1.0.orig/kiva/fonttools/0000755000175000017500000000000011674463636017666 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/fonttools/sstruct.py0000644000175000017500000001726711674463636021764 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()... __version__ = "1.2" __copyright__ = "Copyright 1998, Just van Rossum " import struct import re import types error = "sstruct.error" def pack(format, object): formatstring, names, fixes = getformat(format) elements = [] if type(object) is not types.DictType: object = object.__dict__ for name in names: value = object[name] if fixes.has_key(name): # 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, object=None): if object is None: object = {} formatstring, names, fixes = getformat(format) if type(object) is types.DictType: dict = object else: dict = object.__dict__ elements = struct.unpack(formatstring, data) for i in range(len(names)): name = names[i] value = elements[i] if fixes.has_key(name): # fixed point conversion value = value / fixes[name] dict[name] = value return object def unpack2(format, data, object=None): length = calcsize(format) return unpack(format, data[:length], object), data[length:] def calcsize(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 "\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): 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 error, "a special format char must be first" else: m = _elementRE.match(line) if not m: raise error, "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]: raise error, "fixed point must be 8, 16 or 32 bits long" 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 def _test(): 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 """ print 'size:', calcsize(format) class foo: pass i = foo() i.ashort = 0x7fff i.along = 0x7fffffff i.abyte = 0x7f i.achar = "a" i.astr = "12345" i.afloat = 0.5 i.adouble = 0.5 i.afixed = 1.5 data = pack(format, i) print 'data:', `data` print unpack(format, data) i2 = foo() unpack(format, data, i2) print vars(i2) if __name__ == "__main__": _test() enthought-chaco2-4.1.0.orig/kiva/fonttools/__init__.py0000644000175000017500000000004311674463636021774 0ustar varunvarunfrom font import Font, str_to_font enthought-chaco2-4.1.0.orig/kiva/fonttools/font.py0000644000175000017500000001270511674463636021213 0ustar varunvarun""" Defines the Kiva Font class and a utility method to parse free-form font specification strings into Font instances. """ 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 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 ) 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): return "Font(size=%d,family=%d,weight=%d, style=%d, face_name='%s',encoding=%d )" % \ (self.size, self.family, self.weight, self.style, self.face_name, self.encoding) enthought-chaco2-4.1.0.orig/kiva/fonttools/afm.py0000644000175000017500000002624611674463636021015 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 """ import sys, os #Convert string the 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): if s.lower().strip() in ('false', '0', 'no'): return False else: return True 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 1: line = fh.readline() if not line: break line = line.rstrip() if line.startswith('Comment'): continue lst = line.split( ' ', 1 ) #print '%-s\t%-d line :: %-s' % ( fh.name, len(lst), line ) key = lst[0] if len( lst ) == 2: val = lst[1] else: val = '' #key, val = line.split(' ', 1) try: d[key] = headerConverters[key](val) except ValueError: print >>sys.stderr, 'Value error parsing header in AFM:', key, val continue except KeyError: print >>sys.stderr, '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, numParts = cc[1], _to_int(cc[2]) 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 optional.has_key(key): 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: 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 thisminmaxy: maxy = thismax # find the min y thismin = b if thismin> 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.1.0.orig/kiva/fonttools/fontTools/0000755000175000017500000000000011674463636021655 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/fonttools/fontTools/LICENSE.txt0000644000175000017500000000207711674463636023506 0ustar varunvarunCopyright 1999-2002 by Just van Rossum, Letterror, The Netherlands. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the names of Just van Rossum or Letterror not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. JUST VAN ROSSUM AND LETTERROR DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL JUST VAN ROSSUM OR LETTERROR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. just@letterror.com enthought-chaco2-4.1.0.orig/kiva/fonttools/fontTools/__init__.py0000644000175000017500000000002211674463636023760 0ustar varunvarunversion = "2.0b1" enthought-chaco2-4.1.0.orig/kiva/fonttools/fontTools/misc/0000755000175000017500000000000011674463636022610 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/fonttools/fontTools/misc/__init__.py0000644000175000017500000000022311674463636024716 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.1.0.orig/kiva/fonttools/fontTools/misc/textTools.py0000644000175000017500000000526211674463636025174 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.1.0.orig/kiva/fonttools/fontTools/ttLib/0000755000175000017500000000000011674463636022733 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/fonttools/fontTools/ttLib/tables/0000755000175000017500000000000011674463636024205 5ustar varunvarunenthought-chaco2-4.1.0.orig/kiva/fonttools/fontTools/ttLib/tables/__init__.py0000644000175000017500000000204711674463636026321 0ustar varunvarundef _moduleFinderHint(): """Dummy function to let modulefinder know what tables may be dynamically imported. Generated by MetaTools/buildTableList.py. """ ## import B_A_S_E_ ## import C_F_F_ ## import D_S_I_G_ ## import G_D_E_F_ ## import G_P_O_S_ ## import G_S_U_B_ ## import J_S_T_F_ ## import L_T_S_H_ ## import O_S_2f_2 ## import T_S_I_B_ ## import T_S_I_D_ ## import T_S_I_J_ ## import T_S_I_P_ ## import T_S_I_S_ ## import T_S_I_V_ ## import T_S_I__0 ## import T_S_I__1 ## import T_S_I__2 ## import T_S_I__3 ## import T_S_I__5 ## import _c_m_a_p ## import _c_v_t ## import _f_p_g_m ## import _g_a_s_p ## import _g_l_y_f ## import _h_d_m_x ## import _h_e_a_d ## import _h_h_e_a ## import _h_m_t_x ## import _k_e_r_n ## import _l_o_c_a ## import _m_a_x_p import _n_a_m_e ## import _p_o_s_t ## import _p_r_e_p ## import _v_h_e_a ## import _v_m_t_x enthought-chaco2-4.1.0.orig/kiva/fonttools/fontTools/ttLib/tables/DefaultTable.py0000644000175000017500000000254111674463636027115 0ustar varunvarunimport string import sys class DefaultTable: dependencies = [] def __init__(self, tag): self.tableTag = tag def decompile(self, data, ttFont): self.data = data def compile(self, ttFont): return self.data def toXML(self, writer, ttFont): if hasattr(self, "ERROR"): writer.comment("An error occurred during the decompilation of this table") writer.newline() writer.comment(self.ERROR) writer.newline() writer.begintag("hexdata") writer.newline() writer.dumphex(self.compile(ttFont)) writer.endtag("hexdata") writer.newline() def fromXML(self, (name, attrs, content), ttFont): from kiva.fonttools.fontTools.misc.textTools import readHex from kiva.fonttools.fontTools import ttLib if name <> "hexdata": raise ttLib.TTLibError, "can't handle '%s' element" % name self.decompile(readHex(content), ttFont) def __repr__(self): return "<'%s' table at %x>" % (self.tableTag, id(self)) def __cmp__(self, other): return cmp(self.__dict__, other.__dict__) enthought-chaco2-4.1.0.orig/kiva/fonttools/fontTools/ttLib/tables/_n_a_m_e.py0000644000175000017500000001547511674463636026307 0ustar varunvarunimport DefaultTable import struct from kiva.fonttools import sstruct from kiva.fonttools.fontTools.misc.textTools import safeEval import string import types nameRecordFormat = """ > # big endian platformID: H platEncID: H langID: H nameID: H length: H offset: H """ class table__n_a_m_e(DefaultTable.DefaultTable): def decompile(self, data, ttFont): format, n, stringoffset = struct.unpack(">HHH", data[:6]) stringoffset = int(stringoffset) stringData = data[stringoffset:] data = data[6:stringoffset] self.names = [] for i in range(n): name, data = sstruct.unpack2(nameRecordFormat, data, NameRecord()) name.fixLongs() name.string = stringData[name.offset:name.offset+name.length] assert len(name.string) == name.length #if (name.platEncID, name.platformID) in ((0, 0), (1, 3)): # if len(name.string) % 2: # print "2-byte string doesn't have even length!" # print name.__dict__ del name.offset, name.length self.names.append(name) def compile(self, ttFont): if not hasattr(self, "names"): # only happens when there are NO name table entries read # from the TTX file self.names = [] self.names.sort() # sort according to the spec; see NameRecord.__cmp__() stringData = "" format = 0 n = len(self.names) stringoffset = 6 + n * sstruct.calcsize(nameRecordFormat) data = struct.pack(">HHH", format, n, stringoffset) lastoffset = 0 done = {} # remember the data so we can reuse the "pointers" for name in self.names: if done.has_key(name.string): name.offset, name.length = done[name.string] else: name.offset, name.length = done[name.string] = len(stringData), len(name.string) stringData = stringData + name.string data = data + sstruct.pack(nameRecordFormat, name) return data + stringData def toXML(self, writer, ttFont): for name in self.names: name.toXML(writer, ttFont) def fromXML(self, (name, attrs, content), ttFont): if name <> "namerecord": return # ignore unknown tags if not hasattr(self, "names"): self.names = [] name = NameRecord() self.names.append(name) name.fromXML((name, attrs, content), ttFont) def getName(self, nameID, platformID, platEncID, langID=None): for namerecord in self.names: if ( namerecord.nameID == nameID and namerecord.platformID == platformID and namerecord.platEncID == platEncID): if langID is None or namerecord.langID == langID: return namerecord return None # not found def __cmp__(self, other): return cmp(self.names, other.names) class NameRecord: def toXML(self, writer, ttFont): writer.begintag("namerecord", [ ("nameID", self.nameID), ("platformID", self.platformID), ("platEncID", self.platEncID), ("langID", hex(self.langID)), ]) writer.newline() if self.platformID == 0 or (self.platformID == 3 and self.platEncID in (0, 1)): if len(self.string) % 2: # no, shouldn't happen, but some of the Apple # tools cause this anyway :-( writer.write16bit(self.string + "\0") else: writer.write16bit(self.string) else: writer.write8bit(self.string) writer.newline() writer.endtag("namerecord") writer.newline() def fromXML(self, (name, attrs, content), ttFont): self.nameID = safeEval(attrs["nameID"]) self.platformID = safeEval(attrs["platformID"]) self.platEncID = safeEval(attrs["platEncID"]) self.langID = safeEval(attrs["langID"]) if self.platformID == 0 or (self.platformID == 3 and self.platEncID in (0, 1)): s = "" for element in content: s = s + element s = unicode(s, "utf8") s = s.strip() self.string = s.encode("utf_16_be") else: s = string.strip(string.join(content, "")) self.string = unicode(s, "utf8").encode("latin1") def __cmp__(self, other): """Compare method, so a list of NameRecords can be sorted according to the spec by just sorting it...""" selftuple = (self.platformID, self.platEncID, self.langID, self.nameID, self.string) othertuple = (other.platformID, other.platEncID, other.langID, other.nameID, other.string) return cmp(selftuple, othertuple) def __repr__(self): return "" % ( self.nameID, self.platformID, self.langID) def fixLongs(self): """correct effects from bug in Python 1.5.1, where "H" returns a Python Long int. This has been fixed in Python 1.5.2. """ for attr in dir(self): val = getattr(self, attr) if type(val) == types.LongType: setattr(self, attr, int(val)) enthought-chaco2-4.1.0.orig/kiva/fonttools/fontTools/ttLib/__init__.py0000644000175000017500000007317011674463636025054 0ustar varunvarun"""fontTools.ttLib -- a package for dealing with TrueType fonts. This package offers translators to convert TrueType fonts to Python objects and vice versa, and additionally from Python to TTX (an XML-based text format) and vice versa. Example interactive session: Python 1.5.2c1 (#43, Mar 9 1999, 13:06:43) [CW PPC w/GUSI w/MSL] Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from kiva.fonttools.fontTools import ttLib >>> tt = ttLib.TTFont("afont.ttf") >>> tt['maxp'].numGlyphs 242 >>> tt['OS/2'].achVendID 'B&H\000' >>> tt['head'].unitsPerEm 2048 >>> tt.saveXML("afont.ttx") Dumping 'LTSH' table... Dumping 'OS/2' table... Dumping 'VDMX' table... Dumping 'cmap' table... Dumping 'cvt ' table... Dumping 'fpgm' table... Dumping 'glyf' table... Dumping 'hdmx' table... Dumping 'head' table... Dumping 'hhea' table... Dumping 'hmtx' table... Dumping 'loca' table... Dumping 'maxp' table... Dumping 'name' table... Dumping 'post' table... Dumping 'prep' table... >>> tt2 = ttLib.TTFont() >>> tt2.importXML("afont.ttx") >>> tt2['maxp'].numGlyphs 242 >>> """ # # $Id: __init__.py,v 1.36 2002/07/23 16:43:55 jvr Exp $ # import os import string import types class TTLibError(Exception): pass class TTFont: """The main font object. It manages file input and output, and offers a convenient way of accessing tables. Tables will be only decompiled when neccesary, ie. when they're actually accessed. This means that simple operations can be extremely fast. """ def __init__(self, file=None, res_name_or_index=None, sfntVersion="\000\001\000\000", checkChecksums=0, verbose=0, recalcBBoxes=1): """The constructor can be called with a few different arguments. When reading a font from disk, 'file' should be either a pathname pointing to a file, or a readable file object. It we're running on a Macintosh, 'res_name_or_index' maybe an sfnt resource name or an sfnt resource index number or zero. The latter case will cause TTLib to autodetect whether the file is a flat file or a suitcase. (If it's a suitcase, only the first 'sfnt' resource will be read!) The 'checkChecksums' argument is used to specify how sfnt checksums are treated upon reading a file from disk: - 0: don't check (default) - 1: check, print warnings if a wrong checksum is found - 2: check, raise an exception if a wrong checksum is found. The TTFont constructor can also be called without a 'file' argument: this is the way to create a new empty font. In this case you can optionally supply the 'sfntVersion' argument. If the recalcBBoxes argument is false, a number of things will *not* be recalculated upon save/compile: 1. glyph bounding boxes 2. maxp font bounding box 3. hhea min/max values (1) is needed for certain kinds of CJK fonts (ask Werner Lemberg ;-). Additionally, upon importing an TTX file, this option cause glyphs to be compiled right away. This should reduce memory consumption greatly, and therefore should have some impact on the time needed to parse/compile large fonts. """ import sfnt self.verbose = verbose self.recalcBBoxes = recalcBBoxes self.tables = {} self.reader = None if not file: self.sfntVersion = sfntVersion return if isinstance(file, basestring): if os.name == "mac" and res_name_or_index is not None: # on the mac, we deal with sfnt resources as well as flat files import macUtils if res_name_or_index == 0: if macUtils.getSFNTResIndices(file): # get the first available sfnt font. file = macUtils.SFNTResourceReader(file, 1) else: file = open(file, "rb") else: file = macUtils.SFNTResourceReader(file, res_name_or_index) else: file = open(file, "rb") else: pass # assume "file" is a readable file object self.reader = sfnt.SFNTReader(file, checkChecksums) self.sfntVersion = self.reader.sfntVersion def close(self): """If we still have a reader object, close it.""" if self.reader is not None: self.reader.close() def save(self, file, makeSuitcase=0): """Save the font to disk. Similarly to the constructor, the 'file' argument can be either a pathname or a writable file object. On the Mac, if makeSuitcase is true, a suitcase (resource fork) file will we made instead of a flat .ttf file. """ from kiva.fonttools.fontTools.ttLib import sfnt if isinstance(file, basestring): closeStream = 1 if os.name == "mac" and makeSuitcase: import macUtils file = macUtils.SFNTResourceWriter(file, self) else: file = open(file, "wb") if os.name == "mac": import macfs fss = macfs.FSSpec(file.name) fss.SetCreatorType('mdos', 'BINA') else: # assume "file" is a writable file object closeStream = 0 tags = self.keys() tags.remove("GlyphOrder") numTables = len(tags) writer = sfnt.SFNTWriter(file, numTables, self.sfntVersion) done = [] for tag in tags: self._writeTable(tag, writer, done) writer.close(closeStream) def saveXML(self, fileOrPath, progress=None, tables=None, skipTables=None, splitTables=0, disassembleInstructions=1): """Export the font as TTX (an XML-based text file), or as a series of text files when splitTables is true. In the latter case, the 'fileOrPath' argument should be a path to a directory. The 'tables' argument must either be false (dump all tables) or a list of tables to dump. The 'skipTables' argument may be a list of tables to skip, but only when the 'tables' argument is false. """ from kiva.fonttools.fontTools import version import xmlWriter self.disassembleInstructions = disassembleInstructions if not tables: tables = self.keys() if skipTables: for tag in skipTables: if tag in tables: tables.remove(tag) numTables = len(tables) numGlyphs = self['maxp'].numGlyphs if progress: progress.set(0, numTables) idlefunc = getattr(progress, "idle", None) else: idlefunc = None writer = xmlWriter.XMLWriter(fileOrPath, idlefunc=idlefunc) writer.begintag("ttFont", sfntVersion=`self.sfntVersion`[1:-1], ttLibVersion=version) writer.newline() if not splitTables: writer.newline() else: # 'fileOrPath' must now be a path path, ext = os.path.splitext(fileOrPath) fileNameTemplate = path + ".%s" + ext for i in range(numTables): if progress: progress.set(i) tag = tables[i] if splitTables: tablePath = fileNameTemplate % tagToIdentifier(tag) tableWriter = xmlWriter.XMLWriter(tablePath, idlefunc=idlefunc) tableWriter.begintag("ttFont", ttLibVersion=version) tableWriter.newline() tableWriter.newline() writer.simpletag(tagToXML(tag), src=os.path.basename(tablePath)) writer.newline() else: tableWriter = writer self._tableToXML(tableWriter, tag, progress) if splitTables: tableWriter.endtag("ttFont") tableWriter.newline() tableWriter.close() if progress: progress.set((i + 1)) writer.endtag("ttFont") writer.newline() writer.close() if self.verbose: debugmsg("Done dumping TTX") def _tableToXML(self, writer, tag, progress): if self.has_key(tag): table = self[tag] report = "Dumping '%s' table..." % tag else: report = "No '%s' table found." % tag if progress: progress.setLabel(report) elif self.verbose: debugmsg(report) else: print report if not self.has_key(tag): return xmlTag = tagToXML(tag) if hasattr(table, "ERROR"): writer.begintag(xmlTag, ERROR="decompilation error") else: writer.begintag(xmlTag) writer.newline() if tag in ("glyf", "CFF "): table.toXML(writer, self, progress) else: table.toXML(writer, self) writer.endtag(xmlTag) writer.newline() writer.newline() def importXML(self, file, progress=None): """Import a TTX file (an XML-based text format), so as to recreate a font object. """ if self.has_key("maxp") and self.has_key("post"): # Make sure the glyph order is loaded, as it otherwise gets # lost if the XML doesn't contain the glyph order, yet does # contain the table which was originally used to extract the # glyph names from (ie. 'post', 'cmap' or 'CFF '). self.getGlyphOrder() import xmlImport xmlImport.importXML(self, file, progress) def isLoaded(self, tag): """Return true if the table identified by 'tag' has been decompiled and loaded into memory.""" return self.tables.has_key(tag) def has_key(self, tag): if self.isLoaded(tag): return 1 elif self.reader and self.reader.has_key(tag): return 1 elif tag == "GlyphOrder": return 1 else: return 0 def keys(self): keys = self.tables.keys() if self.reader: for key in self.reader.keys(): if key not in keys: keys.append(key) keys.sort() if "GlyphOrder" in keys: keys.remove("GlyphOrder") return ["GlyphOrder"] + keys def __len__(self): return len(self.keys()) def __getitem__(self, tag): try: return self.tables[tag] except KeyError: if tag == "GlyphOrder": table = GlyphOrder(tag) self.tables[tag] = table return table if self.reader is not None: import traceback if self.verbose: debugmsg("Reading '%s' table from disk" % tag) data = self.reader[tag] tableClass = getTableClass(tag) table = tableClass(tag) self.tables[tag] = table if self.verbose: debugmsg("Decompiling '%s' table" % tag) try: table.decompile(data, self) except "_ _ F O O _ _": # dummy exception to disable exception catching print "An exception occurred during the decompilation of the '%s' table" % tag from tables.DefaultTable import DefaultTable import StringIO file = StringIO.StringIO() traceback.print_exc(file=file) table = DefaultTable(tag) table.ERROR = file.getvalue() self.tables[tag] = table table.decompile(data, self) return table else: raise KeyError, "'%s' table not found" % tag def __setitem__(self, tag, table): self.tables[tag] = table def __delitem__(self, tag): if not self.has_key(tag): raise KeyError, "'%s' table not found" % tag if self.tables.has_key(tag): del self.tables[tag] if self.reader and self.reader.has_key(tag): del self.reader[tag] def setGlyphOrder(self, glyphOrder): self.glyphOrder = glyphOrder def getGlyphOrder(self): try: return self.glyphOrder except AttributeError: pass if self.has_key('CFF '): cff = self['CFF '] if cff.haveGlyphNames(): self.glyphOrder = cff.getGlyphOrder() else: # CID-keyed font, use cmap self._getGlyphNamesFromCmap() elif self.has_key('post'): # TrueType font glyphOrder = self['post'].getGlyphOrder() if glyphOrder is None: # # No names found in the 'post' table. # Try to create glyph names from the unicode cmap (if available) # in combination with the Adobe Glyph List (AGL). # self._getGlyphNamesFromCmap() else: self.glyphOrder = glyphOrder else: self._getGlyphNamesFromCmap() return self.glyphOrder def _getGlyphNamesFromCmap(self): # # This is rather convoluted, but then again, it's an interesting problem: # - we need to use the unicode values found in the cmap table to # build glyph names (eg. because there is only a minimal post table, # or none at all). # - but the cmap parser also needs glyph names to work with... # So here's what we do: # - make up glyph names based on glyphID # - load a temporary cmap table based on those names # - extract the unicode values, build the "real" glyph names # - unload the temporary cmap table # if self.isLoaded("cmap"): # Bootstrapping: we're getting called by the cmap parser # itself. This means self.tables['cmap'] contains a partially # loaded cmap, making it impossible to get at a unicode # subtable here. We remove the partially loaded cmap and # restore it later. # This only happens if the cmap table is loaded before any # other table that does f.getGlyphOrder() or f.getGlyphName(). cmapLoading = self.tables['cmap'] del self.tables['cmap'] else: cmapLoading = None # Make up glyph names based on glyphID, which will be used by the # temporary cmap and by the real cmap in case we don't find a unicode # cmap. numGlyphs = int(self['maxp'].numGlyphs) glyphOrder = [None] * numGlyphs glyphOrder[0] = ".notdef" for i in range(1, numGlyphs): glyphOrder[i] = "glyph%.5d" % i # Set the glyph order, so the cmap parser has something # to work with (so we don't get called recursively). self.glyphOrder = glyphOrder # Get a (new) temporary cmap (based on the just invented names) tempcmap = self['cmap'].getcmap(3, 1) if tempcmap is not None: # we have a unicode cmap from kiva.fonttools.fontTools import agl cmap = tempcmap.cmap # create a reverse cmap dict reversecmap = {} for unicode, name in cmap.items(): reversecmap[name] = unicode allNames = {} for i in range(numGlyphs): tempName = glyphOrder[i] if reversecmap.has_key(tempName): unicode = reversecmap[tempName] if agl.UV2AGL.has_key(unicode): # get name from the Adobe Glyph List glyphName = agl.UV2AGL[unicode] else: # create uni name glyphName = "uni" + string.upper(string.zfill( hex(unicode)[2:], 4)) tempName = glyphName n = 1 while allNames.has_key(tempName): tempName = glyphName + "#" + `n` n = n + 1 glyphOrder[i] = tempName allNames[tempName] = 1 # Delete the temporary cmap table from the cache, so it can # be parsed again with the right names. del self.tables['cmap'] else: pass # no unicode cmap available, stick with the invented names self.glyphOrder = glyphOrder if cmapLoading: # restore partially loaded cmap, so it can continue loading # using the proper names. self.tables['cmap'] = cmapLoading def getGlyphNames(self): """Get a list of glyph names, sorted alphabetically.""" glyphNames = self.getGlyphOrder()[:] glyphNames.sort() return glyphNames def getGlyphNames2(self): """Get a list of glyph names, sorted alphabetically, but not case sensitive. """ from kiva.fonttools.fontTools.misc import textTools return textTools.caselessSort(self.getGlyphOrder()) def getGlyphName(self, glyphID): try: return self.getGlyphOrder()[glyphID] except IndexError: # XXX The ??.W8.otf font that ships with OSX uses higher glyphIDs in # the cmap table than there are glyphs. I don't think it's legal... return "glyph%.5d" % glyphID def getGlyphID(self, glyphName): if not hasattr(self, "_reverseGlyphOrderDict"): self._buildReverseGlyphOrderDict() glyphOrder = self.getGlyphOrder() d = self._reverseGlyphOrderDict if not d.has_key(glyphName): if glyphName in glyphOrder: self._buildReverseGlyphOrderDict() return self.getGlyphID(glyphName) else: raise KeyError, glyphName glyphID = d[glyphName] if glyphName <> glyphOrder[glyphID]: self._buildReverseGlyphOrderDict() return self.getGlyphID(glyphName) return glyphID def _buildReverseGlyphOrderDict(self): self._reverseGlyphOrderDict = d = {} glyphOrder = self.getGlyphOrder() for glyphID in range(len(glyphOrder)): d[glyphOrder[glyphID]] = glyphID def _writeTable(self, tag, writer, done): """Internal helper function for self.save(). Keeps track of inter-table dependencies. """ if tag in done: return tableClass = getTableClass(tag) for masterTable in tableClass.dependencies: if masterTable not in done: if self.has_key(masterTable): self._writeTable(masterTable, writer, done) else: done.append(masterTable) tabledata = self.getTableData(tag) if self.verbose: debugmsg("writing '%s' table to disk" % tag) writer[tag] = tabledata done.append(tag) def getTableData(self, tag): """Returns raw table data, whether compiled or directly read from disk. """ if self.isLoaded(tag): if self.verbose: debugmsg("compiling '%s' table" % tag) return self.tables[tag].compile(self) elif self.reader and self.reader.has_key(tag): if self.verbose: debugmsg("Reading '%s' table from disk" % tag) return self.reader[tag] else: raise KeyError, tag class GlyphOrder: """A pseudo table. The glyph order isn't in the font as a separate table, but it's nice to present it as such in the TTX format. """ def __init__(self, tag): pass def toXML(self, writer, ttFont): glyphOrder = ttFont.getGlyphOrder() writer.comment("The 'id' attribute is only for humans; " "it is ignored when parsed.") writer.newline() for i in range(len(glyphOrder)): glyphName = glyphOrder[i] writer.simpletag("GlyphID", id=i, name=glyphName) writer.newline() def fromXML(self, (name, attrs, content), ttFont): if not hasattr(self, "glyphOrder"): self.glyphOrder = [] ttFont.setGlyphOrder(self.glyphOrder) if name == "GlyphID": self.glyphOrder.append(attrs["name"]) def _test_endianness(): """Test the endianness of the machine. This is crucial to know since TrueType data is always big endian, even on little endian machines. There are quite a few situations where we explicitly need to swap some bytes. """ import struct data = struct.pack("h", 0x01) if data == "\000\001": return "big" elif data == "\001\000": return "little" else: assert 0, "endian confusion!" endian = _test_endianness() def getTableModule(tag): """Fetch the packer/unpacker module for a table. Return None when no module is found. """ import tables pyTag = tagToIdentifier(tag) try: module = __import__("kiva.fonttools.fontTools.ttLib.tables." + pyTag) except ImportError: return None else: return getattr(tables, pyTag) def getTableClass(tag): """Fetch the packer/unpacker class for a table. Return None when no class is found. """ module = getTableModule(tag) if module is None: from tables.DefaultTable import DefaultTable return DefaultTable pyTag = tagToIdentifier(tag) tableClass = getattr(module, "table_" + pyTag) return tableClass def newTable(tag): """Return a new instance of a table.""" tableClass = getTableClass(tag) return tableClass(tag) def _escapechar(c): """Helper function for tagToIdentifier()""" import re if re.match("[a-z0-9]", c): return "_" + c elif re.match("[A-Z]", c): return c + "_" else: return hex(ord(c))[2:] def tagToIdentifier(tag): """Convert a table tag to a valid (but UGLY) python identifier, as well as a filename that's guaranteed to be unique even on a caseless file system. Each character is mapped to two characters. Lowercase letters get an underscore before the letter, uppercase letters get an underscore after the letter. Trailing spaces are trimmed. Illegal characters are escaped as two hex bytes. If the result starts with a number (as the result of a hex escape), an extra underscore is prepended. Examples:: 'glyf' -> '_g_l_y_f' 'cvt ' -> '_c_v_t' 'OS/2' -> 'O_S_2f_2' """ import re if tag == "GlyphOrder": return tag assert len(tag) == 4, "tag should be 4 characters long" while len(tag) > 1 and tag[-1] == ' ': tag = tag[:-1] ident = "" for c in tag: ident = ident + _escapechar(c) if re.match("[0-9]", ident): ident = "_" + ident return ident def identifierToTag(ident): """the opposite of tagToIdentifier()""" if ident == "GlyphOrder": return ident if len(ident) % 2 and ident[0] == "_": ident = ident[1:] assert not (len(ident) % 2) tag = "" for i in range(0, len(ident), 2): if ident[i] == "_": tag = tag + ident[i+1] elif ident[i+1] == "_": tag = tag + ident[i] else: # assume hex tag = tag + chr(string.atoi(ident[i:i+2], 16)) # append trailing spaces tag = tag + (4 - len(tag)) * ' ' return tag def tagToXML(tag): """Similarly to tagToIdentifier(), this converts a TT tag to a valid XML element name. Since XML element names are case sensitive, this is a fairly simple/readable translation. """ import re if tag == "OS/2": return "OS_2" elif tag == "GlyphOrder": return "GlyphOrder" if re.match("[A-Za-z_][A-Za-z_0-9]* *$", tag): return string.strip(tag) else: return tagToIdentifier(tag) def xmlToTag(tag): """The opposite of tagToXML()""" if tag == "OS_2": return "OS/2" if len(tag) == 8: return identifierToTag(tag) else: return tag + " " * (4 - len(tag)) return tag def debugmsg(msg): import time print msg + time.strftime(" (%H:%M:%S)", time.localtime(time.time())) enthought-chaco2-4.1.0.orig/kiva/fonttools/fontTools/ttLib/sfnt.py0000644000175000017500000002366211674463636024270 0ustar varunvarun"""ttLib/sfnt.py -- low-level module to deal with the sfnt file format. Defines two public classes: SFNTReader SFNTWriter (Normally you don't have to use these classes explicitly; they are used automatically by ttLib.TTFont.) The reading and writing of sfnt files is separated in two distinct classes, since whenever to number of tables changes or whenever a table's length chages you need to rewrite the whole file anyway. """ import struct from kiva.fonttools import sstruct import numpy import os # magic value corresponding to 0xb1b0afba; used in lieu of the hex # constant to avoid signedness issues with python 2.4 CHECKSUM_MAGIC = -1313820742 class SFNTReader: def __init__(self, file, checkChecksums=1): self.file = file self.checkChecksums = checkChecksums data = self.file.read(sfntDirectorySize) if len(data) <> sfntDirectorySize: from kiva.fonttools.fontTools import ttLib raise ttLib.TTLibError, "Not a TrueType or OpenType font (not enough data)" sstruct.unpack(sfntDirectoryFormat, data, self) if self.sfntVersion not in ("\000\001\000\000", "OTTO", "true"): from kiva.fonttools.fontTools import ttLib raise ttLib.TTLibError, "Not a TrueType or OpenType font (bad sfntVersion)" self.tables = {} for i in range(self.numTables): entry = SFNTDirectoryEntry() entry.fromFile(self.file) if entry.length > 0: self.tables[entry.tag] = entry else: # Ignore zero-length tables. This doesn't seem to be documented, # yet it's apparently how the Windows TT rasterizer behaves. # Besides, at least one font has been sighted which actually # *has* a zero-length table. pass def has_key(self, tag): return self.tables.has_key(tag) def keys(self): return self.tables.keys() def __getitem__(self, tag): """Fetch the raw table data.""" entry = self.tables[tag] self.file.seek(entry.offset) data = self.file.read(entry.length) if self.checkChecksums: if tag == 'head': # Beh: we have to special-case the 'head' table. checksum = calcChecksum(data[:8] + '\0\0\0\0' + data[12:]) else: checksum = calcChecksum(data) if self.checkChecksums > 1: # Be obnoxious, and barf when it's wrong assert checksum == entry.checksum, "bad checksum for '%s' table" % tag elif checksum <> entry.checkSum: # Be friendly, and just print a warning. print "bad checksum for '%s' table" % tag return data def __delitem__(self, tag): del self.tables[tag] def close(self): self.file.close() class SFNTWriter: def __init__(self, file, numTables, sfntVersion="\000\001\000\000"): self.file = file self.numTables = numTables self.sfntVersion = sfntVersion self.searchRange, self.entrySelector, self.rangeShift = getSearchRange(numTables) self.nextTableOffset = sfntDirectorySize + numTables * sfntDirectoryEntrySize # clear out directory area self.file.seek(self.nextTableOffset) # make sure we're actually where we want to be. (XXX old cStringIO bug) self.file.write('\0' * (self.nextTableOffset - self.file.tell())) self.tables = {} def __setitem__(self, tag, data): """Write raw table data to disk.""" if self.tables.has_key(tag): # We've written this table to file before. If the length # of the data is still the same, we allow overwriting it. entry = self.tables[tag] if len(data) <> entry.length: from kiva.fonttools.fontTools import ttLib raise ttLib.TTLibError, "cannot rewrite '%s' table: length does not match directory entry" % tag else: entry = SFNTDirectoryEntry() entry.tag = tag entry.offset = self.nextTableOffset entry.length = len(data) self.nextTableOffset = self.nextTableOffset + ((len(data) + 3) & ~3) self.file.seek(entry.offset) self.file.write(data) self.file.seek(self.nextTableOffset) # make sure we're actually where we want to be. (XXX old cStringIO bug) self.file.write('\0' * (self.nextTableOffset - self.file.tell())) if tag == 'head': entry.checkSum = calcChecksum(data[:8] + '\0\0\0\0' + data[12:]) else: entry.checkSum = calcChecksum(data) self.tables[tag] = entry def close(self, closeStream=1): """All tables must have been written to disk. Now write the directory. """ tables = self.tables.items() tables.sort() if len(tables) <> self.numTables: from kiva.fonttools.fontTools import ttLib raise ttLib.TTLibError, "wrong number of tables; expected %d, found %d" % (self.numTables, len(tables)) directory = sstruct.pack(sfntDirectoryFormat, self) self.file.seek(sfntDirectorySize) for tag, entry in tables: directory = directory + entry.toString() self.calcMasterChecksum(directory) self.file.seek(0) self.file.write(directory) if closeStream: self.file.close() def calcMasterChecksum(self, directory): # calculate checkSumAdjustment tags = self.tables.keys() checksums = numpy.zeros(len(tags)+1) for i in range(len(tags)): checksums[i] = self.tables[tags[i]].checkSum directory_end = sfntDirectorySize + len(self.tables) * sfntDirectoryEntrySize assert directory_end == len(directory) checksums[-1] = calcChecksum(directory) checksum = numpy.add.reduce(checksums) # BiboAfba! checksumadjustment = numpy.array(CHECKSUM_MAGIC) - checksum # write the checksum to the file self.file.seek(self.tables['head'].offset + 8) self.file.write(struct.pack(">l", checksumadjustment)) # -- sfnt directory helpers and cruft sfntDirectoryFormat = """ > # big endian sfntVersion: 4s numTables: H # number of tables searchRange: H # (max2 <= numTables)*16 entrySelector: H # log2(max2 <= numTables) rangeShift: H # numTables*16-searchRange """ sfntDirectorySize = sstruct.calcsize(sfntDirectoryFormat) sfntDirectoryEntryFormat = """ > # big endian tag: 4s checkSum: l offset: l length: l """ sfntDirectoryEntrySize = sstruct.calcsize(sfntDirectoryEntryFormat) class SFNTDirectoryEntry: def fromFile(self, file): sstruct.unpack(sfntDirectoryEntryFormat, file.read(sfntDirectoryEntrySize), self) def fromString(self, str): sstruct.unpack(sfntDirectoryEntryFormat, str, self) def toString(self): return sstruct.pack(sfntDirectoryEntryFormat, self) def __repr__(self): if hasattr(self, "tag"): return "" % (self.tag, id(self)) else: return "" % id(self) def calcChecksum(data, start=0): """Calculate the checksum for an arbitrary block of data. Optionally takes a 'start' argument, which allows you to calculate a checksum in chunks by feeding it a previous result. If the data length is not a multiple of four, it assumes it is to be padded with null byte. """ from kiva.fonttools.fontTools import ttLib remainder = len(data) % 4 if remainder: data = data + '\0' * (4-remainder) a = numpy.fromstring(struct.pack(">l", start) + data, numpy.int32) if ttLib.endian <> "big": a = a.byteswapped() return numpy.add.reduce(a) def maxPowerOfTwo(x): """Return the highest exponent of two, so that (2 ** exponent) <= x """ exponent = 0 while x: x = x >> 1 exponent = exponent + 1 return max(exponent - 1, 0) def getSearchRange(n): """Calculate searchRange, entrySelector, rangeShift for the sfnt directory. 'n' is the number of tables. """ # This stuff needs to be stored in the file, because? import math exponent = maxPowerOfTwo(n) searchRange = (2 ** exponent) * 16 entrySelector = exponent rangeShift = n * 16 - searchRange return searchRange, entrySelector, rangeShift enthought-chaco2-4.1.0.orig/kiva/fonttools/fontTools/ttLib/macUtils.py0000644000175000017500000001760211674463636025074 0ustar varunvarun"""ttLib.macUtils.py -- Various Mac-specific stuff.""" import os if os.name <> "mac": raise ImportError, "This module is Mac-only!" import cStringIO import macfs try: from Carbon import Res except ImportError: import Res def getSFNTResIndices(path): """Determine whether a file has a resource fork or not.""" fss = macfs.FSSpec(path) try: resref = Res.FSpOpenResFile(fss, 1) # read only except Res.Error: return [] Res.UseResFile(resref) numSFNTs = Res.Count1Resources('sfnt') Res.CloseResFile(resref) return range(1, numSFNTs + 1) def openTTFonts(path): """Given a pathname, return a list of TTFont objects. In the case of a flat TTF/OTF file, the list will contain just one font object; but in the case of a Mac font suitcase it will contain as many font objects as there are sfnt resources in the file. """ from kiva.fonttools.fontTools import ttLib fonts = [] sfnts = getSFNTResIndices(path) if not sfnts: fonts.append(ttLib.TTFont(path)) else: for index in sfnts: fonts.append(ttLib.TTFont(path, index)) if not fonts: raise ttLib.TTLibError, "no fonts found in file '%s'" % path return fonts class SFNTResourceReader: """Simple (Mac-only) read-only file wrapper for 'sfnt' resources.""" def __init__(self, path, res_name_or_index): fss = macfs.FSSpec(path) resref = Res.FSpOpenResFile(fss, 1) # read-only Res.UseResFile(resref) if type(res_name_or_index) == type(""): res = Res.Get1NamedResource('sfnt', res_name_or_index) else: res = Res.Get1IndResource('sfnt', res_name_or_index) self.file = cStringIO.StringIO(res.data) Res.CloseResFile(resref) self.name = path def __getattr__(self, attr): # cheap inheritance return getattr(self.file, attr) class SFNTResourceWriter: """Simple (Mac-only) file wrapper for 'sfnt' resources.""" def __init__(self, path, ttFont, res_id=None): self.file = cStringIO.StringIO() self.name = path self.closed = 0 fullname = ttFont['name'].getName(4, 1, 0) # Full name, mac, default encoding familyname = ttFont['name'].getName(1, 1, 0) # Fam. name, mac, default encoding psname = ttFont['name'].getName(6, 1, 0) # PostScript name, etc. if fullname is None or fullname is None or psname is None: from kiva.fonttools.fontTools import ttLib raise ttLib.TTLibError, "can't make 'sfnt' resource, no Macintosh 'name' table found" self.fullname = fullname.string self.familyname = familyname.string self.psname = psname.string if self.familyname <> self.psname[:len(self.familyname)]: # ugh. force fam name to be the same as first part of ps name, # fondLib otherwise barfs. for i in range(min(len(self.psname), len(self.familyname))): if self.familyname[i] <> self.psname[i]: break self.familyname = self.psname[:i] self.ttFont = ttFont self.res_id = res_id fss = macfs.FSSpec(self.name) if os.path.exists(self.name): os.remove(self.name) Res.FSpCreateResFile(fss, 'DMOV', 'FFIL', 0) self.resref = Res.FSpOpenResFile(fss, 3) # exclusive read/write permission def close(self): if self.closed: return Res.UseResFile(self.resref) try: res = Res.Get1NamedResource('sfnt', self.fullname) except Res.Error: pass else: res.RemoveResource() res = Res.Resource(self.file.getvalue()) if self.res_id is None: self.res_id = Res.Unique1ID('sfnt') res.AddResource('sfnt', self.res_id, self.fullname) res.ChangedResource() self.createFond() del self.ttFont Res.CloseResFile(self.resref) self.file.close() self.closed = 1 def createFond(self): fond_res = Res.Resource("") fond_res.AddResource('FOND', self.res_id, self.fullname) from kiva.fonttools.fontTools import fondLib fond = fondLib.FontFamily(fond_res, "w") fond.ffFirstChar = 0 fond.ffLastChar = 255 fond.fondClass = 0 fond.fontAssoc = [(0, 0, self.res_id)] fond.ffFlags = 20480 # XXX ??? fond.ffIntl = (0, 0) fond.ffLeading = 0 fond.ffProperty = (0, 0, 0, 0, 0, 0, 0, 0, 0) fond.ffVersion = 0 fond.glyphEncoding = {} if self.familyname == self.psname: fond.styleIndices = (1,) * 48 # uh-oh, fondLib is too dumb. else: fond.styleIndices = (2,) * 48 fond.styleStrings = [] fond.boundingBoxes = None fond.ffFamID = self.res_id fond.changed = 1 fond.glyphTableOffset = 0 fond.styleMappingReserved = 0 # calc: scale = 4096.0 / self.ttFont['head'].unitsPerEm fond.ffAscent = scale * self.ttFont['hhea'].ascent fond.ffDescent = scale * self.ttFont['hhea'].descent fond.ffWidMax = scale * self.ttFont['hhea'].advanceWidthMax fond.ffFamilyName = self.familyname fond.psNames = {0: self.psname} fond.widthTables = {} fond.kernTables = {} cmap = self.ttFont['cmap'].getcmap(1, 0) if cmap: names = {} for code, name in cmap.cmap.items(): names[name] = code if self.ttFont.has_key('kern'): kern = self.ttFont['kern'].getkern(0) if kern: fondkerning = [] for (left, right), value in kern.kernTable.items(): if names.has_key(left) and names.has_key(right): fondkerning.append((names[left], names[right], scale * value)) fondkerning.sort() fond.kernTables = {0: fondkerning} if self.ttFont.has_key('hmtx'): hmtx = self.ttFont['hmtx'] fondwidths = [2048] * 256 + [0, 0] # default width, + plus two zeros. for name, (width, lsb) in hmtx.metrics.items(): if names.has_key(name): fondwidths[names[name]] = scale * width fond.widthTables = {0: fondwidths} fond.save() def __del__(self): if not self.closed: self.close() def __getattr__(self, attr): # cheap inheritance return getattr(self.file, attr) enthought-chaco2-4.1.0.orig/kiva/fonttools/font_manager.py0000644000175000017500000013172411674463636022710 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. """ import os, sys, glob, subprocess, warnings, tempfile try: set except NameError: from sets import Set as set import afm from traits.etsconfig.api import ETSConfig from kiva.fonttools.fontTools.ttLib import TTFont try: import cPickle as pickle except ImportError: import pickle 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 #print "kiva font_manager: ", text 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') if not os.path.exists(p): os.makedirs(p) 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, (str, unicode)): 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: propdict[(prop.platformID, prop.platEncID, prop.langID, prop.nameID )] = prop.string return propdict ############################################################################### # matplotlib code below ############################################################################### def get_fontext_synonyms(fontext): """ Return a list of file extensions extensions that are synonyms for the given file extension *fileext*. """ return {'ttf': ('ttf', 'otf'), 'otf': ('ttf', 'otf'), 'afm': ('afm',)}[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 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' # !!!! Incomplete size_adjust = None 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' # !!!! Incomplete size_adjust = None 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: verbose.report("Could not open font file %s"%fpath) continue except UnicodeError: verbose.report("Cannot handle unicode filenames") #print >> sys.stderr, 'Bad file is', fpath 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, # if this is set, it's a hardcoded filename to use _init = None # 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() return getPropDict(TTFont(str(fontManager.findfont(self))))[(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 = [] #This allows matplotlib to put fonts in its directory. #Does kiva need this capability? (probably not) # paths = [os.path.join(rcParams['datapath'], 'fonts', 'ttf'), # os.path.join(rcParams['datapath'], 'fonts', 'afm'), # os.path.join(rcParams['datapath'], 'fonts', 'pdfcorefonts')] # 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: if (directory is not None and os.path.commonprefix([font.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) ext = "." + 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.1.0.orig/kiva/constants.py0000644000175000017500000001005011674463636020221 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])) #-------------------------------------------------------------------- # 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 #EOF enthought-chaco2-4.1.0.orig/enable/0000755000175000017500000000000011674463635016132 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/simple_layout.py0000644000175000017500000000620411674463635021374 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.1.0.orig/enable/drawing/0000755000175000017500000000000011674463635017565 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/drawing/drag_box.py0000644000175000017500000000733111674463635021730 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.1.0.orig/enable/drawing/api.py0000644000175000017500000000051111674463635020705 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.1.0.orig/enable/drawing/drawing_canvas.py0000644000175000017500000001650311674463635023132 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.1.0.orig/enable/drawing/__init__.py0000644000175000017500000000000011674463635021664 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/drawing/drag_line.py0000644000175000017500000000510611674463635022065 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.1.0.orig/enable/drawing/point_line.py0000644000175000017500000002030011674463635022272 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.1.0.orig/enable/drawing/drag_polygon.py0000644000175000017500000000745611674463635022637 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.1.0.orig/enable/drawing/drag_segment.py0000644000175000017500000000652111674463635022602 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.1.0.orig/enable/drawing/drawing_tool.py0000644000175000017500000000331711674463635022633 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.1.0.orig/enable/drawing/point_polygon.py0000644000175000017500000001665311674463635023052 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.1.0.orig/enable/render_controllers.py0000644000175000017500000000642011674463635022413 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.1.0.orig/enable/viewport.py0000644000175000017500000003015511674463635020367 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.1.0.orig/enable/api.py0000644000175000017500000000442311674463635017260 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 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.1.0.orig/enable/__init__.py0000644000175000017500000000037011674463635020243 0ustar varunvarun# Copyright (c) 2007-2011 by Enthought, Inc. # All rights reserved. """ A multi-platform object drawing library. Part of the Enable project of the Enthought Tool Suite. """ __version__ = '4.1.0' __requires__ = [ 'traitsui', 'PIL', ] enthought-chaco2-4.1.0.orig/enable/text_field_style.py0000644000175000017500000000215511674463635022056 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.1.0.orig/enable/toolkit.py0000644000175000017500000000373611674463635020202 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.1.0.orig/enable/container.py0000644000175000017500000006447611674463635020507 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 from abstract_layout_controller import AbstractLayoutController class AbstractResolver(HasTraits): """ A Resolver traverses a component DB and matches a specifier. """ def match(self, db, query): """ Queries a component DB using a dict of keyword-val conditions. Each resolver defines its set of allowed keywords. """ raise NotImplementedError class DefaultResolver(AbstractResolver): """ Basic resolver that searches a container's DB of components using the following conditions: id=foo : the component's .id must be 'foo' class=['foo','bar'] : the component's .class must be in the list target='foo' : the component's .target is 'foo'; this usually applies to tools, overlays, and decorators """ def match(self, db, query): pass 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") #------------------------------------------------------------------------ # DOM-related traits # (Note: These are unused as of 8/13/2007) #------------------------------------------------------------------------ # The layout controller determines how the container's internal layout # mechanism works. It can perform the actual layout or defer to an # enclosing container's layout controller. The default controller is # a cooperative/recursive layout controller. layout_controller = Instance(AbstractLayoutController) # This object resolves queries for components resolver = Instance(AbstractResolver) #------------------------------------------------------------------------ # 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, () ) # Used by the resolver to cache previous lookups _lookup_cache = Any # 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 get(self, **kw): """ Allows for querying of this container's components. """ # TODO: cache requests return self.resolver.query(self._components, kw) 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.1.0.orig/enable/tests/0000755000175000017500000000000011674463635017274 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/tests/container_test_case.py0000644000175000017500000000562011674463635023665 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.1.0.orig/enable/tests/component_test_case.py0000644000175000017500000000512111674463635023701 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.1.0.orig/enable/tests/event_transform_test_case.py0000644000175000017500000001415411674463635025121 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.1.0.orig/enable/tests/coordinate_box_test_case.py0000644000175000017500000000205611674463635024702 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.1.0.orig/enable/tests/viewport_test_case.py0000644000175000017500000000214711674463635023563 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.1.0.orig/enable/tests/kiva_graphics_context_test_case.py0000644000175000017500000000137511674463635026264 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 lenght 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.1.0.orig/enable/window.py0000644000175000017500000000147711674463635020024 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.1.0.orig/enable/drag_resize.py0000644000175000017500000001336411674463635021011 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.1.0.orig/enable/pyglet_backend/0000755000175000017500000000000011674463635021105 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/pyglet_backend/api.py0000644000175000017500000000015511674463635022231 0ustar varunvarun from window import Window # from scrollbar import NativeScrollBar class NativeScrollBar(object): pass enthought-chaco2-4.1.0.orig/enable/pyglet_backend/__init__.py0000644000175000017500000000000011674463635023204 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/pyglet_backend/window.py0000644000175000017500000004712711674463635023001 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.1.0.orig/enable/pyglet_backend/notes.txt0000644000175000017500000000206511674463635023001 0ustar varunvarun - The pyglet backend should provide its own equivalent for wx.SimpleApp, i.e. opens a frame and runs the main loop. The pyglet backend's Window should work like any other backend's Window class, and expect a main loop to be running. - Small error in Pyglet Programming guide windowing.txt: window.Window(fullscreen=True, screens[1]) should be: window.Window(fullscreen=True, screen=screens[1]) - Another error in Pyglet Programming guide mouse.txt: the mouse capture method should be named set_exclusive_mouse(), instead of set_mouse_exclusive() - Integration with WX/qt? (e.g. TraitsPygletWindow) - Use pyglet.clock to implement EnableTimer on it - Need to figure out how to handle double clicks since we don't natively get those from Pyglet - Extend Enable to support horizontal scrolling - We should support on_text_motion and on_text_motion_select, but only text widgets and components would care. Right now Enable doesn't have any concept of distinguishing different kinds of components. It would be a good thing to add. enthought-chaco2-4.1.0.orig/enable/pyglet_backend/pyglet_app.py0000644000175000017500000000104311674463635023621 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.1.0.orig/enable/pyglet_backend/constants.py0000644000175000017500000001077611674463635023506 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.1.0.orig/enable/abstract_window.py0000644000175000017500000004666311674463635021715 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 #------------------------------------------------------------------------ # 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) 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 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.1.0.orig/enable/new_component.py0000644000175000017500000003047011674463635021363 0ustar varunvarun""" Defines the Component class. FIXME: this appears to be unfinished and unworking as of 2008-08-03. """ # Enthought library imports from traits.api import Any, Bool, Delegate, HasTraits, Instance, \ Int, List, Property # Local relative imports from abstract_component import AbstractComponent from abstract_layout_controller import AbstractLayoutController from coordinate_box import CoordinateBox from render_controllers import AbstractRenderController coordinate_delegate = Delegate("inner", modify=True) class Component(CoordinateBox, AbstractComponent): """ Component is the base class for most Enable objects. In addition to the basic position and container features of AbstractComponent, 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 component. These cannot be set, since they are secondary attributes (computed from the component's "inner" size and margin-area attributes). """ #------------------------------------------------------------------------ # 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 4 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 occurring 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 #------------------------------------------------------------------------ # Public methods #------------------------------------------------------------------------ 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 #------------------------------------------------------------------------ # AbstractComponent interface #------------------------------------------------------------------------ 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 #------------------------------------------------------------------------ # Protected methods #------------------------------------------------------------------------ def _get_visible_border(self): """ Helper function to return the amount of border, if visible """ if self.border_visible: return self.border_width else: return 0 #------------------------------------------------------------------------ # Event handlers #------------------------------------------------------------------------ def _bounds_changed(self, old, new): self.cursor_bounds = new if self.container is not None: self.container._component_bounds_changed(self) return def _bounds_items_changed(self, event): self.cursor_bounds = self.bounds[:] if self.container is not None: self.container._component_bounds_changed(self) return #------------------------------------------------------------------------ # Padding setters and 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 #------------------------------------------------------------------------ # 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] return 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() return 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.hpadding return 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() return 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.vpadding return #------------------------------------------------------------------------ # Outer bounds setters and getters #------------------------------------------------------------------------ def _get_outer_bounds(self): border = self._get_visible_border() 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] return def _get_outer_width(self): return self.outer_bounds[0] def _set_outer_width(self, width): self.bounds[0] = width - self.hpadding return def _get_outer_height(self): return self.outer_bounds[1] def _set_outer_height(self, height): self.bounds[1] = height - self.vpadding return class NewComponent(CoordinateBox, AbstractComponent): # 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 optional element ID of this component. #------------------------------------------------------------------------ # Layout traits #------------------------------------------------------------------------ layout_info = Instance(LayoutInfo, args=()) # backwards-compatible layout properties padding_left = Property padding_right = Property padding_top = Property padding_bottom = Property padding = Property hpadding = Property vpadding = Property padding_accepts_focus = Bool(True) class AbstractResolver(HasTraits): """ A Resolver traverses a component DB and matches a specifier. """ def match(self, db, query): raise NotImplementedError class NewContainer(NewComponent): # The layout controller determines how the container's internal layout # mechanism works. It can perform the actual layout or defer to an # enclosing container's layout controller. The default controller is # a cooperative/recursive layout controller. layout_controller = Instance(AbstractLayoutController) # The render controller determines how this container and its enclosed # components are rendered. It can actually perform the rendering calls, # or defer to an enclosing container's render controller. render_controller = Instance(AbstractRenderController) resolver = Instance(AbstractResolver) # Dict that caches previous lookups. _lookup_cache = Any def lookup(self, query): """ Returns the component or components matching the given specifier. """ enthought-chaco2-4.1.0.orig/enable/events.py0000644000175000017500000001743711674463635020024 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 __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.1.0.orig/enable/stacked_container.py0000644000175000017500000000604711674463635022173 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.1.0.orig/enable/example_support.py0000644000175000017500000001062011674463635021732 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 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 = wx.GetApp() if app is None: app = wx.PySimpleApp() frame = demo_class(None, size=size, title=title) app.SetTopWindow(frame) app.MainLoop() elif ETSConfig.toolkit == 'qt4': from pyface.qt import QtGui _app = QtGui.QApplication.instance() if _app is None: import sys _app = QtGui.QApplication(sys.argv) 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." frame = demo_class(None, size=size, title=title) _app.exec_() 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() # EOF enthought-chaco2-4.1.0.orig/enable/component_render_category.py0000644000175000017500000001531111674463635023743 0ustar varunvarun""" This module contains the RenderingCategory, which defines the rendering aspect of components. It uses Traits Categories to extend the Component class defined in component.py. NOTE: This means that you should import enable.Component from enable.api, and not directly from component.py. """ from __future__ import with_statement # Enthought library imports from traits.api import Any, Bool, Category, Enum, Instance, \ Int, List # Local relative imports from colors import black_color_trait, white_color_trait from abstract_component import AbstractComponent from enable_traits import LineStyle from render_controllers import AbstractRenderController, OldEnableRenderController, \ RenderController # Singleton representing the default Enable render controller DefaultRenderController = OldEnableRenderController() class ComponentRenderCategory(Category, AbstractComponent): """ Encapsulates the rendering-related aspects of a component and extends the Component class in component.py. !! This class should not be instantiated or subclassed !! Please refer to traits.Category for more information. """ # The controller that determines how this component renders. By default, # this is the singleton render_controller = Instance(AbstractRenderController, factory = DefaultRenderController) # Is the component visible? visible = Bool(True) # Does this container prefer to draw all of its components in one pass, or # does it prefer to cooperate in its container's layer-by-layer drawing? # If unified_draw is on, then this component will draw as a unified whole, # and its parent container will call our _draw() method when drawing the # layer indicated in self.draw_layer. # If unified_draw is off, then our parent container will call # self._dispatch_draw() with the name of each layer as it goes through its # list of layers. unified_draw = Bool(False) # A list of the order in which various layers of this component # should be rendered. This is only used if the component does # unified draw. draw_order = List # 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 will call this component. draw_layer = Enum(RenderController.LAYERS) #------------------------------------------------------------------------ # Background and padding #------------------------------------------------------------------------ # Should the padding area be filled with the background color? fill_padding = Bool(False) # 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 #------------------------------------------------------------------------ # Border 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 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 # Should the border be drawn as part of the overlay or the background? overlay_border = Bool(True) # Should the border be drawn inset (on the plot) or outside the plot # area? inset_border = Bool(True) #------------------------------------------------------------------------ # 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 backbufferd, even # if explicitly asked to do so. use_backbuffer = Bool(False) # Reflects the validity state of the backbuffer. This 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 components wants to know the validity of this component's # backbuffer, i.e. if a draw were to occur, whether the component would # actually change. draw_valid = Bool(False) # Should the backbuffer include the padding area? # TODO: verify that backbuffer invalidation occurs if this attribute # is changed. backbuffer_padding = Bool(True) #------------------------------------------------------------------------ # Private traits #------------------------------------------------------------------------ _backbuffer = Any def draw(self, gc, view_bounds=None, mode="default"): """ Renders this component onto a GraphicsContext. "view_bounds" is a 4-tuple (x, y, dx, dy) of the viewed region relative to the CTM of the gc. "mode" can be used to require this component render itself in a particular fashion, and can be "default" or any of the enumeration values of self.default_draw_mode. """ self.render_controller.draw(self, gc, view_bounds, mode) return def _draw_component(self, gc, view_bounds=None, mode="default"): """ This function actually draws the core parts of the component itself, i.e. the parts that belong on the "main" layer. Subclasses should implement this. """ pass def _draw_border(self, gc, view_bounds=None, mode="default"): """ Utility method to draw the borders around this component """ 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.begin_path() gc.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) gc.stroke_path() return def _draw_background(self, gc, view_bounds=None, mode="default"): if self.bgcolor not in ("transparent", "none"): gc.set_fill_color(self.bgcolor_) gc.rect(*(self.position + self.bounds)) gc.fill_path() return enthought-chaco2-4.1.0.orig/enable/trait_defs/0000755000175000017500000000000011674463635020256 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/trait_defs/api.py0000644000175000017500000000005111674463635021375 0ustar varunvarunfrom rgba_color_trait import RGBAColor enthought-chaco2-4.1.0.orig/enable/trait_defs/__init__.py0000644000175000017500000000007711674463635022373 0ustar varunvarun# Copyright (c) 2007 by Enthought, Inc. # All rights reserved. enthought-chaco2-4.1.0.orig/enable/trait_defs/ui/0000755000175000017500000000000011674463635020673 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/trait_defs/ui/api.py0000644000175000017500000000005611674463635022017 0ustar varunvarunfrom rgba_color_editor import RGBAColorEditor enthought-chaco2-4.1.0.orig/enable/trait_defs/ui/__init__.py0000644000175000017500000000007711674463635023010 0ustar varunvarun# Copyright (c) 2007 by Enthought, Inc. # All rights reserved. enthought-chaco2-4.1.0.orig/enable/trait_defs/ui/qt4/0000755000175000017500000000000011674463635021403 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/trait_defs/ui/qt4/__init__.py0000644000175000017500000000007711674463635023520 0ustar varunvarun# Copyright (c) 2007 by Enthought, Inc. # All rights reserved. enthought-chaco2-4.1.0.orig/enable/trait_defs/ui/qt4/rgba_color_editor.py0000644000175000017500000000525311674463635025441 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.1.0.orig/enable/trait_defs/ui/rgba_color_editor.py0000644000175000017500000000037111674463635024725 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.1.0.orig/enable/trait_defs/ui/wx/0000755000175000017500000000000011674463635021331 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/trait_defs/ui/wx/__init__.py0000644000175000017500000000007711674463635023446 0ustar varunvarun# Copyright (c) 2007 by Enthought, Inc. # All rights reserved. enthought-chaco2-4.1.0.orig/enable/trait_defs/ui/wx/enable_rgba_color_editor.py0000644000175000017500000001704311674463635026675 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.1.0.orig/enable/trait_defs/ui/wx/rgba_color_editor.py0000644000175000017500000004625011674463635025371 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.1.0.orig/enable/trait_defs/rgba_color_trait.py0000644000175000017500000001067511674463635024155 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.1.0.orig/enable/vtk_backend/0000755000175000017500000000000011674463635020405 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/vtk_backend/__init__.py0000644000175000017500000000000011674463635022504 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/vtk_backend/vtk_window.py0000644000175000017500000004757711674463635023176 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.1.0.orig/enable/vtk_backend/constants.py0000644000175000017500000000143711674463635023000 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.1.0.orig/enable/gl_graphics_context.py0000644000175000017500000000041511674463635022532 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.1.0.orig/enable/text_grid.py0000644000175000017500000002346211674463635020504 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.1.0.orig/enable/interactor.py0000644000175000017500000000671311674463635020665 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 - 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.1.0.orig/enable/qt4/0000755000175000017500000000000011674463635016642 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/qt4/cairo.py0000644000175000017500000000254511674463635020317 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.1.0.orig/enable/qt4/__init__.py0000644000175000017500000000000011674463635020741 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/qt4/gl.py0000644000175000017500000000407011674463635017617 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.1.0.orig/enable/qt4/image.py0000644000175000017500000000331611674463635020301 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() byte_data = QtCore.QByteArray(data) image = QtGui.QImage(byte_data, w, h, QtGui.QImage.Format_RGB32) 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.1.0.orig/enable/qt4/base_window.py0000644000175000017500000003206711674463635021525 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 from traits.api import Instance # Local imports. from constants import BUTTON_NAME_MAP, KEY_MAP, POINTER_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()) 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._enable_window._paint(event) 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) #------------------------------------------------------------------------ # Qt Drag and drop event handlers #------------------------------------------------------------------------ def dragEnterEvent(self, event): pass def dragLeaveEvent(self, event): pass def dragMoveEvent(self, event): pass def dropEvent(self, event): pass class _QtWindow(QtGui.QWidget): """ The Qt widget that implements the enable control. """ def __init__(self, parent, enable_window): super(_QtWindow, self).__init__(parent) 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) 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) 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): # FIXME raise NotImplementedError 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 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 _redraw(self, coordinates=None): if self.control: 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) #------------------------------------------------------------------------ # 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.1.0.orig/enable/qt4/scrollbar.py0000644000175000017500000000747111674463635021210 0ustar varunvarun""" Define a standard horizontal and vertical Enable scrollbar component that wraps the standard Qt one. """ # Major library imports from types import ListType, TupleType # Enthought library imports from traits.api import Any, Bool, 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 return max(min(float(value), high - page_size), low) except: raise raise TraitError 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 #------------------------------------------------------------------------ # Private Traits #------------------------------------------------------------------------ _control = Any _clean = Bool(False) _last_widget_x = Float(0) _last_widget_y = Float(0) _last_widget_height = Float(0) _list_widget_width = Float(0) #------------------------------------------------------------------------ # 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.1.0.orig/enable/qt4/qpainter.py0000644000175000017500000000177511674463635021051 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.1.0.orig/enable/qt4/constants.py0000644000175000017500000001057711674463635021242 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 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_Plus: 'Add', 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_Period: 'Decimal', QtCore.Qt.Key_Delete: 'Delete', #QtCore.Qt.Key_Slash: 'Divide', 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_0: 'Numpad 0', #QtCore.Qt.Key_1: 'Numpad 1', #QtCore.Qt.Key_2: 'Numpad 2', #QtCore.Qt.Key_3: 'Numpad 3', #QtCore.Qt.Key_4: 'Numpad 4', #QtCore.Qt.Key_5: 'Numpad 5', #QtCore.Qt.Key_6: 'Numpad 6', #QtCore.Qt.Key_7: 'Numpad 7', #QtCore.Qt.Key_8: 'Numpad 8', #QtCore.Qt.Key_9: 'Numpad 9', 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_Minus: 'Subtract', QtCore.Qt.Key_Tab: 'Tab', QtCore.Qt.Key_Up: 'Up', QtCore.Qt.Key_Alt: 'Alt', } #if len(key_symbols) != len(key_names): # warnings.warn("The Qt4 toolkit backend keymap is out of sync!") #KEY_MAP = dict(zip(key_symbols, key_names)) enthought-chaco2-4.1.0.orig/enable/coordinate_box.py0000644000175000017500000000731011674463635021504 0ustar varunvarun # Enthought library imports from traits.api import HasTraits, Property # Local, relative imports from enable_traits import bounds_trait, coordinate_trait 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 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 # EOF enthought-chaco2-4.1.0.orig/enable/native_scrollbar.py0000644000175000017500000000152111674463635022034 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.1.0.orig/enable/scroll_handler.py0000644000175000017500000000215111674463635021476 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.1.0.orig/enable/compass.py0000644000175000017500000001533411674463635020157 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.1.0.orig/enable/enable_traits.py0000644000175000017500000000750111674463635021323 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.1.0.orig/enable/text_field_grid.py0000644000175000017500000001360411674463635021644 0ustar varunvarun# Enthought library imports from enable.api import Container, TextField from traits.api import Float, Int, List # Local imports from enable_traits import LineStyle from colors import black_color_trait class TextFieldGrid(Container): """ A 2D grid of TextFields. """ ######################################################################### # TextFieldGrid traits ######################################################################### # The number of columns columns = Int(0) # The number of rows rows = Int(0) # The Cells in the TextGrid - represented as a list of lists cells = List(List) # The initial width of the boxes cell_width = Float(200.0) # The initial height of the boxes cell_height = Float(20.0) # The padding between the boxes cell_padding = Float(1.0) # 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") # A list of tuples of the (i,j) of selected cells selected_cells = List # The total width of the textfields after layout total_width = Float # The total height of the textfields after layout total_height = Float ######################################################################### # object interface ######################################################################### def __init__(self, columns, rows, **traits): """ Create a list of lists of EnableTextFields. These will be the elements in our TextGrid. """ self.rows = rows self.columns = columns self.selected_box = [] super(TextFieldGrid, self).__init__(**traits) def set_cell(self, row, column, text): if row < self.rows and column < self.columns: self.cells[row][column].text = text ######################################################################### # AbstractComponent interface ######################################################################### def _dispatch_draw(self, layer, gc, view_bounds, mode): self._position_cells() Container._dispatch_draw(self, layer, gc, view_bounds, mode) self._draw_grid(gc, view_bounds, mode) #### Private drawing methods ############################################ def _draw_grid(self, gc, view_bounds, mode): gc.set_stroke_color(self.cell_border_color_) gc.set_line_dash(self.cell_border_style_) gc.set_antialias(0) y = self.y for row in range(self.rows + 1): gc.move_to(self.x, y) gc.line_to(self.x+self.width, y) gc.stroke_path() y = y + self.cell_padding + self.cell_height x = self.x for cell in range(self.columns + 1): gc.move_to(x, self.y) gc.line_to(x, self.y + self.height) gc.stroke_path() x = x + self.cell_padding + self.cell_width return def _position_cells(self): y = 0 for row in self.cells: x = 0 for cell in row: cell.position = [x,y] x = x + self.cell_padding + self.cell_width y = y + self.cell_padding + self.cell_height self.total_width = x self.total_height = y def _add_row(self, index): row = [] for i in range(self.columns): tfield = TextField(position=[0,0], width=self.cell_width, height = self.cell_height, multiline=False) self.add(tfield) row.append(tfield) self.cells.insert(index, row) self.bounds[1] = self.bounds[1] + self.cell_padding + self.cell_height def _add_column(self, index): for row in self.cells: tfield = TextField(position=[0,0], width=self.cell_width, height = self.cell_height, multiline=False) self.add(tfield) row.insert(index, tfield) self.bounds[0] = self.bounds[0] + self.cell_padding + self.cell_width def _remove_row(self, index): removed = self.cells[index] self.remove(removed) self.cells.remove(removed) self.bounds[1] = self.bounds[1] - self.cell_padding - self.cell_height def _remove_column(self, index): for row in self.cells: removed = row[index] self.remove(removed) row.remove(removed) self.bounds[0] = self.bounds[0] - self.cell_padding - self.cell_width ######################################################################### # TextFieldGrid interface ######################################################################### def _rows_changed(self, old, new): if new > 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.1.0.orig/enable/graphics_context.py0000644000175000017500000000720211674463635022051 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.1.0.orig/enable/scrollbar.py0000644000175000017500000003646011674463635020500 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.1.0.orig/enable/viewable.py0000644000175000017500000000147511674463635020311 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.1.0.orig/enable/label.py0000644000175000017500000002002311674463635017560 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.1.0.orig/enable/savage/0000755000175000017500000000000011674463635017400 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/compliance/0000755000175000017500000000000011674463635021512 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/compliance/profile_this.py0000644000175000017500000000221611674463635024554 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.1.0.orig/enable/savage/compliance/__init__.py0000644000175000017500000000000011674463635023611 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/compliance/sike.py0000644000175000017500000002727211674463635023031 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.1.0.orig/enable/savage/compliance/crosshair.py0000644000175000017500000000660711674463635024072 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.1.0.orig/enable/savage/compliance/svg_component.py0000644000175000017500000000566011674463635024754 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.1.0.orig/enable/savage/compliance/comparator.py0000644000175000017500000003556711674463635024253 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.1.0.orig/enable/savage/compliance/README0000644000175000017500000000057111674463635022375 0ustar varunvaruncomparator.py will show a suite of SVG images side by side with pngs for the purpose of testing compliance. Currently the app will show the wx backend, the kiva backend, and the reference png. The use of wx here does not imply wx is required to use Savage, but it is obviously needed to compare the wx backend... To get the w3c complaince suite, refer to w3c_svg_11/notes.py enthought-chaco2-4.1.0.orig/enable/savage/compliance/images/0000755000175000017500000000000011674463635022757 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/compliance/images/default.png0000644000175000017500000002133711674463635025117 0ustar varunvarunPNG  IHDR5 pHYs   IDATxyU/4,.Thp0nCb!REfDSET4QQT0۸R j- Uiix۷^Tu{q=;-nݺ5HeSK$#@d @2 HF$#@d @2 HF$#@d @2 HF$#@d @2 HF$#@d @2 HF$#@d @2 HF$#@d @2 HF$#@d @2 HF$#ɴj67n5kĚ5kbqDǎ,Z eiٲe3-?[nZk/r-Z9SuR;#ҥK㭷ފe˖͛FM=<4k֬ظqc[RRݺu={F.]eJ>駟|nݺ^ uhѢOZ|޼y1iҤz^ɓ'W.))Ѳebx֭[#:ujZiݺu3ok=e?p¸ rg֬YO=Tx7뼮,//'e]V?3f_si/MFDL<'E{ٳgdž o}ͣ1MM__b̙;|L֭k׮ѫWh߾.7a„2eJCj{!Yn]L2%6P nӦM;6/g?&\bРA|ܦMb{ŢEb֭WTTØ:ujiӦh|F%K׶m83㤓N;,ZhQy_yyy\2^~xᇫ=&u_{T#QGCVXQp{q7hvϞ=h$k.FW^ye}˗/w~'|`YIII\wu1jԨ_u:ꨘ4iRtA˷l{oC z)#,[oů& ak!no|C9))˗/gEo8SvŤI{˟|XhQ +2JKK e˖5ш/G]é;Ҕ?6o\sύN8^СC>Z/d;:toq7V.+//I&M7ݴQQQ_駟w}7V^6mvEǎ裏/~Ѯ]Fڵk vڵ+eߏŋcݺuqgFw͛7K/j^:֯_۷.]aGqD3Lۓիc˖-;tP0-[_ 6lmFNbq衇5ٴiSa裏i֨e˖5kV}ݱz>n֬YQRRC iMūZy{ѯ_غukW?/ءwĽgώ?p޽{ 2$ӳwGKDĉ ޴;=4ܷ.䒂z(ʢ"xw;z!Ę1cED|'}W1ϟ_x`\xqꩧ͚Ν;G6m aՓv)3gΌM6,;묳l}7N9唘1cF_=֮][=UC^h̘1EM<vwƺMEEE̘1#smqǏzk.aOķx衇vًSN.hoݺ5lRS?=1Ƿ+i[ʊ++)Swtɒ%1jԨ{ʕq饗E;1a„]۬)[hxZGS{ۭZ3<7n\-//cʕ+ 3  ;ƍߎǴi ^cΜ9qG׾j_YS7o^ѲC9N]E[ |31f̘9rdo9΂//ˢOU8я~T%%%ѯ_ׯ_ <8Ə_p(?AuQq4تWw^/޽{5WZU[ZZ\sM|ˏ=8c#"ӧWWQQ7xcw}۾K.ѥKU?ٿFqcog۶ܙm׾}0aBћgqF 80Ǝ[pc|'՞s]w}bu'__p~}}ƠAbx]wřgYpUmnmx ݵn}6ȺIux#<2:묂eK,7 u/˂e'rĵ^[lÆ C5v""">=/M,Z[3g,81r_sРAqƳ>[Çk]߿\uU|ܪUⷿmCK^xa /V.3gVsߞ-/L0dȐ뮻 {E1cFeo3jԨ}/})8\쥗^*8Y]X"Mmذ!VX+VEmˈO?CԘ\;lٲ`mːU,--|;a*//[n%~kU?M8j}mSN9`khOZlFcg͚U0]۶m>Uٕ}ko , 6ľ[4I۲cǎquʢk׮׿rYu'_T=CѼ 8 _|8+o76+W=Spq6aF?-Z?Oڇ~HyxA_gwu^ڵkNNr 'ෟ7zUV>o߾kw(K>z|{Ҷ4hP^m۶5kw)X6p?OǍW|fMiq=4ܦ QtEimݶv_k҂ ">vgc9k͛7ǂ ӧ֯Gǎ 4I۲Ukկ:T7їZFO>֚6gݻw92&N(ߡk6ѲN^ 4ܹs\zV^wyg\}յ^_jD4|RᔆR4*YbE_j~~)C9oOږ9EgVUued4mVW]vs9F-))ݻ]vvnS]n]իW\q5zO^O~鵺UDͦ_VVV7NژXkVw{h뽎0=i[6帶Ԑ6mVW:uo~ѐm~e vٳP-\ >P(!O֭[oUA5|kzqcjO>:gW=d~5zar?Mw17`oCaÆ<~S_p!UuгgϢw]P':0m֜4~p&k 6X`1w܂M6-N>ڵkѣGk9`uKRu5Ƿ=i5UiӦ;Լ7n!t9uVp+oFz 6UV5ZX!>q5,[o:Uf͚3%kbFDt֭ih]y9x'`DE޸͚n|ѲHD]5X83 =1w=7 Q);C.]:aSjޞ4֚en1w:th+YsTN9唢e=Xu4غ X+n->]>SNE;5kVcnӦM4-[}_.]_~wyqyŰabժU{':w\_m6{ʟۿoofU}0`@va***O>d,\Ajm6ʂe~vX-Z(֬YaÆMCs9쨫WQXlY<ZԩSc<-++k n'&Zh'pBs u]+m>.eYp9x7?AY 8b˪Nqy.첂}Qvwyglܸv6mbС5~~c2dH¿/jhSO=5'.䒂u??j[n;۷/޸͚wI']<_ګ'?\sMVjժXred"wkӧn}O?`ԩScڴi|i,XA'ӭ}ݷ/믿~tqu,ܹsviiƷ=i5u]W.|_N+ ޸͚ײe7n\T;6l#GO~ܒ%Kꫯq̔P9WG7 ~ Dn;s/䒘;wnsOկ~5z]9 bO}R>İaiÇ+.x/޽{W7ooV|x<#ds=;I'裏7ވo>}K.m\g?7n\=:****oٲ%~1cF}1pѣGk.JKKcʕo[oK.'xb\~#d"waСcŋkΝ;e]?O Ϟ=;fϞ-Z:(ZlK,0JIII;Y}MVb1jԨ X.]w#Ӊu۶mo'ľK|=y|{Xk]v}/nᆂ79sĜ9s"SJYsV`UGuTtMq 7MsU^^= xh׮]5*O^7q5WVվ}0aBL2%X疕Űas=l5bkMO/^O=TիWǺuM6Ѯ]ԩSs1qqQlذ!{˖-իWG֭SNѩS8_rԱڵkc޼ydɒXjUlٲ%<ѣG#SغYk׮>X|yY&>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 Ha6 IENDB`enthought-chaco2-4.1.0.orig/enable/savage/compliance/drawer.py0000644000175000017500000000666111674463635023361 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.1.0.orig/enable/savage/compliance/w3c_svg_11/0000755000175000017500000000000011674463635023366 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/compliance/w3c_svg_11/notes.txt0000644000175000017500000000032511674463635025257 0ustar varunvarunThese were removed because they are rather large. You can either download them from various sources, or do an 'svn up -r 21167' on this directory to get the last svn revision when these existed in the source tree enthought-chaco2-4.1.0.orig/enable/savage/compliance/viewer.py0000644000175000017500000002050111674463635023363 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.1.0.orig/enable/savage/compliance/xml_view.py0000644000175000017500000000662211674463635023724 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.1.0.orig/enable/savage/__init__.py0000644000175000017500000000053711674463635021516 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.1.0.orig/enable/savage/svg/0000755000175000017500000000000011674463635020177 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/svg/pathdata.py0000644000175000017500000001621111674463635022340 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 self.myException.msg = self.errmsg 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 ) exc = self.myException exc.loc = loc exc.pstr = instring raise exc 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.1.0.orig/enable/savage/svg/__init__.py0000644000175000017500000000000011674463635022276 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/svg/tests/0000755000175000017500000000000011674463635021341 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/svg/tests/__init__.py0000644000175000017500000000000011674463635023440 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/svg/tests/css/0000755000175000017500000000000011674463635022131 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/svg/tests/css/test_block.py0000644000175000017500000000100411674463635024627 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.1.0.orig/enable/savage/svg/tests/css/__init__.py0000644000175000017500000000000011674463635024230 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/svg/tests/css/test_values.py0000644000175000017500000000404311674463635025042 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.1.0.orig/enable/savage/svg/tests/css/test_atrule.py0000644000175000017500000000054311674463635025040 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.1.0.orig/enable/savage/svg/tests/css/test_transform.py0000644000175000017500000000424111674463635025556 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.1.0.orig/enable/savage/svg/tests/css/test_color.py0000644000175000017500000000401511674463635024660 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.1.0.orig/enable/savage/svg/tests/css/test_identifier.py0000644000175000017500000000556611674463635025700 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.1.0.orig/enable/savage/svg/tests/test_document.py0000644000175000017500000000501411674463635024570 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) ) 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, 22) enthought-chaco2-4.1.0.orig/enable/savage/svg/tests/test_pathdata.py0000644000175000017500000001214111674463635024537 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.1.0.orig/enable/savage/svg/tests/test_attributes.py0000644000175000017500000000306411674463635025143 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.1.0.orig/enable/savage/svg/css/0000755000175000017500000000000011674463635020767 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/svg/css/values.py0000644000175000017500000000245511674463635022646 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.1.0.orig/enable/savage/svg/css/transform.py0000644000175000017500000000241311674463635023354 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.1.0.orig/enable/savage/svg/css/__init__.py0000644000175000017500000000010311674463635023072 0ustar varunvarunfrom transform import transformList from inline import inlineStyle enthought-chaco2-4.1.0.orig/enable/savage/svg/css/colour.py0000644000175000017500000001702211674463635022646 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.1.0.orig/enable/savage/svg/css/block.py0000644000175000017500000000014611674463635022434 0ustar varunvarun""" CSS blocks """ from pyparsing import nestedExpr block = nestedExpr(opener="{", closer="}") enthought-chaco2-4.1.0.orig/enable/savage/svg/css/inline.py0000644000175000017500000000037211674463635022621 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.1.0.orig/enable/savage/svg/css/identifier.py0000644000175000017500000000212611674463635023464 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.1.0.orig/enable/savage/svg/css/atrule.py0000644000175000017500000000021611674463635022634 0ustar varunvarun""" CSS at-rules""" from pyparsing import Literal, Combine from identifier import identifier atkeyword = Combine(Literal("@") + identifier) enthought-chaco2-4.1.0.orig/enable/savage/svg/backends/0000755000175000017500000000000011674463635021751 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/svg/backends/__init__.py0000644000175000017500000000000011674463635024050 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/svg/backends/kiva/0000755000175000017500000000000011674463635022703 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/svg/backends/kiva/renderer.py0000644000175000017500000004324711674463635025075 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.1.0.orig/enable/savage/svg/backends/kiva/__init__.py0000644000175000017500000000000011674463635025002 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/svg/backends/null/0000755000175000017500000000000011674463635022723 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/svg/backends/null/__init__.py0000644000175000017500000000000011674463635025022 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/svg/backends/null/null_renderer.py0000644000175000017500000000740511674463635026143 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.1.0.orig/enable/savage/svg/backends/wx/0000755000175000017500000000000011674463635022407 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/svg/backends/wx/renderer.py0000644000175000017500000001516311674463635024575 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.1.0.orig/enable/savage/svg/backends/wx/__init__.py0000644000175000017500000000310411674463635024516 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.1.0.orig/enable/savage/svg/svg_extras.py0000644000175000017500000001222611674463635022741 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.1.0.orig/enable/savage/svg/document.py0000644000175000017500000011536211674463635022377 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 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) element = self.dereference(url) 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.1.0.orig/enable/savage/svg/svg_regex.py0000644000175000017500000002074511674463635022552 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.1.0.orig/enable/savage/svg/attributes.py0000644000175000017500000000255311674463635022744 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.1.0.orig/enable/savage/trait_defs/0000755000175000017500000000000011674463635021524 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/trait_defs/__init__.py0000644000175000017500000000000011674463635023623 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/trait_defs/ui/0000755000175000017500000000000011674463635022141 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/trait_defs/ui/api.py0000644000175000017500000000160611674463635023267 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.1.0.orig/enable/savage/trait_defs/ui/__init__.py0000644000175000017500000000000011674463635024240 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/trait_defs/ui/toolkit.py0000644000175000017500000000446011674463635024204 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.1.0.orig/enable/savage/trait_defs/ui/svg_button.py0000644000175000017500000000712111674463635024706 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.1.0.orig/enable/savage/trait_defs/ui/qt4/0000755000175000017500000000000011674463635022651 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/trait_defs/ui/qt4/__init__.py0000644000175000017500000000000011674463635024750 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/trait_defs/ui/qt4/svg_editor.py0000644000175000017500000000455411674463635025400 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.1.0.orig/enable/savage/trait_defs/ui/qt4/svg_button_editor.py0000644000175000017500000001067511674463635026774 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.1.0.orig/enable/savage/trait_defs/ui/svg_editor.py0000644000175000017500000000267411674463635024671 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.1.0.orig/enable/savage/trait_defs/ui/svg_button_editor.py0000644000175000017500000000635211674463635026261 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.1.0.orig/enable/savage/trait_defs/ui/wx/0000755000175000017500000000000011674463635022577 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/trait_defs/ui/wx/__init__.py0000644000175000017500000000000011674463635024676 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/trait_defs/ui/wx/kiva_render_panel.py0000644000175000017500000000310711674463635026622 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.1.0.orig/enable/savage/trait_defs/ui/wx/svg_editor.py0000644000175000017500000000521111674463635025315 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.1.0.orig/enable/savage/trait_defs/ui/wx/svg_button_editor.py0000644000175000017500000002222611674463635026715 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.1.0.orig/enable/savage/trait_defs/ui/wx/wx_render_panel.py0000644000175000017500000000472711674463635026337 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.1.0.orig/enable/savage/trait_defs/ui/wx/data/0000755000175000017500000000000011674463635023510 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/savage/trait_defs/ui/wx/data/button_toggle.svg0000644000175000017500000000506511674463635027113 0ustar varunvarun image/svg+xml enthought-chaco2-4.1.0.orig/enable/savage/readme.txt0000644000175000017500000000370211674463635021400 0ustar varunvarunKiva/Renderer Tasks ------------------- DONE * Text rendering right side up and positioned correctly. DONE * Text colors set correctly DONE * Circles DONE [kern] * Ellipse DONE [kern] * Ellipse arc. * Line Dashing. [not sure if this is being parsed...] * gradients * blending DONE [kern] * image support * Font lookup isn't very good. It seems to fail a lot. * Correct handling of viewBox and x,y,width,height of , et al. * Relative units (em, ex, %) * Markers and symbols Parsing/Document ---------------- DONE * Bold/Italic handled. * Strike-through and underline. [do we or does the font handle this?] * Text alignment/anchoring handled [ this will likely require more parsing] DONE [kern] * Rework parsing of the path data so that it isn't so slow [different parser?]. (was: s/path data/XML. The XML part uses cElementTree, and isn't slow). * Add lines from svg to the compiled path in one call using lines instead of line_to. * Line dash styles. App --- * Adding kiva.agg and kiva.quartz versions in same UI to get timing and quality comparisons. * Test using Image comparisons * Cleaning up code so that both wx and kiva backends can use the same Document code. Architecture ------------ * Sepearation of rendering from document. I *think* the Document should just build a tree that represents the SVG scene. We then write renderers (wx, kiva, whatever) that walk the tree and render it appropriately. This should simplify the separation of the code and improve the modularity of the various pieces. * It would be interesting if the SVG backend to *kiva* actually used this same Document as its internal representation before writing out to text... Kiva Bugs --------- * Mac requires ints for string styles and weights on fonts. I think it should take strings like 'bold', 'italic', etc. Notes ----- * Should text color be the stroke or fill color? The svg library is using fill color. Kiva uses stroke color... Check into this. enthought-chaco2-4.1.0.orig/enable/canvas.py0000644000175000017500000001562511674463635017770 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.1.0.orig/enable/kiva_graphics_context.py0000644000175000017500000000152111674463635023061 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.1.0.orig/enable/images/0000755000175000017500000000000011674463635017377 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/images/6_weight.gif0000644000175000017500000000013211674463635021576 0ustar varunvarunGIF89a<,<9ڋ޼"扦ʢN M7nL*̦  ;enthought-chaco2-4.1.0.orig/enable/images/1_weight.gif0000644000175000017500000000011411674463635021571 0ustar varunvarunGIF89a<,<+ڋ޼Hyʶ -Jt;enthought-chaco2-4.1.0.orig/enable/images/8_weight.gif0000644000175000017500000000013611674463635021604 0ustar varunvarunGIF89a<,<=ڋ޼^H扦 mLrc* " h̦ J;enthought-chaco2-4.1.0.orig/enable/images/center_position.gif0000644000175000017500000000064711674463635023301 0ustar varunvarunGIF89a<@@@%$!Ŗle]aܸ,<@@`H,ȤrIШ جvzBz讘ncamv- z|V~ smqol}zzooin !! in Ĥh^|UD*\ȰCA;enthought-chaco2-4.1.0.orig/enable/images/bottom_right_position.gif0000644000175000017500000000063211674463635024514 0ustar varunvarunGIF89a<@@@%$!Ŗle]aܸ:::666555444,<@@`H,ȤrIШ جvzBz讘ncaM|n|sZgX` ^ \ZXq}[lZq!USJ /;enthought-chaco2-4.1.0.orig/enable/images/top_left_position.gif0000644000175000017500000000064311674463635023631 0ustar varunvarunGIF89a<@@@%$!Ŗle]aܸ,<@@`H,ȤrIШ جv[zx5bn |.6zvBizzcVy_mklgh !!  }ӀVeŁUSH*\x0;enthought-chaco2-4.1.0.orig/enable/images/image_LICENSE.txt0000644000175000017500000000213111674463635022361 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.1.0.orig/enable/images/bottom_center_position.gif0000644000175000017500000000063111674463635024656 0ustar varunvarunGIF89a<@@@%$!Ŗle]aܸ:::666555444,<@@`H,ȤrIШ جvzBz讘ncaM|n|sZtzo un q}loxntmvitN!USJ ;enthought-chaco2-4.1.0.orig/enable/images/center_align.gif0000644000175000017500000000261311674463635022522 0ustar varunvarunGIF89a<zzNNVVBBrrZZ FFFF֮ڂ..jj22ڒꮮꖖ&&bbvvRR""^^ffffZZ~~66jjҪrr沲JJvvFFNNꚚVVꚚ22NN溺**ڲ֮RRNN&&zzƆ޺ڶҲҞ֦::bb..>>^^ʶ&&vvbb▖vvbbFF⺺ʶjj22jj꾾>>ZZvv""~~⢢ڞҪ66Ҟ֞NNBB66~~zz梢޾֎bbꖖ,<H*4Ç#JHC3j8#Ǐ )z((!8@$ eÕ0hdr@!I8V`` hafF$@0@H#dSZ ;enthought-chaco2-4.1.0.orig/enable/images/top_right_position.gif0000644000175000017500000000064311674463635024014 0ustar varunvarunGIF89a<@@@%$!Ŗle]aܸ,<@@`H,ȤrIШ جvz xLw\P|= wBjzn~~VZ}rphxzy !! l ށퟂUSH*\x0;enthought-chaco2-4.1.0.orig/enable/images/left_align.gif0000644000175000017500000000143611674463635022176 0ustar varunvarunGIF89a<||ddNNYY$$rr꭭==}}kkJJ== 22::TT88PP##䗗EE~~WWࢢΐ繹شӭjjܽ Ʋffշƺoo˖wwآٜ55JJ--qqff嬬ii^^넄㊊鰰bb,<     !"# $%&'()*ڒ)+ ,-.^!cF 5jظCq SB~:l AL2D#+F/}AA&!"<Fi@%L6qbē P6D ҡOOJ)FP9Q% +6XiDW^qP YBhٲY ?'>(/`lA̘ƐAUX@dL+zWY2*8 ۅ L[ۃ/u[xᕣ0 [v%yn!bL@ʈRP l~DY"Bp! bQG'aC8r@`ǰ;xF@Qa#"B91$I"(Y¤':t"7BʔTaW`ɢȜ\DrBgK#,3%2㣘&əhyWA|XQ1L!LHm0D[E,p.^ wFp auȁED6#@w!LD`HX=FGu@vQx I@"pFF'}A @BH:`!: Ru*7qWpB!sՑQQZ(t ')+d[`i[TpC E,CH!eխ~z՘ Wb < !UTp)f diBWCzV-$.;enthought-chaco2-4.1.0.orig/enable/images/center_right_position.gif0000644000175000017500000000064511674463635024474 0ustar varunvarunGIF89a<@@@%$!Ŗle]aܸ,<@@`H,ȤrIШ جvzBz讘ncaM7 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.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.1.0.orig/enable/enable.txt0000644000175000017500000000412011674463635020116 0ustar varunvarunThis file documents/summarizes the classes, methods, and functions in various enable base files. Public attributes and methods are indicated (with return values). Significant protected attributes and methods are prefaced with "_". Note: There are some attributes and methods on components that are part of new-style layout. These are not documented here yet. Interactor event_state pointer tooltip cursor_style cursor_color accepts_focus auto_handle_event dispatch(event, suffix) _dispatch_stateful_event(event, suffix) CoordinateBox position bounds x, y, x2, y2 width, height Component(CoordinateBox, Interactor) container window viewports outer_{position, bounds, x, y, x2, y2, width, height} padding, hpadding, vpadding padding_{left, right, top, bottom} padding_accepts_focus border_width border_visible border_dash border_color bgcolor request_redraw() draw(gc) is_in(x, y) -> bool get_absolute_coords(*coords) -> (x, y) set_outer_position(ndx, val) set_outer_bounds(ndx, val) cleanup(window) _request_redraw() _draw(gc) Container(Component) components auto_size fit_window add(component) remove(component) insert(index, component) components_at(x, y, add_containers=False) -> [components] cleanup() compact() _draw_container(gc, mode) _component_bounds_changed(component) _component_position_changed(component) Viewport(Component) component view_position view_bounds stay_inside bgcolor components_at(x, y, add_containers=False) -> [components] # ----- Event handling stuff ------------------------------------------------ BasicEvent x y handled window push_xy(x, y) pop() offset_xy(x, y) MouseEvent(BasicEvent) alt_down control_down shift_down left_down middle_down right_down mouse_wheel DragEvent(BasicEvent) x0 y0 copy obj start_event KeyEvent(BasicEvent) character alt_down control_down shift_down enthought-chaco2-4.1.0.orig/enable/component_editor.py0000644000175000017500000000533311674463635022060 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. """ self._window = Window( parent, size=self.factory.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 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.1.0.orig/enable/drag.py0000644000175000017500000002232211674463635017422 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.1.0.orig/enable/abstract_layout_controller.py0000644000175000017500000000022311674463635024144 0ustar varunvarun from traits.api import HasTraits class AbstractLayoutController(HasTraits): def layout(self, component): raise NotImplementedError enthought-chaco2-4.1.0.orig/enable/slider.py0000644000175000017500000004370111674463635017773 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.1.0.orig/enable/component.py0000644000175000017500000013467711674463635020530 0ustar varunvarun""" Defines the Component class """ from __future__ import with_statement # Enthought library imports from traits.api \ import Any, Bool, Delegate, Enum, Float, Instance, Int, List, \ Property, Str, Trait from kiva.constants import FILL, STROKE try: from kiva.gl import GraphicsContext as GraphicsContextGL except (ImportError, TypeError): class GraphicsContextGL(object): pass # 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 optional 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 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[:]) if self.use_backbuffer and (not isinstance(gc, GraphicsContextGL)): 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 _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): border = self._get_visible_border() 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.1.0.orig/enable/example_canvas.py0000644000175000017500000000267111674463635021500 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.1.0.orig/enable/overlay_container.py0000644000175000017500000000133011674463635022224 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.1.0.orig/enable/toolkit_constants.py0000644000175000017500000000450311674463635022267 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.1.0.orig/enable/text_field.py0000644000175000017500000005146311674463635020644 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.1.0.orig/enable/base.py0000644000175000017500000002154311674463635017423 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.1.0.orig/enable/controls.py0000644000175000017500000005371211674463635020357 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.1.0.orig/enable/radio_group.py0000644000175000017500000000667511674463635021034 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.1.0.orig/enable/tools/0000755000175000017500000000000011674463635017272 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/tools/resize_tool.py0000644000175000017500000000525511674463635022211 0ustar varunvarun from traits.api import Bool, Enum, Tuple from drag_tool import DragTool class ResizeTool(DragTool): """ Generic tool for resizing a component """ 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 # ResizeTool will be useful. auto_raise = Bool(True) _corner = Enum("ul", "ur", "ll", "lr") _offset = Tuple(0, 0) # 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 is not None: 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 is not None: component = self.component self._prev_pos = (event.x, event.y) # Figure out which corner we are resizing if event.x > component.x + component.width/2: cx = 'r' # right x_offset = component.x2 - event.x + 1 else: cx = 'l' # left x_offset = event.x - component.x + 1 if event.y > component.y + component.height/2: cy = 'u' # upper y_offset = component.y2 - event.y + 1 else: cy = 'l' # lower y_offset = event.y - component.y + 1 self._corner = cy + cx self._offset = (x_offset, y_offset) 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): # FIXME: this function appears to do nothing. if self.component is not None: #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] offset = self._offset if self._corner[1] == 'l': # left raise NotImplementedError else: # right x2 = event.x + offset self.component._layout_needed = True self.component.request_redraw() self._prev_pos = (event.x, event.y) event.handled = True return enthought-chaco2-4.1.0.orig/enable/tools/api.py0000644000175000017500000000040311674463635020412 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 enthought-chaco2-4.1.0.orig/enable/tools/__init__.py0000644000175000017500000000000011674463635021371 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/tools/toolbars/0000755000175000017500000000000011674463635021117 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/tools/toolbars/__init__.py0000644000175000017500000000000011674463635023216 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/tools/toolbars/toolbar_buttons.py0000644000175000017500000001041611674463635024713 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.1.0.orig/enable/tools/toolbars/viewport_toolbar.py0000644000175000017500000000703311674463635025075 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.1.0.orig/enable/tools/viewport_pan_tool.py0000644000175000017500000000774711674463635023435 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.1.0.orig/enable/tools/traits_tool.py0000644000175000017500000000675111674463635022220 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.1.0.orig/enable/tools/viewport_zoom_tool.py0000644000175000017500000002517611674463635023637 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.1.0.orig/enable/tools/tool_history_mixin.py0000644000175000017500000001115311674463635023607 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.1.0.orig/enable/tools/base_zoom_tool.py0000644000175000017500000000540511674463635022663 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.1.0.orig/enable/tools/hover_tool.py0000644000175000017500000001214011674463635022022 0ustar varunvarun""" Tool to detect when the user hovers over a specific part of an underlying components. """ # 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.1.0.orig/enable/tools/move_tool.py0000644000175000017500000000325611674463635021655 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.1.0.orig/enable/tools/drag_tool.py0000644000175000017500000001602411674463635021621 0ustar varunvarun""" Defines the base DragTool class. """ # Enthought library imports from traits.api import Bool, Enum, Tuple from enable.base_tool import BaseTool 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 = Tuple("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) #------------------------------------------------------------------------ # 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): old_state = self._drag_state self._drag_state = "nondrag" if old_state == "dragging": self.drag_cancel(event) self._mouse_down_received = False if event.window.mouse_owner == self: event.window.set_mouse_owner(None) return def _drag_cancel_keypressed(self, event): if self._drag_state != "nondrag": self._cancel_drag(event) return True 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): state = self._drag_state if self.end_drag_on_leave: self._mouse_down_received = False if state == "dragging": return self.drag_cancel(event) else: if event.window.mouse_owner == self: event.window.set_mouse_owner(None) return False def _drag_mouse_enter(self, event): state = self._drag_state if state == "nondrag": pass elif state == "dragging": pass return False # EOF enthought-chaco2-4.1.0.orig/enable/colors.py0000644000175000017500000003065511674463635020016 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.1.0.orig/enable/base_tool.py0000644000175000017500000001334011674463635020454 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.1.0.orig/enable/abstract_overlay.py0000644000175000017500000000641511674463635022056 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.1.0.orig/enable/null/0000755000175000017500000000000011674463635017104 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/null/cairo.py0000644000175000017500000000130611674463635020553 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.1.0.orig/enable/null/__init__.py0000644000175000017500000000000011674463635021203 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/null/quartz.py0000644000175000017500000000360311674463635021006 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.1.0.orig/enable/null/ps.py0000644000175000017500000000147511674463635020107 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.1.0.orig/enable/null/image.py0000644000175000017500000000140611674463635020541 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.1.0.orig/enable/null/pdf.py0000644000175000017500000000204511674463635020230 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.1.0.orig/enable/null/svg.py0000644000175000017500000000130411674463635020253 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.1.0.orig/enable/null/qpainter.py0000644000175000017500000000131011674463635021274 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.1.0.orig/enable/stacked_layout.py0000644000175000017500000001341511674463635021523 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.1.0.orig/enable/component_layout_category.py0000644000175000017500000000123311674463635023777 0ustar varunvarun""" FIXME: Tentative implementation of a new layout mechanism. Unused and unworking. """ # Enthought library imports from traits.api import Any, Category, Enum # Singleton representing the default Enable layout manager DefaultLayoutController = LayoutController() class ComponentLayoutCategory(Category, Component): """ Properties defining how a component should be laid out. """ resizable = Enum('h', 'v') max_width = Any min_width = Any max_height = Any min_height = Any # Various alignment and positioning functions def set_padding(self, left, right, top, bottom): pass def get_padding(self): pass enthought-chaco2-4.1.0.orig/enable/font_metrics_provider.py0000644000175000017500000000153511674463635023116 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.1.0.orig/enable/wx/0000755000175000017500000000000011674463635016570 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/wx/cairo.py0000644000175000017500000000326011674463635020240 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.1.0.orig/enable/wx/__init__.py0000644000175000017500000000000011674463635020667 0ustar varunvarunenthought-chaco2-4.1.0.orig/enable/wx/gl.py0000644000175000017500000000427211674463635017551 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.1.0.orig/enable/wx/quartz.py0000644000175000017500000000661011674463635020473 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.1.0.orig/enable/wx/image.py0000644000175000017500000000506711674463635020234 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.1.0.orig/enable/wx/base_window.py0000644000175000017500000004561311674463635021454 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 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.1.0.orig/enable/wx/scrollbar.py0000644000175000017500000002705211674463635021133 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.1.0.orig/enable/wx/constants.py0000644000175000017500000000642111674463635021161 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.1.0.orig/enable/markers.py0000644000175000017500000002326511674463635020160 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 enthouhgt.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.1.0.orig/enable/images.zip0000644000175000017500000005506511674463635020136 0ustar varunvarunPK]r]/$@ checkbox.png sb``p  $vk)b x<E P01bN)o bݚCef9fCڶq;}&㎚+R=\ݽ(p9.>{̗K/)ҼxXOZ1ͫg8EfOW?uN MPKxr]/Gcheckbox_down.png sb``p  $vk)b x<E P1bN)_.֛hiȩ2́k7ꗶ w.lmϬؒ$,<<?ڥz2gMv_-kym]~˗]<T\wh+B#J.+IENDB`PK r]/1Wppcheckbox_on_over.pngPNG  IHDR s+ pHYsod"IDATxϿK@!]?wѡPB\I\K⢦ RjP*Dhg].wPx}ߗ˗L._?]]ʷ|9b%ƻi/6[_Ļ#Kocq)%3d#@ߕ+'3J,B6'ojq!'Fl$&kڅF-f F;ܫhڬ pRwsI+sK]\2a43)kS֡[J"hN*:z;+ =["8_IENDB`PKlr]/j checkbox_over.png sb``p  $vk)b x<E PpcHŜ 9 l'X/vw߽7?>=tWj$_8UX/pкw'3~gػW.xwhջqwM|n럝1@^a`{}?7-CAGjf~,[@2?R@0xsJhPK ^c/Zv radio.pngPNG  IHDR r|bKGD pHYs  5IDATxڕ=kPWKAK'q#ĵK8(J"PB."؀`SSHvj[Á;=%ȱ&U;X;G4"]cl鸽\ǧwJTtx;NDTC?j;#[f N*j,IENDB`PK ^c/xIJ*radio_down.pngPNG  IHDR r|bKGD pHYs  6IDATxڕK`+1ًt/ !`EC;-JF"o1HGy/I_Dcć$D$>"UXCeԍ.r&XA39;{8[<1 XA&1XAnpwM "1X L]j%YXa` :JJ l 3dȠ6 3a;x}*fD|!fP4-y k ljrӋ4뇈rURu[<>Vh4j5+Q(?DK EBP451f/gQWhl:6K'(D8N$ v27qwNf ./9 pHYsodIDATxM0%<N hS\FeaEw3~$.ZUܷEJ!~B,[x``p;c̺Žx).q6Yň!v>Ħk' :wnl/H{nj *6b` 2}ܗݛ:k&-eSBPK3\p/X|sb_hright_down.png sb``p ,@,$K;f1)$ow `@b# 8UO(81Vd|/#2lJۆԨ'0?dY2`ڷO"vK9ЄaUޭ$Ufp16i/a4seYΥO'Z?0gfiSK+y9_ޫ[li›NetsYPKX[p/;4sb_hright_over.png sb``p ,@,$K;f1)$ow `@b# 8UO(81V9[C-?T0#g0RdžM5EE3h28{Lqu&_{Rzts Rj|b…xV7$=CѓYsmݺ0V\E/cU^tj~;t:&PK,n/lOª sb_htrack.png sb``p  @,$,W)b x<E P01bݫy xX/2EGqPjRW/oOY#6eؔ;~Sfkؾu[YٶXb)T.3?m [T'^Q9EMgtsYPKX\p/Lsb_hpad_down.png sb``p  @,$,W)$ow `@b# 8UO(XRqkC7w[$5HL*.f 3ہbUW!m7Ҏ) PK n/9zsb_vbottom.pngPNG  IHDRC pHYsodIDATx˱ 0@|ɥ\HmڭZBb)`:Q&Z4<Y/.:Vr[2a3aSe6-G{y+&-f:a 3^ǒ0u:? 4:7)Z-q h&U?%oH'iIENDB`PK[p/4+sb_vbottom_down.png sb``p ҂@$8)$ow `@b# 8UO(1Vi{&\ ]HqJ.z;G5AՁEXtum\k1{Mz|񬧷NqgMJeT71+ojTf_^\0g$fqTaхTy~\%WQ0_qs5z@2xsJhPKZp/|sb_vbottom_over.png sb``p ҂@$8)$ow `@b# 8UO(RqF&:X"QIIeW>-6nWcLL]>Qr S ד|&n F'UBk,k;c| ?Oߗ]N\7?6M<]\9%4PK ,n/-L_ sb_vmid.pngPNG  IHDR " pHYsodIDATxK @E8lP?m‰zm9o#)Y(DI'#{̦PdHt2{dY=0H{gy~hA`xg|:o{UIENDB`PK[p/[osb_vmid_down.png sb``p ҂@$)}RlI. Ap品" |G@q64P1ѳ4<ܷK#YX.0v^_E'z'v.sy;|6{zȣ`Lӫtϖǹ|z5oy.J]sk0R_V)0Zykcٟ56쿔,OW?uN MPKZp/%U sb_vmid_over.png sb``p ҂@$)}RlI. Ap品" |G@q64P01VrŗwYv}ҳWc->oKrҚǺ-Zܸ5=Jr˄|_=!YXnyFC˂c?&̎6Z) PKHn/ sb_vpad.png sb``p ҂@$5Y)b x<E P1bӎ|[xhӤ4'SGldYK}_k0/]eEڮ<(xYL VA\Mg,,,nn+:8l%\6JX{IENDB`PK[p/~Asb_vtop_down.png sb``p ҂@$8)$ow `@b# 8UO(1V\MEk(>aG;[ nVHLv /<=Afd,Mv=QjhXfOghi_/RJ)GOt^s~ZޜKEkq3W3WЍ7>Vsb%sC)_ݿK|\t1:&PKZp/zsb_vtop_over.png sb``p ҂@$8)$ow `@b# 8UO(XRq^C ^2GҤAK:r'ZX 0fӎʚ׮>P/V-2+dݦr%8a3 f}Xb][I{X^ ha8\[ RoJ̛f*g*]) PKn/U# sb_vtrack.png sb``p ҂@$5Y)b x<E P1by(8|?olLN۫b}keIy D?z?+vJ^ߝh:&PK\p/Ä_sb_vpad_down.png sb``p ҂@$5Y)$ow `@b# 8UO(XRqi[f ;dpN^d9]A~(}q+R7osg=,ڗ}~c:OMoVs~\gkp΋#%{9nϸnm |%Kj'>[PY5VeS<]\9%4PK[p/=qxsb_vpad_over.png sb``p ҂@$5Y)$ow `@b# 8UO(RqiG. [m.p֫m=Yk[p\>8S &.{vdL)[Ձx>V'^ gPYbu ~.PK cn/v]ff sb_adown.pngPNG  IHDRЭ pHYsodIDATxn0 {؄=\ mV 0> N(X5&MۤBwGXΙKQǥ̥H l/L $lvPGa.(M$xN }bsp0ebqsUB>Rc{bsa9ݖLBp': PNK<<@SShDCB(45:}+ Ğ'he$0k4 Ҽo// 9mg9YHSlԴA&as ! i=c '#ڛS9q\|!D>Ir74GPqʼnk(81N`g1c lNsɠ62%;VFa)L>} ]ƛ c^_[bt";$nHU+NtmE%V,O-kZLPPCA[2BRovRwpJo.zzKe. <ʼ..+Хh7IENDB`PK Zp/?rYsb_adown_down.pngPNG  IHDRЭbKGD pHYs+LIDATxڍoo@A^o`Tb6P:uVfK[&-Y8G HzWd9l}\rsw^AkD);d6jx6XW}vXO"åcRJ}Lfs0q`3I;lʎʈ'ZûmRzep>o0PySG| (*R̪h_# b6o:iDР"j:Rg 悀`3fs^' 'KX,!7]Syf9f8$c?$nJ$aQEg#>5N 'Jirk>uYgz("C@=qf 56=VB + Ti;RBe'W% [[`MNB\ڋ@۟` O NB<@B U)Í:|@ۇÙYs/tIH(B2;p-wB7|Y:"3o`^ZZlZD?vJMҿE)U5qǏ6G_\~$n0{,w`ҧsIENDB`PK Yp/usb_adown_over.pngPNG  IHDRЭbKGD pHYs+-IDATxڕO@pK{c|_Ye?F;FbȠJ{֖Et}r<\r]g _r/}8[fwTug]pϓm׉nCo ]0|P)HoVl?D \ǧ͞hA@0]%^9Mvun'\@uoBafFؼX9ꋓ.Ф\!Iy̬b3'}H>@()%騈F:fO$(@p`ShZFuÁjC2:8EH1W'>qF`Ӆ(u23Ja^wB pk&dގ&-_h:%;!nwĦ L-[ci0JIOmXf˔ͱ7?-[Ŋ%UlbK]Xyedު!bi͘z?~pW~VrdVꩂ*w/;E>IENDB`PK n/cc sb_aleft.pngPNG  IHDRЭ pHYsodIDATxo0qݷ$ĺ$.k6'ݴNKڮ2Q$4?q`}eѓGnWw{}CB׈RωBJqq 5qd0kK`]U/cwu bx b͡E3SŦ;G@ bӌ &gŧ+/g߸Cp8!4Ya_L"vLO`Sb@JE2ADDl LcEG)XL l|hD[;˽=ُtFe7lx*IENDB`PK XZp/&>llsb_aleft_down.pngPNG  IHDRЭbKGD pHYs+ IDATxڕn@}>DߣU>@!R C?a 5P*U);QHoOF%oD\ /:MiRok^rho-2D9#n؅3D x#DšrÍuJыbAd鍤,47o6;a6 (3jq#f "` l*t90)TL |,6TjԠ̉ "֍₋*{L1 9'Xg(TOTRah[=|쉙!ByIOr pɥ5kg5(x{JL .ՃV\(PrWoęi3sڎk~f0`yu]w*e*J~vf'-=ս 7VZw'8IhWqmBgZ>>mO~p=9⪃PdxXY/~IENDB`PK "Zp/])j}}sb_aleft_over.pngPNG  IHDRЭbKGD pHYs+IDATxڕOP& 4Ʒ,)+$:&vLD66N紅82:2}N^tNN'OHI`ʶ糙{zɞ\&-`Nۯkl|>6<eJV}sü =.Rj?t Rr@y =ntOmT69MOC @xo=u n NS ٵ S=;:qQeaZnIl,gCq.!6BS L]lR\{`b>!Į'I.#TڝACEq%R 0oIeMKP}RnU ZnpЮ'bDc9}d̜5ΩΩE +(su=,ja0L=g/sz&yCbdzFS K)l\1؋Ys Jk_N{#]z~>x^H7;cf"ݼڿQeO.8/ДZyIENDB`PK n/cc sb_aright.pngPNG  IHDRЭ pHYsodIDATxn@q`"*R U A,bpak 4QT1S](a@^J0 ".@p ^Y'YfԤ[^ Y*=sV7oD naqx 0*Sƒ‰f&9cw>:䥽8:~-0 2=VIENDB`PK Zp/wwsb_aright_down.pngPNG  IHDRЭbKGD pHYs+IDATxڕn@a`"t*R dU |!18%3ƸJSA c{t(ѷufFGZ.f% kr1q(Ӗ^T'N4ܤf՛Zgxs*!OS0O;vĭLMNݯ (͟{}t,ܡ?Cn b`20|h\]#72'ÂNEIm9 ЉpL#'=d dNL%kP W /SIx'7+ dFē񋽱l_UNy5'FZ_BDfc2gb./^^ms> LNh0Μf0|sFu& =^[~dӜ↗7iޤN3˕n^'BxΝdekcAqVg8TbY 7XjR;K]̖xZ#ycooY$(; ʓ?t JUIENDB`PK vZp/sb_aright_over.pngPNG  IHDRЭbKGD pHYs+%IDATxڕOP$ 4ķ,lSW"ItLLD7B7N紅82:2}N^JO>v0+*kpQgQI3ܖL-9/XKm8EEu%Вދ%~+KɕT @F;]tT-Z)7dJm @zaZMX)ZBuŪKK#c_oش΢asSEMNMN .VTEGQYQoyhK\2)+fd#2~cUMZ Sp]UvTʴn_JZ\fvv^W8:~^ٙ=IENDB`PK 8n/Iqq sb_aup.pngPNG  IHDRЭ pHYsod#IDATxn@ {$=BNZE P06`]v 4*R0Ʊw6ۃ4ܲ4EBdϣHJ0MM$T'ny_XTJymUz WA@™ r+AdI)ǟqt~ `E,,&BgVJwyIހ``|nPGM$TL0}K K 8 x\c01rO=P4'pAxu )7&`Lϸʠ=1vXln#Yd]jcƼyMA͎tMM7Vn' ㅇP}/n}t6X+7{UVaxy^MQKBIENDB`PK Yp/´ٱsb_aup_down.pngPNG  IHDRЭbKGD pHYs+QIDATxڍO@qAŬlmukd@OТ@A@MA41椅-ΐ=̻],1V6޼|>%a>1vrzbZDbfM_0fƓy\X3c_]z&1~M$LJ>eE,X\ -;wn0{qJSTmKk _fIENDB`PK Yp/v%sb_aup_over.pngPNG  IHDRЭbKGD pHYs+9IDATxڕOPpK{1>hee%DĎG`"2hF (Z^X[JffMos='9c9~w,6{G۾t+f"u{btlyh9vb}8DBdCُ.Q@sA "a*m"LaNtJ,@EF/:> ٹ gWj ُ~T:+;Ц\"a6屙Z$fz'(.JgH$ܢ\"D jbm"fn@ 1)ՔL̳/x߬EA[# :[AAa׻}bBi"bvOn\Hz>| p݁T:@ӂHF̓0\8C< p lb@ynS0踑 q;F†y4s2@"LAЦ\/$\3Æ6\Wy,Lf 5Kr,(hޑgfs++EV\O]uz sb_hleft.pngPNG  IHDRu pHYsodIDATxe PEdLQZbe nD=ǯME0a($D/ 9 D/ y4%_N[qC?g*&TObiUGAfi]^L~3ѮT\.Y-n ̖I- (PizW`0v븀IENDB`PK \p/uQsb_hleft_down.png sb``p ,@,$K;f1)$ow `@b# 8UO(1V d|_K%3M8}`f掌WOFq/NOOKO8~@Fӯў F[.*RcXKsue .cxd >OlpC9Zfܿw>oo_˪"8:eSBPK/[p/iFsb_hleft_over.png sb``p ,@,$K;f1)$ow `@b# 8UO(XRq!wL ]`i*n.\r-25W7{G*0ox=yc&U|fo n%-*(po+3yWXmqlHuJ' 'jK~ h5) ~.PK n/b4 sb_hmid.pngPNG  IHDR kA pHYsodIDATxA 0wzPTRJZ2xfcՍ $|?_/xG Xhgװľ%Ɔ^|ݚ$n:;ATҹll%ˇv86?a4O M3@fy*IENDB`PKF\p/Fsb_hmid_down.png sb``p  v\ H%y0{OpxD30aƩ|@).!Z/jri{i E[98KX+dpݎ>8s996{fW~Uآn[Vn09o{Սmidz26_XqٹxFu!]?Skk?mp2߳f~8#sw-ۧ) 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/uM dsb_hmid_over.pngPK n/jc   Vsb_hpad.pngPK n/jy 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/9z 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 Hn/ !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 cn/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 8n/Iqq @sb_aup.pngPK Yp/´ٱ Csb_aup_down.pngPK Yp/v% Esb_aup_over.pngPK yn/y> Hsb_hleft.pngPK  \p/uQ Isb_hleft_down.pngPK /[p/iF Ksb_hleft_over.pngPK n/b4 Lsb_hmid.pngPK F\p/F Msb_hmid_down.pngPK22 2Nenthought-chaco2-4.1.0.orig/enable/compiled_path.py0000644000175000017500000000151311674463635021314 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.1.0.orig/enable/new_abstract_component.py0000644000175000017500000001400111674463635023236 0ustar varunvarun""" Defines the AbstractComponent class """ # Enthought library imports from traits.api import Any, Enum, Instance, List, Property # Local relative imports from enable_traits import coordinate_trait from interactor import Interactor class AbstractComponent(Interactor): """ AbstractComponent is the primitive base class for Component. It only requires the ability to handle events and render itself. It supports being contained within a parent graphical object and defines methods to handle positions. It does not necessarily have bounds, nor does it have any notion of viewports. """ #------------------------------------------------------------------------ # Positioning traits #------------------------------------------------------------------------ # The position relative to the container. If container is None, then # position will be set to (0,0). position = coordinate_trait # X-coordinate of our position x = Property # Y-coordinate of our position y = Property #------------------------------------------------------------------------ # Object/containment hierarchy traits #------------------------------------------------------------------------ # Our container object container = Any # Instance("Container") # A reference to our top-level Enable Window window = Property # Instance("Window") # The list of viewport that are viewing this component viewports = List(Instance("enable.Viewport")) #------------------------------------------------------------------------ # Other public traits #------------------------------------------------------------------------ # How this component should draw itself when draw() is called with # a mode of "default". (If a draw mode is explicitly passed in to # draw(), then this is overruled.) # FIXME: Appears to be unused 5/3/6 default_draw_mode = Enum("normal", "interactive") #------------------------------------------------------------------------ # 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") #------------------------------------------------------------------------ # Public concrete methods # (Subclasses should not override these; they provide an extension point # for mix-in classes.) #------------------------------------------------------------------------ def __init__(self, **traits): # The only reason we need the constructor is to make sure our container # gets notified of our being added to it. if traits.has_key("container"): container = traits.pop("container") Interactor.__init__(self, **traits) container.add(self) else: Interactor.__init__(self, **traits) 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 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 #------------------------------------------------------------------------ # Abstract public and protected methods that subclasses can override #------------------------------------------------------------------------ def is_in(self, x, y): """ Returns True if the point (x,y) is inside this component, False otherwise. Even though AbstractComponents are not required to have bounds, they are still expected to be able to answer the question, "Does the point (x,y) lie within my region of interest?" If so, then is_in() should return True. """ raise NotImplementedError def _request_redraw(self): if self.container is not None: self.container.request_redraw() elif self._window: self._window.redraw() return #------------------------------------------------------------------------ # Event handlers, getters & setters #------------------------------------------------------------------------ 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] return def _position_changed(self): if self.container is not None: self.container._component_position_changed(self) return 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_window(self, win): return self._window def _set_window(self, win): self._window = win return ### Persistence ########################################################### def __getstate__(self): state = super(AbstractComponent,self).__getstate__() for key in ['_window', 'viewports']: if state.has_key(key): del state[key] return state # EOF enthought-chaco2-4.1.0.orig/enable/primitives/0000755000175000017500000000000011674463635020325 5ustar varunvarunenthought-chaco2-4.1.0.orig/enable/primitives/api.py0000644000175000017500000000017711674463635021455 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.1.0.orig/enable/primitives/__init__.py0000644000175000017500000000004711674463635022437 0ustar varunvarun""" Drawing primitives for Enable """ enthought-chaco2-4.1.0.orig/enable/primitives/annotater.py0000644000175000017500000000520111674463635022670 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.1.0.orig/enable/primitives/line.py0000644000175000017500000000727711674463635021643 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.1.0.orig/enable/primitives/shape.py0000644000175000017500000001222511674463635022001 0ustar varunvarun""" The base class for moveable shapes. """ # Standard library imports. import math # Enthought library imports. from enable.api import ColorTrait, Component, 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.1.0.orig/enable/primitives/polygon.py0000644000175000017500000001474111674463635022375 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.1.0.orig/enable/primitives/box.py0000644000175000017500000000253711674463635021476 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.1.0.orig/image_LICENSE_OOo.txt0000644000175000017500000001641111674463635020450 0ustar varunvarunGNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, this License refers to version 3 of the GNU Lesser General Public License, and the GNU GPL refers to version 3 of the GNU General Public License. The Library refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An Application is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A Combined Work is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the Linked Version. The Minimal Corresponding Source for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The Corresponding Application Code for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: * a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or * b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: * a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. * b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: * a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. * b) Accompany the Combined Work with a copy of the GNU GPL and this license document. * c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. * d) Do one of the following: o 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. o 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. * e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: * a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. * b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License or any later version applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. enthought-chaco2-4.1.0.orig/setup.py0000644000175000017500000001216211674463636016421 0ustar varunvarun# Copyright (c) 2008-2011 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 os import shutil from numpy.distutils.core import setup info = {} execfile(join('enable', '__init__.py'), info) # 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 # 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 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", "macport.so"), join("quartz", "ABCGI.c"), join("quartz", "ATSFont.so"), join("quartz", "ATSFont.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) setup( name = 'enable', version = info['__version__'], author = 'Enthought, Inc', author_email = 'info@enthought.com', maintainer = 'ETS Developers', maintainer_email = 'enthought-dev@enthought.com', url = 'http://code.enthought.com/projects/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(), download_url = ('http://www.enthought.com/repo/ets/enable-%s.tar.gz' % info['__version__']), install_requires = info['__requires__'], license = 'BSD', package_data = {'': ['*.zip', '*.svg', 'images/*']}, platforms = ["Windows", "Linux", "Mac OS-X", "Unix", "Solaris"], setup_requires = [ 'cython', ], zip_safe = False, **config ) enthought-chaco2-4.1.0.orig/image_LICENSE_Eclipse.txt0000644000175000017500000002604311674463635021342 0ustar varunvarunEclipse Public License - v 1.0 THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENTS ACCEPTANCE OF THIS AGREEMENT. 1. DEFINITIONS "Contribution" means: a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and b) in the case of each subsequent Contributor: i)changes to the Program, and ii)additions to the Program; where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributors behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. "Contributor" means any person or entity that distributes the Program. "Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. "Program" means the Contributions distributed in accordance with this Agreement. "Recipient" means anyone who receives the Program under this Agreement, including all Contributors. 2. GRANT OF RIGHTS a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipients responsibility to acquire that license before distributing the Program. d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. 3. REQUIREMENTS A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: a) it complies with the terms and conditions of this Agreement; and b) its license agreement: i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. When the Program is made available in source code form: a) it must be made available under this Agreement; and b) a copy of this Agreement must be included with each copy of the Program. Contributors may not remove or alter any copyright notices contained within the Program. Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. 4. COMMERCIAL DISTRIBUTION Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributors responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. 5. NO WARRANTY EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. 6. DISCLAIMER OF LIABILITY EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), 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 OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 7. GENERAL If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipients patent(s), then such Recipients rights granted under Section 2(b) shall terminate as of the date such litigation is filed. All Recipients rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipients rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipients obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. enthought-chaco2-4.1.0.orig/TODO.txt0000644000175000017500000000037611674463635016220 0ustar varunvarun* Clean-up the failing import of enthought.freetype in kiva.trait_defs.ui.wx.kiva_font_editor. * Clean-up imports of enable (I mean NOT enable2) done in: enable2/traits/ui/wx/enable_rgba_color_editor.py * Clean-up direct imports of traitsui.wx enthought-chaco2-4.1.0.orig/image_LICENSE_CP.txt0000644000175000017500000004401411674463635020256 0ustar varunvarunLicense The Crystal Project are released under LGPL. GNU General Public License. 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: 1. The modified work must itself be a software library. 2. You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. 3. You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. 4. If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: 1. Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) . 2. Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. 3. Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. 4. If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. 5. Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: 1. Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. 2. Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. No Warranty 15. Because the library is licensed free of charge, there is no warranty for the library, to the extent permitted by applicable law. Except when otherwise stated in writing the copyright holders and/or other parties provide the library "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the library is with you. Should the library prove defective, you assume the cost of all necessary servicing, repair or correction. 16. In no event unless required by applicable law or agreed to in writing will any copyright holder, or any other party who may modify and/or redistribute the library as permitted above, be liable to you for damages, including any general, special, incidental or consequential damages arising out of the use or inability to use the library (including but not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a failure of the library to operate with any other software), even if such holder or other party has been advised of the possibility of such damages.