> Canonical HTML: https://kerfscript.mylasertools.com/models/pocket-dragonfly/

# Pocket Wildlife dragonfly card

Pocket Wildlife dragonfly: six legs, big eyes and two pairs of wings in seven slot-together pieces, on a 150 x 100 mm card. Each pair of wings drops over a tongue on the thorax. The pieces stay in the card on small tabs until an adult releases them and sands the nubs. Shapes are drawn at their finished size and KerfScript moves the cut paths out by half the beam, so leave kerf offsets off in your laser software.

This design has 1 part on 1 sheet. Customize it in the [playground](https://kerfscript.mylasertools.com/playground/?model=pocket-dragonfly).

## Downloads

- [KerfScript source](https://kerfscript.mylasertools.com/models/pocket-dragonfly/pocket-dragonfly.kerf)
- [SVG](https://kerfscript.mylasertools.com/models/pocket-dragonfly/pocket-dragonfly.svg)
- [DXF](https://kerfscript.mylasertools.com/models/pocket-dragonfly/pocket-dragonfly.dxf)

## Parts

| Part | Quantity | Size |
| --- | ---: | --- |
| Dragonfly card | 1 | 150 × 100 mm |

## Settings

| Name | Default | Range or choices |
| --- | --- | --- |
| `output` | `"card"` | card, loose, coupon |
| `stock` | `3` | 2.8 to 3.2 |
| `beam` | `0.15` | 0.08 to 0.25 |
| `fit` | `0.08` | 0 to 0.18 |
| `bridge` | `0.9` | 0.6 to 1.4 |

## Source

```kerf
// Pocket Wildlife dragonfly: six legs, big eyes and two pairs of wings in
// seven slot-together pieces, on a 150 x 100 mm card. Each pair of wings
// drops over a tongue on the thorax. The pieces stay in the card on small
// tabs until an adult releases them and sands the nubs. Shapes are drawn at
// their finished size and KerfScript moves the cut paths out by half the
// beam, so leave kerf offsets off in your laser software.

/* [Card] */
// The card, the pieces cut free, or a slot fit test
output = "card"; // [card, loose, coupon]

/* [Material] */
// Measured thickness of the plywood
stock = 3; // [2.8:0.1:3.2]
// Width of the laser cut
beam = 0.15; // [0.08:0.01:0.25]
// Slots are this much wider than the stock
fit = 0.08; // [0:0.02:0.18]
// Width of the tabs that hold pieces in the card
bridge = 0.9; // [0.6:0.1:1.4]

/* [Hidden] */
$thickness = stock;
$kerf = beam;
$fn = 48;
$sheet = output == "loose" ? [300, 200] : [160, 110];
card = [150, 100];
s = stock + fit;
// Drawn with the thorax 20 mm up, then lowered
fy = -6;

names = ["Body", "Eyes", "Front legs", "Middle legs", "Back legs", "Forewings", "Hindwings"];
// Piece 0 is the body. Each joint is [piece, place along the body, height,
// true when the crosspiece slot opens upward]. The body is notched to match.
// The wings, pieces 5 and 6, sit on tongues instead.
joints = [[1, 58, 27, false], [2, 36, 20, true], [3, 28, 20, true], [4, 20, 20, true]];

module both() { children(); mirror([1, 0]) children(); }
// Rounds the corners of a shape, inside and out
module soft(r = 0.8) offset(r = -r) offset(r = 2 * r) offset(r = -r) children();
module slot_up(x, y) translate([x - s / 2, y]) square([s, 200]);
module slot_down(x, y) translate([x - s / 2, y - 200]) square([s, 200]);
function joint(i) = [for (j = joints) if (j[0] == i) j][0];

module shape(i) {
  if (i == 0) difference() {
    body();
    for (j = joints) if (j[3]) slot_down(j[1], j[2]); else slot_up(j[1], j[2]);
  }
  else if (joint(i) == undef) flat(i);
  else difference() {
    cross(i);
    if (joint(i)[3]) slot_up(0, joint(i)[2]); else slot_down(0, joint(i)[2]);
  }
}

// x runs from the tail to the head, y is height above the table. Two
// tongues on the thorax carry the wings.
module body() translate([0, fy]) union() {
  path("M50 28 C50 22 46 20 40 20 L18 20 C14 20 11 23 9 26 C-20 28.5 -45 31 -62 32.5 C-66 33 -66 38 -62 38 C-45 38 -20 37 9 36.5 C11 38 13 38 15 38 L45 38 C48 38 50 35 50 32 Z");
  translate([58, 31]) circle(r = 9);
  translate([47, 24]) square([6, 12]);
  for (x = [16, 31]) translate([x, 37]) square([8, 1 + stock]);
}
// Crosspieces: x runs across the dragonfly, y is height
module cross(i) {
  if (i == 1) translate([0, fy]) both() { translate([7.5, 34]) circle(r = 7.5); translate([0, 27]) square([3, 12]); }
  // Legs that reach further out towards the back
  else let (k = [0, 0, 4, 6, 8][i]) soft(0.6) both() polygon([[0, 25], [5, 25], [10, 23], [10 + k, 28], [13.5 + k, 28], [18 + k, 2], [20.5 + k, 0], [15.5 + k, 0], [10 + k, 23], [9, 18], [6, 11], [0, 11]]);
}
// Wings lie flat on the thorax: x across the body, y along it, with a slot
// over their tongue
module flat(i) difference() {
  scale([0.92, 1]) both() {
    if (i == 5) path("M0 42 L5 42 C20 43 40 46 58 48 C63 48.5 65 46 63 43.5 C58 39 45 35 30 32 C20 30 10 28 5 28 L0 28 Z");
    if (i == 6) path("M0 27 L5 27 C20 27.5 40 27 56 24 C61 23 62 19 58 17.5 C46 14 30 9 16 10 C10 10.5 6 12 5 13 L0 13 Z");
  }
  translate([-s / 2, (i == 5 ? 31 : 16) - fit / 2]) square([s, 8 + fit]);
}

// Scored rings on the eyes
module eyes(i) if (i == 1) translate([0, fy]) both() translate([7.5, 34]) score() for (r = [2.5, 5]) outline() circle(r = r);

// Where each piece goes when the model is built: the body stands on edge
// along x, crosspieces stand across it and the wings lie on the thorax
function placement(i) = i == 0 ? [[0, stock / 2, 0], [90, 0, 0]]
  : i < 5 ? [[joint(i)[1] - stock / 2, 0, 0], [90, 0, 90]]
  : [[0, 0, 38 + fy], [0, 0, -90]];

// Where each piece sits on the card [x, y, turn], the tabs that hold it
// [x, y, edge direction] in its own coordinates, and the title's box
layout = [[79.28, 61.48, 0], [131.28, -13.82, 0], [84.46, 11.48, 0], [115.39, 48.19, 260], [29.44, 21.07, 340], [53.81, 15.58, 350], [56.78, 52.59, 350]];
tabs = [[[17.74, 35.0, 0.0], [16.46, 14.15, 168.8], [64.06, 18.37, -138.0], [-61.99, 32.0, 1.6]], [[7.52, 35.5, -0.1], [-4.5, 21.13, -156.4]], [[-15.53, 28.0, 0.0], [14.8, 19.66, 103.4], [-15.69, 15.92, -103.4]], [[-17.61, 28.0, 0.0], [16.75, 19.88, 103.4], [-17.35, 17.35, -103.4]], [[-19.53, 28.0, 0.0], [18.75, 19.86, 103.4], [-18.88, 19.33, -103.4]], [[54.61, 48.06, -0.8], [-53.24, 40.24, 151.9], [-6.6, 42.16, -4.8]], [[-14.09, 27.17, 0.0], [13.78, 10.1, 173.4], [-42.7, 14.18, 163.7]]];
title = [15.08, 13.88, 34, 13];

// Cut each outline with gaps at the tabs
module piece(i, tabs) {
  difference() {
    outline() offset(delta = beam / 2) shape(i);
    for (t = tabs) translate([t[0], t[1]]) rotate(t[2]) square([bridge + beam, 4], center = true);
  }
  eyes(i);
}

if (output == "card") part("Dragonfly card") {
  rect(card, r = 5);
  for (i = [0:len(names) - 1]) translate([layout[i][0], layout[i][1]]) rotate(layout[i][2]) piece(i, tabs[i]);
  engrave() {
    translate([title[0] + title[2] / 2, title[1] + title[3] * 0.62]) text("DRAGONFLY", size = title[3] * 0.42, halign = "center", valign = "center");
    translate([title[0] + title[2] / 2, title[1] + title[3] * 0.16]) text("POCKET WILDLIFE", size = title[3] * 0.15, halign = "center", valign = "center");
  }
}
if (output == "loose") for (i = [0:len(names) - 1]) step(i == 0 ? "Stand the body on edge" : i < 5 ? "Slide the eyes and legs onto the body at their notches" : "Drop each pair of wings over the tongue on the thorax") part(names[i], at = placement(i)[0], rotate = placement(i)[1]) {
  shape(i);
  eyes(i);
}
// Slots from 0.08 mm narrower to 0.12 mm wider than the stock, and three tabs
if (output == "coupon") part("Fit coupon") {
  deltas = [-0.08, -0.04, 0, 0.04, 0.08, 0.12];
  difference() {
    rect([130, 44], r = 3);
    for (k = [0:5]) translate([12 + k * 21, 26]) square([stock + deltas[k], 20]);
  }
  engrave() for (k = [0:5]) translate([12 + k * 21 + stock / 2, 21]) text(str(deltas[k] > 0 ? "+" : "", deltas[k]), size = 2.6, halign = "center", valign = "center");
  for (k = [0:2]) translate([22 + k * 43, 9]) difference() {
    outline() offset(delta = beam / 2) square([24, 8], center = true);
    for (x = [-12, 12]) translate([x, 0]) square([4, bridge + beam], center = true);
  }
}
```

Set power, speed and cut order in your laser software. See the [laser software guide](https://kerfscript.mylasertools.com/docs/compatibility/index.md).
