Skip to content

Commit

Permalink
Add sunrise/set and moonrise/set with complementing UI to set their c…
Browse files Browse the repository at this point in the history
…olors

Also add moon position on celestial circle to join other planets
  • Loading branch information
LEOYoon-Tsaw committed Aug 18, 2022
1 parent 46d740a commit 4d1fe0d
Show file tree
Hide file tree
Showing 8 changed files with 445 additions and 146 deletions.
4 changes: 2 additions & 2 deletions ChineseTime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 31;
CURRENT_PROJECT_VERSION = 33;
DEVELOPMENT_TEAM = 28HU5A7B46;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = ChineseTime/Info.plist;
Expand All @@ -329,7 +329,7 @@
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 31;
CURRENT_PROJECT_VERSION = 33;
DEVELOPMENT_TEAM = 28HU5A7B46;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = ChineseTime/Info.plist;
Expand Down
3 changes: 3 additions & 0 deletions ChineseTime/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// Created by LEO Yoon-Tsaw on 9/21/21.
//

let earthSpeed = 360 / 86164.0989
let moonSpeed = 360 / (27.321582 * 86400)

let moonData: [[Int8]] = [[0,6,6,6,6,6,5,6,3,5,4,4,5,4,6,6,6,6,6,2,6,1,6,5,6,7],
[1,7,7,7,6,4,8,4,8,5,7,5,4,5,4,6,6,6,4,5,0,3,2,5,6,6],
[0,6,6,4,4,5,4,7,5,8,7,6,7,5,5,6,4,5,4,4,4,4,3,4,4,5],
Expand Down
4 changes: 2 additions & 2 deletions ChineseTime/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Enable to automatically fill in location, for sunrise and sunset time calculation</string>
<key>NSLocationUsageDescription</key>
<string>Use location to calculate local sunrise and sunset time</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Enable to automatically fill in location, for sunrise and sunset time calculation</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
Expand Down
27 changes: 25 additions & 2 deletions ChineseTime/Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class WatchLayout {
var oddSolarTermTickColorDark: NSColor
var planetIndicator: [NSColor]
var sunPositionIndicator: [NSColor]
var moonPositionIndicator: [NSColor]
var eclipseIndicator: NSColor
var fullmoonIndicator: NSColor
var oddStermIndicator: NSColor
Expand Down Expand Up @@ -262,11 +263,15 @@ class WatchLayout {
NSColor(displayP3Red: 200/255, green: 190/255, blue: 170/255, alpha: 1.0), //Venus
NSColor(displayP3Red: 210/255, green: 48/255, blue: 40/255, alpha: 1.0), //Mars
NSColor(displayP3Red: 60/255, green: 180/255, blue: 90/255, alpha: 1.0), //Jupyter
NSColor(displayP3Red: 170/255, green: 150/255, blue: 50/255, alpha: 1.0)] //Saturn
NSColor(displayP3Red: 170/255, green: 150/255, blue: 50/255, alpha: 1.0), //Saturn
NSColor(displayP3Red: 220/255, green: 200/255, blue: 60/255, alpha: 1.0)] //Moon
sunPositionIndicator = [NSColor(displayP3Red: 0/255, green: 0/255, blue: 0/255, alpha: 1.0), //Mid Night
NSColor(displayP3Red: 255/255, green: 80/255, blue: 10/255, alpha: 1.0), //Sunrise
NSColor(displayP3Red: 210/255, green: 170/255, blue: 120/255, alpha: 1.0), //Noon
NSColor(displayP3Red: 230/255, green: 120/255, blue: 30/255, alpha: 1.0)] //Sunset
moonPositionIndicator = [NSColor(displayP3Red: 190/255, green: 210/255, blue: 30/255, alpha: 1.0), //Moon rise
NSColor(displayP3Red: 255/255, green: 255/255, blue: 50/255, alpha: 1.0), //Moon at meridian
NSColor(displayP3Red: 120/255, green: 30/255, blue: 150/255, alpha: 1.0)] //Moon set
eclipseIndicator = NSColor(displayP3Red: 50/255, green: 68/255, blue: 96/255, alpha: 1.0)
fullmoonIndicator = NSColor(displayP3Red: 255/255, green: 239/255, blue: 59/255, alpha: 1.0)
oddStermIndicator = NSColor(displayP3Red: 153/255, green: 153/255, blue: 153/255, alpha:1.0)
Expand Down Expand Up @@ -310,6 +315,7 @@ class WatchLayout {
encoded += "oddStermIndicator: \(oddStermIndicator.hexCode)\n"
encoded += "evenStermIndicator: \(evenStermIndicator.hexCode)\n"
encoded += "sunPositionIndicator: \(sunPositionIndicator.map {$0.hexCode}.joined(separator: ", "))\n"
encoded += "moonPositionIndicator: \(moonPositionIndicator.map {$0.hexCode}.joined(separator: ", "))\n"
encoded += "shadeAlpha: \(shadeAlpha)\n"
encoded += "textFont: \(textFont.fontName)\n"
encoded += "centerFont: \(centerFont.fontName)\n"
Expand Down Expand Up @@ -380,6 +386,9 @@ class WatchLayout {
if let colourList = readColorList(values["sunPositionIndicator"]), colourList.count == self.sunPositionIndicator.count {
self.sunPositionIndicator = colourList
}
if let colourList = readColorList(values["moonPositionIndicator"]), colourList.count == self.moonPositionIndicator.count {
self.moonPositionIndicator = colourList
}
eclipseIndicator = values["eclipseIndicator"]?.colorValue ?? eclipseIndicator
fullmoonIndicator = values["fullmoonIndicator"]?.colorValue ?? fullmoonIndicator
oddStermIndicator = values["oddStermIndicator"]?.colorValue ?? oddStermIndicator
Expand Down Expand Up @@ -465,6 +474,7 @@ class ConfigurationViewController: NSViewController, NSWindowDelegate {
@IBOutlet weak var marsIndicatorColorPicker: NSColorWell!
@IBOutlet weak var jupyterIndicatorColorPicker: NSColorWell!
@IBOutlet weak var saturnIndicatorColorPicker: NSColorWell!
@IBOutlet weak var moonIndicatorColorPicker: NSColorWell!
@IBOutlet weak var eclipseIndicatorColorPicker: NSColorWell!
@IBOutlet weak var fullmoonIndicatorColorPicker: NSColorWell!
@IBOutlet weak var oddStermIndicatorColorPicker: NSColorWell!
Expand All @@ -473,6 +483,9 @@ class ConfigurationViewController: NSViewController, NSWindowDelegate {
@IBOutlet weak var sunsetIndicatorColorPicker: NSColorWell!
@IBOutlet weak var noonIndicatorColorPicker: NSColorWell!
@IBOutlet weak var midnightIndicatorColorPicker: NSColorWell!
@IBOutlet weak var moonriseIndicatorColorPicker: NSColorWell!
@IBOutlet weak var moonsetIndicatorColorPicker: NSColorWell!
@IBOutlet weak var moonmeridianIndicatorColorPicker: NSColorWell!
@IBOutlet weak var textFontFamilyPicker: NSPopUpButton!
@IBOutlet weak var textFontTraitPicker: NSPopUpButton!
@IBOutlet weak var centerTextFontFamilyPicker: NSPopUpButton!
Expand Down Expand Up @@ -725,7 +738,8 @@ class ConfigurationViewController: NSViewController, NSWindowDelegate {
venusIndicatorColorPicker.color,
marsIndicatorColorPicker.color,
jupyterIndicatorColorPicker.color,
saturnIndicatorColorPicker.color
saturnIndicatorColorPicker.color,
moonIndicatorColorPicker.color
]
watchLayout.eclipseIndicator = eclipseIndicatorColorPicker.color
watchLayout.fullmoonIndicator = fullmoonIndicatorColorPicker.color
Expand All @@ -737,6 +751,11 @@ class ConfigurationViewController: NSViewController, NSWindowDelegate {
noonIndicatorColorPicker.color,
sunsetIndicatorColorPicker.color
]
watchLayout.moonPositionIndicator = [
moonriseIndicatorColorPicker.color,
moonmeridianIndicatorColorPicker.color,
moonsetIndicatorColorPicker.color
]
watchLayout.textFont = readFont(family: textFontFamilyPicker, style: textFontTraitPicker) ?? watchLayout.textFont
watchLayout.centerFont = readFont(family: centerTextFontFamilyPicker, style: centerTextFontTraitPicker) ?? watchLayout.centerFont
watchLayout.watchSize = NSMakeSize(max(0, widthPicker.doubleValue), max(0, heightPicker.doubleValue))
Expand Down Expand Up @@ -810,6 +829,7 @@ class ConfigurationViewController: NSViewController, NSWindowDelegate {
marsIndicatorColorPicker.color = watchLayout.planetIndicator[2]
jupyterIndicatorColorPicker.color = watchLayout.planetIndicator[3]
saturnIndicatorColorPicker.color = watchLayout.planetIndicator[4]
moonIndicatorColorPicker.color = watchLayout.planetIndicator[5]
eclipseIndicatorColorPicker.color = watchLayout.eclipseIndicator
fullmoonIndicatorColorPicker.color = watchLayout.fullmoonIndicator
oddStermIndicatorColorPicker.color = watchLayout.oddStermIndicator
Expand All @@ -818,6 +838,9 @@ class ConfigurationViewController: NSViewController, NSWindowDelegate {
sunriseIndicatorColorPicker.color = watchLayout.sunPositionIndicator[1]
noonIndicatorColorPicker.color = watchLayout.sunPositionIndicator[2]
sunsetIndicatorColorPicker.color = watchLayout.sunPositionIndicator[3]
moonriseIndicatorColorPicker.color = watchLayout.moonPositionIndicator[0]
moonmeridianIndicatorColorPicker.color = watchLayout.moonPositionIndicator[1]
moonsetIndicatorColorPicker.color = watchLayout.moonPositionIndicator[2]
populateFontFamilies(textFontFamilyPicker)
textFontFamilyPicker.selectItem(withTitle: watchLayout.textFont.familyName!)
populateFontMember(textFontTraitPicker, inFamily: textFontFamilyPicker)
Expand Down
Loading

0 comments on commit 4d1fe0d

Please sign in to comment.