
2. Jak zmodyfikować skrypt, żeby wskazówka od sekund "pływała"?
function init() { clock(); setInterval('clock()',1000); } function clock() { var now = new Date(); var canvas = document.getElementById('page_clock'); if (canvas.getContext) { var ctx = canvas.getContext('2d'); ctx.save(); ctx.clearRect(0,0,200,200); ctx.translate(100,100); //kolor, grubość, styl zakończenia, styl łączenia, przezroczystość ctx.strokeStyle = "#ffffff"; ctx.lineWidth = 8; ctx.lineCap = "round"; ctx.lineJoin = "round"; ctx.globalAlpha = 0.65; var sec = now.getSeconds(); var min = now.getMinutes(); var hr = now.getHours(); hr = hr >= 12 ? hr-12 : hr; ctx.rotate(-Math.PI/2); //godzina ctx.rotate( hr*(Math.PI/6) + (Math.PI/360)*min + (Math.PI/21600)*sec ); ctx.beginPath(); ctx.moveTo(0,0); ctx.lineTo(50,0); ctx.stroke(); //minuta ctx.rotate( (Math.PI/30)*min + (Math.PI/1800)*sec ); ctx.beginPath(); ctx.moveTo(0,0); ctx.lineTo(70,0); ctx.stroke(); //sekunda ctx.rotate(sec * Math.PI/30); ctx.strokeStyle = "#ff0000"; ctx.lineWidth = 5; ctx.beginPath(); ctx.moveTo(0,0); ctx.lineTo(70,0); ctx.stroke(); ctx.restore(); } } window.onload = init;
pzdr
Jeszcze mi się nasunęło 3. Jak przejść walidację?
