How to use center_y method in wpt

Best JavaScript code snippet using wpt

canvasFont.js

Source:canvasFont.js Github

copy

Full Screen

1/*!2 * canvasFont v0.0.13 * https://github.com/auds1n/canvasFont4 *5 * Released under the BSD license6 *7 * Date: 2013-10-198 * 9 * author: Girish Budhwani10 */11// Anonymous function, and it returns two public12// functions initConfig() and create()13var Font = (function () {14 var15 // allowed values = random, sameOrigin1, off16 animation = 'random',17 radius = 5,18 // allowed values = random, triangle, circle, square19 shape = 'random',20 // alowed values = all css colors and 'random'21 color = 'random',22 height,23 width,24 timer,25 gradient = false,26 // for the fillStyle variable27 gradObject = null,28 // for sameOrigin2 animation29 frequency = 500,30 // manually manipulating frame speed31 manualAnimation,32 AnimeId,33 colors = ['greenyellow','aqua','chartreuse','orange','sandybrown','thistle'],34 acceleration = 0.5,35 friction = 0.1,36 sides = {37 'triangle': 3,38 'circle': 0,39 'square': 4,40 },41 // for generating random sides see getSides()42 side = ['triangle', 'circle', 'square'],43 atoms = [],44 context = null,45 requestAnimFrame = (function(){46 return window.requestAnimationFrame || 47 window.webkitRequestAnimationFrame || 48 window.mozRequestAnimationFrame || 49 window.oRequestAnimationFrame || 50 window.msRequestAnimationFrame || 51 function( callback ){52 window.setTimeout(callback, 1000 / 60);53 };54 })(),55 letter = {56 A: (function () {57 var58 w2h = 0.9, // private59 total = 6; // private (may be it has no meaning)60 // height to radius probable ratio 50/461 /*62 * @desc returns the points which make the letter A, similarly for other letters63 * @param {number} x starting x-coordinate64 * @param {number} y starting y-coordinate65 * @param {number} height the height of the letter66 * @return {object} data the object has the width property and points property containing all the points67 */68 function draw (x, y, height) {69 var70 width = w2h * height,71 hypotenus = Math.sqrt(Math.pow(height, 2) + Math.pow(width / 2, 2)),72 center_x = x,73 center_y = y + height,74 sin = height / hypotenus,75 cos = width / (2 * hypotenus),76 data = {77 points: [],78 width: 079 };80 for ( var i = 0; i < total; i++ ) {81 data.points.push({x: center_x, y: center_y});82 center_x += ((hypotenus / (total - 1)) * cos);83 center_y -= ((hypotenus / (total - 1)) * sin);84 }85 center_y += (2 * ((hypotenus / (total - 1)) * sin));86 for ( var i = 0; i < (total - 1); i++ ) {87 data.points.push({x: center_x, y: center_y});88 center_x += ((hypotenus / (total - 1)) * cos);89 center_y += ((hypotenus / (total - 1)) * sin);90 }91 // drawing horizontal line92 center_x = x + 0.4 * width;93 center_y = y + (height * 3.5 / 5);94 data.points.push({x: center_x, y: center_y});95 center_x = x + 0.6 * width;96 data.points.push({x: center_x, y: center_y});97 data.width = width;98 //console.log(data);99 return data;100 }101 return {102 getPoints: draw103 };104 })(),105 B: (function () {106 var 107 w2h = 0.4,108 total = 6;109 function draw (x, y, height) {110 var111 width = w2h * height,112 center_x = x,113 center_y = y,114 data = {115 points: [],116 width: 0117 };118 for( var i = 0; i < total; i++ ) {119 data.points.push({x: center_x, y: center_y});120 center_y += (height / (total - 1));121 }122 center_x = x + width / 2.5;123 center_y = y;124 data.points.push({x: center_x, y: center_y});125 center_y = y + height / 2;126 data.points.push({x: center_x, y: center_y});127 center_y = y + height;128 data.points.push({x: center_x, y: center_y});129 center_x += (width / 2.5);130 center_y = y + height / 10;131 data.points.push({x: center_x, y: center_y});132 center_y = y + 0.4 * height;133 data.points.push({x: center_x, y: center_y});134 center_y = y + 0.6 * height;135 data.points.push({x: center_x, y: center_y});136 center_y = y + height - (height / 10);137 data.points.push({x: center_x, y: center_y});138 center_x += (width / 5);139 center_y = y + 0.25 * height;140 data.points.push({x: center_x, y: center_y});141 center_y = y + 0.75 * height;142 data.points.push({x: center_x, y: center_y});143 144 data.width = width;145 return data;146 }147 return {148 getPoints: draw149 };150 })(),151 E: (function () {152 var153 w2h = 0.35,154 total = 6;155 function draw (x, y, height) {156 var 157 width = w2h * height,158 center_x = x,159 center_y = y,160 data = {161 points: [],162 width: 0163 };164 for(var i = 0; i < total; i++) {165 data.points.push({x: center_x, y: center_y});166 center_y += (height / (total - 1));167 }168 center_x = x + 0.47 * width;169 center_y = y;170 for(var i = 0; i < 3; i++) {171 data.points.push({x: center_x, y: center_y});172 center_y += (height / 2);173 }174 center_x = x + width;175 center_y = y;176 for(var i = 0; i < 3; i++) {177 data.points.push({x: center_x, y: center_y});178 center_y += (height / 2);179 }180 data.width = width;181 return data;182 }183 return {184 getPoints: draw185 };186 })(),187 F: (function () {188 var189 w2h = 0.38,190 total = 6;191 function draw (x, y, height) {192 var 193 width = w2h * height,194 center_x = x,195 center_y = y,196 data = {197 points: [],198 width: 0199 };200 for(var i = 0; i < total; i++) {201 data.points.push({x: center_x, y: center_y});202 center_y += (height / (total - 1));203 }204 center_x = x + 0.47 * width;205 center_y = y;206 for(var i = 0; i < 2; i++) {207 data.points.push({x: center_x, y: center_y});208 center_y += (height / 2);209 }210 center_x = x + width;211 center_y = y;212 for(var i = 0; i < 2; i++) {213 data.points.push({x: center_x, y: center_y});214 center_y += (height / 2);215 }216 data.width = width;217 return data;218 }219 return {220 getPoints: draw221 };222 })(),223 L: (function () {224 var225 w2h = 0.38,226 total = 6;227 function draw (x, y, height) {228 var 229 width = w2h * height,230 center_x = x,231 center_y = y,232 data = {233 points: [],234 width: 0235 };236 for(var i = 0; i < total; i++) {237 data.points.push({x: center_x, y: center_y});238 center_y += (height / (total - 1));239 }240 center_x = x + (width / 2);241 center_y = y + height;242 data.points.push({x: center_x, y: center_y});243 center_x = x + width;244 data.points.push({x: center_x, y: center_y});245 data.width = width;246 return data;247 }248 return {249 getPoints: draw250 };251 })(),252 P: (function () {253 var 254 w2h = 0.4,255 total = 6;256 function draw (x, y, height) {257 var258 width = w2h * height,259 center_x = x,260 center_y = y,261 data = {262 points: [],263 width: 0264 };265 for( var i = 0; i < total; i++ ) {266 data.points.push({x: center_x, y: center_y});267 center_y += (height / (total - 1));268 }269 center_x = x + width / 2.5;270 center_y = y;271 data.points.push({x: center_x, y: center_y});272 center_y = y + height / 2;273 data.points.push({x: center_x, y: center_y});274 center_x += (width / 2.5);275 center_y = y + height / 10;276 data.points.push({x: center_x, y: center_y});277 center_y = y + 0.4 * height;278 data.points.push({x: center_x, y: center_y});279 center_x += (width / 5);280 center_y = y + 0.25 * height;281 data.points.push({x: center_x, y: center_y});282 data.width = width;283 return data;284 }285 return {286 getPoints: draw287 };288 })(),289 H: (function () {290 var291 w2h = 0.5,292 total = 6;293 function draw (x, y, height) {294 var 295 width = w2h * height,296 center_x = x,297 center_y = y,298 data = {299 points: [],300 width: 0301 };302 for(var i = 0; i < total; i++) {303 data.points.push({x: center_x, y: center_y});304 center_y += (height / (total - 1));305 }306 center_x = x + width;307 center_y = y;308 for(var i = 0; i < total; i++) {309 data.points.push({x: center_x, y: center_y});310 center_y += (height / (total - 1));311 }312 center_x = x + (width / 3 - width / 30);313 center_y = y + 0.5 * height;314 data.points.push({x: center_x, y: center_y});315 center_x = x + (width - width / 3 + width / 30);316 data.points.push({x: center_x, y: center_y});317 data.width = width;318 return data;319 }320 return {321 getPoints: draw322 };323 })(),324 I: (function () {325 var326 w2h = 0.4,327 total = 6;328 function draw (x, y, height) {329 var 330 width = w2h * height,331 center_x = x + 0.5 * width,332 center_y = y,333 data = {334 points: [],335 width: 0336 };337 for(var i = 0; i < total; i++) {338 data.points.push({x: center_x, y: center_y});339 center_y += (height / (total - 1));340 }341 center_x = x;342 center_y = y;343 data.points.push({x: center_x, y: center_y});344 center_x = x + width;345 data.points.push({x: center_x, y: center_y});346 center_y = y + height;347 data.points.push({x: center_x, y: center_y});348 center_x = x;349 data.points.push({x: center_x, y: center_y});350 data.width = width;351 return data;352 }353 return {354 getPoints: draw355 };356 })(),357 T: (function () {358 var359 w2h = 0.7,360 total = 6;361 function draw (x, y, height) {362 var 363 width = w2h * height,364 center_x = x + 0.5 * width,365 center_y = y,366 data = {367 points: [],368 width: 0369 };370 for(var i = 0; i < total; i++) {371 data.points.push({x: center_x, y: center_y});372 center_y += (height / (total - 1));373 }374 center_x = x;375 center_y = y;376 data.points.push({x: center_x, y: center_y});377 center_x = x + 0.25 * width;378 data.points.push({x: center_x, y: center_y});379 center_x = x + 0.75 * width;380 data.points.push({x: center_x, y: center_y});381 center_x = x + width;382 data.points.push({x: center_x, y: center_y});383 data.width = width;384 return data;385 }386 return {387 getPoints: draw388 };389 })(),390 N: (function () {391 var392 w2h = 0.6,393 total = 6;394 function draw (x, y, height) {395 var 396 width = w2h * height,397 center_x = x,398 center_y = y,399 data = {400 points: [],401 width: 0402 };403 for(var i = 0; i < total; i++) {404 data.points.push({x: center_x, y: center_y});405 center_y += (height / (total - 1));406 }407 center_x = x + width;408 center_y = y;409 for(var i = 0; i < total; i++) {410 data.points.push({x: center_x, y: center_y});411 center_y += (height / (total - 1));412 }413 center_x = x + (2 / 7 * width);414 center_y = y + 0.15 * height;415 data.points.push({x: center_x, y: center_y});416 center_x += (1 / 7 * width);417 center_y = y + 0.35 * height;418 data.points.push({x: center_x, y: center_y});419 center_x += (1 / 7 * width);420 center_y = y + 0.55 * height;421 data.points.push({x: center_x, y: center_y});422 center_x += (1 / 7 * width);423 center_y = y + 0.75 * height;424 data.points.push({x: center_x, y: center_y});425 data.width = width;426 return data;427 }428 return {429 getPoints: draw430 };431 })(),432 D: (function () {433 var434 w2h = 0.6,435 total = 6;436 function draw (x, y, height) {437 var 438 width = w2h * height,439 center_x = x,440 center_y = y,441 data = {442 points: [],443 width: 0444 };445 for(var i = 0; i < total; i++) {446 data.points.push({x: center_x, y: center_y});447 center_y += (height / (total - 1));448 }449 center_x = x + (2 / 7 * width);450 center_y = y + 0.02 * height;451 data.points.push({x: center_x, y: center_y});452 center_y = y + (height - 0.02 * height);453 data.points.push({x: center_x, y: center_y});454 center_x += (2 / 7 * width);455 center_y = y + 0.10 * height;456 data.points.push({x: center_x, y: center_y});457 center_y = y + (height - 0.10 * height);458 data.points.push({x: center_x, y: center_y});459 center_x += (1.9 / 7 * width);460 center_y = y + 0.24 * height;461 data.points.push({x: center_x, y: center_y});462 center_y = y + (height - 0.24 * height);463 data.points.push({x: center_x, y: center_y});464 center_x = x + width;465 center_y = y + 0.4 * height;466 data.points.push({x: center_x, y: center_y});467 center_y = y + 0.6 * height;468 data.points.push({x: center_x, y: center_y});469 data.width = width;470 return data;471 }472 return {473 getPoints: draw474 };475 })(),476 C: (function () {477 var478 w2h = 0.5,479 total = 6;480 function draw (x, y, height) {481 var 482 width = w2h * height,483 center_x = x,484 center_y = y,485 data = {486 points: [],487 width: 0488 };489 x = x + width;490 center_x = x;491 data.points.push({x: center_x, y: center_y});492 center_y = y + height;493 data.points.push({x: center_x, y: center_y});494 center_x = x - (2 / 7 * width);495 center_y = y + 0.02 * height;496 data.points.push({x: center_x, y: center_y});497 center_y = y + (height - 0.02 * height);498 data.points.push({x: center_x, y: center_y});499 center_x -= (2 / 7 * width);500 center_y = y + 0.10 * height;501 data.points.push({x: center_x, y: center_y});502 center_y = y + (height - 0.10 * height);503 data.points.push({x: center_x, y: center_y});504 center_x -= (1.9 / 7 * width);505 center_y = y + 0.24 * height;506 data.points.push({x: center_x, y: center_y});507 center_y = y + (height - 0.24 * height);508 data.points.push({x: center_x, y: center_y});509 center_x = x - width;510 center_y = y + 0.4 * height;511 data.points.push({x: center_x, y: center_y});512 center_y = y + 0.6 * height;513 data.points.push({x: center_x, y: center_y});514 data.width = width;515 return data;516 }517 return {518 getPoints: draw519 };520 })(),521 J: (function () {522 var523 w2h = 0.6,524 total = 6;525 function draw (x, y, height) {526 var 527 width = w2h * height,528 center_x = x + 0.5 * width,529 center_y = y,530 data = {531 points: [],532 width: 0533 };534 for(var i = 0; i < total; i++) {535 data.points.push({x: center_x, y: center_y});536 center_y += (height / (total - 1));537 }538 center_x = x + 0.28 * width;539 center_y = y + height;540 data.points.push({x: center_x, y: center_y});541 center_x = x + 0.125 * width;542 center_y = y + 0.9 * height;543 data.points.push({x: center_x, y: center_y});544 center_x = x;545 center_y = y;546 data.points.push({x: center_x, y: center_y});547 center_x = x + 0.25 * width;548 data.points.push({x: center_x, y: center_y});549 center_x = x + 0.75 * width;550 data.points.push({x: center_x, y: center_y});551 center_x = x + width;552 data.points.push({x: center_x, y: center_y});553 data.width = width;554 return data;555 }556 return {557 getPoints: draw558 };559 })(),560 R: (function () {561 var 562 w2h = 0.4,563 total = 6;564 function draw (x, y, height) {565 var566 width = w2h * height,567 center_x = x,568 center_y = y,569 data = {570 points: [],571 width: 0572 };573 for( var i = 0; i < total; i++ ) {574 data.points.push({x: center_x, y: center_y});575 center_y += (height / (total - 1));576 }577 center_x = x + width / 2.5;578 center_y = y;579 data.points.push({x: center_x, y: center_y});580 center_y = y + height / 2;581 data.points.push({x: center_x, y: center_y});582 center_x += (width / 2.5);583 center_y = y + height / 10;584 data.points.push({x: center_x, y: center_y});585 center_y = y + 0.4 * height;586 data.points.push({x: center_x, y: center_y});587 center_x += (width / 5);588 center_y = y + 0.25 * height;589 data.points.push({x: center_x, y: center_y});590 center_x = x + 0.6 * width;591 center_y = y + 0.6 * height;592 data.points.push({x: center_x, y: center_y});593 center_x = x + 0.8 * width;594 center_y = y + 0.8 * height;595 data.points.push({x: center_x, y: center_y});596 center_x = x + width;597 center_y = y + height;598 data.points.push({x: center_x, y: center_y});599 data.width = width;600 return data;601 }602 return {603 getPoints: draw604 };605 })(),606 K: (function () {607 var608 w2h = 0.4,609 total = 6;610 function draw (x, y, height) {611 var 612 width = w2h * height,613 center_x = x,614 center_y = y,615 data = {616 points: [],617 width: 0618 };619 for(var i = 0; i < total; i++) {620 data.points.push({x: center_x, y: center_y});621 center_y += (height / (total - 1));622 }623 center_x = x + width / 4;624 center_y = y + (3 / 7 * height);625 data.points.push({x: center_x, y: center_y});626 center_y = y + (4 / 7 * height);627 data.points.push({x: center_x, y: center_y});628 center_x += width / 4;629 center_y = y + (2 / 7 * height);630 data.points.push({x: center_x, y: center_y});631 center_y = y + (5 / 7 * height);632 data.points.push({x: center_x, y: center_y});633 center_x += width / 4;634 center_y = y + (1 / 7 * height);635 data.points.push({x: center_x, y: center_y});636 center_y = y + (6 / 7 * height);637 data.points.push({x: center_x, y: center_y});638 center_x += width / 4;639 center_y = y;640 data.points.push({x: center_x, y: center_y});641 center_y = y + height;642 data.points.push({x: center_x, y: center_y});643 data.width = width;644 return data;645 }646 return {647 getPoints: draw648 };649 })(),650 U: (function () {651 var652 w2h = 0.5,653 total = 6;654 function draw (x, y, height) {655 var 656 width = w2h * height,657 center_x = x,658 center_y = y,659 data = {660 points: [],661 width: 0662 };663 for(var i = 1; i < total; i++) {664 data.points.push({x: center_x, y: center_y});665 center_y += (height / (total - 1));666 }667 center_x = x + width;668 center_y = y;669 for(var i = 1; i < total; i++) {670 data.points.push({x: center_x, y: center_y});671 center_y += (height / (total - 1));672 }673 center_x = x + width / 6;674 center_y = y + 0.95 * height;675 data.points.push({x: center_x, y: center_y});676 center_x += width / 3;677 center_y = y + height;678 data.points.push({x: center_x, y: center_y});679 center_x += width / 3;680 center_y = y + 0.95 * height;681 data.points.push({x: center_x, y: center_y});682 data.width = width;683 return data;684 }685 return {686 getPoints: draw687 };688 })(),689 Y: (function () {690 var691 w2h = 0.7,692 total = 6;693 function draw (x, y, height) {694 var 695 width = w2h * height,696 center_x = x + 0.5 * width,697 center_y = y + 0.6 * height,698 data = {699 points: [],700 width: 0701 };702 for(var i = 0; i < (total / 2); i++) {703 data.points.push({x: center_x, y: center_y});704 center_y += (height / (total - 1));705 }706 center_x = x;707 center_y = y;708 data.points.push({x: center_x, y: center_y});709 center_x = x + width;710 data.points.push({x: center_x, y: center_y});711 center_x = x + width / 6;712 center_y = y + 0.2 * height;713 data.points.push({x: center_x, y: center_y});714 center_x = x + (5 * width / 6);715 data.points.push({x: center_x, y: center_y});716 center_x = x + width / 3;717 center_y = y + 0.4 * height;718 data.points.push({x: center_x, y: center_y});719 center_x = x + (2 * width / 3);720 data.points.push({x: center_x, y: center_y});721 data.width = width;722 return data;723 }724 return {725 getPoints: draw726 };727 })(),728 X: (function () {729 var730 w2h = 0.6,731 total = 6;732 function draw (x, y, height) {733 var 734 width = w2h * height,735 center_x = x,736 center_y = y,737 data = {738 points: [],739 width: 0740 };741 data.points.push({x: center_x, y: center_y});742 center_x = x + width;743 data.points.push({x: center_x, y: center_y});744 center_x = x + width / 6;745 center_y = y + 0.2 * height;746 data.points.push({x: center_x, y: center_y});747 center_x = x + (5 * width / 6);748 data.points.push({x: center_x, y: center_y});749 center_x = x + width / 3;750 center_y = y + 0.4 * height;751 data.points.push({x: center_x, y: center_y});752 center_x = x + (2 * width / 3);753 data.points.push({x: center_x, y: center_y});754 center_y = y + 0.6 * height;755 center_x = x + width / 3;756 data.points.push({x: center_x, y: center_y});757 center_x = x + (2 * width / 3);758 data.points.push({x: center_x, y: center_y});759 center_y = y + 0.8 * height;760 center_x = x + width / 6;761 data.points.push({x: center_x, y: center_y});762 center_x = x + (5 * width / 6);763 data.points.push({x: center_x, y: center_y});764 center_y = y + height;765 center_x = x;766 data.points.push({x: center_x, y: center_y});767 center_x = x + width;768 data.points.push({x: center_x, y: center_y});769 data.width = width;770 return data;771 }772 return {773 getPoints: draw774 };775 })(),776 W: (function () {777 var 778 w2h = 0.7,779 total = 6;780 function draw (x, y, height) {781 var782 width = w2h * height,783 center_x = x,784 center_y = y,785 line_width = width * 0.2,786 middle_width = width * 0.6,787 data = {788 points: [],789 width: 0790 };791 for( var i = 0; i < total; i++ ) {792 data.points.push({x: center_x, y: center_y});793 center_y += (height / (total - 1));794 center_x += (line_width / 6);795 }796 center_x = x + width;797 center_y = y;798 for( var i = 0; i < total; i++ ) {799 data.points.push({x: center_x, y: center_y});800 center_y += (height / (total - 1));801 center_x -= (line_width / 6);802 }803 center_x = x + line_width + middle_width * 0.25;804 center_y = y + height - 0.16 * height;805 data.points.push({x: center_x, y: center_y});806 center_x = x + line_width + middle_width * 0.75;807 data.points.push({x: center_x, y: center_y});808 center_y = y + height - 0.32 * height;809 center_x = x + line_width + middle_width * 0.5;810 data.points.push({x: center_x, y: center_y});811 center_y -= 0.16 * height;812 data.points.push({x: center_x, y: center_y});813 data.width = width;814 return data;815 }816 return {817 getPoints: draw818 };819 })(),820 V: (function () {821 var 822 w2h = 0.7,823 total = 6;824 function draw (x, y, height) {825 var826 width = w2h * height,827 center_x = x,828 center_y = y,829 line_width = width * 0.5,830 data = {831 points: [],832 width: 0833 };834 for( var i = 0; i < total; i++ ) {835 data.points.push({x: center_x, y: center_y});836 center_y += (height / (total - 1));837 center_x += (line_width / 5);838 }839 center_x = x + width;840 center_y = y;841 for( var i = 0; i < total; i++ ) {842 data.points.push({x: center_x, y: center_y});843 center_y += (height / (total - 1));844 center_x -= (line_width / 5);845 }846 data.width = width;847 return data;848 }849 return {850 getPoints: draw851 };852 })(),853 // opposite of W854 M: (function () {855 var 856 w2h = 0.8,857 total = 6;858 function draw (x, y, height) {859 var860 width = w2h * height,861 center_x = x,862 center_y = y + height,863 line_width = width * 0.2,864 middle_width = width * 0.6,865 data = {866 points: [],867 width: 0868 };869 for( var i = 0; i < total; i++ ) {870 data.points.push({x: center_x, y: center_y});871 center_y -= (height / (total - 1));872 center_x += (line_width / 6);873 }874 center_x = x + width;875 center_y = y + height;876 for( var i = 0; i < total; i++ ) {877 data.points.push({x: center_x, y: center_y});878 center_y -= (height / (total - 1));879 center_x -= (line_width / 6);880 }881 center_x = x + line_width + middle_width * 0.25;882 center_y = y + 0.16 * height;883 data.points.push({x: center_x, y: center_y});884 center_x = x + line_width + middle_width * 0.75;885 data.points.push({x: center_x, y: center_y});886 center_y = y + 0.32 * height;887 center_x = x + line_width + middle_width * 0.5;888 data.points.push({x: center_x, y: center_y});889 center_y += 0.16 * height;890 data.points.push({x: center_x, y: center_y});891 data.width = width;892 return data;893 }894 return {895 getPoints: draw896 };897 })(),898 Z: (function () {899 var 900 w2h = 0.7,901 total = 6;902 function draw (x, y, height) {903 var904 width = w2h * height,905 center_x = x,906 center_y = y,907 data = {908 points: [],909 width: 0910 };911 for(var i = 0; i < 4; i++) {912 center_y = y;913 data.points.push({x: center_x, y: center_y});914 center_y = y + height;915 data.points.push({x: center_x, y: center_y});916 center_x += (width / 3);917 }918 center_x = x + width;919 center_y = y;920 for(var i = 0; i < total; i++) {921 data.points.push({x: center_x, y: center_y});922 center_x -= (width / (total - 1));923 center_y += (height / (total -1));924 }925 data.width = width;926 return data;927 }928 return {929 getPoints: draw930 };931 })(),932 G: (function () {933 var934 w2h = 0.5,935 total = 6;936 function draw (x, y, height) {937 var 938 width = w2h * height,939 center_x = x,940 center_y = y,941 data = {942 points: [],943 width: 0944 };945 x = x + width;946 center_x = x;947 data.points.push({x: center_x, y: center_y});948 center_y = y + height;949 data.points.push({x: center_x, y: center_y});950 center_x = x - (2 / 7 * width);951 center_y = y + 0.02 * height;952 data.points.push({x: center_x, y: center_y});953 center_y = y + (height - 0.02 * height);954 data.points.push({x: center_x, y: center_y});955 center_x -= (2 / 7 * width);956 center_y = y + 0.10 * height;957 data.points.push({x: center_x, y: center_y});958 center_y = y + (height - 0.10 * height);959 data.points.push({x: center_x, y: center_y});960 center_x -= (1.9 / 7 * width);961 center_y = y + 0.24 * height;962 data.points.push({x: center_x, y: center_y});963 center_y = y + (height - 0.24 * height);964 data.points.push({x: center_x, y: center_y});965 center_x = x - width;966 center_y = y + 0.4 * height;967 data.points.push({x: center_x, y: center_y});968 center_y = y + 0.6 * height;969 data.points.push({x: center_x, y: center_y});970 center_y = y + 0.8 * height;971 center_x = x;972 data.points.push({x: center_x, y: center_y});973 center_y = y + 0.6 * height;974 data.points.push({x: center_x, y: center_y});975 center_x = x - (2 / 7 * width);976 data.points.push({x: center_x, y: center_y});977 data.width = width;978 return data;979 }980 return {981 getPoints: draw982 };983 })(),984 S: (function () {985 var986 w2h = 0.5,987 total = 6;988 function draw (x, y, height) {989 var 990 width = w2h * height,991 center_x = x,992 center_y = y,993 data = {994 points: [],995 width: 0996 };997 998 center_x = x + width;999 data.points.push({x: center_x, y: center_y});1000 center_x = x;1001 center_y = y + height;1002 data.points.push({x: center_x, y: center_y});1003 center_x = x + 0.7 * width;1004 center_y = y;1005 data.points.push({x: center_x, y: center_y});1006 center_x = x + 0.43 * width;1007 center_y = y + 0.03 * height;1008 data.points.push({x: center_x, y: center_y});1009 center_x = x + 0.57 * width;1010 center_y = y + 0.97 * height;1011 data.points.push({x: center_x, y: center_y});1012 center_y = y + height;1013 center_x = x + 0.3 * width;1014 data.points.push({x: center_x, y: center_y});1015 center_x = x + 0.16 * width;1016 center_y = y + 0.1 * height;1017 data.points.push({x: center_x, y: center_y});1018 center_x = x + 0.84 * width;1019 center_y = y + 0.9 * height;1020 data.points.push({x: center_x, y: center_y});1021 center_x = x;1022 center_y = y + 0.25 * height;1023 data.points.push({x: center_x, y: center_y});1024 center_x = x + width;1025 center_y = y + 0.75 * height;1026 data.points.push({x: center_x, y: center_y});1027 center_x = x + 0.2 * width;1028 center_y = y + 0.4 * height;1029 data.points.push({x: center_x, y: center_y});1030 center_x = x + 0.5 * width;1031 center_y = y + 0.5 * height;1032 data.points.push({x: center_x, y: center_y});1033 center_x = x + 0.8 * width;1034 center_y = y + 0.6 * height;1035 data.points.push({x: center_x, y: center_y});1036 data.width = width;1037 return data;1038 }1039 return {1040 getPoints: draw1041 };1042 })(),1043 O: (function () {1044 var1045 w2h = 0.6,1046 total = 6;1047 function draw (x, y, height) {1048 var 1049 width = w2h * height,1050 center_x = x + 0.5 * width,1051 center_y = y,1052 data = {1053 points: [],1054 width: 01055 };1056 data.points.push({x: center_x, y: center_y});1057 center_y = y + 0.05 * height;1058 center_x = x + 0.2 * width;1059 data.points.push({x: center_x, y: center_y});1060 center_x = x + 0.8 * width;1061 data.points.push({x: center_x, y: center_y});1062 center_y = y + 0.22 * height;1063 center_x = x + 0.05 * width;1064 data.points.push({x: center_x, y: center_y});1065 center_x = x + 0.95 * width;1066 data.points.push({x: center_x, y: center_y});1067 center_y = y + 0.4 * height;1068 center_x = x;1069 data.points.push({x: center_x, y: center_y});1070 center_x = x + width;1071 data.points.push({x: center_x, y: center_y});1072 center_y = y + 0.6 * height;1073 center_x = x;1074 data.points.push({x: center_x, y: center_y});1075 center_x = x + width;1076 data.points.push({x: center_x, y: center_y});1077 center_x = x + 0.05 * width;1078 center_y = y + 0.78 * height;1079 data.points.push({x: center_x, y: center_y});1080 center_x = x + 0.95 * width;1081 data.points.push({x: center_x, y: center_y});1082 center_x = x + 0.2 * width;1083 center_y = y + 0.95 * height;1084 data.points.push({x: center_x, y: center_y});1085 center_x = x + 0.8 * width;1086 data.points.push({x: center_x, y: center_y});1087 center_x = x + 0.5 * width;1088 center_y = y + height;1089 data.points.push({x: center_x, y: center_y});1090 data.width = width;1091 return data;1092 }1093 return {1094 getPoints: draw1095 };1096 })(),1097 Q: (function () {1098 var1099 w2h = 0.7,1100 total = 6;1101 function draw (x, y, height) {1102 var 1103 width = w2h * height,1104 center_x = x + 0.5 * width,1105 center_y = y,1106 data = {1107 points: [],1108 width: 01109 };1110 data.points.push({x: center_x, y: center_y});1111 center_y = y + 0.05 * height;1112 center_x = x + 0.2 * width;1113 data.points.push({x: center_x, y: center_y});1114 center_x = x + 0.8 * width;1115 data.points.push({x: center_x, y: center_y});1116 center_y = y + 0.22 * height;1117 center_x = x + 0.05 * width;1118 data.points.push({x: center_x, y: center_y});1119 center_x = x + 0.95 * width;1120 data.points.push({x: center_x, y: center_y});1121 center_y = y + 0.4 * height;1122 center_x = x;1123 data.points.push({x: center_x, y: center_y});1124 center_x = x + width;1125 data.points.push({x: center_x, y: center_y});1126 center_y = y + 0.6 * height;1127 center_x = x;1128 data.points.push({x: center_x, y: center_y});1129 center_x = x + width;1130 data.points.push({x: center_x, y: center_y});1131 center_x = x + 0.05 * width;1132 center_y = y + 0.78 * height;1133 data.points.push({x: center_x, y: center_y});1134 center_x = x + 0.95 * width;1135 data.points.push({x: center_x, y: center_y});1136 center_x = x + 0.2 * width;1137 center_y = y + 0.95 * height;1138 data.points.push({x: center_x, y: center_y});1139 center_x = x + 0.8 * width;1140 data.points.push({x: center_x, y: center_y});1141 center_x = x + 0.5 * width;1142 center_y = y + height;1143 data.points.push({x: center_x, y: center_y});1144 center_x = x + 0.7 * width;1145 center_y = y + 0.78 * height;1146 data.points.push({x: center_x, y: center_y});1147 center_x = x + 0.9 * width;1148 center_y = y + 1.1 * height;1149 data.points.push({x: center_x, y: center_y});1150 data.width = width;1151 return data;1152 }1153 return {1154 getPoints: draw1155 };1156 })(),1157 ' ': (function () {1158 var1159 w2h = 0;1160 function draw (x, y, height) {1161 var 1162 width = w2h * height,1163 data = {1164 points: [],1165 width: 01166 };1167 data.width = width;1168 return data;1169 }1170 return {1171 getPoints: draw1172 };1173 })(),1174 };1175 function initConfig (data) {1176 context = data.context ? data.context : context;1177 Shape.prototype.context = context;1178 height = data.context.canvas.height ? data.context.canvas.height : height;1179 width = data.context.canvas.width ? data.context.canvas.width : width;1180 radius = data.radius ? data.radius : radius;1181 color = data.color ? data.color : color;1182 animation = data.animation ? data.animation : animation;1183 shape = data.shape ? data.shape : shape;1184 acceleration = data.acceleration ? data.acceleration : acceleration;1185 friction = data.friction ? data.friction : friction;1186 gradient = data.gradient ? true : false;1187 gradObject = data.gradObject ? data.gradObject : null;1188 manualAnimation = data.manualAnimation ? data.manualAnimation : false;1189 if(AnimeId) {1190 window.cancelAnimationFrame(AnimeId);1191 }1192 }1193 function create (x, y, size, string, data) {1194 if(data) {1195 radius = data.radius ? data.radius : radius;1196 color = data.color ? data.color : color;1197 animation = data.animation ? data.animation : animation;1198 shape = data.shape ? data.shape : shape;1199 }1200 // info is the object returned by the letter1201 var info;1202 1203 x = x || 0;1204 y = y || 0;1205 size = size || 50;1206 string = string || '';1207 for(var i = 0; i < string.length; i++) {1208 info = letter[string[i]].getPoints(x, y, size);1209 atoms = atoms.concat(info.points);1210 x += (info.width + size * 0.4);1211 }1212 timer = Date.now();1213 animate();1214 }1215 // implement this function1216 function animateFrame () {1217 if(animation !== 'sameOrigin2') {1218 update();1219 draw();1220 }1221 else {1222 updateSameOrigin2();1223 } 1224 }1225 function animate () {1226 var data = {};1227 for(var i = 0; i < atoms.length; i++) {1228 data.center = {1229 x: atoms[i].x,1230 y: atoms[i].y,1231 };1232 data.pos = getPos(atoms[i].x, atoms[i].y);1233 data.radius = radius;1234 data.sides = getSides();1235 data.color = getColor();1236 data.vel = getVel();1237 atoms[i] = new Shape(data);1238 }1239 if (animation != 'off' && !manualAnimation) {1240 loop();1241 }1242 else {1243 clearCanvas();1244 draw();1245 }1246 }1247 function getPos (x, y) {1248 switch(animation) {1249 case 'random':1250 return new Vector(Math.random() * width, Math.random() * height);1251 case 'sameOrigin1':1252 return new Vector(radius, radius);1253 case 'sameOrigin2':1254 return new Vector(radius, radius);1255 case 'off':1256 return new Vector(x, y);1257 }1258 return new Vector(x, y);1259 }1260 function getVel () {1261 switch(animation) {1262 case 'random':1263 return new Vector(Math.random() * 20 - 10, Math.random() * 20 - 10);1264 case 'sameOrigin1':1265 return new Vector(5, 5);1266 case 'sameOrigin2':1267 return new Vector(5, 5);1268 case 'off':1269 return new Vector(0, 0);1270 }1271 return new Vector(0, 0);1272 }1273 function getSides () {1274 if(shape == 'random') {1275 return sides[side[Math.round(Math.random() * 2)]];1276 }1277 else {1278 return sides[shape];1279 }1280 }1281 function getColor () {1282 if(color == 'random') {1283 return colors[Math.round(Math.random() * (colors.length - 1))];1284 //return '#'+ ('000000' + Math.floor(Math.random()*16777215).toString(16)).slice(-6);1285 }1286 else {1287 return color;1288 }1289 }1290 function loop () {1291 clearCanvas();1292 if(animation !== 'sameOrigin2') {1293 update();1294 draw();1295 }1296 else {1297 updateSameOrigin2();1298 } 1299 queue();1300 }1301 function clearCanvas () {1302 context.clearRect(0, 0, width, height);1303 }1304 function updateSameOrigin2 () {1305 var length;1306 if(animation == 'sameOrigin2') {1307 length = Math.floor((Date.now() - timer) / 100);1308 length = length > atoms.length ? atoms.length : length;1309 }1310 else {1311 length = atoms.length;1312 }1313 for(var i = 0; i < length; i++) {1314 atoms[i].update();1315 }1316 for(var i = 0; i < length; i++) {1317 atoms[i].draw();1318 }1319 }1320 function update () {1321 for(var i = 0; i < atoms.length; i++) {1322 atoms[i].update();1323 }1324 }1325 function draw () {1326 for(var i = 0; i < atoms.length; i++) {1327 atoms[i].draw();1328 }1329 }1330 function queue() {1331 AnimeId = requestAnimFrame(loop);1332 }1333 function Vector( x, y ) {1334 this.x = x;1335 this.y = y;1336 }1337 Vector.prototype.add = function( vector ) {1338 this.x += vector.x;1339 this.y += vector.y;1340 };1341 function Shape (data) {1342 this.center = data.center;1343 this.pos = data.pos;1344 this.radius = data.radius;1345 this.color = data.color || 'black';1346 this.sides = data.sides || 0;1347 this.vel = data.vel || new Vector(0, 0);1348 this.acc = data.acc || new Vector(0, 0); 1349 }1350 Shape.prototype = {1351 acceleration: acceleration,1352 friction: friction,1353 1354 draw: function () {1355 var 1356 r = this.radius,1357 x = this.pos.x,1358 y = this.pos.y,1359 c = this.context,1360 sides = this.sides,1361 angle = 0,1362 grad = null,1363 counterclockwise = false;1364 if(gradient && gradObject) {1365 grad = context.createRadialGradient(x - r / 3, y - r / 3, 0, x, y, r);1366 grad.addColorStop(0,gradObject.start);1367 grad.addColorStop(1,gradObject.stop);1368 c.fillStyle = grad;1369 } else {1370 c.fillStyle = this.color || 'black';1371 }1372 if(sides === 0) {1373 c.beginPath();1374 c.arc(x, y, r, 0, 2 * Math.PI);1375 c.fill();1376 return;1377 } 1378 // drawing a polygon1379 c.moveTo(x + r * Math.sin(0), y - r * Math.cos(0));1380 var delta = 2 * Math.PI / sides;1381 1382 for(var i = 1; i < sides; i++) {1383 angle += counterclockwise?-delta:delta;1384 c.lineTo(x + r * Math.sin(angle), y - r * Math.cos(angle));1385 }1386 c.closePath(); 1387 c.fill(); 1388 },1389 update: function () {1390 var1391 dist_x = this.center.x - this.pos.x,1392 dist_y = this.center.y - this.pos.y,1393 distance = Math.sqrt(dist_x * dist_x + dist_y * dist_y);1394 1395 this.acc.x = acceleration * (dist_x / distance);1396 this.acc.y = acceleration * (dist_y / distance);1397 this.vel.x *= (1 - friction);1398 this.vel.y *= (1 - friction);1399 this.vel.add(this.acc);1400 this.pos.add(this.vel);1401 },1402 };1403 return {1404 create: create,1405 animateFrame: animateFrame,1406 initConfig: initConfig1407 };...

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

1var wptools = require('wptools');2var page = wptools.page('Albert Einstein');3page.get(function(err, resp) {4 if (err) {5 console.log(err);6 } else {7 console.log(resp.data.center_y);8 }9});10var wptools = require('wptools');11var page = wptools.page('Albert Einstein');12page.get(function(err, resp) {13 if (err) {14 console.log(err);15 } else {16 console.log(resp.data.center_y);17 }18});19var wptools = require('wptools');20var page = wptools.page('Albert Einstein');21page.get(function(err, resp) {22 if (err) {23 console.log(err);24 } else {25 console.log(resp.data.center_y);26 }27});28var wptools = require('wptools');29var page = wptools.page('Albert Einstein');30page.get(function(err, resp) {31 if (err) {32 console.log(err);33 } else {34 console.log(resp.data.center_y);35 }36});37var wptools = require('wptools');38var page = wptools.page('Albert Einstein');39page.get(function(err, resp) {40 if (err) {41 console.log(err);42 } else {43 console.log(resp.data.center_y);44 }45});46var wptools = require('wptools');47var page = wptools.page('Albert Einstein');48page.get(function(err, resp) {49 if (err) {50 console.log(err);51 } else {52 console.log(resp.data.center_y);53 }54});55var wptools = require('wptools');56var page = wptools.page('Albert Einstein');57page.get(function(err, resp)

Full Screen

Using AI Code Generation

copy

Full Screen

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

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt.js');2var wpt = require('./wpt.js');3var wpt = require('./wpt.js');4var wpt = require('./wpt.js');5var wpt = require('./wpt.js');6var wpt = require('./wpt.js');7var wpt = require('./wpt.js');8var wpt = require('./wpt.js');9var wpt = require('./wpt.js');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wp = require('wptoolkit');2var w = wp.createWindow();3w.center_y();4w.show();5var wp = require('wptoolkit');6var w = wp.createWindow();7w.center_x();8w.show();9var wp = require('wptoolkit');10var w = wp.createWindow();11w.center();12w.show();13var wp = require('wptoolkit');14var w = wp.createWindow();15w.move(10,10);16w.show();17var wp = require('wptoolkit');18var w = wp.createWindow();19w.resize(300,300);20w.show();21var wp = require('wptoolkit');22var w = wp.createWindow();23w.set_title("Test Window");24w.show();25var wp = require('wptoolkit');26var w = wp.createWindow();27w.set_background_color("red");28w.show();29var wp = require('wptoolkit');30var w = wp.createWindow();31w.set_background_image("bg.jpg");32w.show();33var wp = require('wptoolkit');34var w = wp.createWindow();35w.set_icon("icon.ico");36w.show();37var wp = require('wptoolkit');

Full Screen

Using AI Code Generation

copy

Full Screen

1include('wptoolkit.js');2wptoolkit.init();3var win = wptoolkit.createWindow({4});5var label = wptoolkit.createLabel({6 font: {7 }8});9win.add(label);10label.center_y();11win.open();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = new Wpt();2wpt.center_y(100);3console.log(wpt.y);4### wpt.center()5var wpt = new Wpt();6wpt.center();7console.log(wpt.x, wpt.y);8### wpt.set()9var wpt = new Wpt();10wpt.set(100, 200);11console.log(wpt.x, wpt.y);12### wpt.set_x()13var wpt = new Wpt();14wpt.set_x(100);15console.log(wpt.x);16### wpt.set_y()17var wpt = new Wpt();18wpt.set_y(100);19console.log(wpt.y);20### wpt.move()21var wpt = new Wpt();22wpt.move(100, 200);23console.log(wpt.x, wpt.y);24### wpt.move_x()

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