// Between depth i and i+1, p runs from 0 to 1.
// The outgoing layer grows around its target;
// the incoming layer shrinks onto that same target.
const s = target.width / incoming.width; // < 1
const k = 1 / s;
out.style.transform =
`translate(${(cx - tx) * p}px, ${(cy - ty) * p}px) scale(${k ** p})`;
inc.style.transform =
`translate(${(tx - cx) * (1 - p)}px, ${(ty - cy) * (1 - p)}px) scale(${s ** (1 - p)})`;
enum class State { Idle, Fill, Heat, Wash, Drain, Fault };
State next(State s, const Sensors& in) {
switch (s) {
case State::Idle: return in.doorClosed && in.start ? State::Fill : s;
case State::Fill: return in.level >= target.level ? State::Heat : s;
case State::Heat: return in.temp >= target.temp ? State::Wash : s;
case State::Wash: return timer.expired() ? State::Drain : s;
case State::Drain: return in.level <= 0 ? State::Idle : s;
case State::Fault: return s;
}
return State::Fault;
}
@GET
@Path("/accounts/{id}/balance")
public Response balance(@PathParam("id") String id) {
Account account = accounts.find(id)
.orElseThrow(NotFoundException::new);
Person owner = personService.get(account.ownerId()); // another service, over REST
return Response.ok(new BalanceDto(owner.name(), account.balance())).build();
}
cartRef.addSnapshotListener { snapshot, error ->
if (error != null) return@addSnapshotListener
val items = snapshot?.documents?.mapNotNull { it.toObject<CartItem>() }.orEmpty()
_cart.value = items.sortedBy { it.addedAt }
}
while (window.isOpen()) {
float dt = clock.restart().asSeconds();
handleInput(window);
for (auto& entity : entities) entity->update(dt, world);
resolveCollisions(entities);
window.clear();
for (auto& entity : entities) entity->draw(window);
window.display();
}