As I receive numerous questions and suggestions concerning the custom drawing tool JavaScript interface of LectureNotes and how to implement specific drawing tools, I thought that it might be helpful to collect codes here, which should allow to easily copy them. Please feel invited to post additional ones!
To start, a simple dashed line with longer dashing
or a dashed line for which the dashing is not fixed but depends on pencil width
To start, a simple dashed line with longer dashing
Code:
width = LN.getWidth();
height = LN.getHeight();
size = Math.min(width, height);
strokewidth = LN.getStrokeWidth();
dashing1 = 0.01 * size;
dashing2 = (LN.getStrokeCap() == 1) ? dashing1 : dashing1 + 2 * strokewidth;
x1 = LN.getX1();
y1 = LN.getY1();
x2 = LN.getX2();
y2 = LN.getY2();
LN.setDashing(dashing1, dashing2);
LN.drawLine(x1, y1, x2, y2);
Code:
strokewidth = LN.getStrokeWidth();
dashing1 = 10 * strokewidth;
dashing2 = (LN.getStrokeCap() == 1) ? dashing1 : dashing1 + 2 * strokewidth;
x1 = LN.getX1();
y1 = LN.getY1();
x2 = LN.getX2();
y2 = LN.getY2();
LN.setDashing(dashing1, dashing2);
LN.drawLine(x1, y1, x2, y2);





