Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PrimaryFlightDisplay.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Pod::Spec.new do |spec|
spec.ios.deployment_target = '9.0'
spec.osx.deployment_target = '10.10'
spec.requires_arc = true
spec.swift_version = '4.1'
spec.swift_version = '5.0'

spec.source = { git: "https://github.com/kouky/PrimaryFlightDisplay.git", tag: "#{spec.version}" }
spec.source_files = "Sources/**/*.{h,swift}"
Expand Down
6 changes: 4 additions & 2 deletions PrimaryFlightDisplay.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
TargetAttributes = {
27B17FC31C84309F006EEC9D = {
CreatedOnToolsVersion = 7.2.1;
LastSwiftMigration = 1010;
};
27B17FD81C843D73006EEC9D = {
CreatedOnToolsVersion = 7.2.1;
Expand All @@ -237,6 +238,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 27B17FBA1C84309F006EEC9D;
Expand Down Expand Up @@ -365,7 +367,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -408,7 +410,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.11;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand Down
22 changes: 13 additions & 9 deletions Sources/AttitudeReferenceIndex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ class AttitudeReferenceIndex: SKNode {
let height = CGFloat(style.sideBarHeight)

let path = CGMutablePath()
path.move(to: CGPoint(x: -width, y: 2))
path.addLine(to: CGPoint(x: 0, y: 2))
path.move(to: CGPoint(x: -width, y: halfLineThickness))
path.addLine(to: CGPoint(x: 0, y: halfLineThickness))
path.addLine(to: CGPoint(x: 0, y: -height))
path.addLine(to: CGPoint(x: -4, y: -height))
path.addLine(to: CGPoint(x: -4, y: -2))
path.addLine(to: CGPoint(x: -width, y: -2))
path.addLine(to: CGPoint(x: -style.lineThickness, y: -height))
path.addLine(to: CGPoint(x: -style.lineThickness, y: -halfLineThickness))
path.addLine(to: CGPoint(x: -width, y: -halfLineThickness))
path.closeSubpath()

var trans = transform
Expand All @@ -52,15 +52,19 @@ class AttitudeReferenceIndex: SKNode {
private func buildCenterBar() -> SKShapeNode {
let halfWidth = CGFloat(style.centerBarWidth) / 2
let path = CGMutablePath()
path.move(to: CGPoint(x: -halfWidth, y: 2))
path.addLine(to: CGPoint(x: halfWidth, y: 2))
path.addLine(to: CGPoint(x: halfWidth, y: -2))
path.addLine(to: CGPoint(x: -halfWidth, y: -2))
path.move(to: CGPoint(x: -halfWidth, y: halfLineThickness))
path.addLine(to: CGPoint(x: halfWidth, y: halfLineThickness))
path.addLine(to: CGPoint(x: halfWidth, y: -halfLineThickness))
path.addLine(to: CGPoint(x: -halfWidth, y: -halfLineThickness))
path.closeSubpath()

let shape = SKShapeNode(path: path)
shape.fillColor = style.fillColor
shape.strokeColor = style.strokeColor
return shape
}

private var halfLineThickness: CGFloat {
return style.lineThickness * 0.5
}
}
3 changes: 2 additions & 1 deletion Sources/Horizon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ class Horizon: SKNode {
self.sceneSize = sceneSize
skyNode = SKSpriteNode(color: style.skyColor, size: CGSize(width: 100, height: 100))
groundNode = SKSpriteNode(color: style.groundColor, size: CGSize(width: 100, height: 100))
zeroPitchLine = SKShapeNode(rectOf: CGSize(width: 2 * sceneSize.width, height: 1))
zeroPitchLine = SKShapeNode(rectOf: CGSize(width: 2 * sceneSize.width, height: style.zeroPitchLineThickness))
super.init()

skyNode.size = CGSize(width: sceneSize.width * 2, height: sceneSize.height * 2)
groundNode.size = CGSize(width: sceneSize.width * 2, height: sceneSize.height * 2)
skyNode.position = CGPoint(x: 0, y: sceneSize.height)
groundNode.position = CGPoint(x: 0, y: -sceneSize.height)
zeroPitchLine.strokeColor = style.zeroPitchLineColor
zeroPitchLine.fillColor = style.zeroPitchLineColor
zeroPitchLine.position = CGPoint.zero

gimbalNode.addChild(skyNode)
Expand Down
12 changes: 6 additions & 6 deletions Sources/PitchLadder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PitchLadder: SKNode {
}
let pitchLines = skyPitchLines + skyPitchLines.map { ($0.0 * -1, $0.1) }
for (degree, type) in pitchLines {
cropNode.addChild(builder.pitchLine(sceneSize: sceneSize, degree: degree, type: type))
cropNode.addChild(builder.pitchLine(sceneSize: sceneSize, degree: degree, type: type, lineThickness: style.lineThickness))
}
for (degree, type) in pitchLines.filter({ $1 == .major }) {
cropNode.addChild(builder.leftPitchLineLabel(sceneSize: sceneSize, degree: degree, type: type))
Expand Down Expand Up @@ -64,14 +64,14 @@ private struct PitchLineBuilder {

let style: PitchLadderStyleType

func pitchLine(sceneSize: CGSize, degree: Int, type: PitchLineType) -> SKShapeNode {
func pitchLine(sceneSize: CGSize, degree: Int, type: PitchLineType, lineThickness: CGFloat) -> SKShapeNode {

let halfWidth = halfWidthForPitchLineType(type: type)
let path = CGMutablePath()
path.move(to: CGPoint(x: -halfWidth, y: 2))
path.addLine(to: CGPoint(x: halfWidth, y: 2))
path.addLine(to: CGPoint(x: halfWidth, y: -2))
path.addLine(to: CGPoint(x: -halfWidth, y: -2))
path.move(to: CGPoint(x: -halfWidth, y: lineThickness * 0.5))
path.addLine(to: CGPoint(x: halfWidth, y: lineThickness * 0.5))
path.addLine(to: CGPoint(x: halfWidth, y: -lineThickness * 0.5))
path.addLine(to: CGPoint(x: -halfWidth, y: -lineThickness * 0.5))
path.closeSubpath()

var transform = CGAffineTransform(translationX: 0, y: CGFloat(degree) * sceneSize.pointsPerDegree)
Expand Down
10 changes: 10 additions & 0 deletions Sources/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ public protocol HorizonStyleType {
var skyColor: SKColor { get set }
var groundColor: SKColor { get set }
var zeroPitchLineColor: SKColor { get set }
var zeroPitchLineThickness: CGFloat { get set }
}

public struct DefaultHorizonStyle: HorizonStyleType {
public var skyColor = SKColor(red: 0.078, green: 0.490, blue: 0.816, alpha: 1.00)
public var groundColor = SKColor(red: 0.667, green: 0.855, blue: 0.196, alpha: 1.00)
public var zeroPitchLineColor = SKColor(red: 0.8, green: 0.8, blue: 0.8, alpha: 1)
public var zeroPitchLineThickness = CGFloat(1)

public init() {}
}
Expand All @@ -82,6 +84,7 @@ public protocol AttitudeReferenceIndexStyleType {
var sideBarHeight: Int { get set }
var sideBarWidth: Int { get set }
var sideBarOffset: Int { get set }
var lineThickness: CGFloat { get set }
}

public struct DefaultAttitudeReferenceIndexStyle: AttitudeReferenceIndexStyleType {
Expand All @@ -91,6 +94,7 @@ public struct DefaultAttitudeReferenceIndexStyle: AttitudeReferenceIndexStyleTyp
public var sideBarWidth = 120
public var sideBarHeight = 20
public var sideBarOffset = 70
public var lineThickness = CGFloat(4)

public init() {}
}
Expand All @@ -106,6 +110,7 @@ public protocol PitchLadderStyleType {
var majorLineWidth: Int { get set }
var markerTextOffset: Int { get set }
var magnitudeDisplayDegree: Int { get set } // Keep between 0 and 180
var lineThickness: CGFloat { get set }
}

public struct DefaultPitchLadderStyle: PitchLadderStyleType {
Expand All @@ -117,6 +122,7 @@ public struct DefaultPitchLadderStyle: PitchLadderStyleType {
public var majorLineWidth = 50
public var markerTextOffset = 10
public var magnitudeDisplayDegree = 40
public var lineThickness = CGFloat(4)

public init() {}
}
Expand Down Expand Up @@ -174,6 +180,7 @@ public enum TapeMarkerJustification {
public typealias Legend = (key: String, value: String)

public protocol TapeIndicatorStyleType {
var visible: Bool { get set }
var size: CGSize { get set }
var type: TapeType { get set }
var backgroundColor: SKColor { get set }
Expand All @@ -193,6 +200,7 @@ public protocol TapeIndicatorStyleType {
}

public struct DefaultAltimeterStyle: TapeIndicatorStyleType {
public var visible = true
public var size = CGSize(width: 60, height: 300)
public var type = TapeType.continuous
public var backgroundColor = SKColor(red: 0, green: 0, blue: 0, alpha: 0.5)
Expand All @@ -214,6 +222,7 @@ public struct DefaultAltimeterStyle: TapeIndicatorStyleType {
}

public struct DefaultAirspeedIndicatorStyle: TapeIndicatorStyleType {
public var visible = true
public var size = CGSize(width: 60, height: 300)
public var type = TapeType.continuous
public var backgroundColor = SKColor(red: 0, green: 0, blue: 0, alpha: 0.5)
Expand All @@ -235,6 +244,7 @@ public struct DefaultAirspeedIndicatorStyle: TapeIndicatorStyleType {
}

public struct DefaultHeadingIndicatorStyle: TapeIndicatorStyleType {
public var visible = true
public var size = CGSize(width: 400, height: 60)
public var type = TapeType.compass
public var backgroundColor = SKColor(red: 0, green: 0, blue: 0, alpha: 0.5)
Expand Down
1 change: 1 addition & 0 deletions Sources/TapeIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class TapeIndicator: SKNode {
pointer = TapePointer(initialValue: style.seedModel.lowerValue, style: style)
super.init()

isHidden = !style.visible
let backgroundShape = SKShapeNode(rectOf: style.size, cornerRadius: 2)
backgroundShape.fillColor = style.backgroundColor
backgroundShape.strokeColor = SKColor.clear
Expand Down