simple plasma animation added
This commit is contained in:
parent
4a4b39fc6f
commit
4993fe5194
|
@ -53,4 +53,8 @@ ifeq ($(ANIMATION_LOGO_27C3),y)
|
||||||
SRC += 27c3.c
|
SRC += 27c3.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(ANIMATION_PLASMA),y)
|
||||||
|
SRC += plasma.c
|
||||||
|
endif
|
||||||
|
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
|
@ -14,14 +14,16 @@ comment "Animations"
|
||||||
dep_bool "Breakout Demo" ANIMATION_BREAKOUT $GAME_BREAKOUT
|
dep_bool "Breakout Demo" ANIMATION_BREAKOUT $GAME_BREAKOUT
|
||||||
bool "Martin Herweg" ANIMATION_MHERWEG $RANDOM_SUPPORT
|
bool "Martin Herweg" ANIMATION_MHERWEG $RANDOM_SUPPORT
|
||||||
dep_bool "Langton Ant" ANIMATION_LTN_ANT $RANDOM_SUPPORT
|
dep_bool "Langton Ant" ANIMATION_LTN_ANT $RANDOM_SUPPORT
|
||||||
|
|
||||||
dep_bool_menu "Bitmap Scroller" ANIMATION_BMSCROLLER y $RANDOM_SUPPORT
|
dep_bool_menu "Bitmap Scroller" ANIMATION_BMSCROLLER y $RANDOM_SUPPORT
|
||||||
dep_bool "LABOR Logo" ANIMATION_LABORLOGO $ANIMATION_BMSCROLLER
|
dep_bool "LABOR Logo" ANIMATION_LABORLOGO $ANIMATION_BMSCROLLER
|
||||||
dep_bool "Amphibian" ANIMATION_AMPHIBIAN $ANIMATION_BMSCROLLER
|
dep_bool "Amphibian" ANIMATION_AMPHIBIAN $ANIMATION_BMSCROLLER
|
||||||
dep_bool "27c3 Logo" ANIMATION_LOGO_27C3 $ANIMATION_BMSCROLLER
|
dep_bool "27c3 Logo" ANIMATION_LOGO_27C3 $ANIMATION_BMSCROLLER
|
||||||
endmenu
|
endmenu
|
||||||
|
|
||||||
|
bool "Plasma" ANIMATION_PLASMA
|
||||||
|
|
||||||
comment "Special Animations"
|
comment "Special Animations"
|
||||||
bool "Test Animations" ANIMATION_TESTS
|
bool "Test Animations" ANIMATION_TESTS
|
||||||
bool "Display off mode" ANIMATION_OFF
|
bool "Display off mode" ANIMATION_OFF
|
||||||
endmenu
|
endmenu
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "../config.h"
|
||||||
|
#include "../pixel.h"
|
||||||
|
#include "../util.h"
|
||||||
|
#include "plasma.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define FRAME_TICK 80
|
||||||
|
#define FRAME_COUNT 750
|
||||||
|
#define PLASMA_X (1.0 / (NUM_COLS / (2.0 * M_PI)))
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* calculates the distance between two points
|
||||||
|
* @param x1 x coordinate of the first point
|
||||||
|
* @param y1 y coordinate of the first point
|
||||||
|
* @param x2 x coordinate of the second point
|
||||||
|
* @param y2 y coordinate of the second point
|
||||||
|
* @return distance between the points
|
||||||
|
*/
|
||||||
|
static double dist(double x1, double y1, double x2, double y2)
|
||||||
|
{
|
||||||
|
return sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draws a simple plasma effect
|
||||||
|
*/
|
||||||
|
void plasma(void)
|
||||||
|
{
|
||||||
|
for (double t = 0; t < (FRAME_COUNT / 10.0); t = t + 0.1) {
|
||||||
|
for (unsigned char x = 0; x < NUM_COLS; ++x)
|
||||||
|
{
|
||||||
|
for (unsigned char y = 0; y < NUM_ROWS; ++y)
|
||||||
|
{
|
||||||
|
double nColor1 = sin(x * PLASMA_X + t) + 1;
|
||||||
|
double nColor2 = sin(dist(x, y, NUM_COLS * sin(t) + NUM_COLS,
|
||||||
|
NUM_ROWS * cos(t) + NUM_ROWS) * PLASMA_X) + 1;
|
||||||
|
unsigned char nColor =
|
||||||
|
((nColor1 + nColor2) * (NUMPLANE - 1)) / 2;
|
||||||
|
setpixel((pixel){x, y}, nColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wait(FRAME_TICK);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef PLASMA_H_
|
||||||
|
#define PLASMA_H_
|
||||||
|
|
||||||
|
void plasma(void);
|
||||||
|
|
||||||
|
#endif /* PLASMA_H_ */
|
|
@ -15,6 +15,7 @@
|
||||||
#include "animations/amphibian.h"
|
#include "animations/amphibian.h"
|
||||||
#include "animations/laborlogo.h"
|
#include "animations/laborlogo.h"
|
||||||
#include "animations/27c3.h"
|
#include "animations/27c3.h"
|
||||||
|
#include "animations/plasma.h"
|
||||||
#include "animations/mherweg.h"
|
#include "animations/mherweg.h"
|
||||||
#include "borg_hw/borg_hw.h"
|
#include "borg_hw/borg_hw.h"
|
||||||
#include "can/borg_can.h"
|
#include "can/borg_can.h"
|
||||||
|
@ -171,6 +172,13 @@ void display_loop(){
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ANIMATION_PLASMA
|
||||||
|
case 18:
|
||||||
|
plasma();
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef ANIMATION_TESTS
|
#ifdef ANIMATION_TESTS
|
||||||
case 31:
|
case 31:
|
||||||
test_level(1);
|
test_level(1);
|
||||||
|
|
Loading…
Reference in New Issue