best way to draw an unfilled-in circle

strontiumDog's picture

hello can anyone tell me what is the best way to draw an unfilled-in circle?

CICircleGenerator doesn't have a setting to just draw the rim of the circle. i'd like to be able to specify radius and thickness (although i could just specify ++ circles).

i can't seem to do it with splines... thanks IA s

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

smokris's picture
Troy's DrawCircle.qtz

On the QC Mailing list, Troy recommended doing this by subtracting two radial gradients:

See attached composition (by Troy).

DrawCircle.qtz4.02 KB

cwright's picture

solve it with some maths (this version is hardcoded to use a 512x512 input image, but you can modify it to draw bigger circles if necessary)

circleDraw.qtz3.33 KB

strontiumDog's picture
thanks for the suggestion -

thanks for the suggestion - although that doesn't quite do it for me unfortunately.

i need the circle created using splines or a similar method so that there are no pixels in the middle and i can dynamically alter the radius whilst moving the circle through 3d space with the items behind it visible.

unless i've missed the point of gradients, this isn't going to do it for me. does anyone know how to do it with splines or similar?

thanks s

cwright's picture
circles from spline

You can't create circles from most splines (NURBS are the only splines that can actually create circles correctly -- all other splines are simply approximations of circles, due to how they interpolate points), including the ones built in GL Tools -- it's just not possible. you can add a bunch of control points, and approximate one, that should be fairly straightforward.

you should also try playing with the blend mode of troy's example, or mine -- You'll also need to use the Depth Buffer Alpha Threshold patch, to prevent the sprite from rendering to the depth buffer when pixels are transparent (to get stuff to show up behind them).

gtoledo3's picture
You might want to try

You might want to try searching this forum(?) with the search terms "quartz composer iDVD plug in" ... there is a pretty useful cylinder patch in there that may or may not be able to do what you are saying.

The "circle" around the main sphere image in the middle, and the outside lines, are both made with the iDVD plugin....

iris for kineme upload.qtz144.08 KB

toneburst's picture
You can also use

the builtin GLSL function distance(current pix,centre pix) to get the distance of the current pixel from an arbitrary centre vec2.

Saves a line or two of code in the CIFilter.


smokris's picture
Speaking of Quadrics...

If you take the Kineme GL Torus and set it to Alpha Wireframe mode (using Kineme GL Polygon Mode), you get a pretty nice looking vector circle.

wireframe-torus.qtz2.52 KB

cwright's picture

Ahh, distance. I initially tried using length (and subtracting the center), but it kept returning garbage values, so I ended up just doing it manually. good to know there's a dist function as well (that would simplify a fair amount)

strontiumDog's picture
well spotted

thanks very much for the suggestion - the torus patch does the trick - at least for my original post.

the clickable cylinder patch has all the right params if i'm truthful regarding where i was going - except i can't specify a height like in the renderer cylinder patch. is there a way of varying this param?


strontiumDog's picture
thanks to everybody

it's a good feeling to know there are knowledgable people also willing to help me. it took about half an hour to get about 6 good suggestions.

big up.

gtoledo3's picture
Oooh, forgot about that one.

Oooh, forgot about that one. That torus patch of yours is cool... and I like how it has the maj/min functions just like a GLSL shader....

gtoledo3's picture
Yeah, that is the one thing

Yeah, that is the one thing that sucks about it.... for my uses, I have just put it inside a GL Ortho or Field of View patch when I want it to stretch it one way or another, but that obviously is a lame kind of workaround that doesn't work for every scenario.

strontiumDog's picture

i've been experimenting with the image crop - and can't see how to alter the size of the circle.

unintuitively, increasing the crop height and width makes the circle smaller.

as i don't know glsl yet (although the code in the CIfilter seems to make some sense), i wonder if someone can help me - i can see that in circleDraw qtz the LFO takes the radius to the max which means the edge of the circle is cropped where is meets the crop width/height.


cwright's picture

this demo was sloppily thrown together, so you need to modify 2 parts to get it working happily.

First, you need to enlarge the crop (which you've tried). Then, you need to modify the core image filter to use the new center point. right now, there are some 256.'s in the source (512/2) -- change them to 1/2 your crop's width/height (so, for example, if you made the crop 1024x1024, you'd use 512. in the core image filter).

I think there's a way to make this work transparently, but I'm pretty lousy at CI, so I'll leave that for someone more skilled (like a|x, perhaps?) to chime in.

You can also increase the width/height of the sprite, though it'll start to smear the circle a bit (bilinear filtering) if you stretch it too much without increasing its resolution.

strontiumDog's picture
how do i delete posts?

ignore the last post - sorted it. i've just seen your reply too - cheers for the explanation.

i would have just deleted the last post, but don't seem to see the delete post button...