Script: Golden Ratio - Poyo-SSB/osu-playground GitHub Wiki

function start() {
	var center = Playground.AddVector2('center', new Vector2(Playground.PLAYFIELD_WIDTH / 2, Playground.PLAYFIELD_HEIGHT / 2));
	var rotation = Playground.AddFloat('rotation', 0);
    var radius = Playground.AddInt('radius', 20);
    var repetitions = Playground.AddInt('repetitions', 60);

	Playground.AddOptionVector2(center, 'Center');
	Playground.AddOptionFloat(rotation, 'Rotation', 1, 0, 360);
    Playground.AddOptionInt(radius, 'Radius', 1, 50);
    Playground.AddOptionInt(repetitions, 'Repetitions', 1, 100);
}

function update() {
	var center = Playground.GetValueVector2('center');
	var rotation = Playground.GetValueFloat('rotation');
    var radius = Playground.GetValueInt('radius');
    var repetitions = Playground.GetValueInt('repetitions');

    for (var i = 0; i < repetitions; i++) {
        var t = (2 * Math.PI * i) / (Math.PHI * Math.PHI);
        var r = radius * Math.sqrt(i);

        Playground.AddHitCircle(add(center, new Vector2(
            r * Math.cos(t + Math.PI * rotation / 180),
            r * Math.sin(t + Math.PI * rotation / 180)
        )));
    }
 }