view nodejs/examples/simple/test-translate.js @ 1434:4be04f29fa70

Add functions to search for the text recursively inside coord_t tree. Once we find the first instance, we change the text of it. We need to think about how to manage the multiple segment texts, which is composed of several tspan.
author wycc
date Mon, 11 Apr 2011 12:52:09 +0800
parents b8dfa491ed9d
children
line wrap: on
line source

// -*- 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");

app = new mbapp.app();

coord_parent = app.mb_rt.coord_new(app.mb_rt.root);
coord = app.mb_rt.coord_new(coord_parent)
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.add_shape(img);

var shift = 0;
function translate_handler() {
    coord_parent[2] = shift;
    app.refresh();
    setTimeout(translate_handler, 100);
    shift = shift + 10;
}

translate_handler();
app.loop()