Howdy, Stranger!

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

Problem with painting

in Examples Posts: 4

Hi,
I want to make a painting programm.
I want to Draw a ellipse where the user touch (I know that it works with CurrentTouch.x and CurrentTouch.y)
The Problem is because of the draw Funktion Starts again and again the Circle goes away.
I want the Circle still there so that you can draw something.

Tagged:

Comments

  • dave1707dave1707 Mod
    edited August 1 Posts: 6,230
    displayMode(FULLSCREEN)
    
    function setup()
        pos={}  -- x,y position
    end
    
    function draw()
        background(0)
        fill(255,0,0)
        for a,b in pairs(pos) do
            ellipse(b.x,b.y,40,20)  
        end 
    end
    
    function touched(t)
        if t.state==BEGAN then
            table.insert(pos,vec2(t.x,t.y))
        end
    end
    
  • dave1707dave1707 Mod
    Posts: 6,230

    @lidddl You can find a lot of information/examples by doing a forum search. The search area is at the top right above the New Discussion box.

  • Posts: 78

    Get rid of the background function in draw()

  • dave1707dave1707 Mod
    edited August 1 Posts: 6,230

    Here's a simple painting program. You can change the color and line size. Just drag your finger around the screen.

    function setup()
        backingMode(RETAINED)
        parameter.color("col",255)
        parameter.integer("size",2,40,2)    
    end
    
    function draw()
        if dr then
            stroke(col)
            strokeWidth(size)
            line(bx,by,tx,ty)
            bx,by=tx,ty
        end
    end
    
    function touched(t)
        if t.state==BEGAN then
            bx,by=t.x,t.y
        end 
        if t.state==MOVING then
            dr=true
            tx,ty=t.x,t.y
        end
        if t.state==ENDED then
            dr=false
        end
    end
    
  • Posts: 4

    Thank you for your answers.I will try it

Sign In or Register to comment.