// Copyright © SixtyFPS GmbH // SPDX-License-Identifier: MIT export component SpriteSheet { in property source; in property frames-wide; in property frames-high; in property total-frames: frames-wide * frames-high; in-out property playing: false; in property duration; in property frame: 0; property current-frame: playing ? (total-frames * (animation-tick() / duration)).mod(total-frames) : frame.mod(total-frames).abs(); width: sheet.width; height: sheet.height; sheet :=Image { source: root.source; source-clip-width: self.source.width / root.frames-wide; source-clip-height: self.source.height / root.frames-high; source-clip-x: self.source-clip-width * current-frame.mod(root.frames-wide); source-clip-y: self.source-clip-height * (current-frame / root.frames-wide).floor(); width: self.source.width / root.frames-wide * 1px; height: self.source.height / root.frames-high * 1px; } }