12
12
#include "apps_spline.h"
13
13
14
14
#define D (x ) twin_double_to_fixed(x)
15
+ #define CONTROL_POINT_RADIUS 10
16
+ #define BACKBONE_WIDTH 2
17
+ #define AUX_LINE_WIDTH 2
15
18
16
19
#define _apps_spline_pixmap (spline ) ((spline)->widget.window->pixmap)
17
20
@@ -35,9 +38,9 @@ static void _init_control_point(apps_spline_t *spline)
35
38
};
36
39
const int init_point_cubic [4 ][2 ] = {
37
40
{100 , 100 },
38
- {300 , 300 },
39
- {100 , 300 },
40
- {300 , 100 },
41
+ {280 , 280 },
42
+ {100 , 280 },
43
+ {280 , 100 },
41
44
};
42
45
const int (* init_point )[2 ];
43
46
if (spline -> n_points == 4 ) {
@@ -59,7 +62,7 @@ static void _draw_aux_line(twin_path_t *path,
59
62
twin_path_move (path , spline -> points [idx1 ].x , spline -> points [idx1 ].y );
60
63
twin_path_draw (path , spline -> points [idx2 ].x , spline -> points [idx2 ].y );
61
64
twin_paint_stroke (_apps_spline_pixmap (spline ), 0xc08000c0 , path ,
62
- twin_int_to_fixed (2 ));
65
+ twin_int_to_fixed (AUX_LINE_WIDTH ));
63
66
twin_path_empty (path );
64
67
}
65
68
@@ -84,7 +87,7 @@ static void _apps_spline_paint(apps_spline_t *spline)
84
87
spline -> line_width );
85
88
twin_path_set_cap_style (path , TwinCapButt );
86
89
twin_paint_stroke (_apps_spline_pixmap (spline ), 0xffffff00 , path ,
87
- twin_int_to_fixed (2 ));
90
+ twin_int_to_fixed (BACKBONE_WIDTH ));
88
91
twin_path_empty (path );
89
92
if (spline -> n_points == 4 ) {
90
93
_draw_aux_line (path , spline , 0 , 1 );
@@ -97,7 +100,7 @@ static void _apps_spline_paint(apps_spline_t *spline)
97
100
for (int i = 0 ; i < spline -> n_points ; i ++ ) {
98
101
twin_path_empty (path );
99
102
twin_path_circle (path , spline -> points [i ].x , spline -> points [i ].y ,
100
- twin_int_to_fixed (10 ));
103
+ twin_int_to_fixed (CONTROL_POINT_RADIUS ));
101
104
twin_paint_path (_apps_spline_pixmap (spline ), 0x40004020 , path );
102
105
}
103
106
twin_path_destroy (path );
@@ -143,8 +146,8 @@ static int _apps_spline_hit(apps_spline_t *spline,
143
146
& (spline -> transition ), spline -> points [i ].x , spline -> points [i ].y ));
144
147
twin_fixed_t py = twin_sfixed_to_fixed (_twin_matrix_y (
145
148
& (spline -> transition ), spline -> points [i ].x , spline -> points [i ].y ));
146
- if (twin_fixed_abs (x - px ) < spline -> line_width / 2 &&
147
- twin_fixed_abs (y - py ) < spline -> line_width / 2 )
149
+ if (twin_fixed_abs (x - px ) < twin_int_to_fixed ( CONTROL_POINT_RADIUS ) &&
150
+ twin_fixed_abs (y - py ) < twin_int_to_fixed ( CONTROL_POINT_RADIUS ) )
148
151
return i ;
149
152
}
150
153
return -1 ;
0 commit comments