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 7602217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:21:24+00:00 2026-05-30T23:21:24+00:00

Here is a Fiddle The image is a orange square with a transparent circle.

  • 0

Here is a Fiddle

The image is a orange square with a transparent circle. Is there anyway to change the colour of the the orange without effecting the transparent circle/background with html 5 canvas tag + jquery. If there is a better method I would like to hear that too.

  • 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-30T23:21:26+00:00Added an answer on May 30, 2026 at 11:21 pm

    Basically you want to do something that can be achieved with most image editing softwares. Canvas can be very powerful if you write scripts to manipulate it. For instance, when using CanvasContext (obtained through the getContext(“2d”) on the canvas element) you can get and put image data, which is basically a collection of pixels represented by 4 bytes each (RGBA). That means that you end up with an array of length Width * Height * 4.

    Now i’m no expert on image/canvas manipulation, so what I suggest can probably be done far more easly. If you want to change the orange part of the image, like say paint an image over it (or a plain color), on any image editing software that would mean that you need to use a mask. As far as I know, here, to use a mask you would have to:

    1. Your image should be drawn on a canvas element to manipulate it.
    2. Create a secondary workspace canvas.
    3. Draw your brush (the image you want to paint) onto the workspace.
    4. Get the workspace canvas imageData.
    5. Replace the Alpha channel of the obtained ImageData (with the one from the image of the original canvas)
    6. Clear the workspace canvas.
    7. Put the new image data onto the workspace canvas.
    8. Draw the workspace canvas onto the original canvas.

    That would mean that your brush (plain color) would have an applied Alpha channel that has the exact same shape as the orange part of the original image.

    Now, at least on chrome, there is a problem with that image from imageshack, and that is that you cannot obtain the imageData of a canvas elemen drawn with an image from an external domain. Doing so woul result on an exception saying that the canvas was tainted with data from other domains. That means that the image you want to manipulate should be hosted under the same domain that your test site is run of. (You must check canvas documentation to see how to avoid that).

    Please note that this aims to something more powerful thant just changing the shape color. If you just want to change it’s color you can just manipulate the original canvas’ imageData RGB channels until you find your desired color.

    Some useful links:

    • Using images with canvas
    • Mozilla Developer Network – Canvas Element
    • Mozilla Developer Network – Canvas Rendering Context
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im looking for a way to change the background image of a div using
Is there a way i can draw the black background behind the image using
I think an image best describes this: JS FIDDLE HERE: http://jsfiddle.net/fp2Ak/ What I want
Problem can be seen here . As you can see in the fiddle, there's
I have a fiddle located here illustrating my problem, namely that when I load
JSFIDDLE HERE If you look at the js fiddle you will find clicking the
In the fiddle here http://jsfiddle.net/mjmitche/KvwGw/21/ , when you submit the form, a new form
Ok here is the fiddle. http://jsfiddle.net/ozzy/mnmc7/ Code is very very basic at this stage,
Here is an example of what I mean: JS Fiddle: http://jsfiddle.net/MWAJC/ As you can
First of all there is a question with the same title here on SO

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.