I would like to add a text annotation but would like it to wrap around a circle? For example, I can add text to anywhere in the circle. Here is an example below; I drew a blue arrow line indicating where I want the text to wrap. Is this possible? thanks in advance.
library(magick)
img <- image_read ('https://www.dropbox.com/s/g91f66zd34rhky3/template_1.png?dl=1' )
image_annotate(img, "1345678910110000000000000000000000", font = 'Times', size = 30, location = " 50 150" )
CodePudding user response:
Drawn with ggplot2 and friends. Needs some manual tweaking of text size, text spacing, or plot size to control how much of the circle it covers.
library(ggplot2); library(ggforce); library(geomtextpath)
t = seq(0, 1, length.out = 100) * pi
semi_top <- data.frame(x = cos(t),
y = sin(t),
label = "1345678910110000000000000000000000")
ggplot()
geom_circle(aes(x0=0,y0=0,r=1), fill = "gray70")
scale_x_continuous(limits = c(-1.5, 1.5))
geom_textpath(data = semi_top, aes(x,y,label = label), size = 12, vjust = 1.1)
coord_fixed(clip = "off")
theme_void()
CodePudding user response:
It can be done in Imagemagick as follows, thought not perfectly.
I create a circle image and exend it with white. Then I create text image with transparent background and -distort arc it to 180 deg. I then composite it over the circle image. Unix syntax for IM 6 follows:
convert -size 500x500 xc:white -fill gray \
-draw "circle 250,250 250,0" -alpha off \
-gravity center -background white -extent 750x750 \
\( -background none -fill black -size x100 \
label:"0123456789000000000000" -distort arc "180 0 300 250" \) \
-gravity south -geometry 0 375 -compose over -composite \
x.png