samples/processing_app/basics/image/alphamask.rb in ruby-processing-1.0.11 vs samples/processing_app/basics/image/alphamask.rb in ruby-processing-2.4.1

- old
+ new

@@ -1,23 +1,17 @@ -require 'ruby-processing' - # Loads a "mask" for an image to specify the transparency # in different parts of the image. The two images are blended # together using the mask() method of PImage. -class Alphamask < Processing::App - def setup - @image = load_image "test.jpg" - @image_mask = load_image "mask.jpg" - @image.mask @image_mask - end - - def draw - background (mouse_x + mouse_y) / 1.5 - image @image, 50, 50 - image @image, mouse_x-50, mouse_y-50 - end - +def setup + size 640, 360 + @image = load_image "test.jpg" + @image_mask = load_image "mask.jpg" + @image.mask @image_mask end -Alphamask.new :title => "Alphamask", :width => 200, :height => 200 \ No newline at end of file +def draw + background((mouse_x + mouse_y) / 1.5) + image @image, width / 2, height / 2 + image @image, mouse_x - @image.width, mouse_y - @image.height +end