texplay 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/CHANGELOG +63 -0
  2. data/README +21 -0
  3. data/README1st +9 -0
  4. data/Rakefile +85 -0
  5. data/examples/basic.rb +48 -0
  6. data/examples/basic2.rb +37 -0
  7. data/examples/benchmark.rb +299 -0
  8. data/examples/common.rb +8 -0
  9. data/examples/example_alpha_blend.rb +31 -0
  10. data/examples/example_bezier.rb +51 -0
  11. data/examples/example_color_control.rb +68 -0
  12. data/examples/example_color_transform.rb +29 -0
  13. data/examples/example_dup.rb +52 -0
  14. data/examples/example_each.rb +42 -0
  15. data/examples/example_effect.rb +35 -0
  16. data/examples/example_fill.rb +49 -0
  17. data/examples/example_fill_old.rb +49 -0
  18. data/examples/example_fluent.rb +31 -0
  19. data/examples/example_gen_eval.rb +34 -0
  20. data/examples/example_hash_arguments.rb +47 -0
  21. data/examples/example_melt.rb +27 -0
  22. data/examples/example_polyline.rb +43 -0
  23. data/examples/example_simple.rb +35 -0
  24. data/examples/example_splice.rb +37 -0
  25. data/examples/example_sync.rb +60 -0
  26. data/examples/example_turtle.rb +40 -0
  27. data/examples/media/empty2.png +0 -0
  28. data/examples/media/gosu.png +0 -0
  29. data/examples/media/maria.png +0 -0
  30. data/examples/media/rose.bmp +0 -0
  31. data/examples/media/sand1.png +0 -0
  32. data/examples/media/sunset.png +0 -0
  33. data/examples/media/texplay.png +0 -0
  34. data/examples/specs.rb +240 -0
  35. data/examples/test.rb +70 -0
  36. data/examples/test2.rb +72 -0
  37. data/lib/texplay-contrib.rb +77 -0
  38. data/lib/texplay.rb +134 -0
  39. data/src/Makefile +181 -0
  40. data/src/TAGS +286 -0
  41. data/src/actions.c +1306 -0
  42. data/src/actions.h +52 -0
  43. data/src/actions.o +0 -0
  44. data/src/bindings.c +1081 -0
  45. data/src/bindings.h +45 -0
  46. data/src/bindings.o +0 -0
  47. data/src/cache.c +132 -0
  48. data/src/cache.h +24 -0
  49. data/src/cache.o +0 -0
  50. data/src/compat.h +23 -0
  51. data/src/ctexplay.so +0 -0
  52. data/src/extconf.rb +18 -0
  53. data/src/gen_eval.c +209 -0
  54. data/src/gen_eval.h +20 -0
  55. data/src/gen_eval.o +0 -0
  56. data/src/mkmf.log +22 -0
  57. data/src/object2module.c +171 -0
  58. data/src/object2module.h +11 -0
  59. data/src/object2module.o +0 -0
  60. data/src/texplay.c +136 -0
  61. data/src/texplay.h +107 -0
  62. data/src/texplay.o +0 -0
  63. data/src/utils.c +959 -0
  64. data/src/utils.h +143 -0
  65. data/src/utils.o +0 -0
  66. metadata +126 -0
@@ -0,0 +1,143 @@
1
+ #ifndef GUARD_UTILS_H
2
+ #define GUARD_UTILS_H
3
+
4
+
5
+ /* for use with get_image_local, and set_image_local */
6
+ #define DRAW_OFFSET 0
7
+ #define LAZY_BOUNDS 1
8
+ #define IMAGE_COLOR 2
9
+ #define USER_DEFAULTS 3
10
+
11
+
12
+ /* color and pixel related functions */
13
+ rgba find_color_from_string(char * try_color);
14
+ bool cmp_color(rgba color1, rgba color2);
15
+ void color_copy(float * source, float * dest);
16
+ rgba get_pixel_color(texture_info * tex, int x, int y) ;
17
+ float* get_pixel_data(texture_info * tex, int x, int y);
18
+ void set_pixel_color(rgba * pixel_color, texture_info * tex, int x, int y);
19
+ void zero_color(float * tex);
20
+ bool not_a_color(rgba color1);
21
+ bool is_a_color(rgba color1);
22
+ VALUE convert_rgba_to_rb_color(rgba * pix);
23
+ rgba convert_rb_color_to_rgba(VALUE cval);
24
+
25
+ VALUE save_rgba_to_image_local_color(VALUE image, rgba color);
26
+ rgba convert_image_local_color_to_rgba(VALUE image);
27
+
28
+
29
+ /* string/symbol related functions */
30
+ char* lowercase(char*);
31
+ char* sym2string(VALUE);
32
+ VALUE string2sym(char*);
33
+
34
+ /* is it a hash? */
35
+ bool is_a_hash(VALUE try_hash);
36
+
37
+ /* is an array? */
38
+ bool is_an_array(VALUE try_array);
39
+
40
+ /* is a num? */
41
+ bool is_a_num(VALUE try_num);
42
+
43
+ /* helpful C wrapper for rb_hash_aref */
44
+ VALUE get_from_hash(VALUE hash, char * sym);
45
+
46
+ /* a wrapper for rb_hash_aset */
47
+ VALUE set_hash_value(VALUE hash, char * sym, VALUE val);
48
+
49
+ /* a wrapper for rb_hash_delete */
50
+ VALUE delete_from_hash(VALUE hash, char * sym);
51
+
52
+ /* does the hash key 'sym' map to value 'val'? */
53
+ bool hash_value_is(VALUE hash, char * sym, VALUE val);
54
+
55
+ /* determine whether (1) hash is a T_HASH (2) the sym exists in the hash */
56
+ bool has_optional_hash_arg(VALUE hash, char * sym);
57
+
58
+
59
+ /* helpful C wrapper for rb_array_store */
60
+ VALUE set_array_value(VALUE array, int index, VALUE val);
61
+
62
+ /* helpful C wrapper for rb_array_entry */
63
+ VALUE get_from_array(VALUE array, int index);
64
+
65
+ /* set the lazy_bounds ivar for an image */
66
+ VALUE set_ivar_array(VALUE obj, char * ivar, int argc, ...);
67
+
68
+ /* initialize lazy_bounds */
69
+ void init_lazy_bounds(VALUE image);
70
+
71
+ /* initialize the image_local var array */
72
+ VALUE init_image_local(VALUE image);
73
+
74
+ /* return an image local variable */
75
+ VALUE get_image_local(VALUE image, int name);
76
+
77
+ /* set an image local variable */
78
+ void set_image_local(VALUE image, int name, VALUE val);
79
+
80
+ /* error checking functions */
81
+ void check_mask(VALUE mask);
82
+
83
+ void check_image(VALUE image);
84
+
85
+ /* is try_image a Gosu::Image ? */
86
+ bool is_gosu_image(VALUE try_image);
87
+
88
+ /* create a blank gosu image of width and height */
89
+ VALUE create_image(VALUE window, int width, int height);
90
+
91
+ /* make boundaries sane */
92
+ void constrain_boundaries(int * x0, int * y0, int * x1, int * y1, int width, int height);
93
+
94
+ /* line clipping */
95
+ void cohen_sutherland_clip (int * x0, int * y0,int * x1, int * y1, int xmin, int ymin,
96
+ int xmax, int ymax);
97
+
98
+ /* check if point is bound by rect and inner thickness */
99
+ bool bound_by_rect_and_inner(int x, int y, int x0, int y0, int x1, int y1, int inner);
100
+
101
+ /* check if point is bound by rect */
102
+ bool bound_by_rect(int x, int y, int x0, int y0, int x1, int y1);
103
+
104
+ /* calculate the array offset for a given pixel */
105
+ int calc_pixel_offset(texture_info * tex, int x, int y);
106
+
107
+ /* calculate the array offset for a given pixel in an action context */
108
+ int calc_pixel_offset_for_action(action_struct * cur, texture_info * tex, int x, int y);
109
+
110
+ /* return a pointer to a new texture */
111
+ float* allocate_texture(int width, int height);
112
+
113
+ /* other function prototypes, get info for a texture */
114
+ void get_texture_info(VALUE image, texture_info * tex);
115
+
116
+ /* ensure gl_tex_info returns non nil */
117
+ VALUE check_for_texture_info(VALUE image);
118
+
119
+ /* responsible for syncing a subimage to gl */
120
+ void sync_to_gl(int tex_name, int x_offset, int y_offset, int width, int height, void * sub);
121
+
122
+ /* create a subtexture and sync to gl */
123
+ void create_subtexture_and_sync_to_gl(image_bounds * img_bounds, texture_info * tex);
124
+
125
+ float * get_image_chunk(texture_info * tex, int xmin, int ymin, int xmax, int ymax);
126
+
127
+ rgba get_pixel_color_from_chunk(float * chunk, int width, int height, int x, int y);
128
+
129
+ /* from Texture.cpp in Gosu Graphics folder */
130
+ unsigned max_quad_size(void);
131
+
132
+ /* point utils */
133
+ bool is_a_point(VALUE try_point);
134
+ VALUE point_x(VALUE point);
135
+ VALUE point_y(VALUE point);
136
+
137
+ /* mathematical utils, used by bezier curves */
138
+ double power(float base, int exp);
139
+ unsigned fact(int n);
140
+ unsigned comb(int n, int k);
141
+ double bernstein(int n, int k, float u);
142
+
143
+ #endif
Binary file
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: texplay
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - John Mair (banisterfiend)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-02 00:00:00 +12:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: gosu
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.7.14
24
+ version:
25
+ description: TexPlay is a light-weight image manipulation framework for Ruby and Gosu
26
+ email: jrmair@gmail.com
27
+ executables: []
28
+
29
+ extensions:
30
+ - src/extconf.rb
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - Rakefile
35
+ - README
36
+ - CHANGELOG
37
+ - README1st
38
+ - lib/texplay.rb
39
+ - lib/texplay-contrib.rb
40
+ - src/texplay.c
41
+ - src/utils.o
42
+ - src/object2module.h
43
+ - src/bindings.h
44
+ - src/cache.o
45
+ - src/gen_eval.o
46
+ - src/actions.c
47
+ - src/object2module.c
48
+ - src/utils.h
49
+ - src/actions.h
50
+ - src/bindings.o
51
+ - src/object2module.o
52
+ - src/compat.h
53
+ - src/ctexplay.so
54
+ - src/mkmf.log
55
+ - src/Makefile
56
+ - src/TAGS
57
+ - src/cache.h
58
+ - src/utils.c
59
+ - src/bindings.c
60
+ - src/extconf.rb
61
+ - src/texplay.h
62
+ - src/gen_eval.h
63
+ - src/gen_eval.c
64
+ - src/cache.c
65
+ - src/texplay.o
66
+ - src/actions.o
67
+ - examples/example_dup.rb
68
+ - examples/example_turtle.rb
69
+ - examples/example_color_control.rb
70
+ - examples/example_effect.rb
71
+ - examples/common.rb
72
+ - examples/example_color_transform.rb
73
+ - examples/example_hash_arguments.rb
74
+ - examples/example_gen_eval.rb
75
+ - examples/example_polyline.rb
76
+ - examples/basic.rb
77
+ - examples/test.rb
78
+ - examples/example_fill.rb
79
+ - examples/example_bezier.rb
80
+ - examples/example_simple.rb
81
+ - examples/example_fill_old.rb
82
+ - examples/example_each.rb
83
+ - examples/benchmark.rb
84
+ - examples/example_fluent.rb
85
+ - examples/example_sync.rb
86
+ - examples/example_splice.rb
87
+ - examples/example_alpha_blend.rb
88
+ - examples/basic2.rb
89
+ - examples/example_melt.rb
90
+ - examples/test2.rb
91
+ - examples/specs.rb
92
+ - examples/media/sand1.png
93
+ - examples/media/rose.bmp
94
+ - examples/media/maria.png
95
+ - examples/media/sunset.png
96
+ - examples/media/texplay.png
97
+ - examples/media/gosu.png
98
+ - examples/media/empty2.png
99
+ has_rdoc: false
100
+ homepage: http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/
101
+ post_install_message:
102
+ rdoc_options: []
103
+
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: "0"
111
+ version:
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: "0"
117
+ version:
118
+ requirements: []
119
+
120
+ rubyforge_project:
121
+ rubygems_version: 1.3.1
122
+ signing_key:
123
+ specification_version: 2
124
+ summary: TexPlay is a light-weight image manipulation framework for Ruby and Gosu
125
+ test_files: []
126
+