ОК, я вроде обманул.Я в конечном итоге с помощью JQuery.Вот что у меня получилось:
var elem = document.getElementById('yellow');
if (elem && elem.getContext) {
var ctx = elem.getContext('2d');
ctx.fillStyle = 'rgba(245,171,28,1)';
ctx.beginPath();
ctx.moveTo(150,150);
ctx.lineTo(20,75);
ctx.lineTo(150,0);
ctx.lineTo(150,150);
ctx.fill();
ctx.closePath();
}
var elem = document.getElementById('orange');
if (elem && elem.getContext) {
var ctx = elem.getContext('2d');
ctx.fillStyle = 'rgba(242,109,35,1)';
ctx.beginPath();
ctx.moveTo(150,150);
ctx.lineTo(150,0);
ctx.lineTo(280,75);
ctx.lineTo(150,150);
ctx.fill();
ctx.closePath();
}
var elem = document.getElementById('red');
if (elem && elem.getContext) {
var ctx = elem.getContext('2d');
ctx.fillStyle = 'rgba(205,31,68,1)';
ctx.beginPath();
ctx.moveTo(150,150);
ctx.lineTo(280,75);
ctx.lineTo(280,225);
ctx.lineTo(150,150);
ctx.fill();
ctx.closePath();
}
var elem = document.getElementById('violet');
if (elem && elem.getContext) {
var ctx = elem.getContext('2d');
ctx.fillStyle = 'rgba(133,26,84,1)';
ctx.beginPath();
ctx.moveTo(150,150);
ctx.lineTo(280,225);
ctx.lineTo(150,300);
ctx.lineTo(150,150);
ctx.fill();
ctx.closePath();
}
var elem = document.getElementById('blue');
if (elem && elem.getContext) {
var ctx = elem.getContext('2d');
ctx.fillStyle = 'rgba(41,90,156,1)';
ctx.beginPath();
ctx.moveTo(150, 150);
ctx.lineTo(150, 300);
ctx.lineTo(20, 225);
ctx.lineTo(150, 150);
ctx.fill();
ctx.closePath();
}
$(function() {
var timer = null;
var anim = function() {
$.each([yellow, orange, red, violet, blue], function(i, el) {
$('.color' + (i + 1)).delay(100 * i).fadeIn();
});
setTimeout(function() {
$.each([yellow, orange, red, violet, blue], function(i, el) {
$('.color' + (i + 1)).delay(100 * i).fadeOut();
});
}, 1500);
if (!timer) {
return timer = setInterval(anim, 3000);
} else {
return;
}
}
anim();
})
Я сделал отдельные холсты для каждого пути, абсолютно позиционировал их и анимировал с помощью jQuery.Спасибо за совет!Это помогло.
Обновление: Мой сосед по комнате провёл меня через некоторые улучшения, чтобы очистить код и сделать его более плавным.Я до сих пор не могу заставить это работать в Firefox.