View source: R/gspace-glyph-constructor.R
| glyph_proto | R Documentation |
Create a gs_glyph object from a static shape and its identifying
token. These prototypes form the building blocks of RGraphSpace's glyph
vocabulary (e.g. GlyphArrow).
glyph_proto(
shape,
token,
name = NULL,
draw = c("polyline", "segments", "polygon", "circle"),
offset = 0
)
## S3 method for class 'gs_glyph'
plot(x, ..., ncol = NULL, margin = 0.05, colour = "black")
shape |
A two-column numeric matrix of local points in the canonical
frame: column 1 is the coordinate along the edge (reference point at the
origin, |
token |
The |
name |
A short human-readable name shown by |
draw |
How the points are interpreted:
|
offset |
Where the edge line ends, as an x position in the glyph's
frame: |
x |
A |
... |
Further |
ncol |
Number of glyphs per row; defaults to a single row. |
margin |
Space around the glyphs, as a fraction of the page on each |
colour |
Colour used to draw the glyph preview. |
A gs_glyph object.
New glyphs are added as package contributions, not at runtime: add an
exported Glyph* object, built with glyph_proto(), to
the gspace-glyph-collection.R source file (see that file for the full
recipe). Tokens must be unique across all glyphs; conflicts are reported at
package load.
GlyphArrow, glyph_list
# a pair of vee-like shapes: a filled triangle (odd number) and its open
# form, the same outline as a closed polyline (next, even number)
m <- rbind(c(0, 0), c(-1, 0.6), c(-1, -0.6))
filled <- glyph_proto(m, token = ">91", draw = "polygon")
m <- rbind(c(-1, 0), c(-1, 0.6), c(0, 0), c(-1, -0.6), c(-1, 0))
open <- glyph_proto(m, token = ">92", draw = "polyline")
plot(filled, open)
# a pair of tee-like shapes: a filled block across the edge at the reference
# point, and its open form, the same outline as a closed polyline
m <- rbind(c(0, 0.65), c(0, -0.65), c(-0.25, -0.65), c(-0.25, 0.65))
filled <- glyph_proto(m, token = "|91", draw = "polygon")
m <- rbind(c(-0.25, 0), c(-0.25, 0.65), c(0, 0.65), c(0, -0.65),
c(-0.25, -0.65), c(-0.25, 0))
open <- glyph_proto(m, token = "|92", draw = "polyline")
plot(filled, open)
# a pair of tee-like shapes: a circle (diameter one unit) touching the
# reference point, and its open form, a ring traced as a polyline
filled <- glyph_proto(rbind(c(-0.5, 0)), token = "|93", draw = "circle")
a <- seq(0, 2 * pi, length.out = 49)
m <- cbind(-0.5 - 0.5 * cos(a), 0.5 * sin(a))
open <- glyph_proto(m, token = "|94", draw = "polyline")
plot(filled, open)
# a single open glyph: a bar across the edge at the reference point, as
# one segment
m <- rbind(c(0, 0.65), c(0, -0.65))
glyph <- glyph_proto(m, token = "|95", draw = "segments")
plot(glyph)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.