I need to use a SVG icon to make masked image with appropriated colour. (Same as UIImageView creates it for UIImages with UIImage.RenderingMode.alwaysTemplate) For this I've wrote a code:
func coloredNode(_ node: Node, withColor color: UIColor) -> Node {
let cloner = FASVGNodeDuplicator()
let maskNode = cloner.clone(node)
let locus = node.bounds ?? Rect(x: 0.0, y: 0.0, w: 28.0, h: 28.0)
let imageNode = Shape(form: locus,
fill: Color(withColor: color),
mask: maskNode)
return imageNode
}
bounds always presents, therefore a code Rect(x: 0.0, y: 0.0, w: 28.0, h: 28.0) never will called.
For example, my icon has size 2626, on a screen with 2x, it will drawn with pixel size 5252. I saw that result has blurred lines. After some research I've found that in method getMaskedImage generated CGImage mask with size 26*26. It produces blurred result:
How I can make mask with an alpha component of a node with respects of a screen scale?
I need to use a SVG icon to make masked image with appropriated colour. (Same as UIImageView creates it for UIImages with UIImage.RenderingMode.alwaysTemplate) For this I've wrote a code:
bounds
always presents, therefore a codeRect(x: 0.0, y: 0.0, w: 28.0, h: 28.0)
never will called.For example, my icon has size 2626, on a screen with 2x, it will drawn with pixel size 5252. I saw that result has blurred lines. After some research I've found that in method
getMaskedImage
generated CGImage mask with size 26*26. It produces blurred result:How I can make mask with an alpha component of a node with respects of a screen scale?