Skip to content

Commit

Permalink
debug RuntimeError when requiring 'gr/plot'.
Browse files Browse the repository at this point in the history
  • Loading branch information
mephistobooks authored and kojix2 committed Apr 29, 2022
1 parent 1fd7276 commit 5a99066
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
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

0 comments on commit 5a99066

Please sign in to comment.