I wish to use gganimate and tweener to morph some letters into other letters. Thus, I need a dataframe of x, y coordinates for each letter in a word as input to ggplot.
I'm not really sure how to do this, but my thinking is that library(grImport) may help.
I created a Postscript file of the word "hello" by printing and then saving the output to Postscript. It's here.
This code reads hello.ps
library(grImport)
PostScriptTrace("figures/hello.ps", "hello.xml")
hello <- readPicture("hello.xml")
grid.picture(hello)
hello is an S4 class object.
Am I correct in thinking that the structure of hello holds x,y coordinates for each letter of the the word "hello"?
If so, how do I extract those coordinates?
For the record the solution is:
# Extract x, y coordinates of path from S4 object of class Picture
# letters[i], i is the index into the word, "hello".
x <- hello@paths$text@letters[2]$path@x
y <- hello@paths$text@letters[2]$path@y