2023-Robot
Robot code for 2023 FRC season by Argos, FRC team #1756
Loading...
Searching...
No Matches
animiation.h
Go to the documentation of this file.
1
4
5#pragma once
6
8#include <frc/AddressableLED.h>
9#include <units/angle.h>
10#include <units/time.h>
11
12#include <algorithm>
13#include <functional>
14
15namespace argos_lib {
16 namespace led {
20 struct Animation {
24 Animation() = delete;
25
33 Animation(std::function<Strip()> update, unsigned numLEDs, unsigned offset)
35
36 std::function<Strip()> update;
37 unsigned numLEDs;
38 unsigned offset;
39 };
40
48
49 using AnimatedSprite = std::function<Sprite()>;
50
51 namespace animation {
68 Animation Pong(unsigned offset,
69 unsigned width,
70 unsigned height,
71 unsigned ballSize,
72 bool rainbow,
73 frc::AddressableLED::LEDData ballColor,
74 frc::AddressableLED::LEDData backgroundColor,
75 units::millisecond_t frameTime,
77
78 AnimatedSprite ChompingPacMan(float radius,
79 frc::AddressableLED::LEDData color,
80 units::degree_t direction,
81 units::millisecond_t chompPeriod,
82 bool feathered = false);
83 AnimatedSprite DyingPacMan(float radius,
84 frc::AddressableLED::LEDData color,
85 units::degree_t direction,
86 units::degree_t initialMouthAngle,
87 units::millisecond_t animationTime,
88 bool feathered = false);
89
90 Animation PacManPacing(unsigned offset,
91 unsigned width,
92 unsigned height,
93 bool rainbow,
94 frc::AddressableLED::LEDData pacManColor,
96 units::millisecond_t chompPeriod,
97 units::millisecond_t moveSpeed,
99 bool feathered = false);
100
111 void DrawRectangle(
112 Panel& dest, unsigned rectWidth, unsigned rectHeight, float x, float y, frc::AddressableLED::LEDData color);
113
124 void DrawCircle(
125 Panel& dest, float radius, float x, float y, frc::AddressableLED::LEDData color, bool feathered = false);
126
135 Sprite DrawCircleSprite(float radius, frc::AddressableLED::LEDData color, bool feathered = false);
136
147 void RenderSprite(Panel& dest, const Sprite& sprite, float x, float y, float alpha = 1.0);
148
159 Sprite DrawPacMan(float radius,
160 frc::AddressableLED::LEDData color,
161 units::degree_t direction,
162 units::degree_t mouthAngle,
163 bool feathered = false);
164 } // namespace animation
165 } // namespace led
166} // namespace argos_lib
Animation PacManPacing(unsigned offset, unsigned width, unsigned height, bool rainbow, frc::AddressableLED::LEDData pacManColor, argos_lib::led::PrimaryScanDirection paceDirection, units::millisecond_t chompPeriod, units::millisecond_t moveSpeed, argos_lib::led::PanelScanParams scanParams, bool feathered=false)
Definition animation.cpp:149
Animation Pong(unsigned offset, unsigned width, unsigned height, unsigned ballSize, bool rainbow, frc::AddressableLED::LEDData ballColor, frc::AddressableLED::LEDData backgroundColor, units::millisecond_t frameTime, argos_lib::led::PanelScanParams scanParams)
Animation that kind of works like a DVD player screensaver (https://youtu.be/QOtuX0jL85Y)....
Definition animation.cpp:16
void DrawCircle(Panel &dest, float radius, float x, float y, frc::AddressableLED::LEDData color, bool feathered=false)
Draw a circle to the panel.
Definition animation.cpp:368
void DrawRectangle(Panel &dest, unsigned rectWidth, unsigned rectHeight, float x, float y, frc::AddressableLED::LEDData color)
Draws an axis-aligned rectangle to a panel. All pixels outside the rectangle are unmodified.
Definition animation.cpp:354
void RenderSprite(Panel &dest, const Sprite &sprite, float x, float y, float alpha=1.0)
Draw a sprite centered at a point to a panel. This will align the sprite to the nearest pixel alignme...
Definition animation.cpp:402
Sprite DrawPacMan(float radius, frc::AddressableLED::LEDData color, units::degree_t direction, units::degree_t mouthAngle, bool feathered=false)
Generate PacMan sprite :D.
Definition animation.cpp:426
AnimatedSprite DyingPacMan(float radius, frc::AddressableLED::LEDData color, units::degree_t direction, units::degree_t initialMouthAngle, units::millisecond_t animationTime, bool feathered=false)
Definition animation.cpp:123
Sprite DrawCircleSprite(float radius, frc::AddressableLED::LEDData color, bool feathered=false)
Generate a sprite containing a circle with transparent background.
Definition animation.cpp:374
AnimatedSprite ChompingPacMan(float radius, frc::AddressableLED::LEDData color, units::degree_t direction, units::millisecond_t chompPeriod, bool feathered=false)
Definition animation.cpp:107
PrimaryScanDirection
When representing a panel as a strip, sequential addresses are in this direction. Note that the actua...
Definition panel.h:99
std::function< Sprite()> AnimatedSprite
Callable to get dynamic sprite.
Definition animiation.h:49
std::vector< frc::AddressableLED::LEDData > Strip
A strip of LEDs.
Definition panel.h:91
Definition swap_controllers_command.h:12
A representation of a custom LED animation.
Definition animiation.h:20
std::function< Strip()> update
This function can be any callable that returns a sequence of LED colors.
Definition animiation.h:36
unsigned offset
Address of first LED.
Definition animiation.h:38
unsigned numLEDs
Number of LEDs in the animation.
Definition animiation.h:37
Animation()=delete
Delete default constructor because it is meaningless.
Animation(std::function< Strip()> update, unsigned numLEDs, unsigned offset)
Construct a new Animation object.
Definition animiation.h:33
Definition panel.h:106
https://en.wikipedia.org/wiki/Sprite_(computer_graphics)
Definition animiation.h:44
Mask alpha
Per-pixel transparency.
Definition animiation.h:46
Panel colors
Colors of the sprite.
Definition animiation.h:45