free hand

View: New views
7 Messages — Rating Filter:   Alert me  

free hand

by Peppe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

is there a method to draw "free hand"?

Re: free hand

by Andreas Neumann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

yes, if you track all the coordinates (evt.clientX/evt.clientY), then
translate them into the local coordinate system (using .getScreenCTM())
and then creating and updating the "d" attribute of a path element.

Andreas

Peppe wrote:

>is there a method to draw "free hand"?
>  
>


--
----------------------------------------------
Andreas Neumann
Institute of Cartography
ETH Zurich
Wolfgang-Paulistrasse 15
CH-8093  Zurich, Switzerland

Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
e-mail: neumann@...
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@...
For additional commands, e-mail: batik-users-help@...


Re: free hand

by Peppe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

But, how can i set the values M C or Z of "d" attribute?

Re: free hand

by Andreas Neumann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

there are two methods: either you use the methods of the DOM
SVGPathElement - see http://phrogz.net/ObjJob/object.asp?id=101 or you
create a new textstring everytime a coordinate is added. It might be
enough just to concatenate the new coordinates to the existing "d"
attribute.

Andreas

Peppe wrote:

>But, how can i set the values M C or Z of "d" attribute?
>
>  
>


--
----------------------------------------------
Andreas Neumann
Institute of Cartography
ETH Zurich
Wolfgang-Paulistrasse 15
CH-8093  Zurich, Switzerland

Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
e-mail: neumann@...
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@...
For additional commands, e-mail: batik-users-help@...


Re: free hand

by Peppe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i try to add a path creating a textstring but there is a problem...i don't know what values to use (M C Q T etc..)...for example: if i use C value, what value can i add in C parameters? because C is C x1,y1 x2,y2 x,y but i have only the x,y values...
pathValue = "M "+ startPt.getX()+","+startPt.getY()+" C ";
pathValue = pathValue + pt.getX()+ ","+ pt.getY()+ " " + .......(what??!!);
path.setAttributeNS(null, "d", pathValue);

Re: free hand

by thomas.deweese :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Peppe,

Peppe <peppe.delia@...> wrote on 12/16/2006 07:30:09 AM:

> i try to add a path creating a textstring but there is a problem...i don't
> know what values to use (M C Q T etc..)...for example: if i use C value,
> what value can i add in C parameters?


   So don't use 'C' just use 'M' at the start and 'L' everywhere else
(actually you don't even need the 'L's since "M x0,y0 x1,y1 x2,y2 ..."
is the same as "M x0,y0 L x1,y1 L x2,y2 ...").

> because C is C x1,y1 x2,y2 x,y but i
> have only the x,y values...
> pathValue = "M "+ startPt.getX()+","+startPt.getY()+" C ";
> pathValue = pathValue + pt.getX()+ ","+ pt.getY()+ " " + .......(what??!!);
> path.setAttributeNS(null, "d", pathValue);

   If you really wanted to you could go back after they are done
drawing and 'smooth' the curve, but that get's into 'interpolation'
and there is generally no one good answer here.  You could also
potentially use 'Q' which uses the tangent at the previous point
to generate the control point for a 'C'.  But really most people
just use L.

Re: free hand

by Peppe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Thomas, i've solved also this problem !