teek-sdl2 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63f72a2b303c222592dcd946c8c4d7cc0af1deda6657733f1c521b262c7f7878
4
- data.tar.gz: b313234f243aec167a9dfc722a817efe3bf38ed9f13a329e3323990c165e6e12
3
+ metadata.gz: 5c87f625007ce2918dbb774860499c02b600109523ca6b546fe797697ca7ccd1
4
+ data.tar.gz: 9e3846f955461b2c479647bd05f2fcd4ce92be719ca408f1b12d4a11dffe534e
5
5
  SHA512:
6
- metadata.gz: 8ed2d743e5520a1e44b946c057b5311b2e4b61a0c44211fcbc726720614737d41db3dc431ed78de808aacd9a975e3773d21c27f4127ee4f55387e50281f80a4a
7
- data.tar.gz: b75885d4225ceab098ca9ed12f28717a4ed7823848740de0c6225bd6cce400bca24fedf005beb235b0d04f3f9e3f1c0d8923e4fca78cc1e86af2f7b15c725800
6
+ metadata.gz: 2a39f2f511c186759cd197a30ea9b08f77354a3ab361586d8390518061f1f40c90a37e2e050698a863e5b586caf9f55d2e674a0c6beace0ab0aa842f432778c7
7
+ data.tar.gz: f429de357646467b93478ea0094ada7e815dadd019f69dd7cabdc43f896601b4d1f27a87e36a24e8bdf70395522eff510fee1854460d0ebb6b92e1afda3fe336
@@ -128,16 +128,6 @@ unless pkg_config('SDL2_mixer') || have_library('SDL2_mixer', 'Mix_OpenAudio', '
128
128
  MSG
129
129
  end
130
130
 
131
- # SDL2_gfx for drawing primitives (circles, ellipses, polygons, etc.)
132
- unless pkg_config('SDL2_gfx') || have_library('SDL2_gfx', 'filledCircleRGBA', 'SDL2/SDL2_gfxPrimitives.h')
133
- abort <<~MSG
134
- SDL2_gfx not found. Install it:
135
- macOS: brew install sdl2_gfx
136
- Debian: sudo apt-get install libsdl2-gfx-dev
137
- Windows: pacman -S #{msys2_pkg_prefix}-SDL2_gfx (MSYS2)
138
- MSG
139
- end
140
-
141
131
  $srcs = ['teek_sdl2.c', 'sdl2surface.c', 'sdl2bridge.c', 'sdl2text.c', 'sdl2pixels.c', 'sdl2image.c', 'sdl2mixer.c', 'sdl2audio.c', 'sdl2gamepad.c']
142
132
 
143
133
  create_makefile('teek_sdl2')
@@ -1,5 +1,4 @@
1
1
  #include "teek_sdl2.h"
2
- #include <SDL2/SDL2_gfxPrimitives.h>
3
2
 
4
3
  /* ---------------------------------------------------------
5
4
  * Layer 1: Pure SDL2 surface management
@@ -332,561 +331,6 @@ renderer_draw_rounded_rect(int argc, VALUE *argv, VALUE self)
332
331
  return self;
333
332
  }
334
333
 
335
- /* ---------------------------------------------------------
336
- * SDL2_gfx primitives
337
- * --------------------------------------------------------- */
338
-
339
- /*
340
- * Teek::SDL2::Renderer#draw_circle(cx, cy, radius, r, g, b, a=255)
341
- */
342
- static VALUE
343
- renderer_draw_circle(int argc, VALUE *argv, VALUE self)
344
- {
345
- struct sdl2_renderer *ren = get_renderer(self);
346
- Uint8 r, g, b, a = 255;
347
-
348
- rb_check_arity(argc, 6, 7);
349
- Sint16 cx = (Sint16)NUM2INT(argv[0]);
350
- Sint16 cy = (Sint16)NUM2INT(argv[1]);
351
- Sint16 rad = (Sint16)NUM2INT(argv[2]);
352
- r = (Uint8)NUM2INT(argv[3]);
353
- g = (Uint8)NUM2INT(argv[4]);
354
- b = (Uint8)NUM2INT(argv[5]);
355
- if (argc > 6) a = (Uint8)NUM2INT(argv[6]);
356
-
357
- circleRGBA(ren->renderer, cx, cy, rad, r, g, b, a);
358
- return self;
359
- }
360
-
361
- /*
362
- * Teek::SDL2::Renderer#fill_circle(cx, cy, radius, r, g, b, a=255)
363
- */
364
- static VALUE
365
- renderer_fill_circle(int argc, VALUE *argv, VALUE self)
366
- {
367
- struct sdl2_renderer *ren = get_renderer(self);
368
- Uint8 r, g, b, a = 255;
369
-
370
- rb_check_arity(argc, 6, 7);
371
- Sint16 cx = (Sint16)NUM2INT(argv[0]);
372
- Sint16 cy = (Sint16)NUM2INT(argv[1]);
373
- Sint16 rad = (Sint16)NUM2INT(argv[2]);
374
- r = (Uint8)NUM2INT(argv[3]);
375
- g = (Uint8)NUM2INT(argv[4]);
376
- b = (Uint8)NUM2INT(argv[5]);
377
- if (argc > 6) a = (Uint8)NUM2INT(argv[6]);
378
-
379
- filledCircleRGBA(ren->renderer, cx, cy, rad, r, g, b, a);
380
- return self;
381
- }
382
-
383
- /*
384
- * Teek::SDL2::Renderer#draw_aa_circle(cx, cy, radius, r, g, b, a=255)
385
- *
386
- * Anti-aliased circle outline.
387
- */
388
- static VALUE
389
- renderer_draw_aa_circle(int argc, VALUE *argv, VALUE self)
390
- {
391
- struct sdl2_renderer *ren = get_renderer(self);
392
- Uint8 r, g, b, a = 255;
393
-
394
- rb_check_arity(argc, 6, 7);
395
- Sint16 cx = (Sint16)NUM2INT(argv[0]);
396
- Sint16 cy = (Sint16)NUM2INT(argv[1]);
397
- Sint16 rad = (Sint16)NUM2INT(argv[2]);
398
- r = (Uint8)NUM2INT(argv[3]);
399
- g = (Uint8)NUM2INT(argv[4]);
400
- b = (Uint8)NUM2INT(argv[5]);
401
- if (argc > 6) a = (Uint8)NUM2INT(argv[6]);
402
-
403
- aacircleRGBA(ren->renderer, cx, cy, rad, r, g, b, a);
404
- return self;
405
- }
406
-
407
- /*
408
- * Teek::SDL2::Renderer#draw_ellipse(cx, cy, rx, ry, r, g, b, a=255)
409
- */
410
- static VALUE
411
- renderer_draw_ellipse(int argc, VALUE *argv, VALUE self)
412
- {
413
- struct sdl2_renderer *ren = get_renderer(self);
414
- Uint8 r, g, b, a = 255;
415
-
416
- rb_check_arity(argc, 7, 8);
417
- Sint16 cx = (Sint16)NUM2INT(argv[0]);
418
- Sint16 cy = (Sint16)NUM2INT(argv[1]);
419
- Sint16 rx = (Sint16)NUM2INT(argv[2]);
420
- Sint16 ry = (Sint16)NUM2INT(argv[3]);
421
- r = (Uint8)NUM2INT(argv[4]);
422
- g = (Uint8)NUM2INT(argv[5]);
423
- b = (Uint8)NUM2INT(argv[6]);
424
- if (argc > 7) a = (Uint8)NUM2INT(argv[7]);
425
-
426
- ellipseRGBA(ren->renderer, cx, cy, rx, ry, r, g, b, a);
427
- return self;
428
- }
429
-
430
- /*
431
- * Teek::SDL2::Renderer#fill_ellipse(cx, cy, rx, ry, r, g, b, a=255)
432
- */
433
- static VALUE
434
- renderer_fill_ellipse(int argc, VALUE *argv, VALUE self)
435
- {
436
- struct sdl2_renderer *ren = get_renderer(self);
437
- Uint8 r, g, b, a = 255;
438
-
439
- rb_check_arity(argc, 7, 8);
440
- Sint16 cx = (Sint16)NUM2INT(argv[0]);
441
- Sint16 cy = (Sint16)NUM2INT(argv[1]);
442
- Sint16 rx = (Sint16)NUM2INT(argv[2]);
443
- Sint16 ry = (Sint16)NUM2INT(argv[3]);
444
- r = (Uint8)NUM2INT(argv[4]);
445
- g = (Uint8)NUM2INT(argv[5]);
446
- b = (Uint8)NUM2INT(argv[6]);
447
- if (argc > 7) a = (Uint8)NUM2INT(argv[7]);
448
-
449
- filledEllipseRGBA(ren->renderer, cx, cy, rx, ry, r, g, b, a);
450
- return self;
451
- }
452
-
453
- /*
454
- * Teek::SDL2::Renderer#draw_aa_ellipse(cx, cy, rx, ry, r, g, b, a=255)
455
- *
456
- * Anti-aliased ellipse outline.
457
- */
458
- static VALUE
459
- renderer_draw_aa_ellipse(int argc, VALUE *argv, VALUE self)
460
- {
461
- struct sdl2_renderer *ren = get_renderer(self);
462
- Uint8 r, g, b, a = 255;
463
-
464
- rb_check_arity(argc, 7, 8);
465
- Sint16 cx = (Sint16)NUM2INT(argv[0]);
466
- Sint16 cy = (Sint16)NUM2INT(argv[1]);
467
- Sint16 rx = (Sint16)NUM2INT(argv[2]);
468
- Sint16 ry = (Sint16)NUM2INT(argv[3]);
469
- r = (Uint8)NUM2INT(argv[4]);
470
- g = (Uint8)NUM2INT(argv[5]);
471
- b = (Uint8)NUM2INT(argv[6]);
472
- if (argc > 7) a = (Uint8)NUM2INT(argv[7]);
473
-
474
- aaellipseRGBA(ren->renderer, cx, cy, rx, ry, r, g, b, a);
475
- return self;
476
- }
477
-
478
- /*
479
- * Teek::SDL2::Renderer#draw_aa_line(x1, y1, x2, y2, r, g, b, a=255)
480
- *
481
- * Anti-aliased line.
482
- */
483
- static VALUE
484
- renderer_draw_aa_line(int argc, VALUE *argv, VALUE self)
485
- {
486
- struct sdl2_renderer *ren = get_renderer(self);
487
- Uint8 r, g, b, a = 255;
488
-
489
- rb_check_arity(argc, 7, 8);
490
- Sint16 x1 = (Sint16)NUM2INT(argv[0]);
491
- Sint16 y1 = (Sint16)NUM2INT(argv[1]);
492
- Sint16 x2 = (Sint16)NUM2INT(argv[2]);
493
- Sint16 y2 = (Sint16)NUM2INT(argv[3]);
494
- r = (Uint8)NUM2INT(argv[4]);
495
- g = (Uint8)NUM2INT(argv[5]);
496
- b = (Uint8)NUM2INT(argv[6]);
497
- if (argc > 7) a = (Uint8)NUM2INT(argv[7]);
498
-
499
- aalineRGBA(ren->renderer, x1, y1, x2, y2, r, g, b, a);
500
- return self;
501
- }
502
-
503
- /*
504
- * Teek::SDL2::Renderer#draw_thick_line(x1, y1, x2, y2, width, r, g, b, a=255)
505
- *
506
- * Line with specified pixel width (1-255).
507
- */
508
- static VALUE
509
- renderer_draw_thick_line(int argc, VALUE *argv, VALUE self)
510
- {
511
- struct sdl2_renderer *ren = get_renderer(self);
512
- Uint8 r, g, b, a = 255;
513
-
514
- rb_check_arity(argc, 8, 9);
515
- Sint16 x1 = (Sint16)NUM2INT(argv[0]);
516
- Sint16 y1 = (Sint16)NUM2INT(argv[1]);
517
- Sint16 x2 = (Sint16)NUM2INT(argv[2]);
518
- Sint16 y2 = (Sint16)NUM2INT(argv[3]);
519
- Uint8 width = (Uint8)NUM2INT(argv[4]);
520
- r = (Uint8)NUM2INT(argv[5]);
521
- g = (Uint8)NUM2INT(argv[6]);
522
- b = (Uint8)NUM2INT(argv[7]);
523
- if (argc > 8) a = (Uint8)NUM2INT(argv[8]);
524
-
525
- thickLineRGBA(ren->renderer, x1, y1, x2, y2, width, r, g, b, a);
526
- return self;
527
- }
528
-
529
- /*
530
- * Teek::SDL2::Renderer#draw_arc(cx, cy, radius, start, end, r, g, b, a=255)
531
- *
532
- * Arc outline. Angles in degrees (0=right, 90=down).
533
- */
534
- static VALUE
535
- renderer_draw_arc(int argc, VALUE *argv, VALUE self)
536
- {
537
- struct sdl2_renderer *ren = get_renderer(self);
538
- Uint8 r, g, b, a = 255;
539
-
540
- rb_check_arity(argc, 8, 9);
541
- Sint16 cx = (Sint16)NUM2INT(argv[0]);
542
- Sint16 cy = (Sint16)NUM2INT(argv[1]);
543
- Sint16 rad = (Sint16)NUM2INT(argv[2]);
544
- Sint16 start = (Sint16)NUM2INT(argv[3]);
545
- Sint16 end = (Sint16)NUM2INT(argv[4]);
546
- r = (Uint8)NUM2INT(argv[5]);
547
- g = (Uint8)NUM2INT(argv[6]);
548
- b = (Uint8)NUM2INT(argv[7]);
549
- if (argc > 8) a = (Uint8)NUM2INT(argv[8]);
550
-
551
- arcRGBA(ren->renderer, cx, cy, rad, start, end, r, g, b, a);
552
- return self;
553
- }
554
-
555
- /*
556
- * Teek::SDL2::Renderer#draw_pie(cx, cy, radius, start, end, r, g, b, a=255)
557
- *
558
- * Pie (wedge) outline. Angles in degrees.
559
- */
560
- static VALUE
561
- renderer_draw_pie(int argc, VALUE *argv, VALUE self)
562
- {
563
- struct sdl2_renderer *ren = get_renderer(self);
564
- Uint8 r, g, b, a = 255;
565
-
566
- rb_check_arity(argc, 8, 9);
567
- Sint16 cx = (Sint16)NUM2INT(argv[0]);
568
- Sint16 cy = (Sint16)NUM2INT(argv[1]);
569
- Sint16 rad = (Sint16)NUM2INT(argv[2]);
570
- Sint16 start = (Sint16)NUM2INT(argv[3]);
571
- Sint16 end = (Sint16)NUM2INT(argv[4]);
572
- r = (Uint8)NUM2INT(argv[5]);
573
- g = (Uint8)NUM2INT(argv[6]);
574
- b = (Uint8)NUM2INT(argv[7]);
575
- if (argc > 8) a = (Uint8)NUM2INT(argv[8]);
576
-
577
- pieRGBA(ren->renderer, cx, cy, rad, start, end, r, g, b, a);
578
- return self;
579
- }
580
-
581
- /*
582
- * Teek::SDL2::Renderer#fill_pie(cx, cy, radius, start, end, r, g, b, a=255)
583
- *
584
- * Filled pie (wedge). Angles in degrees.
585
- */
586
- static VALUE
587
- renderer_fill_pie(int argc, VALUE *argv, VALUE self)
588
- {
589
- struct sdl2_renderer *ren = get_renderer(self);
590
- Uint8 r, g, b, a = 255;
591
-
592
- rb_check_arity(argc, 8, 9);
593
- Sint16 cx = (Sint16)NUM2INT(argv[0]);
594
- Sint16 cy = (Sint16)NUM2INT(argv[1]);
595
- Sint16 rad = (Sint16)NUM2INT(argv[2]);
596
- Sint16 start = (Sint16)NUM2INT(argv[3]);
597
- Sint16 end = (Sint16)NUM2INT(argv[4]);
598
- r = (Uint8)NUM2INT(argv[5]);
599
- g = (Uint8)NUM2INT(argv[6]);
600
- b = (Uint8)NUM2INT(argv[7]);
601
- if (argc > 8) a = (Uint8)NUM2INT(argv[8]);
602
-
603
- filledPieRGBA(ren->renderer, cx, cy, rad, start, end, r, g, b, a);
604
- return self;
605
- }
606
-
607
- /* Helper: convert a Ruby Array of Integers to a C array of Sint16.
608
- * Caller must xfree() the returned pointer. */
609
- static Sint16 *
610
- ary_to_sint16(VALUE ary, int *out_len)
611
- {
612
- Check_Type(ary, T_ARRAY);
613
- int n = (int)RARRAY_LEN(ary);
614
- Sint16 *buf = ALLOC_N(Sint16, n);
615
- for (int i = 0; i < n; i++) {
616
- buf[i] = (Sint16)NUM2INT(rb_ary_entry(ary, i));
617
- }
618
- *out_len = n;
619
- return buf;
620
- }
621
-
622
- /*
623
- * Teek::SDL2::Renderer#draw_polygon(xs, ys, r, g, b, a=255)
624
- *
625
- * Polygon outline. xs and ys are Arrays of Integer coordinates.
626
- */
627
- static VALUE
628
- renderer_draw_polygon(int argc, VALUE *argv, VALUE self)
629
- {
630
- struct sdl2_renderer *ren = get_renderer(self);
631
- Uint8 r, g, b, a = 255;
632
-
633
- rb_check_arity(argc, 5, 6);
634
- int nx, ny;
635
- Sint16 *vx = ary_to_sint16(argv[0], &nx);
636
- Sint16 *vy = ary_to_sint16(argv[1], &ny);
637
- if (nx != ny) {
638
- xfree(vx); xfree(vy);
639
- rb_raise(rb_eArgError, "xs and ys must have the same length");
640
- }
641
- r = (Uint8)NUM2INT(argv[2]);
642
- g = (Uint8)NUM2INT(argv[3]);
643
- b = (Uint8)NUM2INT(argv[4]);
644
- if (argc > 5) a = (Uint8)NUM2INT(argv[5]);
645
-
646
- polygonRGBA(ren->renderer, vx, vy, nx, r, g, b, a);
647
- xfree(vx); xfree(vy);
648
- return self;
649
- }
650
-
651
- /*
652
- * Teek::SDL2::Renderer#fill_polygon(xs, ys, r, g, b, a=255)
653
- *
654
- * Filled polygon. xs and ys are Arrays of Integer coordinates.
655
- */
656
- static VALUE
657
- renderer_fill_polygon(int argc, VALUE *argv, VALUE self)
658
- {
659
- struct sdl2_renderer *ren = get_renderer(self);
660
- Uint8 r, g, b, a = 255;
661
-
662
- rb_check_arity(argc, 5, 6);
663
- int nx, ny;
664
- Sint16 *vx = ary_to_sint16(argv[0], &nx);
665
- Sint16 *vy = ary_to_sint16(argv[1], &ny);
666
- if (nx != ny) {
667
- xfree(vx); xfree(vy);
668
- rb_raise(rb_eArgError, "xs and ys must have the same length");
669
- }
670
- r = (Uint8)NUM2INT(argv[2]);
671
- g = (Uint8)NUM2INT(argv[3]);
672
- b = (Uint8)NUM2INT(argv[4]);
673
- if (argc > 5) a = (Uint8)NUM2INT(argv[5]);
674
-
675
- filledPolygonRGBA(ren->renderer, vx, vy, nx, r, g, b, a);
676
- xfree(vx); xfree(vy);
677
- return self;
678
- }
679
-
680
- /*
681
- * Teek::SDL2::Renderer#draw_aa_polygon(xs, ys, r, g, b, a=255)
682
- *
683
- * Anti-aliased polygon outline. xs and ys are Arrays of Integer coordinates.
684
- */
685
- static VALUE
686
- renderer_draw_aa_polygon(int argc, VALUE *argv, VALUE self)
687
- {
688
- struct sdl2_renderer *ren = get_renderer(self);
689
- Uint8 r, g, b, a = 255;
690
-
691
- rb_check_arity(argc, 5, 6);
692
- int nx, ny;
693
- Sint16 *vx = ary_to_sint16(argv[0], &nx);
694
- Sint16 *vy = ary_to_sint16(argv[1], &ny);
695
- if (nx != ny) {
696
- xfree(vx); xfree(vy);
697
- rb_raise(rb_eArgError, "xs and ys must have the same length");
698
- }
699
- r = (Uint8)NUM2INT(argv[2]);
700
- g = (Uint8)NUM2INT(argv[3]);
701
- b = (Uint8)NUM2INT(argv[4]);
702
- if (argc > 5) a = (Uint8)NUM2INT(argv[5]);
703
-
704
- aapolygonRGBA(ren->renderer, vx, vy, nx, r, g, b, a);
705
- xfree(vx); xfree(vy);
706
- return self;
707
- }
708
-
709
- /*
710
- * Teek::SDL2::Renderer#draw_bezier(xs, ys, steps, r, g, b, a=255)
711
- *
712
- * Bezier curve through control points. xs and ys are Arrays of Integer
713
- * coordinates. steps controls interpolation smoothness (higher = smoother).
714
- */
715
- static VALUE
716
- renderer_draw_bezier(int argc, VALUE *argv, VALUE self)
717
- {
718
- struct sdl2_renderer *ren = get_renderer(self);
719
- Uint8 r, g, b, a = 255;
720
-
721
- rb_check_arity(argc, 6, 7);
722
- int nx, ny;
723
- Sint16 *vx = ary_to_sint16(argv[0], &nx);
724
- Sint16 *vy = ary_to_sint16(argv[1], &ny);
725
- if (nx != ny) {
726
- xfree(vx); xfree(vy);
727
- rb_raise(rb_eArgError, "xs and ys must have the same length");
728
- }
729
- int steps = NUM2INT(argv[2]);
730
- r = (Uint8)NUM2INT(argv[3]);
731
- g = (Uint8)NUM2INT(argv[4]);
732
- b = (Uint8)NUM2INT(argv[5]);
733
- if (argc > 6) a = (Uint8)NUM2INT(argv[6]);
734
-
735
- bezierRGBA(ren->renderer, vx, vy, nx, steps, r, g, b, a);
736
- xfree(vx); xfree(vy);
737
- return self;
738
- }
739
-
740
- /*
741
- * Teek::SDL2::Renderer#draw_trigon(x1, y1, x2, y2, x3, y3, r, g, b, a=255)
742
- *
743
- * Triangle outline.
744
- */
745
- static VALUE
746
- renderer_draw_trigon(int argc, VALUE *argv, VALUE self)
747
- {
748
- struct sdl2_renderer *ren = get_renderer(self);
749
- Uint8 r, g, b, a = 255;
750
-
751
- rb_check_arity(argc, 9, 10);
752
- Sint16 x1 = (Sint16)NUM2INT(argv[0]);
753
- Sint16 y1 = (Sint16)NUM2INT(argv[1]);
754
- Sint16 x2 = (Sint16)NUM2INT(argv[2]);
755
- Sint16 y2 = (Sint16)NUM2INT(argv[3]);
756
- Sint16 x3 = (Sint16)NUM2INT(argv[4]);
757
- Sint16 y3 = (Sint16)NUM2INT(argv[5]);
758
- r = (Uint8)NUM2INT(argv[6]);
759
- g = (Uint8)NUM2INT(argv[7]);
760
- b = (Uint8)NUM2INT(argv[8]);
761
- if (argc > 9) a = (Uint8)NUM2INT(argv[9]);
762
-
763
- trigonRGBA(ren->renderer, x1, y1, x2, y2, x3, y3, r, g, b, a);
764
- return self;
765
- }
766
-
767
- /*
768
- * Teek::SDL2::Renderer#fill_trigon(x1, y1, x2, y2, x3, y3, r, g, b, a=255)
769
- *
770
- * Filled triangle.
771
- */
772
- static VALUE
773
- renderer_fill_trigon(int argc, VALUE *argv, VALUE self)
774
- {
775
- struct sdl2_renderer *ren = get_renderer(self);
776
- Uint8 r, g, b, a = 255;
777
-
778
- rb_check_arity(argc, 9, 10);
779
- Sint16 x1 = (Sint16)NUM2INT(argv[0]);
780
- Sint16 y1 = (Sint16)NUM2INT(argv[1]);
781
- Sint16 x2 = (Sint16)NUM2INT(argv[2]);
782
- Sint16 y2 = (Sint16)NUM2INT(argv[3]);
783
- Sint16 x3 = (Sint16)NUM2INT(argv[4]);
784
- Sint16 y3 = (Sint16)NUM2INT(argv[5]);
785
- r = (Uint8)NUM2INT(argv[6]);
786
- g = (Uint8)NUM2INT(argv[7]);
787
- b = (Uint8)NUM2INT(argv[8]);
788
- if (argc > 9) a = (Uint8)NUM2INT(argv[9]);
789
-
790
- filledTrigonRGBA(ren->renderer, x1, y1, x2, y2, x3, y3, r, g, b, a);
791
- return self;
792
- }
793
-
794
- /*
795
- * Teek::SDL2::Renderer#draw_aa_trigon(x1, y1, x2, y2, x3, y3, r, g, b, a=255)
796
- *
797
- * Anti-aliased triangle outline.
798
- */
799
- static VALUE
800
- renderer_draw_aa_trigon(int argc, VALUE *argv, VALUE self)
801
- {
802
- struct sdl2_renderer *ren = get_renderer(self);
803
- Uint8 r, g, b, a = 255;
804
-
805
- rb_check_arity(argc, 9, 10);
806
- Sint16 x1 = (Sint16)NUM2INT(argv[0]);
807
- Sint16 y1 = (Sint16)NUM2INT(argv[1]);
808
- Sint16 x2 = (Sint16)NUM2INT(argv[2]);
809
- Sint16 y2 = (Sint16)NUM2INT(argv[3]);
810
- Sint16 x3 = (Sint16)NUM2INT(argv[4]);
811
- Sint16 y3 = (Sint16)NUM2INT(argv[5]);
812
- r = (Uint8)NUM2INT(argv[6]);
813
- g = (Uint8)NUM2INT(argv[7]);
814
- b = (Uint8)NUM2INT(argv[8]);
815
- if (argc > 9) a = (Uint8)NUM2INT(argv[9]);
816
-
817
- aatrigonRGBA(ren->renderer, x1, y1, x2, y2, x3, y3, r, g, b, a);
818
- return self;
819
- }
820
-
821
- /*
822
- * Teek::SDL2::Renderer#draw_pixel(x, y, r, g, b, a=255)
823
- */
824
- static VALUE
825
- renderer_draw_pixel(int argc, VALUE *argv, VALUE self)
826
- {
827
- struct sdl2_renderer *ren = get_renderer(self);
828
- Uint8 r, g, b, a = 255;
829
-
830
- rb_check_arity(argc, 5, 6);
831
- Sint16 x = (Sint16)NUM2INT(argv[0]);
832
- Sint16 y = (Sint16)NUM2INT(argv[1]);
833
- r = (Uint8)NUM2INT(argv[2]);
834
- g = (Uint8)NUM2INT(argv[3]);
835
- b = (Uint8)NUM2INT(argv[4]);
836
- if (argc > 5) a = (Uint8)NUM2INT(argv[5]);
837
-
838
- pixelRGBA(ren->renderer, x, y, r, g, b, a);
839
- return self;
840
- }
841
-
842
- /*
843
- * Teek::SDL2::Renderer#draw_hline(x1, x2, y, r, g, b, a=255)
844
- *
845
- * Horizontal line from x1 to x2 at row y.
846
- */
847
- static VALUE
848
- renderer_draw_hline(int argc, VALUE *argv, VALUE self)
849
- {
850
- struct sdl2_renderer *ren = get_renderer(self);
851
- Uint8 r, g, b, a = 255;
852
-
853
- rb_check_arity(argc, 6, 7);
854
- Sint16 x1 = (Sint16)NUM2INT(argv[0]);
855
- Sint16 x2 = (Sint16)NUM2INT(argv[1]);
856
- Sint16 y = (Sint16)NUM2INT(argv[2]);
857
- r = (Uint8)NUM2INT(argv[3]);
858
- g = (Uint8)NUM2INT(argv[4]);
859
- b = (Uint8)NUM2INT(argv[5]);
860
- if (argc > 6) a = (Uint8)NUM2INT(argv[6]);
861
-
862
- hlineRGBA(ren->renderer, x1, x2, y, r, g, b, a);
863
- return self;
864
- }
865
-
866
- /*
867
- * Teek::SDL2::Renderer#draw_vline(x, y1, y2, r, g, b, a=255)
868
- *
869
- * Vertical line from y1 to y2 at column x.
870
- */
871
- static VALUE
872
- renderer_draw_vline(int argc, VALUE *argv, VALUE self)
873
- {
874
- struct sdl2_renderer *ren = get_renderer(self);
875
- Uint8 r, g, b, a = 255;
876
-
877
- rb_check_arity(argc, 6, 7);
878
- Sint16 x = (Sint16)NUM2INT(argv[0]);
879
- Sint16 y1 = (Sint16)NUM2INT(argv[1]);
880
- Sint16 y2 = (Sint16)NUM2INT(argv[2]);
881
- r = (Uint8)NUM2INT(argv[3]);
882
- g = (Uint8)NUM2INT(argv[4]);
883
- b = (Uint8)NUM2INT(argv[5]);
884
- if (argc > 6) a = (Uint8)NUM2INT(argv[6]);
885
-
886
- vlineRGBA(ren->renderer, x, y1, y2, r, g, b, a);
887
- return self;
888
- }
889
-
890
334
  /*
891
335
  * Teek::SDL2::Renderer#output_size -> [w, h]
892
336
  */
@@ -1433,27 +877,7 @@ Init_sdl2surface(VALUE mTeekSDL2)
1433
877
  rb_define_method(cRenderer, "draw_line", renderer_draw_line, -1);
1434
878
  rb_define_method(cRenderer, "fill_rounded_rect", renderer_fill_rounded_rect, -1);
1435
879
  rb_define_method(cRenderer, "draw_rounded_rect", renderer_draw_rounded_rect, -1);
1436
- rb_define_method(cRenderer, "draw_circle", renderer_draw_circle, -1);
1437
- rb_define_method(cRenderer, "fill_circle", renderer_fill_circle, -1);
1438
- rb_define_method(cRenderer, "draw_aa_circle", renderer_draw_aa_circle, -1);
1439
- rb_define_method(cRenderer, "draw_ellipse", renderer_draw_ellipse, -1);
1440
- rb_define_method(cRenderer, "fill_ellipse", renderer_fill_ellipse, -1);
1441
- rb_define_method(cRenderer, "draw_aa_ellipse", renderer_draw_aa_ellipse, -1);
1442
- rb_define_method(cRenderer, "draw_aa_line", renderer_draw_aa_line, -1);
1443
- rb_define_method(cRenderer, "draw_thick_line", renderer_draw_thick_line, -1);
1444
- rb_define_method(cRenderer, "draw_arc", renderer_draw_arc, -1);
1445
- rb_define_method(cRenderer, "draw_pie", renderer_draw_pie, -1);
1446
- rb_define_method(cRenderer, "fill_pie", renderer_fill_pie, -1);
1447
- rb_define_method(cRenderer, "draw_polygon", renderer_draw_polygon, -1);
1448
- rb_define_method(cRenderer, "fill_polygon", renderer_fill_polygon, -1);
1449
- rb_define_method(cRenderer, "draw_aa_polygon", renderer_draw_aa_polygon, -1);
1450
- rb_define_method(cRenderer, "draw_bezier", renderer_draw_bezier, -1);
1451
- rb_define_method(cRenderer, "draw_trigon", renderer_draw_trigon, -1);
1452
- rb_define_method(cRenderer, "fill_trigon", renderer_fill_trigon, -1);
1453
- rb_define_method(cRenderer, "draw_aa_trigon", renderer_draw_aa_trigon, -1);
1454
- rb_define_method(cRenderer, "draw_pixel", renderer_draw_pixel, -1);
1455
- rb_define_method(cRenderer, "draw_hline", renderer_draw_hline, -1);
1456
- rb_define_method(cRenderer, "draw_vline", renderer_draw_vline, -1);
880
+
1457
881
  rb_define_method(cRenderer, "output_size", renderer_output_size, 0);
1458
882
  rb_define_method(cRenderer, "read_pixels", renderer_read_pixels, 0);
1459
883
  rb_define_method(cRenderer, "create_texture", renderer_create_texture, -1);
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Teek
4
4
  module SDL2
5
- VERSION = "0.1.3"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teek-sdl2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Cook