Browse Source

capitalize function names like a C# programmer

main
Colin McMillen 12 months ago
parent
commit
4c72f797ab
  1. 33
      Program.cs

33
Program.cs

@ -244,7 +244,7 @@ public class UiGeometry {
int thumbnailHeight = WindowSize.Y / numThumbnails;
int thumbnailWidth = (int) 1.0 * thumbnailHeight * activeCamera.Resolution.X / activeCamera.Resolution.Y;
for (int i = 0; i < numThumbnails; i++) {
Box2i box = Util.makeBox(WindowSize.X - thumbnailWidth, i * thumbnailHeight, thumbnailWidth, thumbnailHeight);
Box2i box = Util.MakeBox(WindowSize.X - thumbnailWidth, i * thumbnailHeight, thumbnailWidth, thumbnailHeight);
ThumbnailBoxes.Add(box);
}
@ -255,24 +255,23 @@ public class UiGeometry {
public static class Util {
public const float PI = (float) Math.PI;
// FIXME: capitalize these functions
public static Box2i makeBox(int left, int top, int width, int height) {
public static Box2i MakeBox(int left, int top, int width, int height) {
return new Box2i(left, top, left + width, top + height);
}
public static Image<Rgba32> makeImage(float width, float height) {
public static Image<Rgba32> MakeImage(float width, float height) {
return new((int) Math.Ceiling(width), (int) Math.Ceiling(height));
}
public static Texture renderText(string text) {
return renderText(text, 16);
public static Texture RenderText(string text) {
return RenderText(text, 16);
}
public static Texture renderText(string text, int size) {
public static Texture RenderText(string text, int size) {
Font font = SystemFonts.CreateFont("Consolas", size, FontStyle.Bold);
TextOptions options = new(font);
FontRectangle rect = TextMeasurer.Measure(text, new TextOptions(font));
Image<Rgba32> image = makeImage(rect.Width, rect.Height);
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));
@ -282,9 +281,9 @@ public static class Util {
return texture;
}
public static Texture renderStar(float radius) {
public static Texture RenderStar(float radius) {
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<Rgba32> image = MakeImage(path.Bounds.Width, path.Bounds.Height);
image.Mutate(x => x.Fill(Color.White, path));
Texture texture = new Texture(image);
image.Dispose();
@ -469,7 +468,7 @@ 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);
Box2i photoBox = Util.MakeBox(center.X - renderSize.X / 2, center.Y - renderSize.Y / 2, renderSize.X, renderSize.Y);
DrawTexture(active, photoBox);
for (int i = 0; i < photos.Count && i < geometry.ThumbnailBoxes.Count(); i++) {
Box2i box = geometry.ThumbnailBoxes[i];
@ -480,8 +479,8 @@ public class Game : GameWindow {
}
}
if (photos[photoIndex].Loaded) {
Texture label = Util.renderText(String.Format("zoom: {0:F1}%", scale * 100));
DrawTexture(label, Util.makeBox(10, 10, label.Size.X, label.Size.Y));
Texture label = Util.RenderText(String.Format("zoom: {0:F1}%", scale * 100));
DrawTexture(label, Util.MakeBox(10, 10, label.Size.X, label.Size.Y));
label.Dispose();
}
@ -501,10 +500,10 @@ public class Game : GameWindow {
}
void DrawBox(Box2i box, int thickness, Color4 color) {
DrawTexture(TEXTURE_WHITE, Util.makeBox(box.Min.X, box.Min.Y, box.Size.X, thickness), color);
DrawTexture(TEXTURE_WHITE, Util.makeBox(box.Min.X, box.Min.Y, thickness, box.Size.Y), color);
DrawTexture(TEXTURE_WHITE, Util.makeBox(box.Min.X, box.Max.Y - thickness, box.Size.X, thickness), color);
DrawTexture(TEXTURE_WHITE, Util.makeBox(box.Max.X - thickness, box.Min.Y, thickness, box.Size.Y), color);
DrawTexture(TEXTURE_WHITE, Util.MakeBox(box.Min.X, box.Min.Y, box.Size.X, thickness), color);
DrawTexture(TEXTURE_WHITE, Util.MakeBox(box.Min.X, box.Min.Y, thickness, box.Size.Y), color);
DrawTexture(TEXTURE_WHITE, Util.MakeBox(box.Min.X, box.Max.Y - thickness, box.Size.X, thickness), color);
DrawTexture(TEXTURE_WHITE, Util.MakeBox(box.Max.X - thickness, box.Min.Y, thickness, box.Size.Y), color);
}
protected override void OnResize(ResizeEventArgs e) {

Loading…
Cancel
Save