cranvas (version 0.8.5)

update_brush_size: Update the brush size in the mouse move event

Description

The brush size is changed by the differences in two successive mouse positions.

Usage

update_brush_size(meta, event)

Arguments

meta
the meta data containing the brush information (meta$pos, meta$brush.size, meta$brush.move and meta$start)
event
the event in the callback (if missing, it will search in the parent environment sys.frame(1) which is often the callback function)

Value

a matrix of the coordinates of the brush rectangle, which can be passed to qrect and used to query the brushed elements by layer$locate(); as a side effect, the brush size is updated, unless it is only a single click or the brush is not in the move mode

Details

The current mouse position is obtained from event$pos(). If the brush is in the move mode (meta$brush.move == TRUE; often set in a mouse click event), the brush size is updated by the differences between meta$start and meta$pos; the former is the starting position of the mouse, and the latter is the current position.

Examples

Run this code
## see source code of qparallel()

Run the code above in your browser using DataLab