Ejemplo n.º 1
0
/* Draw the marker that indicates where the black point is */
static void drawBlackMarker(GdkDrawable *drawable, GtkWidget *greyramp)
{
  GreyrampProperties *properties = greyrampGetProperties(greyramp);
  DotterContext *dc = properties->dwc->dotterCtx;

  GdkRectangle markerRect;
  getBlackMarkerRect(properties, &markerRect);
  
  /* Draw a triangle. Line color is the 'selected' color if dragging */
  GdkColor *fillColor = getGdkColor(DOTCOLOR_MARKER_FILL, dc->defaultColors, FALSE, properties->dwc->usePrintColors);
  GdkColor *lineColor = getGdkColor(DOTCOLOR_MARKER_LINE, dc->defaultColors, properties->draggingBlack, properties->dwc->usePrintColors);
  
  int numPoints = 3;
  GdkPoint points[numPoints];
  points[0].x = markerRect.x + (markerRect.width / 2);
  points[0].y = markerRect.y;
  points[1].x = markerRect.x;
  points[1].y = markerRect.y + markerRect.height;
  points[2].x = markerRect.x + markerRect.width;
  points[2].y = markerRect.y + markerRect.height;
  
  /* Draw fill in white and line in black (or green if dragging) */
  GdkGC *gc = gdk_gc_new(drawable);
  
  gdk_gc_set_foreground(gc, fillColor);
  gdk_draw_polygon(drawable, gc, TRUE, points, numPoints);
  gdk_gc_set_foreground(gc, lineColor);
  gdk_draw_polygon(drawable, gc, FALSE, points, numPoints);
  
  g_object_unref(gc);
}
Ejemplo n.º 2
0
static void 
draw_polygon (DiaRenderer *object, Point *points, int num_points,
	      Color *fill, Color *stroke)
{
  DiaGdkRenderer *renderer = DIA_GDK_RENDERER (object);
  GdkGC *gc = renderer->gc;
  GdkColor color;
  GdkPoint *gdk_points;
  int i,x,y;

  gdk_points = g_new(GdkPoint, num_points);

  for (i=0;i<num_points;i++) {
    dia_transform_coords(renderer->transform, points[i].x, points[i].y, &x, &y);
    gdk_points[i].x = x;
    gdk_points[i].y = y;
  }

  if (fill && fill->alpha > 0.0) {
    renderer_color_convert(renderer, fill, &color);
    gdk_gc_set_foreground(gc, &color);
  
    gdk_draw_polygon(renderer->pixmap, gc, TRUE, gdk_points, num_points);
  }
  if (stroke && stroke->alpha > 0.0) {
    renderer_color_convert(renderer, stroke, &color);
    gdk_gc_set_foreground(gc, &color);
  
    gdk_draw_polygon(renderer->pixmap, gc, FALSE, gdk_points, num_points);
  }
  g_free(gdk_points);
}
Ejemplo n.º 3
0
static void
draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
{
	if (gr->mode == draw_mode_begin || gr->mode == draw_mode_end)
		gdk_draw_polygon(gr->drawable, gc->gc, TRUE, (GdkPoint *)p, count);
	if (gr->mode == draw_mode_end || gr->mode == draw_mode_cursor)
		gdk_draw_polygon(gr->widget->window, gc->gc, TRUE, (GdkPoint *)p, count);
}
Ejemplo n.º 4
0
static void
gwy_hmarker_box_draw_marker(GwyMarkerBox *mbox,
                            gint i)
{
    GtkWidget *widget;
    GtkStateType state, gcstate;
    gboolean ghost, selected;
    GdkPoint points[3];
    gint height, width;
    gdouble pos;
    gint iw, ipos;

    widget = GTK_WIDGET(mbox);
    state = GTK_WIDGET_STATE(widget);
    width = widget->allocation.width;
    height = widget->allocation.height;

    selected = (i == mbox->selected);
    ghost = selected && mbox->ghost;
    selected = selected && mbox->highlight;
    pos = g_array_index(mbox->markers, gdouble, i);

    if (ghost)
        gcstate = GTK_STATE_INSENSITIVE;
    else if (state == GTK_STATE_INSENSITIVE)
        gcstate = state;
    else
        gcstate = GTK_STATE_NORMAL;

    ipos = GWY_ROUND(pos*(width - 1));
    iw = MAX(GWY_ROUND(height/GWY_SQRT3 - 1), 1);
    points[0].x = ipos - iw;
    points[1].x = ipos + iw;
    points[2].x = ipos;
    if (mbox->flipped) {
        points[0].y = 0;
        points[1].y = 0;
        points[2].y = height-1;
    }
    else {
        points[0].y = height-1;
        points[1].y = height-1;
        points[2].y = 0;
    }
    if (selected && !ghost)
        gdk_draw_polygon(widget->window,
                         widget->style->bg_gc[GTK_STATE_SELECTED],
                         TRUE, points, G_N_ELEMENTS(points));
    else
        gdk_draw_polygon(widget->window, widget->style->text_gc[gcstate],
                         TRUE, points, G_N_ELEMENTS(points));

    gdk_draw_polygon(widget->window, widget->style->fg_gc[gcstate],
                     FALSE, points, G_N_ELEMENTS(points));
}
Ejemplo n.º 5
0
Archivo: cdgdk.c Proyecto: LuaDist/cd
static void cdpoly(cdCtxCanvas *ctxcanvas, int mode, cdPoint* poly, int n)
{
  int i;

  if (mode != CD_BEZIER && mode != CD_PATH)
  {
    for (i = 0; i < n; i++)
    {
      if (ctxcanvas->canvas->use_matrix)
        cdMatrixTransformPoint(ctxcanvas->xmatrix, poly[i].x, poly[i].y, &(poly[i].x), &(poly[i].y));
    }
  }

  switch( mode )
  {
  case CD_FILL:
    if (ctxcanvas->canvas->new_region)
    {
      GdkRegion* rgn = gdk_region_polygon((GdkPoint*)poly, n, ctxcanvas->canvas->fill_mode == CD_EVENODD ? GDK_EVEN_ODD_RULE : GDK_WINDING_RULE);
      sCombineRegion(ctxcanvas, rgn);
    }
    else
      gdk_draw_polygon(ctxcanvas->wnd, ctxcanvas->gc, TRUE, (GdkPoint*)poly, n);
    break;

  case CD_CLOSED_LINES:
    cdgdkCheckSolidStyle(ctxcanvas, 1);
    gdk_draw_polygon(ctxcanvas->wnd, ctxcanvas->gc, FALSE, (GdkPoint*)poly, n);
    cdgdkCheckSolidStyle(ctxcanvas, 0);
    break;

  case CD_OPEN_LINES:
    cdgdkCheckSolidStyle(ctxcanvas, 1);
    gdk_draw_lines(ctxcanvas->wnd, ctxcanvas->gc, (GdkPoint*)poly, n);
    cdgdkCheckSolidStyle(ctxcanvas, 0);
    break;

  case CD_CLIP:
    ctxcanvas->clip_rgn = gdk_region_polygon((GdkPoint*)poly, n, ctxcanvas->canvas->fill_mode == CD_EVENODD ? GDK_EVEN_ODD_RULE : GDK_WINDING_RULE);     
    if (ctxcanvas->canvas->clip_mode == CD_CLIPPOLYGON)
      cdclip(ctxcanvas, CD_CLIPPOLYGON);
    break;

  case CD_BEZIER:
    cdSimPolyBezier(ctxcanvas->canvas, poly, n);
    break;

  case CD_PATH:
    cdSimPolyPath(ctxcanvas->canvas, poly, n);
    break;
  }
}
Ejemplo n.º 6
0
/*----------------------------------------------------------------------------*/
void viewPaint3DBlock(GtkWidget* widget, char block, GdkRectangle* rect)
{
	//g_message("block = %d", block);
	GdkPoint pts[6];
	int ind = rect->width / 8;
	pts[0].x = rect->x;
	pts[0].y = rect->y + rect->height;

	pts[1].x = rect->x;
	pts[1].y = rect->y;

	pts[2].x = rect->x + rect->width;
	pts[2].y = rect->y;

	pts[3].x = rect->x + rect->width - ind;
	pts[3].y = rect->y + ind;

	pts[4].x = rect->x + ind;
	pts[4].y = rect->y + ind;

	pts[5].x = rect->x + ind;
	pts[5].y = rect->y + rect->height - ind;
 	gdk_draw_polygon(pixmap,
                     gc[(block-1)%13][0],
                     TRUE,
                     pts,
                     6);
 
	gdk_draw_rectangle(pixmap,
                       gc[(block-1)%13][1],
                       TRUE,
                       rect->x+ind,
                       rect->y+ind,
                       rect->width-ind-ind,
                       rect->height-ind-ind);

	pts[1].x = rect->x + rect->width;
	pts[1].y = rect->y + rect->height;

	pts[4].x = rect->x + rect->width - ind;
	pts[4].y = rect->y + rect->height - ind;

	//g_message("block2 = %d", block);
	gdk_draw_polygon(pixmap,
                     gc[(block-1)%13][2],
                     TRUE,
                     pts,
                     6);
}
Ejemplo n.º 7
0
/*----------------------------------------------------------------------------*/
void viewPaintPyrimidBlock(GtkWidget* widget, char block, GdkRectangle* rect)
{
	GdkPoint pts[4];

	pts[0].x = rect->x;
	pts[0].y = rect->y;

	pts[1].x = rect->x;
	pts[1].y = rect->y+rect->height;

	pts[2].x = rect->x + rect->width;
	pts[2].y = rect->y;

	pts[3].x = rect->x + rect->width;
	pts[3].y = rect->y + rect->height;
	gdk_draw_polygon(pixmap,
                     gc[(block-1)%13][1],
                     TRUE,
                     pts,
                     4);

	int mid = rect->width / 2;

	pts[1].x = rect->x + mid;
	pts[1].y = rect->y + mid;

	pts[2].x = rect->x + rect->width-1;
	gdk_draw_polygon(pixmap,
                     gc[(block-1)%13][0],
                     TRUE,
                     pts,
                     3);

	pts[0].x = rect->x+1;
	pts[0].y = rect->y + rect->height;

	pts[1].x = rect->x + rect->width;
	pts[1].y = rect->y + rect->height;

	pts[2].x = rect->x + rect->width - mid;
	pts[2].y = rect->y + rect->height - mid;

	gdk_draw_polygon(pixmap,
                     gc[(block-1)%13][2],
                     TRUE,
                     pts,
                     3);
}
Ejemplo n.º 8
0
void _HYPlatformGraphicPane::_FillPolygon (Ptr rgn)
{
    if (rgn) {
        _HYGDK_Polygon * thePoly = (_HYGDK_Polygon *)rgn;
        gdk_draw_polygon (thePane, theContext, true, thePoly->thePoints, thePoly->pointCount);
    }
}
Ejemplo n.º 9
0
static void set_foreground(GdkColor *color, int status)
{
    int i, num;
    GdkPoint *p;
    int num_app_shells = get_num_shells();
    GdkGC *app_gc = get_toplevel();

    num = numpoints[status];
    p = polyptr[status];

    if (num) {
        gdk_gc_set_rgb_fg_color(app_gc, color);
        for (i = 0; i < num_app_shells; i++) {
            tape_status_widget *ts = &app_shells[i].tape_status;
            if (ts) {
                gdk_draw_polygon(ts->control_pixmap, app_gc, TRUE, p, num);
                gtk_widget_queue_draw(ts->control);
            }
        }
    } else {
        gdk_gc_set_rgb_fg_color(app_gc, &drive_led_on_red_pixel);
        for (i = 0; i < num_app_shells; i++) {
            tape_status_widget *ts = &app_shells[i].tape_status;
            if (ts) {
                gdk_draw_arc(ts->control_pixmap, app_gc, TRUE, 3, 1, CTRL_WIDTH - 6, CTRL_HEIGHT - 2, 0, 360 * 64);
                gtk_widget_queue_draw(ts->control);
            }
        }
    }
}
Ejemplo n.º 10
0
void _HYPlatformGraphicPane::_DrawPolygon (Ptr rgn, long width)
{
    if (rgn) {
        gdk_gc_set_line_attributes (theContext, width, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
        _HYGDK_Polygon * thePoly = (_HYGDK_Polygon *)rgn;
        gdk_draw_polygon (thePane, theContext, false, thePoly->thePoints, thePoly->pointCount);
    }
}
Ejemplo n.º 11
0
/* This function is based on a portion of EnGradient's draw_box */
void
draw_default_triangle(GtkStyle * style,
	              GdkWindow * window,
	              GtkStateType state_type,
	              GtkShadowType shadow_type,
	              GdkRectangle * area,
	              GtkWidget * widget,
	              const gchar * detail,
		      gint x,
		      gint y,
		      gint width,
		      gint height)
{
  GdkPoint points1[3]; /* dark */
  GdkPoint points2[3]; /* light */
  
  points1[0].x = x+2;  points1[0].y = y+2;
  points1[1].x = x+10; points1[1].y = y+2;
  points1[2].x = x+2;  points1[2].y = y+10;
  points2[0].x = x+3;  points2[0].y = y+3;
  points2[1].x = x+10; points2[1].y = y+3;
  points2[2].x = x+3;  points2[2].y = y+10;

   if (area) {
     gdk_gc_set_clip_rectangle(style->bg_gc[state_type], area);
     gdk_gc_set_clip_rectangle(style->light_gc[state_type], area);
     gdk_gc_set_clip_rectangle(style->dark_gc[state_type], area);
   } 
	
   /* Paint a triangle here instead of in "buttondefault"
      which is drawn _behind_ the current button */
   if (GTK_WIDGET_HAS_DEFAULT (widget)) {
     gdk_draw_polygon(window, style->dark_gc[state_type], FALSE, points1, 3);
     gdk_draw_polygon(window, style->light_gc[state_type], FALSE, points2, 3);
     gdk_draw_polygon(window, style->bg_gc[GTK_STATE_SELECTED], TRUE, points2, 3);
   }

   if (area) {
     gdk_gc_set_clip_rectangle(style->bg_gc[state_type], NULL);
     gdk_gc_set_clip_rectangle(style->light_gc[state_type], NULL);
     gdk_gc_set_clip_rectangle(style->dark_gc[state_type], NULL);
   } 
}
Ejemplo n.º 12
0
static void
draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
{
#if 0
	if (gr->mode == draw_mode_begin || gr->mode == draw_mode_end)
		gdk_draw_polygon(gr->drawable, gc->gc, TRUE, (GdkPoint *)p, count);
	if (gr->mode == draw_mode_end || gr->mode == draw_mode_cursor)
		gdk_draw_polygon(gr->widget->window, gc->gc, TRUE, (GdkPoint *)p, count);
#endif
	int i;
	glColor4f( gc->fr, gc->fg, gc->fb, gc->fa);
	glBegin( GL_POLYGON );
	for (i = 0 ; i < count ; i++) {
		glVertex2i(p[i].x, p[i].y);		
	}
	glVertex2i(p[0].x, p[0].y);		
	glEnd();
	
}
Ejemplo n.º 13
0
/*
 * Aperture macro primitive 4 (outline)
 * - Start point is not included in number of points.
 * - Outline is 1 pixel.
 */
static void
gerbv_gdk_draw_prim4(GdkPixmap *pixmap, GdkGC *gc, double *p, 
		     double scale, gint x, gint y)
{
    const int exposure_idx = 0;
    const int nuf_points_idx = 1;
    const int first_x_idx = 2;
    const int first_y_idx = 3;
    const int rotext_idx = 4;
    GdkGC *local_gc = gdk_gc_new(pixmap);
    int nuf_points, point;
    double rotation;
    GdkPoint *points;
    GdkColor color;

    /* Include start point */
    nuf_points = (int)p[nuf_points_idx] + 1;
    points = (GdkPoint *)g_malloc(sizeof(GdkPoint) * nuf_points);
    if (!points) {
	g_free(points);
	return;
    }

    rotation = p[(nuf_points - 1) * 2 + rotext_idx];
    for (point = 0; point < nuf_points; point++) {
	points[point].x = (int)round(scale * p[point * 2 + first_x_idx]);
	points[point].y = -(int)round(scale * p[point * 2 + first_y_idx]);
	if (rotation != 0.0)
	    points[point] = rotate_point(points[point], rotation);
	points[point].x += x;
	points[point].y += y;
    }

    gdk_gc_copy(local_gc, gc);

    /* Exposure */
    if (p[exposure_idx] == 0.0) {
	color.pixel = 0;
	gdk_gc_set_foreground(local_gc, &color);
    }

    gdk_gc_set_line_attributes(local_gc, 
			       1, /* outline always 1 pixels */
			       GDK_LINE_SOLID, 
			       GDK_CAP_BUTT, 
			       GDK_JOIN_MITER);
    gdk_draw_polygon(pixmap, local_gc, 1, points, nuf_points);

    g_free(points);

    gdk_gc_unref(local_gc);

    return;
} /* gerbv_gdk_draw_prim4 */
Ejemplo n.º 14
0
void iupdrvDrawPolygon(IdrawCanvas* dc, int* points, int count, unsigned char r, unsigned char g, unsigned char b, int style)
{
  GdkColor color;
  iupgdkColorSet(&color, r, g, b);
  gdk_gc_set_rgb_fg_color(dc->pixmap_gc, &color);

  if (style!=IUP_DRAW_FILL)
    iDrawSetLineStyle(dc, style);

  gdk_draw_polygon(dc->pixmap, dc->pixmap_gc, style==IUP_DRAW_FILL, (GdkPoint*)points, count);
}
Ejemplo n.º 15
0
static void
gerbv_gdk_draw_prim21(GdkPixmap *pixmap, GdkGC *gc, double *p, 
		  double scale, gint x, gint y)
{
    const int exposure_idx = 0;
    const int width_idx = 1;
    const int height_idx = 2;
    const int exp_x_idx = 3;
    const int exp_y_idx = 4;
    const int rotation_idx = 5;
    const int nuf_points = 4;
    GdkPoint points[nuf_points];
    GdkColor color;
    GdkGC *local_gc = gdk_gc_new(pixmap);
    int half_width, half_height;
    int i;

    half_width = (int)round(p[width_idx] * scale / 2.0);
    half_height =(int)round(p[height_idx] * scale / 2.0);

    points[0].x = half_width;
    points[0].y = half_height;

    points[1].x = half_width;
    points[1].y = -half_height;

    points[2].x = -half_width;
    points[2].y = -half_height;

    points[3].x = -half_width;
    points[3].y = half_height;

    for (i = 0; i < nuf_points; i++) {
	points[i] = rotate_point(points[i], p[rotation_idx]);
	points[i].x += (x + (int)(p[exp_x_idx] * scale));
	points[i].y += (y - (int)(p[exp_y_idx] * scale));
    }

    gdk_gc_copy(local_gc, gc);

    /* Exposure */
    if (p[exposure_idx] == 0.0) {
	color.pixel = 0;
	gdk_gc_set_foreground(local_gc, &color);
    }

    gdk_draw_polygon(pixmap, local_gc, 1, points, nuf_points);

    gdk_gc_unref(local_gc);

    return;
} /* gerbv_gdk_draw_prim21 */
Ejemplo n.º 16
0
/*
 * Doesn't handle explicit x,y yet
 */
static void
gerbv_gdk_draw_prim22(GdkPixmap *pixmap, GdkGC *gc, double *p, 
		  double scale, gint x, gint y)
{
    const int exposure_idx = 0;
    const int width_idx = 1;
    const int height_idx = 2;
    const int x_lower_left_idx = 3;
    const int y_lower_left_idx = 4;
    const int rotation_idx = 5;
    const int nuf_points = 4;
    GdkPoint points[nuf_points];
    GdkGC *local_gc = gdk_gc_new(pixmap);
    GdkColor color;
    int i;

    points[0].x = (int)round(p[x_lower_left_idx] * scale);
    points[0].y = (int)round(p[y_lower_left_idx] * scale);

    points[1].x = (int)round((p[x_lower_left_idx] + p[width_idx])
			     * scale);
    points[1].y = (int)round(p[y_lower_left_idx] * scale);

    points[2].x = (int)round((p[x_lower_left_idx]  + p[width_idx])
			     * scale);
    points[2].y = (int)round((p[y_lower_left_idx]  + p[height_idx])
			     * scale);

    points[3].x = (int)round(p[x_lower_left_idx] * scale);
    points[3].y = (int)round((p[y_lower_left_idx] + p[height_idx])
			     * scale);

    for (i = 0; i < nuf_points; i++) {
	points[i] = rotate_point(points[i], p[rotation_idx]);
	points[i].x = x + points[i].x;
	points[i].y = y - points[i].y;
    }

    gdk_gc_copy(local_gc, gc);

    /* Exposure */
    if (p[exposure_idx] == 0.0) {
	color.pixel = 0;
	gdk_gc_set_foreground(local_gc, &color);
    }

    gdk_draw_polygon(pixmap, local_gc, 1, points, nuf_points);

    gdk_gc_unref(local_gc);

    return;
} /* gerbv_gdk_draw_prim22 */
Ejemplo n.º 17
0
/**
 * gimp_canvas_draw_polygon:
 * @canvas:     a #GimpCanvas widget
 * @style:      one of the enumerated #GimpCanvasStyle's.
 * @filled:     if %TRUE, fill the polygon.
 * @points:     a #GdkPoint array.
 * @num_points: the number of points in the array.
 *
 * Draws a polygon connecting the specified points, in the specified
 * style.
 **/
void
gimp_canvas_draw_polygon (GimpCanvas      *canvas,
                          GimpCanvasStyle  style,
                          gboolean         filled,
                          GdkPoint        *points,
                          gint             num_points)
{
  if (! gimp_canvas_ensure_style (canvas, style))
    return;

  gdk_draw_polygon (GTK_WIDGET (canvas)->window, canvas->gc[style],
                    filled, points, num_points);
}
Ejemplo n.º 18
0
int GCpolygon(Gwidget_t * widget, int gpn, Gpoint_t * gpp, Ggattr_t * ap)
{

    Grect_t gr;
    int n, i;

    if (gpn == 0)
	return 0;

    gr.o = gpp[0], gr.c = gpp[0];
    for (i = 1; i < gpn; i++) {
	gr.o.x = min(gr.o.x, gpp[i].x);
	gr.o.y = min(gr.o.y, gpp[i].y);
	gr.c.x = min(gr.c.x, gpp[i].x);
	gr.c.y = min(gr.c.y, gpp[i].y);
    }
/*	if(!ISVISIBLE(gr))
		return 1;
*/
    if (gpn + 1 > Gppn) {
	n = (((gpn + 1) + PPINCR - 1) / PPINCR) * PPINCR;
	Gppp = Marraygrow(Gppp, (long) n * PPSIZE);
	Gppn = n;
    }
    for (i = 0; i < gpn; i++)
	Gppp[i] = pdrawtopix(widget, gpp[i]);

    setgattr(widget, ap);
    if (WCU->gattr.fill) {
	if (Gppp[gpn - 1].x != Gppp[0].x || Gppp[gpn - 1].y != Gppp[0].y)
	    Gppp[gpn] = Gppp[0], gpn++;

	gdk_draw_polygon(widget->w, GC, TRUE, Gppp, gpn);
    } else
	gdk_draw_polygon(widget->w, GC, FALSE, Gppp, gpn);

    return 0;
}
Ejemplo n.º 19
0
/*
 * Aperture macro primitive 5 (polygon)
 */
static void
gerbv_gdk_draw_prim5(GdkPixmap *pixmap, GdkGC *gc, double *p, 
		     double scale, gint x, gint y)
{
    const int exposure_idx = 0;
    const int nuf_vertices_idx = 1;
    const int center_x_idx = 2;
    const int center_y_idx = 3;
    const int diameter_idx = 4;
    const int rotation_idx = 5;
    int nuf_vertices, i;
    double vertex, tick, rotation, radius;
    GdkPoint *points;
    GdkGC *local_gc = gdk_gc_new(pixmap);
    GdkColor color;

    nuf_vertices = (int)p[nuf_vertices_idx];
    points = (GdkPoint *)g_malloc(sizeof(GdkPoint) * nuf_vertices);
    if (!points) {
	g_free(points);
	return;
    }

    gdk_gc_copy(local_gc, gc);

    /* Exposure */
    if (p[exposure_idx] == 0.0) {
	color.pixel = 0;
	gdk_gc_set_foreground(local_gc, &color);
    }

    tick = 2 * M_PI / (double)nuf_vertices;
    rotation = -p[rotation_idx] * M_PI / 180.0;
    radius = p[diameter_idx] / 2.0;
    for (i = 0; i < nuf_vertices; i++) {
	vertex =  tick * (double)i + rotation;
	points[i].x = (int)round(scale * radius * cos(vertex)) + x +
	    p[center_x_idx];
	points[i].y = (int)round(scale * radius * sin(vertex)) + y +
	    p[center_y_idx];
    }

    gdk_draw_polygon(pixmap, local_gc, 1, points, nuf_vertices);

    gdk_gc_unref(local_gc);

    g_free(points);
    return;
} /* gerbv_gdk_draw_prim5 */
Ejemplo n.º 20
0
static VALUE
rg_draw_polygon(VALUE self, VALUE rbgc, VALUE rbfilled, VALUE rbpoints)
{
    GdkDrawable *drawable = _SELF(self);
    GdkGC *gc = GDK_GC(RVAL2GOBJ(rbgc));
    gboolean filled = RVAL2CBOOL(rbfilled);
    long n;
    GdkPoint *points = RVAL2GDKPOINTS(rbpoints, &n);

    gdk_draw_polygon(drawable, gc, filled, points, n);

    g_free(points);

    return self;
}
Ejemplo n.º 21
0
static void
gdk_trace_line(HosPainterGdk *self, struct hos_point* points, const gint n_point, gint lvl, gboolean closed)
{
    HosPainter *painter = HOS_PAINTER(self);

    /*
     * The next assertion would be nice, but would require
     * either breaking into the painter's structure (grokking out
     * the adjustment) or creating a selector for the painter's
     * n_lvl; does not seem worth it to be able to do this
     * assertion.
     */
    /* assert(lvl < painter->n_lvl); */

    /* set color */
    {
        GdkColor *color = contour_get_color(painter->contour, lvl);

        /* FIXME adjustable linewidth, etc. */
        gdk_gc_set_rgb_fg_color(self->gc, color);
        gdk_gc_set_line_attributes(self->gc,
                                   painter->contour->line_width,
                                   GDK_LINE_SOLID,
                                   GDK_CAP_BUTT,
                                   GDK_JOIN_MITER);

    }

    {
        GdkPoint gdk_points[n_point];
        guint i;

        /*
         * Points must be copied from a glib-style array to a
         * C-style array for use in gdk_draw_lines.
         */
        for (i = 0; i < n_point; ++i)
        {
            gdk_points[i].x = points[i].x;
            gdk_points[i].y = points[i].y;
        }

        if (closed)
            gdk_draw_polygon(self->drawable, self->gc, FALSE, gdk_points, n_point);
        else
            gdk_draw_lines(self->drawable, self->gc, gdk_points, n_point);
    }
}
Ejemplo n.º 22
0
void iupdrvDrawPolygon(IdrawCanvas* dc, int* points, int count, long color, int style, int line_width)
{
  GdkColor c;
  iupgdkColorSet(&c, color);
  gdk_gc_set_rgb_fg_color(dc->pixmap_gc, &c);

  if (style != IUP_DRAW_FILL)
  {
    iDrawSetLineWidth(dc, line_width);
    iDrawSetLineStyle(dc, style);
  }

  if (style == IUP_DRAW_FILL)
    gdk_draw_polygon(dc->pixmap, dc->pixmap_gc, TRUE, (GdkPoint*)points, count);
  else
    gdk_draw_lines(dc->pixmap, dc->pixmap_gc, (GdkPoint*)points, count);
}
Ejemplo n.º 23
0
void iupDrawPolygon(IdrawCanvas* dc, int* points, int count, unsigned char r, unsigned char g, unsigned char b, int style)
{
  GdkColor color;
  iupgdkColorSet(&color, r, g, b);
  gdk_gc_set_rgb_fg_color(dc->pixmap_gc, &color);

  if (style!=IUP_DRAW_FILL)
  {
    GdkGCValues gcval;
    if (style==IUP_DRAW_STROKE_DASH)
      gcval.line_style = GDK_LINE_ON_OFF_DASH;
    else
      gcval.line_style = GDK_LINE_SOLID;
    gdk_gc_set_values(dc->pixmap_gc, &gcval, GDK_GC_LINE_STYLE);
  }

  gdk_draw_polygon(dc->pixmap, dc->pixmap_gc, style==IUP_DRAW_FILL, (GdkPoint*)points, count);
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_fillPolygon
  (JNIEnv *env, jobject obj, jintArray xpoints, jintArray ypoints, 
   jint npoints)
{
  struct graphics *g;
  GdkPoint *points;

  g = (struct graphics *) NSA_GET_PTR (env, obj);
  points = translate_points (env, xpoints, ypoints, npoints,
			     g->x_offset, g->y_offset);
  gdk_threads_enter ();
  gdk_draw_polygon (g->drawable, g->gc, TRUE, points, npoints);
  gdk_flush ();
  gdk_threads_leave ();

  g_free (points);
}
Ejemplo n.º 25
0
/* affiche flfigpetite dans le pixmap */
void tandrawfloat (GdkPixmap *pixmap, gboolean isoutline){

  tanflfig *flfig=&flfigpetite;
  double dx,dy;
  GdkPoint pnts[PIECENBR*(PNTNBRMAX+1)];
  int flpntnbr;
  int flpiecenbr;
  int i,j;
  tanfpnt *figfpnts;
  double zoom;
  tanpolytype polytype;


  if (isoutline){
    zoom = widgetgrande->allocation.width*figgrande.zoom;
    dx=dxout;
    dy=dyout;
  }
  else{
    zoom = widgetpetite->allocation.width*figpetite.zoom;
    dx=dxpetite;
    dy=dypetite;
  }

  flpiecenbr = flfig->flpiecenbr;
  for (i = 0; i<flpiecenbr; i++){
    figfpnts = flfig->flpieces[i].flpnts;
    flpntnbr = flfig->flpieces[i].flpntnbr;
    polytype = flfig->flpieces[i].polytype;
    for (j = 0; j<flpntnbr; j++){
      pnts[j].x = (gint16)(zoom*(figfpnts[j].posx-dx)+ARON);
      pnts[j].y = (gint16)(zoom*(figfpnts[j].posy-dy)+ARON);
    }
    if (isoutline){
      pnts[flpntnbr] = pnts[0];
      gdk_draw_lines(pixmap, tabgc[GCPIECEHLP], pnts, flpntnbr+1);
    }
    else {
      gdk_draw_polygon(pixmap,
		       (polytype==TAN_POLYON) ? ( figpetite.reussi ? tabgc[GCPETITECHK] : tabgc[GCPETITEBG] ) : tabgc[GCPETITEFG],
		       TRUE, pnts, flpntnbr);
    }
  }
}
Ejemplo n.º 26
0
void
ghid_fill_polygon (hidGC gc, int n_coords, int *x, int *y)
{
    static GdkPoint *points = 0;
    static int npoints = 0;
    int i;
    USE_GC (gc);

    if (npoints < n_coords)
    {
        npoints = n_coords + 1;
        points = (GdkPoint *)realloc (points, npoints * sizeof (GdkPoint));
    }
    for (i = 0; i < n_coords; i++)
    {
        points[i].x = Vx (x[i]);
        points[i].y = Vy (y[i]);
    }
    gdk_draw_polygon (gport->drawable, gport->u_gc, 1, points, n_coords);
}
Ejemplo n.º 27
0
static void 
fill_polygon (DiaRenderer *object, Point *points, int num_points, Color *line_color)
{
  DiaGdkRenderer *renderer = DIA_GDK_RENDERER (object);
  GdkGC *gc = renderer->gc;
  GdkColor color;
  GdkPoint *gdk_points;
  int i,x,y;
  
  gdk_points = g_new(GdkPoint, num_points);

  for (i=0;i<num_points;i++) {
    dia_transform_coords(renderer->transform, points[i].x, points[i].y, &x, &y);
    gdk_points[i].x = x;
    gdk_points[i].y = y;
  }
  
  renderer_color_convert(renderer, line_color, &color);
  gdk_gc_set_foreground(gc, &color);
  
  gdk_draw_polygon(renderer->pixmap, gc, TRUE, gdk_points, num_points);
  g_free(gdk_points);
}
Ejemplo n.º 28
0
static void
gtk_plot_gdk_draw_polygon                            (GtkPlotPC *pc,
                                                     gint filled,
                                                     GtkPlotPoint *points,
                                                     gint numpoints)
{
  GdkPoint *p = NULL;
  gint i;

  if(!GTK_PLOT_GDK(pc)->gc) return;
  if(!GTK_PLOT_GDK(pc)->drawable) return;

  p = (GdkPoint *)g_malloc(numpoints * sizeof(GdkPoint));
  for(i = 0; i < numpoints; i++){
    p[i].x = roundint(points[i].x);
    p[i].y = roundint(points[i].y);
  }

  gdk_draw_polygon(GTK_PLOT_GDK(pc)->drawable, GTK_PLOT_GDK(pc)->gc,
                   filled, p, numpoints);

  g_free(p);
}
Ejemplo n.º 29
0
static void
gtk_databox_marker_real_draw (GtkDataboxGraph *graph,
                             GtkDataboxCanvas *canvas)
{
   GtkDataboxMarker *marker = GTK_DATABOX_MARKER (graph);
   GdkPoint points [3];
   gfloat *X;
   gfloat *Y;
   gint len;
   gint16 x;
   gint16 y;
   GtkDataboxCoord coord;
   gint size;
   gint i;
 
   g_return_if_fail (GTK_DATABOX_IS_MARKER (marker));
   g_return_if_fail (canvas);
   g_return_if_fail (canvas->pixmap);
   g_return_if_fail (canvas->context);

   if (!graph->gc) 
      gtk_databox_graph_create_gc (graph, canvas);

   len = gtk_databox_xyc_graph_get_length (GTK_DATABOX_XYC_GRAPH (graph));
   X = gtk_databox_xyc_graph_get_X (GTK_DATABOX_XYC_GRAPH (graph));
   Y = gtk_databox_xyc_graph_get_Y (GTK_DATABOX_XYC_GRAPH (graph));
   size = gtk_databox_graph_get_size (graph);

   for (i = 0; i < len; ++i)
   {
      x = (gint16) ((X[i] - canvas->top_left_visible.x) 
            * canvas->translation_factor.x);
      y = (gint16) ((Y[i] - canvas->top_left_visible.y) 
            * canvas->translation_factor.y);
      
      switch (marker->priv->type)
      {
         case GTK_DATABOX_MARKER_TRIANGLE:
            switch (marker->priv->marker_info[i].position) 
            {
               case GTK_DATABOX_MARKER_C:
                  coord.x = x;
                  coord.y = y;
                  y = y - size / 2;
                  points[0].x = x;
                  points[0].y = y;
                  points[1].x = x - size / 2;
                  points[1].y = y + size;
                  points[2].x = x + size / 2;
                  points[2].y = y + size;
                  break;
               case GTK_DATABOX_MARKER_N:
                  coord.x = x;
                  coord.y = y - 2 - size / 2;
                  y = y - 2;
                  points[0].x = x;
                  points[0].y = y;
                  points[1].x = x - size / 2;
                  points[1].y = y - size;
                  points[2].x = x + size / 2;
                  points[2].y = y - size;
                  break;
               case GTK_DATABOX_MARKER_E:
                  coord.x = x + 2 + size / 2;
                  coord.y = y;
                  x = x + 2;
                  points[0].x = x;
                  points[0].y = y;
                  points[1].x = x + size;
                  points[1].y = y + size / 2;
                  points[2].x = x + size;
                  points[2].y = y - size / 2;
                  break;
               case GTK_DATABOX_MARKER_S:
                  coord.x = x;
                  coord.y = y + 2 + size / 2;
                  y = y + 2;
                  points[0].x = x;
                  points[0].y = y;
                  points[1].x = x - size / 2;
                  points[1].y = y + size;
                  points[2].x = x + size / 2;
                  points[2].y = y + size;
                  break;
               case GTK_DATABOX_MARKER_W:
                  coord.x = x - 2 - size / 2;
                  coord.y = y;
                  x = x - 2;
                  points[0].x = x;
                  points[0].y = y;
                  points[1].x = x - size;
                  points[1].y = y + size / 2;
                  points[2].x = x - size;
                  points[2].y = y - size / 2;
                  break;
            }
            gdk_draw_polygon (canvas->pixmap, graph->gc, 
                              TRUE, points, 3);
            break;
            /* End of GTK_DATABOX_MARKER_TRIANGLE */
         case GTK_DATABOX_MARKER_SOLID_LINE:
         case GTK_DATABOX_MARKER_DASHED_LINE:
            switch (marker->priv->marker_info[i].position) 
            {
               case GTK_DATABOX_MARKER_C:
                  coord.x = x;
                  coord.y = y;
                  points[0].x = x;
                  points[0].y = 0;
                  points[1].x = x;
                  points[1].y = canvas->height;
                  break;
               case GTK_DATABOX_MARKER_N:
                  coord.x = x;
                  points[0].x = x;
                  points[0].y = 0;
                  points[1].x = x;
                  points[1].y = canvas->height;
                  break;
               case GTK_DATABOX_MARKER_E:
                  coord.y = y;
                  points[0].x = 0;
                  points[0].y = y;
                  points[1].x = canvas->width;
                  points[1].y = y;
                  break;
               case GTK_DATABOX_MARKER_S:
                  coord.x = x;
                  points[0].x = x;
                  points[0].y = 0;
                  points[1].x = x;
                  points[1].y = canvas->height;
                  break;
               case GTK_DATABOX_MARKER_W:
                  coord.y = y;
                  points[0].x = 0;
                  points[0].y = y;
                  points[1].x = canvas->width;
                  points[1].y = y;
                  break;
            }

            gdk_draw_line (canvas->pixmap, graph->gc,
                           points[0].x, points[0].y,
                           points[1].x, points[1].y);
            break;
            /* End of GTK_DATABOX_MARKER_LINE */

         case GTK_DATABOX_MARKER_NONE:
         default:
            coord.x = x;
            coord.y = y;
            break;
      }

      if (marker->priv->marker_info[i].text)
      {
         if (!marker->priv->marker_info[i].label)
         {
            marker->priv->marker_info[i].label = 
               pango_layout_new (canvas->context);
            pango_layout_set_text (marker->priv->marker_info[i].label, 
                                   marker->priv->marker_info[i].text, 
                                   -1);
         }

         if (marker->priv->type == GTK_DATABOX_MARKER_SOLID_LINE
               || marker->priv->type == GTK_DATABOX_MARKER_DASHED_LINE)
         {
            gint width;
            gint height;
            pango_layout_get_pixel_size (marker->priv->marker_info[i].label, 
                                         &width, &height);

            width = (width + 1) / 2 + 2;
            height = (height + 1) / 2 + 2;
            size = 0;

            switch (marker->priv->marker_info[i].position)
            {
               case GTK_DATABOX_MARKER_C:
               break;
               case GTK_DATABOX_MARKER_N:
                  coord.y = height;
               break;
               case GTK_DATABOX_MARKER_E:
                  coord.x = canvas->width - width;
               break;
               case GTK_DATABOX_MARKER_S:
                  coord.y = canvas->height - height;
               break;
               case GTK_DATABOX_MARKER_W:
                  coord.x = width;
               break;
            }
         }
         
         gtk_databox_label_write_at (canvas->pixmap, 
                                    marker->priv->marker_info[i].label, 
                                    marker->priv->label_gc, coord,
                                    marker->priv->marker_info[i].label_position,
                                    (size + 1) / 2 + 2,
                                    marker->priv->marker_info[i].boxed);
      }
   }
      
   return;
}
Ejemplo n.º 30
0
GdkRectangle tandrawpiece (GtkWidget *widget,GdkPixmap *pixmap,
			   tanpiecepos *piecepos,
			   double zoom, tanremplis remplis){

  GdkPoint pnt[PNTNBRMAX+1];
  int i,pntnbr,ix,iy,ixmax=-20000,ixmin=20000,iymax=-20000,iymin=20000;
  GdkRectangle update_rect;
  GdkGC *gc;
  double gris,rx,ry;

  pntnbr=tanplacepiece(piecepos,pnt,zoom);

  for(i=0; i<pntnbr; i++){
    ix=pnt[i].x;
    iy=pnt[i].y;
    if (ix<ixmin)
      ixmin=ix;
    if (ix>ixmax)
      ixmax=ix;
    if (iy<iymin)
      iymin=iy;
    if (iy>iymax)
      iymax=iy;
  }

  update_rect.x=ixmin;
  update_rect.y=iymin;
  update_rect.width=ixmax-ixmin+1;
  update_rect.height=iymax-iymin+1;

  switch (remplis){
  case TAN_PETITEHLP:
    gc=tabgc[GCPETITEHLP];
    break;
  case TAN_PIECENOR:
    gc=tabgc[GCPIECENOR];
    gdk_gc_set_ts_origin (gc,pnt[pntnbr].x,pnt[pntnbr].y);
    break;
  case TAN_PIECEHI:
    gc=tabgc[GCPIECEHI];
    gdk_gc_set_ts_origin (gc,pnt[pntnbr].x,pnt[pntnbr].y);
    break;
  default:
    gc=widget->style->white_gc;
    break;
  }

  gdk_draw_polygon (pixmap,
		    gc,
		    TRUE,
		    pnt,
		    pntnbr);

  if ( remplis==TAN_PIECENOR || remplis==TAN_PIECEHI ){
    pnt[pntnbr]=pnt[0];                 /* ecrase le point du centre */
    for (i=0; i<pntnbr; i++){
      rx=pnt[i+1].x-pnt[i].x;
      ry=pnt[i].y-pnt[i+1].y;
      gris=(ry+rx)*0.35355339/sqrt(rx*rx+ry*ry);
      if (piecepos->flipped)
	gris=-gris;
      gris=gris+0.5;
      gdk_draw_line (pixmap,
		     tabgc[(int)(gris*(GRISNBR))],
		     pnt[i].x,pnt[i].y,pnt[i+1].x,pnt[i+1].y);
    }
  }
  return(update_rect);

}