public static Vec4f ToVec4f(this Color3b color) { ColorSetter3f setter = new ColorSetter3f(); color.GetColor(setter); return(new Vec4f(setter.C1, setter.C2, setter.C3, 1)); }
public static void GenerateMSDF(Bitmap <Color3b> output, Shape shape, Rectangle region, double range, Vector2 scale, Vector2 translate, double edgeThreshold) { int contourCount = shape.Contours.Count; int[] windings = new int[contourCount]; for (int i = 0; i < shape.Contours.Count; i++) { windings[i] = shape.Contours[i].Winding; } int xStart = Math.Min(Math.Max(0, (int)region.Left), output.Width); int yStart = Math.Min(Math.Max(0, (int)region.Top), output.Height); int xEnd = Math.Min(Math.Max(0, (int)region.Right), output.Width); int yEnd = Math.Min(Math.Max(0, (int)region.Bottom), output.Height); MultiDistance[] contourSD = new MultiDistance[contourCount]; for (int y = yStart; y < yEnd; y++) { int row = shape.InverseYAxis ? yEnd - (y - yStart) - 1 : y; for (int x = xStart; x < xEnd; x++) { Vector2 p = (new Vector2(x, y) - region.Position - translate) / scale; output[x, row] = new Color3b(EvaluateMSDF(shape, windings, contourSD, p, range)); } } }
public static Vec4ub ToVec4ub(this Color3b color) { return(new Vec4ub(color.Red, color.Green, color.Blue, 255)); }