Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to canvas coordinates point exception #6

Open
BPing opened this issue Nov 17, 2016 · 1 comment
Open

Convert to canvas coordinates point exception #6

BPing opened this issue Nov 17, 2016 · 1 comment

Comments

@BPing
Copy link
Owner

BPing commented Nov 17, 2016

The lines are not drawn at the location of the mouse point,as follow:

qq 20161117172555

@BPing
Copy link
Owner Author

BPing commented Nov 17, 2016

CSS:

.crysan-canvas-main canvas {
  ....
  width: 1100px;
  height: 800px;
 ....
}

Canvas height and width should not be set in CSS.
Beause,Css only change the canvas element 's width and height,not change drawing surface.

Set the element width and height correctly as follow:

 $(".crysyan-designer").CrysyanDesigner({
        canvas: {
            width: 800,
            height: 500
        }
    }, callback);

About Canvas element size versus drawing surface size(wiki)

A canvas actually has two sizes: the size of the element itself and the size of the element’s drawing surface. Setting the element's width and height attributes sets both of these sizes; CSS attributes affect only the element’s size and not the drawing surface.

By default, both the canvas element’s size and the size of its drawing surface is 300 screen pixels wide and 150 screen pixels high. In the listing shown in the example, which uses CSS to set the canvas element’s size, the size of the element is 600 pixels wide and 300 pixels high, but the size of the drawing surface remains unchanged at the default value of 300 pixels × 150 pixels. When a canvas element’s size does not match the size of its drawing surface, the browser scales the drawing surface to fit the element (which may result in surprising and unwanted effects).

Example on setting element size and drawing surface size to different values:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant