示例#1
0
static DiaPattern *
_create_preset_pattern (guint n)
{
  DiaPattern *pat;
  Color       color;

  g_return_val_if_fail (n < G_N_ELEMENTS (_pattern_presets), NULL);
  switch (_pattern_presets[n].type) {
  case DIA_LINEAR_GRADIENT:
    pat = dia_pattern_new (_pattern_presets[n].type, 0, 0.0, 0.0);
    if (_pattern_presets[n].flags != 0)
      dia_pattern_set_point (pat,
			     _pattern_presets[n].flags & LEFT ? 1.0 : 0.0,
			     _pattern_presets[n].flags & DOWN ? 1.0 : 0.0);
    break;
  case DIA_RADIAL_GRADIENT:
    pat = dia_pattern_new (_pattern_presets[n].type, 0, 0.5, 0.5);
    dia_pattern_set_radius (pat, 0.5);
    /* set the focal point to the center */
    dia_pattern_set_point (pat, 0.5, 0.5);
    break;
  default :
    g_assert_not_reached ();
  }

  color = attributes_get_background ();
  dia_pattern_add_color (pat, 0.0, &color);
  color = attributes_get_foreground ();
  dia_pattern_add_color (pat, 1.0, &color);

  return pat; 
}
示例#2
0
文件: pdf-import.cpp 项目: mpuels/dia
  GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax)
  {
    double x0, y0, r0, x1, y1, r1;
    double dx, dy, dr;

    shading->getCoords(&x0, &y0, &r0, &x1, &y1, &r1);
    x0 *= scale;
    y0 *= scale;
    x1 *= scale;
    y1 *= scale;
    r0 *= scale;
    r1 *= scale;
    dx = x1 - x0;
    dy = y1 - y0;
    dr = r1 - r0;

    if (this->pattern)
      g_object_unref (this->pattern);
    this->pattern = dia_pattern_new (DIA_RADIAL_GRADIENT, DIA_PATTERN_USER_SPACE,
				     x0 + sMax * dx, y0 + sMax * dy);
    dia_pattern_set_radius (this->pattern, r0 + sMax * dr);
    dia_pattern_set_point (this->pattern, x0 + sMin * dx, y0 + sMin * dy);
    // continue with updateFillColorStop calls
    // although wasteful, because Poppler samples these to 256 entries 
    return gFalse;
  }