Created
March 15, 2014 12:26
-
-
Save DanielVartanov/9566380 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Graphics < Struct.new(:screen) | |
def initialize(*args) | |
super | |
extend_point_class | |
end | |
def extend_point_class | |
screen_centre = screen.size.map { |axis| axis / 2 } | |
point_extension = Module.new do | |
define_method :to_screen_coordinates do | |
[screen_centre[0] + x, screen_centre[1] - y] | |
end | |
end | |
::Geometry::Point.class_eval do | |
include point_extension | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment