Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
68 lines (59 loc) · 1.99 KB

File metadata and controls

68 lines (59 loc) · 1.99 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* $Id: gnuplot_dashedlines.js,v 1.2 2010/11/26 23:39:16 sfeam Exp $
*/
/*
* Ethan Merritt November 2010
* Add a dashed line method to gnuplot's HTML5 canvas toolset.
* To start a path use DS(x0,y0) instead of M(x0,y0)
* To draw line segments use DL(x,y) instead of L(x,y)
* Finish as usual with ctx.stroke(); ctx.closePath();
*/
gnuplot.solid = [];
gnuplot.dashpattern1 = gnuplot.solid;
gnuplot.dashpattern2 = [ 0.5, 1.0 ];
gnuplot.dashpattern3 = [ .12, .25, .37, .50, .62, .75, .87, 1.0 ];
gnuplot.dashpattern4 = [ 0.50, 0.70, 0.80, 1.0 ];
gnuplot.dashpattern5 = [ 0.30, 0.50, 0.60, 0.75, 0.85, 1.0 ];
gnuplot.dashlength = 200.; // length of one complete pattern
gnuplot.dashfraction = 0; // how far in the pattern we got last time
gnuplot.dash_x = 0;
gnuplot.dash_y = 0;
gnuplot.dashtype = function(dt) {
gnuplot.pattern = dt;
}
gnuplot.dashstart = function(x,y) {
gnuplot.dash_x = x;
gnuplot.dash_y = y;
gnuplot.dashfraction = 0;
gnuplot.M(x,y);
}
gnuplot.dashstep = function(x,y) {
var delx = x - gnuplot.dash_x;
var dely = y - gnuplot.dash_y;
var stride = Math.sqrt(delx*delx + dely*dely) / gnuplot.dashlength;
var this_step;
if (gnuplot.pattern.length == 0) {gnuplot.L(x,y); return;}
while (stride > 0) {
// Find which piece of the pattern we are in
for (i=0; gnuplot.pattern[i] <= gnuplot.dashfraction; i++);
this_step = gnuplot.pattern[i] - gnuplot.dashfraction;
if (stride > this_step) {
new_x = gnuplot.dash_x + delx*this_step/stride;
new_y = gnuplot.dash_y + dely*this_step/stride;
stride = stride - this_step;
gnuplot.dashfraction = gnuplot.pattern[i];
delx = x - new_x;
dely = y - new_y;
} else {
new_x = x;
new_y = y;
gnuplot.dashfraction = gnuplot.dashfraction + stride;
stride = 0;
}
if (i%2==0) gnuplot.L(new_x,new_y);
else gnuplot.M(new_x,new_y);
gnuplot.dash_x = new_x;
gnuplot.dash_y = new_y;
if (gnuplot.dashfraction >= 1.0) gnuplot.dashfraction = 0;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.