r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[SVG Renderer] SVG rendering in Draw AGG

shadwolf
24-Jun-2005
[25x6]
I'm working hard on the translation of the linearGradient informations 
from SVG files   to AGG
and I have some asks
how to apply a matrix tranformation only over a grendient definition 
?
I think I handle web the creation of the rebol list of linear gradient
if you wants to write the "in" AGG/draw code that is based on my 
rebol linear gradient list there is the code and a sample file from 
InkScape
http://shadwolf.free.fr/svg-demo02.zip
Ashley
25-Jun-2005
[31]
Noticed you found some conversion numbers (where from?? ;) ), so 
here's a simple func to make use of them:

to-unit: func [s [string!]] [
	switch/default skip tail s -2 [
		"pt"	[1.25 * to decimal! copy/part s -2 + length? s]
		"pc"	[15 * to decimal! copy/part s -2 + length? s]
		"mm"	[3.543307 * to decimal! copy/part s -2 + length? s]
		"cm"	[35.43307 * to decimal! copy/part s -2 + length? s]
		"in"	[90 * to decimal! copy/part s -2 + length? s]
		"px"	[to decimal! copy/part s -2 + length? s]
	][
		to decimal! s
	]
]
shadwolf
26-Jun-2005
[32x11]
Ashley yes  !!! You noticed right I found them deep hided in the 
SVG format documentation on W3C dedicated pages to SVG format ....
I copy past the conversion units into the script becaus I know that 
could be usefull but AS I was working on lineargradient and as it's 
a complicated part of the format SVG I had no time to make a conversion 
algorithm I glad to see that you make it  :)
the page where I found the conversion rules
http://www.w3.org/TR/SVG/coords.html
see chapter 7.10
I read most of the documentation but then make the link to AGG data 
structure is rather difficult
linearGradient for example are splitted the first one contain the 
coordonates systeme and tranfromation informations  the second one 
countains the colors involved and their order in the gradient
so you avac primitive(fill:url) ->LinearGRadient (coords) -> LinearGradient 
(colors order)
where do I plug the to-unit function ?
in svg-size
??
Ashley
26-Jun-2005
[43]
Yes, to-unit is called from svg-size; and also from "path d", stroke-width, 
fill-width, etc ... probably anywhere in SVG where we "expect" an 
integer or decimal! ;)
shadwolf
29-Jun-2005
[44]
okay good stuf in it Vincent and I are planning to use the xml-to-object.r 
script from Brian Wisti to enbetter and make a more sophisticate 
support for our actual work upon SVG parsing translation and rendering 
into a VID  window
BrianW
29-Jun-2005
[45]
shadwolf, I'm not the author - just a guy who made it available in 
the Rebol library :-)
shadwolf
29-Jun-2005
[46x3]
it says author hahah ;)
opkay so we are planning on the opportinity to use a REBOL tree object! 
structure to represente SVG datas :)
this in the goal to improve drastically the performance and be more 
performant  on some key issues like recursivity etc...
shadwolf
30-Jun-2005
[49x16]
I make a base code but now I have to find a good code to exploit 
the relevent datas from the object tree
this means to interogate the content of the objet a gived level
then construc path to get data then translate this data to a draw 
equivalent exploitable datas
and fill the draw block with this data
my point is to make a recursif capapble code
for example my object is set into xml global variable
I I want to interrogate the first shape description on the top level 
( out of group blocks) I have to build a path like that xml/svg/path/1/d
or maybe build the path xml/svg/path then attribute to a temporary 
var the foreach ob  xml/svg/path [ ob processing ]
so to build the path we start xml/svg "/ " g or path  if g we seek 
3 thing transform field and path field or sub g field
I give you the code maybe this will be more clear
shadwolf.free.fr/svg-demo-shad04.r
oups sorry
wrong adress
http://shadwolf.free.fr/svg-demo-shad03.r
in this file we have xml-to-object function load-svg function (mostly 
empty there is where to put the data conversion and draw block construction) 
and the widget that start the program
and the windows where the draw block is shown
shadwolf
1-Jul-2005
[65x2]
I solve this issue regarding object retriving information I will 
enhance this pont to make it recursif retriever
at this point code have not drastically change ... like 40% is the 
same code
shadwolf
2-Jul-2005
[67x8]
***************
I'm still working full time on the S VG renderer. I'm close to be 
at the same level than the previous code but as I'm working with 
objects the code seems to be more fast ...
the recursivity treatement for g block are also easier to do
I still not soleve my matrix problems so until now I don't implement 
it into  the actual code
I don't know how to treat linearGradient too
hum xpdf.svg file shows me a problem with the use of xml-to-object 
 ... if you have serveral g block at the same level all g block are 
compacted into the same reference
so in Rebol tree object the g block can be a bloc of sub object or 
an object  ;)
***********