A live drawing on your own page
Use this snippet to embed a drawing into your own blog or web page:
Put the link to the drawing in data-src. When linking to a drawing from livegeometry.com the .lgf extension is optional. The element can be any size, the drawing resizes to fit it; just give it a height, an empty element has none. Readers can drag the points but can't edit the drawing.
You can copy player.js to your own website too. With the drawing next to it (see below), your page won't depend on the Live Geometry website at all.
Example
Pick any drawing of the gallery, or paste the share link of one of your own: the snippet at the top is updated to show it.
Exporting your own drawings
- Export › Copy share link stores the drawing on this site and copies the link to clipboard. Paste the link into the box above to get the snippet, or use it as
data-srcdirectly. A shared drawing never changes: share it again after an edit and use the new link. - Export › Copy embed code puts the same snippet on the clipboard with the drawing itself written into the element, between a
<script type="text/x-livegeometry">tag and its end. Paste it into any HTML. Onlyplayer.jsis fetched, so this works in a page opened from disk too. - Export › Save as .html writes a self-contained page with the player inside. It downloads nothing, so it can be opened from a shared folder or an email attachment.
Or keep the drawing as a file beside your page, saved with Save as .lgf, and point at it: data-src="my-drawing.lgf". A file next to your page needs no permission to be read; one on another site plays only if that site allows it (see below).
Options
Attributes on the element, all optional. The two drawings below are the first two in use.
| Attribute | What it does |
|---|---|
data-src | The address of the drawing to display: an .lgf file, a share link, or a URL to a drawing. Leave it out when the drawing is written into the element. |
data-theme | light, dark, or auto (the reader's system setting, the default). The drawing keeps its own colors; the paper and the default styles follow the theme. |
data-wheel | zoom makes the mouse wheel zoom the drawing. By default it zooms only with Ctrl held, so a drawing in a post doesn't take the page's scrolling; pinching and a double click (zoom to fit) always work. |
data-fit | content fits the figures into the element instead of the view the drawing was saved with. |
data-font | A font family for the text in the drawing. By default it is your page's, so the drawing reads like the text around it. |
data-theme="dark" data-wheel="zoom"
data-theme="light" data-fit="content"
Good to know
Hosting drawings
A drawing next to your page needs no permission to be read, and neither do the drawings on this site. A drawing on another website can be displayed only if that site sends the Access-Control-Allow-Origin header, which is the browser's rule, not ours: GitHub Pages and most static hosts do, and a file in a GitHub repository can be reached through raw.githubusercontent.com, which does too. A page opened from a disk can't read a file beside it, though it can fetch from this site, which is why the exported code carries the drawing inside.
Drawings can't always be hosted
GitHub READMEs, issues and wikis don't allow JavaScript, and neither do most comment boxes, so a drawing can't be displayed there. Save a picture instead (Export › Save as .png, or Export › Copy image) and link it to a page that holds the embed.
Fonts and emoji
The text in a drawing is drawn in your page's font, and the emoji some drawings use come from the reader's own device. The player itself is about 250 KB compressed, loaded once per page however many drawings it has.
Versions
The 1 in /player/1/player.js is the player's major version. Fixes are published there as they are made. If the file format ever outgrows it, a /player/2/ will be published, and /player/1/ will keep displaying what was pasted with it.
From a script
The player is a global, LiveGeometry. LiveGeometry.play(element, { src, theme, wheel, fit }) plays a drawing into an element you made, LiveGeometry.players holds every player on the page by element, and a player's applyTheme("dark"), fit() and load(text) do what their names say. The sun and moon in the corner of this page use the first two.