Best JavaScript code snippet using appium-android-driver
game_spots_plain_model.js
Source:game_spots_plain_model.js
1// ============================2// РазÑабоÑÑик: apelserg ; https://github.com/apelserg/3// ÐиÑензиÑ: WTFPL4// ============================5"use strict";6//===7// ÐазовÑй обÑÐµÐºÑ - мÑÑ8//===9APELSERG.MODEL.Ball = function (ballX, ballY, dirX, dirY, upX, upY, ballColor) {10 this.X = ballX;11 this.Y = ballY;12 this.Radius = APELSERG.CONFIG.SET.BallSize / 2;13 this.DirX = dirX; //-- напÑавление и ÑкоÑоÑÑÑ Ð¿Ð¾ X14 this.DirY = dirY; //-- напÑавление и ÑкоÑоÑÑÑ Ð¿Ð¾ Y15 this.DirXSpeedUp = upX; //-- ÑÑкоÑение по X16 this.DirYSpeedUp = upY; //-- ÑÑкоÑение по Y17 this.Color = ballColor;18}19//===20// ÐовÑй мÑÑ21//===22APELSERG.MODEL.GetBall = function () {23 var ballColor = APELSERG.MODEL.GetColor();24 var ballX = APELSERG.CONFIG.PROC.CanvaID.width / 2;25 var ballY = APELSERG.CONFIG.PROC.CanvaID.height / 2;26 var upX = APELSERG.MODEL.GetRandomSpeedUp();27 var upY = APELSERG.MODEL.GetRandomSpeedUp();28 var dirX = APELSERG.MODEL.GetRandomDir() * APELSERG.CONFIG.SET.Speed;29 var dirY = APELSERG.MODEL.GetRandomDir() * APELSERG.CONFIG.SET.Speed;30 return new APELSERG.MODEL.Ball(ballX, ballY, dirX, dirY, upX, upY, ballColor);31}32//===33// ÐовÑй Ð½Ð°Ð±Ð¾Ñ Ð¼ÑÑей34//===35APELSERG.MODEL.GetBalls = function () {36 var balls = [];37 for(var n = 0; n < APELSERG.CONFIG.SET.BallNum; n++) {38 balls.push(APELSERG.MODEL.GetBall());39 }40 return balls;41}42//===43// CлÑÑайное ÑиÑло в диапазоне Ð¾Ñ 0 до max44//===45APELSERG.MODEL.GetRandomNumber = function (max) {46 if (max < 100) return Math.round(Math.random() * 100) % max;47 else return Math.round(Math.random() * max);48}49//===50// СлÑÑайное напÑавление51//===52APELSERG.MODEL.GetRandomDir = function () {53 if (Math.round(Math.random() * 10) % 2 == 0) return 1;54 else return -1;55}56//===57// СлÑÑайное ÑÑкоÑение58//===59APELSERG.MODEL.GetRandomSpeedUp = function () {60 return APELSERG.MODEL.GetRandomNumber(APELSERG.CONFIG.SET.SpeedUp + 1);61}62//===63// СлÑÑайнÑй ÑÐ²ÐµÑ Ð¸Ð· ÑпиÑка64//===65APELSERG.MODEL.GetColor = function () {66 var colors = ['#CC3300', '#FF9900', '#FFFF00', '#009933', '#3399FF', '#0033CC', '#9900CC'];67 return colors[APELSERG.MODEL.GetRandomNumber(colors.length)];68}69//===70// ÐеÑемеÑÑиÑÑ Ð¼ÑÑ71//===72APELSERG.MODEL.UpdateBall = function () {73 //-- ÑпеÑва пÑовеÑка клика мÑÑи74 //--75 for (var n = 0; n < APELSERG.CONFIG.PROC.Balls.length; n++) {76 var ball = APELSERG.CONFIG.PROC.Balls[n];77 //-- попадание78 //--79 if ((ball.X >= (APELSERG.CONFIG.PROC.MouseX - ball.Radius))80 && (ball.X <= (APELSERG.CONFIG.PROC.MouseX + ball.Radius))81 && (ball.Y >= (APELSERG.CONFIG.PROC.MouseY - ball.Radius))82 && (ball.Y <= (APELSERG.CONFIG.PROC.MouseY + ball.Radius))) {83 APELSERG.CONFIG.PROC.Balls.splice(n, 1);84 APELSERG.CONFIG.PROC.RedCnt = 0;85 APELSERG.CONFIG.PROC.Points += (1 + APELSERG.CONFIG.SET.Speed) * (100 - APELSERG.CONFIG.SET.BallSize);86 break; //-- за Ñаз ÑдалÑеÑÑÑ ÑолÑко один мÑÑ87 }88 }89 //-- пÑомаÑ
90 //--91 if (APELSERG.CONFIG.PROC.RedCnt == 1) {92 APELSERG.CONFIG.PROC.Points -= Math.round(APELSERG.CONFIG.SET.BallSize / APELSERG.CONFIG.SET.Speed);93 }94 APELSERG.CONFIG.PROC.MouseX = -999;95 APELSERG.CONFIG.PROC.MouseY = -999;96 //-- движение мÑÑа97 //--98 for (var n = 0; n < APELSERG.CONFIG.PROC.Balls.length; n++) {99 var ball = APELSERG.CONFIG.PROC.Balls[n];100 if (ball.X < APELSERG.CONFIG.PROC.CanvaID.width / 2) {101 //-- ÐÑÑкок Ð¾Ñ Ð»ÐµÐ²Ð¾Ð¹ ÑÑоÑÐ¾Ð½Ñ ÐºÐ¾ÑÑа102 //--103 if (ball.X <= ball.Radius) {104 ball.X = ball.Radius;105 ball.DirX *= -1;106 ball.DirYSpeedUp = APELSERG.MODEL.GetRandomSpeedUp(); //-- ÑÑкоÑение по Y107 ball.DirY *= APELSERG.MODEL.GetRandomDir();108 APELSERG.CONFIG.PROC.Points -= APELSERG.CONFIG.SET.BallSize / 10;109 }110 }111 else {112 //-- ÐÑÑкок Ð¾Ñ Ð¿Ñавой ÑÑоÑÐ¾Ð½Ñ ÐºÐ¾ÑÑа113 //--114 if (ball.X >= (APELSERG.CONFIG.PROC.CanvaID.width - ball.Radius)) {115 ball.X = APELSERG.CONFIG.PROC.CanvaID.width - ball.Radius;116 ball.DirX *= -1;117 ball.DirYSpeedUp = APELSERG.MODEL.GetRandomSpeedUp(); //-- ÑÑкоÑение по Y118 ball.DirY *= APELSERG.MODEL.GetRandomDir();119 APELSERG.CONFIG.PROC.Points -= APELSERG.CONFIG.SET.BallSize / 10;120 }121 }122 if (ball.Y < APELSERG.CONFIG.PROC.CanvaID.height / 2) {123 //-- ÐÑÑкок Ð¾Ñ Ð²ÐµÑÑ
а коÑÑа124 //--125 if (ball.Y <= ball.Radius) {126 ball.Y = ball.Radius;127 ball.DirY *= -1;128 ball.DirXSpeedUp = APELSERG.MODEL.GetRandomSpeedUp(); //-- ÑÑкоÑение по X129 ball.DirX *= APELSERG.MODEL.GetRandomDir();130 APELSERG.CONFIG.PROC.Points -= APELSERG.CONFIG.SET.BallSize / 10;131 }132 }133 else {134 //-- ÐÑÑкок Ð¾Ñ Ð½Ð¸Ð·Ð° коÑÑа135 //--136 if (ball.Y >= (APELSERG.CONFIG.PROC.CanvaID.height - ball.Radius)) {137 ball.Y = APELSERG.CONFIG.PROC.CanvaID.height - ball.Radius;138 ball.DirY *= -1;139 ball.DirXSpeedUp = APELSERG.MODEL.GetRandomSpeedUp(); //-- ÑÑкоÑение по X140 ball.DirX *= APELSERG.MODEL.GetRandomDir();141 APELSERG.CONFIG.PROC.Points -= APELSERG.CONFIG.SET.BallSize / 10;142 }143 }144 //-- движение мÑÑа145 //--146 if (ball.DirX > 0) {147 ball.X += ball.DirX + ball.DirXSpeedUp;148 }149 else {150 ball.X += ball.DirX - ball.DirXSpeedUp;151 }152 if (ball.DirY > 0) {153 ball.Y += ball.DirY + ball.DirYSpeedUp;154 }155 else {156 ball.Y += ball.DirY - ball.DirYSpeedUp;157 }158 }159 //-- игÑа завеÑÑена (еÑли не оÑÑалоÑÑ Ð¼ÑÑей)160 //--161 if (APELSERG.CONFIG.PROC.Balls.length == 0) {162 APELSERG.CONFIG.PROC.GameStop = true;163 APELSERG.CONFIG.SetResult();164 }165 //-- игÑа завеÑÑена (еÑли оÑки ÑÑли в минÑÑ)166 //--167 if (APELSERG.CONFIG.PROC.Points < -1000) {168 APELSERG.CONFIG.PROC.GameStop = true;169 }...
app.js
Source:app.js
1const COLORS = Object.freeze(2{3 RED: "#FF0000",4 WHITE: "#FFFFFF",5 BLACK: "#000000",6 YELLOW: "#FFFF00",7 BLUE: "#0000FF",8});910const DIRECTION = Object.freeze(11{12 UP: "UP",13 DOWN: "DOWN",14 LEFT: "LEFT",15 RIGHT: "RIGHT",16 DIAGONAL: "DIAGONAL",17 RANDOM: "RANDOM",18});1920const MINSIZE = 15;2122var canvas, ctx;23var items = [];24var timer;25var maxSize = 30, commonDir = DIRECTION.RANDOM, commonSpeed = 5, spawnNumber = 10;2627/* Actions when page is loaded or resized*/28function Init()29{30 canvas = document.getElementById("canvas");31 32 canvas.width = window.innerWidth;33 canvas.height = window.innerHeight / 2;34 35 if(canvas.getContext)36 {37 ctx = canvas.getContext('2d');38 39 DrawBackground();40 SetTimers();41 }42}4344/* Draw functions*/45function DrawBackground()46{47 ctx.save();48 ctx.fillStyle = "gray";49 ctx.fillRect(0, 0, canvas.width, canvas.height);50 ctx.restore();51}5253/* On mouse click */54function CreateItem(evt)55{56 if (timer == -1) return;57 58 let dir = (commonDir == "RANDOM") ? GetRandomDir() : commonDir; 59 let item = new TBall(GetMousePos(evt).x, GetMousePos(evt).y, dir)60 61 if (!IsClashed(item))62 {63 item.Draw();64 item.Move();65 items.push(item);66 }67}6869/* Animation */70function MoveItems()71{72 DrawBackground();73 74 for (let i = 0; i < items.length; i++)75 {76 if (items[i].size >= maxSize) items.splice(i, 1);77 78 if (IsClashed(items[i])) SetOppositeDirection(items[i]);79 80 items[i].Draw();81 items[i].Move();82 }83}8485/* Get random attributes */86function GetRandomColor() 87{88 let keys = Object.keys(COLORS);8990 return COLORS[keys[Math.floor(keys.length * Math.random())]];91}9293function GetRandomDir() 94{95 let keys = Object.keys(DIRECTION);96 97 keys.length -= 1; // del random9899 return DIRECTION[keys[Math.floor(keys.length * Math.random())]];100}101102function GetRandomSize() 103{104 return Math.random() * (maxSize - MINSIZE) + MINSIZE;105}106107/* Utility functions */108function SetOppositeDirection(item)109{110 item.speed += 1; //bug fix111 112 switch(item.dir)113 {114 case DIRECTION.UP:115 item.dir = DIRECTION.DOWN;116 break;117 case DIRECTION.DOWN:118 item.dir = DIRECTION.UP;119 break;120 case DIRECTION.LEFT:121 item.dir = DIRECTION.RIGHT;122 break;123 case DIRECTION.RIGHT:124 item.dir = DIRECTION.LEFT;125 break;126 case DIRECTION.DIAGONAL:127 item.dirX *= -1;128 item.dirY *= -1;129 break;130 default:131 break;132 }133}134135function GetMousePos(evt) 136{137 return( 138 {139 x: evt.clientX - canvas.offsetLeft,140 y: evt.clientY - canvas.offsetTop141 });142}143144//Collision check145function IsClashed(item)146{147 let x = item.posX;148 let y = item.posY;149 let size = item.size;150 151 if (x+size > canvas.width || x-size < 0 || y-size < 0 || y+size > canvas.height) return true;152 else return false;153}154155/* Set animation */156function SetTimers()157{158 timer = setInterval(MoveItems, 30);159}160161function ResetTimers()162{163 clearInterval(timer);164 timer = -1;165}166167/* Input handlers */168function ChangeMaxSize()169{170 maxSize = Number(document.getElementById("size").value);171 172 if (maxSize > 50) maxSize = 100;173 174 if (maxSize < 30) maxSize = 30;175}176177function ChangeSpeed()178{179 commonSpeed = Number(document.getElementById("speed").value);180 181 if (commonSpeed > 10) commonSpeed = 10;182}183184function ChangeSpawnNumber()185{186 spawnNumber = Number(document.getElementById('spawn').value);187 188 //if189}190191/* Button handlers */192function HandleKeys(evt)193{194 let key = evt.keyCode;195 196 switch(key)197 {198 case 32:199 SetPause();200 break;201 case 49:202 ChangeDirection(DIRECTION.RANDOM);203 break;204 case 50:205 ChangeDirection(DIRECTION.UP);206 break;207 case 51:208 ChangeDirection(DIRECTION.DOWN);209 break;210 case 52:211 ChangeDirection(DIRECTION.LEFT);212 break;213 case 53:214 ChangeDirection(DIRECTION.RIGHT);215 break;216 case 54:217 ChangeDirection(DIRECTION.DIAGONAL);218 break;219 default:220 break;221 }222}223224function ChangeDirection(dir)225{226 commonDir = dir;227 228 for (let i = 0; i < items.length; i++)229 {230 if (dir == DIRECTION.RANDOM) items[i].dir = GetRandomDir();231 else items[i].dir = dir;232 }233}234235function SetPause()236{237 if (timer == -1) SetTimers()238 else ResetTimers();239}240241function SpawnItems()242{243 let dir = (commonDir == "RANDOM") ? GetRandomDir() : commonDir; 244 245 for (let i = 0; i < spawnNumber; i++)246 {247 let x = Math.random() * canvas.width-maxSize + maxSize;248 let y = Math.random() * canvas.height-maxSize + maxSize;249 let item = new TBall(x, y, dir)250251 if (!IsClashed(item))252 {253 item.Draw();254 item.Move();255 items.push(item);256 }257 }
...
ps_update.gs
Source:ps_update.gs
1#version 33023layout(points) in;4layout(points) out;5layout(max_vertices = 30) out;67in float Type0[];8in vec3 Position0[];9in vec3 Velocity0[];10in float Age0[];1112out float Type1;13out vec3 Position1;14out vec3 Velocity1;15out float Age1;1617uniform float gDeltaTimeMillis;18uniform float gTime;19uniform sampler1D gRandomTexture;20uniform float gLauncherLifetime;21uniform float gShellLifetime;22uniform float gSecondaryShellLifetime;2324#define PARTICLE_TYPE_LAUNCHER 0.0f25#define PARTICLE_TYPE_SHELL 1.0f26#define PARTICLE_TYPE_SECONDARY_SHELL 2.0f2728vec3 GetRandomDir(float TexCoord)29{30 vec3 Dir = texture(gRandomTexture, TexCoord).xyz;31 Dir -= vec3(0.5, 0.5, 0.5);32 return Dir;33} 3435void main()36{37 float Age = Age0[0] + gDeltaTimeMillis;3839 if (Type0[0] == PARTICLE_TYPE_LAUNCHER) {40 if (Age >= gLauncherLifetime) {41 Type1 = PARTICLE_TYPE_SHELL;42 Position1 = Position0[0];43 vec3 Dir = GetRandomDir(gTime/1000.0);44 Dir.y = max(Dir.y, 0.5);45 Velocity1 = normalize(Dir) / 20.0;46 Age1 = 0.0;47 EmitVertex();48 EndPrimitive();49 Age = 0.0;50 }5152 Type1 = PARTICLE_TYPE_LAUNCHER;53 Position1 = Position0[0];54 Velocity1 = Velocity0[0];55 Age1 = Age;56 EmitVertex();57 EndPrimitive();58 } 59else {60 float DeltaTimeSecs = gDeltaTimeMillis / 1000.0f;61 float t1 = Age0[0] / 1000.0;62 float t2 = Age / 1000.0;63 vec3 DeltaP = DeltaTimeSecs * Velocity0[0];64 vec3 DeltaV = vec3(DeltaTimeSecs) * (0.0, -9.81, 0.0); 65 if (Type0[0] == PARTICLE_TYPE_SHELL) {66 if (Age < gShellLifetime) {67 Type1 = PARTICLE_TYPE_SHELL;68 Position1 = Position0[0] + DeltaP;69 Velocity1 = Velocity0[0] + DeltaV;70 Age1 = Age;71 EmitVertex();72 EndPrimitive();73 }74 else {75 for (int i = 0 ; i < 10 ; i++) {76 Type1 = PARTICLE_TYPE_SECONDARY_SHELL;77 Position1 = Position0[0];78 vec3 Dir = GetRandomDir((gTime + i)/1000.0);79 Velocity1 = normalize(Dir) / 20.0;80 Age1 = 0.0f;81 EmitVertex();82 EndPrimitive();83 }84 }85 }86else {87 if (Age < gSecondaryShellLifetime) {88 Type1 = PARTICLE_TYPE_SECONDARY_SHELL;89 Position1 = Position0[0] + DeltaP;90 Velocity1 = Velocity0[0] + DeltaV;91 Age1 = Age;92 EmitVertex();93 EndPrimitive();94 }95 }96 }
...
asteroid.js
Source:asteroid.js
...46 let z = getRandomInt(manager.ufo.position.z + manager.box.zMin - 200, manager.ufo.position.z + manager.box.zMax);47 this.position = new Vector3(x, y, z);48 let randVelocity;49 if (this.shouldMove) {50 randVelocity = new Vector3(getRandomDir() * this.velocityScalar, getRandomDir() * this.velocityScalar, getRandomDir() * this.velocityScalar);51 } else {52 randVelocity = new Vector3(0, 0, 0);53 }54 this.physics.velocity = randVelocity;55 if (this.shouldRotate) {56 const rot = new Vector3(getRandomDir(), getRandomDir(), getRandomDir());57 rot.multiplyScalar(Math.random() * 80);58 this.physics.angularVelocity = rot;59 }60 this.scale *= getRandomInt(80, 120) / 100;61 }62 onCollisionEnter(gameobject) {63 // let asteroids pass through eachother64 if (!(gameobject instanceof Asteroid)) this.alive = false;65 }66 static spawnAsteroids = (asteroidCount = 100) => {67 let asteroids = [];68 for (let i = 0; i < asteroidCount; i++) {69 asteroids.push(new Asteroid(getRandomInt(0, 2)));70 }...
SnowUpdate.gs
Source:SnowUpdate.gs
1#version 330 core2layout (points) in;3layout (points,max_vertices = 10) out;4in float Type0[];5in vec3 Position0[];6in vec3 Velocity0[];7in float Age0[];8in float Size0[];9out float Type1;10out vec3 Position1;11out vec3 Velocity1;12out float Age1;13out float Size1;14uniform float gDeltaTimeMillis;//æ¯å¸§æ¶é´ååé15uniform float gTime;//æ»çæ¶é´ååé16uniform sampler1D gRandomTexture;17uniform float MAX_SIZE;18uniform float MIN_SIZE;19uniform vec3 MAX_VELOC;20uniform vec3 MIN_VELOC;21uniform float MAX_LAUNCH;22uniform float MIN_LAUNCH;23uniform mat4 view;24#define PARTICLE_TYPE_LAUNCHER 0.0f25#define PARTICLE_TYPE_SHELL 1.0f26vec3 GetRandomDir(float TexCoord);27vec3 Rand(float TexCoord);28void main()29{30 float Age = Age0[0] - gDeltaTimeMillis;31 float speedRate = 0.1f;32 if(Type0[0] == PARTICLE_TYPE_LAUNCHER){//ç«ç°åå°ç²å33 if(Age <= 0 ){34 //åå°ç¬¬äºçº§ç²å35 Type1 = PARTICLE_TYPE_SHELL;36 Position1 = Position0[0];37 vec3 Dir = GetRandomDir(Age0[0]+gTime);38 Dir.y = min(Dir.y,-0.5f);39 Velocity1 = normalize(Dir)/speedRate;40 Age1 = Age0[0];41 Size1 = (MAX_SIZE-MIN_SIZE)*Rand(Age0[0]+gTime).x+MIN_SIZE;42 EmitVertex();43 EndPrimitive();44 Age = (MAX_LAUNCH-MIN_LAUNCH)*Rand(Age0[0]).y + MIN_LAUNCH;45 }46 Type1 = PARTICLE_TYPE_LAUNCHER;47 Position1 = Position0[0];48 Velocity1 = Velocity0[0];49 Age1 = Age;50 Size1 = 0;51 EmitVertex();52 EndPrimitive();53 }54 else{55 if(Position0[0].y > 0){56 float DeltaTimeSecs = gDeltaTimeMillis/1000.0f;57 vec3 DeltaP = Velocity0[0]*DeltaTimeSecs;58 vec3 DeltaV = DeltaTimeSecs*vec3(10.0,-9.81,0.0);59 Type1 = PARTICLE_TYPE_SHELL;60 Position1 = Position0[0] + DeltaP;61 Velocity1 = Velocity0[0] + DeltaV;62 Age1 = Age;63 Size1 = Size0[0];64 EmitVertex();65 EndPrimitive();66 }67 }68}69vec3 GetRandomDir(float TexCoord)70{71 vec3 Dir = texture(gRandomTexture,TexCoord).xyz;72 Dir -= vec3(0.5,0.5,0.5);73 return Dir;74}75vec3 Rand(float TexCoord){//éæº0-176 vec3 ret = texture(gRandomTexture,TexCoord).xyz;77 return ret;...
particle.gs
Source:particle.gs
1#version 430 core2layout(points) in; 3layout(points, max_vertices = 30) out; 4 5in VS6{7 vec3 Position; 8 vec3 Velocity; 9 float Age;10} gs_in[];11 12out GS13{14 vec3 Position; 15 vec3 Velocity; 16 float Age; 17} gs_out;18 19uniform float gDeltaTime; 20uniform float gTime;21uniform sampler1D gRandomTexture; 22 23vec3 GetRandomDir(float TexCoord) 24{ 25 vec3 Dir = texture(gRandomTexture, TexCoord).xyz; 26 Dir -= vec3(0.5f); 27 return Dir; 28} 29 30void main() 31{ 32 float age = gs_in[0].Age + gDeltaTime;33 vec3 dir = GetRandomDir(gTime*0.01f);34 for(int i=0;i<30;++i)35 {36 if(gs_in[0].Age >=2.0f || gs_in[0].Position.y>=1.0f)37 {38 gs_out.Position = dir * gs_in[0].Velocity;39 gs_out.Velocity = gs_in[0].Velocity;40 gs_out.Age = 0.0f;41 }42 else43 {44 gs_out.Position = gs_in[0].Position + dir * gs_in[0].Velocity;45 gs_out.Velocity = gs_in[0].Velocity;46 gs_out.Age += age;47 }48 EmitVertex();49 }50 EndPrimitive(); ...
index.js
Source:index.js
...11 { x: movement, y: -movement }12];13let previous = {};14let counter = 0;15function getRandomDir() {16 return random(directions);17}18function getModifiedColorPart(c) {19 return (c + random(-3, 3) + 255) % 255;20}21function getModifiedRGB(color) {22 return { r: getModifiedColorPart(color.r), g: getModifiedColorPart(color.g), b: getModifiedColorPart(color.b) };23}24function getNextShape() {25 let dir = previous.dir;26 if (counter === 10) {27 dir = getRandomDir();28 while (dir.x === -previous.dir.x && dir.y === -previous.dir.y) {29 dir = getRandomDir();30 }31 counter = 0;32 }33 counter = (counter + 1);34 return {35 x: (previous.x + dir.x + windowWidth) % windowWidth,36 y: (previous.y + dir.y + windowHeight) % windowHeight,37 color: getModifiedRGB(previous.color),38 dir: dir39 };40}41function getRandomColor() {42 return {43 r: random(255),44 g: random(255),45 b: random(255)46 };47}48function setup() {49 const bg = getRandomColor();50 const color = getRandomColor();51 createCanvas(windowWidth, windowHeight);52 background(bg.r, bg.g, bg.b);53 noStroke();54 previous = {55 dir: getRandomDir(),56 x: windowWidth / 2,57 y: windowHeight / 2,58 color: color,59 };60}61function draw() {62 const shape = getNextShape();63 //stroke(shape.color.r - 20, shape.color.g - 20, shape.color.b - 20);64 fill(shape.color.r, shape.color.g, shape.color.b);65 circle(shape.x, shape.y, random(size - 20, size));66 previous = shape;...
main.js
Source:main.js
1const getIntRandom = (num1,num2) => {2 const getCheck = (number) => number<0 ? 0 : number;3 const getRandomInt = (min,max) => Math.floor(Math.random()*(max-min+1)) + min;4 const getRandomDir = (numA,numB) => numA>numB ? getRandomInt(numB,numA) : getRandomInt(numA,numB);5 const rez=(getCheck(num1) && getCheck(num2)) === true ? getRandomDir(num1 , num2) :-1;6 return rez;7};8getIntRandom(1,2);9//Ð ÑабоÑе иÑполÑзовалиÑÑ Ð¼Ð°ÑеÑÐ¸Ð°Ð»Ñ https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Math/random10const getCoordinates = (strt,nd,numSig) => {11 const getCheck = (number) => number<0 ? 0 : number;12 const getRandomArbitrary = (min,max) => (Math.random()*(max-min+1)) + min;13 const getRandomDir = (numA,numB) => numA>numB ? getRandomArbitrary(numB,numA) : getRandomArbitrary(numA,numB);14 const rez=(getCheck(strt) && getCheck(nd) && getCheck(numSig) && numSig<21) === true ? getRandomDir(strt , nd) :-1;15 return rez.toFixed(numSig);16};17getCoordinates(1,2,3);...
Using AI Code Generation
1var driver = new AndroidDriver();2var randomDir = driver.getRandomDir();3console.log(randomDir);4var driver = new IOSDriver();5var randomDir = driver.getRandomDir();6console.log(randomDir);7var driver = new AndroidDriver();8var randomFile = driver.getRandomFile();9console.log(randomFile);10var driver = new AndroidDriver();11var randomString = driver.getRandomString();12console.log(randomString);
Using AI Code Generation
1var wd = require('wd');2var assert = require('assert');3var driver = wd.promiseChainRemote("localhost", 4723);4var desired = {5};6 .init(desired)7 .then(function() {8 return driver.setImplicitWaitTimeout(5000);9 })10 .then(function() {11 return driver.elementByName("App");12 })13 .then(function(el) {14 return el.click();15 })16 .then(function() {17 return driver.elementByName("Activity");18 })19 .then(function(el) {20 return el.click();21 })22 .then(function() {23 return driver.elementByName("Custom Title");24 })25 .then(function(el) {26 return el.click();27 })28 .then(function() {29 return driver.elementByName("Custom Title");30 })31 .then(function(el) {32 return el.getLocation();33 })34 .then(function(loc) {35 console.log("Location of element: " + loc.x + ", " + loc.y);36 return driver.elementByName("Custom Title");37 })38 .then(function(el) {39 return el.getSize();40 })41 .then(function(size) {42 console.log("Size of element: " + size.width + ", " + size.height);43 return driver.elementByName("Custom Title");44 })45 .then(function(el) {46 return el.text();47 })48 .then(function(text) {49 console.log("Text of element: " + text);50 return driver.elementByName("Custom Title");51 })52 .then(function(el) {53 return el.getAttribute("contentDescription");54 })55 .then(function(desc) {56 console.log("Content description of element: " + desc);57 return driver.elementByName("Custom Title");58 })59 .then(function(el) {60 return el.getAttribute("packageName");61 })62 .then(function(pkg) {63 console.log("Package name of element: " + pkg);64 return driver.elementByName("Custom Title");65 })66 .then(function(el) {67 return el.getAttribute("className");68 })69 .then(function(cls) {70 console.log("Class name of element: " + cls);71 return driver.elementByName("
Using AI Code Generation
1var driver = require('appium-android-driver');2var randomDir = driver.getRandomDir();3console.log(randomDir);4var driver = require('appium-android-driver');5var apiDemosDir = driver.getApiDemosDir();6console.log(apiDemosDir);
Using AI Code Generation
1var driver = new AndroidDriver();2driver.getRandomDir();3class AndroidDriver extends Driver {4 getRandomDir() {5 }6}7class Driver {8 getRandomDir() {9 }10}11var driver = new AndroidDriver();12driver.getRandomDir();13var Driver = require('./driver');14class AndroidDriver extends Driver {15 getRandomDir() {16 }17}18class Driver {19 getRandomDir() {20 }21}22import { AndroidDriver } from './android-driver';23let driver = new AndroidDriver();24driver.getRandomDir();25import { Driver } from './driver';26export class AndroidDriver extends Driver {27 getRandomDir() {28 }29}30export class Driver {31 getRandomDir() {32 }33}34import AndroidDriver from './android-driver';35let driver = new AndroidDriver();36driver.getRandomDir();37import Driver from './driver';38export default class AndroidDriver extends Driver {39 getRandomDir() {40 }41}42export default class Driver {43 getRandomDir() {44 }45}46If you are using TypeScript, you can use the import statement to import the code from one file to another. The
Using AI Code Generation
1driver.getRandomDir();2commands.getRandomDir = async function () {3 let {appPackage, appActivity} = this.opts;4 let cmd = `am start -W -n ${appPackage}/${appActivity} -S`;5 await this.adb.shell(cmd);6 let {stdout} = await this.adb.shell(['echo', '$EXTERNAL_STORAGE']);7 return stdout.trim();8};9commands.getCurrentContext = async function () {10 return await this.proxyCommand('/context', 'GET');11};12commands.getContexts = async function () {13 return await this.proxyCommand('/contexts', 'GET');14};15commands.setContext = async function (name, callback, skipReadyCheck) {16 if (name === null) {17 name = NATIVE_WIN;18 }19 if (name === this.curContext) {20 return;21 }22 let contexts = await this.getContexts();23 if (!_.contains(contexts, name)) {24 let msg = `The context '${name}' does not exist. Available contexts are: ` +25 `'${contexts.join("', '")}'`;26 throw new errors.NoSuchContextError(msg);27 }28 log.debug(`Attempting to set context to '${name}'`);29 await this.proxyCommand('/context', 'POST', {name});30 this.curContext = name;31 if (!skipReadyCheck) {32 await this.waitForApp();33 }34 if (callback) {35 await callback();36 }37};38commands.setContext = async function (name, callback, skipReadyCheck) {39 if (name === null) {40 name = NATIVE_WIN;41 }42 if (name === this.curContext) {43 return;44 }45 let contexts = await this.getContexts();46 if (!_.contains(contexts, name)) {47 let msg = `The context '${
Using AI Code Generation
1var driver = new AndroidDriver();2driver.getRandomDir();3var AndroidDriver = function() {4 this.getRandomDir = function() {5 };6};7var IosDriver = function() {8 this.getRandomDir = function() {9 };10};11var AndroidDriver = require('./android');12var driver = new AndroidDriver();13driver.getRandomDir();14var IosDriver = require('./ios');15var driver = new IosDriver();16driver.getRandomDir();17var AndroidDriver = require('./android');18var driver = new AndroidDriver();19driver.getRandomDir();20var IosDriver = require('./ios');21var driver = new IosDriver();22driver.getRandomDir();23var AndroidDriver = require('./android');24var driver = new AndroidDriver();25driver.getRandomDir();26var IosDriver = require('./ios');27var driver = new IosDriver();28driver.getRandomDir();29var AndroidDriver = require('./android');30var driver = new AndroidDriver();31driver.getRandomDir();32var IosDriver = require('./ios');33var driver = new IosDriver();34driver.getRandomDir();35var AndroidDriver = require('./android');36var driver = new AndroidDriver();37driver.getRandomDir();38var IosDriver = require('./ios');39var driver = new IosDriver();40driver.getRandomDir();41var AndroidDriver = require('./android');42var driver = new AndroidDriver();43driver.getRandomDir();44var IosDriver = require('./ios');45var driver = new IosDriver();46driver.getRandomDir();
Using AI Code Generation
1var AppiumAndroidDriver = require('./lib/driver.js').Driver;2var driver = new AppiumAndroidDriver();3driver.getRandomDir()4Driver.prototype.getRandomDir = function() {5 var dir = '/data/local/tmp/';6 dir += Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 10);7 return dir;8}9var AppiumAndroidDriver = require('./lib/driver.js').Driver;10var driver = new AppiumAndroidDriver();11var dir = driver.getRandomDir();12driver.adb.shell("mkdir " + dir);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!