Thank you Achim,
That has shown me three newish things:
String(Thing[i].constructor) , .constructor method and .match(/
function\s+(\w+)/)
Presumably String(Thing[i]) is same as Thing[i].toString()
Constructor I get, and .match I get with a little reference to google.
I would like to tell if it is specifically a colour, as at other times
QCstructures objects might be there instead that would generate false
positives β in this case breaks the code with runtime errors but I
guess that can be sorted.
This script has to cope with any kind of object QC can throw at it. I
don't know why I can't test if its a 4 item QCstructure and the (thing
[0] == "R="). I seems like colors are not handled inside QC as a
structure because I can't even test for Thing.length where Thing is a
color
I realised in SL I could use standard patches for a test inside an
iterator and port the matches out with a queue. The structure to be
tested is only periodically dynamic so speed isn't a big deal. But i'm
on 10.5.8 :?
Gonna have to move on⦠It's for a screen dump of a structure which is
user determined and can be any combination of objects. I'l use a
manual index setting for object display method for each item in
structure. As in an index for 0: Bool, 1: Number/String, 2: Colour,
Structure (just show its length or no info) 3: Number to 3dp etc
instead of auto-detection.
Cheers
Alastair
On 10/08/2010, at 1:46 AM, Achim Breidenbach wrote:
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
<objectTypeName.qtz>
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]
_______________________________________________
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]