mirror of
				https://github.com/AquaMorph/Droplets.git
				synced 2025-10-31 08:23:18 +00:00 
			
		
		
		
	Sprite based graphics
This commit is contained in:
		| @@ -29,6 +29,9 @@ void Droplet::AnimationInc() { | ||||
|     count = 0; | ||||
|   } | ||||
|   count++; | ||||
|   //animation_count = animation_count % animation_rate; | ||||
|   WriteCenteredString(*patch, (screen_min + screen_max) / 2, 40, | ||||
| 		      Font_6x8, std::to_string(animation_count)); | ||||
| } | ||||
|  | ||||
| void Droplet::SetAnimationRate(int rate) { | ||||
|   | ||||
| @@ -46,29 +46,15 @@ void VCODroplet::Process(float** in, float** out, size_t size) { | ||||
| } | ||||
|  | ||||
| void VCODroplet::Draw() { | ||||
|   int sine_width = 20; | ||||
|   bool sine_wave[sine_width][Droplet::kTitleHeight]; | ||||
|  | ||||
|   // Set blank pattern | ||||
|   for (int h = 0; h < kTitleHeight; h++) { | ||||
|     for (int w = screen_min; w < screen_max; w++) { | ||||
|       sine_wave[w][h] = false; | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   wave->SetBlank(); | ||||
|   for (int i = 0; i < sine_width; i++) { | ||||
|     int pixel = (int) round(std::sin(2*pi*((double)(i + animation_count%sine_width)/sine_width)) * (kTitleHeight/2) + kTitleHeight/2); | ||||
|   sine_wave[i][pixel] = true; | ||||
|   } | ||||
|  | ||||
|   for (int h = 0; h < kTitleHeight; h++) { | ||||
|     for (int w = screen_min; w < screen_max; w++) { | ||||
|       patch->display.DrawPixel(w, h, sine_wave[w%sine_width][h%kTitleHeight]); | ||||
|     } | ||||
|     wave->SetPixel(i, pixel, true); | ||||
|   } | ||||
|    | ||||
|   WriteString(*patch, 0, 54, Font_6x8, | ||||
| 	      WaveToString(wavectrl.Process())); | ||||
|   wave->DrawTile(*patch, screen_min, 0, screen_max, kTitleHeight); | ||||
|   DrawName(patch, "VCO"); | ||||
|   AnimationInc(); | ||||
| } | ||||
|   | ||||
| @@ -10,6 +10,7 @@ | ||||
|  | ||||
| #include "droplet.h" | ||||
| #include "../util.h" | ||||
| #include "../graphics/sprite.h" | ||||
|  | ||||
| using namespace daisy; | ||||
| using namespace daisysp; | ||||
| @@ -20,6 +21,8 @@ private: | ||||
|   Parameter freqctrl, wavectrl, ampctrl, finectrl; | ||||
|   std::string WaveToString(uint8_t); | ||||
|   const double pi = std::acos(-1); | ||||
|   int sine_width = 20; | ||||
|   Sprite* wave = new Sprite(sine_width, kTitleHeight); | ||||
| public: | ||||
|   VCODroplet(DaisyPatch*, DropletState, float); | ||||
|   void Control(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user