Skip to content

Commit

Permalink
starting live repo
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Sep 18, 2014
0 parents commit c8f1569
Show file tree
Hide file tree
Showing 43 changed files with 6,617 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MosaicPlanner</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
7 changes: 7 additions & 0 deletions .pydevproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse-pydev version="1.0"?>

<pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
</pydev_project>
46 changes: 46 additions & 0 deletions CenterRectangle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#===============================================================================
#
# License: GPL
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License 2
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#===============================================================================

import matplotlib.patches

class CenterRectangle(matplotlib.patches.Rectangle):
"""a simple extension of the matplotlib Rectangle class which allows you to specify the center and width/height
rather than the corner and the width/height of the rectangle"""
def __init__(self,xy, width, height, **kwargs):
self.xyc=xy
(x,y)=xy
self.l=x-width/2
self.b=y-height/2
matplotlib.patches.Rectangle.__init__(self, (self.l,self.b), width, height,**kwargs)

def set_center(self,xy):
"""sets a new center point tuple for the rectangle.. do not use set_x and set_y with this class
as those still specify the corner"""
self.xyc=xy
(x,y)=xy
self.set_x(x-self.get_width()/2)
self.set_y(y-self.get_height()/2)
def set_width(self,width):
"""sets the width of this rectangle, and then recalls the setting of the center so that its center stays still"""
super(type(self), self).set_width(width)
self.set_center(self.xyc)
def set_height(self,height):
"""sets the height of this rectangle, and then recalls the set_center so that the center stays still"""
super(type(self), self).set_height(height)
self.set_center(self.xyc)
Loading

0 comments on commit c8f1569

Please sign in to comment.