mirror of
https://github.com/fadden/6502bench.git
synced 2024-10-31 19:04:44 +00:00
Render the animation overlay image instead of loading from a file
Mostly because I'm a lousy artist, and if I do it in code it's easy to make it symmetric and tweak the colors.
This commit is contained in:
parent
12293d3cf8
commit
4e645d911c
Binary file not shown.
@ -103,6 +103,14 @@ namespace SourceGen {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Visualization sets. Uses file offset as key.
|
/// Visualization sets. Uses file offset as key.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// TODO(maybe): certain operations must be performed on the set of all visualizations
|
||||||
|
/// or the set of all animations, requiring a double "foreach" with an "is" clause.
|
||||||
|
/// It might be simpler and more efficient overall to split this into three lists: one
|
||||||
|
/// for visualizations (perhaps keyed by serial number), one for animations, and one
|
||||||
|
/// for VisualizationSet objects (the latter required to establish ordering). The
|
||||||
|
/// primary argument against is that this makes undo/redo more complicated.
|
||||||
|
/// </remarks>
|
||||||
public SortedList<int, VisualizationSet> VisualizationSets { get; private set; }
|
public SortedList<int, VisualizationSet> VisualizationSets { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 376 B |
@ -430,8 +430,5 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Resource Include="Res\RedX.png" />
|
<Resource Include="Res\RedX.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Resource Include="Res\BlueChevron.png" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
@ -77,7 +77,7 @@ namespace SourceGen {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool HasImage {
|
public bool HasImage {
|
||||||
get {
|
get {
|
||||||
return CachedImage != BROKEN_IMAGE && CachedImage != ANIM_IMAGE;
|
return CachedImage != BROKEN_IMAGE && CachedImage != ANIM_OVERLAY_IMAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,8 +87,11 @@ namespace SourceGen {
|
|||||||
public static readonly BitmapImage BROKEN_IMAGE =
|
public static readonly BitmapImage BROKEN_IMAGE =
|
||||||
new BitmapImage(new Uri("pack://application:,,,/Res/RedX.png"));
|
new BitmapImage(new Uri("pack://application:,,,/Res/RedX.png"));
|
||||||
|
|
||||||
internal static readonly BitmapImage ANIM_IMAGE =
|
/// <summary>
|
||||||
new BitmapImage(new Uri("pack://application:,,,/Res/BlueChevron.png"));
|
/// Image to overlay on animation visualizations.
|
||||||
|
/// </summary>
|
||||||
|
internal static readonly BitmapSource ANIM_OVERLAY_IMAGE =
|
||||||
|
VisualizationAnimation.GenerateAnimOverlayImage();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Serial number, for reference from other Visualization objects. Not serialized.
|
/// Serial number, for reference from other Visualization objects. Not serialized.
|
||||||
|
@ -80,7 +80,7 @@ namespace SourceGen {
|
|||||||
mSerialNumbers.Add(serial);
|
mSerialNumbers.Add(serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedImage = ANIM_IMAGE; // default to this
|
CachedImage = ANIM_OVERLAY_IMAGE; // default to this
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -93,7 +93,7 @@ namespace SourceGen {
|
|||||||
public void GenerateImage(SortedList<int, VisualizationSet> visSets) {
|
public void GenerateImage(SortedList<int, VisualizationSet> visSets) {
|
||||||
const int IMAGE_SIZE = 64;
|
const int IMAGE_SIZE = 64;
|
||||||
|
|
||||||
CachedImage = ANIM_IMAGE;
|
CachedImage = ANIM_OVERLAY_IMAGE;
|
||||||
|
|
||||||
if (mSerialNumbers.Count == 0) {
|
if (mSerialNumbers.Count == 0) {
|
||||||
return;
|
return;
|
||||||
@ -113,16 +113,16 @@ namespace SourceGen {
|
|||||||
|
|
||||||
DrawingVisual visual = new DrawingVisual();
|
DrawingVisual visual = new DrawingVisual();
|
||||||
//RenderOptions.SetBitmapScalingMode(visual, BitmapScalingMode.NearestNeighbor);
|
//RenderOptions.SetBitmapScalingMode(visual, BitmapScalingMode.NearestNeighbor);
|
||||||
DrawingContext dc = visual.RenderOpen();
|
using (DrawingContext dc = visual.RenderOpen()) {
|
||||||
dc.DrawImage(vis.CachedImage, imgBounds);
|
dc.DrawImage(vis.CachedImage, imgBounds);
|
||||||
dc.DrawImage(ANIM_IMAGE, new Rect(0, 0, IMAGE_SIZE, IMAGE_SIZE));
|
dc.DrawImage(ANIM_OVERLAY_IMAGE, new Rect(0, 0, IMAGE_SIZE, IMAGE_SIZE));
|
||||||
dc.Close();
|
}
|
||||||
|
|
||||||
RenderTargetBitmap bmp = new RenderTargetBitmap(IMAGE_SIZE, IMAGE_SIZE, 96.0, 96.0,
|
RenderTargetBitmap bmp = new RenderTargetBitmap(IMAGE_SIZE, IMAGE_SIZE, 96.0, 96.0,
|
||||||
PixelFormats.Pbgra32);
|
PixelFormats.Pbgra32);
|
||||||
bmp.Render(visual);
|
bmp.Render(visual);
|
||||||
CachedImage = bmp;
|
CachedImage = bmp;
|
||||||
Debug.WriteLine("RENDERED " + Tag);
|
//Debug.WriteLine("RENDERED " + Tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -176,6 +176,35 @@ namespace SourceGen {
|
|||||||
return somethingRemoved;
|
return somethingRemoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BitmapSource GenerateAnimOverlayImage() {
|
||||||
|
const int IMAGE_SIZE = 128;
|
||||||
|
|
||||||
|
// Glowy "high tech" blue.
|
||||||
|
SolidColorBrush outlineBrush = new SolidColorBrush(Color.FromArgb(255, 0, 216, 255));
|
||||||
|
SolidColorBrush fillBrush = new SolidColorBrush(Color.FromArgb(128, 0, 182, 215));
|
||||||
|
|
||||||
|
DrawingVisual visual = new DrawingVisual();
|
||||||
|
using (DrawingContext dc = visual.RenderOpen()) {
|
||||||
|
// Thanks: https://stackoverflow.com/a/29249100/294248
|
||||||
|
Point p1 = new Point(IMAGE_SIZE * 5 / 8, IMAGE_SIZE / 2);
|
||||||
|
Point p2 = new Point(IMAGE_SIZE * 3 / 8, IMAGE_SIZE / 4);
|
||||||
|
Point p3 = new Point(IMAGE_SIZE * 3 / 8, IMAGE_SIZE * 3 / 4);
|
||||||
|
StreamGeometry sg = new StreamGeometry();
|
||||||
|
using (StreamGeometryContext sgc = sg.Open()) {
|
||||||
|
sgc.BeginFigure(p1, true, true);
|
||||||
|
PointCollection points = new PointCollection() { p2, p3 };
|
||||||
|
sgc.PolyLineTo(points, true, true);
|
||||||
|
}
|
||||||
|
sg.Freeze();
|
||||||
|
dc.DrawGeometry(fillBrush, new Pen(outlineBrush, 3), sg);
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderTargetBitmap bmp = new RenderTargetBitmap(IMAGE_SIZE, IMAGE_SIZE, 96.0, 96.0,
|
||||||
|
PixelFormats.Pbgra32);
|
||||||
|
bmp.Render(visual);
|
||||||
|
return bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static bool operator ==(VisualizationAnimation a, VisualizationAnimation b) {
|
public static bool operator ==(VisualizationAnimation a, VisualizationAnimation b) {
|
||||||
if (ReferenceEquals(a, b)) {
|
if (ReferenceEquals(a, b)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user