Easy drawing of basic geometric objects: SimpleDrawingObjects

There are full-featured, sophisticated Julia packages for plotting and visualization. Personally, I have found them to be so rich that they are difficult to learn and use (for me). To make drawing easier, I wrote SimpleDrawing and now offer SimpleDrawingObjects. These make drawing of basic geometric structures such as line segments, circles, and so on rather painless. Both are built on top of Plots.

For example, to draw a red circle, centered at the origin, with radius 1, and with line thickness 2, we have these choices:

Using SimpleDrawing:

draw_circle(0, 0, 1, linecolor = :red, linewidth = 2)

Using SimpleDrawingObjects:

C = Circle(0, 0, 1)
set_linewidth!(C, 2)
set_linecolor!(C, :red)
draw(C)

The advantage to the second approach is that the drawing attributes of C can be modified and then C can be redrawn.

I hope this makes other folks plotting as easy as:

using SimpleDrawing, SimpleDrawingObjects

function pie()
    s1 = Segment(0, 0, 1, 0)
    s2 = Segment(0, 0, sqrt(0.5), sqrt(0.5))
    a = Arc(0, 0, 1, 0, pi / 8, pi / 4)

    newdraw()
    draw([s1, s2, a])
end
4 Likes