From d98a6e6123e7510aebd0debd08a0c2f3882bd27b Mon Sep 17 00:00:00 2001 From: lecoanet Date: Thu, 2 Oct 2003 12:29:44 +0000 Subject: Changed the CONICAL gradient parameters. If only one value is given it is taken for the gradient starting angle, the center being 0,0. If two values are given, they are taken as the gradient center, the starting angle being 0. If three values are given they are the gradient center followed by the gradient starting angle. If four values are given, they are two points defining the center and the angle/extent of the gradient (vector based definition). --- generic/Color.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'generic') diff --git a/generic/Color.c b/generic/Color.c index 4863b52..a395fa1 100644 --- a/generic/Color.c +++ b/generic/Color.c @@ -904,7 +904,7 @@ ZnGetGradient(Tcl_Interp *interp, scan_ptr += 7; type = ZN_CONICAL_GRADIENT; num_coords = ParseRealList(scan_ptr, next_ptr, coords, 4); - if ((num_coords != 1) && (num_coords != 3) && (num_coords != 4)) { + if ((num_coords < 1) && (num_coords > 4)) { goto grad_err3; } angle = (int) coords[0]; @@ -941,8 +941,22 @@ ZnGetGradient(Tcl_Interp *interp, simple = True; grad->num_colors_in = num_colors; grad->type = type; + grad->p.x = grad->p.y = grad->e.x = grad->e.y = 0.0; + switch (type) { case ZN_AXIAL_GRADIENT: + if ((num_coords == 4) && + ((coords[0] != coords[2]) || (coords[1] != coords[3]))) { + grad->p.x = coords[0]; + grad->p.y = coords[1]; + simple = False; + grad->e.x = coords[2]; + grad->e.y = coords[3]; + } + else { + grad->angle = (int) angle; + } + break; case ZN_CONICAL_GRADIENT: if ((num_coords == 4) && ((coords[0] != coords[2]) || (coords[1] != coords[3]))) { @@ -952,7 +966,12 @@ ZnGetGradient(Tcl_Interp *interp, grad->e.x = coords[2]; grad->e.y = coords[3]; } - else if ((type == ZN_CONICAL_GRADIENT) && (num_coords == 3)) { + else if (num_coords == 2) { + grad->p.x = coords[0]; + grad->p.y = coords[1]; + grad->angle = 0; + } + else if (num_coords == 3) { grad->p.x = coords[0]; grad->p.y = coords[1]; grad->angle = (int) coords[2]; -- cgit v1.1