@@ 3,7 3,7 @@
#define HOR 32
#define VER 16
-#define PAD 32
+#define PAD 16
#define ZOOM 4
#define color1 0x000000
#define color2 0x72DEC2
@@ 11,7 11,7 @@
#define color4 0x444444
#define color0 0x111111
-#define SZ HOR* VER * 16
+#define SZ (HOR * VER * 16)
typedef struct Point {
int x;
@@ 41,9 41,9 @@ char* modes[] = {
unsigned char buffer[SZ];
int colors[] = {color1, color2, color3, color4, color0};
-int WIDTH = 8 * HOR * ZOOM + PAD * 2;
-int HEIGHT = 8 * VER * ZOOM + PAD * 2;
-int FPS = 15;
+int WIDTH = 8 * HOR + PAD * 2;
+int HEIGHT = 8 * VER + PAD * 2;
+int FPS = 30;
int GUIDES = 1;
SDL_Window* gWindow = NULL;
SDL_Renderer* gRenderer = NULL;
@@ 73,10 73,7 @@ dispt(Point* a, Point* b)
void
pixel(uint32_t* dst, int x, int y, int c)
{
- int h, v;
- for(h = 0; h < ZOOM; ++h)
- for(v = 0; v < ZOOM; ++v)
- dst[((y * ZOOM) + PAD + v) * WIDTH + ((x * ZOOM) + PAD + h)] = c;
+ dst[(y + PAD) * WIDTH + (x + PAD)] = c;
}
void
@@ 333,16 330,16 @@ domouse(SDL_Event* event, Brush* b)
if(event->button.button == SDL_BUTTON_LEFT) {
b->down = 1;
setpt(&b->prev,
- (event->motion.x - PAD) / ZOOM,
- (event->motion.y - PAD) / ZOOM);
+ (event->motion.x - (PAD * ZOOM)) / ZOOM,
+ (event->motion.y - (PAD * ZOOM)) / ZOOM);
}
if(event->button.button == SDL_BUTTON_RIGHT)
b->erase = 1;
case SDL_MOUSEMOTION:
if(b->down) {
setpt(&b->pos,
- (event->motion.x - PAD) / ZOOM,
- (event->motion.y - PAD) / ZOOM);
+ (event->motion.x - (PAD * ZOOM)) / ZOOM,
+ (event->motion.y - (PAD * ZOOM)) / ZOOM);
if(b->mode == 0)
line(&b->prev, &b->pos, b->erase ? 0 : b->color);
else if(b->mode == 7)
@@ 423,8 420,8 @@ init(void)
gWindow = SDL_CreateWindow("nasu",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
- WIDTH,
- HEIGHT,
+ WIDTH * ZOOM,
+ HEIGHT * ZOOM,
SDL_WINDOW_SHOWN);
if(gWindow == NULL)
return error("Window", SDL_GetError());