Я получаю тонны CGContextDrawPath: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
ошибок с этого кода. Он выполнен в SKScene. В основном я получаю рисунок пользователя на экране как SKShapeNode. Затем я заполняю путь рисования кругами по Core Graphics. Однако код работает медленно и дает мне массу ошибок. Я вроде как новый для Свифта. Можете ли вы помочь мне с тем, что происходит? Как я могу ускорить это? Как я могу предоставить собственный контекст CoreGraphics?Результаты рисования CoreGraphics в CGContextDrawPath: недопустимый контекст 0x0
let boundingBox = createdShape.frame
for j in stride(from: Int(boundingBox.minX), to: Int(boundingBox.maxX), by: 10) {
for i in stride(from: Int(boundingBox.minY), to: Int(boundingBox.maxY), by: 10) {
//for i in 0..<10 {
counter += 1
//let originalPoint = CGPoint(x: ((boundingBox.maxX - boundingBox.minX)/2)+boundingBox.minX, y: (boundingBox.maxY-CGFloat(i*10)))
//let originalPoint = CGPoint(x: CGFloat(j), y: (boundingBox.maxY-CGFloat(i*10)))
let originalPoint = CGPoint(x: CGFloat(j), y: (CGFloat(i)))
let point:CGPoint = self.view!.convert(originalPoint, from: self)
if (createdShape.path?.contains(createdShape.convert(originalPoint, from: self)))! {
let circlePath = UIBezierPath(arcCenter: point, radius: CGFloat(5), startAngle: CGFloat(0), endAngle:CGFloat(M_PI * 2), clockwise: true)
circlePath.fill()
let shapeLayer = CAShapeLayer()
shapeLayer.path = circlePath.cgPath
shapeLayer.fillColor = UIColor(red: 180/255, green: 180/255, blue: 180/255, alpha: 0.4).cgColor
shapeLayer.strokeColor = UIColor(red: 180/255, green: 180/255, blue: 180/255, alpha: 0.4).cgColor
shapeLayer.lineWidth = 0.0
view!.layer.addSublayer(shapeLayer)
}
}
}
Хорошо, похоже, вы смешиваете здесь 2 разных технологии, и вы сбиваетесь с толку. Вы не хотите иметь дело с основной графикой, – Knight0fDragon