diff --git a/generators/php/colour.js b/generators/php/colour.js index 2ca67a80d..4a11a926f 100644 --- a/generators/php/colour.js +++ b/generators/php/colour.js @@ -84,12 +84,12 @@ Blockly.PHP['colour_blend'] = function(block) { [ 'function ' + Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_ + '($c1, $c2, $ratio) {', ' $ratio = max(min($ratio, 1), 0);', - ' $r1 = hexdec(substr($c1,0,2));', - ' $g1 = hexdec(substr($c1,2,2));', - ' $b1 = hexdec(substr($c1,4,2));', - ' $r2 = hexdec(substr($c2,0,2));', - ' $g2 = hexdec(substr($c2,2,2));', - ' $b2 = hexdec(substr($c2,4,2));', + ' $r1 = hexdec(substr($c1, 1, 2));', + ' $g1 = hexdec(substr($c1, 3, 2));', + ' $b1 = hexdec(substr($c1, 5, 2));', + ' $r2 = hexdec(substr($c2, 1, 2));', + ' $g2 = hexdec(substr($c2, 3, 2));', + ' $b2 = hexdec(substr($c2, 5, 2));', ' $r = round($r1 * (1 - $ratio) + $r2 * $ratio);', ' $g = round($g1 * (1 - $ratio) + $g2 * $ratio);', ' $b = round($b1 * (1 - $ratio) + $b2 * $ratio);', diff --git a/php_compressed.js b/php_compressed.js index a4aa88a43..d379656cd 100644 --- a/php_compressed.js +++ b/php_compressed.js @@ -13,8 +13,8 @@ Blockly.PHP.scrub_=function(a,b){var c="";if(!a.outputConnection||!a.outputConne Blockly.PHP.colour={};Blockly.PHP.colour_picker=function(a){return["'"+a.getFieldValue("COLOUR")+"'",Blockly.PHP.ORDER_ATOMIC]};Blockly.PHP.colour_random=function(a){return[Blockly.PHP.provideFunction_("colour_random",["function "+Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"() {"," return '#' . str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);","}"])+"()",Blockly.PHP.ORDER_FUNCTION_CALL]}; Blockly.PHP.colour_rgb=function(a){var b=Blockly.PHP.valueToCode(a,"RED",Blockly.PHP.ORDER_COMMA)||0,c=Blockly.PHP.valueToCode(a,"GREEN",Blockly.PHP.ORDER_COMMA)||0;a=Blockly.PHP.valueToCode(a,"BLUE",Blockly.PHP.ORDER_COMMA)||0;return[Blockly.PHP.provideFunction_("colour_rgb",["function "+Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($r, $g, $b) {"," $r = round(max(min($r, 100), 0) * 2.55);"," $g = round(max(min($g, 100), 0) * 2.55);"," $b = round(max(min($b, 100), 0) * 2.55);",' $hex = "#";',' $hex .= str_pad(dechex($r), 2, "0", STR_PAD_LEFT);', ' $hex .= str_pad(dechex($g), 2, "0", STR_PAD_LEFT);',' $hex .= str_pad(dechex($b), 2, "0", STR_PAD_LEFT);'," return $hex;","}"])+"("+b+", "+c+", "+a+")",Blockly.PHP.ORDER_FUNCTION_CALL]}; -Blockly.PHP.colour_blend=function(a){var b=Blockly.PHP.valueToCode(a,"COLOUR1",Blockly.PHP.ORDER_COMMA)||"'#000000'",c=Blockly.PHP.valueToCode(a,"COLOUR2",Blockly.PHP.ORDER_COMMA)||"'#000000'";a=Blockly.PHP.valueToCode(a,"RATIO",Blockly.PHP.ORDER_COMMA)||.5;return[Blockly.PHP.provideFunction_("colour_blend",["function "+Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($c1, $c2, $ratio) {"," $ratio = max(min($ratio, 1), 0);"," $r1 = hexdec(substr($c1,0,2));"," $g1 = hexdec(substr($c1,2,2));"," $b1 = hexdec(substr($c1,4,2));", -" $r2 = hexdec(substr($c2,0,2));"," $g2 = hexdec(substr($c2,2,2));"," $b2 = hexdec(substr($c2,4,2));"," $r = round($r1 * (1 - $ratio) + $r2 * $ratio);"," $g = round($g1 * (1 - $ratio) + $g2 * $ratio);"," $b = round($b1 * (1 - $ratio) + $b2 * $ratio);",' $hex = "#";',' $hex .= str_pad(dechex($r), 2, "0", STR_PAD_LEFT);',' $hex .= str_pad(dechex($g), 2, "0", STR_PAD_LEFT);',' $hex .= str_pad(dechex($b), 2, "0", STR_PAD_LEFT);'," return $hex;","}"])+"("+b+", "+c+", "+a+")",Blockly.PHP.ORDER_FUNCTION_CALL]}; +Blockly.PHP.colour_blend=function(a){var b=Blockly.PHP.valueToCode(a,"COLOUR1",Blockly.PHP.ORDER_COMMA)||"'#000000'",c=Blockly.PHP.valueToCode(a,"COLOUR2",Blockly.PHP.ORDER_COMMA)||"'#000000'";a=Blockly.PHP.valueToCode(a,"RATIO",Blockly.PHP.ORDER_COMMA)||.5;return[Blockly.PHP.provideFunction_("colour_blend",["function "+Blockly.PHP.FUNCTION_NAME_PLACEHOLDER_+"($c1, $c2, $ratio) {"," $ratio = max(min($ratio, 1), 0);"," $r1 = hexdec(substr($c1, 1, 2));"," $g1 = hexdec(substr($c1, 3, 2));"," $b1 = hexdec(substr($c1, 5, 2));", +" $r2 = hexdec(substr($c2, 1, 2));"," $g2 = hexdec(substr($c2, 3, 2));"," $b2 = hexdec(substr($c2, 5, 2));"," $r = round($r1 * (1 - $ratio) + $r2 * $ratio);"," $g = round($g1 * (1 - $ratio) + $g2 * $ratio);"," $b = round($b1 * (1 - $ratio) + $b2 * $ratio);",' $hex = "#";',' $hex .= str_pad(dechex($r), 2, "0", STR_PAD_LEFT);',' $hex .= str_pad(dechex($g), 2, "0", STR_PAD_LEFT);',' $hex .= str_pad(dechex($b), 2, "0", STR_PAD_LEFT);'," return $hex;","}"])+"("+b+", "+c+", "+a+")",Blockly.PHP.ORDER_FUNCTION_CALL]}; // Copyright 2015 Google Inc. Apache License 2.0 Blockly.PHP.lists={};Blockly.PHP.lists_create_empty=function(a){return["array()",Blockly.PHP.ORDER_ATOMIC]};Blockly.PHP.lists_create_with=function(a){for(var b=Array(a.itemCount_),c=0;c