gosu 1.0.0.pre2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee520b114c06651017a9aac042728e418654c2721bd483fe3de6c44be2acc1de
4
- data.tar.gz: 2da43a5b2e1a19d45e1be85acceb48210c70a9fb866e03ca392c6232c8e89186
3
+ metadata.gz: 9c9b393a63015707256dca78e9079b01dbc004d85b89c6bf68d021085f65a905
4
+ data.tar.gz: 60396892082e2fa81a7ab03f8662fe00630745f84b1e0a47e9abcd7bed5c7692
5
5
  SHA512:
6
- metadata.gz: af2d2f9ac8121b4edae0ab5fd2bdd9aa69c0209741ae2af4dabc99419ab0ba9520c0dafa51640132db79c1496f2993f40ab000c475e562d079b59fdecd3227e7
7
- data.tar.gz: 0ee8ff41e302362370ed40d2d640444a89a232ddd35a072d4c038941b6412ea7662d06ea5acdabe8ffc1739ca73aade3d88ec0b4090bb7db8023b5ec777f97d2
6
+ metadata.gz: fb477140be8f524abfeb3694277bd815690c4c0ae432ac011956a43640f49309aca3c0a9b3619c17cc83461ae5c9c9b6fb1bfa155e72f1be19b4f166e23b3022
7
+ data.tar.gz: 24707e94f193a4fe949a447a01b732057860eb271a8a0d61ba6c45a0b1b5da8c2894ffc65d3ff3fe2b97fe7e8b9c5b38b9995d4d443d014fe6059f520f900393
@@ -40,7 +40,7 @@ namespace Gosu
40
40
 
41
41
  //! Returns the width, in pixels, the given text would occupy if drawn.
42
42
  double text_width(const std::string& text) const;
43
- //! Returns the width, in pixels, the given text would occupy if drawn.
43
+ //! Returns the width, in pixels, the given markup would occupy if drawn.
44
44
  double markup_width(const std::string& markup) const;
45
45
 
46
46
  //! Draws text so the top left corner of the text is at (x; y).
@@ -18,26 +18,12 @@ class ::Numeric
18
18
  end
19
19
  end
20
20
 
21
- class Gosu::Font
22
- # draw_text will stop parsing markup in Gosu 1.0.
23
- alias_method :draw_text, :draw_markup
24
- # draw_text_rel will stop parsing markup in Gosu 1.0.
25
- alias_method :draw_text_rel, :draw_markup_rel
26
- # text_width will stop parsing markup in Gosu 1.0.
27
- alias_method :text_width, :markup_width
28
- end
29
-
30
21
  class Gosu::Image
31
22
  BlobHelper = Struct.new(:columns, :rows, :to_blob)
32
23
 
33
24
  def self.from_blob(width, height, rgba = "\0\0\0\0" * (width * height))
34
25
  self.new(BlobHelper.new(width, height, rgba))
35
26
  end
36
-
37
- # from_markup will stop parsing markup in Gosu 1.0.
38
- def self.from_markup(*args)
39
- self.from_text(*args)
40
- end
41
27
  end
42
28
 
43
29
  # Color constants.
@@ -3,8 +3,6 @@ warn "gosu/preview.rb has been removed in Gosu 0.9.0, and Gosu itself \n" +
3
3
  "Notable differences:\n" +
4
4
  "• no global $window variable\n" +
5
5
  "• no global Gosu.mouse_x and Gosu.mouse_y functions\n" +
6
- "• Image#initialize et.al. use an options hash now\n" +
7
- "If you cannot update your code base right now, you should require \n" +
8
- "Gosu 0.8.x in your Gemfile: gem 'gosu', '~> 0.8.0'";
6
+ "• Image#initialize et.al. use an options hash now";
9
7
 
10
8
  require 'gosu'
@@ -2856,11 +2856,19 @@ SWIGINTERN Gosu::Font *new_Gosu_Font__SWIG_1(int height,VALUE options=0){
2856
2856
 
2857
2857
  return new Gosu::Font(height, font_name, font_flags);
2858
2858
  }
2859
+ SWIGINTERN double Gosu_Font_text_width(Gosu::Font *self,std::string const &markup,double scale_x=1.0){
2860
+ static bool issued_warning = false;
2861
+ if (scale_x != 1.0 && !issued_warning) {
2862
+ issued_warning = true;
2863
+ rb_warn("The second argument to Gosu::Font#text_width is deprecated, multiply the result instead");
2864
+ }
2865
+ return self->text_width(markup) * scale_x;
2866
+ }
2859
2867
  SWIGINTERN double Gosu_Font_markup_width(Gosu::Font *self,std::string const &markup,double scale_x=1.0){
2860
2868
  static bool issued_warning = false;
2861
2869
  if (scale_x != 1.0 && !issued_warning) {
2862
2870
  issued_warning = true;
2863
- rb_warn("The second argument to Font#markup_width and Font#text_width is deprecated, multiply the result instead");
2871
+ rb_warn("The second argument to Gosu::Font#markup_width is deprecated, multiply the result instead");
2864
2872
  }
2865
2873
  return self->markup_width(markup) * scale_x;
2866
2874
  }
@@ -2926,7 +2934,81 @@ SWIGINTERN Gosu::Image *Gosu_Image_subimage(Gosu::Image *self,int x,int y,int w,
2926
2934
  std::unique_ptr<Gosu::ImageData> image_data = self->data().subimage(x, y, w, h);
2927
2935
  return image_data.get() ? new Gosu::Image(std::move(image_data)) : nullptr;
2928
2936
  }
2929
- SWIGINTERN Gosu::Image *Gosu_Image_from_text(std::string const &markup,double font_height,VALUE options=0){
2937
+ SWIGINTERN Gosu::Image *Gosu_Image_from_text(std::string const &text,double font_height,VALUE options=0){
2938
+ std::string font = Gosu::default_font_name();
2939
+ int width = -1;
2940
+ double spacing = 0;
2941
+ Gosu::Alignment align = Gosu::AL_LEFT;
2942
+ unsigned image_flags = 0;
2943
+ unsigned font_flags = 0;
2944
+
2945
+ if (options) {
2946
+ Check_Type(options, T_HASH);
2947
+
2948
+ VALUE keys = rb_funcall(options, rb_intern("keys"), 0, NULL);
2949
+ int keys_size = NUM2INT(rb_funcall(keys, rb_intern("size"), 0, NULL));
2950
+
2951
+ for (int i = 0; i < keys_size; ++i) {
2952
+ VALUE key = rb_ary_entry(keys, i);
2953
+ const char* key_string = Gosu::cstr_from_symbol(key);
2954
+
2955
+ VALUE value = rb_hash_aref(options, key);
2956
+ if (!strcmp(key_string, "font")) {
2957
+ font = StringValuePtr(value);
2958
+ }
2959
+ else if (!strcmp(key_string, "bold")) {
2960
+ if (RTEST(value)) font_flags |= Gosu::FF_BOLD;
2961
+ }
2962
+ else if (!strcmp(key_string, "italic")) {
2963
+ if (RTEST(value)) font_flags |= Gosu::FF_ITALIC;
2964
+ }
2965
+ else if (!strcmp(key_string, "underline")) {
2966
+ if (RTEST(value)) font_flags |= Gosu::FF_UNDERLINE;
2967
+ }
2968
+ else if (!strcmp(key_string, "align")) {
2969
+ const char* cstr = Gosu::cstr_from_symbol(value);
2970
+
2971
+ if (!strcmp(cstr, "left")) {
2972
+ align = Gosu::AL_LEFT;
2973
+ }
2974
+ else if (!strcmp(cstr, "center")) {
2975
+ align = Gosu::AL_CENTER;
2976
+ }
2977
+ else if (!strcmp(cstr, "right")) {
2978
+ align = Gosu::AL_RIGHT;
2979
+ }
2980
+ else if (!strcmp(cstr, "justify")) {
2981
+ align = Gosu::AL_JUSTIFY;
2982
+ }
2983
+ else {
2984
+ rb_raise(rb_eArgError, "Argument passed to :align must be a valid text "
2985
+ "alignment (:left, :center, :right, :justify)");
2986
+ }
2987
+ }
2988
+ else if (!strcmp(key_string, "width")) {
2989
+ width = NUM2INT(value);
2990
+ }
2991
+ else if (!strcmp(key_string, "spacing")) {
2992
+ spacing = NUM2DBL(value);
2993
+ }
2994
+ else if (!strcmp(key_string, "retro")) {
2995
+ if (RTEST(value)) image_flags |= Gosu::IF_RETRO;
2996
+ }
2997
+ else {
2998
+ static bool issued_warning = false;
2999
+ if (!issued_warning) {
3000
+ issued_warning = true;
3001
+ rb_warn("Unknown keyword argument: :%s", key_string);
3002
+ }
3003
+ }
3004
+ }
3005
+ }
3006
+
3007
+ Gosu::Bitmap bitmap = Gosu::layout_text(text, font, font_height, spacing, width,
3008
+ align, font_flags);
3009
+ return new Gosu::Image(bitmap, image_flags);
3010
+ }
3011
+ SWIGINTERN Gosu::Image *Gosu_Image_from_markup(std::string const &markup,double font_height,VALUE options=0){
2930
3012
  std::string font = Gosu::default_font_name();
2931
3013
  int width = -1;
2932
3014
  double spacing = 0;
@@ -5281,6 +5363,134 @@ fail:
5281
5363
  }
5282
5364
 
5283
5365
 
5366
+ SWIGINTERN VALUE
5367
+ _wrap_Font_draw_text(int argc, VALUE *argv, VALUE self) {
5368
+ Gosu::Font *arg1 = (Gosu::Font *) 0 ;
5369
+ std::string *arg2 = 0 ;
5370
+ double arg3 ;
5371
+ double arg4 ;
5372
+ Gosu::ZPos arg5 ;
5373
+ double arg6 = (double) 1 ;
5374
+ double arg7 = (double) 1 ;
5375
+ Gosu::Color arg8 = (Gosu::Color) Gosu::Color::WHITE ;
5376
+ Gosu::AlphaMode arg9 = (Gosu::AlphaMode) Gosu::AM_DEFAULT ;
5377
+ void *argp1 = 0 ;
5378
+ int res1 = 0 ;
5379
+ int res2 = SWIG_OLDOBJ ;
5380
+ double val3 ;
5381
+ int ecode3 = 0 ;
5382
+ double val4 ;
5383
+ int ecode4 = 0 ;
5384
+ double val5 ;
5385
+ int ecode5 = 0 ;
5386
+ double val6 ;
5387
+ int ecode6 = 0 ;
5388
+ double val7 ;
5389
+ int ecode7 = 0 ;
5390
+
5391
+ if ((argc < 4) || (argc > 8)) {
5392
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 4)",argc); SWIG_fail;
5393
+ }
5394
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Gosu__Font, 0 | 0 );
5395
+ if (!SWIG_IsOK(res1)) {
5396
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "Gosu::Font const *","draw_text", 1, self ));
5397
+ }
5398
+ arg1 = reinterpret_cast< Gosu::Font * >(argp1);
5399
+ {
5400
+ std::string *ptr = (std::string *)0;
5401
+ res2 = SWIG_AsPtr_std_string(argv[0], &ptr);
5402
+ if (!SWIG_IsOK(res2)) {
5403
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "std::string const &","draw_text", 2, argv[0] ));
5404
+ }
5405
+ if (!ptr) {
5406
+ SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::string const &","draw_text", 2, argv[0]));
5407
+ }
5408
+ arg2 = ptr;
5409
+ }
5410
+ ecode3 = SWIG_AsVal_double(argv[1], &val3);
5411
+ if (!SWIG_IsOK(ecode3)) {
5412
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "double","draw_text", 3, argv[1] ));
5413
+ }
5414
+ arg3 = static_cast< double >(val3);
5415
+ ecode4 = SWIG_AsVal_double(argv[2], &val4);
5416
+ if (!SWIG_IsOK(ecode4)) {
5417
+ SWIG_exception_fail(SWIG_ArgError(ecode4), Ruby_Format_TypeError( "", "double","draw_text", 4, argv[2] ));
5418
+ }
5419
+ arg4 = static_cast< double >(val4);
5420
+ ecode5 = SWIG_AsVal_double(argv[3], &val5);
5421
+ if (!SWIG_IsOK(ecode5)) {
5422
+ SWIG_exception_fail(SWIG_ArgError(ecode5), Ruby_Format_TypeError( "", "Gosu::ZPos","draw_text", 5, argv[3] ));
5423
+ }
5424
+ arg5 = static_cast< Gosu::ZPos >(val5);
5425
+ if (argc > 4) {
5426
+ ecode6 = SWIG_AsVal_double(argv[4], &val6);
5427
+ if (!SWIG_IsOK(ecode6)) {
5428
+ SWIG_exception_fail(SWIG_ArgError(ecode6), Ruby_Format_TypeError( "", "double","draw_text", 6, argv[4] ));
5429
+ }
5430
+ arg6 = static_cast< double >(val6);
5431
+ }
5432
+ if (argc > 5) {
5433
+ ecode7 = SWIG_AsVal_double(argv[5], &val7);
5434
+ if (!SWIG_IsOK(ecode7)) {
5435
+ SWIG_exception_fail(SWIG_ArgError(ecode7), Ruby_Format_TypeError( "", "double","draw_text", 7, argv[5] ));
5436
+ }
5437
+ arg7 = static_cast< double >(val7);
5438
+ }
5439
+ if (argc > 6) {
5440
+ {
5441
+ if (TYPE(argv[6]) == T_FIXNUM || TYPE(argv[6]) == T_BIGNUM) {
5442
+ arg8 = Gosu::Color(NUM2ULONG(argv[6]));
5443
+ }
5444
+ else {
5445
+ void* ptr;
5446
+ int res = SWIG_ConvertPtr(argv[6], &ptr, SWIGTYPE_p_Gosu__Color, 0);
5447
+ if (!SWIG_IsOK(res)) {
5448
+ SWIG_exception_fail(SWIG_ValueError, "invalid value");
5449
+ }
5450
+ else if (ptr == nullptr) {
5451
+ SWIG_exception_fail(SWIG_ValueError, "invalid null reference of type Gosu::Color");
5452
+ }
5453
+ else {
5454
+ arg8 = *reinterpret_cast<Gosu::Color*>(ptr);
5455
+ }
5456
+ }
5457
+ }
5458
+ }
5459
+ if (argc > 7) {
5460
+ {
5461
+ const char* cstr = Gosu::cstr_from_symbol(argv[7]);
5462
+
5463
+ if (!strcmp(cstr, "default")) {
5464
+ arg9 = Gosu::AM_DEFAULT;
5465
+ }
5466
+ else if (!strcmp(cstr, "add") || !strcmp(cstr, "additive")) {
5467
+ arg9 = Gosu::AM_ADD;
5468
+ }
5469
+ else if (!strcmp(cstr, "multiply")) {
5470
+ arg9 = Gosu::AM_MULTIPLY;
5471
+ }
5472
+ else {
5473
+ SWIG_exception_fail(SWIG_ValueError, "invalid alpha mode (expected one of :default, :add, "
5474
+ ":multiply)");
5475
+ }
5476
+ }
5477
+ }
5478
+ {
5479
+ try {
5480
+ ((Gosu::Font const *)arg1)->draw_text((std::string const &)*arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
5481
+ }
5482
+ catch (const std::exception& e) {
5483
+ SWIG_exception(SWIG_RuntimeError, e.what());
5484
+ }
5485
+ }
5486
+ if (SWIG_IsNewObj(res2)) delete arg2;
5487
+ return Qnil;
5488
+ fail:
5489
+ if (SWIG_IsNewObj(res2)) delete arg2;
5490
+ return Qnil;
5491
+ }
5492
+
5493
+
5284
5494
  SWIGINTERN VALUE
5285
5495
  _wrap_Font_draw_markup(int argc, VALUE *argv, VALUE self) {
5286
5496
  Gosu::Font *arg1 = (Gosu::Font *) 0 ;
@@ -5409,6 +5619,150 @@ fail:
5409
5619
  }
5410
5620
 
5411
5621
 
5622
+ SWIGINTERN VALUE
5623
+ _wrap_Font_draw_text_rel(int argc, VALUE *argv, VALUE self) {
5624
+ Gosu::Font *arg1 = (Gosu::Font *) 0 ;
5625
+ std::string *arg2 = 0 ;
5626
+ double arg3 ;
5627
+ double arg4 ;
5628
+ Gosu::ZPos arg5 ;
5629
+ double arg6 ;
5630
+ double arg7 ;
5631
+ double arg8 = (double) 1 ;
5632
+ double arg9 = (double) 1 ;
5633
+ Gosu::Color arg10 = (Gosu::Color) Gosu::Color::WHITE ;
5634
+ Gosu::AlphaMode arg11 = (Gosu::AlphaMode) Gosu::AM_DEFAULT ;
5635
+ void *argp1 = 0 ;
5636
+ int res1 = 0 ;
5637
+ int res2 = SWIG_OLDOBJ ;
5638
+ double val3 ;
5639
+ int ecode3 = 0 ;
5640
+ double val4 ;
5641
+ int ecode4 = 0 ;
5642
+ double val5 ;
5643
+ int ecode5 = 0 ;
5644
+ double val6 ;
5645
+ int ecode6 = 0 ;
5646
+ double val7 ;
5647
+ int ecode7 = 0 ;
5648
+ double val8 ;
5649
+ int ecode8 = 0 ;
5650
+ double val9 ;
5651
+ int ecode9 = 0 ;
5652
+
5653
+ if ((argc < 6) || (argc > 10)) {
5654
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 6)",argc); SWIG_fail;
5655
+ }
5656
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Gosu__Font, 0 | 0 );
5657
+ if (!SWIG_IsOK(res1)) {
5658
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "Gosu::Font const *","draw_text_rel", 1, self ));
5659
+ }
5660
+ arg1 = reinterpret_cast< Gosu::Font * >(argp1);
5661
+ {
5662
+ std::string *ptr = (std::string *)0;
5663
+ res2 = SWIG_AsPtr_std_string(argv[0], &ptr);
5664
+ if (!SWIG_IsOK(res2)) {
5665
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "std::string const &","draw_text_rel", 2, argv[0] ));
5666
+ }
5667
+ if (!ptr) {
5668
+ SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::string const &","draw_text_rel", 2, argv[0]));
5669
+ }
5670
+ arg2 = ptr;
5671
+ }
5672
+ ecode3 = SWIG_AsVal_double(argv[1], &val3);
5673
+ if (!SWIG_IsOK(ecode3)) {
5674
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "double","draw_text_rel", 3, argv[1] ));
5675
+ }
5676
+ arg3 = static_cast< double >(val3);
5677
+ ecode4 = SWIG_AsVal_double(argv[2], &val4);
5678
+ if (!SWIG_IsOK(ecode4)) {
5679
+ SWIG_exception_fail(SWIG_ArgError(ecode4), Ruby_Format_TypeError( "", "double","draw_text_rel", 4, argv[2] ));
5680
+ }
5681
+ arg4 = static_cast< double >(val4);
5682
+ ecode5 = SWIG_AsVal_double(argv[3], &val5);
5683
+ if (!SWIG_IsOK(ecode5)) {
5684
+ SWIG_exception_fail(SWIG_ArgError(ecode5), Ruby_Format_TypeError( "", "Gosu::ZPos","draw_text_rel", 5, argv[3] ));
5685
+ }
5686
+ arg5 = static_cast< Gosu::ZPos >(val5);
5687
+ ecode6 = SWIG_AsVal_double(argv[4], &val6);
5688
+ if (!SWIG_IsOK(ecode6)) {
5689
+ SWIG_exception_fail(SWIG_ArgError(ecode6), Ruby_Format_TypeError( "", "double","draw_text_rel", 6, argv[4] ));
5690
+ }
5691
+ arg6 = static_cast< double >(val6);
5692
+ ecode7 = SWIG_AsVal_double(argv[5], &val7);
5693
+ if (!SWIG_IsOK(ecode7)) {
5694
+ SWIG_exception_fail(SWIG_ArgError(ecode7), Ruby_Format_TypeError( "", "double","draw_text_rel", 7, argv[5] ));
5695
+ }
5696
+ arg7 = static_cast< double >(val7);
5697
+ if (argc > 6) {
5698
+ ecode8 = SWIG_AsVal_double(argv[6], &val8);
5699
+ if (!SWIG_IsOK(ecode8)) {
5700
+ SWIG_exception_fail(SWIG_ArgError(ecode8), Ruby_Format_TypeError( "", "double","draw_text_rel", 8, argv[6] ));
5701
+ }
5702
+ arg8 = static_cast< double >(val8);
5703
+ }
5704
+ if (argc > 7) {
5705
+ ecode9 = SWIG_AsVal_double(argv[7], &val9);
5706
+ if (!SWIG_IsOK(ecode9)) {
5707
+ SWIG_exception_fail(SWIG_ArgError(ecode9), Ruby_Format_TypeError( "", "double","draw_text_rel", 9, argv[7] ));
5708
+ }
5709
+ arg9 = static_cast< double >(val9);
5710
+ }
5711
+ if (argc > 8) {
5712
+ {
5713
+ if (TYPE(argv[8]) == T_FIXNUM || TYPE(argv[8]) == T_BIGNUM) {
5714
+ arg10 = Gosu::Color(NUM2ULONG(argv[8]));
5715
+ }
5716
+ else {
5717
+ void* ptr;
5718
+ int res = SWIG_ConvertPtr(argv[8], &ptr, SWIGTYPE_p_Gosu__Color, 0);
5719
+ if (!SWIG_IsOK(res)) {
5720
+ SWIG_exception_fail(SWIG_ValueError, "invalid value");
5721
+ }
5722
+ else if (ptr == nullptr) {
5723
+ SWIG_exception_fail(SWIG_ValueError, "invalid null reference of type Gosu::Color");
5724
+ }
5725
+ else {
5726
+ arg10 = *reinterpret_cast<Gosu::Color*>(ptr);
5727
+ }
5728
+ }
5729
+ }
5730
+ }
5731
+ if (argc > 9) {
5732
+ {
5733
+ const char* cstr = Gosu::cstr_from_symbol(argv[9]);
5734
+
5735
+ if (!strcmp(cstr, "default")) {
5736
+ arg11 = Gosu::AM_DEFAULT;
5737
+ }
5738
+ else if (!strcmp(cstr, "add") || !strcmp(cstr, "additive")) {
5739
+ arg11 = Gosu::AM_ADD;
5740
+ }
5741
+ else if (!strcmp(cstr, "multiply")) {
5742
+ arg11 = Gosu::AM_MULTIPLY;
5743
+ }
5744
+ else {
5745
+ SWIG_exception_fail(SWIG_ValueError, "invalid alpha mode (expected one of :default, :add, "
5746
+ ":multiply)");
5747
+ }
5748
+ }
5749
+ }
5750
+ {
5751
+ try {
5752
+ ((Gosu::Font const *)arg1)->draw_text_rel((std::string const &)*arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11);
5753
+ }
5754
+ catch (const std::exception& e) {
5755
+ SWIG_exception(SWIG_RuntimeError, e.what());
5756
+ }
5757
+ }
5758
+ if (SWIG_IsNewObj(res2)) delete arg2;
5759
+ return Qnil;
5760
+ fail:
5761
+ if (SWIG_IsNewObj(res2)) delete arg2;
5762
+ return Qnil;
5763
+ }
5764
+
5765
+
5412
5766
  SWIGINTERN VALUE
5413
5767
  _wrap_Font_draw_markup_rel(int argc, VALUE *argv, VALUE self) {
5414
5768
  Gosu::Font *arg1 = (Gosu::Font *) 0 ;
@@ -5766,6 +6120,62 @@ fail:
5766
6120
  }
5767
6121
 
5768
6122
 
6123
+ SWIGINTERN VALUE
6124
+ _wrap_Font_text_width(int argc, VALUE *argv, VALUE self) {
6125
+ Gosu::Font *arg1 = (Gosu::Font *) 0 ;
6126
+ std::string *arg2 = 0 ;
6127
+ double arg3 = (double) 1.0 ;
6128
+ void *argp1 = 0 ;
6129
+ int res1 = 0 ;
6130
+ int res2 = SWIG_OLDOBJ ;
6131
+ double val3 ;
6132
+ int ecode3 = 0 ;
6133
+ double result;
6134
+ VALUE vresult = Qnil;
6135
+
6136
+ if ((argc < 1) || (argc > 2)) {
6137
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
6138
+ }
6139
+ res1 = SWIG_ConvertPtr(self, &argp1,SWIGTYPE_p_Gosu__Font, 0 | 0 );
6140
+ if (!SWIG_IsOK(res1)) {
6141
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "Gosu::Font *","text_width", 1, self ));
6142
+ }
6143
+ arg1 = reinterpret_cast< Gosu::Font * >(argp1);
6144
+ {
6145
+ std::string *ptr = (std::string *)0;
6146
+ res2 = SWIG_AsPtr_std_string(argv[0], &ptr);
6147
+ if (!SWIG_IsOK(res2)) {
6148
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "std::string const &","text_width", 2, argv[0] ));
6149
+ }
6150
+ if (!ptr) {
6151
+ SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::string const &","text_width", 2, argv[0]));
6152
+ }
6153
+ arg2 = ptr;
6154
+ }
6155
+ if (argc > 1) {
6156
+ ecode3 = SWIG_AsVal_double(argv[1], &val3);
6157
+ if (!SWIG_IsOK(ecode3)) {
6158
+ SWIG_exception_fail(SWIG_ArgError(ecode3), Ruby_Format_TypeError( "", "double","text_width", 3, argv[1] ));
6159
+ }
6160
+ arg3 = static_cast< double >(val3);
6161
+ }
6162
+ {
6163
+ try {
6164
+ result = (double)Gosu_Font_text_width(arg1,(std::string const &)*arg2,arg3);
6165
+ }
6166
+ catch (const std::exception& e) {
6167
+ SWIG_exception(SWIG_RuntimeError, e.what());
6168
+ }
6169
+ }
6170
+ vresult = SWIG_From_double(static_cast< double >(result));
6171
+ if (SWIG_IsNewObj(res2)) delete arg2;
6172
+ return vresult;
6173
+ fail:
6174
+ if (SWIG_IsNewObj(res2)) delete arg2;
6175
+ return Qnil;
6176
+ }
6177
+
6178
+
5769
6179
  SWIGINTERN VALUE
5770
6180
  _wrap_Font_markup_width(int argc, VALUE *argv, VALUE self) {
5771
6181
  Gosu::Font *arg1 = (Gosu::Font *) 0 ;
@@ -7015,6 +7425,56 @@ fail:
7015
7425
  }
7016
7426
 
7017
7427
 
7428
+ SWIGINTERN VALUE
7429
+ _wrap_Image_from_markup(int argc, VALUE *argv, VALUE self) {
7430
+ std::string *arg1 = 0 ;
7431
+ double arg2 ;
7432
+ VALUE arg3 = (VALUE) 0 ;
7433
+ int res1 = SWIG_OLDOBJ ;
7434
+ double val2 ;
7435
+ int ecode2 = 0 ;
7436
+ Gosu::Image *result = 0 ;
7437
+ VALUE vresult = Qnil;
7438
+
7439
+ if ((argc < 2) || (argc > 3)) {
7440
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
7441
+ }
7442
+ {
7443
+ std::string *ptr = (std::string *)0;
7444
+ res1 = SWIG_AsPtr_std_string(argv[0], &ptr);
7445
+ if (!SWIG_IsOK(res1)) {
7446
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "std::string const &","Gosu_Image_from_markup", 1, argv[0] ));
7447
+ }
7448
+ if (!ptr) {
7449
+ SWIG_exception_fail(SWIG_ValueError, Ruby_Format_TypeError("invalid null reference ", "std::string const &","Gosu_Image_from_markup", 1, argv[0]));
7450
+ }
7451
+ arg1 = ptr;
7452
+ }
7453
+ ecode2 = SWIG_AsVal_double(argv[1], &val2);
7454
+ if (!SWIG_IsOK(ecode2)) {
7455
+ SWIG_exception_fail(SWIG_ArgError(ecode2), Ruby_Format_TypeError( "", "double","Gosu_Image_from_markup", 2, argv[1] ));
7456
+ }
7457
+ arg2 = static_cast< double >(val2);
7458
+ if (argc > 2) {
7459
+ arg3 = argv[2];
7460
+ }
7461
+ {
7462
+ try {
7463
+ result = (Gosu::Image *)Gosu_Image_from_markup((std::string const &)*arg1,arg2,arg3);
7464
+ }
7465
+ catch (const std::exception& e) {
7466
+ SWIG_exception(SWIG_RuntimeError, e.what());
7467
+ }
7468
+ }
7469
+ vresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Gosu__Image, SWIG_POINTER_OWN | 0 );
7470
+ if (SWIG_IsNewObj(res1)) delete arg1;
7471
+ return vresult;
7472
+ fail:
7473
+ if (SWIG_IsNewObj(res1)) delete arg1;
7474
+ return Qnil;
7475
+ }
7476
+
7477
+
7018
7478
  SWIGINTERN VALUE
7019
7479
  _wrap_Image_load_tiles__SWIG_0(int argc, VALUE *argv, VALUE self) {
7020
7480
  VALUE arg1 = (VALUE) 0 ;
@@ -12024,9 +12484,12 @@ SWIGEXPORT void Init_gosu(void) {
12024
12484
  rb_define_method(SwigClassFont.klass, "name", VALUEFUNC(_wrap_Font_name), -1);
12025
12485
  rb_define_method(SwigClassFont.klass, "height", VALUEFUNC(_wrap_Font_height), -1);
12026
12486
  rb_define_method(SwigClassFont.klass, "flags", VALUEFUNC(_wrap_Font_flags), -1);
12487
+ rb_define_method(SwigClassFont.klass, "draw_text", VALUEFUNC(_wrap_Font_draw_text), -1);
12027
12488
  rb_define_method(SwigClassFont.klass, "draw_markup", VALUEFUNC(_wrap_Font_draw_markup), -1);
12489
+ rb_define_method(SwigClassFont.klass, "draw_text_rel", VALUEFUNC(_wrap_Font_draw_text_rel), -1);
12028
12490
  rb_define_method(SwigClassFont.klass, "draw_markup_rel", VALUEFUNC(_wrap_Font_draw_markup_rel), -1);
12029
12491
  rb_define_method(SwigClassFont.klass, "set_image", VALUEFUNC(_wrap_Font_set_image), -1);
12492
+ rb_define_method(SwigClassFont.klass, "text_width", VALUEFUNC(_wrap_Font_text_width), -1);
12030
12493
  rb_define_method(SwigClassFont.klass, "markup_width", VALUEFUNC(_wrap_Font_markup_width), -1);
12031
12494
  SwigClassFont.mark = 0;
12032
12495
  SwigClassFont.destroy = (void (*)(void *)) free_Gosu_Font;
@@ -12063,6 +12526,7 @@ SWIGEXPORT void Init_gosu(void) {
12063
12526
  rb_define_method(SwigClassImage.klass, "gl_tex_info", VALUEFUNC(_wrap_Image_gl_tex_info), -1);
12064
12527
  rb_define_method(SwigClassImage.klass, "subimage", VALUEFUNC(_wrap_Image_subimage), -1);
12065
12528
  rb_define_singleton_method(SwigClassImage.klass, "from_text", VALUEFUNC(_wrap_Image_from_text), -1);
12529
+ rb_define_singleton_method(SwigClassImage.klass, "from_markup", VALUEFUNC(_wrap_Image_from_markup), -1);
12066
12530
  rb_define_singleton_method(SwigClassImage.klass, "load_tiles", VALUEFUNC(_wrap_Image_load_tiles), -1);
12067
12531
  rb_define_method(SwigClassImage.klass, "to_blob", VALUEFUNC(_wrap_Image_to_blob), -1);
12068
12532
  rb_define_method(SwigClassImage.klass, "columns", VALUEFUNC(_wrap_Image_columns), -1);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Raschke
@@ -225,7 +225,6 @@ files:
225
225
  - lib/gosu/preview.rb
226
226
  - lib/gosu/run.rb
227
227
  - lib/gosu/swig_patches.rb
228
- - lib/gosu/zen.rb
229
228
  - lib64/OpenAL32.dll
230
229
  - lib64/SDL2.dll
231
230
  - rdoc/gosu.rb
@@ -333,9 +332,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
333
332
  version: 2.5.0
334
333
  required_rubygems_version: !ruby/object:Gem::Requirement
335
334
  requirements:
336
- - - ">"
335
+ - - ">="
337
336
  - !ruby/object:Gem::Version
338
- version: 1.3.1
337
+ version: '0'
339
338
  requirements: []
340
339
  rubygems_version: 3.2.3
341
340
  signing_key:
@@ -1,89 +0,0 @@
1
- require 'gosu/preview'
2
-
3
- module Gosu
4
- module Zen
5
-
6
- @@window_args = [800, 600, {}]
7
- @@options = {}
8
-
9
- def window width, height, options = nil
10
- if $window.nil?
11
- @@window_args[0] = width
12
- @@window_args[1] = height
13
- @@window_args[2].merge! options if options
14
- else
15
- raise "window size can only be set before the window is created"
16
- end
17
- end
18
-
19
- def set what, value
20
- if $window.nil?
21
- @@options[what.to_sym] = value
22
- else
23
- $window.send "#{what}=", value
24
- end
25
- end
26
-
27
- def init &body
28
- ZenWindow.send :define_method, :init, &body
29
- end
30
-
31
- def button_down id = nil, &body
32
- m = id ? "button_down_#{id}" : :button_down_other
33
- ZenWindow.send :define_method, m, &body
34
- end
35
-
36
- def button_up id = nil, &body
37
- m = id ? "button_up_#{id}" : :button_up_other
38
- ZenWindow.send :define_method, m, &body
39
- end
40
-
41
- def update &body
42
- ZenWindow.send :define_method, :update, &body
43
- end
44
-
45
- def draw &body
46
- ZenWindow.send :define_method, :draw, &body
47
- end
48
-
49
- def run!
50
- window = ZenWindow.new *@@window_args
51
- @@options.each do |opt, value|
52
- window.send "#{opt}=", value
53
- end
54
- window.show
55
- end
56
-
57
- def Zen.included mod
58
- at_exit { run! unless $! }
59
- end
60
-
61
- end
62
-
63
- class ZenWindow < Window
64
- def initialize *args
65
- super
66
- init
67
- end
68
-
69
- def init
70
- end
71
-
72
- def button_down id
73
- m = :"button_down_#{id}"
74
- respond_to?(m) ? send(m) : button_down_other(id)
75
- end
76
-
77
- def button_up id
78
- m = :"button_up_#{id}"
79
- respond_to?(m) ? send(m) : button_up_other(id)
80
- end
81
-
82
- def button_down_other id
83
- end
84
-
85
- def button_up_other id
86
- end
87
-
88
- end
89
- end