Attribute/Property Parameters

If that topic already has been discussed
in this list or other news-groups,
please forgive me, I am new to the SVG-scene.
In the current SVG version I am missing some thing:

Attribute/Property Parameters

It would be great to have a mechanism,
which allows you to change some attributes/properties
of a graphic that is instantiated with the
use- or image-element, without using scripts.
This could be achieved with named parameters.
For every animatable attribute/property an
def-param element could be defined in the
same way than animation elements are defined:

<!ENTITY % setExt "" >
<!ELEMENT def-param (%descTitle;%setExt;) >
<!ATTLIST def-param
  %stdAttrs;
  %testAttrs;
  externalResourcesRequired %Boolean; #IMPLIED
  %animTargetAttrs;
  name CDATA #REQUIRED >

When an graphic is instantiated with use
or image, a set-param element can be
used to set a named parameter:

<!ENTITY % setExt "" >
<!ELEMENT set-param (%descTitle;%setExt;) >
<!ATTLIST set-param
  %stdAttrs;
  %testAttrs;
  name CDATA #REQUIRED
  to CDATA #REQUIRED >

<!ENTITY % useExt "" >
<!ELEMENT use
(%descTitle;,(def-param|set-param|animate|set|animateMotion|animateColor|animateTransform
                   %geExt;%useExt;)*) >
<!ATTLIST use
  ... >

<!ENTITY % imageExt "" >
<!ELEMENT image
(%descTitle;,(def-param|set-param|animate|set|animateMotion|animateColor|animateTransform
                   %geExt;%imageExt;)*) >
<!ATTLIST image
  ... >


Here is an example-dokument, which shows this mechanism:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN" 
 
"http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd">
<svg width="100" height="50">
  <desc>Example for using def-param and set-param</desc>

  <defs>
    <g id="MyGroup">
      <rect width="100" height="50">
        <def-param name="rectWidth" attributeName="width" />
        <def-param name="rectHeight" attributeName="height" />
      </rect>
      <circle cx="25" cy="25" r="10" style="fill:red; stroke:blue">
        <def-param name="circleFill" attributeName="fill" />
        <def-param name="circleStroke" attributeName="stroke" />
        <def-param name="circleOffset" attributeName="cx" />
        <def-param name="circleOffset" attributeName="cy" />
      </circle>
    </g>
  </defs>

  <use xlink:href="#MyGroup">
    <set-param name="rectWidth" to="75" />
    <set-param name="rectHeight" to="25" />
    <set-param name="circleFill" to="yellow" />
    <set-param name="circleStroke" to="black" />
    <set-param name="circleOffset" to="20" />
  </use>

</svg>


OK, that's the simple version.
But it would be also useful, to execute
some basic mathematical calculations 
before a parameter is applied to an attribute.
That would enable us to link different graphic-primitives
to a single parameter, with a free defineable behavior.
For instance one could place a text always 5 pixel 
above an complex graphics, whose position/size is
animated via parameters
(offcourse the parameters themselve are full animateable).
The values of other parameters should be available
for the calculation.
Then it's possible to use anonymous parameters,
that calculate their values from other named parameters:

      <rect width="100" height="50">
        <def-param name="size" attributeName="width" function="size+2"/>
        <def-param function="size/2" attributeName="height" />
      </rect>

After all parameters of an use- or image-element are set,
the functions are calculated and the results are stored in
the corresponding attributes (not in the 'parameter-variables',
because that would leed to recursivity).

Defining multiple parameters with the same name,
is equivalent to defining one named parameter,
and other, anonymous parameters, whose functions
use the named paramter without any calculation:

        <def-param name="circleOffset" attributeName="cx" />
        <def-param name="circleOffset" attributeName="cy" />

is equivalent to:

        <def-param     name="circleOffset" attributeName="cx" />
        <def-param function="circleOffset" attributeName="cy" />


The attributes function and name would be #IMPLIED in the
DTD above. If none of the two attributes is present,
the value of attributeName is used for name.


What do you think about that ?

-Erik Unger
(Next-Reality)



-- 
Sent through GMX FreeMail - http://www.gmx.net

Received on Monday, 3 July 2000 13:13:23 UTC