diff --git a/lib/badge_animation/ani_snowflake.dart b/lib/badge_animation/ani_snowflake.dart index 9fc1c8a0d..637f2b391 100644 --- a/lib/badge_animation/ani_snowflake.dart +++ b/lib/badge_animation/ani_snowflake.dart @@ -5,10 +5,34 @@ class SnowFlakeAnimation extends BadgeAnimation { void processAnimation(int badgeHeight, int badgeWidth, int animationIndex, List> processGrid, List> canvas) { int newWidth = processGrid[0].length; - int totalAnimationLength = badgeHeight * 16; - int frame = animationIndex % totalAnimationLength; + int newHeight = processGrid.length; - int horizontalOffset = (badgeWidth - newWidth) ~/ 2; + // Calculate the total number of frames that fit the badge width + int framesCount = (newWidth / badgeWidth).ceil(); + + // Calculate the total animation length for one complete snowflake cycle + int snowflakeCycleLength = badgeHeight * 16; + + // For transfer optimization: limit to 8 frames maximum + int maxFrames = 8; + int effectiveFramesCount = framesCount.clamp(1, maxFrames); + + // Calculate the total length for one complete text scroll cycle + int totalCycleLength = snowflakeCycleLength * effectiveFramesCount; + + // Get the current position in the overall cycle + int cyclePosition = animationIndex % totalCycleLength; + + // Determine which text section we're currently showing + int currentFrame = cyclePosition ~/ snowflakeCycleLength; + + // Calculate the starting column for the current frame in newGrid + int startCol = currentFrame * badgeWidth; + + // Get the frame within the current snowflake cycle + int frame = cyclePosition % snowflakeCycleLength; + + int horizontalOffset = (badgeWidth - newWidth).clamp(0, badgeWidth) ~/ 2; bool phase1 = frame < badgeHeight * 4; bool phase2 = frame >= badgeHeight * 4 && frame < badgeHeight * 8; @@ -22,9 +46,9 @@ class SnowFlakeAnimation extends BadgeAnimation { if (fallPosition >= 0 && fallPosition < badgeHeight) { for (int col = 0; col < badgeWidth; col++) { - int sourceCol = col - horizontalOffset; + int sourceCol = startCol + col - horizontalOffset; bool isWithinNewGrid = sourceCol >= 0 && sourceCol < newWidth; - if (isWithinNewGrid) { + if (isWithinNewGrid && row < newHeight) { canvas[fallPosition][col] = processGrid[row][sourceCol]; } } @@ -38,9 +62,9 @@ class SnowFlakeAnimation extends BadgeAnimation { if (fallOutPosition < row) { for (int col = 0; col < badgeWidth; col++) { - int sourceCol = col - horizontalOffset; + int sourceCol = startCol + col - horizontalOffset; bool isWithinNewGrid = sourceCol >= 0 && sourceCol < newWidth; - if (isWithinNewGrid) { + if (isWithinNewGrid && row < newHeight) { canvas[row][col] = processGrid[row][sourceCol]; } } @@ -52,9 +76,11 @@ class SnowFlakeAnimation extends BadgeAnimation { } for (int col = 0; col < badgeWidth; col++) { - int sourceCol = col - horizontalOffset; + int sourceCol = startCol + col - horizontalOffset; bool isWithinNewGrid = sourceCol >= 0 && sourceCol < newWidth; - if (isWithinNewGrid && fallOutPosition < badgeHeight) { + if (isWithinNewGrid && + fallOutPosition < badgeHeight && + row < newHeight) { canvas[fallOutPosition][col] = processGrid[row][sourceCol]; } } diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index b18ba9152..a3cd10676 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -131,7 +131,7 @@ "up": "Up", "down": "Down", "fixed": "Fixed", - "animation": "Animation", + "animation": "Dot-Matrix", "snowflake": "Snowflake", "picture": "Picture", "laser": "Laser", diff --git a/lib/l10n/app_hi.arb b/lib/l10n/app_hi.arb index 8de6ae93d..0880b3536 100644 --- a/lib/l10n/app_hi.arb +++ b/lib/l10n/app_hi.arb @@ -147,7 +147,7 @@ "failedToSaveBadge": "बैज सेव नहीं हुआ", "save": "सेव करें", "speed": "स्पीड", - "animation": "एनिमेशन", + "animation": "डॉट-मैट्रिक्स", "effects": "इफेक्ट", "transfer": "बैज पर भेजें", "saveBadge": "बैज सेव करें", diff --git a/lib/l10n/app_localizations_hi.dart b/lib/l10n/app_localizations_hi.dart index 7def314e3..ccbf41b81 100644 --- a/lib/l10n/app_localizations_hi.dart +++ b/lib/l10n/app_localizations_hi.dart @@ -185,7 +185,7 @@ class AppLocalizationsHi extends AppLocalizations { String get speedTitle => 'स्पीड'; @override - String get animation => 'एनिमेशन'; + String get animation => 'डॉट-मैट्रिक्स'; @override String get transition => 'बदलाव';