I had this idea already weeks ago, but now I had the time to realize it.

I had this idea already weeks ago, but now I had the time to realize it.

Now its far enough to be shown. It’s nothing ready or save, more a preview.

It’s free Gesture drawing.

It gets slower with more gestures saved, I don’t know where the maximum is.

]]>

16 Commentsto I had this idea already weeks ago, but now I had the time to realize it.

  1. Anonymous says:

    < ![CDATA[

    //config


    var tolerance=7;


    var itemID=0x070001;


    var bgColor=0x00000000;


    var gestureColor=0xffffffff;


    //endconfig



    if(typeof add===’undefined’)add=null;


    try{


    switch(event.getAction())


    {


    case MotionEvent.ACTION_DOWN:


    gestures=JSON.parse(item.getTag())||[];


    for(var a=0;a


    {


    if(LL.getItemById(gestures[a][1])==null)gestures.splice(a,1);


    }


    item.setTag(JSON.stringify(gestures));


    paint=new Paint(Paint.ANTI_ALIAS_FLAG);


    paint.setColor(gestureColor);


    paint.setStrokeWidth(5);


    paint.setStrokeJoin(Paint.Join.ROUND);


    image=item.getBoxBackground(“n”);


    if(image.getWidth()!=item.getWidth()||image.getHeight()!=item.getHeight())image=LL.createImage(item.getWidth(),item.getHeight());


    canvas=image.draw();


    image.getBitmap().eraseColor(Color.TRANSPARENT);


    canvas.drawColor(bgColor);


    this.gesture=[];


    this.gesture.push([event.getX(),event.getY()]);


    break;


    case MotionEvent.ACTION_MOVE:


    this.gesture.push([event.getX(),event.getY()]);


    canvas.drawLine(this.gesture[this.gesture.length-2][0],this.gesture[this.gesture.length-2][1],event.getX(),event.getY(),paint);


    image.update();


    break;


    case MotionEvent.ACTION_UP:


    this.gesture.push([event.getX(),event.getY()]);


    canvas.drawLine(this.gesture[this.gesture.length-2][0],this.gesture[this.gesture.length-2][1],event.getX(),event.getY(),paint);


    if(add!=null)


    {


    gestures.push([scaleGesture(this.gesture),add]);


    item.setTag(JSON.stringify(gestures));


    add=null;


    Android.makeNewToast(“Saved!”,true).show();


    }


    else


    {


    var sg=scaleGesture(this.gesture);


    schleife:for(var x=0;x


    {


    var sp=gestures[x][0];


    var gesDiff=0;


    for(var i=0;i


    {


    var p0=sg[i];


    var diff=200;


    for(var a=Math.round((i/sg.length)*sp.length)-Math.round(sp.length/4)<0?0:Math.round((i/sg.length)*sp.length)-Math.round(sp.length/4);a< =Math.round((i/sg.length)*sp.length)+Math.round(sp.length/4)&&a


    {


    var p1=sp[a];


    var newDiff=Math.sqrt(Math.pow(p0[0]-p1[0],2)+Math.pow(p0[1]-p1[1],2));


    if(newDiff


    {


    diff=newDiff;


    }


    }


    if(diff>tolerance*4)


    {


    continue schleife;


    }


    gesDiff=gesDiff+diff;


    }


    if(gesDiff/sg.length


    {


    break;


    }


    }


    if(x==gestures.length)Android.makeNewToast(“No gesture detected”,true).show();


    else LL.startActivity(LL.getItemById(gestures[x][1]).getIntent());


    }


    image.getBitmap().eraseColor(Color.TRANSPARENT);


    canvas.drawColor(bgColor);


    image.save();


    item.setBoxBackground(image,”n”);


    break;


    }


    }


    catch(NullPointerException)


    {


    gestures=JSON.parse((LL.getItemById(itemID)).getTag())||[];


    for(var a=0;a


    {


    if(LL.getItemById(gestures[a][1])==null)gestures.splice(a,1);


    }


    event=LL.getEvent();


    for(var a=0;a


    {


    if(gestures[a][1]==event.getItem().getId())


    {


    if(!confirm(“This shortcut has already a gesture. Do you want to replace it?”))return;


    gestures.splice(a,1);


    break;


    }


    }


    LL.getItemById(itemID).setTag(JSON.stringify(gestures));


    Android.makeNewToast(“The next drawn Gesture will be set to this shortcut”,true).show();


    add=event.getItem().getId();


    }



    function scaleGesture(GESTURE)


    {


    var maxx=0,minx=item.getWidth(),maxy=0,miny=item.getHeight();


    for(var i=0;i


    {


    if(GESTURE[i][0]


    if(GESTURE[i][0]>maxx)maxx=GESTURE[i][0];


    if(GESTURE[i][1]


    if(GESTURE[i][1]>maxy)maxy=GESTURE[i][1];


    }


    var scaled=[];


    for(var i=0;i


    {


    scaled.push([(GESTURE[i][0]-minx)/(maxx-minx)*100,(GESTURE[i][1]-miny)/(maxy-miny)*100]);


    }


    return scaled;


    }

    ]]>

  2. Anonymous says:

    < ![CDATA[

    Amazing!



    I am impressed.

    ]]>

  3. Anonymous says:

    < ![CDATA[

    Beautiful work… Im interested to know about your app drawer too

    ]]>

  4. Anonymous says:

    < ![CDATA[

    Hammer


    🙂

    ]]>

  5. Anonymous says:

    < ![CDATA[

    Impressive. What is the live Wallpaper ?

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Xavier Nicaise


    audio glow lwp

    ]]>

  7. Anonymous says:

    < ![CDATA[

    ‘Schleife’


    Ah! So you can continue a ‘for’ inside another ‘for’…impressed. Didn’t know.


    Good job.

    ]]>

  8. Anonymous says:

    < ![CDATA[

    the name doesn’t matter, you can use any other name (beside reserved ones).


    ‘schleife’ just  maens loop in german 😀


    BTW: this works also with break

    ]]>

  9. Anonymous says:

    < ![CDATA[

    when changing the itemID is that for the gesture shortcut we created?

    ]]>

  10. Anonymous says:

    < ![CDATA[

    Curtis Sylvester Jr.


    yes.

    ]]>

  11. Anonymous says:

    < ![CDATA[

    then something is wrong because i created my shortcut, grabbed its ID and put it in the script. then i ran the script from [choose app shortcut here] (which flashed a notice for next drawing being saved), i went to draw my gesture to save and the same notice came up again…. this time taking about 5 minutes to shut up. the gesture never got saved

    ]]>

  12. Anonymous says:

    < ![CDATA[

    I haven’t tried this script for a while, maybe it’s broken in the current version… My phone is broken ATM, I can’t try.

    ]]>

  13. Anonymous says:

    < ![CDATA[

    I added it from the repository importer as the instructions say but when I swipe over it it says “At line 56: missing ; after for-loop condition”. How do I fix it? Also what is the proper way to change the itemID?


    Edit: I added the script in the first comment & now I’m having the same problem as Curtis Sylvester Jr.​ What’s wrong?

    ]]>

  14. Anonymous says:

    < ![CDATA[

    bahrta sai


    i could not reproduce the error. And honetly, I haven’t looked at this script for more than a year, I have no idea if it will work in the current version.

    ]]>

  15. Anonymous says:

    < ![CDATA[

    bahrta sai​ do you have the latest version of repository importer?


    If so, what your line 56 look like? 

    ]]>

  16. Anonymous says:

    < ![CDATA[

    bahrta sai the script in the first comment is outdated. I am currently rebuilding this functionality from scratch as part of my MultiTool. Are you interested in testing it?

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *