X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/baf9ff0ec39c13f52ee8d4f087641dc5fcc9c53b..fcc68b4dc198b7cb0cf93467d96038b0844675fe:/vendor/plugins/ym4r_gm/lib/gm_plugin/point.rb diff --git a/vendor/plugins/ym4r_gm/lib/gm_plugin/point.rb b/vendor/plugins/ym4r_gm/lib/gm_plugin/point.rb new file mode 100644 index 0000000..bcde4e2 --- /dev/null +++ b/vendor/plugins/ym4r_gm/lib/gm_plugin/point.rb @@ -0,0 +1,34 @@ +module Ym4r + module GmPlugin + #A point in pixel coordinates + class GPoint < Struct.new(:x,:y) + include MappingObject + def create + "new GPoint(#{x},#{y})" + end + end + #A rectangular that contains all the pixel points passed as arguments + class GBounds + include MappingObject + attr_accessor :points + #Accepts both an array of GPoint and an array of 2-element arrays + def initialize(points) + if !points.empty? and points[0].is_a?(Array) + @points = points.collect { |pt| GPoint.new(pt[0],pt[1]) } + else + @points = points + end + end + def create + "new GBounds([#{@points.map { |pt| pt.to_javascript}.join(",")}])" + end + end + #A size object, in pixel space + class GSize < Struct.new(:width,:height) + include MappingObject + def create + "new GSize(#{width},#{height})" + end + end + end +end