isogen-cd2025/readme.md

83 lines
2.2 KiB
Markdown
Raw Normal View History

2024-05-21 21:27:35 +02:00
# isogen
2024-05-21 21:37:20 +02:00
![](https://github.com/buckaroobanzay/isogen/workflows/luacheck/badge.svg)
![](https://github.com/buckaroobanzay/isogen/workflows/test/badge.svg)
[![License](https://img.shields.io/badge/License-MIT-green.svg)](license.txt)
[![Download](https://img.shields.io/badge/Download-ContentDB-blue.svg)](https://content.minetest.net/packages/buckaroobanzay/isogen)
2024-05-21 21:41:19 +02:00
[![Coverage Status](https://coveralls.io/repos/github/BuckarooBanzay/isogen/badge.svg?branch=master)](https://coveralls.io/github/BuckarooBanzay/isogen?branch=master)
2024-05-21 21:37:20 +02:00
2024-05-21 21:27:35 +02:00
Generate isometric images from ingame builds
![](./isogen.png)
2024-05-21 21:31:50 +02:00
# Commands
If the `worldedit` mod is present you can use the following command to render the current we-region to a png-file:
```
//isogen [filename]
```
**NOTE**: larger regions require more memory
# Colors
Supported node-colors:
* colors.txt files in the `/colors` directory
* palette-support for `unifieddyes_palette_extended`
* `mapcolor` node definition
* `colors.txt` file in the world-directory (if found)
2024-05-21 21:27:35 +02:00
# Api
2024-05-22 09:40:07 +02:00
## `isogen.draw(pos1, pos2, cube_len?)`
2024-05-21 21:27:35 +02:00
Renders an isometric image and returns the png data
Example:
```lua
local pos1 = vector.new(0,0,0)
2024-05-21 21:31:50 +02:00
local pos2 = vector.new(16,16,16) -- NOTE: larger regions require more memory
2024-05-21 21:27:35 +02:00
local cube_len = 24 -- multiple of 4 and greater than 4 pixels
-- render and save to world-directory
2024-05-22 09:40:07 +02:00
local png = isogen.draw(pos1, pos2, cube_len)
2024-05-21 21:27:35 +02:00
local path = minetest.get_worldpath() .. "/iso.png"
minetest.safe_file_write(path, png)
```
## `isogen.draw_map(pos1, pos2)`
Renders a map image and returns the png data
Example:
```lua
local pos1 = vector.new(0,0,0)
local pos2 = vector.new(16,16,16) -- NOTE: larger regions require more memory
-- render and save to world-directory
local png = isogen.draw_map(pos1, pos2)
local path = minetest.get_worldpath() .. "/map.png"
minetest.safe_file_write(path, png)
```
2024-05-21 21:27:35 +02:00
## `isogen.create_canvas(width, height)`
Creates a canvas to set and get pixels
Example:
```lua
-- create a canvas, draw a pixel on the coords 0,0 and save the png to the world-directory
local c = isogen.create_canvas(240, 160)
c:set_pixel(0, 0, { r=255, g=0, b=0, a=0 })
local png = c:png()
local path = minetest.get_worldpath() .. "/iso.png"
minetest.safe_file_write(path, png)
```
# License
* Code: `MIT`