-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
We should be able to support multiple types of context.
So far, the API is restricted to the Cairo backend and assumes that it will be the only one.
I suggest that we:
- separate the backend logic and the rendering API by putting in another layer of abstraction between then
- make
showadd to global context - whose actual behaviour will be different depending on the actual backend - let each backend define its own context type
- have each backend loosely conform to an interface
e.g. the context type that is as of now a record that immediately stores the cairo context and surface, will change to a sum type:
type context =
CairoContext of Backends.Cairo.context
| SVGContext of Backends.SVG.contextThe global context will be of context type, then we change the rendering logic to do a match-case on the context before we pass it to the actual backend.
The interface for each backend should be something like:
type context = anything_at_all
val show: (?ctx: context) -> Joy.shape list -> unit (* ctx defaults to the global context *)Metadata
Metadata
Assignees
Labels
No labels