mirror of
https://github.com/google/blockly.git
synced 2026-01-05 08:00:09 +01:00
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:
committed by
Andrew n marshall
parent
abcc9b82a1
commit
071798546c
@@ -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);',
|
||||
|
||||
Reference in New Issue
Block a user