vb绘图程序代码
In WWDC2019, Apple gifted us with a brand new Apple Pencil framework: the PencilKit. Before that, it was very hard and complex to build a Pencil app only by detecting touching gestures and making Math calculations, but with this new library, it costs only a few lines of code to present a drawing canvas with a simple tool picker.
在WWDC2019中,Apple向我们赠送了全新的Apple Pencil框架:PencilKit。 在此之前,仅通过检测触摸手势并进行数学计算来构建Pencil应用程序非常困难且复杂,但是使用这个新库,只需花费几行代码即可用一个简单的工具选择器显示一个绘图画布。
First, let's start describing the magic around the Pencil Kit by giving a brief introduction of the basic concepts around implementing a drawing app:
首先,通过简要介绍实现绘图应用程序的基本概念,让我们开始描述Pencil Kit的魔力:
帆布 (Canvas)
The canvas is basically the view where the user can draw something. It corresponds to any surface that sensitive to the Apple Pencil. It can also allow the user to draw with his own fingers. The canvas captures each point touched by the user and renders it within in periodic times(less than one second).
画布基本上是用户可以在其中绘制内容的视图。 它对应于对Apple Pencil敏感的任何表面。 它还可以允许用户用自己的手指画画。 画布捕获用户触摸的每个点,并在周期性的时间内(少于一秒钟)进行渲染。
In Swift, The canvas view corresponds to a struct which belongs to the PencilKit framework, which is named PKCanvasView. The PKCanvasView has a delegate object(f