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

  • Home
  • SEARCH
  • 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 9283705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:41:56+00:00 2026-06-18T18:41:56+00:00

window.onload = function() { var Can1 = document.getElementById(‘canvas2’); var ctx = Can1.getContext(2d); Can1.width=960; Can1.height=720;

  • 0
window.onload = function() {
                var Can1 = document.getElementById('canvas2');

                    var ctx = Can1.getContext("2d");
                    Can1.width=960;
                    Can1.height=720;
                        //ctx.fillStyle = "rgba(0,255,0,0)";
                        //ctx.fillRect(0,0,960,720);
                    var imgData=ctx.getImageData(0,0,960,720);
                     for (var i=0;i<imgData.data.length;i+=4)
                          {
                             imgData.data[i]=255/*-imgData.data[i]*/;
                             imgData.data[i+1]=0/*255-imgData.data[i+1]*/;
                             imgData.data[i+2]=0/*255-imgData.data[i+2]*/;
                             imgData.data[i+3]=255-imgData.data[i+3];
                          }
                          ctx.putImageData(imgData,0,0);




}
  • 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-06-18T18:41:57+00:00Added an answer on June 18, 2026 at 6:41 pm

    This will change every pixel of your canvas to red with alpha unchanged;

        var Can1 = document.getElementById("canvas2");
        var ctx = Can1.getContext("2d");
    
        // get all canvas pixel data
        imgData = ctx.getImageData(0, 0, Can1.width, Can1.height);
    
        // change every pixel on the canvas to rgba(255,0,0,255);
        for (var i=0;i<imgData.data.length;i+=4){
            imgData.data[i]=255     // this is the red component of this pixel
            imgData.data[i+1]=0     // this is the green component of this pixel
            imgData.data[i+2]=0     // this is the blue component of this pixel
            // To keep the alpha the same, just leave .data[i+3] unchanged
            //imgData.data[i+3];  // this is the alpha component of this pixel
        }
    
        // replace all the canvas pixels with your modified pixels
        ctx.putImageData(imgData,0,0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a js code: window.onload = function() { document.getElementById(Button1).onclick = function() { var
Consider a basic addEventListener as window.onload=function(){ document.getElementById(alert) .addEventListener('click', function(){ alert(OK); }, false); } where
i have the following code <script> window.onload = function(){ var a = document.getElementsByTagName(a); for(var
This is my script : window.onload = function (){ var title = document.getElementsByTagName('h1')[0].id =
When I run window.onload = function () { document.addEventListener(deviceready, getGeolocation); } function getGeolocation() {
Why does this occur: window.onload = function(){ var bob=new Number(1); for (var i=0; i<8
I wrote something like this: window.onload = function() { var a = new A();
I have declared my array globally like so: window.onload = function(){ var test =
When I try the following: <html> <body> <script type=text/javascript> window.onload = function() { var
My CKEditor code is window.onload = function() { var editor = CKEDITOR.replace( \'big_info\' );

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.