put stars at the center bottom and make f/ stringification simpler
This commit is contained in:
parent
e98b19d87b
commit
8ca4ff7cad
44
Program.cs
44
Program.cs
@ -292,17 +292,11 @@ public class Photo {
|
||||
IExifValue<Rational>? fNumber;
|
||||
if (exifs.TryGetValue(ExifTag.FNumber, out fNumber)) {
|
||||
Rational r = fNumber.Value;
|
||||
if (r.Denominator == 1) {
|
||||
FNumber = $"f/{r.Numerator}";
|
||||
if (r.Numerator % r.Denominator == 0) {
|
||||
FNumber = $"f/{r.Numerator / r.Denominator}";
|
||||
} else {
|
||||
if (r.Denominator != 10) {
|
||||
Console.WriteLine($"*** WARNING: unexpected FNumber denominator: {r.Denominator}");
|
||||
}
|
||||
if (r.Numerator % 10 == 0) {
|
||||
FNumber = $"f/{r.Numerator / 10}";
|
||||
} else {
|
||||
FNumber= $"f/{r.Numerator / 10}.{r.Numerator % 10}";
|
||||
}
|
||||
int fTimesTen = (int) Math.Round(10f * r.Numerator / r.Denominator);
|
||||
FNumber = $"f/{fTimesTen / 10}.{fTimesTen % 10}";
|
||||
}
|
||||
}
|
||||
|
||||
@ -424,18 +418,19 @@ public class Texture : IDisposable {
|
||||
}
|
||||
|
||||
public class UiGeometry {
|
||||
public static Vector2i MIN_WINDOW_SIZE = new(640, 480);
|
||||
public static Vector2i MIN_WINDOW_SIZE = new(1024, 768);
|
||||
private static CameraInfo activeCamera = CameraInfo.CANON_EOS_R6M2;
|
||||
|
||||
public readonly Vector2i WindowSize;
|
||||
public readonly Box2i ThumbnailBox;
|
||||
public readonly List<Box2i> ThumbnailBoxes = new();
|
||||
public readonly List<Box2i> StarBoxes = new();
|
||||
public readonly Box2i PhotoBox;
|
||||
public readonly Box2i StatusBox;
|
||||
|
||||
public UiGeometry() : this(MIN_WINDOW_SIZE) {}
|
||||
public UiGeometry() : this(MIN_WINDOW_SIZE, 0) {}
|
||||
|
||||
public UiGeometry(Vector2i windowSize) {
|
||||
public UiGeometry(Vector2i windowSize, int starSize) {
|
||||
WindowSize = windowSize;
|
||||
|
||||
int numThumbnails = 15;
|
||||
@ -451,6 +446,13 @@ public class UiGeometry {
|
||||
PhotoBox = new Box2i(0, 0, WindowSize.X - thumbnailWidth, WindowSize.Y - statusBoxHeight - statusBoxPadding);
|
||||
StatusBox = new Box2i(0, WindowSize.Y - statusBoxHeight, WindowSize.X - thumbnailWidth, WindowSize.Y);
|
||||
ThumbnailBox = new Box2i(ThumbnailBoxes[0].Min.X, ThumbnailBoxes[0].Min.Y, WindowSize.X, WindowSize.Y);
|
||||
|
||||
int starSpacing = 10;
|
||||
int starBoxLeft = (int) (PhotoBox.Center.X - 2.5 * starSize - starSpacing * 2);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
Box2i box = Util.MakeBox(starBoxLeft + i * (starSize + starSpacing), PhotoBox.Max.Y - starSize - 10, starSize, starSize);
|
||||
StarBoxes.Add(box);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -518,17 +520,19 @@ public static class Util {
|
||||
}
|
||||
|
||||
public static Texture RenderStar(float radius, bool filled) {
|
||||
IPath path = new Star(x: radius, y: radius, prongs: 5, innerRadii: radius * 0.45f, outerRadii: radius, angle: Util.PI);
|
||||
IPath path = new Star(x: radius, y: radius + 1, prongs: 5, innerRadii: radius * 0.4f, outerRadii: radius, angle: Util.PI);
|
||||
// We add a little bit to the width & height because the reported
|
||||
// path.Bounds are often a little tighter than they should be & a couple
|
||||
// pixels end up obviously missing...
|
||||
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);
|
||||
IPen white = Pens.Solid(Color.White, 1.5f);
|
||||
IPen black = Pens.Solid(Color.Black, 3f);
|
||||
image.Mutate(x => x.Draw(black, path));
|
||||
if (filled) {
|
||||
image.Mutate(x => x.Fill(brush, path));
|
||||
}
|
||||
image.Mutate(x => x.Draw(pen, path));
|
||||
image.Mutate(x => x.Draw(white, path));
|
||||
Texture texture = new Texture(image);
|
||||
image.Dispose();
|
||||
return texture;
|
||||
@ -713,8 +717,8 @@ 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(@"G:\DCIM\100EOSR6\");
|
||||
// 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\many-birds\");
|
||||
@ -798,7 +802,7 @@ public class Game : GameWindow {
|
||||
DrawTexture(active, photoBox);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
Texture star = (activePhoto.Rating > i) ? STAR_FILLED : STAR_EMPTY;
|
||||
DrawTexture(star, (star.Size.X + 10) * i + 10, 10);
|
||||
DrawTexture(star, geometry.StarBoxes[i].Min.X, geometry.StarBoxes[i].Min.Y);
|
||||
}
|
||||
|
||||
// Draw thumbnail boxes.
|
||||
@ -870,7 +874,7 @@ public class Game : GameWindow {
|
||||
base.OnResize(e);
|
||||
Console.WriteLine($"OnResize: {e.Width}x{e.Height}");
|
||||
|
||||
geometry = new UiGeometry(e.Size);
|
||||
geometry = new UiGeometry(e.Size, STAR_FILLED.Size.X);
|
||||
|
||||
projection = Matrix4.CreateOrthographicOffCenter(0f, e.Width, e.Height, 0f, -1f, 1f);
|
||||
GL.UniformMatrix4(shader.GetUniformLocation("projection"), true, ref projection);
|
||||
|
Loading…
Reference in New Issue
Block a user