• Register
  • Log In
  • Home
  • Quick Start
    • Configurator
    • Download YUI 3
  • Documentation
    • User Guides
    • Examples
    • API Docs
    • Environments
    • Tutorials
  • Community
    • Gallery
    • Blog
    • Forums
    • YUI Theater
    • Calendar
  • Contribute
    • YUI on GitHub »
    • File a Ticket
    • View Tickets
    • Dashboard
  • Other Projects
    • Shifter »
    • Yogi »
    • YUI 2
    • YUI Doc »
    • YUI Test
    • YUI Website
    • YUI Compressor »
    • YUI Builder »
    • YUI PHP Loader
    • Grid Builder »
    • Skin Builder »
  • YUI
  • >
  • Community
  • >
  • Gallery

Gallery

Modules

  • Home
  • Featured
  • Popular
  • New
  • All

Documentation

  • Yogi Documentation
  • Shifter Documentation
  • Developer Guide
  • Module Setup

Tag Cloud

Context Navigation

    Build Tag: gallery-2012.07.11-21-38

    Return to Conway's Game of Life Simulator

    YUI({
        //Last Gallery Build of this module
        gallery: 'gallery-2012.07.11-21-38'
    }).use('gallery-conway', 'graphics', 'node', function (Y) {
        var circle,
            circles = [],
            graphic = new Y.Graphic({
                render: '#conway'
            }),
            gridHeight = 21,
            gridWidth = 21,
            i,
            j,
            running = false,
            simulation = new Y.Conway({
                height: gridHeight,
                toroidal: true,
                width: gridWidth
            }),
            startStopButtonNode = Y.one('#start-stop-button'),
     
            onClick = function (x, y) {
                return function () {
                    simulation.setCell(x, y, !simulation.getCell(x, y));
                };
            },
     
            run = function () {
                if (running) {
                    simulation.step(function (updated) {
                        if (!updated.length) {
                            running = false;
                        }
     
                        run();
                    });
                }
            };
     
        for (j = 0; j < gridHeight; j += 1) {
            for (i = 0; i < gridWidth; i += 1) {
                circle = graphic.addShape({
                    fill: {
                        color: '#FFFFFF'
                    },
                    height: 12,
                    stroke: {
                        color: '#000000',
                        width: 1
                    },
                    type: 'circle',
                    width: 12,
                    x: 13 * i,
                    y: 13 * j
                });
     
                circles.push(circle);
     
                Y.Node(circle.get('node')).on('click', onClick(i, j));
            }
        }
     
        simulation.after('cellChange', function (eventFacade) {
            circles[eventFacade.index].set('fill', {
                color: eventFacade.cell ? '#000000' : '#FFFFFF'
            });
        });
     
        simulation.setCell(1, 8, true).setCell(2, 8, true).setCell(3, 8, true).setCell(3, 7, true).setCell(2, 6, true);
     
        if (startStopButtonNode) {
            startStopButtonNode.on('click', function () {
                running = !running;
                run();
            });
        }
    });

    Build Output

    /home/y/libexec/ant/bin/ant all
    Buildfile: build.xml
         [echo] Starting Build For gallery-conway
    
    clean:
    
    init:
        [mkdir] Created dir: /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-conway/build_tmp
         [echo] Starting Build For gallery-conway
    
    -lint-server:
         [echo] Starting Build For gallery-conway
    
    -node:
         [echo] For faster builds, install Node.js.
    
    -concatdebug:
         [copy] Copying 1 file to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-conway/build_tmp/ant
       [delete] Deleting directory /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-conway/build_tmp/ant
    
    -registerdebug:
         [copy] Copying 1 file to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-conway/build_tmp
    
    -prependdebug:
    
    -appenddebug:
    
    builddebug:
    
    -createcore:
         [copy] Copying 1 file to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-conway/build_tmp
    
    -loggerregex:
    
    buildcore:
    
    -rollupjs:
    
    -concatskins:
    
    -buildskins:
    
    -rollupcss:
    
    buildskins:
    
    -buildlangs:
    
    -rolluplangs:
    
    buildlangs:
    
    build:
    
    minify:
    [yuicompressor] Compressing /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-conway/build_tmp/gallery-conway.js
    [yuicompressor] 
    [yuicompressor] [WARNING] Invalid hint syntax: use strict
    [yuicompressor] {(function(Y,moduleName){ ---> "use strict" <--- ;var _null=null,_string_cellChange="cellChange",
    [yuicompressor] Compressed to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-conway/build_tmp/gallery-conway-min.js
    
    lint:
         [echo] Using Rhino. Install nodejs to improve jslint speed, or skip with -Dlint.skip=true
         [java] Running JSLint on : /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/src/gallery-conway/build_tmp/gallery-conway.js
         [java] - OK
    
    local:
    
    deploybuild:
         [copy] Copying 3 files to /home/y/var/builds/workspace/gallery/build_tmp/src/yui3-gallery/build/gallery-conway
    
    deployassets:
    
    deployskins:
    
    deploylang:
    
    deploydocs:
    
    deploy:
    
    all:
    
    BUILD SUCCESSFUL
    Total time: 2 seconds

    © 2006-2013 Yahoo! Inc. All rights reserved.
    All code on this site is licensed under the BSD License unless stated otherwise.
    About This Site · Security Contact Info