Hello Keith,

QC hanging with JavaScript: My bug report about this is 4 years old and got 
closed by a "duplicate" statement and obviously never get solved. (#4685625)

The problem is easy to explain: If the for()-loop never get to an end, 
JavaScript will execute this script for ever. Your original code looked like

for (var i=0; i < 360;60){}

which means no increment for var i at all (because "60" doesn't do anything).

So be care full when using while() or for() in JavaScript! Make sure that those 
loops always exit sometimes, otherwise QC will get stuck and you have to force 
quit.

best,

Achim Breidenbach
Boinx Software


On 24.11.2010, at 06:06, Keith Lang wrote:

> Success!
> 
> Attached is patch with Javascript that creates structure to create a
> mesh made of triangles forming a polygon with x sides. 3 = triangle,
> anything above 40 looks pretty identical to a perfect circle. You
> might want to do some 'morphing' between shapes (eg triangle to
> square), but that's beyond my abilities.
> 
> It may be handy to others. (BTW I'm drawing every second triangle
> facing the wrong way.)
> 
> SIDENOTE: My experience was that attempting to increment by anything
> in a For loop other than ++i, then QC hangs. I don't understand these
> things though…should I file a ticket?
> 
> 
> Keith
> 
> ### Javascript below ###
> 
> var _Vertices = [];
> var segmentSize = 3;
> 
> function (__structure Vertices) main (__number numberOfSegments) {
>        var result = new Object();
>        var pos=0;
>        if (numberOfSegments != null) {
>              var v=0;
>              _Vertices.length=0;
>              var leapDistance=6.2831853/numberOfSegments;
>                       var currentPos=0;
>                for (var i=0; i <= numberOfSegments;++i){
>                       currentPos=currentPos+leapDistance;
>                        _Vertices[v++] = [0.5*(Math.sin(currentPos)),
> 0.5*(Math.cos(currentPos)), 0.0 ];
>                        _Vertices[v++] = [0.0, 0.0, 0.0 ];
>                        _Vertices[v++] = [0.5*(Math.sin(currentPos
> +leapDistance)), (0.5* Math.cos(currentPos+leapDistance)), 0.0 ];
>               }
>        }
> result.Vertices = _Vertices
>       return result;
> }
> 
> 
> 
> 
> 
> On Wed, Nov 24, 2010 at 1:47 PM, Keith Lang <[email protected]> wrote:
>> Appreciate your expert help on this…
>> 
>> I'm no coder, and as an exercise in learning Javascript, I tried to
>> help Adam by writing a patch to take in a variable for the number of
>> sides, and to output a structure to create a mesh from.
>> 
>> The Javascript is a terribly hacked version of the Mouse Ribbon.qtz
>> Apple example. (disclaimer: I can't code)
>> 
>> var _Vertices = [];
>> var segmentSize = 3;
>> 
>> function (__structure Vertices) main (__number numberOfSegments) {
>>        var result = new Object();
>>        var v=0;
>>        if (numberOfSegments != null) {
>>                var arcLength =(360/60);
>>                for (var i=0; i < 360;60){
>>                        var pos = i/60;
>>                        _Vertices[v++] = [Math.sin(i), Math.cos(i),
>> 0.0 ];                }
>>        }
>> 
>>        return result;
>> }
>> 
>> 
>> Problem is, if I paste this in a (unconnected) Javascript patch,
>> Quartz Composer becomes unresponsive, requires me to Force Quit.
>> 
>> 
>> Is this normal?
>> 
>> 
>>  ie, that some poorly written Javascript can make QC require a force
>> quit (losing work). Or is my install acting weird?
>> 
>> 
>> 
>> Keith
>> 
>> 
>> 
>> ########
>> 
>> On Wed, Nov 24, 2010 at 5:25 AM, adam morten <[email protected]> wrote:
>>> I would like to create a circle which reacts to audio input. I want the 
>>> circle to change colour with frequency and change size with volume. I have 
>>> done this but the part which I am struggling with is that when the 
>>> frequency changes I want the circle to change through a series of shapes in 
>>> this order; circle, octagon, heptagon, hexagon, pentagon, square, triangle. 
>>> So when the frequency is highest it will be a triangle.
>>> 
>>> Thank you in advance,
>>> Adam _______________________________________________
>>> 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/songcarver%40gmail.com
>>> 
>>> This email sent to [email protected]
>>> 
>> 
> <polygon_mesh_variable_sides.qtz> 
> _______________________________________________
> 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/achim%40boinx.com
> 
> This email sent to [email protected]

 _______________________________________________
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