Skip to content

Commit

Permalink
still experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
wjschne committed Oct 2, 2024
1 parent db84446 commit 6cde162
Show file tree
Hide file tree
Showing 156 changed files with 31,406 additions and 546 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export(resect)
export(rotate)
export(round_probability)
export(set_props)
export(shape_array)
export(ob_array)
export(subscript)
export(superscript)
export(turn)
Expand Down
4 changes: 2 additions & 2 deletions R/a_early.R
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ ob_covariance <- new_generic(
#' @param anchor bounding box anchor
#' @param ... <[`dynamic-dots`][rlang::dyn-dots]> properties passed to shape
#' @export
shape_array <- new_generic(name = "make_array", dispatch_args = "x", fun = function(x, k = 2, sep = 1, where = "east", anchor = "center", ...) {
ob_array <- new_generic(name = "ob_array", dispatch_args = "x", fun = function(x, k = 2, sep = 1, where = "east", anchor = "center", ...) {
S7_dispatch()
})

Expand Down Expand Up @@ -514,7 +514,7 @@ replace_na <- function(x, y) {


#' @keywords internal
shape_array_helper <- function(x, k = 2, sep = 1, where = "east", anchor = "center", ...) {
ob_array_helper <- function(x, k = 2, sep = 1, where = "east", anchor = "center", ...) {
if (x@length > 1) stop("The shape must start with an object of length 1.")

dots <- rlang::list2(...)
Expand Down
4 changes: 2 additions & 2 deletions R/circles.R
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ method(place, list(ob_line, ob_circle)) <- function(x, from, where = "right", se
from@tangent_at(where)
}

method(shape_array, ob_circle) <- function(x, k = 2, sep = 1, where = "east", anchor = "center", ...) {
method(ob_array, ob_circle) <- function(x, k = 2, sep = 1, where = "east", anchor = "center", ...) {
# s <- seq(0, (sep + x@radius) * (k - 1), sep + x@radius)
# px <- cos(degree(where)) * s
# py <- sin(degree(where)) * s
Expand All @@ -325,7 +325,7 @@ method(shape_array, ob_circle) <- function(x, k = 2, sep = 1, where = "east", an
# }
# ob_circle(p@center - p_anchor + x@center, style = x@style, ...)

sa <- shape_array_helper(x = x, k = k, sep = sep, where = where, anchor = anchor, ...)
sa <- ob_array_helper(x = x, k = k, sep = sep, where = where, anchor = anchor, ...)

rlang::inject(ob_circle(center = sa$p_center,
radius = x@radius,
Expand Down
4 changes: 2 additions & 2 deletions R/ellipses.R
Original file line number Diff line number Diff line change
Expand Up @@ -654,9 +654,9 @@ method(place, list(ob_line, ob_ellipse)) <- function(x, from, where = "right", s



method(shape_array, ob_ellipse) <- function(x, k = 2, sep = 1, where = "east", anchor = "center", ...) {
method(ob_array, ob_ellipse) <- function(x, k = 2, sep = 1, where = "east", anchor = "center", ...) {

sa <- shape_array_helper(x = x, k = k, sep = sep, where = where, anchor = anchor, ...)
sa <- ob_array_helper(x = x, k = k, sep = sep, where = where, anchor = anchor, ...)

rlang::inject(ob_ellipse(sa$p_center,
a = x@a,
Expand Down
2 changes: 1 addition & 1 deletion R/points.R
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ method(nudge, list(ob_point, class_missing, class_numeric)) <- function(object,
object + ob_point(0, y)
}

method(shape_array, ob_point) <- function(x, k = 2, sep = 1, where = "east", anchor = "center", ...) {
method(ob_array, ob_point) <- function(x, k = 2, sep = 1, where = "east", anchor = "center", ...) {
s <- seq(0, sep * (k - 1), sep)
px <- cos(degree(where)) * s
py <- sin(degree(where)) * s
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

The ggdiagram package takes an object-oriented approach to making diagrams and plots the results using [ggplot2](https://ggplot2.tidyverse.org/).

This package is in the early stages of construction. It has some structural beams and a bit of plumbing but is not yet capable of fulfilling its eventual purpose.
This package is still experimental, and functions are likely to change in many ways. Every time I run into speed bumps or inconveniences as I use the program in practice, I adapt it to anticipate user needs.

My motivation in making ggdiagram was to find a way to approach the functionality of TikZ but with the flexibility and convenience of R. The ggdiagram package is built atop [S7](https://rconsortium.github.io/S7/) and is integrated with [ggplot2](https://ggplot2.tidyverse.org/), making heavy use of [ggtext](https://wilkelab.org/ggtext/), [ggforce](https://ggforce.data-imaginist.com/), and [ggarrow](https://teunbrand.github.io/ggarrow/).

Expand Down

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Loading

0 comments on commit 6cde162

Please sign in to comment.