2

Hey Everyone I am new to html5 canvas as I would like to know is there any possibility of getting the image height,width and angle values while resizing and rotating.The image which displays what i want.Image I want that process after dropping in to canvas as i searched Google for this couldn't find relevant answer almost everyone is showing the positions of image in canvas that is to kept in code but i want the image should should display its values automatically by click on dimensions button.Thanks in advance any help would be great.

The image should display its dimensions in canvas according to image like if image is changed(or re-sized or rotate automatically the dimensions should change using button click function).

14
  • Depends upon how are you resizing and rotating the image! Commented Mar 1, 2013 at 11:32
  • yes @MJQ if we resize the image it automatically should display the image height,width Commented Mar 1, 2013 at 11:42
  • You have to keep track of image coordinates, i.e where is it being drawn and its width and height! If you have this you can display them! Commented Mar 1, 2013 at 11:44
  • is there any library to use for this Commented Mar 1, 2013 at 11:48
  • How are you dragging and resizing the drawing? Commented Mar 1, 2013 at 11:50

1 Answer 1

0

You can play with canvas in the following manner

 <canvas id="myCanvas">Your browser does not support the canvas tag.</canvas>
<script type="text/javascript">

    var canvas = document.getElementById('myCanvas');
    var ctx = canvas.getContext('2d');

    // Draw blue rectangle
    ctx.fillStyle = '#0065BD';
    ctx.fillRect(0, 0, 125, 75);

    // Draw white X
    ctx.beginPath();
    ctx.lineWidth = "15";
    ctx.strokeStyle = "white";
    ctx.moveTo(0, 0);
    ctx.lineTo(125, 75);
    ctx.moveTo(125, 0);
    ctx.lineTo(0, 75);
    ctx.stroke();

</script>

Hope this helps you.

Sign up to request clarification or add additional context in comments.

3 Comments

thanks for ur help this is not what i want actually if u saw the image u will understand what is my concept i can resize and rotate my image in canvas but im unable to display the height,width and angle values while resizing,rotating
I think for that you have to play with jquery where you assign x & y-axis dynamically . So when you move from 1 position to another , you see the dynamic change in position of your cursor which is the height & width of your image
thanq for ur suggestion i will try with that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.