Porterduff模式DST_IN在路径周围绘制矩形

时间:2018-07-11 01:23:47

标签: android canvas path mask

我试图绘制一条路径,然后使用DST_IN Porterduff模式用另一条路径遮罩它。

这是我做绘图的代码块

public static void populateGamedata(string gameDataFileName)
{
    if (gameDataFileName == null)
        return;
    // Path.Combine combines strings into a file path
    // Application.StreamingAssets points to Assets/StreamingAssets in the Editor, and the StreamingAssets folder in a build        
    string filePath = Path.Combine(Application.streamingAssetsPath, gameDataFileName);
    if (File.Exists(filePath))
    {
        // Read the json from the file into a string
        string dataAsJson = File.ReadAllText(filePath);
        // Pass the json to JsonUtility, and tell it to create a ContentJson object from it
        ContentJson gameData = JsonUtility.FromJson<ContentJson>(dataAsJson);

        // Retrieve the levels and funfacts property of gameData
        levels = gameData.allLevels;
        funFacts = gameData.funFacts;
        Debug.Log("dataAsJson === " + dataAsJson);
        Debug.Log("gameData == " + gameData.ToString());
        Debug.Log("levels == " + levels[0].name);            
    }
    else
    {
        Debug.LogError("Cannot load game data!");
    }
}

这可以进行遮罩,但路径周围还有一个矩形,超出该范围遮罩将无法使用,如下所示。外星是原始路径,斑点是遮蔽路径。您会看到该Blob具有矩形边框,超过该边框遮罩将不起作用 enter image description here

请注意,这仅在启用硬件加速后才起作用。这是预期的吗?

0 个答案:

没有答案