arrow conveniences

This commit is contained in:
Thomas Breloff 2016-05-10 13:57:38 -04:00
parent 678dde710b
commit a81af2b449
2 changed files with 26 additions and 2 deletions

View File

@ -605,6 +605,24 @@ function preprocessArgs!(d::KW)
# convert into strokes and brushes # convert into strokes and brushes
if haskey(d, :arrow)
a = d[:arrow]
d[:arrow] = if a == true
arrow()
elseif a == false
nothing
elseif !(typeof(a) <: Arrow)
arrow(wraptuple(a)...)
else
a
end
end
if get(d, :arrow, false) == true
d[:arrow] = arrow()
end
# legends # legends
if haskey(d, :legend) if haskey(d, :legend)
d[:legend] = convertLegendValue(d[:legend]) d[:legend] = convertLegendValue(d[:legend])

View File

@ -410,13 +410,19 @@ end
function arrow(args...) function arrow(args...)
style = :simple style = :simple
headlength = 0.3 headlength = 0.3
headwidth = 0.2 headwidth = 0.3
setlength = false
for arg in args for arg in args
T = typeof(arg) T = typeof(arg)
if T == Symbol if T == Symbol
style = arg style = arg
elseif T <: Number elseif T <: Number
headlength = headwidth = Float64(arg) # first we apply to both, but if there's more, then only change width after the first number
headwidth = Float64(arg)
if !setlength
headlength = headwidth
end
setlength = true
elseif T <: Tuple && length(arg) == 2 elseif T <: Tuple && length(arg) == 2
headlength, headwidth = Float64(arg[1]), Float64(arg[2]) headlength, headwidth = Float64(arg[1]), Float64(arg[2])
else else