Exemple #1
0
 def cmcoord2pix(self, cx, cy, display_index=None):
     if display_index == self.getIndex():
         return psychopy2displayPix(
             misc.cm2pix(
                 cx, self._psychopy_monitor), misc.cm2pix(
                 cy, self._psychopy_monitor))
     return cx, cy
 def cmcoord2pix(self, cx, cy, display_index=None):
     if display_index == self.getIndex():
         return psychopy2displayPix(
             misc.cm2pix(
                 cx, self._psychopy_monitor), misc.cm2pix(
                 cy, self._psychopy_monitor))
     return cx, cy
Exemple #3
0
    def __init__(self,
                 size=(800, 600),
                 position=None,
                 units="pix",
                 monitor=None):
        """
        Parameters
        ----------

        size : *(800, 600)* or tuple
            tuple containing the width and the height of the window in pixel
        position : *None* or tuple
            if None screen center, otherwise the position given in a tuple 
            containing the center of the window relative to the center of
            the screen (positive values mean up/right)
        units : "pix", "deg", "cm", "norm" (optional)
            psychopy units to calculate size and position of the window. If
            units is different from "pix" monitor must be present. Default is
            "pix."
        monitor : psychopy.monitors.Monitor (optional)
            psychopy monitor object, that is used to convert units.


        """
        if units != "pix":
            if not monitor:
                raise ValueError(
                    "if units is not 'pix', monitor must be supplied")

        # convert to pixel
        if units == "deg":
            size = [misc.deg2pix(x, monitor) for x in size]
            if position:
                position = [misc.deg2pix(x, monitor) for x in position]
        elif units == "cm":
            size = [misc.cm2pix(x, monitor) for x in size]
            if position:
                position = [misc.cm2pix(x, monitor) for x in position]
        elif units == "norm":
            size = [
                int(monitor.getSizePix()[0] * (float(size[0]) / 2)),
                int(monitor.getSizePix()[1] * (float(size[1]) / 2))
            ]
            if position:
                position = [
                    int(monitor.getSizePix()[0] * position[0]),
                    int(monitor.getSizePix()[1] * position[1])
                ]
        else:
            raise ValueError(
                "only 'pix', 'deg', 'cm', or 'norm' are accepted units.")

        # call parent with calculated parameters
        super(PsyTMLPsychopy, self).__init__(size, position)
Exemple #4
0
 def degcoord2pix(self, degx, degy, display_index=None):
     if display_index == self.getIndex():
         return psychopy2displayPix(
             misc.deg2pix(
                 degx, self._psychopy_monitor), misc.cm2pix(
                 degy, self._psychopy_monitor))
     return degx, degy
 def degcoord2pix(self, degx, degy, display_index=None):
     if display_index == self.getIndex():
         return psychopy2displayPix(
             misc.deg2pix(
                 degx, self._psychopy_monitor), misc.cm2pix(
                 degy, self._psychopy_monitor))
     return degx, degy
Exemple #6
0
    def __init__(self, size=(800, 600), position=None, units="pix",
                 monitor=None):
        """
        Parameters
        ----------

        size : *(800, 600)* or tuple
            tuple containing the width and the height of the window in pixel
        position : *None* or tuple
            if None screen center, otherwise the position given in a tuple 
            containing the center of the window relative to the center of
            the screen (positive values mean up/right)
        units : "pix", "deg", "cm", "norm" (optional)
            psychopy units to calculate size and position of the window. If
            units is different from "pix" monitor must be present. Default is
            "pix."
        monitor : psychopy.monitors.Monitor (optional)
            psychopy monitor object, that is used to convert units.


        """
        if units != "pix":
            if not monitor:
                raise ValueError("if units is not 'pix', monitor must be supplied")

        # convert to pixel
        if units == "deg":
            size = [misc.deg2pix(x, monitor) for x in size]
            if position:
                position = [misc.deg2pix(x, monitor) for x in position]
        elif units == "cm":
            size = [misc.cm2pix(x, monitor) for x in size]
            if position:
                position = [misc.cm2pix(x, monitor) for x in position]
        elif units == "norm":
            size = [int(monitor.getSizePix()[0] * (float(size[0])/2)), int(monitor.getSizePix()[1] * (float(size[1])/2))]
            if position:
                position = [int(monitor.getSizePix()[0] * position[0]), int(monitor.getSizePix()[1] * position[1])]
        else:
            raise ValueError("only 'pix', 'deg', 'cm', or 'norm' are accepted units.")
        
        # call parent with calculated parameters
        super(PsyTMLPsychopy, self).__init__(size, position)