-
Notifications
You must be signed in to change notification settings - Fork 0
/
color_channels.js
112 lines (105 loc) · 2.22 KB
/
color_channels.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
(function(Scratch) {
const renderer = vm.renderer;
const gl = renderer._gl;
class LBdrawtest {
getInfo() {
return {
id: 'lbdrawtest',
name: 'Draw Test',
color1: '#aaaaaa',
color2: '#888888',
color3: '#888888',
blocks: [
{
opcode: 'true',
blockType: Scratch.BlockType.BOOLEAN,
text: 'true'
},
{
opcode: 'false',
blockType: Scratch.BlockType.BOOLEAN,
text: 'false',
},
{
opcode: 'draw',
blockType: Scratch.BlockType.COMMAND,
text: 'only draw colors:[R]green:[G]blue:[B]',
arguments: {
R: {
type: Scratch.ArgumentType.BOOLEAN
},
G: {
type: Scratch.ArgumentType.BOOLEAN
},
B: {
type: Scratch.ArgumentType.BOOLEAN
}
}
},
{
opcode: 'drawOneColor',
blockType: Scratch.BlockType.COMMAND,
text: 'only draw [COLOR]',
arguments: {
COLOR: {
type: Scratch.ArgumentType.STRING,
menu: 'COLOR_MENU'
}
}
},
{
opcode: 'drawDepth',
blockType: Scratch.BlockType.COMMAND,
text: 'enable depth mask?[DRAW]',
arguments: {
DRAW: {
type: Scratch.ArgumentType.BOOLEAN
}
}
},
{
opcode: 'clearEffects',
blockType: Scratch.BlockType.COMMAND,
text: 'clear color draw effects',
}
],
menus: {
COLOR_MENU: {
acceptReporters: true,
items: ['red','green','blue']
}
}
};
}
true() {
return true;
}
false() {
return false;
}
draw({R, G, B}) {
gl.colorMask(R, G, B, true);
vm.renderer.dirty = true
}
drawOneColor({COLOR}) {
if (COLOR == 'red') {
gl.colorMask(true, false, false, true);
} else if (COLOR == 'green') {
gl.colorMask(false, true, false, true);
} else {
gl.colorMask(false, false, true, true);
}
vm.renderer.dirty = true
}
drawDepth({DRAW}) {
gl.depthMask(DRAW);
vm.renderer.dirty = true
}
clearEffects() {
gl.colorMask(true, true, true, true)
gl.depthMask(true);
vm.renderer.dirty = true
}
}
Scratch.extensions.register(new LBdrawtest());
})(Scratch);