Gerrit . wrote:
[...]
I am currently concentrating on Batik programming, but if you would like to try
and implement such a function, I'll be glad to help.
Yes, I'd like. Patch attached. It combines two transforms into one by
multiplicating matrices with C function, just as you suggested.
swft:transform2, gives two transform specification and produces tag just
like swft:tranform. Patch includes test case, which looks same with both
versions (trunk and patched), but "wrap-element" test (in scriptout text
field) shows difference.
The problems I've found:
1. svg:use which links to svg:use is not even present in the clip (both
in trunk and my version). I don't know how to handle it recursively
2. I want inkscape's transformation center to be origin of movie clip
(possibly optionally), but the problem is that it's bound to center of
object, but I have no great ideas how to find that point (traversing of
whole tree of contained objects probably not good option)
Any comments and pointers are welcome.
--
Paul.
Index: test/library/test.svg
===================================================================
--- test/library/test.svg (revision 0)
+++ test/library/test.svg (revision 0)
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="90"
+ height="60"
+ id="svg2"
+ sodipodi:version="0.32"
+ inkscape:version="0.45.1"
+ version="1.0"
+ sodipodi:docbase="/home/pc/dev/swfmill/test/library"
+ sodipodi:docname="test.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2.6776316"
+ inkscape:cx="133"
+ inkscape:cy="-0.70470402"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ width="90px"
+ height="60px"
+ inkscape:window-width="948"
+ inkscape:window-height="629"
+ inkscape:window-x="218"
+ inkscape:window-y="113" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1">
+ <rect
+
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect2172"
+ width="90.004913"
+ height="59.380829"
+ x="-0.37346438"
+ y="-0.0049132975" />
+ <rect
+
style="opacity:1;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="rect2160"
+ width="19"
+ height="19"
+ x="3.8697791"
+ y="3.2432435" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#rect2160"
+ id="use2164"
+ transform="translate(-9.8812542e-8,22)"
+ width="200"
+ height="200" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#use2164"
+ id="use2166"
+ transform="translate(64,-22)"
+ width="200"
+ height="200" />
+ <use
+ x="0"
+ y="0"
+ xlink:href="#use2166"
+ id="use2168"
+ transform="translate(-15.818182,36.351352)"
+ width="200"
+ height="200"
+ inkscape:transform-center-x="-15.604422"
+ inkscape:transform-center-y="19.957003" />
+ <g
+ id="outer"
+ transform="translate(-10.830466,-9.3366085)">
+ <path
+ sodipodi:type="star"
+
style="opacity:1;fill:#b3b3b3;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ id="inner"
+ sodipodi:sides="3"
+ sodipodi:cx="38.466831"
+ sodipodi:cy="37.916462"
+ sodipodi:r1="5.6019654"
+ sodipodi:r2="3.3332222"
+ sodipodi:arg1="0.64350111"
+ sodipodi:arg2="1.6906987"
+ inkscape:flatsided="false"
+ inkscape:rounded="1.23"
+ inkscape:randomized="0"
+ d="M 42.948404,41.277641 C 39.346556,46.080105 44.028106,41.943812
38.068127,41.225753 C 32.108148,40.507693 35.67331,45.637551
33.315178,40.117028 C 30.957047,34.596504 32.198406,40.718992
35.800254,35.916529 C 39.402101,31.114065 33.176933,31.636657
39.136912,32.354717 C 45.096891,33.072777 39.173982,31.086581
41.532113,36.607105 C 43.890245,42.127628 46.550251,36.475178
42.948404,41.277641 z "
+ transform="translate(-14,-16)" />
+ </g>
+ <use
+ x="0"
+ y="0"
+ xlink:href="#outer"
+ id="use2171"
+ transform="translate(63.66585,-4.6934061e-7)"
+ width="200"
+ height="200" />
+ </g>
+</svg>
Index: test/Main.as
===================================================================
--- test/Main.as (revision 241)
+++ test/Main.as (working copy)
@@ -3,10 +3,10 @@
Stage.scaleMode="noscale";
Stage.align = "TL";
-
debug("set: "+(_root.star.text == "Hello World!" ? "OK" :
"FAILED") );
debug("place assignment: "+(_root.star.text2 == "Hello World!"
? "OK" : "FAILED") );
debug("depth: "+(_root.star.getDepth()+16384)+"==19?" );
+ debug("wrap-element: "+(_root.squares['Layer 1'].outer.inner ?
'no (OK)': 'yes (FAILED)') );
}
static function debug( text:String ) {
Index: test/test.swfml
===================================================================
--- test/test.swfml (revision 241)
+++ test/test.swfml (working copy)
@@ -12,6 +12,7 @@
<clip id="png8" import="library/testpng8.png"/>
<clip id="jpega" import="library/testjpg.jpg"
mask="library/testgradient.png"/>
<clip id="swf" class="org.swfmill.Foo"
import="library/star.swf"/>
+ <clip id="svg" import="library/test.svg"/>
</library>
<font id="vera" import="library/vera.ttf"
glyphs="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ÄÖÜäöüß
.:!&"+=?-"/>
@@ -90,8 +91,16 @@
/>
<place id="texttext" x="100" y="140" depth="22"/>
+ <place id="svg" name="squares" x="220" y="85" depth="24" />
+ <textfield id="textsvg"
+ width="100" height="15"
+ font="vera" size="12"
+ text="SVG"
+ />
+ <place id="textsvg" x="220" y="140" depth="25"/>
+
<textfield id="scriptout"
- width="200" height="70"
+ width="200" height="84"
font="vera" size="10"
text=""
/>
Index: src/xslt/simple-svg.xslt
===================================================================
--- src/xslt/simple-svg.xslt (revision 241)
+++ src/xslt/simple-svg.xslt (working copy)
@@ -11,14 +11,21 @@
<!-- named template for redundant transforms -->
<xsl:template name="transform">
+ <xsl:param name="transform2" />
<transform>
<xsl:choose>
<!-- catch empty transform attributes. -->
- <xsl:when test="not(@transform) or @transform=''">
+ <xsl:when test="(not(@transform) or @transform='') and
(not($transform2) or $transform2='')">
<Transform transX="0" transY="0"/>
</xsl:when>
- <xsl:otherwise>
+ <xsl:when test="not(@transform) or @transform=''">
+ <xsl:copy-of
select="swft:transform($transform2)"/>
+ </xsl:when>
+ <xsl:when test="not($transform2) or $transform2=''">
<xsl:copy-of
select="swft:transform(@transform)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of
select="swft:transform2(@transform, $transform2)"/>
</xsl:otherwise>
</xsl:choose>
</transform>
@@ -70,12 +77,21 @@
included in their definition. -->
<xsl:choose>
<xsl:when test="name()='use'">
- <xsl:call-template name="transform" />
+ <xsl:variable name="destlink">
+ <xsl:value-of select="@xlink:href" />
+ </xsl:variable>
+ <xsl:variable name="desttransform">
+ <xsl:value-of select="//[EMAIL
PROTECTED]($destlink,2)]/@transform" />
+ </xsl:variable>
+ <xsl:call-template name="transform">
+ <xsl:with-param name="transform2" select="$desttransform"
/>
+ </xsl:call-template>
</xsl:when>
+ <xsl:when test="name()='path'">
+ <Transform X="0" Y="0" />
+ </xsl:when>
<xsl:otherwise>
- <transform>
- <Transform transX="0" transY="0"/>
- </transform>
+ <xsl:call-template name="transform" />
</xsl:otherwise>
</xsl:choose>
</PlaceObject2>
@@ -222,11 +238,6 @@
<xsl:param name="name"/>
<xsl:param name="export"/>
- <!-- test if a wrapper is needed for a group transform -->
- <xsl:choose>
- <xsl:when test="not(@transform) or @transform='' or
-transform='translate(0,0)'">
- <!-- no transform, define the group and place the
subparts -->
<DefineSprite objectID="{$id}" frames="1">
<tags>
<xsl:apply-templates mode="placement" />
@@ -234,25 +245,7 @@
<End/>
</tags>
</DefineSprite>
- </xsl:when>
- <xsl:otherwise>
- <!-- define an inner group and wrap it with the group
transform -->
- <xsl:variable name="innerid"><xsl:value-of
-select="swft:next-id()"/></xsl:variable>
- <DefineSprite objectID="{$innerid}" frames="1">
- <tags>
- <xsl:apply-templates mode="placement" />
- <ShowFrame/>
- <End/>
- </tags>
- </DefineSprite>
- <xsl:call-template name="wrapElement">
- <xsl:with-param name="innerid"
select="$innerid" />
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
-
<!-- export -->
<xsl:if test="$export = 'all' or $export = 'groups'">
<xsl:call-template name="exportElement" />
Index: src/swft/swft_path.cpp
===================================================================
--- src/swft/swft_path.cpp (revision 241)
+++ src/swft/swft_path.cpp (working copy)
@@ -176,3 +176,33 @@
transformParser.getMatrix().setXMLProps(doc->xmlRootNode);
valuePush( ctx, xmlXPathNewNodeSet( (xmlNodePtr)doc ) );
}
+
+void swft_transform2( xmlXPathParserContextPtr ctx, int nargs ) {
+ if(nargs != 2) {
+ xmlXPathSetArityError(ctx);
+ return;
+ }
+
+ xmlChar *transform = xmlXPathPopString(ctx);
+ if(xmlXPathCheckError(ctx) || (transform == NULL)) {
+ return;
+ }
+
+ TransformParser transformParser1;
+ transformParser1.parse((char *)transform);
+
+ transform = xmlXPathPopString(ctx);
+ if(xmlXPathCheckError(ctx) || (transform == NULL)) {
+ return;
+ }
+
+ TransformParser transformParser2;
+ transformParser2.parse((char *)transform);
+
+ xmlDocPtr doc;
+ doc = xmlNewDoc( (const xmlChar *)"1.0");
+ doc->xmlRootNode = xmlNewDocNode( doc, NULL, (const xmlChar
*)"Transform", NULL );
+
(transformParser2.getMatrix()*transformParser1.getMatrix()).setXMLProps(doc->xmlRootNode);
+ //~ transformParser2.getMatrix().setXMLProps(doc->xmlRootNode);
+ valuePush( ctx, xmlXPathNewNodeSet( (xmlNodePtr)doc ) );
+}
Index: src/swft/swft.cpp
===================================================================
--- src/swft/swft.cpp (revision 241)
+++ src/swft/swft.cpp (working copy)
@@ -42,6 +42,7 @@
void swft_path( xmlXPathParserContextPtr ctx, int nargs );
void swft_bounds( xmlXPathParserContextPtr ctx, int nargs );
void swft_transform( xmlXPathParserContextPtr ctx, int nargs );
+void swft_transform2( xmlXPathParserContextPtr ctx, int nargs );
static void swft_pushgradient( xsltTransformContextPtr ctx, xmlNodePtr node,
xmlNodePtr inst, xsltElemPreCompPtr com ) {
swft_ctx *c = (swft_ctx*)xsltGetExtData( ctx, SWFT_NAMESPACE );
@@ -226,6 +227,7 @@
xsltRegisterExtFunction( ctx, (const xmlChar *) "path", SWFT_NAMESPACE,
swft_path);
// xsltRegisterExtFunction( ctx, (const xmlChar *) "bounds",
SWFT_NAMESPACE, swft_bounds);
xsltRegisterExtFunction( ctx, (const xmlChar *) "transform",
SWFT_NAMESPACE, swft_transform);
+ xsltRegisterExtFunction( ctx, (const xmlChar *) "transform2",
SWFT_NAMESPACE, swft_transform2);
xsltRegisterExtElement( ctx, (const xmlChar *) "push-style",
SWFT_NAMESPACE, swft_pushstyle);
xsltRegisterExtElement( ctx, (const xmlChar *) "pop-style",
SWFT_NAMESPACE, swft_popstyle);
xsltRegisterExtElement( ctx, (const xmlChar *) "push-gradient",
SWFT_NAMESPACE, swft_pushgradient);
_______________________________________________
swfmill mailing list
[email protected]
http://osflash.org/mailman/listinfo/swfmill_osflash.org