示例#1
0
    public void Despeckle(ref Texture2D tex, Color backgroundColor,
                          LonePixelEvaluationMode configurationLonePixelEvaluationMode)
    {
        for (var column = 0; column < tex.width; column++)
        {
            for (var row = 0; row < tex.height; row++)
            {
                switch (configurationLonePixelEvaluationMode)
                {
                case LonePixelEvaluationMode.CardinalDirectionsOnly:
                    if (BooleanPixel4WayContext.GetContext(new Vector2Int(column, row), tex, backgroundColor).IsSpeckle())
                    {
                        tex.SetPixel(column, row, backgroundColor);
                    }
                    break;

                case LonePixelEvaluationMode.IncludeDiagonals:
                    if (BooleanPixel8WayContext.GetPixelContext(tex, column, row, backgroundColor).IsSpeckle())
                    {
                        tex.SetPixel(column, row, backgroundColor);
                    }
                    break;
                }
            }
        }
    }
示例#2
0
    void AttemptToOutline(ref Texture2D texture, Color backgroundColor, Vector2Int coordinates)
    {
        var pixelContext = BooleanPixel4WayContext.GetContext(coordinates, texture, backgroundColor);

        if (pixelContext.AnyAdjacentNonBackgroundPixels()) //TODO: or has a color and adjacent to end of texture
        {
            outlineCoordinates.Add(new Vector2Int(coordinates.x, coordinates.y));
        }
    }