File: shadowtext.R

package info (click to toggle)
r-cran-teachingdemos 2.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,168 kB
  • sloc: makefile: 2
file content (17 lines) | stat: -rw-r--r-- 552 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
shadowtext <- function(x, y=NULL, labels, col='white', bg='black',
	theta= seq(pi/32, 2*pi, length.out=64), r=0.1, cex=1, ... ) {

	xy <- xy.coords(x,y)
	fx <- grconvertX(xy$x, to='nfc')
	fy <- grconvertY(xy$y, to='nfc')
	fxo <- r*strwidth('A', units='figure', cex=cex)
	fyo <- r*strheight('A', units='figure', cex=cex)
	
	for (i in theta) {
	  text(grconvertX(fx + cos(i)*fxo, from="nfc"),
	       grconvertY(fy + sin(i)*fyo, from="nfc"),
	       labels, cex=cex, col=bg, ...)
	}
	text(xy$x, xy$y, labels, cex=cex, col=col, ... ) 
}