making Trace in 2D that can have different memory colors, currently it can only show static one colo
lookang
244 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".
Re: making Trace in 2D that can have different memory colors, currently it can only show static one colo -
Francisco Esquembre
238 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.
Re: Re: Re: Re: making Trace in 2D that can have different memory colors, currently it can only show static one colo -
lookang
244 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!