Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug RuntimeError when requiring 'gr/plot'. #66

Merged
merged 1 commit into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions lib/gr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,32 @@ def inqtext(x, y, string)
end
end

# Draw a text at position `x`, `y` using the given options and current text
# attributes.
#
# @param x [Numeric] The X coordinate of the starting position of the text string
# @param y [Numeric] The Y coordinate of the starting position of the text string
# @param string [String] The text to be drawn
# @param opts [Integer] Bit mask including text options (GR_TEXT_USE_WC,
# GR_TEXT_ENABLE_INLINE_MATH)
#
# The values for `x` and `y` specify the text position. If the GR_TEXT_USE_WC
# option is set, they are interpreted as world cordinates, otherwise as
# normalized device coordinates. The string may contain new line characters
# and inline math expressions ($...$). The latter are only taken into account,
# if the GR_TEXT_ENABLE_INLINE_MATH option is set.
# The attributes that control the appearance of text are text font and
# precision, character expansion factor, character spacing, text color index,
# character height, character up vector, text path and text alignment.
#
# @!method text

def inqtextx(x, y, string, opts)
inquiry [{ double: 4 }, { double: 4 }] do |tbx, tby|
super(x, y, string, opts, tbx, tby)
end
end

# Allows you to specify a polygonal shape of an area to be filled.
#
# @param x [Array, NArray] A list containing the X coordinates
Expand Down
2 changes: 1 addition & 1 deletion lib/gr/ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module FFI
try_extern 'void gr_text(double, double, char *)'
try_extern 'void gr_textx(double, double, char *, int)'
try_extern 'void gr_inqtext(double, double, char *, double *, double *)'
try_extern 'gr_inqtextx(double, double, char *, int, double *, double *)'
try_extern 'void gr_inqtextx(double, double, char *, int, double *, double *)'
try_extern 'void gr_fillarea(int, double *, double *)'
try_extern 'void gr_cellarray(double, double, double, double, ' \
'int, int, int, int, int, int, int *)'
Expand Down
6 changes: 6 additions & 0 deletions test/gr_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ def test_inqtext
assert_kind_of Array, GR.inqtext(0, 0, 'Ruby')
end

def test_inqtextx
assert_kind_of Array, GR.inqtextx(0, 0, 'Ruby',
GR::TEXT_ENABLE_INLINE_MATH | \
GR::TEXT_USE_WC)
end

def test_linetype
assert_nil GR.setlinetype(3)
assert_equal 3, GR.inqlinetype
Expand Down