swift-graphics icon indicating copy to clipboard operation
swift-graphics copied to clipboard

Simplify module and type naming scheme for library consumers

Open fwcd opened this issue 1 year ago • 0 comments

For the next major version, we may consider a new naming scheme that is simpler for downstream consumers, e.g.

  • Modules
    • Graphics -> GraphicsBase
    • PlatformGraphics -> Graphics (re-exporting everything needed, including Utils)
  • Types
    • Image (+ BufferedImage) -> ImageProtocol
    • PlatformImage -> Image

Ideally, we would want parity between the different backends and polyfill as needed, so that they can be used interchangeably. It should not matter whether a CoreGraphicsImage or a CairoImage is used and portable code should not have to deal with this distinction, i.e. Image should always refer to the "one true" image type.

Perhaps introducing a wrapper layer (e.g. have Image and GraphicsContext be shared types that internally uses a platform-specific backends) would be worth looking into, to avoid accidentally leaking platform-specific implementation details if the platform-specific types implement something not declared in the protocol. This might require renaming the protocol for clarity (e.g. BackingImage, ImageBackend or similar).

fwcd avatar Jul 03 '24 20:07 fwcd