-
... TALLED! See also: RedLTurtle , RedIFS , RedMandelbrot Description Plotting with Pen . After Flake - "The Computational Beauty of Nature". Class Methods . new Arguments: drawFunc A Function that draws something. matrices An array of arrays d ...
-
//simple pendulum in a world with gravity ( var width= 300, height= 300, w, wgrav, world, n= 1, ploc; //--world w= RedWindow("pendulum test1", Rect(128, 64, width, height)).front; wgrav= RedVector2D[0, 0.98]; world= RedWorld(RedVector2D[wid ...
-
... ctor2D[0, 0], 1.5, 10) }.dup(n); //world,loc,vel,acc,mass,size //--loop w.draw{ Pen.strokeColor= Color.green; rep.loc= w.mouse; Pen.strokeRect(Rect.aboutRedObject2D(rep)); Pen.strokeColor= Color.white; world.objects.do{|o| if(o!=rep, { o.ad ...
-
//a few pendulums that attract eachother ( var width= 300, height= 300, w, wgrav, world, n= 18, ploc; //--world w= RedWindow("pendulum test3", Rect(128, 64, width, height)).front; wgrav= RedVector2D[0, 0.98]; world= RedWorld(RedVector2D[wid ...
-
//linked pendulums ( var width= 300, height= 300, w, wgrav, world, n= 5, ploc; //--world w= RedWindow("linked pendulums", Rect(128, 64, width, height)).front; wgrav= RedVector2D[0, 0.98]; world= RedWorld(RedVector2D[width, height], wgrav, 2 ...
-
... i-1), world.objects.wrapAt(i+1)); }; world.objects.do{|o| o.update}; //--render Pen.width= 5; Pen.strokeColor= Color.black; Pen.fillColor= Color.white; world.objects.do{|o| var p, x, y; p= o.loc.asPoint; Pen.addOval(Rect.aboutPoint(p, o.siz ...
-
... r.notNil, { over.loc= w.mouse; }); sprs.do{|spr| spr.update; //--render springs Pen.strokeColor= Color.grey; Pen.line(spr.object.loc.asPoint, spr.target.loc.asPoint); Pen.stroke; }; world.objects.do{|obj, i| obj.addForce(world.gravity); //w ...
-
//many pendulums in a world with gravity ( var width= 300, height= 300, w, wgrav, world, n= 50, ploc; //--world w= RedWindow("pendulum test2", Rect(128, 64, width, height)).front; wgrav= RedVector2D[0, 0.98]; world= RedWorld3(RedVector2D[wi ...
-
... 0.001))*0.5+0.5*width, cos(w.frame*0.027+cos(w.frame*0.0012))*0.5+0.5*height ]; Pen.strokeColor= Color.yellow; Pen.strokeOval(Rect.aboutRedObject2D(rep)); Pen.strokeColor= Color.white; world.objects.do{|o, i| if(o!=rep, { o.addForce(o.gravi ...
-
... el, 0, mass, mass*10); //world,loc,vel,acc,mass,size }.dup(n); //--loop w.draw{ Pen.fillColor= Color.grey(0, cnt.fold(0, 500)/10000); Pen.fillRect(Rect(0, 0, width, height)); world.objects.do{|o| world.objects.do{|oo| var dist= o.loc.distan ...