letterToPolygon: Convert an image file to a polygon

Description Usage Arguments Examples

Description

Convert an image file to a polygon

Usage

1
2
3
4
5
6
7
8
9
letterToPolygon(
  ch,
  fontfamily = "Helvetica",
  fontsize = 576,
  tol = 1,
  dim = c(480, 480),
  threshold = 0.5,
  var = "red"
)

Arguments

ch

letter

fontfamily

R has a few default fonts that are always available, such as e.g. Helvetica, Arial, Courier New, and Garamond. Other fonts might be available depending on the platform used.

fontsize

by default 576. If the resulting string exceeds the boundary of the matrix returned, reduced font size

tol

tolerance

dim

vector of length two specifying width and height (in pixels) of the temporary jpg file created for the letter. Defaults to 480 x 480 pixels.

threshold

numerical cutoff between 0 and 1

var

one of "red", "green", "blue".

Examples

1
2
3
4
library(ggplot2)
letter <- letterToPolygon("R", fontfamily="Helvetica")
qplot(x, y, geom="polygon", data = letter, fill=I("black"), alpha=I(0.8))+
     coord_equal()

Example output

Attaching package: 'ggplot2'

The following object is masked from 'package:gglogo':

    fortify

gglogo documentation built on Jan. 29, 2020, 1:09 a.m.