Ejemplo n.º 1
0
void
_cleanup_path(PathIterator& path, const agg::trans_affine& trans,
              bool remove_nans, bool do_clip,
              const agg::rect_base<double>& rect,
              e_snap_mode snap_mode, double stroke_width,
              bool do_simplify, bool return_curves,
              std::vector<double>& vertices,
              std::vector<npy_uint8>& codes)
{
    typedef agg::conv_transform<PathIterator>  transformed_path_t;
    typedef PathNanRemover<transformed_path_t> nan_removal_t;
    typedef PathClipper<nan_removal_t>         clipped_t;
    typedef PathSnapper<clipped_t>             snapped_t;
    typedef PathSimplifier<snapped_t>          simplify_t;
    typedef agg::conv_curve<simplify_t>        curve_t;

    transformed_path_t tpath(path, trans);
    nan_removal_t      nan_removed(tpath, remove_nans, path.has_curves());
    clipped_t          clipped(nan_removed, do_clip, rect);
    snapped_t          snapped(clipped, snap_mode, path.total_vertices(), stroke_width);
    simplify_t         simplified(snapped, do_simplify, path.simplify_threshold());

    vertices.reserve(path.total_vertices() * 2);
    codes.reserve(path.total_vertices());

    if (return_curves)
    {
        __cleanup_path(simplified, vertices, codes);
    }
    else
    {
        curve_t curve(simplified);
        __cleanup_path(curve, vertices, codes);
    }
}
Ejemplo n.º 2
0
  virtual void Paint(DrawTarget* aDT, const gfx::Point& aDeviceOffset,
                     Layer* aMaskLayer) override {
    if (IsHidden()) {
      return;
    }

    Rect snapped(mBounds.X(), mBounds.Y(), mBounds.Width(), mBounds.Height());
    MaybeSnapToDevicePixels(snapped, *aDT, true);

    // Clip drawing in case we're using (unbounded) operator source.
    aDT->PushClipRect(snapped);
    FillRectWithMask(
        aDT, aDeviceOffset, snapped, mColor,
        DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)),
        aMaskLayer);
    aDT->PopClip();
  }
Ejemplo n.º 3
0
void FaceItem::snapSelectedToGrid(float grid) {
	if (_selected) {
		Vector2 centroid = getCentroid();

		Vector2 snapped(
			float_snapped(centroid[0], grid),
			float_snapped(centroid[1], grid)
		);

		Vector3 translation;
		translation[0] = snapped[0] - centroid[0];
		translation[1] = snapped[1] - centroid[1];

		Matrix4 matrix = Matrix4::getTranslation(translation);

		// Do the transformation
		transform(matrix);
	}

	// Let the base class call the method on our children
	TexToolItem::snapSelectedToGrid(grid);
}