Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Help with changing multiple parameters proportionally

edited November 6 in Questions Posts: 15

So I have two parameters: Diameter and StrokeSize. The way I want this to work is when the Diameter is at it’s maximum: 600, I want the StrokeSize to be 5, which is its maximum. Same for the minimum of the parameters.

How could this be done?

function setup()
    parameter.number("Diameter",10,600,50)
    parameter.number("StrokeSize",2.5,5,2.5)
end

function draw()
    background(0)

    strokeWidth(StrokeSize)

    stroke(150,255,150,255)

    noFill()
    ellipse(WIDTH/2,HEIGHT/2,Diameter)

    line(WIDTH/2,HEIGHT/2,WIDTH/2 + (Diameter/2 -4),HEIGHT/2)
end 

Comments

  • dave1707dave1707 Mod
    Posts: 8,671

    Are you going to do anything with the StrokeSize parameter. You can alter the StrokeSize based on the Diameter value and not use the StrokeSize parameter.

  • dave1707dave1707 Mod
    Posts: 8,671

    Here an example of changing the strokeWidth based on the Diameter size.

    viewer.mode=STANDARD
    
    function setup()
        parameter.number("Diameter",10,600,50)
        --parameter.number("StrokeSize",2.5,5,2.5)
    end
    
    function draw()
        background(0)
        strokeWidth(2.5+2.5*Diameter/600)    
        stroke(150,255,150,255)    
        noFill()
        ellipse(WIDTH/2,HEIGHT/2,Diameter)    
        line(WIDTH/2,HEIGHT/2,WIDTH/2 + (Diameter/2 -4),HEIGHT/2)
    end
    
  • Posts: 15

    Thanks again!

Sign In or Register to comment.