JAVASCRIPT   70

BlockSpecs

Guest on 9th July 2022 06:19:05 PM

  1.  
  2. BlockSpecs = function() {};
  3.                        
  4. BlockSpecs.init = function (){
  5.         BlockSpecs.baseData = BlockSpecs.setupBaseData();
  6.         BlockSpecs.createGraphics();
  7.         BlockSpecs.defs= BlockSpecs.setupBlocksSpecs();
  8. }
  9.  
  10. BlockSpecs.createGraphics = function (){
  11.         BlockSpecs.greenCmd = SVG.getBlock("cmd", "green");
  12.         BlockSpecs.greenCmd2 = SVG.getBlock("cmd2", "green");
  13.         BlockSpecs.greenCmdNoImput= SVG.getBlock("cmd0", "green");
  14.         BlockSpecs.greenReporter = SVG.getBlock("input", "green" );
  15.         BlockSpecs.cyanCmd = SVG.getBlock("cmd", "cyan");
  16.         BlockSpecs.cyanCmd0 = SVG.getBlock("cmd0", "cyan");
  17.         BlockSpecs.cyanCmd2 = SVG.getBlock("cmd2", "cyan2");
  18.         BlockSpecs.cyanReporter = SVG.getBlock("input", "cyan" );
  19.         BlockSpecs.mathOp = SVG.getBlock("math", "pink" );
  20.         BlockSpecs.numberInput = SVG.getBlock("input", "pink" );
  21.         BlockSpecs.randomCmd = SVG.getBlock("random", "pink2" );
  22.         BlockSpecs.compCmd = SVG.getBlock("comp", "pink2" );
  23.         BlockSpecs.openBracket = SVG.getBlock("bracket1", "pink" );
  24.         BlockSpecs.closeBracket = SVG.getBlock("bracket2", "pink" );
  25.         BlockSpecs.pinkCmd = SVG.getBlock("cmd", "pink");
  26.         BlockSpecs.orangeCmd = SVG.getBlock("cmd", "orange");
  27.         BlockSpecs.extender1 = SVG.getBlock("hspace", "orange");
  28.         BlockSpecs.extender2 = SVG.getBlock("vspace", "orange");
  29.         BlockSpecs.orangeLoop = SVG.getBlock("forever", "orange1");            
  30.         BlockSpecs.orangeRepeatLoop = SVG.getBlock("repeat", "orange2");
  31.         BlockSpecs.orangeIf = SVG.getBlock("if", "orange2");
  32.         BlockSpecs.endCmd = SVG.getBlock("stopall", "orange");
  33.         BlockSpecs.startHat =  SVG.getBlock("hat", "yellow");
  34.         BlockSpecs.startHat1 =  SVG.getBlock("hat1", "yellow");
  35.         BlockSpecs.startHat2 =  SVG.getBlock("hat2", "yellow");
  36.         BlockSpecs.yellowCmd = SVG.getBlock("cmd", "yellow");
  37.         BlockSpecs.argReporter = SVG.getBlock("arg", "yellow" );
  38.         BlockSpecs.yellowReporter = SVG.getBlock("input", "yellow");
  39. }
  40.  
  41. BlockSpecs.setupBlocksSpecs = function (){     
  42.         return {
  43.                                         "clean": ["clean",  [["clean"]], BlockSpecs.greenCmdNoImput, null, "cmdblock", "green"],
  44.                                         "forward": ["forward", [["forward"]], BlockSpecs.greenCmd, [100], "cmdblock", "green"],
  45.                                         "back": ["back", [["back"]], BlockSpecs.greenCmd, [100], "cmdblock", "green"],
  46.                                         "test":  ["set", [["set"]], BlockSpecs.yellowCmd, [100], "cmdblock", "yellow"],
  47.                                         "right": ["right", [["right"]], BlockSpecs.greenCmd, [90], "cmdblock", "green"],
  48.                                         "left": ["left", [["left"]], BlockSpecs.greenCmd, [90], "cmdblock", "green"],
  49.                                          "arc": ["arc", [["arc"], ["angle", "radius"]], BlockSpecs.greenCmd2, [100, 100], "cmdblock twoargs", "green"],                        
  50.                                         "setxy": ["setxy", [["setxy"], ["x", "y"]], BlockSpecs.greenCmd2, [100, 100], "cmdblock twoargs", "green"],
  51.                                         "seth": ["seth", [["seth"]], BlockSpecs.greenCmd, [0], "cmdblock", "green"],
  52.                                         "xcoor": ["xcoor", [["xcoor"]], BlockSpecs.greenReporter, null, "reporter", "green"],
  53.                                         "ycoor": ["ycoor", [["ycoor"]], BlockSpecs.greenReporter, null, "reporter", "green"],
  54.                                         "heading": ["heading", [["heading"]], BlockSpecs.greenReporter, null, "reporter", "green"],
  55.                        
  56.                                         "forever": ["forever", [["forever"]], BlockSpecs.orangeLoop, null, "cmdblock", "orange"],
  57.                                         "repeat": ["repeat", [["repeat"]], BlockSpecs.orangeRepeatLoop, [4], "cmdblock", "orange"],
  58.                                         "if": ["if", [["if"]], BlockSpecs.orangeIf, null, "cmdblock", "orange"],
  59.  
  60.  
  61.                                         "wait": ["wait", [["wait"]], BlockSpecs.orangeCmd, [100], "cmdblock", "orange"],
  62.                                         "extender1": ["extender1", [["--->"]], BlockSpecs.extender1, null, "cmdblock", "orange"],
  63.                                         "extender2": ["extender2", [["|", "|", "V"]], BlockSpecs.extender2, null, "cmdblock arrowdown", "orange"],
  64.        
  65.                                         "stopall": ["stopall", [["stop"]], BlockSpecs.endCmd, null, "cmdblock", "orange"],
  66.                        
  67.                                         "pu": ["pu",  [["pu"]], BlockSpecs.cyanCmd0, null, "cmdblock", "cyan"],
  68.                                         "pd": ["pd",  [["pd"]], BlockSpecs.cyanCmd0, null, "cmdblock", "cyan"],
  69.  
  70.                                         "startfill": ["startfill",  [["start", "fill"]], BlockSpecs.cyanCmd0, null, "cmdblock twolines", "cyan"],
  71.                                         "endfill": ["endfill",  [["end", "fill"]], BlockSpecs.cyanCmd0, null, "cmdblock twolines", "cyan"],
  72.  
  73.                                         "setc": ["setc", [["setc"]], BlockSpecs.cyanCmd, [4], "cmdblock twolines", "cyan"],
  74.                                         "setshade": ["setshade", [["set", "shade"]], BlockSpecs.cyanCmd, [4], "cmdblock twolines", "cyan"],
  75.                                         "setpensize": ["setpensize", [["set", "pensize"]], BlockSpecs.cyanCmd, [4], "cmdblock twolines", "cyan"],
  76.                                         "fill": ["fill", [["fill", "screen"], ["color", "shade"]], BlockSpecs.cyanCmd2, [100, 100], "cmdblock bigtwo", "cyan"],                        
  77.        
  78.                                         "pensize": ["pensize", [["pensize"]], BlockSpecs.cyanReporter, null, "reporter", "cyan"],
  79.                                         "color": ["color", [["color"]], BlockSpecs.cyanReporter, null, "reporter", "cyan"],
  80.                                         "shade": ["shade", [["shade"]], BlockSpecs.cyanReporter, null, "reporter", "cyan"],
  81.                                         "plus": ["plus", [["+"]], BlockSpecs.mathOp, null, "reporter op", "pink"],
  82.                                         "minus": ["minus", [["-"]], BlockSpecs.mathOp, null, "reporter op", "pink"],
  83.                                         "mul": ["mul", [["X"]], BlockSpecs.mathOp, null, "reporter op", "pink"],
  84.                                         "div": ["div", [["/"]], BlockSpecs.mathOp, null, "reporter op", "pink"],
  85.                                         "mod": ["mod", [["%"]], BlockSpecs.mathOp, null, "reporter op", "pink"],
  86.                                         "random": ["random", [["random"]], BlockSpecs.randomCmd, null, "reporter random", "pink"],
  87.                                         "greater": ["greater", [[">"]], BlockSpecs.compCmd, null, "reporter random comp", "pink"],
  88.                                         "less": ["lesss", [["<"]], BlockSpecs.compCmd, null, "reporter random comp", "pink"],
  89.                                         "equal": ["equal", [["="]], BlockSpecs.compCmd, null, "reporter random comp", "pink"],
  90.                                         "print": ["print", [["print"]], BlockSpecs.pinkCmd, [100], "cmdblock", "pink"],
  91.                                         "par1":  ["par1", [["("]], BlockSpecs.openBracket, null, "reporter br", "pink"],
  92.                                         "par2":  ["par2", [[")"]], BlockSpecs.closeBracket, null, "reporter br", "pink"],
  93.                                         "number": ["number", [["number"]], BlockSpecs.numberInput, [10], "reporter", "pink", true],
  94.                                         "procedure": ["procedure", [[""]], BlockSpecs.startHat, "", "cmdblock", "yellow"],
  95.                                         "procedure1": ["procedure1", [[""]], BlockSpecs.startHat1, "", "cmdblock", "yellow"],
  96.                                         "procedure2": ["procedure2", [[""]], BlockSpecs.startHat2, "", "cmdblock", "yellow"],
  97.                                         "setbox1":  ["setbox1", [["store in"]], BlockSpecs.yellowCmd, "box1", "cmdblock box", "yellow"],
  98.                                         "box1":  ["box1", [[""]], BlockSpecs.yellowReporter, "box1", "reporter rbox", "yellow", true],
  99.                                         "n1": ["n1", [[""]], BlockSpecs.argReporter, "n1", "reporter rbox", "yellow", true]
  100.                                        
  101.                                 };
  102.         }
  103.  
  104.  
  105. ///////////////////////
  106. //  For drawing blocks only
  107. ////////////////////////
  108.                
  109. BlockSpecs.setupBaseData = function (){
  110.         return {
  111.                 'green': {stroke: '#00C000', lightcolor: '#90ff90', basecolor: '#00FF00', text: "#4E8712", box: [20,0, 42,48]},
  112.                 'cyan': { stroke: '#04A2B2', lightcolor: '#78F7FF', basecolor: '#00F0FF',  text: "#005000", box: [20,0, 42,48]},
  113.                 'cyan2': {stroke: '#137484', lightcolor: '#90ffff', basecolor: '#00ffff',  text: "#137484", box: [20,0, 42,110]},
  114.                 'orange': {stroke: "#AF6C02", lightcolor: '#FFE060', basecolor: '#FFC000',  text: "#8B6010", box: [20,0, 42,48]},
  115.                 'orange1': {stroke: "#AF6C02", lightcolor: '#FFE060', basecolor: '#FFC000', text: "#8B6010", box: [20,0, 64,64]},
  116.                 'orange2': {stroke: "#AF6C02", lightcolor: '#FFE060', basecolor: '#FFC000', text: "#8B6010", box: [20,0, 64,98]},
  117.                 'pink': {stroke: '#D855BF', lightcolor: '#FCC4F9'  , basecolor: '#F991F3', text: "#5C1C49",  box: [0,0, 90,32]},
  118.                 'pink2': {stroke: '#D855BF', lightcolor: '#FCC4F9',  basecolor: '#F991F3',  text: "#5C1C49", box: [0,0, 150,45]},
  119.                 'yellow': {stroke: '#B7A11C', lightcolor: '#FFFF40', basecolor: "#FFEA00", text: "#B7A11C", box: [20,0, 42,48]},
  120.                                
  121.                 "cmd0": {path: ShapeDef.cmdNoArgPath, width: 90, height: 64},
  122.                 'cmd': {path: ShapeDef.cmdOneArgPath, width: 105, height: 64},
  123.                 'cmd2': {path: ShapeDef.cmdTwoArgPath, width: 105, height: 120},
  124.                 "input": {path: ShapeDef.numberPath, width: 105, height: 35},
  125.                 "arg": {path: ShapeDef.newLocalPath, width: 52, height: 35},
  126.                 "math": {path: ShapeDef.mathPath, width: 65, height: 49},
  127.                 "comp": {path: ShapeDef.comparisonPath, width: 268, height: 48},
  128.                 "random": {path: ShapeDef.randomPath, width: 259, height: 63},
  129.                 "forever": {path: ShapeDef.foreverPath, width: 185, height: 64},
  130.                 "repeat": {path: ShapeDef.repeatPath, width: 201, height: 125},
  131.                 "if": {path: ShapeDef.ifPath, width: 199, height: 134},
  132.                 "stopall": {path: ShapeDef.endPath, width: 260, height: 62},
  133.                 "hat": {path: ShapeDef.newHatPath, width: 120, height: 76},
  134.                 "hat1": {path: ShapeDef.newHat1Path, width: 125, height: 116},
  135.                 "hat2": {path: ShapeDef.newHat2Path, width: 150, height: 150},
  136.                 'hspace': {path: ShapeDef.extender1, width: 199, height: 50},
  137.                 'vspace': {path: ShapeDef.extender2, width: 89, height: 94},
  138.  
  139.                 "bracket1": {path: ShapeDef.openBracketPath, width: 62, height: 48},
  140.                 "bracket2": {path: ShapeDef.closeBracketPath, width: 58, height: 48}
  141.                 }
  142. }

Raw Paste


Login or Register to edit or fork this paste. It's free.