@@ -338,6 +338,39 @@ export function initGlobalStrandsAPI(p5, fn, strandsContext) {
338338 return fn . mix ( ...args ) ;
339339 } ) ;
340340
341+ // Component accessors: extract scalar channels from a vec4 color
342+ const originalRed = fn . red ;
343+ augmentFn ( fn , p5 , 'red' , function ( ...args ) {
344+ if ( ! strandsContext . active ) {
345+ return originalRed . apply ( this , args ) ;
346+ }
347+ return p5 . strandsNode ( args [ 0 ] ) . x ;
348+ } ) ;
349+
350+ const originalGreen = fn . green ;
351+ augmentFn ( fn , p5 , 'green' , function ( ...args ) {
352+ if ( ! strandsContext . active ) {
353+ return originalGreen . apply ( this , args ) ;
354+ }
355+ return p5 . strandsNode ( args [ 0 ] ) . y ;
356+ } ) ;
357+
358+ const originalBlue = fn . blue ;
359+ augmentFn ( fn , p5 , 'blue' , function ( ...args ) {
360+ if ( ! strandsContext . active ) {
361+ return originalBlue . apply ( this , args ) ;
362+ }
363+ return p5 . strandsNode ( args [ 0 ] ) . z ;
364+ } ) ;
365+
366+ const originalAlpha = fn . alpha ;
367+ augmentFn ( fn , p5 , 'alpha' , function ( ...args ) {
368+ if ( ! strandsContext . active ) {
369+ return originalAlpha . apply ( this , args ) ;
370+ }
371+ return p5 . strandsNode ( args [ 0 ] ) . w ;
372+ } ) ;
373+
341374 augmentFn ( fn , p5 , 'getTexture' , function ( ...rawArgs ) {
342375 if ( strandsContext . active ) {
343376 const { id, dimension } = strandsContext . backend . createGetTextureCall ( strandsContext , rawArgs ) ;
0 commit comments