How to use yForT method in wpt

Best JavaScript code snippet using wpt

CurveObject.js

Source:CurveObject.js Github

copy

Full Screen

1var sec = sec || {};2sec.sun = sec.sun || {};3sec.sun.awt = sec.sun.awt || {};4sec.sun.awt.geom = sec.sun.awt.geom || {};5sec.sun.awt.geom.CurveObject = function()6{7 this.order0 = null;8 this.order1 = null;9 this.order2 = null;10 this.order3 = null;11 this.order = -1;12 this.setParent = function()13 {14 switch (this.order) {15 case 0:16 this.order0.setParent(this);17 break;18 case 1:19 this.order1.setParent(this);20 break;21 case 2:22 this.order2.setParent(this);23 break;24 case 3:25 this.order3.setParent(this);26 break;27 default:28 break;29 }30 return;31 }32 var obj = arguments[0];33 if (Clazz.instanceOf(obj, sec.sun.awt.geom.Order0)) {34 this.order0 = obj;35 this.order = 0;36 } else if (Clazz.instanceOf(obj, sec.sun.awt.geom.Order1)) {37 this.order1 = obj;38 this.order = 1;39 } else if (Clazz.instanceOf(obj, sec.sun.awt.geom.Order2)) {40 this.order2 = obj;41 this.order = 2;42 } else if (Clazz.instanceOf(obj, sec.sun.awt.geom.Order3)) {43 this.order3 = obj;44 this.order = 3;45 }46 this.setParent();47 this.getCurve = function() {48 switch (this.order) {49 case 0:50 return this.order0;51 case 1:52 return this.order1;53 case 2:54 return this.order2;55 case 3:56 return this.order3;57 default:58 return null;59 }60 };61 this.getOrder = function() {62 return this.order;63 };64 this.getXTop = function() {65 switch (this.order) {66 case 0:67 return this.order0.getXTop();68 case 1:69 return this.order1.getXTop();70 case 2:71 return this.order2.getXTop();72 case 3:73 return this.order3.getXTop();74 default:75 return -7;76 }77 };78 this.getYTop = function() {79 switch (this.order) {80 case 0:81 return this.order0.getYTop();82 case 1:83 return this.order1.getYTop();84 case 2:85 return this.order2.getYTop();86 case 3:87 return this.order3.getYTop();88 default:89 return -7;90 }91 };92 this.getXBot = function() {93 switch (this.order) {94 case 0:95 return this.order0.getXBot();96 case 1:97 return this.order1.getXBot();98 case 2:99 return this.order2.getXBot();100 case 3:101 return this.order3.getXBot();102 default:103 return -7;104 }105 };106 this.getYBot = function() {107 switch (this.order) {108 case 0:109 return this.order0.getYBot();110 case 1:111 return this.order1.getYBot();112 case 2:113 return this.order2.getYBot();114 case 3:115 return this.order3.getYBot();116 default:117 return -7;118 }119 };120 this.getXMin = function() {121 switch (this.order) {122 case 0:123 return this.order0.getXMin();124 case 1:125 return this.order1.getXMin();126 case 2:127 return this.order2.getXMin();128 case 3:129 return this.order3.getXMin();130 default:131 return -7;132 }133 };134 this.getXMax = function() {135 switch (this.order) {136 case 0:137 return this.order0.getXMax();138 case 1:139 return this.order1.getXMax();140 case 2:141 return this.order2.getXMax();142 case 3:143 return this.order3.getXMax();144 default:145 return -7;146 }147 };148 this.getDirection = function() {149 switch (this.order) {150 case 0:151 return this.order0.direction;152 case 1:153 return this.order1.direction;154 case 2:155 return this.order2.direction;156 case 3:157 return this.order3.direction;158 default:159 return -1;160 }161 };162 this.XforY = function(y) {163 switch (this.order) {164 case 0:165 return this.order0.XforY(y);166 case 1:167 return this.order1.XforY(y);168 case 2:169 return this.order2.XforY(y);170 case 3:171 return this.order3.XforY(y);172 default:173 return -7;174 }175 };176 this.getReversedCurve = function() {177 switch (this.order) {178 case 0:179 return this.order0.getReversedCurve();180 case 1:181 return this.order1.getReversedCurve();182 case 2:183 return this.order2.getReversedCurve();184 case 3:185 return this.order3.getReversedCurve();186 default:187 return null;188 }189 };190 this.getX0 = function() {191 switch (this.order) {192 case 0:193 return this.order0.getX0();194 case 1:195 return this.order1.getX0();196 case 2:197 return this.order2.getX0();198 case 3:199 return this.order3.getX0();200 default:201 return -7;202 }203 };204 this.getY0 = function() {205 switch (this.order) {206 case 0:207 return this.order0.getY0();208 case 1:209 return this.order1.getY0();210 case 2:211 return this.order2.getY0();212 case 3:213 return this.order3.getY0();214 default:215 return -7;216 }217 };218 this.getX1 = function() {219 switch (this.order) {220 case 0:221 return this.order0.getX1();222 case 1:223 return this.order1.getX1();224 case 2:225 return this.order2.getX1();226 case 3:227 return this.order3.getX1();228 default:229 return -7;230 }231 };232 this.getY1 = function() {233 switch (this.order) {234 case 0:235 return this.order0.getY1();236 case 1:237 return this.order1.getY1();238 case 2:239 return this.order2.getY1();240 case 3:241 return this.order3.getY1();242 default:243 return -7;244 }245 };246 this.XforT = function(t) {247 switch (this.order) {248 case 0:249 return this.order0.XforT(t);250 case 1:251 return this.order1.XforT(t);252 case 2:253 return this.order2.XforT(t);254 case 3:255 return this.order3.XforT(t);256 default:257 return -7;258 }259 };260 this.YforT = function(t) {261 switch (this.order) {262 case 0:263 return this.order0.YforT(t);264 case 1:265 return this.order1.YforT(t);266 case 2:267 return this.order2.YforT(t);268 case 3:269 return this.order3.YforT(t);270 default:271 return -7;272 }273 };274 this.TforY = function(t) {275 switch (this.order) {276 case 0:277 return this.order0.TforY(t);278 case 1:279 return this.order1.TforY(t);280 case 2:281 return this.order2.TforY(t);282 case 3:283 return this.order3.TforY(t);284 default:285 return -7;286 }287 };288 this.nextVertical = function(t0, t1) {289 switch (this.order) {290 case 0:291 return this.order0.nextVertical(t0, t1);292 case 1:293 return this.order1.nextVertical(t0, t1);294 case 2:295 return this.order2.nextVertical(t0, t1);296 case 3:297 return this.order3.nextVertical(t0, t1);298 default:299 return -7;300 }301 };302 this.controlPointString = function() {303 switch (this.order) {304 case 0:305 return "";306 case 1:307 return "";308 case 2:309 return this.order2.controlPointString();310 case 3:311 return this.order3.controlPointString();312 default:313 return "";314 }315 };316 this.toString = function() {317 return ("Curve[" + this.getOrder() + ", " + ("(" + sec.sun.awt.geom.Curve.round(this.getX0()) + ", " + sec.sun.awt.geom.Curve.round(this.getY0()) + "), ") + this.controlPointString() + ("(" + sec.sun.awt.geom.Curve.round(this.getX1()) + ", " + sec.sun.awt.geom.Curve.round(this.getY1()) + "), ") + (this.getDirection() === 1 ? "D" : "U") + "]");318 };319 this.crossingsFor = function(x, y) {320 if (y >= this.getYTop() && y < this.getYBot()) {321 if (x < this.getXMax() && (x < this.getXMin() || x < this.XforY(y))) {322 return 1;323 }324 }325 return 0;326 };327 this.accumulateCrossings = function(c) {328 var xhi = c.getXHi();329 if (this.getXMin() >= xhi) {330 return false;331 }332 var xlo = c.getXLo();333 var ylo = c.getYLo();334 var yhi = c.getYHi();335 var y0 = this.getYTop();336 var y1 = this.getYBot();337 var tstart;338 var ystart;339 var tend;340 var yend;341 if (y0 < ylo) {342 if (y1 <= ylo) {343 return false;344 }345 ystart = ylo;346 tstart = this.TforY(ylo);347 } else {348 if (y0 >= yhi) {349 return false;350 }351 ystart = y0;352 tstart = 0;353 }354 if (y1 > yhi) {355 yend = yhi;356 tend = this.TforY(yhi);357 } else {358 yend = y1;359 tend = 1;360 }361 var hitLo = false;362 var hitHi = false;363 while (true) {364 var x = this.XforT(tstart);365 if (x < xhi) {366 if (hitHi || x > xlo) {367 return true;368 }369 hitLo = true;370 } else {371 if (hitLo) {372 return true;373 }374 hitHi = true;375 }376 if (tstart >= tend) {377 break;378 }379 tstart = this.nextVertical(tstart, tend);380 }381 if (hitLo) {382 c.record(ystart, yend, this.getDirection());383 }384 return false;385 };386 this.refineTforY = function(t0, yt0, y0) {387 var t1 = 1;388 while (true) {389 var th = (t0 + t1) / 2;390 if (th === t0 || th === t1) {391 return t1;392 }393 var y = this.YforT(th);394 if (y < y0) {395 t0 = th;396 yt0 = y;397 } else if (y > y0) {398 t1 = th;399 } else {400 return t1;401 }402 }403 };404 this.findIntersect = function(that, yrange, ymin, slevel, tlevel, s0, xs0, ys0, s1, xs1, ys1, t0, xt0, yt0, t1, xt1, yt1) {405 if (ys0 > yt1 || yt0 > ys1) {406 return false;407 }408 if (Math.min(xs0, xs1) > Math.max(xt0, xt1) || Math.max(xs0, xs1) < Math.min(xt0, xt1)) {409 return false;410 }411 if (s1 - s0 > 0.0010) {412 var s = (s0 + s1) / 2;413 var xs = this.XforT(s);414 var ys = this.YforT(s);415 if (s === s0 || s === s1) {416 System.out.println("s0 = " + s0);417 System.out.println("s1 = " + s1);418 throw new InternalError("no s progress!");419 }420 if (t1 - t0 > 0.0010) {421 var t = (t0 + t1) / 2;422 var xt = that.XforT(t);423 var yt = that.YforT(t);424 if (t === t0 || t === t1) {425 System.out.println("t0 = " + t0);426 System.out.println("t1 = " + t1);427 throw new InternalError("no t progress!");428 }429 if (ys >= yt0 && yt >= ys0) {430 if (this.findIntersect(that, yrange, ymin, slevel + 1, tlevel + 1, s0, xs0, ys0, s, xs, ys, t0, xt0, yt0, t, xt, yt)) {431 return true;432 }433 }434 if (ys >= yt) {435 if (this.findIntersect(that, yrange, ymin, slevel + 1, tlevel + 1, s0, xs0, ys0, s, xs, ys, t, xt, yt, t1, xt1, yt1)) {436 return true;437 }438 }439 if (yt >= ys) {440 if (this.findIntersect(that, yrange, ymin, slevel + 1, tlevel + 1, s, xs, ys, s1, xs1, ys1, t0, xt0, yt0, t, xt, yt)) {441 return true;442 }443 }444 if (ys1 >= yt && yt1 >= ys) {445 if (this.findIntersect(that, yrange, ymin, slevel + 1, tlevel + 1, s, xs, ys, s1, xs1, ys1, t, xt, yt, t1, xt1, yt1)) {446 return true;447 }448 }449 } else {450 if (ys >= yt0) {451 if (this.findIntersect(that, yrange, ymin, slevel + 1, tlevel, s0, xs0, ys0, s, xs, ys, t0, xt0, yt0, t1, xt1, yt1)) {452 return true;453 }454 }455 if (yt1 >= ys) {456 if (this.findIntersect(that, yrange, ymin, slevel + 1, tlevel, s, xs, ys, s1, xs1, ys1, t0, xt0, yt0, t1, xt1, yt1)) {457 return true;458 }459 }460 }461 } else if (t1 - t0 > 0.0010) {462 var t = (t0 + t1) / 2;463 var xt = that.XforT(t);464 var yt = that.YforT(t);465 if (t === t0 || t === t1) {466 System.out.println("t0 = " + t0);467 System.out.println("t1 = " + t1);468 throw new InternalError("no t progress!");469 }470 if (yt >= ys0) {471 if (this.findIntersect(that, yrange, ymin, slevel, tlevel + 1, s0, xs0, ys0, s1, xs1, ys1, t0, xt0, yt0, t, xt, yt)) {472 return true;473 }474 }475 if (ys1 >= yt) {476 if (this.findIntersect(that, yrange, ymin, slevel, tlevel + 1, s0, xs0, ys0, s1, xs1, ys1, t, xt, yt, t1, xt1, yt1)) {477 return true;478 }479 }480 } else {481 var xlk = xs1 - xs0;482 var ylk = ys1 - ys0;483 var xnm = xt1 - xt0;484 var ynm = yt1 - yt0;485 var xmk = xt0 - xs0;486 var ymk = yt0 - ys0;487 var det = xnm * ylk - ynm * xlk;488 if (det !== 0) {489 var detinv = 1 / det;490 var s = (xnm * ymk - ynm * xmk) * detinv;491 var t = (xlk * ymk - ylk * xmk) * detinv;492 if (s >= 0 && s <= 1 && t >= 0 && t <= 1) {493 s = s0 + s * (s1 - s0);494 t = t0 + t * (t1 - t0);495 if (s < 0 || s > 1 || t < 0 || t > 1) {496 System.out.println("Uh oh!");497 }498 var y = (this.YforT(s) + that.YforT(t)) / 2;499 if (y <= yrange[1] && y > yrange[0]) {500 yrange[1] = y;501 return true;502 }503 }504 }505 }506 return false;507 };508 this.compareTo = function(that, yrange) {509 if (this.order === 1) {510 return this.order1.compareTo(that, yrange);511 }512 var y0 = yrange[0];513 var y1 = yrange[1];514 y1 = Math.min(Math.min(y1, this.getYBot()), that.getYBot());515 if (y1 <= yrange[0]) {516 System.err.println("this === " + this);517 System.err.println("that === " + that);518 System.out.println("target range = " + yrange[0] + "=>" + yrange[1]);519 throw new InternalError("backstepping from " + yrange[0] + " to " + y1);520 }521 yrange[1] = y1;522 if (this.getXMax() <= that.getXMin()) {523 if (this.getXMin() === that.getXMax()) {524 return 0;525 }526 return -1;527 }528 if (this.getXMin() >= that.getXMax()) {529 return 1;530 }531 var s0 = this.TforY(y0);532 var ys0 = this.YforT(s0);533 if (ys0 < y0) {534 s0 = this.refineTforY(s0, ys0, y0);535 ys0 = this.YforT(s0);536 }537 var s1 = this.TforY(y1);538 if (this.YforT(s1) < y0) {539 s1 = this.refineTforY(s1, this.YforT(s1), y0);540 }541 var t0 = that.TforY(y0);542 var yt0 = that.YforT(t0);543 if (yt0 < y0) {544 t0 = that.refineTforY(t0, yt0, y0);545 yt0 = that.YforT(t0);546 }547 var t1 = that.TforY(y1);548 if (that.YforT(t1) < y0) {549 t1 = that.refineTforY(t1, that.YforT(t1), y0);550 }551 var xs0 = this.XforT(s0);552 var xt0 = that.XforT(t0);553 var scale = Math.max(Math.abs(y0), Math.abs(y1));554 var ymin = Math.max(scale * 1E-14, 1E-300);555 if (sec.sun.awt.geom.Curve.fairlyClose(xs0, xt0)) {556 var bump = ymin;557 var maxbump = Math.min(ymin * 1E13, (y1 - y0) * .1);558 var y = y0 + bump;559 while (y <= y1) {560 if (sec.sun.awt.geom.Curve.fairlyClose(this.XforY(y), that.XforY(y))) {561 if ((bump *= 2) > maxbump) {562 bump = maxbump;563 }564 } else {565 y -= bump;566 while (true) {567 bump /= 2;568 var newy = y + bump;569 if (newy <= y) {570 break;571 }572 if (sec.sun.awt.geom.Curve.fairlyClose(this.XforY(newy), that.XforY(newy))) {573 y = newy;574 }575 }576 break;577 }578 y += bump;579 }580 if (y > y0) {581 if (y < y1) {582 yrange[1] = y;583 }584 return 0;585 }586 }587 if (ymin <= 0) {588 System.out.println("ymin = " + ymin);589 }590 while (s0 < s1 && t0 < t1) {591 var sh = this.nextVertical(s0, s1);592 var xsh = this.XforT(sh);593 var ysh = this.YforT(sh);594 var th = that.nextVertical(t0, t1);595 var xth = that.XforT(th);596 var yth = that.YforT(th);597 try {598 if (this.findIntersect(that, yrange, ymin, 0, 0, s0, xs0, ys0, sh, xsh, ysh, t0, xt0, yt0, th, xth, yth)) {599 break;600 }601 } catch (t) {602 if (Clazz.instanceOf(t, Throwable)) {603 System.err.println("Error: " + t);604 System.err.println("y range was " + yrange[0] + "=>" + yrange[1]);605 System.err.println("s y range is " + ys0 + "=>" + ysh);606 System.err.println("t y range is " + yt0 + "=>" + yth);607 System.err.println("ymin is " + ymin);608 return 0;609 } else {610 throw t;611 }612 }613 if (ysh < yth) {614 if (ysh > yrange[0]) {615 if (ysh < yrange[1]) {616 yrange[1] = ysh;617 }618 break;619 }620 s0 = sh;621 xs0 = xsh;622 ys0 = ysh;623 } else {624 if (yth > yrange[0]) {625 if (yth < yrange[1]) {626 yrange[1] = yth;627 }628 break;629 }630 t0 = th;631 xt0 = xth;632 yt0 = yth;633 }634 }635 var ymid = (yrange[0] + yrange[1]) / 2;636 return sec.sun.awt.geom.Curve.orderof(this.XforY(ymid), that.XforY(ymid));637 };638 this.getSegment = function(coords) {639 switch (this.order) {640 case 0:641 return this.order0.getSegment(coords);642 case 1:643 return this.order1.getSegment(coords);644 case 2:645 return this.order2.getSegment(coords);646 case 3:647 return this.order3.getSegment(coords);648 default:649 return -7;650 }651 };652 this.getSubCurve = function(ystart, yend, dir) {653 switch (this.order) {654 case 0:655 return this.order0.getSubCurve(ystart, yend, dir);656 case 1:657 return this.order1.getSubCurve(ystart, yend, dir);658 case 2:659 return this.order2.getSubCurve(ystart, yend, dir);660 case 3:661 return this.order3.getSubCurve(ystart, yend, dir);662 default:663 return null;664 }665 };666 this.enlarge = function(r) {667 switch (this.order) {668 case 0:669 this.order0.enlarge(r);670 case 1:671 this.order1.enlarge(r);672 case 2:673 this.order2.enlarge(r);674 case 3:675 this.order3.enlarge(r);676 default:677 return;678 }679 };680 this.getWithDirection = function(direction) {681 switch (this.order) {682 case 0:683 return this.order0.getWithDirection(direction);684 case 1:685 return this.order1.getWithDirection(direction);686 case 2:687 return this.order2.getWithDirection(direction);688 case 3:689 return this.order3.getWithDirection(direction);690 default:691 return null;692 }693 };...

Full Screen

Full Screen

testcommon.js

Source:testcommon.js Github

copy

Full Screen

...27 function xForT(t) {28 var omt = 1-t;29 return 3 * omt * omt * t * x1 + 3 * omt * t * t * x2 + t * t * t;30 }31 function yForT(t) {32 var omt = 1-t;33 return 3 * omt * omt * t * y1 + 3 * omt * t * t * y2 + t * t * t;34 }35 function tForX(x) {36 // Binary subdivision.37 var mint = 0, maxt = 1;38 for (var i = 0; i < 30; ++i) {39 var guesst = (mint + maxt) / 2;40 var guessx = xForT(guesst);41 if (x < guessx) {42 maxt = guesst;43 } else {44 mint = guesst;45 }46 }47 return (mint + maxt) / 2;48 }49 return function bezierClosure(x) {50 if (x == 0) {51 return 0;52 }53 if (x == 1) {54 return 1;55 }56 return yForT(tForX(x));57 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1console.log(wpt.yForT(2));2console.log(wpt.xForT(2));3console.log(wpt.tForY(2));4console.log(wpt.tForX(2));5console.log(wpt.yForT(2));6console.log(wpt.xForT(2));7console.log(wpt.tForY(2));8console.log(wpt.tForX(2));

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.yForT('www.webpagetest.org', 100, function(err, data) {4 console.log(data);5});6### runTest(url, options, callback)7wpt.runTest('www.webpagetest.org', function(err, data) {8 console.log(data);9});10### getTestResults(testId, callback)11wpt.getTestResults('130619_8A_6J', function(err, data) {12 console.log(data);13});14### getLocations(callback)15wpt.getLocations(function(err, data) {16 console.log(data);17});18### getTesters(callback)19wpt.getTesters(function(err, data) {20 console.log(data);21});22### getTestStatus(testId, callback)23wpt.getTestStatus('130619_8A_6J', function(err, data) {24 console.log(data);25});26### getMedianRun(testId, callback)27wpt.getMedianRun('130619_8A_6J', function(err, data) {28 console.log(data);29});30### getMedianRunView(testId, view, callback)31wpt.getMedianRunView('130619_8A_6J', 'FirstView', function(err, data) {32 console.log(data);33});34### getTesters(callback)35wpt.getTesters(function(err, data) {36 console.log(data);37});38### getLocations(callback)39wpt.getLocations(function(err, data) {40 console.log(data);41});42### getTesters(callback)43wpt.getTesters(function(err, data) {44 console.log(data);45});46### getLocations(callback)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var test = wpt(options);5test.runTest(url, function(err, data) {6 if (err) return console.error(err);7 test.yForT(data.data.median.firstView, function(err, data) {8 if (err) return console.error(err);9 console.log(data);10 });11});12{ y: 0.8, t: 0.2 }

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require("./wpt");2var myWpt = new wpt("myWpt", 0, 0);3var wpt = require("./wpt");4var myWpt = new wpt("myWpt", 0, 0);5var wpt = require("./wpt");6var myWpt = new wpt("myWpt", 0, 0);7var wpt = require("./wpt");8var myWpt = new wpt("myWpt", 0, 0);9console.log(myWpt

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful