PencilKit

RSS for tag

Capture touch input as an opaque drawing and turn it into high-quality images that can be displayed on iOS and macOS using PencilKit.

Posts under PencilKit tag

137 Posts

Post

Replies

Boosts

Views

Activity

PencilKit ColorPicker in ToolPicker color mode mismatch
I'm currently using PencilKit in an app that is forced to run in dark mode (UIUserInterfaceStyle == Dark in Info.plist). But for one UIViewController only, I'm using the light mode for note taking with PencilKit. I change the ToolPicker style by using toolPicker.overrideUserInterfaceStyle = .light and it works great that way. Unfortunately, if I want a custom color and I tap on the ColorPicker icon, it seems to still be in dark mode, because when I choose white, it draws black, and if I choose black, it draws black. This doesn't happen if I tap the black color in the predefined palette (not the color picker). Any idea how to force to color picker to respect the tool picker userInterfaceStyle?
2
2
2.2k
Jun ’22
How to build a flood fill tool in PencilKit?
I want to create a flood fill (aka paint bucket) tool with PencilKit. I am aware of the way to inspect the PKStrokes to identify an enclosed space to fill inside of them but I'm not sure the way to create the internal shape inside that space. Any suggestion or leads would be appreciated. Thanks in advance and please have a beautiful day.
1
0
1.4k
May ’22
High CPU usage (167%) just by scrolling canvasView in the sample project
In the sample project "Drawing with PencilKit", even scrolling by 1 pixel can cause my iPad Pro to use 167% CPU and keep this usage for 2-5 seconds. My iPad got too hot after few minutes that I can't barely put my palm on it. This a serious problem and could be reprocedure easily: Run the sample "Drawing with PencilKit" on your iPad Open the sample note Select all strokes in the note and duplicate about 7 times (it is just an average number of strokes I write in a page on a note-taking app like GoodNotes). Scroll and watch the CPU usage jumps in Xcode It is not matter how long you scroll or how many strokes are visible on the screen. If the drawing has that much strokes, the CoreHandwriting objects will eat all the CPU. I hope it got fixed soon because it make apps with PencilKit consume too much baterry, getting too hot and we receive many bad review because of it :( Many thank to Pencil and Paperteam for developing this Framework btw, this framework is awesome, but it could be better, I believe.
0
0
1.2k
May ’22
Is it a bug of PencilKit?
When I use pencil or highlighter of PencilKit on debug, and write it quickly, it'll crash. But it's fine on release the error message: -[MTLDebugCommandBuffer lockPurgeableObjects]:2103: failed assertion `MTLResource 0x2816cd0a0 (label: (null)), referenced in cmd buffer 0x11a041400 (label: Live rendering command buffer) is in volatile or empty purgeable state at commit' is it a bug, or am I making something wrong?
1
0
1.1k
Apr ’22
PencilKit clearing canvas not always working
I am building a PencilKit app that interprets a canvasView.drawing's size. Drawings below a certain size are interpreted as tap gestures and get cleared in the interpretation process. Effectively, I am doing it like this: func canvasViewDrawingDidChange(_ canvasView: PKCanvasView) { // Check if drawing is empty, // otherwise this would loop guard !canvasView.drawing.bounds.isEmpty else { return } if canvasView.drawing.bounds.width 10 && canvasView.drawing.bounds.height 10 { canvasView.drawing = PKDrawing() handleDetectedTapGesture() } } On my 2020 iPad Pro, this works flawlessly. On other iPads however, I observe a strange behaviour: In a series of drawing little specks on the canvas that are all supposed to be cleared immediately, sometimes the canvas seems to not be cleared, a single speck stays visible. After I draw the next speck somewhere else, the clearing is functional again, which means the canvas was internally emptied, the visible state was just not up-to-date. Finger input on the canvas is deactivated. The canvas tool is set to pencil, width 5.0. Does anybody have an idea what could be the reason for this behaviour?
1
0
1.6k
Mar ’22
PKCanvasView acting weird after it's resized
Every time I resize the PKCanvasView on a button tap, PKCanvasView, sometimes a few strokes later, sometimes on the first stroke after resize, removes all strokes except the one currently being drawn & this happens as soon as I start to draw. Then, when I lift the pencil up & away from screen, all previous strokes become visible except the one I just drew. And then, on the very next stroke, the drawing is updated correctly, with all strokes correctly visible. This is how I update the view when it's resized: UIView.animate(withDuration: 0.3, animations: { self.descriptionPane.isHidden = self.canvasToggle.isSelected (self.descriptionPane.superview as! UIStackView).layoutIfNeeded() self.currentMaxZoomScale = self.canvasToggle.isSelected ? (self.canvasView.bounds.width / oldCanvasRect.width) : 1 self.canvasView.maximumZoomScale = self.currentMaxZoomScale self.canvasView.setZoomScale(self.currentMaxZoomScale, animated: false) self.canvasView.setContentOffset(CGPoint(x: 0,y: 0), animated: false) }, completion: { isComplete in self.canvasToggle.isUserInteractionEnabled = true self.canvasView.isUserInteractionEnabled = true }) I more often than not see the following warning when I this problem occurs. [Stroke Generator] Missed updates at end of stroke: 2 (total points: 69) Could anyone guide me on how I should approach this problem? Is it even a good idea to resize the canvas?
0
0
849
Mar ’22
PencilKit crashing on iOS 15.1 on iPad
I am starting to work with PencilKit and have a small sample app set up with Swift. When I draw a line too long it will crash from com.apple.pencilkit.renderer with the following: -[MTLDebugCommandBuffer lockPurgeableObjects]:2103: failed assertion `MTLResource 0x280584a10 (label: (null)), referenced in cmd buffer 0x107019400 (label: Live rendering command buffer) is in volatile or empty purgeable state at commit' I can draw lots of small lines without issue. Doesn't seem to matter what size the canvas is or any other specific attributes I can determine. It's a quick sample so there's really not much going on, and this appears to be coming from pencil kit and metal under the hood. I am using an iPad pro, iOS 15.1 and a pencil2 and using finger to draw with the same crash if it helps.
4
0
2k
Mar ’22
Using PencilKit with PDFKit
I'm developing an app that allows you to view PDFs (music notes). I'm using PDFkit to display the pdf and need the pencilkit functionality while viewing the pdf (in the same way that you could mark up a book you are reading in iBooks when you click on the "Mark up" button). I am able to add a canvas on top of the pdf view however, I cannot save the canvas to be merged with the PDF. QuickLook offers a solution because the pencilkit looks to be built into it and works perfectly just the way I need it to, however, I don't need the other things that come with QuickLook. I desperately need your help with how I can get the pencilkit functionality on my custom PDF viewing app. At this point, I can't even find a solution for the "Mark up" button (pencil.tip.crop.circle) to be filled when tapped. Thank you in advance!
2
0
2.1k
Jan ’22
PencilKit Path raw points
I've got a question about PKPoint processing. I've got an application where I have to get both image and points which generated this image. However I've checked that points have been already interpolated, so there's no way to get raw points (which I thought should be similar to display's refresh rate x seconds requested to draw). Is there a way to get raw points (not processed) and not interpolated points?
0
0
536
Dec ’21
converting PKDrawing to NSImage fails
Hi. My goal is to convert PKDrawing to NSImage on Mac Server. For this, I use Vapor framework and receive POST request with PKDraiwng's base64 string(from PKDrawing.dataRepresentaion()). However, this task succeeds on local device, but fails on Remote Mac server. (with exact same logic & data) In failing cases, input base64 string was successfully converted to PKDrawing, but PKDrawing to NSImage converting was failed. (NSImage object is located at 0x000000 memory address) Is there any hardware dependencies to convert PKDrawing to NSImage? Please give me some help. let base64String = "d3Jk8AEACAASEAAAAAAAAAAAAAAAAAAAAAASECTanLurR0TesQ6DbJmhcB4aBggAEAAYABoGCAEQARgBIi4KFA39/Hw/FcXERD4dhYSEPiXNzEw/EhRjb20uYXBwbGUuaW5rLm1hcmtlchgDKuMHChDT0UH2JnhFKJXSKOjPQ4MBEgYIABABGAEaBggAEAEYACAAKp8HChD+PS4PhSlOD4NNWagXDeasEXgNipZotcNBGCwg4wMoHDIIAABcQegDAAA68AZww4BBYPKVQgAAAADNABSQwlXQOFhkkEEAiZhCaJFtPSkB0o7CVQhBMDaaQcBDlkLn+6k9OAHOjsJVX0IQuaRBUDOSQs3MzD04Ac6OwlVfQvA7r0HQS41CQmDlPTABzo7CVV9CsPq2QYC7iEKPwvU9JgHOjsJVqUGArrtBYPaFQgAAAD4mAc6OwlXCQOCNv0GQCINCkxgEPiYBzo7CVcJAQG3DQSDkf0InMQg+JwHOjsJV2kAIcMdBwAh5QrpJDD4qAc6OwlUoQWCeykEA3HFCTmIQPi4Bzo7CVX1BGD/NQeBdakLhehQ+MwHOjsJV80HYkNBBQJphQpqZGT45Ac6OwlV5QoDP0UEgHFpCLbIdPj0Bzo7CVdBCkDHTQQCeUkLByiE+QAHOjsJVGEM4cNRB4MJKQlTjJT5BAc6OwlU/Q0jS1UHARENC5/spPkMBzo7CVVtD6F/WQUB1O0J7FC4+QwHOjsJVW0MAc9hBQAMyQjMzMz5DAc6OwlVbQ6ix2UEghSpCx0s3PkMBzo7CVVtDuBPbQQAHI0JaZDs+QwHOjsJVW0NoA91BQNobQu58Pz5DAc6OwlVbQyCk30GAChVCgZVDPkMBzo7CVVtDeNLiQYCADkIUrkc+QwHOjsJVW0M4JOZBYAIHQs3MTD5DAc6OwlVbQ1hV7UFA2/lB9P1UPkMBzo7CVVtDgDf1QUD35kEbL10+QwHmjsJVW0PYGwFCwM7OQfp+aj5DAamPWVVbQ8y1BkKA0r9BtMh2PkMBJJD/VFtDkJYMQgC+tEFKDII+QwGIkMZUW0OwxxNCgDOwQXE9ij4/AeCQtFRbQ6jwG0IAebFBqvGSPjgB/ZC0VAdDyCEjQkDqvUGamZk+OAH9kLRUW0JsqypCACzOQXe+nz44Af2QtFRbQtzsL0JA49lBCtejPjgB/ZC0VFtCHHU1QoCa5UGwcqg+OAH9kLRUbUKMtjpCQAzwQUSLrD4+Af2QtFTqQnifP0KAfvhB16OwPkYB/ZC0VJ1DaBdHQoDJAULHS7c+UQH9kLRUoUQ0qU1CIL0EQqRwvT5XAf2QtFQtRXziU0JADgZCkxjEPlkB/ZC0VFdFgEtfQkCxBUJg5dA+WQH9kLRUV0XQNWZC4BoCQj0K1z7zAP2QtFRXRWRdbELAIPtB46XbPkwA/ZC0VD4tMhQNAACgQBUAAGBBHQAAhEIlAACMQkDAn9OfkwU6BggAEAAYAEIQxjieV95cTuaAtuVXCPxhZA==" let drawingData: PKDrawing = try! .init(data: Data(base64Encoded: base64String)!) let image = drawingData.image(from: drawingData.bounds, scale: 2) // -> fails
0
0
583
Dec ’21
Apple Pencil azimuth not working
I have a drawing app that I created and have sold on the App Store since 2018. It requires an Apple Pencil. My app uses the azimuth feature to orient the brush pattern that is drawn on the screen. A user just contacted me and said his azimuth feature is not working. Now it works fine for me, and I have not heard complaints from other users, so this leads me to believe it could be a problem with his Pencil. I wanted to show my code just to rule out that the problem is on my end and also get suggestions on what I should tell this user to do. Should he just contact Apple about it?                      // calculate the pencil direction let vector1 = touch.azimuthUnitVector(in: selectedCanvas) let angle = atan2(vector1.dy, vector1.dx) let azimu = angle - CGFloat(Double.pi) / 2.0 // adjust for wonky azimuth rotation translation if azimu >= -4.5 && azimu <= 0 {       rot = abs(azimu) } else {        rot = 6.2 - azimu } The azimu is then used as a point rotation in a basic Bézier curve and drawn on the screen. If it works on one iPad, it should work on all of them, right? He’s using an iPad Pro and so am I. I asked if he was using an Apple Pencil and he said yes.
0
0
793
Nov ’21
PencilKit lasso tool does not focus on the pasted stroke
I am trying to use the PencilKit to build a note App. One of the issue I had was that if I use the lasso tool to select and copy a stroke, and pasted the stroke that I copied, the lasso tool focuses on the original stroke instead of the newly pasted one. Wondering if anyone have the same issue, and how can I solve it? I uploaded a demo git in stack overflow
Replies
0
Boosts
0
Views
551
Activity
Jun ’22
PencilKit ColorPicker in ToolPicker color mode mismatch
I'm currently using PencilKit in an app that is forced to run in dark mode (UIUserInterfaceStyle == Dark in Info.plist). But for one UIViewController only, I'm using the light mode for note taking with PencilKit. I change the ToolPicker style by using toolPicker.overrideUserInterfaceStyle = .light and it works great that way. Unfortunately, if I want a custom color and I tap on the ColorPicker icon, it seems to still be in dark mode, because when I choose white, it draws black, and if I choose black, it draws black. This doesn't happen if I tap the black color in the predefined palette (not the color picker). Any idea how to force to color picker to respect the tool picker userInterfaceStyle?
Replies
2
Boosts
2
Views
2.2k
Activity
Jun ’22
How to build a flood fill tool in PencilKit?
I want to create a flood fill (aka paint bucket) tool with PencilKit. I am aware of the way to inspect the PKStrokes to identify an enclosed space to fill inside of them but I'm not sure the way to create the internal shape inside that space. Any suggestion or leads would be appreciated. Thanks in advance and please have a beautiful day.
Replies
1
Boosts
0
Views
1.4k
Activity
May ’22
Apple pencil battery jumped from 34% to 100%
I connected my pencil to charge but the number didn’t change even after a while. I forget/reconnect it, and the battery was full (it was 34% before). Why did that happen?
Replies
1
Boosts
0
Views
680
Activity
May ’22
Apple pencil 2 Scribble in the latest IpadOS 15.5
Hi everyone, i have two questions about pencil 2 that how many language does it support using scribble? At the present, i know it supports english and japanese. The second quesion is... How long can its battery use in once full charge? Thanks
Replies
1
Boosts
0
Views
1.3k
Activity
May ’22
High CPU usage (167%) just by scrolling canvasView in the sample project
In the sample project "Drawing with PencilKit", even scrolling by 1 pixel can cause my iPad Pro to use 167% CPU and keep this usage for 2-5 seconds. My iPad got too hot after few minutes that I can't barely put my palm on it. This a serious problem and could be reprocedure easily: Run the sample "Drawing with PencilKit" on your iPad Open the sample note Select all strokes in the note and duplicate about 7 times (it is just an average number of strokes I write in a page on a note-taking app like GoodNotes). Scroll and watch the CPU usage jumps in Xcode It is not matter how long you scroll or how many strokes are visible on the screen. If the drawing has that much strokes, the CoreHandwriting objects will eat all the CPU. I hope it got fixed soon because it make apps with PencilKit consume too much baterry, getting too hot and we receive many bad review because of it :( Many thank to Pencil and Paperteam for developing this Framework btw, this framework is awesome, but it could be better, I believe.
Replies
0
Boosts
0
Views
1.2k
Activity
May ’22
any updates about Snap to Shape feature's public availability ?
i read year old post here https://developer.apple.com/forums/thread/650386?answerId=628394022#reply-to-this-question , where it is said it's not available for everyone right now. does anyone have any info about this when snap to Shape and writing to text might be available for every one ?
Replies
0
Boosts
0
Views
672
Activity
May ’22
iPad OS 15.5 beta 3/Apple Pencil/Magic Keyboard issue
Seeing an issue with 15.5 beta 3, where the Apple Pencil disconnects from the iPad Pro 3rd gen when the iPad is also connected to the Magic Keyboard. Once I disconnect the keyboard the Apple Pencil works again. Anyone else seeing this?
Replies
2
Boosts
0
Views
1.3k
Activity
May ’22
Is it a bug of PencilKit?
When I use pencil or highlighter of PencilKit on debug, and write it quickly, it'll crash. But it's fine on release the error message: -[MTLDebugCommandBuffer lockPurgeableObjects]:2103: failed assertion `MTLResource 0x2816cd0a0 (label: (null)), referenced in cmd buffer 0x11a041400 (label: Live rendering command buffer) is in volatile or empty purgeable state at commit' is it a bug, or am I making something wrong?
Replies
1
Boosts
0
Views
1.1k
Activity
Apr ’22
PencilKit clearing canvas not always working
I am building a PencilKit app that interprets a canvasView.drawing's size. Drawings below a certain size are interpreted as tap gestures and get cleared in the interpretation process. Effectively, I am doing it like this: func canvasViewDrawingDidChange(_ canvasView: PKCanvasView) { // Check if drawing is empty, // otherwise this would loop guard !canvasView.drawing.bounds.isEmpty else { return } if canvasView.drawing.bounds.width 10 &amp;&amp; canvasView.drawing.bounds.height 10 { canvasView.drawing = PKDrawing() handleDetectedTapGesture() } } On my 2020 iPad Pro, this works flawlessly. On other iPads however, I observe a strange behaviour: In a series of drawing little specks on the canvas that are all supposed to be cleared immediately, sometimes the canvas seems to not be cleared, a single speck stays visible. After I draw the next speck somewhere else, the clearing is functional again, which means the canvas was internally emptied, the visible state was just not up-to-date. Finger input on the canvas is deactivated. The canvas tool is set to pencil, width 5.0. Does anybody have an idea what could be the reason for this behaviour?
Replies
1
Boosts
0
Views
1.6k
Activity
Mar ’22
PKCanvasView acting weird after it's resized
Every time I resize the PKCanvasView on a button tap, PKCanvasView, sometimes a few strokes later, sometimes on the first stroke after resize, removes all strokes except the one currently being drawn & this happens as soon as I start to draw. Then, when I lift the pencil up & away from screen, all previous strokes become visible except the one I just drew. And then, on the very next stroke, the drawing is updated correctly, with all strokes correctly visible. This is how I update the view when it's resized: UIView.animate(withDuration: 0.3, animations: { self.descriptionPane.isHidden = self.canvasToggle.isSelected (self.descriptionPane.superview as! UIStackView).layoutIfNeeded() self.currentMaxZoomScale = self.canvasToggle.isSelected ? (self.canvasView.bounds.width / oldCanvasRect.width) : 1 self.canvasView.maximumZoomScale = self.currentMaxZoomScale self.canvasView.setZoomScale(self.currentMaxZoomScale, animated: false) self.canvasView.setContentOffset(CGPoint(x: 0,y: 0), animated: false) }, completion: { isComplete in self.canvasToggle.isUserInteractionEnabled = true self.canvasView.isUserInteractionEnabled = true }) I more often than not see the following warning when I this problem occurs. [Stroke Generator] Missed updates at end of stroke: 2 (total points: 69) Could anyone guide me on how I should approach this problem? Is it even a good idea to resize the canvas?
Replies
0
Boosts
0
Views
849
Activity
Mar ’22
PencilKit crashing on iOS 15.1 on iPad
I am starting to work with PencilKit and have a small sample app set up with Swift. When I draw a line too long it will crash from com.apple.pencilkit.renderer with the following: -[MTLDebugCommandBuffer lockPurgeableObjects]:2103: failed assertion `MTLResource 0x280584a10 (label: (null)), referenced in cmd buffer 0x107019400 (label: Live rendering command buffer) is in volatile or empty purgeable state at commit' I can draw lots of small lines without issue. Doesn't seem to matter what size the canvas is or any other specific attributes I can determine. It's a quick sample so there's really not much going on, and this appears to be coming from pencil kit and metal under the hood. I am using an iPad pro, iOS 15.1 and a pencil2 and using finger to draw with the same crash if it helps.
Replies
4
Boosts
0
Views
2k
Activity
Mar ’22
PKCanvasView and document based App
I created a document based app with SwiftUI and a PKCanvasView. Now I want to save the drawings of the PKCanvasView inside of the file. How can I do this?
Replies
0
Boosts
0
Views
1.1k
Activity
Jan ’22
How to use 'dataRepresentation()' with PKCanvasView in Swift?
The title is my question.
Replies
0
Boosts
0
Views
819
Activity
Jan ’22
Using PencilKit with PDFKit
I'm developing an app that allows you to view PDFs (music notes). I'm using PDFkit to display the pdf and need the pencilkit functionality while viewing the pdf (in the same way that you could mark up a book you are reading in iBooks when you click on the "Mark up" button). I am able to add a canvas on top of the pdf view however, I cannot save the canvas to be merged with the PDF. QuickLook offers a solution because the pencilkit looks to be built into it and works perfectly just the way I need it to, however, I don't need the other things that come with QuickLook. I desperately need your help with how I can get the pencilkit functionality on my custom PDF viewing app. At this point, I can't even find a solution for the "Mark up" button (pencil.tip.crop.circle) to be filled when tapped. Thank you in advance!
Replies
2
Boosts
0
Views
2.1k
Activity
Jan ’22
PKPoint max force value
I thought that PencilKit's PKPoint force was in a some kind of interval. However I don't find anywhere a max value for this pressure property. Is there a max value? If not, how could I know the almost max pressure level value?
Replies
0
Boosts
0
Views
467
Activity
Dec ’21
PencilKit Path raw points
I've got a question about PKPoint processing. I've got an application where I have to get both image and points which generated this image. However I've checked that points have been already interpolated, so there's no way to get raw points (which I thought should be similar to display's refresh rate x seconds requested to draw). Is there a way to get raw points (not processed) and not interpolated points?
Replies
0
Boosts
0
Views
536
Activity
Dec ’21
Why is there no Apple Pencil Support on the iPhone?
Why is there no Apple Pencil Support on the iPhone?
Replies
1
Boosts
0
Views
938
Activity
Dec ’21
converting PKDrawing to NSImage fails
Hi. My goal is to convert PKDrawing to NSImage on Mac Server. For this, I use Vapor framework and receive POST request with PKDraiwng's base64 string(from PKDrawing.dataRepresentaion()). However, this task succeeds on local device, but fails on Remote Mac server. (with exact same logic & data) In failing cases, input base64 string was successfully converted to PKDrawing, but PKDrawing to NSImage converting was failed. (NSImage object is located at 0x000000 memory address) Is there any hardware dependencies to convert PKDrawing to NSImage? Please give me some help. let base64String = "d3Jk8AEACAASEAAAAAAAAAAAAAAAAAAAAAASECTanLurR0TesQ6DbJmhcB4aBggAEAAYABoGCAEQARgBIi4KFA39/Hw/FcXERD4dhYSEPiXNzEw/EhRjb20uYXBwbGUuaW5rLm1hcmtlchgDKuMHChDT0UH2JnhFKJXSKOjPQ4MBEgYIABABGAEaBggAEAEYACAAKp8HChD+PS4PhSlOD4NNWagXDeasEXgNipZotcNBGCwg4wMoHDIIAABcQegDAAA68AZww4BBYPKVQgAAAADNABSQwlXQOFhkkEEAiZhCaJFtPSkB0o7CVQhBMDaaQcBDlkLn+6k9OAHOjsJVX0IQuaRBUDOSQs3MzD04Ac6OwlVfQvA7r0HQS41CQmDlPTABzo7CVV9CsPq2QYC7iEKPwvU9JgHOjsJVqUGArrtBYPaFQgAAAD4mAc6OwlXCQOCNv0GQCINCkxgEPiYBzo7CVcJAQG3DQSDkf0InMQg+JwHOjsJV2kAIcMdBwAh5QrpJDD4qAc6OwlUoQWCeykEA3HFCTmIQPi4Bzo7CVX1BGD/NQeBdakLhehQ+MwHOjsJV80HYkNBBQJphQpqZGT45Ac6OwlV5QoDP0UEgHFpCLbIdPj0Bzo7CVdBCkDHTQQCeUkLByiE+QAHOjsJVGEM4cNRB4MJKQlTjJT5BAc6OwlU/Q0jS1UHARENC5/spPkMBzo7CVVtD6F/WQUB1O0J7FC4+QwHOjsJVW0MAc9hBQAMyQjMzMz5DAc6OwlVbQ6ix2UEghSpCx0s3PkMBzo7CVVtDuBPbQQAHI0JaZDs+QwHOjsJVW0NoA91BQNobQu58Pz5DAc6OwlVbQyCk30GAChVCgZVDPkMBzo7CVVtDeNLiQYCADkIUrkc+QwHOjsJVW0M4JOZBYAIHQs3MTD5DAc6OwlVbQ1hV7UFA2/lB9P1UPkMBzo7CVVtDgDf1QUD35kEbL10+QwHmjsJVW0PYGwFCwM7OQfp+aj5DAamPWVVbQ8y1BkKA0r9BtMh2PkMBJJD/VFtDkJYMQgC+tEFKDII+QwGIkMZUW0OwxxNCgDOwQXE9ij4/AeCQtFRbQ6jwG0IAebFBqvGSPjgB/ZC0VAdDyCEjQkDqvUGamZk+OAH9kLRUW0JsqypCACzOQXe+nz44Af2QtFRbQtzsL0JA49lBCtejPjgB/ZC0VFtCHHU1QoCa5UGwcqg+OAH9kLRUbUKMtjpCQAzwQUSLrD4+Af2QtFTqQnifP0KAfvhB16OwPkYB/ZC0VJ1DaBdHQoDJAULHS7c+UQH9kLRUoUQ0qU1CIL0EQqRwvT5XAf2QtFQtRXziU0JADgZCkxjEPlkB/ZC0VFdFgEtfQkCxBUJg5dA+WQH9kLRUV0XQNWZC4BoCQj0K1z7zAP2QtFRXRWRdbELAIPtB46XbPkwA/ZC0VD4tMhQNAACgQBUAAGBBHQAAhEIlAACMQkDAn9OfkwU6BggAEAAYAEIQxjieV95cTuaAtuVXCPxhZA==" let drawingData: PKDrawing = try! .init(data: Data(base64Encoded: base64String)!) let image = drawingData.image(from: drawingData.bounds, scale: 2) // -> fails
Replies
0
Boosts
0
Views
583
Activity
Dec ’21
Apple Pencil azimuth not working
I have a drawing app that I created and have sold on the App Store since 2018. It requires an Apple Pencil. My app uses the azimuth feature to orient the brush pattern that is drawn on the screen. A user just contacted me and said his azimuth feature is not working. Now it works fine for me, and I have not heard complaints from other users, so this leads me to believe it could be a problem with his Pencil. I wanted to show my code just to rule out that the problem is on my end and also get suggestions on what I should tell this user to do. Should he just contact Apple about it?                      // calculate the pencil direction let vector1 = touch.azimuthUnitVector(in: selectedCanvas) let angle = atan2(vector1.dy, vector1.dx) let azimu = angle - CGFloat(Double.pi) / 2.0 // adjust for wonky azimuth rotation translation if azimu >= -4.5 && azimu <= 0 {       rot = abs(azimu) } else {        rot = 6.2 - azimu } The azimu is then used as a point rotation in a basic Bézier curve and drawn on the screen. If it works on one iPad, it should work on all of them, right? He’s using an iPad Pro and so am I. I asked if he was using an Apple Pencil and he said yes.
Replies
0
Boosts
0
Views
793
Activity
Nov ’21