Skip to content

Commit

Permalink
ENH: added bounding box property to extract the w,h of rendered text
Browse files Browse the repository at this point in the history
NB: Currently only works in pixels
  • Loading branch information
peircej committed Jun 25, 2015
1 parent 02571d0 commit 35c168f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion psychopy/visual/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,18 @@ def wrapWidth(self, wrapWidth):
self.__dict__['wrapWidth'] = wrapWidth
self._wrapWidthPix = convertToPix(pos = numpy.array([0, 0]), vertices=numpy.array([self.wrapWidth, 0]), units=self.units, win=self.win)[0]
self._needSetText = True


@property
def boundingBox(self):
"""(read only) attribute representing the bounding box of the text (w,h).
This differs from `width` in that the width represents the width of the
margins, which might differ from the width of the text within them
NOTE: currently always returns the size in pixels
(this will change to return in stimulus units)
"""
return (self._pygletTextObj._layout.content_width, self._pygletTextObj._layout.content_height)

@property
def posPix(self):
"""This determines the coordinates in pixels of the position for the
Expand Down

0 comments on commit 35c168f

Please sign in to comment.