File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -2123,17 +2123,21 @@ export class LinearGradient {
21232123 let stopsRef = null ;
21242124 if ( this . stops ) {
21252125 const CGFloatArray = interop . sizeof ( interop . types . id ) === 4 ? Float32Array : Float64Array ;
2126- const buffer = CGFloatArray . from ( this . stops ) ;
2126+ const buffer = CGFloatArray . from ( this . stops . map ( ( s ) => Math . max ( 0 , Math . min ( 1 , s ) ) ) ) ;
21272127 stopsRef = buffer ;
21282128 }
21292129
21302130 const cgColors = this . colors . map ( ( c ) => ( c instanceof Color ? c : new Color ( c ) ) . ios . CGColor ) ;
21312131 this . _gradient = CGGradientCreateWithColors ( CGColorSpaceCreateDeviceRGB ( ) , cgColors as any , stopsRef ) ;
2132- CFRetain ( this . _gradient ) ;
2132+ if ( this . _gradient ) {
2133+ CFRetain ( this . _gradient ) ;
2134+ }
21332135 } else {
21342136 const cgColors = [ this . colors , this . stops ] . map ( ( c ) => ( c instanceof Color ? c : new Color ( c ) ) . ios . CGColor ) ;
21352137 this . _gradient = CGGradientCreateWithColors ( CGColorSpaceCreateDeviceRGB ( ) , cgColors as any , null ) ;
2136- CFRetain ( this . _gradient ) ;
2138+ if ( this . _gradient ) {
2139+ CFRetain ( this . _gradient ) ;
2140+ }
21372141 }
21382142 }
21392143 return this . _gradient ;
You can’t perform that action at this time.
0 commit comments