Halftone Hexagons

Halftone Hexagons

March 28, 2023

We can use Perlin noise to generate a halftone grid of hexagons.

def new_layout(w, h, stroke_thickness, margin_thickness, color_mode, print_dpi=300):
    # print width is in inches
    print_width = w / 100
    print_height = h / 100
    print_w = print_width * print_dpi
    print_h = print_height * print_dpi
    return Layout(
        w=int(print_w),
        h=int(print_h),
        base_width=int(w),
        base_height=int(h),
        left_x=int(print_w * -0.5),
        right_x=int(print_w * 1.5),
        top_y=int(print_h * -0.5),
        bottom_y=int(print_h * 1.5),
        image_left_x=0,
        image_right_x=w,
        image_top_y=0,
        image_bottom_y=h,
        stroke_thickness=stroke_thickness,
        margin_thickness=margin_thickness,
        margin=(stroke_thickness + margin_thickness),
        color_mode=color_mode
        )