diff --git a/examples/helper/spiral b/examples/helper/spiral new file mode 100755 index 00000000..212b8695 --- /dev/null +++ b/examples/helper/spiral @@ -0,0 +1,32 @@ +#! /usr/bin/env python3 +import numpy as np +from com.dtmilano.android.viewclient import ViewClient + +def toint(n): + return n.item() + +def npint(a): + return np.round(a).astype(int) + +def spiral(t): + a = 0.5 # Controls the tightness of the spiral + b = 0.5 # Controls the spacing between turns + g = 40 # Factor + dx = 400 # Delta x + dy = 600 # Delta y + x = g * a * t * np.cos(t + b) + dx + y = g * a * t * np.sin(t + b) + dy + return list(zip(map(toint, npint(x)), map(toint, npint(y)))) + +# get helper +helper = ViewClient.view_client_helper() + +# generate values for the parameter t +t = np.linspace(0, 4 * np.pi, 100) + +# calculate (x, y) coordinates +segments = spiral(t) + +# assume google keep is open so we can see it drawing +# see spiral.gif +helper.ui_device.swipe(segments=segments, segment_steps=3) diff --git a/examples/helper/spiral.gif b/examples/helper/spiral.gif new file mode 100644 index 00000000..4d40ddba Binary files /dev/null and b/examples/helper/spiral.gif differ