ManevilleF / hexx

Hexagonal tools lib in rust
Apache License 2.0
276 stars 22 forks source link

Fractional hex on HexLayout #141

Closed ManevilleF closed 6 months ago

ManevilleF commented 6 months ago

Closes #138 Supercedes #140

Re implementation of #140 by @msparkles

I added CHANGELOG entries and some code clarifications.

Work done

Added the capacity to use fractional axial coordinates as Vec2 in HexLayout methods:

To avoid duplication and multi-method chaining I encapsulated the matrix computations in:

I also added these utility methods:

msparkles commented 6 months ago

@ManevilleF Semirelated, why not just use Vec2? You can actually deconstruct them like this: fn foo(Vec2 { x, y }: Vec2)

...It's weird, no idea why Rust made it this way, but

ManevilleF commented 6 months ago

@ManevilleF Semirelated, why not just use Vec2? You can actually deconstruct them like this: fn foo(Vec2 { x, y }: Vec2)

...It's weird, no idea why Rust made it this way, but

Where ? The HexLayout methods do use a Vec2

msparkles commented 6 months ago

This

fn matrix_op(matrix: [f32; 4], [x, y]: [f32; 2]) -> [f32; 2] {

(on phone, dunno how to make links to lines on phone, soz)

ManevilleF commented 6 months ago

Yeah that is voluntary, I try to keep internal code as dependency free as possible, in the future I wish to have glam as an optional dependency