Compare commits

..
13 Commits
Author SHA1 Message Date
tangent 40ae0a3861 Update ReadMe.md 2026-09-14 02:50:10 -06:00
tangent fce2c75fea Update ReadMe.md 2026-08-16 18:58:11 -06:00
tangent 0d0801e193 Update ReadMe.md 2026-08-16 18:45:55 -06:00
tangent 2dd1f4f3e5 hidden nodes don't affect map scale 2025-12-27 06:01:20 +00:00
tangent bf1ee3aedb not sure what these updates are 2025-12-26 22:58:28 -07:00
tangent 617cb7480e a small addition form a couple days ago 2025-11-13 18:56:16 -07:00
tangent addfa41f98 run script 2025-11-06 16:30:42 -07:00
tangent f0349b4d82 better image handling 2025-11-05 16:52:18 -07:00
tangent c4bc94fa63 better map 2025-11-05 16:18:12 -07:00
tangent 2ad7875a7f images, boxes, ellipses, lines 2025-11-05 15:44:08 -07:00
tangent 83c89542fb vague memories and vibes 2025-11-05 03:23:44 -07:00
tangent a38466b8e0 okay, colors for everything 2025-11-05 03:11:41 -07:00
tangent 12e0518948 areas 2025-11-05 03:00:23 -07:00
7 changed files with 138 additions and 18 deletions

No files matched your search

+21 -2
View File
@@ -1,4 +1,6 @@
# World6-travelmap # World6-travelmap
I made a tool for marking paths and measuring distance. :D
I made a little program for displaying a simplistic graph of nodes and edges to I made a little program for displaying a simplistic graph of nodes and edges to
make a travel network with calculated distances... specifically for my Minecraft make a travel network with calculated distances... specifically for my Minecraft
World. World.
@@ -18,8 +20,19 @@ You can drag and drop a JSON file to load it.
Both nodes and edges can have an extra object with metadata, some of which is Both nodes and edges can have an extra object with metadata, some of which is
used by this program. An array called `offset` will adjust the positioning of used by this program. An array called `offset` will adjust the positioning of
labels. An array called `color` will set the color via 0 to 1 RGBA values labels. An array called `color` will set the color via 0 to 1 RGBA values.
(node only).
Added `areas` which are exactly like nodes except that they always draw a white
label and can have a custom radius specified. Drawn between edges and nodes.
Use transparency. 25% works well.
- `box` can be an array of width/height to draw a rectangular shape instead
- `radius` can be an array of x/z radii to draw an ellipse instead of a circle
- `mode` can be "line" to draw an outline instead of filling
- `image` can be a file path, in which case `size` must be an array of desired
width/height (I recommend placing these in a subdirectory)
- path must be relative to the JSON file
Images are only loaded if they will be displayed.
## Example JSON ## Example JSON
@@ -44,3 +57,9 @@ labels. An array called `color` will set the color via 0 to 1 RGBA values
] ]
} }
``` ```
## Tasks
- [ ] image loading can't cope with arbitrary JSON file locations and always tries to load from within the repo
fix: use the DroppedFile during load to get path to load relative to
- [ ] r should reload whatever is currently loaded, not the default
- [ ] Split the code that makes this work from its use for my world, make it available easily from anywhere.
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

+31 -7
View File
@@ -28,13 +28,18 @@
"village crossroad": [130, 101, 296, false, {"notes": "insignificant"}], "village crossroad": [130, 101, 296, false, {"notes": "insignificant"}],
"Second Farm original route corner": [-180, 69, -30, false], "Second Farm original route corner": [-180, 69, -30, false],
"Second Farm original route corner 2": [-202, 79, -169, false], "Second Farm original route corner 2": [-202, 79, -169, false],
"cherry blossum divergence point": [-332, 104, -423], "cherry blossum divergence point": [-332, 104, -423, false],
"original farm worldborder deadend": [-346, 109, -456], "original farm worldborder deadend": [-346, 109, -456, false],
"Cherry Point": [-480, 104, -404, true, {"color": [1, 0.67, 0.67, 1]}], "Cherry Point": [-480, 104, -404, true, {"color": [1, 0.67, 0.67, 1]}],
"unnamed beach point": [-376, 63, -313], "unnamed beach point": [-376, 63, -313, false],
"unnamed summit curve point": [-387, 119, -229], "unnamed summit curve point": [-387, 119, -229, false],
"unnamed summit": [-408, 130, -251], "unnamed summit": [-408, 130, -251],
"Sugarcane Point": [-161, 62, -365, true, {"color": [0.75, 1, 0.25, 1]}] "Sugarcane Point": [-161, 62, -365, true, {"color": [0.75, 1, 0.25, 1]}],
"original border 1": [-500, 0, -500, false],
"original border 2": [-500, 0, 500, false],
"original border 3": [500, 0, 500, false],
"original border 4": [500, 0, -500, false],
"spoil chest": [-264, -54, 120]
}, },
"edges": [ "edges": [
["tree farm north", "Second Farm", null, {"offset": [0, -12]}], ["tree farm north", "Second Farm", null, {"offset": [0, -12]}],
@@ -63,6 +68,25 @@
["Cherry Point", "cherry blossum divergence point"], ["Cherry Point", "cherry blossum divergence point"],
["unnamed summit curve point", "unnamed beach point"], ["unnamed summit curve point", "unnamed beach point"],
["unnamed summit curve point", "unnamed summit", null, {"offset": [-14, 10]}], ["unnamed summit curve point", "unnamed summit", null, {"offset": [-14, 10]}],
["Sugarcane Point", "Second Farm"] ["Sugarcane Point", "Second Farm"],
] ["original border 2", "original border 1", "original border (west)"],
["original border 1", "original border 4", "original border (north)"],
["original border 4", "original border 3", "original border (east)"],
["original border 3", "original border 2", "original border (south)"],
["unnamed beach point", "Sugarcane Point", "", {"color": [0.33, 0.33, 1, 0.67]}],
["future sand mine", "Sugarcane Point", true, {"color": [0.33, 0.33, 1, 0.67], "offset": [0, 14]}],
["future sand mine", "spawn hovel", true, {"color": [0.33, 0.33, 1, 0.67]}],
["Spawn Point", "spawn hovel", ""]
],
"areas": {
"unnamed ocean": [875, 64, -50, true, {"radius": [420, 400], "color": [0, 0, 1, 0.25]}],
"Farm Region": [-235, 80, -100, true, {"radius": 230, "color": [0, 0.5, 0, 0.15], "offset": [-54, 0]}],
"Mount Sharpe": [735, 110, 685, "mountainous region", {"radius": 165, "color": [1, 1, 1, 0.1], "offset": [-54, 4]}],
"approximate area of extreme mountains": [-50, 100, 750, true, {"radius": [570, 525], "color": [1, 1, 1, 0.15]}],
"map_3": [448, 64, 448, true, {"image": "images/map_3.png", "size": [1024, 1024], "color": [1, 1, 1, 0.33]}],
"unnamed hill": [400, 100, 235, true, {"radius": [110, 100], "offset": [-40, 0]}],
"unnamed plains": [40, 100, 140, true, {"radius": [115, 85], "offset": [-50, 0]}],
"original worldborder": [0, 87, 0, false, {"box": [1000, 1000], "mode": "line"}],
"possible runway location": [-40, 100, 135, null, {"box": [64, 9], "mode": "line"}]
}
} }
Executable
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env zsh
source ~/.zshrc # why is this having to be done manually?
cd "$(dirname "$0")"
love src
+77 -8
View File
@@ -12,7 +12,7 @@ local scale_fix_translation_adjustment = 300 -- this is wrong, and the wrong way
local nodes, edges, minimums, maximums, scale, translation local nodes, edges, areas, minimums, maximums, scale, translation
local function load_map(map_file_name) local function load_map(map_file_name)
local file, text local file, text
if type(map_file_name) == "string" then if type(map_file_name) == "string" then
@@ -20,6 +20,7 @@ local function load_map(map_file_name)
if not file then if not file then
nodes = {} nodes = {}
edges = {} edges = {}
areas = {}
minimums = {0, 0} minimums = {0, 0}
maximums = {100, 100} maximums = {100, 100}
scale = 1 scale = 1
@@ -32,25 +33,37 @@ local function load_map(map_file_name)
file:open("r") file:open("r")
text = file:read("string") text = file:read("string")
end end
file:close()
local map = json.decode(text) local map = json.decode(text)
nodes = map.nodes nodes = map.nodes or {}
edges = map.edges or {} edges = map.edges or {}
areas = map.areas or {}
for _, area in pairs(map.areas) do
local image_file_name = (area[4] or area[4] == nil) and area[5] and area[5].image
if image_file_name then
local file = io.open(image_file_name, "rb")
local data = file:read("*all")
file:close()
local byte_data = love.data.newByteData(data)
area[5].image_object = love.graphics.newImage(byte_data)
end
end
-- find map size -- find map size
minimums = {math.huge, math.huge} -- x, z minimums = {math.huge, math.huge} -- x, z
maximums = {-math.huge, -math.huge} -- x, z maximums = {-math.huge, -math.huge} -- x, z
for _, node in pairs(nodes) do for _, node in pairs(nodes) do
if node[1] > maximums[1] then if node[1] > maximums[1] and node[4] ~= false then
maximums[1] = node[1] maximums[1] = node[1]
end end
if node[1] < minimums[1] then if node[1] < minimums[1] and node[4] ~= false then
minimums[1] = node[1] minimums[1] = node[1]
end end
if node[3] > maximums[2] then if node[3] > maximums[2] and node[4] ~= false then
maximums[2] = node[3] maximums[2] = node[3]
end end
if node[3] < minimums[2] then if node[3] < minimums[2] and node[4] ~= false then
minimums[2] = node[3] minimums[2] = node[3]
end end
end end
@@ -60,6 +73,9 @@ local function load_map(map_file_name)
local distance_z = maximums[2] - minimums[2] local distance_z = maximums[2] - minimums[2]
scale = math.min((screen_width - safe_zone * 2) / distance_x, (screen_height - safe_zone * 2) / distance_z) scale = math.min((screen_width - safe_zone * 2) / distance_x, (screen_height - safe_zone * 2) / distance_z)
translation = {-minimums[1] + safe_zone / scale, -minimums[2] + safe_zone / scale} translation = {-minimums[1] + safe_zone / scale, -minimums[2] + safe_zone / scale}
-- TEMP displaying scale to debug
-- scale = 1
end end
load_map("map.json") load_map("map.json")
@@ -79,7 +95,8 @@ function love.draw()
end end
if not (edge[3] == false) then if not (edge[3] == false) then
love.graphics.setColor(0.33, 0.33, 0.33, 1) local color = edge[4] and edge[4].color or {0.33, 0.33, 0.33, 1}
love.graphics.setColor(color)
love.graphics.line(node_a[1], node_a[3], node_b[1], node_b[3]) love.graphics.line(node_a[1], node_a[3], node_b[1], node_b[3])
local center_x = node_a[1] + (node_b[1] - node_a[1]) / 2 local center_x = node_a[1] + (node_b[1] - node_a[1]) / 2
@@ -89,7 +106,8 @@ function love.draw()
distance = edge[3] distance = edge[3]
end end
love.graphics.setColor(0.67, 0.67, 0.67, 1) local color = edge[4] and edge[4].color or {0.67, 0.67, 0.67, 1}
love.graphics.setColor(color)
if edge[4] and edge[4].offset then if edge[4] and edge[4].offset then
-- these actually work better not scale-adjusted -- these actually work better not scale-adjusted
center_x = center_x + edge[4].offset[1] center_x = center_x + edge[4].offset[1]
@@ -99,6 +117,57 @@ function love.draw()
end end
end end
-- areas sit between edges and nodes
for name, area in pairs(areas) do
local color = area[5] and area[5].color or {1, 1, 1, 0.25}
love.graphics.setColor(color)
if not (area[4] == false) then
local mode = area[5] and area[5].mode or "fill"
local box = area[5] and area[5].box
local image = area[5] and area[5].image_object
if image then
local size = area[5].size
local image_width, image_height = image:getWidth(), image:getHeight()
love.graphics.draw(image, area[1], area[3], 0, size[1] / image_width, size[2] / image_height, image_width / 2, image_height / 2)
elseif box then
love.graphics.rectangle(mode, area[1] - box[1] / 2, area[3] - box[2] / 2, box[1], box[2])
else
local radius = area[5] and area[5].radius or node_radius
if type(radius) == "number" then
love.graphics.circle(mode, area[1], area[3], radius)
else
love.graphics.ellipse(mode, area[1], area[3], radius[1], radius[2])
end
end
end
if area[4] then
if type(area[4]) == "string" then
name = area[4]
end
local text_x, text_z = area[1] + node_radius / scale, area[3] + node_radius / scale
local difference = area[1] + font:getWidth(name) - maximums[1]
if difference > 0 then
text_x = area[1] - (node_radius + difference) / scale
end
local difference = area[3] + font:getHeight() - maximums[2]
if difference > 0 then
text_z = area[3] - (node_radius + difference) / scale
end
if area[5] and area[5].offset then
text_x = text_x + area[5].offset[1] / scale
text_z = text_z + area[5].offset[2] / scale
end
love.graphics.setColor(1, 1, 1, 1)
love.graphics.print(name, text_x, text_z, 0, 1 / scale, 1 / scale)
end
end
-- draw nodes and label them -- draw nodes and label them
for name, node in pairs(nodes) do for name, node in pairs(nodes) do
local color = node[5] and node[5].color or {1, 1, 1, 1} local color = node[5] and node[5].color or {1, 1, 1, 1}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

+4 -1
View File
@@ -5,5 +5,8 @@
"BottomLeft": [0, 0, 900, true], "BottomLeft": [0, 0, 900, true],
"BottomRight": [1600, 0, 900, true] "BottomRight": [1600, 0, 900, true]
}, },
"edges": [] "edges": [],
"areas": {
"test image": [100, 0, 100, true, {"image": "test image.png", "size": [200, 200], "color": [1, 1, 1, 1]}]
}
} }