Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and rename: backends, cairo, contexts #129

Merged
merged 12 commits into from
Mar 12, 2024
Merged

Refactor and rename: backends, cairo, contexts #129

merged 12 commits into from
Mar 12, 2024

Conversation

nikochiko
Copy link
Collaborator

@nikochiko nikochiko commented Mar 12, 2024

Refactor:

  • Color API
    • color fn: color : ?a:float -> int -> int -> int -> unit (rgba color making function)
    • rgb fn: rgb : int -> int -> int -> unit (rgb - opaque color making function. renamed and changed signature from opaque) - Color API: rename opaque #117
    • color type is now int * int * int * float (from int * int * int).
    • stroke defaults to Color.black for all shapes, fill defaults to Color.transparent
  • Cairo backend
    • Moved from context.ml / render.ml to backend_cairo.ml and mli.
    • Stroke and fill are required for draw_{anything} functions
    • Expanded the argument types for draw_{anything} functions (was running into a cycle dependency error without - maybe that was due to something else and it isn't needed now).
    • Rename background -> set_background
    • Make set_background and set_line_width take ctx as an arg : at the backend ctx level
    • When there is a default context (context.ml), this is not needed and the global default is used
  • Context API
  • Shapes
    • Renamed center to origin in shape.ml code
    • Remove no_fill and no_stroke (it is the same as with_stroke Color.transparent and with_fill Color.transparent)
    • Stroke and fill are non-optional on shapes
  • Examples
    • Rename line to parallel_lines and create a new simpler line example

@nikochiko
Copy link
Collaborator Author

The backend structure can change further in another PR (with #98 under review).

This can be done once we figure out a good subset of functions to take from modules such that our types can work with theirs.

@Sudha247 Sudha247 merged commit 34fede4 into main Mar 12, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants