Intents
works on iOS, tvOS, watchOS and macOS
.package(url: "https://github.com/hexagons/Trails.git", from: "1.1.1")
import SwiftUI import Trails
struct ContentView: View { var main: Main = Main() var body: some View { TrailsView(trailer: main.trailer) } }
class Main { let trailer: Trailer init() { let trailCount: Int = 3 let seconds: Double = 10.0 trailer = Trailer(count: trailCount, duration: seconds) trailer.circlesActive = true startTimer() } func startTimer() { let startDate: Date = Date() let timer: Timer = Timer(timeInterval: 0.5, repeats: true) { _ in let time: Double = -startDate.timeIntervalSinceNow let valueA: Double = cos(time) let valueB: Double = cos(time + (.pi * 2) * (1.0 / 3.0)) let valueC: Double = cos(time + (.pi * 2) * (2.0 / 3.0)) self.trailer.add(valueA, at: 0) self.trailer.add(valueB, at: 1) self.trailer.add(valueC, at: 2) } RunLoop.current.add(timer, forMode: .common) } }
trailer.duration = 10.0
duration is in seconds
.duration can be changed while running
.duration
values added longer ago than the duration will be removed
trailer.circlesActive = true
.circlesActive default is false
.circlesActive
false
trailer.circleBorder = false trailer.circleRadius = 2.0
.circleBorder default is true
.circleBorder
true
.circleRadius default is 3.0
.circleRadius
3.0
trailer.lineWidth = 3.0
.lineWidth default is 1.0
.lineWidth
1.0
trailer.colorsActive = false
when count is 1, .colorsActive is false by default
1
.colorsActive
when count is 2 or more, .colorsActive is true by default
2
trailer.hues = [0.0, 0.1, 0.2]
the number of hues must match the count passed to Trailer
Trailer
.hues is “rainbow” by default
.hues
a hue is a value between 0.0 and 1.0, low values: red to green, middle values: green to blue, high values: blue to red
0.0
trailer.colorBlend = false
when .colorBlend is false the lines will not be blended. this option is visible when a lot of lines overlap
.colorBlend
when .colorBlend is true, light mode blends with .multiply, dark mode blends with .lighten
.multiply
.lighten
.colorBlend is true by default
trailer.drawValueEndLines = false
.drawValueEndLines is true by default
.drawValueEndLines
trailer.drawValueBackground = false
.drawValueBackground is true by default on iOS and watchOS can be useful to turn to false if your background is transparent
.drawValueBackground
trailer.drawDefaultTextBackground = false
trailer.fontSize = 12.0
.fontSize is 8.0 by default
.fontSize
8.0
trailer.leftSpacing = 10.0 trailer.rightSpacing = 10.0
.leftSpacing and .rightSpacing is 20.0 by default
.leftSpacing
.rightSpacing
20.0
To repilcate the randomness seen in the gifs in the top of this readme, use this code:
let trailer: Trailer = TrailerMock.make()
provided by TrailerMock.swift
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
Trails
works on iOS, tvOS, watchOS and macOS
Install
Swift Package
Setup
Properties
Mock
To repilcate the randomness seen in the gifs in the top of this readme, use this code:
provided by TrailerMock.swift