-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ab8ee1
commit d23b100
Showing
5 changed files
with
342 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
<UserControl x:Class="Aurorae.Aurora" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:Aurorae" | ||
mc:Ignorable="d" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<Grid> | ||
<Image Name="LayerOne"/> | ||
<Image Name="LayerTwo"/> | ||
<Image Name="LayerThree"/> | ||
<Label Name="Touch" MouseDown="Touch_MouseDown"/> | ||
<Image Name="LayerOne" /> | ||
<Image Name="LayerTwo" /> | ||
<Image Name="LayerThree" /> | ||
<Label Name="Touch" MouseDown="Touch_MouseDown" /> | ||
</Grid> | ||
</UserControl> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using ExtendedSystemObjects; | ||
using Imaging; | ||
using Brushes = System.Drawing.Brushes; | ||
|
||
namespace Aurorae | ||
{ | ||
/// <summary> | ||
/// Handle all the Image generation Tasks | ||
/// </summary> | ||
internal static class Helper | ||
{ | ||
/// <summary> | ||
/// The padding for the numbers | ||
/// </summary> | ||
private const int Padding = 2; | ||
|
||
/// <summary> | ||
/// The render Interface | ||
/// </summary> | ||
private static readonly ImageRender Render = new(); | ||
|
||
/// <summary> | ||
/// Generates the image. | ||
/// </summary> | ||
/// <param name="width">The width.</param> | ||
/// <param name="height">The height.</param> | ||
/// <param name="textureSize">Size of the texture.</param> | ||
/// <param name="textures">The textures.</param> | ||
/// <param name="map">The map.</param> | ||
/// <returns>The generated Map</returns> | ||
internal static BitmapImage GenerateImage(int width, int height, int textureSize, List<Texture> textures, | ||
IEnumerable<int> map) | ||
{ | ||
var background = new Bitmap(width * textureSize, height * textureSize); | ||
|
||
var boxes = new List<Box>(); | ||
|
||
var layers = map.ChunkBy(height); | ||
|
||
for (var y = 0; y < layers.Count; y++) | ||
{ | ||
var slice = layers[y]; | ||
|
||
for (var x = 0; x < slice.Count; x++) | ||
{ | ||
var id = slice[x]; | ||
if (id <= 0) | ||
{ | ||
continue; | ||
} | ||
|
||
var texture = textures[id]; | ||
var image = Render.GetBitmapFile(texture.Path); | ||
|
||
var box = new Box {X = x * textureSize, Y = y * textureSize, Image = image, Layer = texture.Layer}; | ||
|
||
boxes.Add(box); | ||
} | ||
} | ||
|
||
background = boxes.OrderBy(layer => layer.Layer).ToList().Aggregate(background, | ||
(current, slice) => Render.CombineBitmap(current, slice.Image, slice.X, slice.Y)); | ||
|
||
return background.ToBitmapImage(); | ||
} | ||
|
||
/// <summary> | ||
/// Generates the grid. | ||
/// </summary> | ||
/// <param name="width">The width.</param> | ||
/// <param name="height">The height.</param> | ||
/// <param name="textureSize">Size of the texture.</param> | ||
/// <returns>A grid overlay</returns> | ||
internal static ImageSource GenerateGrid(int width, int height, int textureSize) | ||
{ | ||
var background = new Bitmap(width * textureSize, height * textureSize); | ||
|
||
for (var y = 0; y < height; y++) | ||
{ | ||
for (var x = 0; x < width; x++) | ||
{ | ||
using var graphics = Graphics.FromImage(background); | ||
graphics.DrawRectangle(Pens.Black, x * textureSize, y * textureSize, textureSize, textureSize); | ||
} | ||
} | ||
|
||
return background.ToBitmapImage(); | ||
} | ||
|
||
/// <summary> | ||
/// Generates the numbers. | ||
/// </summary> | ||
/// <param name="width">The width.</param> | ||
/// <param name="height">The height.</param> | ||
/// <param name="textureSize">Size of the texture.</param> | ||
/// <returns>A number overlay</returns> | ||
public static ImageSource GenerateNumbers(int width, int height, int textureSize) | ||
{ | ||
var background = new Bitmap(width * textureSize, height * textureSize); | ||
|
||
var count = -1; | ||
|
||
for (var y = 0; y < height; y++) | ||
{ | ||
for (var x = 0; x < width; x++) | ||
{ | ||
count++; | ||
|
||
using var graphics = Graphics.FromImage(background); | ||
var rectangle = new RectangleF((x * textureSize) + Padding, (y * textureSize) + Padding, | ||
textureSize - Padding, textureSize - Padding); | ||
graphics.DrawString(count.ToString(), new Font("Tahoma", 8), Brushes.Black, rectangle); | ||
} | ||
} | ||
|
||
return background.ToBitmapImage(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<UserControl x:Class="Aurorae.Polaris" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<Grid> | ||
<Image Name="LayerOne" /> | ||
<Image Name="LayerTwo" /> | ||
<Image Name="LayerThree" /> | ||
<Label Name="Touch" MouseDown="Touch_MouseDown" /> | ||
</Grid> | ||
</UserControl> |
Oops, something went wrong.