scratch-blocks 2.0.0-spork.2 → 2.0.0-spork.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/main.js +1 -1
- package/package.json +1 -1
- package/src/{block_reporting.js → block_reporting.ts} +7 -5
- package/src/blocks/{colour.js → colour.ts} +6 -6
- package/src/blocks/{control.js → control.ts} +21 -54
- package/src/blocks/{data.js → data.ts} +134 -142
- package/src/blocks/{event.js → event.ts} +12 -33
- package/src/blocks/{looks.js → looks.ts} +24 -73
- package/src/blocks/{math.js → math.ts} +6 -11
- package/src/blocks/{matrix.js → matrix.ts} +2 -3
- package/src/blocks/{motion.js → motion.ts} +23 -70
- package/src/blocks/{note.js → note.ts} +2 -3
- package/src/blocks/{operators.js → operators.ts} +18 -55
- package/src/blocks/{procedures.js → procedures.ts} +418 -269
- package/src/blocks/{sensing.js → sensing.ts} +21 -61
- package/src/blocks/{sound.js → sound.ts} +9 -28
- package/src/blocks/{text.js → text.ts} +1 -2
- package/src/blocks/{vertical_extensions.js → vertical_extensions.ts} +63 -100
- package/src/checkable_continuous_flyout.js +2 -2
- package/src/{checkbox_bubble.js → checkbox_bubble.ts} +36 -53
- package/src/{colours.js → colours.ts} +11 -4
- package/src/{constants.js → constants.ts} +13 -0
- package/src/{context_menu_items.js → context_menu_items.ts} +18 -12
- package/src/{data_category.js → data_category.ts} +216 -150
- package/src/events/{events_block_comment_base.js → events_block_comment_base.ts} +23 -4
- package/src/events/{events_block_comment_change.js → events_block_comment_change.ts} +29 -5
- package/src/events/{events_block_comment_collapse.js → events_block_comment_collapse.ts} +24 -6
- package/src/events/{events_block_comment_create.js → events_block_comment_create.ts} +36 -10
- package/src/events/{events_block_comment_delete.js → events_block_comment_delete.ts} +6 -2
- package/src/events/{events_block_comment_move.js → events_block_comment_move.ts} +36 -6
- package/src/events/events_block_comment_resize.ts +88 -0
- package/src/events/events_block_drag_end.ts +49 -0
- package/src/events/events_block_drag_outside.ts +44 -0
- package/src/events/{events_scratch_variable_create.js → events_scratch_variable_create.ts} +28 -15
- package/src/fields/{field_colour_slider.js → field_colour_slider.ts} +117 -106
- package/src/fields/{field_matrix.js → field_matrix.ts} +189 -215
- package/src/fields/{field_note.js → field_note.ts} +227 -286
- package/src/fields/{field_textinput_removable.js → field_textinput_removable.ts} +17 -20
- package/src/fields/{field_variable_getter.js → field_variable_getter.ts} +28 -17
- package/src/fields/{field_vertical_separator.js → field_vertical_separator.ts} +14 -30
- package/src/fields/{field_angle.js → scratch_field_angle.ts} +124 -80
- package/src/fields/{field_dropdown.js → scratch_field_dropdown.ts} +9 -7
- package/src/fields/{field_number.js → scratch_field_number.ts} +60 -55
- package/src/fields/{field_variable.js → scratch_field_variable.ts} +46 -27
- package/src/{flyout_checkbox_icon.js → flyout_checkbox_icon.ts} +15 -19
- package/src/{glows.js → glows.ts} +29 -18
- package/src/index.ts +59 -60
- package/src/procedures.ts +462 -0
- package/src/{recyclable_block_flyout_inflater.js → recyclable_block_flyout_inflater.ts} +35 -35
- package/src/renderer/{bowler_hat.js → bowler_hat.ts} +1 -1
- package/src/renderer/{constants.js → constants.ts} +26 -12
- package/src/renderer/{drawer.js → drawer.ts} +8 -3
- package/src/renderer/{path_object.js → path_object.ts} +2 -2
- package/src/renderer/{render_info.js → render_info.ts} +19 -7
- package/src/renderer/renderer.ts +76 -0
- package/src/{scratch_block_paster.js → scratch_block_paster.ts} +9 -7
- package/src/scratch_blocks_utils.ts +39 -0
- package/src/{scratch_comment_icon.js → scratch_comment_icon.ts} +43 -26
- package/src/scratch_connection_checker.ts +44 -0
- package/src/{scratch_continuous_category.js → scratch_continuous_category.ts} +20 -13
- package/src/{scratch_continuous_toolbox.js → scratch_continuous_toolbox.ts} +20 -18
- package/src/{scratch_dragger.js → scratch_dragger.ts} +97 -28
- package/src/{scratch_variable_map.js → scratch_variable_map.ts} +4 -1
- package/src/scratch_variable_model.ts +30 -0
- package/src/{shadows.js → shadows.ts} +8 -4
- package/src/{status_indicator_label.js → status_indicator_label.ts} +24 -36
- package/src/{status_indicator_label_flyout_inflater.js → status_indicator_label_flyout_inflater.ts} +9 -7
- package/src/{variables.js → variables.ts} +153 -123
- package/tsconfig.json +5 -0
- package/src/categories.js +0 -15
- package/src/events/events_block_comment_resize.js +0 -52
- package/src/events/events_block_drag_end.js +0 -33
- package/src/events/events_block_drag_outside.js +0 -30
- package/src/procedures.js +0 -425
- package/src/renderer/renderer.js +0 -74
- package/src/scratch_blocks_utils.js +0 -148
- package/src/scratch_connection_checker.js +0 -29
- package/src/scratch_variable_model.js +0 -24
- /package/src/{css.js → css.ts} +0 -0
- /package/{continuous-toolbox.d.ts → types/continuous-toolbox.d.ts} +0 -0
|
@@ -23,52 +23,60 @@
|
|
|
23
23
|
* @author fraser@google.com (Neil Fraser)
|
|
24
24
|
*/
|
|
25
25
|
import * as Blockly from "blockly/core";
|
|
26
|
-
import { FieldColour } from "@blockly/field-colour";
|
|
26
|
+
import { FieldColour, FieldColourFromJsonConfig } from "@blockly/field-colour";
|
|
27
|
+
|
|
28
|
+
enum ColourChannel {
|
|
29
|
+
HUE = "hue",
|
|
30
|
+
SATURATION = "saturation",
|
|
31
|
+
BRIGHTNESS = "brightness",
|
|
32
|
+
}
|
|
27
33
|
|
|
28
34
|
/**
|
|
29
35
|
* Class for a slider-based colour input field.
|
|
30
|
-
* @param {string} colour The initial colour in '#rrggbb' format.
|
|
31
|
-
* @param {Function=} opt_validator A function that is executed when a new
|
|
32
|
-
* colour is selected. Its sole argument is the new colour value. Its
|
|
33
|
-
* return value becomes the selected colour, unless it is undefined, in
|
|
34
|
-
* which case the new colour stands, or it is null, in which case the change
|
|
35
|
-
* is aborted.
|
|
36
|
-
* @extends {Blockly.Field}
|
|
37
|
-
* @constructor
|
|
38
36
|
*/
|
|
39
37
|
export class FieldColourSlider extends FieldColour {
|
|
40
38
|
/**
|
|
41
39
|
* Function to be called if eyedropper can be activated.
|
|
42
40
|
* If defined, an eyedropper button will be added to the color picker.
|
|
43
41
|
* The button calls this function with a callback to update the field value.
|
|
44
|
-
* BEWARE: This is not a stable API
|
|
45
|
-
* @private
|
|
42
|
+
* BEWARE: This is not a stable API. It may change.
|
|
46
43
|
*/
|
|
47
|
-
static activateEyedropper_
|
|
44
|
+
static activateEyedropper_: (
|
|
45
|
+
callback: (colour: string) => void
|
|
46
|
+
) => void | null = null;
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Path to the eyedropper svg icon.
|
|
50
|
+
*/
|
|
51
|
+
EYEDROPPER_PATH = "eyedropper.svg";
|
|
52
|
+
SERIALIZABLE = true;
|
|
53
|
+
EDITABLE = true;
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
private hueChangeEventKey_?: Blockly.browserEvents.Data;
|
|
56
|
+
private saturationChangeEventKey_?: Blockly.browserEvents.Data;
|
|
57
|
+
private brightnessChangeEventKey_?: Blockly.browserEvents.Data;
|
|
58
|
+
private hueSlider_?: HTMLInputElement;
|
|
59
|
+
private saturationSlider_?: HTMLInputElement;
|
|
60
|
+
private brightnessSlider_?: HTMLInputElement;
|
|
61
|
+
private hueReadout_?: Element;
|
|
62
|
+
private saturationReadout_?: Element;
|
|
63
|
+
private brightnessReadout_?: Element;
|
|
64
|
+
private hue_?: number;
|
|
65
|
+
private saturation_?: number;
|
|
66
|
+
private brightness_?: number;
|
|
67
|
+
private eyedropperEventData_?: Blockly.browserEvents.Data;
|
|
59
68
|
|
|
60
69
|
/**
|
|
61
70
|
* Construct a FieldColourSlider from a JSON arg object.
|
|
62
|
-
*
|
|
63
|
-
* @
|
|
64
|
-
* @
|
|
65
|
-
* @nocollapse
|
|
71
|
+
*
|
|
72
|
+
* @param options A JSON object with options (colour).
|
|
73
|
+
* @returns The new field instance.
|
|
66
74
|
*/
|
|
67
|
-
static fromJson(options) {
|
|
75
|
+
static fromJson(options: FieldColourFromJsonConfig): FieldColourSlider {
|
|
68
76
|
return new FieldColourSlider(options["colour"]);
|
|
69
77
|
}
|
|
70
78
|
|
|
71
|
-
doValueUpdate_(newValue) {
|
|
79
|
+
doValueUpdate_(newValue: string) {
|
|
72
80
|
super.doValueUpdate_(newValue);
|
|
73
81
|
this.updateSliderHandles_();
|
|
74
82
|
this.updateDom_();
|
|
@@ -76,25 +84,25 @@ export class FieldColourSlider extends FieldColour {
|
|
|
76
84
|
|
|
77
85
|
/**
|
|
78
86
|
* Create the hue, saturation or value CSS gradient for the slide backgrounds.
|
|
79
|
-
*
|
|
80
|
-
* @
|
|
81
|
-
* @
|
|
87
|
+
*
|
|
88
|
+
* @param channel – Either "hue", "saturation" or "value".
|
|
89
|
+
* @return Array colour hex colour stops for the given channel
|
|
82
90
|
*/
|
|
83
|
-
createColourStops_(channel) {
|
|
84
|
-
|
|
85
|
-
for (
|
|
91
|
+
private createColourStops_(channel: ColourChannel): string[] {
|
|
92
|
+
const stops = [];
|
|
93
|
+
for (let n = 0; n <= 360; n += 20) {
|
|
86
94
|
switch (channel) {
|
|
87
|
-
case
|
|
95
|
+
case ColourChannel.HUE:
|
|
88
96
|
stops.push(
|
|
89
97
|
Blockly.utils.colour.hsvToHex(n, this.saturation_, this.brightness_)
|
|
90
98
|
);
|
|
91
99
|
break;
|
|
92
|
-
case
|
|
100
|
+
case ColourChannel.SATURATION:
|
|
93
101
|
stops.push(
|
|
94
102
|
Blockly.utils.colour.hsvToHex(this.hue_, n / 360, this.brightness_)
|
|
95
103
|
);
|
|
96
104
|
break;
|
|
97
|
-
case
|
|
105
|
+
case ColourChannel.BRIGHTNESS:
|
|
98
106
|
stops.push(
|
|
99
107
|
Blockly.utils.colour.hsvToHex(
|
|
100
108
|
this.hue_,
|
|
@@ -112,25 +120,24 @@ export class FieldColourSlider extends FieldColour {
|
|
|
112
120
|
|
|
113
121
|
/**
|
|
114
122
|
* Set the gradient CSS properties for the given node and channel
|
|
115
|
-
*
|
|
116
|
-
* @param
|
|
117
|
-
* @
|
|
123
|
+
*
|
|
124
|
+
* @param node The DOM node the gradient will be set on.
|
|
125
|
+
* @param channel Either "hue", "saturation" or "value".
|
|
118
126
|
*/
|
|
119
|
-
setGradient_(node, channel) {
|
|
120
|
-
|
|
127
|
+
private setGradient_(node: HTMLElement, channel: ColourChannel) {
|
|
128
|
+
const gradient = this.createColourStops_(channel).join(",");
|
|
121
129
|
node.style["background"] = `linear-gradient(to right, ${gradient})`;
|
|
122
130
|
}
|
|
123
131
|
|
|
124
132
|
/**
|
|
125
133
|
* Update the readouts and slider backgrounds after value has changed.
|
|
126
|
-
* @private
|
|
127
134
|
*/
|
|
128
|
-
updateDom_() {
|
|
135
|
+
private updateDom_() {
|
|
129
136
|
if (this.hueSlider_) {
|
|
130
137
|
// Update the slider backgrounds
|
|
131
|
-
this.setGradient_(this.hueSlider_,
|
|
132
|
-
this.setGradient_(this.saturationSlider_,
|
|
133
|
-
this.setGradient_(this.brightnessSlider_,
|
|
138
|
+
this.setGradient_(this.hueSlider_, ColourChannel.HUE);
|
|
139
|
+
this.setGradient_(this.saturationSlider_, ColourChannel.SATURATION);
|
|
140
|
+
this.setGradient_(this.brightnessSlider_, ColourChannel.BRIGHTNESS);
|
|
134
141
|
|
|
135
142
|
// Update the readouts
|
|
136
143
|
this.hueReadout_.textContent = Math.floor(
|
|
@@ -147,28 +154,27 @@ export class FieldColourSlider extends FieldColour {
|
|
|
147
154
|
|
|
148
155
|
/**
|
|
149
156
|
* Update the slider handle positions from the current field value.
|
|
150
|
-
* @private
|
|
151
157
|
*/
|
|
152
|
-
updateSliderHandles_() {
|
|
158
|
+
private updateSliderHandles_() {
|
|
153
159
|
if (this.hueSlider_) {
|
|
154
|
-
this.hueSlider_.value = this.hue_
|
|
155
|
-
this.saturationSlider_.value = this.saturation_
|
|
156
|
-
this.brightnessSlider_.value = this.brightness_
|
|
160
|
+
this.hueSlider_.value = `${this.hue_}`;
|
|
161
|
+
this.saturationSlider_.value = `${this.saturation_}`;
|
|
162
|
+
this.brightnessSlider_.value = `${this.brightness_}`;
|
|
157
163
|
}
|
|
158
164
|
}
|
|
159
165
|
|
|
160
166
|
/**
|
|
161
|
-
* Create label and readout DOM elements, returning the readout
|
|
162
|
-
*
|
|
163
|
-
* @
|
|
164
|
-
* @
|
|
167
|
+
* Create label and readout DOM elements, returning the readout.
|
|
168
|
+
*
|
|
169
|
+
* @param labelText Text for the label
|
|
170
|
+
* @return The container node and the readout node.
|
|
165
171
|
*/
|
|
166
|
-
createLabelDom_(labelText) {
|
|
167
|
-
|
|
172
|
+
private createLabelDom_(labelText: string): Element[] {
|
|
173
|
+
const labelContainer = document.createElement("div");
|
|
168
174
|
labelContainer.setAttribute("class", "scratchColourPickerLabel");
|
|
169
|
-
|
|
175
|
+
const readout = document.createElement("span");
|
|
170
176
|
readout.setAttribute("class", "scratchColourPickerReadout");
|
|
171
|
-
|
|
177
|
+
const label = document.createElement("span");
|
|
172
178
|
label.setAttribute("class", "scratchColourPickerLabelText");
|
|
173
179
|
label.textContent = labelText;
|
|
174
180
|
labelContainer.appendChild(label);
|
|
@@ -178,71 +184,69 @@ export class FieldColourSlider extends FieldColour {
|
|
|
178
184
|
|
|
179
185
|
/**
|
|
180
186
|
* Factory for creating the different slider callbacks
|
|
181
|
-
*
|
|
182
|
-
* @
|
|
183
|
-
* @
|
|
187
|
+
*
|
|
188
|
+
* @param channel One of "hue", "saturation" or "brightness"
|
|
189
|
+
* @returns The callback for slider update
|
|
184
190
|
*/
|
|
185
|
-
sliderCallbackFactory_(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
191
|
+
private sliderCallbackFactory_(
|
|
192
|
+
channel: ColourChannel
|
|
193
|
+
): (event: PointerEvent) => void {
|
|
194
|
+
return (event: PointerEvent) => {
|
|
195
|
+
const channelValue = (event.target as HTMLInputElement).value;
|
|
189
196
|
switch (channel) {
|
|
190
|
-
case
|
|
191
|
-
|
|
197
|
+
case ColourChannel.HUE:
|
|
198
|
+
this.hue_ = Number(channelValue);
|
|
192
199
|
break;
|
|
193
|
-
case
|
|
194
|
-
|
|
200
|
+
case ColourChannel.SATURATION:
|
|
201
|
+
this.saturation_ = Number(channelValue);
|
|
195
202
|
break;
|
|
196
|
-
case
|
|
197
|
-
|
|
203
|
+
case ColourChannel.BRIGHTNESS:
|
|
204
|
+
this.brightness_ = Number(channelValue);
|
|
198
205
|
break;
|
|
199
206
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
207
|
+
const colour = Blockly.utils.colour.hsvToHex(
|
|
208
|
+
this.hue_,
|
|
209
|
+
this.saturation_,
|
|
210
|
+
this.brightness_
|
|
204
211
|
);
|
|
205
212
|
if (colour !== null) {
|
|
206
|
-
|
|
213
|
+
this.setValue(colour, true);
|
|
207
214
|
}
|
|
208
215
|
};
|
|
209
216
|
}
|
|
210
217
|
|
|
211
218
|
/**
|
|
212
219
|
* Activate the eyedropper, passing in a callback for setting the field value.
|
|
213
|
-
* @private
|
|
214
220
|
*/
|
|
215
|
-
activateEyedropperInternal_() {
|
|
216
|
-
|
|
217
|
-
FieldColourSlider.activateEyedropper_(function (chosenColour) {
|
|
221
|
+
private activateEyedropperInternal_() {
|
|
222
|
+
FieldColourSlider.activateEyedropper_((chosenColour: string) => {
|
|
218
223
|
// Update the internal hue/saturation/brightness values so sliders update.
|
|
219
224
|
const components = Blockly.utils.colour.hexToRgb(chosenColour);
|
|
220
|
-
const { hue, saturation, value } =
|
|
225
|
+
const { hue, saturation, value } = this.rgbToHsv(
|
|
221
226
|
components[0],
|
|
222
227
|
components[1],
|
|
223
228
|
components[2]
|
|
224
229
|
);
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
230
|
+
this.hue_ = hue;
|
|
231
|
+
this.saturation_ = saturation;
|
|
232
|
+
this.brightness_ = value;
|
|
233
|
+
this.setValue(chosenColour);
|
|
229
234
|
});
|
|
230
235
|
}
|
|
231
236
|
|
|
232
237
|
/**
|
|
233
238
|
* Create hue, saturation and brightness sliders under the colour field.
|
|
234
|
-
* @private
|
|
235
239
|
*/
|
|
236
240
|
showEditor_() {
|
|
237
241
|
Blockly.DropDownDiv.hideWithoutAnimation();
|
|
238
242
|
Blockly.DropDownDiv.clearContent();
|
|
239
|
-
|
|
243
|
+
const div = Blockly.DropDownDiv.getContentDiv();
|
|
240
244
|
div.className = "scratchColourPicker";
|
|
241
245
|
|
|
242
246
|
// Init color component values that are used while the editor is open
|
|
243
247
|
// in order to keep the slider values stable.
|
|
244
248
|
const components = Blockly.utils.colour.hexToRgb(this.getValue());
|
|
245
|
-
|
|
249
|
+
const { hue, saturation, value } = this.rgbToHsv(
|
|
246
250
|
components[0],
|
|
247
251
|
components[1],
|
|
248
252
|
components[2]
|
|
@@ -251,45 +255,45 @@ export class FieldColourSlider extends FieldColour {
|
|
|
251
255
|
this.saturation_ = saturation;
|
|
252
256
|
this.brightness_ = value;
|
|
253
257
|
|
|
254
|
-
|
|
258
|
+
const hueElements = this.createLabelDom_(Blockly.Msg.COLOUR_HUE_LABEL);
|
|
255
259
|
div.appendChild(hueElements[0]);
|
|
256
260
|
this.hueReadout_ = hueElements[1];
|
|
257
261
|
this.hueSlider_ = document.createElement("input");
|
|
258
262
|
this.hueSlider_.type = "range";
|
|
259
|
-
this.hueSlider_.min = 0;
|
|
260
|
-
this.hueSlider_.max = 360;
|
|
263
|
+
this.hueSlider_.min = "0";
|
|
264
|
+
this.hueSlider_.max = "360";
|
|
261
265
|
this.hueSlider_.className = "scratchColourSlider";
|
|
262
266
|
div.appendChild(this.hueSlider_);
|
|
263
267
|
|
|
264
|
-
|
|
268
|
+
const saturationElements = this.createLabelDom_(
|
|
265
269
|
Blockly.Msg.COLOUR_SATURATION_LABEL
|
|
266
270
|
);
|
|
267
271
|
div.appendChild(saturationElements[0]);
|
|
268
272
|
this.saturationReadout_ = saturationElements[1];
|
|
269
273
|
this.saturationSlider_ = document.createElement("input");
|
|
270
274
|
this.saturationSlider_.type = "range";
|
|
271
|
-
this.saturationSlider_.step = 0.001;
|
|
272
|
-
this.saturationSlider_.min = 0;
|
|
273
|
-
this.saturationSlider_.max = 1.0;
|
|
275
|
+
this.saturationSlider_.step = "0.001";
|
|
276
|
+
this.saturationSlider_.min = "0";
|
|
277
|
+
this.saturationSlider_.max = "1.0";
|
|
274
278
|
this.saturationSlider_.className = "scratchColourSlider";
|
|
275
279
|
div.appendChild(this.saturationSlider_);
|
|
276
280
|
|
|
277
|
-
|
|
281
|
+
const brightnessElements = this.createLabelDom_(
|
|
278
282
|
Blockly.Msg.COLOUR_BRIGHTNESS_LABEL
|
|
279
283
|
);
|
|
280
284
|
div.appendChild(brightnessElements[0]);
|
|
281
285
|
this.brightnessReadout_ = brightnessElements[1];
|
|
282
286
|
this.brightnessSlider_ = document.createElement("input");
|
|
283
287
|
this.brightnessSlider_.type = "range";
|
|
284
|
-
this.brightnessSlider_.min = 0;
|
|
285
|
-
this.brightnessSlider_.max = 255;
|
|
288
|
+
this.brightnessSlider_.min = "0";
|
|
289
|
+
this.brightnessSlider_.max = "255";
|
|
286
290
|
this.brightnessSlider_.className = "scratchColourSlider";
|
|
287
291
|
div.appendChild(this.brightnessSlider_);
|
|
288
292
|
|
|
289
293
|
if (FieldColourSlider.activateEyedropper_) {
|
|
290
|
-
|
|
294
|
+
const button = document.createElement("button");
|
|
291
295
|
button.setAttribute("class", "scratchEyedropper");
|
|
292
|
-
|
|
296
|
+
const image = document.createElement("img");
|
|
293
297
|
image.src =
|
|
294
298
|
Blockly.getMainWorkspace().options.pathToMedia + this.EYEDROPPER_PATH;
|
|
295
299
|
button.appendChild(image);
|
|
@@ -303,7 +307,10 @@ export class FieldColourSlider extends FieldColour {
|
|
|
303
307
|
}
|
|
304
308
|
|
|
305
309
|
Blockly.DropDownDiv.setColour("#ffffff", "#dddddd");
|
|
306
|
-
Blockly.DropDownDiv.showPositionedByBlock(
|
|
310
|
+
Blockly.DropDownDiv.showPositionedByBlock(
|
|
311
|
+
this,
|
|
312
|
+
this.getSourceBlock() as Blockly.BlockSvg
|
|
313
|
+
);
|
|
307
314
|
|
|
308
315
|
// Set value updates the slider positions
|
|
309
316
|
// Do this before attaching callbacks to avoid extra events from initial set
|
|
@@ -313,19 +320,19 @@ export class FieldColourSlider extends FieldColour {
|
|
|
313
320
|
this.hueSlider_,
|
|
314
321
|
"input",
|
|
315
322
|
this,
|
|
316
|
-
this.sliderCallbackFactory_(
|
|
323
|
+
this.sliderCallbackFactory_(ColourChannel.HUE)
|
|
317
324
|
);
|
|
318
325
|
this.saturationChangeEventKey_ = Blockly.browserEvents.bind(
|
|
319
326
|
this.saturationSlider_,
|
|
320
327
|
"input",
|
|
321
328
|
this,
|
|
322
|
-
this.sliderCallbackFactory_(
|
|
329
|
+
this.sliderCallbackFactory_(ColourChannel.SATURATION)
|
|
323
330
|
);
|
|
324
331
|
this.brightnessChangeEventKey_ = Blockly.browserEvents.bind(
|
|
325
332
|
this.brightnessSlider_,
|
|
326
333
|
"input",
|
|
327
334
|
this,
|
|
328
|
-
this.sliderCallbackFactory_(
|
|
335
|
+
this.sliderCallbackFactory_(ColourChannel.BRIGHTNESS)
|
|
329
336
|
);
|
|
330
337
|
}
|
|
331
338
|
|
|
@@ -347,7 +354,11 @@ export class FieldColourSlider extends FieldColour {
|
|
|
347
354
|
}
|
|
348
355
|
|
|
349
356
|
// From Closure
|
|
350
|
-
rgbToHsv(
|
|
357
|
+
rgbToHsv(
|
|
358
|
+
red: number,
|
|
359
|
+
green: number,
|
|
360
|
+
blue: number
|
|
361
|
+
): { hue: number; saturation: number; value: number } {
|
|
351
362
|
const max = Math.max(Math.max(red, green), blue);
|
|
352
363
|
const min = Math.min(Math.min(red, green), blue);
|
|
353
364
|
let hue;
|