Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Curved vector graphics using paths

Tags:

r

graphics

When drawing curved shapes in R, they are typically made up of a collection of short straight line segments (with circular line endings). The result looks good to the human eye but is a bit of a roundabout way of doing it as you need to interpolate the curve to get the coordinates of the segments. It also produces unnecessarily large files, although this is not a big problem unless the plot contains an extreme amount of curves.

Is there a way to create curved vector shapes the proper way using paths made up of anchor and pivot points as in the figure below?

enter image description here

like image 468
Backlin Avatar asked Nov 28 '12 10:11

Backlin


People also ask

How do I curve an SVG?

An SVG quadratic curve will probably suffice. To draw it, you need the end points (which you have) and a control point which will determine the curve. To make a symmetrical curve, the control point needs to be on the perpendicular bisector of the line between the end points.

What are paths in vector graphics?

In graphics design, a vector path is a drawn or generated outline that represents a series of smooth straight (vector) lines instead of raster dots (or bitmap dots). Therefore, the paths are independent of resolution.

What is curved path in Photoshop?

Using Curves in Photoshop Elements If you're using Photoshop Elements, you won't be able to create a Curves adjustment layer, but there is a similar tool you can use. To access this tool, select Enhance > Adjust Color > Adjust Color Curves. You can then click and drag the sliders to adjust the curve.


1 Answers

Short answer: "No".

Long answer: R doesn't know if your output device supports describing curves from formulae - for example PDF and PostScript can (I think) have arcs and curves, but R doesn't know if its drawing to one of those or to a bitmap device.

Hence when you want to draw an arc on an R plot, it can't do:

0 0 moveto
25 25 pi arcto

(or whatever the PostScript is) to describe an arc that will be infinitely smoothly zoomable. It has to render the arc into segments.

If you run the example in help(bezierGrob) to a PDF device and zoom in, you can see the segments (zoomed in to 500%).

like image 64
Spacedman Avatar answered Sep 18 '22 21:09

Spacedman