pointToPoly: Convert points to polygons

Description Usage Arguments Value Shape scaling

Description

Converts a vector of coordinate points to a data object that can be drawn with polygon. It calculate the values need to plot the points as polygons specified by shape. Currently only triangles pointing up and triangles pointing down can be specified. Each point can be described separately by passing in a vector for the shapes parameter. Other than x and y coordinates of the points to plot and the two scale paramters, provided values will be wrapped as needed.

Usage

1
2
3
pointToPoly(x, y, widths = 20, heights = 20, shapes = "triangleDown",
  sides = 5, fillColors = "red", borderColors = "black", scale = c(4,
  1), resScale = c(1, 1))

Arguments

x

The x plot coordinates where the the poly-points should be drawn

y

The y plot coordinates where the the poly-points should be drawn

widths

The widths in plot coordinates of the poly-points. Default = 5.

heights

The height in plot coordinates of the poly-points. Default = 5.

shapes

The shape of the poly-point. Allowed shapes are 'triangleDown' (the default) and 'triangleUp'.

sides

The position of the poly-points over the coordinate point. Can have a value from 1-9, oriented like a 3 x 3 touch pad, 1 has uper left corner of poly as the point, 5 has the middle over the point, and 9 has the lower right as the point. Default = 5, centered.

fillColors

The colors filling the poly-point. Default = 'red'.

borderColors

The colors of the poly-point borders. Default = 'black'.

scale

The scale factor of the x and y axis of the plot, i.e if plot is 100x500, scale should be c(1,5) or c(0.2,1). By default this is c(1,1).

resScale

The scale factor of the device, i.e. if the screen resolution is 1024x768, this should be c(1,1024/768) or c(768/1024,1). By default this is c(1,1).

Value

Returns a list with the data needed to plot the points as polygons. The elements of the list are:

count number of points plotted as polygons
xRadii 1/2 widths of points, after wrapping
yRadii 1/2 heights of points, after wrapping
shapes The shapes parameter, after wrapping
sides The sides parameter, after wrapping
fillColors The fillColors parameter, after wrapping
borderColors The borderColors parameter, after wrapping
x X coordinates of polygons to draw, NA separated
y Y coordinates of polygons to draw, NA separated
xRange lowest and highest x value drawn
yRange lowest and highest y values drawn

Shape scaling

The shape of a pixel is not necessarily square, so a square of 10 x 10 pixels may not be square but instead rectangular. To make the polygon shapes come out symetrical, the relative heights and widths of the pixels must be specified. This is the purpose of the scale and resScale parameters. Two parameters are provided to allow specifying the plot scaling ratio and the screen resolution scaling ratio separately.


jefferys/FusionExpressionPlot documentation built on May 19, 2019, 3:59 a.m.