Fix custom clock hands offset and decimal preset
This commit is contained in:
@@ -131,7 +131,7 @@ export function CustomClock() {
|
||||
displayValue = rawValue;
|
||||
}
|
||||
|
||||
const angle = direction * valueToAngle(displayValue, absUnits, 0);
|
||||
const angle = direction * valueToAngle(displayValue, absUnits, 0) - Math.PI / 2;
|
||||
|
||||
context.beginPath();
|
||||
context.strokeStyle = getHandColor(i, total);
|
||||
|
||||
@@ -31,7 +31,7 @@ export const PRESETS: Record<PresetName, ClockConfig> = {
|
||||
cyclesPerDay: 2,
|
||||
},
|
||||
decimal: {
|
||||
hands: [10, 10, 10],
|
||||
hands: [10, 100, 100],
|
||||
numberStyle: 'arabic',
|
||||
cyclesPerDay: 1,
|
||||
},
|
||||
|
||||
@@ -181,7 +181,7 @@ export function drawDigitalClock(params: DigitalClockParams): void {
|
||||
let totalWidth = 0;
|
||||
for (let i = 0; i < hands.length; i++) {
|
||||
const maxUnits = getDigitalMaxUnits(i, hands, cyclesPerDay);
|
||||
const digitCount = maxUnits.toString().length;
|
||||
const digitCount = (maxUnits - 1).toString().length;
|
||||
totalWidth += digitCount * (digitWidth + spacing);
|
||||
if (i < hands.length - 1) {
|
||||
totalWidth += colonWidth + spacing;
|
||||
@@ -194,7 +194,7 @@ export function drawDigitalClock(params: DigitalClockParams): void {
|
||||
for (let i = 0; i < hands.length; i++) {
|
||||
const value = Math.floor(getDigitalValue(dayFraction, i, hands, cyclesPerDay));
|
||||
const maxUnits = getDigitalMaxUnits(i, hands, cyclesPerDay);
|
||||
const digitCount = maxUnits.toString().length;
|
||||
const digitCount = (maxUnits - 1).toString().length;
|
||||
const valueStr = value.toString().padStart(digitCount, '0');
|
||||
|
||||
for (const char of valueStr) {
|
||||
|
||||
Reference in New Issue
Block a user