graphics 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +15 -0
- data/Rakefile +2 -0
- data/examples/logo.rb +1 -1
- data/ext/sdl/sdl.c +78 -15
- data/ext/sdl/sge/sge_surface.cpp +1 -1
- data/graphics_setup.sh +2 -2
- data/lib/graphics/simulation.rb +8 -5
- data/lib/graphics.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +20 -20
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67d82ed6f28d5e1a85f4bc54a31e67804e6f0071645c8174d96ee7eb72d5fa30
|
4
|
+
data.tar.gz: ef980c42b79b48f48d8ecb143bc912c295b08171479d0e877f58baab4687ea39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ed3a2b99b78e0910d63b8cc119a6f229364713026d1002a5e139ea8814472392db32051b3385e346b4c619adf27c81c068432dadf9719ca01fee9af994b1f89
|
7
|
+
data.tar.gz: eac5fcf6f1576ac47a2f77e06b46b39fdc7489429f8e9099cbfa49140cfeacde037d8545140ad875542c3532c900c1a0ce550d8e6fcf7629cdf38eb7ff0cbc26
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
=== 1.1.0 / 2023-07-26
|
2
|
+
|
3
|
+
* 3 minor enhancements:
|
4
|
+
|
5
|
+
* Added anti-aliasing to polygon. Want to add filling at some point.
|
6
|
+
* Requiring ruby 2.7+. Too many changes to ruby internals to try to maintain.
|
7
|
+
* polygon now takes an array of points.
|
8
|
+
|
9
|
+
* 4 bug fixes:
|
10
|
+
|
11
|
+
* Fixed a bunch of compiler warnings for ruby struct changes.
|
12
|
+
* Fixed font lookup on linux. (presidentbeef)
|
13
|
+
* Fixed graphics_setup.sh for obsolete build flag on sdl2_image. (NickSchimek)
|
14
|
+
* ruby 3.2: Fixed warning from ruby headers by explicitly removing alloc funcs.
|
15
|
+
|
1
16
|
=== 1.0.1 / 2018-11-14
|
2
17
|
|
3
18
|
* 2 bug fixes:
|
data/Rakefile
CHANGED
data/examples/logo.rb
CHANGED
data/ext/sdl/sdl.c
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
#include <sge/sge_collision.h>
|
9
9
|
#include <SDL_mixer.h>
|
10
10
|
|
11
|
-
// https://github.com/
|
11
|
+
// https://github.com/ruby/ruby/blob/master/doc/extension.rdoc#c-struct-to-ruby-object-
|
12
12
|
|
13
13
|
#define DEFINE_CLASS_(name, string_name, mark, free, memsize) \
|
14
14
|
static void mark(void*); \
|
@@ -16,7 +16,15 @@
|
|
16
16
|
static VALUE c##name; \
|
17
17
|
static const rb_data_type_t _##name##_type = { \
|
18
18
|
string_name, \
|
19
|
-
{ mark,
|
19
|
+
{ mark, \
|
20
|
+
free, \
|
21
|
+
memsize, \
|
22
|
+
NULL, /* compact */ \
|
23
|
+
{ NULL } \
|
24
|
+
}, \
|
25
|
+
NULL, /* parent */ \
|
26
|
+
NULL, /* data */ \
|
27
|
+
0, /* flags */ \
|
20
28
|
}; \
|
21
29
|
static SDL_##name* ruby_to_##name(VALUE val) { \
|
22
30
|
SDL_##name* ret; \
|
@@ -30,7 +38,8 @@
|
|
30
38
|
_##name##_mark, _##name##_free, _##name##_memsize)
|
31
39
|
|
32
40
|
#define DEFINE_CLASS_0(name, string_name) \
|
33
|
-
DEFINE_CLASS_(name, string_name,
|
41
|
+
DEFINE_CLASS_(name, string_name, \
|
42
|
+
_##name##_mark, _##name##_free, NULL)
|
34
43
|
|
35
44
|
#define DEFINE_SELF(type, var, rb_var) \
|
36
45
|
SDL_##type* var = ruby_to_##type(rb_var)
|
@@ -321,7 +330,7 @@ static VALUE Key_s_press_p(VALUE mod, VALUE keycode_) {
|
|
321
330
|
SDL_Keycode keycode = NUM2INT(keycode_);
|
322
331
|
SDL_Scancode scancode = SDL_GetScancodeFromKey(keycode);
|
323
332
|
|
324
|
-
if (0 >= scancode || scancode >= key_state_len)
|
333
|
+
if (0 >= scancode || scancode >= (SDL_Scancode)key_state_len)
|
325
334
|
rb_raise(eSDLError, "%d (%d) is out of bounds: %d",
|
326
335
|
keycode, scancode, key_state_len);
|
327
336
|
|
@@ -508,6 +517,10 @@ typedef int (*f_rxyxyc)(SDL_Renderer*,
|
|
508
517
|
typedef int (*f_rxyrc)(SDL_Renderer*,
|
509
518
|
Sint16, Sint16, Sint16,
|
510
519
|
Uint32);
|
520
|
+
typedef int (*f_poly)(SDL_Renderer*,
|
521
|
+
const Sint16 *, const Sint16 *,
|
522
|
+
int,
|
523
|
+
Uint32);
|
511
524
|
|
512
525
|
// TODO: ? maybe ?
|
513
526
|
// int hlineColor (SDL_Renderer *renderer, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color)
|
@@ -521,9 +534,7 @@ typedef int (*f_rxyrc)(SDL_Renderer*,
|
|
521
534
|
// int trigonColor (SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
|
522
535
|
// int aatrigonColor (SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
|
523
536
|
// int filledTrigonColor (SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color)
|
524
|
-
// int
|
525
|
-
// int aapolygonColor (SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color)
|
526
|
-
// int filledPolygonColor (SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color)
|
537
|
+
// int filledPolygonColor (SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color)
|
527
538
|
// int texturedPolygon (SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, SDL_Surface *texture, int texture_dx, int texture_dy)
|
528
539
|
// void gfxPrimitivesSetFont (const void *fontdata, Uint32 cw, Uint32 ch)
|
529
540
|
// void gfxPrimitivesSetFontRotation(Uint32 rotation)
|
@@ -648,6 +659,46 @@ static VALUE Renderer_draw_line(VALUE self,
|
|
648
659
|
return Qnil;
|
649
660
|
}
|
650
661
|
|
662
|
+
// int polygonColor (SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color)
|
663
|
+
// int aapolygonColor (SDL_Renderer *renderer, const Sint16 *vx, const Sint16 *vy, int n, Uint32 color)
|
664
|
+
|
665
|
+
static f_poly f_polygon[] = { &polygonColor,
|
666
|
+
&aapolygonColor };
|
667
|
+
|
668
|
+
static VALUE Renderer_draw_polygon(VALUE self,
|
669
|
+
VALUE xs_,
|
670
|
+
VALUE ys_,
|
671
|
+
VALUE c,
|
672
|
+
VALUE aa) {
|
673
|
+
DEFINE_SELF(Renderer, renderer, self);
|
674
|
+
|
675
|
+
int xlen = RARRAY_LENINT(xs_);
|
676
|
+
int ylen = RARRAY_LENINT(ys_);
|
677
|
+
|
678
|
+
if (xlen != ylen)
|
679
|
+
rb_raise(rb_eArgError, "xs & ys are different length");
|
680
|
+
|
681
|
+
Sint16 *xs = malloc(xlen*sizeof(Sint16));
|
682
|
+
for (int i = 0; i < xlen; i++) {
|
683
|
+
xs[i] = NUM2SINT16(RARRAY_AREF(xs_, i));
|
684
|
+
}
|
685
|
+
|
686
|
+
Sint16 *ys = malloc(ylen*sizeof(Sint16));
|
687
|
+
for (int i = 0; i < ylen; i++) {
|
688
|
+
ys[i] = NUM2SINT16(RARRAY_AREF(ys_, i));
|
689
|
+
}
|
690
|
+
|
691
|
+
Uint8 idx = IDX1(RTEST(aa));
|
692
|
+
|
693
|
+
if (f_polygon[idx](renderer, xs, ys, xlen, VALUE2COLOR(c)))
|
694
|
+
FAILURE("draw_polygon");
|
695
|
+
|
696
|
+
free(xs);
|
697
|
+
free(ys);
|
698
|
+
|
699
|
+
return Qnil;
|
700
|
+
}
|
701
|
+
|
651
702
|
static f_rxyxyc f_rect[] = { &rectangleColor,
|
652
703
|
&boxColor };
|
653
704
|
|
@@ -1076,17 +1127,17 @@ void Init_sdl() {
|
|
1076
1127
|
mKey = rb_define_module_under(mSDL, "Key");
|
1077
1128
|
mMouse = rb_define_module_under(mSDL, "Mouse");
|
1078
1129
|
|
1079
|
-
cAudio = rb_define_class_under(mSDL, "Audio",
|
1080
|
-
cCollisionMap = rb_define_class_under(mSDL, "CollisionMap",
|
1130
|
+
cAudio = rb_define_class_under(mSDL, "Audio", rb_cObject);
|
1131
|
+
cCollisionMap = rb_define_class_under(mSDL, "CollisionMap", rb_cObject);
|
1081
1132
|
cEvent = rb_define_class_under(mSDL, "Event", rb_cObject);
|
1082
|
-
cPixelFormat = rb_define_class_under(mSDL, "PixelFormat",
|
1083
|
-
cSurface = rb_define_class_under(mSDL, "Surface",
|
1084
|
-
cTTFFont = rb_define_class_under(mSDL, "TTF",
|
1133
|
+
cPixelFormat = rb_define_class_under(mSDL, "PixelFormat", rb_cObject);
|
1134
|
+
cSurface = rb_define_class_under(mSDL, "Surface", rb_cObject);
|
1135
|
+
cTTFFont = rb_define_class_under(mSDL, "TTF", rb_cObject); // TODO: Font
|
1085
1136
|
|
1086
1137
|
cScreen = rb_define_class_under(mSDL, "Screen", cSurface);
|
1087
|
-
cRenderer = rb_define_class_under(mSDL, "Renderer",
|
1088
|
-
cWindow = rb_define_class_under(mSDL, "Window",
|
1089
|
-
cTexture = rb_define_class_under(mSDL, "Texture",
|
1138
|
+
cRenderer = rb_define_class_under(mSDL, "Renderer", rb_cObject);
|
1139
|
+
cWindow = rb_define_class_under(mSDL, "Window", rb_cObject);
|
1140
|
+
cTexture = rb_define_class_under(mSDL, "Texture", rb_cObject);
|
1090
1141
|
|
1091
1142
|
cEventQuit = rb_define_class_under(cEvent, "Quit", cEvent);
|
1092
1143
|
cEventKeydown = rb_define_class_under(cEvent, "Keydown", cEvent);
|
@@ -1098,6 +1149,17 @@ void Init_sdl() {
|
|
1098
1149
|
|
1099
1150
|
eSDLError = rb_define_class_under(mSDL, "Error", rb_eStandardError);
|
1100
1151
|
|
1152
|
+
//// T_DATA cleanup: (mirror DEFINE_CLASS* calls above)
|
1153
|
+
|
1154
|
+
rb_undef_alloc_func(cAudio);
|
1155
|
+
rb_undef_alloc_func(cSurface);
|
1156
|
+
rb_undef_alloc_func(cCollisionMap);
|
1157
|
+
rb_undef_alloc_func(cPixelFormat);
|
1158
|
+
rb_undef_alloc_func(cTTFFont);
|
1159
|
+
rb_undef_alloc_func(cRenderer);
|
1160
|
+
rb_undef_alloc_func(cWindow);
|
1161
|
+
rb_undef_alloc_func(cTexture);
|
1162
|
+
|
1101
1163
|
//// SDL methods:
|
1102
1164
|
|
1103
1165
|
rb_define_module_function(mSDL, "init", sdl_s_init, 1);
|
@@ -1185,6 +1247,7 @@ void Init_sdl() {
|
|
1185
1247
|
rb_define_method(cRenderer, "draw_ellipse", Renderer_draw_ellipse, 7);
|
1186
1248
|
rb_define_method(cRenderer, "draw_line", Renderer_draw_line, 6);
|
1187
1249
|
rb_define_method(cRenderer, "draw_rect", Renderer_draw_rect, 6);
|
1250
|
+
rb_define_method(cRenderer, "draw_polygon", Renderer_draw_polygon, 4);
|
1188
1251
|
rb_define_method(cRenderer, "fast_rect", Renderer_fast_rect, 5);
|
1189
1252
|
rb_define_method(cRenderer, "h", Renderer_h, 0);
|
1190
1253
|
rb_define_method(cRenderer, "new_texture", Renderer_new_texture, 0);
|
data/ext/sdl/sge/sge_surface.cpp
CHANGED
data/graphics_setup.sh
CHANGED
@@ -10,8 +10,8 @@ case `uname` in
|
|
10
10
|
brew install sdl2
|
11
11
|
brew install sdl2_mixer
|
12
12
|
brew install sdl2_ttf
|
13
|
-
brew install sdl2_image
|
14
|
-
|
13
|
+
brew install sdl2_image
|
14
|
+
brew install sdl2_gfx
|
15
15
|
;;
|
16
16
|
Linux)
|
17
17
|
echo "I'm on linux, using sudo where needed"
|
data/lib/graphics/simulation.rb
CHANGED
@@ -206,7 +206,7 @@ class Graphics::AbstractSimulation
|
|
206
206
|
File.expand_path("~/Library/Fonts/"),
|
207
207
|
|
208
208
|
# Ubuntu
|
209
|
-
"/usr/share/fonts
|
209
|
+
"/usr/share/fonts/**/",
|
210
210
|
]
|
211
211
|
FONT_GLOB = "{#{font_dirs.join(",")}}" # :nodoc:
|
212
212
|
|
@@ -497,11 +497,14 @@ class Graphics::AbstractSimulation
|
|
497
497
|
# Draw a closed form polygon from an array of points in a particular
|
498
498
|
# color.
|
499
499
|
|
500
|
-
def polygon
|
500
|
+
def polygon points, c
|
501
|
+
return unless points.size > 1
|
502
|
+
|
501
503
|
points << points.first
|
502
|
-
|
503
|
-
|
504
|
-
|
504
|
+
|
505
|
+
xs, ys = points.transpose
|
506
|
+
|
507
|
+
renderer.draw_polygon xs, ys.map { |y| h-y-1 }, c, :aa
|
505
508
|
end
|
506
509
|
|
507
510
|
##
|
data/lib/graphics.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDPjCCAiagAwIBAgIBBzANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
|
14
14
|
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
15
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2dOG
|
30
|
+
nsNBRuQJ1UfiCG97a6DNm+Fr
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
32
|
+
date: 2023-07-26 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rdoc
|
@@ -71,14 +71,14 @@ dependencies:
|
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '4.0'
|
75
75
|
type: :development
|
76
76
|
prerelease: false
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
81
|
+
version: '4.0'
|
82
82
|
description: |-
|
83
83
|
Graphics provides a simple framework to implement games and/or
|
84
84
|
simulations and is designed to follow mathematical conventions, NOT
|
@@ -182,8 +182,9 @@ files:
|
|
182
182
|
homepage: https://github.com/zenspider/graphics
|
183
183
|
licenses:
|
184
184
|
- MIT
|
185
|
-
metadata:
|
186
|
-
|
185
|
+
metadata:
|
186
|
+
homepage_uri: https://github.com/zenspider/graphics
|
187
|
+
post_install_message:
|
187
188
|
rdoc_options:
|
188
189
|
- "--main"
|
189
190
|
- README.rdoc
|
@@ -193,16 +194,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
193
194
|
requirements:
|
194
195
|
- - ">="
|
195
196
|
- !ruby/object:Gem::Version
|
196
|
-
version: '
|
197
|
+
version: '2.7'
|
197
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
199
|
requirements:
|
199
200
|
- - ">="
|
200
201
|
- !ruby/object:Gem::Version
|
201
202
|
version: '0'
|
202
203
|
requirements: []
|
203
|
-
|
204
|
-
|
205
|
-
signing_key:
|
204
|
+
rubygems_version: 3.4.10
|
205
|
+
signing_key:
|
206
206
|
specification_version: 4
|
207
207
|
summary: Graphics provides a simple framework to implement games and/or simulations
|
208
208
|
and is designed to follow mathematical conventions, NOT game programming conventions
|
metadata.gz.sig
CHANGED
Binary file
|