[RQt-devel] segment glyph

Yihui Xie xieyihui at gmail.com
Thu Oct 21 00:18:42 CEST 2010


Hi,

I want to define a glyph which is a short segment as follows, but when
the slope b=0, the glyph looks weird on screen (it is a filled
square); other slopes are fine. I don't know what's going on:

library(qtpaint)
## x: length; b: slope
qglyphSegment <- function(x = 5, b = 0) {
  glyph <- Qt$QPainterPath()
  x0 <- x * cos(atan(b))
  y0 <- x * sin(atan(b))
  glyph$moveTo(-x0, -y0)
  glyph$lineTo(x0, y0)
#  glyph$closeSubpath()
  glyph
}

s <- qscene()
test_layer <- qlayer(s, function(layer, painter) {
    qdrawGlyph(painter, qglyphSegment(), 1:10, .5, stroke = 'black')
    qdrawGlyph(painter, qglyphSegment(10, 1), 1:10, .7, stroke = 'black')
    qdrawGlyph(painter, qglyphSegment(10, -1), 1:10, .3, stroke = 'black')
}, limits=qrect(0,0,11,1))
qplotView(s)
## see the screenshot attached


Thanks!

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: glyphSegment.png
Type: image/png
Size: 2777 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/qtinterfaces-devel/attachments/20101020/d878c5e0/attachment.png>


More information about the Qtinterfaces-devel mailing list