Browse Source

Prepare for GitHub pages deployment

rexim 3 years ago
parent
commit
63c27f0a97
10 changed files with 227 additions and 6 deletions
  1. 1 0
      build.sh
  2. 68 0
      css/index.css
  3. 48 0
      css/reset.css
  4. BIN
      fonts/LibreBaskerville-Regular.ttf
  5. 94 0
      fonts/OFL.txt
  6. 16 5
      index.html
  7. 0 1
      js/vc.js
  8. BIN
      wasm/3d.wasm
  9. BIN
      wasm/squish.wasm
  10. BIN
      wasm/triangle.wasm

+ 1 - 0
build.sh

@@ -6,6 +6,7 @@ build_vc_example() {
     NAME=$1
 
     clang -Os -fno-builtin -Wall -Wextra -Wswitch-enum --target=wasm32 --no-standard-libraries -Wl,--no-entry -Wl,--export=render -Wl,--export=init -Wl,--allow-undefined -I. -I./build/ -I./thirdparty/ -o ./build/$NAME.wasm -DPLATFORM=WASM_PLATFORM ./examples/$NAME.c
+    cp ./build/$NAME.wasm ./wasm/
     clang -Wall -Wextra -ggdb -I. -I./build/ -I./thirdparty/ -o ./build/$NAME.sdl -DPLATFORM=SDL_PLATFORM ./examples/$NAME.c -lm -lSDL2
     clang -Wall -Wextra -ggdb -I. -I./build/ -I./thirdparty/ -o ./build/$NAME.term -DPLATFORM=TERM_PLATFORM ./examples/$NAME.c -lm
 }

+ 68 - 0
css/index.css

@@ -0,0 +1,68 @@
+@font-face {
+    font-family: 'LibreBaskerville';
+    src: url('../fonts/LibreBaskerville-Regular.ttf') format('truetype');
+}
+body {
+    background: #181818;
+    color: #F0F0F0;
+    font-family: LibreBaskerville;
+    margin: auto;
+    max-width: 960px;
+    font-size: 16px;
+}
+p {
+    padding-bottom: 20px;
+    line-height: 1.5;
+}
+h1 {
+    font-size: 40px;
+    text-align: center;
+    padding-top: 40px;
+    padding-bottom: 40px;
+}
+h2 {
+    font-size: 28px;
+    text-align: left;
+    padding-top: 20px;
+    padding-bottom: 40px;
+}
+h2 a {
+    color: #F0F0F0;
+}
+kbd {
+    display: inline-block;
+    font-family: monospace;
+    padding: 3px 5px;
+    background: #303030;
+    line-height: 10px;
+    vertical-align: middle;
+    text-align: center;
+    border-radius: 5px;
+}
+code {
+    display: inline-block;
+    font-family: monospace;
+}
+ul {
+    padding-bottom: 20px;
+    list-style: inside square;
+}
+ul li {
+    padding-bottom: 10px;
+}
+.plot {
+    width: 100%;
+    padding-bottom: 20px;
+}
+a {
+    color: #9090EE;
+    text-decoration: none;
+}
+.author {
+    text-align: center;
+    padding-bottom: 40px;
+    font-style: italic;
+}
+.author a {
+    color: #F0F0F0;
+}

+ 48 - 0
css/reset.css

@@ -0,0 +1,48 @@
+/* http://meyerweb.com/eric/tools/css/reset/ 
+   v2.0 | 20110126
+   License: none (public domain)
+*/
+
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside, canvas, details, embed, 
+figure, figcaption, footer, header, hgroup, 
+menu, nav, output, ruby, section, summary,
+time, mark, audio, video {
+	margin: 0;
+	padding: 0;
+	border: 0;
+	font-size: 100%;
+	font: inherit;
+	vertical-align: baseline;
+}
+/* HTML5 display-role reset for older browsers */
+article, aside, details, figcaption, figure, 
+footer, header, hgroup, menu, nav, section {
+	display: block;
+}
+body {
+	line-height: 1;
+}
+ol, ul {
+	list-style: none;
+}
+blockquote, q {
+	quotes: none;
+}
+blockquote:before, blockquote:after,
+q:before, q:after {
+	content: '';
+	content: none;
+}
+table {
+	border-collapse: collapse;
+	border-spacing: 0;
+}

BIN
fonts/LibreBaskerville-Regular.ttf


+ 94 - 0
fonts/OFL.txt

@@ -0,0 +1,94 @@
+Copyright (c) 2012, Pablo Impallari (www.impallari.com|[email protected]), 
+Copyright (c) 2012, Rodrigo Fuenzalida (www.rfuenzalida.com|[email protected]), with Reserved Font Name Libre Baskerville.
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded, 
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.

+ 16 - 5
index.html

@@ -1,21 +1,32 @@
 <html>
   <head>
     <title>Olive.c</title>
+    <link rel="stylesheet" href="css/reset.css" />
+    <link rel="stylesheet" href="css/index.css" />
   </head>
   <body>
     <h1>Olive.c Demos</h1>
+    <p>Olive.c is a simple graphics library that does not have any dependencies and renders everything into the given memory pixel by pixel.</p>
+    <p>Below is a bunch of demos written in C using this library compiled to WebAssembly. Every frame of the animations is generated pixel by pixel on CPU without using any special GPU APIs like OpenGL, Metal, etc. </p>
+    <p>The source code of the library and the demos is available on GitHub: <a href="https://github.com/tsoding/olive.c">https://github.com/tsoding/olive.c</a></p>
+
     <h2 id="demo-triangle"><a href="#demo-triangle">Triangle</a></h2>
+    <p>Rainbow triangle together with a transparent circle. Source:&nbsp;<a href="https://github.com/tsoding/olive.c/blob/master/examples/triangle.c">examples/triangle.c</a></p>
     <canvas id="app-triangle"></canvas>
+
     <h2 id="demo-3d"><a href="#demo-3d">3D</a></h2>
+    <p>A bunch of 3D points projected onto your 2D screen plus a text with a builtin monospaced font. Source:&nbsp;<a href="https://github.com/tsoding/olive.c/blob/master/examples/3d.c">examples/3d.c</a></p>
     <canvas id="app-3d"></canvas>
+
     <h2 id="demo-squish"><a href="#demo-squish">Squish</a></h2>
+    <p>Resizing images on the fly. Source:&nbsp;<a href="https://github.com/tsoding/olive.c/blob/master/examples/squish.c">examples/squish.c</a></p>
     <canvas id="app-squish"></canvas>
-    <script src="vc.js"></script>
+
+    <script src="js/vc.js"></script>
     <script>
-      startExample("app-triangle", "./build/triangle.wasm");
-      startExample("app-3d", "./build/3d.wasm");
-      startExample("app-squish", "./build/squish.wasm");
+      startExample("app-triangle", "./wasm/triangle.wasm");
+      startExample("app-3d", "./wasm/3d.wasm");
+      startExample("app-squish", "./wasm/squish.wasm");
     </script>
   </body>
 </html>
-<!-- TODO: deploy the WASM examples to GitHub pages -->

+ 0 - 1
vc.js → js/vc.js

@@ -47,7 +47,6 @@ async function startExample(elementId, wasmPath) {
         const buffer = w.instance.exports.memory.buffer;
         const image = new ImageData(new Uint8ClampedArray(buffer, pixels, app.width*app.height*4), app.width);
         ctx.putImageData(image, 0, 0);
-
         window.requestAnimationFrame(loop);
     }
     window.requestAnimationFrame(first);

BIN
wasm/3d.wasm


BIN
wasm/squish.wasm


BIN
wasm/triangle.wasm