Fix PHP's RGB colour block.

This commit is contained in:
Neil Fraser
2015-06-04 15:12:37 -07:00
parent b935dd8613
commit c95865a181
2 changed files with 21 additions and 16 deletions

View File

@@ -58,6 +58,9 @@ Blockly.PHP['colour_rgb'] = function(block) {
'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);',