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

Steeve
12-Oct-2009
[169x7]
in fact, i think i could simulate that behavior.
By 
1/ rendering the radial gradient in the initial circle.

2/ create an image with that circle and clip it with the shape of 
the second one.
3/ Use that image as a pattern for the fill-pen attribut


But it would be a mess of  computing time and of memory, because 
in the draw block we would have images used as pattern instead of 
computed gradients
i think that feature (2 different centers) is not used that much.

In the lizard.svg example i gave, they don't use it, the 2 centers 
are always equal.
By default Inkscape don't use that feature when you design a radial 
vector.
Ok, i finished with Radial gradients (less the impossible feature: 
2 different centers)


SVG use a matrix transformation to convert a circular radial gradient 
into an ellipsoid.

And you know what ? 

We can do the same thing with grad-pen which provides 2 scalling 
factors (grad-scale-x and grad-scale-y)

So in that case it's easier than for linear-gradient.
1/ take the focal point of the Radial gradient (fx, fy)

2/ Create 2 vectors starting from this point: 1 vertical and 1 horizontal, 
using the radius as their length.
3/ apply the matrix transformation on them.

5/ get  the component X of the transformed horizontal vector, and 
the component Y of the transformed vetical vector
6/ grad-scale-x:  x / r
7/ grad-scale-y: y / r

That's all folks
Gezz... i forget the rotation of the ellipsoid...
more work...
Ok, done
Guys, i updated the lizard.svg rendered with Rebol http://sites.google.com/site/rebolish/test-1/lizard-rebol.png

To compare with http://sites.google.com/site/rebolish/test-1/lizard.svg.


I'm glad to announce that i see absolutly no differences inside Google 
chrome.

All the grandients (linear and radial) are perfectly rendered by 
Rebol.
Graham
12-Oct-2009
[176]
Nice ...
ICarii
12-Oct-2009
[177]
great work steeve! :)
Steeve
12-Oct-2009
[178]
Basically, you can load the draw block generated for the lizard here.
it's handed by the variable PANE.
http://sites.google.com/site/rebolish/test-1/lizard.r
Maxim
12-Oct-2009
[179]
GREAT WORK Steeve  :-)
Steeve
12-Oct-2009
[180]
Added a litte animation.
The bumping lizard !!!!
http://sites.google.com/site/rebolish/test-1/lizard.r
Maxim
12-Oct-2009
[181]
the difference in your render and SVG render is mainly the anti-aliasing, 
which is crisper in the svg renderer.... probably has a better algorythm 
setup than the one use by R3... this is probably manageable within 
AGG, but AFAIK there is no control for it within R3.
Steeve
12-Oct-2009
[182]
Not the problem of the antialiasing, I just think i made a false 
translation of the command used in the shapes.

They use a smouthing curve, me not i guess. I have to verify that.
But Rebol can draw smoothing curves too, no problemo.
Maxim
12-Oct-2009
[183x3]
if you draw the outlines twice, they should be a bit crisper... is 
that what you mean?
there seems to be two spots missing on the left left... very faint, 
but missing or not visible at least.
also the anti-aliasing was a result of my browser which rescaled 
the image minus 5 pixels... so it has nothing to do with your render.
Steeve
12-Oct-2009
[186x2]
ok
i only checked with google chrome, it was very similar
BrianH
12-Oct-2009
[188]
Sorry, got tired of the shouted group name/description :)
Steeve
12-Oct-2009
[189]
i don't know which renderer chrome uses
BrianH
12-Oct-2009
[190]
It's a good one. It looks identical to yours, though that may be 
server side in your example link.
Maxim
12-Oct-2009
[191]
we should also note that this is in R3  :-)  not everyone realizes 
this IMO.
BrianH
12-Oct-2009
[192]
Seriously? Cool :)
Steeve
12-Oct-2009
[193]
yes it's R3
BrianH
12-Oct-2009
[194]
Draw should be the same, afaik, which isn't that far. Have the parse 
improvements helped?
Steeve
12-Oct-2009
[195x2]
not so much ;-)
but the new grad-pen command of draw is awesome
BrianH
12-Oct-2009
[197]
Cool :)
Maxim
12-Oct-2009
[198]
that was seriously missing in R2 draw.. happy its in R3  :-)
Steeve
12-Oct-2009
[199]
By the way the DRAW function can't render that, it's crashing.
BrianH
12-Oct-2009
[200]
The DRAW function is still there? I really need to pay more attention 
to the graphics stuff.
Steeve
12-Oct-2009
[201]
i wonder why it's crashing. I thougth gobs was using the DRAW function 
in background, but seems not...
BrianH
12-Oct-2009
[202]
They probably call the same code internally, but the draw function 
may be crashing in a non-shared portion of its code.
Maxim
12-Oct-2009
[203]
to image works though?
Steeve
12-Oct-2009
[204]
sometimes ;-)
Maxim
12-Oct-2009
[205]
hehe
BrianH
12-Oct-2009
[206x2]
I'd put a :( on that.
I know we haven't been focussing on graphics or GUI bugs lately, 
but you should at least write the graphics bugs down somewhere.
Steeve
12-Oct-2009
[208]
You know it's a problem when you can't replicate the bug and focus 
clearly what the problem is.
Carl put a spell on me because of that (in his last note)
BrianH
12-Oct-2009
[209]
Heisenbugs are the worst :(
Steeve
12-Oct-2009
[210x2]
There is another problem with draw in Gobs.

When there is an error in the commands, nothing is showed but you 
don't know where it comes from.
blank page, that''s what you got
Henrik
12-Oct-2009
[212]
it usually renders up until the error occurs
Steeve
12-Oct-2009
[213]
that's not what i got.
i got a blank screen when an error occurs.
Maxim
12-Oct-2009
[214]
it depends on the error... its the same in R2.
Steeve
12-Oct-2009
[215]
yep it depends... Brian"s heisenbugs are everywhere in draw
Henrik
12-Oct-2009
[216]
well, it should do the same in R3. at least it did in earlier builds, 
but does PARSE have anything to do with that?
Steeve
12-Oct-2009
[217]
why parse ?
Maxim
12-Oct-2009
[218]
doesn't DRAW use the other fast dialect making parser? don't remember 
its name.