From 5a99066fa3fa1172f20797977168741cce0a2195 Mon Sep 17 00:00:00 2001 From: "YAMAMOTO, Masayuki" Date: Fri, 29 Apr 2022 08:42:39 +0900 Subject: [PATCH] debug RuntimeError when requiring 'gr/plot'. --- lib/gr.rb | 26 ++++++++++++++++++++++++++ lib/gr/ffi.rb | 2 +- test/gr_test.rb | 6 ++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/gr.rb b/lib/gr.rb index ee97f9c1..8bc02667 100644 --- a/lib/gr.rb +++ b/lib/gr.rb @@ -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 diff --git a/lib/gr/ffi.rb b/lib/gr/ffi.rb index 868cab32..b5b28293 100644 --- a/lib/gr/ffi.rb +++ b/lib/gr/ffi.rb @@ -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 *)' diff --git a/test/gr_test.rb b/test/gr_test.rb index 5a238cf8..5bb22890 100644 --- a/test/gr_test.rb +++ b/test/gr_test.rb @@ -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