From 071798546cb7504a7827f5cd76ca27327a0a9e38 Mon Sep 17 00:00:00 2001 From: Tony Lian <1040424979@qq.com> Date: Tue, 11 Jul 2017 16:43:50 -0700 Subject: [PATCH] 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. --- generators/dart/colour.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/generators/dart/colour.js b/generators/dart/colour.js index 7ded91419..105608988 100644 --- a/generators/dart/colour.js +++ b/generators/dart/colour.js @@ -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);',