Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Junior Mechanic
Posted
I'm new to SVG and XML.
Having read several tutorials, I started coding some SVGs.
Now here is what I wanna do in some pseudo-code:
(doesn't work like this, of course Wink )

...
var x=5;
var y=2.5;
<rect x="{$x}" y="{$x*2}" width="{$y}" height="68" />
<circle cx="{$x+5}" cy="0" r="10" />
...

Hope this is understandable.

I found out that something like this can be done with java-script.
But: Is there any chance of using variables without java-script?
Thx.
 
Posts: 2 | Registered: February 09, 2006Reply With QuoteEdit or Delete MessageReport This Post
Guru 'Power' Mechanic
Picture of Bruceee
Posted Hide Post
I'm not an SVG user, so you'd have to be guided by what your SVG tutorials say. You know much more than me Smile

If you can do something similar to what you want in SiteSpinner or Web Engine, you may find it useful to look at the SVG code they generate.
 
Posts: 9269 | Location: Wellington, New Zealand | Registered: December 11, 2003Reply With QuoteEdit or Delete MessageReport This Post
Junior Mechanic
Posted Hide Post
Well, the problem ist:
When you create SVGs with WYSIWYG programs like SiteSpinner, the size of an object is always seen as a constant number, so the code looks like this:

...
<rect x="5" y="10" width="2.5" height="68" />
<circle cx="10" cy="0" r="10" />
...

After modification of the rectangle and the circle, the constants would be changed:

...
<rect x="7" y="14" width="4" height="68" />
<circle cx="12" cy="0" r="10" />
...

This is rather inconvenient because I want to make an SVG where the positions and sizes of about 20 objects can be easily changed in order to create several versions of the same drawing.
At the moment, the only technique seems to be:
* re-calculate the values manually, then
* modify every single object

I thought there might be a way of using variables in XML like in my above post?
(Actually, it has nothing to do with SVG in particular.)
 
Posts: 2 | Registered: February 09, 2006Reply With QuoteEdit or Delete MessageReport This Post
Guru 'Power' Mechanic
Picture of Bruceee
Posted Hide Post
The general procedure would be to put your drawing code (circle and rectangles) into javascript functions. Then in javascript you would say something like:
<script>
DrawRectangle(5,10,2.5,68) //passing the variables to function DrawRectangle()
DrawRectangle(7,14,4,68)
.
.etc for as many rectangles as you want
.
</script>

The tricky bit for me would be the function DrawRectangle(), because that would have to be coded to use SVG (XML?). Sorry my knowledge in this area is nil Frown But judging by the number of Google references for SVG+javascript, it should be possible Smile
 
Posts: 9269 | Location: Wellington, New Zealand | Registered: December 11, 2003Reply With QuoteEdit or Delete MessageReport This Post
  Powered by Eve Community  
 


™ & © 1998 - 2008, Virtual Mechanics Inc. All rights reserved.