1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
function drawSeaweeds(t, pos){
for(var i = seaweeds.length - 1; i >= 0; i--) {
var startingX = 42 + (seaweeds[i].x/1.2),
startingY = H,
firstX = 42 + seaweeds[i].x + (10 * Math.sin((t*15) * 5 * Math.PI / 2000 + seaweeds[i].x)),
firstY = H + seaweeds[i].x,
secondX = 40 + seaweeds[i].x + ((10 - seaweeds[i].x) * Math.sin((t*15) * 5 * Math.PI / 3000 + seaweeds[i].x)),
secondY = H-50,
endingX = 50 + seaweeds[i].x + Math.sin(t/20) * (30 + (seaweeds[i].x / 2) * Math.sin((t*15*2) * 2 * Math.PI / 2000 + seaweeds[i].x)),
endingY = H-150 + seaweeds[i].x / 2;
cvs.drawBezier({
strokeStyle: "#068C14",
strokeWidth: 1,
fillStyle: "#017A0D",
x1: startingX, y1: startingY, // Start point
cx1: startingX, cy1: firstY, // Control point
cx2: secondX, cy2: secondY, // Control point
x2: endingX, y2: endingY, // Start/end point
cx3: secondX + 15, cy3: secondY - 5, // Control point
cx4: startingX + 20, cy4: firstY - 5, // Control point
x3: startingX + 6, y3: startingY - 3, // Start/end point
});
};
} |
Partager