Trace of points from Java script

Igal.Sapir shared this question 5 years ago


I have a simple GeoGebra applet where points are randomly chosen in a Java Script.

The purpose of the script is to fill an area with different colors according to certain conditions by Tracing these random points

The point's color changes according to these conditions.

In order to speed the filling of the area I have a Turbo mode that makes the Java script loop through 1000 points each time it is activated.

It works perfectly in GeoGebra 4.2.6 but does not work in GeoGebra 5.

In version 5 the 1000 points generated inside the Java script do not generate a Trace color.

Is there a way to make these points generate a Trace color?

I attach a Demo applet to demonstrate the problem.

The point R is the Random point and it changes color acording to the Quadrant it is in: Green, Red, Turqoise, Magenta for I, II, III, IV accordingly.

The points are randomized in the VRectangle only

Pushing Run starts the Randomization using the number Randomiser

Everything is done in the On Update script of Randomiser:

Pushing Turbo makes the Java script loop 1000 times

Here are the 3 lines of code that do this:

    count = ggbApplet.getValue("TurboF") ? 1000 : 1

    for (i=0; i<count; i++)

    ggbApplet.evalCommand("SetValue[R, V1 + RandomUniform[0,1] (V2-V1) + RandomUniform[0,1] (V4-V1)]")

I really need this to work for a Math workshop I am doing in a week.

I did not know it stopped working so now this is urgent

Please help!

Thank you


Comments (1)


Hi Igal

In the attachment a solution without JS.

I think she is more quickly than JS


The slider initiate with each step the recalculation of a list with 200 random points (max 500).

If TurboF is OFF then all Elements with index > 1 are undefined else all are defined.

The spreadsheet get all points of list in the cells B_n (using cells A_n as index)

The point in cells B_n are visible, has trace ON and use the same advanced color setting.



© 2021 International GeoGebra Institute