| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Everyone,
// set up the endpoints A.x = Ax; A.y = Ay; B.x =Bx; B.y =By; A *= samplerSize(image); B *= samplerSize(image);
// Compute where the minimum is between A and B
float q = ((where.x-A.x)*(B.x-A.x) + (where.y-A.y)*(B.y-A.y)) /
(pow((B.x-A.x),2.0) + pow((B.y-A.y),2.0));// Clamp the result between zero and one q = q < 0.0 ? 0.0 : q; q = q > 1.0 ? 1.0 : q;
// Compute the coordinates of the nearest point on the line segment P.x = (1.0 - q)*A.x + q*B.x; P.y = (1.0 -q)*A.y + q*B.y;
// Set Alpha to zero if we're outside the desired distance. result.a *= distance(P,where) < thickness ? 1.0 : 0.0;
return result; }
which generates line segments with nice, rounded end-caps:
Here's the composition:
Attachment:
Circle kernel.qtz
Description: application/quartzcomposer
-jcr
John C. Randolph <email@hidden> (408) 914-0013 Roaming Cocoa Engineer, Available for your projects at great Expense and Inconvenience.
_______________________________________________ Do not post admin requests to the list. They will be ignored. Quartzcomposer-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/quartzcomposer-dev/email@hidden This email sent to email@hidden
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.