Mercurial > MadButterfly
view nodejs/testsvg.js @ 760:5781b2485e38
Fix position issue of stext.
Sometime, stext does not show at correct position. After some study,
it is caused by a typo in the code of create scaled font
(make_scaled_font_face()). The typo causes a fault in compute
transform matrix for scale fonts.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sat, 28 Aug 2010 22:54:07 +0800 |
parents | 6879aa403306 |
children | caa2fdb5f220 |
line wrap: on
line source
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; 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 an = new animate.linear(app,lightbar,target[2],target[5],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 an = new animate.linear(app,lightbar,target[2],target[5],0.3); an.start(); } }); app.loop();