~rabbits/dito

9188c223e32227a31be2a5b940af419a49e839ba — neauoire 2 years ago 3709f28
Added indicators
4 files changed, 19 insertions(+), 20 deletions(-)

M build.sh
M dito.c
A example1.bmp
A example2.bmp
M build.sh => build.sh +3 -3
@@ 7,10 7,10 @@ clang-format -i dito.c
rm -f ./dito

# debug(slow)
cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined dito.c -L/usr/local/lib -lSDL2 -o dito
# cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined dito.c -L/usr/local/lib -lSDL2 -o dito

# build(fast)
# cc dito.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o dito
cc dito.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o dito

# Size
echo "Size: $(du -sk ./dito)"


@@ 23,4 23,4 @@ then
fi

# run
./dito example.bmp
./dito example3.bmp

M dito.c => dito.c +16 -17
@@ 12,8 12,8 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/

#define HOR 22
#define VER 22
#define HOR 32
#define VER 16
#define PAD 2
#define SZ (HOR * VER * 16)



@@ 35,7 35,7 @@ typedef struct {

int WIDTH = 8 * HOR + 8 * PAD * 2;
int HEIGHT = 8 * (VER + 2) + 8 * PAD * 2;
int FPS = 30, GUIDES = 1, DOWN = 0, ZOOM = 1, COLORS = 1;
int FPS = 30, GUIDES = 1, DOWN = 0, ZOOM = 2, COLORS = 1;

Document doc;
Size2d size;


@@ 55,10 55,10 @@ Uint8 icons[][8] = {
	{0x00, 0x38, 0x7c, 0x7c, 0x7c, 0x38, 0x00, 0x00}, /* color:blank */
	{0xfe, 0x82, 0x82, 0xfe, 0x82, 0x82, 0xfe, 0x00}, /* brush:colors2 */
	{0xfe, 0x92, 0x92, 0xfe, 0x92, 0x92, 0xfe, 0x00}, /* brush:colors4 */
	{0xc0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0x60, 0x00}, /* picker:1 */
	{0x0c, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x06, 0x00}, /* picker:2 */
	{0x00, 0x00, 0x00, 0x00, 0xe0, 0xe0, 0xc0, 0x00}, /* picker:3 */
	{0x00, 0x00, 0x00, 0x00, 0x0e, 0x0e, 0x0c, 0x00}, /* picker:4 */
	{0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00}, /* picker:1 */
	{0x7c, 0xc6, 0x0e, 0x3c, 0x78, 0xe0, 0xfe, 0x00}, /* picker:2 */
	{0x7e, 0x0c, 0x18, 0x3c, 0x06, 0xc6, 0x7c, 0x00}, /* picker:3 */
	{0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x0c, 0x00}, /* picker:4 */
	{0xee, 0x92, 0x82, 0x54, 0x82, 0x92, 0xee, 0x00}, /* view:bigpixels */
	{0x00, 0x00, 0x00, 0x82, 0x44, 0x38, 0x00, 0x00}, /* eye open */
	{0x00, 0x38, 0x44, 0x92, 0x28, 0x10, 0x00, 0x00}, /* eye closed */


@@ 205,11 205,7 @@ drawui(Uint32 *dst)
{
	int bottom = VER * 8 + 8;
	drawicon(dst, 0, bottom, icons[COLORS ? 3 : 2], 1, 0);
	drawiconalpha(dst, 1 * 8, bottom, icons[4], 0);
	drawiconalpha(dst, 1 * 8, bottom, icons[5], 1);
	drawiconalpha(dst, 2 * 8, bottom, icons[4], 2);
	drawiconalpha(dst, 2 * 8, bottom, icons[5], 3);
	drawicon(dst, 4 * 8, bottom, icons[GUIDES ? 10 : 9], GUIDES ? 1 : 2, 0);
	drawicon(dst, 2 * 8, bottom, icons[GUIDES ? 10 : 9], GUIDES ? 1 : 2, 0);
	drawicon(dst, (HOR - 1) * 8, bottom, icons[11], doc.unsaved ? 2 : 3, 0); /* save state */
}



@@ 242,7 238,7 @@ getcolor(int x, int y)
int
getpalette(Uint32 clr)
{
	Uint32 res, rec = 999999;
	Uint32 res = 0, rec = 999999;
	int i;
	for(i = 0; i < 4; ++i) {
		Uint32 d = coloroffset(clr, theme[i]);


@@ 257,11 253,11 @@ getpalette(Uint32 clr)
int
getpattern(int palette, int x, int y)
{
	if(palette == 1)
	if(palette == 3)
		return 1;
	if(palette == 2)
		return ((x + y) % 2) == 0 && ((y - x) % 2) == 0;
	if(palette == 3)
	if(palette == 1)
		return ((x + y) % 4) == 0 && ((y - x) % 4) == 0;
	return 0;
}


@@ 300,6 296,10 @@ redraw(Uint32 *dst)
		drawiconalpha(pixels, pickers[1].x - 3, pickers[1].y - 3, icons[1], 1);
		drawiconalpha(pixels, pickers[2].x - 3, pickers[2].y - 3, icons[1], 2);
		drawiconalpha(pixels, pickers[3].x - 3, pickers[3].y - 3, icons[1], 3);
		drawiconalpha(pixels, pickers[0].x + 8, pickers[0].y - 3, icons[4], 4);
		drawiconalpha(pixels, pickers[1].x + 8, pickers[1].y - 3, icons[5], 4);
		drawiconalpha(pixels, pickers[2].x + 8, pickers[2].y - 3, icons[6], 4);
		drawiconalpha(pixels, pickers[3].x + 8, pickers[3].y - 3, icons[7], 4);
	}
	SDL_UpdateTexture(gTexture, NULL, dst, WIDTH * sizeof(Uint32));
	SDL_RenderClear(gRenderer);


@@ 354,7 354,6 @@ setpicker(Point2d *picker, int x, int y)
{
	picker->x = clamp(x, 0, HOR * 8);
	picker->y = clamp(y, 0, VER * 8);
	printf("%d,%d\n", x, y);
	redraw(pixels);
}



@@ 390,7 389,7 @@ selectoption(int option)
{
	switch(option) {
	case 0: savemode(&COLORS, !COLORS); break;
	case 4: savemode(&GUIDES, !GUIDES); break;
	case 2: savemode(&GUIDES, !GUIDES); break;
	case HOR - 1: savedoc(&doc, doc.name); break;
	}
}

A example1.bmp => example1.bmp +0 -0
A example2.bmp => example2.bmp +0 -0