Howdy, Stranger!

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

In this Discussion

FPS dial

dave1707dave1707 Mod
in Code Sharing Posts: 6,397

I had nothing better to do, so here's some useless code. It's a frames per second dial. Slide the parameter to change the for loop value to put a load on the draw function. You can change the x,y position, the radius of the circle, and the step value for the dial numbers. I don't see a real use for this, but it was something to do.

function setup()
    parameter.integer("val",0,20,2)
    lineCapMode(SQUARE)
end

function draw()
    background(0)
    fps=1/DeltaTime
    fpsDial(WIDTH/2,HEIGHT/2,400,fps,2)
    for z=1,val*100000 do
        s=math.sqrt(z)
    end
end

function fpsDial(x,y,r,f,s)   -- x-pos, y-pos, radius, fps, step
    pushMatrix()
    pushStyle()
    noFill()
    stroke(255, 0, 0, 255)
    strokeWidth(15)    
    ellipse(x,y,r)    
    translate(x,y)
    rotate(f*5)
    stroke(0, 255, 0, 255)
    strokeWidth(5)
    line(0,0,r/2-15,0)
    popStyle()
    popMatrix()
    fill(0, 70, 255, 255)
    ellipse(x,y,45)
    fill(255)
    text(string.format("%.1f",f),x,y)
    for z=0,70,s do
        sx=math.cos(math.rad(z*5))*(r/2+10)
        sy=math.sin(math.rad(z*5))*(r/2+10)
        text(z,x+sx,y+sy)
    end    
end

Comments

  • Posts: 50

    @dav1707 I think it's great and I think the idea could be used for debugging, to slow down the action to help see what's going on.

Sign In or Register to comment.