Euclid
:pencil2: Euclidean geometry in javascript
Install / Use
/learn @anandthakker/EuclidREADME
Euclid

Euclidean geometry in javascript. Here's a demo; here's another one (mess with it by clicking "Play with the geometry background!" at the bottom).
NOTE: Still very preliminary / experimental.
git clone https://github.com/anandthakker/euclid.git
cd euclid
npm install
gulp
Usage
Load It:
Add dist/geometry.css for the basic SVG styles.
<link rel="stylesheet" href="geometry.css">
Put an <svg> element somewhere.
<svg class="geometry-scene" viewbox="0 0 800 800"></svg>
Pull in the javascript, either as a node module...
var geom = require('euclid');
or a browser standalone(ish) script (depends on d3 to be
loaded already).
<script src="js/vendor/d3.min.js"></script>
<script src="js/geometry.js"></script> <!-- exposes geom as a global -->
Use It:
And then
var scene = new geom.Scene({
left: 0,
top: 0,
right: 1000,
bottom: 1000
});
scene
.point('A', width/7*3, height/3) // add a couple of free points.
.poinnt('B', width/7*5, height/3)
.segment('S', 'A', 'B')
// add circle centered at point 'A', with point 'B' on its circumference.
.circle('M', 'A', 'B')
.circle('N', 'B', 'A')
// tag subsequent objects with string 'layer2', used by renderer to add
// arbitrary CSS classes to svg objects.
.group('layer2')
// let C and D be the two intersections of circles M and N
.intersection('C', 'M', 'N', 0)
.intersection('D', 'M', 'N', 1)
.line('T', 'A', 'C')
.segment('U', 'A', 'D')
// let E be the intersection of line T and circle M that *isn't* equivalent to point C.
.intersection('E', 'T', 'M', scene.isnt('C') )
.segment('V', 'E', 'B')
.intersection('F', 'V', 'U')
.segment('W', 'F', 'C')
.intersection('W', 'S')
// render using d3.
var render = geom.renderer(scene, document.querySelector('svg'));
render();
Related Skills
node-connect
345.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
106.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
345.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
