straightentool now works in 100ths of degrees
This commit is contained in:
parent
5f636dd910
commit
a2a5448afe
6
Photo.cs
6
Photo.cs
@ -105,7 +105,7 @@ public class Photo {
|
|||||||
public GpsInfo? Gps = null;
|
public GpsInfo? Gps = null;
|
||||||
public Rectangle CropRectangle = Rectangle.Empty;
|
public Rectangle CropRectangle = Rectangle.Empty;
|
||||||
public Vector2i ViewOffset = Vector2i.Zero;
|
public Vector2i ViewOffset = Vector2i.Zero;
|
||||||
public float RotationDegrees = 0;
|
public int RotationDegreeHundredths = 0;
|
||||||
|
|
||||||
private static long touchCounter = 0;
|
private static long touchCounter = 0;
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
@ -219,8 +219,8 @@ public class Photo {
|
|||||||
Console.WriteLine($"{Filename} => {jpgOut}");
|
Console.WriteLine($"{Filename} => {jpgOut}");
|
||||||
await image.SaveAsync(jpgOut, new JpegEncoder() { Quality = 100 });
|
await image.SaveAsync(jpgOut, new JpegEncoder() { Quality = 100 });
|
||||||
|
|
||||||
if (Math.Abs(RotationDegrees) > 0.001) {
|
if (RotationDegreeHundredths != 0) {
|
||||||
image.Mutate(x => x.Rotate(RotationDegrees));
|
image.Mutate(x => x.Rotate(RotationDegreeHundredths / 100f));
|
||||||
}
|
}
|
||||||
if (CropRectangle != Rectangle.Empty) {
|
if (CropRectangle != Rectangle.Empty) {
|
||||||
image.Mutate(x => x.Crop(CropRectangle));
|
image.Mutate(x => x.Crop(CropRectangle));
|
||||||
|
16
Program.cs
16
Program.cs
@ -257,24 +257,24 @@ public class CropTool : ITool {
|
|||||||
public class StraightenTool : ITool {
|
public class StraightenTool : ITool {
|
||||||
|
|
||||||
Photo photo;
|
Photo photo;
|
||||||
float initialRotation;
|
int initialRotation;
|
||||||
|
|
||||||
public StraightenTool(Photo photo) {
|
public StraightenTool(Photo photo) {
|
||||||
this.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) {
|
public ToolStatus HandleInput(KeyboardState input, MouseState mouse, Transform transform, Game game, Photo photo, UiGeometry geometry) {
|
||||||
if (input.IsKeyPressed(Keys.D0)) {
|
if (input.IsKeyPressed(Keys.D0)) {
|
||||||
photo.RotationDegrees = 0;
|
photo.RotationDegreeHundredths = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyPressed(Keys.Left)) {
|
if (input.IsKeyPressed(Keys.Left)) {
|
||||||
photo.RotationDegrees += .1f;
|
photo.RotationDegreeHundredths += 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyPressed(Keys.Right)) {
|
if (input.IsKeyPressed(Keys.Right)) {
|
||||||
photo.RotationDegrees -= .1f;
|
photo.RotationDegreeHundredths -= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyPressed(Keys.Enter)) {
|
if (input.IsKeyPressed(Keys.Enter)) {
|
||||||
@ -282,7 +282,7 @@ public class StraightenTool : ITool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsKeyPressed(Keys.Escape)) {
|
if (input.IsKeyPressed(Keys.Escape)) {
|
||||||
photo.RotationDegrees = initialRotation;
|
photo.RotationDegreeHundredths = initialRotation;
|
||||||
return ToolStatus.Canceled;
|
return ToolStatus.Canceled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ public class StraightenTool : ITool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string Status() {
|
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);
|
renderSize.X, renderSize.Y);
|
||||||
activeOffset = new(photoBox.Min.X, photoBox.Min.Y);
|
activeOffset = new(photoBox.Min.X, photoBox.Min.Y);
|
||||||
transform = new Transform(activeScale, activeOffset, activePhoto.Size);
|
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++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
Texture star = (activePhoto.Rating > i) ? STAR_FILLED : STAR_EMPTY;
|
Texture star = (activePhoto.Rating > i) ? STAR_FILLED : STAR_EMPTY;
|
||||||
DrawTexture(star, geometry.StarBoxes[i].Min.X, geometry.StarBoxes[i].Min.Y);
|
DrawTexture(star, geometry.StarBoxes[i].Min.X, geometry.StarBoxes[i].Min.Y);
|
||||||
|
Loading…
Reference in New Issue
Block a user