Browse Source

straightentool now works in 100ths of degrees

main
Colin McMillen 7 months ago
parent
commit
a2a5448afe
  1. 6
      Photo.cs
  2. 16
      Program.cs

6
Photo.cs

@ -105,7 +105,7 @@ public class Photo {
public GpsInfo? Gps = null;
public Rectangle CropRectangle = Rectangle.Empty;
public Vector2i ViewOffset = Vector2i.Zero;
public float RotationDegrees = 0;
public int RotationDegreeHundredths = 0;
private static long touchCounter = 0;
private Texture texture;
@ -219,8 +219,8 @@ public class Photo {
Console.WriteLine($"{Filename} => {jpgOut}");
await image.SaveAsync(jpgOut, new JpegEncoder() { Quality = 100 });
if (Math.Abs(RotationDegrees) > 0.001) {
image.Mutate(x => x.Rotate(RotationDegrees));
if (RotationDegreeHundredths != 0) {
image.Mutate(x => x.Rotate(RotationDegreeHundredths / 100f));
}
if (CropRectangle != Rectangle.Empty) {
image.Mutate(x => x.Crop(CropRectangle));

16
Program.cs

@ -257,24 +257,24 @@ public class CropTool : ITool {
public class StraightenTool : ITool {
Photo photo;
float initialRotation;
int initialRotation;
public StraightenTool(Photo photo) {
this.photo = photo;
initialRotation = photo.RotationDegrees;
initialRotation = photo.RotationDegreeHundredths;
}
public ToolStatus HandleInput(KeyboardState input, MouseState mouse, Transform transform, Game game, Photo photo, UiGeometry geometry) {
if (input.IsKeyPressed(Keys.D0)) {
photo.RotationDegrees = 0;
photo.RotationDegreeHundredths = 0;
}
if (input.IsKeyPressed(Keys.Left)) {
photo.RotationDegrees += .1f;
photo.RotationDegreeHundredths += 10;
}
if (input.IsKeyPressed(Keys.Right)) {
photo.RotationDegrees -= .1f;
photo.RotationDegreeHundredths -= 10;
}
if (input.IsKeyPressed(Keys.Enter)) {
@ -282,7 +282,7 @@ public class StraightenTool : ITool {
}
if (input.IsKeyPressed(Keys.Escape)) {
photo.RotationDegrees = initialRotation;
photo.RotationDegreeHundredths = initialRotation;
return ToolStatus.Canceled;
}
@ -290,7 +290,7 @@ public class StraightenTool : ITool {
}
public string Status() {
return String.Format("[straighten] {0:F2}", photo.RotationDegrees);
return String.Format("[straighten] {0:F2}", photo.RotationDegreeHundredths / 100f);
}
}
@ -983,7 +983,7 @@ public class Game : GameWindow {
renderSize.X, renderSize.Y);
activeOffset = new(photoBox.Min.X, photoBox.Min.Y);
transform = new Transform(activeScale, activeOffset, activePhoto.Size);
DrawTexture(active, photoBox, Color4.White, activePhoto.RotationDegrees);
DrawTexture(active, photoBox, Color4.White, activePhoto.RotationDegreeHundredths / 100f);
for (int i = 0; i < 5; i++) {
Texture star = (activePhoto.Rating > i) ? STAR_FILLED : STAR_EMPTY;
DrawTexture(star, geometry.StarBoxes[i].Min.X, geometry.StarBoxes[i].Min.Y);

Loading…
Cancel
Save