1212#include "apps_spline.h"
1313
1414#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
1518
1619#define _apps_spline_pixmap (spline ) ((spline)->widget.window->pixmap)
1720
@@ -35,9 +38,9 @@ static void _init_control_point(apps_spline_t *spline)
3538 };
3639 const int init_point_cubic [4 ][2 ] = {
3740 {100 , 100 },
38- {300 , 300 },
39- {100 , 300 },
40- {300 , 100 },
41+ {280 , 280 },
42+ {100 , 280 },
43+ {280 , 100 },
4144 };
4245 const int (* init_point )[2 ];
4346 if (spline -> n_points == 4 ) {
@@ -59,7 +62,7 @@ static void _draw_aux_line(twin_path_t *path,
5962 twin_path_move (path , spline -> points [idx1 ].x , spline -> points [idx1 ].y );
6063 twin_path_draw (path , spline -> points [idx2 ].x , spline -> points [idx2 ].y );
6164 twin_paint_stroke (_apps_spline_pixmap (spline ), 0xc08000c0 , path ,
62- twin_int_to_fixed (2 ));
65+ twin_int_to_fixed (AUX_LINE_WIDTH ));
6366 twin_path_empty (path );
6467}
6568
@@ -84,7 +87,7 @@ static void _apps_spline_paint(apps_spline_t *spline)
8487 spline -> line_width );
8588 twin_path_set_cap_style (path , TwinCapButt );
8689 twin_paint_stroke (_apps_spline_pixmap (spline ), 0xffffff00 , path ,
87- twin_int_to_fixed (2 ));
90+ twin_int_to_fixed (BACKBONE_WIDTH ));
8891 twin_path_empty (path );
8992 if (spline -> n_points == 4 ) {
9093 _draw_aux_line (path , spline , 0 , 1 );
@@ -97,7 +100,7 @@ static void _apps_spline_paint(apps_spline_t *spline)
97100 for (int i = 0 ; i < spline -> n_points ; i ++ ) {
98101 twin_path_empty (path );
99102 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 ));
101104 twin_paint_path (_apps_spline_pixmap (spline ), 0x40004020 , path );
102105 }
103106 twin_path_destroy (path );
@@ -143,8 +146,8 @@ static int _apps_spline_hit(apps_spline_t *spline,
143146 & (spline -> transition ), spline -> points [i ].x , spline -> points [i ].y ));
144147 twin_fixed_t py = twin_sfixed_to_fixed (_twin_matrix_y (
145148 & (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 ) )
148151 return i ;
149152 }
150153 return -1 ;
0 commit comments