initial support for nanoseconds

This commit is contained in:
2023-01-23 20:51:03 -08:00
parent 9fcd64581d
commit cfc75c2ce7
4 changed files with 68 additions and 53 deletions

View File

@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 47;
objectVersion = 56;
objects = {
/* Begin PBXBuildFile section */
@@ -17,7 +17,7 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
3A40066818B53112005F43A6 /* Epoch Flip Clock.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Epoch Flip Clock.saver"; sourceTree = BUILT_PRODUCTS_DIR; };
3A40066818B53112005F43A6 /* Fast Epoch Flip Clock.saver */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Fast Epoch Flip Clock.saver"; sourceTree = BUILT_PRODUCTS_DIR; };
3A40066D18B53113005F43A6 /* ScreenSaver.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ScreenSaver.framework; path = System/Library/Frameworks/ScreenSaver.framework; sourceTree = SDKROOT; };
3A40068218B53129005F43A6 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
3A95A94B18EA12D30036779C /* EpochFlipClock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EpochFlipClock.h; sourceTree = SOURCE_ROOT; };
@@ -56,7 +56,7 @@
3A40066918B53112005F43A6 /* Products */ = {
isa = PBXGroup;
children = (
3A40066818B53112005F43A6 /* Epoch Flip Clock.saver */,
3A40066818B53112005F43A6 /* Fast Epoch Flip Clock.saver */,
);
name = Products;
sourceTree = "<group>";
@@ -97,9 +97,9 @@
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
3A40066718B53112005F43A6 /* Epoch Flip Clock */ = {
3A40066718B53112005F43A6 /* Fast Epoch Flip Clock */ = {
isa = PBXNativeTarget;
buildConfigurationList = 3A40067F18B53113005F43A6 /* Build configuration list for PBXNativeTarget "Epoch Flip Clock" */;
buildConfigurationList = 3A40067F18B53113005F43A6 /* Build configuration list for PBXNativeTarget "Fast Epoch Flip Clock" */;
buildPhases = (
3A40066218B53112005F43A6 /* Sources */,
3A40066318B53112005F43A6 /* Frameworks */,
@@ -111,9 +111,9 @@
);
dependencies = (
);
name = "Epoch Flip Clock";
name = "Fast Epoch Flip Clock";
productName = "Epoch Flip Clock";
productReference = 3A40066818B53112005F43A6 /* Epoch Flip Clock.saver */;
productReference = 3A40066818B53112005F43A6 /* Fast Epoch Flip Clock.saver */;
productType = "com.apple.product-type.bundle";
};
/* End PBXNativeTarget section */
@@ -122,27 +122,23 @@
3A40065E18B53112005F43A6 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0920;
ORGANIZATIONNAME = chrstphrknwtn;
TargetAttributes = {
3A40066718B53112005F43A6 = {
ProvisioningStyle = Manual;
};
};
LastUpgradeCheck = 1420;
ORGANIZATIONNAME = smparkin;
};
buildConfigurationList = 3A40066118B53112005F43A6 /* Build configuration list for PBXProject "Epoch Flip Clock" */;
compatibilityVersion = "Xcode 6.3";
developmentRegion = English;
buildConfigurationList = 3A40066118B53112005F43A6 /* Build configuration list for PBXProject "Fast Epoch Flip Clock" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 3A40065D18B53112005F43A6;
productRefGroup = 3A40066918B53112005F43A6 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
3A40066718B53112005F43A6 /* Epoch Flip Clock */,
3A40066718B53112005F43A6 /* Fast Epoch Flip Clock */,
);
};
/* End PBXProject section */
@@ -185,6 +181,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
@@ -192,14 +189,17 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -208,6 +208,7 @@
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_NS_ASSERTIONS = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -238,6 +239,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_OBJC_ARC = YES;
@@ -245,14 +247,17 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
@@ -261,6 +266,7 @@
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_NS_ASSERTIONS = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -284,13 +290,20 @@
3A40068018B53113005F43A6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = "";
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = QR825BQSTL;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
PRODUCT_BUNDLE_IDENTIFIER = "com.chrstphrknwtn.${PRODUCT_NAME:rfc1034identifier}";
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2022.1.23;
PRODUCT_BUNDLE_IDENTIFIER = "in.smpark.Fast-Epoch-Flip-Clock";
PRODUCT_NAME = $TARGET_NAME;
PROVISIONING_PROFILE_SPECIFIER = "";
WRAPPER_EXTENSION = saver;
};
name = Debug;
@@ -298,13 +311,20 @@
3A40068118B53113005F43A6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "";
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = "";
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = QR825BQSTL;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
PRODUCT_BUNDLE_IDENTIFIER = "com.chrstphrknwtn.${PRODUCT_NAME:rfc1034identifier}";
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2022.1.23;
PRODUCT_BUNDLE_IDENTIFIER = "in.smpark.Fast-Epoch-Flip-Clock";
PRODUCT_NAME = $TARGET_NAME;
PROVISIONING_PROFILE_SPECIFIER = "";
WRAPPER_EXTENSION = saver;
};
name = Release;
@@ -312,7 +332,7 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
3A40066118B53112005F43A6 /* Build configuration list for PBXProject "Epoch Flip Clock" */ = {
3A40066118B53112005F43A6 /* Build configuration list for PBXProject "Fast Epoch Flip Clock" */ = {
isa = XCConfigurationList;
buildConfigurations = (
3A40067D18B53113005F43A6 /* Debug */,
@@ -321,7 +341,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
3A40067F18B53113005F43A6 /* Build configuration list for PBXNativeTarget "Epoch Flip Clock" */ = {
3A40067F18B53113005F43A6 /* Build configuration list for PBXNativeTarget "Fast Epoch Flip Clock" */ = {
isa = XCConfigurationList;
buildConfigurations = (
3A40068018B53113005F43A6 /* Debug */,

View File

@@ -11,19 +11,19 @@
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>0.0.5</string>
<string>2022.12.22</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>0.0.5</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.0.5</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2019 Christopher Newton. All rights reserved.</string>
<string>Hi</string>
<key>NSPrincipalClass</key>
<string>EpochFlipClock</string>
</dict>

View File

@@ -56,12 +56,12 @@ flap-bottom-flip {
flap-top-flip {
display: none;
transform-origin: 100% 100%;
animation: flip-top-down 300ms ease-in;
animation: flip-top-down var(--anim) ease-in;
}
flap-bottom-flip {
display: none;
transform-origin: 100% 0%;
animation: flip-bottom-down 150ms ease-out;
animation: flip-bottom-down var(--anim) ease-out;
}
flap-top > n,

View File

@@ -1,22 +1,25 @@
'use strict';
var digits = [];
const digitDict = {};
function getEpoch() {
return Date.now().toString().slice(0,-3);
return Date.now().toString();
}
function createDigit() {
function createDigit(i) {
var anim = [10, 11, 12].includes(i) ? 30 : (10-i) * 300;
var anim2 = Math.floor(anim/2)
var digit = document.createElement('digit');
digit.innerHTML = '\
digit.innerHTML = `\
<flap-top> <n></n> </flap-top>\
<flap-top-flip> <n></n> </flap-top-flip>\
<flap-top-flip style="--anim: ${anim}ms;"> <n></n> </flap-top-flip>\
<flap-bottom> <n></n> </flap-bottom>\
<flap-bottom-flip> <n></n> </flap-bottom-flip>';
<flap-bottom-flip style="--anim: ${anim2}ms;"> <n></n> </flap-bottom-flip>`;
return digit;
}
function flipDigitTo(digit, currentVal, updatedVal) {
function flipDigitTo(digit, currentVal, updatedVal, i) {
var topFlapNum = digit.querySelector('flap-top > n'),
topFlapFlip = digit.querySelector('flap-top-flip'),
topFlapFlipNum = topFlapFlip.querySelector('n'),
@@ -32,56 +35,48 @@ function flipDigitTo(digit, currentVal, updatedVal) {
setTimeout(function() {
topFlapFlip.style.display = 'none';
}, 300);
}, [10, 11, 12].includes(i) ? 30 : (10-i) * 300);
setTimeout(function() {
bottomFlapFlipNum.innerHTML = updatedVal;
bottomFlapFlip.style.display = 'block';
}, 300);
}, [10, 11, 12].includes(i) ? 30 : (10-i) * 300);
setTimeout(function() {
bottomFlapNum.innerHTML = updatedVal;
bottomFlapFlip.style.display = 'none';
}, 450);
}, [10, 11, 12].includes(i) ? 45 : (10-i) * 450);
digit.setAttribute('current-val', updatedVal);
}
function updateClock() {
var epoch = getEpoch(),
staggerDelay,
currentVal,
updatedVal,
i;
for (i = 0; i < epoch.length; i+=1) {
if(i === epoch.length-1) {
staggerDelay = 0;
} else {
staggerDelay = Math.random() * 400;
}
currentVal = digits[i].getAttribute('current-val');
updatedVal = epoch[i];
if(currentVal !== updatedVal) {
setTimeout(flipDigitTo, staggerDelay, digits[i], currentVal, updatedVal);
setTimeout(flipDigitTo, 0, digits[i], currentVal, updatedVal, i);
}
}
}
function setupClock() {
var epoch = getEpoch(),
staggerDelay,
digit,
i;
for (i = 0; i < epoch.length; i+=1) {
digit = createDigit();
staggerDelay = Math.random() * 400;
digit = createDigit(i);
document.body.appendChild(digit);
setTimeout(flipDigitTo, staggerDelay, digit, null, epoch[i]);
setTimeout(flipDigitTo, 0, digit, null, epoch[i], i);
}
digits = document.querySelectorAll('digit');
}
setupClock();
setInterval(updateClock, 1000);
setInterval(updateClock, 1);