Releases: shnewto/edges
0.6.0 - 2024-12-14
Changes
Added
- Feature
parallel
, which depends onrayon
(6dab192). - External public crate
binary_image
(076d53b). - Iterator
iter::Edges
forEdges
(10397be).
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
tosingle_translated
.single_image_edge_raw
tosingle_raw
.multi_image_edge_translated
tomulti_translated
.multi_image_edge_raw
tomulti_raw
.
- Now
Edges
is unit
(10397be). - Implementation of
From
forbevy_image::prelude::Image
replaced byTryFrom
(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();
0.5.1 - 2024-12-04
0.5.0 - 2024-12-04
Changes
Added
- Implementation of
Clone
,Into<Vec<Vec<UVec2>>
traits forEdges
(662f42c) (0fdc732). translate_objects
method toEdges
for replace flagtranslate
(1bb608c).
Changed
- Upgrade dependencies: Bevy 0.15 (ac1a5a5).
- Dependency on
bevy_render
replaced withbevy_image
.
- Dependency on
- Function
multi_image_edges_raw
renamed tomulti_image_edge_raw
(1bb608c). - Now methods
image_edges
,multi_image_edge_raw
,single_image_edge_raw
returnsVec<Vec<UVec2>>
(1bb608c).
Removed
translate
flag forimage_edges
function (1bb608c).
Migration guide
Definition of edges
.
let edges = Edges::from(&image);
About Into
You can replace call Edges::multi_image_edge_raw
or
Edges::image_edges
with Into::into
with type declaration.
let objects1 = edges.image_edges();
let objects2 = edges.multi_image_edge_raw();
let objects3: Vec<Vec<UVec2>> = edges.into();
assert_eq!(objects1, objects2);
assert_eq!(objects2, objects3);
About translate
flag
If you use Edges::image_edges
like there:
let objects = edges.image_edges(true);
You must replace it with this:
// this two lines equal.
let objects1 = edges.multi_image_edge_translated();
let objects2 = edges.translate_objects(edges.image_edges());
assert_eq!(objects1, objects2);
About new type of output
If you use raw variants of edges like there:
let objects = edges.multi_image_edge_raw();
let object = edges.single_image_edge_raw();
And type of points in output you wait is Vec2
you can convert UVec2
like there:
// What these two examples have in common is the use of `UVec2::as_vec2`.
let objects: Vec<Vec<Vec2>> = edges
.multi_image_edge_raw()
.into_iter()
.map(|object| {
object.into_iter().map(|p| p.as_vec2()/* <-- */).collect()
}).collect();
let object: Vec<Vec2> = edges
.single_image_edge_raw()
.into_iter()
.map(|p| p.as_vec2()/* <-- */)
.collect();
0.4.0 - 2024-11-12
Changes
Added
- Reworked edges search algorithm for work with diagonal lines too
(60cb046) (c4ca604) (06012b7) (ac0c3dd) (8d38555). - Feature
glam-latest
for those who useglam
(e7ab40a). - Crate
rayon
to dependencies for parallelism (df77244). - Method
new
to takeEdges
from any data (3f5052f).
Changed
- Now
Edges
is structure (3f5052f). - Method
translate_vec
renamed totranslate
(5573751). - Dependency on
bevy
replaced withbevy_math
andbevy_render
(e7ab40a).
Fixed
Removed
Migration guide
Definition of edges
.
let edges = Edges::from(&image);
About feature glam-latest
This feature added for lightweight of usage of this crate without bevy
and support latest version of glam
.
Note
The bevy
feature disables the glam-latest
feature.
[dependencies.edges]
version = "*" # Your version
default-features = false
features = ["glam-latest"]
About Edges::new
Now, you mustn't call Edges::march_edges
.
To get edges from custom data, you can use Edges::new
.
Warning
The data size must be greater than or equal to height multiplied by width.
let data: &[u8];
let edges = Edges::new(height, width, data);
let objects = edges.multi_image_edge_translated();
About Edges
If you use match-case
on Edges
to return an image.
You should now use one of these options.
This will preserve your ownership of the image.
let data: &[u8];
let edges: Edges = Edges::new(height, width, data);
let edges: Edges = Edges::from(&image);
0.3.4 - 2024-08-13
0.3.3 - 2024-07-08
0.3.2 - 2024-05-13
0.3.1 - 2024-03-05
0.3.0 - 2024-03-04
Changes
Changed
- Methods
march_edges
,translate_vec
are provided as associated functions
(faee752).
Migration guide
Definition of edges
.
let edges = Edges::from(&image);
About march_edges
If you use Edges::march_edges
like there:
let objects = edges.march_edges(&data, rows, cols, translate);
You must replace it with this:
let objects = Edges::march_edges(&data, rows, cols, translate);
About translate_vec
You must replace call to translate_vec
like there:
let vec: Vec<Vec2> = Vec::new();
// Before:
let translate_vec = edges.translated_vec(vec, rows, cols);
// After:
let translated_vec = Edges::translate_vec(vec, rows, cols);