diff --git a/README.md b/README.md
index 45a238c..8c611fd 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,8 @@ Have fun!
- Phosphor in MIT License
- Steve Schoger in PD License
- Thewolfkit in CC Attribution License
+ - Uxaspects in Apache License
+ - Uxwb in GPL License
- Wishforge.games in CC Attribution License
- Yamatsum in MIT License
- Zest in MIT License
diff --git a/ZXBStudio/Dialogs/SplashScreen.axaml b/ZXBStudio/Dialogs/SplashScreen.axaml
index 813d64a..e64bebd 100644
--- a/ZXBStudio/Dialogs/SplashScreen.axaml
+++ b/ZXBStudio/Dialogs/SplashScreen.axaml
@@ -13,7 +13,7 @@
-
+
diff --git a/ZXBStudio/Dialogs/SplashScreen.axaml.cs b/ZXBStudio/Dialogs/SplashScreen.axaml.cs
index 5be7d11..0f58757 100644
--- a/ZXBStudio/Dialogs/SplashScreen.axaml.cs
+++ b/ZXBStudio/Dialogs/SplashScreen.axaml.cs
@@ -8,7 +8,7 @@ public partial class SplashScreen : Window
public SplashScreen()
{
InitializeComponent();
- lblVersion.Content = $"v{Program.Version} | {Program.VersionDate}";
+ lblVersion.Content=$"{Program.Version} | {Program.VersionDate}";
}
}
}
diff --git a/ZXBStudio/DocumentEditors/ZXGraphics/PaletteBuilderDialog.axaml b/ZXBStudio/DocumentEditors/ZXGraphics/PaletteBuilderDialog.axaml
index 35e4920..2e60542 100644
--- a/ZXBStudio/DocumentEditors/ZXGraphics/PaletteBuilderDialog.axaml
+++ b/ZXBStudio/DocumentEditors/ZXGraphics/PaletteBuilderDialog.axaml
@@ -47,7 +47,7 @@
Convert to current palette
-
+
Append new colors to current palette
@@ -78,7 +78,7 @@
-
+
@@ -95,10 +95,21 @@
-
+
+
+
+
+
+
+
+
diff --git a/ZXBStudio/DocumentEditors/ZXGraphics/PaletteBuilderDialog.axaml.cs b/ZXBStudio/DocumentEditors/ZXGraphics/PaletteBuilderDialog.axaml.cs
index 123c6ed..251c34b 100644
--- a/ZXBStudio/DocumentEditors/ZXGraphics/PaletteBuilderDialog.axaml.cs
+++ b/ZXBStudio/DocumentEditors/ZXGraphics/PaletteBuilderDialog.axaml.cs
@@ -33,6 +33,7 @@
using Avalonia.Controls.Shapes;
using static CommunityToolkit.Mvvm.ComponentModel.__Internals.__TaskExtensions.TaskAwaitableWithoutEndValidation;
using FFmpeg.AutoGen;
+using System.Diagnostics;
namespace ZXBasicStudio.DocumentEditors.ZXGraphics
{
@@ -44,6 +45,7 @@ public partial class PaletteBuilderDialog : Window, IDisposable
private Rectangle[] rectangulos = new Rectangle[256];
private PaletteColor[] palette = null;
+ private PaletteColor[] palette512 = null;
private string sourceFile = null;
private string convertedFile = null;
private bool imgSourceLoaded = false;
@@ -68,8 +70,9 @@ public PaletteBuilderDialog()
// Set the palette
palette = ServiceLayer.GetPalette(GraphicsModes.Next);
- selectedColorIndex = 0;
+ selectedColorIndex = 0;
DrawPalette();
+ DrawColorPicker();
btnFileSource.Tapped += BtnFileSource_Tapped;
btnResetPalette.Click += BtnResetPalette_Click;
@@ -85,7 +88,10 @@ public PaletteBuilderDialog()
btnRefresh.Click += BtnRefresh_Click;
btnSaveImage.Click += BtnSaveImage_Click;
+ btnColorPicker.Click += BtnColorPicker_Click;
+
btnClose.Click += BtnClose_Click;
+
}
@@ -893,5 +899,170 @@ private void CrearPaletaGPL9bits()
}
#endregion
+
+
+ #region Color Picker
+
+ private int Circles = 8; //16;
+ private int Sectors = 32;
+ private double Radius = 200;
+
+ private void BtnColorPicker_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
+ {
+ grdColorPicker.IsVisible = true;
+ }
+
+
+ private void DrawColorPicker()
+ {
+ Create512Palette();
+
+ ColorWheelCanvas.Children.Clear();
+ double ringWidth = Radius / Circles;
+ double angleStep = 360.0 / Sectors;
+ double cx = Radius;
+ double cy = Radius;
+
+ for (int circle = 0; circle < Circles; circle++)
+ {
+ double r1 = ringWidth * circle;
+ double r2 = ringWidth * (circle + 1);
+ double value = (circle + 1) / (double)Circles;
+
+ for (int sector = 0; sector < Sectors; sector++)
+ {
+ double hue = sector * angleStep;
+ Color color = FromHSV(hue, 1.0, value);
+ int idx=ServiceLayer.GetColor(color.R, color.G, color.B, palette512, 5);
+ var p = palette512[idx];
+ var color512=Color.FromRgb(p.Red, p.Green, p.Blue);
+ DrawSegment(cx, cy, r1, r2, hue, angleStep, color512);
+ }
+ }
+ }
+
+ private void DrawSegment(double cx, double cy, double r1, double r2, double startAngle, double angleSize, Color color)
+ {
+ var startRad = Math.PI * startAngle / 180.0;
+ var endRad = Math.PI * (startAngle + angleSize) / 180.0;
+
+ var p1 = new Point(cx + r1 * Math.Cos(startRad), cy + r1 * Math.Sin(startRad));
+ var p2 = new Point(cx + r2 * Math.Cos(startRad), cy + r2 * Math.Sin(startRad));
+ var p3 = new Point(cx + r2 * Math.Cos(endRad), cy + r2 * Math.Sin(endRad));
+ var p4 = new Point(cx + r1 * Math.Cos(endRad), cy + r1 * Math.Sin(endRad));
+
+ var path = new Avalonia.Controls.Shapes.Path
+ {
+ Fill = new SolidColorBrush(color),
+ StrokeThickness = 0,
+ Data = new PathGeometry
+ {
+ Figures = new PathFigures
+ {
+ new PathFigure
+ {
+ StartPoint = p1,
+ Segments = new PathSegments
+ {
+ new LineSegment { Point = p2 },
+ new ArcSegment
+ {
+ Point = p3,
+ Size = new Size(r2, r2),
+ SweepDirection = SweepDirection.Clockwise,
+ IsLargeArc = angleSize > 180
+ },
+ new LineSegment { Point = p4 },
+ new ArcSegment
+ {
+ Point = p1,
+ Size = new Size(r1, r1),
+ SweepDirection = SweepDirection.CounterClockwise,
+ IsLargeArc = angleSize > 180
+ }
+ }
+ }
+ }
+ }
+ };
+
+ ColorWheelCanvas.Children.Add(path);
+ }
+
+ private void ColorWheelCanvas_PointerPressed(object? sender, PointerPressedEventArgs e)
+ {
+ var pos = e.GetPosition(ColorWheelCanvas);
+ double dx = pos.X - Radius;
+ double dy = pos.Y - Radius;
+ double distance = Math.Sqrt(dx * dx + dy * dy);
+ if (distance > Radius) return;
+
+ double angle = Math.Atan2(dy, dx) * 180 / Math.PI;
+ if (angle < 0) angle += 360;
+
+ int sector = (int)(angle / (360.0 / Sectors));
+ int circle = (int)(distance / (Radius / Circles));
+
+ double hue = sector * (360.0 / Sectors);
+ double value = (circle + 1) / (double)Circles;
+ Color color = FromHSV(hue, 1.0, value);
+
+ SelectedColorPreview.Fill = new SolidColorBrush(color);
+ }
+
+ private static Color FromHSV(double hue, double saturation, double value)
+ {
+ double c = value * saturation;
+ double x = c * (1 - Math.Abs((hue / 60.0 % 2) - 1));
+ double m = value - c;
+
+ double r = 0, g = 0, b = 0;
+
+ if (hue < 60) { r = c; g = x; }
+ else if (hue < 120) { r = x; g = c; }
+ else if (hue < 180) { g = c; b = x; }
+ else if (hue < 240) { g = x; b = c; }
+ else if (hue < 300) { r = x; b = c; }
+ else { r = c; b = x; }
+
+ byte R = (byte)((r + m) * 255);
+ byte G = (byte)((g + m) * 255);
+ byte B = (byte)((b + m) * 255);
+
+ return Color.FromRgb(R, G, B);
+ }
+
+ private void Create512Palette()
+ {
+ palette512 = new PaletteColor[512];
+ for (int i = 0; i < 512; i++)
+ {
+ int r = ((i & 0b111000000) >> 6)*36;
+ int g = ((i & 0b000111000) >> 3)*36;
+ int b = (i & 0b000000111)*36;
+ if (r > 250)
+ {
+ r = 255;
+ }
+ if (g > 250)
+ {
+ g = 255;
+ }
+ if (b > 250)
+ {
+ b = 255;
+ }
+
+ palette512[i] = new PaletteColor()
+ {
+ Red = (byte)r,
+ Green = (byte)g,
+ Blue = (byte)b,
+ HasPriority = false
+ };
+ }
+ }
+
+ #endregion
}
}
diff --git a/ZXBStudio/DocumentEditors/ZXGraphics/SpriteEditor.axaml b/ZXBStudio/DocumentEditors/ZXGraphics/SpriteEditor.axaml
index 94da8c8..f38140e 100644
--- a/ZXBStudio/DocumentEditors/ZXGraphics/SpriteEditor.axaml
+++ b/ZXBStudio/DocumentEditors/ZXGraphics/SpriteEditor.axaml
@@ -27,10 +27,10 @@
-