def rect(self, x, y, w, h): self.pathStr.append(PathElement.moveTo(x, y, self)) self.pathStr.append(PathElement.lineTo(x + w, y, self)) self.pathStr.append(PathElement.lineTo(x + w, y + h, self)) self.pathStr.append(PathElement.lineTo(x, y + h, self)) self.pathStr.append(PathElement.closePath()) self.currentX = x self.currentY = y + h
def quadraticCurveTo(self, cpx, cpy, x, y): cp1x = (self.currentX + 2.0 / 3.0 * (cpx - self.currentX)) cp1y = (self.currentY + 2.0 / 3.0 * (cpy - self.currentY)) cp2x = (cp1x + (x - self.currentX) / 3.0) cp2y = (cp1y + (y - self.currentY) / 3.0) self.pathStr.append(PathElement.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y, self)) self.currentX = x self.currentY = y
def closePath(self): self.pathStr.append(PathElement.closePath())
def arc(self, x, y, radius, startAngle, endAngle, anticlockwise): self.pathStr.append(PathElement.arc(x, y, radius, startAngle, endAngle, anticlockwise, self))
def moveTo(self, x, y): self.pathStr.append(PathElement.moveTo(x, y, self)) self.currentX = x self.currentY = y
def cubicCurveTo(self, cp1x, cp1y, cp2x, cp2y, x, y): self.pathStr.append(PathElement.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y, self)) self.currentX = x self.currentY = y
def cubicCurveTo(self, cp1x, cp1y, cp2x, cp2y, x, y): self.pathStr.append( PathElement.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y, self)) self.currentX = x self.currentY = y
def arc(self, x, y, radius, startAngle, endAngle, anticlockwise): self.pathStr.append( PathElement.arc(x, y, radius, startAngle, endAngle, anticlockwise, self))