Fun With Circles

@kendog400 Like this.

displayMode(FULLSCREEN)

function setup()
    ellipseMode(CENTER) 
    strokeWidth(3)
    t=ElapsedTime
    backingMode(RETAINED)
end

function draw()
    --background(0)
    if ElapsedTime>t+1 then      -- 1 second delay
        colr=color(math.random(255),math.random(255),math.random(255))
        fill(colr)
        t=ElapsedTime
        ellipse(math.random(WIDTH),math.random(HEIGHT),300,200)
    end
end

Another question : does codea have overlay modes like in photoshop’s ?..

Not sure what photoshop does. You can create multiple pages and display one over the other or move one in relation to the other.

@kendog400 - Codea does have overlays. You can specify them, I think they may be called levels - possibly z level, haven’t actually used them. Look in the graphics section of the reference within the Codea app or on the web.

Edit - just checked the web ref and it’s zlevel, check it out.

I checked and codea has 3 blend modes, normal, additive, and multiply…

While we’re on the subject, here’s a program I wrote long ago. It creates random colored circles and grows them a random size or until they touch another circle.

displayMode(FULLSCREEN)

function setup()
    tab={}
    x=math.random(WIDTH)
    y=math.random(HEIGHT)
    d=math.random(20,80)
    table.insert(tab,vec3(x,y,d))
    col={}
    table.insert(col,color(math.random(255),math.random(255),math.random(255)))
    makeCircle=true
    growCircle=false
end

function draw()
    background(0)
    for a,b in pairs(tab) do
        fill(col[a])
        ellipse(b.x,b.y,b.z)
    end
    if makeCircle then
        x=math.random(WIDTH)
        y=math.random(HEIGHT)
        d=0
        table.insert(tab,vec3(x,y,d))
        table.insert(col,color(math.random(255),math.random(255),math.random(255)))
        checkLimit(x,y)
    end
    if growCircle then
        tab[#tab].z=tab[#tab].z+1  
        if tab[#tab].z>size then
            growCircle=false
            makeCircle=true
        end
    end
end

function checkLimit(x,y)
    --print("checklimit")
    d=9999
    for a,b in pairs(tab) do
        if a<#tab then
            v1=vec2(x,y)
            dis=v1:dist(vec2(b.x,b.y))
            if dis<b.z/2 then
                table.remove(tab,#tab) 
                table.remove(col,#col)
                makeCircle=true  
                growCircle=false           
                return
            else
                dis=dis-b.z/2
                if dis<d then
                    d=dis
                end
            end
        end  
    end
    size=d*2+4
    if size>160 then
        size=math.random(20,80)
    end 
    makeCircle=false
    growCircle=true           
end

@kendog400 - those modes are for merging graphics, is that what you need? The zlevel is for 2D overlapping of graphics so you can move graphics in 2.5D formats to simulate 3D without interfering with graphics in other levels.

Yes, I’m looking to blend and merge to spice up animations…

@kendog400 - if you search the forum for blend modes you should find several goods demos on this. Needed them recently to cut out a circle within a built up graphic.

I did check the blend modes and only the additive one worked, .multiply didn’t work…So I’ll take that with a smile…

@kendog400 - did you check out the following thread?

Blendmode Demos

Demos there for you.

I’m trying to get a flower to spin (from the center), I tried putting into a table, but still no dice…take a peek anyone…I think I might need a couple of pushes & pops…

Here’s an example.

displayMode(STANDARD)

function setup()   
    parameter.integer("nbr",50,150,100)
    parameter.integer("step",2,180,40)
    parameter.integer("size",2,30,10)
    ang=0
end

function draw()
    background(50, 53, 27)
    createLines()
    for a,b in pairs(tab) do
        fill(math.random(255),math.random(255) ,math.random(255))
        ellipse(WIDTH/2+b.x,HEIGHT/2+b.y,b.z)        
    end  
end

function createLines()
    tab={}
    ang=ang+.1
    for z=1,nbr do
        for a=0,360,step do
            x=math.cos(math.rad(ang*z+a))*size*z
            y=math.sin(math.rad(ang*z+a))*size*z
            table.insert(tab,vec3(x,y,(nbr-z)/6))  
        end
    end
end