// creates 1 side of the idt
module delay_line(lambda = 1, n_fingers = 1, finger_length = 50, gap = 0, thickness = 0) {
    // code
    l45 =lambda*5/4;
    l2 = lambda/2;
    l4 = lambda/4;
    l8 = lambda/8;
    b = l4 + thickness;
    f = l4 + finger_length*lambda;

    points_cap = [
        [0, 0],
        [0, l2],
        [-b-f, l2],
        [-b-f, l4],
        [-b, l4],
        [-b, 0]
    ];

    points = [
        [0, 0],
        [b, 0],
        [b, l2],
        [b+f, l2],
        [b+f, l2+l4],
        [b, l2+l4],
        [b, l4*5-l4],
        [0, l4*5-l4]
    ];
    // union () {

    translate([0, l2, 0]){
            for(i = [0:n_fingers]){
                translate([0, i*(l45-l4), 0]) {
                polygon(points);
                }
            }

        color("red") {
            rotate([0, 0, 180])
            translate([0, 0, 0]) {
                polygon(points_cap);
            }

            translate([f+l2+gap+thickness, -l2, 0]) {
                square(size=[l4+thickness, l4]);
            }
        }

        
            union() {
                for(i = [0:n_fingers]){
                    translate([2*b+f+gap+l4, i*(l45-l4)+l2+l4 , 0]) 
                    rotate([0, 0, 180])
                    polygon(points);
                }
            }
        
        color("red") {
            translate([2*b+f+gap+l4, n_fingers*lambda+lambda-l4, 0]) {
                polygon(points_cap);
            }
            translate([0, n_fingers*lambda+lambda, 0]) {
                square(size=[l4+thickness, l4]);
            }
        }

    }
}
