Skip to content

Latest commit

 

History

History
117 lines (92 loc) · 4.09 KB

File metadata and controls

117 lines (92 loc) · 4.09 KB

Personalized Signatures

DeveloperSignatureKit supports two personalization paths:

  • Generated signatures tuned with ProgrammaticSignatureStyle.
  • Captured signatures drawn on iOS with SignatureCaptureView and replayed with CapturedSignatureReplayView.

Programmatic Style

Use ProgrammaticSignatureView when the developer does not have an Apple Pencil or wants a fast, code-driven signature.

let style = ProgrammaticSignatureStyle(
    ink: .developerBlue,
    lineWidth: 3.6,
    slant: 0.28,
    characterSpacing: -0.035,
    roundedness: 0.9,
    baselineWobble: 0.4,
    scaleVariance: 0.35,
    flourishStrength: 1.08,
    uppercaseEmphasis: 1.02,
    replaySpeed: 1.1,
    seed: 87
)

DeveloperSignatureCard(
    signature: ProgrammaticSignatureView("Your Name", style: style),
    personalizationMessage: "Thanks for supporting the app.",
    developerName: "Your Name",
    role: "Developer"
)

Style values are clamped to supported ranges on initialization, mutation, and JSON decoding so persisted settings cannot produce pathological layouts.

Parameter guide:

  • ink: RGBA signature color.
  • lineWidth: stroke thickness, clamped to 1.0...8.0.
  • slant: horizontal handwriting lean, clamped to -0.25...0.60.
  • characterSpacing: spacing between generated glyphs, clamped to -0.12...0.16.
  • wordSpacing: spacing for spaces in the input string, clamped to 0.12...0.80.
  • roundedness: endpoint and join mode, clamped to 0...1; values below 0.5 render with sharper caps and joins, and values at or above 0.5 render rounded.
  • baselineWobble: deterministic per-character vertical variation, clamped to 0...1.
  • scaleVariance: deterministic per-character size variation, clamped to 0...1.
  • flourishStrength: width emphasis for expressive glyphs such as initials, clamped to 0.65...1.50.
  • uppercaseEmphasis: scale multiplier for uppercase characters, clamped to 0.70...1.35.
  • replaySpeed: draw-in animation speed, clamped to 0.25...3.0.
  • animationDelay: delay before replay begins, clamped to 0...5.
  • seed: deterministic personalization seed.

ProgrammaticSignatureStyle is Codable, Equatable, and Sendable, so apps can persist a chosen style in settings or ship a preconfigured style constant.

Captured Style

On iOS, record Apple Pencil or touch input:

@State private var signature: CapturedSignature?

SignatureCaptureView(signature: $signature)

Store the result as JSON:

let data = try signature.jsonData()
let restored = try CapturedSignature(jsonData: data)

Replay it later:

CapturedSignatureReplayView(
    signature: signature,
    ink: .developerBlue,
    lineWidth: 3.2
)

Captured signatures are normalized to the drawing canvas size. They preserve stroke timing so replay feels written instead of faded in. Replay trims empty capture-canvas whitespace by default; pass trimsWhitespace: false if the destination should preserve raw canvas-space placement. The format includes formatVersion, canvasSize, strokes, duration, and createdAt. CapturedSignature(jsonData:) rejects data with a newer formatVersion than the package understands, along with malformed canvas sizes, empty signatures, one-point strokes, invalid coordinates, non-monotonic timing, invalid force values, invalid line widths, and durations shorter than the captured points.

Each CapturedSignaturePoint stores normalized x and y coordinates, a timeOffset, and optional Pencil force. CapturedSignatureStroke can carry ink and line-width metadata. Replay uses stroke metadata when present and falls back to the CapturedSignatureReplayView ink and line width otherwise.

Example App

Examples/SignatureStudio includes:

  • A draw tab for iPad + Apple Pencil or touch capture.
  • A tune tab for developers who want to adjust a generated signature.
  • A card preview that swaps between the captured signature and generated signature.
  • An export button that shares captured signatures as DeveloperSignature.json.

Generate the project with XcodeGen from the example folder:

xcodegen generate
open SignatureStudio.xcodeproj