diff --git a/aegisub/src/visual_tool_rotatexy.cpp b/aegisub/src/visual_tool_rotatexy.cpp index 7df36e07a..0677b00ff 100644 --- a/aegisub/src/visual_tool_rotatexy.cpp +++ b/aegisub/src/visual_tool_rotatexy.cpp @@ -49,20 +49,30 @@ void VisualToolRotateXY::Draw() { float g = colour[0].Green() / 255.f; float b = colour[0].Blue() / 255.f; - std::vector colors(11 * 8 * 4); - for (int i = 0; i < 88; ++i) { + // Number of lines on each side of each axis + static const int radius = 5; + // Total number of lines, including center axis line + static const int line_count = radius * 2 + 1; + // Distance between each line in pixels + static const int spacing = 20; + // Length of each grid line in pixels from axis to one end + static const int half_line_length = spacing * (radius + 1); + static const float fade_factor = 0.9f / radius; + + std::vector colors(line_count * 8 * 4); + for (int i = 0; i < line_count * 8; ++i) { colors[i * 4 + 0] = r; colors[i * 4 + 1] = g; colors[i * 4 + 2] = b; - colors[i * 4 + 3] = (i + 3) % 4 > 1 ? 0 : (1.f - abs(i / 8 - 5) * 0.18f); + colors[i * 4 + 3] = (i + 3) % 4 > 1 ? 0 : (1.f - abs(i / 8 - radius) * fade_factor); } - std::vector points(11 * 8 * 2); - for (int i = 0; i < 11; ++i) { - int pos = 20 * (i - 5); + std::vector points(line_count * 8 * 2); + for (int i = 0; i < line_count; ++i) { + int pos = spacing * (i - radius); points[i * 16 + 0] = pos; - points[i * 16 + 1] = 120; + points[i * 16 + 1] = half_line_length; points[i * 16 + 2] = pos; points[i * 16 + 3] = 0; @@ -71,9 +81,9 @@ void VisualToolRotateXY::Draw() { points[i * 16 + 5] = 0; points[i * 16 + 6] = pos; - points[i * 16 + 7] = -120; + points[i * 16 + 7] = -half_line_length; - points[i * 16 + 8] = 120; + points[i * 16 + 8] = half_line_length; points[i * 16 + 9] = pos; points[i * 16 + 10] = 0; @@ -82,7 +92,7 @@ void VisualToolRotateXY::Draw() { points[i * 16 + 12] = 0; points[i * 16 + 13] = pos; - points[i * 16 + 14] = -120; + points[i * 16 + 14] = -half_line_length; points[i * 16 + 15] = pos; }