From f19ed443087cf52a7e405520bf332785be7d4a32 Mon Sep 17 00:00:00 2001 From: Jonathan Busch Date: Sun, 8 Jan 2023 20:19:56 +0100 Subject: [PATCH 1/2] add cubic curves --- src/Graphics.jl | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Graphics.jl b/src/Graphics.jl index 3f5bf67..a732554 100644 --- a/src/Graphics.jl +++ b/src/Graphics.jl @@ -29,7 +29,7 @@ Graphics defines an API for drawing in two dimensions. - Clipping: `clip`, `clip_preserve`, `reset_clip`, `inner_canvas` -- Paths: `move_to`, `line_to`, `rel_line_to`, `rel_move_to`, +- Paths: `move_to`, `line_to`, `curve_to`, `rel_curve_to`, `rel_line_to`, `rel_move_to`, `new_path`, `new_sub_path`, `close_path`, `arc` - High-level paths: `rectangle`, `circle`, `polygon` @@ -71,7 +71,7 @@ export clip, clip_preserve, reset_clip, inner_canvas, # path primitives - move_to, line_to, rel_line_to, rel_move_to, new_path, new_sub_path, + move_to, line_to, curve_to, rel_curve_to, rel_line_to, rel_move_to, new_path, new_sub_path, close_path, arc, # fill and stroke @@ -722,6 +722,24 @@ See also: [`rel_line_to`](@ref). """ @mustimplement line_to(gc::GraphicsContext, ::Real, ::Real) +""" +curve_to(gc::GraphicsContext, c1x, c1y, c2x, c2y, x, y) + +Add a cubic bezier curve to the path. The control points will be the current point, `(c1x, c1y)`, `(c2x, c2y)` and `(x, y)`. The current point will be moved to `(x, y)`. + +See also: [`rel_curve_to`](@ref). +""" +@mustimplement curve_to(gc::GraphicsContext, ::Real, ::Real, ::Real, ::Real, ::Real, ::Real) + +""" +rel_curve_to(gc::GraphicsContex, Δc1x, Δc1y, Δc2x, Δc2y, Δx, Δy) + +Add a cubic bezier curve to the path. The control points will be the current point `(x, y)` and `(x, y) + [(Δc1x, Δc1y), (Δc2x, Δc2y), (Δx, Δy)]`. The current point will be moved to `(x + Δx, y + Δy)`. + +See also: [`curve_to`](@ref). +""" +@mustimplement rel_curve_to(gc::GraphicsContext, ::Real, ::Real, ::Real, ::Real, ::Real, ::Real) + """ rel_move_to(gc::GraphicsContext, Δx, Δy) From 33fa943c572d0315b18c1241d67dd0a63a36746e Mon Sep 17 00:00:00 2001 From: Jonathan Busch Date: Fri, 18 Jul 2025 12:23:15 +0200 Subject: [PATCH 2/2] fix formatting --- src/Graphics.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Graphics.jl b/src/Graphics.jl index a732554..d6c1338 100644 --- a/src/Graphics.jl +++ b/src/Graphics.jl @@ -723,7 +723,7 @@ See also: [`rel_line_to`](@ref). @mustimplement line_to(gc::GraphicsContext, ::Real, ::Real) """ -curve_to(gc::GraphicsContext, c1x, c1y, c2x, c2y, x, y) + curve_to(gc::GraphicsContext, c1x, c1y, c2x, c2y, x, y) Add a cubic bezier curve to the path. The control points will be the current point, `(c1x, c1y)`, `(c2x, c2y)` and `(x, y)`. The current point will be moved to `(x, y)`. @@ -732,7 +732,7 @@ See also: [`rel_curve_to`](@ref). @mustimplement curve_to(gc::GraphicsContext, ::Real, ::Real, ::Real, ::Real, ::Real, ::Real) """ -rel_curve_to(gc::GraphicsContex, Δc1x, Δc1y, Δc2x, Δc2y, Δx, Δy) + rel_curve_to(gc::GraphicsContex, Δc1x, Δc1y, Δc2x, Δc2y, Δx, Δy) Add a cubic bezier curve to the path. The control points will be the current point `(x, y)` and `(x, y) + [(Δc1x, Δc1y), (Δc2x, Δc2y), (Δx, Δy)]`. The current point will be moved to `(x + Δx, y + Δy)`.