mirror of https://github.com/GNOME/gimp.git
app: change the unit of angles in the draw tool's draw_arc() functions
from the weird X 1/64 of a degree to radian.
This commit is contained in:
parent
df44ced093
commit
02924e1e70
|
@ -518,22 +518,19 @@ gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height,
|
gdouble height,
|
||||||
gint angle1,
|
gdouble start_angle,
|
||||||
gint angle2)
|
gdouble slice_angle)
|
||||||
{
|
{
|
||||||
GimpCanvasItem *item;
|
GimpCanvasItem *item;
|
||||||
gdouble a1, a2;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
|
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
|
||||||
|
|
||||||
a1 = (gdouble) angle1 / 64.0 / 180.0 * G_PI;
|
|
||||||
a2 = (gdouble) angle2 / 64.0 / 180.0 * G_PI;
|
|
||||||
|
|
||||||
item = gimp_canvas_arc_new (x + width / 2.0,
|
item = gimp_canvas_arc_new (x + width / 2.0,
|
||||||
y + height / 2.0,
|
y + height / 2.0,
|
||||||
width / 2.0,
|
width / 2.0,
|
||||||
height / 2.0,
|
height / 2.0,
|
||||||
a1, a2,
|
start_angle,
|
||||||
|
slice_angle,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
gimp_draw_tool_add_item (draw_tool, item);
|
gimp_draw_tool_add_item (draw_tool, item);
|
||||||
|
@ -547,12 +544,11 @@ gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
gint width,
|
gint width,
|
||||||
gint height,
|
gint height,
|
||||||
gint angle1,
|
gdouble start_angle,
|
||||||
gint angle2,
|
gdouble slice_angle,
|
||||||
GtkAnchorType anchor)
|
GtkAnchorType anchor)
|
||||||
{
|
{
|
||||||
GimpCanvasItem *item;
|
GimpCanvasItem *item;
|
||||||
gdouble a1, a2;
|
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
|
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
|
||||||
|
|
||||||
|
@ -561,10 +557,8 @@ gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
|
||||||
GIMP_HANDLE_CIRCLE,
|
GIMP_HANDLE_CIRCLE,
|
||||||
anchor, x, y, width, height);
|
anchor, x, y, width, height);
|
||||||
|
|
||||||
a1 = (gdouble) angle1 / 64.0 / 180.0 * G_PI;
|
gimp_canvas_handle_set_angles (GIMP_CANVAS_HANDLE (item),
|
||||||
a2 = (gdouble) angle2 / 64.0 / 180.0 * G_PI;
|
start_angle, slice_angle);
|
||||||
|
|
||||||
gimp_canvas_handle_set_angles (GIMP_CANVAS_HANDLE (item), a1, a2);
|
|
||||||
|
|
||||||
gimp_draw_tool_add_item (draw_tool, item);
|
gimp_draw_tool_add_item (draw_tool, item);
|
||||||
g_object_unref (item);
|
g_object_unref (item);
|
||||||
|
|
|
@ -114,8 +114,8 @@ void gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
gdouble width,
|
gdouble width,
|
||||||
gdouble height,
|
gdouble height,
|
||||||
gint angle1,
|
gdouble start_angle,
|
||||||
gint angle2);
|
gdouble slice_angle);
|
||||||
|
|
||||||
void gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
|
void gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
|
||||||
gboolean filled,
|
gboolean filled,
|
||||||
|
@ -123,8 +123,8 @@ void gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
gint width,
|
gint width,
|
||||||
gint height,
|
gint height,
|
||||||
gint angle1,
|
gdouble start_angle,
|
||||||
gint angle2,
|
gdouble slice_angle,
|
||||||
GtkAnchorType anchor);
|
GtkAnchorType anchor);
|
||||||
|
|
||||||
void gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
|
void gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
|
||||||
|
|
|
@ -114,7 +114,7 @@ gimp_ellipse_select_tool_draw (GimpDrawTool *draw_tool)
|
||||||
FALSE,
|
FALSE,
|
||||||
x1, y1,
|
x1, y1,
|
||||||
x2 - x1, y2 - y1,
|
x2 - x1, y2 - y1,
|
||||||
0, 360 * 64);
|
0.0, 2 * G_PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -614,7 +614,8 @@ gimp_foreground_select_tool_draw (GimpDrawTool *draw_tool)
|
||||||
|
|
||||||
gimp_draw_tool_draw_arc (draw_tool, FALSE,
|
gimp_draw_tool_draw_arc (draw_tool, FALSE,
|
||||||
x - radius, y - radius,
|
x - radius, y - radius,
|
||||||
2 * radius, 2 * radius, 0, 360 * 64);
|
2 * radius, 2 * radius,
|
||||||
|
0.0, 2.0 * G_PI);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -663,7 +663,6 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
|
||||||
GimpMeasureTool *measure = GIMP_MEASURE_TOOL (draw_tool);
|
GimpMeasureTool *measure = GIMP_MEASURE_TOOL (draw_tool);
|
||||||
GimpTool *tool = GIMP_TOOL (draw_tool);
|
GimpTool *tool = GIMP_TOOL (draw_tool);
|
||||||
gint i;
|
gint i;
|
||||||
gint angle1, angle2;
|
|
||||||
gint draw_arc = 0;
|
gint draw_arc = 0;
|
||||||
|
|
||||||
for (i = 0; i < measure->num_points; i++)
|
for (i = 0; i < measure->num_points; i++)
|
||||||
|
@ -711,15 +710,16 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
|
||||||
|
|
||||||
if (measure->num_points > 1 && draw_arc == measure->num_points - 1)
|
if (measure->num_points > 1 && draw_arc == measure->num_points - 1)
|
||||||
{
|
{
|
||||||
angle1 = measure->angle2 * 64.0;
|
gdouble angle1 = measure->angle2 / 180.0 * G_PI;
|
||||||
angle2 = (measure->angle1 - measure->angle2) * 64.0;
|
gdouble angle2 = (measure->angle1 - measure->angle2) / 180.0 * G_PI;
|
||||||
|
|
||||||
if (angle2 > 11520)
|
if (angle2 > G_PI)
|
||||||
angle2 -= 23040;
|
angle2 -= 2.0 * G_PI;
|
||||||
if (angle2 < -11520)
|
|
||||||
angle2 += 23040;
|
|
||||||
|
|
||||||
if (angle2 != 0)
|
if (angle2 < -G_PI)
|
||||||
|
angle2 += 2.0 * G_PI;
|
||||||
|
|
||||||
|
if (angle2 != 0.0)
|
||||||
{
|
{
|
||||||
gimp_draw_tool_draw_arc_by_anchor (draw_tool,
|
gimp_draw_tool_draw_arc_by_anchor (draw_tool,
|
||||||
FALSE,
|
FALSE,
|
||||||
|
|
|
@ -313,22 +313,22 @@ gimp_rectangle_select_tool_draw (GimpDrawTool *draw_tool)
|
||||||
gimp_draw_tool_draw_arc (draw_tool, FALSE,
|
gimp_draw_tool_draw_arc (draw_tool, FALSE,
|
||||||
x1, y1,
|
x1, y1,
|
||||||
square_size, square_size,
|
square_size, square_size,
|
||||||
90 * 64, 90 * 64);
|
G_PI / 2.0, G_PI / 2.0);
|
||||||
|
|
||||||
gimp_draw_tool_draw_arc (draw_tool, FALSE,
|
gimp_draw_tool_draw_arc (draw_tool, FALSE,
|
||||||
x2 - square_size, y1,
|
x2 - square_size, y1,
|
||||||
square_size, square_size,
|
square_size, square_size,
|
||||||
0, 90 * 64);
|
0.0, G_PI / 2.0);
|
||||||
|
|
||||||
gimp_draw_tool_draw_arc (draw_tool, FALSE,
|
gimp_draw_tool_draw_arc (draw_tool, FALSE,
|
||||||
x2 - square_size, y2 - square_size,
|
x2 - square_size, y2 - square_size,
|
||||||
square_size, square_size,
|
square_size, square_size,
|
||||||
270 * 64, 90 * 64);
|
G_PI * 1.5, G_PI / 2.0);
|
||||||
|
|
||||||
gimp_draw_tool_draw_arc (draw_tool, FALSE,
|
gimp_draw_tool_draw_arc (draw_tool, FALSE,
|
||||||
x1, y2 - square_size,
|
x1, y2 - square_size,
|
||||||
square_size, square_size,
|
square_size, square_size,
|
||||||
180 * 64, 90 * 64);
|
G_PI, G_PI / 2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_rectangle_tool_draw (draw_tool);
|
gimp_rectangle_tool_draw (draw_tool);
|
||||||
|
|
Loading…
Reference in New Issue