Skip to content

0.6.0 - 2024-12-14

Latest
Compare
Choose a tag to compare
@salam99823 salam99823 released this 26 Dec 06:26
· 4 commits to main since this release

Changes

Added

Changed

  • rayon marked as optional dependencies
    (6dab192).
  • Functions factored out to utils.
    • translate
    • translate_objects
  • Now UVec2, Vec2 is inner
    (ba68b6c).
  • Function names have been shortened
    (0266d7e):
    • single_image_edge_translated to single_translated.
    • single_image_edge_raw to single_raw.
    • multi_image_edge_translated to multi_translated.
    • multi_image_edge_raw to multi_raw.
  • Now Edges is unit
    (10397be).
  • Implementation of From for bevy_image::prelude::Image
    replaced by TryFrom
    (10397be).

Fixed

  • Work with channels of pixels
    (10397be).

Removed

  • Functions image_edges, new
    (10397be).

Migration guide

About Using the parallel Feature

If you want to enable the parallel feature using rayon,
you'll need to add it to your Cargo.toml:

[dependencies]
edges = { version = "0.6.0", features = ["parallel"] }

About Using the New Iterator iter::Edges

To utilize the new iterator for Edges, you can iterate over the edges like this:

use edges::Edges;
use std::path::Path;

let image = image::open(Path::new("assets/car.png")).unwrap();
let edges = Edges::from(image);

for polygon in edges.iter() {
    println!("{:?}", polygon);
}

About Updating Function Calls

As mentioned, the functions translate and translate_objects
have been moved to the utils module.
Here’s how to update your calls:

use edges::utils::{translate, translate_objects};

let translated = translate(image_data, image_width, image_height);
let translated_objects = translate_objects(objects_data, image_width, image_height);

About Handling the TryFrom Implementation

If you were previously using From for converting bevy_image::prelude::Image,
you should update your code to use TryFrom:

use bevy_image::prelude::Image;

let bevy_image = Image::from_buffer(
    include_bytes!("../assets/boulders.png"), // buffer
    ImageType::Extension("png"),
    CompressedImageFormats::default(),
    true,
    ImageSampler::default(),
    RenderAssetUsages::default(),
);
// Panic occurs if image format does not support conversion to `BinaryImage`
let bevy_edges = Edges::try_from(bevy_image).unwrap();