cranvas (version 0.8.5)

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

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

one_pixel(painter)

Arguments

painter
the painter of a layer

Value

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

Examples

Run this code
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)

Run the code above in your browser using DataCamp Workspace