SynthMaker

Expanding sweep with draw primitives

Archive · 2011 10 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

Dozius ·

I've been trying to draw an expanding sweep line similar to the attached image. It turned out to be much more difficult than I expected. Anybody else ever attempt this style of sweep? Maybe I'm missing something really simple.

oddson ·

You could do it as an animated control. PhotoShop could handle generating the images.

If you want to do the sweep withing SynthMaker's vector graphics a regular sweep with a transparent window could do the job.

Dozius ·

oddson wrote: You could do it as an animated control. PhotoShop could handle generating the images.

Yeah, not what I'm looking to do. It needs to be vectors. Too bad SM can't import svg.

oddson wrote: If you want to do the sweep withing SynthMaker's vector graphics a regular sweep with a transparent window could to the job.

This is pretty much where things became way more complicated than I anticipated. It looks like you should be able to just mask out some of the arc with an ellipse but it doesn't work out that nicely.

oddson ·

While this is nowhere near a complete solution (and far messier than I like to post for an OSM!) it might serve as a proof of concept.

Playing with the areas of the ellipses (making the sweep and masks more or less eccentric and more or less offset in the two dimensions) could give you what you're looking for... provided you only want 270 degrees of sweep.

The other approach that might work is a VLoop where a line segment is rotated about the centre and increases in length as it goes.

infuzion ·

Dozius wrote: oddson wrote: You could do it as an animated control. PhotoShop could handle generating the images.

Yeah, not what I'm looking to do. It needs to be vectors. Too bad SM can't import svg.

I'm sure Inkscape & other programs can export to PNG, perhaps even by command line so you can execute it with in SM: http://wiki.inkscape.org/wiki/index.php ... Fexport.3F IMHO this is the best bet for now...

oddson wrote: While this is nowhere near a complete solution (and far messier than I like to post for an OSM!) it might serve as a proof of concept. .. The other approach that might work is a VLoop where a line segment is rotated about the centre and increases in length as it goes.

Great, I've been wanting to do this, but didn't take the time yet! I'd make the entire graphic fit slightly smaller inside the bounding box so SM doesn't clip the edges as always.

trogluddite ·

oddson wrote: The other approach that might work is a VLoop where a line segment is rotated about the centre and increases in length as it goes.

Here's a first draft using a draw loop. I've used arcs with gradually increasing pen thickness rather than line segments in order to reduce the number of draw loop iterations needed.

In the properties, you can set the number of sections that the arc is split into - to compromise between the smoothness of the thickness changes, and the CPU use of ReDraws. As posted there are 20 sections, but the sweep angle of the 'last' segment is calculated correctly so that sweeps are not confined to whole segments - so you keep the advantage of vectors being scalable and not being 'quantised' to a limited number of positions (I imagine this is why Doziuz would prefer not to use bitmaps).

infuzion ·

I would use a draw loop only as a last last resort; uses too many triggers, & in this case unneeded math. Besides, it looks chunky.

trogluddite ·

infuzion wrote: I would use a draw loop only as a last last resort

Always! But this method does have one big advantage (so long as the knob is not to be animated fast!) - it retains the transparency of the 'not sweep' parts. This would make it much easier to use when placed on e.g. a texture/grad background, which would be almost impossible to match up if using other primitives to mask out the required shape.

I agree though that the 'chunkiness' can be tricky to eliminate completely with wider sweeps, even when more segments are used. This is in part due to a problem that we have seen before with the arc primitive - the flat 'line caps' do not get projected correctly along the radius of the arc (thread here). That's why I cheated a little bit and added a 1deg extension to the 'whole' segments, but even this does nor work completely for thicker sweeps.

Dozius ·

oddson wrote: While this is nowhere near a complete solution (and far messier than I like to post for an OSM!) it might serve as a proof of concept.

This is pretty much as good as I could get it on my own. As in my own attempts the arc doesn't expand properly. It even begins to shrink again towards the end of the sweep. I had another chance today to look at the problem and I figured out why that is. Take a look at this picture I made up to demonstrate.

The 'inside' line of the sweep follows a circular path, while the outer line actually follows a logarithmic spiral path. This is impossible to reproduce with an ellipse and why both our efforts didn't come out quite right.

infuzion wrote: I'm sure Inkscape & other programs can export to PNG

This doesn't meet the vector requirement.

trogluddite wrote: Here's a first draft using a draw loop. I've used arcs with gradually increasing pen thickness rather than line segments in order to reduce the number of draw loop iterations needed.

I had thought about trying this but was afraid it would a) be too 'steppy' and b) consume way too much CPU. I really appreciate the effort to prove this out (since I had planned to try it out tonight!), but it looks like my fears were correct. If I limit the sections to a reasonable amount of CPU it's too 'steppy' and if I increase it to an acceptable level of smoothness the CPU is way too much. Still very cool to see it in action though.

The last idea I had for this was to use a few PALines somehow, but I think this too would end up being entirely too CPU intensive. Thanks for the input guys, but I think I'm just going to have to accept that I won't be able to do this within SM.

infuzion ·

trogluddite wrote: infuzion wrote: I would use a draw loop only as a last last resort

Always! But this method does have one big advantage (so long as the knob is not to be animated fast!)

Always assume knobs will be automated, thus may have to be moved fast.

Dozius wrote: infuzion wrote: I'm sure Inkscape & other programs can export to PNG

This doesn't meet the vector requirement.

I still don't know why you have this requirement. If you need vector so badly, & Oddson's is not so good for you, then wait for Ruby in SM to be released.

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.