示例#1
0
 def drawConnector(text, nback, width):
     vtx = stimuli.Shape(line_width=2)
     halfwidth = int(width / 2 * nback)
     height = int(-width / 3)
     vtx.add_vertices([(-halfwidth * 1.4, height),
                       (-halfwidth * 0.6, -height),
                       (halfwidth * 0.6, height)])
     vtx.move((-width / 2 * nback, 0))
     txt = stimuli.TextBox(text, size=(width, width), position=(0, height))
     return (vtx, txt)
示例#2
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)
示例#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)