Mercurial > MadButterfly
changeset 939:a74b4d986a91
Move examples for nodejs into nodejs/examples/ sub-directories.
See INSTALL.txt. Use nodejs/examples/run.sh to run examples.
For example,
cd nodejs/examples; ./run.sh examples/testsvg/testsvg.js
line wrap: on
line diff
--- a/nodejs/INSTALL.txt Fri Nov 12 17:08:13 2010 +0800 +++ b/nodejs/INSTALL.txt Fri Nov 12 17:39:04 2010 +0800 @@ -20,5 +20,5 @@ ~user/MadButterfly/nodejs$ export NODE_PATH=objs/default (5) Execute testsvg.js - ~user/MadButterfly/nodejs$ node testsvg.js + ~user/MadButterfly/nodejs$ ./run examples/testsvg/testsvg.js
--- a/nodejs/desktop.svg Fri Nov 12 17:08:13 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,507 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> - -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:xlink="http://www.w3.org/1999/xlink" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="744.09448" - height="480" - id="svg2" - version="1.1" - inkscape:version="0.47 r22583" - sodipodi:docname="desktop.svg"> - <defs - id="defs4"> - <inkscape:perspective - sodipodi:type="inkscape:persp3d" - inkscape:vp_x="0 : 240 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_z="744.09448 : 240 : 1" - inkscape:persp3d-origin="372.04724 : 160 : 1" - id="perspective21" /> - <linearGradient - inkscape:collect="always" - id="linearGradient3706"> - <stop - style="stop-color:#000000;stop-opacity:1;" - offset="0" - id="stop3708" /> - <stop - style="stop-color:#000000;stop-opacity:0;" - offset="1" - id="stop3710" /> - </linearGradient> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient3706" - id="linearGradient3712" - x1="0" - y1="240" - x2="747.27411" - y2="240" - gradientUnits="userSpaceOnUse" /> - <inkscape:perspective - id="perspective3711" - inkscape:persp3d-origin="0.5 : 0.33333333 : 1" - inkscape:vp_z="1 : 0.5 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_x="0 : 0.5 : 1" - sodipodi:type="inkscape:persp3d" /> - <inkscape:perspective - id="perspective2953" - inkscape:persp3d-origin="0.5 : 0.33333333 : 1" - inkscape:vp_z="1 : 0.5 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_x="0 : 0.5 : 1" - sodipodi:type="inkscape:persp3d" /> - <inkscape:perspective - id="perspective2981" - inkscape:persp3d-origin="0.5 : 0.33333333 : 1" - inkscape:vp_z="1 : 0.5 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_x="0 : 0.5 : 1" - sodipodi:type="inkscape:persp3d" /> - <inkscape:perspective - id="perspective3009" - inkscape:persp3d-origin="0.5 : 0.33333333 : 1" - inkscape:vp_z="1 : 0.5 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_x="0 : 0.5 : 1" - sodipodi:type="inkscape:persp3d" /> - <inkscape:perspective - id="perspective3037" - inkscape:persp3d-origin="0.5 : 0.33333333 : 1" - inkscape:vp_z="1 : 0.5 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_x="0 : 0.5 : 1" - sodipodi:type="inkscape:persp3d" /> - <inkscape:perspective - id="perspective3065" - inkscape:persp3d-origin="0.5 : 0.33333333 : 1" - inkscape:vp_z="1 : 0.5 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_x="0 : 0.5 : 1" - sodipodi:type="inkscape:persp3d" /> - <inkscape:perspective - id="perspective3093" - inkscape:persp3d-origin="0.5 : 0.33333333 : 1" - inkscape:vp_z="1 : 0.5 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_x="0 : 0.5 : 1" - sodipodi:type="inkscape:persp3d" /> - <inkscape:perspective - id="perspective2960" - inkscape:persp3d-origin="0.5 : 0.33333333 : 1" - inkscape:vp_z="1 : 0.5 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_x="0 : 0.5 : 1" - sodipodi:type="inkscape:persp3d" /> - <inkscape:perspective - id="perspective2988" - inkscape:persp3d-origin="0.5 : 0.33333333 : 1" - inkscape:vp_z="1 : 0.5 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_x="0 : 0.5 : 1" - sodipodi:type="inkscape:persp3d" /> - <inkscape:perspective - id="perspective3016" - inkscape:persp3d-origin="0.5 : 0.33333333 : 1" - inkscape:vp_z="1 : 0.5 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_x="0 : 0.5 : 1" - sodipodi:type="inkscape:persp3d" /> - <inkscape:perspective - id="perspective3016-0" - inkscape:persp3d-origin="0.5 : 0.33333333 : 1" - inkscape:vp_z="1 : 0.5 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_x="0 : 0.5 : 1" - sodipodi:type="inkscape:persp3d" /> - <inkscape:perspective - id="perspective3016-6" - inkscape:persp3d-origin="0.5 : 0.33333333 : 1" - inkscape:vp_z="1 : 0.5 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_x="0 : 0.5 : 1" - sodipodi:type="inkscape:persp3d" /> - <inkscape:perspective - id="perspective3016-7" - inkscape:persp3d-origin="0.5 : 0.33333333 : 1" - inkscape:vp_z="1 : 0.5 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_x="0 : 0.5 : 1" - sodipodi:type="inkscape:persp3d" /> - <inkscape:perspective - id="perspective3016-5" - inkscape:persp3d-origin="0.5 : 0.33333333 : 1" - inkscape:vp_z="1 : 0.5 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_x="0 : 0.5 : 1" - sodipodi:type="inkscape:persp3d" /> - </defs> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="1.56875" - inkscape:cx="207.9" - inkscape:cy="290.99601" - inkscape:document-units="px" - inkscape:current-layer="layer1" - showgrid="false" - inkscape:window-width="1440" - inkscape:window-height="900" - inkscape:window-x="-1" - inkscape:window-y="-1" - inkscape:window-maximized="0" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:groupmode="layer" - id="layer3" - inkscape:label="background" - sodipodi:insensitive="true" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="0" - inkscape:bbox-y="0" - inkscape:bbox-width="747.27411" - inkscape:bbox-height="480"> - <rect - style="fill:url(#linearGradient3712);fill-opacity:1" - id="rect2928" - width="747.27411" - height="480" - x="0" - y="0" - ry="3.0304577" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="0" - inkscape:bbox-y="0" - inkscape:bbox-width="747.27411" - inkscape:bbox-height="480" /> - </g> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="35.355339" - inkscape:bbox-y="249.90203" - inkscape:bbox-width="641.44684" - inkscape:bbox-height="219.19541" - style="display:inline"> - <g - id="g2917" - transform="translate(-27.274116,-798.02051)" - mbname="video" - inkscape:transform-center-x="0" - inkscape:transform-center-y="42.294399" - inkscape:bbox-x="35.992421" - inkscape:bbox-y="383.87928" - inkscape:bbox-width="85.598946" - inkscape:bbox-height="84.588799"> - <image - sodipodi:absref="/usr/home/thinker/progm/MadButterfly/nodejs/video.png" - xlink:href="video.png" - width="85.598946" - height="84.588799" - id="image2983" - x="63.266537" - y="809.55243" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="35.992421" - inkscape:bbox-y="383.87928" - inkscape:bbox-width="85.598946" - inkscape:bbox-height="84.588799" /> - </g> - <g - id="g2917-8" - transform="translate(126.77414,-798.02053)" - mbname="audio" - inkscape:transform-center-x="0" - inkscape:transform-center-y="38.464287" - inkscape:bbox-x="189.7836" - inkscape:bbox-y="386.37278" - inkscape:bbox-width="86.5" - inkscape:bbox-height="76.928574"> - <image - sodipodi:absref="/usr/home/thinker/progm/MadButterfly/nodejs/music.png" - xlink:href="music.png" - width="86.5" - height="76.928574" - id="image3048" - x="63.00946" - y="814.71918" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="189.7836" - inkscape:bbox-y="386.37278" - inkscape:bbox-width="86.5" - inkscape:bbox-height="76.928574" /> - </g> - <g - id="g2917-88" - transform="translate(290.67139,-799.03067)" - mbname="picture" - inkscape:transform-center-x="0" - inkscape:transform-center-y="38.07143" - inkscape:bbox-x="354.2955" - inkscape:bbox-y="392.95458" - inkscape:bbox-width="84" - inkscape:bbox-height="76.14286"> - <image - sodipodi:absref="/usr/home/thinker/progm/MadButterfly/nodejs/photo.png" - xlink:href="photo.png" - width="84" - height="76.14286" - id="image3049" - x="63.624115" - y="809.93323" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="354.2955" - inkscape:bbox-y="392.95458" - inkscape:bbox-width="84" - inkscape:bbox-height="76.14286" /> - </g> - <g - id="g2917-8-6" - transform="translate(462.9024,-794.99007)" - mbname="setting" - inkscape:transform-center-x="0" - inkscape:transform-center-y="37.57143" - inkscape:bbox-x="526.42387" - inkscape:bbox-y="389.0568" - inkscape:bbox-width="84.571426" - inkscape:bbox-height="75.14286"> - <image - sodipodi:absref="/usr/home/thinker/progm/MadButterfly/nodejs/tool.png" - xlink:href="tool.png" - width="84.571426" - height="75.14286" - id="image3168" - x="63.521473" - y="810.79041" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="526.42387" - inkscape:bbox-y="389.0568" - inkscape:bbox-width="84.571426" - inkscape:bbox-height="75.14286" /> - </g> - <rect - style="fill:#dfdf49;fill-opacity:1" - id="rect2929" - width="641.44684" - height="71.720833" - x="35.355339" - y="158.37714" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - rx="10" - ry="10" - inkscape:bbox-x="35.355339" - inkscape:bbox-y="249.90203" - inkscape:bbox-width="641.44684" - inkscape:bbox-height="71.720833" - mbname="lightbar" /> - <text - xml:space="preserve" - style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" - x="124.96794" - y="185.925" - id="text2931" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="126.28044" - inkscape:bbox-y="271.84843" - inkscape:bbox-width="488.15625" - inkscape:bbox-height="32.382812" - mbname="line1"><tspan - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - x="124.96794" - y="185.925" - id="tspan2935" - style="font-size:16px" - inkscape:bbox-x="126.53825" - inkscape:bbox-y="288.74687" - inkscape:bbox-width="487.89844" - inkscape:bbox-height="15.484375">Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up</tspan><tspan - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - x="124.96794" - y="205.925" - style="font-size:16px" - inkscape:bbox-x="126.28044" - inkscape:bbox-y="271.84843" - inkscape:bbox-width="75.335938" - inkscape:bbox-height="12.101562" - id="tspan2941">7:00-7:30</tspan></text> - <text - xml:space="preserve" - style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans" - x="124.96794" - y="247.75766" - id="text2931-20" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="126.28044" - inkscape:bbox-y="210.01578" - inkscape:bbox-width="488.15625" - inkscape:bbox-height="32.382812" - mbname="line2"><tspan - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - x="124.96794" - y="247.75766" - id="tspan2935-1" - style="font-size:16px" - inkscape:bbox-x="126.53825" - inkscape:bbox-y="226.91422" - inkscape:bbox-width="487.89844" - inkscape:bbox-height="15.484375">Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up</tspan><tspan - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - x="124.96794" - y="267.75766" - style="font-size:16px" - inkscape:bbox-x="126.28044" - inkscape:bbox-y="210.01578" - inkscape:bbox-width="75.335938" - inkscape:bbox-height="12.101562" - id="tspan2941-9">7:30-8:30</tspan></text> - <text - xml:space="preserve" - style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans" - x="124.96794" - y="309.59033" - id="text2931-21" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="126.05388" - inkscape:bbox-y="152.18311" - inkscape:bbox-width="488.38281" - inkscape:bbox-height="32.382812" - mbname="line3"><tspan - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - x="124.96794" - y="309.59033" - id="tspan2935-2" - style="font-size:16px" - inkscape:bbox-x="126.53825" - inkscape:bbox-y="169.08154" - inkscape:bbox-width="487.89844" - inkscape:bbox-height="15.484375">Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up</tspan><tspan - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - x="124.96794" - y="329.59033" - style="font-size:16px" - inkscape:bbox-x="126.05388" - inkscape:bbox-y="152.18311" - inkscape:bbox-width="75.5625" - inkscape:bbox-height="12.101562" - id="tspan2941-0">8:30-9:30</tspan></text> - <text - xml:space="preserve" - style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans" - x="124.96794" - y="371.423" - id="text2931-3" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="125.97575" - inkscape:bbox-y="90.350433" - inkscape:bbox-width="488.46094" - inkscape:bbox-height="32.382812" - mbname="line4"><tspan - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - x="124.96794" - y="371.423" - id="tspan2935-11" - style="font-size:16px" - inkscape:bbox-x="126.53825" - inkscape:bbox-y="107.24887" - inkscape:bbox-width="487.89844" - inkscape:bbox-height="15.484375">Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up</tspan><tspan - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - x="124.96794" - y="391.423" - style="font-size:16px" - inkscape:bbox-x="125.97575" - inkscape:bbox-y="90.350433" - inkscape:bbox-width="85.828125" - inkscape:bbox-height="12.101562" - id="tspan2941-90">9:30-10:30</tspan></text> - <text - xml:space="preserve" - style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans" - x="124.96794" - y="433.25568" - id="text2931-6" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="126.53825" - inkscape:bbox-y="28.517761" - inkscape:bbox-width="487.89844" - inkscape:bbox-height="32.382812" - mbname="line5"><tspan - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - x="124.96794" - y="433.25568" - id="tspan2935-7" - style="font-size:16px" - inkscape:bbox-x="126.53825" - inkscape:bbox-y="45.416199" - inkscape:bbox-width="487.89844" - inkscape:bbox-height="15.484375">Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up</tspan><tspan - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - x="124.96794" - y="453.25568" - style="font-size:16px" - inkscape:bbox-x="126.72575" - inkscape:bbox-y="28.517761" - inkscape:bbox-width="95.265625" - inkscape:bbox-height="12.101562" - id="tspan2941-7">10:30-11:30</tspan></text> - </g> -</svg>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/desktop/desktop.svg Fri Nov 12 17:39:04 2010 +0800 @@ -0,0 +1,507 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="744.09448" + height="480" + id="svg2" + version="1.1" + inkscape:version="0.47 r22583" + sodipodi:docname="desktop.svg"> + <defs + id="defs4"> + <inkscape:perspective + sodipodi:type="inkscape:persp3d" + inkscape:vp_x="0 : 240 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_z="744.09448 : 240 : 1" + inkscape:persp3d-origin="372.04724 : 160 : 1" + id="perspective21" /> + <linearGradient + inkscape:collect="always" + id="linearGradient3706"> + <stop + style="stop-color:#000000;stop-opacity:1;" + offset="0" + id="stop3708" /> + <stop + style="stop-color:#000000;stop-opacity:0;" + offset="1" + id="stop3710" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3706" + id="linearGradient3712" + x1="0" + y1="240" + x2="747.27411" + y2="240" + gradientUnits="userSpaceOnUse" /> + <inkscape:perspective + id="perspective3711" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective2953" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective2981" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3009" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3037" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3065" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3093" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective2960" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective2988" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3016" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3016-0" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3016-6" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3016-7" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + <inkscape:perspective + id="perspective3016-5" + inkscape:persp3d-origin="0.5 : 0.33333333 : 1" + inkscape:vp_z="1 : 0.5 : 1" + inkscape:vp_y="0 : 1000 : 0" + inkscape:vp_x="0 : 0.5 : 1" + sodipodi:type="inkscape:persp3d" /> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="1.56875" + inkscape:cx="207.9" + inkscape:cy="290.99601" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="1440" + inkscape:window-height="900" + inkscape:window-x="-1" + inkscape:window-y="-1" + inkscape:window-maximized="0" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:groupmode="layer" + id="layer3" + inkscape:label="background" + sodipodi:insensitive="true" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="0" + inkscape:bbox-y="0" + inkscape:bbox-width="747.27411" + inkscape:bbox-height="480"> + <rect + style="fill:url(#linearGradient3712);fill-opacity:1" + id="rect2928" + width="747.27411" + height="480" + x="0" + y="0" + ry="3.0304577" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="0" + inkscape:bbox-y="0" + inkscape:bbox-width="747.27411" + inkscape:bbox-height="480" /> + </g> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="35.355339" + inkscape:bbox-y="249.90203" + inkscape:bbox-width="641.44684" + inkscape:bbox-height="219.19541" + style="display:inline"> + <g + id="g2917" + transform="translate(-27.274116,-798.02051)" + mbname="video" + inkscape:transform-center-x="0" + inkscape:transform-center-y="42.294399" + inkscape:bbox-x="35.992421" + inkscape:bbox-y="383.87928" + inkscape:bbox-width="85.598946" + inkscape:bbox-height="84.588799"> + <image + sodipodi:absref="/usr/home/thinker/progm/MadButterfly/nodejs/video.png" + xlink:href="video.png" + width="85.598946" + height="84.588799" + id="image2983" + x="63.266537" + y="809.55243" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="35.992421" + inkscape:bbox-y="383.87928" + inkscape:bbox-width="85.598946" + inkscape:bbox-height="84.588799" /> + </g> + <g + id="g2917-8" + transform="translate(126.77414,-798.02053)" + mbname="audio" + inkscape:transform-center-x="0" + inkscape:transform-center-y="38.464287" + inkscape:bbox-x="189.7836" + inkscape:bbox-y="386.37278" + inkscape:bbox-width="86.5" + inkscape:bbox-height="76.928574"> + <image + sodipodi:absref="/usr/home/thinker/progm/MadButterfly/nodejs/music.png" + xlink:href="music.png" + width="86.5" + height="76.928574" + id="image3048" + x="63.00946" + y="814.71918" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="189.7836" + inkscape:bbox-y="386.37278" + inkscape:bbox-width="86.5" + inkscape:bbox-height="76.928574" /> + </g> + <g + id="g2917-88" + transform="translate(290.67139,-799.03067)" + mbname="picture" + inkscape:transform-center-x="0" + inkscape:transform-center-y="38.07143" + inkscape:bbox-x="354.2955" + inkscape:bbox-y="392.95458" + inkscape:bbox-width="84" + inkscape:bbox-height="76.14286"> + <image + sodipodi:absref="/usr/home/thinker/progm/MadButterfly/nodejs/photo.png" + xlink:href="photo.png" + width="84" + height="76.14286" + id="image3049" + x="63.624115" + y="809.93323" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="354.2955" + inkscape:bbox-y="392.95458" + inkscape:bbox-width="84" + inkscape:bbox-height="76.14286" /> + </g> + <g + id="g2917-8-6" + transform="translate(462.9024,-794.99007)" + mbname="setting" + inkscape:transform-center-x="0" + inkscape:transform-center-y="37.57143" + inkscape:bbox-x="526.42387" + inkscape:bbox-y="389.0568" + inkscape:bbox-width="84.571426" + inkscape:bbox-height="75.14286"> + <image + sodipodi:absref="/usr/home/thinker/progm/MadButterfly/nodejs/tool.png" + xlink:href="tool.png" + width="84.571426" + height="75.14286" + id="image3168" + x="63.521473" + y="810.79041" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="526.42387" + inkscape:bbox-y="389.0568" + inkscape:bbox-width="84.571426" + inkscape:bbox-height="75.14286" /> + </g> + <rect + style="fill:#dfdf49;fill-opacity:1" + id="rect2929" + width="641.44684" + height="71.720833" + x="35.355339" + y="158.37714" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + rx="10" + ry="10" + inkscape:bbox-x="35.355339" + inkscape:bbox-y="249.90203" + inkscape:bbox-width="641.44684" + inkscape:bbox-height="71.720833" + mbname="lightbar" /> + <text + xml:space="preserve" + style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + x="124.96794" + y="185.925" + id="text2931" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="126.28044" + inkscape:bbox-y="271.84843" + inkscape:bbox-width="488.15625" + inkscape:bbox-height="32.382812" + mbname="line1"><tspan + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + x="124.96794" + y="185.925" + id="tspan2935" + style="font-size:16px" + inkscape:bbox-x="126.53825" + inkscape:bbox-y="288.74687" + inkscape:bbox-width="487.89844" + inkscape:bbox-height="15.484375">Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up</tspan><tspan + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + x="124.96794" + y="205.925" + style="font-size:16px" + inkscape:bbox-x="126.28044" + inkscape:bbox-y="271.84843" + inkscape:bbox-width="75.335938" + inkscape:bbox-height="12.101562" + id="tspan2941">7:00-7:30</tspan></text> + <text + xml:space="preserve" + style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans" + x="124.96794" + y="247.75766" + id="text2931-20" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="126.28044" + inkscape:bbox-y="210.01578" + inkscape:bbox-width="488.15625" + inkscape:bbox-height="32.382812" + mbname="line2"><tspan + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + x="124.96794" + y="247.75766" + id="tspan2935-1" + style="font-size:16px" + inkscape:bbox-x="126.53825" + inkscape:bbox-y="226.91422" + inkscape:bbox-width="487.89844" + inkscape:bbox-height="15.484375">Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up</tspan><tspan + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + x="124.96794" + y="267.75766" + style="font-size:16px" + inkscape:bbox-x="126.28044" + inkscape:bbox-y="210.01578" + inkscape:bbox-width="75.335938" + inkscape:bbox-height="12.101562" + id="tspan2941-9">7:30-8:30</tspan></text> + <text + xml:space="preserve" + style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans" + x="124.96794" + y="309.59033" + id="text2931-21" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="126.05388" + inkscape:bbox-y="152.18311" + inkscape:bbox-width="488.38281" + inkscape:bbox-height="32.382812" + mbname="line3"><tspan + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + x="124.96794" + y="309.59033" + id="tspan2935-2" + style="font-size:16px" + inkscape:bbox-x="126.53825" + inkscape:bbox-y="169.08154" + inkscape:bbox-width="487.89844" + inkscape:bbox-height="15.484375">Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up</tspan><tspan + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + x="124.96794" + y="329.59033" + style="font-size:16px" + inkscape:bbox-x="126.05388" + inkscape:bbox-y="152.18311" + inkscape:bbox-width="75.5625" + inkscape:bbox-height="12.101562" + id="tspan2941-0">8:30-9:30</tspan></text> + <text + xml:space="preserve" + style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans" + x="124.96794" + y="371.423" + id="text2931-3" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="125.97575" + inkscape:bbox-y="90.350433" + inkscape:bbox-width="488.46094" + inkscape:bbox-height="32.382812" + mbname="line4"><tspan + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + x="124.96794" + y="371.423" + id="tspan2935-11" + style="font-size:16px" + inkscape:bbox-x="126.53825" + inkscape:bbox-y="107.24887" + inkscape:bbox-width="487.89844" + inkscape:bbox-height="15.484375">Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up</tspan><tspan + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + x="124.96794" + y="391.423" + style="font-size:16px" + inkscape:bbox-x="125.97575" + inkscape:bbox-y="90.350433" + inkscape:bbox-width="85.828125" + inkscape:bbox-height="12.101562" + id="tspan2941-90">9:30-10:30</tspan></text> + <text + xml:space="preserve" + style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans" + x="124.96794" + y="433.25568" + id="text2931-6" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="126.53825" + inkscape:bbox-y="28.517761" + inkscape:bbox-width="487.89844" + inkscape:bbox-height="32.382812" + mbname="line5"><tspan + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + x="124.96794" + y="433.25568" + id="tspan2935-7" + style="font-size:16px" + inkscape:bbox-x="126.53825" + inkscape:bbox-y="45.416199" + inkscape:bbox-width="487.89844" + inkscape:bbox-height="15.484375">Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up</tspan><tspan + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + x="124.96794" + y="453.25568" + style="font-size:16px" + inkscape:bbox-x="126.72575" + inkscape:bbox-y="28.517761" + inkscape:bbox-width="95.265625" + inkscape:bbox-height="12.101562" + id="tspan2941-7">10:30-11:30</tspan></text> + </g> +</svg>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/desktop/testdesktop.js Fri Nov 12 17:39:04 2010 +0800 @@ -0,0 +1,126 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var svg = require("svg"); +var mbapp = require("mbapp"); +var sys=require("sys"); +var animate=require("animate"); +var fs = require("fs"); + +app = new mbapp.app(); +app.loadSVG("desktop.svg"); + +video = app.get("video"); +//var an = new animate.alpha(app,video,0,1); +//an.start(); +audio = app.get("audio"); +picture = app.get("picture"); +setting = app.get("setting"); + +lightbar = app.get("lightbar"); +lines = []; +for(i = 0; i < 5; i++) { + line = app.get("line" + (i + 1)); + lines.push(line); +} +line=0; + +items=[video, audio, picture, setting]; + +item = 0; + +animate.run([new animate.scale(app,items[item], 1, 1.5)], 0, 0.1); +app.refresh(); + +app.addKeyListener(mbapp.KEY_LEFT, function() { + var old = items[item]; + item = item - 1; + if (item == -1) { + item = 0; + return; + } + + var target = items[item]; + + old.bbox.update(); + target.bbox.update(); + + var an = new animate.scale(app, old, 1, 1); + animate.run([an], 0, 0.1); + an = new animate.scale(app, target, 1, 1.5); + animate.run([an], 0, 0.3); +}); + +app.addKeyListener(mbapp.KEY_RIGHT, function() { + var old = items[item]; + item = item + 1; + if (item == items.length) { + item = item - 1; + return; + } + + var target = items[item]; + + old.bbox.update(); + target.bbox.update(); + + var an = new animate.scale(app, old, 1, 1); + animate.run([an], 0, 0.1); + an = new animate.scale(app, target, 1, 1.5); + animate.run([an], 0, 0.3); +}); + +app.addKeyListener(mbapp.KEY_UP, function() { + var old = lines[line]; + line = line - 1; + if (line == -1) { + line = 0; + return; + } + var target = lines[line]; + var sy = target.center.y - lightbar.center.y; + sys.puts(sy); + var an = new animate.shift(app, lightbar, 0, sy); + animate.run([an], 0, 0.3); +}); +app.addKeyListener(mbapp.KEY_DOWN, function() { + var old = lines[line]; + line = line + 1; + if (line == lines.length) { + line = line - 1; + return; + } + var target = lines[line]; + var sy = target.center.y - lightbar.center.y; + sys.puts("line="+line); + sys.puts("sy="+sy); + sys.puts("target.y="+target.center.y); + sys.puts("lightbar.y="+lightbar.center.y); + var an = new animate.shift(app, lightbar, 0, sy); + animate.run([an], 0, 0.3); +}); + +app.addKeyListener(mbapp.KEY_ENTER, function() { + var target = items[item]; + var sx = 500 - target.center.x; + var sy = 220 - target.center.y; + sys.puts("target "+sx+','+sy); + var an = new animate.shift(app,target,sx,sy,1); + an.start(); + for(i=0;i<items.length;i++) { + if (i == item) continue; + var x = Math.random(); + var y = Math.random(); + if (x > 0.5) x = 900; + else x = -500; + if (y > 0.5) y = 900; + else y = -500; + sx = x - items[i].center.x; + sy = y - items[i].center.y; + an = new animate.shift(app,items[i], sx, sy); + animate.run([an], 0, 2); + alpha = new animate.alpha(app,items[i], 0); + animate.run([an], 0, 1); + } +}); + +app.loop();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/phone/phone.js Fri Nov 12 17:39:04 2010 +0800 @@ -0,0 +1,61 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var mbapp = require("mbapp"); +var sys=require("sys"); +var animate=require("animate"); + +app = new mbapp.app(":0.0", 320, 480); +app.loadSVG("phone_ui.svg"); + +var icons = []; +var r, c; +var mbname; +for(c = 0; c < 4; c++) { // 4 columns + for(r = 0; r < 5; r++) { // 5 rows + mbname = "icon" + c + "" + r; + icons.push(app.get(mbname)); + } +} + +var overhint, presshint; +var overholder, pressholder; +overhint = app.get("overhint"); +presshint = app.get("presshint"); +overholder = new animate.holder(app, overhint); +pressholder = new animate.holder(app, presshint); + +var dock; +var dockholder; +dock = app.get("dock"); +dockholder = new animate.holder(app, dock); + +var i; +var icon; +for(i = 0; i < icons.length; i++) { + icon = icons[i]; + icon.mouse_event.add_event_observer(1, function(evt) { + overholder.go_center(evt.cur_tgt); + }); + icon.mouse_event.add_event_observer(2, function(evt) { + overholder.home(); + }); + icon.mouse_event.add_event_observer(4, function(evt) { + pressholder.go_center(evt.cur_tgt); + var rotate = new animate.rotate(app, evt.cur_tgt, 2 * 3.1415); + animate.run([rotate], 0, 0.7); + }); +} + +var sw = 0; +var dock_up = new animate.shift(app, dock, 0, -300); +var dock_down = new animate.shift(app, dock, 0, 0); +dock.mouse_event.add_event_observer(4, function(evt) { + if(sw == 0) { + animate.run([dock_up], 0, 0.5); + } else { + animate.run([dock_down], 0, 0.2); + } + sw = sw ^ 1; + }); + +app.loop();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/phone/phone_ui.svg Fri Nov 12 17:39:04 2010 +0800 @@ -0,0 +1,491 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="320" + height="480" + id="svg2" + version="1.1" + inkscape:version="0.48+devel r9732" + sodipodi:docname="phone_ui.svg"> + <defs + id="defs4" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.90416667" + inkscape:cx="312.60279" + inkscape:cy="186.36119" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + width="320px" + inkscape:window-width="888" + inkscape:window-height="684" + inkscape:window-x="333" + inkscape:window-y="132" + inkscape:window-maximized="0" /> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + inkscape:bbox-x="-1.1059908" + inkscape:bbox-y="-860.32248" + inkscape:bbox-width="415.19362" + inkscape:bbox-height="773.49026"> + <rect + mbname="icon00" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" + id="rect3599" + width="56.328701" + height="44.162804" + x="31.642097" + y="60.326893" + inkscape:bbox-x="30.603683" + inkscape:bbox-y="374.47189" + inkscape:bbox-width="58.40553" + inkscape:bbox-height="46.239633" + rx="11.071856" + ry="9.7391548" + inkscape:tile-cx="82.396311" + inkscape:tile-cy="75.207361" + inkscape:tile-w="56.328701" + inkscape:tile-h="44.162804" + inkscape:tile-x0="54.23196" + inkscape:tile-y0="53.125959" /> + <rect + mbname="icon01" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="312.64394" + inkscape:bbox-x="30.603683" + y="122.15484" + x="31.642097" + height="44.162804" + width="56.328701" + id="use3685" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon02" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="250.81607" + inkscape:bbox-x="30.603683" + y="183.98271" + x="31.642097" + height="44.162804" + width="56.328701" + id="use3687" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon03" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="188.98813" + inkscape:bbox-x="30.603683" + y="245.81065" + x="31.642097" + height="44.162804" + width="56.328701" + id="use3689" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon04" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="127.16017" + inkscape:bbox-x="30.603683" + y="307.63861" + x="31.642097" + height="44.162804" + width="56.328701" + id="use3691" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon10" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="374.47189" + inkscape:bbox-x="98.198119" + y="60.326893" + x="99.236534" + height="44.162804" + width="56.328701" + id="use3693" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon11" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="312.64394" + inkscape:bbox-x="98.198119" + y="122.15484" + x="99.236534" + height="44.162804" + width="56.328701" + id="use3695" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon12" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="250.81607" + inkscape:bbox-x="98.198119" + y="183.98271" + x="99.236534" + height="44.162804" + width="56.328701" + id="use3697" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon13" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="188.98813" + inkscape:bbox-x="98.198119" + y="245.81065" + x="99.236534" + height="44.162804" + width="56.328701" + id="use3699" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon14" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="127.16017" + inkscape:bbox-x="98.198119" + y="307.63861" + x="99.236534" + height="44.162804" + width="56.328701" + id="use3701" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon20" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="374.47189" + inkscape:bbox-x="165.79256" + y="60.326893" + x="166.83098" + height="44.162804" + width="56.328701" + id="use3703" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon21" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="312.64394" + inkscape:bbox-x="165.79256" + y="122.15484" + x="166.83098" + height="44.162804" + width="56.328701" + id="use3705" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon22" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="250.81607" + inkscape:bbox-x="165.79256" + y="183.98271" + x="166.83098" + height="44.162804" + width="56.328701" + id="use3707" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon23" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="188.98813" + inkscape:bbox-x="165.79256" + y="245.81065" + x="166.83098" + height="44.162804" + width="56.328701" + id="use3709" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon24" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="127.16017" + inkscape:bbox-x="165.79256" + y="307.63861" + x="166.83098" + height="44.162804" + width="56.328701" + id="use3711" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon30" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="374.47189" + inkscape:bbox-x="233.387" + y="60.326893" + x="234.42542" + height="44.162804" + width="56.328701" + id="use3713" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon31" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="312.64394" + inkscape:bbox-x="233.387" + y="122.15484" + x="234.42542" + height="44.162804" + width="56.328701" + id="use3715" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon32" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="250.81607" + inkscape:bbox-x="233.387" + y="183.98271" + x="234.42542" + height="44.162804" + width="56.328701" + id="use3717" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon33" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="188.98813" + inkscape:bbox-x="233.387" + y="245.81065" + x="234.42542" + height="44.162804" + width="56.328701" + id="use3719" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <rect + mbname="icon34" + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239633" + inkscape:bbox-width="58.40553" + inkscape:bbox-y="127.16017" + inkscape:bbox-x="233.387" + y="307.63861" + x="234.42542" + height="44.162804" + width="56.328701" + id="use3721" + style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> + <g + id="g3781" + inkscape:bbox-x="-2.6747894e-07" + inkscape:bbox-y="440.72538" + inkscape:bbox-width="321.84332" + inkscape:bbox-height="43.133648" + transform="translate(1.1059905,-570.69124)"> + <rect + inkscape:bbox-height="35.391705" + inkscape:bbox-width="320.73734" + inkscape:bbox-y="440.72538" + inkscape:bbox-x="-2.7016535e-07" + y="574.57416" + x="-1.1059908" + height="35.391705" + width="320.73734" + id="rect3761" + style="fill:#f2f2f2;fill-opacity:1;stroke:none" /> + <rect + inkscape:bbox-height="35.391705" + inkscape:bbox-width="320.73734" + inkscape:bbox-y="448.46732" + inkscape:bbox-x="1.1059882" + y="566.83221" + x="-2.250144e-06" + height="35.391705" + width="320.73734" + id="rect3761-7" + style="fill:#ececec;fill-opacity:1;stroke:none" /> + </g> + <rect + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + inkscape:tile-h="44.162804" + inkscape:tile-w="56.328701" + inkscape:tile-cy="75.207361" + inkscape:tile-cx="82.396311" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239804" + inkscape:bbox-width="58.405701" + inkscape:bbox-y="370.70221" + inkscape:bbox-x="356.04143" + y="64.096489" + x="357.07993" + height="44.162804" + width="56.328701" + id="rect3599-9" + style="fill:none;stroke:#ff1010;stroke-width:2.0769999;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + mbname="overhint" /> + <rect + inkscape:tile-y0="53.125959" + inkscape:tile-x0="54.23196" + inkscape:tile-h="44.162804" + inkscape:tile-w="56.328701" + inkscape:tile-cy="75.207361" + inkscape:tile-cx="82.396311" + ry="9.7391548" + rx="11.071856" + inkscape:bbox-height="46.239804" + inkscape:bbox-width="58.405701" + inkscape:bbox-y="318.06628" + inkscape:bbox-x="356.78795" + y="116.73241" + x="357.82645" + height="44.162804" + width="56.328701" + id="rect3599-9-3" + style="fill:none;stroke:#000080;stroke-width:2.07699990000000012;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + mbname="presshint" /> + <g + id="g3849" + inkscape:bbox-x="2.2255181" + inkscape:bbox-y="-289.63124" + inkscape:bbox-width="317.40625" + inkscape:bbox-height="359.25593" + mbname="dock" + transform="translate(1.1059905,-570.69124)"> + <path + inkscape:bbox-height="76.31255" + inkscape:bbox-width="317.40625" + inkscape:bbox-y="-6.68786" + inkscape:bbox-x="2.2255181" + inkscape:connector-curvature="0" + id="rect2817" + d="m 163.68203,981.06655 c -63.1198,0 -120.411185,7.92804 -162.5625024,20.84375 l 0,55.4688 317.4062524,0 0,-57.7188 C 277.22165,988.08365 223.03485,981.06655 163.68203,981.06655 z" + style="fill:#4494c2;fill-opacity:0.59174314;stroke:none" /> + <path + style="fill:#6083ff;fill-opacity:1;stroke:#1033ff;stroke-width:2.0769999;stroke-miterlimit:4;stroke-opacity:1" + d="m 182.48848,1003.6866 c 0,8.2461 -9.16063,14.9309 -20.46083,14.9309 -11.3002,0 -20.46083,-6.6848 -20.46083,-14.9309 0,-8.24608 9.16063,-14.93086 20.46083,-14.93086 11.3002,0 20.46083,6.68478 20.46083,14.93086 z" + id="path3843" + inkscape:connector-curvature="0" + inkscape:bbox-x="141.63431" + inkscape:bbox-y="31.03524" + inkscape:bbox-width="42.99866" + inkscape:bbox-height="31.93876" /> + <rect + style="fill:#ececec;fill-opacity:1;stroke:#c7cfff;stroke-width:2.03777313;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + id="rect2838" + width="310.82263" + height="282.06689" + x="4.4043493" + y="1057.2367" + inkscape:bbox-x="4.4914533" + inkscape:bbox-y="-289.63124" + inkscape:bbox-width="312.8604" + inkscape:bbox-height="284.10467" /> + </g> + </g> +</svg>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/simple/testcanvas.js Fri Nov 12 17:39:04 2010 +0800 @@ -0,0 +1,31 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var mbapp = require("mbapp"); +var sys=require("sys"); +var canvas=require("canvas"); + +app = new mbapp.app(); + +app.canvas = new canvas.canvas(app,app.mb_rt.root); + +app.canvas.background(0,0,0,1); +app.canvas.rect(0,0,400,400); +app.canvas.strokeWeight(8); +width=200; +height=200; + +setInterval(function() { + app.canvas.clear(); + + for(i=0;i<width;i++) { + x = Math.random()*255; + y = Math.random()*200; + cr = Math.random() + cg = Math.random() + cb = Math.random() + app.canvas.stroke(cr,cg,cb,1); + app.canvas.line(i,0,x,height); + } + app.update(); +},33); +app.loop();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/simple/testcase.js Fri Nov 12 17:39:04 2010 +0800 @@ -0,0 +1,169 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var mbfly = require("mbfly"); +var r = mbfly.Hello(" test"); +var sys = require("sys"); +sys.puts(r); + +var display_name = ":0.0"; +if(process.argv.length == 3) + display_name = process.argv[2]; + +var mb_rt = new mbfly.mb_rt(display_name, 300, 200); +var root = mb_rt.root; +sys.puts("root matrix: " + + [root[0], root[1], root[2], root[3], root[4], root[5]]); +var coord = mb_rt.coord_new(root); +sys.puts("coord matrix: " + + [coord[0], coord[1], coord[2], coord[3], coord[4], coord[5]]); + +/* Testcase for image shapes */ +var img = mb_rt.image_new(10, 10, 50, 50); +var ldr = mbfly.img_ldr_new("."); +var img_data = ldr.load("sample.png"); +var paint = mb_rt.paint_image_new(img_data); +var img_coord = mb_rt.coord_new(root); +paint.fill(img); +img_coord.add_shape(img); + +/* test linear paint and rectangle */ +var rect = mb_rt.rect_new(100, 100, 50, 50, 10, 10); +sys.puts(mb_rt.paint_linear_new); +var paint = mb_rt.paint_linear_new(100, 100, 150, 150); +paint.set_stops([[0, 0, 1, 0, 1], [1, 0, 0, 1, 1]]); +paint.fill(rect); +root.add_shape(rect); + +/* test radial paint and rectangle */ +var rect = mb_rt.rect_new(150, 100, 50, 50, 10, 10); +sys.puts(mb_rt.paint_radial_new); +var paint = mb_rt.paint_radial_new(175, 125, 25); +paint.set_stops([[0, 0, 1, 0, 1], [1, 0, 0, 1, 1]]); +paint.fill(rect); +root.add_shape(rect); + +/* test alpha blending and rectangle */ +var rect = mb_rt.rect_new(40, 40, 100, 100, 10, 10); +sys.puts(mb_rt.paint_color_new); +var paint = mb_rt.paint_color_new(1, 0.5, 0.5, 0.5); +paint.fill(rect); +root.add_shape(rect); + +/* test hide of shapes */ +var sw = 1; +setInterval(function() { + if(sw) { + rect.hide(); + sw = 0; + } else { + rect.show(); + sw = 1; + } + }, 1000); + +/* test hide of coord */ +var cw = 1; +setInterval(function() { + if(sw) { + coord.hide(); + cw = 0; + } else { + coord.show(); + cw = 1; + } + }, 3000); + +/* test removing a coord */ +var rm_coord = mb_rt.coord_new(root); +var rm_rect1 = mb_rt.rect_new(150, 150, 50, 50, 10, 10); +paint.fill(rm_rect1); +rm_coord.add_shape(rm_rect1); +var rm_rect2 = mb_rt.rect_new(100, 150, 50, 50, 10, 10); +paint.fill(rm_rect2); +rm_coord.add_shape(rm_rect2); +setTimeout(function() { + rm_coord.remove(); + mb_rt.redraw_changed(); + mb_rt.flush(); + }, 3000); + +/* test removing a shape */ +setTimeout(function() { + rm_rect1.remove(); + mb_rt.redraw_changed(); + mb_rt.flush(); + }, 2000); + +/* Moving a path */ +sys.puts(mb_rt.path_new); +var path = mb_rt.path_new("m 100,50 L 120,50 L 200,150 L 180,150 z"); +sys.puts(path); +sys.puts(coord.add_shape); +coord.add_shape(path); + +sys.puts(mb_rt.paint_color_new); +var paint = mb_rt.paint_color_new(1, 1, 1, 1); +sys.puts(paint); +paint.stroke(path); + +sys.puts(path.stroke_width); +path.stroke_width = 2; +sys.puts(path.stroke_width); + +var face = mb_rt.font_face_query("courier", 2, 100); +var blks = [[5, face, 20]]; +var stext = mb_rt.stext_new("Hello", 100, 50); +stext.set_style(blks); +paint.fill(stext); +coord.add_shape(stext); + +mb_rt.redraw_all(); +mb_rt.flush(); + +var i = 0; +setInterval(function() { + var deg = (i++) * 0.1; + coord[2] = (i % 40) * 5; + mb_rt.redraw_changed(); + mb_rt.flush(); + }, 20); +setTimeout(function() { sys.puts("timeout"); }, 1000); + +sys.puts(root.mouse_event); +var observer; +/* Mouse button pressed */ +observer = root.mouse_event.add_event_observer(4, function(evt) { + var c = 1 - (i % 40) / 40; + sys.puts(c); + + sys.puts("mouse " + evt.x + " " + evt.y); + sys.puts(c); + sys.puts(paint.set_color); + paint.set_color(c, 1, 1, 1); + mb_rt.redraw_changed(); + mb_rt.flush(); + }); + +var resize_sw = 0; +setInterval(function() { + var sz; + + resize_sw++; + + sz = (resize_sw % 20) - 10; + if(sz < 0) + sz = -sz; + sz = 2 - sz / 10; + + img_coord[0] = sz; + img_coord[4] = sz; + mb_rt.redraw_changed(); + mb_rt.flush(); + }, 50); + +var kbobserver; +/* Keyboard event */ +kbobserver = mb_rt.kbevents.add_event_observer(6, function(evt) { + sys.puts("keycode = " + evt.keycode); + sys.puts("sym = " + evt.sym); + });
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/simple/testimage.js Fri Nov 12 17:39:04 2010 +0800 @@ -0,0 +1,19 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var svg = require("svg"); +var mbapp = require("mbapp"); +var sys=require("sys"); +var animate=require("animate"); +var fs = require("fs"); + +app = new mbapp.app(); + +coord = app.mb_rt.coord_new(app.mb_rt.root); +data=mbapp.ldr.load("sample.png"); +paint = app.mb_rt.paint_image_new(data); +img = app.mb_rt.image_new(10,10,50,50); +paint.fill(img); +coord.opacity = 0.9; +coord.add_shape(img); + +app.loop();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/simple/testleak.js Fri Nov 12 17:39:04 2010 +0800 @@ -0,0 +1,217 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var mbfly = require("mbfly"); +var sys = require("sys"); +var cproc = require("child_process"); + +function testcase1() { + var mbrt = new mbfly.mb_rt(":32.0", 300, 200); + var root = mbrt.root; + var coords = []; + var coord; + var i; + + while(true) { + for(i = 0; i < 200; i++) { + coords.push(mbrt.coord_new(root)); + } + mbrt.redraw_changed(); + mbrt.flush(); + + while(coords.length > 0) { + coord = coords.pop(); + coord.remove(); + } + } +} + +function testcase2() { + var mbrt = new mbfly.mb_rt(":32.0", 300, 200); + var root = mbrt.root; + var coords = []; + var coord; + var i, j; + + while(true) { + for(i = 0; i < 200; i++) { + coords.push(mbrt.coord_new(root)); + for(j = 0; j < 10; j++) + coord = mbrt.coord_new(coords[i]); + } + mbrt.redraw_changed(); + mbrt.flush(); + + while(coords.length > 0) { + coord = coords.pop(); + coord.remove(); + } + } +} + +function testcase3() { + var mbrt = new mbfly.mb_rt(":32.0", 300, 200); + var root = mbrt.root; + var coords = []; + var coord; + var shape; + var i, j; + + while(true) { + for(i = 0; i < 200; i++) { + coords.push(mbrt.coord_new(root)); + for(j = 0; j < 10; j++) { + coord = mbrt.coord_new(coords[i]); + shape = mbrt.rect_new(15, 15, 20, 20, 0, 0); + coord.add_shape(shape); + } + } + mbrt.redraw_changed(); + mbrt.flush(); + + while(coords.length > 0) { + coord = coords.pop(); + coord.remove(); + } + } +} + +function testcase4() { + var mbrt = new mbfly.mb_rt(":32.0", 300, 200); + var root = mbrt.root; + var coords = []; + var coord; + var shape; + var i, j; + + while(true) { + for(i = 0; i < 200; i++) { + coords.push(mbrt.coord_new(root)); + for(j = 0; j < 10; j++) { + coord = mbrt.coord_new(coords[i]); + shape = mbrt.path_new("m 10,10 l 55,27 l -30,-3 z"); + coord.add_shape(shape); + } + } + mbrt.redraw_changed(); + mbrt.flush(); + + while(coords.length > 0) { + coord = coords.pop(); + coord.remove(); + } + } +} + +function testcase5() { + var mbrt = new mbfly.mb_rt(":32.0", 300, 200); + var root = mbrt.root; + var paint; + + while(true) { + paint = mbrt.paint_color_new(0.5, 0.5, 0.5, 1); + } +} + +function testcase6() { + var mbrt = new mbfly.mb_rt(":32.0", 300, 200); + var root = mbrt.root; + var coords = []; + var coord; + var shape; + var paint; + var i, j; + + while(true) { + for(i = 0; i < 200; i++) { + coords.push(mbrt.coord_new(root)); + /* Paint is free, but rdman is dirty */ + paint = mbrt.paint_color_new(0.5, 0.5, 0.5, 1); + for(j = 0; j < 10; j++) { + coord = mbrt.coord_new(coords[i]); + shape = mbrt.rect_new(5, 5, 20, 20, 0, 0); + coord.add_shape(shape); + } + } + mbrt.redraw_changed(); + mbrt.flush(); + + while(coords.length > 0) { + coord = coords.pop(); + coord.remove(); + } + } +} + +function testcase7() { + var mbrt = new mbfly.mb_rt(":32.0", 300, 200); + var root = mbrt.root; + var coords = []; + var coord; + var shape; + var paint; + var i, j; + + while(true) { + for(i = 0; i < 200; i++) { + coords.push(mbrt.coord_new(root)); + for(j = 0; j < 10; j++) { + /* paint is not free, and rdman is dirty */ + paint = mbrt.paint_color_new(0.5, 0.5, 0.5, 1); + coord = mbrt.coord_new(coords[i]); + shape = mbrt.path_new("M 100,100 L 30,30 L 0,30 z"); + coord.add_shape(shape); + paint.stroke(shape); + } + } + mbrt.redraw_changed(); + mbrt.flush(); + + while(coords.length > 0) { + coord = coords.pop(); + coord.remove(); + } + } +} + +cproc.exec("killall -9 Xvfb; Xvfb :32 -screen 0 800x600x24"); +setTimeout(function() { + if(process.argv.length == 1) + testcase1(); + else if(process.argv.length == 3) { + sys.puts("testcase " + process.argv[2]); + switch(process.argv[2]) { + case "1": + testcase1(); + break; + + case "2": + testcase2(); + break; + + case "3": + testcase3(); + break; + + case "4": + testcase4(); + break; + + case "5": + testcase5(); + break; + + case "6": + testcase6(); + break; + + case "7": + testcase7(); + break; + + default: + sys.puts("Usage: node testleak.js [1|2|3...7]"); + } + } else + sys.puts("Usage: node testleak.js [1|2|3...7]"); + cproc.exec("killall -9 Xvfb"); + }, 1500);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/testsvg/svgviewer.js Fri Nov 12 17:39:04 2010 +0800 @@ -0,0 +1,8 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var svg = require("svg"); +var mbapp = require("mbapp"); + +app = new mbapp.app(); +app.loadSVG("test.svg"); +app.loop();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/testsvg/test.svg Fri Nov 12 17:39:04 2010 +0800 @@ -0,0 +1,538 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:ns0="http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="720" + height="480" + id="svg2" + sodipodi:version="0.32" + inkscape:version="0.47 r22583" + sodipodi:docname="test.svg" + version="1.0" + inkscape:output_extension="org.inkscape.output.svg.inkscape"> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + gridtolerance="10000" + guidetolerance="10" + objecttolerance="10" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="1.0347223" + inkscape:cx="151.05815" + inkscape:cy="228.90269" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="1347" + inkscape:window-height="894" + inkscape:window-x="0" + inkscape:window-y="25" + inkscape:window-maximized="0" /> + <defs + id="defs4"> + <linearGradient + id="linearGradient3183"> + <stop + style="stop-color:#000000;stop-opacity:1;" + offset="0" + id="stop3185" /> + <stop + style="stop-color:#505050;stop-opacity:1;" + offset="1" + id="stop3187" /> + </linearGradient> + <inkscape:perspective + id="perspective10" + inkscape:persp3d-origin="804.3173 : 267.38473 : 1" + inkscape:vp_z="1630.7262 : 376.00761 : 1" + inkscape:vp_y="0 : 619.30892 : 0" + inkscape:vp_x="-22.091594 : 376.00761 : 1" + sodipodi:type="inkscape:persp3d" /> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3183" + id="linearGradient3189" + x1="0" + y1="239.5" + x2="719.99998" + y2="239.5" + gradientUnits="userSpaceOnUse" /> + </defs> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + </cc:Work> + </rdf:RDF> + <ns0:scenes + current="1" /> + </metadata> + <g + inkscape:groupmode="layer" + id="layer2" + inkscape:label="Background" + sodipodi:insensitive="true"> + <rect + style="opacity:1;fill:url(#linearGradient3189);fill-opacity:1;stroke:#000000;stroke-width:0.9993065;stroke-opacity:1" + id="rect3181" + width="719.00067" + height="480.0007" + x="0.49965325" + y="-0.50034672" /> + </g> + <g + id="layer1" + inkscape:groupmode="layer" + inkscape:label="Layer 1"> + <g + transform="translate(144.04213,-2.85715)" + id="item1" + mbname="item1" + style="fill-opacity:1" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="422.51731" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219"> + <text + id="text2395" + y="60" + x="157.14285" + style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" + xml:space="preserve" + sodipodi:linespacing="125%" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="422.51731" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219"><tspan + mbname="item1text" + y="60" + x="157.14285" + id="tspan2397" + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="422.51731" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219">item1</tspan></text> + </g> + <g + transform="translate(144.04213,39.689836)" + id="item2" + mbname="item2" + style="fill-opacity:1" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="379.97032" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219"> + <text + id="text2421" + y="60" + x="157.14285" + style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" + xml:space="preserve" + sodipodi:linespacing="125%" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="379.97032" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219"><tspan + mbname="item2text" + y="60" + x="157.14285" + id="tspan2423" + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="379.97032" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219">item1</tspan></text> + </g> + <g + transform="translate(144.04213,82.236798)" + id="item3" + mbname="item3" + style="fill-opacity:1" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="337.42336" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219"> + <text + id="item3text" + y="60" + x="157.14285" + style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" + xml:space="preserve" + sodipodi:linespacing="125%" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="337.42336" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219"><tspan + mbname="item3text" + y="60" + x="157.14285" + id="tspan2429" + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="337.42336" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219">item1</tspan></text> + </g> + <g + transform="translate(144.04213,124.7838)" + id="item4" + mbname="item4" + style="fill-opacity:1" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="294.87636" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219"> + <text + id="item4text" + y="60" + x="157.14285" + style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" + xml:space="preserve" + sodipodi:linespacing="125%" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="294.87636" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219"><tspan + mbname="item4text" + y="60" + x="157.14285" + id="tspan2435" + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="294.87636" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219">item1</tspan></text> + </g> + <g + transform="translate(144.04213,167.33077)" + id="item5" + mbname="item5" + style="fill-opacity:1" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="252.32939" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219"> + <text + id="item5text" + y="60" + x="157.14285" + style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" + xml:space="preserve" + sodipodi:linespacing="125%" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="252.32939" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219"><tspan + mbname="item5text" + y="60" + x="157.14285" + id="tspan2441" + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="252.32939" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219">item1</tspan></text> + </g> + <g + transform="translate(144.04213,209.87776)" + id="item6" + mbname="item6" + style="fill-opacity:1" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="209.7824" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219"> + <text + id="item6text" + y="60" + x="157.14285" + style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" + xml:space="preserve" + sodipodi:linespacing="125%" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="209.7824" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219"><tspan + mbname="item6text" + y="60" + x="157.14285" + id="tspan2447" + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="209.7824" + inkscape:bbox-width="74.0625" + inkscape:bbox-height="18.574219">item1</tspan></text> + </g> + <g + transform="translate(145.21401,252.42474)" + id="item7" + mbname="item7" + style="fill-opacity:1" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="167.23542" + inkscape:bbox-width="65.027344" + inkscape:bbox-height="18.574219"> + <text + id="item7text" + y="60" + x="157.14285" + style="font-size:24px;font-style:oblique;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Oblique" + xml:space="preserve" + sodipodi:linespacing="125%" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="167.23542" + inkscape:bbox-width="65.027344" + inkscape:bbox-height="18.574219"><tspan + mbname="item7text" + y="60" + x="157.14285" + id="tspan2453" + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="167.23542" + inkscape:bbox-width="65.027344" + inkscape:bbox-height="18.574219">item1</tspan></text> + </g> + <g + transform="translate(143.79604,294.97172)" + id="item8" + mbname="item8" + style="fill-opacity:1" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="124.68844" + inkscape:bbox-width="65.027344" + inkscape:bbox-height="18.574219"> + <text + id="item8text" + y="60" + x="157.14285" + style="font-size:24px;font-style:normal;font-weight:normal;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="124.68844" + inkscape:bbox-width="65.027344" + inkscape:bbox-height="18.574219"><tspan + mbname="item8text" + y="60" + x="157.14285" + id="tspan2459" + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="124.68844" + inkscape:bbox-width="65.027344" + inkscape:bbox-height="18.574219">item1</tspan></text> + </g> + <g + transform="translate(143.79604,337.5187)" + id="item9" + mbname="item9" + style="fill-opacity:1" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="82.141456" + inkscape:bbox-width="65.027344" + inkscape:bbox-height="18.574219"> + <text + mbname="" + id="text2407" + y="60" + x="157.14285" + style="font-size:24px;font-style:normal;font-weight:normal;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" + xml:space="preserve" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="82.141456" + inkscape:bbox-width="65.027344" + inkscape:bbox-height="18.574219"><tspan + mbname="item9text" + y="60" + x="157.14285" + id="tspan2409" + sodipodi:role="line" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="303.20061" + inkscape:bbox-y="82.141456" + inkscape:bbox-width="65.027344" + inkscape:bbox-height="18.574219">item1</tspan></text> + </g> + <text + id="text2416" + y="44.383541" + x="24.177626" + style="font-size:24px;font-style:normal;font-weight:normal;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" + xml:space="preserve"><tspan + mbname="title" + y="44.383541" + x="24.177626" + id="tspan2418" + sodipodi:role="line">Menu test</tspan></text> + </g> + <g + inkscape:groupmode="layer" + id="layer4" + inkscape:label="lightbar"> + <g + mbname="item_lightbar" + transform="matrix(0.9148913,0,0,1,168.41407,93.684101)" + id="item_lightbar" + style="stroke:none" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="164.66374" + inkscape:bbox-y="326.01386" + inkscape:bbox-width="409.10203" + inkscape:bbox-height="33.623234"> + <rect + style="opacity:0.3669725;fill:#001f41;fill-opacity:1;stroke:none" + id="rect3191" + width="442.8623" + height="29.190758" + x="0.19951171" + y="31.140766" + transform="matrix(0.9999958,-0.00289533,0,1,0,0)" + rx="10.000001" + ry="10" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="168.5966" + inkscape:bbox-y="326.01386" + inkscape:bbox-width="405.16917" + inkscape:bbox-height="30.41517" /> + <rect + style="opacity:0.3669725;fill:#eafbf3;fill-opacity:1;stroke:none" + id="rect2405" + width="442.86224" + height="29.190758" + x="-4.099226" + y="27.920256" + transform="matrix(0.9999958,-0.00289533,0,1,0,0)" + rx="10" + ry="10" + inkscape:transform-center-x="0" + inkscape:transform-center-y="0" + inkscape:bbox-x="164.66374" + inkscape:bbox-y="329.22193" + inkscape:bbox-width="405.16911" + inkscape:bbox-height="30.41517" /> + </g> + <image + y="78.788635" + x="34.986565" + id="image3033" + xlink:href="file:logo.png" + height="37" + width="46" /> + <g + sodipodi:type="inkscape:box3d" + style="fill:none;stroke:none" + id="g2953" + inkscape:perspectiveID="#perspective10" + inkscape:corner0="11.418244 : -1.091331 : 0 : 1" + inkscape:corner7="6.2635014 : -2.542367 : 0.25 : 1"> + <path + sodipodi:type="inkscape:box3dside" + id="path2963" + style="fill:#afafde;fill-rule:evenodd;stroke:none" + inkscape:box3dsidetype="13" + d="M 44.456373,239.52954 91.68396,335.71719 142.89318,328.00691 75.760432,236.8548 z" /> + <path + sodipodi:type="inkscape:box3dside" + id="path2955" + style="fill:#353564;fill-rule:evenodd;stroke:none" + inkscape:box3dsidetype="6" + d="m 44.456373,167.16508 0,72.36446 31.304059,-2.67474 0,-70.93639 z" /> + <path + sodipodi:type="inkscape:box3dside" + id="path2965" + style="fill:#e9e9ff;fill-rule:evenodd;stroke:none" + inkscape:box3dsidetype="11" + d="m 75.760432,165.91841 67.132748,42.48521 0,119.60329 -67.132748,-91.15211 z" /> + <path + sodipodi:type="inkscape:box3dside" + id="path2957" + style="fill:#4d4d9f;fill-rule:evenodd;stroke:none" + inkscape:box3dsidetype="5" + d="m 44.456373,167.16508 47.227587,44.83223 51.20922,-3.59369 -67.132748,-42.48521 z" /> + <path + sodipodi:type="inkscape:box3dside" + id="path2961" + style="fill:#d7d7ff;fill-rule:evenodd;stroke:none" + inkscape:box3dsidetype="14" + d="m 91.68396,211.99731 0,123.71988 51.20922,-7.71028 0,-119.60329 z" /> + <path + sodipodi:type="inkscape:box3dside" + id="path2959" + style="fill:#8686bf;fill-rule:evenodd;stroke:none" + inkscape:box3dsidetype="3" + d="m 44.456373,167.16508 47.227587,44.83223 0,123.71988 -47.227587,-96.18765 z" /> + </g> + </g> +</svg>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/testsvg/testsvg.js Fri Nov 12 17:39:04 2010 +0800 @@ -0,0 +1,53 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var svg = require("svg"); +var mbapp = require("mbapp"); +var sys=require("sys"); +var animate=require("animate"); +var fs = require("fs"); + +app = new mbapp.app(); +app.loadSVG("test.svg"); +lightbar = app.get("item_lightbar"); +item=1; +var target = app.get("item" + item); +lightbar.center.move_pnt(target.center); + +app.files=fs.readdirSync("/tmp/"); +for(i=1;i<10;i++) { + var o = app.get("item"+i+"text"); + o.set_text(app.files[i]); +} + + + + +app.addKeyListener(mbapp.KEY_UP, function() { + item = item - 1; + if (item == 0) + item = 1; + else { + var target = app.get("item"+item); + var shx = target.center.x - lightbar.center.x; + var shy = target.center.y - lightbar.center.y; + var action = new animate.shift(app, lightbar, shx, shy); + var an = new animate.linear(action, 0, 0.3); + an.start(); + } +}); + +app.addKeyListener(mbapp.KEY_DOWN, function() { + item = item + 1; + if (item == 10) { + item = 9; + } else { + var target = app.get("item"+item); + var shx = target.center.x - lightbar.center.x; + var shy = target.center.y - lightbar.center.y; + var action = new animate.shift(app, lightbar, shx, shy); + var an = new animate.linear(action, 0, 0.3); + an.start(); + } +}); + +app.loop();
--- a/nodejs/phone.js Fri Nov 12 17:08:13 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- -// vim: sw=4:ts=8:sts=4 -var mbapp = require("./mbapp"); -var sys=require("sys"); -var animate=require("./animate"); - -app = new mbapp.app(":0.0", 320, 480); -app.loadSVG("phone_ui.svg"); - -var icons = []; -var r, c; -var mbname; -for(c = 0; c < 4; c++) { // 4 columns - for(r = 0; r < 5; r++) { // 5 rows - mbname = "icon" + c + "" + r; - icons.push(app.get(mbname)); - } -} - -var overhint, presshint; -var overholder, pressholder; -overhint = app.get("overhint"); -presshint = app.get("presshint"); -overholder = new animate.holder(app, overhint); -pressholder = new animate.holder(app, presshint); - -var dock; -var dockholder; -dock = app.get("dock"); -dockholder = new animate.holder(app, dock); - -var i; -var icon; -for(i = 0; i < icons.length; i++) { - icon = icons[i]; - icon.mouse_event.add_event_observer(1, function(evt) { - overholder.go_center(evt.cur_tgt); - }); - icon.mouse_event.add_event_observer(2, function(evt) { - overholder.home(); - }); - icon.mouse_event.add_event_observer(4, function(evt) { - pressholder.go_center(evt.cur_tgt); - var rotate = new animate.rotate(app, evt.cur_tgt, 2 * 3.1415); - animate.run([rotate], 0, 0.7); - }); -} - -var sw = 0; -var dock_up = new animate.shift(app, dock, 0, -300); -var dock_down = new animate.shift(app, dock, 0, 0); -dock.mouse_event.add_event_observer(4, function(evt) { - if(sw == 0) { - animate.run([dock_up], 0, 0.5); - } else { - animate.run([dock_down], 0, 0.2); - } - sw = sw ^ 1; - }); - -app.loop();
--- a/nodejs/phone_ui.svg Fri Nov 12 17:08:13 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,491 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> - -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="320" - height="480" - id="svg2" - version="1.1" - inkscape:version="0.48+devel r9732" - sodipodi:docname="phone_ui.svg"> - <defs - id="defs4" /> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="0.90416667" - inkscape:cx="312.60279" - inkscape:cy="186.36119" - inkscape:document-units="px" - inkscape:current-layer="layer1" - showgrid="false" - width="320px" - inkscape:window-width="888" - inkscape:window-height="684" - inkscape:window-x="333" - inkscape:window-y="132" - inkscape:window-maximized="0" /> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <g - inkscape:label="Layer 1" - inkscape:groupmode="layer" - id="layer1" - inkscape:bbox-x="-1.1059908" - inkscape:bbox-y="-860.32248" - inkscape:bbox-width="415.19362" - inkscape:bbox-height="773.49026"> - <rect - mbname="icon00" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" - id="rect3599" - width="56.328701" - height="44.162804" - x="31.642097" - y="60.326893" - inkscape:bbox-x="30.603683" - inkscape:bbox-y="374.47189" - inkscape:bbox-width="58.40553" - inkscape:bbox-height="46.239633" - rx="11.071856" - ry="9.7391548" - inkscape:tile-cx="82.396311" - inkscape:tile-cy="75.207361" - inkscape:tile-w="56.328701" - inkscape:tile-h="44.162804" - inkscape:tile-x0="54.23196" - inkscape:tile-y0="53.125959" /> - <rect - mbname="icon01" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="312.64394" - inkscape:bbox-x="30.603683" - y="122.15484" - x="31.642097" - height="44.162804" - width="56.328701" - id="use3685" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon02" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="250.81607" - inkscape:bbox-x="30.603683" - y="183.98271" - x="31.642097" - height="44.162804" - width="56.328701" - id="use3687" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon03" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="188.98813" - inkscape:bbox-x="30.603683" - y="245.81065" - x="31.642097" - height="44.162804" - width="56.328701" - id="use3689" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon04" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="127.16017" - inkscape:bbox-x="30.603683" - y="307.63861" - x="31.642097" - height="44.162804" - width="56.328701" - id="use3691" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon10" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="374.47189" - inkscape:bbox-x="98.198119" - y="60.326893" - x="99.236534" - height="44.162804" - width="56.328701" - id="use3693" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon11" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="312.64394" - inkscape:bbox-x="98.198119" - y="122.15484" - x="99.236534" - height="44.162804" - width="56.328701" - id="use3695" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon12" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="250.81607" - inkscape:bbox-x="98.198119" - y="183.98271" - x="99.236534" - height="44.162804" - width="56.328701" - id="use3697" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon13" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="188.98813" - inkscape:bbox-x="98.198119" - y="245.81065" - x="99.236534" - height="44.162804" - width="56.328701" - id="use3699" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon14" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="127.16017" - inkscape:bbox-x="98.198119" - y="307.63861" - x="99.236534" - height="44.162804" - width="56.328701" - id="use3701" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon20" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="374.47189" - inkscape:bbox-x="165.79256" - y="60.326893" - x="166.83098" - height="44.162804" - width="56.328701" - id="use3703" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon21" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="312.64394" - inkscape:bbox-x="165.79256" - y="122.15484" - x="166.83098" - height="44.162804" - width="56.328701" - id="use3705" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon22" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="250.81607" - inkscape:bbox-x="165.79256" - y="183.98271" - x="166.83098" - height="44.162804" - width="56.328701" - id="use3707" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon23" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="188.98813" - inkscape:bbox-x="165.79256" - y="245.81065" - x="166.83098" - height="44.162804" - width="56.328701" - id="use3709" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon24" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="127.16017" - inkscape:bbox-x="165.79256" - y="307.63861" - x="166.83098" - height="44.162804" - width="56.328701" - id="use3711" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon30" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="374.47189" - inkscape:bbox-x="233.387" - y="60.326893" - x="234.42542" - height="44.162804" - width="56.328701" - id="use3713" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon31" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="312.64394" - inkscape:bbox-x="233.387" - y="122.15484" - x="234.42542" - height="44.162804" - width="56.328701" - id="use3715" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon32" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="250.81607" - inkscape:bbox-x="233.387" - y="183.98271" - x="234.42542" - height="44.162804" - width="56.328701" - id="use3717" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon33" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="188.98813" - inkscape:bbox-x="233.387" - y="245.81065" - x="234.42542" - height="44.162804" - width="56.328701" - id="use3719" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <rect - mbname="icon34" - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239633" - inkscape:bbox-width="58.40553" - inkscape:bbox-y="127.16017" - inkscape:bbox-x="233.387" - y="307.63861" - x="234.42542" - height="44.162804" - width="56.328701" - id="use3721" - style="fill:#ffe8e8;fill-opacity:1;stroke:#800000;stroke-width:2.07682943;stroke-miterlimit:4;stroke-dasharray:none" /> - <g - id="g3781" - inkscape:bbox-x="-2.6747894e-07" - inkscape:bbox-y="440.72538" - inkscape:bbox-width="321.84332" - inkscape:bbox-height="43.133648" - transform="translate(1.1059905,-570.69124)"> - <rect - inkscape:bbox-height="35.391705" - inkscape:bbox-width="320.73734" - inkscape:bbox-y="440.72538" - inkscape:bbox-x="-2.7016535e-07" - y="574.57416" - x="-1.1059908" - height="35.391705" - width="320.73734" - id="rect3761" - style="fill:#f2f2f2;fill-opacity:1;stroke:none" /> - <rect - inkscape:bbox-height="35.391705" - inkscape:bbox-width="320.73734" - inkscape:bbox-y="448.46732" - inkscape:bbox-x="1.1059882" - y="566.83221" - x="-2.250144e-06" - height="35.391705" - width="320.73734" - id="rect3761-7" - style="fill:#ececec;fill-opacity:1;stroke:none" /> - </g> - <rect - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - inkscape:tile-h="44.162804" - inkscape:tile-w="56.328701" - inkscape:tile-cy="75.207361" - inkscape:tile-cx="82.396311" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239804" - inkscape:bbox-width="58.405701" - inkscape:bbox-y="370.70221" - inkscape:bbox-x="356.04143" - y="64.096489" - x="357.07993" - height="44.162804" - width="56.328701" - id="rect3599-9" - style="fill:none;stroke:#ff1010;stroke-width:2.0769999;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" - mbname="overhint" /> - <rect - inkscape:tile-y0="53.125959" - inkscape:tile-x0="54.23196" - inkscape:tile-h="44.162804" - inkscape:tile-w="56.328701" - inkscape:tile-cy="75.207361" - inkscape:tile-cx="82.396311" - ry="9.7391548" - rx="11.071856" - inkscape:bbox-height="46.239804" - inkscape:bbox-width="58.405701" - inkscape:bbox-y="318.06628" - inkscape:bbox-x="356.78795" - y="116.73241" - x="357.82645" - height="44.162804" - width="56.328701" - id="rect3599-9-3" - style="fill:none;stroke:#000080;stroke-width:2.07699990000000012;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" - mbname="presshint" /> - <g - id="g3849" - inkscape:bbox-x="2.2255181" - inkscape:bbox-y="-289.63124" - inkscape:bbox-width="317.40625" - inkscape:bbox-height="359.25593" - mbname="dock" - transform="translate(1.1059905,-570.69124)"> - <path - inkscape:bbox-height="76.31255" - inkscape:bbox-width="317.40625" - inkscape:bbox-y="-6.68786" - inkscape:bbox-x="2.2255181" - inkscape:connector-curvature="0" - id="rect2817" - d="m 163.68203,981.06655 c -63.1198,0 -120.411185,7.92804 -162.5625024,20.84375 l 0,55.4688 317.4062524,0 0,-57.7188 C 277.22165,988.08365 223.03485,981.06655 163.68203,981.06655 z" - style="fill:#4494c2;fill-opacity:0.59174314;stroke:none" /> - <path - style="fill:#6083ff;fill-opacity:1;stroke:#1033ff;stroke-width:2.0769999;stroke-miterlimit:4;stroke-opacity:1" - d="m 182.48848,1003.6866 c 0,8.2461 -9.16063,14.9309 -20.46083,14.9309 -11.3002,0 -20.46083,-6.6848 -20.46083,-14.9309 0,-8.24608 9.16063,-14.93086 20.46083,-14.93086 11.3002,0 20.46083,6.68478 20.46083,14.93086 z" - id="path3843" - inkscape:connector-curvature="0" - inkscape:bbox-x="141.63431" - inkscape:bbox-y="31.03524" - inkscape:bbox-width="42.99866" - inkscape:bbox-height="31.93876" /> - <rect - style="fill:#ececec;fill-opacity:1;stroke:#c7cfff;stroke-width:2.03777313;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" - id="rect2838" - width="310.82263" - height="282.06689" - x="4.4043493" - y="1057.2367" - inkscape:bbox-x="4.4914533" - inkscape:bbox-y="-289.63124" - inkscape:bbox-width="312.8604" - inkscape:bbox-height="284.10467" /> - </g> - </g> -</svg>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/run.sh Fri Nov 12 17:39:04 2010 +0800 @@ -0,0 +1,11 @@ +#!/bin/sh + +ABS=`realpath $0` +BASE=`dirname $ABS` +NODE_PATH=$BASE:$NODE_PATH +export NODE_PATH + +DIR=`dirname $1` +FNAME=`basename $1` + +cd $DIR; node $FNAME
--- a/nodejs/svgviewer.js Fri Nov 12 17:08:13 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- -// vim: sw=4:ts=8:sts=4 -var svg = require("./svg"); -var mbapp = require("./mbapp"); - -app = new mbapp.app(); -app.loadSVG("test.svg"); -app.loop();
--- a/nodejs/test.svg Fri Nov 12 17:08:13 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,538 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- Created with Inkscape (http://www.inkscape.org/) --> - -<svg - xmlns:ns0="http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd" - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:xlink="http://www.w3.org/1999/xlink" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="720" - height="480" - id="svg2" - sodipodi:version="0.32" - inkscape:version="0.47 r22583" - sodipodi:docname="test.svg" - version="1.0" - inkscape:output_extension="org.inkscape.output.svg.inkscape"> - <sodipodi:namedview - id="base" - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1.0" - gridtolerance="10000" - guidetolerance="10" - objecttolerance="10" - inkscape:pageopacity="0.0" - inkscape:pageshadow="2" - inkscape:zoom="1.0347223" - inkscape:cx="151.05815" - inkscape:cy="228.90269" - inkscape:document-units="px" - inkscape:current-layer="layer1" - showgrid="false" - inkscape:window-width="1347" - inkscape:window-height="894" - inkscape:window-x="0" - inkscape:window-y="25" - inkscape:window-maximized="0" /> - <defs - id="defs4"> - <linearGradient - id="linearGradient3183"> - <stop - style="stop-color:#000000;stop-opacity:1;" - offset="0" - id="stop3185" /> - <stop - style="stop-color:#505050;stop-opacity:1;" - offset="1" - id="stop3187" /> - </linearGradient> - <inkscape:perspective - id="perspective10" - inkscape:persp3d-origin="804.3173 : 267.38473 : 1" - inkscape:vp_z="1630.7262 : 376.00761 : 1" - inkscape:vp_y="0 : 619.30892 : 0" - inkscape:vp_x="-22.091594 : 376.00761 : 1" - sodipodi:type="inkscape:persp3d" /> - <linearGradient - inkscape:collect="always" - xlink:href="#linearGradient3183" - id="linearGradient3189" - x1="0" - y1="239.5" - x2="719.99998" - y2="239.5" - gradientUnits="userSpaceOnUse" /> - </defs> - <metadata - id="metadata7"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - <ns0:scenes - current="1" /> - </metadata> - <g - inkscape:groupmode="layer" - id="layer2" - inkscape:label="Background" - sodipodi:insensitive="true"> - <rect - style="opacity:1;fill:url(#linearGradient3189);fill-opacity:1;stroke:#000000;stroke-width:0.9993065;stroke-opacity:1" - id="rect3181" - width="719.00067" - height="480.0007" - x="0.49965325" - y="-0.50034672" /> - </g> - <g - id="layer1" - inkscape:groupmode="layer" - inkscape:label="Layer 1"> - <g - transform="translate(144.04213,-2.85715)" - id="item1" - mbname="item1" - style="fill-opacity:1" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="422.51731" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219"> - <text - id="text2395" - y="60" - x="157.14285" - style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" - xml:space="preserve" - sodipodi:linespacing="125%" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="422.51731" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219"><tspan - mbname="item1text" - y="60" - x="157.14285" - id="tspan2397" - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="422.51731" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219">item1</tspan></text> - </g> - <g - transform="translate(144.04213,39.689836)" - id="item2" - mbname="item2" - style="fill-opacity:1" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="379.97032" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219"> - <text - id="text2421" - y="60" - x="157.14285" - style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" - xml:space="preserve" - sodipodi:linespacing="125%" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="379.97032" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219"><tspan - mbname="item2text" - y="60" - x="157.14285" - id="tspan2423" - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="379.97032" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219">item1</tspan></text> - </g> - <g - transform="translate(144.04213,82.236798)" - id="item3" - mbname="item3" - style="fill-opacity:1" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="337.42336" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219"> - <text - id="item3text" - y="60" - x="157.14285" - style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" - xml:space="preserve" - sodipodi:linespacing="125%" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="337.42336" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219"><tspan - mbname="item3text" - y="60" - x="157.14285" - id="tspan2429" - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="337.42336" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219">item1</tspan></text> - </g> - <g - transform="translate(144.04213,124.7838)" - id="item4" - mbname="item4" - style="fill-opacity:1" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="294.87636" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219"> - <text - id="item4text" - y="60" - x="157.14285" - style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" - xml:space="preserve" - sodipodi:linespacing="125%" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="294.87636" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219"><tspan - mbname="item4text" - y="60" - x="157.14285" - id="tspan2435" - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="294.87636" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219">item1</tspan></text> - </g> - <g - transform="translate(144.04213,167.33077)" - id="item5" - mbname="item5" - style="fill-opacity:1" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="252.32939" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219"> - <text - id="item5text" - y="60" - x="157.14285" - style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" - xml:space="preserve" - sodipodi:linespacing="125%" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="252.32939" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219"><tspan - mbname="item5text" - y="60" - x="157.14285" - id="tspan2441" - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="252.32939" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219">item1</tspan></text> - </g> - <g - transform="translate(144.04213,209.87776)" - id="item6" - mbname="item6" - style="fill-opacity:1" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="209.7824" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219"> - <text - id="item6text" - y="60" - x="157.14285" - style="font-size:24px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Bold" - xml:space="preserve" - sodipodi:linespacing="125%" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="209.7824" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219"><tspan - mbname="item6text" - y="60" - x="157.14285" - id="tspan2447" - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="209.7824" - inkscape:bbox-width="74.0625" - inkscape:bbox-height="18.574219">item1</tspan></text> - </g> - <g - transform="translate(145.21401,252.42474)" - id="item7" - mbname="item7" - style="fill-opacity:1" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="167.23542" - inkscape:bbox-width="65.027344" - inkscape:bbox-height="18.574219"> - <text - id="item7text" - y="60" - x="157.14285" - style="font-size:24px;font-style:oblique;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;-inkscape-font-specification:Bitstream Vera Sans Oblique" - xml:space="preserve" - sodipodi:linespacing="125%" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="167.23542" - inkscape:bbox-width="65.027344" - inkscape:bbox-height="18.574219"><tspan - mbname="item7text" - y="60" - x="157.14285" - id="tspan2453" - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="167.23542" - inkscape:bbox-width="65.027344" - inkscape:bbox-height="18.574219">item1</tspan></text> - </g> - <g - transform="translate(143.79604,294.97172)" - id="item8" - mbname="item8" - style="fill-opacity:1" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="124.68844" - inkscape:bbox-width="65.027344" - inkscape:bbox-height="18.574219"> - <text - id="item8text" - y="60" - x="157.14285" - style="font-size:24px;font-style:normal;font-weight:normal;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" - xml:space="preserve" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="124.68844" - inkscape:bbox-width="65.027344" - inkscape:bbox-height="18.574219"><tspan - mbname="item8text" - y="60" - x="157.14285" - id="tspan2459" - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="124.68844" - inkscape:bbox-width="65.027344" - inkscape:bbox-height="18.574219">item1</tspan></text> - </g> - <g - transform="translate(143.79604,337.5187)" - id="item9" - mbname="item9" - style="fill-opacity:1" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="82.141456" - inkscape:bbox-width="65.027344" - inkscape:bbox-height="18.574219"> - <text - mbname="" - id="text2407" - y="60" - x="157.14285" - style="font-size:24px;font-style:normal;font-weight:normal;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans" - xml:space="preserve" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="82.141456" - inkscape:bbox-width="65.027344" - inkscape:bbox-height="18.574219"><tspan - mbname="item9text" - y="60" - x="157.14285" - id="tspan2409" - sodipodi:role="line" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="303.20061" - inkscape:bbox-y="82.141456" - inkscape:bbox-width="65.027344" - inkscape:bbox-height="18.574219">item1</tspan></text> - </g> - <text - id="text2416" - y="44.383541" - x="24.177626" - style="font-size:24px;font-style:normal;font-weight:normal;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" - xml:space="preserve"><tspan - mbname="title" - y="44.383541" - x="24.177626" - id="tspan2418" - sodipodi:role="line">Menu test</tspan></text> - </g> - <g - inkscape:groupmode="layer" - id="layer4" - inkscape:label="lightbar"> - <g - mbname="item_lightbar" - transform="matrix(0.9148913,0,0,1,168.41407,93.684101)" - id="item_lightbar" - style="stroke:none" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="164.66374" - inkscape:bbox-y="326.01386" - inkscape:bbox-width="409.10203" - inkscape:bbox-height="33.623234"> - <rect - style="opacity:0.3669725;fill:#001f41;fill-opacity:1;stroke:none" - id="rect3191" - width="442.8623" - height="29.190758" - x="0.19951171" - y="31.140766" - transform="matrix(0.9999958,-0.00289533,0,1,0,0)" - rx="10.000001" - ry="10" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="168.5966" - inkscape:bbox-y="326.01386" - inkscape:bbox-width="405.16917" - inkscape:bbox-height="30.41517" /> - <rect - style="opacity:0.3669725;fill:#eafbf3;fill-opacity:1;stroke:none" - id="rect2405" - width="442.86224" - height="29.190758" - x="-4.099226" - y="27.920256" - transform="matrix(0.9999958,-0.00289533,0,1,0,0)" - rx="10" - ry="10" - inkscape:transform-center-x="0" - inkscape:transform-center-y="0" - inkscape:bbox-x="164.66374" - inkscape:bbox-y="329.22193" - inkscape:bbox-width="405.16911" - inkscape:bbox-height="30.41517" /> - </g> - <image - y="78.788635" - x="34.986565" - id="image3033" - xlink:href="file:logo.png" - height="37" - width="46" /> - <g - sodipodi:type="inkscape:box3d" - style="fill:none;stroke:none" - id="g2953" - inkscape:perspectiveID="#perspective10" - inkscape:corner0="11.418244 : -1.091331 : 0 : 1" - inkscape:corner7="6.2635014 : -2.542367 : 0.25 : 1"> - <path - sodipodi:type="inkscape:box3dside" - id="path2963" - style="fill:#afafde;fill-rule:evenodd;stroke:none" - inkscape:box3dsidetype="13" - d="M 44.456373,239.52954 91.68396,335.71719 142.89318,328.00691 75.760432,236.8548 z" /> - <path - sodipodi:type="inkscape:box3dside" - id="path2955" - style="fill:#353564;fill-rule:evenodd;stroke:none" - inkscape:box3dsidetype="6" - d="m 44.456373,167.16508 0,72.36446 31.304059,-2.67474 0,-70.93639 z" /> - <path - sodipodi:type="inkscape:box3dside" - id="path2965" - style="fill:#e9e9ff;fill-rule:evenodd;stroke:none" - inkscape:box3dsidetype="11" - d="m 75.760432,165.91841 67.132748,42.48521 0,119.60329 -67.132748,-91.15211 z" /> - <path - sodipodi:type="inkscape:box3dside" - id="path2957" - style="fill:#4d4d9f;fill-rule:evenodd;stroke:none" - inkscape:box3dsidetype="5" - d="m 44.456373,167.16508 47.227587,44.83223 51.20922,-3.59369 -67.132748,-42.48521 z" /> - <path - sodipodi:type="inkscape:box3dside" - id="path2961" - style="fill:#d7d7ff;fill-rule:evenodd;stroke:none" - inkscape:box3dsidetype="14" - d="m 91.68396,211.99731 0,123.71988 51.20922,-7.71028 0,-119.60329 z" /> - <path - sodipodi:type="inkscape:box3dside" - id="path2959" - style="fill:#8686bf;fill-rule:evenodd;stroke:none" - inkscape:box3dsidetype="3" - d="m 44.456373,167.16508 47.227587,44.83223 0,123.71988 -47.227587,-96.18765 z" /> - </g> - </g> -</svg>
--- a/nodejs/testcanvas.js Fri Nov 12 17:08:13 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- -// vim: sw=4:ts=8:sts=4 -var mbapp = require("./mbapp"); -var sys=require("sys"); -var canvas=require("./canvas"); - -app = new mbapp.app(); - -app.canvas = new canvas.canvas(app,app.mb_rt.root); - -app.canvas.background(0,0,0,1); -app.canvas.rect(0,0,400,400); -app.canvas.strokeWeight(8); -width=200; -height=200; - -setInterval(function() { - app.canvas.clear(); - - for(i=0;i<width;i++) { - x = Math.random()*255; - y = Math.random()*200; - cr = Math.random() - cg = Math.random() - cb = Math.random() - app.canvas.stroke(cr,cg,cb,1); - app.canvas.line(i,0,x,height); - } - app.update(); -},33); -app.loop();
--- a/nodejs/testcase.js Fri Nov 12 17:08:13 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,169 +0,0 @@ -// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- -// vim: sw=4:ts=8:sts=4 -var mbfly = require("mbfly"); -var r = mbfly.Hello(" test"); -var sys = require("sys"); -sys.puts(r); - -var display_name = ":0.0"; -if(process.argv.length == 3) - display_name = process.argv[2]; - -var mb_rt = new mbfly.mb_rt(display_name, 300, 200); -var root = mb_rt.root; -sys.puts("root matrix: " + - [root[0], root[1], root[2], root[3], root[4], root[5]]); -var coord = mb_rt.coord_new(root); -sys.puts("coord matrix: " + - [coord[0], coord[1], coord[2], coord[3], coord[4], coord[5]]); - -/* Testcase for image shapes */ -var img = mb_rt.image_new(10, 10, 50, 50); -var ldr = mbfly.img_ldr_new("."); -var img_data = ldr.load("sample.png"); -var paint = mb_rt.paint_image_new(img_data); -var img_coord = mb_rt.coord_new(root); -paint.fill(img); -img_coord.add_shape(img); - -/* test linear paint and rectangle */ -var rect = mb_rt.rect_new(100, 100, 50, 50, 10, 10); -sys.puts(mb_rt.paint_linear_new); -var paint = mb_rt.paint_linear_new(100, 100, 150, 150); -paint.set_stops([[0, 0, 1, 0, 1], [1, 0, 0, 1, 1]]); -paint.fill(rect); -root.add_shape(rect); - -/* test radial paint and rectangle */ -var rect = mb_rt.rect_new(150, 100, 50, 50, 10, 10); -sys.puts(mb_rt.paint_radial_new); -var paint = mb_rt.paint_radial_new(175, 125, 25); -paint.set_stops([[0, 0, 1, 0, 1], [1, 0, 0, 1, 1]]); -paint.fill(rect); -root.add_shape(rect); - -/* test alpha blending and rectangle */ -var rect = mb_rt.rect_new(40, 40, 100, 100, 10, 10); -sys.puts(mb_rt.paint_color_new); -var paint = mb_rt.paint_color_new(1, 0.5, 0.5, 0.5); -paint.fill(rect); -root.add_shape(rect); - -/* test hide of shapes */ -var sw = 1; -setInterval(function() { - if(sw) { - rect.hide(); - sw = 0; - } else { - rect.show(); - sw = 1; - } - }, 1000); - -/* test hide of coord */ -var cw = 1; -setInterval(function() { - if(sw) { - coord.hide(); - cw = 0; - } else { - coord.show(); - cw = 1; - } - }, 3000); - -/* test removing a coord */ -var rm_coord = mb_rt.coord_new(root); -var rm_rect1 = mb_rt.rect_new(150, 150, 50, 50, 10, 10); -paint.fill(rm_rect1); -rm_coord.add_shape(rm_rect1); -var rm_rect2 = mb_rt.rect_new(100, 150, 50, 50, 10, 10); -paint.fill(rm_rect2); -rm_coord.add_shape(rm_rect2); -setTimeout(function() { - rm_coord.remove(); - mb_rt.redraw_changed(); - mb_rt.flush(); - }, 3000); - -/* test removing a shape */ -setTimeout(function() { - rm_rect1.remove(); - mb_rt.redraw_changed(); - mb_rt.flush(); - }, 2000); - -/* Moving a path */ -sys.puts(mb_rt.path_new); -var path = mb_rt.path_new("m 100,50 L 120,50 L 200,150 L 180,150 z"); -sys.puts(path); -sys.puts(coord.add_shape); -coord.add_shape(path); - -sys.puts(mb_rt.paint_color_new); -var paint = mb_rt.paint_color_new(1, 1, 1, 1); -sys.puts(paint); -paint.stroke(path); - -sys.puts(path.stroke_width); -path.stroke_width = 2; -sys.puts(path.stroke_width); - -var face = mb_rt.font_face_query("courier", 2, 100); -var blks = [[5, face, 20]]; -var stext = mb_rt.stext_new("Hello", 100, 50); -stext.set_style(blks); -paint.fill(stext); -coord.add_shape(stext); - -mb_rt.redraw_all(); -mb_rt.flush(); - -var i = 0; -setInterval(function() { - var deg = (i++) * 0.1; - coord[2] = (i % 40) * 5; - mb_rt.redraw_changed(); - mb_rt.flush(); - }, 20); -setTimeout(function() { sys.puts("timeout"); }, 1000); - -sys.puts(root.mouse_event); -var observer; -/* Mouse button pressed */ -observer = root.mouse_event.add_event_observer(4, function(evt) { - var c = 1 - (i % 40) / 40; - sys.puts(c); - - sys.puts("mouse " + evt.x + " " + evt.y); - sys.puts(c); - sys.puts(paint.set_color); - paint.set_color(c, 1, 1, 1); - mb_rt.redraw_changed(); - mb_rt.flush(); - }); - -var resize_sw = 0; -setInterval(function() { - var sz; - - resize_sw++; - - sz = (resize_sw % 20) - 10; - if(sz < 0) - sz = -sz; - sz = 2 - sz / 10; - - img_coord[0] = sz; - img_coord[4] = sz; - mb_rt.redraw_changed(); - mb_rt.flush(); - }, 50); - -var kbobserver; -/* Keyboard event */ -kbobserver = mb_rt.kbevents.add_event_observer(6, function(evt) { - sys.puts("keycode = " + evt.keycode); - sys.puts("sym = " + evt.sym); - });
--- a/nodejs/testdesktop.js Fri Nov 12 17:08:13 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- -// vim: sw=4:ts=8:sts=4 -var svg = require("./svg"); -var mbapp = require("./mbapp"); -var sys=require("sys"); -var animate=require("./animate"); -var fs = require("fs"); - -app = new mbapp.app(); -app.loadSVG("desktop.svg"); - -video = app.get("video"); -//var an = new animate.alpha(app,video,0,1); -//an.start(); -audio = app.get("audio"); -picture = app.get("picture"); -setting = app.get("setting"); - -lightbar = app.get("lightbar"); -lines = []; -for(i = 0; i < 5; i++) { - line = app.get("line" + (i + 1)); - lines.push(line); -} -line=0; - -items=[video, audio, picture, setting]; - -item = 0; - -animate.run([new animate.scale(app,items[item], 1, 1.5)], 0, 0.1); -app.refresh(); - -app.addKeyListener(mbapp.KEY_LEFT, function() { - var old = items[item]; - item = item - 1; - if (item == -1) { - item = 0; - return; - } - - var target = items[item]; - - old.bbox.update(); - target.bbox.update(); - - var an = new animate.scale(app, old, 1, 1); - animate.run([an], 0, 0.1); - an = new animate.scale(app, target, 1, 1.5); - animate.run([an], 0, 0.3); -}); - -app.addKeyListener(mbapp.KEY_RIGHT, function() { - var old = items[item]; - item = item + 1; - if (item == items.length) { - item = item - 1; - return; - } - - var target = items[item]; - - old.bbox.update(); - target.bbox.update(); - - var an = new animate.scale(app, old, 1, 1); - animate.run([an], 0, 0.1); - an = new animate.scale(app, target, 1, 1.5); - animate.run([an], 0, 0.3); -}); - -app.addKeyListener(mbapp.KEY_UP, function() { - var old = lines[line]; - line = line - 1; - if (line == -1) { - line = 0; - return; - } - var target = lines[line]; - var sy = target.center.y - lightbar.center.y; - sys.puts(sy); - var an = new animate.shift(app, lightbar, 0, sy); - animate.run([an], 0, 0.3); -}); -app.addKeyListener(mbapp.KEY_DOWN, function() { - var old = lines[line]; - line = line + 1; - if (line == lines.length) { - line = line - 1; - return; - } - var target = lines[line]; - var sy = target.center.y - lightbar.center.y; - sys.puts("line="+line); - sys.puts("sy="+sy); - sys.puts("target.y="+target.center.y); - sys.puts("lightbar.y="+lightbar.center.y); - var an = new animate.shift(app, lightbar, 0, sy); - animate.run([an], 0, 0.3); -}); - -app.addKeyListener(mbapp.KEY_ENTER, function() { - var target = items[item]; - var sx = 500 - target.center.x; - var sy = 220 - target.center.y; - sys.puts("target "+sx+','+sy); - var an = new animate.shift(app,target,sx,sy,1); - an.start(); - for(i=0;i<items.length;i++) { - if (i == item) continue; - var x = Math.random(); - var y = Math.random(); - if (x > 0.5) x = 900; - else x = -500; - if (y > 0.5) y = 900; - else y = -500; - sx = x - items[i].center.x; - sy = y - items[i].center.y; - an = new animate.shift(app,items[i], sx, sy); - animate.run([an], 0, 2); - alpha = new animate.alpha(app,items[i], 0); - animate.run([an], 0, 1); - } -}); - -app.loop();
--- a/nodejs/testimage.js Fri Nov 12 17:08:13 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- -// vim: sw=4:ts=8:sts=4 -var svg = require("./svg"); -var mbapp = require("./mbapp"); -var sys=require("sys"); -var animate=require("./animate"); -var fs = require("fs"); - -app = new mbapp.app(); - -coord = app.mb_rt.coord_new(app.mb_rt.root); -data=mbapp.ldr.load("sample.png"); -paint = app.mb_rt.paint_image_new(data); -img = app.mb_rt.image_new(10,10,50,50); -paint.fill(img); -coord.opacity = 0.9; -coord.add_shape(img); - -app.loop();
--- a/nodejs/testleak.js Fri Nov 12 17:08:13 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,217 +0,0 @@ -// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- -// vim: sw=4:ts=8:sts=4 -var mbfly = require("mbfly"); -var sys = require("sys"); -var cproc = require("child_process"); - -function testcase1() { - var mbrt = new mbfly.mb_rt(":32.0", 300, 200); - var root = mbrt.root; - var coords = []; - var coord; - var i; - - while(true) { - for(i = 0; i < 200; i++) { - coords.push(mbrt.coord_new(root)); - } - mbrt.redraw_changed(); - mbrt.flush(); - - while(coords.length > 0) { - coord = coords.pop(); - coord.remove(); - } - } -} - -function testcase2() { - var mbrt = new mbfly.mb_rt(":32.0", 300, 200); - var root = mbrt.root; - var coords = []; - var coord; - var i, j; - - while(true) { - for(i = 0; i < 200; i++) { - coords.push(mbrt.coord_new(root)); - for(j = 0; j < 10; j++) - coord = mbrt.coord_new(coords[i]); - } - mbrt.redraw_changed(); - mbrt.flush(); - - while(coords.length > 0) { - coord = coords.pop(); - coord.remove(); - } - } -} - -function testcase3() { - var mbrt = new mbfly.mb_rt(":32.0", 300, 200); - var root = mbrt.root; - var coords = []; - var coord; - var shape; - var i, j; - - while(true) { - for(i = 0; i < 200; i++) { - coords.push(mbrt.coord_new(root)); - for(j = 0; j < 10; j++) { - coord = mbrt.coord_new(coords[i]); - shape = mbrt.rect_new(15, 15, 20, 20, 0, 0); - coord.add_shape(shape); - } - } - mbrt.redraw_changed(); - mbrt.flush(); - - while(coords.length > 0) { - coord = coords.pop(); - coord.remove(); - } - } -} - -function testcase4() { - var mbrt = new mbfly.mb_rt(":32.0", 300, 200); - var root = mbrt.root; - var coords = []; - var coord; - var shape; - var i, j; - - while(true) { - for(i = 0; i < 200; i++) { - coords.push(mbrt.coord_new(root)); - for(j = 0; j < 10; j++) { - coord = mbrt.coord_new(coords[i]); - shape = mbrt.path_new("m 10,10 l 55,27 l -30,-3 z"); - coord.add_shape(shape); - } - } - mbrt.redraw_changed(); - mbrt.flush(); - - while(coords.length > 0) { - coord = coords.pop(); - coord.remove(); - } - } -} - -function testcase5() { - var mbrt = new mbfly.mb_rt(":32.0", 300, 200); - var root = mbrt.root; - var paint; - - while(true) { - paint = mbrt.paint_color_new(0.5, 0.5, 0.5, 1); - } -} - -function testcase6() { - var mbrt = new mbfly.mb_rt(":32.0", 300, 200); - var root = mbrt.root; - var coords = []; - var coord; - var shape; - var paint; - var i, j; - - while(true) { - for(i = 0; i < 200; i++) { - coords.push(mbrt.coord_new(root)); - /* Paint is free, but rdman is dirty */ - paint = mbrt.paint_color_new(0.5, 0.5, 0.5, 1); - for(j = 0; j < 10; j++) { - coord = mbrt.coord_new(coords[i]); - shape = mbrt.rect_new(5, 5, 20, 20, 0, 0); - coord.add_shape(shape); - } - } - mbrt.redraw_changed(); - mbrt.flush(); - - while(coords.length > 0) { - coord = coords.pop(); - coord.remove(); - } - } -} - -function testcase7() { - var mbrt = new mbfly.mb_rt(":32.0", 300, 200); - var root = mbrt.root; - var coords = []; - var coord; - var shape; - var paint; - var i, j; - - while(true) { - for(i = 0; i < 200; i++) { - coords.push(mbrt.coord_new(root)); - for(j = 0; j < 10; j++) { - /* paint is not free, and rdman is dirty */ - paint = mbrt.paint_color_new(0.5, 0.5, 0.5, 1); - coord = mbrt.coord_new(coords[i]); - shape = mbrt.path_new("M 100,100 L 30,30 L 0,30 z"); - coord.add_shape(shape); - paint.stroke(shape); - } - } - mbrt.redraw_changed(); - mbrt.flush(); - - while(coords.length > 0) { - coord = coords.pop(); - coord.remove(); - } - } -} - -cproc.exec("killall -9 Xvfb; Xvfb :32 -screen 0 800x600x24"); -setTimeout(function() { - if(process.argv.length == 1) - testcase1(); - else if(process.argv.length == 3) { - sys.puts("testcase " + process.argv[2]); - switch(process.argv[2]) { - case "1": - testcase1(); - break; - - case "2": - testcase2(); - break; - - case "3": - testcase3(); - break; - - case "4": - testcase4(); - break; - - case "5": - testcase5(); - break; - - case "6": - testcase6(); - break; - - case "7": - testcase7(); - break; - - default: - sys.puts("Usage: node testleak.js [1|2|3...7]"); - } - } else - sys.puts("Usage: node testleak.js [1|2|3...7]"); - cproc.exec("killall -9 Xvfb"); - }, 1500);
--- a/nodejs/testsvg.js Fri Nov 12 17:08:13 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- -// vim: sw=4:ts=8:sts=4 -var svg = require("./svg"); -var mbapp = require("./mbapp"); -var sys=require("sys"); -var animate=require("./animate"); -var fs = require("fs"); - -app = new mbapp.app(); -app.loadSVG("test.svg"); -lightbar = app.get("item_lightbar"); -item=1; -var target = app.get("item" + item); -sys.puts(lightbar.center.x); -sys.puts(lightbar.center.y); -lightbar.center.move_pnt(target.center); -// lightbar[5] = app.get("item"+item)[5]; - -app.files=fs.readdirSync("/tmp/"); -for(i=1;i<10;i++) { - var o = app.get("item"+i+"text"); - o.set_text(app.files[i]); -} - - - - -app.addKeyListener(mbapp.KEY_UP, function() { - item = item - 1; - if (item == 0) - item = 1; - else { - var target = app.get("item"+item); - var shx = target.center.x - lightbar.center.x; - var shy = target.center.y - lightbar.center.y; - var action = new animate.shift(app, lightbar, shx, shy); - var an = new animate.linear(action, 0, 0.3); - an.start(); - } -}); - -app.addKeyListener(mbapp.KEY_DOWN, function() { - item = item + 1; - if (item == 10) { - item = 9; - } else { - var target = app.get("item"+item); - var shx = target.center.x - lightbar.center.x; - var shy = target.center.y - lightbar.center.y; - var action = new animate.shift(app, lightbar, shx, shy); - var an = new animate.linear(action, 0, 0.3); - sys.puts(target.center.y); - sys.puts(lightbar.center.y); - an.start(); - } -}); - -app.loop();