From ab2b79186659f6cafb6b4544cc38d905e9a6b923 Mon Sep 17 00:00:00 2001 From: Viktor Lidholt Date: Fri, 24 Jul 2015 12:39:02 -0700 Subject: [PATCH] Optimizes ColorSequence --- packages/flutter/example/game/lib/color_secuence.dart | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/flutter/example/game/lib/color_secuence.dart b/packages/flutter/example/game/lib/color_secuence.dart index ed4abd89b3..e8e46aae63 100644 --- a/packages/flutter/example/game/lib/color_secuence.dart +++ b/packages/flutter/example/game/lib/color_secuence.dart @@ -24,13 +24,11 @@ class ColorSequence { colors = new List(); colorStops = new List.from(sequence.colorStops); - math.Random rand = new math.Random(); - for (Color color in sequence.colors) { - int aDelta = ((rand.nextDouble() * 2.0 - 1.0) * alphaVar).toInt(); - int rDelta = ((rand.nextDouble() * 2.0 - 1.0) * redVar).toInt(); - int gDelta = ((rand.nextDouble() * 2.0 - 1.0) * greenVar).toInt(); - int bDelta = ((rand.nextDouble() * 2.0 - 1.0) * blueVar).toInt(); + int aDelta = ((randomDouble() * 2.0 - 1.0) * alphaVar).toInt(); + int rDelta = ((randomDouble() * 2.0 - 1.0) * redVar).toInt(); + int gDelta = ((randomDouble() * 2.0 - 1.0) * greenVar).toInt(); + int bDelta = ((randomDouble() * 2.0 - 1.0) * blueVar).toInt(); int aNew = (color.alpha + aDelta).clamp(0, 255); int rNew = (color.red + rDelta).clamp(0, 255);