@@ -127,6 +127,22 @@ qx.Class.define("osparc.ui.basic.SVGImage", {
127127 const brightnessValue = l3 => l3 ;
128128 const contrastValue = l4 => l4 > 50 ? 50 : l4 ;
129129 return `invert(${ invertValue ( l ) } %) sepia(${ sepiaValue ( s ) } %) saturate(${ saturateValue ( s ) } %) hue-rotate(${ h } deg) brightness(${ brightnessValue ( l ) } %) contrast(${ contrastValue ( l ) } %)` ;
130+ } ,
131+
132+ setColorToImage : function ( image , keywordOrRgb ) {
133+ if ( keywordOrRgb === null ) {
134+ keywordOrRgb = "text" ;
135+ }
136+ let filterValue = this . self ( ) . keywordToCSSFilter ( keywordOrRgb ) ;
137+ if ( filterValue === null ) {
138+ const hexColor = qx . theme . manager . Color . getInstance ( ) . resolve ( keywordOrRgb ) ;
139+ const rgbColor = qx . util . ColorUtil . hexStringToRgb ( hexColor ) ;
140+ filterValue = this . self ( ) . rgbToCSSFilter ( rgbColor ) ;
141+ }
142+ const myStyle = {
143+ "filter" : filterValue
144+ } ;
145+ image . getContentElement ( ) . setStyles ( myStyle ) ;
130146 }
131147 } ,
132148
@@ -160,19 +176,7 @@ qx.Class.define("osparc.ui.basic.SVGImage", {
160176 * @param keywordOrRgb {string} predefined keyword or rgb in the following format "0,255,0"
161177 */
162178 __applyImageColor : function ( keywordOrRgb ) {
163- if ( keywordOrRgb === null ) {
164- keywordOrRgb = "text" ;
165- }
166- let filterValue = this . self ( ) . keywordToCSSFilter ( keywordOrRgb ) ;
167- if ( filterValue === null ) {
168- const hexColor = qx . theme . manager . Color . getInstance ( ) . resolve ( keywordOrRgb ) ;
169- const rgbColor = qx . util . ColorUtil . hexStringToRgb ( hexColor ) ;
170- filterValue = this . self ( ) . rgbToCSSFilter ( rgbColor ) ;
171- }
172- const myStyle = {
173- "filter" : filterValue
174- } ;
175- this . getChildControl ( "image" ) . getContentElement ( ) . setStyles ( myStyle ) ;
176- }
179+ this . self ( ) . setColorToImage ( this . getChildControl ( "image" ) , keywordOrRgb ) ;
180+ } ,
177181 }
178182} ) ;
0 commit comments