[oden] Circles work
This commit is contained in:
parent
26a3939012
commit
020bb8f124
7 changed files with 83 additions and 51 deletions
|
|
@ -15,18 +15,6 @@ pub struct ClearCommand {
|
|||
pub color: [f64; 4],
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SpriteCommand {
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
pub w: f32,
|
||||
pub h: f32,
|
||||
pub u: f32,
|
||||
pub v: f32,
|
||||
pub sw: f32,
|
||||
pub sh: f32,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CreateTextureCommand {
|
||||
pub id: u32,
|
||||
|
|
@ -38,7 +26,8 @@ pub struct CreateTextureCommand {
|
|||
pub enum GraphicsCommand {
|
||||
Clear(ClearCommand),
|
||||
Print(PrintCommand),
|
||||
Sprite(SpriteCommand),
|
||||
Circle(crate::CircleInstance),
|
||||
Sprite(crate::SpriteInstance),
|
||||
CreateTexture(CreateTextureCommand),
|
||||
CreateWritableTexture {
|
||||
id: u32,
|
||||
|
|
@ -78,16 +67,26 @@ impl GraphicsImpl {
|
|||
}
|
||||
|
||||
fn spr(&self, x: f32, y: f32, w: f32, h: f32, u: f32, v: f32, sw: f32, sh: f32) {
|
||||
let _ = self.sender.send(GraphicsCommand::Sprite(SpriteCommand {
|
||||
x,
|
||||
y,
|
||||
w,
|
||||
h,
|
||||
u,
|
||||
v,
|
||||
sw,
|
||||
sh,
|
||||
}));
|
||||
let _ = self
|
||||
.sender
|
||||
.send(GraphicsCommand::Sprite(crate::SpriteInstance {
|
||||
src_top_left: [u, v],
|
||||
src_dims: [sw, sh],
|
||||
dest_top_left: [x, y],
|
||||
dest_dims: [w, h],
|
||||
}));
|
||||
}
|
||||
|
||||
fn circle(&self, x: f32, y: f32, r: f32, s: f32) {
|
||||
let _ = self
|
||||
.sender
|
||||
.send(GraphicsCommand::Circle(crate::CircleInstance {
|
||||
center: [x, y],
|
||||
radius: r,
|
||||
stroke_width: s,
|
||||
stroke_color: [1.0, 0.0, 0.0, 1.0],
|
||||
fill_color: [1.0, 1.0, 1.0, 1.0],
|
||||
}));
|
||||
}
|
||||
|
||||
fn create_texture(
|
||||
|
|
@ -183,6 +182,15 @@ impl GraphicsAPI {
|
|||
)?,
|
||||
)?;
|
||||
}
|
||||
{
|
||||
let gfx = gfx.clone();
|
||||
builder.export(
|
||||
"circle",
|
||||
ctx.new_fn(move |_: &ContextRef, x: f32, y: f32, r: f32, s: f32| {
|
||||
gfx.circle(x, y, r, s)
|
||||
})?,
|
||||
)?;
|
||||
}
|
||||
{
|
||||
let gfx = gfx.clone();
|
||||
builder.export(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue