Skip to content

Instantly share code, notes, and snippets.

@joepetrakovich
joepetrakovich / gist:2eb951ce0a6e02753179fc825e331e75
Created November 9, 2025 04:41
Simple spritesheet animation renderer for SwiftUI
import SwiftUI
struct AnimationDefinition {
let frames: ClosedRange<Int>
let frameDuration: TimeInterval
let loop: Bool
init(frames: ClosedRange<Int>, frameDuration: TimeInterval = 0.1, loop: Bool = false) {
self.frames = frames
self.frameDuration = frameDuration
@joepetrakovich
joepetrakovich / gist:41d54d0bdaa88fd0b8a543227e3b7819
Last active October 31, 2025 05:45
Simple spritesheet animation renderer for Android Jetpack Compose
@Composable
fun SpriteSheet(
modifier: Modifier = Modifier,
spriteSheetResId: Int, // e.g., R.drawable.my_spritesheet
frameWidth: Int, // Width of each frame in pixels
frameHeight: Int, // Height of each frame in pixels
animations: Map<String, Pair<Int, Int>>, // Name to (startFrame, endFrame)
currentAnimation: String, // Name of the animation to loop
frameDurationMillis: Long = 100L // Time per frame
) {
@joepetrakovich
joepetrakovich / translation.js
Last active July 31, 2022 04:48
Translating strings that weren't translated on the server
jQuery(function ($) {
function applyTranslation(stringInfo, currentLanguage) {
const elements = $(stringInfo.selector);
if (!elements.length) {
return;
}
const translation = stringInfo.translations