graph drawing tool
Go to file
Kartik K. Agaram 4bd3075a10 show a grid when dragging things
Helps me keep my pictures a little neater.
2024-03-23 09:59:48 -07:00
assets publish snap.love 2023-04-21 18:35:59 -07:00
0000-freewheeling-start Merge template-live-editor 2023-04-16 12:02:28 -07:00
0001-on wire up mouse move handler 2023-12-26 08:28:23 -08:00
0002-Debug_animations_in_progress debug animations 2023-11-11 10:00:54 -08:00
0002-vx undo 2 most recent commits 2023-10-25 09:29:22 -07:00
0003-refresh_debug_animations debug animations 2023-11-11 10:00:54 -08:00
0003-scale undo 2 most recent commits 2023-10-25 09:29:22 -07:00
0004-on.update debug animations 2023-11-11 10:00:54 -08:00
0004-vy undo 2 most recent commits 2023-10-25 09:29:22 -07:00
0005-Cursor_node Merge template-live-editor 2023-04-16 12:02:28 -07:00
0005-animate debug animations 2023-11-11 10:00:54 -08:00
0006-loiter debug animations 2023-11-11 10:00:54 -08:00
0006-on.mouse_press Merge luaML.love 2023-10-25 20:19:22 -07:00
0007-save_callstack debug animations 2023-11-11 10:00:54 -08:00
0008-Debug_animation_period debug animations 2023-11-11 10:00:54 -08:00
0008-Viewport undo 2 most recent commits 2023-10-25 09:29:22 -07:00
0009-on.code_change Merge template-live-editor 2023-04-16 12:02:28 -07:00
0010-initialize_editor Merge luaML.love 2023-12-29 15:45:38 -08:00
0011-box_height snapshot: commit 0ca5bb0e8d, take 2 2023-10-25 09:30:50 -07:00
0012-on.initialize undo 2 most recent commits 2023-10-25 09:29:22 -07:00
0013-font Merge template-live-editor 2023-04-16 12:02:28 -07:00
0014-y_of_schema1 bugfix: pin down schema1->y behavior 2023-10-25 00:11:58 -07:00
0015-line_height Merge template-live-editor 2023-04-16 12:02:28 -07:00
0016-schema1_of_y Merge template-live-editor 2023-04-16 12:02:28 -07:00
0017-on.mouse_release skip reflexive or duplicate edges 2023-12-13 17:17:05 -08:00
0018-on.update bugfix: stop writing repeatedly to disk 2023-09-16 22:48:32 -07:00
0019-B snapshot: a whole new approach to panning 2023-10-27 16:07:34 -07:00
0021-compute_layout Merge luaML.love 2023-10-27 18:24:59 -07:00
0022-on.text_input bugfix: switch text_input to new panning impl 2023-10-27 23:01:46 -07:00
0023-on.keychord_press Merge luaML.love 2023-10-27 18:27:07 -07:00
0024-copy_shape Merge template-live-editor 2023-04-16 12:02:28 -07:00
0025-add_thick_line Merge template-live-editor 2023-04-16 12:02:28 -07:00
0026-on.draw show a grid when dragging things 2024-03-23 09:59:48 -07:00
0027-Surface undo 2 most recent commits 2023-10-25 09:29:22 -07:00
0028-A Merge luaML.love 2023-10-27 18:24:59 -07:00
0030-update_editor_box bugfix: switch text_input to new panning impl 2023-10-27 23:01:46 -07:00
0031-Nodes keep edges short 2023-04-18 22:16:49 -07:00
0031-cols some helpers 2023-06-20 17:34:03 -07:00
0032-rows some helpers 2023-06-20 17:34:03 -07:00
0032-set_mouse_cursor mock up affordances for moving and resizing 2023-04-17 23:22:01 -07:00
0033-test_y_of_schema1 bugfix: pin down schema1->y behavior 2023-10-25 00:11:58 -07:00
0034-dump_state snapshot: insight 2023-10-25 16:14:08 -07:00
0034-sx mock up affordances for moving and resizing 2023-04-17 23:22:01 -07:00
0035-pan_viewport_to_contain_cursor clean up debug prints 2023-10-27 18:26:29 -07:00
0035-sy mock up affordances for moving and resizing 2023-04-17 23:22:01 -07:00
0036-on_move_bar switch Nodes from array to table 2023-04-18 17:52:19 -07:00
0037-on_resize keep edges short 2023-04-18 22:16:49 -07:00
0039-on_node keep edges short 2023-04-18 22:16:49 -07:00
0040-A1 Merge luaML.love 2023-10-21 10:01:52 -07:00
0041-on_border keep edges short 2023-04-18 22:16:49 -07:00
0044-First_available_id switch Nodes from array to table 2023-04-18 17:52:19 -07:00
0045-next_key switch Nodes from array to table 2023-04-18 17:52:19 -07:00
0046-to_key switch Nodes from array to table 2023-04-18 17:52:19 -07:00
0047-test_to_key switch Nodes from array to table 2023-04-18 17:52:19 -07:00
0049-table.length keep edges short 2023-04-18 22:16:49 -07:00
0050-node_height keep edges short 2023-04-18 22:16:49 -07:00
0051-intersect_with_centroid typo bugfix 2023-04-18 23:45:03 -07:00
0055-y_at_x keep edges short 2023-04-18 22:16:49 -07:00
0056-x_at_y keep edges short 2023-04-18 22:16:49 -07:00
0057-distance_sq keep edges short 2023-04-18 22:16:49 -07:00
0058-centroid start drawing edges 2023-04-18 22:43:22 -07:00
0059-compute_layout_for_edge arrowheads 2023-04-20 23:35:04 -07:00
0060-Filename pass in files on the commandline 2023-04-20 19:27:06 -07:00
0061-on.quit open new file when dropped on window 2023-04-20 20:09:26 -07:00
0062-save_graph_to_disk delete one more field from file format 2023-04-20 22:10:55 -07:00
0063-load_graph_from_disk bugfix: open_for_reading can no longer :read('*a') 2023-08-31 07:21:42 -07:00
0064-on.file_drop bugfix: open empty files 2023-07-10 12:52:49 -07:00
0065-on.load_settings Merge luaML.love 2023-07-10 19:29:09 -07:00
0066-on.save_settings load/save viewport settings 2023-04-20 20:18:18 -07:00
0067-Settings load/save viewport settings 2023-04-20 20:18:18 -07:00
0068-table.copy chunk up the saved file to be git friendly 2023-04-20 22:10:55 -07:00
0069-on_edge delete edge by clicking on either terminus 2023-04-20 22:59:29 -07:00
0070-detach_edge delete edge by clicking on either terminus 2023-04-20 22:59:29 -07:00
0071-table.remove_value delete edge by clicking on either terminus 2023-04-20 22:59:29 -07:00
0072-test_remove_value delete edge by clicking on either terminus 2023-04-20 22:59:29 -07:00
0074-on.resize show a grid when dragging things 2024-03-23 09:59:48 -07:00
0075-draw_grid show a grid when dragging things 2024-03-23 09:59:48 -07:00
0076-floor_to show a grid when dragging things 2024-03-23 09:59:48 -07:00
0077-base_for_zoom show a grid when dragging things 2024-03-23 09:59:48 -07:00
LICENSE.txt add a license 2022-05-16 18:51:28 -07:00
Manual_tests.md Merge template-live-editor 2023-12-07 01:25:09 -08:00
MemoryReferenceInfo.lua.0 remove some memory leaks from rendered fragments 2022-06-10 11:16:41 -07:00
MemoryReferenceInfo.lua.unused clean up memory leak experiments 2022-06-10 13:46:59 -07:00
README.md Merge luaML.love 2024-03-10 22:43:35 -07:00
app.lua Merge text0 2024-02-04 17:45:48 -08:00
button.lua bugfix :( 2023-12-18 21:39:01 -08:00
default_map suggest a default layout for freewheeling apps 2023-11-11 10:31:25 -08:00
edit.lua Merge luaML.love 2024-02-16 21:39:43 -08:00
file.lua audit all asserts 2023-11-18 11:32:01 -08:00
json.lua forgot to add json.lua 2022-05-15 14:36:25 -07:00
keychord.lua support for num pad 2023-07-07 18:40:12 -07:00
live.lua rename a function to be more specific 2023-12-15 15:17:28 -08:00
main.lua Merge luaML.love 2024-01-15 03:37:39 -08:00
nativefs.lua cleaner API for file-system access 2023-08-30 19:04:06 -07:00
reference.md Merge luaML.love 2024-02-04 18:01:39 -08:00
search.lua Merge text0 2024-01-15 02:33:22 -08:00
select.lua Merge lines.love 2024-01-15 01:38:38 -08:00
test.lua show another detail on test failure 2023-01-20 21:48:49 -08:00
text.lua Merge text0 2024-02-08 02:58:10 -08:00
text_tests bugfix: clear selection when clicking above or below lines 2023-09-20 13:39:29 -07:00
text_tests.lua Merge text0 2024-02-08 02:58:10 -08:00
undo.lua fix a couple of asserts missed in the recent audit 2023-12-09 09:22:45 -08:00

README.md

snap.love: a graph drawing tool

Unlike Graphviz and PlantUML, this tool is for small graphs where you want complete control over layout. Unlike PowerPoint or draw.io, this tool results generates text files that are more amenable to version control. The catch: it's a lot more limited than all these tools; all you can do so far is draw rectangles and edges between them.

drawing

You can't change the styling. Unless you modify the code. But that's easy! This repo is an example of a Freewheeling App, designed above all to be easy to run, easy to modify and easy to share.

Getting started

Install LÖVE. It's just a 5MB download, open-source and extremely well-behaved.

Run the app using LÖVE.

You'll see a single box on screen. Drag the surface or press arrow keys to pan around. Try dragging the border of the box. You'll see an edge stick out. Release the mouse button, and a new box (node) will pop out at the other end of the edge. Try dragging the top-left bar for each box. They move relative to each other. Try typing inside. The text wraps within and the box grows taller to accomodate it. Try dragging the parallel lines to the right of a box. The width of the box changes.

Try quitting and restarting. Your changes will still be present. By default, snap.love writes to a file called graph in a directory relative to this app. To switch to a different file, drop it on the snap.love window. You can also pass in a filename when starting the app from the terminal.

Hacking

To make changes to this app without restarting the app each time, download the driver app. Example session:

making changes without restarting the app

Some reference documentation on how to create your own apps.

If the app being modified by the driver lives in a .love file, your changes will go into the save directory. If it lives in a directory (like this repo), your changes will go straight into the same directory.

Keyboard shortcuts

While editing within a node:

  • ctrl+f to find patterns
  • ctrl+c to copy, ctrl+x to cut, ctrl+v to paste
  • ctrl+z to undo, ctrl+y to redo
  • ctrl+= to zoom in, ctrl+- to zoom out, ctrl+0 to reset zoom
  • alt+right/alt+left to jump to the next/previous word, respectively
  • mouse drag or shift + movement to select text, ctrl+a to select all

When cursor is not in an editor:

  • arrow keys pan the surface
  • shift+arrow keys pan faster
    • pagedown and pageup are aliases for shift+down and shift+up respectively

Exclusively tested so far with a US keyboard layout. If you use a different layout, please let me know if things worked, or if you found anything amiss: http://akkartik.name/contact

Known issues

  • No scrollbars yet. That stuff is hard.

Mirrors and Forks

This repo is a fork of lines.love, an editor for plain text where you can also seamlessly insert line drawings. Its immediate upstream is luaML.love, a box model for a Lua-based markup language that models an infinite pannable, zoomable 2D surface. Updates to it can be downloaded from:

Further forks are encouraged. If you show me your fork, I'll link to it here.

Feedback

Most appreciated.