one_pixel: Get the relative width and height of one pixel on the screen

Description Usage Arguments Value Author(s) Examples

View source: R/utils.R

Description

This function calculates the relative size of one pixel in a layer coordinate system, since it has different relative dimensions in different coordinate systems.

Usage

1
one_pixel(painter)

Arguments

painter

the painter of a layer

Value

A numeric vector of length 2 (width and height).

Author(s)

Yihui Xie <http://yihui.name>

Examples

1
2
3
4
5
6
7
8
9
library(qtpaint)
s <- qscene()
qlayer(s, paintFun = function(layer, painter) {
    d <- one_pixel(painter)
    # one pixel segments
    qdrawSegment(painter, 0.1, seq(0, 1, 0.1), 0.1 + d[1], seq(0, 1, 0.1))
    qdrawRect(painter, 0.3, 0.4, 0.3 + d[1], 0.4 + d[2])  # one pixel rectangle
}, limits = qrect(c(0, 1), c(0, 1)))
qplotView(scene = s)

ggobi/cranvas documentation built on May 17, 2019, 3:10 a.m.