summarylogtreecommitdiffstats
path: root/SDLPolar.cpp
blob: e28a487574aa925f3f89b1a47705d480443185a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "./SDLPolar.h"

void SDL_Polar::render()
{
	double r0 = Math::evaluateRPN(rpn[0],(-width/2),false) + (double)(height/2 - yOffset);
	double x0 = r0;
	double y0 = 0.0;
	last = {x0,y0};
	for(int i = 0; i < functions.size(); i++)
	{
		switch(i)
		{
			case 0:
				SDL_SetRenderDrawColor(renderer,0xFF,0xFF,0,0xFF);
				break;
			case 1:
				SDL_SetRenderDrawColor(renderer,0xFF,0x22,0x22,0xFF);
				break;
			case 2:
				SDL_SetRenderDrawColor(renderer,0x44,0x44,0xFF,0xFF);
				break;
			case 3:
				SDL_SetRenderDrawColor(renderer,0xFF,0x66,0x00,0xFF);
				break;
		}

		for(double t = 0.0f; t <= 64 * M_PI; t += 0.1f)
		{
			r0 = Math::evaluateRPN(rpn[i],t,false);
			//printf("%f\n",r0);
			x0 = r0 * cos(t) * xScale;
			y0 = r0 * sin(t) * yScale;
			next = {x0 - xOffset + width/2, -y0 + height/2 - yOffset};
			if(t != 0.0)SDL_RenderDrawLine(renderer,last.x,last.y,next.x,next.y);
			last = next;
		}
	}
}