SvgPathSegCurvetoQuadraticAbs.cs :  » GUI » SharpVectorGraphics » SharpVectors » Dom » Svg » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » GUI » SharpVectorGraphics 
SharpVectorGraphics » SharpVectors » Dom » Svg » SvgPathSegCurvetoQuadraticAbs.cs
using System;
using System.Drawing;
using System.Text;

#if TEST
using NUnit.Framework;
#endif

namespace SharpVectors.Dom.Svg{
  /// <summary>
  /// Summary description for SvgPathSegCurvetoCubicAbs.
  /// </summary>
  public class SvgPathSegCurvetoQuadraticAbs : SvgPathSegCurvetoQuadratic, ISvgPathSegCurvetoQuadraticAbs
  {
        #region constructors
    internal SvgPathSegCurvetoQuadraticAbs(float x, float y, float x1, float y1) : base(SvgPathSegType.CurveToQuadraticAbs)
    {
      this.x = x;
      this.y = y;
      this.x1 = x1;
      this.y1 = y1;
    }
        #endregion

        #region implementation of ISvgPathSegCurvetoQuadraticAbs
    private float x;
    public float X
    {
      get{return x;}
      set{x = value;}
    }      

    private float y;    
    public float Y
    {
      get{return y;}
      set{y = value;}
    }      

    private float x1;
    public float X1    
    {
      get{return x1;}
      set{x1 = value;}
    }      

    private float y1;    
    public float Y1
    {
      get{return y1;}
      set{y1 = value;}
    }
        #endregion
    
        #region public methods
    public override PointF AbsXY
    {
      get
      {
        return new PointF(X, Y);
      }
    }

    public override PointF QuadraticX1Y1
    {
      get
      {
        return new PointF(X1, Y1);
      }
    }

    /*
    * Convert to cubic bezier using the algorithm from Math:Bezier:Convert in CPAN
    * $p0x+($p1x-$p0x)*2/3
    * $p0y+($p1y-$p0y)*2/3
    * $p1x+($p2x-$p1x)/3
    * $p1x+($p2x-$p1x)/3
    * */

    public override PointF CubicX1Y1
    {
      get
      {
        PointF prevPoint = PreviousSeg.AbsXY;

        float x1 = prevPoint.X + (X1 - prevPoint.X) * 2/3;
        float y1 = prevPoint.Y + (Y1 - prevPoint.Y) * 2/3;
      
        return new PointF(x1, y1);
      }
    }

    public override PointF CubicX2Y2
    {
      get
      {
        float x2 = X1 + (X - X1) / 3;
        float y2 = Y1 + (Y - Y1) / 3;

        return new PointF(x2, y2);
      }
    }

    public override string PathText
    {
      get
      {
        StringBuilder sb = new StringBuilder();
        sb.Append(PathSegTypeAsLetter);
        sb.Append(X1);
        sb.Append(",");
        sb.Append(Y1);
        sb.Append(",");
        sb.Append(X);
        sb.Append(",");
        sb.Append(Y);

        return sb.ToString();
      }
    }
        #endregion

        #region unit tests
        #if TEST
        [TestFixture]
        public class QuadraticAbsTests : QuadraticTests
        {
            public override SvgPathSegList makeSegments()
            {
                return new SvgPathSegList("M10,10 Q100,100 200,10", false);
            }

            public override SvgPathSegCurvetoQuadratic getTestSegment()
            {
                return (SvgPathSegCurvetoQuadratic) segments[1];
            }
        }
        #endif
        #endregion
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.