Esempio n. 1
0
		void AddParameterValues(Collection.List<float> parameters, Geometry2D.Single.Point vector, Geometry2D.Single.Point zero, Geometry2D.Single.Point one, Geometry2D.Single.Point two)
		{
			Geometry2D.Single.Point zerop = new Geometry2D.Single.Point(zero.X * vector.Y, zero.Y * vector.X);
			Geometry2D.Single.Point onep = new Geometry2D.Single.Point(one.X * vector.Y, one.Y * vector.X);
			Geometry2D.Single.Point twop = new Geometry2D.Single.Point(two.X * vector.Y, two.Y * vector.X);
			float zeroCoefficient = zerop.X - zerop.Y;
			float oneCoefficient = onep.X - onep.Y;
			float twoCoefficient = twop.X - twop.Y;
			if (twoCoefficient != 0)
			{
				zeroCoefficient /= twoCoefficient;
				oneCoefficient /= twoCoefficient;
				float s = Kean.Math.Single.Power(-oneCoefficient / 2, 2) - zeroCoefficient;
				if (s >= 0)
				{
					s = Kean.Math.Single.SquareRoot(s);
					float x1 = -oneCoefficient / 2 + s;
					float x2 = -oneCoefficient / 2 - s;
					if (x1 >= 0 && x1 <= 1)
						parameters.Add(x1);
					if (x2 >= 0 && x2 <= 1)
						parameters.Add(x2);
				}
			}
			else if (oneCoefficient != 0)
			{
				float x1 = -zeroCoefficient / oneCoefficient;
				if (x1 >= 0 && x1 <= 1)
					parameters.Add(x1);
			}
		}
        /// <summary>
        /// Appends a child element to the root xml document <para />
        /// Always places a transcibed custom svg character, and optionally the free text beside it.
        /// </summary>
        /// <param name="consonant"></param>
        /// <param name="vowel"></param>
        public void Append(char character)
        {
            Geometry2D.Single.Point translate = this.position * this.Feed + this.Offset;
            //Adds an xml child element with the transcribed character svg(?) to the root element
            //this.root.Add(new Xml.Dom.Element("path",
            //                                  KeyValue.Create("d", this[character]),
            //                                  KeyValue.Create("transform", "translate(" + translate.ToString() + ")")
            //)
            //);
            this.root.Add(new Xml.Dom.Element("text",
                                              new Xml.Dom.Text(new string(new char[] { character })),
                                              KeyValue.Create("style", "text-anchor: right; font-family: Times New Roman; font-size: " + charSize + "mm"),
                                              KeyValue.Create("transform", "translate(" + translate.ToString() + ")")
                                              ));
            if (this.Help)
            {
                //Adds an xml child text element to the root element. Just for testing purposes I guess, free text of the transcribed text I guess
                this.root.Add(new Xml.Dom.Element("text",
                                                  new Xml.Dom.Text(new string(new char[] { character })),
                                                  KeyValue.Create("style", "text-anchor: right; font: Verdana 10pt"),
                                                  KeyValue.Create("transform", "translate(" + (translate.X + this.Feed.Width - 10).AsString() + ", " + (translate.Y + this.Feed.Height / 2).AsString() + ")")
                                                  )
                              );
            }

            this.Move(1.0f);
        }
Esempio n. 3
0
		protected override Geometry2D.Single.Box SegmentBounds(Geometry2D.Single.Transform transform)
		{
			Geometry2D.Single.Point p0 = this.Start;
			Geometry2D.Single.Point p1 = this.First;
			Geometry2D.Single.Point p2 = this.Second;
			Geometry2D.Single.Point p3 = this.End;
			Geometry2D.Single.Transform derivative = new Geometry2D.Single.Transform(transform.A, transform.B, transform.C, transform.D, 0, 0);
			Geometry2D.Single.Transform inverse = derivative.Inverse;
			Geometry2D.Single.Point e1p = inverse * new Geometry2D.Single.Point(1, 0);
			Geometry2D.Single.Point e2p = inverse * new Geometry2D.Single.Point(0, 1);
			Geometry2D.Single.Point zero = -3 * p0 + 3 * p1;
			Geometry2D.Single.Point one = 6 * p0 - 12 * p1 + 6 * p2;
			Geometry2D.Single.Point two = -3 * p0 + 9 * p1 - 9 * p2 + 3 * p3;
			Collection.List<float> parameters = new Collection.List<float>();
			parameters.Add(0f);
			parameters.Add(1f);
			this.AddParameterValues(parameters, e1p, zero, one, two);
			this.AddParameterValues(parameters, e2p, zero, one, two);
			Geometry2D.Single.Point[] points = new Geometry2D.Single.Point[parameters.Count];
			for (int i = 0; i < points.Length; i++)
			{
				//float alpha = i / (float)(points.Length - 1);
				float alpha = parameters[i];
				Geometry2D.Single.Point current = Kean.Math.Single.Power(1 - alpha, 3) * p0 + 3 * Kean.Math.Single.Power(1 - alpha, 2) * alpha * p1 + 3 * (1 - alpha) * Kean.Math.Single.Power(alpha, 2) * p2 + Kean.Math.Single.Power(alpha, 3) * p3;
				points[i] = transform * current;
			}
			return Geometry2D.Single.Box.Bounds(points);
		}
Esempio n. 4
0
		protected Image(Geometry2D.Integer.Size size, CoordinateSystem coordinateSystem, Geometry2D.Integer.Shell crop) :
			base(size, coordinateSystem, crop)
		{
			this.LeftTop = new Geometry2D.Single.Point(0, 0);
			this.RightTop = new Geometry2D.Single.Point(1, 0);
			this.LeftBottom = new Geometry2D.Single.Point(0, 1);
			this.RightBottom = new Geometry2D.Single.Point(1, 1);
		}
Esempio n. 5
0
		protected Image(Image original) :
			base(original) 
		{
			this.LeftTop = original.LeftTop;
			this.RightTop = original.RightTop;
			this.LeftBottom = original.LeftBottom;
			this.RightBottom = original.RightBottom;
		}
Esempio n. 6
0
		protected override Geometry2D.Single.Box SegmentBounds(Geometry2D.Single.Transform transform)
		{
			Geometry2D.Single.Point startPoint = transform * this.Start;
			Geometry2D.Single.Point endPoint = transform * this.End;
			Geometry2D.Single.Point leftTop = new Geometry2D.Single.Point(Kean.Math.Single.Minimum(startPoint.X, endPoint.X), Kean.Math.Single.Minimum(startPoint.Y, endPoint.Y));
			Geometry2D.Single.Size size = new Geometry2D.Single.Size(Kean.Math.Single.Absolute(startPoint.X - endPoint.X), Kean.Math.Single.Absolute(startPoint.Y - endPoint.Y));
			return new Geometry2D.Single.Box(leftTop, size);
		}
 protected override void Move(float distance)
 {
     this.position += new Geometry2D.Single.Point(0, distance);
     Geometry2D.Single.Point totalSize = this.position * this.Feed + this.Feed + 2 * this.Offset;
     if (totalSize.Y >= this.PageSize.Height)
     {
         this.position = new Geometry2D.Single.Point(this.position.X + 1, 0);
     }
 }
Esempio n. 8
0
 protected override void Move(float distance)
 {
     this.position += new Geometry2D.Single.Point(distance, 0);
     Geometry2D.Single.Point totalSize = this.position * this.Feed + this.Feed + 2 * this.Offset;
     if (totalSize.X >= this.PageSize.Width)
     {
         this.position = new Geometry2D.Single.Point(0, this.position.Y + 1);
     }
 }
Esempio n. 9
0
 protected bool ResetPage()
 {
     this.position = new Geometry2D.Single.Point();
     this.root     = new Xml.Dom.Element("svg",
                                         KeyValue.Create("xmlns", "http://www.w3.org/2000/svg"),
                                         KeyValue.Create("version", "1.1"),
                                         KeyValue.Create("width", this.PageSize.Width.AsString()),
                                         KeyValue.Create("height", this.PageSize.Height.AsString()));
     return(true);
 }
        protected bool ResetPage()
        {
            this.position = new Geometry2D.Single.Point();
            this.root     = new Xml.Dom.Element("svg",
                                                KeyValue.Create("xmlns", "http://www.w3.org/2000/svg"),
                                                KeyValue.Create("version", "1.1"),
                                                KeyValue.Create("width", this.PageSize.Width.AsString()),
                                                KeyValue.Create("height", this.PageSize.Height.AsString()));

            //if (this.Help)
            //{
            //    while (this.position.X * this.Feed.Width < this.PageSize.Width && position.Y * this.Feed.Height < this.PageSize.Height)
            //    {
            //        Append(".");
            //    }
            //    this.position = new Geometry2D.Single.Point();
            //}
            return(true);
        }
Esempio n. 11
0
		internal void Render(Map map, Geometry2D.Single.Box source, Geometry2D.Single.Box destination)
		{
			if (this.Crop.NotZero)
			{
				source = (source).Intersection(this.Crop.Decrease(this.Size));
				destination = ((Geometry2D.Single.Box)destination).Intersection(this.Crop.Decrease(this.Size));
			}
			Geometry2D.Single.Point leftTop = new Geometry2D.Single.Point(source.Left / this.Size.Width, source.Top / this.Size.Height);
			Geometry2D.Single.Point rightTop = new Geometry2D.Single.Point(source.Right / this.Size.Width, source.Top / this.Size.Height);
			Geometry2D.Single.Point leftBottom = new Geometry2D.Single.Point(source.Left / this.Size.Width, source.Bottom / this.Size.Height);
			Geometry2D.Single.Point rightBottom = new Geometry2D.Single.Point(source.Right / this.Size.Width, source.Bottom / this.Size.Height);
			leftTop.X = this.LeftTop.X * (1 - leftTop.X) + this.RightTop.X * leftTop.X;
			rightTop.X = this.LeftTop.X * (1 - rightTop.X) + this.RightTop.X * rightTop.X;
			leftBottom.X = this.LeftBottom.X * (1 - leftBottom.X) + this.RightBottom.X * leftBottom.X;
			rightBottom.X = this.LeftBottom.X * (1 - rightBottom.X) + this.RightBottom.X * rightBottom.X;
			leftTop.Y = this.LeftTop.Y * (1 - leftTop.Y) + this.LeftBottom.Y * leftTop.Y;
			leftBottom.Y = this.LeftTop.Y * (1 - leftBottom.Y) + this.LeftBottom.Y * leftBottom.Y;
			rightTop.Y = this.RightTop.Y * (1 - rightTop.Y) + this.RightBottom.Y * rightTop.Y;
			rightBottom.Y = this.RightTop.Y * (1 - rightBottom.Y) + this.RightBottom.Y * rightBottom.Y;
			this.Render(map, leftTop, rightTop, leftBottom, rightBottom, destination);
		}
Esempio n. 12
0
        /// <summary>
        /// Appends a child element to the root xml document <para />
        /// Always places a transcibed custom svg character, and optionally the free text beside it.
        /// </summary>
        /// <param name="consonant"></param>
        /// <param name="vowel"></param>
        public void Append(char consonant, char vowel)
        {
            Geometry2D.Single.Point translate = this.position * this.Feed + this.Offset;
            //Adds an xml child element with the transcribed character svg(?) to the root element
            this.root.Add(new Xml.Dom.Element("path",
                                              KeyValue.Create("d", this[consonant, vowel]),
                                              KeyValue.Create("transform", "translate(" + translate.ToString() + ")")
                                              )
                          );
            if (true || this.Help)
            {
                //Adds an xml child text element to the root element. Just for testing purposes I guess, free text of the transcribed text I guess
                this.root.Add(new Xml.Dom.Element("text",
                                                  new Xml.Dom.Text(new string(new char[] { consonant, vowel })),
                                                  KeyValue.Create("style", "text-anchor: right; font: Verdana 10pt"),
                                                  KeyValue.Create("transform", "translate(" + (translate.X + this.Feed.Width - 10).AsString() + ", " + (translate.Y + this.Feed.Height / 2).AsString() + ")")
                                                  )
                              );
            }

            this.Move(1.0f);
        }
Esempio n. 13
0
		protected override Geometry2D.Single.Box SegmentBounds(Geometry2D.Single.Transform transform)
		{
			Geometry2D.Single.Box result = new Geometry2D.Single.Box();
			Tuple<Geometry2D.Single.Point, float, float> coordinates = this.PlatformctArcCoordinates();
			float startAngle = coordinates.Item2;
			float endAngle = coordinates.Item3;
			Geometry2D.Single.Transform derivative = new Geometry2D.Single.Transform(transform.A, transform.B, transform.C, transform.D, 0, 0);
			Geometry2D.Single.Transform inverse = derivative.Inverse;
			Geometry2D.Single.Point e1p = inverse * new Geometry2D.Single.Point(1, 0);
			Geometry2D.Single.Point e2p = inverse * new Geometry2D.Single.Point(0, 1);
			Collection.List<float> angles = new Collection.List<float>();
			angles.Add(startAngle);
			angles.Add(endAngle);
			this.AnglesAdd(angles, Kean.Math.Single.ArcusTangensExtended(-e1p.X * this.Radius.Height, e1p.Y * this.Radius.Width), startAngle, endAngle);
			this.AnglesAdd(angles, Kean.Math.Single.ArcusTangensExtended(-e2p.X * this.Radius.Height, e2p.Y * this.Radius.Width), startAngle, endAngle);
			Geometry2D.Single.Point[] points = new Geometry2D.Single.Point[angles.Count];
			for (int i = 0; i < points.Length; i++)
			{
				float angle = angles[i];
				points[i] = transform * (new Geometry2D.Single.Point(this.Radius.Width * Kean.Math.Single.Cosinus(angle), this.Radius.Height * Kean.Math.Single.Sinus(angle)) + coordinates.Item1);
			}
			result = Geometry2D.Single.Box.Bounds(points);
			return result;
		}
Esempio n. 14
0
 void Move(float distance)
 {
     this.position += new Geometry2D.Single.Point(0, distance);
     Geometry2D.Single.Point totalSize = this.position * this.Feed + this.Feed + 2 * this.Offset;
     if (totalSize.Y >= this.PageSize.Height)
         this.position = new Geometry2D.Single.Point(this.position.X + 1, 0);
 }
Esempio n. 15
0
 public Geometry2D.Single.Point GetNewLine(Geometry2D.Single.Point position, int noOfLineBreaks)
 {
     return(new Geometry2D.Single.Point(0, position.Y + noOfLineBreaks));
 }
Esempio n. 16
0
		public Tuple<Geometry2D.Single.Point, float, float> PlatformctArcCoordinates()
		{
			float x1 = this.Start.X,
				  y1 = this.Start.Y,
				  x2 = this.End.X,
				  y2 = this.End.Y,
				  rx = this.Radius.Width,
				  ry = this.Radius.Height,
				  phi = this.Angle;

			float cx, cy; // Center point
			float cxp, cyp;
			float deltaTheta;
			float k1, k2, k3, k4;

			float cosPhi = Kean.Math.Single.Cosinus(phi),
				  sinPhi = Kean.Math.Single.Sinus(phi);

			if (rx < 0)
				rx = -rx;
			if (ry < 0)
				ry = -ry;

			float xp = (x1 - x2) / 2 * cosPhi + (y1 - y2) / 2 * sinPhi;
			float yp = (x1 - x2) / 2 * -sinPhi + (y1 - y2) / 2 * cosPhi;

			// Compute the center point
			k1 = rx * rx * yp * yp + ry * ry * xp * xp;
			if (k1 == 0)
				return null;

			k1 = Kean.Math.Single.SquareRoot(Kean.Math.Single.Absolute((rx * rx * ry * ry) / k1 - 1));
			if (this.Sweep == this.LargeArc)
				k1 = -k1;

			cxp = k1 * rx * yp / ry;
			cyp = -k1 * ry * xp / rx;

			cx = cosPhi * cxp - sinPhi * cyp + (x1 + x2) / 2;
			cy = sinPhi * cxp + cosPhi * cyp + (y1 + y2) / 2;

			k1 = (xp - cxp) / rx;
			k2 = (yp - cyp) / ry;
			k3 = (-xp - cxp) / rx;
			k4 = (-yp - cyp) / ry;

			Geometry2D.Single.Point first = new Geometry2D.Single.Point(k1, k2);
			Geometry2D.Single.Point second = new Geometry2D.Single.Point(k3, k4);
			float startAngle = Kean.Math.Geometry2D.Single.Point.BasisX.Angle(first);
			deltaTheta = first.Angle(second);
			/*
			// Start currentAngle
			k1 = (xp - cxp) / rx;
			k2 = (yp - cyp) / ry;
			k3 = (-xp - cxp) / rx;
			k4 = (-yp - cyp) / ry;

			k5 = Function.Single.Sqrt(k1 * k1 + k2 * k2);

			k5 = k1 / k5;
			if (k5 < -1)
				k5 = -1;
			else if (k5 > 1)
				k5 = 1;
			float startAngle = Function.Single.ArcCos(k5);
			if (k2 < 0)
				startAngle = -startAngle;

			// End currentAngle
			k5 = Function.Single.Sqrt((k1 * k1 + k2 * k2) * (k3 * k3 + k4 * k4));

			k5 = (k1 * k3 + k2 * k4) / k5;
			if (k5 < -1)
				k5 = -1;
			else if (k5 > 1)
				k5 = 1;
			deltaTheta = Function.Single.ArcCos(k5);
			if (k1 * k4 - k3 * k2 < 0)
				deltaTheta = -deltaTheta;
			*/
			if (this.Sweep && deltaTheta < 0)
				deltaTheta += Kean.Math.Single.Pi * 2;
			else if (!this.Sweep && deltaTheta > 0)
				deltaTheta -= Kean.Math.Single.Pi * 2;
			return Tuple.Create(new Geometry2D.Single.Point(cx, cy), startAngle, startAngle + deltaTheta);
		}
Esempio n. 17
0
		protected Text(Text original) :
			base(original)
		{
			this.Data = original.Data;
			this.Position = original.Position;
		}
Esempio n. 18
0
 bool ResetPage()
 {
     this.position = new Geometry2D.Single.Point();
     this.root = new Xml.Dom.Element("svg",
                                     KeyValue.Create("xmlns", "http://www.w3.org/2000/svg"),
                                     KeyValue.Create("version", "1.1"),
                                     KeyValue.Create("width", this.PageSize.Width.AsString()),
                                     KeyValue.Create("height", this.PageSize.Height.AsString()));
     return true;
 }
Esempio n. 19
0
		public Control()
		{
			this.DesignMode = this.DesignMode;
			this.SuspendLayout();
			// 
			// backend
			// 
			if (!this.DesignMode)
			{
				this.backend = Backend.Control.Create();
				this.backend.Initialized += () => this.Initialized.Call();
				#region Pointer Events Hookup
				this.backend.MouseClick += (sender, arguments) =>
				{
					Error.Log.Call((Action<System.Windows.Forms.MouseEventArgs>)(e =>
					{
						Geometry2D.Single.Point position = new Geometry2D.Single.Point(e.X, e.Y);
						switch (e.Button)
						{
							case System.Windows.Forms.MouseButtons.Left:
								this.PointerLeftClicked(position);
								break;
							case System.Windows.Forms.MouseButtons.Middle:
								this.PointerMiddleClicked(position);
								break;
							case System.Windows.Forms.MouseButtons.Right:
								this.PointerRightClicked(position);
								break;
						}
					}), arguments);
				};
				this.backend.MouseMove += (sender, arguments) =>
				{
					Error.Log.Call((Action<System.Windows.Forms.MouseEventArgs>)(e =>
					{
						Geometry2D.Single.Point currentPosition = new Geometry2D.Single.Point(e.X, e.Y);
						this.PointerMoved((Geometry2D.Single.Size)(currentPosition - this.lastPointerPosition), currentPosition, e.Button == System.Windows.Forms.MouseButtons.Left, e.Button == System.Windows.Forms.MouseButtons.Middle, e.Button == System.Windows.Forms.MouseButtons.Right);
						this.lastPointerPosition = currentPosition;
					}), arguments);
				};
				this.backend.MouseWheel += (sender, arguments) => Error.Log.Call((Action<System.Windows.Forms.MouseEventArgs>)(e => this.PointerWheelChanged(e.Delta / 120f, new Geometry2D.Single.Point(e.X, e.Y))), arguments);
				#endregion
				this.backend.Draw += renderer =>
				{
					using (Surface surface = new Surface(renderer))
					{
						surface.Use();
						surface.Transform = Geometry2D.Single.Transform.CreateTranslation(surface.Size / 2);
						this.Draw(surface);
						surface.Unuse();
					}
				};
				this.backend.AutoSize = true;
				this.backend.BackColor = System.Drawing.Color.Transparent;
				this.backend.Dock = System.Windows.Forms.DockStyle.Fill;
				this.backend.Location = new System.Drawing.Point(0, 0);
				this.backend.Name = "backend";
				this.backend.Size = new System.Drawing.Size(150, 150);
				this.backend.TabIndex = 0;
				this.backend.VSync = false;
				this.Controls.Add(this.backend);
			}
			// 
			// Control
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.Name = "Viewer";
			this.ResumeLayout(false);
			this.PerformLayout();
		}
Esempio n. 20
0
		protected override bool PointerLeftClick(Geometry2D.Single.Point position)
		{
			this.Position = position;
			return true;
		}
Esempio n. 21
0
		public CurveTo(Geometry2D.Single.Point first, Geometry2D.Single.Point second, Geometry2D.Single.Point end) :
			base(end)
		{
			this.First = first;
			this.Second = second;
		}
Esempio n. 22
0
		public Text(IPaint fill, Stroke stroke, Draw.Text text, Geometry2D.Single.Point position) :
			base(fill, stroke)
		{
			this.Data = text;
			this.Position = position;
		}