Function-Draw Problem

Hello guys, I’ve go a problem, with my code. I want to create an interface for my first app, but there is one problem, that I don’t know how this works, because if I write the fill function to the text, the rect color changed. An I don’t know, how the zLevel function works here :frowning:
Can you please help me? Please try this code.

function setup()
end

function draw()

background(61, 62, 92, 255)

--rect
rect(0, 690, 1024, 200)
fill(0, 0, 0, 98)

--stroke
stroke(0, 0, 0, 255)
strokeWidth(1)
line(0, 690, 1024, 690)

--text
font("Futura-Medium")
fill(255, 255, 255, 255)
fontSize(40)
textWrapWidth(1000)
text("Fahndung Pro Deutschland", 512, 730)  

--textfield Land
rect(345, 300, 300, 50)

end

The user and all related content has been deleted.

Ok :slight_smile:


displayMode(FULLSCREEN)

function setup()
    getImg()
end

function draw()
    background(40, 40, 50)
    fill(255)
    if img==nil then
        text("Loading image",WIDTH/2,HEIGHT/2)
    else
        sprite(img,WIDTH/2,HEIGHT/2,700)
    end
end

function getImg()
    http.request('https://dl.dropboxusercontent.com/s/3149mj9xjx1w71e/Costa Rican Frog.jpg',gotImage)
end

function gotImage(image,status,header)
    img=image
end

The user and all related content has been deleted.

Uhh Sorry wrong code #-o
Here,

background(61, 62, 92, 255)

--rect
rect(0, 690, 1024, 200)
fill(0, 0, 0, 98)

--stroke
stroke(0, 0, 0, 255)
strokeWidth(1)
line(0, 690, 1024, 690)

--text
font("Futura-Medium")
fill(255, 255, 255, 255)
fontSize(40)
textWrapWidth(1000)
text("Fahndung Pro Deutschland", 512, 730)  

--textfield Land
rect(345, 300, 300, 50)

The user and all related content has been deleted.

Can you please tell me how I can do this, becaus I’m very new here :slight_smile:

@hallomio77 Not sure what you’re doing, but you need to set the fill color before each item you want changed. Also, you need to set the noStroke after stroke to prevent it from show on other items.


supportedOrientations(LANDSCAPE_ANY)

function draw()
    background(61, 62, 92, 255)
    
    --rect
    fill(255, 0, 0, 98)
    rect(0, 690, 1024, 200)
   
    --stroke
    stroke(255, 255, 255, 255)
    strokeWidth(5)
    line(0, 690, 1024, 690)
    noStroke()
    
    --text
    fill(255, 255, 255, 255)
    font("Futura-Medium")
    fontSize(40)
    textWrapWidth(1000)
    text("Fahndung Pro Deutschland", WIDTH/2, 730)  
    
    --textfield Land
    fill(0, 255, 62, 255)
    rect(345, 300, 300, 50)
end

Hi @hallomio77, I’m a noob coder, but tried your code and found that the URL you’re using could be the issue as it contains spaces in the file name.

I might be wrong, but this should be more or less what ( I think ) you are looking for :



displayMode(FULLSCREEN)
local Image
function setup()
    getImg()
end

function draw()
background(61, 62, 92, 255)

pushStyle()
--rect
rect(0, 690, 1024, 200)
fill(0, 0, 0, 98)
popStyle()
    
pushStyle()
--stroke
stroke(0, 0, 0, 255)
strokeWidth(1)
line(0, 690, 1024, 690)
popStyle()

pushStyle()    
--text
font("Futura-Medium")
fill(255, 255, 255, 255)
fontSize(40)
textWrapWidth(1000)
text("Fahndung Pro Deutschland", 512, 730)  
popStyle()
--textfield Land
rect(345, 300, 300, 50)

pushStyle()
if Image ~= nill then
sprite(Image,200,HEIGHT/2,300,600)
end
popStyle()
end

function getImg()
    http.request("http://gdeluxe.com/wp-content/uploads/2011/08/osx-lion-wallpaper-andromeda.jpg", gotImage)

end

function gotImage(img)
Image=img
sound(SOUND_BLIT, 29826)
end


Hope this helps, regards

Codea reads your code from the top to the bottom, so you’re drawing a rectangle over your text. Also, you can call fill() multiple times to change the colors of multiple objects. Like this:

background(61, 62, 92, 255)

--rect
fill(0, 0, 0, 98)
rect(0, 690, 1024, 200)

--stroke
stroke(0, 0, 0, 255)
strokeWidth(1)
line(0, 690, 1024, 690)

--textfield Land
--Draw the rectangle first, it's the background
fill(255, 0, 0, 255) -- Change the color to red
rect(345, 300, 300, 50) -- Draw a rectangle (uses the last specified fill(), so in this case red)

--text
--Then draw the text afterwards, on top of the rectangle
font("Futura-Medium")
fill(255, 255, 255, 255) -- Change the next color to white
fontSize(40)
textWrapWidth(1000)
text("Fahndung Pro Deutschland", 512, 730) -- Draw some text (uses the last specified fill() yet again, so in this case white)