From e3c0d63c143ae639376bafb02b8fecc5a9e398be Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Mon, 9 Oct 2023 12:26:48 +0300 Subject: [PATCH 01/23] regular polygons --- examples/dune | 45 +++++++++++++++----------------------------- examples/hexagon.ml | 44 +++++++++++++++++++++++++++++++++++++++++++ examples/pentagon.ml | 43 ++++++++++++++++++++++++++++++++++++++++++ examples/square.ml | 42 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+), 30 deletions(-) create mode 100644 examples/hexagon.ml create mode 100644 examples/pentagon.ml create mode 100644 examples/square.ml diff --git a/examples/dune b/examples/dune index 7b9088e..0a7f3cf 100644 --- a/examples/dune +++ b/examples/dune @@ -44,36 +44,21 @@ (libraries graphics)) (executable - (name axes) - (modules axes) - (libraries joy)) - -(executable - (name translate_circle) - (modules translate_circle) - (libraries joy)) - -(executable - (name translate_rectangle) - (modules translate_rectangle) - (libraries joy)) + (name square) + (modules square) + (libraries graphics)) -(executable - (name translate_ellipse) - (modules translate_ellipse) - (libraries joy)) + (executable + (name pentagon) + (modules pentagon) + (libraries graphics)) -(executable - (name circle_row_joy) - (modules circle_row_joy) - (libraries joy)) + (executable + (name hexagon) + (modules hexagon) + (libraries graphics)) -(executable - (name rotate) - (modules rotate) - (libraries joy))) - -(executable - (name line) - (modules line) - (libraries joy) + (executable + (name axes) + (modules axes) + (libraries joy)) diff --git a/examples/hexagon.ml b/examples/hexagon.ml new file mode 100644 index 0000000..3972101 --- /dev/null +++ b/examples/hexagon.ml @@ -0,0 +1,44 @@ +open Graphics + +type point = { x : int; y : int } +type hexagon = { c : point; side_length : int} + +type shape = Hexagon of hexagon + +let canvas_size = (500, 500) +let canvas_mid = { x = fst canvas_size / 2; y = snd canvas_size / 2 } + +let render_shape s = + match s with + | Hexagon hex -> + let side = hex.side_length in + let x = hex.c.x in + let y = hex.c.y in + let points = + [|(x + (side/2), y + side); + (x - (side/2), y + side); + (x - (side), y); + (x - (side/2), y - side); + (x + (side/2), y - side); + (x + side, y);|] + in + draw_poly points + + +let hexagon ?x ?y side_length = + let center = match (x, y) with + | Some x, Some y -> { x; y } + | _ -> canvas_mid in + Hexagon { c = center; side_length } + +let show shapes = List.iter render_shape shapes + +let () = + open_graph (" " ^ string_of_int (fst canvas_size) ^ "x" ^ string_of_int (snd canvas_size)); + set_color black; + + let hex = hexagon 100 in + show [hex]; + + ignore (read_line ()); + close_graph () diff --git a/examples/pentagon.ml b/examples/pentagon.ml new file mode 100644 index 0000000..f250a6a --- /dev/null +++ b/examples/pentagon.ml @@ -0,0 +1,43 @@ +open Graphics + +type point = { x : int; y : int } +type pentagon = { c : point; side_length : int} + +type shape = Pentagon of pentagon + +let canvas_size = (500, 500) +let canvas_mid = { x = fst canvas_size / 2; y = snd canvas_size / 2 } + +let render_shape s = + match s with + | Pentagon pent -> + let side = pent.side_length in + let x = pent.c.x in + let y = pent.c.y in + let points = + [|(x, y + side); + (x - side, y); + (x - (side/2), y - side); + (x +(side/2), y - side); + (x + side, y);|] + in + draw_poly points + + +let pentagon ?x ?y side_length = + let center = match (x, y) with + | Some x, Some y -> { x; y } + | _ -> canvas_mid in + Pentagon { c = center; side_length } + +let show shapes = List.iter render_shape shapes + +let () = + open_graph (" " ^ string_of_int (fst canvas_size) ^ "x" ^ string_of_int (snd canvas_size)); + set_color black; + + let pent = pentagon 100 in + show [pent]; + + ignore (read_line ()); + close_graph () diff --git a/examples/square.ml b/examples/square.ml new file mode 100644 index 0000000..0a0b250 --- /dev/null +++ b/examples/square.ml @@ -0,0 +1,42 @@ +open Graphics + +type point = { x : int; y : int } +type square = { c : point; side_length : int} + +type shape = Square of square + +let canvas_size = (500, 500) +let canvas_mid = { x = fst canvas_size / 2; y = snd canvas_size / 2 } + +let render_shape s = + match s with + | Square sqr -> + let side = sqr.side_length in + let x = sqr.c.x in + let y = sqr.c.y in + let points = + [| (x - side, y - side); + (x + side, y - side); + (x + side, y + side); + (x - side, y + side) |] + in + draw_poly points + + +let square ?x ?y side_length = + let center = match (x, y) with + | Some x, Some y -> { x; y } + | _ -> canvas_mid in + Square { c = center; side_length } + +let show shapes = List.iter render_shape shapes + +let () = + open_graph (" " ^ string_of_int (fst canvas_size) ^ "x" ^ string_of_int (snd canvas_size)); + set_color black; + + let sqr = square 100 in + show [sqr]; + + ignore (read_line ()); + close_graph () From e0dea2a421bf4f4c89d8b2b687304d1a865cfdc6 Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Mon, 9 Oct 2023 12:37:32 +0300 Subject: [PATCH 02/23] The square polygon --- examples/pentagon.ml | 2 +- examples/square.ml | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/pentagon.ml b/examples/pentagon.ml index f250a6a..8cb865f 100644 --- a/examples/pentagon.ml +++ b/examples/pentagon.ml @@ -18,7 +18,7 @@ let render_shape s = [|(x, y + side); (x - side, y); (x - (side/2), y - side); - (x +(side/2), y - side); + (x + (side/2), y - side); (x + side, y);|] in draw_poly points diff --git a/examples/square.ml b/examples/square.ml index 0a0b250..596e9c4 100644 --- a/examples/square.ml +++ b/examples/square.ml @@ -15,10 +15,12 @@ let render_shape s = let x = sqr.c.x in let y = sqr.c.y in let points = - [| (x - side, y - side); - (x + side, y - side); - (x + side, y + side); - (x - side, y + side) |] + [| + (x - side, y - side); + (x + side, y - side); + (x + side, y + side); + (x - side, y + side) + |] in draw_poly points From 1c2044a42d0cf2b9358df4da7dcb5a5bd9d3d998 Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Mon, 9 Oct 2023 12:38:38 +0300 Subject: [PATCH 03/23] The pentagon polygon --- examples/pentagon.ml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/pentagon.ml b/examples/pentagon.ml index 8cb865f..ca00fe0 100644 --- a/examples/pentagon.ml +++ b/examples/pentagon.ml @@ -15,11 +15,13 @@ let render_shape s = let x = pent.c.x in let y = pent.c.y in let points = - [|(x, y + side); + [| + (x, y + side); (x - side, y); (x - (side/2), y - side); (x + (side/2), y - side); - (x + side, y);|] + (x + side, y); + |] in draw_poly points From 49f3dd558f6c19708dd42dd264f638bcbdac9f0f Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Mon, 9 Oct 2023 12:39:55 +0300 Subject: [PATCH 04/23] The hexagon polygon --- examples/hexagon.ml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/hexagon.ml b/examples/hexagon.ml index 3972101..10a444e 100644 --- a/examples/hexagon.ml +++ b/examples/hexagon.ml @@ -15,12 +15,14 @@ let render_shape s = let x = hex.c.x in let y = hex.c.y in let points = - [|(x + (side/2), y + side); + [| + (x + (side/2), y + side); (x - (side/2), y + side); (x - (side), y); (x - (side/2), y - side); (x + (side/2), y - side); - (x + side, y);|] + (x + side, y); + |] in draw_poly points From d123473c6a03e69e8018601fb277448b67f7ee02 Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Sat, 14 Oct 2023 22:23:56 +0300 Subject: [PATCH 05/23] pentagon points --- examples/pentagon.ml | 55 ++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/examples/pentagon.ml b/examples/pentagon.ml index ca00fe0..61767ed 100644 --- a/examples/pentagon.ml +++ b/examples/pentagon.ml @@ -1,45 +1,24 @@ open Graphics -type point = { x : int; y : int } -type pentagon = { c : point; side_length : int} - -type shape = Pentagon of pentagon - -let canvas_size = (500, 500) -let canvas_mid = { x = fst canvas_size / 2; y = snd canvas_size / 2 } - -let render_shape s = - match s with - | Pentagon pent -> - let side = pent.side_length in - let x = pent.c.x in - let y = pent.c.y in - let points = - [| - (x, y + side); - (x - side, y); - (x - (side/2), y - side); - (x + (side/2), y - side); - (x + side, y); - |] - in - draw_poly points - - -let pentagon ?x ?y side_length = - let center = match (x, y) with - | Some x, Some y -> { x; y } - | _ -> canvas_mid in - Pentagon { c = center; side_length } - -let show shapes = List.iter render_shape shapes - let () = - open_graph (" " ^ string_of_int (fst canvas_size) ^ "x" ^ string_of_int (snd canvas_size)); + open_graph " 500x500"; + set_color black; - let pent = pentagon 100 in - show [pent]; + let draw_pentagon () = + let points = + [| + (250, 450); + (60, 312); + (132, 88); + (368, 88); + (440, 312); + |] in + Graphics.draw_poly points + in + + draw_pentagon(); ignore (read_line ()); - close_graph () + close_graph (); + exit 0 \ No newline at end of file From daa9ed7575f9a30cf7afa5021ca4ccdc04b7f7d5 Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Sat, 14 Oct 2023 23:15:52 +0300 Subject: [PATCH 06/23] Adding points --- examples/hexagon.ml | 57 ++++++++++++++------------------------------ examples/pentagon.ml | 4 ++-- examples/square.ml | 53 +++++++++++++--------------------------- 3 files changed, 36 insertions(+), 78 deletions(-) diff --git a/examples/hexagon.ml b/examples/hexagon.ml index 10a444e..d3b79da 100644 --- a/examples/hexagon.ml +++ b/examples/hexagon.ml @@ -1,46 +1,25 @@ open Graphics -type point = { x : int; y : int } -type hexagon = { c : point; side_length : int} - -type shape = Hexagon of hexagon - -let canvas_size = (500, 500) -let canvas_mid = { x = fst canvas_size / 2; y = snd canvas_size / 2 } - -let render_shape s = - match s with - | Hexagon hex -> - let side = hex.side_length in - let x = hex.c.x in - let y = hex.c.y in - let points = - [| - (x + (side/2), y + side); - (x - (side/2), y + side); - (x - (side), y); - (x - (side/2), y - side); - (x + (side/2), y - side); - (x + side, y); - |] - in - draw_poly points - - -let hexagon ?x ?y side_length = - let center = match (x, y) with - | Some x, Some y -> { x; y } - | _ -> canvas_mid in - Hexagon { c = center; side_length } - -let show shapes = List.iter render_shape shapes - let () = - open_graph (" " ^ string_of_int (fst canvas_size) ^ "x" ^ string_of_int (snd canvas_size)); + open_graph " 500x500"; + set_color black; - let hex = hexagon 100 in - show [hex]; + let draw_hexagon () = + let points = + [| + (132, 450); + (60, 312); + (132, 174); + (368, 174); + (440, 312); + (368, 450); + |] in + draw_poly points + in + + draw_hexagon(); ignore (read_line ()); - close_graph () + close_graph (); + exit 0 \ No newline at end of file diff --git a/examples/pentagon.ml b/examples/pentagon.ml index 61767ed..f7febb0 100644 --- a/examples/pentagon.ml +++ b/examples/pentagon.ml @@ -12,9 +12,9 @@ let () = (60, 312); (132, 88); (368, 88); - (440, 312); + (440, 312) |] in - Graphics.draw_poly points + draw_poly points in draw_pentagon(); diff --git a/examples/square.ml b/examples/square.ml index 596e9c4..7af3602 100644 --- a/examples/square.ml +++ b/examples/square.ml @@ -1,44 +1,23 @@ open Graphics -type point = { x : int; y : int } -type square = { c : point; side_length : int} - -type shape = Square of square - -let canvas_size = (500, 500) -let canvas_mid = { x = fst canvas_size / 2; y = snd canvas_size / 2 } - -let render_shape s = - match s with - | Square sqr -> - let side = sqr.side_length in - let x = sqr.c.x in - let y = sqr.c.y in - let points = - [| - (x - side, y - side); - (x + side, y - side); - (x + side, y + side); - (x - side, y + side) - |] - in - draw_poly points - - -let square ?x ?y side_length = - let center = match (x, y) with - | Some x, Some y -> { x; y } - | _ -> canvas_mid in - Square { c = center; side_length } - -let show shapes = List.iter render_shape shapes - let () = - open_graph (" " ^ string_of_int (fst canvas_size) ^ "x" ^ string_of_int (snd canvas_size)); + open_graph " 500x500"; + set_color black; - let sqr = square 100 in - show [sqr]; + let draw_square () = + let points = + [| + (250, 450); + (350, 450); + (350, 350); + (250, 350); + |] in + draw_poly points + in + + draw_square(); ignore (read_line ()); - close_graph () + close_graph (); + exit 0 \ No newline at end of file From 7339e3b2490687a4ac9b09cebdd6bc5b74c44a60 Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Sat, 14 Oct 2023 23:52:56 +0300 Subject: [PATCH 07/23] adding points --- examples/dune | 14 ++--------- examples/hexagon.ml | 25 ------------------- examples/pentagon.ml | 24 ------------------ examples/polygons.ml | 58 ++++++++++++++++++++++++++++++++++++++++++++ examples/square.ml | 23 ------------------ 5 files changed, 60 insertions(+), 84 deletions(-) delete mode 100644 examples/hexagon.ml delete mode 100644 examples/pentagon.ml create mode 100644 examples/polygons.ml delete mode 100644 examples/square.ml diff --git a/examples/dune b/examples/dune index 0a7f3cf..3fdf914 100644 --- a/examples/dune +++ b/examples/dune @@ -44,18 +44,8 @@ (libraries graphics)) (executable - (name square) - (modules square) - (libraries graphics)) - - (executable - (name pentagon) - (modules pentagon) - (libraries graphics)) - - (executable - (name hexagon) - (modules hexagon) + (name polygons) + (modules polygons) (libraries graphics)) (executable diff --git a/examples/hexagon.ml b/examples/hexagon.ml deleted file mode 100644 index d3b79da..0000000 --- a/examples/hexagon.ml +++ /dev/null @@ -1,25 +0,0 @@ -open Graphics - -let () = - open_graph " 500x500"; - - set_color black; - - let draw_hexagon () = - let points = - [| - (132, 450); - (60, 312); - (132, 174); - (368, 174); - (440, 312); - (368, 450); - |] in - draw_poly points - in - - draw_hexagon(); - - ignore (read_line ()); - close_graph (); - exit 0 \ No newline at end of file diff --git a/examples/pentagon.ml b/examples/pentagon.ml deleted file mode 100644 index f7febb0..0000000 --- a/examples/pentagon.ml +++ /dev/null @@ -1,24 +0,0 @@ -open Graphics - -let () = - open_graph " 500x500"; - - set_color black; - - let draw_pentagon () = - let points = - [| - (250, 450); - (60, 312); - (132, 88); - (368, 88); - (440, 312) - |] in - draw_poly points - in - - draw_pentagon(); - - ignore (read_line ()); - close_graph (); - exit 0 \ No newline at end of file diff --git a/examples/polygons.ml b/examples/polygons.ml new file mode 100644 index 0000000..cb8b486 --- /dev/null +++ b/examples/polygons.ml @@ -0,0 +1,58 @@ +open Graphics +let draw_square () = + let points = + [| + (100, 400); + (200, 400); + (200, 300); + (100, 300); + |] in + draw_poly points + + let draw_triangle () = + let points = + [| + (300, 300); + (400, 300); + (350, 400); + |] in + draw_poly points +let draw_hexagon () = + let points = + [| + (266, 215); + (230, 146); + (266, 77); + (384, 77); + (420, 146); + (384, 215); + |] + in + draw_poly points + + let draw_pentagon () = + let points = + [| + (125, 225); + (30, 156); + (66, 44); + (184, 44); + (220, 156) + |] + in + draw_poly points + + +let () = + open_graph " 500x500"; + + set_color black; + draw_square(); + draw_hexagon(); + draw_pentagon(); + draw_triangle (); + + + ignore (read_line ()); + close_graph (); + exit 0 \ No newline at end of file diff --git a/examples/square.ml b/examples/square.ml deleted file mode 100644 index 7af3602..0000000 --- a/examples/square.ml +++ /dev/null @@ -1,23 +0,0 @@ -open Graphics - -let () = - open_graph " 500x500"; - - set_color black; - - let draw_square () = - let points = - [| - (250, 450); - (350, 450); - (350, 350); - (250, 350); - |] in - draw_poly points - in - - draw_square(); - - ignore (read_line ()); - close_graph (); - exit 0 \ No newline at end of file From cd85dd54f55668ce4f0cce1757b906495ad79dec Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Sat, 14 Oct 2023 23:59:29 +0300 Subject: [PATCH 08/23] same file --- examples/polygons.ml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/examples/polygons.ml b/examples/polygons.ml index cb8b486..051d813 100644 --- a/examples/polygons.ml +++ b/examples/polygons.ml @@ -17,7 +17,8 @@ let draw_square () = (350, 400); |] in draw_poly points -let draw_hexagon () = + + let draw_hexagon () = let points = [| (266, 215); @@ -42,17 +43,13 @@ let draw_hexagon () = in draw_poly points - let () = open_graph " 500x500"; - set_color black; draw_square(); draw_hexagon(); draw_pentagon(); draw_triangle (); - - ignore (read_line ()); close_graph (); exit 0 \ No newline at end of file From 8002e25b3a27865ac4915daf0a8ccf492a1aa67b Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Sun, 15 Oct 2023 00:53:18 +0300 Subject: [PATCH 09/23] adding the programs --- examples/dune | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/examples/dune b/examples/dune index 3fdf914..54d2334 100644 --- a/examples/dune +++ b/examples/dune @@ -43,12 +43,42 @@ (modules star) (libraries graphics)) -(executable + (executable (name polygons) (modules polygons) (libraries graphics)) - (executable - (name axes) - (modules axes) - (libraries joy)) +(executable + (name axes) + (modules axes) + (libraries joy)) + +(executable + (name translate_circle) + (modules translate_circle) + (libraries joy)) + +(executable + (name translate_rectangle) + (modules translate_rectangle) + (libraries joy)) + +(executable + (name translate_ellipse) + (modules translate_ellipse) + (libraries joy)) + +(executable + (name circle_row_joy) + (modules circle_row_joy) + (libraries joy)) + +(executable + (name rotate) + (modules rotate) + (libraries joy)) + +(executable + (name line) + (modules line) + (libraries joy) ) \ No newline at end of file From a46703a5039d9246b3ccd150899ee5eebc56aecf Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Wed, 18 Oct 2023 10:42:56 +0300 Subject: [PATCH 10/23] Format the source code --- .ocamlformat | 2 +- examples/axes.ml | 8 +-- examples/circle_graph.ml | 66 +++++++++-------- examples/circle_grid.ml | 21 +++--- examples/circle_rectangle.ml | 20 ++++-- examples/circle_row.ml | 23 +++--- examples/circle_row_joy.ml | 6 +- examples/concentric_circles.ml | 13 ++-- examples/dune | 8 +-- examples/line.ml | 16 +++-- examples/polygons.ml | 55 ++++---------- examples/rectangle.ml | 15 ++-- examples/rotate.ml | 13 ++-- examples/star.ml | 29 +++++--- examples/translate_circle.ml | 4 +- examples/translate_ellipse.ml | 4 +- examples/translate_rectangle.ml | 4 +- examples/triangle.ml | 17 +++-- lib/joy.ml | 2 +- lib/shape.ml | 122 +++++++++++++++++++------------- lib/shape.mli | 7 +- test/test_all.ml | 2 +- test/test_ellipse.ml | 8 +-- test/test_rectangle.ml | 10 +-- 24 files changed, 253 insertions(+), 222 deletions(-) diff --git a/.ocamlformat b/.ocamlformat index 0b240ee..7df62da 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -1,2 +1,2 @@ profile = default -version = 0.26.0 \ No newline at end of file +version = 0.26.1 \ No newline at end of file diff --git a/examples/axes.ml b/examples/axes.ml index 7fe2376..1b7f6ff 100644 --- a/examples/axes.ml +++ b/examples/axes.ml @@ -1,9 +1,9 @@ -open Joy.Shape +open Joy.Shape -let _ = +let _ = draw_axes true; init (); - let c = circle 50 in + let c = circle 50 in render_shape c; close (); - exit 0 \ No newline at end of file + exit 0 diff --git a/examples/circle_graph.ml b/examples/circle_graph.ml index 5639197..35d6885 100644 --- a/examples/circle_graph.ml +++ b/examples/circle_graph.ml @@ -1,38 +1,36 @@ (* open Graphics -type point = { x : int; y : int } -type rectangle = { c : point; length : int; width : int } -type circle = { c : point; radius : int } -type shape = Circle of circle | Rectangle of rectangle -type _shapes = shape list - -let render_shape s = - match s with - | Circle circle -> draw_circle circle.c.x circle.c.y circle.radius - | Rectangle rectangle -> - draw_rect rectangle.c.x rectangle.c.y rectangle.length rectangle.width - -let circle ?x ?y r = - match (x, y) with - | Some x, Some y -> Circle { c = { x; y }; radius = r } - | _ -> Circle { c = { x = 450; y = 450 }; radius = r } - -let _rectangle ?x ?y length width = - match (x, y) with - | Some x, Some y -> Rectangle { c = { x; y }; length; width } - | _ -> Rectangle { c = { x = 150; y = 150 }; length; width } - -let show shapes = List.iter render_shape shapes *) - + type point = { x : int; y : int } + type rectangle = { c : point; length : int; width : int } + type circle = { c : point; radius : int } + type shape = Circle of circle | Rectangle of rectangle + type _shapes = shape list + + let render_shape s = + match s with + | Circle circle -> draw_circle circle.c.x circle.c.y circle.radius + | Rectangle rectangle -> + draw_rect rectangle.c.x rectangle.c.y rectangle.length rectangle.width + + let circle ?x ?y r = + match (x, y) with + | Some x, Some y -> Circle { c = { x; y }; radius = r } + | _ -> Circle { c = { x = 450; y = 450 }; radius = r } + + let _rectangle ?x ?y length width = + match (x, y) with + | Some x, Some y -> Rectangle { c = { x; y }; length; width } + | _ -> Rectangle { c = { x = 150; y = 150 }; length; width } + + let show shapes = List.iter render_shape shapes *) open Graphics type point = { x : int; y : int } type circle = { c : point; radius : int } - type shape = Circle of circle -let canvas_mid = { x = 250; y = 250} +let canvas_mid = { x = 250; y = 250 } let render_shape s = match s with @@ -46,16 +44,16 @@ let circle ?x ?y r = let show shapes = List.iter render_shape shapes (* let () = - open_graph " 500x500"; - (* Open a graphics window with dimensions 800x600 *) - set_color black; + open_graph " 500x500"; + (* Open a graphics window with dimensions 800x600 *) + set_color black; - let c1 = circle 100 in - let c2 = circle 200 in - show [ c1; c2 ]; + let c1 = circle 100 in + let c2 = circle 200 in + show [ c1; c2 ]; - ignore (read_line ()); - close_graph () *) + ignore (read_line ()); + close_graph () *) let () = Graphics.open_graph " 500x500"; diff --git a/examples/circle_grid.ml b/examples/circle_grid.ml index 386f994..1498e6c 100644 --- a/examples/circle_grid.ml +++ b/examples/circle_grid.ml @@ -2,7 +2,6 @@ open Graphics type point = { x : int; y : int } type circle = { c : point; radius : int } - type shape = Circle of circle let canvas_size = (1000, 1000) @@ -13,16 +12,14 @@ let render_shape s = | Circle circle -> draw_circle circle.c.x circle.c.y circle.radius let grid_of_circles ?x ?y spacing = - let center = match (x, y) with - | Some x, Some y -> { x; y } - | _ -> canvas_mid in - let create_circle x y = - Circle { c = { x; y }; radius = 50 } + let center = + match (x, y) with Some x, Some y -> { x; y } | _ -> canvas_mid in + let create_circle x y = Circle { c = { x; y }; radius = 50 } in let circles = ref [] in let half_spacing = spacing / 2 in - let x_positions = [center.x - half_spacing; center.x + half_spacing] in - let y_positions = [center.y - half_spacing; center.y + half_spacing] in + let x_positions = [ center.x - half_spacing; center.x + half_spacing ] in + let y_positions = [ center.y - half_spacing; center.y + half_spacing ] in for x = 0 to 1 do for y = 0 to 1 do let circle_x = List.nth x_positions x in @@ -35,10 +32,14 @@ let grid_of_circles ?x ?y spacing = let show shapes = List.iter render_shape shapes let () = - open_graph (" " ^ string_of_int (fst canvas_size) ^ "x" ^ string_of_int (snd canvas_size)); + open_graph + (" " + ^ string_of_int (fst canvas_size) + ^ "x" + ^ string_of_int (snd canvas_size)); set_color black; - let spacing = 100 in + let spacing = 100 in let circles = grid_of_circles spacing in show circles; diff --git a/examples/circle_rectangle.ml b/examples/circle_rectangle.ml index 42c2eb0..6c8f5a3 100644 --- a/examples/circle_rectangle.ml +++ b/examples/circle_rectangle.ml @@ -3,7 +3,6 @@ open Graphics type point = { x : int; y : int } type circle = { c : point; radius : int } type rectangle = { c : point; length : int; width : int } - type shape = Circle of circle | Rectangle of rectangle let canvas_size = (500, 500) @@ -31,18 +30,27 @@ let rectangle_outside_circle rectangle_length rectangle_width circle_radius = let rectangle_cy = circle_cy in let distance_x = circle_radius + (rectangle_length / 2) + 20 in let distance_y = circle_radius + (rectangle_width / 2) + 20 in - Rectangle { c = { x = rectangle_cx; y = rectangle_cy }; length = distance_x; width = distance_y } + Rectangle + { + c = { x = rectangle_cx; y = rectangle_cy }; + length = distance_x; + width = distance_y; + } let show shapes = List.iter render_shape shapes let () = - open_graph (" " ^ string_of_int (fst canvas_size) ^ "x" ^ string_of_int (snd canvas_size)); + open_graph + (" " + ^ string_of_int (fst canvas_size) + ^ "x" + ^ string_of_int (snd canvas_size)); set_color black; - let circle_shape = circle 40 in - let rectangle_shape = rectangle_outside_circle 120 80 60 in + let circle_shape = circle 40 in + let rectangle_shape = rectangle_outside_circle 120 80 60 in - show [circle_shape; rectangle_shape]; + show [ circle_shape; rectangle_shape ]; ignore (read_line ()); close_graph () diff --git a/examples/circle_row.ml b/examples/circle_row.ml index e24a0cf..cdc99d5 100644 --- a/examples/circle_row.ml +++ b/examples/circle_row.ml @@ -2,7 +2,6 @@ open Graphics type point = { x : int; y : int } type circle = { c : point; radius : int } - type shape = Circle of circle let canvas_size = (1000, 1000) @@ -13,17 +12,15 @@ let render_shape s = | Circle circle -> draw_circle circle.c.x circle.c.y circle.radius let row_of_circles ?x ?y spacing = - let center = match (x, y) with - | Some x, Some y -> { x; y } - | _ -> canvas_mid in - let create_circle x = - Circle { c = { x; y = center.y }; radius = 50 } + let center = + match (x, y) with Some x, Some y -> { x; y } | _ -> canvas_mid in + let create_circle x = Circle { c = { x; y = center.y }; radius = 50 } in let circles = ref [] in - let total_width = 3 * spacing in - let start_x = center.x - total_width / 2 in + let total_width = 3 * spacing in + let start_x = center.x - (total_width / 2) in for i = 0 to 2 do - let x = start_x + i * spacing in + let x = start_x + (i * spacing) in circles := create_circle x :: !circles done; !circles @@ -31,10 +28,14 @@ let row_of_circles ?x ?y spacing = let show shapes = List.iter render_shape shapes let () = - open_graph (" " ^ string_of_int (fst canvas_size) ^ "x" ^ string_of_int (snd canvas_size)); + open_graph + (" " + ^ string_of_int (fst canvas_size) + ^ "x" + ^ string_of_int (snd canvas_size)); set_color black; - let spacing = 150 in + let spacing = 150 in let circles = row_of_circles spacing in show circles; diff --git a/examples/circle_row_joy.ml b/examples/circle_row_joy.ml index dd01189..f205d4e 100644 --- a/examples/circle_row_joy.ml +++ b/examples/circle_row_joy.ml @@ -1,9 +1,9 @@ open Joy.Shape -let ()= +let () = init (); let base_circle = circle 50 in let circle1 = base_circle |> translate (-100) 0 in let circle2 = base_circle |> translate 100 0 in - show [circle1; base_circle; circle2]; - close() \ No newline at end of file + show [ circle1; base_circle; circle2 ]; + close () diff --git a/examples/concentric_circles.ml b/examples/concentric_circles.ml index 6b10b56..1f2edf0 100644 --- a/examples/concentric_circles.ml +++ b/examples/concentric_circles.ml @@ -2,7 +2,6 @@ open Graphics type point = { x : int; y : int } type circle = { c : point; radius : int } - type shape = Circle of circle let canvas_size = (500, 500) @@ -13,9 +12,9 @@ let render_shape s = | Circle circle -> draw_circle circle.c.x circle.c.y circle.radius let concentric_circles ?x ?y num_circles spacing = - let center = match (x, y) with - | Some x, Some y -> { x; y } - | _ -> canvas_mid in + let center = + match (x, y) with Some x, Some y -> { x; y } | _ -> canvas_mid + in let rec create_circles n radius acc = if n <= 0 then acc else @@ -27,7 +26,11 @@ let concentric_circles ?x ?y num_circles spacing = let show shapes = List.iter render_shape shapes let () = - open_graph (" " ^ string_of_int (fst canvas_size) ^ "x" ^ string_of_int (snd canvas_size)); + open_graph + (" " + ^ string_of_int (fst canvas_size) + ^ "x" + ^ string_of_int (snd canvas_size)); set_color black; let circles = concentric_circles 5 20 in diff --git a/examples/dune b/examples/dune index 54d2334..52b2a0b 100644 --- a/examples/dune +++ b/examples/dune @@ -43,7 +43,7 @@ (modules star) (libraries graphics)) - (executable +(executable (name polygons) (modules polygons) (libraries graphics)) @@ -77,8 +77,8 @@ (name rotate) (modules rotate) (libraries joy)) - -(executable + +(executable (name line) (modules line) - (libraries joy) ) \ No newline at end of file + (libraries joy)) diff --git a/examples/line.ml b/examples/line.ml index be28d7c..686a860 100644 --- a/examples/line.ml +++ b/examples/line.ml @@ -1,13 +1,19 @@ -open Joy.Shape +open Joy.Shape let interval = 16 -let line_interval = 500 / interval +let line_interval = 500 / interval let rec range a b = if a > b then [] else a :: range (a + 1) b let inc x = x + 1 -let lines = List.map (fun i -> let newx = (i |> inc |> ( * ) line_interval) in (line ~x1:newx ~y1:0 newx 500)) (range 0 interval) -let _ = +let lines = + List.map + (fun i -> + let newx = i |> inc |> ( * ) line_interval in + line ~x1:newx ~y1:0 newx 500) + (range 0 interval) + +let _ = init (); List.iter render_shape lines; close (); - exit 0 \ No newline at end of file + exit 0 diff --git a/examples/polygons.ml b/examples/polygons.ml index 051d813..b5a3fdb 100644 --- a/examples/polygons.ml +++ b/examples/polygons.ml @@ -1,55 +1,30 @@ open Graphics + let draw_square () = - let points = - [| - (100, 400); - (200, 400); - (200, 300); - (100, 300); - |] in + let points = [| (100, 400); (200, 400); (200, 300); (100, 300) |] in draw_poly points - let draw_triangle () = - let points = - [| - (300, 300); - (400, 300); - (350, 400); - |] in - draw_poly points +let draw_triangle () = + let points = [| (300, 300); (400, 300); (350, 400) |] in + draw_poly points - let draw_hexagon () = - let points = - [| - (266, 215); - (230, 146); - (266, 77); - (384, 77); - (420, 146); - (384, 215); - |] +let draw_hexagon () = + let points = + [| (266, 215); (230, 146); (266, 77); (384, 77); (420, 146); (384, 215) |] in draw_poly points - let draw_pentagon () = - let points = - [| - (125, 225); - (30, 156); - (66, 44); - (184, 44); - (220, 156) - |] - in - draw_poly points +let draw_pentagon () = + let points = [| (125, 225); (30, 156); (66, 44); (184, 44); (220, 156) |] in + draw_poly points let () = open_graph " 500x500"; set_color black; - draw_square(); - draw_hexagon(); - draw_pentagon(); + draw_square (); + draw_hexagon (); + draw_pentagon (); draw_triangle (); ignore (read_line ()); close_graph (); - exit 0 \ No newline at end of file + exit 0 diff --git a/examples/rectangle.ml b/examples/rectangle.ml index c071f8b..d785580 100644 --- a/examples/rectangle.ml +++ b/examples/rectangle.ml @@ -2,7 +2,6 @@ open Graphics type point = { x : int; y : int } type rectangle = { c : point; length : int; width : int } - type shape = Rectangle of rectangle let canvas_size = (500, 500) @@ -18,19 +17,23 @@ let render_shape s = draw_rect x1 y1 (x2 - x1) (y2 - y1) let rectangle ?x ?y length width = - let center = match (x, y) with - | Some x, Some y -> { x; y } - | _ -> canvas_mid in + let center = + match (x, y) with Some x, Some y -> { x; y } | _ -> canvas_mid + in Rectangle { c = center; length; width } let show shapes = List.iter render_shape shapes let () = - open_graph (" " ^ string_of_int (fst canvas_size) ^ "x" ^ string_of_int (snd canvas_size)); + open_graph + (" " + ^ string_of_int (fst canvas_size) + ^ "x" + ^ string_of_int (snd canvas_size)); set_color black; let rect = rectangle 200 100 in - show [rect]; + show [ rect ]; ignore (read_line ()); close_graph () diff --git a/examples/rotate.ml b/examples/rotate.ml index 4649253..9612316 100644 --- a/examples/rotate.ml +++ b/examples/rotate.ml @@ -3,10 +3,15 @@ open Joy.Shape let max = 32 let rec range a b = if a > b then [] else a :: range (a + 1) b -let _ = +let _ = init (); - let rect = rectangle 10 10 in - let nums = range 0 max in - let rotated = (List.map (fun i -> (rotate (int_of_float (float_of_int i /. float_of_int max *. 360.0)) rect)) nums) in + let rect = rectangle 10 10 in + let nums = range 0 max in + let rotated = + List.map + (fun i -> + rotate (int_of_float (float_of_int i /. float_of_int max *. 360.0)) rect) + nums + in show rotated; close () diff --git a/examples/star.ml b/examples/star.ml index 9a36b1b..f40a008 100644 --- a/examples/star.ml +++ b/examples/star.ml @@ -2,7 +2,12 @@ open Graphics type point = { x : int; y : int } -type star = { center : point; outer_radius : int; inner_radius : int; num_points : int } +type star = { + center : point; + outer_radius : int; + inner_radius : int; + num_points : int; +} type shape = Star of star @@ -13,16 +18,20 @@ let render_shape s = | Star star -> let center_x = star.center.x in let center_y = star.center.y in - let outer_r = float_of_int star.outer_radius in - let inner_r = float_of_int star.inner_radius in + let outer_r = float_of_int star.outer_radius in + let inner_r = float_of_int star.inner_radius in let num_points = star.num_points in let angle_step = 360.0 /. float_of_int num_points in moveto (center_x + int_of_float outer_r) center_y; for i = 1 to num_points * 2 do let angle = float_of_int i *. angle_step in let radius = if i mod 2 = 0 then outer_r else inner_r in - let x = center_x + int_of_float (radius *. cos (angle *. 3.14159265 /. 180.0)) in - let y = center_y + int_of_float (radius *. sin (angle *. 3.14159265 /. 180.0)) in + let x = + center_x + int_of_float (radius *. cos (angle *. 3.14159265 /. 180.0)) + in + let y = + center_y + int_of_float (radius *. sin (angle *. 3.14159265 /. 180.0)) + in lineto x y done; lineto (center_x + int_of_float outer_r) center_y @@ -33,14 +42,16 @@ let star center outer_radius inner_radius num_points = let show shapes = List.iter render_shape shapes let () = - open_graph (" " ^ string_of_int (fst canvas_size) ^ "x" ^ string_of_int (snd canvas_size)); + open_graph + (" " + ^ string_of_int (fst canvas_size) + ^ "x" + ^ string_of_int (snd canvas_size)); set_color black; let star_shape = star { x = 250; y = 250 } 50 20 5 in - show [star_shape]; + show [ star_shape ]; ignore (read_line ()); close_graph () - - \ No newline at end of file diff --git a/examples/translate_circle.ml b/examples/translate_circle.ml index 2c26df3..bd1a88b 100644 --- a/examples/translate_circle.ml +++ b/examples/translate_circle.ml @@ -8,6 +8,6 @@ let () = (* Translate it to the right by 100 *) let c2 = translate 100 0 c1 in (* Display both circles *) - show [c1; c2]; + show [ c1; c2 ]; - close () \ No newline at end of file + close () diff --git a/examples/translate_ellipse.ml b/examples/translate_ellipse.ml index d47f04e..a240cb0 100644 --- a/examples/translate_ellipse.ml +++ b/examples/translate_ellipse.ml @@ -8,6 +8,6 @@ let () = (* Translate it to the right by 100 and up by 50 *) let e2 = translate 100 50 e1 in (* Display both ellipses *) - show [e1; e2]; + show [ e1; e2 ]; - close () \ No newline at end of file + close () diff --git a/examples/translate_rectangle.ml b/examples/translate_rectangle.ml index 89afb4c..5f9fa4d 100644 --- a/examples/translate_rectangle.ml +++ b/examples/translate_rectangle.ml @@ -8,6 +8,6 @@ let () = let r2 = translate 100 0 r1 in (* Display rectangle transform *) - show [r1; r2]; + show [ r1; r2 ]; - close () \ No newline at end of file + close () diff --git a/examples/triangle.ml b/examples/triangle.ml index 51e6398..4c3a088 100644 --- a/examples/triangle.ml +++ b/examples/triangle.ml @@ -2,7 +2,6 @@ open Graphics type point = { x : int; y : int } type triangle = { p1 : point; p2 : point; p3 : point } - type shape = Triangle of triangle let canvas_size = (500, 500) @@ -21,18 +20,22 @@ let render_shape s = lineto x3 y3; lineto x1 y1 -let triangle p1 p2 p3 = - Triangle { p1; p2; p3 } - +let triangle p1 p2 p3 = Triangle { p1; p2; p3 } let show shapes = List.iter render_shape shapes let () = - open_graph (" " ^ string_of_int (fst canvas_size) ^ "x" ^ string_of_int (snd canvas_size)); + open_graph + (" " + ^ string_of_int (fst canvas_size) + ^ "x" + ^ string_of_int (snd canvas_size)); set_color black; - let triangle_shape = triangle { x = 250; y = 400 } { x = 150; y = 200 } { x = 350; y = 200 } in + let triangle_shape = + triangle { x = 250; y = 400 } { x = 150; y = 200 } { x = 350; y = 200 } + in - show [triangle_shape]; + show [ triangle_shape ]; ignore (read_line ()); close_graph () diff --git a/lib/joy.ml b/lib/joy.ml index 3230102..af1e230 100644 --- a/lib/joy.ml +++ b/lib/joy.ml @@ -1 +1 @@ -module Shape = Shape \ No newline at end of file +module Shape = Shape diff --git a/lib/shape.ml b/lib/shape.ml index e4b5ddc..bfaf03c 100644 --- a/lib/shape.ml +++ b/lib/shape.ml @@ -4,39 +4,41 @@ type point = { x : int; y : int } type line = { a : point; b : point } type rectangle = { c : point; length : int; width : int } type circle = { c : point; radius : int } -type ellipse = {c : point; rx : int; ry: int} -type shape = Circle of circle | Rectangle of rectangle | Ellipse of ellipse | Line of line -type shapes = shape list +type ellipse = { c : point; rx : int; ry : int } -let dimensions = ref {x = 500; y = 500} -let set_dimensions x y = - dimensions := {x;y} +type shape = + | Circle of circle + | Rectangle of rectangle + | Ellipse of ellipse + | Line of line -let canvas_mid = { x = (!dimensions.x / 2); y = (!dimensions.y / 2)} +type shapes = shape list +let dimensions = ref { x = 500; y = 500 } +let set_dimensions x y = dimensions := { x; y } +let canvas_mid = { x = !dimensions.x / 2; y = !dimensions.y / 2 } let axes_flag = ref false -let draw_axes flag = - axes_flag := flag - -let draw_line x1 y1 x2 y2 = - draw_poly_line [|(x1, y1); (x2, y2)|] +let draw_axes flag = axes_flag := flag +let draw_line x1 y1 x2 y2 = draw_poly_line [| (x1, y1); (x2, y2) |] let denormalize point = { x = point.x + canvas_mid.x; y = point.y + canvas_mid.y } let render_shape s = match s with - | Circle circle -> draw_circle (denormalize circle.c).x (denormalize circle.c).y circle.radius + | Circle circle -> + draw_circle (denormalize circle.c).x (denormalize circle.c).y + circle.radius | Rectangle rectangle -> let c = denormalize rectangle.c in draw_rect c.x c.y rectangle.length rectangle.width | Ellipse ellipse -> - let c = denormalize ellipse.c in - draw_ellipse c.x c.y ellipse.rx ellipse.ry + let c = denormalize ellipse.c in + draw_ellipse c.x c.y ellipse.rx ellipse.ry | Line line -> - let a = denormalize line.a in - let b = denormalize line.b in - draw_line a.x a.y b.x b.y + let a = denormalize line.a in + let b = denormalize line.b in + draw_line a.x a.y b.x b.y let circle ?x ?y r = match (x, y) with @@ -50,58 +52,76 @@ let rectangle ?x ?y length width = let ellipse ?x ?y rx ry = match (x, y) with - | Some x, Some y -> Ellipse {c = {x; y}; rx; ry} - | _ -> Ellipse {c = { x = 0; y = 0}; rx; ry} + | Some x, Some y -> Ellipse { c = { x; y }; rx; ry } + | _ -> Ellipse { c = { x = 0; y = 0 }; rx; ry } let line ?x1 ?y1 x2 y2 = - match (x1, y1) with - | Some x, Some y -> Line {a = {x;y}; b = {x = x2; y = y2}} - | _ -> Line {a = {x = 0; y = 0}; b = {x = x2; y = y2}} + match (x1, y1) with + | Some x, Some y -> Line { a = { x; y }; b = { x = x2; y = y2 } } + | _ -> Line { a = { x = 0; y = 0 }; b = { x = x2; y = y2 } } let translate dx dy shape = match shape with - | Circle circle -> Circle { circle with c = { x = circle.c.x + dx; y = circle.c.y + dy } } - | Rectangle rectangle -> Rectangle { rectangle with c = { x = rectangle.c.x + dx; y = rectangle.c.y + dy } } - | Ellipse ellipse -> Ellipse { ellipse with c = { x = ellipse.c.x + dx; y = ellipse.c.y + dy } } - | Line line -> Line {a = {x = line.a.x + dx; y = line.a.y + dy}; b = {x = line.b.x + dx; y = line.b.y + dy}} + | Circle circle -> + Circle { circle with c = { x = circle.c.x + dx; y = circle.c.y + dy } } + | Rectangle rectangle -> + Rectangle + { + rectangle with + c = { x = rectangle.c.x + dx; y = rectangle.c.y + dy }; + } + | Ellipse ellipse -> + Ellipse + { ellipse with c = { x = ellipse.c.x + dx; y = ellipse.c.y + dy } } + | Line line -> + Line + { + a = { x = line.a.x + dx; y = line.a.y + dy }; + b = { x = line.b.x + dx; y = line.b.y + dy }; + } let show shapes = List.iter render_shape shapes -let bi_to_uni x y = - let nx = x *. 0.5 +. (float_of_int !dimensions.x *. 0.5) in - let ny = y *. 0.5 +. (float_of_int !dimensions.y *. 0.5) in +let bi_to_uni x y = + let nx = (x *. 0.5) +. (float_of_int !dimensions.x *. 0.5) in + let ny = (y *. 0.5) +. (float_of_int !dimensions.y *. 0.5) in (int_of_float nx, int_of_float ny) -let deg_to_rad degrees = - degrees *. (Stdlib.Float.pi /. 180.) +let deg_to_rad degrees = degrees *. (Stdlib.Float.pi /. 180.) -let rot { x : int; y : int} degrees = +let rot { x : int; y : int } degrees = let radians = deg_to_rad (float_of_int degrees) in - let dx = ((float_of_int x) *. (cos radians)) -. ((float_of_int y) *. (sin radians)) in - let dy = ((float_of_int x) *. (sin radians)) +. ((float_of_int y) *. (cos radians)) in - let (dx, dy) = bi_to_uni dx dy in - {x = dx; y = dy} - -let rotate degrees shape = - match shape with - | Circle circle -> Circle { c = (rot circle.c degrees); radius = circle.radius } - | Rectangle rectangle -> Rectangle { c = (rot rectangle.c degrees); length = rectangle.length; width = rectangle.width } - | Ellipse ellipse -> Ellipse { c = (rot ellipse.c degrees); rx = ellipse.rx; ry = ellipse.ry } - -let render_axes () = + let dx = (float_of_int x *. cos radians) -. (float_of_int y *. sin radians) in + let dy = (float_of_int x *. sin radians) +. (float_of_int y *. cos radians) in + let dx, dy = bi_to_uni dx dy in + { x = dx; y = dy } + +let rotate degrees shape = + match shape with + | Circle circle -> Circle { c = rot circle.c degrees; radius = circle.radius } + | Rectangle rectangle -> + Rectangle + { + c = rot rectangle.c degrees; + length = rectangle.length; + width = rectangle.width; + } + | Ellipse ellipse -> + Ellipse { c = rot ellipse.c degrees; rx = ellipse.rx; ry = ellipse.ry } + +let render_axes () = set_color (rgb 192 192 192); - let half_x = (size_x ()) / 2 in + let half_x = size_x () / 2 in draw_line half_x 0 half_x (size_y ()); - let half_y = (size_y ()) / 2 in + let half_y = size_y () / 2 in draw_line 0 half_y (size_x ()) half_y let init () = open_graph (Printf.sprintf " %ix%i" !dimensions.x !dimensions.y); - if !axes_flag then - render_axes (); - + if !axes_flag then render_axes (); + set_color black let close () = ignore (read_line ()); - close_graph () \ No newline at end of file + close_graph () diff --git a/lib/shape.mli b/lib/shape.mli index 7d95b02..d7b38b4 100644 --- a/lib/shape.mli +++ b/lib/shape.mli @@ -5,14 +5,11 @@ val render_shape : shape -> unit val circle : ?x:int -> ?y:int -> int -> shape val rectangle : ?x:int -> ?y:int -> int -> int -> shape val ellipse : ?x:int -> ?y:int -> int -> int -> shape - val line : ?x1:int -> ?y1:int -> int -> int -> shape -val translate: int -> int -> shape -> shape +val translate : int -> int -> shape -> shape val show : shape list -> unit - val rotate : int -> shape -> shape - val draw_axes : bool -> unit val set_dimensions : int -> int -> unit val init : unit -> unit -val close : unit -> unit \ No newline at end of file +val close : unit -> unit diff --git a/test/test_all.ml b/test/test_all.ml index b1c89e5..37d23e1 100644 --- a/test/test_all.ml +++ b/test/test_all.ml @@ -1,4 +1,4 @@ let () = Test_circle.run (); Test_ellipse.run (); - Test_rectangle.run (); \ No newline at end of file + Test_rectangle.run () diff --git a/test/test_ellipse.ml b/test/test_ellipse.ml index 91376d4..9e6d7bc 100644 --- a/test/test_ellipse.ml +++ b/test/test_ellipse.ml @@ -2,10 +2,10 @@ open Joy.Shape let run () = init (); - + let e1 = ellipse 50 30 in let e2 = ellipse 100 60 in - - show [e1; e2]; - + + show [ e1; e2 ]; + close () diff --git a/test/test_rectangle.ml b/test/test_rectangle.ml index d5161de..24b6891 100644 --- a/test/test_rectangle.ml +++ b/test/test_rectangle.ml @@ -2,10 +2,10 @@ open Joy.Shape let run () = init (); - + let r1 = rectangle 50 30 in let r2 = rectangle 100 60 in - - show [r1; r2]; - - close () \ No newline at end of file + + show [ r1; r2 ]; + + close () From a1cce272e27a6937f572a55211013c16fe1af384 Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Fri, 20 Oct 2023 14:23:12 +0300 Subject: [PATCH 11/23] non-exhaustive pattern --- lib/shape.ml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/shape.ml b/lib/shape.ml index bfaf03c..2c63632 100644 --- a/lib/shape.ml +++ b/lib/shape.ml @@ -96,18 +96,19 @@ let rot { x : int; y : int } degrees = let dx, dy = bi_to_uni dx dy in { x = dx; y = dy } -let rotate degrees shape = - match shape with - | Circle circle -> Circle { c = rot circle.c degrees; radius = circle.radius } - | Rectangle rectangle -> - Rectangle - { - c = rot rectangle.c degrees; - length = rectangle.length; - width = rectangle.width; - } - | Ellipse ellipse -> - Ellipse { c = rot ellipse.c degrees; rx = ellipse.rx; ry = ellipse.ry } + +let rotate degrees shape = + match shape with + | Circle circle -> Circle { c = (rot circle.c degrees); radius = circle.radius } + | Rectangle rectangle -> + Rectangle + { + c = (rot rectangle.c degrees); + length = rectangle.length; + width = rectangle.width + } + | Ellipse ellipse -> Ellipse { c = (rot ellipse.c degrees); rx = ellipse.rx; ry = ellipse.ry } + | Line line -> Line {a = (rot line.a degrees); b = (rot line.b degrees)} let render_axes () = set_color (rgb 192 192 192); From 95abe11c6be471e48a4af721e74963da0c6fb4c2 Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Fri, 20 Oct 2023 14:45:37 +0300 Subject: [PATCH 12/23] Automatic formatting --- examples/dune | 5 +--- lib/shape.ml | 56 +++++++++++++++++++++++++++++----------- lib/shape.mli | 3 +-- test/test_all.ml | 2 +- test/test_scale_shape.ml | 3 +-- 5 files changed, 45 insertions(+), 24 deletions(-) diff --git a/examples/dune b/examples/dune index f1f7bd4..4844f34 100644 --- a/examples/dune +++ b/examples/dune @@ -82,11 +82,8 @@ (name line) (modules line) (libraries joy)) -<<<<<<< HEAD -======= -(executable +(executable (name ellipse) (modules ellipse) (libraries joy)) ->>>>>>> origin/main diff --git a/lib/shape.ml b/lib/shape.ml index 9f97966..7fbe61f 100644 --- a/lib/shape.ml +++ b/lib/shape.ml @@ -62,18 +62,38 @@ let line ?x1 ?y1 x2 y2 = let translate dx dy shape = match shape with - | Circle circle -> Circle { circle with c = { x = circle.c.x + dx; y = circle.c.y + dy } } - | Rectangle rectangle -> Rectangle { rectangle with c = { x = rectangle.c.x + dx; y = rectangle.c.y + dy } } - | Ellipse ellipse -> Ellipse { ellipse with c = { x = ellipse.c.x + dx; y = ellipse.c.y + dy } } - | Line line -> Line {a = {x = line.a.x + dx; y = line.a.y + dy}; b = {x = line.b.x + dx; y = line.b.y + dy}} + | Circle circle -> + Circle { circle with c = { x = circle.c.x + dx; y = circle.c.y + dy } } + | Rectangle rectangle -> + Rectangle + { + rectangle with + c = { x = rectangle.c.x + dx; y = rectangle.c.y + dy }; + } + | Ellipse ellipse -> + Ellipse + { ellipse with c = { x = ellipse.c.x + dx; y = ellipse.c.y + dy } } + | Line line -> + Line + { + a = { x = line.a.x + dx; y = line.a.y + dy }; + b = { x = line.b.x + dx; y = line.b.y + dy }; + } let scale factor s = - let round x = int_of_float(x +. 0.5) in - let scale_length len fact = round ((float_of_int len) *. sqrt(fact)) in + let round x = int_of_float (x +. 0.5) in + let scale_length len fact = round (float_of_int len *. sqrt fact) in match s with - | Circle circle' -> circle ~x:circle'.c.x ~y:circle'.c.y (scale_length circle'.radius factor) - | Rectangle rectangle' -> rectangle ~x:rectangle'.c.x ~y:rectangle'.c.y (scale_length rectangle'.length factor) (scale_length rectangle'.width factor) - | Ellipse ellipse' -> ellipse ~x:ellipse'.c.x ~y:ellipse'.c.y (scale_length ellipse'.rx factor) (scale_length ellipse'.ry factor) + | Circle circle' -> + circle ~x:circle'.c.x ~y:circle'.c.y (scale_length circle'.radius factor) + | Rectangle rectangle' -> + rectangle ~x:rectangle'.c.x ~y:rectangle'.c.y + (scale_length rectangle'.length factor) + (scale_length rectangle'.width factor) + | Ellipse ellipse' -> + ellipse ~x:ellipse'.c.x ~y:ellipse'.c.y + (scale_length ellipse'.rx factor) + (scale_length ellipse'.ry factor) | Line _line' -> failwith "Not Implemented" let show shapes = List.iter render_shape shapes @@ -92,12 +112,18 @@ let rot { x : int; y : int } degrees = let dx, dy = bi_to_uni dx dy in { x = dx; y = dy } - -let rotate degrees shape = - match shape with - | Circle circle -> Circle { c = (rot circle.c degrees); radius = circle.radius } - | Rectangle rectangle -> Rectangle { c = (rot rectangle.c degrees); length = rectangle.length; width = rectangle.width } - | Ellipse ellipse -> Ellipse { c = (rot ellipse.c degrees); rx = ellipse.rx; ry = ellipse.ry } +let rotate degrees shape = + match shape with + | Circle circle -> Circle { c = rot circle.c degrees; radius = circle.radius } + | Rectangle rectangle -> + Rectangle + { + c = rot rectangle.c degrees; + length = rectangle.length; + width = rectangle.width; + } + | Ellipse ellipse -> + Ellipse { c = rot ellipse.c degrees; rx = ellipse.rx; ry = ellipse.ry } | Line _line -> failwith "Not Implemented" let render_axes () = diff --git a/lib/shape.mli b/lib/shape.mli index ad6adf9..b672636 100644 --- a/lib/shape.mli +++ b/lib/shape.mli @@ -8,8 +8,7 @@ val ellipse : ?x:int -> ?y:int -> int -> int -> shape val line : ?x1:int -> ?y1:int -> int -> int -> shape val translate : int -> int -> shape -> shape val show : shape list -> unit -val scale: float -> shape -> shape - +val scale : float -> shape -> shape val rotate : int -> shape -> shape val draw_axes : bool -> unit val set_dimensions : int -> int -> unit diff --git a/test/test_all.ml b/test/test_all.ml index 1a67017..8990990 100644 --- a/test/test_all.ml +++ b/test/test_all.ml @@ -2,4 +2,4 @@ let () = Test_circle.run (); Test_ellipse.run (); Test_rectangle.run (); - Test_scale_shape.run (); \ No newline at end of file + Test_scale_shape.run () diff --git a/test/test_scale_shape.ml b/test/test_scale_shape.ml index 02c4f2e..5ac5124 100644 --- a/test/test_scale_shape.ml +++ b/test/test_scale_shape.ml @@ -12,5 +12,4 @@ let run () = let e2 = scale 2. e1 in let e3 = scale 0.7 e1 in show [ c1; c2; c3; r1; r2; r3; e1; e2; e3 ]; - close (); - \ No newline at end of file + close () From 042d8eb9e966724cb6bd12f0b87199ff38924e2d Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Tue, 24 Oct 2023 11:11:34 +0300 Subject: [PATCH 13/23] Adding the rotate transformation for lines --- lib/shape.ml | 5 +++-- test/test_scale_shape.ml | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/shape.ml b/lib/shape.ml index 7fbe61f..e06a0db 100644 --- a/lib/shape.ml +++ b/lib/shape.ml @@ -111,7 +111,7 @@ let rot { x : int; y : int } degrees = let dy = (float_of_int x *. sin radians) +. (float_of_int y *. cos radians) in let dx, dy = bi_to_uni dx dy in { x = dx; y = dy } - + let rotate degrees shape = match shape with | Circle circle -> Circle { c = rot circle.c degrees; radius = circle.radius } @@ -124,7 +124,8 @@ let rotate degrees shape = } | Ellipse ellipse -> Ellipse { c = rot ellipse.c degrees; rx = ellipse.rx; ry = ellipse.ry } - | Line _line -> failwith "Not Implemented" + | Line line -> + Line { a= rot line.a degrees; b = rot line.b degrees } let render_axes () = set_color (rgb 192 192 192); diff --git a/test/test_scale_shape.ml b/test/test_scale_shape.ml index 5ac5124..16f5589 100644 --- a/test/test_scale_shape.ml +++ b/test/test_scale_shape.ml @@ -11,5 +11,8 @@ let run () = let e1 = ellipse 30 50 |> translate 500 500 in let e2 = scale 2. e1 in let e3 = scale 0.7 e1 in - show [ c1; c2; c3; r1; r2; r3; e1; e2; e3 ]; + let line1 = line 250 250 in + let rotatedLine = rotate 45 line1 in + + show [ c1; c2; c3; r1; r2; r3; e1; e2; e3; rotatedLine]; close () From d87930e15e62f8e287bd2d4f58a8d7eb54144298 Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Tue, 24 Oct 2023 22:46:05 +0300 Subject: [PATCH 14/23] Added information to the readMe file --- README.md | 117 ++++++++++++++++++++++++++++++++++++++- lib/shape.ml | 3 +- test/test_scale_shape.ml | 4 +- 3 files changed, 121 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9821f1a..3b9eb7f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,120 @@ # Joy in OCaml -More information coming soon. +## Project Overview +This library is like a toolbox for creating cool shapes and patterns using OCaml. It takes inspiration from [joy](https://github.com/fossunited/joy). Whether you're an artist or a coder, you can use it to make interesting art with code. + +## Project Benefits + +Here's how this project can make your life easier and more creative: + +1. **Get Creative with Geometry:** This project simplifies geometric creative coding in OCaml, helping you explore the exciting world where programming meets art. + +2. **User-Friendly Tools:** We provide an easy-to-use API, so whether you're a newbie or a pro, you can dive into creative coding without confusion. + +3. **Basic Shapes at Your Fingertips:** Use simple shapes as your creative building blocks, making it a breeze to start your artistic coding journey. + +4. **Mix and Match with Ease:** Combine, transform, and build complex shapes effortlessly. + + +## Getting Started with OCaml + +Follow these simple steps to begin working with ocaml-joy : + +### 1. Install OCaml + +Start by installing OCaml by following the official installation tutorial at [https://ocaml.org/docs/installing-ocaml](https://ocaml.org/docs/installing-ocaml). + +### 2. Install Opam + +After successfully installing OCaml, proceed to install Opam, the OCaml package manager. It provides a convenient way to install, manage, and share OCaml libraries and tools. + +For Windows, Opam can be installed on Windows using Windows Subsystem for Linux (WSL) or other virtualization methods, as OCaml development is primarily done on Unix-like systems. You can set up WSL and then follow the Linux installation instructions. + +For Linux, If you're using Debian or Ubuntu, you can install Opam via the system package manager. Open a terminal and run the following commands: + +`sudo apt update +sudo apt install opam +` + +### 3. Update Opam +Once Opam is installed, make sure to update and upgrade it to the latest version of packages by running the following commands: + +`opam update && opam upgrade` + +### 4. Install dune +Dune is a build system we are using for our OCaml project. It is to help us to simplify and automate the build process. Run the following command for it to be installed. + +`opam install dune` + +### 5. Installing Graphics Library: +To install the necessary Graphics library, execute the following command inside the directory where your OCaml code is located: + +`opam install graphics` + +The Graphics library is a simple graphics module in OCaml that provides functions for creating graphical windows, drawing shapes, and handling user input events. + +### 6. Building and Running Examples: +To build and execute examples, navigate to the directory where your OCaml code is located (e.g., ocaml-joy) + +`cd ocaml-joy # Change to your project directory` + +Then, build the examples using Dune + +`dune build examples/` + +Run your preferred file for example to display the file in the examples directory named circle.ml we use the command + +`dune exec -- examples/circle.exe` + +To verify the success of this installation, you will see the following output: + +![circle Image](https://github.com/joanita-51/ocaml-joy/assets/82649346/87bf01ad-836f-4491-97c2-8724b8047429) + +## Getting Help +At any point, please don't hesitate to ask questions. You can contact the mentors either here in the issue tracker or in the #outreachy channel in [OCaml discord](https://discord.com/invite/cCYQbqN). + +## Other wonderful Shapes you will find +![axes image](https://github.com/joanita-51/ocaml-joy/assets/82649346/0b8b402e-65ee-45a8-b568-cf0434a10f5e) +![circle graph image](https://github.com/joanita-51/ocaml-joy/assets/82649346/1ac34bd9-553b-45e2-90cf-240c73b63256) +![rectangle image](https://github.com/joanita-51/ocaml-joy/assets/82649346/c00e5df4-83bd-4cf7-a864-6f26da0d1fac) +![circle grid image](https://github.com/joanita-51/ocaml-joy/assets/82649346/20176f2d-cf96-4ec1-93ed-e5eaf1682600) +![star image](https://github.com/joanita-51/ocaml-joy/assets/82649346/5a8cd0ea-f00b-46b0-b34d-406d76561a2d) +![circle rectangle image](https://github.com/joanita-51/ocaml-joy/assets/82649346/d53af149-83e3-40ac-b34d-d83c69eede3b) +![circle row joy image](https://github.com/joanita-51/ocaml-joy/assets/82649346/6a67187a-ef85-4549-9920-a674740731a7) +![triangle image](https://github.com/joanita-51/ocaml-joy/assets/82649346/de6f1384-94cd-4d78-8380-74d0c38b9331) +![concentric circles image](https://github.com/joanita-51/ocaml-joy/assets/82649346/8085d796-4672-413f-904e-01d843e076a1) +![Line image](https://github.com/joanita-51/ocaml-joy/assets/82649346/3b53a1b1-4192-4039-a78d-452116cf683b) +![translate circle image](https://github.com/joanita-51/ocaml-joy/assets/82649346/f4b570ef-cc66-46a8-9360-8796e1fb7361) +![translate rectangle image](https://github.com/joanita-51/ocaml-joy/assets/82649346/aedfaeb4-4ddc-4d82-a77f-a2dfdd071b3d) +![polygon image](https://github.com/joanita-51/ocaml-joy/assets/82649346/1201e352-ef3f-433c-82cc-c834b3d52daf) +![high order transformation image](https://github.com/joanita-51/ocaml-joy/assets/82649346/eeb2d2fc-86c5-4159-b559-4e280232798f) +![translate eclipse image](https://github.com/joanita-51/ocaml-joy/assets/82649346/70026da8-92a3-4c3f-a90a-6827b87e1b8a) +![circle grid image](https://github.com/joanita-51/ocaml-joy/assets/82649346/2d24f4a5-2d06-4091-806a-1c7b412a3ef7) + + +## Contributing to Ocaml-Joy + +We warmly welcome contributions from the community. If you'd like to contribute to Ocaml-Joy after setting it up on your machine, follow these steps to get started: + +1. **Select a Good-First Issue:** Begin your contribution journey by checking our issue tracker for issues tagged as 'good-first-issue.' These are typically beginner-friendly tasks designed to help new contributors get acquainted with the project. + +2. **Fork the Repository:** Once you've chosen an issue to work on, fork the Ocaml-Joy repository to create your own copy. + +3. **Create a Branch:** Before making any changes, create a new branch for your work. This helps keep your changes isolated and organized. + +4. **Make Your Changes:** Dive into the code and make the necessary modifications to address the chosen issue. Ensure that you follow our coding guidelines and best practices. + +5. **Test Your Changes:** After implementing your modifications, thoroughly test your code to ensure it functions as expected and doesn't introduce new issues. + +6. **Submit a Pull Request:** When you're confident that your changes are ready, submit a pull request (PR) to the main repository. Provide a clear description of your changes and reference the issue you've resolved. + +7. **Engage in Discussion:** Engage in discussions and reviews on your PR. Our team and the community will provide feedback and guidance to ensure your contribution aligns with the project's goals. + +8. **Get Your Contribution Merged:** Once your PR is approved and passes all checks, it will be merged into the main project. Congratulations on your successful contribution! + +By following these steps, you'll be actively contributing to Ocaml-Joy and helping improve the project. We appreciate your consideration of joining our community! + + +## Acknowlegments *This library is inspired by [joy](https://github.com/fossunited/joy). Thanks to the creators!* diff --git a/lib/shape.ml b/lib/shape.ml index 3dfc94b..1a223dc 100644 --- a/lib/shape.ml +++ b/lib/shape.ml @@ -124,7 +124,8 @@ let rotate degrees shape = } | Ellipse ellipse -> Ellipse { c = rot ellipse.c degrees; rx = ellipse.rx; ry = ellipse.ry } - | Line _line -> failwith "Not Implemented" + | Line line -> + Line { a= rot line.a degrees; b = rot line.b degrees } let compose f g x = g (f x) diff --git a/test/test_scale_shape.ml b/test/test_scale_shape.ml index 5ac5124..da6aaba 100644 --- a/test/test_scale_shape.ml +++ b/test/test_scale_shape.ml @@ -11,5 +11,7 @@ let run () = let e1 = ellipse 30 50 |> translate 500 500 in let e2 = scale 2. e1 in let e3 = scale 0.7 e1 in - show [ c1; c2; c3; r1; r2; r3; e1; e2; e3 ]; + let line1 = line 100 100 in + let rotatedLine = rotate 45 line1 in + show [ c1; c2; c3; r1; r2; r3; e1; e2; e3; rotatedLine ]; close () From 77eb225c65d39e8dda5b00027cf4a259e2ff6c9e Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Tue, 24 Oct 2023 23:04:24 +0300 Subject: [PATCH 15/23] Adding the table of contents to the file --- README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3b9eb7f..fa8c7a7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,14 @@ # Joy in OCaml +## Table of Contents +- [Project Overview](#project-overview) +- [Project Benefits](#project-benefits) +- [Installation](#installation) +- [Getting Help](#getting-help) +- [Other wonderful Shapes](#other-wonderful-shapes) +- [Contribution](#contribution) +- [Acknowlegments](#acknowlegments) + ## Project Overview This library is like a toolbox for creating cool shapes and patterns using OCaml. It takes inspiration from [joy](https://github.com/fossunited/joy). Whether you're an artist or a coder, you can use it to make interesting art with code. @@ -16,7 +25,7 @@ Here's how this project can make your life easier and more creative: 4. **Mix and Match with Ease:** Combine, transform, and build complex shapes effortlessly. -## Getting Started with OCaml +## Installation Follow these simple steps to begin working with ocaml-joy : @@ -92,7 +101,7 @@ At any point, please don't hesitate to ask questions. You can contact the mentor ![circle grid image](https://github.com/joanita-51/ocaml-joy/assets/82649346/2d24f4a5-2d06-4091-806a-1c7b412a3ef7) -## Contributing to Ocaml-Joy +## Contribution We warmly welcome contributions from the community. If you'd like to contribute to Ocaml-Joy after setting it up on your machine, follow these steps to get started: From a3a987b47d8c3847959b6655be71e589e9dc4ec7 Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Tue, 24 Oct 2023 23:05:55 +0300 Subject: [PATCH 16/23] Editing the title --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fa8c7a7..8fc465c 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ To verify the success of this installation, you will see the following output: ## Getting Help At any point, please don't hesitate to ask questions. You can contact the mentors either here in the issue tracker or in the #outreachy channel in [OCaml discord](https://discord.com/invite/cCYQbqN). -## Other wonderful Shapes you will find +## Other wonderful Shapes ![axes image](https://github.com/joanita-51/ocaml-joy/assets/82649346/0b8b402e-65ee-45a8-b568-cf0434a10f5e) ![circle graph image](https://github.com/joanita-51/ocaml-joy/assets/82649346/1ac34bd9-553b-45e2-90cf-240c73b63256) ![rectangle image](https://github.com/joanita-51/ocaml-joy/assets/82649346/c00e5df4-83bd-4cf7-a864-6f26da0d1fac) From 351b16084b8c5d15e28a2fd7596e844a9bcffb3a Mon Sep 17 00:00:00 2001 From: NAKITYO JOANITA <82649346+joanita-51@users.noreply.github.com> Date: Thu, 26 Oct 2023 13:44:01 +0300 Subject: [PATCH 17/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8fc465c..d57b1a6 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ To verify the success of this installation, you will see the following output: ## Getting Help At any point, please don't hesitate to ask questions. You can contact the mentors either here in the issue tracker or in the #outreachy channel in [OCaml discord](https://discord.com/invite/cCYQbqN). -## Other wonderful Shapes +## Shape Examples ![axes image](https://github.com/joanita-51/ocaml-joy/assets/82649346/0b8b402e-65ee-45a8-b568-cf0434a10f5e) ![circle graph image](https://github.com/joanita-51/ocaml-joy/assets/82649346/1ac34bd9-553b-45e2-90cf-240c73b63256) ![rectangle image](https://github.com/joanita-51/ocaml-joy/assets/82649346/c00e5df4-83bd-4cf7-a864-6f26da0d1fac) From c4902ea1603e6f09394d5b0d64698ab89ddf2d08 Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Thu, 26 Oct 2023 13:55:45 +0300 Subject: [PATCH 18/23] Removing some shapes --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d57b1a6..0f1b90c 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,9 @@ At any point, please don't hesitate to ask questions. You can contact the mentor ![circle graph image](https://github.com/joanita-51/ocaml-joy/assets/82649346/1ac34bd9-553b-45e2-90cf-240c73b63256) ![rectangle image](https://github.com/joanita-51/ocaml-joy/assets/82649346/c00e5df4-83bd-4cf7-a864-6f26da0d1fac) ![circle grid image](https://github.com/joanita-51/ocaml-joy/assets/82649346/20176f2d-cf96-4ec1-93ed-e5eaf1682600) -![star image](https://github.com/joanita-51/ocaml-joy/assets/82649346/5a8cd0ea-f00b-46b0-b34d-406d76561a2d) +[star image](https://github.com/joanita-51/ocaml-joy/assets/82649346/5a8cd0ea-f00b-46b0-b34d-406d76561a2d) +![high order transformation image](https://github.com/joanita-51/ocaml-joy/assets/82649346/eeb2d2fc-86c5-4159-b559-4e280232798f) + ## Contribution From e941317fc3a8f4bcb1e4cd2a5a990ffb9ec9b0ca Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Thu, 26 Oct 2023 14:04:19 +0300 Subject: [PATCH 19/23] short description --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f1b90c..d7486ef 100644 --- a/README.md +++ b/README.md @@ -83,11 +83,14 @@ To verify the success of this installation, you will see the following output: At any point, please don't hesitate to ask questions. You can contact the mentors either here in the issue tracker or in the #outreachy channel in [OCaml discord](https://discord.com/invite/cCYQbqN). ## Shape Examples + +These shapes have been crafted with the aid of this library. + ![axes image](https://github.com/joanita-51/ocaml-joy/assets/82649346/0b8b402e-65ee-45a8-b568-cf0434a10f5e) ![circle graph image](https://github.com/joanita-51/ocaml-joy/assets/82649346/1ac34bd9-553b-45e2-90cf-240c73b63256) ![rectangle image](https://github.com/joanita-51/ocaml-joy/assets/82649346/c00e5df4-83bd-4cf7-a864-6f26da0d1fac) ![circle grid image](https://github.com/joanita-51/ocaml-joy/assets/82649346/20176f2d-cf96-4ec1-93ed-e5eaf1682600) -[star image](https://github.com/joanita-51/ocaml-joy/assets/82649346/5a8cd0ea-f00b-46b0-b34d-406d76561a2d) +![star image](https://github.com/joanita-51/ocaml-joy/assets/82649346/5a8cd0ea-f00b-46b0-b34d-406d76561a2d) ![high order transformation image](https://github.com/joanita-51/ocaml-joy/assets/82649346/eeb2d2fc-86c5-4159-b559-4e280232798f) +## Getting Help +At any point, please don't hesitate to ask questions. You can contact the mentors either here in the issue tracker or in the #outreachy channel in [OCaml discord](https://discord.com/invite/cCYQbqN). -## Contribution - -We warmly welcome contributions from the community. If you'd like to contribute to Ocaml-Joy after setting it up on your machine, follow these steps to get started: - -1. **Select a Good-First Issue:** Begin your contribution journey by checking our issue tracker for issues tagged as 'good-first-issue.' These are typically beginner-friendly tasks designed to help new contributors get acquainted with the project. - -2. **Fork the Repository:** Once you've chosen an issue to work on, fork the Ocaml-Joy repository to create your own copy. - -3. **Create a Branch:** Before making any changes, create a new branch for your work. This helps keep your changes isolated and organized. - -4. **Make Your Changes:** Dive into the code and make the necessary modifications to address the chosen issue. Ensure that you follow our coding guidelines and best practices. - -5. **Test Your Changes:** After implementing your modifications, thoroughly test your code to ensure it functions as expected and doesn't introduce new issues. - -6. **Submit a Pull Request:** When you're confident that your changes are ready, submit a pull request (PR) to the main repository. Provide a clear description of your changes and reference the issue you've resolved. - -7. **Engage in Discussion:** Engage in discussions and reviews on your PR. Our team and the community will provide feedback and guidance to ensure your contribution aligns with the project's goals. - -8. **Get Your Contribution Merged:** Once your PR is approved and passes all checks, it will be merged into the main project. Congratulations on your successful contribution! +## How to Contribute +For information on how to contribute to this project, please see [CONTRIBUTING.md](CONTRIBUTING.md). -By following these steps, you'll be actively contributing to Ocaml-Joy and helping improve the project. We appreciate your consideration of joining our community! +## License +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. ## Acknowlegments From 79862110d5982d5fefc17548ac1a4027d5e2c6d7 Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Fri, 27 Oct 2023 10:07:11 +0300 Subject: [PATCH 21/23] modifying the readme --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 72af676..1a4c22d 100644 --- a/README.md +++ b/README.md @@ -48,10 +48,8 @@ These shapes have been crafted with the aid of this library. ![translate eclipse image](https://github.com/joanita-51/ocaml-joy/assets/82649346/70026da8-92a3-4c3f-a90a-6827b87e1b8a) ![circle grid image](https://github.com/joanita-51/ocaml-joy/assets/82649346/2d24f4a5-2d06-4091-806a-1c7b412a3ef7) --> -## Getting Help -At any point, please don't hesitate to ask questions. You can contact the mentors either here in the issue tracker or in the #outreachy channel in [OCaml discord](https://discord.com/invite/cCYQbqN). - ## How to Contribute + For information on how to contribute to this project, please see [CONTRIBUTING.md](CONTRIBUTING.md). ## License From 73c5e62b2707fba2e65c088169e54d13f34ae3ed Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Fri, 27 Oct 2023 10:08:07 +0300 Subject: [PATCH 22/23] modifying the readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a4c22d..22ca466 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ These shapes have been crafted with the aid of this library. ## How to Contribute -For information on how to contribute to this project, please see [CONTRIBUTING.md](CONTRIBUTING.md). +For information on how to contribute to this project, please see [CONTRIBUTING.md](CONTRIBUTING.md) file. ## License From f781c84810995e5fa15ac137d2448796e47c2285 Mon Sep 17 00:00:00 2001 From: joanita-51 Date: Fri, 27 Oct 2023 10:25:45 +0300 Subject: [PATCH 23/23] Add 'Getting Help' section to the documentation --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 22ca466..0ce4308 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,10 @@ These shapes have been crafted with the aid of this library. ![translate eclipse image](https://github.com/joanita-51/ocaml-joy/assets/82649346/70026da8-92a3-4c3f-a90a-6827b87e1b8a) ![circle grid image](https://github.com/joanita-51/ocaml-joy/assets/82649346/2d24f4a5-2d06-4091-806a-1c7b412a3ef7) --> +## Getting Help + +At any point, please don't hesitate to ask questions. You can contact the mentors either here in the issue tracker or in the #outreachy channel in [OCaml discord](https://discord.com/invite/cCYQbqN). + ## How to Contribute For information on how to contribute to this project, please see [CONTRIBUTING.md](CONTRIBUTING.md) file.