Sha256: 316583b980a8391c662b15e20b951a0920194bcee274a2c71ba9a2ffb38acfbb
Contents?: true
Size: 774 Bytes
Versions: 3
Compression:
Stored size: 774 Bytes
Contents
# frozen_string_literal: true module ShapeHelper def path_commands $path_commands ||= [] end def move_to(x, y) validate_coordinates(x, y) path_commands << "M #{x} #{y}" end def line_to(x, y) validate_coordinates(x, y) path_commands << "L #{x} #{y}" end def shape_path path_commands_str = path_commands.join(" ") path_commands_str end def colors $colors ||= [] end def fill(color) $current_color = color end def color_for_fill $current_color || "black" end private def validate_coordinates(x, y) raise ArgumentError, "Invalid coordinates: x=#{x}, y=#{y}" unless valid_coordinate?(x) && valid_coordinate?(y) end def valid_coordinate?(coordinate) coordinate.is_a?(Numeric) end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
lacci-0.2.1 | lib/scarpe/wv/shape_helper.rb |
scarpe-0.2.1 | lib/scarpe/wv/shape_helper.rb |
scarpe-0.2.0 | lib/scarpe/wv/shape_helper.rb |