ObjectProfile / Roassal3Exporters

PDF Exporter for Roassal3
MIT License
8 stars 3 forks source link

surround svg content with a <g> ... </g> tag #27

Closed jmari closed 2 years ago

jmari commented 2 years ago

in RGSVGExporter, is it possible to add a tag, it will help me to apply style to all the inner elements ( I want to zoom and dragg the svg)


visitCanvas: aRSCanvas 
    | extent |
    pathTransform := AthensAffineTransform new.
    extent := aRSCanvas extent.
    pathTransform
        translateBy: (extent / 2) asFloatPoint;
        scaleBy: aRSCanvas camera scale asFloat;
        translateBy: aRSCanvas camera position negated asFloatPoint.
    self 
        write: '<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="'.
    self stream
        << extent x asSVGString;
        << 'pt" height="';
        << extent y asSVGString;
        << 'pt" viewBox="0 0 ';
        << extent x asSVGString;
        << ' ';
        << extent y asSVGString;
        << '" style="background-color:#';
        << canvas color asHexString.
    self write: '" version="1.1">**<g>**
'.

    self writeLabelDefinitionsIfNecessary: aRSCanvas.
    aRSCanvas shapes do: [ :shape | shape accept: self ].
    self write: '**</g>**</svg>'. ```
akevalion commented 2 years ago

I think yes, it is possible, but also you can create a subclass of RSSVGExporter and override method visitCanvas: And use your new exporter for your custom project. If you think that you change should be on Roassal3 you can do a pull request. Thank you very much for your feedback

jmari commented 2 years ago

You are right! Thank you for your suggestion