Skip to content

Commit

Permalink
feat: Added the left animation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhalakupadhyay committed Sep 8, 2024
1 parent 4be7e17 commit cd353bb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
32 changes: 32 additions & 0 deletions lib/badge_animation/anim_left.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:badgemagic/badge_animation/animation_abstract.dart';

class LeftAnimation extends BadgeAnimation {
@override
void animation(
List<List<bool>> grid,
List<List<int>> newGrid,
int animationIndex,
bool validMarquee,
bool flashLEDOn,
int currentcountFrame,
int i,
int j,
int newHeight,
int newWidth,
int badgeHeight,
int badgeWidth) {
// Calculate how much of the new grid is currently visible in the grid
int scrollOffset = animationIndex % (newWidth + badgeWidth);

// Get the corresponding column in the new grid based on the scroll position
int sourceCol = j + scrollOffset - badgeWidth;

// If sourceCol is negative, display blank space (off-screen part of the grid)
if (sourceCol >= 0 && sourceCol < newWidth) {
// Ensure flashLEDOn and validMarquee effects are applied
grid[i][j] = flashLEDOn && newGrid[i % newHeight][sourceCol] == 1;
} else {
grid[i][j] = false;
}
}
}
5 changes: 3 additions & 2 deletions lib/providers/badgeview_provider.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';

import 'package:badgemagic/bademagic_module/utils/byte_array_utils.dart';
import 'package:badgemagic/badge_animation/anim_left.dart';
import 'package:badgemagic/badge_animation/animation_abstract.dart';
import 'package:badgemagic/constants.dart';
import 'package:badgemagic/providers/cardsprovider.dart';
Expand Down Expand Up @@ -115,7 +116,7 @@ class DrawBadgeProvider extends ChangeNotifier {
switch (cardData.getAnimationIndex()) {
//add cases from 0 to 8
case 0:
currentAnimation = null;
currentAnimation = LeftAnimation();
break;
case 1:
// currentAnimation = RightAnimation();
Expand All @@ -142,7 +143,7 @@ class DrawBadgeProvider extends ChangeNotifier {
currentAnimation = null;
break;
default:
currentAnimation = null;
currentAnimation = LeftAnimation();
break;
}
}
Expand Down

0 comments on commit cd353bb

Please sign in to comment.