diff --git a/examples_proto/README.md b/examples_proto/README.md index 467168a..82766db 100644 --- a/examples_proto/README.md +++ b/examples_proto/README.md @@ -7,7 +7,7 @@ The following is the list of examples present in this book and more from our exc Featured examples shared by our readers and students. We are looking forward to see a lot more shaders created with the [GLSL editor](http://editor.thebookofshaders.com/). Please share your masterpiecess to [@bookofshaders](https://twitter.com/bookofshaders). -
+
## Getting started @@ -31,7 +31,7 @@ uniform vec2 u_mouse; // mouse position in screen pixels uniform float u_time; // Time in seconds since load ``` -
+
@@ -42,7 +42,7 @@ Shaping functions is fundamental technique that is recursively used throughout t Read [Shaping functions](../05) to learn more. -
+
See All Examples
@@ -54,7 +54,7 @@ In GLSL, colors are simply just vectors, which means you can easily apply the co Read [Colors](../06) to learn more. -
+
See All Examples
@@ -64,7 +64,7 @@ Let's look at how to draw simple shapes in a parallel procedural way. In a nutsh Read [Shapes](../07) to learn more. -
+
See All Examples
@@ -75,7 +75,7 @@ Matrices may look complex at a first glance, but you'll find it very handy and u Read [Matrix](../08) to learn more. -
+
See All Examples
@@ -86,7 +86,7 @@ Repetitive patterns are perfect theme for computational sketching. Different fro Read [Patterns](../09) to learn more. -
+
See All Examples
@@ -98,7 +98,7 @@ Life is boring if everything was predictable. Though nothing is truly random in Read [Random](../10) to learn more. -
+
See All Examples
@@ -110,7 +110,7 @@ Since Ken Perlin invented his first noise algorithm in 80s, the technique has be Read [Noise](../11) to learn more. -
+
See All Examples
@@ -119,5 +119,5 @@ Read [Noise](../11) to learn more. This section features relatively advanced examples from different chapters. Try if you can read and understand all the examples here to test yourself. -
+
See All Examples
diff --git a/examples_proto/src/examples.js b/examples_proto/src/examples.js index 7349711..36ab396 100644 --- a/examples_proto/src/examples.js +++ b/examples_proto/src/examples.js @@ -124,22 +124,32 @@ var shaderList = { }; window.addEventListener("load", function () { - var options = {clickRun: 'editor'}; var elms = document.getElementsByClassName('glslChapterGallery'); for (var i = 0; i < elms.length; i++) { var elm = elms[i]; - if (elm.hasAttribute('data')) { - var data = elm.getAttribute('data').split(','); - if (data[1]) { - options.logs = shaderList[data[0]].slice(0, Number(data[1])); + if (elm.hasAttribute('log')) { + var options = {clickRun: 'editor'}; + var d = elm.getAttribute('log').split(','); + if (d[1]) { + options.logs = concatList(shaderList[d[0]], Number(d[1])); } else { - options.logs = shaderList[data[0]]; + options.logs = concatList(shaderList[d[0]]); } - console.log(options.logs); var gallery = new GlslGallery(elm, options); } } + function concatList(list, n) { + var str = ""; + if (n) { + list = list.slice(0, n); + } + for (var i = 0; i < list.length; i ++) { + str += list[i]; + if (i != list.length - 1) { str += ","} + } + return str; + } }); diff --git a/examples_proto/test.html b/examples_proto/test.html new file mode 100644 index 0000000..ec7ea17 --- /dev/null +++ b/examples_proto/test.html @@ -0,0 +1,14 @@ + + +