MaLiang icon indicating copy to clipboard operation
MaLiang copied to clipboard

lag if set canvas inside scroll view , and canvas has bouds more than 2500

Open VJosan opened this issue 4 years ago • 6 comments

i make drawing app, and if i set brish width like 250 and canvas bounds is 2500+ it have big lags

VJosan avatar Oct 07 '20 14:10 VJosan

MaLiang's Canvas is not compatiable with UIScrollView, please use ScrollableCanvas instead

Harley-xk avatar Oct 09 '20 00:10 Harley-xk

but, if use not with scrollaview, how to zoom/move background image , and one more question, with MaLiang`s can draw with glitter? i mean can i set color like this func createGlitterColor(image: UIImage, forBG: Bool = false) -> UIColor{ let glitterImage = image let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: forBG ? 80 : 800, height: forBG ? 80 : 800))

imageView.image = glitterImage
imageView.contentMode = .scaleAspectFit
let layer = imageView.layer
UIGraphicsBeginImageContextWithOptions(imageView.layer.frame.size, false, 0)

guard let cgContext = UIGraphicsGetCurrentContext() else
{
    return .white
}
layer.render(in: cgContext)
guard let screenshot = UIGraphicsGetImageFromCurrentImageContext() else
{
    return .white
}
UIGraphicsEndImageContext()

let glitterColor = UIColor.init(patternImage: screenshot)
return glitterColor

}

VJosan avatar Oct 09 '20 07:10 VJosan

Zoom background with canvas is truly the problem now. In fact there's many problem with scrolling too. Zoomming feature is only at toy level currently. I'm not quite understand what glitter is? can you show me some examples?

Harley-xk avatar Oct 10 '20 07:10 Harley-xk

glitter is a image, so in upper function is describe how it work, it like copy multiple time photo, and paste with brush when you draw, so you draw with image :D

VJosan avatar Oct 12 '20 07:10 VJosan

@VJosan If you are tring to draw an image to the canvas, just use the Chartlet apis

Harley-xk avatar Oct 12 '20 08:10 Harley-xk

yeah, i tryed

VJosan avatar Oct 12 '20 08:10 VJosan