texplay 0.2.800 → 0.2.900
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.
- data/CHANGELOG +138 -119
- data/README.markdown +43 -41
- data/Rakefile +68 -68
- data/examples/common.rb +8 -8
- data/examples/example_alpha_blend.rb +31 -31
- data/examples/example_bezier.rb +42 -42
- data/examples/example_color_control.rb +69 -69
- data/examples/example_color_transform.rb +64 -67
- data/examples/example_color_transform_circle.rb +65 -0
- data/examples/example_dup.rb +75 -75
- data/examples/example_each.rb +42 -42
- data/examples/example_effect.rb +35 -35
- data/examples/example_fill.rb +44 -44
- data/examples/example_fill_old.rb +49 -49
- data/examples/example_fluent.rb +31 -31
- data/examples/example_gen_eval.rb +34 -34
- data/examples/example_hash_arguments.rb +47 -47
- data/examples/example_light.rb +77 -0
- data/examples/example_lsystem.rb +61 -61
- data/examples/example_melt.rb +27 -27
- data/examples/example_meyet.rb +64 -0
- data/examples/example_polyline.rb +43 -43
- data/examples/example_scale.rb +29 -29
- data/examples/example_simple.rb +48 -38
- data/examples/example_sync.rb +60 -60
- data/examples/example_trace.rb +1 -1
- data/examples/example_turtle.rb +40 -40
- data/examples/example_weird.rb +3 -1
- data/examples/media/Thumbs.db +0 -0
- data/ext/texplay/actions.c +999 -1001
- data/ext/texplay/actions.h +60 -60
- data/ext/texplay/bindings.c +1162 -1149
- data/ext/texplay/bindings.h +46 -46
- data/ext/texplay/cache.c +118 -118
- data/ext/texplay/cache.h +24 -24
- data/ext/texplay/compat.h +27 -27
- data/ext/texplay/extconf.rb +28 -28
- data/ext/texplay/gen_eval.c +211 -211
- data/ext/texplay/gen_eval.h +20 -20
- data/ext/texplay/graphics_utils.c +188 -63
- data/ext/texplay/graphics_utils.h +0 -1
- data/ext/texplay/object2module.c +171 -171
- data/ext/texplay/object2module.h +11 -11
- data/ext/texplay/texplay.c +169 -169
- data/ext/texplay/texplay.h +147 -130
- data/ext/texplay/utils.c +816 -752
- data/ext/texplay/utils.h +151 -145
- data/lib/texplay-contrib.rb +171 -171
- data/lib/texplay.rb +162 -137
- data/lib/texplay/version.rb +1 -1
- metadata +9 -5
data/ext/texplay/object2module.h
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/* object2module.h */
|
|
2
|
-
|
|
3
|
-
#ifndef GUARD_OBJECT2MODULE_H
|
|
4
|
-
#define GUARD_OBJECT2MODULE_H
|
|
5
|
-
|
|
6
|
-
VALUE rb_gen_include(int argc, VALUE * argv, VALUE self);
|
|
7
|
-
VALUE rb_gen_extend(int argc, VALUE * argv, VALUE self);
|
|
8
|
-
VALUE rb_to_module(VALUE self);
|
|
9
|
-
VALUE rb_reset_tbls(VALUE self);
|
|
10
|
-
|
|
11
|
-
#endif
|
|
1
|
+
/* object2module.h */
|
|
2
|
+
|
|
3
|
+
#ifndef GUARD_OBJECT2MODULE_H
|
|
4
|
+
#define GUARD_OBJECT2MODULE_H
|
|
5
|
+
|
|
6
|
+
VALUE rb_gen_include(int argc, VALUE * argv, VALUE self);
|
|
7
|
+
VALUE rb_gen_extend(int argc, VALUE * argv, VALUE self);
|
|
8
|
+
VALUE rb_to_module(VALUE self);
|
|
9
|
+
VALUE rb_reset_tbls(VALUE self);
|
|
10
|
+
|
|
11
|
+
#endif
|
data/ext/texplay/texplay.c
CHANGED
|
@@ -1,169 +1,169 @@
|
|
|
1
|
-
/* texplay.c, light-weight alternative to rmagick for ruby */
|
|
2
|
-
/* (C) John Mair 2009
|
|
3
|
-
* This program is distributed under the terms of the MIT License
|
|
4
|
-
* */
|
|
5
|
-
|
|
6
|
-
#include <ruby.h>
|
|
7
|
-
#include <stdio.h>
|
|
8
|
-
#include <time.h>
|
|
9
|
-
#include "texplay.h"
|
|
10
|
-
#include "actions.h"
|
|
11
|
-
#include "utils.h"
|
|
12
|
-
#include "bindings.h"
|
|
13
|
-
#include "object2module.h"
|
|
14
|
-
#include "gen_eval.h"
|
|
15
|
-
#ifdef __APPLE__
|
|
16
|
-
# include <glut.h>
|
|
17
|
-
#else
|
|
18
|
-
# include <GL/glut.h>
|
|
19
|
-
#endif
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/* setup ruby bindings */
|
|
23
|
-
|
|
24
|
-
/** constructor for TPPoint class **/
|
|
25
|
-
static VALUE m_init_TPPoint(int argc, VALUE * argv, VALUE self);
|
|
26
|
-
static void monkey_patch_gosu(void);
|
|
27
|
-
|
|
28
|
-
void
|
|
29
|
-
Init_texplay() {
|
|
30
|
-
|
|
31
|
-
VALUE jm_Module = rb_define_module("TexPlay");
|
|
32
|
-
VALUE TPPoint = rb_define_class_under(jm_Module, "TPPoint", rb_cObject);
|
|
33
|
-
|
|
34
|
-
/** define basic point class TPPoint **/
|
|
35
|
-
rb_attr(TPPoint, rb_intern("x"), 1, 1, Qtrue);
|
|
36
|
-
rb_attr(TPPoint, rb_intern("y"), 1, 1, Qtrue);
|
|
37
|
-
rb_define_method(TPPoint, "initialize", m_init_TPPoint, -1);
|
|
38
|
-
/** end of TPPoint definition **/
|
|
39
|
-
|
|
40
|
-
/* TexPlay methods */
|
|
41
|
-
rb_define_method(jm_Module, "paint", m_paint, -1);
|
|
42
|
-
rb_define_method(jm_Module, "get_pixel", m_getpixel, -1);
|
|
43
|
-
rb_define_method(jm_Module, "circle", m_circle, -1);
|
|
44
|
-
rb_define_method(jm_Module, "line", m_line, -1);
|
|
45
|
-
rb_define_method(jm_Module, "rect", m_rect, -1);
|
|
46
|
-
rb_define_method(jm_Module, "clear", m_clear, -1);
|
|
47
|
-
rb_define_method(jm_Module, "pixel", m_pixel, -1);
|
|
48
|
-
rb_define_method(jm_Module, "fill", m_flood_fill, -1);
|
|
49
|
-
rb_define_method(jm_Module, "bezier", m_bezier, -1);
|
|
50
|
-
rb_define_method(jm_Module, "polyline", m_polyline, -1);
|
|
51
|
-
rb_define_method(jm_Module, "ngon", m_ngon, -1);
|
|
52
|
-
|
|
53
|
-
rb_define_method(jm_Module, "splice", m_splice, -1);
|
|
54
|
-
|
|
55
|
-
rb_define_method(jm_Module, "color", m_color, -1);
|
|
56
|
-
rb_define_method(jm_Module, "offset", m_offset, -1);
|
|
57
|
-
rb_define_method(jm_Module, "method_missing", m_missing, -1);
|
|
58
|
-
rb_define_method(jm_Module, "quad_cached?", m_quad_cached, 0);
|
|
59
|
-
|
|
60
|
-
rb_define_method(jm_Module, "each", m_each, -1);
|
|
61
|
-
|
|
62
|
-
/* needs to be updated, not yet done **/
|
|
63
|
-
/* rb_define_method(jm_Module, "bitmask", m_bitmask, -1); */
|
|
64
|
-
/* rb_define_method(jm_Module, "leftshift", m_lshift, -1); */
|
|
65
|
-
/* rb_define_method(jm_Module, "rightshift", m_rshift, -1); */
|
|
66
|
-
/* rb_define_method(jm_Module, "[]=", m_special_pixel, -1); */
|
|
67
|
-
|
|
68
|
-
rb_define_method(jm_Module, "dup", m_dup_image, 0);
|
|
69
|
-
rb_define_method(jm_Module, "clone", m_clone_image, 0);
|
|
70
|
-
rb_define_method(jm_Module, "to_blob", m_to_blob, 0);
|
|
71
|
-
rb_define_method(jm_Module, "force_sync", m_force_sync, 1);
|
|
72
|
-
rb_define_method(jm_Module, "set_options", m_user_set_options, 1);
|
|
73
|
-
rb_define_method(jm_Module, "get_options", m_get_options, 0);
|
|
74
|
-
rb_define_method(jm_Module, "delete_options", m_user_delete_options, 0);
|
|
75
|
-
|
|
76
|
-
rb_define_method(jm_Module, "refresh_cache", m_cache_refresh, 0);
|
|
77
|
-
|
|
78
|
-
/* a constant containing the sidelength of largest allowable quad */
|
|
79
|
-
rb_define_const(jm_Module, "TP_MAX_QUAD_SIZE", INT2FIX(max_quad_size() - 2));
|
|
80
|
-
|
|
81
|
-
/* singleton method for creating & removing macros */
|
|
82
|
-
rb_define_singleton_method(jm_Module, "create_macro", M_create_macro, 1);
|
|
83
|
-
rb_define_singleton_method(jm_Module, "remove_macro", M_remove_macro, 1);
|
|
84
|
-
rb_define_singleton_method(jm_Module, "refresh_cache_all", M_refresh_cache_all, 0);
|
|
85
|
-
rb_define_singleton_method(jm_Module, "create_blank_image", M_create_blank, 3);
|
|
86
|
-
|
|
87
|
-
/** aliases; must be made on singleton class because we're using class methods **/
|
|
88
|
-
rb_define_method(jm_Module, "box", m_rect, -1);
|
|
89
|
-
rb_define_method(jm_Module, "colour", m_color, -1);
|
|
90
|
-
rb_define_method(jm_Module, "composite", m_splice, -1);
|
|
91
|
-
rb_define_method(jm_Module, "set_pixel", m_pixel, -1);
|
|
92
|
-
rb_define_method(jm_Module, "[]", m_getpixel, 2);
|
|
93
|
-
/** end of aliases **/
|
|
94
|
-
|
|
95
|
-
/** associated with gen_eval **/
|
|
96
|
-
rb_define_method(rb_cObject, "gen_eval", rb_gen_eval, -1);
|
|
97
|
-
rb_define_method(rb_cObject, "capture", rb_capture, 0);
|
|
98
|
-
|
|
99
|
-
rb_define_method(rb_cObject, "to_module", rb_to_module , 0);
|
|
100
|
-
rb_define_method(rb_cObject, "reset_tbls", rb_reset_tbls , 0);
|
|
101
|
-
rb_define_method(rb_cObject, "gen_extend", rb_gen_extend, -1);
|
|
102
|
-
rb_define_method(rb_cModule, "gen_include", rb_gen_include, -1);
|
|
103
|
-
|
|
104
|
-
rb_define_alias(rb_cObject, "gen_eval_with", "gen_eval");
|
|
105
|
-
/** end of gen_eval defs **/
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
/** basic setup **/
|
|
109
|
-
|
|
110
|
-
/* seed the random number generator */
|
|
111
|
-
srand(time(NULL));
|
|
112
|
-
|
|
113
|
-
monkey_patch_gosu();
|
|
114
|
-
/** end basic setup **/
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/** constructor for TPPoint class **/
|
|
118
|
-
static VALUE
|
|
119
|
-
m_init_TPPoint(int argc, VALUE * argv, VALUE self)
|
|
120
|
-
{
|
|
121
|
-
if(argc == 0) {
|
|
122
|
-
rb_iv_set(self, "@x", INT2FIX(0));
|
|
123
|
-
rb_iv_set(self, "@y", INT2FIX(0));
|
|
124
|
-
}
|
|
125
|
-
else if(argc == 2){
|
|
126
|
-
if(is_a_num(argv[0]) && is_a_num(argv[1])) {
|
|
127
|
-
rb_iv_set(self, "@x", argv[0]);
|
|
128
|
-
rb_iv_set(self, "@y", argv[1]);
|
|
129
|
-
}
|
|
130
|
-
else
|
|
131
|
-
rb_raise(rb_eArgError, "must provide two numbers");
|
|
132
|
-
}
|
|
133
|
-
else
|
|
134
|
-
rb_raise(rb_eArgError, "please provide x and y args only");
|
|
135
|
-
|
|
136
|
-
return Qnil;
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
/** end constructor for TPPoint **/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
static VALUE
|
|
143
|
-
gosu_window_to_blob(VALUE self)
|
|
144
|
-
{
|
|
145
|
-
int width, height;
|
|
146
|
-
VALUE blob;
|
|
147
|
-
|
|
148
|
-
width = rb_funcall(self, rb_intern("width"), 0);
|
|
149
|
-
height = rb_funcall(self, rb_intern("height"), 0);
|
|
150
|
-
|
|
151
|
-
blob = rb_str_new(NULL, 4 * width * height);
|
|
152
|
-
|
|
153
|
-
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, RSTRING_PTR(blob));
|
|
154
|
-
|
|
155
|
-
return blob;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
static void
|
|
159
|
-
monkey_patch_gosu(void)
|
|
160
|
-
{
|
|
161
|
-
VALUE Gosu = rb_const_get(rb_cObject, rb_intern("Gosu"));
|
|
162
|
-
VALUE GosuWindow = rb_const_get(Gosu, rb_intern("Window"));
|
|
163
|
-
|
|
164
|
-
rb_define_method(GosuWindow, "to_blob", gosu_window_to_blob, 0);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
1
|
+
/* texplay.c, light-weight alternative to rmagick for ruby */
|
|
2
|
+
/* (C) John Mair 2009
|
|
3
|
+
* This program is distributed under the terms of the MIT License
|
|
4
|
+
* */
|
|
5
|
+
|
|
6
|
+
#include <ruby.h>
|
|
7
|
+
#include <stdio.h>
|
|
8
|
+
#include <time.h>
|
|
9
|
+
#include "texplay.h"
|
|
10
|
+
#include "actions.h"
|
|
11
|
+
#include "utils.h"
|
|
12
|
+
#include "bindings.h"
|
|
13
|
+
#include "object2module.h"
|
|
14
|
+
#include "gen_eval.h"
|
|
15
|
+
#ifdef __APPLE__
|
|
16
|
+
# include <glut.h>
|
|
17
|
+
#else
|
|
18
|
+
# include <GL/glut.h>
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/* setup ruby bindings */
|
|
23
|
+
|
|
24
|
+
/** constructor for TPPoint class **/
|
|
25
|
+
static VALUE m_init_TPPoint(int argc, VALUE * argv, VALUE self);
|
|
26
|
+
static void monkey_patch_gosu(void);
|
|
27
|
+
|
|
28
|
+
void
|
|
29
|
+
Init_texplay() {
|
|
30
|
+
|
|
31
|
+
VALUE jm_Module = rb_define_module("TexPlay");
|
|
32
|
+
VALUE TPPoint = rb_define_class_under(jm_Module, "TPPoint", rb_cObject);
|
|
33
|
+
|
|
34
|
+
/** define basic point class TPPoint **/
|
|
35
|
+
rb_attr(TPPoint, rb_intern("x"), 1, 1, Qtrue);
|
|
36
|
+
rb_attr(TPPoint, rb_intern("y"), 1, 1, Qtrue);
|
|
37
|
+
rb_define_method(TPPoint, "initialize", m_init_TPPoint, -1);
|
|
38
|
+
/** end of TPPoint definition **/
|
|
39
|
+
|
|
40
|
+
/* TexPlay methods */
|
|
41
|
+
rb_define_method(jm_Module, "paint", m_paint, -1);
|
|
42
|
+
rb_define_method(jm_Module, "get_pixel", m_getpixel, -1);
|
|
43
|
+
rb_define_method(jm_Module, "circle", m_circle, -1);
|
|
44
|
+
rb_define_method(jm_Module, "line", m_line, -1);
|
|
45
|
+
rb_define_method(jm_Module, "rect", m_rect, -1);
|
|
46
|
+
rb_define_method(jm_Module, "clear", m_clear, -1);
|
|
47
|
+
rb_define_method(jm_Module, "pixel", m_pixel, -1);
|
|
48
|
+
rb_define_method(jm_Module, "fill", m_flood_fill, -1);
|
|
49
|
+
rb_define_method(jm_Module, "bezier", m_bezier, -1);
|
|
50
|
+
rb_define_method(jm_Module, "polyline", m_polyline, -1);
|
|
51
|
+
rb_define_method(jm_Module, "ngon", m_ngon, -1);
|
|
52
|
+
|
|
53
|
+
rb_define_method(jm_Module, "splice", m_splice, -1);
|
|
54
|
+
|
|
55
|
+
rb_define_method(jm_Module, "color", m_color, -1);
|
|
56
|
+
rb_define_method(jm_Module, "offset", m_offset, -1);
|
|
57
|
+
rb_define_method(jm_Module, "method_missing", m_missing, -1);
|
|
58
|
+
rb_define_method(jm_Module, "quad_cached?", m_quad_cached, 0);
|
|
59
|
+
|
|
60
|
+
rb_define_method(jm_Module, "each", m_each, -1);
|
|
61
|
+
|
|
62
|
+
/* needs to be updated, not yet done **/
|
|
63
|
+
/* rb_define_method(jm_Module, "bitmask", m_bitmask, -1); */
|
|
64
|
+
/* rb_define_method(jm_Module, "leftshift", m_lshift, -1); */
|
|
65
|
+
/* rb_define_method(jm_Module, "rightshift", m_rshift, -1); */
|
|
66
|
+
/* rb_define_method(jm_Module, "[]=", m_special_pixel, -1); */
|
|
67
|
+
|
|
68
|
+
rb_define_method(jm_Module, "dup", m_dup_image, 0);
|
|
69
|
+
rb_define_method(jm_Module, "clone", m_clone_image, 0);
|
|
70
|
+
rb_define_method(jm_Module, "to_blob", m_to_blob, 0);
|
|
71
|
+
rb_define_method(jm_Module, "force_sync", m_force_sync, 1);
|
|
72
|
+
rb_define_method(jm_Module, "set_options", m_user_set_options, 1);
|
|
73
|
+
rb_define_method(jm_Module, "get_options", m_get_options, 0);
|
|
74
|
+
rb_define_method(jm_Module, "delete_options", m_user_delete_options, 0);
|
|
75
|
+
|
|
76
|
+
rb_define_method(jm_Module, "refresh_cache", m_cache_refresh, 0);
|
|
77
|
+
|
|
78
|
+
/* a constant containing the sidelength of largest allowable quad */
|
|
79
|
+
rb_define_const(jm_Module, "TP_MAX_QUAD_SIZE", INT2FIX(max_quad_size() - 2));
|
|
80
|
+
|
|
81
|
+
/* singleton method for creating & removing macros */
|
|
82
|
+
rb_define_singleton_method(jm_Module, "create_macro", M_create_macro, 1);
|
|
83
|
+
rb_define_singleton_method(jm_Module, "remove_macro", M_remove_macro, 1);
|
|
84
|
+
rb_define_singleton_method(jm_Module, "refresh_cache_all", M_refresh_cache_all, 0);
|
|
85
|
+
/* rb_define_singleton_method(jm_Module, "create_blank_image", M_create_blank, 3); */
|
|
86
|
+
|
|
87
|
+
/** aliases; must be made on singleton class because we're using class methods **/
|
|
88
|
+
rb_define_method(jm_Module, "box", m_rect, -1);
|
|
89
|
+
rb_define_method(jm_Module, "colour", m_color, -1);
|
|
90
|
+
rb_define_method(jm_Module, "composite", m_splice, -1);
|
|
91
|
+
rb_define_method(jm_Module, "set_pixel", m_pixel, -1);
|
|
92
|
+
rb_define_method(jm_Module, "[]", m_getpixel, 2);
|
|
93
|
+
/** end of aliases **/
|
|
94
|
+
|
|
95
|
+
/** associated with gen_eval **/
|
|
96
|
+
rb_define_method(rb_cObject, "gen_eval", rb_gen_eval, -1);
|
|
97
|
+
rb_define_method(rb_cObject, "capture", rb_capture, 0);
|
|
98
|
+
|
|
99
|
+
rb_define_method(rb_cObject, "to_module", rb_to_module , 0);
|
|
100
|
+
rb_define_method(rb_cObject, "reset_tbls", rb_reset_tbls , 0);
|
|
101
|
+
rb_define_method(rb_cObject, "gen_extend", rb_gen_extend, -1);
|
|
102
|
+
rb_define_method(rb_cModule, "gen_include", rb_gen_include, -1);
|
|
103
|
+
|
|
104
|
+
rb_define_alias(rb_cObject, "gen_eval_with", "gen_eval");
|
|
105
|
+
/** end of gen_eval defs **/
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
/** basic setup **/
|
|
109
|
+
|
|
110
|
+
/* seed the random number generator */
|
|
111
|
+
srand(time(NULL));
|
|
112
|
+
|
|
113
|
+
monkey_patch_gosu();
|
|
114
|
+
/** end basic setup **/
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** constructor for TPPoint class **/
|
|
118
|
+
static VALUE
|
|
119
|
+
m_init_TPPoint(int argc, VALUE * argv, VALUE self)
|
|
120
|
+
{
|
|
121
|
+
if(argc == 0) {
|
|
122
|
+
rb_iv_set(self, "@x", INT2FIX(0));
|
|
123
|
+
rb_iv_set(self, "@y", INT2FIX(0));
|
|
124
|
+
}
|
|
125
|
+
else if(argc == 2){
|
|
126
|
+
if(is_a_num(argv[0]) && is_a_num(argv[1])) {
|
|
127
|
+
rb_iv_set(self, "@x", argv[0]);
|
|
128
|
+
rb_iv_set(self, "@y", argv[1]);
|
|
129
|
+
}
|
|
130
|
+
else
|
|
131
|
+
rb_raise(rb_eArgError, "must provide two numbers");
|
|
132
|
+
}
|
|
133
|
+
else
|
|
134
|
+
rb_raise(rb_eArgError, "please provide x and y args only");
|
|
135
|
+
|
|
136
|
+
return Qnil;
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
/** end constructor for TPPoint **/
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
static VALUE
|
|
143
|
+
gosu_window_to_blob(VALUE self)
|
|
144
|
+
{
|
|
145
|
+
int width, height;
|
|
146
|
+
VALUE blob;
|
|
147
|
+
|
|
148
|
+
width = rb_funcall(self, rb_intern("width"), 0);
|
|
149
|
+
height = rb_funcall(self, rb_intern("height"), 0);
|
|
150
|
+
|
|
151
|
+
blob = rb_str_new(NULL, 4 * width * height);
|
|
152
|
+
|
|
153
|
+
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, RSTRING_PTR(blob));
|
|
154
|
+
|
|
155
|
+
return blob;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
static void
|
|
159
|
+
monkey_patch_gosu(void)
|
|
160
|
+
{
|
|
161
|
+
VALUE Gosu = rb_const_get(rb_cObject, rb_intern("Gosu"));
|
|
162
|
+
VALUE GosuWindow = rb_const_get(Gosu, rb_intern("Window"));
|
|
163
|
+
|
|
164
|
+
rb_define_method(GosuWindow, "to_blob", gosu_window_to_blob, 0);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
data/ext/texplay/texplay.h
CHANGED
|
@@ -1,130 +1,147 @@
|
|
|
1
|
-
/* texplay.h (C) John Mair 2008
|
|
2
|
-
* This program is distributed under the terms of the MIT License
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* */
|
|
6
|
-
|
|
7
|
-
#ifndef GUARD_TEXPLAY_H
|
|
8
|
-
#define GUARD_TEXPLAY_H
|
|
9
|
-
|
|
10
|
-
#include <ruby.h>
|
|
11
|
-
|
|
12
|
-
/* #defines */
|
|
13
|
-
#define OOB_VAL 9999
|
|
14
|
-
#define XMAX_OOB OOB_VAL
|
|
15
|
-
#define YMAX_OOB OOB_VAL
|
|
16
|
-
#define XMIN_OOB -OOB_VAL
|
|
17
|
-
#define YMIN_OOB -OOB_VAL
|
|
18
|
-
|
|
19
|
-
#define PI 3.14159265358979
|
|
20
|
-
|
|
21
|
-
/* macros */
|
|
22
|
-
#define SWAP(X, Y) {(X) ^= (Y); (Y) ^= (X); (X) ^= (Y);}
|
|
23
|
-
#define ROUND(X) (int)((X) + 0.5)
|
|
24
|
-
#define ARY_SIZE(X) sizeof(X) / sizeof(*X)
|
|
25
|
-
#define SGN(X) ((X) >= 0 ? 1 : -1)
|
|
26
|
-
#define MAX(X, Y) ((X) > (Y)) ? (X) :(Y)
|
|
27
|
-
#define MIN(X, Y) ((X) < (Y)) ? (X) : (Y)
|
|
28
|
-
#define ABS(X) ((X) >= 0 ? (X) : -(X))
|
|
29
|
-
|
|
30
|
-
/* enums */
|
|
31
|
-
typedef enum e_bool {
|
|
32
|
-
false, true
|
|
33
|
-
} bool;
|
|
34
|
-
|
|
35
|
-
typedef enum e_color {
|
|
36
|
-
red, green, blue, alpha
|
|
37
|
-
} color_t;
|
|
38
|
-
|
|
39
|
-
typedef enum e_sync_mode {
|
|
40
|
-
lazy_sync, eager_sync, no_sync
|
|
41
|
-
} sync;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
typedef struct {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
int
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/*
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
/*
|
|
122
|
-
bool
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
1
|
+
/* texplay.h (C) John Mair 2008
|
|
2
|
+
* This program is distributed under the terms of the MIT License
|
|
3
|
+
*
|
|
4
|
+
*
|
|
5
|
+
* */
|
|
6
|
+
|
|
7
|
+
#ifndef GUARD_TEXPLAY_H
|
|
8
|
+
#define GUARD_TEXPLAY_H
|
|
9
|
+
|
|
10
|
+
#include <ruby.h>
|
|
11
|
+
|
|
12
|
+
/* #defines */
|
|
13
|
+
#define OOB_VAL 9999
|
|
14
|
+
#define XMAX_OOB OOB_VAL
|
|
15
|
+
#define YMAX_OOB OOB_VAL
|
|
16
|
+
#define XMIN_OOB -OOB_VAL
|
|
17
|
+
#define YMIN_OOB -OOB_VAL
|
|
18
|
+
#define RGBA_LIST_SIZE 100
|
|
19
|
+
#define PI 3.14159265358979
|
|
20
|
+
|
|
21
|
+
/* macros */
|
|
22
|
+
#define SWAP(X, Y) {(X) ^= (Y); (Y) ^= (X); (X) ^= (Y);}
|
|
23
|
+
#define ROUND(X) (int)((X) + 0.5)
|
|
24
|
+
#define ARY_SIZE(X) sizeof(X) / sizeof(*X)
|
|
25
|
+
#define SGN(X) ((X) >= 0 ? 1 : -1)
|
|
26
|
+
#define MAX(X, Y) ((X) > (Y)) ? (X) :(Y)
|
|
27
|
+
#define MIN(X, Y) ((X) < (Y)) ? (X) : (Y)
|
|
28
|
+
#define ABS(X) ((X) >= 0 ? (X) : -(X))
|
|
29
|
+
|
|
30
|
+
/* enums */
|
|
31
|
+
typedef enum e_bool {
|
|
32
|
+
false, true
|
|
33
|
+
} bool;
|
|
34
|
+
|
|
35
|
+
typedef enum e_color {
|
|
36
|
+
red, green, blue, alpha
|
|
37
|
+
} color_t;
|
|
38
|
+
|
|
39
|
+
typedef enum e_sync_mode {
|
|
40
|
+
lazy_sync, eager_sync, no_sync
|
|
41
|
+
} sync;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
typedef enum {
|
|
45
|
+
clear, copy, noop,
|
|
46
|
+
set, copy_inverted,
|
|
47
|
+
invert, and_reverse, and,
|
|
48
|
+
or, nand, nor, xor,
|
|
49
|
+
equiv, and_inverted,
|
|
50
|
+
or_inverted, additive,
|
|
51
|
+
multiply, screen, overlay,
|
|
52
|
+
darken, lighten, color_dodge,
|
|
53
|
+
color_burn, hard_light, soft_light,
|
|
54
|
+
difference, exclusion
|
|
55
|
+
} draw_mode;
|
|
56
|
+
|
|
57
|
+
/* structs */
|
|
58
|
+
typedef struct s_rgba {
|
|
59
|
+
float red, green, blue, alpha;
|
|
60
|
+
} rgba;
|
|
61
|
+
|
|
62
|
+
typedef struct {
|
|
63
|
+
rgba colors[RGBA_LIST_SIZE];
|
|
64
|
+
int size;
|
|
65
|
+
} rgba_list;
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
/* stores image data */
|
|
69
|
+
typedef struct {
|
|
70
|
+
int width, height;
|
|
71
|
+
float top, left;
|
|
72
|
+
int tname;
|
|
73
|
+
float * td_array;
|
|
74
|
+
int yincr, firstpixel;
|
|
75
|
+
int x_offset, y_offset;
|
|
76
|
+
VALUE image;
|
|
77
|
+
} texture_info;
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
/* convenience macro */
|
|
81
|
+
#define IMAGE_BOUNDS(X) ((image_bounds *) (X))
|
|
82
|
+
typedef struct {
|
|
83
|
+
int xmin;
|
|
84
|
+
int ymin;
|
|
85
|
+
int xmax;
|
|
86
|
+
int ymax;
|
|
87
|
+
} image_bounds;
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
typedef struct action_struct {
|
|
91
|
+
int xmin, ymin, xmax, ymax;
|
|
92
|
+
sync sync_mode;
|
|
93
|
+
|
|
94
|
+
/* pointer to associated texture */
|
|
95
|
+
/* a bit of a kludge having this here
|
|
96
|
+
since it's only being used by convert_image_local_color_to_rgba */
|
|
97
|
+
texture_info * tex;
|
|
98
|
+
|
|
99
|
+
VALUE hash_arg;
|
|
100
|
+
|
|
101
|
+
/* action color */
|
|
102
|
+
rgba color;
|
|
103
|
+
|
|
104
|
+
/* pen data */
|
|
105
|
+
struct {
|
|
106
|
+
|
|
107
|
+
/* color control, dynamic */
|
|
108
|
+
bool has_color_control_proc;
|
|
109
|
+
VALUE color_control_proc;
|
|
110
|
+
int color_control_arity;
|
|
111
|
+
|
|
112
|
+
/* color control, static */
|
|
113
|
+
bool has_color_control_transform;
|
|
114
|
+
rgba color_mult;
|
|
115
|
+
rgba color_add;
|
|
116
|
+
|
|
117
|
+
/* texture fill */
|
|
118
|
+
bool has_source_texture;
|
|
119
|
+
texture_info source_tex;
|
|
120
|
+
|
|
121
|
+
/* lerp */
|
|
122
|
+
bool has_lerp;
|
|
123
|
+
float lerp;
|
|
124
|
+
|
|
125
|
+
/* alpha blend */
|
|
126
|
+
bool alpha_blend;
|
|
127
|
+
|
|
128
|
+
/* drawing mode */
|
|
129
|
+
bool has_drawing_mode;
|
|
130
|
+
draw_mode drawing_mode;
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
/* color selection */
|
|
135
|
+
|
|
136
|
+
bool has_color_select;
|
|
137
|
+
rgba_list source_select;
|
|
138
|
+
rgba_list source_ignore;
|
|
139
|
+
rgba_list dest_select;
|
|
140
|
+
rgba_list dest_ignore;
|
|
141
|
+
|
|
142
|
+
} pen;
|
|
143
|
+
|
|
144
|
+
} action_struct;
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
#endif
|