Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

any example EJSS of color change from Math.floor((Math.random()*255)+1) post and replies

Return to the any example EJSS of color change from Math.floor((Math.random()*255)+1) thread
Login to post to this thread

any example EJSS of color change from Math.floor((Math.random()*255)+1) - Mar 27 at 11:22PM
lookang Avatar
lookang
107 Posts

any example EJSS of color change from Math.floor((Math.random()*255)+1)

i am trying to generate different color and different runs of the EJSS.

any easier method i can explore?

my current method used is not scalable. i have created arrays and make them visible when certain conditions are true. source: https://dl.dropboxusercontent.com/u/44365627/lookangEJSworkspace/export/ejss_src_SHMresonance01.zip

http://weelookang.blogspot.sg/2014/03/ejss-shm-model-with-resonance-showing.html

any examples in EJSS for me to study?

thanks!

 

Post edited March 27, 2014 at 11:23 PM EST.

Post edited March 27, 2014 at 11:26 PM EST.

Attached File: yjcresonanance_2014-03-24_1340.png


http://weelookang.blogspot.sg

Replies to any example EJSS of color change from Math.floor((Math.random()*255)+1)

Re: any example EJSS of color change from Math.floor((Math.random()*255)+1) - Apr 01 3:45PM
Francisco Esquembre
130 Posts

Hi LooKang,

Let me see if I understood well what you need.

a) you can use set a color to a (random) integer. EjsS will convert this into a color.

b) if you want dashed lines, play with the Atribute property of the graphic element.
Set it, for example, to { "stroke-dasharray":"8 4 2 4" }

You can read what tho smears here: http://www.w3schools.com/svg/svg_stroking.asp

Paco



Re: Re: any example EJSS of color change from Math.floor((Math.random()*255)+1) - Apr 02 4:29AM
lookang Avatar
lookang
107 Posts

a)  yes. it is the same request as http://www.compadre.org/osp/bulletinboard/TDetails.cfm?ViewType=2&TID=2457&CID=60085&#PID60089
in Java
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,....
  
  
  
}
but it does not work for JavaScript.
i eagerly await your exciting strategy to create newSegment() with different (random is easy) colors.
thanks!



b) yes. done. very nice.


http://weelookang.blogspot.sg


Re: Re: Re: any example EJSS of color change from Math.floor((Math.random()*255)+1) - Apr 08 3:33PM
Francisco Esquembre
130 Posts

LooKang,

You found a bug on the newSegment() function of the trail! We will fix it and let you know.

Paco



Re: Re: Re: Re: any example EJSS of color change from Math.floor((Math.random()*255)+1) - Aug 19 11:23PM
lookang Avatar
lookang
107 Posts

dear prof paco,

i eagerly awaits bug fix to
"_view.voltageTrail.newSegment();"

example of what i being trying to do
https://dl.dropboxusercontent.com/u/44365627/lookangEJSworkspace/export/ejss_model_SHMxvaverticalsensorsecondary/SHMxvaverticalsensorsecondary_Simulation.xhtml

3 different run but not working as designed :)

the color seems to still to the new value
source code attached

Attached File: ejss_src_SHMxvaverticalsensorsecondary.zip


http://weelookang.blogspot.sg


The OSP Network:
Open Source Physics - Tracker - EJS Modeling
Physlet Physics
Physlet Quantum Physics