Skip to content

Commit

Permalink
Longboost/color_channels: Change boolean inputs to menus (#1366)
Browse files Browse the repository at this point in the history
https://github.com/TurboWarp/extensions/assets/106490990/906ad007-96a7-49b5-afaf-1e18a33ec2f5

Of course, the old blocks weren't removed, but just hidden from the palette.
  • Loading branch information
DNin01 authored Mar 17, 2024
1 parent 5bc4dac commit 3f624e6
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions extensions/Longboost/color_channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
opcode: "true",
blockType: Scratch.BlockType.BOOLEAN,
text: "true",
hideFromPalette: true,
disableMonitor: true,
},
{
Expand All @@ -50,10 +51,30 @@
},
},
},
{
opcode: "drawSelected",
blockType: Scratch.BlockType.COMMAND,
text: "set colors red:[R]green:[G]blue:[B]",
arguments: {
R: {
type: Scratch.ArgumentType.MENU,
menu: "ENABLED_MENU",
},
G: {
type: Scratch.ArgumentType.MENU,
menu: "ENABLED_MENU",
},
B: {
type: Scratch.ArgumentType.MENU,
menu: "ENABLED_MENU",
},
},
},
{
opcode: "draw",
blockType: Scratch.BlockType.COMMAND,
text: "only draw colors:[R]green:[G]blue:[B]",
hideFromPalette: true,
arguments: {
R: {
type: Scratch.ArgumentType.BOOLEAN,
Expand Down Expand Up @@ -99,6 +120,19 @@
acceptReporters: true,
items: ["red", "green", "blue"],
},
ENABLED_MENU: {
acceptReporters: true,
items: [
{
text: "off",
value: "false",
},
{
text: "on",
value: "true",
},
],
},
},
};
}
Expand All @@ -123,6 +157,22 @@
}
}

drawSelected({ R, G, B }) {
channel_array = [
Scratch.Cast.toBoolean(R),
Scratch.Cast.toBoolean(G),
Scratch.Cast.toBoolean(B),
true,
];
gl.colorMask(
channel_array[0],
channel_array[1],
channel_array[2],
channel_array[3]
);
Scratch.vm.renderer.dirty = true;
}

draw({ R, G, B }) {
channel_array = [R, G, B, true];
gl.colorMask(
Expand Down

0 comments on commit 3f624e6

Please sign in to comment.