|
|
@ -496,8 +496,6 @@ public static class Util { |
|
|
|
FontRectangle rect = TextMeasurer.Measure(text, new TextOptions(font)); |
|
|
|
Image<Rgba32> image = MakeImage(rect.Width, rect.Height); |
|
|
|
IBrush brush = Brushes.Solid(Color.White); |
|
|
|
// IPen pen = Pens.Solid(Color.Black, 1f);
|
|
|
|
// image.Mutate(x => x.DrawText(options, text, brush, pen));
|
|
|
|
image.Mutate(x => x.DrawText(options, text, brush)); |
|
|
|
Texture texture = new Texture(image); |
|
|
|
image.Dispose(); |
|
|
@ -519,10 +517,15 @@ public static class Util { |
|
|
|
return new OpenTK.Windowing.Common.Input.Image[]{ opentkImage }; |
|
|
|
} |
|
|
|
|
|
|
|
public static Texture RenderStar(float radius) { |
|
|
|
public static Texture RenderStar(float radius, bool filled) { |
|
|
|
IPath path = new Star(x: radius, y: radius, prongs: 5, innerRadii: radius * 0.4f, outerRadii: radius, angle: Util.PI); |
|
|
|
Image<Rgba32> image = MakeImage(path.Bounds.Width, path.Bounds.Height); |
|
|
|
image.Mutate(x => x.Fill(Color.White, path)); |
|
|
|
Image<Rgba32> image = MakeImage(path.Bounds.Width + 2, path.Bounds.Height + 2); |
|
|
|
IBrush brush = Brushes.Solid(Color.White); |
|
|
|
IPen pen = Pens.Solid(Color.White, 1.5f); |
|
|
|
if (filled) { |
|
|
|
image.Mutate(x => x.Fill(brush, path)); |
|
|
|
} |
|
|
|
image.Mutate(x => x.Draw(pen, path)); |
|
|
|
Texture texture = new Texture(image); |
|
|
|
image.Dispose(); |
|
|
|
return texture; |
|
|
@ -534,6 +537,8 @@ public class Game : GameWindow { |
|
|
|
|
|
|
|
private static Texture TEXTURE_WHITE = new(new Image<Rgba32>(1, 1, new Rgba32(255, 255, 255))); |
|
|
|
private static Texture TEXTURE_BLACK = new(new Image<Rgba32>(1, 1, new Rgba32(0, 0, 0))); |
|
|
|
private static Texture STAR_FILLED = Util.RenderStar(20, true); |
|
|
|
private static Texture STAR_EMPTY= Util.RenderStar(20, false); |
|
|
|
|
|
|
|
UiGeometry geometry = new(); |
|
|
|
FpsCounter fpsCounter = new(); |
|
|
@ -704,10 +709,10 @@ public class Game : GameWindow { |
|
|
|
|
|
|
|
// Load photos from a directory.
|
|
|
|
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\photos-test\");
|
|
|
|
// string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\07\14\");
|
|
|
|
string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\07\14\"); |
|
|
|
// string[] files = Directory.GetFiles(@"G:\DCIM\100EOSR6\");
|
|
|
|
// string[] files = Directory.GetFiles(@"C:\Users\colin\Pictures\photos\2018\06\23");
|
|
|
|
string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\Germany all\104D7000"); |
|
|
|
// string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\Germany all\104D7000");
|
|
|
|
// string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\many-birds\");
|
|
|
|
|
|
|
|
for (int i = 0; i < files.Count(); i++) { |
|
|
@ -786,7 +791,11 @@ public class Game : GameWindow { |
|
|
|
Vector2i renderSize = (Vector2i) (((Vector2) active.Size) * scale); |
|
|
|
Vector2i center = (Vector2i) geometry.PhotoBox.Center; |
|
|
|
Box2i photoBox = Util.MakeBox(center.X - renderSize.X / 2, center.Y - renderSize.Y / 2, renderSize.X, renderSize.Y); |
|
|
|
DrawTexture(active, photoBox); |
|
|
|
DrawTexture(active, photoBox); |
|
|
|
for (int i = 0; i < 5; i++) { |
|
|
|
Texture star = (activePhoto.Rating > i) ? STAR_FILLED : STAR_EMPTY; |
|
|
|
DrawTexture(star, Util.MakeBox((star.Size.X + 10) * i + 10, 10, star.Size.X, star.Size.Y)); |
|
|
|
} |
|
|
|
|
|
|
|
// Draw thumbnail boxes.
|
|
|
|
ribbonIndex = Math.Clamp(photoIndex - (geometry.ThumbnailBoxes.Count - 1) / 2, 0, Math.Max(0, photos.Count - geometry.ThumbnailBoxes.Count)); |
|
|
@ -807,7 +816,8 @@ public class Game : GameWindow { |
|
|
|
int statusPadding = 2; |
|
|
|
DrawFilledBox(geometry.StatusBox, Color4.Black); |
|
|
|
DrawText(activePhoto.Description(), geometry.StatusBox.Min.X + 80, geometry.StatusBox.Min.Y + statusPadding); |
|
|
|
DrawText($" FPS: {fpsCounter.Fps}", geometry.StatusBox.Max.X - 76, geometry.StatusBox.Min.Y + statusPadding); |
|
|
|
DrawText(String.Format("FPS: {0,2}", fpsCounter.Fps), geometry.StatusBox.Max.X - 66, geometry.StatusBox.Min.Y + statusPadding); |
|
|
|
|
|
|
|
if (activePhoto.Loaded) { |
|
|
|
DrawText($"{(scale * 100):F1}%", geometry.StatusBox.Min.X, geometry.StatusBox.Min.Y + statusPadding); |
|
|
|
} |
|
|
|