One-hop php code implementation, php code
The example in this article shares the specific php hop code for your reference. The specific content is as follows:
<? Php require 'config. php '; function similar ($ rgb1, $ rgb2) {$ r1 = ($ rgb1> 16) & 0xFF; $ g1 = ($ rgb1> 8) & 0xFF; $ b1 = $ rgb1 & 0xFF; $ r2 = ($ rgb2> 16) & 0xFF; $ g2 = ($ rgb2> 8) & 0xFF; $ b2 = $ rgb2 & 0xFF; return abs ($ r1-$ r2) <10 & abs ($ b1-$ b2) <10 & abs ($ g1-$ g2) <10;} function getStart () {global $ image; $ width = imagesx ($ image ); $ height = imagesy ($ image); for ($ I = $ height/3; $ I <$ Height/3*2; $ I ++) {for ($ j = 0; $ j <$ width-75; $ j ++) {if (checkStart ($ I, $ j) {$ x = $ I; $ y = $ j + 37 ;}} return array ($ x, $ y);} function getEnd () {global $ image; global $ sx, $ sy; $ l_r = 0; $ cnt = 0; $ width = imagesx ($ image ); $ height = imagesy ($ image); for ($ I = $ height/3; $ I <$ sx; $ I ++) {$ demo = imagecolorat ($ image, 0, $ I); for ($ l = 0; $ l <$ width; $ l ++) {$ c = imagecolorat ($ Image, $ l, $ I); if (! Similar ($ c, $ demo) {$ r = $ l; while ($ r + 1 <$ width &&! Similar (imagecolorat ($ image, $ r + 1, $ I), $ demo) {$ r ++;} if (abs ($ l + $ r) /2-$ sy)> 20) {if (! Isset ($ mid) $ mid = ($ l + $ r)/2; if ($ r-$ l> BODY_WIDTH * 1.1) {if ($ r <= $ l_r) {$ cnt ++; if ($ cnt = 3) {return [$ I, round ($ mid)];} else {$ cnt = 0 ;}$ l_r = $ r ;}}$ l = $ r ;}}return [$ sx-round (abs ($ mid-$ sy) /sqrt (3), round ($ mid)]; ;}$ cheet = [2829129,282 9129, 2829129,282 9129, 2829387,296 0716, 2960461,296 0463, 3026256,302 6256, 3092563,309 2563, 3158614,315 3224408,329 0202,335 6252, 3356252,335 6252, 3356767,335 7024, 3553376,361 8913, 3618913,355 3891, 3684707,375 0243, 3684706,368 4707, 3684707,368 4707, 3750243,361 8914, 3618913,368 4450, 3750243,375 0243, 3750243,375 0243, 3750243,368 4706, 3618913,361 8913, 3618913,368 4450, 3684706,368 4706, 3684450,368 4450, 3750243,375 0243, 3684450,368 4706, 3750243,361 8913, 3618913,361 8913, 3684448,374 9727, 3749727, 3749727,374 9727, 3749727,374 9470, 3749469,374 9469, 3749721,374 9720, 3749720,381 4998, 3814997,388 0534, 3880533,394 6835, 3881042]; function checkStart ($ sx, $ sy) {global $ cheet; global $ image; for ($ I = 0; $ I <75; $ I ++) {$ rgb = imagecolorat ($ image, $ sy + $ I, $ sx ); if (! Similar ($ rgb, $ cheet [$ I]) {return false ;}} return true;} function screencap () {ob_start (); system ('adb shell screencap-p/sdcard/screen.png '); system ('adb pull/sdcard/screen.png. '); ob_end_clean ();} function press ($ time) {system ('adb shell input swipe 500 1600 500 '. $ time) ;}for ($ id = 0; $ id ++) {echo sprintf ("# % 05d:", $ id); // screencap (); // obtain the coordinates $ image = imagecreatefrompng('screen.png '); list ($ sx, $ sy) = getStart (); list ($ tx, $ ty) = getEnd (); if ($ sx = 0) break; echo sprintf ("(% d, % d)-> (% d, % d)", $ sx, $ sy, $ tx, $ ty); // image profiling imagefilledellipse ($ image, $ sy, $ sx, 10, 10, 0xFF0000); imagefilledellipse ($ image, $ ty, $ tx, 10, 10, 0xFF0000); imagepng ($ image, sprintf ("screen/10905d.png", $ id )); // calculate the press time $ time = pow ($ tx-$ sx, 2) + pow ($ ty-$ sy, 2), 0.425) * PRESS_TIME; $ time = round ($ time); echo sprintf ("time: % f \ n", $ time); press ($ time ); // wait for the next sleep (SLEEP_TIME );}
<? Php/*** PRESS the strength parameter and adjust it according to the actual performance. * If the long jump occurs, lower the value. * // define ('Press _ time', 3.752 ); define ('Press _ time', 3.452);/*** sleep time */define ('sleep _ time', 2);/*** role width, no need to adjust */define ('body _ width', 75 );
################### I am a splitting line ################## ####
Another method
Function jump () {sleep (2.5); // The latency is 2.5 seconds. The music box, convenience stores, manhole covers, and other sites are added in 2 seconds. $ screenShell = "cd D: \ & adb shell/system/bin/screencap-p/sdcard/screenshot.png & adb pull/sdcard/screenshot.png d: jumper/screenshot.png "; exec ($ screenShell ); // $ I = imagecreatefrompng ("d: jumper/screenshot.png"); // read the image $ point = array (); for ($ y = 400; $ y <imagesy ($ I); $ y ++) {// starting from row 400th, avoid the upper content for ($ x = 0; $ x <imagesx ($ I); $ x ++) {// horizontal scan $ rgb = imagecolo Rat ($ I, $ x, $ y); // obtain the color $ point ["now"] ["r"] = ($ rgb> 16) & 0xFF; $ point ["now"] ["g"] = ($ rgb> 8) & 0xFF; $ point ["now"] ["B"] = $ rgb & 0xFF; if (isset ($ point ["last"] ["r"]) {if (! Isset ($ point ["x"] ["a"]) {if (abs ($ point ["now"] ["r"]-$ point ["last"] ["r"])> 1 or abs ($ point ["now"] ["g"]-$ point ["last"] ["g"])> 1 or abs ($ point ["now"] ["B"]-$ point ["last"] ["B"])> 1) {$ point ["x"] ["a"] = $ x; if (imagesx ($ I)/2> $ x) {$ point ["direction"] = "left";} else {$ point ["direction"] = "right ";} $ point ["a"] = $ point ["last"] ;}} else {if ($ point ["now"] ==$ point ["a"]) {$ point ["x"] ["B"] = $ X-1; break ;}}$ point ["last"] = $ point ["now"];} if (isset ($ point ["x"]) {break ;}}$ param ["left"] = 3750; $ param ["right"] = 3100; $ time = pow (abs (imagesx ($ I) /2-($ point ["x"] ["a"] + $ point ["x"] ["a"])/2) /imagesx ($ I), 1) * $ param [$ point ["direction"]; if ($ time <400) {$ time + = ($ param [$ point ["direction"]/300);} $ time = round ($ time, 0); echo "direction :". $ point ["direction"]; echo "\ nx. a :". $ point ["x"] ["a"]; echo "\ nx. B :". $ point ["x"] ["B"]; echo "\ ntime :". $ time. "\ n"; $ touchShell = "cd D: \ & adb shell input swipe 50 250 250 250 ". $ time; exec ($ touchShell); imagedestroy ($ I); jump ();} jump ();
For more information, refer to the topic ".
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.