示例#1
0
		private void RenderLineFromPoint (CGPoint start, CGPoint end)
		{
			int vertexCount = 0;
			if (vertexBuffer == null) {
				vertexBuffer = new nfloat [vertexMax * 2];
			}
			var count = Math.Max (Math.Ceiling (Math.Sqrt ((end.X - start.X) * (end.X - start.X) + (end.Y - start.Y) * (end.Y - start.Y)) / BrushPixelStep),
					1);
			for (int i = 0; i < count; ++i, ++vertexCount) {
				if (vertexCount == vertexMax) {
					vertexMax *= 2;
					Array.Resize (ref vertexBuffer, vertexMax * 2);
				}
				vertexBuffer [2 * vertexCount + 0] = start.X + (end.X - start.X) * (float) i / (float) count;
				vertexBuffer [2 * vertexCount + 1] = start.Y + (end.Y - start.Y) * (float) i / (float) count;
			}
			GL.VertexPointer (2, All.Float, 0, vertexBuffer);
			GL.DrawArrays (All.Points, 0, vertexCount);

			SwapBuffers ();
		}
示例#2
0
文件: PenHandler.cs 项目: picoe/Eto
			void SetDashStyle ()
			{
				if (DashStyle == null || DashStyle.IsSolid) {
					cgdashes = null;
				} else {
					// TODO: this is not quite perfect for Square/Round for small thicknesses
					
					var dashes = DashStyle.Dashes;
					cgoffset = DashStyle.Offset * Thickness;
					
					if (LineCap == CGLineCap.Butt)
						cgdashes = Array.ConvertAll (dashes, x => (nfloat)(x * Thickness));
					else {
						if (Math.Abs(Thickness - 1) < 0.01f)
							cgoffset += Thickness / 2;
						cgdashes = new nfloat[dashes.Length];
						for (int i = 0; i < cgdashes.Length; i++) {
							var dash = dashes [i] * Thickness;
							if ((i % 2) == 1) {
								// gap must include square/round thickness
								dash += Thickness;
							} else {
								// dash must exclude square/round thickness
								dash -= Thickness;
							}
							cgdashes [i] = dash;
						}
					}
				}
			}