Ask Experts Questions for FREE Help !
Ask
    camyyssa's Avatar
    camyyssa Posts: 14, Reputation: 1
    New Member
     
    #1

    May 14, 2012, 04:32 AM
    Canvas resizes elements
    Hey,

    My canvas is resizing everything I draw on it based on its size, including images. Is there anyway I can draw using pixel values, without the canvas resizing it?

    Here is my drawing function:

    Code:
    function drawOnCanvas() {
        var b_canvas = document.getElementById("bubbles");
        var context = b_canvas.getContext("2d");
        context.setTransform(1, 0, 0, 1, 0, 0);
        
        for (var x = 0.5; x < 500; x += 10) {
        context.moveTo(x, 0);
        context.lineTo(x, 375);
        }
        for (var y = 0.5; y < 375; y += 10) {
        context.moveTo(0, y);
        context.lineTo(500, y);
        }
        
        context.strokeStyle = "#eee";
        context.stroke();
    }
    And this is how it looks like:



    No errors.

    ----- Edit ----
    I have found the solution here: http://stackoverflow.com/questions/1...-to-fit-window. The fix was to set the canvas width and height before drawing:

    context.canvas.width = window.innerWidth;
    context.canvas.height = window.innerHeight;

Check out some similar questions!

I to have a very nice canvas [ 0 Answers ]

I to have a canvas oil paining my Melton. There is no date on it. It's a painting people standing in front of the water front. Im not sure but it almost looks like Big Ben clock on the back ground. Like maybe old england. The painting was sold to me years ago out of an old hotel that is on the...

Can anyone identify this oil on canvas? [ 0 Answers ]

Hi. I saw this for sale at a old furniture store. I could not find a signature on it at all.. but the artwork looked good and clean. Can anyone identify the oil on canvas(style,motif etc) Thanks,

Windows explorer rapidly resizes automatically [ 1 Answers ]

Hi I have a acer laptop extensa series with windows xp Problem is whenever I open windows explorer or internet explorer it maximizes and minimizes rapidly it never stops until I press windows key in the keyboard Also at time of boot I hear short beeps continuously later log in screen...

Would any fabric do for a canvas [ 16 Answers ]

I am stretching a very big canvas and the only fabric I could find with the right size seems more like.. well it's a bit the same material used in sterile compresses or POP etc.. I mean the wholes are visible. I will put gesso on it of course but I was wondering if it will work or not.. I don't...


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.