Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: tracing/tracing/base/sinebow_color_generator.html

Issue 2771723003: [tracing] Move math utilities from base into their own subdirectory (attempt 2) (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2016 The Chromium Authors. All rights reserved. 3 Copyright 2016 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/base/color.html"> 8 <link rel="import" href="/tracing/base/color.html">
9 <link rel="import" href="/tracing/base/iteration_helpers.html"> 9 <link rel="import" href="/tracing/base/iteration_helpers.html">
10 <link rel="import" href="/tracing/base/math.html"> 10 <link rel="import" href="/tracing/base/math/math.html">
11 11
12 <script> 12 <script>
13 'use strict'; 13 'use strict';
14 tr.exportTo('tr.b', function() { 14 tr.exportTo('tr.b', function() {
15 /** 15 /**
16 * Generate pretty colors! 16 * Generate pretty colors!
17 * http://basecase.org/env/on-rainbows 17 * http://basecase.org/env/on-rainbows
18 * https://mycarta.wordpress.com/2012/10/06/the-rainbow-is-deadlong-live-the-r ainbow-part-3/ 18 * https://mycarta.wordpress.com/2012/10/06/the-rainbow-is-deadlong-live-the-r ainbow-part-3/
19 * 19 *
20 * Set brightness = 0 to always generate black. 20 * Set brightness = 0 to always generate black.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 SinebowColorGenerator.nthColor = function(n) { 68 SinebowColorGenerator.nthColor = function(n) {
69 return SinebowColorGenerator.sinebow_(n * this.PHI); 69 return SinebowColorGenerator.sinebow_(n * this.PHI);
70 }; 70 };
71 71
72 SinebowColorGenerator.calculateColor = function(r, g, b, a, brightness) { 72 SinebowColorGenerator.calculateColor = function(r, g, b, a, brightness) {
73 if (brightness <= 1) { 73 if (brightness <= 1) {
74 r *= brightness; 74 r *= brightness;
75 g *= brightness; 75 g *= brightness;
76 b *= brightness; 76 b *= brightness;
77 } else { 77 } else {
78 r = tr.b.lerp(tr.b.normalize(brightness, 1, 2), r, 255); 78 r = tr.b.math.lerp(tr.b.math.normalize(brightness, 1, 2), r, 255);
79 g = tr.b.lerp(tr.b.normalize(brightness, 1, 2), g, 255); 79 g = tr.b.math.lerp(tr.b.math.normalize(brightness, 1, 2), g, 255);
80 b = tr.b.lerp(tr.b.normalize(brightness, 1, 2), b, 255); 80 b = tr.b.math.lerp(tr.b.math.normalize(brightness, 1, 2), b, 255);
81 } 81 }
82 r = Math.round(r); 82 r = Math.round(r);
83 g = Math.round(g); 83 g = Math.round(g);
84 b = Math.round(b); 84 b = Math.round(b);
85 return 'rgba(' + r + ',' + g + ',' + b + ', ' + a + ')'; 85 return 'rgba(' + r + ',' + g + ',' + b + ', ' + a + ')';
86 }; 86 };
87 87
88 return { 88 return {
89 SinebowColorGenerator, 89 SinebowColorGenerator,
90 }; 90 };
91 }); 91 });
92 </script> 92 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/base/running_statistics_test.html ('k') | tracing/tracing/base/sorted_array_utils.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698