³ò ÓÔ±Ic@sœddkZddkZddkZddkZd„Zdd„Zdd„ZdZdd„Zd „Z d d „Z d d „Z e d ƒe d ƒdS(iÿÿÿÿNcCst|ddƒS(s;Scale a floating-point value in [-1,1] to an int in [0,255]gà_@(tint(tz((sart.pyttoBytesi–c CsáyÇd|d}tid||fƒ}x–td|ƒD]…}x|td|ƒD]k}t||ƒ|}t||ƒ |}t|||ƒ}t|ddƒ} |i||f| ƒqOWq9W|SWntdƒ‚nXdS(NiitLigà_@tOops(tImagetnewtrangetfloattevalExpRtputpixelt Exception( texpt pixelsPerUnitt canvasWidthtcanvastpytpxtxtyRt intensity((sart.pyt plotIntensity scCsFt||ƒ}t||ƒ}t||ƒ}tid|||fƒS(sBReturn an image constructed from the three RGB intensity functionstRGB(RRtmerge(tredExptgreenExptblueExpR tredPlanet greenPlanet bluePlane((sart.pyt plotColor!stSigcse09i cCs|djotiddƒ}t|Sntiddƒ}|djot|t|dƒgSn&t|t|dƒt|dƒgSdS(Niiiii(trandomtrandintt keyphraset buildExpr(tdepthtn((sart.pyR#*s   cCsk|djo|SnS|djo|Sn>|ddjo,t|d||ƒt|d||ƒSn|ddjo0t|d||ƒt|d||ƒdSnÀ|dd jo(titit|d||ƒƒSn‡|dd jo(titit|d||ƒƒSnN|dd jot|||ƒn)|d jotit|dƒƒSndS( NtStiitgiitcg@tstet0t9(R tmathtsintpitcostsqrt(R+RR((sart.pyR 6s   ,0(( icCsktiƒxZtd|ƒD]I}dt|ƒd}|GHtƒ}t|ƒ}|i|dƒdGHqWdS(s?Creates n grayscale image files named gray0.png, gray1.png, ...itgrays.pngtPNGs doneN(R tseedRtstrR#Rtsave(tnumPicsR'tfilenametgrayExptimage((sart.pytmakeGrayHs   cCsƒtiƒxrtd|ƒD]a}dt|ƒd}|GHtƒ}tƒ}tƒ}t|||ƒ}|i|dƒdGHqWdS(s=Creates n color image files named color0.png, color1.png, ...itcolors.pngR4s doneN(R R5RR6R#RR7(R8R'R9RRRR;((sart.pyt makeColorSs    i( R R.t tracebackRRRRR"R#R R<R>(((sart.pyss0