Пример #1
0
def poisson(r):
    setup_poisson(gridnumbers, cols, rows)
    if _adjustment.surpass_volume_poisson(1.02, Circles, ideal_volumes):
        while _adjustment.surpass_volume_poisson(
                1.02, Circles, ideal_volumes) and _adjustment.stop_recursion(
                    Circles, roundRadius):
            _adjustment.adjust_radius(-1, Circles, roundRadius)
        if not _adjustment.surpass_volume_poisson(1, Circles, ideal_volumes):
            _adjustment.adjust_radius(1, Circles, roundRadius)
    elif not _adjustment.surpass_volume_poisson(1, Circles, ideal_volumes):
        _adjustment.remove_particles(maximums[0], roundRadius[0], Circles)
        r = r - 10
        poisson(r)
def poisson(r):
	gradient = width / 100
	setup_poisson(gridnumbers, cols, rows)
	if _adjustment.surpass_volume_poisson(5, Circles, ideal_volumes):
		# volume surpasses the target by more than 20%, remove the particle and regenerate with a larger minimum radius
		_adjustment.remove_particles(maximums[0], roundRadius[0], Circles)
		if r + gradient < width:
			r = r + gradient
			poisson(r)
	elif _adjustment.surpass_volume_poisson(2, Circles, ideal_volumes):
		# volume surpasses the target by more than 2%, shrink the radius
		while _adjustment.surpass_volume_poisson(1.02, Circles, ideal_volumes) and _adjustment.stop_recursion(Circles, roundRadius):
			_adjustment.adjust_radius(-1, Circles, roundRadius)
		if not _adjustment.surpass_volume_poisson(1, Circles, ideal_volumes):
			_adjustment.adjust_radius(1, Circles, roundRadius)
	elif not _adjustment.surpass_volume_poisson(1, Circles, ideal_volumes):
		# volume does not reach the target, remove the particle and regenerate with a smaller minimum radius
		_adjustment.remove_particles(maximums[0], roundRadius[0], Circles)
		r = r - gradient
		poisson(r)