Anfängerfrage: Wie kann ich JavaScript zur Ausführung bringen?

UlrichA shared this question 2 years ago
Answered

Hallo,

ich habe bei den GeoGebra-Beispielen den Bresenham-Algorithmus gefunden, Quelle:

https://www.geogebra.org/m/C8s7ywhb


Dort sind JavaScript-Befehle aufgelistet. Wie kann ich diese Befehle

über das GeoGebra-Desktop-Programm ausführen?

Ich hätte z.B. über das Menü eine Import-Funktion erwartet.

Comments (2)

photo
1

This is pseudo-code not JavaScript

x_=0, y_= r, d_ = 3-2r solange (x_<=y_) { zeichne (x_y_) wenn (d_<0) { d_= d_+4x_+6 } sonst { d_=d_+4(x_-y_)+10, y_-- } x_++ }

photo
1

This is the JavaScript that the button runs

var e=[];

rad=ggbApplet.getValue("r");

x=0;

y=rad;

d=3-2*rad;

z=0;

while(x<=y) {

e.push([x,y]);

e.push([y,x]);

e.push([y,-x]);

e.push([x,-y]);

e.push([-x,-y]);

e.push([-y,-x]);

e.push([-y,x]);

e.push([-x,y]);

z+=8;

if (d<0) { d = d+4*x+6 }

else {

d=d+4*(x-y)+10;

y--;

}

x++;

}

ggbApplet.setValue("n",z);

for (var i=1;i<z;i++) {

ggbApplet.evalCommand("Kaestchen[("+e[i][0]+","+e[i][1]+")]")

}

© 2023 International GeoGebra Institute