private void ReadGlyph(Glyph glyph) { short numberOfContours = ReadInt16(); // Simple ? if (numberOfContours < 0) { throw new NotImplementedException("Compound glyphs not supported"); } double minx = ReadFUnit(); double miny = ReadFUnit(); double maxx = ReadFUnit(); double maxy = ReadFUnit(); var endPoints = ReadUInt16Array(numberOfContours); var instructionLength = ReadUInt16(); var instructions = _reader.ReadBytes(instructionLength); var numPoints = endPoints[endPoints.Length - 1] + 1; glyph.contours = new Contour[numberOfContours]; for (int i = 0, start = 0; i < numberOfContours; i++) { glyph.contours[i].start = start; glyph.contours[i].length = endPoints[i] - start + 1; start = endPoints[i] + 1; } // Read the flags. var flags = new PointFlags[numPoints]; for (int i = 0; i < numPoints;) { var readFlags = (PointFlags)_reader.ReadByte(); flags[i++] = readFlags; if (readFlags.HasFlag(PointFlags.Repeat)) { var repeat = _reader.ReadByte(); for (int r = 0; r < repeat; r++) { flags[i++] = readFlags; } } } glyph.points = new Point[numPoints]; glyph.size = new Vector2Double(maxx - minx, maxy - miny); glyph.bearing = new Vector2Double(minx, maxy); for (int i = 0; i < numPoints; i++) { glyph.points[i].curve = flags[i].HasFlag(PointFlags.OnCurve) ? CurveType.None : CurveType.Conic; glyph.points[i].xy = Vector2Double.Zero; } ReadPoints(glyph, flags, true); ReadPoints(glyph, flags, false); }
// Token: 0x0600002E RID: 46 RVA: 0x00002644 File Offset: 0x00000844 private static PointFlags clipFlagsToPointFlags(ClipFlags clipFlags) { PointFlags pointFlags = PointFlags.NONE; if ((clipFlags & ClipFlags.ClipLandStep) != ClipFlags.ClipNone) { pointFlags |= PointFlags.ONLAND; } else if ((clipFlags & ClipFlags.ClipLandUnder) != ClipFlags.ClipNone) { pointFlags |= PointFlags.UNDERLAND; } else if ((clipFlags & ClipFlags.ClipLandAbove) != ClipFlags.ClipNone) { pointFlags |= PointFlags.ABOVELAND; } else if ((clipFlags & ClipFlags.ClipLandKeep) != ClipFlags.ClipNone) { pointFlags |= PointFlags.KEEPLAND; } if ((clipFlags & ClipFlags.ClipDecalStep) != ClipFlags.ClipNone) { pointFlags |= PointFlags.DECAL; } else if ((clipFlags & ClipFlags.ClipDecalVertical) != ClipFlags.ClipNone) { pointFlags |= PointFlags.VDECAL; } if ((clipFlags & (ClipFlags)209715200) != ClipFlags.ClipNone) { pointFlags |= PointFlags.NOLIGHT; } else if ((clipFlags & (ClipFlags)212860928) != ClipFlags.ClipNone) { pointFlags |= PointFlags.FULLLIGHT; } else if ((clipFlags & (ClipFlags)211812352) != ClipFlags.ClipNone) { pointFlags |= PointFlags.HALFLIGHT; } else if ((clipFlags & (ClipFlags)210763776) != ClipFlags.ClipNone) { pointFlags |= PointFlags.AMBIENT; } if ((clipFlags & ClipFlags.ClipFogStep) != ClipFlags.ClipNone) { pointFlags |= PointFlags.NOFOG; } else if ((clipFlags & ClipFlags.ClipFogSky) != ClipFlags.ClipNone) { pointFlags |= PointFlags.SKYFOG; } int num = (int)((clipFlags & ClipFlags.ClipUserMask) / ClipFlags.ClipUserStep); return(pointFlags | (PointFlags)(65536 * num)); }
public void Join(Point other, float iw, bool bevelOrRound, float miterLimit, ref uint nleft, ref uint bevelCount) { Vector2D <float> dl0 = new(other.Determinant.Y, -other.Determinant.X); Vector2D <float> dl1 = new(Determinant.Y, -Determinant.X); MatrixDeterminant = new((dl0.X + dl1.X) * 0.5f, (dl0.Y + dl1.Y) * 0.5f); float dmr2 = (MatrixDeterminant.X * MatrixDeterminant.X) + (MatrixDeterminant.Y * MatrixDeterminant.Y); if (dmr2 > 0.000001f) { float scale = 1.0f / dmr2; scale = MathF.Min(scale, 600.0f); MatrixDeterminant *= scale; } Flags = ((Flags & PointFlags.Corner) != 0) ? PointFlags.Corner : 0; float cross = (Determinant.X * other.Determinant.Y) - (other.Determinant.X * Determinant.Y); if (cross > 0.0f) { nleft++; Flags |= PointFlags.Left; } float limit = MathF.Max(1.0f, MathF.Min(other.Length, Length) * iw); if ((dmr2 * limit * limit) < 1.0f) { Flags |= PointFlags.Innerbevel; } if ((Flags & PointFlags.Corner) != 0) { if ((dmr2 * miterLimit * miterLimit) < 1.0f || bevelOrRound) { Flags |= PointFlags.Bevel; } } if ((Flags & (PointFlags.Bevel | PointFlags.Innerbevel)) != 0) { bevelCount++; } }
private void ReadPoints(Glyph glyph, PointFlags[] flags, bool isX) { PointFlags byteFlag = isX ? PointFlags.XShortVector : PointFlags.YShortVector; PointFlags deltaFlag = isX ? PointFlags.XIsSame : PointFlags.YIsSame; double value = 0; for (int i = 0; i < glyph.points.Length; i++) { ref var point = ref glyph.points[i]; var pointFlags = flags[i]; if ((pointFlags & byteFlag) == byteFlag) { if ((pointFlags & deltaFlag) == deltaFlag) { value += _reader.ReadByte(); } else { value -= _reader.ReadByte(); } } else if ((pointFlags & deltaFlag) != deltaFlag) { value += ReadInt16(); } if (isX) { point.xy.x = value * _scale.x; } else { point.xy.y = value * _scale.y; } }
public PointSet(PointF[] pts, PointFlags settings) { this.points = pts; this.flags = settings; }
public Point(BinaryReaderEx input) : base(input) { PointFlags = (PointFlags)input.ReadInt32(); }
public Point(Vector3P pos, PointFlags flags) : base(pos.X, pos.Y, pos.Z) { PointFlags = flags; }
void ReadSimple(Stream stream, BinaryReader reader, int contourCount) { var endPointIndices = new int[contourCount]; for (short i = 0; i < contourCount; i++) endPointIndices[i] = reader.ReadUInt16(); int pointCount = endPointIndices.Last() + 1; int instructionLength = reader.ReadUInt16(); stream.Position += instructionLength; var flags = new PointFlags[pointCount]; int flagCount = 0; while (flagCount < pointCount) { PointFlags currentFlags = (PointFlags)reader.ReadByte(); flags[flagCount] = currentFlags; flagCount++; if (currentFlags.HasFlag(PointFlags.Repeat)) { int newCount = flagCount + reader.ReadByte(); for (; flagCount < newCount; flagCount++) flags[flagCount] = currentFlags; } } var xCoordinates = new List<int>[contourCount]; int contourIndex = 0; int previousX = 0; for (int i = 0; i < pointCount; i++) { if (xCoordinates[contourIndex] == null) xCoordinates[contourIndex] = new List<int>(); int x = flags[i].HasFlag(PointFlags.XShortVector) ? ((flags[i].HasFlag(PointFlags.XIsPositive) ? reader.ReadByte() : -reader.ReadByte()) + previousX) : (flags[i].HasFlag(PointFlags.XIsSame) ? previousX : (reader.ReadInt16() + previousX)); xCoordinates[contourIndex].Add(x); previousX = x; if (endPointIndices.Contains(i)) contourIndex++; } Contours = new List<ControlPoint>[contourCount]; contourIndex = 0; int pointIndex = 0; int previousY = 0; for (int i = 0; i < pointCount; i++) { if (Contours[contourIndex] == null) Contours[contourIndex] = new List<ControlPoint>(); int y = flags[i].HasFlag(PointFlags.YShortVector) ? ((flags[i].HasFlag(PointFlags.YIsPositive) ? reader.ReadByte() : -reader.ReadByte()) + previousY) : (flags[i].HasFlag(PointFlags.YIsSame) ? previousY : (reader.ReadInt16() + previousY)); Contours[contourIndex].Add(new ControlPoint(xCoordinates[contourIndex][pointIndex], y, flags[i].HasFlag(PointFlags.OnCurve))); previousY = y; if (endPointIndices.Contains(i)) { contourIndex++; pointIndex = 0; } else { pointIndex++; } } }
public PointSet(PointF[] pts, PointFlags settings) { this.points = pts; this.flags = settings; }
private void TesselateBezier(Vector2D <float> p1, Vector2D <float> p2, Vector2D <float> p3, Vector2D <float> p4, byte level, PointFlags flags) { if (level > MAX_TESSELATION_DEPTH) { return; } Vector2D <float> p12 = (p1 + p2) * 0.5f; Vector2D <float> p23 = (p2 + p3) * 0.5f; Vector2D <float> p34 = (p3 + p4) * 0.5f; Vector2D <float> p123 = (p12 + p23) * 0.5f; Vector2D <float> d = p4 - p1; float d2 = MathF.Abs((p2.X - p4.X) * d.Y - (p2.Y - p4.Y) * d.X); float d3 = MathF.Abs((p3.X - p4.X) * d.Y - (p3.Y - p4.Y) * d.X); if ((d2 + d3) * (d2 + d3) < _tessTol * (d.X * d.X + d.Y * d.Y)) { _pathCache.LastPath.AddPoint(p4, flags); return; } Vector2D <float> p234 = (p23 + p34) * 0.5f; Vector2D <float> p1234 = (p123 + p234) * 0.5f; TesselateBezier(p1, p12, p123, p1234, (byte)(level + 1), 0); TesselateBezier(p1234, p234, p34, p4, (byte)(level + 1), flags); }
void ReadSimple(Stream stream, BinaryReader reader, int contourCount) { var endPointIndices = new int[contourCount]; for (short i = 0; i < contourCount; i++) { endPointIndices[i] = reader.ReadUInt16(); } int pointCount = endPointIndices.Last() + 1; int instructionLength = reader.ReadUInt16(); stream.Position += instructionLength; var flags = new PointFlags[pointCount]; int flagCount = 0; while (flagCount < pointCount) { PointFlags currentFlags = (PointFlags)reader.ReadByte(); flags[flagCount] = currentFlags; flagCount++; if (currentFlags.HasFlag(PointFlags.Repeat)) { int newCount = flagCount + reader.ReadByte(); for (; flagCount < newCount; flagCount++) { flags[flagCount] = currentFlags; } } } var xCoordinates = new List <int> [contourCount]; int contourIndex = 0; int previousX = 0; for (int i = 0; i < pointCount; i++) { if (xCoordinates[contourIndex] == null) { xCoordinates[contourIndex] = new List <int>(); } int x = flags[i].HasFlag(PointFlags.XShortVector) ? ((flags[i].HasFlag(PointFlags.XIsPositive) ? reader.ReadByte() : -reader.ReadByte()) + previousX) : (flags[i].HasFlag(PointFlags.XIsSame) ? previousX : (reader.ReadInt16() + previousX)); xCoordinates[contourIndex].Add(x); previousX = x; if (endPointIndices.Contains(i)) { contourIndex++; } } Contours = new List <ControlPoint> [contourCount]; contourIndex = 0; int pointIndex = 0; int previousY = 0; for (int i = 0; i < pointCount; i++) { if (Contours[contourIndex] == null) { Contours[contourIndex] = new List <ControlPoint>(); } int y = flags[i].HasFlag(PointFlags.YShortVector) ? ((flags[i].HasFlag(PointFlags.YIsPositive) ? reader.ReadByte() : -reader.ReadByte()) + previousY) : (flags[i].HasFlag(PointFlags.YIsSame) ? previousY : (reader.ReadInt16() + previousY)); Contours[contourIndex].Add(new ControlPoint(xCoordinates[contourIndex][pointIndex], y, flags[i].HasFlag(PointFlags.OnCurve))); previousY = y; if (endPointIndices.Contains(i)) { contourIndex++; pointIndex = 0; } else { pointIndex++; } } }
public Point(Vector2D <float> position, PointFlags flags) { Position = position; Flags = flags; }