java - How to create clickable lines in android -
if utilize line :
canvas.drawline(stx,sty, spx,spy);
how can later observe illustration motionevent
whether line touched or not? let's assume line not straight.
i know there things rect
or rectf
can handle events can't draw slope lines.
maybe suggest me alternative method draw lines object used handle events...
well after night research seems way go switch canvas opengl es api.
and yet foul trail...but after giving sec though if have
line ( point ( x1, y1 ), point2 ( x2, y2))
like loving mother, math
comes understanding , simple answare, simple line of code can determine wheather event point contained in line
:
(x2 - x1)(eventy - y1) = (y2 - y1) (eventx - x1);
to blur touch area can add:
for(int = -10; i<10;i++){ for(int j=-10; j<10; j++){ if((x2 - x1)*(eventy+i - y1) == (y2 - y1)* (eventx+j - x1)) homecoming true;}}
java android canvas graphics event-handling
No comments:
Post a Comment