How to rotate a view

Yihui Xie edited this page Dec 18, 2010 · 1 revision

We can rotate a view by the rotate() method on the view:

library(qtpaint)
s = qscene()
n = 1000; x=rnorm(n, 50, 15); y = runif(n, 20, 80); r = runif(n, 0, 10); col = sample(colors(), n, TRUE)
test_layer = qlayer(s, function(layer, painter) {
   qdrawRect(painter, 5, 10, 95, 90, stroke = 'black')
   qdrawCircle(painter, x, y, r, stroke = col)
   qdrawText(painter, 'TEXT TEST', 50, 5)
}, limits=qrect(0,0,100,100))
v = qplotView(s)
print(v)
## rotate
v$rotate(90)
v$updateSceneGeometry()
## 45 degrees
v$rotate(45)
v$updateSceneGeometry()

Original:

Rotate by 90 degrees:

45 degrees:

Looks like the direction is clockwise.