aboutsummaryrefslogtreecommitdiff
path: root/generic/Arc.c
diff options
context:
space:
mode:
authorlecoanet2002-03-15 14:11:35 +0000
committerlecoanet2002-03-15 14:11:35 +0000
commit3d4ee44e88120a74d95b9daf03485c2f781c3656 (patch)
tree3fb4180bf155eac52402b07e7ed154bcbcb6bda9 /generic/Arc.c
parente03a3e417c3b889ff66b4eb64d6731995adf6f91 (diff)
downloadtkzinc-3d4ee44e88120a74d95b9daf03485c2f781c3656.zip
tkzinc-3d4ee44e88120a74d95b9daf03485c2f781c3656.tar.gz
tkzinc-3d4ee44e88120a74d95b9daf03485c2f781c3656.tar.bz2
tkzinc-3d4ee44e88120a74d95b9daf03485c2f781c3656.tar.xz
Traitement centralis� des images.
Correction d'un bug qui empechait de dessiner les arcs pleins correctement. GetCirclePoints traite les arcs dont l'angle de fin coincide avec l'angle de d�but comme complets alors que l'item utilise un extent de 360. Ajustement des couleurs par d�faut pour tenir compte de la g�n�ralisation des gradients.
Diffstat (limited to 'generic/Arc.c')
-rw-r--r--generic/Arc.c48
1 files changed, 19 insertions, 29 deletions
diff --git a/generic/Arc.c b/generic/Arc.c
index c65a4f1..253aaef 100644
--- a/generic/Arc.c
+++ b/generic/Arc.c
@@ -225,8 +225,8 @@ Init(Item item,
(*args)++;
(*argc)--;
- arc->fill_color = ZnGetGradientByValue(wi->fore_gradient);
- arc->line_color = ZnGetGradientByValue(wi->fore_gradient);
+ arc->fill_color = ZnGetGradientByValue(wi->fore_color);
+ arc->line_color = ZnGetGradientByValue(wi->fore_color);
return ZN_OK;
}
@@ -247,7 +247,7 @@ Clone(Item item)
char *text;
arc->grad_geo = NULL;
- if (strlen(arc->tile_name) != 0) {
+ if (arc->tile != ZnUnspecifiedImage) {
text = ZnMalloc((strlen(arc->tile_name) + 1) * sizeof(char));
strcpy(text, arc->tile_name);
arc->tile_name = text;
@@ -353,33 +353,16 @@ Configure(Item item,
Tcl_Obj *CONST argv[],
int *flags)
{
- WidgetInfo *wi = item->wi;
ArcItem arc = (ArcItem) item;
int status = ZN_OK;
status = ITEM_P.ConfigureAttributes((char *) item, -1, argc, argv, flags);
if (ISSET(*flags, ZN_TILE_FLAG)) {
- Tk_Image tile;
-
- if (strcmp(arc->tile_name, "") != 0) {
- tile = Tk_GetImage(wi->interp, wi->win, arc->tile_name,
- ArcTileChange, (ClientData) arc);
- if (tile == NULL) {
- /*
- * The name will not be in sync with the image in
- * this case.
- */
- status = ZN_ERROR;
- }
+ if (ValidateImage(item->wi, item, arc->tile_name, ArcTileChange,
+ &arc->tile, "arc -tile") == ZN_ERROR) {
+ status = ZN_ERROR;
}
- else {
- tile = ZnUnspecifiedImage;
- }
- if (arc->tile != ZnUnspecifiedImage) {
- Tk_FreeImage(arc->tile);
- }
- arc->tile = tile;
}
SetRenderFlags(arc);
@@ -480,13 +463,16 @@ UpdateRenderShape(ArcItem arc)
{
ZnPoint *p_list, p, p2, o, o2;
ZnReal width, height, d;
- int num_p, i, quality;
+ int num_p, i, quality, extent;
ZnTransfo *t = ((Item) arc)->wi->current_transfo;
if (!arc->render_shape) {
arc->render_shape = ZnListNew(8, sizeof(ZnPoint));
}
-
+ extent = arc->angle_extent;
+ if (extent == 360) {
+ extent = 0;
+ }
o.x = (arc->coords[1].x + arc->coords[0].x)/2.0;
o.y = (arc->coords[1].y + arc->coords[0].y)/2.0;
width = (arc->coords[1].x - arc->coords[0].x)/2.0;
@@ -496,7 +482,7 @@ UpdateRenderShape(ArcItem arc)
p_list = GetCirclePoints(ISCLEAR(arc->flags, PIE_SLICE_BIT) ? 1 : 2,
quality,
DegreesToRadian(arc->start_angle),
- DegreesToRadian(arc->start_angle+arc->angle_extent),
+ DegreesToRadian(arc->start_angle+extent),
&num_p,
arc->render_shape);
@@ -521,7 +507,7 @@ UpdateRenderShape(ArcItem arc)
p_list = GetCirclePoints(ISCLEAR(arc->flags, PIE_SLICE_BIT) ? 1 : 2,
quality,
DegreesToRadian(arc->start_angle),
- DegreesToRadian(arc->start_angle+arc->angle_extent),
+ DegreesToRadian(arc->start_angle+extent),
&num_p,
arc->render_shape);
}
@@ -1624,16 +1610,20 @@ static void
UpdateRenderShapeX(ArcItem arc)
{
ZnReal ox, oy, width_2, height_2;
- int i, num_p;
+ int i, num_p, extent;
ZnPoint *p_list;
if (!arc->render_shape) {
arc->render_shape = ZnListNew(8, sizeof(ZnPoint));
}
+ extent = arc->angle_extent;
+ if (extent == 360) {
+ extent = 0;
+ }
p_list = GetCirclePoints(ISCLEAR(arc->flags, PIE_SLICE_BIT) ? 1 : 2,
ZN_CIRCLE_FINE,
DegreesToRadian(arc->start_angle),
- DegreesToRadian(arc->start_angle+arc->angle_extent),
+ DegreesToRadian(arc->start_angle+extent),
&num_p, arc->render_shape);
ox = (arc->corner.x + arc->orig.x) / 2.0;
oy = (arc->corner.y + arc->orig.y) / 2.0;