Jump to content

  • Free consultations and support
  • Live chatClick Here for Live Chat
  • Call ico 1888-906-1888
    Phone support: Open

    Ready for your call :)

    Our business hours:

    Mon — Fri, 2am — 8pm (EST)

    US & EU support teams

    Phone support: Closed

    We are back in: 1h 20m

    Our business hours:

    Mon — Fri, 2am — 8pm (EST)

    US & EU support teams

HTML5 Canvas Colors

html5 canvas colors

  • Please log in to reply

#1 OneDes


    Senior Member

  • Designer
  • 282 posts

Posted 29 December 2012 - 04:40 PM

The context object within an HTML5 canvas can determain colors for lines and shapes and shadows and gradients.
To set the line color in and HTML5 canvas, use the below JavaScript syntax:
cont.strokeStyle = "#FF0000";
To set the fill style for shapes drawn, use the following syntax:
cont.fillStyle = "#0000FF";
To create a gradient, use the following code:
var gradientObject = cont.createLinearGradient(55 ,55, 220, 220);
gradientObject.addColorStop(0, "#FFFF00");
gradientObject.addColorStop(1, "#00FFFF");
This code above specifies the dimensions and position of the gradient area, and the two values, indicate the colors at both ends of the gradient.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users