Skip to content

Commit

Permalink
Add string helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jheinen committed Aug 20, 2024
1 parent a394741 commit 4555650
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/GR.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ export
inqmathfont,
setclipregion,
inqclipregion,
getformat,
ftoa,
# Convenience functions
jlgr,
colormap,
Expand Down Expand Up @@ -4451,6 +4453,24 @@ function inqclipregion()
return _region[1]
end

function getformat(origin::Real, amin::Real, amax::Real, tick::Real, major::Int)
_format = Cint[0, 0]
ccall( libGR_ptr(:gr_getformat),
Nothing,
(Ptr{Cint}, Cdouble, Cdouble, Cdouble, Cdouble, Cint),
_format, origin, amin, amax, tick, major)
return Int32[_format...]
end

function ftoa(value::Real, format::Vector{Int32})
string = Vector{UInt8}(undef, 256)
s = ccall( libGR_ptr(:gr_ftoa),
Cstring,
(Ptr{UInt8}, Cdouble, Ptr{Cint}),
string, value, format)
return unsafe_string(s)
end

function axis(which::Char; min::Real = NaN, max::Real = NaN, tick::Real = NaN, org::Real = NaN, position::Real = NaN, major_count::Int = 1, ticks::Union{Vector{GRTick}, Nothing} = nothing, tick_size::Real = NaN, tick_labels::Union{Vector{GRTickLabel}, Nothing} = nothing, label_position::Real = NaN, draw_axis_line::Int = 1)::GRAxis
c_axis = c_axis_t(min=min, max=max, tick=tick, org=org, position=position, major_count=major_count, tick_size=tick_size, label_position=label_position, draw_axis_line=draw_axis_line)
if ticks != nothing
Expand Down
2 changes: 2 additions & 0 deletions src/libgr_syms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@
:gr_inqmathfont
:gr_setclipregion
:gr_inqclipregion
:gr_getformat
:gr_ftoa
:gr_axis
:gr_drawaxis
:gr_drawaxes
Expand Down

0 comments on commit 4555650

Please sign in to comment.