def stroke(self):
        """ 使用stroke方法将图形绘制在窗口里，仅对基本的几何图形有效 """
        self.update_all()
        length = len(self.points)
        
        # thick lines
        if self.line_width <= 3:
            if length==4:
                self.vertex_list.draw(pyglet.gl.GL_LINES)
            elif length > 4:
                self.vertex_list.draw(pyglet.gl.GL_LINE_LOOP)
            return

        # 
        color = color_to_tuple(self.color, self.opacity)
        if length == 4:
            x, y, x1, y1 = self.points[0:4]
            l = max(1, math.sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y)))
            ly = (x1-x) / l * self.line_width / 2
            lx = - (y1-y) / l * self.line_width / 2

            points = [x-lx, y-ly, x+lx, y+ly, x1+lx, y1+ly, x1-lx, y1-ly]

            vertex_list = pyglet.graphics.vertex_list(
                4,
                ('v2f', points),
                ('c4B', color * 4))
            vertex_list.draw(pyglet.gl.GL_QUADS)

        elif length > 4:
            points = []
            for i in range(0, length, 2):
                x, y = self.points[i], self.points[i+1]
                x1, y1 = self.points[i-2], self.points[i-1]
                x2, y2 = self.points[(i+2) % length], self.points[(i+3) % length]

                l1 = max(1, math.sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y)))
                l2 = max(1, math.sqrt((x2-x)*(x2-x)+(y2-y)*(y2-y)))

                nx1, ny1 = (x - x1) / l1, (y - y1) / l1
                nx2, ny2 = (x - x2) / l2, (y - y2) / l2
                nx, ny = nx1 + nx2, ny1 + ny2
                vx, vy = -ny1, nx1

                t = nx1*nx2 + ny1*ny2
                if t > 0.99:
                    lx = vx * self.line_width / 2
                    ly = vy * self.line_width / 2
                    points += [x-lx, y-ly, x+lx, y+ly, x+lx, y+ly, x-lx, y-ly]
                elif t < -0.99:
                    lx = vx * self.line_width / 2
                    ly = vy * self.line_width / 2
                    points += [x+lx, y+ly, x-lx, y-ly]
                else:
                    radio = 1/(vx*nx + vy*ny)
                    if radio < 0: 
                        radio = -radio

                    lx = (nx1+nx2) * self.line_width / 2 * radio
                    ly = (ny1+ny2) * self.line_width / 2 * radio
                    points += [x+lx, y+ly, x-lx, y-ly]

            batch = pyglet.graphics.Batch()
            for i in range(0, len(points), 4):

                batch.add(4, pyglet.gl.GL_QUADS, None,
                    ('v2f', (points[i-4], points[i-3], points[i-2], points[i-1],
                        points[i+2], points[i+3], points[i], points[i+1])),
                    ('c4B', color * 4))

            batch.draw()

        pyglet.gl.glLoadIdentity()