doodle icon indicating copy to clipboard operation
doodle copied to clipboard

BufferedImageConverter cleanup

Open noelwelsh opened this issue 11 months ago • 3 comments

Consider the following:

  • BufferedImageConverter is quite a mouthful. Can we shorten the name? Perhaps we use the term "Writer" for anything we can convert a Picture into, and rename the current Writer to FileWriter (and Base64 becomes Base64Writer)?

  • Can we make the Frame optional? Can we get it from a DefaultRenderer? Maybe the idea of a default frame should be extracted into it's own effect (it's not really an effect, but it is associated with effects.)

  • Do we need to return the value of type A when we convert to a BufferedImage? Most of the time the user will throw it away. (Same issue exists for Base64). Maybe the convention should be you get the A if you convert to an IO but we throw it away in you immediately run that IO. This would match what happens in draw.

  • Maybe what we need is a generic conversion effect type class. Something like

    trait To[+Alg <: Algebra, Frame, Out] {
      def to[A](description: Frame, picture: Picture[Alg, A]): IO[(A, Out)]
    }
    
  • Java2dBufferedImageWriter in Java2dWriter.scala should be renamed and moved to its own file.

  • Add tests.

  • Add documentation.

This issue could probably be usefully turned into a project. Each bullet could be it's own issue.

noelwelsh avatar Mar 12 '24 15:03 noelwelsh