Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions docs/api/math/Color.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,17 @@ <h3>[method:Color copy]( [param:Color color] ) </h3>
Copies the [page:.r r], [page:.g g] and [page:.b b] parameters from [page:Color color] in to this color.
</p>

<h3>[method:Color convertGammaToLinear]() </h3>
<p>Converts this color from gamma to linear space by squaring the values of [page:.r r], [page:.g g] and [page:.b b] ).</p>

<h3>[method:Color convertLinearToGamma]() </h3>
<p>Converts this color from linear to gamma space by taking the square root of [page:.r r], [page:.g g] and [page:.b b]).</p>
<h3>[method:Color convertGammaToLinear]( [param:Float gammaFactor] ) </h3>
<p>
[page:Float gammaFactor] - (optional). Default is *2.0*.<br /><br />
Converts this color from gamma to linear space by taking [page:.r r], [page:.g g] and [page:.b b] to the power of [page:Float gammaFactor].
</p>

<h3>[method:Color convertLinearToGamma]( [param:Float gammaFactor] ) </h3>
<p>
[page:Float gammaFactor] - (optional). Default is *2.0*.<br /><br />
Converts this color from linear to gamma space by taking [page:.r r], [page:.g g] and [page:.b b] to the power of 1 / [page:Float gammaFactor].
</p>

<h3>[method:Color copyGammaToLinear]( [param:Color color], [param:Float gammaFactor] ) </h3>
<p>
Expand Down
14 changes: 4 additions & 10 deletions src/math/Color.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,23 +313,17 @@ Object.assign( Color.prototype, {

},

convertGammaToLinear: function () {
convertGammaToLinear: function ( gammaFactor ) {

var r = this.r, g = this.g, b = this.b;

this.r = r * r;
this.g = g * g;
this.b = b * b;
this.copyGammaToLinear( this, gammaFactor );

return this;

},

convertLinearToGamma: function () {
convertLinearToGamma: function ( gammaFactor ) {

this.r = Math.sqrt( this.r );
this.g = Math.sqrt( this.g );
this.b = Math.sqrt( this.b );
this.copyLinearToGamma( this, gammaFactor );

return this;

Expand Down