diff options
Diffstat (limited to 'js/blit.js')
| -rw-r--r-- | js/blit.js | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -47,11 +47,26 @@ var blit = (function(){ } }) } + var distance_rect = function(x, y, ratio){ + return Math.sqrt((Math.pow(y * ratio, 2)) + Math.pow(x, 2)) + } + var distance_square = function(x, y, ratio){ + return Math.sqrt((Math.pow(y * ratio, 2)) + Math.pow(x * ratio, 2)) + } blit.circle = function(A, lex){ - var hw = brush.w/2|0, hh = brush.h/2|0 + var hw = brush.w/2, hh = brush.h/2 + var ratio, distance + + if (brush.w === brush.h){ + distance = distance_square + ratio = hw / hh * (brush.w === 3 || brush.w === 5 ? 1.2 : 1.05) + } else { + distance = distance_rect + ratio = hw / hh + } + A.forEach(function(lex,x,y) { - var len = Math.sqrt(Math.pow(x-hw,2)+Math.pow(y-hh,2)) - if (len > Math.abs(hw)) { + if (distance(x - hw + 0.5, y - hh + 0.5, ratio) > hw){ lex.clear() } }) |
