Project

General

Profile

SVG drawing : modifying the shape-rendering attribute

Added by Bertrand Chagny almost 4 years ago

Hello,

Hope you are fine.

The code below generates the following result :

Code :

Wt::WPainter painter(paintDevice);

painter.drawEllipse(20, 20, 300, 300);

Result :


<g style="fill:none;shape-rendering:optimizeSpeed;stroke:rgb(0,0,0);

stroke-linecap:square;stroke-linejoin:bevel;
font-size: 10.0pt;font-family: sans-serif;">




Question :

How to modify the shape-rendering attribute from default "optimizeSpeed"

to "geometricPrecision" or "crispEdges"

For example, is it possible to have access to the SVG code generator ?

Thank you.

Best regards,

Bertrand


Replies (2)

RE: SVG drawing : modifying the shape-rendering attribute - Added by Roel Standaert almost 4 years ago

I don't think you can. WPainter provides a common interface, abstracting away the details of the implementation. If there's a particular thing that one specific implementation can do, it doesn't provide access to it. That's the downside of using a generic abstraction.

I think maybe what you want to do, though, is just turn on anti-aliasing? You can do that with WPainter::setRenderHint(RenderHint::Antialiasing). The optimizeSpeed is not included when anti-aliasing is enabled.

RE: SVG drawing : modifying the shape-rendering attribute - Added by Bertrand Chagny almost 4 years ago

Thank you Roel.

Another question.

Code :

auto hint = Wt::RenderHint::Antialiasing;

painter.setRenderHint(hint, true);

Result :

shape-rendering:optimizeSpeed has been suppressed so it works.

default value of SVG rendering is auto.

Question :

If it's necessary to be more precised, is it possible

to connect the root of SVG or better an individual SVG element (class identification ?) to a CSS file

and then precisely enter the attribute of the rendering (auto | optimizeSpeed | crispEdges | geometricPrecision)

or an other property by the way ?

  • The CSS file have to take the power over the native SVG attributes.

Best regards,

Bertrand

    (1-2/2)