Skip to content
Open
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
44 changes: 35 additions & 9 deletions lib/badge_animation/ani_snowflake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,34 @@ class SnowFlakeAnimation extends BadgeAnimation {
void processAnimation(int badgeHeight, int badgeWidth, int animationIndex,
List<List<bool>> processGrid, List<List<bool>> 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
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment mentions 'text section' but this is a snowflake animation. The comment should be updated to reflect the actual purpose, such as 'Determine which content frame we're currently showing'.

Suggested change
// Determine which text section we're currently showing
// Determine which content frame we're currently showing

Copilot uses AI. Check for mistakes.
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;
Expand All @@ -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];
}
}
Expand All @@ -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];
}
}
Expand All @@ -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];
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"up": "Up",
"down": "Down",
"fixed": "Fixed",
"animation": "Animation",
"animation": "Dot-Matrix",
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate key 'animation' found in the localization file. This key appears at lines 65, 134, and 161. In JSON/ARB files, duplicate keys can cause unpredictable behavior as only the last occurrence will be used. Each key should be unique or the keys should be renamed to be more specific (e.g., 'animationMode', 'animationType', 'animationLabel').

Copilot uses AI. Check for mistakes.
"snowflake": "Snowflake",
"picture": "Picture",
"laser": "Laser",
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n/app_hi.arb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
"failedToSaveBadge": "बैज सेव नहीं हुआ",
"save": "सेव करें",
"speed": "स्पीड",
"animation": "एनिमेशन",
"animation": "डॉट-मैट्रिक्स",
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate key 'animation' found in the localization file. This key appears at lines 58, 123, and 150. In JSON/ARB files, duplicate keys can cause unpredictable behavior as only the last occurrence will be used. Each key should be unique or the keys should be renamed to be more specific (e.g., 'animationMode', 'animationType', 'animationLabel').

Copilot uses AI. Check for mistakes.
"effects": "इफेक्ट",
"transfer": "बैज पर भेजें",
"saveBadge": "बैज सेव करें",
Expand Down
2 changes: 1 addition & 1 deletion lib/l10n/app_localizations_hi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class AppLocalizationsHi extends AppLocalizations {
String get speedTitle => 'स्पीड';

@override
String get animation => 'एनिमेशन';
String get animation => 'डॉट-मैट्रिक्स';

@override
String get transition => 'बदलाव';
Expand Down
Loading