Skip to content

Commit

Permalink
SVGRenderer: Add .outputColorSpace=DisplayP3ColorSpace support (#26914)
Browse files Browse the repository at this point in the history
  • Loading branch information
donmccurdy authored Oct 27, 2023
1 parent 3c21783 commit d2f7811
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions examples/jsm/renderers/SVGRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Matrix3,
Matrix4,
Object3D,
SRGBColorSpace,
Vector3
} from 'three';
import { Projector } from '../renderers/Projector.js';
Expand Down Expand Up @@ -75,6 +76,8 @@ class SVGRenderer {

this.overdraw = 0.5;

this.outputColorSpace = SRGBColorSpace;

this.info = {

render: {
Expand Down Expand Up @@ -155,7 +158,7 @@ class SVGRenderer {
this.clear = function () {

removeChildNodes();
_svg.style.backgroundColor = _clearColor.getStyle();
_svg.style.backgroundColor = _clearColor.getStyle( _this.outputColorSpace );

};

Expand All @@ -173,7 +176,7 @@ class SVGRenderer {
if ( background && background.isColor ) {

removeChildNodes();
_svg.style.backgroundColor = background.getStyle();
_svg.style.backgroundColor = background.getStyle( _this.outputColorSpace );

} else if ( this.autoClear === true ) {

Expand Down Expand Up @@ -389,7 +392,7 @@ class SVGRenderer {

if ( material.isSpriteMaterial || material.isPointsMaterial ) {

style = 'fill:' + material.color.getStyle() + ';fill-opacity:' + material.opacity;
style = 'fill:' + material.color.getStyle( _this.outputColorSpace ) + ';fill-opacity:' + material.opacity;

}

Expand All @@ -403,7 +406,7 @@ class SVGRenderer {

if ( material.isLineBasicMaterial ) {

let style = 'fill:none;stroke:' + material.color.getStyle() + ';stroke-opacity:' + material.opacity + ';stroke-width:' + material.linewidth + ';stroke-linecap:' + material.linecap;
let style = 'fill:none;stroke:' + material.color.getStyle( _this.outputColorSpace ) + ';stroke-opacity:' + material.opacity + ';stroke-width:' + material.linewidth + ';stroke-linecap:' + material.linecap;

if ( material.isLineDashedMaterial ) {

Expand Down Expand Up @@ -463,11 +466,11 @@ class SVGRenderer {

if ( material.wireframe ) {

style = 'fill:none;stroke:' + _color.getStyle() + ';stroke-opacity:' + material.opacity + ';stroke-width:' + material.wireframeLinewidth + ';stroke-linecap:' + material.wireframeLinecap + ';stroke-linejoin:' + material.wireframeLinejoin;
style = 'fill:none;stroke:' + _color.getStyle( _this.outputColorSpace ) + ';stroke-opacity:' + material.opacity + ';stroke-width:' + material.wireframeLinewidth + ';stroke-linecap:' + material.wireframeLinecap + ';stroke-linejoin:' + material.wireframeLinejoin;

} else {

style = 'fill:' + _color.getStyle() + ';fill-opacity:' + material.opacity;
style = 'fill:' + _color.getStyle( _this.outputColorSpace ) + ';fill-opacity:' + material.opacity;

}

Expand Down

0 comments on commit d2f7811

Please sign in to comment.