Tic-tac-toe (laser cut)
Tic-Tac-Toe (Laser Cut)
Section titled “Tic-Tac-Toe (Laser Cut)”A complete tic-tac-toe set laid out flat for laser cutting from a single sheet of material — five X pieces, five O pieces, and the game board.
Layout
Section titled “Layout”The board sits at the top of the layout. The O pieces are arranged in a row below it, and the X pieces in the row below that, with spacing calculated automatically from the cell size.
Pieces
Section titled “Pieces”Board — a square plate with four slots cut through it forming the 3 × 3 grid. The slot width should match your laser’s kerf so the cuts read clearly.
O pieces — solid rings (outer circle minus inner circle). Adjust Ring width to control how chunky the ring is.
X pieces — two arms crossed at ±45°. The arm length is calculated automatically so the X always fills the available cell space regardless of arm width.
Parameters
Section titled “Parameters”| Parameter | Effect |
|---|---|
| Cell size | Size of each grid square |
| Piece margin | Gap between piece edge and cell boundary |
| Slot width | Width of the grid-line cuts in the board |
| Ring width | Radial thickness of the O ring |
| Arm width | Width of each X arm |
"use strict";
const jscad = require('@jscad/modeling');const { rectangle, circle } = jscad.primitives;const { union, subtract } = jscad.booleans;const { translate, rotateZ } = jscad.transforms;const { colorize } = jscad.colors;
const getParameterDefinitions = () => [ { name: 'cellSize', type: 'number', widget: 'slider', caption: 'Cell size (mm)', default: 40, min: 20, max: 100, step: 5 }, { name: 'pieceMargin', type: 'number', widget: 'slider', caption: 'Piece margin (mm)', default: 6, min: 2, max: 15, step: 1 }, { name: 'slotWidth', type: 'number', widget: 'slider', caption: 'Slot width (mm)', default: 3, min: 1, max: 8, step: 0.5 }, { name: 'ringWidth', type: 'number', widget: 'slider', caption: 'Ring width (mm)', default: 5, min: 2, max: 12, step: 0.5 }, { name: 'armWidth', type: 'number', widget: 'slider', caption: 'Arm width (mm)', default: 5, min: 2, max: 12, step: 0.5 },];
function main(params) { const { cellSize, pieceMargin, slotWidth, ringWidth, armWidth } = params;
const boardSize = cellSize * 3; const pieceSize = cellSize - pieceMargin * 2;
// ---- Board ---- // Grid lines sit at ±cellSize/2 from the board centre along each axis, // dividing the board into nine equal cells. const boardPlate = rectangle({ size: [boardSize, boardSize] }); const hSlot = rectangle({ size: [boardSize, slotWidth] }); const vSlot = rectangle({ size: [slotWidth, boardSize] }); const linePos = cellSize / 2; // distance from board centre to each grid line const board = subtract( boardPlate, translate([ linePos, 0], vSlot), translate([-linePos, 0], vSlot), translate([0, linePos], hSlot), translate([0, -linePos], hSlot), );
// ---- O piece: ring ---- function makeO() { const outerR = pieceSize / 2; const innerR = Math.max(1, outerR - ringWidth); return subtract( circle({ radius: outerR, segments: 64 }), circle({ radius: innerR, segments: 64 }), ); }
// ---- X piece: two arms at ±45° ---- // Arm length is chosen so the X always fills the pieceSize bounding square. function makeX() { const armLength = pieceSize * Math.SQRT2 - armWidth; const arm = rectangle({ size: [armWidth, Math.max(armWidth, armLength)] }); return union( rotateZ( Math.PI / 4, arm), rotateZ(-Math.PI / 4, arm), ); }
// ---- Layout ---- const gap = cellSize * 0.25; const piecePitch = pieceSize + gap;
// Centre each row of 5 pieces; place below the board with a gap const rowY = (row) => -(boardSize / 2 + gap + pieceSize / 2 + piecePitch * row);
const oRow = Array.from({ length: 5 }, (_, i) => translate([(i - 2) * piecePitch, rowY(0)], makeO()), ); const xRow = Array.from({ length: 5 }, (_, i) => translate([(i - 2) * piecePitch, rowY(1)], makeX()), );
return [ colorize([0.71, 0.60, 0.42, 1], board), ...oRow.map(o => colorize([0.22, 0.55, 0.80, 1], o)), ...xRow.map(x => colorize([0.82, 0.33, 0.22, 1], x)), ];}
module.exports = { main, getParameterDefinitions };