Home Forums Nazca How to draw a triangle Reply To: How to draw a triangle

#5400
Ronald
Keymaster

Dear Wanshu,

A straight forward way to define these kind of structures is to create a function that returns your custom polygon (list of points) and create a Polygon mask element from the list of points:

from math import tan, radians
import nazca as nd

def triangle(length=10, angle=45):
    base = 2*length*tan(radians(0.5*angle))
    return [(0, 0.5*base), (0, -0.5*base), (length, 0)]

tri = nd.Polygon(points=triangle(length=50, angle=30))
tri.put(0)
tri.put(0, 10, 45)

nd.export_gds()

Ronald