How to use center_x method in wpt

Best JavaScript code snippet using wpt

venn.js

Source:venn.js Github

copy

Full Screen

1// Adopted from 2d3.layout.venn = function() {3 var size = [1, 1],4 hierarchy = d3.layout.hierarchy().sort(null).value(null),5 normalize = false; //Keep the size of the areas standard6 7 function percentSort(nums){8 var max = Math.max.apply( Math, nums ); 9 var returnList = [];10 for (num in nums){11 returnList.push(nums[num]/max);12 }13 return returnList;14 }15 /*16 * returns an object with calculated circle dimensions and17 * relative positions for the given percent, and base radius18 */19 function createCircleDims(pcnt,base_rad){20 var dims = {};21 dims['pcnt'] = pcnt;22 dims['rad'] = base_rad*Math.sqrt(pcnt);23 dims['diameter'] = dims['rad']*2;24 return dims;25 }26 /*27 * gets the intersecting points between two circles28 */29 function intersectingPoints(c1,c2){30 // Formulas nabbed from http://2000clicks.com/mathhelp/GeometryConicSectionCircleIntersection.aspx31 var d = Math.sqrt(Math.pow((c2['center_x'] - c1['center_x']),2) + Math.pow(c2['center_y'] - c1['center_y'],2));32 var d_sq = Math.pow(d,2); // d squared33 var K = (.25)*Math.sqrt((Math.pow(c1['rad']+c2['rad'],2)-d_sq)*(d_sq-Math.pow(c1['rad']-c2['rad'],2)));34 // split up the equations for readability35 var xpart1 = (.5)*(c2['center_x']+c1['center_x']) + ((.5)*(c2['center_x']-c1['center_x'])*(Math.pow(c1['rad'],2) - Math.pow(c2['rad'],2))/d_sq);36 var xpart2 = 2*(c2['center_y']-c1['center_y'])*K/d_sq;37 var ypart1 = (.5)*(c2['center_y']+c1['center_y']) + ((.5)*(c2['center_y']-c1['center_y'])*(Math.pow(c1['rad'],2) - Math.pow(c2['rad'],2))/d_sq);38 var ypart2 = 2*(c2['center_x']-c1['center_x'])*K/d_sq;39 var points = {};40 points['x1'] = xpart1 + xpart2;41 points['x2'] = xpart1 - xpart2;42 points['y1'] = ypart1 - ypart2;43 points['y2'] = ypart1 + ypart2;44 return points;45 }46 47 function intersectionDetails(a,b)48 {49 var details = {};50 var ab = intersectingPoints(a,b); 51 // we are finding the intersection with regard to only 2 circles in this case 52 // find middle of the two points53 details['x'] = (ab['x1'] + ab['x2']) /2;54 details['y'] = (ab['y1'] + ab['y2']) /2;55 details['points'] = ab;56 return details;57 58 }59 60 /*61 * Get area that overlaps the intersection of two circles.62 */63 function dot(v1,v2)64 {65 return (v1[0]*v2[0])+(v1[1]*v2[1]);66 }67 function dist(v)68 {69 return Math.sqrt(v[0]*v[0]+v[1]*v[1]);70 }71 72 function getIntersectingArea(c1,c2, ct)73 {74 var i = intersectionDetails(c1,c2);75 // the actual intersecting points76 var topy = i['points']['y1'];77 var topx = i['points']['x1'];78 var bottomy = i['points']['y2'];79 var bottomx = i['points']['x2'];80 81 var vec1 = [(topx-c1['center_x']), (topy-c1['center_y'])];82 var vec2 = [(bottomx-c1['center_x']), (bottomy-c1['center_y'])];83 var startAngle1 = Math.atan2(vec1[1], vec1[0]); 84 var endAngle1 = Math.atan2(vec2[1], vec2[0]);85 86 var vec3 = [(topx-c2['center_x']), (topy-c2['center_y'])];87 var vec4 = [(bottomx-c2['center_x']), (bottomy-c2['center_y'])];88 var startAngle2 = Math.atan2(vec3[1], vec3[0]); 89 var endAngle2 = Math.atan2(vec4[1], vec4[0]);90 91 var AB_Path = [{"arc": [c1['center_x'], c1['center_y'], c1['rad'], startAngle1, endAngle1, false]},92 {"arc": [c2['center_x'], c2['center_y'], c2['rad'], endAngle2, startAngle2, false]}];93 var ApB_Path = [{"arc": [c1['center_x'], c1['center_y'], c1['rad'], startAngle1, endAngle1, false]},94 {"arc": [c2['center_x'], c2['center_y'], c2['rad'], endAngle2 ,startAngle2, true]}];95 var ABp_Path = [{"arc": [c1['center_x'], c1['center_y'], c1['rad'], startAngle1, endAngle1, true]},96 {"arc": [c2['center_x'], c2['center_y'], c2['rad'], endAngle2 ,startAngle2, false]}];97 var ApBp_Path = [{"arc": [c1['center_x'], c1['center_y'], c1['rad'], startAngle1, endAngle1, true]},98 {"arc": [c2['center_x'], c2['center_y'], c2['rad'], endAngle2 ,startAngle2, true]},99 {"moveTo":[ct['center_x']+ct['rad'], ct['center_y']]},100 {"arc": [ct['center_x'], ct['center_y'], ct['rad'], 0, 2*Math.PI, false]}];101 //i['path'] = intersectionPath;102 103 data = {}104 data["AB"] = AB_Path;105 data["A'B"] = ApB_Path;106 data["AB'"] = ABp_Path;107 data["A'B'"] = ApBp_Path;108 109 return data;110 }111 112 function compute2CircleVenn(data)113 {114 var height = size[1];115 var base_rad = height/2;116 117 118 119 // get the data120 var l1 = data['A'].size; // left 121 var r1 = data['B'].size; // right122 var both = data['AB'].size; // intersection123 var total = data['TOTAL'].size;124 125 126 127 var ctotal = {}; // overall circle128 var cl = {}; //left circle129 var cr = {}; //right circle130 131 ctotal['rad'] = base_rad;132 ctotal['center_y'] = size[1]/2; 133 ctotal['center_x'] = size[0]/2;134 135 136 // figure out the circle sizes137 percents = percentSort([l1,r1,both,total]);138 cl = createCircleDims(percents[0],base_rad);139 cr = createCircleDims(percents[1],base_rad);140 141 142 //figure out starting positions for the 2 circles143 //var center_y = Math.max(cl['rad'],cr['rad'])+2;144 145 cl['center_y'] = ctotal['center_y']; 146 cr['center_y'] = ctotal['center_y']; 147 148 cl['center_x'] = ctotal['center_x']-cl['rad']; //cl['rad'];149 //place right circle equally to the right150 cr['center_x'] = ctotal['center_x'] + cr['rad'] ;151 //with a 2 circle venn, we have the option of also scaling the overlap area152 153 var ld1 = cl['center_x'] - cl['rad'];154 var ld2 = cl['center_x'] + cl['rad'];155 var rd1 = cr['center_x'] - cr['rad'];156 var rd2 = cr['center_x'] + cr['rad'];157 var diff1 = rd1-ld1;158 var diff2 = rd2-ld2;159 var startPoint = cr['center_x'];160 var stopPoint = cl['center_x'] - cl['rad'] + cr['rad']; 161 if (diff1 > diff2)162 {163 //left circle is bigger164 stopPoint = cl['center_x'] +cl['rad'] - cr['rad']; 165 }166 var maxMovement = startPoint - stopPoint;167 168 169 if ((percents[2]/percents[0]) > 0)170 {171 if(normalize){172 cr['center_x'] = startPoint - (maxMovement*0.5*(percents[2]/percents[0]));//(maxMovement*(percents[2]+.2));173 cl['center_x'] = stopPoint + (maxMovement*0.5*(percents[2]/percents[0]));174 }else{175 cr['center_x'] = startPoint - (maxMovement*(percents[2]/percents[0]));176 }177 }178 if (!normalize){179 console.log(cr['center_x'], cr['rad'], ctotal['center_x'], ctotal['rad']);180 if ((cr['center_x']+cr['rad']) > (ctotal['center_x']+ctotal['rad'])){181 var ct_dif = (cr['center_x']+cr['rad']) - (ctotal['center_x']+ctotal['rad']);182 console.log("ct_dif", ct_dif);183 cr['center_x'] = cr['center_x'] - ct_dif;184 cl['center_x'] = cl['center_x'] - ct_dif; 185 }else if ((cl['center_x']-cl['rad']) < (ctotal['center_x']-ctotal['rad'])){186 var ct_dif = (cl['center_x']-cl['rad']) - (ctotal['center_x']-ctotal['rad']);187 cr['center_x'] = cr['center_x'] - ct_dif;188 cl['center_x'] = cl['center_x'] - ct_dif; 189 }190 191 192 193 }194 var iDetail = getIntersectingArea(cl, cr, ctotal);195 196 var areas = [{name:"TOTAL", size: data["TOTAL"].size, units: data["TOTAL"].units, detail: data["TOTAL"].detail, path:[{"arc": [ctotal['center_x'], ctotal['center_y'], ctotal['rad'], 0, 2*Math.PI, true]}]},197 {name:"B", size: data["B"].size, units: data["B"].units, detail: data["B"].detail, path:[{"arc": [cr['center_x'], cr['center_y'], cr['rad'], 0, 2*Math.PI, true]}]},198 {name:"A", size: data["A"].size, units: data["A"].units, detail: data["A"].detail, path:[{"arc": [cl['center_x'], cl['center_y'], cl['rad'], 0, 2*Math.PI, true]}]},199 200 {name:"AB'", size: data["AB'"].size, units: data["AB'"].units, detail: data["AB'"].detail, path:iDetail["AB'"]}, 201 {name:"AB", size: data["AB"].size, units: data["AB"].units,detail: data["AB"].detail, path:iDetail["AB"]}, 202 {name:"B'", size: data["B'"].size, units: data["B'"].units, detail: data["B'"].detail, path:[{"arc": [ctotal['center_x'], ctotal['center_y'], ctotal['rad'], 0, 2*Math.PI, false]},203 {"moveTo":[cr['center_x']+cr['rad'], cr['center_y']]},204 {"arc": [cr['center_x'], cr['center_y'], cr['rad'], 0, 2*Math.PI, true]}]},205 {name:"A'", size: data["A'"].size, units: data["A'"].units, detail: data["A'"].detail, path:[{"arc": [ctotal['center_x'], ctotal['center_y'], ctotal['rad'], 0, 2*Math.PI, false]},206 {"moveTo":[cl['center_x']+cl['rad'], cl['center_y']]},207 {"arc": [cl['center_x'], cl['center_y'], cl['rad'], 0, 2*Math.PI, true]}]},208 209 210 {name:"A'B", size: data["A'B"].size, units: data["A'B"].units, detail: data["A'B"].detail, path:iDetail["A'B"]}, 211 {name:"A'B'", size: data["A'B'"].size, units: data["A'B'"].units, detail: data["A'B'"].detail, path:iDetail["A'B'"]},212 213 ];214 return areas;//[ctotal, cl, cr];215 }216 217 function venn(d, i) {218 var nodes = hierarchy.call(this, d, i),219 root = nodes[0],220 data = {};221 222 data['TOTAL'] ={}223 data['TOTAL'].size = root.size;224 data['TOTAL'].detail = root.detail;225 data['TOTAL'].units = root.units;226 for(var i=1; i < nodes.length; i++){227 if(data[nodes[i].name]){228 data[nodes[i].name].size += nodes[i].size;229 }else{230 data[nodes[i].name] = {}231 data[nodes[i].name].size = nodes[i].size;232 data[nodes[i].name].detail = nodes[i].detail;233 data[nodes[i].name].units = nodes[i].units;234 }235 if(nodes[i].depth > 1){236 // sort key so that A is always before B237 var key = (nodes[i].parent.name < nodes[i].name) ? nodes[i].parent.name+nodes[i].name : nodes[i].name+nodes[i].parent.name;238 if(data[key]){239 data[key].size += nodes[i].size;240 //data[nodes[i].parent.name+nodes[i].name].detail += " & " + nodes[i].detail;241 }else{242 data[key] = {}243 data[key].size = nodes[i].size;244 data[key].detail = nodes[i].parent.detail +" & "+ nodes[i].detail;245 data[key].units = nodes[i].units;246 }247 }248 }249 if(normalize){250 data["TOTAL"].size = 100;251 data["A"].size = 30;252 data["B"].size = 30;253 254 data["A'"].size = 70;255 data["B'"].size = 70;256 257 data["AB"].size = 10;258 data["AB'"].size = 20;259 data["A'B"].size = 20;260 data["A'B'"].size = 40;261 }262 263 return compute2CircleVenn(data);264 }265 venn.size = function(x) {266 if (!arguments.length) return size;267 size = x;268 return venn;269 };270 271 venn.normalize = function(x) {272 if (!arguments.length) return size;273 normalize = x;274 return venn;275 };276 venn.value = function(x) {277 if (!arguments.length) return value;278 value = x;279 return venn;280 };281 return venn;...

Full Screen

Full Screen

seeds.ts

Source:seeds.ts Github

copy

Full Screen

1const CENTER_X = 0;2const CENTER_Y = 0;3const _constructMatrix = (row: number, column: number, matrix: {}) => {4 if (!matrix[row]) matrix[row] = {};5 matrix[row][column] = 1;6};7const GiantCross = (matrixCopy: {}, height: number, width: number) => {8 for (let j = -Math.floor(height / 2); j < Math.ceil(height / 2); j++) {9 if (!matrixCopy[j]) matrixCopy[j] = {};10 for (let i = -Math.floor(width / 2); i < Math.ceil(width / 2); i++) {11 if (Math.abs(j) === Math.abs(i) || j === 0 || i === 0) {12 matrixCopy[j][i] = 1;13 continue;14 }15 if (!matrixCopy[j][i]) matrixCopy[j][i] = 0;16 }17 }18};19const Beehive = (matrixCopy: {}) => {20 _constructMatrix(CENTER_X, CENTER_Y, matrixCopy);21 _constructMatrix(CENTER_X, CENTER_Y + 1, matrixCopy);22 _constructMatrix(CENTER_X + 1, CENTER_Y - 1, matrixCopy);23 _constructMatrix(CENTER_X + 1, CENTER_Y + 2, matrixCopy);24 _constructMatrix(CENTER_X + 2, CENTER_Y, matrixCopy);25 _constructMatrix(CENTER_X + 2, CENTER_Y + 1, matrixCopy);26};27const BlinkerOscillator = (matrixCopy: {}) => {28 _constructMatrix(CENTER_X, CENTER_Y, matrixCopy);29 _constructMatrix(CENTER_X, CENTER_Y + 1, matrixCopy);30 _constructMatrix(CENTER_X, CENTER_Y + 2, matrixCopy);31};32const Beacon = (matrixCopy: {}) => {33 _constructMatrix(CENTER_X, CENTER_Y, matrixCopy);34 _constructMatrix(CENTER_X, CENTER_Y + 1, matrixCopy);35 _constructMatrix(CENTER_X + 1, CENTER_Y, matrixCopy);36 _constructMatrix(CENTER_X + 2, CENTER_Y + 3, matrixCopy);37 _constructMatrix(CENTER_X + 3, CENTER_Y + 2, matrixCopy);38 _constructMatrix(CENTER_X + 3, CENTER_Y + 3, matrixCopy);39};40const Glider = (matrixCopy: {}) => {41 _constructMatrix(CENTER_X, CENTER_Y, matrixCopy);42 _constructMatrix(CENTER_X + 1, CENTER_Y + 1, matrixCopy);43 _constructMatrix(CENTER_X + 2, CENTER_Y - 1, matrixCopy);44 _constructMatrix(CENTER_X + 2, CENTER_Y, matrixCopy);45 _constructMatrix(CENTER_X + 2, CENTER_Y + 1, matrixCopy);46};47const SmallExploder = (matrixCopy: {}) => {48 _constructMatrix(CENTER_X, CENTER_Y, matrixCopy);49 _constructMatrix(CENTER_X + 1, CENTER_Y - 1, matrixCopy);50 _constructMatrix(CENTER_X + 1, CENTER_Y, matrixCopy);51 _constructMatrix(CENTER_X + 1, CENTER_Y + 1, matrixCopy);52 _constructMatrix(CENTER_X + 2, CENTER_Y - 1, matrixCopy);53 _constructMatrix(CENTER_X + 2, CENTER_Y + 1, matrixCopy);54 _constructMatrix(CENTER_X + 3, CENTER_Y, matrixCopy);55};56const Exploder = (matrixCopy: {}) => {57 _constructMatrix(CENTER_X, CENTER_Y - 2, matrixCopy);58 _constructMatrix(CENTER_X, CENTER_Y, matrixCopy);59 _constructMatrix(CENTER_X, CENTER_Y + 2, matrixCopy);60 _constructMatrix(CENTER_X + 1, CENTER_Y - 2, matrixCopy);61 _constructMatrix(CENTER_X + 1, CENTER_Y + 2, matrixCopy);62 _constructMatrix(CENTER_X + 2, CENTER_Y - 2, matrixCopy);63 _constructMatrix(CENTER_X + 2, CENTER_Y + 2, matrixCopy);64 _constructMatrix(CENTER_X + 3, CENTER_Y - 2, matrixCopy);65 _constructMatrix(CENTER_X + 3, CENTER_Y + 2, matrixCopy);66 _constructMatrix(CENTER_X + 4, CENTER_Y - 2, matrixCopy);67 _constructMatrix(CENTER_X + 4, CENTER_Y, matrixCopy);68 _constructMatrix(CENTER_X + 4, CENTER_Y + 2, matrixCopy);69};70const TenCellRow = (matrixCopy: {}) => {71 _constructMatrix(CENTER_X, CENTER_Y - 5, matrixCopy);72 _constructMatrix(CENTER_X, CENTER_Y - 4, matrixCopy);73 _constructMatrix(CENTER_X, CENTER_Y - 3, matrixCopy);74 _constructMatrix(CENTER_X, CENTER_Y - 2, matrixCopy);75 _constructMatrix(CENTER_X, CENTER_Y - 1, matrixCopy);76 _constructMatrix(CENTER_X, CENTER_Y, matrixCopy);77 _constructMatrix(CENTER_X, CENTER_Y + 1, matrixCopy);78 _constructMatrix(CENTER_X, CENTER_Y + 2, matrixCopy);79 _constructMatrix(CENTER_X, CENTER_Y + 3, matrixCopy);80 _constructMatrix(CENTER_X, CENTER_Y + 4, matrixCopy);81};82const LightweightSpaceship = (matrixCopy: {}) => {83 _constructMatrix(CENTER_X, CENTER_Y - 5, matrixCopy);84 _constructMatrix(CENTER_X, CENTER_Y - 4, matrixCopy);85 _constructMatrix(CENTER_X, CENTER_Y - 3, matrixCopy);86 _constructMatrix(CENTER_X, CENTER_Y - 2, matrixCopy);87 _constructMatrix(CENTER_X + 1, CENTER_Y - 6, matrixCopy);88 _constructMatrix(CENTER_X + 1, CENTER_Y - 2, matrixCopy);89 _constructMatrix(CENTER_X + 2, CENTER_Y - 2, matrixCopy);90 _constructMatrix(CENTER_X + 3, CENTER_Y - 5, matrixCopy);91 _constructMatrix(CENTER_X + 3, CENTER_Y - 3, matrixCopy);92};93const Tumbler = (matrixCopy: {}) => {94 _constructMatrix(CENTER_X, CENTER_Y - 2, matrixCopy);95 _constructMatrix(CENTER_X, CENTER_Y - 1, matrixCopy);96 _constructMatrix(CENTER_X, CENTER_Y + 1, matrixCopy);97 _constructMatrix(CENTER_X, CENTER_Y + 2, matrixCopy);98 _constructMatrix(CENTER_X + 1, CENTER_Y - 2, matrixCopy);99 _constructMatrix(CENTER_X + 1, CENTER_Y - 1, matrixCopy);100 _constructMatrix(CENTER_X + 1, CENTER_Y + 1, matrixCopy);101 _constructMatrix(CENTER_X + 1, CENTER_Y + 2, matrixCopy);102 _constructMatrix(CENTER_X + 2, CENTER_Y - 1, matrixCopy);103 _constructMatrix(CENTER_X + 2, CENTER_Y + 1, matrixCopy);104 _constructMatrix(CENTER_X + 3, CENTER_Y - 3, matrixCopy);105 _constructMatrix(CENTER_X + 3, CENTER_Y - 1, matrixCopy);106 _constructMatrix(CENTER_X + 3, CENTER_Y + 1, matrixCopy);107 _constructMatrix(CENTER_X + 3, CENTER_Y + 3, matrixCopy);108 _constructMatrix(CENTER_X + 4, CENTER_Y - 3, matrixCopy);109 _constructMatrix(CENTER_X + 4, CENTER_Y - 1, matrixCopy);110 _constructMatrix(CENTER_X + 4, CENTER_Y + 1, matrixCopy);111 _constructMatrix(CENTER_X + 4, CENTER_Y + 3, matrixCopy);112 _constructMatrix(CENTER_X + 5, CENTER_Y - 3, matrixCopy);113 _constructMatrix(CENTER_X + 5, CENTER_Y - 2, matrixCopy);114 _constructMatrix(CENTER_X + 5, CENTER_Y + 2, matrixCopy);115 _constructMatrix(CENTER_X + 5, CENTER_Y + 3, matrixCopy);116};117const GosperGliderGun = (matrixCopy: {}) => {118 _constructMatrix(CENTER_X, CENTER_Y - 10, matrixCopy);119 _constructMatrix(CENTER_X, CENTER_Y - 9, matrixCopy);120 _constructMatrix(CENTER_X + 1, CENTER_Y - 10, matrixCopy);121 _constructMatrix(CENTER_X + 1, CENTER_Y - 9, matrixCopy);122 _constructMatrix(CENTER_X, CENTER_Y - 1, matrixCopy);123 _constructMatrix(CENTER_X, CENTER_Y, matrixCopy);124 _constructMatrix(CENTER_X + 1, CENTER_Y - 2, matrixCopy);125 _constructMatrix(CENTER_X + 1, CENTER_Y, matrixCopy);126 _constructMatrix(CENTER_X + 2, CENTER_Y - 2, matrixCopy);127 _constructMatrix(CENTER_X + 2, CENTER_Y - 1, matrixCopy);128 _constructMatrix(CENTER_X + 2, CENTER_Y + 6, matrixCopy);129 _constructMatrix(CENTER_X + 2, CENTER_Y + 7, matrixCopy);130 _constructMatrix(CENTER_X + 3, CENTER_Y + 6, matrixCopy);131 _constructMatrix(CENTER_X + 3, CENTER_Y + 8, matrixCopy);132 _constructMatrix(CENTER_X + 4, CENTER_Y + 6, matrixCopy);133 _constructMatrix(CENTER_X, CENTER_Y + 12, matrixCopy);134 _constructMatrix(CENTER_X, CENTER_Y + 13, matrixCopy);135 _constructMatrix(CENTER_X - 1, CENTER_Y + 12, matrixCopy);136 _constructMatrix(CENTER_X - 1, CENTER_Y + 14, matrixCopy);137 _constructMatrix(CENTER_X - 2, CENTER_Y + 13, matrixCopy);138 _constructMatrix(CENTER_X - 2, CENTER_Y + 14, matrixCopy);139 _constructMatrix(CENTER_X + 10, CENTER_Y + 14, matrixCopy);140 _constructMatrix(CENTER_X + 10, CENTER_Y + 15, matrixCopy);141 _constructMatrix(CENTER_X + 10, CENTER_Y + 16, matrixCopy);142 _constructMatrix(CENTER_X + 11, CENTER_Y + 14, matrixCopy);143 _constructMatrix(CENTER_X + 12, CENTER_Y + 15, matrixCopy);144 _constructMatrix(CENTER_X - 1, CENTER_Y + 24, matrixCopy);145 _constructMatrix(CENTER_X - 1, CENTER_Y + 25, matrixCopy);146 _constructMatrix(CENTER_X - 2, CENTER_Y + 24, matrixCopy);147 _constructMatrix(CENTER_X - 2, CENTER_Y + 25, matrixCopy);148 _constructMatrix(CENTER_X + 5, CENTER_Y + 25, matrixCopy);149 _constructMatrix(CENTER_X + 5, CENTER_Y + 26, matrixCopy);150 _constructMatrix(CENTER_X + 6, CENTER_Y + 25, matrixCopy);151 _constructMatrix(CENTER_X + 6, CENTER_Y + 27, matrixCopy);152 _constructMatrix(CENTER_X + 7, CENTER_Y + 25, matrixCopy);153};154export const SeedsNameArray = [155 "GiantCross",156 "Beehive",157 "BlinkerOscillator",158 "Beacon",159 "Glider",160 "SmallExploder",161 "Exploder",162 "TenCellRow",163 "LightweightSpaceship",164 "Tumbler",165 "GosperGliderGun"166];167export const SeedsNameToShowInTheScreen = {168 "GiantCross": "Giant Cross",169 "Beehive": "Beehive",170 "BlinkerOscillator": "Blinker Oscillator",171 "Beacon": "Beacon",172 "Glider": "Glider",173 "SmallExploder": "Small Exploder",174 "Exploder": "Exploder",175 "TenCellRow": "Ten Cell Row",176 "LightweightSpaceship": "Lightweight Spaceship",177 "Tumbler": "Tumbler",178 "GosperGliderGun": "Gosper Glider Gun"179};180export const Seeds = {181 "GiantCross": (matrixCopy: {}, width: number, height: number) => GiantCross(matrixCopy, height, width),182 "Beehive": (matrixCopy: {}) => Beehive(matrixCopy),183 "BlinkerOscillator": (matrixCopy: {}) => BlinkerOscillator(matrixCopy),184 "Beacon": (matrixCopy: {}) => Beacon(matrixCopy),185 "Glider": (matrixCopy: {}) => Glider(matrixCopy),186 "SmallExploder": (matrixCopy: {}) => SmallExploder(matrixCopy),187 "Exploder": (matrixCopy: {}) => Exploder(matrixCopy),188 "TenCellRow": (matrixCopy: {}) => TenCellRow(matrixCopy),189 "LightweightSpaceship": (matrixCopy: {}) => LightweightSpaceship(matrixCopy),190 "Tumbler": (matrixCopy: {}) => Tumbler(matrixCopy),191 "GosperGliderGun": (matrixCopy: {}) => GosperGliderGun(matrixCopy),...

Full Screen

Full Screen

char.js

Source:char.js Github

copy

Full Screen

1window.onload = function() {2 // Get a reference to the canvas object3 var canvas = document.getElementById('myCanvas');4 // Create an empty project and a view for the canvas:5 paper.setup(canvas);6 7 var center_x = 400;8 var center_y = 260;9 var body = new paper.Shape.Ellipse({10 center: [center_x, center_y+225],11 radius: [190, 210],12 fillColor: 'black'13 });14 var left_leg = new paper.Shape.Ellipse({15 center: [center_x-125, center_y+360],16 radius: [85, 85],17 fillColor: 'black'18 });19 var right_leg = new paper.Shape.Ellipse({20 center: [center_x+125, center_y+360],21 radius: [85, 85],22 fillColor: 'black'23 });24 var left_foot = new paper.Path.Line({25 from: [center_x-205, center_y+445-15],26 to: [center_x-125, center_y+445-15],27 strokeColor: 'black',28 strokeCap: 'round',29 strokeWidth: 3030 });31 var right_foot = new paper.Path.Line({32 from: [center_x+205, center_y+445-15],33 to: [center_x+125, center_y+445-15],34 strokeColor: 'black',35 strokeCap: 'round',36 strokeWidth: 3037 });38 var stomach = new paper.Shape.Ellipse({39 center: [center_x, center_y+225],40 radius: [160, 180],41 //fillColor: '#b54a03'42 });43 var face = new paper.Shape.Ellipse({44 center: [center_x, center_y],45 radius: [155, 155],46 fillColor: 'black'47 });48 var left_cheek = new paper.Shape.Ellipse({49 center: [center_x-125, center_y+65],50 radius: [105, 105],51 fillColor: 'black'52 });53 var right_cheek = new paper.Shape.Ellipse({54 center: [center_x+125, center_y+65],55 radius: [105, 105],56 fillColor: 'black'57 });58 var left_ear = new paper.Shape.Ellipse({59 center: [center_x-100, center_y-130],60 radius: [40, 30],61 fillColor: 'black'62 }).rotate(45);63 var right_ear = new paper.Shape.Ellipse({64 center: [center_x+100, center_y-130],65 radius: [40, 30],66 fillColor: 'black'67 }).rotate(-45);68 var left_mouse = new paper.Path.Arc({69 from: [center_x-60, center_y+75],70 through: [center_x-35, center_y+105],71 to: [center_x, center_y+75],72 strokeColor: 'white',73 strokeWidth: 1074 });75 var right_mouse = new paper.Path.Arc({76 from: [center_x+60, center_y+75],77 through: [center_x+35, center_y+105],78 to: [center_x, center_y+75],79 strokeColor: 'white',80 strokeWidth: 1081 });82 var left_eye = new paper.Shape.Ellipse({83 center: [center_x-70, center_y-40],84 radius: [12, 25],85 fillColor: 'white'86 });87 var right_eye = new paper.Shape.Ellipse({88 center: [center_x+70, center_y-40],89 radius: [12, 25],90 fillColor: 'white'91 });92 var left_arm = new paper.Path.Rectangle({93 topLeft: [center_x-120, center_y+225],94 bottomRight: [center_x-80, center_y+295],95 radius: 20,96 strokeColor: 'white',97 strokeWidth: 1098 });99 var left_block = new paper.Path.Rectangle({100 topLeft: [center_x-125, center_y+220],101 bottomRight: [center_x-75, center_y+245],102 fillColor: 'black'103 });104 var right_arm = new paper.Path.Rectangle({105 topLeft: [center_x+120, center_y+225],106 bottomRight: [center_x+80, center_y+295],107 radius: 20,108 strokeColor: 'white',109 strokeWidth: 10110 });111 var right_block = new paper.Path.Rectangle({112 topLeft: [center_x+125, center_y+220],113 bottomRight: [center_x+75, center_y+245],114 fillColor: 'black'115 });116 var left_circle = new paper.Shape.Ellipse({117 center: [center_x-165, center_y+65],118 radius: [50, 50],119 fillColor: '#b54a03'120 });121 var right_circle = new paper.Shape.Ellipse({122 center: [center_x+165, center_y+65],123 radius: [50, 50],124 fillColor: '#b54a03'125 });126 var almond_start_x = center_x-100;127 var almond_start_y = center_x+150;128 var almond_end_x = almond_start_x+200;129 var almond_end_y = almond_start_y;130 var almond_lines = [];131 for(var i=0; i<9; i++){132 var sign = 1;133 if(i%2 == 1){134 sign *= -1;135 }136 var first_segment = new paper.Segment({137 point: [almond_start_x, almond_start_y],138 handleOut: [30, sign*(100-parseInt(i/2)*25)]139 });140 var second_segment = new paper.Segment({141 point: [almond_end_x, almond_end_y],142 handleIn: [-30, sign*(40-parseInt(i/2)*10)]143 });144 145 almond_lines[i] = new paper.Path({146 segments: [first_segment, second_segment],147 strokeColor: 'black',148 strokeWidth: 2-parseInt(i/2)*0.3,149 fillColor: new paper.Color(0.66+(i*0.05), 0.23+(i*0.05), 0+(i*0.05))150 });151 }152 // Draw the view now:153 paper.view.draw();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1console.log(wpt.center_x());2console.log(wpt.center_y());3console.log(wpt.center());4console.log(wpt.distance());5console.log(wpt.distance_to());6console.log(wpt.move());7console.log(wpt.move_to());8console.log(wpt.to_string());9console.log(wpt.add());10console.log(wpt.add_to());11console.log(wpt.subtract());12console.log(wpt.subtract_from());13console.log(wpt.multiply());14console.log(wpt.multiply_by());15console.log(wpt.divide());16console.log(wpt.divide_by());17console.log(wpt.equals());18console.log(wpt.compare());19console.log(wpt.is_left());20console.log(wpt.is_right());21console.log(wpt.is_above());22console.log(wpt.is_below());23console.log(wpt.is_between());24console.log(wpt.is_collinear());25console.log(wpt.is_collinear_with());26console.log(wpt.is_between());27console.log(wpt.is_between_inclusive());

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.log(err);4 console.log(data);5 wpt.getTestResults(data.data.testId, function(err, data) {6 if (err) return console.log(err);7 console.log(data);8 });9});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = new wpt('API_KEY');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9var wpt = require('webpagetest');10var test = new wpt('API_KEY');11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16});17var wpt = require('webpagetest');18var test = new wpt('API_KEY');19 if (err) {20 console.log(err);21 } else {22 console.log(data);23 }24});25var wpt = require('webpagetest');26var test = new wpt('API_KEY');27 if (err) {28 console.log(err);29 } else {30 console.log(data);31 }32});33var wpt = require('webpagetest');34var test = new wpt('API_KEY');35 if (err) {36 console.log(err);37 } else {38 console.log(data);39 }40});41var wpt = require('webpagetest');42var test = new wpt('API_KEY');43 if (err) {44 console.log(err);45 } else {46 console.log(data);47 }48});49var wpt = require('webpagetest');50var test = new wpt('API_KEY');51 if (err) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var webPageTest = new wpt('API_KEY');3 if (err) {4 console.log('Error: ' + err);5 } else {6 console.log('Test Results: ' + data);7 }8});9Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.center_x(100, 50);3var wpt = require('wpt');4wpt.center_x(100, 50);5var wpt = require('wpt');6wpt.center_x(100, 50);7var wpt = require('wpt');8wpt.center_x(100, 50);9var wpt = require('wpt');10wpt.center_x(100, 50);11var wpt = require('wpt');12wpt.center_x(100, 50);13var wpt = require('wpt');14wpt.center_x(100, 50);15var wpt = require('wpt');16wpt.center_x(100, 50);17var wpt = require('wpt');18wpt.center_x(100, 50);19var wpt = require('wpt');20wpt.center_x(100, 50);21var wpt = require('wpt');22wpt.center_x(100, 50);23var wpt = require('wpt');24wpt.center_x(100, 50);25var wpt = require('wpt');26wpt.center_x(100, 50);27var wpt = require('wpt');28wpt.center_x(100,

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wiki = wptools.page('Barack Obama');3wiki.get(function(err, resp) {4 console.log(wiki.center_x());5});6var wptools = require('wptools');7var wiki = wptools.page('Barack Obama');8wiki.get(function(err, resp) {9 console.log(wiki.center_y());10});11var wptools = require('wptools');12var wiki = wptools.page('Barack Obama');13wiki.get(function(err, resp) {14 console.log(wiki.coordinates());15});16var wptools = require('wptools');17var wiki = wptools.page('Barack Obama');18wiki.get(function(err, resp) {19 console.log(wiki.country());20});21var wptools = require('wptools');22var wiki = wptools.page('Barack Obama');23wiki.get(function(err, resp) {24 console.log(wiki.country_code());25});26var wptools = require('wptools');27var wiki = wptools.page('Barack Obama');28wiki.get(function(err, resp) {29 console.log(wiki.description());30});31var wptools = require('wptools');32var wiki = wptools.page('Barack Obama');33wiki.get(function(err, resp) {34 console.log(wiki.description_source());35});36var wptools = require('wptools');37var wiki = wptools.page('Barack Obama');38wiki.get(function(err, resp) {39 console.log(wiki.description_url());40});41var wptools = require('wptools');42var wiki = wptools.page('Barack Obama');43wiki.get(function(err, resp) {44 console.log(wiki.dim());45});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.center_x(function(x) {3 wpt.center_y(function(y) {4 wpt.mouse_click(x + img_x, y + img_y);5 });6 });7 });8});

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