How to increase the width of PencilKit .pen stroke?

The default PKInkingTool with inkType .pen seems to be limited in its stroke width. With a maximum width of around 25.66. Why is that? How can I increase it?

Example code:

canvasView.tool = PKInkingTool(.pen, color: .black, width: 10)
print(canvasView.tool)
//Prints: PKInkingTool(tool: <PKInkingTool: 0x2837ba140 com.apple.ink.pen color=UIExtendedSRGBColorSpace 0 0 0 1 width=10.000000>)

canvasView.tool = PKInkingTool(.pen, color: .black, width: 20)
//Prints: PKInkingTool(tool: <PKInkingTool: 0x282730140 com.apple.ink.pen color=UIExtendedSRGBColorSpace 0 0 0 1 width=20.000000>)

//Problem starts here:
canvasView.tool = PKInkingTool(.pen, color: .black, width: 30)
//Prints: PKInkingTool(tool: <PKInkingTool: 0x28077a0c0 com.apple.ink.pen color=UIExtendedSRGBColorSpace 0 0 0 1 width=25.659260>)

canvasView.tool = PKInkingTool(.pen, color: .black, width: 100)
//Prints: PKInkingTool(tool: <PKInkingTool: 0x2824e08e0 com.apple.ink.pen color=UIExtendedSRGBColorSpace 0 0 0 1 width=25.659260>)

How can I increase the stroke width? 🤔

  • Investigating this I've come across a computed variable in the default PKInk named validWidthRange it has these ranges:

    for .pen: 0.8781664588318914...25.659259612471967 for .pencil: 2.4000000953674316...16.0

    Is there any way I can increase these ranges? Or crate a copy of .pen PKInk with my own validWidthRange?

Add a Comment

Replies

Investigating this I've come across a computed variable in the default PKInk named validWidthRange it has these ranges:

for .pen: 0.8781664588318914...25.659259612471967
for .pencil: 2.4000000953674316...16.0

Is there any way I can increase these ranges? Or create a copy of .pen PKInk with my own validWidthRange?