Пример #1
0
        /// <summary>
        /// Sets the clipping region of the specified <see cref="ISvgRenderer"/>.
        /// </summary>
        /// <param name="renderer">The <see cref="ISvgRenderer"/> to have its clipping region set.</param>
        protected internal virtual void SetClip(ISvgRenderer renderer)
        {
            if (this.ClipPath != null || !string.IsNullOrEmpty(this.Clip))
            {
                this._previousClip = renderer.GetClip();

                if (this.ClipPath != null)
                {
                    SvgClipPath clipPath = this.OwnerDocument.GetElementById <SvgClipPath>(this.ClipPath.ToString());
                    if (clipPath != null)
                    {
                        renderer.SetClip(clipPath.GetClipRegion(this, renderer), CombineMode.Intersect);
                    }
                }

                var clip = this.Clip;
                if (!string.IsNullOrEmpty(clip) && clip.StartsWith("rect("))
                {
                    clip = clip.Trim();
                    var offsets = (from o in clip.Substring(5, clip.Length - 6).Split(',')
                                   select float.Parse(o.Trim(), NumberStyles.Any, CultureInfo.InvariantCulture)).ToList();
                    var bounds   = this.Bounds;
                    var clipRect = new RectangleF(bounds.Left + offsets[3], bounds.Top + offsets[0],
                                                  bounds.Width - (offsets[3] + offsets[1]),
                                                  bounds.Height - (offsets[2] + offsets[0]));
                    renderer.SetClip(new Region(clipRect), CombineMode.Intersect);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Sets the clipping region of the specified <see cref="SvgRenderer"/>.
        /// </summary>
        /// <param name="renderer">The <see cref="SvgRenderer"/> to have its clipping region set.</param>
        protected internal virtual void SetClip(SvgRenderer renderer)
        {
            if (this.ClipPath != null)
            {
                SvgClipPath clipPath = this.OwnerDocument.GetElementById <SvgClipPath>(this.ClipPath.ToString());
                this._previousClip = renderer.Clip;

                if (clipPath != null)
                {
                    renderer.Clip = clipPath.GetClipRegion(this);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Sets the clipping region of the specified <see cref="SvgRenderer"/>.
        /// </summary>
        /// <param name="renderer">The <see cref="SvgRenderer"/> to have its clipping region set.</param>
        protected internal virtual void SetClip(SvgRenderer renderer)
        {
            SvgClipPath clipPath = GetSvgClipPath();

            if (clipPath != null)
            {
                this._previousClip = renderer.Clip;

                if (clipPath != null)
                {
                    renderer.Clip = clipPath.GetClipRegion(this);
                }
            }
        }