forked from pixijs/pixijs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b84c8c8
commit 7a977ac
Showing
42 changed files
with
3,882 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License | ||
|
||
Copyright (c) 2013-2014 Mathew Groves | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,76 @@ | ||
pixi.js | ||
======= | ||
Pixi Renderer | ||
============= | ||
|
||
#### JavaScript 2D Renderer #### | ||
|
||
The aim of this project is to provide a fast lightweight 2D library that works across all devices. | ||
The Pixi renderer allows everyone to enjoy the power of hardware acceleration without prior knowledge of webGL. | ||
Also its fast. | ||
|
||
### Demo ### | ||
|
||
[Check out the Bunny Demo here](http://matgroves.com/pixijs/) | ||
|
||
### Current features ### | ||
|
||
- webGL renderer (with automatic smart batching allowing for REALLY fast performance) | ||
- canvas renderer | ||
- full scene graph | ||
- super easy to use API (similar to the flash display list API) | ||
- support for texture atlas's | ||
- asset loader / sprite sheet loader | ||
- auto detect which renderer should be used | ||
- handles device context loss | ||
|
||
### Coming soon ### | ||
|
||
- Filters | ||
- Render Texture | ||
- Text | ||
- Interactivity | ||
- Documentation | ||
|
||
|
||
### Coming later ### | ||
|
||
- Awesome Post processing effects | ||
|
||
### Usage ### | ||
|
||
```javascript | ||
|
||
/* | ||
you can use either PIXI.WebGLRenderer or PIXI.CanvasRenderer | ||
*/ | ||
var renderer = new PIXI.WebGLRenderer(800, 600); | ||
|
||
document.body.appendChild(renderer.view); | ||
|
||
var stage = new PIXI.Stage; | ||
|
||
var bunnyTexture = new PIXI.Texture("bunny.png"); | ||
var bunny = new PIXI.Sprite(rabbitTexture); | ||
|
||
bunny.position.x = 400; | ||
bunny.position.y = 300; | ||
|
||
bunny.scale.x = 2; | ||
bunny.scale.y = 2; | ||
|
||
stage.addChild(bunny); | ||
|
||
requestAnimationFrame( animate ); | ||
|
||
function animate() { | ||
|
||
requestAnimationFrame( animate ); | ||
|
||
bunny.rotation += 0.01; | ||
|
||
renderer.render(stage); | ||
} | ||
``` | ||
|
||
This content is released under the (Link Goes Here) MIT License. | ||
|
||
|
||
Super fast HTML 5 2D rendering engine that uses webGL with canvas fallback |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0"?> | ||
<project basedir="." default="run"> | ||
|
||
<taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask" classpath="${basedir}/compiler.jar"/> | ||
<taskdef resource="net/sf/antcontrib/antlib.xml"> | ||
<classpath> | ||
<pathelement location="${basedir}/ant-contrib-1.0b3.jar"/> | ||
</classpath> | ||
</taskdef> | ||
|
||
<target name="run"> | ||
|
||
<jscomp compilationLevel="simple" debug="false" output="../bin/pixi.js"> | ||
|
||
|
||
|
||
<sources dir="../src/pixi/"> | ||
<file name="utils/Utils.js"/> | ||
<file name="utils/EventTarget.js"/> | ||
<file name="utils/gl-matrix-min.js"/> | ||
<file name="renderers/WebGLShaders.js"/> | ||
<file name="renderers/WebGLRenderer.js"/> | ||
<file name="renderers/CanvasRenderer.js"/> | ||
<file name="Point.js"/> | ||
<file name="Rectangle.js"/> | ||
<file name="DisplayObject.js"/> | ||
<file name="renderers/WebGLBatch.js"/> | ||
<file name="DisplayObjectContainer.js"/> | ||
<file name="Stage.js"/> | ||
<file name="Sprite.js"/> | ||
<file name="extras/Strip.js"/> | ||
<file name="extras/Rope.js"/> | ||
<file name="MovieClip.js"/> | ||
<file name="textures/BaseTexture.js"/> | ||
<file name="textures/Texture.js"/> | ||
<file name="utils/Detector.js"/> | ||
<file name="loaders/SpriteSheetLoader.js"/> | ||
<file name="loaders/AssetLoader.js"/> | ||
</sources> | ||
|
||
</jscomp> | ||
|
||
</target> | ||
|
||
</project> |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
body{ | ||
border: 0; | ||
margin: 0; | ||
} | ||
.counter { | ||
background: #ccc; | ||
width: 74px; | ||
position: absolute; | ||
background-color:#105CB6; | ||
padding: 3px; | ||
|
||
top:50px; | ||
|
||
color:#0ff; | ||
font-family: Helvetica, Arial; | ||
font-size: 9px; | ||
font-weight: bold; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | ||
"http://www.w3.org/TR/html4/loose.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | ||
|
||
<title>Pixi Renderer: Alien Demo</title> | ||
<link rel="stylesheet" href="css/main.css"> | ||
</head> | ||
<body> | ||
<script src="js/vendor/jquery-1.8.3.min.js"></script> | ||
<script src="js/stats.min.js"></script> | ||
<script src="js/pixi.min.js"></script> | ||
<script src="js/StressTest.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
|
||
|
||
$(document).ready(onReady) | ||
|
||
$(window).resize(resize) | ||
window.onorientationchange = resize; | ||
|
||
var width = 480; | ||
var height = 320; | ||
|
||
var aliens = []; | ||
|
||
var maxX = width; | ||
var minX = 0; | ||
var maxY = height; | ||
var minY = 0; | ||
|
||
var startAlienCount = 100; | ||
var isAdding = false; | ||
var count = 0; | ||
var loader; | ||
var alienFrames = ["eggHead.png", "flowerTop.png", "helmlok.png", "skully.png"]; | ||
|
||
function onReady() | ||
{ | ||
loader = new PIXI.AssetLoader(["GameAssets.json"]) | ||
|
||
loader.addEventListener( 'loaded', function ( event ) { | ||
init(); | ||
} ); | ||
|
||
loader.load(); | ||
} | ||
|
||
function init() | ||
{ | ||
renderer = PIXI.autoDetectRenderer(800, 600); | ||
|
||
stage = new PIXI.Stage; | ||
|
||
document.body.appendChild(renderer.view); | ||
|
||
stats = new Stats(); | ||
|
||
document.body.appendChild( stats.domElement ); | ||
stats.domElement.style.position = "absolute"; | ||
stats.domElement.style.top = "0px"; | ||
requestAnimFrame(update); | ||
|
||
resize(); | ||
|
||
// add a bunch of aliens | ||
for (var i = 0; i < startAlienCount; i++) | ||
{ | ||
var alien = new PIXI.Sprite.spriteFromFrame(alienFrames[i % 4]); | ||
alien.position.x = Math.random() * maxX; | ||
alien.position.y = Math.random() * maxY; | ||
alien.anchor.x = 0.5; | ||
alien.anchor.y = 0.5; | ||
aliens.push(alien); | ||
|
||
stage.addChild(alien); | ||
} | ||
|
||
// add some events counter | ||
$(renderer.view).mousedown(function(){ | ||
isAdding = true; | ||
}); | ||
|
||
$(renderer.view).mouseup(function(){ | ||
isAdding = false; | ||
}) | ||
|
||
document.addEventListener("touchstart", onTouchStart, true); | ||
document.addEventListener("touchend", onTouchEnd, true); | ||
|
||
// add the bunny counter | ||
counter = document.createElement("div"); | ||
counter.className = "counter"; | ||
document.body.appendChild( counter); | ||
|
||
count = startAlienCount; | ||
counter.innerHTML = count + " ALIENS"; | ||
|
||
|
||
} | ||
|
||
function onTouchStart(event) | ||
{ | ||
isAdding = true; | ||
} | ||
|
||
function onTouchEnd(event) | ||
{ | ||
isAdding = false; | ||
} | ||
|
||
function resize() | ||
{ | ||
var width = $(window).width(); | ||
var height = $(window).height(); | ||
|
||
maxX = width; | ||
maxY = height; | ||
|
||
renderer.resize(width, height); | ||
|
||
for (var i = 0; i < aliens.length; i++) | ||
{ | ||
var alien = aliens[i]; | ||
alien.position.x = Math.random() * maxX; | ||
alien.position.y = Math.random() * maxY; | ||
} | ||
} | ||
|
||
function update() | ||
{ | ||
stats.begin(); | ||
|
||
if(isAdding) | ||
{ | ||
// add 10 at a time :) | ||
|
||
for (var i = 0; i < 2; i++) | ||
{ | ||
var alien = PIXI.Sprite.spriteFromFrame(alienFrames[count % 4]); | ||
alien.position.x = Math.random() * maxX; | ||
alien.position.y = Math.random() * maxY; | ||
alien.anchor.x = 0.5; | ||
alien.anchor.y = 0.5; | ||
alien.rotation = Math.random() - 0.5; | ||
stage.addChild(alien); | ||
count++; | ||
aliens.push(alien); | ||
} | ||
|
||
counter.innerHTML = count + " ALIENS"; | ||
} | ||
|
||
for (var i = 0; i < aliens.length; i++) | ||
{ | ||
var alien = aliens[i]; | ||
alien.rotation += 0.05; | ||
} | ||
|
||
renderer.render(stage); | ||
requestAnimFrame(update); | ||
stats.end(); | ||
} |
Oops, something went wrong.