How to use fromPoint method in Testcafe

Best JavaScript code snippet using testcafe

shapes2.mjs

Source:shapes2.mjs Github

copy

Full Screen

1// Return points for WebGL use2export default {3 wire: {4 triangle: function() {},5 cube: function(fromPoint, toPoint) {6 var dims = [7 toPoint[0] - fromPoint[0],8 toPoint[1] - fromPoint[1],9 toPoint[2] - fromPoint[2]10 ];11 // 12 var points = new Float32Array([13 // lower face's outline14 fromPoint[0], fromPoint[1], fromPoint[2],15 fromPoint[0] + dims[0], fromPoint[1], fromPoint[2],16 fromPoint[0] + dims[0], fromPoint[1], fromPoint[2],17 fromPoint[0] + dims[0], fromPoint[1] + dims[1], fromPoint[2],18 fromPoint[0] + dims[0], fromPoint[1] + dims[1], fromPoint[2],19 fromPoint[0], fromPoint[1] + dims[1], fromPoint[2],20 fromPoint[0], fromPoint[1] + dims[1], fromPoint[2],21 fromPoint[0], fromPoint[1], fromPoint[2],22 // higher face's outine23 toPoint[0], toPoint[1], toPoint[2],24 toPoint[0] - dims[0], toPoint[1], toPoint[2],25 toPoint[0] - dims[0], toPoint[1], toPoint[2],26 toPoint[0] - dims[0], toPoint[1] - dims[1], toPoint[2],27 toPoint[0] - dims[0], toPoint[1] - dims[1], toPoint[2],28 toPoint[0], toPoint[1] - dims[1], toPoint[2],29 toPoint[0], toPoint[1] - dims[1], toPoint[2],30 toPoint[0], toPoint[1], toPoint[2],31 // connectors32 fromPoint[0], fromPoint[1], fromPoint[2],33 toPoint[0] - dims[0], toPoint[1] - dims[1], toPoint[2],34 fromPoint[0] + dims[0], fromPoint[1], fromPoint[2],35 toPoint[0], toPoint[1] - dims[1], toPoint[2],36 fromPoint[0] + dims[0], fromPoint[1] + dims[1], fromPoint[2],37 toPoint[0], toPoint[1], toPoint[2],38 fromPoint[0], fromPoint[1] + dims[1], fromPoint[2],39 toPoint[0] - dims[0], toPoint[1], toPoint[2]40 ]);41 return points;42 },43 mesh: function(fromPoint, width, depth) {44 var points = [];45 var w = width - 1;46 var d = depth - 1;47 for (var i = 1; i < w; i++) {48 points.push(fromPoint[0] + i, fromPoint[1], fromPoint[2]);49 points.push(fromPoint[0] + i, fromPoint[1], fromPoint[2] + depth);50 }51 for (var j = 1; j < d; j++) {52 points.push(fromPoint[0], fromPoint[1], fromPoint[2] + j);53 points.push(fromPoint[0] + width, fromPoint[1], fromPoint[2] + j);54 }55 return new Float32Array(points);56 }57 },58 // A flat triangle59 triangle: function(offset) {60 var points = [ 0, 0, 0, 1, 0, 0, 1, 1, 0 ];61 for (var i = 0; i < points.length; i += 3) {62 points[i] += offset[0];63 points[i + 1] += offset[1];64 points[i + 2] += offset[2];65 }66 return {67 vertices: points,68 faces: [ 0, 1, 2 ],69 texcoord: [ 0, 0, 1, 0, 1, 1 ]70 };71 },72 // A flat square - two triangles73 square: function(offset) {74 var points = [75 0, 0, 0,76 0, 1, 0,77 1, 1, 0,78 1, 0, 079 ];80 for (var i = 0; i < points.length; i += 3) {81 points[i] += offset[0];82 points[i + 1] += offset[1];83 points[i + 2] += offset[2];84 }85 return {86 vertices: points,87 faces: [88 0, 3, 2,89 0, 2, 190 ],91 texcoord: [ 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0 ]92 };93 },94 two: {95 // start coordinates and end coordinates96 rectangle: function(start, end) {97 var points = [];98 /*99 0, 0, 0,100 0, 1, 0,101 2, 1, 0,102 0, 0, 0,103 2, 1, 0,104 2, 0, 0105 ];106 */107 /*108 Damn, thought I could bake proper rotation into this, with simple addition.109 Not going to work.110 */111 // hmm, it's easy to think about this in 2 dimensions, but hard in 3112 // easy to choose whether to pull from start or end in 2 dims, but hard in 3113 points.push(start[0], start[1], start[2]);114 points.push(end[0], start[1], end[2]);115 points.push(end[0], end[1], end[2]);116 points.push(start[0], start[1], start[2]);117 points.push(end[0], end[1], end[2]);118 points.push(start[0], end[1], end[2]);119 return {120 position: points,121 texcoord: null,122 normals: null123 };124 }125 },126 three: {127 // Being able to pass divideBy helps us specify whole number values,128 // especially with UV maps129 // Idea taken from avatar module130 rectangle: function(width, height, depth, uvCoordinates, divideBy, texture) {131 var w = width / 2;132 var h = height / 2;133 var d = depth / 2;134 divideBy = divideBy || 1;135 var points = [136 // Back face137 -w, -h, d,138 w, -h, d,139 w, h, d,140 -w, -h, d,141 w, h, d,142 -w, h, d,143 // Front face144 w, -h, -d,145 -w, -h, -d,146 -w, h, -d,147 w, -h, -d,148 -w, h, -d,149 w, h, -d,150 // Top151 -w, h, d,152 w, h, d,153 w, h, -d,154 -w, h, d,155 w, h, -d,156 -w, h, -d,157 // Bottom158 -w, -h, -d,159 w, -h, -d,160 w, -h, d,161 -w, -h, -d,162 w, -h, d,163 -w, -h, d,164 // Left165 -w, -h, -d,166 -w, -h, d,167 -w, h, d,168 -w, -h, -d,169 -w, h, d,170 -w, h, -d,171 // Right172 w, -h, d,173 w, -h, -d,174 w, h, -d,175 w, -h, d,176 w, h, -d,177 w, h, d178 ];179 /*180 var indices = new Uint16Array([181 // TODO: FIX THESE FOR PROPER ROTATION182 // Back183 0, 1, 2,184 0, 2, 3,185 // Front186 5, 4, 7,187 5, 7, 6,188 // Top189 3, 2, 6,190 3, 6, 7,191 // Bottom192 4, 5, 1,193 4, 1, 0,194 // Left195 4, 0, 3,196 4, 3, 7,197 // Right198 1, 5, 6,199 1, 6, 2200 ]);201 */202 var texcoord = new Float32Array((points.length / 3) * 2);203 var j = 0;204 for (var i = 0; i < uvCoordinates.length; i += 4) {205 var x = uvCoordinates[i] / divideBy;206 var y = uvCoordinates[i + 1] / divideBy;207 var x2 = x + (uvCoordinates[i + 2] / divideBy);208 var y2 = y + (uvCoordinates[i + 3] / divideBy);209 texcoord[j] = x210 texcoord[j + 1] = y;211 texcoord[j + 2] = x2;212 texcoord[j + 3] = y;213 texcoord[j + 4] = x2;214 texcoord[j + 5] = y2;215 texcoord[j + 6] = x;216 texcoord[j + 7] = y;217 texcoord[j + 8] = x2;218 texcoord[j + 9] = y2;219 texcoord[j + 10] = x;220 texcoord[j + 11] = y2;221 j += 12;222 }223 var normals = [];224 // back225 normals.push(226 0.0, 0.0, -1.0,227 0.0, 0.0, -1.0,228 0.0, 0.0, -1.0,229 0.0, 0.0, -1.0,230 0.0, 0.0, -1.0,231 0.0, 0.0, -1.0232 );233 // front234 normals.push(235 0.0, 0.0, 1.0,236 0.0, 0.0, 1.0,237 0.0, 0.0, 1.0,238 0.0, 0.0, 1.0,239 0.0, 0.0, 1.0,240 0.0, 0.0, 1.0241 );242 //top243 normals.push(244 0.0, 1.0, 0.0,245 0.0, 1.0, 0.0,246 0.0, 1.0, 0.0,247 0.0, 1.0, 0.0,248 0.0, 1.0, 0.0,249 0.0, 1.0, 0.0250 );251 // bottom252 normals.push(253 0.0, -1.0, 0.0,254 0.0, -1.0, 0.0,255 0.0, -1.0, 0.0,256 0.0, -1.0, 0.0,257 0.0, -1.0, 0.0,258 0.0, -1.0, 0.0259 );260 // left261 normals.push(262 -1.0, 0.0, 0.0,263 -1.0, 0.0, 0.0,264 -1.0, 0.0, 0.0,265 -1.0, 0.0, 0.0,266 -1.0, 0.0, 0.0,267 -1.0, 0.0, 0.0268 );269 // right270 normals.push(271 1.0, 0.0, 0.0,272 1.0, 0.0, 0.0,273 1.0, 0.0, 0.0,274 1.0, 0.0, 0.0,275 1.0, 0.0, 0.0,276 1.0, 0.0, 0.0277 );278 return {279 vertices: new Float32Array(points),280 //indices: indices,281 //faces: faces,282 texcoords: texcoord,283 normals: normals,284 texture: texture285 };286 }287 }...

Full Screen

Full Screen

Diagram.js

Source:Diagram.js Github

copy

Full Screen

1function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }2function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }3import React, { forwardRef, useCallback, useContext, useEffect, useRef, useState } from 'react';4import { ThemeContext } from 'styled-components';5import { defaultProps } from '../../default-props';6import { normalizeColor, parseMetricToNum, useForwardedRef } from '../../utils';7import { StyledDiagram } from './StyledDiagram';8var computeMidPoint = function computeMidPoint(fromPoint, toPoint) {9 return [fromPoint[0] > toPoint[0] ? toPoint[0] + (fromPoint[0] - toPoint[0]) / 2 : fromPoint[0] + (toPoint[0] - fromPoint[0]) / 2, fromPoint[1] > toPoint[1] ? toPoint[1] + (fromPoint[1] - toPoint[1]) / 2 : fromPoint[1] + (toPoint[1] - fromPoint[1]) / 2];10};11var COMMANDS = {12 curved: function curved(fromPoint, toPoint, offset, anchor) {13 var midPoint = computeMidPoint(fromPoint, toPoint);14 var cmds = "M " + (fromPoint[0] + offset) + "," + (fromPoint[1] + offset) + " ";15 if (anchor === 'horizontal') {16 cmds += "Q " + (midPoint[0] + offset) + "," + (fromPoint[1] + offset) + " " + (midPoint[0] + offset + "," + (midPoint[1] + offset) + " ");17 } else {18 cmds += "Q " + (fromPoint[0] + offset) + "," + (midPoint[1] + offset) + " " + (midPoint[0] + offset + "," + (midPoint[1] + offset) + " ");19 }20 cmds += "T " + (toPoint[0] + offset) + "," + (toPoint[1] + offset);21 return cmds;22 },23 direct: function direct(fromPoint, toPoint, offset) {24 return "M " + (fromPoint[0] + offset) + "," + (fromPoint[1] + offset) + " " + ("L " + (toPoint[0] + offset) + "," + (toPoint[1] + offset));25 },26 rectilinear: function rectilinear(fromPoint, toPoint, offset, anchor) {27 var midPoint = computeMidPoint(fromPoint, toPoint);28 var cmds = "M " + (fromPoint[0] + offset) + "," + (fromPoint[1] + offset) + " ";29 if (anchor === 'horizontal') {30 cmds += "L " + (midPoint[0] + offset) + "," + (fromPoint[1] + offset) + " " + ("L " + (midPoint[0] + offset) + "," + (toPoint[1] + offset) + " ");31 } else {32 cmds += "L " + (fromPoint[0] + offset) + "," + (midPoint[1] + offset) + " " + ("L " + (toPoint[0] + offset) + "," + (midPoint[1] + offset) + " ");33 }34 cmds += "L " + (toPoint[0] + offset) + "," + (toPoint[1] + offset);35 return cmds;36 }37};38var findTarget = function findTarget(target) {39 if (typeof target === 'string') {40 return document.getElementById(target);41 }42 return target;43};44var Diagram = /*#__PURE__*/forwardRef(function (_ref, ref) {45 var connections = _ref.connections,46 rest = _objectWithoutPropertiesLoose(_ref, ["connections"]);47 var theme = useContext(ThemeContext) || defaultProps.theme;48 var _useState = useState({49 width: 0,50 height: 051 }),52 dimensions = _useState[0],53 setDimensions = _useState[1];54 var _useState2 = useState(),55 connectionPoints = _useState2[0],56 setConnectionPoints = _useState2[1];57 var svgRef = useForwardedRef(ref);58 useEffect(function () {59 setConnectionPoints(undefined);60 }, [connections]);61 var onResize = useCallback(function () {62 var svg = svgRef.current;63 if (svg) {64 var rect = svg.getBoundingClientRect();65 if (rect.width !== dimensions.width || rect.height !== dimensions.height) {66 setDimensions({67 width: rect.width,68 height: rect.height69 });70 setConnectionPoints(undefined);71 }72 }73 }, [dimensions.width, dimensions.height, svgRef]); // Ref that stores resize handler74 var savedOnResize = useRef(); // Update resize ref value if onResize changes.75 // This allows our effect below to always get latest handler76 useEffect(function () {77 savedOnResize.current = onResize;78 }, [onResize]);79 useEffect(function () {80 var onResizeHandler = function onResizeHandler(event) {81 return savedOnResize.current(event);82 };83 onResizeHandler();84 window.addEventListener('resize', onResizeHandler);85 return function () {86 window.removeEventListener('resize', onResizeHandler);87 };88 }, []);89 var placeConnections = useCallback(function () {90 var containerRect = svgRef.current.getBoundingClientRect();91 var updatedConnectionPoints = connections.map(function (_ref2) {92 var anchor = _ref2.anchor,93 fromTarget = _ref2.fromTarget,94 toTarget = _ref2.toTarget;95 var points;96 var fromElement = findTarget(fromTarget);97 var toElement = findTarget(toTarget);98 if (!fromElement) {99 console.warn("Diagram cannot find " + fromTarget);100 }101 if (!toElement) {102 console.warn("Diagram cannot find " + toTarget);103 }104 if (fromElement && toElement) {105 var fromRect = fromElement.getBoundingClientRect();106 var toRect = toElement.getBoundingClientRect(); // There is no x and y when unit testing.107 var fromPoint = [fromRect.left - containerRect.left || 0, fromRect.top - containerRect.top || 0];108 var toPoint = [toRect.left - containerRect.left || 0, toRect.top - containerRect.top || 0];109 if (anchor === 'vertical') {110 fromPoint[0] += fromRect.width / 2;111 toPoint[0] += toRect.width / 2;112 if (fromRect.top < toRect.top) {113 fromPoint[1] += fromRect.height;114 } else {115 toPoint[1] += toRect.height;116 }117 } else if (anchor === 'horizontal') {118 fromPoint[1] += fromRect.height / 2;119 toPoint[1] += toRect.height / 2;120 if (fromRect.left < toRect.left) {121 fromPoint[0] += fromRect.width;122 } else {123 toPoint[0] += toRect.width;124 }125 } else {126 // center127 fromPoint[0] += fromRect.width / 2;128 fromPoint[1] += fromRect.height / 2;129 toPoint[0] += toRect.width / 2;130 toPoint[1] += toRect.height / 2;131 }132 points = [fromPoint, toPoint];133 }134 return points;135 });136 setConnectionPoints(updatedConnectionPoints);137 }, [connections, svgRef]);138 useEffect(function () {139 if (!connectionPoints) {140 placeConnections();141 }142 }, [connectionPoints, placeConnections]);143 var paths;144 if (connectionPoints) {145 paths = connections.map(function (_ref3, index) {146 var anchor = _ref3.anchor,147 color = _ref3.color,148 offset = _ref3.offset,149 round = _ref3.round,150 thickness = _ref3.thickness,151 type = _ref3.type,152 connectionRest = _objectWithoutPropertiesLoose(_ref3, ["anchor", "color", "offset", "round", "thickness", "type"]);153 var path;154 var cleanedRest = _extends({}, connectionRest);155 delete cleanedRest.fromTarget;156 delete cleanedRest.toTarget;157 var points = connectionPoints[index];158 if (points) {159 var offsetWidth = offset ? parseMetricToNum(theme.global.edgeSize[offset]) : 0;160 var d = COMMANDS[type || 'curved'](points[0], points[1], offsetWidth, anchor);161 var strokeWidth = thickness ? parseMetricToNum(theme.global.edgeSize[thickness] || thickness) : 1;162 var colorName = color || theme.diagram.line && theme.diagram.line.color;163 if (!colorName) {164 var colors = Object.keys(theme.global.colors).filter(function (n) {165 return n.match(/^graph-[0-9]$/);166 });167 colorName = colors[index % colors.length];168 }169 path = /*#__PURE__*/React.createElement("path", _extends({170 // eslint-disable-next-line react/no-array-index-key171 key: index172 }, cleanedRest, {173 stroke: normalizeColor(colorName, theme),174 strokeWidth: strokeWidth,175 strokeLinecap: round ? 'round' : 'butt',176 strokeLinejoin: round ? 'round' : 'miter',177 fill: "none",178 d: d179 }));180 }181 return path;182 });183 }184 return /*#__PURE__*/React.createElement(StyledDiagram, _extends({185 ref: svgRef,186 viewBox: "0 0 " + dimensions.width + " " + dimensions.height,187 preserveAspectRatio: "xMinYMin meet"188 }, rest), /*#__PURE__*/React.createElement("g", null, paths));189});190Diagram.displayName = 'Diagram';191Diagram.defaultProps = {192 connections: []193};194var DiagramDoc;195if (process.env.NODE_ENV !== 'production') {196 // eslint-disable-next-line global-require197 DiagramDoc = require('./doc').doc(Diagram);198}199var DiagramWrapper = DiagramDoc || Diagram;...

Full Screen

Full Screen

DimensioningLink.js

Source:DimensioningLink.js Github

copy

Full Screen

1"use strict";2/*3* Copyright (C) 1998-2018 by Northwoods Software Corporation. All Rights Reserved.4*/5// A custom routed Link for showing the distances between a point on one node and a point on another node.6// Note that because this is a Link, the points being measured must be on Nodes, not simple Parts.7// The exact point on each Node is determined by the Link.fromSpot and Link.toSpot.8// Several properties of the DimensioningLink customize the appearance of the dimensioning:9// direction, for orientation of the dimension line and which side it is on,10// extension, for how far the dimension line is from the measured points,11// inset, for leaving room for a text label, and12// gap, for distance that the extension line starts from the measured points13/**14* @constructor15* @extends Link16* @class17*/18function DimensioningLink() {19 go.Link.call(this);20 this.isLayoutPositioned = false;21 this.isTreeLink = false;22 this.routing = go.Link.Orthogonal;23 /** @type {number} */24 this._direction = 0;25 /** @type {number} */26 this._extension = 30;27 /** @type {number} */28 this._inset = 10;29 /** @type {number} */30 this._gap = 10;31}32go.Diagram.inherit(DimensioningLink, go.Link);33/*34* The general angle at which the measurement should be made.35* The default value is 0, meaning to go measure only along the X axis,36* with the dimension line and label above the two nodes (at lower Y coordinates).37* New values must be one of: 0, 90, 180, 270, or NaN.38* The value NaN indicates that the measurement is point-to-point and not orthogonal.39* @name DimensioningLink#direction40* @function.41* @return {number}42*/43Object.defineProperty(DimensioningLink.prototype, "direction", {44 get: function() { return this._direction; },45 set: function(value) {46 if (isNaN(value) || value === 0 || value === 90 || value === 180 || value === 270) {47 this._direction = value;48 } else {49 throw new Error("DimensioningLink: invalid new direction: " + value);50 }51 }52});53/*54* The distance at which the dimension line should be from the points being measured.55* The default value is 30.56* Larger values mean further away from the nodes.57* The new value must be greater than or equal to zero.58* @name DimensioningLink#extension59* @function.60* @return {number}61*/62Object.defineProperty(DimensioningLink.prototype, "extension", {63 get: function() { return this._extension; },64 set: function(value) { this._extension = value; }65});66/*67* The distance that the dimension line should be "indented" from the ends of the68* extension lines that are orthogonal to the dimension line.69* The default value is 10.70* @name DimensioningLink#inset71* @function.72* @return {number}73*/74Object.defineProperty(DimensioningLink.prototype, "inset", {75 get: function() { return this._inset; },76 set: function(value) {77 if (value >= 0) {78 this._inset = value;79 } else {80 throw new Error("DimensioningLink: invalid new inset: " + value);81 }82 }83});84/*85* The distance that the extension lines should come short of the measured points.86* The default value is 10.87* @name DimensioningLink#gap88* @function.89* @return {number}90*/91Object.defineProperty(DimensioningLink.prototype, "gap", {92 get: function() { return this._gap; },93 set: function(value) {94 if (value >= 0) {95 this._gap = value;96 } else {97 throw new Error("DimensioningLink: invalid new gap: " + value);98 }99 }100});101/**102* @override103* @return {boolean} true if it computed a route of points104*/105DimensioningLink.prototype.computePoints = function() {106 var fromnode = this.fromNode;107 if (!fromnode) return false;108 var fromport = this.fromPort;109 var fromspot = this.computeSpot(true);110 var tonode = this.toNode;111 if (!tonode) return false;112 var toport = this.toPort;113 var tospot = this.computeSpot(false);114 var frompoint = this.getLinkPoint(fromnode, fromport, fromspot, true, true, tonode, toport);115 if (!frompoint.isReal()) return false;116 var topoint = this.getLinkPoint(tonode, toport, tospot, false, true, fromnode, fromport);117 if (!topoint.isReal()) return false;118 this.clearPoints();119 var ang = this.direction;120 if (isNaN(ang)) {121 ang = frompoint.directionPoint(topoint);122 var p = new go.Point(this.extension, 0);123 p.rotate(ang + 90);124 var q = new go.Point(this.extension - this.inset, 0);125 q.rotate(ang + 90);126 var g = new go.Point(this.gap, 0);127 g.rotate(ang + 90);128 this.addPointAt(frompoint.x + g.x, frompoint.y + g.y);129 this.addPointAt(frompoint.x + p.x, frompoint.y + p.y);130 this.addPointAt(frompoint.x + q.x, frompoint.y + q.y);131 this.addPointAt(topoint.x + q.x, topoint.y + q.y);132 this.addPointAt(topoint.x + p.x, topoint.y + p.y);133 this.addPointAt(topoint.x + g.x, topoint.y + g.y);134 } else {135 var dist = this.extension;136 var r = 0.0;137 var s = 0.0;138 var t0 = 0.0;139 var t1 = 0.0;140 if (ang === 0 || ang === 180) {141 if (ang === 0) {142 r = Math.min(frompoint.y, topoint.y) - this.extension;143 s = r + this.inset;144 t0 = frompoint.y - this.gap;145 t1 = topoint.y - this.gap;146 } else {147 r = Math.max(frompoint.y, topoint.y) + this.extension;148 s = r - this.inset;149 t0 = frompoint.y + this.gap;150 t1 = topoint.y + this.gap;151 }152 this.addPointAt(frompoint.x, t0);153 this.addPointAt(frompoint.x + 0.01, r);154 this.addPointAt(frompoint.x, s);155 this.addPointAt(topoint.x, s);156 this.addPointAt(topoint.x - 0.01, r);157 this.addPointAt(topoint.x, t1);158 } else if (ang === 90 || ang === 270) {159 if (ang === 90) {160 r = Math.max(frompoint.x, topoint.x) + this.extension;161 s = r - this.inset;162 t0 = frompoint.x + this.gap;163 t1 = topoint.x + this.gap;164 } else {165 r = Math.min(frompoint.x, topoint.x) - this.extension;166 s = r + this.inset;167 t0 = frompoint.x - this.gap;168 t1 = topoint.x - this.gap;169 }170 this.addPointAt(t0, frompoint.y);171 this.addPointAt(r, frompoint.y + 0.01);172 this.addPointAt(s, frompoint.y);173 this.addPointAt(s, topoint.y);174 this.addPointAt(r, topoint.y - 0.01);175 this.addPointAt(t1, topoint.y);176 }177 }178 this.updateTargetBindings();179 return true;...

Full Screen

Full Screen

day_5.js

Source:day_5.js Github

copy

Full Screen

1// ##################### Part 1 #####################2const fs = require('fs')3const content = fs.readFileSync(process.cwd() + "\\" + "day_5_data.txt").toString()4/*5Parse format: 6[7 { fromPoint: { x: 715, y: 620 }, toPoint: { x: 715, y: 633 } },8 { fromPoint: { x: 915, y: 385 }, toPoint: { x: 505, y: 385 } },9 ...10]11*/12const contentArr = content13 .split("\r\n")14 .map(line => {15 const fromToArr = line.split(" -> ")16 return {17 fromPoint: {18 x: parseInt(fromToArr[0].split(",")[0]),19 y: parseInt(fromToArr[0].split(",")[1])20 },21 toPoint: {22 x: parseInt(fromToArr[1].split(",")[0]),23 y: parseInt(fromToArr[1].split(",")[1])24 }25 }26 })27//Find the largest X and Y coordinate28let maxX = 029let maxY = 030contentArr.forEach(line => {31 line.fromPoint.x > maxX && (maxX = line.fromPoint.x)32 line.toPoint.x > maxX && (maxX = line.toPoint.x)33 line.fromPoint.y > maxY && (maxY = line.fromPoint.y)34 line.toPoint.y > maxY && (maxY = line.toPoint.y)35})36// Create maxX by maxY matrix representing diagram37const diagram = Array.from(Array(maxY + 1), _ => Array(maxX + 1).fill(0))38// Filter ut only the straight lines (no diagonals)39const straightLines = contentArr.filter(line =>40 line.fromPoint.x === line.toPoint.x ||41 line.fromPoint.y === line.toPoint.y42)43// Fills a straight line in the diagram, increments the cell44// in the diagram it crosses45function fillStraightLineInDiagram(line) {46 if (line.fromPoint.x === line.toPoint.x) {47 let x = line.fromPoint.x48 let fromY = Math.min(line.fromPoint.y, line.toPoint.y)49 let toY = Math.max(line.fromPoint.y, line.toPoint.y)50 for (let y = fromY; y <= toY; y++) {51 diagram[x][y] += 152 }53 } else {54 let y = line.fromPoint.y55 let fromX = Math.min(line.fromPoint.x, line.toPoint.x)56 let toX = Math.max(line.fromPoint.x, line.toPoint.x)57 for (let x = fromX; x <= toX; x++) {58 diagram[x][y] += 159 }60 }61}62// Fill all the straight lines63straightLines.forEach(line => {64 fillStraightLineInDiagram(line)65})66// Count the cells which are crossed by multiple lines, 67// i.e. contain a number higher than 168let straightLineCounter = 069for (let i = 0; i < diagram.length; i++) {70 for (let j = 0; j < diagram[i].length; j++) {71 if (2 <= diagram[i][j]) straightLineCounter++;72 }73}74// Part 1 result75console.log({ straightLineCounter });76// ##################### Part 2 #####################77// All the diagonal lines78const diagonalLines = contentArr.filter(line =>79 line.fromPoint.x !== line.toPoint.x &&80 line.fromPoint.y !== line.toPoint.y81)82// Not the prettiest solution...83// It's late and I can't be bothered84// Fills a diagonal line in the diagram, increments the cell85// in the diagram it crosses86function fillDiagonalLineInDiagram(line) {87 let x = line.fromPoint.x88 let y = line.fromPoint.y89 if (line.fromPoint.x < line.toPoint.x) {90 if (line.fromPoint.y < line.toPoint.y) {91 while (true) {92 if (x > line.toPoint.x) break;93 diagram[x][y] += 194 x++;95 y++;96 }97 } else {98 while (true) {99 if (x > line.toPoint.x) break;100 diagram[x][y] += 1101 x++;102 y--;103 }104 }105 } else {106 if (line.fromPoint.y < line.toPoint.y) {107 while (true) {108 if (x < line.toPoint.x) break;109 diagram[x][y] += 1110 x--;111 y++;112 }113 } else {114 while (true) {115 if (x < line.toPoint.x) break;116 diagram[x][y] += 1117 x--;118 y--;119 }120 }121 }122}123// Fill all the diagonal lines124// Part 1 filled the straight lines, this is using the125// same (already filled) diagram from part 1126diagonalLines.forEach(line => {127 fillDiagonalLineInDiagram(line)128})129// Count the cells which are crossed by multiple lines 130// (both diagonal and straight), 131// i.e. contain a number higher than 1132let totalCounter = 0133for (let i = 0; i < diagram.length; i++) {134 for (let j = 0; j < diagram[i].length; j++) {135 if (2 <= diagram[i][j]) totalCounter++;136 }137}138// Part 2 result...

Full Screen

Full Screen

RollerCoasterLifters.js

Source:RollerCoasterLifters.js Github

copy

Full Screen

1/**2 * @author mrdoob / http://mrdoob.com/3 */4var routing = require('../routing');5var RollerCoasterLifters = function ( curve, size ) {6 THREE.BufferGeometry.call( this );7 var vertices = [];8 var normals = [];9 var quaternion = new THREE.Quaternion();10 var up = new THREE.Vector3( 0, 1, 0 );11 var point = new THREE.Vector3();12 var tangent = new THREE.Vector3();13 // shapes14 var tube1 = [15 new THREE.Vector3( 0, 0.5, -0.5 ),16 new THREE.Vector3( 0, 0.5, 0.5 ),17 new THREE.Vector3( 0, -0.5, 0 )18 ];19 var tube2 = [20 new THREE.Vector3( -0.5, 0, 0.5 ),21 new THREE.Vector3( -0.5, 0, -0.5 ),22 new THREE.Vector3( 0.5, 0, 0 )23 ];24 var tube3 = [25 new THREE.Vector3( 0.5, 0, -0.5 ),26 new THREE.Vector3( 0.5, 0, 0.5 ),27 new THREE.Vector3( -0.5, 0, 0 )28 ];29 var vector1 = new THREE.Vector3();30 var vector2 = new THREE.Vector3();31 var vector3 = new THREE.Vector3();32 var vector4 = new THREE.Vector3();33 var normal1 = new THREE.Vector3();34 var normal2 = new THREE.Vector3();35 var normal3 = new THREE.Vector3();36 var normal4 = new THREE.Vector3();37 var extrudeShape = function ( shape, fromPoint, toPoint ) {38 for ( var j = 0, jl = shape.length; j < jl; j ++ ) {39 var point1 = shape[ j ];40 var point2 = shape[ ( j + 1 ) % jl ];41 vector1.copy( point1 )42 vector1.applyQuaternion( quaternion );43 vector1.add( fromPoint );44 vector2.copy( point2 )45 vector2.applyQuaternion( quaternion );46 vector2.add( fromPoint );47 vector3.copy( point2 )48 vector3.applyQuaternion( quaternion );49 vector3.add( toPoint );50 vector4.copy( point1 )51 vector4.applyQuaternion( quaternion );52 vector4.add( toPoint );53 vertices.push( vector1.x, vector1.y, vector1.z );54 vertices.push( vector2.x, vector2.y, vector2.z );55 vertices.push( vector4.x, vector4.y, vector4.z );56 vertices.push( vector2.x, vector2.y, vector2.z );57 vertices.push( vector3.x, vector3.y, vector3.z );58 vertices.push( vector4.x, vector4.y, vector4.z );59 //60 normal1.copy( point1 );61 normal1.applyQuaternion( quaternion );62 normal1.normalize();63 normal2.copy( point2 );64 normal2.applyQuaternion( quaternion );65 normal2.normalize();66 normal3.copy( point2 );67 normal3.applyQuaternion( quaternion );68 normal3.normalize();69 normal4.copy( point1 );70 normal4.applyQuaternion( quaternion );71 normal4.normalize();72 normals.push( normal1.x, normal1.y, normal1.z );73 normals.push( normal2.x, normal2.y, normal2.z );74 normals.push( normal4.x, normal4.y, normal4.z );75 normals.push( normal2.x, normal2.y, normal2.z );76 normals.push( normal3.x, normal3.y, normal3.z );77 normals.push( normal4.x, normal4.y, normal4.z );78 }79 };80 var fromPoint = new THREE.Vector3();81 var toPoint = new THREE.Vector3();82 for ( var i = 1; i <= size; i ++ ) {83 point.copy( curve.getPointAt( i / size ) );84 tangent.copy( curve.getTangentAt( i / size ) );85 var angle = Math.atan2( tangent.x, tangent.z );86 quaternion.setFromAxisAngle( up, angle );87 //88 if ( point.y > 100 ) {89 fromPoint.set( -7.5, -3.5, 0 );90 fromPoint.applyQuaternion( quaternion );91 fromPoint.add( point );92 toPoint.set( 7.5, -3.5, 0 );93 toPoint.applyQuaternion( quaternion );94 toPoint.add( point );95 extrudeShape( tube1, fromPoint, toPoint );96 97 fromPoint.set( -7, -3, 0 );98 fromPoint.applyQuaternion( quaternion );99 fromPoint.add( point );100 toPoint.set( -7, -point.y, 0 );101 toPoint.applyQuaternion( quaternion );102 toPoint.add( point );103 extrudeShape( tube2, fromPoint, toPoint );104 fromPoint.set( 7, -3, 0 );105 fromPoint.applyQuaternion( quaternion );106 fromPoint.add( point );107 toPoint.set( 7, -point.y, 0 );108 toPoint.applyQuaternion( quaternion );109 toPoint.add( point );110 extrudeShape( tube3, fromPoint, toPoint );111 } else {112 fromPoint.set( 0, -2, 0 );113 fromPoint.applyQuaternion( quaternion );114 fromPoint.add( point );115 toPoint.set( 0, -point.y, 0 );116 toPoint.applyQuaternion( quaternion );117 toPoint.add( point );118 extrudeShape( tube3, fromPoint, toPoint );119 }120 }121 this.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( vertices ), 3 ) );122 this.addAttribute( 'normal', new THREE.BufferAttribute( new Float32Array( normals ), 3 ) );123};124module.exports = RollerCoasterLifters;...

Full Screen

Full Screen

LineTextView_svg.js

Source:LineTextView_svg.js Github

copy

Full Screen

1/**2 * <p>Title: </p>3 * <p>Description: </p>4 * <p>Copyright: Copyright (c) xio.name 2006</p>5 * @author xio6 */7function LineTextView_svg() {8 this.base = LineView_svg_t;9 this.base();10 //this.setPosition("absolute");11 //this.setLeft("0px");12 //this.setTop("0px");13 //14 //this.path = Toolkit.newElement("<v:path textpathok='true'/>");15 this.path = Toolkit.newElement("<input type='hidden' name='path' />");16 this.add(this.path);17 //18 this.textPath = Toolkit.newElement("<input type='text' name='textpath' />");19 this.add(this.textPath);20}21LineTextView_svg.prototype = new LineView_svg_t();22//23LineTextView_svg.prototype.setText = function (text) {24 text = text ? text : "";25 //this.textPath.string = text;26 this.getSvgLineUI().textContent = "  "+text;27};28LineTextView_svg.prototype.getText = function () {29 return this.textPath.string;30};31//32LineTextView_svg.prototype.setFrom = function (point) {33 if (!point) {34 return;35 }36 this.fromPoint = point;37 this._updateDirection();38};39LineTextView_svg.prototype.setTo = function (point) {40 if (!point) {41 return;42 }43 this.toPoint = point;44 this._updateDirection();45};46LineTextView_svg.prototype._updateDirection = function () {47 if (!this.fromPoint) {48 return;49 }50 if (!this.toPoint) {51 return;52 }53 //54 if (this.fromPoint.getX() == this.toPoint.getX()) {55 this.fromPoint.setX(this.fromPoint.getX() - 1);56 }57 if (this.fromPoint.getY() == this.toPoint.getY()) {58 this.fromPoint.setY(this.fromPoint.getY() - 1);59 }60 61 //设置text的起始位置62 var XX1=this.fromPoint.getX();63 var YY1=this.fromPoint.getY();64 var XX2=this.toPoint.getX();65 var YY2=this.toPoint.getY();66 //67 if (this.fromPoint.getX() > this.toPoint.getX()) {68 //this.getUI().from = this.toPoint.getX() + "," + this.toPoint.getY();69 //this.getUI().to = this.fromPoint.getX() + "," + this.fromPoint.getY();70 /*this.getSvgLineUI().setAttribute("x1",this.toPoint.getX());71 this.getSvgLineUI().setAttribute("y1",this.toPoint.getY());72 this.getSvgLineUI().setAttribute("x2",this.fromPoint.getX());73 this.getSvgLineUI().setAttribute("y2",this.fromPoint.getY());*/74 this.getSvgLineUI().setAttribute("x",this.toPoint.getX());75 this.getSvgLineUI().setAttribute("y",this.toPoint.getY());76 XX2=this.fromPoint.getX();77 YY2=this.fromPoint.getY();78 XX1=this.toPoint.getX();79 YY1=this.toPoint.getY();80 81 } else {82 //this.getUI().from = this.fromPoint.getX() + "," + this.fromPoint.getY();83 //this.getUI().to = this.toPoint.getX() + "," + this.toPoint.getY();84 /*this.getSvgLineUI().setAttribute("x2",this.toPoint.getX());85 this.getSvgLineUI().setAttribute("y2",this.toPoint.getY());86 this.getSvgLineUI().setAttribute("x1",this.fromPoint.getX());87 this.getSvgLineUI().setAttribute("y1",this.fromPoint.getY());*/88 this.getSvgLineUI().setAttribute("x",this.fromPoint.getX());89 this.getSvgLineUI().setAttribute("y",this.fromPoint.getY());90 XX1=this.fromPoint.getX();91 YY1=this.fromPoint.getY();92 XX2=this.toPoint.getX();93 YY2=this.toPoint.getY();94 }95 //var x0=(XX1+XX2)/2;96 //var y0=(YY1+YY2)/2;97 98 //设置字的角度99 var angle=Toolkit.getAngle(XX1,YY1, XX2, YY2);100 this.getSvgLineUI().setAttribute("transform", " rotate("+ angle+","+XX1+","+YY1+")");...

Full Screen

Full Screen

LineTextView.js

Source:LineTextView.js Github

copy

Full Screen

1/**2 * <p>Title: </p>3 * <p>Description: </p>4 * <p>Copyright: Copyright (c) itsm.name 2006</p>5 * @author itsm6 */7function LineTextView() {8 //this.base = LineView;9 this.base = Component;10 this.base(Toolkit.newElement("v:line"));11 //this.base();12 this.setPosition("absolute");13 this.setLeft("0px");14 this.setTop("0px");15 //16 this.path = Toolkit.newElement("<v:path textpathok='true'/>");17 this.add(this.path);18 //19 this.textPath = Toolkit.newElement("<v:textpath on='true' style='font-size:15' string=''/>");20 this.add(this.textPath);21}22LineTextView.prototype = new LineView();23//24LineTextView.prototype.setText = function (text) {25 text = text ? text : "";26 this.textPath.string = text;27};28LineTextView.prototype.getText = function () {29 return this.textPath.string;30};31//32LineTextView.prototype.setFrom = function (point) {33 if (!point) {34 return;35 }36 this.fromPoint = point;37 this._updateDirection();38};39LineTextView.prototype.setTo = function (point) {40 if (!point) {41 return;42 }43 this.toPoint = point;44 this._updateDirection();45};46LineTextView.prototype._updateDirection = function () {47 //alert('bbbb');48 if (!this.fromPoint) {49 return;50 }51 if (!this.toPoint) {52 return;53 }54 //alert('ccc');55 //this.fromPoint.setX('248.33333333333337')56 //this.fromPoint.setY('118')57 //this.toPoint.setX('148.66666666666663')58 //this.toPoint.setY('170')59 //60 //alert(this.fromPoint.getX()+'=='+this.fromPoint.getY()+'=='+this.toPoint.getX()+'=='+this.toPoint.getY());61 if (this.fromPoint.getX() == this.toPoint.getX()) {62 this.fromPoint.setX(this.fromPoint.getX() - 1);63 }64 if (this.fromPoint.getY() == this.toPoint.getY()) {65 this.fromPoint.setY(this.fromPoint.getY() - 1);66 }67 //alert(this.fromPoint.getX()+'--'+this.fromPoint.getY()+'--'+this.toPoint.getX()+'--'+this.toPoint.getY());68 //69 var absX = Math.abs(this.toPoint.getX() - this.fromPoint.getX());70 var absY = Math.abs(this.toPoint.getY() - this.fromPoint.getY());71 var absL = Math.sqrt(absX*absX+absY*absY);72 var xx = absY*10/absL; /// (absX * absY);73 var yy = absX*10/absL; /// (absX * absY);74 if (this.fromPoint.getX() > this.toPoint.getX()) {75 if(this.fromPoint.getY()>this.toPoint.getY()){76 this.getUI().from = (this.toPoint.getX()+xx) + "," + (this.toPoint.getY()-yy);77 this.getUI().to = (this.fromPoint.getX()+xx) + "," + (this.fromPoint.getY()-yy);78 }else{79 this.getUI().from = (this.toPoint.getX()+xx) + "," + (this.toPoint.getY()+yy);80 this.getUI().to = (this.fromPoint.getX()+xx) + "," + (this.fromPoint.getY()+yy);81 }82 } else {83 if(this.fromPoint.getY()>this.toPoint.getY()){84 this.getUI().from = (this.fromPoint.getX()+xx) + "," + (this.fromPoint.getY()+yy);85 this.getUI().to = (this.toPoint.getX()+xx) + "," + (this.toPoint.getY()+yy);86 }else{87 this.getUI().from = (this.fromPoint.getX()+xx) + "," + (this.fromPoint.getY()-yy);88 this.getUI().to = (this.toPoint.getX()+xx) + "," + (this.toPoint.getY()-yy);89 }90 //this.getUI().from = this.fromPoint.getX() + "," + this.fromPoint.getY();91 //this.getUI().to = this.toPoint.getX() + "," + this.toPoint.getY();92 }...

Full Screen

Full Screen

atan2-1.js

Source:atan2-1.js Github

copy

Full Screen

1// SETUP CANVAS2var canvas = document.getElementById('gamearea'),3ctx = canvas.getContext('2d');4canvas.width = 500;5canvas.height = 500;6 7var state = {8 toPoint: {9 x: canvas.width / 2 + 50,10 y: canvas.height / 2 + 5011 },12 fromPoint: {13 x: canvas.width / 2,14 y: canvas.height / 215 },16 a: 0,17 findAngle: function () {18 this.a = Math.atan2(this.toPoint.y - this.fromPoint.y, this.toPoint.x - this.fromPoint.x);19 }20};21 22// a findAngle method that takes 2 arguments and returns and angle in degrees23var findAngle = function (source, destination) {24 const dx = destination.x - source.x;25 const dy = destination.y - source.y;26 // return (Math.atan2(y1 - y2, x1 - x2) + Math.PI) / Math.PI * 180;27 var angleRad = Math.atan2(dy, dx);28 var angleDegrees = angleRad * (180 / Math.PI);29 /* 30 if(angleRad < 0) {31 angleDegrees = angleDegrees + 360;32}33*/34//degree: 180 - angle35 return 180 - angleDegrees;36 };37// UPADTE38var update = function () {39 state.findAngle();40};41 42// DRAW43var drawPoint = function (point, style) {44 style = style || 'red';45 ctx.beginPath();46 ctx.strokeStyle = style;47 ctx.arc(point.x, point.y, 15, 0, Math.PI * 2);48 ctx.closePath();49 ctx.stroke();50};51 52var draw = function () {53 ctx.fillStyle = 'black';54 ctx.fillRect(0, 0, canvas.width, canvas.height);55 56 drawPoint(state.fromPoint, 'white');57 drawPoint(state.toPoint, 'red');58 59 // draw line from state.fromPoint tp state.toPoint60 ctx.strokeStyle = 'yellow';61 ctx.beginPath();62 ctx.moveTo(state.fromPoint.x, state.fromPoint.y);63 ctx.lineTo(64 state.fromPoint.x + Math.cos(state.a) * 50,65 state.fromPoint.y + Math.sin(state.a) * 50)66 ctx.stroke();67};68 69// INPUT70canvas.addEventListener('mousemove', function (e) {71 var bb = e.target.getBoundingClientRect(),72 x1 = e.clientX - bb.left,73 y1 = e.clientY - bb.top;74 75 state.toPoint.x = x1;76 state.toPoint.y = y1;77 var x2 = state.fromPoint.x;78 var y2 = state.fromPoint.y;79 var info = document.getElementById('angle');80 var angle = findAngle (state.toPoint, state.fromPoint);81 info.innerHTML = "angle = " + angle;82 83});84canvas.addEventListener('mousedown', function (e) {85 var bb = e.target.getBoundingClientRect();86 var x1 = e.clientX - bb.left;87 var y1 = e.clientY - bb.top;88 var info = document.getElementById('angle');89 var x2 = state.fromPoint.x;90 var y2 = state.fromPoint.y;91 var angle = findAngle (state.fromPoint, state.fromPoint);92 info.innerHTML = "angle = " + angle;93 /* 94 state.fromPoint.x = x;95 state.fromPoint.y = y;96 */97});98 99// LOOP100var loop = function () {101 requestAnimationFrame(loop);102 update();103 draw();104};105 ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#tried-test-cafe')5 .click(Selector('label').withText('JavaScript API'))6 .click('#submit-button');7});8import { Selector } from 'testcafe';9test('My first test', async t => {10 .typeText('#developer-name', 'John Smith')11 .click('#tried-test-cafe')12 .click(Selector('label').withText('JavaScript API'))13 .click('#submit-button');14});15import { Selector } from 'testcafe';16test('My first test', async t => {17 .typeText('#developer-name', 'John Smith')18 .click('#tried-test-cafe')19 .click(Selector('label').withText('JavaScript API'))20 .click('#submit-button');21});22import { Selector } from 'testcafe';23test('My first test', async t => {24 .typeText('#developer-name', 'John Smith')25 .click('#tried-test-cafe')26 .click(Selector('label').withText('JavaScript API'))27 .click('#submit-button');28});29import { Selector } from 'testcafe';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 .typeText('#developer-name', 'John Smith')4 .click('#macos')5 .click('#submit-button');6 const articleHeader = await Selector('.result-content').find('h1');7 let headerText = await articleHeader.innerText;8});9import { Selector } from 'testcafe';10test('My first test', async t => {11 .typeText('#developer-name', 'John Smith')12 .click('#macos')13 .click('#submit-button');14 const articleHeader = Selector(() => {15 const article = document.querySelector('#article-header');16 return article.querySelector('h1');17 });18 let headerText = await articleHeader.innerText;19});20import { Selector, ClientFunction } from 'testcafe';21test('My first test', async t => {22 .typeText('#developer-name', 'John Smith')23 .click('#macos')24 .click('#submit-button');25 const getArticleHeader = ClientFunction(() => document.querySelector('#article-header').innerHTML);26 const articleHeader = Selector(getArticleHeader);27 let headerText = await articleHeader.innerText;28});29import { Selector } from 'testcafe';30test('My first test', async t => {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 const developerName = Selector('#developer-name');4 const osOption = Selector('#macos');5 const submitButton = Selector('#submit-button');6 .typeText(developerName, 'John Smith')7 .click(osOption)8 .click(submitButton);9});10import { Selector } from 'testcafe';11test('My first test', async t => {12 const developerName = Selector('#developer-name');13 const osOption = Selector('#macos');14 const submitButton = Selector('#submit-button');15 .typeText(developerName, 'John Smith')16 .click(osOption)17 .click(submitButton);18});19import { Selector } from 'testcafe';20test('My first test', async t => {21 const developerName = Selector('#developer-name');22 const osOption = Selector('#macos');23 const submitButton = Selector('#submit-button');24 .typeText(developerName, 'John Smith')25 .click(osOption)26 .click(submitButton);27});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 const element = Selector('label').withText("I have tried TestCafe");4 const location = await element();5 console.log(location);6 .click(element);7});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My Test', async t => {3 .click(Selector('label').withText('I have tried TestCafe'))4 .click(Selector('label').withText('I have tried TestCafe').child('span'))5 .click(Selector('label').withText('I have tried TestCafe').child(0))6 .click(Selector('label').withText('I have tried TestCafe').child('span').parent())7 .click(Selector('label').withText('I have tried TestCafe').parent('div').child('span'))8});9import { Selector } from 'testcafe';10test('My Test', async t => {11 const triedTestCafeCheckbox = Selector('label').withText('I have tried TestCafe');12 .click(triedTestCafeCheckbox);13});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2const fromPoint = require('testcafe-browser-tools').fromPoint;3test('My test', async t => {4 const button = Selector('#submit-button');5 await t.click(button);6 const buttonOffset = await button();7 const buttonCenter = {8 };9 const buttonColor = await fromPoint(buttonCenter.x, buttonCenter.y);10 await t.expect(buttonColor).eql('#008000');11});12import { Selector } from 'testcafe';13const fromPoint = require('testcafe-browser-tools').fromPoint;14test('My test', async t => {15 const button = Selector('#submit-button');16 await t.click(button);17 const buttonOffset = await button();18 const buttonCenter = {19 };20 const buttonColor = await fromPoint(buttonCenter.x, buttonCenter.y);21 await t.expect(buttonColor).eql('#008000');22});23import { Selector } from 'testcafe';24const fromPoint = require('testcafe-browser-tools').fromPoint;25test('My test', async t => {26 const button = Selector('#submit-button');27 await t.click(button);28 const buttonOffset = await button();29 const buttonCenter = {30 };31 const buttonColor = await fromPoint(buttonCenter.x, buttonCenter.y);32 await t.expect(buttonColor).eql('#008000');33});34import { Selector } from 'testcafe

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2const fromPoint = require('testcafe').fromPoint;3test('My first test', async t => {4 const button = await fromPoint(200, 200);5 await t.click(button);6});7import { Selector } from 'testcafe';8const fromPoint = require('testcafe').fromPoint;9test('My first test', async t => {10 const button = await fromPoint(200, 200);11 await t.click(button);12});13import { Selector } from 'testcafe';14const fromPoint = require('testcafe').fromPoint;15test('My first test', async t => {16 const button = await fromPoint(200, 200);17 await t.click(button);18});19import { Selector } from 'testcafe';20const fromPoint = require('testcafe').fromPoint;21test('My first test', async t => {22 const button = await fromPoint(200, 200);23 await t.click(button);24});25import { Selector } from 'testcafe';26const fromPoint = require('testcafe').fromPoint;27test('My first test', async t => {28 const button = await fromPoint(200, 200);29 await t.click(button);30});

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 Testcafe 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