Graphyc program in C.

graphics_present.h

				
					/*
 * graphics_presents.h
 *
 *  Created on: 7. 10. 2018
 *      Author: IvanMahdik
 */

#ifndef SOURCE_GRAPHICS_PRESENTS_H_
#define SOURCE_GRAPHICS_PRESENTS_H_

extern void enlargeCircle(int radius, int x, int y, int rychlost, uint32_t *array_scene_fn);
extern void reductionCircle(int radius, int x, int y, int rychlost, uint32_t *array_scene_fn);
extern void enlargeReductionCircle(int radius, int x, int y, int rychlost, uint32_t *array_scene_fn);

extern void drawSquare(unsigned radius_x, unsigned radius_y, uint32_t *array_scene_fn);

#endif /* SOURCE_GRAPHICS_PRESENTS_H_ */

				
			

graphics_present.c

				
					/*
 * graphics_presents.c
 *
 *  Created on: 7. 10. 2018
 *      Author: IvanMahdik
 */

#include <stdint.h>
#include "graphics_presents.h"
#include "dlm3232.h"

void drawCircle(unsigned x, unsigned y, unsigned radius, uint32_t *array_scene_fn);
void fillRectangle(unsigned x, unsigned y, uint32_t *array_scene);

void enlargeCircle(int radius, int x, int y, int rychlost, uint32_t *array_scene_fn);
void reductionCircle(int radius, int x, int y, int rychlost, uint32_t *array_scene_fn);
void enlargeReductionCircle(int radius, int x, int y, int rychlost, uint32_t *array_scene_fn);

void drawSquare(unsigned radius_x, unsigned radius_y, uint32_t *array_scene_fn);

void drawCircle(unsigned x, unsigned y, unsigned radius, uint32_t *array_scene)
{
	int f = 1 - radius;
	int ddF_x = 1;
	int ddF_y = -2 * radius;
	int x1 = 0;
	int y1 = radius;

	fillRectangle(x, y + radius, array_scene);
	fillRectangle(x, y - radius, array_scene);
	fillRectangle(x + radius, y, array_scene);
	fillRectangle(x - radius, y, array_scene);

	while (x1 < y1)
	{
		if (f >= 1)
		{
			y1--;
			ddF_y += 2;
			f += ddF_y;
		}
		x1++;
		ddF_x += 2;
		f += ddF_x;

		fillRectangle(x + x1, y + y1, array_scene);
		fillRectangle(x - x1, y + y1, array_scene);
		fillRectangle(x + x1, y - y1, array_scene);
		fillRectangle(x - x1, y - y1, array_scene);
		fillRectangle(x + y1, y + x1, array_scene);
		fillRectangle(x - y1, y + x1, array_scene);
		fillRectangle(x + y1, y - x1, array_scene);
		fillRectangle(x - y1, y - x1, array_scene);
	}
}
void fillRectangle(unsigned x, unsigned y, uint32_t *array_scene)
{
	if (x < dlm3232_size_x + 1 && x > 0 && y < dlm3232_size_y + 1 && y > 0)
		for (unsigned j = 0; j < y; j++)
		{
			uint32_t rectangle_array;
			rectangle_array = 1;
			for (int a=0; a<x-1; a++)
			{
				rectangle_array <<= 1;
			}
			array_scene[y - 1] |= rectangle_array;
		}
}

void enlargeCircle(int radius, int x, int y, int rychlost, uint32_t *array_scene)
{
	for (int i=0; i<radius; i++)			//enlarge
	{
		drawCircle(x, y, i, array_scene);

		for (int j = 0; j < rychlost; j++)	//circle per frame
			dlm3232_print(array_scene);

		for (int o = 0; o < 32; o++)		//erasing after frame
			array_scene[o] = 0;
	}
}
void reductionCircle(int radius, int x, int y, int rychlost, uint32_t *array_scene)
{
	for (int i = radius-1; i>=0; i--)		//reduction
	{
		drawCircle(x, y, i, array_scene);

		for (int j = 0; j < rychlost; j++)	//circle per frame
			dlm3232_print(array_scene);

		for (int o=0; o<32; o++)			//erasing after frame
			array_scene[o] = 0;
	}
}
void enlargeReductionCircle(int radius, int x, int y, int rychlost, uint32_t *array_scene) //pozor chyba - pri vacsich velkostiach konci v inom bode ako zacina
{
	enlargeCircle(radius, x, y, rychlost, array_scene);
	reductionCircle(radius, x, y, rychlost, array_scene);
}

void drawSquare(unsigned radius_x, unsigned radius_y, uint32_t *array_scene)
{
	radius_x = radius_x > dlm3232_size_x ? dlm3232_size_x : radius_x;
	radius_y = radius_y > dlm3232_size_y ? dlm3232_size_y : radius_y;

	if ((radius_x > 0) && (radius_y > 0))
	{
		for (int i = 0; i < radius_x; i++)				//creating of first line
		{
			array_scene[0] <<= 1;
			array_scene[0] |= 1;
		}

		array_scene[radius_y - 1] |= array_scene[0];	//copy of first line

		for (int i = 1; i < radius_y - 1; i++)
		{
			array_scene[i] |= 1;
			for (int j = 0; j < radius_x - 1; j++)
				array_scene[i] <<= 1;
			array_scene[i] |= 1;
		}

		dlm3232_print(array_scene);
		for (int o = 0; o < dlm3232_size_x; o++)		//erasing after frame
			array_scene[o] = 0;
	}
}

				
			

shift_effect.h

				
					/*
 * shift_effect.h
 *
 *  Created on: 17. 2. 2019
 *      Author: IvanMahdik
 */

#ifndef SHIFT_EFFECT_H_
#define SHIFT_EFFECT_H_

extern void shift_effect(uint32_t *array_scene, char *scene_input, int clock_per_frame, const int suradnice_y);

#endif /* SHIFT_EFFECT_H_ */

				
			

shift_effect.c

				
					/*
 * shift_effect.c
 *
 *  Created on: 17. 2. 2019
 *      Author: IvanMahdik
 */

#include <stdint.h>
#include <string.h>
#include "shift_effect.h"
#include "dlm3232.h"

void shift_effect(uint32_t *array_scene, char *scene_input, int clock_per_frame, const int suradnice_y)
{
	const int sirka_fontu = 5;
	const int vyska_fontu = 9;
	const int medzera_za_znakom = 1;
	const int medzera_font = 5;
	int suradnice_y2 = suradnice_y < 32-vyska_fontu ? suradnice_y : 32-vyska_fontu; //ochrana proti orezaniu a vyteceniu obrazu
	const uint8_t znak[37][9] =
	{
		{0xE, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0xE},		//0
		{1, 0x3, 0x5, 0x9, 0x11, 1, 1, 1, 1}, 						//1
		{0xE, 0x11, 1, 1, 0x2, 0x4, 0x8, 0x10, 0x1F},				//2
		{0xE, 0x11, 1, 1, 0x6, 1, 1, 0x11, 0xE},					//3
		{0x11, 0x11, 0x11, 0x11, 0x1F, 1, 1, 1, 1},					//4
		{0x1F, 0x10, 0x10, 0x10, 0x1E, 1, 1, 1, 0x1E},				//5
		{0xE, 0x11, 0x10, 0x10, 0x1E, 0x11, 0x11, 0x11, 0xE},		//6
		{0x1F, 1, 0x2, 0x2, 0x4, 0x4, 0x8, 0x8, 0x8},				//7
		{0xE, 0x11, 0x11, 0x11, 0xE, 0x11, 0x11, 0x11, 0xE},		//8
		{0xE, 0x11, 0x11, 0x11, 0xF, 1, 1, 0x11, 0xE},				//9
		{0x4, 0xA, 0xA, 0x11, 0x1F, 0x11, 0x11, 0x11, 0x11},		//A
		{0x1E, 0x11, 0x11, 0x11, 0x1E, 0x11, 0x11, 0x11, 0x1E},		//B
		{0xE, 0x11, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0xE},		//C
		{0x1E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x1E},		//D
		{0x1F, 0x10, 0x10, 0x10, 0x1E, 0x10, 0x10, 0x10, 0x1F},		//E
		{0x1F, 0x10, 0x10, 0x10, 0x1E, 0x10, 0x10, 0x10, 0x10},		//F
		{0xE, 0x11, 0x10, 0x10, 0x17, 0x11, 0x11, 0x11, 0xE},		//G
		{0x11, 0x11, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11, 0x11},		//H
		{0x1F, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x1F},			//I
		{0x1F, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x11, 0xE},			//J
		{0x11, 0x11, 0x12, 0x14, 0x18, 0x14, 0x12, 0x11, 0x11},		//K
		{0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1F},		//L
		{0x11, 0x1B, 0x1B, 0x15, 0x15, 0x11, 0x11, 0x11, 0x11},		//M
		{0x11, 0x19, 0x19, 0x15, 0x15, 0x15, 0x13, 0x13, 0x11},		//N
		{0xE, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0xE},		//O
		{0x1E, 0x11, 0x11, 0x11, 0x1E, 0x10, 0x10, 0x10, 0x10},		//P
		{0xE, 0x11, 0x11, 0x11, 0x11, 0x11, 0x15, 0x13, 0xF},		//Q
		{0x1E, 0x11, 0x11, 0x11, 0x1E, 0x14, 0x12, 0x11, 0x11},		//R
		{0xE, 0x11, 0x10, 0x10, 0xE, 0x1, 0x1, 0x11, 0xE},			//S
		{0x1F, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4, 0x4},				//T
		{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0xE},		//U
		{0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0xA, 0xA, 0x4},		//V
		{0x11, 0x11, 0x11, 0x11, 0x15, 0x15, 0x1B, 0x1B, 0x11},		//W
		{0x11, 0x11, 0xA, 0xA, 0x4, 0xA, 0xA, 0x11, 0x11},			//X
		{0x11, 0x11, 0xA, 0xA, 0x4, 0x4, 0x4, 0x4, 0x4, },			//Y
		{0x1F, 0x1, 0x2, 0x2, 0x4, 0x8, 0x8, 0x10, 0x1F},			//Z
//		{0x15, 0xA, 0x15, 0xA, 0x15, 0xA, 0x15, 0xA, 0x15}			//unknown char
		{0, 0, 0xA, 0x15, 0x11, 0xA, 0x4, 0, 0}			//heart
	};
	for(int i=0; i<strlen(scene_input); i++)
	{
		int k;								//width of font
		if ((int)scene_input[i] == 32)		//generator of space - upravuje sirku fontu pre seba
			k = medzera_font - 1;
		else
			k = sirka_fontu - 1 + medzera_za_znakom;
		for(; k>=0; k--) 					//width of font + automaticallz space
		{
			for (int j=0; j<vyska_fontu; j++)
			{
				array_scene[j + suradnice_y2] <<= 1;							//shif celeho obrazu
				if ((int)scene_input[i] > 47 && (int)scene_input[i] < 58)
					array_scene[j + suradnice_y2] |= (znak[(int)scene_input[i]-48][j] >> k);
				else
					if ((int)scene_input[i] > 64 && (int)scene_input[i] < 91)
						array_scene[j + suradnice_y2] |= (znak[(int)scene_input[i]-55][j] >> k);
					else
						if ((int)scene_input[i] == 32)							//generator of a space
							array_scene[j + suradnice_y2] |= 0;
						else
							array_scene[j + suradnice_y2] |= znak[36][j] >> k;	//generator of an unknown char
			}
			for (int l=0; l<clock_per_frame; l++)	//clock_per_frame
				dlm3232_print(array_scene);
		}
	}
	for(int i=0; i<32; i++)							//overovanie ze je ciel obrazu vyprazdneny predtym nez funkcia prevezme novy text a suradnice
	{
		for (int j=0; j<32; j++)
			if (array_scene[j] != 0)
				array_scene[j] <<= 1;
		for (int l=0; l<clock_per_frame; l++)		//clock_per_frame
			dlm3232_print(array_scene);
	}
}