basic support for arrow in GR
This commit is contained in:
parent
dfb89ef7f5
commit
bf0f44773f
@ -30,6 +30,7 @@ const _gr_attr = merge_with_base_supported([
|
|||||||
:normalize, :weights,
|
:normalize, :weights,
|
||||||
:inset_subplots,
|
:inset_subplots,
|
||||||
:bar_width,
|
:bar_width,
|
||||||
|
:arrow,
|
||||||
])
|
])
|
||||||
const _gr_seriestype = [
|
const _gr_seriestype = [
|
||||||
:path, :scatter,
|
:path, :scatter,
|
||||||
@ -131,7 +132,7 @@ gr_set_textcolor(c) = GR.settextcolorind(gr_getcolorind(cycle(c,1)))
|
|||||||
|
|
||||||
# draw line segments, splitting x/y into contiguous/finite segments
|
# draw line segments, splitting x/y into contiguous/finite segments
|
||||||
# note: this can be used for shapes by passing func `GR.fillarea`
|
# note: this can be used for shapes by passing func `GR.fillarea`
|
||||||
function gr_polyline(x, y, func = GR.polyline)
|
function gr_polyline(x, y, func = GR.polyline; arrow=false)
|
||||||
iend = 0
|
iend = 0
|
||||||
n = length(x)
|
n = length(x)
|
||||||
while iend < n-1
|
while iend < n-1
|
||||||
@ -159,6 +160,9 @@ function gr_polyline(x, y, func = GR.polyline)
|
|||||||
# if we found a start and end, draw the line segment, otherwise we're done
|
# if we found a start and end, draw the line segment, otherwise we're done
|
||||||
if istart > 0 && iend > 0
|
if istart > 0 && iend > 0
|
||||||
func(x[istart:iend], y[istart:iend])
|
func(x[istart:iend], y[istart:iend])
|
||||||
|
if arrow
|
||||||
|
GR.drawarrow(x[iend-1], y[iend-1], x[iend], y[iend])
|
||||||
|
end
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -764,7 +768,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
# draw the line(s)
|
# draw the line(s)
|
||||||
if st == :path
|
if st == :path
|
||||||
gr_set_line(series[:linewidth], series[:linestyle], series[:linecolor]) #, series[:linealpha])
|
gr_set_line(series[:linewidth], series[:linestyle], series[:linecolor]) #, series[:linealpha])
|
||||||
gr_polyline(x, y)
|
gr_polyline(x, y; arrow = isa(series[:arrow], Arrow))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user