forked from phaserjs/phaser
-
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
3f99b69
commit 46cf024
Showing
10 changed files
with
120 additions
and
4 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,68 @@ | ||
PIXI.GreyFilter = function() | ||
{ | ||
PIXI.AbstractFilter.call( this ); | ||
|
||
this.passes = [this]; | ||
|
||
// set the uniforms | ||
this.uniforms = { | ||
grey: {type: 'f', value: 1}, | ||
}; | ||
|
||
this.OLDfragmentSrc = [ | ||
"precision mediump float;", | ||
"varying vec2 vTextureCoord;", | ||
"varying float vColor;", | ||
"uniform sampler2D uSampler;", | ||
"uniform float grey;", | ||
"void main(void) {", | ||
"gl_FragColor = texture2D(uSampler, vTextureCoord);", | ||
"gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), grey);", | ||
"gl_FragColor = gl_FragColor * vColor;", | ||
"}" | ||
]; | ||
|
||
|
||
|
||
|
||
|
||
} | ||
|
||
PIXI.GreyFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); | ||
PIXI.GreyFilter.prototype.constructor = PIXI.GreyFilter; | ||
|
||
/** | ||
The strength of the grey. 1 will make the object black and white, 0 will make the object its normal color | ||
@property grey | ||
*/ | ||
Object.defineProperty(PIXI.GreyFilter.prototype, 'grey', { | ||
get: function() { | ||
return this.uniforms.grey.value; | ||
}, | ||
set: function(value) { | ||
this.uniforms.grey.value = value; | ||
} | ||
}); | ||
|
||
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render }); | ||
|
||
function preload() { | ||
|
||
game.load.image('atari1', 'assets/sprites/atari130xe.png'); | ||
game.load.image('coke', 'assets/sprites/cokecan.png'); | ||
game.load.image('mushroom', 'assets/sprites/mushroom2.png'); | ||
|
||
} | ||
|
||
function create() { | ||
|
||
game.add.sprite(60, 100, 'atari1'); | ||
game.add.sprite(360, 200, 'coke'); | ||
|
||
} | ||
|
||
function update() { | ||
} | ||
|
||
function render() { | ||
} |
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 @@ | ||
<?php | ||
$output = "this.fragmentSrc = [\n"; | ||
|
||
if (isset($_POST['shader'])) | ||
{ | ||
$shader = explode("\n", $_POST['shader']); | ||
|
||
for ($i = 0; $i < count($shader); $i++) | ||
{ | ||
$output = $output . "\t\"" . trim($shader[$i]) . "\",\n"; | ||
} | ||
} | ||
|
||
$output .= "];"; | ||
?> | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>phaser - filter conv</title> | ||
<style> | ||
body { | ||
font-family: Arial; | ||
font-size: 14px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<form action="filterconv.php" method="post"> | ||
|
||
<h2>Input</h2> | ||
<textarea name="shader" style="width: 800px; height: 400px"></textarea> | ||
|
||
<h2>Output</h2> | ||
<textarea style="width: 800px; height: 400px"><?php echo $output ?></textarea> | ||
|
||
<br /> | ||
|
||
<input type="submit" value="Convert" /> | ||
|
||
</form> | ||
|
||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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