reanimate / reanimate-svg

BSD 3-Clause "New" or "Revised" License
4 stars 8 forks source link

Make number of decimal places for float serialisation configurable #28

Open georgefst opened 3 years ago

georgefst commented 3 years ago

(This is a mess, but I figured I'd see what you think before I go any further...)

Currently serialisation is hardcoded to always use six decimal places, which is often excessive. For my use case, it would be really great to get this down.

Unfortunately this change is very pervasive. And this is probably only about half of it (see hardcodedPrecision). I feel I ought to take a step back and try to understand the library architecture better to see if there may be a more elegant solution. Perhaps some refactoring is in order first - for example things like ParseableAttribute and parseIn have clearly outgrown their original purpose (not a criticism of you - I see that code predates the fork).

lemmih commented 3 years ago

I like it.

georgefst commented 3 years ago

Great, I'll finish it off then.

Do you reckon it's worth using a record:

data SerializationOpts = SerializationOpts
    { floatPrecision :: Int
    }

?

Would be more descriptive than a plain Int argument, and make it easier to add other configuration. But then I don't know if there are any other options one would ever want.

lemmih commented 3 years ago

Maybe prettyPrint :: Bool and indentation :: Int would be possible future options. In any case, I like the idea of using a record.