Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7494701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:43:46+00:00 2026-05-29T17:43:46+00:00

the code below displays a radial gradient filled rectangle. If I un-comment the two

  • 0

the code below displays a radial gradient filled rectangle. If I un-comment the two lines that set canvas’ width and height, it displays a black rectangle instead of a gradient filled one. why? how to set the width and height and still be able to show a gradient?

<!DOCTYPE HTML>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <script type="text/javascript">
      function on_load(e) {
        var container = document.getElementById("container");
        var canvas = container.appendChild(document.createElement("canvas"));
        var context = canvas.getContext("2d");
        var gradient = context.createRadialGradient(30, 30, 10, 30, 30, 30);
gradient.addColorStop(0, "rgba(0,0,0,1)"); gradient.addColorStop(1, "rgba(0,0,0,0)");
context.fillStyle = gradient;
//canvas.width = 150; //canvas.height = 150;
context.fillRect(0, 0, 60, 60); } </script> </head> <body onload="on_load()"><div id="container"></div></body> </html>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T17:43:48+00:00Added an answer on May 29, 2026 at 5:43 pm

    You have to change canvas size before using its context

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that displays videos. The code below gets a list of
The line of code below displays a dialog box with two buttons: Yes and
In the code below, $row['site'] is an URL. In Chrome and IE8, it displays
The below HTML/CSS/Javascript (jQuery) code displays the #makes select box. Selecting an option displays
I have a model, Director with two DateFields, and two subclasses (code below). I
I'm using the code below to take a screenshot of all the active displays
The code below is used to calculate the miles between two cities. In this
There is a script that triggers the code below I want to disallow executing
The pagination code below displays nicely. However, it is always left-justified against the edge
The code snippet below displays a Dialog with a simple login-form. The problem is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.