function intersects(x, y, cx, cy, r) {
var dx = x-cx
var dy = y-cy
// return dx*dx+dy*dy <= r*r //true/false
return dx*dx+dy*dy+'|'+r*r; // gives the numbers compared
//can find some 'fuzzy' math to round the corners?
}
//cx, cy are the center of the circles (mouse click)
//x, y are the pixels that we are looking for (surrounding)
//r is the radius
console.log(intersects(15,13,10,10,6));
function createDivs(){
appendToDivs = '';
for(i=0,r=1,e=1;i < (32*32);i++){
if(e == 33){
e=1;
r++
};
appendToDivs += '<div x='+e+' y='+r+' class="pixel" style="background-color:#666666"></div>';
e++
};
$('.e').html(appendToDivs);
};
brush = {size:6,shape:'square'};
createDivs();
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.