@@ -8,20 +8,61 @@ import * as Blockly from "blockly/core";
8
8
import { Drawer } from "./drawer.js" ;
9
9
import { RenderInfo } from "./render_info.js" ;
10
10
import { ConstantProvider } from "./constants.js" ;
11
+ import { PathObject } from "./path_object.js" ;
11
12
13
+ /**
14
+ * Custom renderer for Scratch-style blocks.
15
+ */
12
16
export class ScratchRenderer extends Blockly . zelos . Renderer {
17
+ /**
18
+ * Create a new instance of the renderer's drawer.
19
+ *
20
+ * @param {!Blockly.BlockSvg } block The block to render.
21
+ * @param info {!Blockly.blockRendering.RenderInfo} An object containing all
22
+ * information needed to render this block.
23
+ * @returns {!Drawer } The drawer.
24
+ */
13
25
makeDrawer_ ( block , info ) {
14
26
return new Drawer ( block , info ) ;
15
27
}
16
28
29
+ /**
30
+ * Create a new instance of the renderer's render info object.
31
+ *
32
+ * @param {!Blockly.BlockSvg } block The block to measure.
33
+ * @returns {!RenderInfo } The render info object.
34
+ */
17
35
makeRenderInfo_ ( block ) {
18
36
return new RenderInfo ( this , block ) ;
19
37
}
20
38
39
+ /**
40
+ * Create a new instance of the renderer's constant provider.
41
+ *
42
+ * @returns {!ConstantProvider } The constant provider.
43
+ */
21
44
makeConstants_ ( ) {
22
45
return new ConstantProvider ( ) ;
23
46
}
24
47
48
+ /**
49
+ * Create a new instance of a renderer path object.
50
+ *
51
+ * @param {!SVGElement } root The root SVG element.
52
+ * @param {!Blockly.BlockStyle } style The style object to use for colouring.
53
+ * @returns {!PathObject } The renderer path object.
54
+ */
55
+ makePathObject ( root , style ) {
56
+ return new PathObject ( root , style , this . getConstants ( ) ) ;
57
+ }
58
+
59
+ /**
60
+ * Determine whether or not to highlight a connection.
61
+ *
62
+ * @param {!Blockly.RenderedConnection } connection The connection to determine
63
+ * whether or not to highlight.
64
+ * @returns {boolean } True if we should highlight the connection.
65
+ */
25
66
shouldHighlightConnection ( connection ) {
26
67
return (
27
68
connection . type === Blockly . ConnectionType . INPUT_VALUE &&
0 commit comments