コード例 #1
0
    def __init__(self, size, position=None, colour=None, anti_aliasing=None):
        """Create a filled rectangle.

        Parameters
        ----------
        size : (int, int)
            size (width, height) of the Rectangle
        position : (int, int), optional
            position of the stimulus
        colour   : (int, int, int), optional
            colour of the rectangle
        anti_aliasing : int, optional
            anti aliasing parameter

        """

        if position is None:
            position = defaults.polygonrectangle_position
        if colour is None:
            colour = defaults.polygonrectangle_colour
        if colour is None:
            colour = expyriment._active_exp.foreground_colour
        if anti_aliasing is None:
            anti_aliasing = defaults.polygonrectangle_anti_aliasing

        Shape.__init__(self,
                       position=position,
                       colour=colour,
                       line_width=0,
                       anti_aliasing=anti_aliasing)
        self.add_vertex((size[0], 0))
        self.add_vertex((0, size[1]))
        self.add_vertex((-size[0], 0))
コード例 #2
0
    def __init__(self, size, position=None, colour=None, anti_aliasing=None):
        """Create a filled rectangle.

        Parameters
        ----------
        size : (int, int)
            size (width, height) of the Rectangle
        position : (int, int), optional
            position of the stimulus
        colour   : (int, int, int), optional
            colour of the rectangle
        anti_aliasing : int, optional
            anti aliasing parameter

        """

        if position is None:
            position = defaults.polygonrectangle_position
        if colour is None:
            colour = defaults.polygonrectangle_colour
        if colour is None:
            colour = expyriment._active_exp.foreground_colour
        if anti_aliasing is None:
            anti_aliasing = defaults.polygonrectangle_anti_aliasing

        Shape.__init__(self, position=position, colour=colour,
                       line_width=0, anti_aliasing=anti_aliasing)
        self.add_vertex((size[0], 0))
        self.add_vertex((0, size[1]))
        self.add_vertex((-size[0], 0))
コード例 #3
0
    def __init__(self, size, position=None, line_width=None, colour=None,
                 resolution_factor=None, anti_aliasing=None):
        """Create an ellipse.

        Parameters
        ----------
        size : (int,int)
            size of the ellipse (x,y)
        position : (int, int, int), optional
            position of the stimulus
        colour  : (int, int, int), optional
        line_width : int, optional
            if line width is 0, the shape is filled
        resolution_factor : int, optional
            The resolution_factor increases the resolution of the eclipse.
            The default factor is 1 resulting in 36 points describing the
            ellipse
        anti_aliasing : int, optional
            anti aliasing parameter

        """

        if position is None:
            position = defaults.polygonellipse_position
        if colour is None:
            colour = defaults.polygonellipse_colour
        if anti_aliasing is None:
            anti_aliasing = defaults.polygonellipse_anti_aliasing
        if resolution_factor is None:
            resolution_factor = defaults.polygonellipse_resolution_factor
        if line_width is None:
            line_width = defaults.polygonellipse_line_width

        Shape.__init__(self, position=position, colour=colour,
                         anti_aliasing=anti_aliasing,
                         line_width=line_width)

        self._resolution_factor = resolution_factor
        self._ellipse_size = list(size)
        self._circumference = None

        n_vtx = self._default_number_of_vertices * self._resolution_factor
        s = 2 * _math.pi / n_vtx
        w, h = self.ellipse_size
        l = 0
        points = []
        while l < 2 * _math.pi:
            points.append([.5 * _math.cos(l) * w + .5 * w,
                           .5 * _math.sin(l) * h + .5 * h])
            l = l + s
        self._vertices = _geometry.points_to_vertices(points)
        self._update_points()
コード例 #4
0
    def __init__(self, size, position=None, colour=None, anti_aliasing=0):
        """Create a filled rectangle.

        Parameters
        ----------
        size : (int, int)
            size (width, height) of the Rectangle
        position : (int, int), optional
            position of the stimulus
        colour   : (int, int, int), optional
            colour of the rectangle
        anti_aliasing : int, optional
            anti aliasing parameter (default=0)

        """

        Shape.__init__(self, position=position, colour=colour,
                       line_width=0, anti_aliasing=anti_aliasing)
        self.add_vertex((size[0], 0))
        self.add_vertex((0, size[1]))
        self.add_vertex((-size[0], 0))