-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.js
52 lines (45 loc) · 1.51 KB
/
functions.js
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
var labelEngine = new labelgun["default"](
function(label){
label.labelObject.hide = true;
},
function(label){
label.labelObject.hide = false;
}
);
var createTextStyle = function(feature, resolution, labelText, labelFont,
labelFill) {
if (feature.hide) {
return new ol.style.Text();
}
var textStyle = new ol.style.Text({
font: labelFont,
text: labelText,
textBaseline: "middle",
textAlign: "left",
offsetX: 8,
offsetY: 3,
fill: new ol.style.Fill({
color: labelFill
})
});
return textStyle;
};
function stripe(stripeWidth, gapWidth, angle, color) {
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
canvas.width = screen.width;
canvas.height = stripeWidth + gapWidth;
context.fillStyle = color;
context.lineWidth = stripeWidth;
context.fillRect(0, 0, canvas.width, stripeWidth);
innerPattern = context.createPattern(canvas, 'repeat');
var outerCanvas = document.createElement('canvas');
var outerContext = outerCanvas.getContext('2d');
outerCanvas.width = screen.width;
outerCanvas.height = screen.height;
outerContext.rotate((Math.PI / 180) * angle);
outerContext.translate(-(screen.width/2), -(screen.height/2));
outerContext.fillStyle = innerPattern;
outerContext.fillRect(0,0,screen.width,screen.height);
return outerContext.createPattern(outerCanvas, 'no-repeat');
};