Esempio n. 1
0
	def polygon(self, vertices):

		if self.fill:
			line_width = 0
		else:
			line_width = self.penwidth
		# The coordinate transformations are a bit awkard. Shape expects
		# a list of vertices that start form (0,0), but the position of the
		# shape is the center of the shape. So we first need to determine
		# the center of the polygon=(min+max)/2 and then convert the list
		# of vertices to a format that's acceptable to Shape
		center = (min(p[0] for p in vertices) + \
			max(p[0] for p in vertices)) / 2, \
			(min(p[1] for p in vertices) + \
			max(p[1] for p in vertices)) / 2
		stim = stimuli.Shape(colour=self.color.backend_color,
			position=self.to_xy(center), anti_aliasing=self.aa,
			line_width=line_width)
		l = p2v([self.to_xy(p) for p in vertices])
		for v in l: stim.add_vertex(v)
		self.add_stim(stim)
Esempio n. 2
0
	def polygon(self, vertices, fill=False, color=None):

		"""See openexp._canvas.legacy"""

		if color != None: color = self.color(color)
		else: color = self.fgcolor
		if fill: line_width = 0
		else: line_width = self.penwidth
		# The coordinate transformations are a bit awkard. Shape expects
		# a list of vertices that start form (0,0), but the position of the
		# shape is the center of the shape. So we first need to determine
		# the center of the polygon=(min+max)/2 and then convert the list
		# of vertices to a format that's acceptable to Shape
		center = (min(p[0] for p in vertices) + \
			max(p[0] for p in vertices)) / 2, \
			(min(p[1] for p in vertices) + \
			max(p[1] for p in vertices)) / 2
		stim = stimuli.Shape(colour=color, position=c2p(center), \
			anti_aliasing=self.aa, line_width=line_width)
		l = p2v([c2p(p) for p in vertices])
		for v in l: stim.add_vertex(v)
		self.add_stim(stim)
Esempio n. 3
0
    def polygon(self, vertices, fill=False, color=None):
        """See openexp._canvas.legacy"""

        if color != None: color = self.color(color)
        else: color = self.fgcolor
        if fill: line_width = 0
        else: line_width = self.penwidth
        # The coordinate transformations are a bit awkard. Shape expects
        # a list of vertices that start form (0,0), but the position of the
        # shape is the center of the shape. So we first need to determine
        # the center of the polygon=(min+max)/2 and then convert the list
        # of vertices to a format that's acceptable to Shape
        center = (min(p[0] for p in vertices) + \
         max(p[0] for p in vertices)) / 2, \
         (min(p[1] for p in vertices) + \
         max(p[1] for p in vertices)) / 2
        stim = stimuli.Shape(colour=color, position=c2p(center), \
         anti_aliasing=self.aa, line_width=line_width)
        l = p2v([c2p(p) for p in vertices])
        for v in l:
            stim.add_vertex(v)
        self.add_stim(stim)