Skip to content

Add‐ons code examples

limafresh edited this page Mar 26, 2026 · 4 revisions

Add-ons code examples

Star

import math

def register(brushshe):
    brushshe.set_addon_tool_size(10)
    brushshe.change_color("orange")

    cx, cy = 250, 250
    r = 100
    points = []

    for i in range(5):
        angle = math.radians(90 + i * 72)
        x = cx + r * math.cos(angle)
        y = cy - r * math.sin(angle)
        points.append((x, y))

    order = [0, 2, 4, 1, 3, 0]

    for i in range(len(order) - 1):
        x1, y1 = points[order[i]]
        x2, y2 = points[order[i + 1]]

        brushshe.draw_line(int(x1), int(y1), int(x2), int(y2))

star.py

Heart

import math

def register(brushshe):
    brushshe.set_addon_tool_size(10)
    brushshe.change_color("magenta")

    cx, cy = 250, 250
    r = 100
    points = []

    for t in range(0, 361, 5):
        angle = math.radians(t)
        x = cx + r * 16 * math.sin(angle) ** 3 / 17
        y = cy - r * (13*math.cos(angle) - 5 * math.cos(2 * angle) - 2 * math.cos(3 * angle) - math.cos(4 * angle)) / 17
        points.append((x, y))

    for i in range(len(points) - 1):
        x1, y1 = points[i]
        x2, y2 = points[i + 1]

        brushshe.draw_line(int(x1), int(y1), int(x2), int(y2))

heart.py

Clone this wiki locally