Documentation
¶
Overview ¶
Package haptics plays the phone's taps and buzzes: the system's own feedback (Impact, Notify, Selection) and patterns of your own (Play) — Core Haptics on iOS, the vibrator's effects on Android. Every call returns at once (the feedback plays on its own), so they are safe anywhere, handlers included. On the web, and on phones without a haptic engine, they do nothing.
haptics.Impact(haptics.Medium, 1) // a tap
haptics.Notify(haptics.Success) // something worked
haptics.Play([]haptics.Event{ // a thud, then a hum
{Intensity: 1, Sharpness: 0.35},
{At: 50 * time.Millisecond, Duration: time.Second, Intensity: 0.9, Sharpness: 0.3},
})
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Notify ¶
func Notify(kind Kind)
Notify is the system's feedback for a success, warning or error.
Types ¶
type Curve ¶
type Curve struct {
Sharpness bool // false: the curve is for intensity
Points []Point // its values over time
}
Curve changes a pattern's intensity or sharpness over time while it plays (a hum that swells). Intensity values multiply (0…1); sharpness values add (-1…1).
type Event ¶
type Event struct {
At, Duration time.Duration // when it starts, and how long it lasts; a Duration of 0 is a tap
Intensity, Sharpness float32 // each 0 to 1: how strong, and how crisp rather than round
}
Event is one moment of a pattern: a tap (Duration 0) or a buzz that lasts Duration, At its offset from the start. Intensity and Sharpness are 0…1: how strong, and how crisp rather than round.