Module: Skeptick::RoundedCornersImage

Included in:
Skeptick, DslContext
Defined in:
lib/skeptick/sugar/rounded_corners_image.rb

Instance Method Summary collapse

Instance Method Details

#rounded_corners_image(*args, &blk) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/skeptick/sugar/rounded_corners_image.rb', line 7

def rounded_corners_image(*args, &blk)
  opts = args.last.is_a?(Hash) ? args.pop : {}
  radius = opts[:radius] || 15
  size   = opts[:size]
  width  = opts[:width]
  height = opts[:height]

  if size
    width, height = size.split('x').map(&:to_i)
  end

  border = if width && height
    "roundrectangle 1,1 #{width},#{height} #{radius},#{radius}"
  else
    Convert.new(self, *args, to: 'info:') do
      format "roundrectangle 1,1 %[fx:w], %[fx:h] #{radius},#{radius}"
    end.run.strip
  end

  compose(:dstin, *args) do
    convert(&blk) if block_given?

    convert do
      set '+clone'
      set :draw, border
    end
  end
end