Skip to content
Merged
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
17 changes: 13 additions & 4 deletions android/app/src/main/kotlin/cc/hafa/reader/ui/Logo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ private const val DOT_RADIUS = 6f
private const val SPACING = 13.2f
private const val FIRST_RADIUS = 16.8f
private const val STROKE = 8.1f
private const val LAST_RADIUS = FIRST_RADIUS + SPACING

// outer edge of the still logo's last arc, which no wave crosses
private const val EDGE = LAST_RADIUS + STROKE / 2
private const val STEP_SECONDS = 0.7
private const val NANOS_PER_SECOND = 1e9
private val SLOTS = listOf(-1, 0, 1, 2)
Expand All @@ -57,10 +61,15 @@ private fun wavesAt(phase: Double): List<Wave> {
val whole = floor(phase).toInt()
val fraction = (phase - whole).toFloat()
return SLOTS.map { slot ->
val radius = FIRST_RADIUS + SPACING * (slot + fraction)
val grow = smooth((radius - (FIRST_RADIUS - SPACING)) / SPACING)
val shrink = smooth(1 - (radius - (FIRST_RADIUS + SPACING)) / SPACING)
Wave(radius, STROKE * minOf(grow, shrink), if ((slot - whole) % 2 == 0) WHITE else BLUE)
val travel = FIRST_RADIUS + SPACING * (slot + fraction)
val color = if ((slot - whole) % 2 == 0) WHITE else BLUE
if (travel <= LAST_RADIUS) {
Wave(travel, STROKE * smooth((travel - (FIRST_RADIUS - SPACING)) / SPACING), color)
} else {
// past the last arc it holds its outer edge and thins inward
val width = STROKE * (1 - smooth((travel - LAST_RADIUS) / SPACING))
Wave(EDGE - width / 2, width, color)
}
}
}

Expand Down
22 changes: 13 additions & 9 deletions web/src/lib/components/logo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
const SPACING = 13.2;
const FIRST_RADIUS = 16.8;
const STROKE = 8.1;
const LAST_RADIUS = FIRST_RADIUS + SPACING;
// outer edge of the still logo's last arc, which no wave crosses
const EDGE = LAST_RADIUS + STROKE / 2;
const STEP_SECONDS = 0.7;
const SLOTS = [-1, 0, 1, 2];
const WHITE = "#fff";
Expand All @@ -33,15 +36,16 @@
const whole = Math.floor(phase);
const fraction = phase - whole;
return SLOTS.map((slot) => {
const radius = FIRST_RADIUS + SPACING * (slot + fraction);
const grow = smooth((radius - (FIRST_RADIUS - SPACING)) / SPACING);
const shrink = smooth(1 - (radius - (FIRST_RADIUS + SPACING)) / SPACING);
return {
slot,
radius,
width: STROKE * Math.min(grow, shrink),
color: (slot - whole) % 2 === 0 ? WHITE : BLUE,
};
const travel = FIRST_RADIUS + SPACING * (slot + fraction);
const color = (slot - whole) % 2 === 0 ? WHITE : BLUE;
if (travel <= LAST_RADIUS) {
const grow = smooth((travel - (FIRST_RADIUS - SPACING)) / SPACING);
return { slot, radius: travel, width: STROKE * grow, color };
} else {
// past the last arc it holds its outer edge and thins inward
const width = STROKE * (1 - smooth((travel - LAST_RADIUS) / SPACING));
return { slot, radius: EDGE - width / 2, width, color };
}
});
});

Expand Down
Loading