RE: Using gpp preprocessor to create more easily svg code
<[email protected]> 05 Feb 2014 00:02:15 -0800
| Newsgroups | gmane.text.xml.svg.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello Cameron,
Thank you for your feeback.
GPP have some limits, it can't define a new macro with a macro argument, and accept only 9 arguments.
I never find a macro processor to do more, even CPP.
But macros can be nested, to create more complex macros.
I use it for animations, filters, and gradients too.
I give some samples below.
I learn many about svg with this method, because some websites never give all info about some procedures.
So i discover that <animateTransform> dont work outside the tagged element to animate, even with the xlink:href.
<use> dont accept all <animate> tags.
But <animate> work with all xlink:href.
So, my macros work with a little model, and can make animations with a simili time line and events depending of other events.
In the exemple below, the _RHD and _RAD macros call _Rd1 and _Rd2 "sub" macros. So nesting is easy and natural.
#define _Rd1 #eval #1+#1
#define _Rd2 #eval 0-#1-#1
#define _RHD <path id=#1 d="M #2,#3 a #4 #4 0 0 0 _Rd1(#4),0 a #4 #4 0 0 0 _Rd2(#4),0" #5/>
#define _RAD <path id=#1 d="M #2,#3 a #4 #4 0 0 1 _Rd1(#4),0 a -#4 #4 0 0 1 _Rd2(#4),0" #5/>
To comment, _RHD and _RAD are macros to define circular paths used for <textpath> or <mpath>. _RHD permit rotating left to right, and _RAD rotating rigth to left.
In the source, a macro call can be an argument in another macro call :
_STY(_st2, _FSS(black,1,none,0) _TSS("Comic sans Ms",1.5cm) _invi;)
The above style definition macro _STY use 3 macro calls :
_FSS for fill, opacity and stroke, _TSS for font-family and size
About a simili timeline for animation, look at the sample below :
_INV(gr01,0.1s)
_VIS(gr02,0.1s)
_INV(gr02,0.2s)
_VIS(gr03,0.2s)
_INV(gr03,0.3s)
_VIS(gr04,0.3s)
_INV(gr04,0.4s)
gr01 to gr04 are defined paths. _INV macro give the path invisible
_VIS macro give the path visible. This 2 macros use <attribute> tag with "begin=" as argument (0.1s to 0.4s).
I will post soon the svg.inc file, and some samples i write.
Greetings !
Yves