Open CoderMaurice opened 5 years ago
Hi! Yeah the PencilKit is very exciting, i haven't had a chance to play with it too much yet, but very promising. I hope they eventually offer access to the underlying vector data one day too.
For rendering, i've been able to get very clean edges using CAShapeLayer
. I create those layers, then add them as sublayers in a UIView, and apply a transform to that UIView
to scale it all up/down. I'm surprised you're seeing pixelation with those, they should be very crisp. do you have an example project showing the pixelation issue?
Another option would be to use CATiledLayer
. You can look at their PDF rendering sample code here: https://developer.apple.com/library/archive/samplecode/ZoomingPDFViewer/Introduction/Intro.html
Their TiledPDFView
uses a CATiledLayer
to render a PDF very very cleanly regardless of zoom level. When watching their WWDC video about PencilKit, I noticed they used the term "tiles" when describing their rendering, so it wouldn't surprise me if they're using a CATiledLayer
somehow in their PKCanvasView
as well.
I'm exploring some other rendering methods at https://github.com/adamwulf/DrawUI. There's not much there at the moment, but I plan to add support for zoom and show a number of a different rendering methods and so trade-offs are easy to compare.
I used CAShapeLayer, but I found it to be just a fixed-width path, unable to reflect the thickness of the stroke when accelerating, and I want to customize the various pens, I did not get the answer on CAShapeLayer
ah yes, it's significantly harder to get that smooth width gradient because of the fixed lineWidth property. That's something i'm hoping to experiment with in the DrawUI stuff, so maybe there will be an option there soon.
Hi Adam, I was working on a drawing board project six months ago, and your JotUI gave me a lot of help, thanks again, I am very grateful for your help.. Now a new framework called PencilKit appears on iOS13 that allows developers to easily add canvas features. I once asked you about the jagged problem of strokes on JotUI due to rasterization #41 , I studied CAShapeLayer and finally found that it might not show smooth handwritten strokes. But in the PencilKit's canvas, no matter how thin the strokes are, there is no jaggedness. The same technique appears on other drawing applications on the appstore, such as SketchBook. I have been searching for a long time but still don't know how it is implemented. Do you know how this is done?
Best regards, Maurice