Sha256: ad6001baa3c2b494058f5a1d3b184ac8647da91ef878ccb2c3f33d8c0a170fdd

Contents?: true

Size: 1.1 KB

Versions: 117

Compression:

Stored size: 1.1 KB

Contents

#!/usr/bin/env ruby

top = File.expand_path(File.join(File.dirname(__FILE__), ".."))
$LOAD_PATH.unshift File.join(top, "ext", "cairo")
$LOAD_PATH.unshift File.join(top, "lib")

require 'cairo'

margin = 10
rectangle_width = 300
rectangle_height = 100

width = rectangle_width + 2 * margin
height = (rectangle_height + 2 * margin) * 3

surface = Cairo::ImageSurface.new(width, height)
context = Cairo::Context.new(surface)

context.set_source_color(:white)
context.paint

module Cairo
  module Color
    GRAY30 = Cairo::Color::RGB.new(0.3, 0.3, 0.3)
  end
end

context.set_source_color(:gray30)
context.rectangle(margin, margin, rectangle_width, rectangle_height)
context.fill

context.pseudo_blur do
  context.set_source_color(:gray30)
  context.rectangle(margin, rectangle_height + 2 * margin + margin / 2,
                    rectangle_width, rectangle_height)
  context.fill
end

context.pseudo_blur(5) do
  context.set_source_color(:gray30)
  context.rectangle(margin, (rectangle_height + 2 * margin) * 2 + margin / 2,
                    rectangle_width, rectangle_height)
  context.fill
end

surface.write_to_png("blur.png")

Version data entries

117 entries across 109 versions & 2 rubygems

Version Path
savant-echo-0.1.9 bin/alexa-0.1.2-osx/lib/vendor/ruby/2.2.0/gems/cairo-1.15.2/samples/blur.rb
savant-echo-0.1.9 bin/packaging/vendor/ruby/2.2.0/gems/cairo-1.15.2/samples/blur.rb
savant-echo-0.1.6 bin/alexa-0.1.2-osx/lib/vendor/ruby/2.2.0/gems/cairo-1.15.2/samples/blur.rb
savant-echo-0.1.6 bin/packaging/vendor/ruby/2.2.0/gems/cairo-1.15.2/samples/blur.rb
savant-echo-0.1.5 bin/alexa-0.1.2-osx/lib/vendor/ruby/2.2.0/gems/cairo-1.15.2/samples/blur.rb
savant-echo-0.1.5 bin/packaging/vendor/ruby/2.2.0/gems/cairo-1.15.2/samples/blur.rb
savant-echo-0.1.4 bin/alexa-0.1.2-osx/lib/vendor/ruby/2.2.0/gems/cairo-1.15.2/samples/blur.rb
savant-echo-0.1.4 bin/packaging/vendor/ruby/2.2.0/gems/cairo-1.15.2/samples/blur.rb
savant-echo-0.1.3 bin/packaging/vendor/ruby/2.2.0/gems/cairo-1.15.2/samples/blur.rb
savant-echo-0.1.3 bin/alexa-0.1.2-osx/lib/vendor/ruby/2.2.0/gems/cairo-1.15.2/samples/blur.rb
cairo-1.15.3-x86-mingw32 samples/blur.rb
cairo-1.15.3-x64-mingw32 samples/blur.rb
cairo-1.15.3 samples/blur.rb
cairo-1.14.6 samples/blur.rb
cairo-1.14.6-x86-mingw32 samples/blur.rb
cairo-1.14.6-x64-mingw32 samples/blur.rb
cairo-1.15.2-x64-mingw32 samples/blur.rb
cairo-1.15.2-x86-mingw32 samples/blur.rb
cairo-1.15.2 samples/blur.rb
cairo-1.14.3-x86-mingw32 samples/blur.rb