【问题标题】:Custom PKDrawing fileCustom PKDrawing file
【发布时间】:2022-12-27 08:29:13
【问题描述】:

can you please please help me how can I create my own, custom PKDrawing file? I've watched WWDC and I see that in the code of the sample app are using PKDrawing file. I would like to create my own PKDrawing file, with lines or curves. Any tips on how to approach this?

Tried creating random json file to .drawing one, but did not work properly.

Thank you in advance for your help!

struct TextGenerator {
    let lowercaseDrawings: [PKDrawing]
    let uppercaseDrawings: [PKDrawing]

    // The number of strokes in each letter of the alphabet, for upper/lowercase assets.
    static let lowercaseStrokeCount = [1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1]
    static let uppercaseStrokeCount = [3, 2, 1, 2, 4, 3, 2, 3, 3, 2, 2, 1, 2, 2, 1, 2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 1]
    

【问题讨论】:

    标签: dataset drawing pencilkit


    【解决方案1】:

    You can create a new drawing by providing strokes: PKDrawing(strokes:[PKStroke])

    The line and curves you want to create are the PKStrokes you provided. To create a PKStroke, you need many parameters, but the most important parameter is the PKStrokePath. PKStrokePath contains all points to form curves.

    If you able to find all the points on the curve you want to create, you can create PKStrokePoint from CGPoint and from those PKStrokePoints you can create a StrokePath: PKStrokePath(points: [PKStrokePoint])

    【讨论】:

      【解决方案2】:

      As far as I know, you must create it with an iPad, by drawing, then exporting as Data, persisting to disk as a file, and then you may rename it. I'm unaware of other ways of creating such files outside of the iPad environment, unfortunately. It looks like their "file encoding" is proprietary, so there may not be external tools that do this.

      I hope this helps!

      【讨论】:

        猜你喜欢
        • 2019-12-25
        • 1970-01-01
        • 2022-12-02
        • 2019-11-05
        • 1970-01-01
        • 1970-01-01
        • 2021-11-17
        • 1970-01-01
        • 2020-02-18
        相关资源
        最近更新 更多