我有一个脚本,它通过根据单元格与一组坐标的距离为单元格着色来创建渐变。我想要做的是使渐变圆形而不是现在的菱形。你可以在这里看到一个例子:http: //jsbin.com/uwivev/9/edit
var row = 5, col = 5, total_rows = 20, total_cols = 20;
$('table td').each(function(index, item) {
// Current row and column
var current_row = $(item).parent().index(),
current_col = $(item).index();
// Percentage based on location, always using positive numbers
var percentage_row = Math.abs(current_row-row)/total_rows;
var percentage_col = Math.abs(current_col-col)/total_cols;
// I'm thinking this is what I need to change to achieve the curve I'm after
var percentage = (percentage_col+percentage_row)/2;
$(this).find('div').fadeTo(0,percentage*3);
});
如果你能给我提供正确的数学函数来获得我所追求的曲线,那就太好了!谢谢!
达伦