Couldn't you just check the input is a structure composed of 4 members, then check each member has a value in the 0 > 1 range?


Thanks for the interest Alex, but No!

Length test fails on a QC Color object. 

for (i in Object_of_interest) {…}, will not iterate for a color object.

Attachment: JS objectTypeName II.qtz
Description: application/quartzcomposer


There are ways to test if an object is a QC color outside of the _javascript_ patch as shown in first comp I posted. This query is about doing it with _javascript_.

Cheers
Alastair



On 10/08/2010, at 7:12 AM, Alex Drinkwater wrote:

Couldn't you just check the input is a structure composed of 4 members, then check each member has a value in the 0 > 1 range?

a|x

--- On Mon, 9/8/10, Achim Breidenbach <[email protected]> wrote:

From: Achim Breidenbach <[email protected]>
Subject: Re: .IsColor() method in _javascript_ ?!
To: "Alastair Leith" <[email protected]>
Cc: "quartzcomposer-dev list list" <[email protected]>
Date: Monday, 9 August, 2010, 16:46

Hello Alastair,

I googled a method that reads the object type from its constructor. Find enclosed a variant of your composition how it works.

Unfortunately it says: "Number" for bool, "String" for string and "Object " for colors. But maybe this is all you need to make your decisions within your _javascript_?

best,

Achim Breidenbach
Boinx Software


On 09.08.2010, at 15:29, Alastair Leith wrote:

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.

<I want an IsColor?() JS method.qtz>




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/achim%40boinx.com

This email sent to [email protected]


-----Inline Attachment Follows-----

_______________________________________________
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/the_voder%40yahoo.co.uk

This email sent to [email protected]

_______________________________________________
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/qc.student.au%40gmail.com

This email sent to [email protected]

 _______________________________________________
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