In Vietnamese architecture and interior design, the Lo Ban Ruler (Thước Lỗ Ban) is commonly used to check auspicious dimensions for doors, furniture, and home layouts. Instead of relying on heavy frameworks or external APIs, you can model all three standard Lo Ban rulers in just a few lines of Vanilla JavaScript using modulo arithmetic and lookup arrays.
Understanding the Three Ruler Cycles
Each Lo Ban ruler repeats periodically along a fixed length, divided into major segments (cung lớn) and minor sub-segments (cung nhỏ):
- 52.2 cm (Thông Thủy) — Used for clear openings such as doors, windows, and hallways (8 major segments of
6.525 cm, each split into 5 sub-segments). - 42.9 cm (Dương Trạch) — Used for solid structures and furniture like desks, beds, and cabinets (8 major segments, 4 sub-segments each).
- 38.8 cm (Âm Phần) — Used for altars and memorial dimensions (10 major segments of
3.88 cm, 4 sub-segments each).
Core Modulo Calculation in JavaScript
To evaluate any input measurement mm against a ruler cycle cycleMm and an ordered array of segment definitions:
function checkLoBan(lengthMm, cycleMm, segments) { if (lengthMm <= 0) return null; // Normalize measurement into a single ruler cycle const posInCycle = ((lengthMm % cycleMm) + cycleMm) % cycleMm; const segmentSize = cycleMm / segments.length; const index = Math.min( Math.floor(posInCycle / segmentSize), segments.length - 1 ); return { positionMm: Number(posInCycle.toFixed(2)), segment: segments[index], }; } By keeping the ruler definitions as pure JSON/array data and computing positions client-side in mm, the UI stays instantaneous even when dragging a virtual ruler slider in real time.
Live Demo & Source Code
We built an open-source, zero-dependency online lookup tool combining all three rulers (52.2cm, 42.9cm, 38.8cm) with instant search and visual scale rendering:
- Live Demo: Tra cứu Thước Lỗ Ban Online
- Source Code (GitHub): lequy240193/thuoc-lo-ban-phong-thuy
- Project Homepage: Phong Thủy Thức Tâm
Feedback and pull requests for improving accessibility or adding SVG ruler rendering are always welcome!