you wrote:
----------------
i am going to use batik and i think my approach is very bad

(for a rect)
 - on mouse down, i start to make the shape by setting its x and y
coordinates, add the id, fills, stroke..
 - on mouse move while mouse down, i add the element to the svg and
updates the element by translate..
 - on mouse up, do nothing..

i am pretty sure there is a better way for doing this. and i want to
be able to modify them by mouse (resize, rotate, etc)..  any
suggestions? thank you
------------------

I think the approach you describe is illustrated here: 
http://srufaculty.sru.edu/david.dailey/svg/rectdraw.svg

the only difference (I think) is that the object is added to the DOM on 
mousedown rather than mousemove, which would seem to make more sense (why 
append on mousemove since then you'd be appending several times?).

Others may have different opinions, but what makes more sense to me, assuming 
you might add many objects to the DOM as with a drawing program, is to keep an 
array of drawn objects with current coordinates and other properties virtually, 
then to update the x and y values of the rect, rather than using a transform. 
Though translate, rotate and rescaling can all be appended to one another (for 
example, see 
http://srufaculty.sru.edu/david.dailey/svg/newstuff/transformRotate1.svg), to 
use properties of the objects in DOM as a place to do your bookkeeping may well 
be more sluggish than to build a parallel virtual representation in script. 

As examples of things using a more "virtual" approach to bookkeeping, see this 
relatively simple example using HTML: 
http://srufaculty.sru.edu/david.dailey/javascript/ani/rectangle2.html or this 
more complex example using SVG: 
http://srufaculty.sru.edu/david.dailey/svg/graphs30.svg .

You will note that in the former, the i-th "balloon" is defined as an object:
Balloons[i]={x:x,y:y,color:c,xv:xv,yv:yv,o:O}
containing its current position, color, velocity, and a pointer to the DOM 
object given by document.getElementById(i). This prevents having to traverse 
the DOM again to find the thing and then interrogate its properties -- at least 
so I think.

Others may have alternative suggestions and good reasons for doing things 
differently.

cheers,
David

[Non-text portions of this message have been removed]



-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to