我已經得到了通過創建基於陰影從一組座標的距離細胞梯度的腳本。我想要做的是使漸變圓形,而不是它目前的菱形形狀。你可以在這裏看到一間例如:http://jsbin.com/uwivev/9/edit獲取彎曲的結果集,而不是角在JavaScript(數學幫助需要)
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);
});
如果你能給我的手用正確的數學函數來獲取曲線後,我這將是偉大的!謝謝!
達倫
你爲什麼做這樣的嗎?爲什麼不使用畫布? – elclanrs