Skip to content

Commit

Permalink
windows 0.39
Browse files Browse the repository at this point in the history
  • Loading branch information
kennykerr authored and robmikh committed Jul 20, 2022
1 parent e03f444 commit 1a17605
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 286 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Expand Up @@ -8,9 +8,8 @@ edition = "2021"
rand = "0.8.5"

[dependencies.windows]
version = "0.38.0"
version = "0.39.0"
features = [
"alloc",
"Foundation_Collections",
"Foundation_Numerics",
"Graphics",
Expand Down
265 changes: 47 additions & 218 deletions src/comp_assets.rs
Expand Up @@ -6,8 +6,8 @@ use windows::{
UI::{
Colors,
Composition::{
CompositionColorBrush, CompositionGeometry, CompositionShape, CompositionSpriteShape,
Compositor,
CompositionColorBrush, CompositionGeometry, CompositionShape,
CompositionShapeCollection, CompositionSpriteShape, Compositor,
},
},
};
Expand Down Expand Up @@ -123,16 +123,20 @@ impl CompAssets {
let circle_geometry: CompositionGeometry = circle_geometry.cast()?;
let dot_brush = compositor.CreateColorBrushWithColor(Colors::Black()?)?;

let append_shape = |shapes: &CompositionShapeCollection, vector| {
shapes.Append(&get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
vector,
)?)
};

// 1
{
let container_shape = compositor.CreateContainerShape()?;
let shapes = container_shape.Shapes()?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
tile_size / 2.0,
)?)?;
append_shape(&shapes, tile_size / 2.0)?;
self.mine_count_shapes.insert(1, container_shape.cast()?);
}
// 2
Expand All @@ -141,18 +145,8 @@ impl CompAssets {
let shapes = container_shape.Shapes()?;
let third_x = tile_size.X / 3.0;
let half_y = tile_size.Y / 2.0;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(third_x, half_y),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(third_x * 2.0, half_y),
)?)?;
append_shape(&shapes, Vector2::new(third_x, half_y))?;
append_shape(&shapes, Vector2::new(third_x * 2.0, half_y))?;
self.mine_count_shapes.insert(2, container_shape.cast()?);
}
// 3
Expand All @@ -161,24 +155,9 @@ impl CompAssets {
let shapes = container_shape.Shapes()?;
let fourth_x = tile_size.X / 4.0;
let fourth_y = tile_size.Y / 4.0;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
tile_size / 2.0,
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x, fourth_y * 3.0),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x * 3.0, fourth_y),
)?)?;
append_shape(&shapes, tile_size / 2.0)?;
append_shape(&shapes, Vector2::new(fourth_x, fourth_y * 3.0))?;
append_shape(&shapes, Vector2::new(fourth_x * 3.0, fourth_y))?;
self.mine_count_shapes.insert(3, container_shape.cast()?);
}
// 4
Expand All @@ -187,30 +166,10 @@ impl CompAssets {
let shapes = container_shape.Shapes()?;
let third_x = tile_size.X / 3.0;
let third_y = tile_size.Y / 3.0;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(third_x, third_y),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(third_x * 2.0, third_y),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(third_x, third_y * 2.0),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(third_x * 2.0, third_y * 2.0),
)?)?;
append_shape(&shapes, Vector2::new(third_x, third_y))?;
append_shape(&shapes, Vector2::new(third_x * 2.0, third_y))?;
append_shape(&shapes, Vector2::new(third_x, third_y * 2.0))?;
append_shape(&shapes, Vector2::new(third_x * 2.0, third_y * 2.0))?;
self.mine_count_shapes.insert(4, container_shape.cast()?);
}
// 5
Expand All @@ -219,36 +178,11 @@ impl CompAssets {
let shapes = container_shape.Shapes()?;
let fourth_x = tile_size.X / 4.0;
let fourth_y = tile_size.Y / 4.0;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
tile_size / 2.0,
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x, fourth_y * 3.0),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x * 3.0, fourth_y),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x, fourth_y),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x * 3.0, fourth_y * 3.0),
)?)?;
append_shape(&shapes, tile_size / 2.0)?;
append_shape(&shapes, Vector2::new(fourth_x, fourth_y * 3.0))?;
append_shape(&shapes, Vector2::new(fourth_x * 3.0, fourth_y))?;
append_shape(&shapes, Vector2::new(fourth_x, fourth_y))?;
append_shape(&shapes, Vector2::new(fourth_x * 3.0, fourth_y * 3.0))?;
self.mine_count_shapes.insert(5, container_shape.cast()?);
}
// 6
Expand All @@ -257,42 +191,12 @@ impl CompAssets {
let shapes = container_shape.Shapes()?;
let fourth_x = tile_size.X / 4.0;
let fourth_y = tile_size.Y / 4.0;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x, fourth_y * 2.0),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x, fourth_y * 3.0),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x * 3.0, fourth_y),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x, fourth_y),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x * 3.0, fourth_y * 3.0),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x * 3.0, fourth_y * 2.0),
)?)?;
append_shape(&shapes, Vector2::new(fourth_x, fourth_y * 2.0))?;
append_shape(&shapes, Vector2::new(fourth_x, fourth_y * 3.0))?;
append_shape(&shapes, Vector2::new(fourth_x * 3.0, fourth_y))?;
append_shape(&shapes, Vector2::new(fourth_x, fourth_y))?;
append_shape(&shapes, Vector2::new(fourth_x * 3.0, fourth_y * 3.0))?;
append_shape(&shapes, Vector2::new(fourth_x * 3.0, fourth_y * 2.0))?;
self.mine_count_shapes.insert(6, container_shape.cast()?);
}
// 7
Expand All @@ -301,48 +205,13 @@ impl CompAssets {
let shapes = container_shape.Shapes()?;
let fourth_x = tile_size.X / 4.0;
let fourth_y = tile_size.Y / 4.0;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x, fourth_y * 2.0),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x, fourth_y * 3.0),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x * 3.0, fourth_y),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x, fourth_y),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x * 3.0, fourth_y * 3.0),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x * 3.0, fourth_y * 2.0),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
tile_size / 2.0,
)?)?;
append_shape(&shapes, Vector2::new(fourth_x, fourth_y * 2.0))?;
append_shape(&shapes, Vector2::new(fourth_x, fourth_y * 3.0))?;
append_shape(&shapes, Vector2::new(fourth_x * 3.0, fourth_y))?;
append_shape(&shapes, Vector2::new(fourth_x, fourth_y))?;
append_shape(&shapes, Vector2::new(fourth_x * 3.0, fourth_y * 3.0))?;
append_shape(&shapes, Vector2::new(fourth_x * 3.0, fourth_y * 2.0))?;
append_shape(&shapes, tile_size / 2.0)?;
self.mine_count_shapes.insert(7, container_shape.cast()?);
}
// 8
Expand All @@ -353,54 +222,14 @@ impl CompAssets {
let fourth_y = tile_size.Y / 4.0;
let half_x = tile_size.X / 2.0;
let third_y = tile_size.Y / 3.0;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x, fourth_y * 2.0),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x, fourth_y * 3.0),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x * 3.0, fourth_y),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x, fourth_y),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x * 3.0, fourth_y * 3.0),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(fourth_x * 3.0, fourth_y * 2.0),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(half_x, third_y),
)?)?;
shapes.Append(get_dot_shape(
compositor,
&circle_geometry,
&dot_brush,
Vector2::new(half_x, third_y * 2.0),
)?)?;
append_shape(&shapes, Vector2::new(fourth_x, fourth_y * 2.0))?;
append_shape(&shapes, Vector2::new(fourth_x, fourth_y * 3.0))?;
append_shape(&shapes, Vector2::new(fourth_x * 3.0, fourth_y))?;
append_shape(&shapes, Vector2::new(fourth_x, fourth_y))?;
append_shape(&shapes, Vector2::new(fourth_x * 3.0, fourth_y * 3.0))?;
append_shape(&shapes, Vector2::new(fourth_x * 3.0, fourth_y * 2.0))?;
append_shape(&shapes, Vector2::new(half_x, third_y))?;
append_shape(&shapes, Vector2::new(half_x, third_y * 2.0))?;
self.mine_count_shapes.insert(8, container_shape.cast()?);
}

Expand Down

0 comments on commit 1a17605

Please sign in to comment.