
Science SPORE Prize
November 2011

The Open Source Physics Project is supported by NSF DUE-0442581.
|
making Trace in 2D that can have different memory colors, currently it can only show static one color
post and replies
Return to the making Trace in 2D that can have different memory colors, currently it can only show static one color thread
Login to post to this thread
|
making Trace in 2D that can have different memory colors, currently it can only show static one colo
- Feb 28 at 4:29AM
|

lookang
49 Posts
|
hi profs,
it seems according to http://www.um.es/fem/EjsWiki/Main/ElementsAboutColors that there is no way to display different 'runs' of the traces with unique different colors.
having different memory colors serves to allow students to quickly differentiate between their different runs of the simulation after _initialize() button that i created.
can advise if i can do this feature now or will this be available in future EJS versions?
thanks! if the source code is opened, it is the emf graph look for "tracevoltage".
Attached File: ejs_FallingMagnet10memory4.3.0.zip
http://weelookang.blogspot.sg
|
|
Re: making Trace in 2D that can have different memory colors, currently it can only show static one colo - Feb 28 4:36AM
|
Francisco Esquembre
72 Posts
|
Hi,
This is not correct. You can make a trail or trace display with different colors.
For a trail, you need to create a new segment of the trail. This is done like this: _view.newSegment(); Then, change the colour and the old (previous) segment will keep its colour, and the new one will use the new color. You can do this as many times as desired, until you reset the trail.
For a trace, you just change the colour you are using. A trace is able to add each point with a new color.
Unfortunately, your attached file causes an OutOfMemory error in my computer. But I hope my explanation suffices to solve your problem.
Cheers, Paco
|
|
Re: Re: making Trace in 2D that can have different memory colors, currently it can only show static one colo - Feb 28 5:33AM
|

lookang
49 Posts
|
dear prof paco, thank you for the quick response :)
chance of a simple example you can make quickly? or point me to a EJS that does the different colors for trace.
this is very interesting for me!
http://weelookang.blogspot.sg
|
|
Re: Re: Re: making Trace in 2D that can have different memory colors, currently it can only show static one colo - Feb 28 6:49AM
|
Francisco Esquembre
72 Posts
|
Sure!
See attachment.
Paco
Attached File: ejs_ColoredTrails.zip
|
|
Re: Re: Re: Re: making Trace in 2D that can have different memory colors, currently it can only show static one colo - Mar 03 10:39PM
|

lookang
49 Posts
|
thank you! managed to produced the required effect.
created 2 variables memorycolor int type initial value =0 memorycolormagnet int type initial value =10 // arbitrarily set assume max 10 runs of different colors
evolution page: time += 0.005; if (_isPaused()==true) { // assume _isPaused() can detect new runs
_view.voltageTrail.newSegment(); _view.coilZTrail.newSegment(); _view.coilVzTrail.newSegment(); _view.ForceTrailcoil.newSegment(); memorycolor++; // assume no more than runs selected (unique colors)new color 0,1,2,.... _view.magnetZTrail.newSegment(); _view.magnetVzTrail.newSegment(); _view.ForceTrailmagnet.newSegment(); memorycolormagnet++; // new color 10,11,12,.... }
very nice indeed! thank you prof paco and prof wolfgang! attached is my model in case anyone is interested to learn from it!
Post edited March 3, 2013 at 10:42 PM EST.
Attached File: ejs_FallingMagnet10memory4.3.01.zip
http://weelookang.blogspot.sg
|
|
Re: Re: making Trace in 2D that can have different memory colors, currently it can only show static one colo - Feb 28 7:22AM
|
Wolfgang
52 Posts
|
The Special Functions model in the OSP Collection does what you want using a Trail Element.
http://www.compadre.org/osp/items/detail.cfm?ID=8384
You can also change the color of a Trace Element as shown in the attached example.
Wolfgang
Attached File: ejs_TraceColorTest.zip
|
|
Re: Re: Re: making Trace in 2D that can have different memory colors, currently it can only show static one colo - Mar 03 10:43PM
|

lookang
49 Posts
|
thanks prof wolfgang! i learnt a lot from the source :)
Post edited March 3, 2013 at 10:44 PM EST.
http://weelookang.blogspot.sg
|
|