better image handling
This commit is contained in:
@@ -30,6 +30,8 @@ Use transparency. 25% works well.
|
|||||||
width/height
|
width/height
|
||||||
- (path relative to the JSON file? or relative to the executable?)
|
- (path relative to the JSON file? or relative to the executable?)
|
||||||
|
|
||||||
|
Images are only loaded if they will be displayed.
|
||||||
|
|
||||||
## Example JSON
|
## Example JSON
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
2
map.json
2
map.json
@@ -82,7 +82,7 @@
|
|||||||
"Farm Region": [-235, 80, -100, true, {"radius": 230, "color": [0, 0.5, 0, 0.15], "offset": [-54, 0]}],
|
"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]}],
|
"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]}],
|
"approximate area of extreme mountains": [-50, 100, 750, true, {"radius": [570, 525], "color": [1, 1, 1, 0.15]}],
|
||||||
"map_3": [448, 64, 448, false, {"image": "map_3.png", "size": [1024, 1024], "color": [1, 1, 1, 0.5]}],
|
"map_3": [448, 64, 448, false, {"image": "images/map_3.png", "size": [1024, 1024], "color": [1, 1, 1, 0.5]}],
|
||||||
"unnamed hill": [400, 100, 235, true, {"radius": [110, 100], "offset": [-40, 0]}],
|
"unnamed hill": [400, 100, 235, true, {"radius": [110, 100], "offset": [-40, 0]}],
|
||||||
"unnamed plains": [40, 100, 140, true, {"radius": [115, 85], "offset": [-50, 0]}],
|
"unnamed plains": [40, 100, 140, true, {"radius": [115, 85], "offset": [-50, 0]}],
|
||||||
"original worldborder": [0, 87, 0, false, {"box": [1000, 1000], "mode": "line"}]
|
"original worldborder": [0, 87, 0, false, {"box": [1000, 1000], "mode": "line"}]
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ local function load_map(map_file_name)
|
|||||||
edges = map.edges or {}
|
edges = map.edges or {}
|
||||||
areas = map.areas or {}
|
areas = map.areas or {}
|
||||||
for _, area in pairs(map.areas) do
|
for _, area in pairs(map.areas) do
|
||||||
local image_file_name = area[5] and area[5].image
|
local image_file_name = (area[4] or area[4] == nil) and area[5] and area[5].image
|
||||||
if image_file_name then
|
if image_file_name then
|
||||||
local file = io.open(image_file_name, "rb")
|
local file = io.open(image_file_name, "rb")
|
||||||
local data = file:read("*all")
|
local data = file:read("*all")
|
||||||
|
|||||||
@@ -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]}]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user