Last active
May 4, 2016 22:20
-
-
Save cmosguy/7333c5514c8ebffdfedf65c9370de961 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
def getOffsets(big_length, small_length, grid): | |
""" | |
return the lowest/highest offsets, if a shape of small length is | |
rendered and centered inside a larger shape length | |
Returns: | |
An OffsetInfo object with the following attributes: | |
loffset - lowest offset | |
hoffset - highest offset | |
""" | |
offset = big_length - small_length | |
hoffset = snap2Grid(offset / 2.0, grid) | |
loffset = snap2Grid(offset - hoffset, grid) | |
if loffset > hoffset: | |
(loffset, hoffset) = (hoffset, loffset) | |
# assemble OffsetInfo object | |
class OffsetInfo: | |
pass | |
oi = ContactInfo() | |
oi.loffset = loffset | |
oi.hoffset = hoffset | |
return oi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment