Пример #1
0
 def _posToRating(self, pos):
     # Get ticks or substitute
     if self.ticks is not None:
         ticks = self.ticks
     else:
         ticks = [0, 1]
     # Get in pix
     pos = layout.Position(pos, units=self.win.units, win=self.win).pix
     # Get difference from scale pos
     delta = pos - self._pos.pix
     # Adjust to scale size
     delta = delta / self._extent.pix + 0.5
     # Adjust to scale magnitude
     magDelta = delta * (ticks[-1] - ticks[0])
     # Adjust to scale bottom
     rating = magDelta + ticks[0]
     # Return relevant value according to orientation
     return rating[1 - int(self.horiz)]
Пример #2
0
 def _ratingToPos(self, rating):
     # Get ticks or substitute
     if self.ticks is not None:
         ticks = self.ticks
     else:
         ticks = [0, 1]
     # Reshape rating to handle multiple values
     rating = np.array(rating)
     rating = rating.reshape((-1, 1))
     rating = np.hstack((rating, rating))
     # Adjust to scale bottom
     magDelta = rating - ticks[0]
     # Adjust to scale magnitude
     delta = magDelta / (ticks[-1] - ticks[0])
     # Adjust to scale size
     delta = self._extent.pix * (delta - 0.5)
     # Adjust to scale pos
     pos = delta + self._pos.pix
     # Replace irrelevant value according to orientation
     pos[:, int(self.horiz)] = self._pos.pix[int(self.horiz)]
     # Convert to native units
     return getattr(layout.Position(pos, units="pix", win=self.win),
                    self.units)
Пример #3
0
from psychopy.tests import utils
from psychopy.visual import helpers
from numpy import sqrt
import matplotlib

mon = monitors.Monitor('testMonitor')
mon.setDistance(57)
mon.setWidth(40.0)
mon.setSizePix([1024, 768])
win = visual.Window([512, 512], monitor=mon, winType='pyglet', autoLog=False)

unitDist = 0.2
sqrt2 = sqrt(2)

points = [
    layout.Position((0, 0), 'height', win),
    layout.Position((0, unitDist), 'height', win),
    layout.Position((0, unitDist * 2), 'height', win),
    layout.Position(((unitDist / sqrt2), (unitDist / sqrt2)), 'height', win),
    layout.Position((unitDist * sqrt2, 0), 'height', win),
    layout.Position((unitDist * sqrt2, unitDist * sqrt2), 'height', win)
]

postures = [{
    'ori': 0,
    'size': layout.Size((1.0, 1.0), 'height', win),
    'pos': layout.Position((0, 0), 'height', win)
}, {
    'ori': 0,
    'size': layout.Size((1.0, 2.0), 'height', win),
    'pos': layout.Position((0, 0), 'height', win)