A Bevy plugin for 2d mouse interactions
Easy ninepatch progress bar in bevy
I have tried to create an interaction area that is more flexible than a simple boundary box. Implementing a first extension in bevy_interact_2d, I got as far as the code below, but I assume this is much easier done with better support for a ‘contains’ method on the lyon side, so I raised an issue at bevy_prototype_lyon. i don't think what I do here is perfect, I would feel much better about re-using an existing geometry type.
pub enum InteractionArea {
BoundingBox(Vec2, Vec2),
Triangle(Vec2, Vec2, Vec2),
}
/// A convenience thing, so existing bounding boxes just need `.into()`
impl From<(Vec2, Vec2)> for InteractionArea {
fn from((corner1, corner2): (Vec2, Vec2)) -> Self {
InteractionArea::BoundingBox(corner1, corner2)
}
}
/// This component makes an entity interactable with the mouse cursor
#[derive(Component)]
pub struct Interactable {
/// The interaction groups this interactable entity belongs to
pub groups: Vec<Group>,
/// The interaction area for the interactable entity
pub interaction_area: InteractionArea,
}
impl Interactable {
fn contains(&self, cursor: &Vec2) -> bool {
match self.interaction_area {
InteractionArea::BoundingBox(corner1, corner2) => {
(corner1.x..corner2.x).contains(&cursor.x) && (corner1.y..corner2.y).contains(&cursor.y)
}
InteractionArea::Triangle(a, b, c) => Triangle {
a: point2(a.x, a.y),
b: point2(b.x, b.y),
c: point2(c.x, c.y),
}
.contains_point(point2(cursor.x, cursor.y)),
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.