-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathputImageData.js
93 lines (88 loc) · 2.5 KB
/
putImageData.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
module.exports = {
name: "putImageData",
ns: "canvas",
title: "Put Image Data",
description: "Put Image Data",
phrases: {
active: "Putting image data"
},
ports: {
input: {
"in": {
title: "ImageData",
type: "ImageData"
},
context: {
title: "Context",
type: "CanvasRenderingContext2D"
},
dx: {
title: "Dx",
type: "number",
description: "Horizontal position (x-coordinate) in the source imagedata from which to start copying. Defaults to the top left of the whole image data.",
"default": 0
},
dy: {
title: "Dy",
type: "number",
description: "Vertical position (y-coordinate) in the source imagedata from which to start copying. Defaults to the top left of the whole image data.",
"default": 0
},
dirtyX: {
title: "Dirty X",
type: "number",
description: "Horizontal position (x-coordinate) of the upper-left corner at which to place the image data in the destination canvas.",
required: false
},
dirtyY: {
title: "Dirty Y",
type: "number",
description: "Vertical position (y-coordinate) of the upper-left corner at which to place the image in the destination canvas.",
required: false
},
dirtyWidth: {
title: "Dirty Width",
type: "number",
description: "Width of the rectangle to be painted. Defaults to the width of the image data.",
required: false
},
dirtyHeight: {
title: "Dirty Height",
type: "number",
description: "Height of the rectangle to be painted. Defaults to the height of the image data.",
required: false
}
},
output: {
context: {
title: "Context",
type: "CanvasRenderingContext2D"
},
out: {
title: "ImageData",
type: "ImageData"
}
}
},
fn: function putImageData(input, $, output, state, done, cb, on) {
var r = function() {
const props = ['dx', 'dy', 'dirtyX', 'dirtyY', 'dirtyWidth', 'dirtyHeight'];
const args = [$.in];
for (let i = 0; i < props.length; i++) {
if ($[props[i]] === undefined) break;
args.push($[props[i]])
}
$.context.putImageData.apply($.context, args);
output({
context: $.get('context'),
out: $.get('in')
});
}.call(this);
return {
output: output,
state: state,
on: on,
return: r
};
}
}