Giter Club home page Giter Club logo

gury's People

Contributors

brucespang avatar rsandor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gury's Issues

IE9 __defineGetter__ issues

When running in IE9 the script falls over due to IE9 and EC5 not supporting defineGetter method.

This is a simple fix:

this.__defineGetter__("length", function() { return length; });

becomes:

Object.defineProperty(this, "length", {
    get: function() {
        return length;
    }
});

And then:

this.__defineGetter__("length", function() { return table.length; });

becomes:

Object.defineProperty(this, "length", {
    get: function() {
        return table.length;
    }
});

Thanks for a nice library by the way!

.mouseenter/.mouseleave not working?

Hello there, I'm really enjoying this library, but I .mouseenter/.mouseleave isn't working for some reason. Any ideas?

Code:

<!DOCTYPE html><html>
  <head>
    <title>Guryyyyy</title>
    <style>
        * {
            margin:0;
            padding:0;
        }
        html, body{
                width: 100%;
                height: 100%;
                overflow: hidden;
            }   
    </style>
    <script type="text/javascript" charset="utf-8" src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="http://github.com/downloads/rsandor/gury/gury.min.js"></script>
  </head>
  <body>

  </body>

<script type="text/javascript" charset="utf-8">
function coordinates(x, y) {
    if (typeof x === "undefined") {
        this.x = 0;
    } else {
        this.x = x;
    }

    if (typeof y === "undefined") {
        this.y = 0;
    } else {
        this.y = y;
    }
};

var ANCHOR_TOP_LEFT = new coordinates();
var ANCHOR_TOP_RIGHT = new coordinates(window.innerWidth);
var ANCHOR_BOT_LEFT = new coordinates(0, window.innerHeight);
var ANCHOR_BOT_RIGHT = new coordinates(window.innerWidth, window.innerHeight);

g = $g().size(ANCHOR_BOT_RIGHT.x, ANCHOR_BOT_RIGHT.y).background("black").place('body');

function boxy(width) {
    this.width = width;
}

boxy.prototype.draw = function(ctx,canvas) {
    ctx.fillStyle = "#FFF";
    ctx.beginPath();
    ctx.rect((0.05*ANCHOR_BOT_RIGHT.x),(0.05*ANCHOR_BOT_RIGHT.y),this.width,(0.9*ANCHOR_BOT_RIGHT.y));
    ctx.fill();
};

g.add('box', new boxy(100));
//Click works great
//g.click('box', function(e){this.width += 10;});
g.mouseenter('box', function(e){this.width += 10;});
g.play(32);
</script>
</html>

Bezier curves?

Hi,

Is it possible to draw and animate bezier curves with this library?

Thx,

Clement

Same Game

Could I get the demo code for same game?

Automatically delegating events to added objects?

I'm adding objects to my canvas, and they have their own update and draw functions, which get called automatically after play() is started. However, I also want them have their own functions for event handling, such as mouseenter, mousedown, etc.

So instead of

$g().add('myGuy', new Guy());
$g().mousedown('myGuy', handleMouseDown());

The mousedown events will be delegated to the objects themselves, so adding myGuy to the canvas will let it start receiving events automatically, like this:

$g().add('myGuy', new Guy());
// now when the mouse enters the Guy object's space, it will call the Guy object's mouseEnter function, etc.

I don't see anyway to set this up currently, is it possible, or can it be made possible?

.each should have a callback with index and object, not object and index

.each currently uses a callback where arguments are in order object, index, but jQuery for its .each uses first index and then object. It is really unintuitive to use different arguments order in the code for a similar method, so I would propose an API change, .each should use a callback with arguments in order same as in jQuery: first index, then object.

Code error in the API intro

Your second example I think should start with :

$g("canvasOne")

It is currently missing the g.

I am having fun learning the library. Good stuff.

Unify play and draw

Currently it is really cumbersome to switch between play and draw. Most of the time I have a static drawing, but for some effects I use animation. Because I would like to keep CPU usage for clients low I do not want to "play" all the time.

So I have a proposal: let objects added to the drawing queue have additional method "animate" which returns true or false if it is necessary to animate it (and call "update" and so on). Then provide additional method (to keep things backwards compatible) called "run", which would do something like every few ms: go trough all objects and call "animate". If any object returns true, call update on it. At the end, if any object returned true from "animate", redraw. Otherwise do nothing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.