Apologies if this message appears twice, but I originally posted this about 12 hours ago, and with no sign of it appearing on the list I'm trying again.


Thanks very much to everyone who got back to me on this one.

I don't know what I was doing wrong before, but the code below (adapted from Adrian Ward's post) seems to work fine, with all inputs and outputs showing-up with the correct names.

function (
__number SpriteX,
__number SpriteY,
__number SpriteWidth,
__number SpriteHeight,
__number SampleX,
__number SampleY
) main (
__number UnitWidth,
__number UnitHeight,
__number PixWidth,
__number PixHeight,
__number Rows,
__number Cols,
__number Iteration
)
{
var result = new Object();

spriteWidth = UnitWidth / Cols;
spriteHeight = UnitHeight / Rows;
rowNum = (Math.floor(Iteration / Rows));
colNum = Iteration - (rowNum * Cols);
pixCellWidth = PixWidth / Cols;
pixCellHeight = PixHeight / Rows;


result.SpriteX = colNum * spriteWidth;
result.SpriteY = rowNum * spriteHeight;
result.SpriteWidth = spriteWidth;
result.SpriteHeight = spriteHeight;
result.SampleX = colNum * pixCellWidth;
result.SampleY = rowNum * pixCellHeight;

return result;
}

Oddly, the QTZ it forms part of (which I've attached) still doesn't seem to work, for some reason. I wonder if someone would have a quick look at it for me:
The basic idea is that a grid of sprites is setup using an Iterator, then each sprite is colourised using colour values sampled from the input image by an Image Pixel patch.
For some reason, I can't get the correct value to the Pixel Y input of the Image Pixel patch. I assume the problem is with the above code, in the _javascript_ patch, but I can't work out where the problem lies. It's probably just some simple logical error that I haven't spotted, but a more competent coder will probably be able to spot it instantly.


Thanks once again!

alx


Attachment: Spritefield_Test_01.qtz
Description: application/quartzcomposer

 _______________________________________________
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