Modify the colour_rgb function to match other languages (#1210)

There are two tests fail before modifying the color_rgb function because it behaves differently in Dart and in other languages. In Dart, this function takes parameters ranging from 0 to 1.0 while in other languages such as Lua the counterpart function takes parameters ranging from 0 to 100. Now I have modified it to let it behave the same as other languages.
This commit is contained in:
Tony Lian
2017-07-11 16:43:50 -07:00
committed by Andrew n marshall
parent abcc9b82a1
commit 071798546c

View File

@@ -69,15 +69,15 @@ Blockly.Dart['colour_rgb'] = function(block) {
'colour_rgb',
['String ' + Blockly.Dart.FUNCTION_NAME_PLACEHOLDER_ +
'(num r, num g, num b) {',
' num rn = (Math.max(Math.min(r, 1), 0) * 255).round();',
' num rn = (Math.max(Math.min(r, 100), 0) * 2.55).round();',
' String rs = rn.toInt().toRadixString(16);',
' rs = \'0$rs\';',
' rs = rs.substring(rs.length - 2);',
' num gn = (Math.max(Math.min(g, 1), 0) * 255).round();',
' num gn = (Math.max(Math.min(g, 100), 0) * 2.55).round();',
' String gs = gn.toInt().toRadixString(16);',
' gs = \'0$gs\';',
' gs = gs.substring(gs.length - 2);',
' num bn = (Math.max(Math.min(b, 1), 0) * 255).round();',
' num bn = (Math.max(Math.min(b, 100), 0) * 2.55).round();',
' String bs = bn.toInt().toRadixString(16);',
' bs = \'0$bs\';',
' bs = bs.substring(bs.length - 2);',