diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/STYLE.nfo b/patterns/C64_TrueType_v1.2.1-STYLE/STYLE.nfo new file mode 100644 index 0000000..9aa033a --- /dev/null +++ b/patterns/C64_TrueType_v1.2.1-STYLE/STYLE.nfo @@ -0,0 +1,129 @@ + + Б А А Б + лА ллБ Влл Ал + лл ллллВБ БВлллл лл + ллл лллллллВ Вллллллл ллл + лллВ лллллллллВБ БВллллллллл Вллл + ллллБ ллллллллллллВ Влллллллллллл Влллл + лллллБ ллллллллллллллВлллллллллллллл Бллллл + ллллллА ллллллллллллВ Влллллллллллл Алллллл + ллллллл лллллллллВБ БВллллллллл ллллллл + лллллллл ллллллВВ ВВлллллл лллллллл + ллллллллл ллллБА АБлллл ллллллллл + лллллллллВ ллБ Влл Вллллллллл + ллллллллллБ А млм А Блллллллллл + лллллллллллА ллллл Аллллллллллл + лллллллллллл плп лллллллллллл + ллллллллллллл ллллллллллллл + лллллллллллллл лллллллллллллл + ллллллллллллллл ллллллллллллллл + лллллллллллллллВ млм Вллллллллллллллл + ллллллллллллллллБ ллллл Блллллллллллллллл + лллллллллллллллллБ плп Бллллллллллллллллл + ллллллллллллллллллА Алллллллллллллллллл + ллллллллллллллллллл ллллллллллллллллллл + лллллллллллллллллллл лллллллллллллллллллл + ллллллллллллллллллллВ млм Влллллллллллллллллллл + лллллллллллллллллллллВ ллллл Вллллллллллллллллллллл + ллллллллллллллллллллллБ плп Блллллллллллллллллллллл + лллллллллллллллллллллллА Аллллллллллллллллллллллл + лллллллллллллллллллллллл лллллллллллллллллллллллл + ллллллллллллллллллллллллл ллллллллллллллллллллллллл + лллллллллллллллллллллллллл лллллллллллллллллллллллллл + ллллллллллллллллллллллллллл ллллллллллллллллллллллллллл + лллллллллллллллллллллллллллВ Вллллллллллллллллллллллллллл + ллллллллллллллллллллллллллллВ Влллллллллллллллллллллллллллл + лллллллллллллллллллллллллллллВллллллллллллллллллллллллллллл + + лллА лллллллллА лллА лллА лллА лллллллА + лллА лллллллллА лллА лллА лллА лллллллА + лллА лллА лллА лллА лллА лллА + лллА лллА лллА лллА лллА лллА + лллА лллА ллВ ВллА лллА лллА + лллА лллА ллл лллА лллА лллА + лллА лллА лллллА лллА лллллллА + лллА лллА лллллА лллА лллллллА + лллА лллА лллА лллА лллА + лллА лллА лллА лллА лллА + лллА лллА лллА лллА лллА + лллА лллА лллА лллА лллА + лллА лллА лллА лллА лллА + лллА лллА лллА лллА лллА + ллллА лллА лллА лллллллА лллллллА + лллА лллА лллА лллллллА лллллллА + + п ппппппппппппппппппппппппппппппппппппппппппппппппппппппп п + title: C64 TrueType v1.2.1 type: fonts + date: April 15, 2019 platform: Any OS/web + м ммммммммммммммммммммммммммммммммммммммммммммммммммммммм м + + + >> What the hell is it? + + Our C64 TrueType fonts provide monospace and + variable pitch versions of the legendary C64 + character set. For programmers, each font contains + Unicode mappings to accomodate either a direct + PETSCII mapping or a screencode mapping. For users, + the fonts map to some obvious code points (like the + Unicode box drawing range) and should also support + easy mapping from applicable code points in cp437 + and cp1252. Our goal is to provide all 304 necessary + glyphs in the C64 character set in as small a file + as possible while still being programmer-friendly. + Finally, six additional glyphs are included to round + out the US-ASCII table with \, ^, `, {, }, and ~ for + the sake of providing a usable PETSCII experience + in code editors/IDEs. + + This update corrects some bounding box issues as + reported in the updated Microsoft Font Validator, + left side bearing on one glyph, and updates some + PS names. + + This update also adds a 'proper' OpenType format + (.otf) with CFF outlines. All files should be + smaller than the previous release. SVG format + has been dropped. + + "C64 Pro Mono" is the fixed pitch while "C64 Pro" + is a variable pitch (propertional) version. In the + legacy folder you can also find "C64 Elite Mono" + which was used in DirMaster v2.x - we don't + recommend using it for anything else other than + if you need it for running an older version of + DirMaster. The "C64 Pro Mono" in this release is + the same as what ships with DirMaster v3.1.2 but + will work with any older 3.x version of DirMaster. + + + >> What does the future hold? + + The Unicode Consortium (or acolytes thereof) + recently tackled the issue of missing legacy + computing character sets. The first attempt + has omitted several of the C64's vertical and + horizontal 'quarter-bar' characters. Pending + the final outcome we'll add whatever new + mappings that are relevant to the C64 when + the next Unicode update drops. + + + >> Previous releases: + + v1.0 - Oct 1, 2010 + v1.2 - Sep 2, 2014 + + + >> For more information: + + http://style64.org/c64-truetype + + http://style64.org/c64-truetype/license + + http://style64.org/petscii + + + п ппппппппппппппппппппппппппппппппппппппппппппппппппппппп п + Keep scene spirit alive! + м ммммммммммммммммммммммммммммммммммммммммммммммммммммммм м diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/file_id.diz b/patterns/C64_TrueType_v1.2.1-STYLE/file_id.diz new file mode 100644 index 0000000..df67707 --- /dev/null +++ b/patterns/C64_TrueType_v1.2.1-STYLE/file_id.diz @@ -0,0 +1,16 @@ + + п ппппппппппппппппппппппппппппппппппп п + C64 TrueType v1.2.1/Style + м ммммммммммммммммммммммммммммммммммм м + + В лВ Вл В ппппппппппппппп + лБ лллмАмллл Бл release type: + ллА лллпАпллл Алл ў fonts + ллл лВ Вл ллл + лллВ л Вллл for platform: + ллллБ Блллл ў Any OS/web + лллллА л Аллллл + лллллл лллллл released on: + ллллллл л ллллллл ў 2019-04-15 + лллллллл лллллллл ммммммммммммммм + ллллллллл ллллллллл њњњ[01/01]њњњ diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro-STYLE.eot b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro-STYLE.eot new file mode 100644 index 0000000..3124016 Binary files /dev/null and b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro-STYLE.eot differ diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro-STYLE.otf b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro-STYLE.otf new file mode 100644 index 0000000..f1e4dfe Binary files /dev/null and b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro-STYLE.otf differ diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro-STYLE.ttf b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro-STYLE.ttf new file mode 100644 index 0000000..a6c30a6 Binary files /dev/null and b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro-STYLE.ttf differ diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro-STYLE.woff b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro-STYLE.woff new file mode 100644 index 0000000..c711dd8 Binary files /dev/null and b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro-STYLE.woff differ diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro-STYLE.woff2 b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro-STYLE.woff2 new file mode 100644 index 0000000..1d0a8d6 Binary files /dev/null and b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro-STYLE.woff2 differ diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro_Mono-STYLE.eot b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro_Mono-STYLE.eot new file mode 100644 index 0000000..b671904 Binary files /dev/null and b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro_Mono-STYLE.eot differ diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro_Mono-STYLE.otf b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro_Mono-STYLE.otf new file mode 100644 index 0000000..b96258c Binary files /dev/null and b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro_Mono-STYLE.otf differ diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro_Mono-STYLE.ttf b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro_Mono-STYLE.ttf new file mode 100644 index 0000000..02ff5fc Binary files /dev/null and b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro_Mono-STYLE.ttf differ diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro_Mono-STYLE.woff b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro_Mono-STYLE.woff new file mode 100644 index 0000000..60347be Binary files /dev/null and b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro_Mono-STYLE.woff differ diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro_Mono-STYLE.woff2 b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro_Mono-STYLE.woff2 new file mode 100644 index 0000000..a1b72c5 Binary files /dev/null and b/patterns/C64_TrueType_v1.2.1-STYLE/fonts/C64_Pro_Mono-STYLE.woff2 differ diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/legacy_fonts/C64_Elite_Mono_v1.0-STYLE.ttf b/patterns/C64_TrueType_v1.2.1-STYLE/legacy_fonts/C64_Elite_Mono_v1.0-STYLE.ttf new file mode 100644 index 0000000..3cdc289 Binary files /dev/null and b/patterns/C64_TrueType_v1.2.1-STYLE/legacy_fonts/C64_Elite_Mono_v1.0-STYLE.ttf differ diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/license.txt b/patterns/C64_TrueType_v1.2.1-STYLE/license.txt new file mode 100644 index 0000000..e8ab319 --- /dev/null +++ b/patterns/C64_TrueType_v1.2.1-STYLE/license.txt @@ -0,0 +1,8 @@ + +Fonts in this package are (c) 2010-2019 Style. + +This license is applicable to each font file included in this package in all their variants (ttf, otf, eot, woff, woff2, svg). + +You MAY NOT: sell this font; include/redistribute the font in any font collection regardless of pricing; provide the font for direct download from any web site, modify or rename the font. You MAY: link to "http://style64.org/c64-truetype" in order for others to download and install the font; embed the font (without any modification or file renaming) for display on any web site using @font-face rules; use this font in static images and vector art; include this font (without any modification or file renaming) as part of a software package but ONLY if said software package is freely provided to end users. You may also contact us to negotiate a (possibly commercial) license for your use outside of these guidelines at "http://style64.org/contact-style". + +At all times the most recent version of this license can be found at "http://style64.org/c64-truetype/license". diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/screenshot.png b/patterns/C64_TrueType_v1.2.1-STYLE/screenshot.png new file mode 100644 index 0000000..dcec67f Binary files /dev/null and b/patterns/C64_TrueType_v1.2.1-STYLE/screenshot.png differ diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/test/test-eot.html b/patterns/C64_TrueType_v1.2.1-STYLE/test/test-eot.html new file mode 100644 index 0000000..d5a81c4 --- /dev/null +++ b/patterns/C64_TrueType_v1.2.1-STYLE/test/test-eot.html @@ -0,0 +1,170 @@ + + + + C64 Pro Mono: EOT (Embedded OpenType) test + + + + + +
+ +
+ See: http://caniuse.com/#feat=eot +

If you do not see the font, you may be using a browser that disallows local font loading due to CORS (probably Firefox or IE).

+
+ +
+
+ +
+ “C64 Pro Mono/Style”
+    upper/graphics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+ +
+ “C64 Pro Mono/Style”
+    lower/upper + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+
+ + + + + diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/test/test-otf.html b/patterns/C64_TrueType_v1.2.1-STYLE/test/test-otf.html new file mode 100644 index 0000000..5e571b0 --- /dev/null +++ b/patterns/C64_TrueType_v1.2.1-STYLE/test/test-otf.html @@ -0,0 +1,170 @@ + + + + C64 Pro Mono: OTF (OpenType) test + + + + + +
+ +
+ See: http://caniuse.com/#feat=otf +

If you do not see the font, you may be using a browser that disallows local font loading due to CORS (probably Firefox or IE).

+
+ +
+
+ +
+ “C64 Pro Mono/Style”
+    upper/graphics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+ +
+ “C64 Pro Mono/Style”
+    lower/upper + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+
+ + + + + diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/test/test-ttf.html b/patterns/C64_TrueType_v1.2.1-STYLE/test/test-ttf.html new file mode 100644 index 0000000..ef2666d --- /dev/null +++ b/patterns/C64_TrueType_v1.2.1-STYLE/test/test-ttf.html @@ -0,0 +1,169 @@ + + + + C64 Pro Mono: TTF (TrueType) test + + + + + +
+ +
+ See: http://caniuse.com/#feat=ttf +

If you do not see the font, you may be using a browser that disallows local font loading due to CORS (probably Firefox or IE).

+
+ +
+
+ +
+ “C64 Pro Mono/Style”
+    upper/graphics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+ +
+ “C64 Pro Mono/Style”
+    lower/upper + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+
+ + + + diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/test/test-woff.html b/patterns/C64_TrueType_v1.2.1-STYLE/test/test-woff.html new file mode 100644 index 0000000..0451af0 --- /dev/null +++ b/patterns/C64_TrueType_v1.2.1-STYLE/test/test-woff.html @@ -0,0 +1,170 @@ + + + + C64 Pro Mono: WOFF (Web Open Font Format) test + + + + + +
+ +
+ See: http://caniuse.com/#feat=woff +

If you do not see the font, you may be using a browser that disallows local font loading due to CORS (probably Firefox or IE).

+
+ +
+
+ +
+ “C64 Pro Mono/Style”
+    upper/graphics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+ +
+ “C64 Pro Mono/Style”
+    lower/upper + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+
+ + + + + diff --git a/patterns/C64_TrueType_v1.2.1-STYLE/test/test-woff2.html b/patterns/C64_TrueType_v1.2.1-STYLE/test/test-woff2.html new file mode 100644 index 0000000..f9bd457 --- /dev/null +++ b/patterns/C64_TrueType_v1.2.1-STYLE/test/test-woff2.html @@ -0,0 +1,170 @@ + + + + C64 Pro Mono: WOFF2 (Web Open Font Format 2.0) test + + + + + +
+ +
+ See: http://caniuse.com/#feat=woff2 +

If you do not see the font, you may be using a browser that disallows local font loading due to CORS (probably Firefox or IE).

+
+ +
+
+ +
+ “C64 Pro Mono/Style”
+    upper/graphics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+ +
+ “C64 Pro Mono/Style”
+    lower/upper + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +




+
+
+ + + + + diff --git a/patterns/bits-ascii-unicode.ipynb b/patterns/bits-ascii-unicode.ipynb new file mode 100644 index 0000000..988213c --- /dev/null +++ b/patterns/bits-ascii-unicode.ipynb @@ -0,0 +1,149 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# *bits*, *ASCII*, *Unicode*" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Encoding systems\n", + "\n", + "As a computer can only work with numbers, it cannot process of letters text directly. In order to work with text, textual characters need to be translated into numbers and vice versa. This is done via the process of text encodings.\n", + "\n", + "It might be your first reaction to think that this shouldnт€™t be so difficult. We could represent the letter in binary code. An a encoded as a 0, b as a 1 and c as a 01 etc. And in fact this is more or less how text encodings work. However, at the time when computing was being developed different encodings emerged.\n", + "\n", + "## ASCII encoding\n", + "\n", + "The dominant encoding at the time became ASCII (for American Standard Code for Information Interchange.), which was created on behalf of the U.S. Government in 1963 to allow for information interchange between their different computing systems.\n", + "\n", + "The encoding uses a 7-bit system, which means that they could only store characters in 128 (2^7=128) numbers (0000 0000 until 0111 1111). The resulting encoding schema assigned to each of these 128 numbers:\n", + "\n", + " all the letters in the English alphabet\n", + " numbers from 0-9\n", + " punctuation marks\n", + " and control characters\n", + "\n", + "Thanks to the simplicity of the encoding it quickly became a standard for the American computing industry.\n", + "\n", + "## ASCII imperialism\n", + "\n", + "Thanks to the power of the US Military and US corporations the American computing industry became the global computing industry. Computers that we use today are rooted in American networking history, and so is the ASCII standard. However, the reality is that ASCII can only represent 26 Latin letters in the English alphabet but computers are used all over the world, by people speaking different languages. They would often end up with American computers that could not represent their language in ASCII. Think for example of scripts like Greek, Cyrillic and Arabic or even Latin scripts that use accents such as the УМ or УИ. Altough 128 might sound like a lot of characters, it is not enough to represent all different languages." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## ASCII flavours: PETSCII\n", + "\n", + "### Commodore 64 (1982)\n", + "\n", + "![](https://upload.wikimedia.org/wikipedia/commons/thumb/e/e9/Commodore-64-Computer-FL.jpg/320px-Commodore-64-Computer-FL.jpg)\n", + "\n", + "> The Commodore 64, also known as the C64 or the CBM 64, is an 8-bit home computer introduced in January 1982 by Commodore International (first shown at the Consumer Electronics Show, January 7т€“10, 1982, in Las Vegas). It has been listed in the Guinness World Records as the highest-selling single computer model of all time, with independent estimates placing the number sold between 12.5 and 17 million units. \n", + "\n", + "> Preceded by the Commodore VIC-20 and Commodore PET, the C64 took its name from its 64 kilobytes (65,536 bytes) of RAM. With support for multicolor sprites and a custom chip for waveform generation, the C64 could create superior visuals and audio compared to systems without such custom hardware. \n", + "\n", + "https://en.wikipedia.org/wiki/Commodore_64\n", + "\n", + "> Part of the Commodore 64's success was its sale in regular retail stores instead of only electronics or computer hobbyist specialty stores. Commodore produced many of its parts in-house to control costs, including custom integrated circuit chips from MOS Technology. In the United States, it has been compared to the Ford Model T automobile for its role in bringing a new technology to middle-class households via creative and affordable mass-production.\n", + "\n", + "Kahney, Leander (September 9, 2003). \"Grandiose Price for a Modest PC\". CondУЉNet, Inc. Archived from the original on September 14, 2008. Retrieved September 13, 2008.\n", + "\n", + "![](https://upload.wikimedia.org/wikipedia/commons/4/48/C64_startup_animiert.gif)\n", + "\n", + "### PETSCII \n", + "\n", + "![](https://www.pagetable.com/docs/c64ref_charset/colorscheme.gif)\n", + "\n", + "> The Commodore PET's lack of a programmable bitmap-mode for computer graphics, as well as it having no redefinable character set capability, may be one of the reasons PETSCII was developed; by creatively using the well-thought-out block graphics, a higher degree of sophistication in screen graphics is attainable than by using plain ASCII's letter/digit/punctuation characters. In addition to the relatively diverse set of geometrical shapes that can thus be produced, PETSCII allows for several grayscale levels by its provision of differently hatched checkerboard squares/half-squares. Finally, the reverse-video mode (see below) is used to complete the range of graphics characters, in that it provides mirrored half-square blocks. \n", + "\n", + "https://en.wikipedia.org/wiki/PETSCII\n", + "\n", + "Draw PETSCII art in the browser:\n", + "\n", + "* https://petscii.krissz.hu/\n", + "* https://www.masswerk.at/pet/\n", + "\n", + "Use PETSCII as a font!\n", + "\n", + "* https://style64.org/c64-truetype\n", + "\n", + "PETSCII bots!\n", + "\n", + "* https://twitter.com/PETSCIIBOTS" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Unicode universalism\n", + "\n", + "т€™As electronic text was increasingly being exchanged online and between language areas, issues emerged when text encoded in one language was shared and read on systems assuming an encoding in another language. Unicode was a response to the incompatible text encoding standards that were proliferating.\n", + "\n", + "When different encodings assign the same binary numbers to different characters, this results in illegible documents. The solution, partly made possible by increased computing capacity, was to strive for a single universal encoding which would encompass all writing systemsт€™ 6\n", + "\n", + "You can experience this following this exercise.\n", + "\n", + "So in order to overcome the limitations of ASCII people created the Unicode Consortium to create a single universal character encoding:\n", + "\n", + "т€˜The Unicode standards are designed to normalise the encoding of characters, to efficiently manage the way they are stored, referred to and displayed in order to facilitate cross-platform, multilingual and international text exchange. The Unicode Standard is mammoth in\n", + "size and covers well over 110,000 characters, of which [..] 1,000 are [..] emoji.т€™ 7\n", + "\n", + "In effect the Unicode Standard combined all the different national character encodings together into a single large ledger in order to try to represent all languages.\n", + "\n", + "It is divided in so called blocks, which are basically number tables that describe which number is connected to which character.\n", + "\n", + "The table starts counting at 0x0 and continues all the way up to 0x10FFFF.\n", + "\n", + "The first block actually corresponds with ASCII:\n", + "\n", + "https://en.wikibooks.org/wiki/Unicode/Character_reference/0000-0FFF\n", + "\n", + "It contains many different scripts for supporting large and smaller language groups, including for example Ethiopian and Cherokee:\n", + "\n", + "https://en.wikibooks.org/wiki/Unicode/Character_reference/1000-1FFF\n", + "\n", + "However there are also blocks that describe Arrows and other symbols:\n", + "\n", + "https://en.wikibooks.org/wiki/Unicode/Character_reference/2000-2FFF\n", + "\n", + "Emoji are also part of the unicode table." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/patterns/generating-maps.ipynb b/patterns/generating-maps.ipynb new file mode 100644 index 0000000..fbbe405 --- /dev/null +++ b/patterns/generating-maps.ipynb @@ -0,0 +1,652 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Generating maps" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Stepping away from random.choice(): writing an algorithm to create ASCII tile maps" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In order to generate patterns in a non-random way, we might want to move around through our canvas in a **non-linear way**, to make the patterns a bit more complex.\n", + "\n", + "### moving through the canvas\n", + "\n", + "Each character on our \"canvas\" has a specific position and thus is connected to a `x` and `y` coordinate.\n", + "\n", + "How can we do that?\n", + "\n", + "We will use a `list-of-lists`... or in other words: \n", + "\n", + "we make **one big list**, that contains a # of **rows** (**the `y` axis, or *height* of the canvas**), with a # of **characters** (**the `x` axis, or *width* of the canvas**). \n", + "\n", + "To make this `list-of-lists`, we will use a `loop-in-a-loop`:" + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]\n" + ] + } + ], + "source": [ + "width = 10\n", + "height = 10\n", + "\n", + "canvas = []\n", + "\n", + "for y in range(height):\n", + " \n", + " row = []\n", + "\n", + " for x in range(width):\n", + " row.append(x)\n", + " \n", + " canvas.append(row)\n", + " \n", + "print(canvas)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's print the canvas row for row, to make it easier to see it as a x-y canvas:" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n", + "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n", + "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n", + "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n", + "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n", + "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n", + "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n", + "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n", + "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n", + "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n" + ] + } + ], + "source": [ + "for row in canvas:\n", + " print(row)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "And let's bring it back into an plain text pattern: turn this `list-of-lists` into a `multiline string`:" + ] + }, + { + "cell_type": "code", + "execution_count": 74, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0123456789\n", + "0123456789\n", + "0123456789\n", + "0123456789\n", + "0123456789\n", + "0123456789\n", + "0123456789\n", + "0123456789\n", + "0123456789\n", + "0123456789\n", + "\n" + ] + } + ], + "source": [ + "# canvas is our list-of-lists\n", + "# canvas_string is the plain text version that we want to create\n", + "\n", + "canvas_string = ''\n", + "\n", + "for row in canvas:\n", + " row_string = ''\n", + " for character in row:\n", + " row_string += str(character)\n", + " canvas_string += row_string + \"\\n\"\n", + "\n", + "print(canvas_string)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's save this as a function that we can reuse later!" + ] + }, + { + "cell_type": "code", + "execution_count": 75, + "metadata": {}, + "outputs": [], + "source": [ + "def plain(canvas):\n", + " canvas_string = ''\n", + " for row in canvas:\n", + " row_string = \"\".join(row)\n", + " canvas_string += row_string + \"\\n\"\n", + "\n", + " return canvas_string" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now, we can work with the `x` and `y` axes of the canvas, by *slicing* the `canvas`:" + ] + }, + { + "cell_type": "code", + "execution_count": 76, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 76, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "canvas[0][0]" + ] + }, + { + "cell_type": "code", + "execution_count": 77, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "9" + ] + }, + "execution_count": 77, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "canvas[1][9]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### My first algorithm" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now let's write a short algorithm, to generate a map.\n", + "\n", + "We will start by writing the **rules** of our algorithm.\n", + "\n", + "Let's first think of these rules without writing them in code. \n", + "\n", + "How would you like to generate a pattern?\n", + "\n", + "For example: \n", + "\n", + "**Characters**\n", + "\n", + "* `.` is used as background\n", + "* `т–‘` as light shade\n", + "* `т–’` as darker shade\n", + "\n", + "**Rules** \n", + "\n", + "* `т–‘` always appears in horizontal УЁnd vertical blocks of 3\n", + "\n", + "```\n", + ".....\n", + "..т–‘..\n", + ".т–‘т–‘т–‘.\n", + "..т–‘..\n", + ".....\n", + "```\n", + "\n", + "* `т–’` surrounds the blobs of light shade on the left side of each light shadow \n", + "\n", + "```\n", + ".....\n", + ".т–’т–‘..\n", + "т–’т–‘т–‘т–‘.\n", + ".т–’т–‘..\n", + ".....\n", + "```\n", + "\n", + "Let's try this!" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First we create a new canvas and fill it with `.`'s." + ] + }, + { + "cell_type": "code", + "execution_count": 78, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "....................................................................................................\n", + "\n" + ] + } + ], + "source": [ + "width = 100\n", + "height = 25\n", + "\n", + "canvas = []\n", + "for y in range(height):\n", + " row = []\n", + " for x in range(width):\n", + " row.append('.')\n", + " canvas.append(row)\n", + "\n", + "print(plain(canvas))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now let's add the light shade..." + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "т–‘.т–‘.................т–‘..........т–‘............................т–‘.........т–‘т–‘т–‘.........т–‘.................\n", + "т–‘т–‘т–‘т–‘...............т–‘т–‘т–‘........т–‘т–‘т–‘..........................т–‘т–‘т–‘..т–‘......т–‘.......т–‘.т–‘т–‘т–‘................\n", + "т–‘.т–‘.......т–‘.........т–‘..........т–‘...........т–‘................т–‘..т–‘т–‘т–‘............т–‘т–‘т–‘.т–‘.................\n", + ".........т–‘т–‘т–‘........т–‘.....................т–‘т–‘т–‘..т–‘................т–‘..............т–‘.............т–‘......\n", + "..........т–‘........т–‘т–‘т–‘.....................т–‘..т–‘т–‘т–‘.............................т–‘.............т–‘т–‘т–‘.....\n", + "...................т–‘т–‘т–‘....т–‘....................т–‘.............................т–‘т–‘т–‘.............т–‘......\n", + "............т–‘.......т–‘....т–‘т–‘т–‘.................т–‘..т–‘..............т–‘...т–‘.........т–‘т–‘т–‘....................\n", + "...т–‘.......т–‘т–‘т–‘............т–‘.....т–‘...........т–‘т–‘т–‘т–‘т–‘т–‘............т–‘т–‘т–‘.т–‘т–‘т–‘.........т–‘.........т–‘...........\n", + "..т–‘т–‘т–‘...т–‘.т–‘.т–‘.......т–‘..........т–‘т–‘т–‘...........т–‘..т–‘....т–‘....т–‘....т–‘...т–‘....т–‘..............т–‘т–‘т–‘..........\n", + "...т–‘...т–‘т–‘т–‘т–‘т–‘.......т–‘т–‘т–‘..........т–‘...................т–‘т–‘т–‘..т–‘т–‘т–‘...........т–‘т–‘т–‘..............т–‘...........\n", + "........т–‘т–‘т–‘т–‘........т–‘т–‘т–‘.......т–‘.....................т–‘т–‘т–‘...т–‘.............т–‘............т–‘.т–‘т–‘т–‘..........\n", + ".......т–‘т–‘т–‘т–‘т–‘.........т–‘.......т–‘т–‘т–‘....т–‘................т–‘..т–‘...........................т–‘т–‘т–‘.т–‘...........\n", + "........т–‘.т–‘т–‘.................т–‘т–‘т–‘...т–‘т–‘т–‘..т–‘...т–‘..........т–‘т–‘т–‘........т–‘................т–‘т–‘т–‘..........т–‘...\n", + ".....т–‘....т–‘т–‘т–‘.............т–‘...т–‘.....т–‘..т–‘т–‘т–‘.т–‘т–‘т–‘..........т–‘......т–‘.т–‘т–‘т–‘................т–‘..........т–‘т–‘т–‘..\n", + "....т–‘т–‘т–‘....т–‘.............т–‘т–‘т–‘............т–‘.т–‘.т–‘............т–‘....т–‘т–‘т–‘.т–‘......т–‘.т–‘....................т–‘...\n", + "....т–‘т–‘......т–‘.............т–‘...т–‘.....т–‘....т–‘т–‘т–‘............т–‘т–‘т–‘....т–‘т–‘.......т–‘т–‘т–‘т–‘т–‘.......................\n", + "...т–‘т–‘т–‘.....т–‘т–‘т–‘.........т–‘..т–‘..т–‘т–‘т–‘...т–‘т–‘т–‘....т–‘..............т–‘.....т–‘т–‘т–‘.......т–‘.т–‘........................\n", + "....т–‘.......т–‘.........т–‘т–‘т–‘т–‘т–‘т–‘..т–‘.....т–‘....................т–‘......т–‘........т–‘..........................\n", + ".......................т–‘..т–‘..т–‘..........................т–‘т–‘т–‘т–‘.т–‘..........т–‘т–‘т–‘.................т–‘.......\n", + "............................т–‘т–‘т–‘т–‘.........................т–‘т–‘т–‘т–‘т–‘т–‘..........т–‘.................т–‘т–‘т–‘.....т–‘\n", + "....................т–‘........т–‘т–‘т–‘т–‘..........................т–‘.т–‘..............................т–‘.....т–‘т–‘\n", + ".....т–‘......т–‘......т–‘т–‘т–‘.........т–‘..................................................................т–‘т–‘\n", + "..т–‘.т–‘т–‘т–‘....т–‘т–‘т–‘т–‘.....т–‘...........................................т–‘...............................т–‘..т–‘\n", + ".т–‘т–‘т–‘.т–‘.....т–‘т–‘т–‘т–‘т–‘...................т–‘...........................т–‘т–‘т–‘.............................т–‘т–‘т–‘..\n", + "..т–‘т–‘т–‘.......т–‘т–‘т–‘т–‘..................т–‘т–‘т–‘...........................т–‘...............................т–‘...\n", + "\n" + ] + } + ], + "source": [ + "from random import randrange\n", + "\n", + "light_shade = 'т–‘'\n", + "\n", + "for y in range(height):\n", + " for x in range(width):\n", + " \n", + " # To work with a degree of chance, \n", + " # we \"roll the dice\" and only add a т–‘\n", + " # when the number is lower then 5\n", + " random_number = randrange(0, 100, 1)\n", + " if random_number < 3: \n", + " \n", + " # If so, then we add a т–‘\n", + " canvas[y][x] = light_shade\n", + " \n", + " # Check is there is a character on the left, right, \n", + " # top and bottom AT ALL, before adding them...\n", + " if x - 1 >= 0:\n", + " canvas[y][x - 1] = light_shade\n", + " if x + 1 < width:\n", + " canvas[y][x + 1] = light_shade\n", + " if y - 1 >= 0:\n", + " canvas[y - 1][x] = light_shade\n", + " if y + 1 < height:\n", + " canvas[y + 1][x] = light_shade\n", + " \n", + " else:\n", + " continue\n", + " \n", + "print(plain(canvas))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now let's add the darker shade..." + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "т–‘т–’т–‘................т–’т–‘.........т–’т–‘...........................т–’т–‘........т–’т–‘т–‘т–‘........т–’т–‘.................\n", + "т–‘т–‘т–‘т–‘..............т–’т–‘т–‘т–‘.......т–’т–‘т–‘т–‘.........................т–’т–‘т–‘т–‘.т–’т–‘.....т–’т–‘......т–’т–‘т–’т–‘т–‘т–‘................\n", + "т–‘т–’т–‘......т–’т–‘........т–’т–‘.........т–’т–‘..........т–’т–‘...............т–’т–‘.т–’т–‘т–‘т–‘...........т–’т–‘т–‘т–‘т–’т–‘.................\n", + "........т–’т–‘т–‘т–‘.......т–’т–‘....................т–’т–‘т–‘т–‘.т–’т–‘...............т–’т–‘.............т–’т–‘............т–’т–‘......\n", + ".........т–’т–‘.......т–’т–‘т–‘т–‘....................т–’т–‘.т–’т–‘т–‘т–‘............................т–’т–‘............т–’т–‘т–‘т–‘.....\n", + "..................т–’т–‘т–‘т–‘...т–’т–‘...................т–’т–‘............................т–’т–‘т–‘т–‘............т–’т–‘......\n", + "...........т–’т–‘......т–’т–‘...т–’т–‘т–‘т–‘................т–’т–‘.т–’т–‘.............т–’т–‘..т–’т–‘........т–’т–‘т–‘т–‘....................\n", + "..т–’т–‘......т–’т–‘т–‘т–‘...........т–’т–‘....т–’т–‘..........т–’т–‘т–‘т–‘т–‘т–‘т–‘...........т–’т–‘т–‘т–‘т–’т–‘т–‘т–‘........т–’т–‘........т–’т–‘...........\n", + ".т–’т–‘т–‘т–‘..т–’т–‘т–’т–‘т–’т–‘......т–’т–‘.........т–’т–‘т–‘т–‘..........т–’т–‘.т–’т–‘...т–’т–‘...т–’т–‘...т–’т–‘..т–’т–‘...т–’т–‘.............т–’т–‘т–‘т–‘..........\n", + "..т–’т–‘..т–’т–‘т–‘т–‘т–‘т–‘......т–’т–‘т–‘т–‘.........т–’т–‘..................т–’т–‘т–‘т–‘.т–’т–‘т–‘т–‘..........т–’т–‘т–‘т–‘.............т–’т–‘...........\n", + ".......т–’т–‘т–‘т–‘т–‘.......т–’т–‘т–‘т–‘......т–’т–‘....................т–’т–‘т–‘т–‘..т–’т–‘............т–’т–‘...........т–’т–‘т–’т–‘т–‘т–‘..........\n", + "......т–’т–‘т–‘т–‘т–‘т–‘........т–’т–‘......т–’т–‘т–‘т–‘...т–’т–‘...............т–’т–‘.т–’т–‘..........................т–’т–‘т–‘т–‘т–’т–‘...........\n", + ".......т–’т–‘т–’т–‘т–‘................т–’т–‘т–‘т–‘..т–’т–‘т–‘т–‘.т–’т–‘..т–’т–‘.........т–’т–‘т–‘т–‘.......т–’т–‘...............т–’т–‘т–‘т–‘.........т–’т–‘...\n", + "....т–’т–‘...т–’т–‘т–‘т–‘............т–’т–‘..т–’т–‘....т–’т–‘.т–’т–‘т–‘т–‘т–’т–‘т–‘т–‘.........т–’т–‘.....т–’т–‘т–’т–‘т–‘т–‘...............т–’т–‘.........т–’т–‘т–‘т–‘..\n", + "...т–’т–‘т–‘т–‘...т–’т–‘............т–’т–‘т–‘т–‘...........т–’т–‘т–’т–‘т–’т–‘...........т–’т–‘...т–’т–‘т–‘т–‘т–’т–‘.....т–’т–‘т–’т–‘...................т–’т–‘...\n", + "...т–’т–‘т–‘.....т–’т–‘............т–’т–‘..т–’т–‘....т–’т–‘...т–’т–‘т–‘т–‘...........т–’т–‘т–‘т–‘...т–’т–‘т–‘......т–’т–‘т–‘т–‘т–‘т–‘.......................\n", + "..т–’т–‘т–‘т–‘....т–’т–‘т–‘т–‘........т–’т–‘.т–’т–‘.т–’т–‘т–‘т–‘..т–’т–‘т–‘т–‘...т–’т–‘.............т–’т–‘....т–’т–‘т–‘т–‘......т–’т–‘т–’т–‘........................\n", + "...т–’т–‘......т–’т–‘........т–’т–‘т–‘т–‘т–‘т–‘т–‘.т–’т–‘....т–’т–‘...................т–’т–‘.....т–’т–‘.......т–’т–‘..........................\n", + "......................т–’т–‘.т–’т–‘.т–’т–‘.........................т–’т–‘т–‘т–‘т–‘т–’т–‘.........т–’т–‘т–‘т–‘................т–’т–‘.......\n", + "...........................т–’т–‘т–‘т–‘т–‘........................т–’т–‘т–‘т–‘т–‘т–‘т–‘.........т–’т–‘................т–’т–‘т–‘т–‘....т–’т–‘\n", + "...................т–’т–‘.......т–’т–‘т–‘т–‘т–‘.........................т–’т–‘т–’т–‘.............................т–’т–‘....т–’т–‘т–‘\n", + "....т–’т–‘.....т–’т–‘.....т–’т–‘т–‘т–‘........т–’т–‘.................................................................т–’т–‘т–‘\n", + ".т–’т–‘т–’т–‘т–‘т–‘...т–’т–‘т–‘т–‘т–‘....т–’т–‘..........................................т–’т–‘..............................т–’т–‘.т–’т–‘\n", + "т–’т–‘т–‘т–‘т–’т–‘....т–’т–‘т–‘т–‘т–‘т–‘..................т–’т–‘..........................т–’т–‘т–‘т–‘............................т–’т–‘т–‘т–‘..\n", + ".т–’т–‘т–‘т–‘......т–’т–‘т–‘т–‘т–‘.................т–’т–‘т–‘т–‘..........................т–’т–‘..............................т–’т–‘...\n", + "\n" + ] + } + ], + "source": [ + "from random import randrange\n", + "\n", + "light_shade = 'т–‘'\n", + "darker_shade = 'т–’'\n", + "\n", + "for y in range(height):\n", + " for x in range(width):\n", + " \n", + " # First we check if the current character is a light shade\n", + " if canvas[y][x] == light_shade:\n", + " \n", + " # If that is the case, we need to look around, to see if we need to place a shade on the left, right, top or bottom\n", + " \n", + " # Check is there is a left character AT ALL\n", + " if x - 1 >= 0:\n", + " # If so, then we check if the left character is a '.'\n", + " if canvas[y][x - 1] == '.':\n", + " # If so, then we replace it with a dark shade\n", + " canvas[y][x - 1] = 'т–’'\n", + " \n", + " else:\n", + " continue\n", + " \n", + "print(plain(canvas))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Make your own tiles! " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Instead of ASCII characters, you could also replace each character with your own tiny png tiles!\n", + "\n", + "If we turn the generated ASCII into HTML, we can replace the ` ` (space) and `.` characters into images.\n", + "\n", + "Let's start with two small tiles. The example below is based on two world tiles from this tileset: https://opengameart.org/content/pixel-world-hex-tileset\n", + "\n", + "![](tile1.png) `tile1.png`\n", + "\n", + "and\n", + "\n", + "![](tile2.png) `tile2.png`" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "metadata": { + "scrolled": true, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "
\n" + ] + } + ], + "source": [ + "from random import choice\n", + "\n", + "tiles = ['tile1.png', 'tile2.png']\n", + "width = 50\n", + "height = 25\n", + "\n", + "html = ''\n", + "\n", + "css = '''\n", + "'''\n", + "\n", + "html += css\n", + "\n", + "for y in range(height):\n", + " html += '
'\n", + " for x in range(width):\n", + " tile = choice(tiles)\n", + " tile_html = f''\n", + " html += tile_html\n", + " html += '
'\n", + "\n", + "print(html)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We can use a feature of the Notebooks to preview this HTML here:" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "
" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "from IPython.core.display import display, HTML\n", + "\n", + "display(HTML(html))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Or save it to a file:" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "metadata": {}, + "outputs": [], + "source": [ + "with open('map.html', 'w+') as out:\n", + " out.write(html)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/patterns/generating-mini-games.ipynb b/patterns/generating-mini-games.ipynb new file mode 100644 index 0000000..00b4560 --- /dev/null +++ b/patterns/generating-mini-games.ipynb @@ -0,0 +1,158 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Generating mini-games with random.choice()" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + ". . . . .. . . .. \n", + " . . . . . . . . . . . \n", + " . . . .. .. . . .\n", + " . . . . . . . . \n", + " . . . . . . . . . . \n", + " . . . . . . . . . \n", + " . . . . . . .. \n", + " . . . .. . . . . .. . .. \n", + " . . . . . . . .. . \n", + ". . . . . . . . .. . \n", + ". . . .. . . \n", + " . . . . . . . .. . \n", + " . . . . . \n", + " . . . . . . . \n", + " . . . . . . . .\n", + ". . . .. . . . . . \n", + " .. . . . . \n", + " . . . . . . . . . . . \n", + " . . . . . . . .. \n", + " . . . . . \n", + " . . . . . . . . . . . . \n", + " . . . . . . . . . . . \n", + " . . . . . . . . . . \n", + " . . . . . . . . . \n", + " . . . . . . . . . \n" + ] + } + ], + "source": [ + "from random import choice\n", + "\n", + "characters = ['.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']\n", + "width = 100\n", + "height = 25\n", + "\n", + "for y in range(height):\n", + " for x in range(width):\n", + " print(choice(characters), end='')\n", + " print('')" + ] + }, + { + "cell_type": "code", + "execution_count": 130, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " a o it m i i m f c \n", + " c i ag n o amf f o i \n", + " o i o f i a g af i g\n", + " m i f a t g c f t i\n", + " n o f a f tnf o f \n", + " a i i i i i t in c caa \n", + " t fa n f i t a i o\n", + " o i ag ig g g a i i i n ag \n", + " n m gt a i o f i o ni i i \n", + " m i f i a a a o i m a g c \n", + " f am a c o i f cna f mi\n", + " t a i c f g f n i c o o g \n", + " o f t a g ng i a i a n n o a t oi i it\n", + " o t n o m f g a i a m ni \n", + " f i i g m o i a n t a i a a m i a i a\n", + "i a a ac i a t i tn t a \n", + " o f tf i an i n o f i t t \n", + " c g fg i o o ca i o o o m t \n", + " f o i i i c i ta i ca c f \n", + " c n aa g i m g m i c \n", + " c i c i f i n m f i i \n", + " a o i g m o ot a i a c f m i \n", + " i a a i f f a c g i\n", + " to in a t og im i o i f n c \n", + "ao m g ii c n a to t \n" + ] + } + ], + "source": [ + "from random import choice\n", + "\n", + "character_set = 'gamification '\n", + "characters = [character for character in character_set]\n", + "width = 100\n", + "height = 25\n", + "\n", + "for y in range(height):\n", + " for x in range(width):\n", + " print(choice(characters), end='')\n", + " print('')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# More games plz!" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Try to make some more mini-games yourself.\n", + "\n", + "You can restrict yourself to using **ASCII characters only** (see https://en.wikipedia.org/wiki/ASCII) and stay in touch with early computer graphics ASCII art...\n", + "\n", + "Or you can extend your pallete with **Unicode characters**. This is a nice website that highlights specific character sets: http://xahlee.info/comp/unicode_index.html" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/patterns/labyrinths.ipynb b/patterns/labyrinths.ipynb new file mode 100644 index 0000000..7c36d42 --- /dev/null +++ b/patterns/labyrinths.ipynb @@ -0,0 +1,46 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Labyrithns" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "https://en.wikipedia.org/wiki/Maze_generation_algorithm" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/patterns/tile1.png b/patterns/tile1.png new file mode 100644 index 0000000..7030b85 Binary files /dev/null and b/patterns/tile1.png differ diff --git a/patterns/tile2.png b/patterns/tile2.png new file mode 100644 index 0000000..c05c4f6 Binary files /dev/null and b/patterns/tile2.png differ diff --git a/web-to-print/img/browser-engines.png b/web-to-print/img/browser-engines.png new file mode 100644 index 0000000..018d37b Binary files /dev/null and b/web-to-print/img/browser-engines.png differ diff --git a/web-to-print/img/browser-support.png b/web-to-print/img/browser-support.png new file mode 100644 index 0000000..c7087a1 Binary files /dev/null and b/web-to-print/img/browser-support.png differ diff --git a/web-to-print/web-to-print.ipynb b/web-to-print/web-to-print.ipynb new file mode 100644 index 0000000..3bfea1c --- /dev/null +++ b/web-to-print/web-to-print.ipynb @@ -0,0 +1,93 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# web-to-print" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## HTML т†’ PDF \n", + "\n", + "HTML can be used as an environment to make PDFs. HTML5 pages are used to structure and mark up material, for example by adding headers, footnotes, images and adding bolds and italics to the text. In combination with CSS3 and the Paged Media CSS rules to create lay-outs and work on the styling of the documents. \n", + "\n", + "There is not one way to work with web-to-print technologies. There are different tools being developed that each come with their specific features, culture and context.\n", + "\n", + "* CTRL + p\n", + "* [Weasyprint](https://weasyprint.org/) ([Kozea](https://kozea.fr/)/[CourtBouillon](https://www.courtbouillon.org/), FR)\n", + "* [Paged.js](https://www.pagedjs.org/) ([Coko Foundation](https://coko.foundation/), NZ/*)\n", + "* wkhtmltoprint\n", + "* [html2print](http://osp.kitchen/tools/html2print/) ([OSP](osp.kitchen/), BE)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Standardization\n", + "\n", + "The W3C Foundation plays an important role in the devlopment of web-to-print techniques. This organisation works on the open standards of the web, which means that they define how the HTML5 and CSS3 standards look like and can push for standardizing certain functionalities. Once a W3C is accepted, it is very likely that different browsers will adapt such feature. \n", + "\n", + "One of the biggest struggles with web-to-print techniques is that not all browsers support the same CSS3 standards and that browsers use different PDF engines to render PDF documents. Safari is based on WebKit (developped by Apple), Firefox is based on Gecko (developed by Mozilla) and Chrome is based on Blink (developed by Google). Each of these browser engines render web pages УЁnd PDF document slightly differently, as they implement and render HTML5 and CSS3 rules in different ways.\n", + "\n", + "![](img/browser-engines.png)\n", + "\n", + "\n", + "\n", + "As an example, we can look at the support for the @page Paged Media CSS3 rules, that can be used to set the page size, orientation and margin of a PDF document. \n", + "\n", + "![](img/browser-support.png)\n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Story of OSP Kit\n", + "\n", + "OSP Kit, CSS regions, multiple textflow support\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Promiscuous publishing & limits" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}