Jump to content
php.lv forumi

html5 canvas, pašreizējais laiks, variabļi


aezaurs

Recommended Posts

nu ideja apmēram tāda ka viss ir labi līdz nemēģinu lietot now.getHours(), gribējās, lai pie noteiktām stundām uzzimētu nedaudz savādāku bildi ...

 

 

 

function drawShape(){

 

var canvas = document.getElementById('mycanvas');

 

if (canvas.getContext){

 

// use getContext to use the canvas for drawing

var ctx = canvas.getContext('2d');

 

// Create gradients

 

 

//// mans gabals

var hrs = now.getHours();

if(hrs == 12){

var radgrad = ctx.createRadialGradient(50,50,10,52,50,30); /// defaultais radgrad

}

else if(hrs == 18){

var radgrad = ctx.createRadialGradient(50,40,10,52,50,30);

}

 

//// beigas

 

 

radgrad.addColorStop(0, '#f5ff4f');

radgrad.addColorStop(0.3, 'rgba(245,255,79,0.7)');

radgrad.addColorStop(1, 'rgba(104,181,229,1)');

 

// draw shapes

 

ctx.fillStyle = radgrad;

ctx.fillRect(0,0,960,150);

//}

} else {

alert('You need Safari or Firefox 1.5+ to see this demo.');

}

}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...