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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:18:51+00:00 2026-06-13T01:18:51+00:00

I’ve been looking for a long time for the reason why the drawing, erasing

  • 0

I’ve been looking for a long time for the reason why the drawing, erasing and redrawing of a rotated rectangle on the canvas element does not work in google chrome on mac.

I need this because i want to render a hover overlay on the canvas.

I’ve created a Fiddle that represents my code: link

Html:

<canvas id="canvas"  width="400" height="165" style="left: 0px; top: 0px; background-color:red;"></canvas>

Javascript:

var canvas =null;
var ctx;
var target;

$(function() {
        canvas=document.getElementById('canvas');
        ctx = canvas.getContext('2d');
        target = { h:81, id:"i1_2", isempty:false, r:-11.64, w:60, x:143, y:19, zindex:2};
});

function drawRectangle() {
        ctx.save();
        ctx.translate(target.x, target.y);
        ctx.fillStyle = "green";
        ctx.strokeStyle = "blue";
        ctx.globalAlpha = 0.40;
        ctx.rotate(target.r / 180 * Math.PI); //NO Rotation => It works!
        ctx.fillRect(0,0,target.w,target.h);
        ctx.restore();   
}

function clearRectangle() {
    ctx.clearRect(0,0,400,165);
}    

This works fine in all browsers on windows and mac except for Chrome on Mac.

When i comment out the line

// ctx.rotate(angle);

The rectangle is drawn on the canvas. (without rotation of course)

Did I do something wrong? Or is this maybe a bug in Chrome?

Edit: Probably not a bug in Chrome because this test page works in chrome on Mac:

http://www.html5canvastutorials.com/demos/advanced/html5_canvas_transform_rotate/

Edit 2: I’ve been doing some more research on this and i found this issue logged: link

I took there test fiddle and added some more tests with rotates canvas elements: link
Reading there info, the problem is “solved” when you draw on a smaller canvas.

See here my results of the fiddle:
Bad results

When I change the sizes of the canvases in the above fiddle, making them just 1pixel smaller. Then the results are ok.

Good results

Final conclusion: It seems I can draw a rotated rectangle once. But when i use the clearRect method to erase the canvas, I cannot draw the rectangle again. This only happens when the size of the canvas is big enough. (Bigger than 65600px)

Does anyone of you knows a sollution for this so i can draw and redraw rectangles on the canvas using chrome on mac?

I’m getting crazy about this.

  • 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-13T01:18:53+00:00Added an answer on June 13, 2026 at 1:18 am

    Judging by the research you’ve done you’re already aware this is a browser bug, so you can’t fix it yourself per se. You can, however, work around the problem by using smaller canvases adjacent to each other and drawing on each one with a different offset so the edges of your shapes are aligned.

    It’s not exactly nice from the point of view of the code, but visually it will look the same and it should work around the bug.

    I’ve modified your fiddle to demonstrate: http://jsfiddle.net/z8f2f/35/

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
Does anyone know how can I replace this 2 symbol below from the string
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT

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.