Skip to content

Wider Vec2 support #13

@TheRedDeveloper

Description

@TheRedDeveloper

Summary

Methods that take separate x: f32, y: f32 parameters should accept impl Into<Vector2> instead and there should be From implementations for (f32, f32), and macroquad's Vec2.

Motivation

Builder methods like .offset(x, y) and .pivot(x, y) take two separate floats. This means you can't pass a Vec2 directly, you have to destructure it: .offset(pos.x, pos.y).

With impl Into<Vector2>, you pass whatever you have.

Proposed API

el.floating(|f| f.offset((10.0, 20.0)));
el.rotation(|r| r.pivot((0.5, 0.5)));

let pos = Vec2::new(10.0, 20.0);
el.floating(|f| f.offset(pos));

Behavior

  • .offset(10.0, 20.0) won't compile anymore. (Breaking change)
  • The prelude remains unchanged

Metadata

Metadata

Assignees

No one assigned

    Labels

    approvedA feature that has been approvedfeatNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions