ute 0.0.2

ute - (U)biquitous (T)ile (E)ngine - library for matching and manipulating n-sided polygons with tagged sides (in rust)
Documentation

UTE ( yoot )

ute - engine for matching and manipulating n-sided polygons with tagged sides (in rust)

navigation

[you're here]

this page is a brief how-to-use overview. for detailed examples and faqs, read the wiki

using ute

examples

features references

using ute

including in your project

[top]

  • add this repo* to your Cargo.toml:
[dependencies]

# ... other deps are probably here ...

ute = {git = "https://github.com/parkcitymedia/ute", branch="main"}

*cargo searches by default for a "master" branch, so branch specification may/may not be necessary.

examples

using handmade or generated tiles

assuming tile path "tile.json" has been made/exists:

  • map json to a tile (serde)

[top]

// likely your main.rs:
use ute::{Tile, identify_tile};
use serde_json::{from_str};
use std::fs::read_to_string;

#[tokio::main] // requires tokio = {features = ["full"]}
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    
    // where does the tile live?
    let raw_tile_path: &str = "tile.json";
    
    // read the tile info into a String (re-borrow
    // into &str for serde_json compatibility)
    let tile_r: String = read_to_string(raw_tile_path).unwrap();
    let tile_r: &str = &tile_r;

    // use serde_json::from_str() to
    // map the json string to a pantsemm::Tile
    // note: this tile is mutable - while they don't
    // need to be, this is good for when
    // you want to change tile field values later
    let mut tile: Tile = from_str(tile_r)?;
    
    // generate a unique tile-data-based tile name
    // with pantsemm's pantsemm::identify_tile()
    // (returns a Tile!!! common use: mutation)
    tile = identify_tile(&mut tile)?;

    // print the tile_id out after generating it!
    println!("my new tile id: {:#?}", tile.tile_id);

    Ok(())
}

single tile input

[top]

an example can be found in tiles/tile_example.jsonof a handwritten/generated hexagon for data input. here's an example quad/square to look at right now: quad_example.json

{
    "tile_id": "",
    "tile_center": "5",
    "tile_edges": [
        {
            "tile_edge": {
                "is_open": true,
                "name": "top_edge",
                "edge_tag": [
                    {
                        "tag_position": "0",
                        "tag_value": "r"
                    },
                    {
                        "tag_position": "1",
                        "tag_value": "q"
                    },
                    {
                        "tag_position": "2",
                        "tag_value": "p"
                    }
                ]
            }
        },
        {
            "tile_edge": {
                "is_open": true,
                "name": "right_edge",
                "edge_tag": [
                    {
                        "tag_position": "0",
                        "tag_value": "o"
                    },
                    {
                        "tag_position": "1",
                        "tag_value": "n"
                    },
                    {
                        "tag_position": "2",
                        "tag_value": "m"
                    }
                ]
            }
        },
        {
            "tile_edge": {
                "is_open": true,
                "name": "bottom_edge",
                "edge_tag": [
                    {
                        "tag_position": "0",
                        "tag_value": "l"
                    },
                    {
                        "tag_position": "1",
                        "tag_value": "k"
                    },
                    {
                        "tag_position": "2",
                        "tag_value": "j"
                    }
                ]
            }
        },
        {
            "tile_edge": {
                "is_open": true,
                "name": "left_edge",
                "edge_tag": [
                    {
                        "tag_position": "0",
                        "tag_value": "c"
                    },
                    {
                        "tag_position": "1",
                        "tag_value": "b"
                    },
                    {
                        "tag_position": "2",
                        "tag_value": "a"
                    }
                ]
            }
        }
    ]
}

features

[top]

references

[top]