texplay 0.2.935 → 0.2.940

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 CHANGED
@@ -1,3 +1,8 @@
1
+ 9/6/10
2
+ version 0.2.940
3
+ * hopefully fixed :trace behaviour. Should now return nil for color when
4
+ pixel out of bounds.
5
+
1
6
  9/6/10
2
7
  version 0.2.930
3
8
  * not_a_color now returns true when color channel < 0
data/README.markdown CHANGED
@@ -5,7 +5,7 @@
5
5
  INSTRUCTIONS
6
6
  ============
7
7
 
8
- **TexPlay version 0.2.935**
8
+ **TexPlay version 0.2.940**
9
9
 
10
10
  [Read The Documentation](http://banisterfiend.wordpress.com/2008/08/23/texplay-an-image-manipulation-tool-for-ruby-and-gosu/)
11
11
 
@@ -17,24 +17,24 @@ class W < Gosu::Window
17
17
  @s = true
18
18
 
19
19
  @copy = TexPlay.create_image(self, @rad * 2 + 1, @rad * 2 + 1)
20
- @copy2 = TexPlay.create_image(self, @rad * 2 + 1, @rad * 2 + 1)
20
+ @copy2 = TexPlay.create_image(self, @rad * 2 + 1, @rad * 2 + 1)
21
21
  end
22
22
 
23
23
  def draw
24
+ @pause = true
24
25
 
26
+ @x += 1
27
+ @y += 1
25
28
 
26
- @x += 3
27
- @y += 3
28
-
29
- @x2 -= 3
30
- @y2 += 3
29
+ @x2 -= 1
30
+ @y2 += 1
31
31
 
32
32
 
33
33
  @copy2.splice @img, 0, 0, :crop => [@x2 - @rad, @y2 - @rad, @x2 + @rad, @y2 + @rad], :sync_mode => :no_sync
34
34
  @copy.splice @img, 0, 0, :crop => [@x - @rad, @y - @rad, @x + @rad, @y + @rad], :sync_mode => :no_sync
35
- @img.rect @x - @rad, @y - @rad, @x + @rad, @y + @rad, :fill => true, :mode => :overlay, :color => :red
35
+ @img.rect @x - @rad, @y - @rad, @x + @rad, @y + @rad, :fill => true, :mode => :overlay, :color => :tyrian
36
36
 
37
- @img.rect @x2 - @rad, @y2 - @rad, @x2 + @rad, @y2 + @rad, :fill => true, :mode => :overlay, :color => :blue
37
+ @img.rect @x2 - @rad, @y2 - @rad, @x2 + @rad, @y2 + @rad, :fill => true, :mode => :invert, :color => :blue
38
38
 
39
39
  # @img.force_sync [0,0, @img.width, @img.height]
40
40
 
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require 'common'
3
+ require 'gosu'
4
+ require 'texplay'
5
+
6
+ class Window < Gosu::Window
7
+ def initialize
8
+ super(500, 500, false, 20)
9
+
10
+ @image = TexPlay.create_image(self, 50, 50)
11
+
12
+ from_x = 50
13
+ from_y = 50
14
+ to_x = 51
15
+ to_y = 51
16
+
17
+ x2, y2, color = @image.line from_x, from_y, to_x, to_y, :trace => { :while_color => :red }
18
+
19
+ p x2
20
+ p y2
21
+ p color
22
+ end
23
+ end
24
+
25
+ Window.new.show
@@ -8,7 +8,7 @@ class W < Gosu::Window
8
8
  super(500, 500, false, 20)
9
9
  @img = TexPlay.create_image(self, 500, 500).fill(3,3, :color => :alpha)
10
10
  @img.rect 100, 100, 300 , 300, :color => :blue, :fill => true
11
- puts (@img.line 400, 200, 100, 200, :trace => { :until_color => :blue }, :color_mode => :gosu)
11
+ puts (@img.line 498, 200, 600, 200, :trace => { :while_color => :blue })
12
12
  end
13
13
 
14
14
  def draw
@@ -162,7 +162,7 @@ line_do_action(int x1, int y1, int x2, int y2, texture_info * tex, VALUE hash_ar
162
162
  }
163
163
  draw_epilogue(&cur, tex, primary);
164
164
 
165
- return (trace_match) { .x = -1, .y = -1 };
165
+ return (trace_match) { .x = -9999, .y = -9999, .color = not_a_color_v };
166
166
  }
167
167
  /** end line **/
168
168
 
@@ -562,12 +562,12 @@ m_line(int argc, VALUE * argv, VALUE self)
562
562
  match = line_do_action(x1, y1, x2, y2, &tex, options, sync_mode, true, NULL);
563
563
 
564
564
  if (has_optional_hash_arg(options, "trace")) {
565
- if (match.x == -1)
565
+ if (match.x == -9999)
566
566
  return Qnil;
567
567
  else
568
568
  return convert_trace_match_to_ruby_array(match, gosu_color_mode);
569
569
  }
570
-
570
+
571
571
  return self;
572
572
  }
573
573
 
data/ext/texplay/utils.c CHANGED
@@ -407,6 +407,8 @@ convert_gosu_to_rgba_color(VALUE gcolor)
407
407
  VALUE
408
408
  convert_rgba_to_rb_color(rgba * pix)
409
409
  {
410
+ if (not_a_color(*pix)) return Qnil;
411
+
410
412
  /* create a new ruby array to store the pixel data */
411
413
  VALUE pix_array = rb_ary_new2(4);
412
414
 
@@ -423,6 +425,8 @@ convert_rgba_to_rb_color(rgba * pix)
423
425
  VALUE
424
426
  convert_rgba_to_gosu_color(rgba * pix)
425
427
  {
428
+ if (not_a_color(*pix)) return Qnil;
429
+
426
430
  VALUE gosu_color_class = 0;
427
431
 
428
432
  if (gosu_color_class == 0) {
@@ -1,3 +1,3 @@
1
1
  module TexPlay
2
- VERSION = "0.2.935"
2
+ VERSION = "0.2.940"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 935
9
- version: 0.2.935
8
+ - 940
9
+ version: 0.2.940
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Mair (banisterfiend)
@@ -80,6 +80,7 @@ files:
80
80
  - examples/example_fluent.rb
81
81
  - examples/example_gen_eval.rb
82
82
  - examples/example_hash_arguments.rb
83
+ - examples/example_ippa.rb
83
84
  - examples/example_light.rb
84
85
  - examples/example_light_multiply.rb
85
86
  - examples/example_lsystem.rb