I'm trying to find a way to recognise if a given item in a structure is a 'Color' object. I need to do this totally inside JS patch – no outside patches to help with the effort – because the JS patch needs to iterate thru 100 items in the structure (precluding a QC-patch-methodology).

The closest I've got is the JS '===' comparison (which compares type as well as value and is one of a scant couple of useful, non-ubiquitous facts in the Apple _javascript_ docs). If I coerce the object to a String and then compare the object to it's coerced string with '===' a colour will not result in true (whereas '==' would be true)  but neither will any other QC-Structure :/

Using stock patches, best method I've found is to plug the object of interest into String Components patch giving a 4 item structure if it's a color then checking first element for "R=" in first 2 char. But like I said, I need to do this inside _javascript_. 

Seems QC evaluates colors under the hood differently depending on the Patch that is receiving it: Image to String will show a colour as "R=0.123456 G=0.1234546 B=0.1233445 A=1". 

Putting the color through other patches like splitters makes Image to String show "<QC Structure>" instead.

When a noodle porting a color is pulled off an input port of any kind of String patch, the text <NSCalibratedRGBColor> is left in the port. So many hints this could be possible but no cigars.

I wish I could write even elementary plugins* this must be a few lines of code only! ;) 

* Read wouldn't it be great to use QC5 to write plugins and/or sample and create under-the-hood data types.

Attachment: I want an IsColor?() JS method.qtz
Description: application/quartzcomposer





The machine does not isolate man from the great problems of nature but plunges him more deeply into them. 
Antoine de Saint-Exupery 

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to