AnonMiraj / fig

FIG (Fortran Intuitive Graphics)
MIT License
27 stars 2 forks source link

initial svg draft #12

Closed AnonMiraj closed 4 months ago

AnonMiraj commented 4 months ago

The first steps of SVG support: I have only added the rect and circle primitives for now. I still need to modify the bitmap canvas and its related primitives.

CC @everythingfunctional, @perazz.

johandweber commented 4 months ago

Maybe there should be an abtract type for the vector dtawing operations defining the interface and the SVG implementation be derived from that abstract type. So polymorphism could be used, allowing a more stightforward integration of new possible data types (e.g., Postscript, some type of abstract canvas..)

johandweber commented 4 months ago

This does not neccessarily have to be implemented in the next merge

AnonMiraj commented 4 months ago

Maybe there should be an abtract type for the vector dtawing operations defining the interface and the SVG implementation be derived from that abstract type. So polymorphism could be used, allowing a more stightforward integration of new possible data types (e.g., Postscript, some type of abstract canvas..)

Fair enough, It will be easier to do it now rather than later.

AnonMiraj commented 4 months ago

I've been testing different ways to implement canvas over the past couple of days, and so far, this is the best solution I've come up with. If you have any ideas or feedback, please let me know!

johandweber commented 4 months ago

Hallo,

while I have not tested it, I think that your approach with a list of shapes really is really flexible and a good idea for a modular design.

AnonMiraj commented 4 months ago

Hello,

I want to make it possible to write to both SVG and bitmap formats using the same class. That's why I made them use the same Shapes class in the first place. However, I'm not really sure how to implement this.

Should I create a third general class that inherits from the Bitmap class and writes to SVG using some subroutines? Or should I create a class that directly inherits from the base Canvas and uses objects from both the Bitmap and SVG classes to facilitate writing to the desired file? There's also the option to keep the different canvases separate but allow for easy movement of the shapes array between different objects.

johandweber commented 4 months ago

Hello,

I want to make it possible to write to both SVG and bitmap formats using the same class. That's why I made them use the same Shapes class in the first place. However, I'm not really sure how to implement this.

Should I create a third general class that inherits from the Bitmap class and writes to SVG using some subroutines? Or should I create a class that directly inherits from the base Canvas and uses objects from both the Bitmap and SVG classes to facilitate writing to the desired file? There's also the option to keep the different canvases separate but allow for easy movement of the shapes array between different objects.

I do not think thar making a vector class a child of a bitmap class makes a lot of sense. Otherwise I am not sure.

AnonMiraj commented 4 months ago

I do not think thar making a vector class a child of a bitmap class makes a lot of sense. Otherwise I am not sure.

I guess I had a weird design in mind. I didn't want to just create a bitmap object and then trash it right after writing to a file.

I think I am going to migrate as many primitives as possible to both SVG and bitmap for now.

AnonMiraj commented 4 months ago

This PR LGTM as an initial draft. Let's open new issues/PRs with the further developments

Sure, I'm going to edit some of the tests to use the new design, and then I'm going to merge this PR.