texplay 0.2.700-x86-mswin32 → 0.2.710-x86-mswin32
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 +12 -0
 - data/README.markdown +1 -1
 - data/Rakefile +4 -3
 - data/examples/example_color_transform.rb +45 -6
 - data/examples/example_fill_test.rb +106 -0
 - data/examples/example_modify.rb +40 -0
 - data/examples/example_sine.rb +55 -0
 - data/examples/media/platform.png +0 -0
 - data/ext/texplay/actions.c +25 -17
 - data/ext/texplay/cache.c +4 -21
 - data/ext/texplay/texplay.c +32 -0
 - data/lib/1.8/texplay.so +0 -0
 - data/lib/1.9/texplay.so +0 -0
 - data/lib/texplay.rb +24 -21
 - data/lib/texplay/version.rb +3 -0
 - metadata +7 -2
 
    
        data/CHANGELOG
    CHANGED
    
    | 
         @@ -1,3 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            6/12/09
         
     | 
| 
      
 2 
     | 
    
         
            +
            version 0.2.710
         
     | 
| 
      
 3 
     | 
    
         
            +
            * fixed bug in line drawing code (wasn't drawing final pixel)
         
     | 
| 
      
 4 
     | 
    
         
            +
            * fixed bug in filled rect code (wasn't drawing final row)
         
     | 
| 
      
 5 
     | 
    
         
            +
            * fixed bug in flood fill (wasn't drawing on first column)
         
     | 
| 
      
 6 
     | 
    
         
            +
            * added glDisable(GL_TEXTURE_2D) calls to cache.c, and removed 'restore previous texture binding' (i doubt there is any previous binding to restore)
         
     | 
| 
      
 7 
     | 
    
         
            +
            * using version.rb to help manage versions
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            23/11/09
         
     | 
| 
      
 10 
     | 
    
         
            +
            * fixed bug in texplay.rb. Replaced TexPlay::TP_MAX_QUAD_SIZE - 2 with
         
     | 
| 
      
 11 
     | 
    
         
            +
            just TexPlay::TP_MAX_QUAD_SIZE (the -2 is now built into the constant)
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
       1 
13 
     | 
    
         
             
            16/10/09
         
     | 
| 
       2 
14 
     | 
    
         
             
            version 0.2.700
         
     | 
| 
       3 
15 
     | 
    
         
             
            * removed memory leak from Gosu::Image#to_blob, now writing directly to RSTRING_PTR
         
     | 
    
        data/README.markdown
    CHANGED
    
    
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -2,7 +2,8 @@ require 'rake/clean' 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require 'rake/gempackagetask'
         
     | 
| 
       3 
3 
     | 
    
         
             
            require 'rake/extensiontask'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
            # get the texplay version
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'lib/texplay/version'
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
       7 
8 
     | 
    
         
             
            $dlext = Config::CONFIG['DLEXT']
         
     | 
| 
       8 
9 
     | 
    
         | 
| 
         @@ -12,7 +13,7 @@ CLOBBER.include("**/*.#{$dlext}", "**/*~", "**/*#*", "**/*.log", "**/*.o") 
     | 
|
| 
       12 
13 
     | 
    
         
             
            specification = Gem::Specification.new do |s|
         
     | 
| 
       13 
14 
     | 
    
         
             
                s.name = "texplay"
         
     | 
| 
       14 
15 
     | 
    
         
             
                s.summary = "TexPlay is a light-weight image manipulation framework for Ruby and Gosu"
         
     | 
| 
       15 
     | 
    
         
            -
                s.version =  
     | 
| 
      
 16 
     | 
    
         
            +
                s.version = TexPlay::VERSION
         
     | 
| 
       16 
17 
     | 
    
         
             
                s.date = Time.now.strftime '%Y-%m-%d'
         
     | 
| 
       17 
18 
     | 
    
         
             
                s.author = "John Mair (banisterfiend)"
         
     | 
| 
       18 
19 
     | 
    
         
             
                s.email = 'jrmair@gmail.com'
         
     | 
| 
         @@ -25,7 +26,7 @@ specification = Gem::Specification.new do |s| 
     | 
|
| 
       25 
26 
     | 
    
         | 
| 
       26 
27 
     | 
    
         
             
                s.extensions = ["ext/texplay/extconf.rb"]
         
     | 
| 
       27 
28 
     | 
    
         
             
                s.files =  ["Rakefile", "README.markdown", "CHANGELOG", 
         
     | 
| 
       28 
     | 
    
         
            -
                            "lib/texplay.rb", "lib/texplay-contrib.rb"] +
         
     | 
| 
      
 29 
     | 
    
         
            +
                            "lib/texplay.rb", "lib/texplay-contrib.rb", "lib/texplay/version.rb"] +
         
     | 
| 
       29 
30 
     | 
    
         
             
                    FileList["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "examples/*.rb",
         
     | 
| 
       30 
31 
     | 
    
         
             
                             "examples/media/*"].to_a 
         
     | 
| 
       31 
32 
     | 
    
         
             
            end
         
     | 
| 
         @@ -2,23 +2,62 @@ require 'rubygems' 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require 'common'
         
     | 
| 
       3 
3 
     | 
    
         
             
            require 'gosu'
         
     | 
| 
       4 
4 
     | 
    
         
             
            require 'texplay'
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
            require 'devil/gosu'
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            class W < Gosu::Window
         
     | 
| 
       8 
8 
     | 
    
         
             
                def initialize
         
     | 
| 
       9 
9 
     | 
    
         
             
                    super(1024, 768, false, 20)
         
     | 
| 
       10 
10 
     | 
    
         
             
                    @img = Gosu::Image.new(self, "#{Common::MEDIA}/sunset.png")
         
     | 
| 
      
 11 
     | 
    
         
            +
                    @x = 100
         
     | 
| 
      
 12 
     | 
    
         
            +
                    @y = 100
         
     | 
| 
      
 13 
     | 
    
         
            +
                    
         
     | 
| 
      
 14 
     | 
    
         
            +
                    @x2 = 400
         
     | 
| 
      
 15 
     | 
    
         
            +
                    @y2 = 100
         
     | 
| 
      
 16 
     | 
    
         
            +
                    @rad = 50
         
     | 
| 
      
 17 
     | 
    
         
            +
                    @s = true
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    @copy = TexPlay.create_blank_image(self, @rad * 2 + 1, @rad * 2 + 1)
         
     | 
| 
      
 20 
     | 
    
         
            +
                    @copy2 = TexPlay.create_blank_image(self, @rad * 2 + 1, @rad * 2 + 1)
         
     | 
| 
       11 
21 
     | 
    
         
             
                end
         
     | 
| 
       12 
22 
     | 
    
         | 
| 
       13 
23 
     | 
    
         
             
                def draw
         
     | 
| 
       14 
     | 
    
         
            -
                    x = (@img.width - 100/2) * rand 
         
     | 
| 
       15 
     | 
    
         
            -
                    y = (@img.height - 100/2) * rand 
         
     | 
| 
       16 
24 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
                    @img.rect x, y, x + 50, y + 50, :fill => true,
         
     | 
| 
       18 
     | 
    
         
            -
                    :color_control => { :mult => [0.9 , 0.3, 0.3, 1] }
         
     | 
| 
       19 
25 
     | 
    
         | 
| 
      
 26 
     | 
    
         
            +
                    @x += 1
         
     | 
| 
      
 27 
     | 
    
         
            +
                    @y += 1
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                    @x2 -= 1
         
     | 
| 
      
 30 
     | 
    
         
            +
                    @y2 += 1
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                    @copy2.splice @img, 0, 0, :crop => [@x2 - @rad, @y2 - @rad, @x2 + @rad, @y2 + @rad]
         
     | 
| 
      
 34 
     | 
    
         
            +
                    @copy.splice @img, 0, 0, :crop => [@x - @rad, @y - @rad, @x + @rad, @y + @rad]
         
     | 
| 
      
 35 
     | 
    
         
            +
                    @img.
         
     | 
| 
      
 36 
     | 
    
         
            +
                        circle @x, @y, @rad, :fill => true,
         
     | 
| 
      
 37 
     | 
    
         
            +
                    :color_control => { :mult => [1, 1, 1, 1] }
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                     #    circle @x2, @y2, @rad, :fill => true,
         
     | 
| 
      
 40 
     | 
    
         
            +
            #             :color_control => { :mult => [0.3, 0.9, 0.3, 1] }
         
     | 
| 
      
 41 
     | 
    
         
            +
                    
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            #        @img.force_sync [0,0, @img.width, @img.height]
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                    @img.draw 10, 10,1
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                    if button_down?(Gosu::KbEscape)
         
     | 
| 
      
 48 
     | 
    
         
            +
                        IL.Enable(IL::ORIGIN_SET)
         
     | 
| 
      
 49 
     | 
    
         
            +
                        IL.OriginFunc(IL::ORIGIN_UPPER_LEFT)
         
     | 
| 
      
 50 
     | 
    
         
            +
                        screenshot.crop(0,0, 500, 500).save("screenshot.jpg").free
         
     | 
| 
      
 51 
     | 
    
         
            +
                        exit
         
     | 
| 
      
 52 
     | 
    
         
            +
                    end  
         
     | 
| 
      
 53 
     | 
    
         
            +
                    
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                def update
         
     | 
| 
      
 57 
     | 
    
         
            +
                    @img.splice @copy, @x - @rad, @y - @rad if !@s
         
     | 
| 
      
 58 
     | 
    
         
            +
                    @img.splice @copy2, @x2 - @rad, @y2 - @rad if !@s
         
     | 
| 
      
 59 
     | 
    
         
            +
                    @s = nil if @s
         
     | 
| 
       20 
60 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                    @img.draw 100, 50,1
         
     | 
| 
       22 
61 
     | 
    
         
             
                end
         
     | 
| 
       23 
62 
     | 
    
         | 
| 
       24 
63 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,106 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'common'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'texplay'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'devil/gosu'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            class W < Gosu::Window
         
     | 
| 
      
 8 
     | 
    
         
            +
                WIDTH = 1000
         
     | 
| 
      
 9 
     | 
    
         
            +
                HEIGHT = 800
         
     | 
| 
      
 10 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 11 
     | 
    
         
            +
                    super(1024, 768, false, 20)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    @img = TexPlay::create_blank_image(self, WIDTH, HEIGHT)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    @tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
         
     | 
| 
      
 14 
     | 
    
         
            +
                    @gosu = Gosu::Image.new(self, "#{Common::MEDIA}/sand1.png")
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    image = TexPlay::create_blank_image(self, WIDTH, HEIGHT)
         
     | 
| 
      
 18 
     | 
    
         
            +
                    image2 = TexPlay::create_blank_image(self, WIDTH, HEIGHT)
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                    puts "..created blank!"
         
     | 
| 
      
 21 
     | 
    
         
            +
                    puts "..starting drawing!"
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                    # now let's create the landscape
         
     | 
| 
      
 24 
     | 
    
         
            +
                    points = []
         
     | 
| 
      
 25 
     | 
    
         
            +
                    (0..WIDTH + 120).step(90) {  |x|
         
     | 
| 
      
 26 
     | 
    
         
            +
                        p = TexPlay::TPPoint.new
         
     | 
| 
      
 27 
     | 
    
         
            +
                        p.x = x
         
     | 
| 
      
 28 
     | 
    
         
            +
                        p.y = HEIGHT - rand * 600
         
     | 
| 
      
 29 
     | 
    
         
            +
                        if p.y >= HEIGHT - 1 
         
     | 
| 
      
 30 
     | 
    
         
            +
                            p.y = HEIGHT - 1
         
     | 
| 
      
 31 
     | 
    
         
            +
                        end
         
     | 
| 
      
 32 
     | 
    
         
            +
                        points << p
         
     | 
| 
      
 33 
     | 
    
         
            +
                    }
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                    points.first.y = 600
         
     | 
| 
      
 36 
     | 
    
         
            +
                    points.last.x = WIDTH + 200
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                    points.last.y = 600
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                    mag = rand(50) + 10
         
     | 
| 
      
 41 
     | 
    
         
            +
                    rough = 2 + rand(20)
         
     | 
| 
      
 42 
     | 
    
         
            +
                    spike = 2 + rand(14)
         
     | 
| 
      
 43 
     | 
    
         
            +
                    period = 2 * rand + 0.2
         
     | 
| 
      
 44 
     | 
    
         
            +
                    image.move_to(points.first.x, points.first.y)
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                    image.rect 200, 200, 300, 300, :color => :green, :fill => true
         
     | 
| 
      
 47 
     | 
    
         
            +
                    image.rect 300, 200, 400, 300, :color => :green, :fill => false
         
     | 
| 
      
 48 
     | 
    
         
            +
                    #image.line 200, 200, 300, 300, :color => :green, :fill => true#, :thickness => 3
         
     | 
| 
      
 49 
     | 
    
         
            +
                    #        image.pixel 300,300, :color => :white
         
     | 
| 
      
 50 
     | 
    
         
            +
                    #        image.line 200, 300, 300, 300, :color => :white, :sync_mode => :eager_sync
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                    #       
         
     | 
| 
      
 53 
     | 
    
         
            +
                    image.rect 0, 0, image.width - 1, image.height - 1, :color => :white
         
     | 
| 
      
 54 
     | 
    
         
            +
                    image.circle image.width, 0, 10, :color => :red, :fill => true
         
     | 
| 
      
 55 
     | 
    
         
            +
                    #        image.rect 0, 400, image.width - 1, 600, :color => :green
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                    # plain beziers are boring, so let's augment it with a randomized sine wave
         
     | 
| 
      
 58 
     | 
    
         
            +
                    image.bezier points, :color => :white,  :color_control => proc {  |c, t, y|
         
     | 
| 
      
 59 
     | 
    
         
            +
                        y +=  mag * Math::sin(t * period * Math::PI / 180)
         
     | 
| 
      
 60 
     | 
    
         
            +
                        if (t % rough == 0 ) then
         
     | 
| 
      
 61 
     | 
    
         
            +
                            image.line_to(t, y + rand * spike - (spike / 2), :texture => @gosu)
         
     | 
| 
      
 62 
     | 
    
         
            +
                        end
         
     | 
| 
      
 63 
     | 
    
         
            +
                        :none
         
     | 
| 
      
 64 
     | 
    
         
            +
                    }
         
     | 
| 
      
 65 
     | 
    
         
            +
                    
         
     | 
| 
      
 66 
     | 
    
         
            +
                    #image.bezier [rand(500), 700, rand(100), 800, rand(800), 900, rand(300), 850 ], :closed => true
         
     | 
| 
      
 67 
     | 
    
         
            +
                    image.fill 300, 760, :color => :red #:texture => @gosu
         
     | 
| 
      
 68 
     | 
    
         
            +
                    image.rect 0,0, image.width - 1, image.height - 1, :fill => true, :color => :blue
         
     | 
| 
      
 69 
     | 
    
         
            +
                    image2.fill 300, 300, :color => :red
         
     | 
| 
      
 70 
     | 
    
         
            +
                    
         
     | 
| 
      
 71 
     | 
    
         
            +
                    @img = image
         
     | 
| 
      
 72 
     | 
    
         
            +
                    @img2 = image2
         
     | 
| 
      
 73 
     | 
    
         
            +
                    #       @img.circle  10, image.height / 2, 50, :color => :red, :fill => true
         
     | 
| 
      
 74 
     | 
    
         
            +
                    #@img.rect 0,100, 100, 200, :color => :red, :fill => true
         
     | 
| 
      
 75 
     | 
    
         
            +
                    #@img.line -1, 100, 100, 100, :color => :blue, :fill => true
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                    #        @img.line 0,100, 0, 200, :color => :red, :fill => true
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                    
         
     | 
| 
      
 80 
     | 
    
         
            +
                    #        @img.force_sync [0,0, image.width, image.height]
         
     | 
| 
      
 81 
     | 
    
         
            +
                    #        @img.rect  -10, image.height / 2, 50, image.height / 2 + 50, :color => :red, :fill => true
         
     | 
| 
      
 82 
     | 
    
         
            +
                    #        @img.line 0,0, 0, image.height - 1, :color => :red
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                    @bunk = TexPlay.create_blank_image(self, 100, 100)
         
     | 
| 
      
 85 
     | 
    
         
            +
                    @bunk.circle 50, 50, 50, :color => :rand, :fill => true
         
     | 
| 
      
 86 
     | 
    
         
            +
                    
         
     | 
| 
      
 87 
     | 
    
         
            +
                end
         
     | 
| 
      
 88 
     | 
    
         
            +
                
         
     | 
| 
      
 89 
     | 
    
         
            +
                def draw
         
     | 
| 
      
 90 
     | 
    
         
            +
                    @img.draw  0, 600,1
         
     | 
| 
      
 91 
     | 
    
         
            +
                    @img2.draw 50, 600, 1
         
     | 
| 
      
 92 
     | 
    
         
            +
                    @bunk.draw 500, 500, 1
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                    if button_down?(Gosu::KbEscape)
         
     | 
| 
      
 95 
     | 
    
         
            +
                        Devil.from_blob(self.to_blob, self.width, self.height).save("hello.jpg")
         
     | 
| 
      
 96 
     | 
    
         
            +
                        #screenshot.crop(100, 100, 500, 500).save("hello.jpg")
         
     | 
| 
      
 97 
     | 
    
         
            +
                        exit
         
     | 
| 
      
 98 
     | 
    
         
            +
                    end
         
     | 
| 
      
 99 
     | 
    
         
            +
                end
         
     | 
| 
      
 100 
     | 
    
         
            +
                
         
     | 
| 
      
 101 
     | 
    
         
            +
            end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
            w = W.new
         
     | 
| 
      
 105 
     | 
    
         
            +
            w.show
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,40 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'common'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'gosu'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'texplay'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'devil/gosu'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            class W < Gosu::Window
         
     | 
| 
      
 9 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 10 
     | 
    
         
            +
                    super(1024, 768, false, 20)
         
     | 
| 
      
 11 
     | 
    
         
            +
                    @img = Gosu::Image.new(self, "#{Common::MEDIA}/platform.png")
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                    # each can accept a block of two types of arity:
         
     | 
| 
      
 14 
     | 
    
         
            +
                    # arity 1 - yields just the pixel color
         
     | 
| 
      
 15 
     | 
    
         
            +
                    # arity 3 - yield the pixel color, and the x and y
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    # max out the blue component of every pixel
         
     | 
| 
      
 18 
     | 
    
         
            +
                    @img.each { |v|
         
     | 
| 
      
 19 
     | 
    
         
            +
                        if v[0] > 0.7 && v[1] > 0.6 && v[2] < 0.6 then
         
     | 
| 
      
 20 
     | 
    
         
            +
                            v[1] = 0.0
         
     | 
| 
      
 21 
     | 
    
         
            +
                            v[2] = 0.0
         
     | 
| 
      
 22 
     | 
    
         
            +
                        end
         
     | 
| 
      
 23 
     | 
    
         
            +
                    }
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    #@img.save("/home/john/Desktop/red.png")
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
             
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
                
         
     | 
| 
      
 30 
     | 
    
         
            +
                def draw
         
     | 
| 
      
 31 
     | 
    
         
            +
                
         
     | 
| 
      
 32 
     | 
    
         
            +
                    @img.draw 100, 50,1
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
                
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            w = W.new
         
     | 
| 
      
 39 
     | 
    
         
            +
            w.show
         
     | 
| 
      
 40 
     | 
    
         
            +
                    
         
     | 
| 
         @@ -0,0 +1,55 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'common'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'texplay'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            class W < Gosu::Window
         
     | 
| 
      
 7 
     | 
    
         
            +
                NUM_WAVES = 10
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 10 
     | 
    
         
            +
                    super(1024, 768, false, 20)
         
     | 
| 
      
 11 
     | 
    
         
            +
                    @img = TexPlay::create_blank_image(self, 1022, 800)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    @tp = Gosu::Image.new(self, "#{Common::MEDIA}/texplay.png")
         
     | 
| 
      
 13 
     | 
    
         
            +
                    @gosu = Gosu::Image.new(self, "#{Common::MEDIA}/sand1.png")
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                    points = []
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    # NOTE: TexPlay also accepts points. a 'point' is any object that responds to 'x' or y
         
     | 
| 
      
 18 
     | 
    
         
            +
                    # NOTE: current maximum points for a bezier is 13
         
     | 
| 
      
 19 
     | 
    
         
            +
                    (0..@img.width + 90).step(185) { |x|
         
     | 
| 
      
 20 
     | 
    
         
            +
                        p = TexPlay::TPPoint.new
         
     | 
| 
      
 21 
     | 
    
         
            +
                        p.x = x
         
     | 
| 
      
 22 
     | 
    
         
            +
                        p.y = @img.height * rand
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                        points << p
         
     | 
| 
      
 25 
     | 
    
         
            +
                    }
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                    waves = []
         
     | 
| 
      
 28 
     | 
    
         
            +
                    NUM_WAVES.times {
         
     | 
| 
      
 29 
     | 
    
         
            +
                        waves.push({ :amp => rand(100), :freq => rand(1000).to_f })
         
     | 
| 
      
 30 
     | 
    
         
            +
                    }
         
     | 
| 
      
 31 
     | 
    
         
            +
                        
         
     | 
| 
      
 32 
     | 
    
         
            +
                    @img.move_to 0, 300
         
     | 
| 
      
 33 
     | 
    
         
            +
                    (0..1100).step(10) { |x|
         
     | 
| 
      
 34 
     | 
    
         
            +
                        y = 300
         
     | 
| 
      
 35 
     | 
    
         
            +
                        waves.each { |w|
         
     | 
| 
      
 36 
     | 
    
         
            +
                            y += w[:amp] * Math::sin((x / w[:freq]) * Math::PI * 2) 
         
     | 
| 
      
 37 
     | 
    
         
            +
                        }
         
     | 
| 
      
 38 
     | 
    
         
            +
                        @img.line_to(x, y)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    }
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                    # NOTE: the :texture hash argument works on ALL drawing actions; not just fills
         
     | 
| 
      
 42 
     | 
    
         
            +
                    @img.fill 300, 650, :texture => @gosu
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
                
         
     | 
| 
      
 46 
     | 
    
         
            +
                def draw
         
     | 
| 
      
 47 
     | 
    
         
            +
                    @img.draw 10, 10,1
         
     | 
| 
      
 48 
     | 
    
         
            +
                end
         
     | 
| 
      
 49 
     | 
    
         
            +
                
         
     | 
| 
      
 50 
     | 
    
         
            +
            end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            w = W.new
         
     | 
| 
      
 54 
     | 
    
         
            +
            w.show
         
     | 
| 
      
 55 
     | 
    
         
            +
                    
         
     | 
| 
         Binary file 
     | 
    
        data/ext/texplay/actions.c
    CHANGED
    
    | 
         @@ -66,6 +66,14 @@ line_do_action(int x1, int y1, int x2, int y2, texture_info * tex, VALUE hash_ar 
     | 
|
| 
       66 
66 
     | 
    
         
             
                if(W >= H) {
         
     | 
| 
       67 
67 
     | 
    
         
             
                    F = 2 * H - W;
         
     | 
| 
       68 
68 
     | 
    
         
             
                    while(x != x2) {
         
     | 
| 
      
 69 
     | 
    
         
            +
                       if(thickness <= 1) {
         
     | 
| 
      
 70 
     | 
    
         
            +
                            set_pixel_color_with_style(payload, tex, x, y);
         
     | 
| 
      
 71 
     | 
    
         
            +
                        }
         
     | 
| 
      
 72 
     | 
    
         
            +
                        else {
         
     | 
| 
      
 73 
     | 
    
         
            +
                            set_hash_value(hash_arg, "fill", Qtrue);
         
     | 
| 
      
 74 
     | 
    
         
            +
                            circle_do_action(x, y, thickness / 2, tex, hash_arg, no_sync, false, payload);
         
     | 
| 
      
 75 
     | 
    
         
            +
                        }
         
     | 
| 
      
 76 
     | 
    
         
            +
                       
         
     | 
| 
       69 
77 
     | 
    
         
             
                        if(F < 0)
         
     | 
| 
       70 
78 
     | 
    
         
             
                            F += 2 * H;
         
     | 
| 
       71 
79 
     | 
    
         
             
                        else {
         
     | 
| 
         @@ -73,6 +81,11 @@ line_do_action(int x1, int y1, int x2, int y2, texture_info * tex, VALUE hash_ar 
     | 
|
| 
       73 
81 
     | 
    
         
             
                            y += yinc;
         
     | 
| 
       74 
82 
     | 
    
         
             
                        }
         
     | 
| 
       75 
83 
     | 
    
         
             
                        x += xinc;
         
     | 
| 
      
 84 
     | 
    
         
            +
                    }
         
     | 
| 
      
 85 
     | 
    
         
            +
                }
         
     | 
| 
      
 86 
     | 
    
         
            +
                else {
         
     | 
| 
      
 87 
     | 
    
         
            +
                    F = 2 * W - H;
         
     | 
| 
      
 88 
     | 
    
         
            +
                    while(y != y2 ) {
         
     | 
| 
       76 
89 
     | 
    
         | 
| 
       77 
90 
     | 
    
         
             
                        if(thickness <= 1) {
         
     | 
| 
       78 
91 
     | 
    
         
             
                            set_pixel_color_with_style(payload, tex, x, y);
         
     | 
| 
         @@ -81,11 +94,7 @@ line_do_action(int x1, int y1, int x2, int y2, texture_info * tex, VALUE hash_ar 
     | 
|
| 
       81 
94 
     | 
    
         
             
                            set_hash_value(hash_arg, "fill", Qtrue);
         
     | 
| 
       82 
95 
     | 
    
         
             
                            circle_do_action(x, y, thickness / 2, tex, hash_arg, no_sync, false, payload);
         
     | 
| 
       83 
96 
     | 
    
         
             
                        }
         
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
                }
         
     | 
| 
       86 
     | 
    
         
            -
                else {
         
     | 
| 
       87 
     | 
    
         
            -
                    F = 2 * W - H;
         
     | 
| 
       88 
     | 
    
         
            -
                    while(y != y2 ) {
         
     | 
| 
      
 97 
     | 
    
         
            +
                        
         
     | 
| 
       89 
98 
     | 
    
         
             
                        if(F < 0)
         
     | 
| 
       90 
99 
     | 
    
         
             
                            F += 2 * W;
         
     | 
| 
       91 
100 
     | 
    
         
             
                        else {
         
     | 
| 
         @@ -93,18 +102,17 @@ line_do_action(int x1, int y1, int x2, int y2, texture_info * tex, VALUE hash_ar 
     | 
|
| 
       93 
102 
     | 
    
         
             
                            x += xinc;
         
     | 
| 
       94 
103 
     | 
    
         
             
                        }
         
     | 
| 
       95 
104 
     | 
    
         
             
                        y += yinc;
         
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
                        if(thickness <= 1) {
         
     | 
| 
       98 
     | 
    
         
            -
                            set_pixel_color_with_style(payload, tex, x, y);
         
     | 
| 
       99 
     | 
    
         
            -
                        }
         
     | 
| 
       100 
     | 
    
         
            -
                        else {
         
     | 
| 
       101 
     | 
    
         
            -
                            set_hash_value(hash_arg, "fill", Qtrue);
         
     | 
| 
       102 
     | 
    
         
            -
                            circle_do_action(x, y, thickness / 2, tex, hash_arg, no_sync, false, payload);
         
     | 
| 
       103 
     | 
    
         
            -
                        }
         
     | 
| 
       104 
     | 
    
         
            -
                        
         
     | 
| 
       105 
105 
     | 
    
         
             
                    }
         
     | 
| 
       106 
106 
     | 
    
         
             
                }
         
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                if(thickness <= 1) {
         
     | 
| 
      
 109 
     | 
    
         
            +
                    set_pixel_color_with_style(payload, tex, x2, y2);
         
     | 
| 
      
 110 
     | 
    
         
            +
                }
         
     | 
| 
      
 111 
     | 
    
         
            +
                else {
         
     | 
| 
      
 112 
     | 
    
         
            +
                    set_hash_value(hash_arg, "fill", Qtrue);
         
     | 
| 
      
 113 
     | 
    
         
            +
                    circle_do_action(x2, y2, thickness / 2, tex, hash_arg, no_sync, false, payload);
         
     | 
| 
      
 114 
     | 
    
         
            +
                            
         
     | 
| 
      
 115 
     | 
    
         
            +
                }
         
     | 
| 
       108 
116 
     | 
    
         
             
                draw_epilogue(&cur, tex, primary);
         
     | 
| 
       109 
117 
     | 
    
         
             
            }
         
     | 
| 
       110 
118 
     | 
    
         
             
            /** end line **/
         
     | 
| 
         @@ -311,7 +319,7 @@ rect_do_action(int x1, int y1, int x2, int y2, texture_info * tex, VALUE hash_ar 
     | 
|
| 
       311 
319 
     | 
    
         
             
                    int y;
         
     | 
| 
       312 
320 
     | 
    
         
             
                    if(y1 > y2) SWAP(y1, y2);
         
     | 
| 
       313 
321 
     | 
    
         | 
| 
       314 
     | 
    
         
            -
                    for(y = y1; y  
     | 
| 
      
 322 
     | 
    
         
            +
                    for(y = y1; y <= y2; y++)
         
     | 
| 
       315 
323 
     | 
    
         
             
                        line_do_action(x1, y, x2, y, tex, hash_arg, no_sync, false, payload);
         
     | 
| 
       316 
324 
     | 
    
         
             
                }
         
     | 
| 
       317 
325 
     | 
    
         | 
| 
         @@ -660,7 +668,7 @@ scan_fill_do_action(int x, int y, texture_info * tex, VALUE hash_arg, 
     | 
|
| 
       660 
668 
     | 
    
         
             
                                /* update the drawing rectangle */
         
     | 
| 
       661 
669 
     | 
    
         
             
                                update_bounds(payload, x, y1, x, y1);
         
     | 
| 
       662 
670 
     | 
    
         | 
| 
       663 
     | 
    
         
            -
                                if(!spanLeft && x >  
     | 
| 
      
 671 
     | 
    
         
            +
                                if(!spanLeft && x > 0 && cmp_color(old_color, get_pixel_color(tex, x - 1, y1))) 
         
     | 
| 
       664 
672 
     | 
    
         
             
                                    {
         
     | 
| 
       665 
673 
     | 
    
         
             
                                        if(!push(x - 1, y1, tex->width - 1)) return;
         
     | 
| 
       666 
674 
     | 
    
         
             
                                        spanLeft = true;
         
     | 
    
        data/ext/texplay/cache.c
    CHANGED
    
    | 
         @@ -25,13 +25,9 @@ cache_entry* 
     | 
|
| 
       25 
25 
     | 
    
         
             
            cache_create_entry(int tname) {
         
     | 
| 
       26 
26 
     | 
    
         
             
                float * new_array;
         
     | 
| 
       27 
27 
     | 
    
         
             
                int sidelength, new_element = cache.len;
         
     | 
| 
       28 
     | 
    
         
            -
                GLint saved_tname;
         
     | 
| 
       29 
28 
     | 
    
         | 
| 
       30 
29 
     | 
    
         
             
                if(cache.len >= CACHE_SIZE) {  rb_raise(rb_eRuntimeError, "cache is full! increase CACHE_SIZE");  }
         
     | 
| 
       31 
30 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
                /* save current texture binding */
         
     | 
| 
       33 
     | 
    
         
            -
                /*  glGetIntegerv(GL_TEXTURE_BINDING_2D, &saved_tname); */
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
31 
     | 
    
         
             
                /* opengl initialization code */
         
     | 
| 
       36 
32 
     | 
    
         
             
                glEnable(GL_TEXTURE_2D);
         
     | 
| 
       37 
33 
     | 
    
         
             
                glBindTexture(GL_TEXTURE_2D, tname);
         
     | 
| 
         @@ -53,12 +49,8 @@ cache_create_entry(int tname) { 
     | 
|
| 
       53 
49 
     | 
    
         
             
                /* update size of cache */
         
     | 
| 
       54 
50 
     | 
    
         
             
                cache.len++;
         
     | 
| 
       55 
51 
     | 
    
         | 
| 
       56 
     | 
    
         
            -
                /* restore saved texture binding */
         
     | 
| 
       57 
     | 
    
         
            -
                /* glBindTexture(GL_TEXTURE_2D, saved_tname); */
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
52 
     | 
    
         
             
                glDisable(GL_TEXTURE_2D);
         
     | 
| 
       60 
53 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
54 
     | 
    
         
             
                return &cache.entry[new_element];
         
     | 
| 
       63 
55 
     | 
    
         
             
            }
         
     | 
| 
       64 
56 
     | 
    
         | 
| 
         @@ -92,35 +84,27 @@ void 
     | 
|
| 
       92 
84 
     | 
    
         
             
            cache_refresh_all(void) {
         
     | 
| 
       93 
85 
     | 
    
         
             
                float * tdata;
         
     | 
| 
       94 
86 
     | 
    
         
             
                int tname, index;
         
     | 
| 
       95 
     | 
    
         
            -
                GLint saved_tname;
         
     | 
| 
       96 
87 
     | 
    
         | 
| 
       97 
     | 
    
         
            -
                /*  
     | 
| 
       98 
     | 
    
         
            -
                 
     | 
| 
      
 88 
     | 
    
         
            +
                /* opengl initialization code */
         
     | 
| 
      
 89 
     | 
    
         
            +
                glEnable(GL_TEXTURE_2D);
         
     | 
| 
       99 
90 
     | 
    
         | 
| 
       100 
91 
     | 
    
         
             
                for(index = 0; index < cache.len; index++) {
         
     | 
| 
       101 
92 
     | 
    
         
             
                    tdata = cache.entry[index].tdata;
         
     | 
| 
       102 
93 
     | 
    
         
             
                    tname = cache.entry[index].tname;
         
     | 
| 
       103 
94 
     | 
    
         | 
| 
       104 
     | 
    
         
            -
                    /* opengl initialization code */
         
     | 
| 
       105 
     | 
    
         
            -
                    glEnable(GL_TEXTURE_2D);
         
     | 
| 
       106 
95 
     | 
    
         
             
                    glBindTexture(GL_TEXTURE_2D, tname);
         
     | 
| 
       107 
96 
     | 
    
         | 
| 
       108 
97 
     | 
    
         
             
                    glGetTexImage(GL_TEXTURE_2D,  0, GL_RGBA, GL_FLOAT, (void*)(tdata));
         
     | 
| 
       109 
98 
     | 
    
         
             
                }
         
     | 
| 
       110 
99 
     | 
    
         | 
| 
       111 
     | 
    
         
            -
                 
     | 
| 
       112 
     | 
    
         
            -
                glBindTexture(GL_TEXTURE_2D, saved_tname);
         
     | 
| 
      
 100 
     | 
    
         
            +
                glDisable(GL_TEXTURE_2D);
         
     | 
| 
       113 
101 
     | 
    
         
             
            }
         
     | 
| 
       114 
102 
     | 
    
         | 
| 
       115 
103 
     | 
    
         
             
            /* refresh the cache for a specific quad */
         
     | 
| 
       116 
104 
     | 
    
         
             
            void
         
     | 
| 
       117 
105 
     | 
    
         
             
            cache_refresh_entry(int tname) {
         
     | 
| 
       118 
     | 
    
         
            -
                GLint saved_tname;
         
     | 
| 
       119 
106 
     | 
    
         
             
                cache_entry * entry;
         
     | 
| 
       120 
107 
     | 
    
         | 
| 
       121 
     | 
    
         
            -
                /* save current texture binding */
         
     | 
| 
       122 
     | 
    
         
            -
                glGetIntegerv(GL_TEXTURE_BINDING_2D, &saved_tname);
         
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
108 
     | 
    
         
             
                entry = find_in_cache(tname);
         
     | 
| 
       125 
109 
     | 
    
         | 
| 
       126 
110 
     | 
    
         
             
                /* opengl initialization code */
         
     | 
| 
         @@ -129,7 +113,6 @@ cache_refresh_entry(int tname) { 
     | 
|
| 
       129 
113 
     | 
    
         | 
| 
       130 
114 
     | 
    
         
             
                glGetTexImage(GL_TEXTURE_2D,  0, GL_RGBA, GL_FLOAT, (void*)(entry->tdata));
         
     | 
| 
       131 
115 
     | 
    
         | 
| 
       132 
     | 
    
         
            -
                 
     | 
| 
       133 
     | 
    
         
            -
                glBindTexture(GL_TEXTURE_2D, saved_tname);
         
     | 
| 
      
 116 
     | 
    
         
            +
                glDisable(GL_TEXTURE_2D);
         
     | 
| 
       134 
117 
     | 
    
         
             
            }
         
     | 
| 
       135 
118 
     | 
    
         | 
    
        data/ext/texplay/texplay.c
    CHANGED
    
    | 
         @@ -12,11 +12,18 @@ 
     | 
|
| 
       12 
12 
     | 
    
         
             
            #include "bindings.h"
         
     | 
| 
       13 
13 
     | 
    
         
             
            #include "object2module.h"
         
     | 
| 
       14 
14 
     | 
    
         
             
            #include "gen_eval.h"
         
     | 
| 
      
 15 
     | 
    
         
            +
            #ifdef __APPLE__
         
     | 
| 
      
 16 
     | 
    
         
            +
            # include <glut.h>
         
     | 
| 
      
 17 
     | 
    
         
            +
            #else
         
     | 
| 
      
 18 
     | 
    
         
            +
            # include <GL/glut.h>
         
     | 
| 
      
 19 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
       15 
21 
     | 
    
         | 
| 
       16 
22 
     | 
    
         
             
            /* setup ruby bindings */
         
     | 
| 
       17 
23 
     | 
    
         | 
| 
       18 
24 
     | 
    
         
             
            /** constructor for TPPoint class **/
         
     | 
| 
       19 
25 
     | 
    
         
             
            static VALUE m_init_TPPoint(int argc, VALUE * argv, VALUE self);
         
     | 
| 
      
 26 
     | 
    
         
            +
            static void monkey_patch_gosu(void);
         
     | 
| 
       20 
27 
     | 
    
         | 
| 
       21 
28 
     | 
    
         
             
            void
         
     | 
| 
       22 
29 
     | 
    
         
             
            Init_texplay() {
         
     | 
| 
         @@ -103,6 +110,7 @@ Init_texplay() { 
     | 
|
| 
       103 
110 
     | 
    
         
             
                /* seed the random number generator */
         
     | 
| 
       104 
111 
     | 
    
         
             
                srand(time(NULL));
         
     | 
| 
       105 
112 
     | 
    
         | 
| 
      
 113 
     | 
    
         
            +
                monkey_patch_gosu();
         
     | 
| 
       106 
114 
     | 
    
         
             
                /** end basic setup **/
         
     | 
| 
       107 
115 
     | 
    
         
             
            }
         
     | 
| 
       108 
116 
     | 
    
         | 
| 
         @@ -130,7 +138,31 @@ m_init_TPPoint(int argc, VALUE * argv, VALUE self) 
     | 
|
| 
       130 
138 
     | 
    
         
             
            }
         
     | 
| 
       131 
139 
     | 
    
         
             
            /** end constructor for TPPoint **/
         
     | 
| 
       132 
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"));
         
     | 
| 
       133 
163 
     | 
    
         | 
| 
      
 164 
     | 
    
         
            +
                rb_define_method(GosuWindow, "to_blob", gosu_window_to_blob, 0);
         
     | 
| 
      
 165 
     | 
    
         
            +
            }    
         
     | 
| 
       134 
166 
     | 
    
         | 
| 
       135 
167 
     | 
    
         | 
| 
       136 
168 
     | 
    
         | 
    
        data/lib/1.8/texplay.so
    CHANGED
    
    | 
         Binary file 
     | 
    
        data/lib/1.9/texplay.so
    CHANGED
    
    | 
         Binary file 
     | 
    
        data/lib/texplay.rb
    CHANGED
    
    | 
         @@ -5,30 +5,35 @@ begin 
     | 
|
| 
       5 
5 
     | 
    
         
             
            rescue LoadError
         
     | 
| 
       6 
6 
     | 
    
         
             
            end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
      
 8 
     | 
    
         
            +
            direc = File.dirname(__FILE__)
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
       8 
10 
     | 
    
         
             
            # include gosu first
         
     | 
| 
       9 
11 
     | 
    
         
             
            require 'rbconfig'
         
     | 
| 
       10 
12 
     | 
    
         
             
            require 'gosu'
         
     | 
| 
      
 13 
     | 
    
         
            +
            require "#{direc}/texplay/version"
         
     | 
| 
       11 
14 
     | 
    
         | 
| 
       12 
15 
     | 
    
         
             
            module TexPlay
         
     | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                     
     | 
| 
       20 
     | 
    
         
            -
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 17 
     | 
    
         
            +
                    def on_setup(&block)
         
     | 
| 
      
 18 
     | 
    
         
            +
                        raise "need a block" if !block
         
     | 
| 
      
 19 
     | 
    
         
            +
                        
         
     | 
| 
      
 20 
     | 
    
         
            +
                        @__init_procs__ ||= []
         
     | 
| 
      
 21 
     | 
    
         
            +
                        @__init_procs__.push(block)
         
     | 
| 
      
 22 
     | 
    
         
            +
                    end
         
     | 
| 
       21 
23 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
                    def setup(receiver)
         
     | 
| 
      
 25 
     | 
    
         
            +
                        if @__init_procs__ then
         
     | 
| 
      
 26 
     | 
    
         
            +
                            @__init_procs__.each do |init_proc|
         
     | 
| 
      
 27 
     | 
    
         
            +
                                receiver.instance_eval(&init_proc)
         
     | 
| 
      
 28 
     | 
    
         
            +
                            end
         
     | 
| 
       26 
29 
     | 
    
         
             
                        end
         
     | 
| 
       27 
30 
     | 
    
         
             
                    end
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
31 
     | 
    
         | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 32 
     | 
    
         
            +
                    def create_blank_image(window, width, height)
         
     | 
| 
      
 33 
     | 
    
         
            +
                        Gosu::Image.new(window, EmptyImageStub.new(width, height))
         
     | 
| 
      
 34 
     | 
    
         
            +
                    end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                    alias_method :create_image, :create_blank_image
         
     | 
| 
       32 
37 
     | 
    
         
             
                end
         
     | 
| 
       33 
38 
     | 
    
         | 
| 
       34 
39 
     | 
    
         
             
                module Colors
         
     | 
| 
         @@ -90,6 +95,8 @@ module Gosu 
     | 
|
| 
       90 
95 
     | 
    
         | 
| 
       91 
96 
     | 
    
         
             
                    # bring in the TexPlay image manipulation methods
         
     | 
| 
       92 
97 
     | 
    
         
             
                    include TexPlay
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                    attr_reader :__window__
         
     | 
| 
       93 
100 
     | 
    
         | 
| 
       94 
101 
     | 
    
         
             
                    class << self 
         
     | 
| 
       95 
102 
     | 
    
         
             
                        alias_method :original_new, :new
         
     | 
| 
         @@ -100,8 +107,8 @@ module Gosu 
     | 
|
| 
       100 
107 
     | 
    
         
             
                            obj = original_new(*args, &block)
         
     | 
| 
       101 
108 
     | 
    
         | 
| 
       102 
109 
     | 
    
         
             
                            # refresh the TexPlay image cache
         
     | 
| 
       103 
     | 
    
         
            -
                            if obj.width <= (TexPlay::TP_MAX_QUAD_SIZE 
     | 
| 
       104 
     | 
    
         
            -
                                    obj.height <= (TexPlay::TP_MAX_QUAD_SIZE 
     | 
| 
      
 110 
     | 
    
         
            +
                            if obj.width <= (TexPlay::TP_MAX_QUAD_SIZE) &&
         
     | 
| 
      
 111 
     | 
    
         
            +
                                    obj.height <= (TexPlay::TP_MAX_QUAD_SIZE) && obj.quad_cached? then
         
     | 
| 
       105 
112 
     | 
    
         | 
| 
       106 
113 
     | 
    
         
             
                                obj.refresh_cache
         
     | 
| 
       107 
114 
     | 
    
         
             
                            end
         
     | 
| 
         @@ -115,10 +122,6 @@ module Gosu 
     | 
|
| 
       115 
122 
     | 
    
         
             
                            obj
         
     | 
| 
       116 
123 
     | 
    
         
             
                        end
         
     | 
| 
       117 
124 
     | 
    
         
             
                    end
         
     | 
| 
       118 
     | 
    
         
            -
                    
         
     | 
| 
       119 
     | 
    
         
            -
                    def __window__
         
     | 
| 
       120 
     | 
    
         
            -
                        @__window__
         
     | 
| 
       121 
     | 
    
         
            -
                    end
         
     | 
| 
       122 
125 
     | 
    
         
             
                end
         
     | 
| 
       123 
126 
     | 
    
         
             
            end
         
     | 
| 
       124 
127 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: texplay
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.710
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: x86-mswin32
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
7 
     | 
    
         
             
            - John Mair (banisterfiend)
         
     | 
| 
         @@ -9,7 +9,7 @@ autorequire: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            date: 2009- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2009-12-08 00:00:00 -05:00
         
     | 
| 
       13 
13 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -36,6 +36,7 @@ files: 
     | 
|
| 
       36 
36 
     | 
    
         
             
            - CHANGELOG
         
     | 
| 
       37 
37 
     | 
    
         
             
            - lib/texplay.rb
         
     | 
| 
       38 
38 
     | 
    
         
             
            - lib/texplay-contrib.rb
         
     | 
| 
      
 39 
     | 
    
         
            +
            - lib/texplay/version.rb
         
     | 
| 
       39 
40 
     | 
    
         
             
            - ext/texplay/extconf.rb
         
     | 
| 
       40 
41 
     | 
    
         
             
            - ext/texplay/object2module.h
         
     | 
| 
       41 
42 
     | 
    
         
             
            - ext/texplay/bindings.h
         
     | 
| 
         @@ -55,9 +56,11 @@ files: 
     | 
|
| 
       55 
56 
     | 
    
         
             
            - examples/example_dup.rb
         
     | 
| 
       56 
57 
     | 
    
         
             
            - examples/example_turtle.rb
         
     | 
| 
       57 
58 
     | 
    
         
             
            - examples/example_color_control.rb
         
     | 
| 
      
 59 
     | 
    
         
            +
            - examples/example_sine.rb
         
     | 
| 
       58 
60 
     | 
    
         
             
            - examples/example_effect.rb
         
     | 
| 
       59 
61 
     | 
    
         
             
            - examples/common.rb
         
     | 
| 
       60 
62 
     | 
    
         
             
            - examples/example_color_transform.rb
         
     | 
| 
      
 63 
     | 
    
         
            +
            - examples/example_fill_test.rb
         
     | 
| 
       61 
64 
     | 
    
         
             
            - examples/example_hash_arguments.rb
         
     | 
| 
       62 
65 
     | 
    
         
             
            - examples/example_gen_eval.rb
         
     | 
| 
       63 
66 
     | 
    
         
             
            - examples/example_polyline.rb
         
     | 
| 
         @@ -67,6 +70,7 @@ files: 
     | 
|
| 
       67 
70 
     | 
    
         
             
            - examples/example_fill_old.rb
         
     | 
| 
       68 
71 
     | 
    
         
             
            - examples/example_blur.rb
         
     | 
| 
       69 
72 
     | 
    
         
             
            - examples/example_each.rb
         
     | 
| 
      
 73 
     | 
    
         
            +
            - examples/example_modify.rb
         
     | 
| 
       70 
74 
     | 
    
         
             
            - examples/example_fluent.rb
         
     | 
| 
       71 
75 
     | 
    
         
             
            - examples/example_sync.rb
         
     | 
| 
       72 
76 
     | 
    
         
             
            - examples/example_splice.rb
         
     | 
| 
         @@ -81,6 +85,7 @@ files: 
     | 
|
| 
       81 
85 
     | 
    
         
             
            - examples/media/texplay.png
         
     | 
| 
       82 
86 
     | 
    
         
             
            - examples/media/gosu.png
         
     | 
| 
       83 
87 
     | 
    
         
             
            - examples/media/logo.png
         
     | 
| 
      
 88 
     | 
    
         
            +
            - examples/media/platform.png
         
     | 
| 
       84 
89 
     | 
    
         
             
            - examples/media/empty2.png
         
     | 
| 
       85 
90 
     | 
    
         
             
            - lib/1.8/texplay.so
         
     | 
| 
       86 
91 
     | 
    
         
             
            - lib/1.9/texplay.so
         
     |