1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

Bigger then & Smaller Then

Posted by Melan on Apr 21, 2007

hi all,

Are these 2 mathematical instructions in NodeBox written like this >= and


 
Posted by Melan on Apr 21, 2007

Uh, doesn't seem to work.

Well, i want a circle to grow bigger to certain amount of size (lets say 25) and then get smaller till he reaches 0. Then it should grow bigger again.

How do i create a loop like that ?

Below is wrong, because as from the moment it's counting down, its below the value of 25 and gets stuck between adding 0.4 and substracting 0.4.

if diameter



Posted by Melan on Apr 21, 2007

if diameter



Posted by Melan on Apr 21, 2007

Arghh, code doesn't work here really well.



Posted by tom on Apr 21, 2007

Hi Melan,

There was a bug in the forum when you used <= and => but that's hopefully solved now.

As to your question, the trick is to keep a direction variable which is 1 when the loop is going up and -1 when the loop is going down:

# Initialise at the top of your script.
direction = 1
diameter = 0
 

# The actual increment:
if diameter < 0 or diameter >= 25:
    direction = -direction
diameter += 0.4 * direction