line pointing a direction with touch

How would I make a line point towards the place I touch?

I’m on an iPhone, so this may work

line(0,0,CurrentTouch.x,CurrentTouch.y)

line at 200,200 wih length 100:

function draw()
    background(0)
    local p = vec2(200,200)
    local v = (vec2(CurrentTouch.x,CurrentTouch.y)-p):normalize()
    local p2 = p + v*100
    fill(255, 255, 255, 255)
    strokeWidth(10)
    line(p.x,p.y, p2.x, p2.y)
end

@CodeaNoob i thought that would work too but that makes the line extend all the way to the touch point.
@tnlogy thanks a lot that worked

This post reminded me of something I used to see on PC’s a long time ago. Of course it was a lot smaller and at the bottom of the screen.


supportedOrientations(LANDSCAPE_ANY)
displayMode(FULLSCREEN)

function setup()
    rectMode(CENTER)
    p1={vec2(WIDTH*.33,HEIGHT/2),vec2(WIDTH*.66,HEIGHT/2)}
    p2={vec2(WIDTH*.33,HEIGHT/2),vec2(WIDTH*.66,HEIGHT/2)}
end

function draw()
    background(40, 40, 50)
    fill(255)
    text("Slide your finger around the screen",WIDTH/2,HEIGHT-50)
    noFill()
    stroke(255,0,0)
    strokeWidth(5)
    fill(223, 202, 164, 255)
    rect(WIDTH/2,HEIGHT/2,600,250)
    for z=1,2 do
        fill(255)
        stroke(255)
        ellipse(WIDTH*.33*z,HEIGHT/2,200)
        noStroke()
        fill(0, 24, 255, 255)
        ellipse(p2[z].x,p2[z].y,80)
    end
end

function touched(t)
    if t.state==BEGAN or t.state==MOVING then
        for z=1,2 do
            p2[z]=p1[z]+(vec2(t.x,t.y)-p1[z]):normalize()*60
        end
    end
    if t.state==ENDED then
        setup()
    end
end

@Joey72099 a forum search or a look at some of the tutorials would have shown you how