diff -urN wf-/data.c wf/data.c --- wf-/data.c Wed Jan 13 00:00:00 2016 +++ wf/data.c Sun Jan 17 00:00:00 2016 @@ -19,6 +19,7 @@ CASE_RET(type_circle); CASE_RET(type_circle_y); CASE_RET(type_circle_x); + CASE_RET(type_curve); CASE_RET(type_ball); CASE_RET(type_arc); CASE_RET(type_octahedron); @@ -303,6 +304,31 @@ } static void +curve_draw(struct curve *cv, prm_t *prm) +{ + int i, n = cv->n; + d3_t p[256*2]; + int odr[256+3]; + data_t data = { + type_wire_frame, + &(struct wire_frame){ n, cv->ps, odr, p, &p[n] } + }; + data_t op = { + type_rdiv, + &(struct rdiv){ cv->div_n, 1 } + }; + + if(cv->n > 256) ERR("cv->n > 256"); + + for(i=0; iclosed) odr[i++] = 0; + odr[i] = odr[i+1] = -1; + + if(cv->div_n <= 0) data_draw(&data, prm); + else op_data_draw(&op, &data, prm); +} + +static void ball_draw(struct ball *ball, prm_t *prm) { data_t op = { type_arr, (data_t[]){ @@ -421,6 +447,9 @@ break; case type_circle_x: circle_x_draw(data->p, prm); + break; + case type_curve: + curve_draw(data->p, prm); break; case type_ball: ball_draw(data->p, prm); diff -urN wf-/data.h wf/data.h --- wf-/data.h Wed Jan 13 00:00:00 2016 +++ wf/data.h Sun Jan 17 00:00:00 2016 @@ -21,6 +21,7 @@ #define type_circle 5 #define type_circle_y 21 #define type_circle_x 22 +#define type_curve 30 #define type_ball 6 #define type_arc 7 @@ -80,6 +81,13 @@ struct circle{ double r; int n; +}; + +struct curve{ + int n; + pos_t *ps; + int closed; + int div_n; }; struct ball{ diff -urN wf-/wf_ex.c wf/wf_ex.c --- wf-/wf_ex.c Sat Jan 16 00:00:00 2016 +++ wf/wf_ex.c Sun Jan 17 00:00:00 2016 @@ -411,6 +411,14 @@ { type_end } }}, .data = { type_cube } }}; + data_t *rail1 = &(data_t){ type_op_data_set, &(struct op_data_set){ + .op = { type_slide, &(d3_t){0,-4*a,0} }, + .data = { type_curve, &(struct curve){.n=rail->n,.ps=rail->ps,.closed=1,.div_n=10} } }}; + + data_t *rail2 = &(data_t){ type_op_data_set, &(struct op_data_set){ + .op = { type_slide, &(d3_t){0,-4*a,-a*0.5} }, + .data = { type_curve, &(struct curve){.n=rail->n,.ps=rail->ps,.closed=1,.div_n=0} } }}; + data_t *matryoshka = &(data_t){ type_op_data_set, &(struct op_data_set){ .op = { type_arr, (data_t[]){ { type_slide, &(d3_t){20,20,20} }, @@ -504,7 +512,7 @@ *exile, *lissajours, *half_pipe, *fireworks, - *train, + *train, *rail1, *rail2, *matryoshka, *clock, *ripple, *wave,