Mercurial > MadButterfly
changeset 752:ffbf9910213c
Add testdesktop,js example.
Add animation.scale module.
author | wycc |
---|---|
date | Thu, 26 Aug 2010 09:53:15 +0800 |
parents | 9f4a1134ec82 |
children | 86f2c0fbadfc |
files | nodejs/desktop.svg nodejs/testdesktop.js |
diffstat | 2 files changed, 155 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/desktop.svg Thu Aug 26 09:53:15 2010 +0800 @@ -0,0 +1,108 @@ +<?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="744.09448" + height="480" + id="svg2" + version="1.1" + inkscape:version="0.47+devel r9312" + sodipodi:docname="desktop.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.98994949" + inkscape:cx="375" + inkscape:cy="177.14286" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="1920" + inkscape:window-height="1006" + inkscape:window-x="0" + inkscape:window-y="25" + inkscape:window-maximized="1" /> + <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></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-572.36218)"> + <g + id="g2917" + transform="translate(106.06602,-7.0710678)" + mbname="video"> + <rect + transform="translate(0,572.36218)" + y="238.57355" + x="63.63961" + height="74.751289" + width="83.842659" + id="rect2915" + style="fill:#0000ff;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + </g> + <g + id="g2917-8" + transform="translate(194.45437,-7.071074)" + mbname="audio"> + <rect + transform="translate(0,572.36218)" + y="238.57355" + x="63.63961" + height="74.751289" + width="83.842659" + id="rect2915-9" + style="fill:#0000ff;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + </g> + <g + id="g2917-88" + transform="translate(282.59017,-7.0710688)" + mbname="picture"> + <rect + transform="translate(0,572.36218)" + y="238.57355" + x="63.63961" + height="74.751289" + width="83.842659" + id="rect2915-8" + style="fill:#0000ff;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + </g> + <g + id="g2917-8-6" + transform="translate(370.97852,-7.0710788)" + mbname="setting"> + <rect + transform="translate(0,572.36218)" + y="238.57355" + x="63.63961" + height="74.751289" + width="83.842659" + id="rect2915-9-8" + style="fill:#0000ff;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + </g> + </g> +</svg>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/testdesktop.js Thu Aug 26 09:53:15 2010 +0800 @@ -0,0 +1,47 @@ +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"); +audio = app.get("audio"); +picture = app.get("picture"); +setting = app.get("setting"); +items=[video,audio,picture,setting]; +item = 2; +an = new animate.scale(app,items[item],1,1.5,0.3); +an.start(); + +app.addKeyListener(mbapp.KEY_UP, function() { + var old = items[item]; + item = item - 1; + if (item == -1) { + item = 0; + return; + } + var target = items[item]; + var an = new animate.scale(app,old,1,1,0.3); + an.start(); + an = new animate.scale(app,target,1,1.5,0.3); + an.start(); +}); + +app.addKeyListener(mbapp.KEY_DOWN, function() { + var old = items[item]; + item = item + 1; + if (item == items.length) { + item = item - 1; + return; + } + var target = items[item]; + var an = new animate.scale(app,old,1,1,0.3); + an.start(); + an = new animate.scale(app,target,1,1.5,0.3); + an.start(); +}); + +app.loop();