Skip to content

Commit

Permalink
fixing merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
FayCarsons committed Feb 16, 2024
1 parent 625fdab commit 14d1f2d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 59 deletions.
1 change: 0 additions & 1 deletion examples/complex.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ let () =
(fun (x, y) -> circle ~c:(point (x * radius) (y * radius)) radius)
coords)
in
let complex_shape = circle 50 :: complex_shape in
(* translating that complex shape by radius / 2 *)
let complex_transformed = translate half_radius half_radius complex_shape in
show [ complex_shape; complex_transformed ];
Expand Down
53 changes: 5 additions & 48 deletions lib/context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,73 +21,30 @@ let () =
match e with Context err -> Some ("Context: " ^ err) | _ -> None)

let fail () = raise (Context "not initialized")
<<<<<<< HEAD

<<<<<<< HEAD
let init_context line_width (w, h) axes =
(* Fail if context has already been instantiated *)
if Option.is_some !context then
raise (Context "Cannot initialize context twice");

let surface = Cairo.Image.create Cairo.Image.ARGB32 ~w ~h in
let ctx = Cairo.create surface in
Cairo.set_line_width ctx line_width;
Cairo.translate ctx (w / 2 |> float_of_int) (h / 2 |> float_of_int);
context := Some { ctx; surface; size = (w, h); axes }

let resolution () = match !context with Some ctx -> ctx.size | None -> fail ()
let tmap3 f (a, b, c) = (f a, f b, f c)
let tmap4 f (a, b, c, d) = (f a, f b, f c, f d)
let scale_color_channel x = x /. 256.
let scale_color_channel = float_of_int >> scale_color_channel

let tmap3 f (a, b, c) = (f a, f b, f c)
let tmap4 f (a, b, c, d) = (f a, f b, f c, f d)
let scale_channel n = float_of_int n /. 255.
let (>>) f g x = g (f x)
let scale_channel n = n /. 255.
let scale_color_channel = float_of_int >> scale_channel

let set_color color =
match !context with
| Some ctx ->
let r, g, b = tmap3 scale_color_channel color in
<<<<<<< HEAD
Cairo.set_source_rgb ctx.ctx r g b
=======
Cairo.set_source_rgba ctx.ctx r g b 1.
>>>>>>> 9b47680 (dune fmt)
| None -> fail ()

(* sets background color *)
let background color =
match !context with
| Some { ctx; _ } ->
| Some { ctx; _ } ->
let r, g, b, alpha = tmap4 scale_color_channel color in
Cairo.set_source_rgb ctx r g b;
Cairo.paint ctx ~alpha;
Cairo.fill ctx
=======
=======
>>>>>>> 40ac680 (added stroke and fill fields, 'with' fns to add them to shapes, and map fns for applying fns to those fields)
let resolution () = match !context with Some ctx -> ctx.size | None -> fail ()
let tmap3 f (a, b, c) = (f a, f b, f c)
let tmap4 f (a, b, c, d) = (f a, f b, f c, f d)
let scale_channel n = float_of_int n /. 255.

(* sets background color *)
let background color =
match !context with
| Some ctx ->
let r, g, b, a = tmap4 scale_channel color in
Cairo.set_source_rgba ctx.ctx r g b a;
Cairo.paint ctx.ctx
>>>>>>> b1a2518 (merging w/ main branch)
| None -> fail ()

let set_color color =
match !context with
| Some ctx ->
let r, g, b = tmap3 scale_channel color in
Cairo.set_source_rgba ctx.ctx r g b 1.
| None -> fail ()
| None -> fail ()

(** Sets the width of lines for both stroke of shapes and line primitives.
Can be any positive integer, with larger numbers producing thicker lines.
Expand Down
11 changes: 1 addition & 10 deletions lib/joy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ type shape = Shape.shape
type shapes = Shape.shapes
type transformation = Transform.transformation

type color = Color.color
<<<<<<< HEAD
<<<<<<< HEAD
=======
=======
(** Three-tuple representing a 24-bit RGB color *)
>>>>>>> 40ac680 (added stroke and fill fields, 'with' fns to add them to shapes, and map fns for applying fns to those fields)
type color = Color.color

let black = Color.black
let white = Color.white
Expand All @@ -21,11 +16,7 @@ let blue = Color.blue
let yellow = Color.yellow
let transparent = Color.transparent
let opaque = Color.opaque
<<<<<<< HEAD
>>>>>>> b1a2518 (merging w/ main branch)

=======
>>>>>>> 40ac680 (added stroke and fill fields, 'with' fns to add them to shapes, and map fns for applying fns to those fields)
let point = Shape.point
let circle = Shape.circle
let rectangle = Shape.rectangle
Expand Down

0 comments on commit 14d1f2d

Please sign in to comment.