some asciisvg questions

16 views
Skip to first unread message

Marc Grober

unread,
Apr 28, 2009, 12:45:36 PM4/28/09
to asci...@googlegroups.com
I am working on a lesson for teachers using asciimath and
asciisvg and have come up against the following:

1) Is there an existing way to do subscripts in asciisvg? I
want to identify a point as (x_1, y_1), is there a way to do
it without have to start a new text directive that shifts
the y value of the subscript?

2) What about text orientation, as in selecting a ray along
which the text is displayed and orienting the text to the
ray.....

Paul and SA, have you looked at text options at all in
your versions?

miedema

unread,
Apr 28, 2009, 1:53:30 PM4/28/09
to ASCIIMath
Just place it between `` so (`x_1`,`y_`) or `(x_1,y_1)` in my version
this works perfectly. I also added rotation to the text command, so
you can rotate text in any angle.
>  smime.p7s
> 4KViewDownload

miedema

unread,
Apr 28, 2009, 1:56:07 PM4/28/09
to ASCIIMath
By the way, just check the examples at www.fullxml.org
> > 4KViewDownload- Hide quoted text -
>
> - Show quoted text -

Paulo Soares

unread,
Apr 28, 2009, 2:02:18 PM4/28/09
to ASCIIMath
Hi Marc,

1) I'm pretty sure that asciisvg suports mathml over the svg picture
with the text command, e.g., text((1,1),"`(x_1,y_1)`").

2) my version allows the rotation and translation of elements
(including text except mathml over svg as in the previous point). I
believe it is not possible to do it with Peter's code.

--
Paulo Soares
>  smime.p7s
> 4KVerTransferir

Marc Grober

unread,
Apr 28, 2009, 2:33:33 PM4/28/09
to asci...@googlegroups.com
Yes, that seems to work fine.... brain fart in that single
quote broke the text function and haven't identified the
escape sequence (backslash does not work), which is a
separate issue....

I did notice that using `y=1/3x+2` inside svg resulted in
the insertion of the implied dot, which can be eliminated
with `y=1/3\x+2`

should I want to now combine the fallback version I am now
using with your version or SA's version it could amount to
quite a bit of work making sure there are inconsistencies in
the myriad functions.... so I think a core script with
libraries for incremental functioning would be a great idea,
but I think that also means some rewriting of the core to
make it, well, more transparent, and perhaps adding a line
that simply references any library found to be in the same
directory??

> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups "ASCIIMath" group.
> To post to this group, send email to asci...@googlegroups.com
> To unsubscribe from this group, send email to asciimath+...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/asciimath?hl=en
> -~----------~----~----~----~------~----~------~--~---
>

miedema

unread,
Apr 28, 2009, 2:44:42 PM4/28/09
to ASCIIMath
Also look at: http://www.fullxml.org/dredging/media/excersises/cutting.html
I'm busy making an interactive course and in the figure you see the
indices.

On Apr 28, 6:45 pm, Marc Grober <m...@interak.com> wrote:
>  smime.p7s
> 4KViewDownload

David Lippman

unread,
Apr 28, 2009, 2:53:30 PM4/28/09
to asci...@googlegroups.com
I haven't gone digging through the code yet... Does the `` approach overlay MathML in HTML divs over the SVG, or does it actually use SVG text elements?

Marc Grober

unread,
Apr 28, 2009, 2:53:55 PM4/28/09
to asci...@googlegroups.com
I would think that the appearance of the implied dot
suggests that it is using SVG elements, no?

Marc Grober

unread,
Apr 28, 2009, 3:08:27 PM4/28/09
to asci...@googlegroups.com
Intriguing....
the backslash will delete the next text svg character except
the implied dot, so text(z,"4\th") deletes the t and
produces 4h, while text(z, "4th") inserts the implied dot
between 4 and t..... but the backslash will not operate
on the single quote, and text(z,"Don't do this") will cause
an error ....

miedema

unread,
Apr 28, 2009, 3:11:33 PM4/28/09
to ASCIIMath
Its using div elements inside the mml div, when you refresh or resize,
in IE the contents of the mml div is ereased, resulting in a new svg
picture, in firefox its not erased and every object should have an id
otherwise it will be drawn twice.

For the rotation you can do the following:

function rotate(id, p, angle) {
var node, rotatestr;
rotatestr = "";
if (id!=null) {
node = doc.getElementById(id);
var xangle = p[0]*xunitlength+origin[0];
var yangle = height-p[1]*yunitlength-origin[1];
rotatestr = " translate("+xangle+","+yangle+") rotate("+angle+")
translate(-"+xangle+",-"+yangle+")";
node.setAttribute("transform",rotatestr);
}
return rotatestr;
}

In this function id is the id of an existing object, so give your text
an id and refer to it in this function.
p is to point to rotate around so p=[x,y];
angle is the rotation angle in degrees.

Here you also have the functions for the other transformations:

function translation(id, p) {
var node, translatestr;
translatestr = "";
if (id!=null) {
node = doc.getElementById(id);
var xangle = p[0]*xunitlength;
var yangle = -p[1]*yunitlength;
translatestr = " translate("+xangle+","+yangle+")";
node.setAttribute("transform",translatestr);
}
return translatestr;
}

function skewx(id, p, angle) {
var node, skewxstr;
skewxstr = "";
if (id!=null) {
node = doc.getElementById(id);
var xangle = p[0]*xunitlength+origin[0];
var yangle = height-p[1]*yunitlength-origin[1];
skewxstr = " translate("+xangle+","+yangle+") skewX("+angle+")
translate(-"+xangle+",-"+yangle+")";
node.setAttribute("transform",skewxstr);
}
return skewxstr;
}

function skewy(id, p, angle) {
var node, skewystr;
skewystr = "";
if (id!=null) {
node = doc.getElementById(id);
var xangle = p[0]*xunitlength+origin[0];
var yangle = height-p[1]*yunitlength-origin[1];
skewystr = " translate("+xangle+","+yangle+") skewY("+angle+")
translate(-"+xangle+",-"+yangle+")";
node.setAttribute("transform",skewystr);
}
return skewystr;
}

function scale(id, p, scalex, scaley) {
var node, scalestr;
scalestr = "";
if (id!=null) {
node = doc.getElementById(id);
var xangle = p[0]*xunitlength+origin[0];
var yangle = height-p[1]*yunitlength-origin[1];
scalestr = " translate("+xangle+","+yangle+") scale("+scalex
+","+scaley+") translate(-"+xangle+",-"+yangle+")";
node.setAttribute("transform",scalestr);
}
return scalestr;
}


On Apr 28, 8:53 pm, Marc Grober <m...@interak.com> wrote:
> I would think that the appearance of the implied dot
> suggests that it is using SVG elements, no?
>
>
>
> David Lippman wrote:
> > I haven't gone digging through the code yet... Does the `` approach overlay MathML in HTML divs over the SVG, or does it actually use SVG text elements?
>
> > -----Original Message-----
> > From: asci...@googlegroups.com [mailto:asci...@googlegroups.com] On Behalf Of miedema
> > Sent: Tuesday, April 28, 2009 10:54 AM
> > To: ASCIIMath
> > Subject: [ASCIIMath] Re: some asciisvg questions
>
> > Just place it between `` so (`x_1`,`y_`) or `(x_1,y_1)` in my version this works perfectly. I also added rotation to the text command, so you can rotate text in any angle.
>
> > On Apr 28, 6:45 pm, Marc Grober <m...@interak.com> wrote:
> >> I am working on a lesson for teachers using asciimath and asciisvg and
> >> have come up against the following:
>
> >> 1) Is there an existing way to do subscripts in asciisvg?  I want to
> >> identify a point as (x_1, y_1), is there a way to do it without have
> >> to start a new text directive that shifts the y value of the
> >> subscript?
>
> >> 2) What about text orientation, as in selecting a ray along which the
> >> text is displayed and orienting the text to the ray.....
>
> >> Paul and  SA,  have you looked at text options at all in your
> >> versions?
>
> >>  smime.p7s
> >> 4KViewDownload
>
> > >
>
>

miedema

unread,
Apr 28, 2009, 3:16:15 PM4/28/09
to ASCIIMath
I removed this because I wanted to be able to use multi character
indices, for examle F_hydr for a hydraulic force, the original
ASCIIMathML would place a multiplication dot between the "h" and the
"y".
In the examples I mentioned on my website, long indices work
perfectly.

Marc Grober

unread,
Apr 28, 2009, 6:54:31 PM4/28/09
to asci...@googlegroups.com
Curious part is that the version I am using does F_hydr
without any problem, unless I put it inside the asciisvg
text function (although I have to do F_(hydr) or it assumes
the y is a separate variable.) Where it does add a dot (as
in `y=1/3x+2`, as I noted earlier, I can avoid the dot by
backslashing so `y=1/3\x+2`

miedema

unread,
Apr 29, 2009, 6:07:25 AM4/29/09
to ASCIIMath
I know this, but I want to use the same equation for svg and for my
calculations, so the syntax should match the javascript syntax.
Reply all
Reply to author
Forward
0 new messages