-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawImage.js
117 lines (113 loc) · 3.82 KB
/
drawImage.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
module.exports = {
name: "drawImage",
ns: "canvas",
async: true,
title: "Draw Image",
description: "",
phrases: {
active: "Drawing image"
},
ports: {
input: {
context: {
title: "Context",
type: "CanvasRenderingContext2D"
},
image: {
title: "Image",
type: ["HTMLElement",
"Image"
],
async: true,
fn: function __IMAGE__(data, source, state, input, $, output) {
var r = function() {
var args = [$.image];
if ($.args.sx && $.args.sy && $.args.sw && $.args.sh) {
args.push($.args.sx);
args.push($.args.sy);
args.push($.args.sw);
args.push($.args.sh);
}
args.push($.args.dx || 0);
args.push($.args.dy || 0);
if ($.args.dw) {
args.push($.args.dw);
if ($.args.dh) {
args.push($.args.dh);
}
}
$.context.drawImage.apply($.context, args);
output({
context: $.get('context')
});
}.call(this);
return {
state: state,
return: r
};
}
},
args: {
title: "Dimensions",
type: "object",
properties: {
dx: {
title: "Destination X",
type: "number",
description: "The X coordinate in the destination canvas at which to place the top-left corner of the source image.",
"default": 0
},
dy: {
title: "Destination Y",
type: "number",
description: "The Y coordinate in the destination canvas at which to place the top-left corner of the source image.",
"default": 0
},
dw: {
title: "Destination Width",
type: "number",
description: "The width to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in width when drawn.",
required: false
},
dh: {
title: "Destination Height",
type: "number",
description: "The height to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in height when drawn.",
required: false
},
sx: {
title: "Source X",
type: "number",
description: "The X coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.",
required: false
},
sy: {
title: "Source Y",
type: "number",
description: "The Y coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.",
required: false
},
sw: {
title: "Source Width",
type: "number",
description: "The width of the sub-rectangle of the source image to draw into the destination context. If not specified, the entire rectangle from the coordinates specified by sx and sy to the bottom-right corner of the image is used. If you specify a negative value, the image is flipped horizontally when drawn.",
required: false
},
sh: {
title: "Source Height",
type: "number",
description: "The height of the sub-rectangle of the source image to draw into the destination context. If you specify a negative value, the image is flipped vertically when drawn.",
required: false
}
}
}
},
output: {
context: {
title: "Context",
type: "CanvasRenderingContext2D"
}
}
},
state: {}
}