swift-在黑色像素处停止绘制线(不越界)
我正在创建“绘画”应用程序,遇到了一个问题 用来画我正在使用的线条swift-在黑色像素处停止绘制线(不越界),swift,core-graphics,Swift,Core Graphics,我正在创建“绘画”应用程序,遇到了一个问题 用来画我正在使用的线条 func draw() { guard let ctx = UIGraphicsGetCurrentContext() else { return } ctx.setShouldAntialias(false) ctx.addPath(path) ctx.setLineCap(.round) ctx.setLineWidth(lineWidth)
func draw() {
guard let ctx = UIGraphicsGetCurrentContext() else { return }
ctx.setShouldAntialias(false)
ctx.addPath(path)
ctx.setLineCap(.round)
ctx.setLineWidth(lineWidth)
ctx.setStrokeColor(lineColor.cgColor)
ctx.setBlendMode(.normal)
ctx.setAlpha(lineAlpha)
ctx.strokePath()
}
在哪里
所以图像是黑白的,我需要检测黑边界并在穿越之前停止我的线路。有没有办法做到这一点
我试图获取路径上的一系列点并检查黑色的点,但这种方法没有成功
任何建议都会对我有帮助
path = CGMutablePath.init()