Sha256: 466dc9f796f72371937a89d14089d63dd0de9c362844c9b0dd4730253bdbdcc7

Contents?: true

Size: 868 Bytes

Versions: 137

Compression:

Stored size: 868 Bytes

Contents

module Cairo
  class Context
    module Rectangle
      def rounded_rectangle(x, y, width, height, x_radius, y_radius=nil)
        x1 = x
        x2 = x1 + width
        y1 = y
        y2 = y1 + height

        y_radius ||= x_radius

        x_radius = [x_radius, width / 2.0].min
        y_radius = [y_radius, height / 2.0].min

        xr1 = x_radius
        xr2 = x_radius / 2.0
        yr1 = y_radius
        yr2 = y_radius / 2.0

        move_to(x1 + xr1, y1)
        line_to(x2 - xr1, y1)
        curve_to(x2 - xr2, y1, x2, y1 + yr2, x2, y1 + yr1)
        line_to(x2, y2 - yr1)
        curve_to(x2, y2 - yr2, x2 - xr2, y2, x2 - xr1, y2)
        line_to(x1 + xr1, y2)
        curve_to(x1 + xr2, y2, x1, y2 - yr2, x1, y2 - yr1)
        line_to(x1, y1 + yr1)
        curve_to(x1, y1 + yr2, x1 + xr2, y1, x1 + xr1, y1)
        close_path
      end
    end
  end
end

Version data entries

137 entries across 129 versions & 2 rubygems

Version Path
cairo-1.17.13 lib/cairo/context/rectangle.rb
cairo-1.17.12 lib/cairo/context/rectangle.rb
cairo-1.17.11 lib/cairo/context/rectangle.rb
cairo-1.17.10 lib/cairo/context/rectangle.rb
cairo-1.17.9 lib/cairo/context/rectangle.rb
cairo-1.17.8 lib/cairo/context/rectangle.rb
cairo-1.17.7 lib/cairo/context/rectangle.rb
cairo-1.17.6 lib/cairo/context/rectangle.rb
cairo-1.17.5 lib/cairo/context/rectangle.rb
cairo-1.17.4 lib/cairo/context/rectangle.rb
cairo-1.16.6 lib/cairo/context/rectangle.rb
cairo-1.16.5 lib/cairo/context/rectangle.rb
cairo-1.16.4 lib/cairo/context/rectangle.rb
cairo-1.16.3 lib/cairo/context/rectangle.rb
cairo-1.16.2 lib/cairo/context/rectangle.rb
cairo-1.16.1-x86-mingw32 lib/cairo/context/rectangle.rb
cairo-1.16.1-x64-mingw32 lib/cairo/context/rectangle.rb
cairo-1.16.1 lib/cairo/context/rectangle.rb
cairo-1.16.0-x86-mingw32 lib/cairo/context/rectangle.rb
cairo-1.16.0-x64-mingw32 lib/cairo/context/rectangle.rb