Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Circle?



Hi,


From: David Remahl <email@hidden>
Subject: Re: Circle?
To: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes;
    format=flowed

Thanks for that suggestion! Hadn't thought of that...

I'm also replying to myself; I figured out how to act without source
material. The function I had missed in the reference material was
destCoord (). Here is some code generating a circle centered around
(0,0):

kernel vec4 circle ()
{
     vec4 v = destCoord ();
     float c = ( sqrt ( v.x*v.x + v.y*v.y ) < 300. ? 0. : 1. );
     return vec4 ( c, c, c, 1.0 );;
}

/ David

A more efficient way to write this would be:

kernel vec4 circle(vec2 center, float radius, __color color)
{
return color * clamp(radius - distance(destCoord(), center), 0.0, 1.0);
}


the built-in function distance() is usually faster than using sqrt (sum of squares).
- Ralph


_______________________________________________
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


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.