~rabbits/nasu

522bee68b2f6955df0895a5c47a772970f84c045 — neauoire 2 years ago 9786221
Added colorpicker
2 files changed, 9 insertions(+), 5 deletions(-)

M README.md
M nasu.c
M README.md => README.md +1 -0
@@ 41,3 41,4 @@ To resume working on a tileset:
- `mouse1` Paint
- `mouse2` Line
- `mouse1+mouse3` Erase
- `ctrl+mouse1` Color Picker

M nasu.c => nasu.c +8 -5
@@ 441,6 441,7 @@ quit(void)
void
domouse(SDL_Event *event)
{
	int ctrl = SDL_GetModState() & KMOD_LCTRL || SDL_GetModState() & KMOD_RCTRL;
	switch(event->type) {
	case SDL_MOUSEBUTTONUP:
		if(event->button.button == SDL_BUTTON_LEFT)


@@ 461,10 462,11 @@ domouse(SDL_Event *event)
			line(brush.px, brush.py, screenpos(event->motion.x, brush.vx), screenpos(event->motion.y, brush.vy), brush.erase ? 0 : brush.color);
		brush.px = screenpos(event->motion.x, brush.vx);
		brush.py = screenpos(event->motion.y, brush.vy);
		if(!BIGPIXEL) {
		if(!BIGPIXEL)
			lookat((brush.px / 8) * 8, (brush.py / 8) * 8);
		}
		if(brush.down) {
		if(ctrl) /* color picker */
			savemode(&brush.color, getchr(brush.px, brush.py));
		else if(brush.down) {
			if(brush.mode == 0)
				putchr(brush.px, brush.py, brush.erase ? 0 : brush.color);
			else


@@ 476,7 478,9 @@ domouse(SDL_Event *event)
		if(brush.down) {
			brush.x = screenpos(event->motion.x, brush.vx);
			brush.y = screenpos(event->motion.y, brush.vy);
			if(!brush.mode)
			if(ctrl) /* color picker */
				savemode(&brush.color, getchr(brush.px, brush.py));
			else if(!brush.mode)
				line(brush.px, brush.py, brush.x, brush.y, brush.erase ? 0 : brush.color);
			else
				fill(brush.x, brush.y, brush.mode, brush.size, brush.erase ? 0 : brush.color);


@@ 515,7 519,6 @@ dokey(SDL_Event *event)
		case SDLK_b: savemode(&BIGPIXEL, !BIGPIXEL); break;
		case SDLK_z: savemode(&brush.size, brush.size + (brush.size > 1 ? -1 : 0)); break;
		case SDLK_x: savemode(&brush.size, brush.size + (brush.size < 30 ? 1 : 0)); break;

		case SDLK_UP: lookat(brush.vx, brush.vy - 1); break;
		case SDLK_DOWN: lookat(brush.vx, brush.vy + 1); break;
		case SDLK_LEFT: lookat(brush.vx - 1, brush.vy); break;