Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cj-holmes committed Aug 8, 2022
1 parent fdc7f08 commit 44ca2e7
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 19 deletions.
7 changes: 4 additions & 3 deletions R/cuboid_image.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#' @description
#' `r lifecycle::badge('experimental')`
#'
#' Convert image pixels into cuboids that are raised from the ground plane and view as isometric projection (by default)
#' Convert image pixels into cuboids that are raised from the ground plane and viewed isometrically (by default)
#'
#' @details
#' By default cuboids are raised in proportion to pixel brightness on a scale between 1 and 10.
#' If angles a1 and a2 are changed from their default values, the view will no longer by isometric.
#' Shading of the cuboid faces is also done naively - it's a simple reduction in brightness, so there is no clever physics going on here!
#' Some further reading on the Mitchell-Netravali resize filter https://www.cs.utexas.edu/~fussell/courses/cs384g-fall2013/lectures/mitchell/Mitchell.pdf and here https://legacy.imagemagick.org/Usage/filter/#mitchell
#'
Expand All @@ -20,8 +21,8 @@
#' @param orientation orientation of the image prior to being projected (1, 2, 3 or 4) (default = 1)
#' @param crop_square crop image to a square (default = TRUE)
#' @param crop_gravity gravity of square crop if \code{crop_square = TRUE} (value from \code{magick::gravity_types()})
#' @param a1 angle of rotation around the vertical axis in degrees (default = 45)
#' @param a2 angle of rotation around the horizontal axis in degrees (default = asin(tan(pi/6))*(180/pi) ~35.264)
#' @param a1 angle of rotation around the vertical axis in degrees (default = 45) (default a1 and a2 give isometric view)
#' @param a2 angle of rotation around the horizontal axis in degrees (default = asin(tan(pi/6))*(180/pi) ~35.264) (default a1 and a2 give isometric view)
#' @param shading a vector of 3 numbers between 0 and 1. The amount of shading applied to each cuboid face. Order is top, left, right. (Default = c(0, 0.25, 0.5))
#' @param return_data return dataframe instead of image (default = FALSE)
#' @param show_axes show axes on the output image? (default = TRUE)
Expand Down
7 changes: 4 additions & 3 deletions R/cuboid_matrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
#' @description
#' `r lifecycle::badge('experimental')`
#'
#' Convert a numeric matrix into cuboids that are raised from the ground plane and view as isometric projection (by default)
#' Convert a numeric matrix into cuboids that are raised from the ground plane and viewed isometrically (by default)
#'
#' @details
#' Shading of the cuboid faces is done naively - it's a simple reduction in brightness, so there is no clever physics going on here!
#' If angles a1 and a2 are changed from their default values, the view will no longer by isometric.
#'
#' @param mat a matrix
#' @param cuboid_fill a vector of colours to be mapped to cuboid height (for images this defaults to the original pixel colour)
#' @param cuboid_col a colour for the cuboid stroke outline
#' @param orientation orientation of the output (1, 2, 3 or 4) (default = 1)
#' @param a1 angle of rotation around the vertical axis in degrees (default = 45)
#' @param a2 angle of rotation around the horizontal axis in degrees (default = asin(tan(pi/6))*(180/pi) ~35.264)
#' @param a1 angle of rotation around the vertical axis in degrees (default = 45) (default a1 and a2 give isometric view)
#' @param a2 angle of rotation around the horizontal axis in degrees (default = asin(tan(pi/6))*(180/pi) ~35.264) (default a1 and a2 give isometric view)
#' @param shading a vector of 3 numbers between 0 and 1. The amount of shading applied to each cuboid face. Order is top, left, right. (Default = c(0, 0.25, 0.5))
#' @param return_data return dataframe instead of image (default = FALSE)
#' @param show_axes show axes on the output image? (default = TRUE)
Expand Down
5 changes: 2 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ image_read(i)
```

## Defaults
By default, images are resized to be 60 cuboids wide `res = 60` and rendered at isometric projection angles. Cuboid heights are mapped to the brightness value of their corresponding pixel and scaled to range between 1 and 10 units high
By default, images are resized to be 60 cuboids wide `res = 60` and rendered as an isometric view. Cuboid heights are mapped to the brightness value of their corresponding pixel and scaled to range between 1 and 10 units high
```{r out.width = "75%"}
cuboid_image(i)
```
Expand Down Expand Up @@ -185,8 +185,7 @@ Various functions of the x and z coordinates
cuboid_image(i2,
height_map = sin(scales::rescale(x,c(0,4*pi))),
crop_square = FALSE,
height_scale = c(1, 10)
)
height_scale = c(1, 10))
cuboid_image(i2,
height_map = z^3,
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ image_read(i)
## Defaults

By default, images are resized to be 60 cuboids wide `res = 60` and
rendered at isometric projection angles. Cuboid heights are mapped to
the brightness value of their corresponding pixel and scaled to range
rendered as an isometric view. Cuboid heights are mapped to the
brightness value of their corresponding pixel and scaled to range
between 1 and 10 units high

``` r
Expand Down Expand Up @@ -238,8 +238,7 @@ Various functions of the x and z coordinates
cuboid_image(i2,
height_map = sin(scales::rescale(x,c(0,4*pi))),
crop_square = FALSE,
height_scale = c(1, 10)
)
height_scale = c(1, 10))

cuboid_image(i2,
height_map = z^3,
Expand Down
7 changes: 4 additions & 3 deletions man/cuboid_image.Rd

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

7 changes: 4 additions & 3 deletions man/cuboid_matrix.Rd

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

Binary file modified man/figures/README-unnamed-chunk-12-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 44ca2e7

Please sign in to comment.