# HG changeset patch # User Matti Hamalainen # Date 1534242894 -10800 # Node ID bb1602f371d4421d51c18c12ef4b9633c2f9da8f # Parent 5af8b5ddf349fca9203efc7ceeaabdb89f2aa252 Add helper function chopv() and use it. diff -r 5af8b5ddf349 -r bb1602f371d4 draw_outputs.pde --- a/draw_outputs.pde Tue Aug 14 13:12:43 2018 +0300 +++ b/draw_outputs.pde Tue Aug 14 13:34:54 2018 +0300 @@ -11,6 +11,10 @@ return int(v / 8) * 8; } +int chopv(int v, int qv) +{ + return int(v / qv) * qv; +} void createpoint(int x, int y, int mo) @@ -115,8 +119,8 @@ if (g_data[int('c')] == 1 || g_shift == true) { if (g_data[int('q')] == 1) { // XXX is this g_gridx an error? - midy = int(midy / g_gridx) * g_gridx; - midx = int(midx / g_gridx) * g_gridx; + midy = chopv(midy, g_gridx); + midx = chopv(midx, g_gridx); } } int orient; @@ -998,19 +1002,15 @@ g_storedcoordx = x; g_storedcoordy = y; - int midx = 0; - int midy = 0; //brush handle mid point //some tools are exempted if (g_btype == 9 && tool() != 4 && tool() != 0 && mbut != 255) { - midx = int((g_bsourcex2 - g_bsourcex) / 2); - midy = int((g_bsourcey2 - g_bsourcey) / 2); - x = x - midx; - y = y - midy; + x -= int((g_bsourcex2 - g_bsourcex) / 2); + y -= int((g_bsourcey2 - g_bsourcey) / 2); } if (g_data[int('c')] == 1 || g_shift) { - x = int(x / g_gridx) * g_gridx; - y = int(y / g_gridy) * g_gridy; + x = chopv(x, g_gridx); + y = chopv(y, g_gridy); } if (g_pixelw == 2) { @@ -1026,8 +1026,8 @@ g_data[int('q')] = 0; g_data[int('z')] = 0; - x = int(ox / g_gridx) * g_gridx; - y = int(oy / g_gridy) * g_gridy; + x = chopv(ox, g_gridx); + y = chopv(oy, g_gridy); g_bsourcex = x; g_bsourcey = y;