mirror of
https://github.com/patriciogonzalezvivo/thebookofshaders
synced 2024-11-03 23:15:23 +00:00
Merge pull request #111 from patriciogonzalezvivo/gallery
Gallery updates
This commit is contained in:
commit
d101fe31b9
@ -295,16 +295,18 @@ code {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.glslGallery_item{
|
.glslGallery_item{
|
||||||
|
vertical-align: top;
|
||||||
width: 242px;
|
width: 242px;
|
||||||
margin: 8px;
|
margin: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.glslGallery_thumb{
|
.glslGallery_thumb{
|
||||||
max-width: 240px;
|
max-width: 240px;
|
||||||
border: solid 1px #EEEEEE;
|
border: solid 1px #EEEEEE;
|
||||||
}
|
}
|
||||||
|
|
||||||
.glslGallery_item canvas.glslGallery_canvas{
|
.glslGallery_item canvas.glslGallery_canvas{
|
||||||
|
vertical-align: top;
|
||||||
max-width: 242px;
|
max-width: 242px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
0
examples/README.md
Executable file → Normal file
0
examples/README.md
Executable file → Normal file
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
error_reporting(0);
|
||||||
$path = '..';
|
$path = '..';
|
||||||
$subtitle = ': Gallery';
|
$subtitle = ': Gallery';
|
||||||
$language = '';
|
$language = '';
|
||||||
@ -14,7 +15,6 @@
|
|||||||
include('../chap-header.php');
|
include('../chap-header.php');
|
||||||
|
|
||||||
echo '<div id="content">';
|
echo '<div id="content">';
|
||||||
|
|
||||||
include($path.'/src/parsedown/Parsedown.php');
|
include($path.'/src/parsedown/Parsedown.php');
|
||||||
$Parsedown = new Parsedown();
|
$Parsedown = new Parsedown();
|
||||||
|
|
||||||
@ -22,26 +22,32 @@
|
|||||||
|
|
||||||
if (empty($_GET)) {
|
if (empty($_GET)) {
|
||||||
// Load all the chapters
|
// Load all the chapters
|
||||||
$dirs = array_filter(glob('../??/'), 'is_dir');
|
$dirs = array_filter(glob('../*/'), 'is_dir');
|
||||||
|
|
||||||
foreach ($dirs as &$folder) {
|
foreach ($dirs as &$folder) {
|
||||||
$chp = '';
|
$chp = '';
|
||||||
preg_match("/\.\.\/(\d\d)\//", $folder, $matches);
|
preg_match("/\.\.\/(.+)\//", $folder, $matches);
|
||||||
if (count($matches) > 0) {
|
if (count($matches) > 0) {
|
||||||
$chp = $matches[1];
|
$chp = $matches[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($folder.'TITLE'.$language.'.md') and file_exists($folder.'SUMMARY'.$language.'.md')) {
|
if (file_exists($folder.'TITLE'.$language.'.md') and file_exists($folder.'SUMMARY'.$language.'.md')) {
|
||||||
echo '<a href="'.$folder.'">';
|
if (file_exists($folder.'README.md')) {
|
||||||
echo $Parsedown->text(file_get_contents($folder.'TITLE'.$language.'.md'));
|
echo '<a href="'.$folder.'">';
|
||||||
echo '</a>';
|
echo $Parsedown->text(file_get_contents($folder.'TITLE'.$language.'.md'));
|
||||||
|
echo '</a>';
|
||||||
|
} else {
|
||||||
|
echo $Parsedown->text(file_get_contents($folder.'TITLE'.$language.'.md'));
|
||||||
|
}
|
||||||
|
|
||||||
if (file_exists($folder.'SUMMARY'.$language.'.md')) {
|
if (file_exists($folder.'SHORT_SUMMARY'.$language.'.md')) {
|
||||||
|
echo $Parsedown->text(file_get_contents($folder.'SHORT_SUMMARY'.$language.'.md'));
|
||||||
|
} else if (file_exists($folder.'SUMMARY'.$language.'.md')) {
|
||||||
echo $Parsedown->text(file_get_contents($folder.'SUMMARY'.$language.'.md'));
|
echo $Parsedown->text(file_get_contents($folder.'SUMMARY'.$language.'.md'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$shaders = array_reverse(glob($folder.'*.frag'));
|
$shaders = array_reverse(glob($folder.'*.frag'));
|
||||||
$shadersTotal = min(count($shaders), 3);
|
$shadersTotal = min(count($shaders), 3);
|
||||||
|
|
||||||
if ($shadersTotal > 0) {
|
if ($shadersTotal > 0) {
|
||||||
echo '<div class="glslGallery" data="';
|
echo '<div class="glslGallery" data="';
|
||||||
for ($i = 0; $i < $shadersTotal; $i++) {
|
for ($i = 0; $i < $shadersTotal; $i++) {
|
||||||
@ -52,14 +58,29 @@
|
|||||||
}
|
}
|
||||||
echo '" data-properties="clickRun:editor,hoverPreview:false,showAuthor:false,openFrameIcon:false"></div>';
|
echo '" data-properties="clickRun:editor,hoverPreview:false,showAuthor:false,openFrameIcon:false"></div>';
|
||||||
}
|
}
|
||||||
|
if (file_exists($folder.'featured_examples.php') and $shaderTotal == 0) {
|
||||||
|
|
||||||
if (file_exists($folder.'featured_examples.php') and file_exists('FEATURED'.$language.'.md')) {
|
$featuredCode = file_get_contents($folder.'featured_examples.php');
|
||||||
|
preg_match_all("(\d+)", $featuredCode, $ids);
|
||||||
|
if (count($ids) > 0) {
|
||||||
|
echo '<div class="glslGallery" data="';
|
||||||
|
$numIds = min(count($ids[0]), 3);
|
||||||
|
for ($i = 0; $i < $numIds; $i++) {
|
||||||
|
echo $ids[0][$i];
|
||||||
|
if ($i < $numIds - 1) {
|
||||||
|
echo ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo '" data-properties="clickRun:editor,hoverPreview:false,showAuthor:false,openFrameIcon:false"></div>';
|
||||||
|
$shadersTotal = count($ids[0]);
|
||||||
|
}
|
||||||
|
} else if (file_exists($folder.'featured_examples.php') and file_exists('FEATURED'.$language.'.md')) {
|
||||||
include($folder.'featured_examples.php');
|
include($folder.'featured_examples.php');
|
||||||
$shadersTotal += 3;
|
$shadersTotal += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($shaders) > 3 or $shadersTotal > 3) {
|
if (count($shaders) > 3 or $shadersTotal > 3) {
|
||||||
echo '<p class="more"><a href="/examples/?chapter='.$chp.'">more</a></p>';
|
echo '<p class="more"><a href="../examples/?chapter='.$chp.'">more</a></p>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,7 +111,9 @@
|
|||||||
|
|
||||||
|
|
||||||
if (file_exists($folder.'featured_examples.php') and file_exists('FEATURED'.$language.'.md')) {
|
if (file_exists($folder.'featured_examples.php') and file_exists('FEATURED'.$language.'.md')) {
|
||||||
echo $Parsedown->text(file_get_contents('FEATURED'.$language.'.md'));
|
if ($shadersTotal != 0) {
|
||||||
|
echo $Parsedown->text(file_get_contents('FEATURED'.$language.'.md'));
|
||||||
|
}
|
||||||
include($folder.'featured_examples.php');
|
include($folder.'featured_examples.php');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
motionToolKit/SHORT_SUMMARY.md
Normal file
6
motionToolKit/SHORT_SUMMARY.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
*[kynd](http://www.kynd.info) Sep 9, 2016*
|
||||||
|
|
||||||
|
Designing motion in a fragment shader is not straight forward and can be a bit tedious since it is not an animation tool after all. Here are some convenient tools and examples for controlling easing and timing, drawing shapes, and combining all these to create a nice sequence of motion. The first five examples introduce many useful functions that you can use as building blocks for your design. Following examples demonstrate how you can combine these tool to design complex animations.
|
||||||
|
|
||||||
|
|
||||||
|
|
17
motionToolKit/SUMMARY.md
Normal file
17
motionToolKit/SUMMARY.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
*[kynd](http://www.kynd.info) Sep 9, 2016*
|
||||||
|
|
||||||
|
Designing motion in a fragment shader is not straight forward and can be a bit tedious since it is not an animation tool after all. Here are some convenient tools and examples for controlling easing and timing, drawing shapes, and combining all these to create a nice sequence of motion. The first five examples introduce many useful functions that you can use as building blocks for your design. Following examples demonstrate how you can combine these tool to design complex animations.
|
||||||
|
|
||||||
|
Exercises:
|
||||||
|
|
||||||
|
* Can you draw different waves using different easing functions, then animate circles following the waves?
|
||||||
|
|
||||||
|
* Animate two circles. Can you express difference between different materials through motion? How a metal ball and a plastic ball behave differently?
|
||||||
|
|
||||||
|
* Design your character(an animal, monster, spaceship, etc.) by combining shapes and animate it.
|
||||||
|
|
||||||
|
* Speed up or down your character animation. Can you make it five times faster or slower than the original?
|
||||||
|
|
||||||
|
* Add a new scene to the "wipes" example. How can you make it easy so that you don't have to adjust the timing of all subsequent parts manually?
|
||||||
|
|
||||||
|
* The examples here are not necessarily optimized, especially the last one. Try reducing the number of calculation as much as possible. Many functions are running even when the elements they draw are not on-screen. How can you avoid this?
|
1
motionToolKit/TITLE.md
Normal file
1
motionToolKit/TITLE.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# MotionToolKit
|
1
motionToolKit/featured_examples.php
Normal file
1
motionToolKit/featured_examples.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
<div class="glslGallery" data="160909064320,160909064357,160909064458,160909064528,160909041106,160909064609,160909064651,160909064723,160909064802,160909064829,160909065019,160909065049,160909065147" data-properties="clickRun:editor,hoverPreview:false"></div>
|
@ -1 +1 @@
|
|||||||
Subproject commit 3b02fadfa9a7ff9218382f8ad2334628dad4b742
|
Subproject commit 22050b571c923a702761844c91d26dfbbd841750
|
28
src/main.js
28
src/main.js
@ -2,7 +2,7 @@
|
|||||||
// PARSING
|
// PARSING
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
|
|
||||||
// Graph plotter function take from
|
// Graph plotter function take from
|
||||||
// From http://blog.hvidtfeldts.net/index.php/2011/07/plotting-high-frequency-functions-using-a-gpu/
|
// From http://blog.hvidtfeldts.net/index.php/2011/07/plotting-high-frequency-functions-using-a-gpu/
|
||||||
var preFunction = "\n\
|
var preFunction = "\n\
|
||||||
#ifdef GL_ES\n\
|
#ifdef GL_ES\n\
|
||||||
@ -114,9 +114,9 @@ function styleCodeBlocks() {
|
|||||||
// Highlight code blocks
|
// Highlight code blocks
|
||||||
var list = document.getElementsByTagName("code");
|
var list = document.getElementsByTagName("code");
|
||||||
for(var i = 0; i < list.length; i++){
|
for(var i = 0; i < list.length; i++){
|
||||||
if (list[i].className == "language-glsl" ||
|
if (list[i].className == "language-glsl" ||
|
||||||
list[i].className == "language-bash" ||
|
list[i].className == "language-bash" ||
|
||||||
list[i].className == "language-cpp" ||
|
list[i].className == "language-cpp" ||
|
||||||
list[i].className == "language-html" ||
|
list[i].className == "language-html" ||
|
||||||
list[i].className == "language-processing" ){
|
list[i].className == "language-processing" ){
|
||||||
hljs.highlightBlock(list[i]);
|
hljs.highlightBlock(list[i]);
|
||||||
@ -130,7 +130,7 @@ function loadGlslElements() {
|
|||||||
var canvas = document.getElementsByClassName("canvas");
|
var canvas = document.getElementsByClassName("canvas");
|
||||||
for (var i = 0; i < canvas.length; i++){
|
for (var i = 0; i < canvas.length; i++){
|
||||||
glslCanvas.push(new GlslCanvas(canvas[i]));
|
glslCanvas.push(new GlslCanvas(canvas[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse EDITORS
|
// parse EDITORS
|
||||||
var ccList = document.querySelectorAll(".codeAndCanvas");
|
var ccList = document.querySelectorAll(".codeAndCanvas");
|
||||||
@ -150,7 +150,7 @@ function loadGlslElements() {
|
|||||||
var srcFile = sfList[i].getAttribute("data");
|
var srcFile = sfList[i].getAttribute("data");
|
||||||
glslGraphs.push(new GlslEditor(sfList[i], { canvas_width: 800, lineNumbers: false, canvas_height: 250, frag_header: preFunction, frag_footer: postFunction, tooltips: true }).open(srcFile));
|
glslGraphs.push(new GlslEditor(sfList[i], { canvas_width: 800, lineNumbers: false, canvas_height: 250, frag_header: preFunction, frag_footer: postFunction, tooltips: true }).open(srcFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertAfter(newElement,targetElement) {
|
function insertAfter(newElement,targetElement) {
|
||||||
@ -163,15 +163,15 @@ function insertAfter(newElement,targetElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function captionizeImages() {
|
function captionizeImages() {
|
||||||
if (!document.getElementsByTagName)
|
if (!document.getElementsByTagName)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!document.createElement)
|
if (!document.createElement)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var images = document.getElementsByTagName("img");
|
var images = document.getElementsByTagName("img");
|
||||||
if (images.length < 1)
|
if (images.length < 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (var i = 0; i < images.length; i++) {
|
for (var i = 0; i < images.length; i++) {
|
||||||
var title = images[i].getAttribute("alt");
|
var title = images[i].getAttribute("alt");
|
||||||
@ -262,13 +262,13 @@ function nextPage() {
|
|||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = function(){
|
window.addEventListener("load", function(){
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
styleCodeBlocks();
|
styleCodeBlocks();
|
||||||
loadGlslElements();
|
loadGlslElements();
|
||||||
captionizeImages();
|
captionizeImages();
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
}, 500);
|
}, 500);
|
||||||
};
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user