Pictures created with Codea

If you want to have a look, please enjoy. Really amazing what kind of effects are doable …

http://crazyed.posterous.com/pic1
http://crazyed.posterous.com/pic2
http://crazyed.posterous.com/pic3
http://crazyed.posterous.com/pic4
http://crazyed.posterous.com/pic5
http://crazyed.posterous.com/eye-in-the-sky

Very cool looking. I would particularly like to see the code that did 1 and 4 if you can.

and the others! all are amazing!!

This really are lovely. I’m using the first one as a background on my iPad.

These are awesome @CrazyEd. How did you get the additive blending effect in pic1? Particularly the way the middle lights up.

Wow. That’s awsome! It would e great if you shared the code for them. If its alright with you, I have some awsome ideas for it.

I played around with the HSV settings instead of RGB. The code below shows also the converter. The code is here, feel free to modify it. I was thinking using such technique to create the background for a theme.

The commented lines for x and ellipse can be used to create pics1 to 5. Any suggestions, improvements are more than welcome.

The code was inspired by a processing routine which I found here (look last example)
http://lernprocessing.wordpress.com/2010/01/11/zufall/

@Simeon: this galaxy alike effect was done by adding a second ellipse (currently disabled).

function setup()
    print("Just for fun")
    background(0)
    backingMode(RETAINED); displayMode(FULLSCREEN)
    smooth(); noStroke()
    z = 0.0; next= math.pi/2; frame=0; limit=700
end

function draw()
    while next<limit do
        pushMatrix()
            translate(WIDTH/2, HEIGHT/2)
            x = (5+noise(z) * 10)
            --x = math.tan(0+noise(z) * 4.2)
            --x = math.log(math.tan(0+noise(z) * 4.2))*4
            --x = math.log(math.tan(0+noise(-0.5,-0.5,z) * 5))*1.6
            h=(frame%360)/360; s=1; v=1
            r,g,b=hsv2rgb(h,s,v); fill(r,g,b,50)
            ellipse (next*math.sin(next)+x,next*math.cos(next)+x, 5*x, 5*x)
            --ellipse (next*math.sin(next)+x,math.sin(next)*math.cos(next)+x, 5*x, 5*x)
            z=z+0.01; next = next+0.1; frame = frame + 0.5
        popMatrix()
    end
end

function hsv2rgb(H, S, V)
    -- H, S, V is allowed having values between [0 ... 1].
    
    H=6*H; I=math.floor(H - 0.000001); F=H-I  
    M=V*(1-S); N=V*(1-S*F); K=V*(1-S*(1-F))
   
    if I<=0 then
        R=V; G=K; B=M
    elseif I==1 then
        R=N; G=V; B=M
    elseif I==2 then
        R=M; G=V; B=K
    elseif I==3 then
        R=M; G=N; B=V
    elseif I==4 then
        R=K; G=M; B=V
    elseif I==5 then
        R=V; G=M; B=N
    end

    return math.floor(R*255), math.floor(G*255), math.floor(B*255)

end

@CrazyEd… Thanks for the wonderful images and code (I’m especially grateful for the timely appearance of the HSV function)!

This one generates Pic1.

I more or less stumbled by accident over that, when playing around with those functions. Note that in this function only the commented pieces have changed …

function draw()
    while next<limit do
        pushMatrix()
            translate(WIDTH/2, HEIGHT/2)
            --x = (5+noise(z) * 10)
            --x = math.tan(0+noise(z) * 4.2)
            x = math.log(math.tan(0+noise(z) * 4.2))*4
            --x = math.log(math.tan(0+noise(-0.5,-0.5,z) * 5))*1.6
            h=(frame%360)/360; s=1; v=1
            r,g,b=hsv2rgb(h,s,v); fill(r,g,b,50)
            ellipse (next*math.sin(next)+x,next*math.cos(next)+x, 5*x, 5*x)
            ellipse (next*math.sin(next)+x,math.sin(next)*math.cos(next)+x, 5*x, 5*x)
            z=z+0.01; next = next+0.1; frame = frame + 0.5
        popMatrix()
    end
end


@Blanchot. Believe it or not, but you brought me towards the idea of inspecting the Processing world (yesterday’s post of you). So I did. The code fragments are really wonderful and give lots of hints what to do with Codea as well. The HSV converter (hope I coded that correctly) was something I wanted to have anyway. There are so many different color schemes up and running, and I simply wanted to see the difference between those. Never thought that HSV is able to create such pictures - that was really a surprise to me.

The reason I asked for the code was because I was wondering if I could make an app that basically asks you for a function of where to draw the images, the number of times, start scale, and end scale. It would be a great a wall paper maker. I’d also add different images. If I could build it off your image maker, that would be great. Let me know if it’s ok with you. Thanks!

@Zoyt: just go ahead. Would be nice to see what you are going to use that for.

This is a great “if I ever need to do this start here” thread

Alright. I’ll see what I can do. Thanks!

The HSV converter (hope I coded that correctly) was something I wanted to have anyway. 

@CrazyEd… I don’t pretend to understand your converter function but I find that it works just fine (see below). As I am sure you know – a hue circle is very useful for calculating complimentary colors and palettes. Thanks again!

function setup()
    img=image(360,50)
    for x=1,360 do
        r,g,b=hsv2rgb(x/360,1,1)
        for y=1,50 do
            img:set(x,y,r,g,b)
        end
    end
end

function draw()
    background(0, 0, 0)
    sprite(img, WIDTH/2,HEIGHT/2)
end

function hsv2rgb(H, S, V)
    -- H, S, V allows values between [0 ... 1]
    -- Coded by @CrazyEd
    
    H=6*H; I=math.floor(H - 0.000001); F=H-I  
    M=V*(1-S); N=V*(1-S*F); K=V*(1-S*(1-F))
   
    if I<=0 then
        R=V; G=K; B=M
    elseif I==1 then
        R=N; G=V; B=M
    elseif I==2 then
        R=M; G=V; B=K
    elseif I==3 then
        R=M; G=N; B=V
    elseif I==4 then
        R=K; G=M; B=V
    elseif I==5 then
        R=V; G=M; B=N
    end

    return math.floor(R*255), math.floor(G*255), math.floor(B*255)

end

@Blanchot: Thanks for the bar plot. Just for fun I have combined now both of them, hsvcircle and hsvbar.


setInstructionLimit(0)

function setup()
    hsvcircle()
    hsvbar()
end

function draw()
    background(0, 0, 0)
    sprite(hsvcircle, WIDTH/2,HEIGHT/2+100)      
    sprite(hsvbar, WIDTH/2,HEIGHT/2-100)   
end

function hsv2rgb(H, S, V)
    -- H, S, V allows values between [0 ... 1]
    
    H=6*H; I=math.floor(H - 0.000001); F=H-I  
    M=V*(1-S); N=V*(1-S*F); K=V*(1-S*(1-F))
   
    if I<=0 then
        R=V; G=K; B=M
    elseif I==1 then
        R=N; G=V; B=M
    elseif I==2 then
        R=M; G=V; B=K
    elseif I==3 then
        R=M; G=N; B=V
    elseif I==4 then
        R=K; G=M; B=V
    elseif I==5 then
        R=V; G=M; B=N
    end

    return math.floor(R*255), math.floor(G*255), math.floor(B*255)

end

function hsvbar()
    hsvbar=image(360,50)
    for x=1,360 do
        r,g,b=hsv2rgb(x/360,1,1)
        for y=1,50 do
            hsvbar:set(x,y,r,g,b)
        end
    end
end

function hsvcircle()
    r0=100
    fac=4; maxangle=fac*360    -- needed for better resolution
    hsvcircle=image(2*r0+1,2*r0+1)
    for angle=1,maxangle do
        r,g,b=hsv2rgb(angle/maxangle,1,1)
        for rr=0, r0 do
            x=r0+1 + rr*math.cos(math.rad(angle/fac))
            y=r0+1 + rr*math.sin(math.rad(angle/fac))
            hsvcircle:set(x,y,r,g,b)
        end
    end
end

Just for fun I have combined now both of them, hsvcircle and hsvbar.

Nice!

@CrazyEd… have you, perchance, coded an RGB to HSV converter?

I have updated a new figure called “eye-in-the-sky”

@Blanchot: not yet, but I can do so. Just give me some time (weekend?)

@CrazyEd… That would be wonderful but there is absolutely no rush… so please take your time…

@Blanchot: please try this one. Maybe it would be good to change also hsv2rgb such to accept h in range 0° to 360° and s,v having values between 0 and 100%, to be consistent.

function rgb2hsv(R, G, B)
    -- R, G, B allows values between [0 ... 255]
    -- H has values between 0° and 360°
    -- S and V are between [0 ... 1]
    local max, min, rr, gg, bb = 0, 0, false, false, false
    max=math.max(r,g,b)
    min=math.min(r,g,b)
    
    rr = r==max; gg = g==max; bb = b==max

    if max==min then
        H=0
    elseif rr==true then
        H=0+(G-B)/(max-min)
    elseif gg==true then
        H=2+(B-R)/(max-min)
    elseif bb==true then
        H=4+(R-G)/(max-min)
    end
    
    H=H*60   
    if H<0 then
        H=H+360
    end

    if max==0 then
        S=0
    else
        S=(max-min)/max
    end
    
    V = max/255
    
    return H, S, V
end