├── .eleventy.js ├── .gitignore ├── CNAME ├── README.md ├── favicon.ico ├── gulpfile.babel.js ├── package-lock.json ├── package.json └── src ├── img ├── 1.png ├── 10.png ├── 100.png ├── 101.png ├── 102.png ├── 103.png ├── 104.png ├── 105.png ├── 106.png ├── 107.png ├── 108.png ├── 109.png ├── 11.png ├── 110.png ├── 111.png ├── 112.png ├── 113.png ├── 114.png ├── 115.png ├── 116.png ├── 117.png ├── 118.png ├── 119.png ├── 12.png ├── 120.png ├── 121.png ├── 122.png ├── 123.png ├── 124.png ├── 125.png ├── 126.png ├── 127.png ├── 128.png ├── 129.png ├── 13.png ├── 130.png ├── 131.png ├── 132.png ├── 133.png ├── 134.png ├── 135.png ├── 136.png ├── 137.png ├── 138.png ├── 139.png ├── 14.png ├── 140.png ├── 141.png ├── 142.png ├── 143.png ├── 144.png ├── 145.png ├── 146.png ├── 147.png ├── 148.png ├── 149.png ├── 15.png ├── 150.png ├── 151.png ├── 152.png ├── 153.png ├── 154.png ├── 16.png ├── 17.png ├── 18.png ├── 19.png ├── 2.png ├── 20.png ├── 21.png ├── 22.png ├── 23.png ├── 24.png ├── 25.png ├── 26.png ├── 27.png ├── 28.png ├── 29.png ├── 3.png ├── 30.png ├── 31.png ├── 32.png ├── 33.png ├── 34.png ├── 35.png ├── 36.png ├── 37.png ├── 38.png ├── 39.png ├── 4.png ├── 40.png ├── 41.png ├── 42.png ├── 43.png ├── 44.png ├── 45.png ├── 46.png ├── 47.png ├── 48.png ├── 49.png ├── 5.png ├── 50.png ├── 51.png ├── 52.png ├── 53.png ├── 54.png ├── 55.png ├── 56.png ├── 57.png ├── 58.png ├── 59.png ├── 6.png ├── 60.png ├── 61.png ├── 62.png ├── 63.png ├── 64.png ├── 65.png ├── 66.png ├── 67.png ├── 68.png ├── 69.png ├── 7.png ├── 70.png ├── 71.png ├── 72.png ├── 73.png ├── 74.png ├── 75.png ├── 76.png ├── 77.png ├── 78.png ├── 79.png ├── 8.png ├── 80.png ├── 81.png ├── 82.png ├── 83.png ├── 84.png ├── 85.png ├── 86.png ├── 87.png ├── 88.png ├── 89.png ├── 9.png ├── 90.png ├── 91.png ├── 92.png ├── 93.png ├── 94.png ├── 95.png ├── 96.png ├── 97.png ├── 98.png └── 99.png └── views ├── _includes └── base.njk └── index.md /.eleventy.js: -------------------------------------------------------------------------------- 1 | module.exports = function(eleventyConfig) { 2 | eleventyConfig.addPassthroughCopy('./favicon.ico'); 3 | eleventyConfig.addPassthroughCopy('./CNAME'); 4 | 5 | return { 6 | templateFormats: [ 7 | "md", 8 | "njk" 9 | ], 10 | passthroughFileCopy: true, 11 | dir: { 12 | input: 'src/views', 13 | output: 'dist' 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Dirs 2 | dist/ 3 | 4 | # Dependency directories 5 | node_modules/ 6 | 7 | # Logs 8 | *.log 9 | npm-debug.log* 10 | 11 | # dotenv environment variables file 12 | .env 13 | 14 | # mac shit 15 | .DS_Store 16 | 17 | # generated files 18 | .jekyll-metadata -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | generative-art-with-css.commons.host -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Generative Art with CSS. 2 | by [Yuan Chuan](https://yuanchuan.name/) (translated by Chen Hui Jing) 3 | 4 | *Given at the [5th CSSConf in China](https://css.w3ctech.com/)* 5 | *Original video: [CSS生成艺术@袁川_CSSConf CN 2019](https://youtu.be/mEpocRIc3q8)* 6 | *Talk recap: [「CSS生成艺术」演讲视频出炉](https://www.yuque.com/cssconf/5th/hyku3f)* 7 | -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/favicon.ico -------------------------------------------------------------------------------- /gulpfile.babel.js: -------------------------------------------------------------------------------- 1 | import { src, dest, watch as watchSrc, parallel, series } from 'gulp' 2 | import del from 'del' 3 | import plumber from 'gulp-plumber' 4 | import cp from 'child_process' 5 | 6 | import browserSync from 'browser-sync' 7 | 8 | // directories 9 | const SRC = 'src' 10 | const DIST = 'dist' 11 | 12 | // source file globs 13 | const IMAGES_GLOB = `${SRC}/img/**/*` 14 | const FAVICONS_GLOB = `${SRC}/favicons/**/*` 15 | const VIEWS_GLOB = `${SRC}/views/**/*` 16 | 17 | // clean the output directory 18 | export const clean = () => { 19 | return del([DIST]) 20 | } 21 | 22 | export const images = () => { 23 | return ( 24 | src(IMAGES_GLOB) 25 | // @TODO Minify 26 | .pipe(plumber()) 27 | .pipe(dest(`${DIST}/img`)) 28 | .pipe(browserSync.stream()) 29 | ) 30 | } 31 | 32 | export const generate = done => { 33 | return cp.spawn('eleventy').on('close', code => { 34 | if (code === 0) { 35 | browserSync.reload() 36 | done() 37 | } else { 38 | console.error(`build failed with code ${code}`) 39 | browserSync.notify('build failed 😞') 40 | done() 41 | } 42 | }) 43 | } 44 | 45 | export const watch = () => { 46 | browserSync.init({ server: DIST }) 47 | watchSrc(VIEWS_GLOB, generate) 48 | watchSrc(IMAGES_GLOB, images) 49 | } 50 | 51 | export const dev = series(clean, generate, images, watch) 52 | export const build = series(clean, generate, images) 53 | 54 | // set bare 'gulp' command to dev 55 | export default dev 56 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eleventy-bp", 3 | "version": "0.9.0", 4 | "description": "Starter project for site powered by Eleventy", 5 | "license": "MIT", 6 | "scripts": { 7 | "start": "gulp dev", 8 | "build": "gulp build" 9 | }, 10 | "dependencies": { 11 | "@11ty/eleventy": "^0.8.2", 12 | "@babel/core": "^7.4.3", 13 | "@babel/preset-env": "^7.4.3", 14 | "@babel/register": "^7.4.0", 15 | "autoprefixer": "^9.5.1", 16 | "browser-sync": "^2.26.3", 17 | "del": "^4.1.0", 18 | "gulp": "^4.0.0", 19 | "gulp-concat": "^2.6.1", 20 | "gulp-plumber": "^1.2.1", 21 | "gulp-postcss": "^8.0.0", 22 | "gulp-sass": "^4.0.2" 23 | }, 24 | "babel": { 25 | "presets": [ 26 | "@babel/preset-env" 27 | ] 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/img/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/1.png -------------------------------------------------------------------------------- /src/img/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/10.png -------------------------------------------------------------------------------- /src/img/100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/100.png -------------------------------------------------------------------------------- /src/img/101.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/101.png -------------------------------------------------------------------------------- /src/img/102.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/102.png -------------------------------------------------------------------------------- /src/img/103.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/103.png -------------------------------------------------------------------------------- /src/img/104.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/104.png -------------------------------------------------------------------------------- /src/img/105.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/105.png -------------------------------------------------------------------------------- /src/img/106.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/106.png -------------------------------------------------------------------------------- /src/img/107.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/107.png -------------------------------------------------------------------------------- /src/img/108.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/108.png -------------------------------------------------------------------------------- /src/img/109.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/109.png -------------------------------------------------------------------------------- /src/img/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/11.png -------------------------------------------------------------------------------- /src/img/110.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/110.png -------------------------------------------------------------------------------- /src/img/111.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/111.png -------------------------------------------------------------------------------- /src/img/112.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/112.png -------------------------------------------------------------------------------- /src/img/113.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/113.png -------------------------------------------------------------------------------- /src/img/114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/114.png -------------------------------------------------------------------------------- /src/img/115.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/115.png -------------------------------------------------------------------------------- /src/img/116.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/116.png -------------------------------------------------------------------------------- /src/img/117.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/117.png -------------------------------------------------------------------------------- /src/img/118.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/118.png -------------------------------------------------------------------------------- /src/img/119.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/119.png -------------------------------------------------------------------------------- /src/img/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/12.png -------------------------------------------------------------------------------- /src/img/120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/120.png -------------------------------------------------------------------------------- /src/img/121.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/121.png -------------------------------------------------------------------------------- /src/img/122.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/122.png -------------------------------------------------------------------------------- /src/img/123.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/123.png -------------------------------------------------------------------------------- /src/img/124.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/124.png -------------------------------------------------------------------------------- /src/img/125.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/125.png -------------------------------------------------------------------------------- /src/img/126.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/126.png -------------------------------------------------------------------------------- /src/img/127.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/127.png -------------------------------------------------------------------------------- /src/img/128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/128.png -------------------------------------------------------------------------------- /src/img/129.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/129.png -------------------------------------------------------------------------------- /src/img/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/13.png -------------------------------------------------------------------------------- /src/img/130.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/130.png -------------------------------------------------------------------------------- /src/img/131.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/131.png -------------------------------------------------------------------------------- /src/img/132.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/132.png -------------------------------------------------------------------------------- /src/img/133.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/133.png -------------------------------------------------------------------------------- /src/img/134.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/134.png -------------------------------------------------------------------------------- /src/img/135.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/135.png -------------------------------------------------------------------------------- /src/img/136.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/136.png -------------------------------------------------------------------------------- /src/img/137.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/137.png -------------------------------------------------------------------------------- /src/img/138.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/138.png -------------------------------------------------------------------------------- /src/img/139.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/139.png -------------------------------------------------------------------------------- /src/img/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/14.png -------------------------------------------------------------------------------- /src/img/140.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/140.png -------------------------------------------------------------------------------- /src/img/141.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/141.png -------------------------------------------------------------------------------- /src/img/142.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/142.png -------------------------------------------------------------------------------- /src/img/143.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/143.png -------------------------------------------------------------------------------- /src/img/144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/144.png -------------------------------------------------------------------------------- /src/img/145.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/145.png -------------------------------------------------------------------------------- /src/img/146.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/146.png -------------------------------------------------------------------------------- /src/img/147.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/147.png -------------------------------------------------------------------------------- /src/img/148.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/148.png -------------------------------------------------------------------------------- /src/img/149.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/149.png -------------------------------------------------------------------------------- /src/img/15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/15.png -------------------------------------------------------------------------------- /src/img/150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/150.png -------------------------------------------------------------------------------- /src/img/151.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/151.png -------------------------------------------------------------------------------- /src/img/152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/152.png -------------------------------------------------------------------------------- /src/img/153.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/153.png -------------------------------------------------------------------------------- /src/img/154.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/154.png -------------------------------------------------------------------------------- /src/img/16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/16.png -------------------------------------------------------------------------------- /src/img/17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/17.png -------------------------------------------------------------------------------- /src/img/18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/18.png -------------------------------------------------------------------------------- /src/img/19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/19.png -------------------------------------------------------------------------------- /src/img/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/2.png -------------------------------------------------------------------------------- /src/img/20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/20.png -------------------------------------------------------------------------------- /src/img/21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/21.png -------------------------------------------------------------------------------- /src/img/22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/22.png -------------------------------------------------------------------------------- /src/img/23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/23.png -------------------------------------------------------------------------------- /src/img/24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/24.png -------------------------------------------------------------------------------- /src/img/25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/25.png -------------------------------------------------------------------------------- /src/img/26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/26.png -------------------------------------------------------------------------------- /src/img/27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/27.png -------------------------------------------------------------------------------- /src/img/28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/28.png -------------------------------------------------------------------------------- /src/img/29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/29.png -------------------------------------------------------------------------------- /src/img/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/3.png -------------------------------------------------------------------------------- /src/img/30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/30.png -------------------------------------------------------------------------------- /src/img/31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/31.png -------------------------------------------------------------------------------- /src/img/32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/32.png -------------------------------------------------------------------------------- /src/img/33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/33.png -------------------------------------------------------------------------------- /src/img/34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/34.png -------------------------------------------------------------------------------- /src/img/35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/35.png -------------------------------------------------------------------------------- /src/img/36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/36.png -------------------------------------------------------------------------------- /src/img/37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/37.png -------------------------------------------------------------------------------- /src/img/38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/38.png -------------------------------------------------------------------------------- /src/img/39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/39.png -------------------------------------------------------------------------------- /src/img/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/4.png -------------------------------------------------------------------------------- /src/img/40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/40.png -------------------------------------------------------------------------------- /src/img/41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/41.png -------------------------------------------------------------------------------- /src/img/42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/42.png -------------------------------------------------------------------------------- /src/img/43.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/43.png -------------------------------------------------------------------------------- /src/img/44.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/44.png -------------------------------------------------------------------------------- /src/img/45.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/45.png -------------------------------------------------------------------------------- /src/img/46.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/46.png -------------------------------------------------------------------------------- /src/img/47.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/47.png -------------------------------------------------------------------------------- /src/img/48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/48.png -------------------------------------------------------------------------------- /src/img/49.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/49.png -------------------------------------------------------------------------------- /src/img/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/5.png -------------------------------------------------------------------------------- /src/img/50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/50.png -------------------------------------------------------------------------------- /src/img/51.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/51.png -------------------------------------------------------------------------------- /src/img/52.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/52.png -------------------------------------------------------------------------------- /src/img/53.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/53.png -------------------------------------------------------------------------------- /src/img/54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/54.png -------------------------------------------------------------------------------- /src/img/55.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/55.png -------------------------------------------------------------------------------- /src/img/56.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/56.png -------------------------------------------------------------------------------- /src/img/57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/57.png -------------------------------------------------------------------------------- /src/img/58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/58.png -------------------------------------------------------------------------------- /src/img/59.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/59.png -------------------------------------------------------------------------------- /src/img/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/6.png -------------------------------------------------------------------------------- /src/img/60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/60.png -------------------------------------------------------------------------------- /src/img/61.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/61.png -------------------------------------------------------------------------------- /src/img/62.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/62.png -------------------------------------------------------------------------------- /src/img/63.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/63.png -------------------------------------------------------------------------------- /src/img/64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/64.png -------------------------------------------------------------------------------- /src/img/65.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/65.png -------------------------------------------------------------------------------- /src/img/66.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/66.png -------------------------------------------------------------------------------- /src/img/67.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/67.png -------------------------------------------------------------------------------- /src/img/68.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/68.png -------------------------------------------------------------------------------- /src/img/69.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/69.png -------------------------------------------------------------------------------- /src/img/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/7.png -------------------------------------------------------------------------------- /src/img/70.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/70.png -------------------------------------------------------------------------------- /src/img/71.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/71.png -------------------------------------------------------------------------------- /src/img/72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/72.png -------------------------------------------------------------------------------- /src/img/73.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/73.png -------------------------------------------------------------------------------- /src/img/74.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/74.png -------------------------------------------------------------------------------- /src/img/75.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/75.png -------------------------------------------------------------------------------- /src/img/76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/76.png -------------------------------------------------------------------------------- /src/img/77.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/77.png -------------------------------------------------------------------------------- /src/img/78.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/78.png -------------------------------------------------------------------------------- /src/img/79.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/79.png -------------------------------------------------------------------------------- /src/img/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/8.png -------------------------------------------------------------------------------- /src/img/80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/80.png -------------------------------------------------------------------------------- /src/img/81.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/81.png -------------------------------------------------------------------------------- /src/img/82.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/82.png -------------------------------------------------------------------------------- /src/img/83.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/83.png -------------------------------------------------------------------------------- /src/img/84.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/84.png -------------------------------------------------------------------------------- /src/img/85.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/85.png -------------------------------------------------------------------------------- /src/img/86.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/86.png -------------------------------------------------------------------------------- /src/img/87.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/87.png -------------------------------------------------------------------------------- /src/img/88.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/88.png -------------------------------------------------------------------------------- /src/img/89.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/89.png -------------------------------------------------------------------------------- /src/img/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/9.png -------------------------------------------------------------------------------- /src/img/90.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/90.png -------------------------------------------------------------------------------- /src/img/91.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/91.png -------------------------------------------------------------------------------- /src/img/92.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/92.png -------------------------------------------------------------------------------- /src/img/93.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/93.png -------------------------------------------------------------------------------- /src/img/94.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/94.png -------------------------------------------------------------------------------- /src/img/95.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/95.png -------------------------------------------------------------------------------- /src/img/96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/96.png -------------------------------------------------------------------------------- /src/img/97.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/97.png -------------------------------------------------------------------------------- /src/img/98.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/98.png -------------------------------------------------------------------------------- /src/img/99.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huijing/xlat-generative-art-with-css/21e2020f7829037849551993e35411192f26a627/src/img/99.png -------------------------------------------------------------------------------- /src/views/_includes/base.njk: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Generative art with CSS 9 | 10 | 11 | 12 | 33 | 34 | 35 | 36 |

Generative Art with CSS
by Yuan Chuan (translated by Chen Hui Jing)

37 |

Given at the 5th CSSConf in China
Original video: CSS生成艺术@袁川_CSSConf CN 2019
Talk recap: 「CSS生成艺术」演讲视频出炉

38 | {{ content | safe }} 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/views/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: base.njk 3 | --- 4 | ![](img/1.png) 5 | 6 | Hello everyone, I’m very happy to be here. This is the first time I’m giving a talk, and might also be the last time I’m speaking at CSSConf in China, so this can be considered a rare opportunity. I’ve written a lot of CSS demos over the past year, I mostly do this during weekends or whenever I can spare some free time. 7 | 8 | Before long, it became a habit, I’d start to just code up a few things every evening. If, as luck would have it, I was able to discover something new, then I’d be fairly happy the rest of the night. Today I’d like to share with everyone some of the things I’ve learned along this journey, but be warned, I think most of it isn’t all that practical. 9 | 10 | ![](img/2.png) 11 | 12 | I’m a frontend developer, and I’m mostly active on Twitter and CodePen. I also put up some small projects on Github. So these are links to find me online. 13 | 14 | Even though I’m a frontend developer, I usually enjoy browsing design-related or more artistic creations and I like to focus more on the details. There is a lot to be learned from this process of observation, from how these creations express a concept or idea, to how each brush stroke reflects the unique characteristics of the tools that created them. 15 | 16 | ![](img/3.png) 17 | 18 | This is a traditional Chinese painting, and bamboo is a common theme in traditional Chinese painting. Bamboo leaves are extremely challeging to get right, and there are numerous ways you can paint them. Based on the angle which you observe them, they all have different shapes. 19 | 20 | Typically, bamboo leaves can be drawn with a single stroke of the brush, while applying varying amounts of pressure at different points of the leaf to obain that blade-shape. It takes a lot of skill to grasp the nuance required for such control. 21 | 22 | This is the amazing part of Chinese brush painting. It hinges on the shape and softness of the brush. Painting bamboo leaves with another stiffer implement would not give you this same effect. 23 | 24 | ![](img/4.png) 25 | 26 | Another interesting type of art I’ve come across is sand painting. Sand painting relies on the texture of the sand itself and their interplay with light and shadow. It’s not an easy task to draw a straight line with sand. It is a different form of expression. 27 | 28 | ![](img/5.png) 29 | 30 | There are numerous techniques we have now in CSS that stemmed from dealing the issues of cross-browser support, or attempts to achieve certain complex designs. Even though it was a pain to deal with such issues, it’s pretty exciting if you manage to find a solution. 31 | 32 | CSS may be less flexible than Canvas or SVG, and may also be less perfomant at times, but that’s because CSS was not meant for drawing. However, many people do use CSS to create art, myself included, purely for the fun of it. 33 | 34 | In order to use CSS to create art, it is neccessary to understand the limits of CSS and what it is capable of. More importantly, you must accept its limits and weaknesses. 35 | 36 | ![](img/6.png) 37 | 38 | Let’s first take a look at lines, as it is a basic element for drawing. There are numerous ways we can draw a line using CSS. But there is actually no concept of a line in CSS, we are merely creating the illusion of a line with other elements or properties. 39 | 40 | ![](img/7.png) 41 | 42 | You can set a height and width on an element, then give it a background colour, to make it look like a line. 43 | 44 | ![](img/8.png) 45 | 46 | Another way is to use any single side of the border property. 47 | 48 | ![](img/9.png) 49 | 50 | You could also make use of the `lineargradient()` property. 51 | 52 | ![](img/10.png) 53 | 54 | One thing I want to mention is the possibility of using `text-decoration` on a pseudo-element. You don’t need textual content, just some underscores to control the length of the line, and the thickness can be controlled by font size. 55 | 56 | ![](img/11.png) 57 | 58 | An advantage of this technique is that you can easily draw dashed lines by setting `text-decoration-style` to `dashed`. 59 | 60 | ![](img/12.png) 61 | 62 | Speaking of dashed lines, an interesting technique to consider is with `text-emphasis`, because we are free to determine what characters to use for it, for example, dots or dashes. You can then use `letter-spacing` to control gap size. 63 | 64 | ![](img/13.png) 65 | 66 | Using `linear-gradient()` is also an option because you can make use of the `background-repeat` property. 67 | 68 | ![](img/14.png) 69 | 70 | But it’s really most straight-forward to use borders. 71 | 72 | ![](img/15.png) 73 | 74 | It has a dashed property built-in, and is the most versatile of all the techniques I’ve covered 75 | 76 | ![](img/16.png) 77 | 78 | Lines with rounded corners can be done with `border-radius`. 79 | 80 | ![](img/17.png) 81 | 82 | But an issue is that Chrome does not render them well at small pixel sizes, just something to take note of. 83 | 84 | ![](img/18.png) 85 | 86 | If you don’t mind the trouble, you could also use multiple gradients to achieve the same effect. 87 | 88 | ![](img/19.png) 89 | 90 | Moving on to another basic element, which is circles. The web is all boxes, so again, there is no true concept of a circle in CSS. 91 | 92 | ![](img/20.png) 93 | 94 | Drawing a circle requires an element with equal width and height, plus a `border-radius` of `50%`. 95 | 96 | ![](img/21.png) 97 | 98 | By setting different values of each of the 4 corners, you can make this blob-like shape. 99 | 100 | ![](img/22.png) 101 | 102 | Circles can also be drawn with `radial-gradient()`, but it’s limitation is that the edges of your circle won’t be that smooth. 103 | 104 | ![](img/23.png) 105 | 106 | You could also use a dot, and adjust its size using the `font-size` property. 107 | 108 | ![](img/24.png) 109 | 110 | I think `clip-path` is the best bet, because it does have a built-in `circle()` function. Though if you use `clip-path`, then you won’t be able to use `box-shadow` or any borders. 111 | 112 | ![](img/25.png) 113 | 114 | `clip-path` makes it easy to draw semi-circles or ellipses. 115 | And this is what I like most about CSS, that we can use a myriad of techniques to achieve the same effect. 116 | 117 | ![](img/26.png) 118 | 119 | 120 | Triangles. 121 | 122 | ![](img/27.png) 123 | 124 | The earliest CSS-only triangles were drawn on elements with no height and width and manipulating their border values to achieve different triangular shapes. I reckon the people who came up with this technique were really smart. I first came across this from a blog post by Yahoo quite early on. 125 | 126 | ![](img/28.png) 127 | 128 | Right-angled triangles can be created fairly simply by manipulating the `linear-gradient()` property. 129 | 130 | ![](img/29.png) 131 | 132 | But `clip-path` is the most straight-forward implementation of all, because what are triangles but 3 points on a plane? You just need to plot those 3 points to create the triangle of your choice. 133 | 134 | ![](img/30.png) 135 | 136 | Unicode also provides a large number of shapes, which we can utilise via pseudo-elements in CSS. 137 | 138 | ![](img/31.png) 139 | 140 | For polygons, things are not quite as simple. These mostly would require the use of `clip-path`. 141 | 142 | ![](img/32.png) 143 | 144 | Let’s take a deeper look at what’s going on here. If we think of a typical cartesian plane, which is made up of an infinite number of discrete x, y coordinate pairs, that’s what the `polygon()` function in clip-path is making use of to create different shapes. Here, we can make use of some trigonometric functions to help us figure things out. 145 | 146 | ![](img/33.png) 147 | 148 | At this point, we will need to utilise Javascript, and I think that’s totally fine. Using Javascript to help us generate the requisite values dynamically is a much better approach than manual calculation. 149 | 150 | ![](img/34.png) 151 | 152 | Here we have 3 points, and we are only considering regular polygons for this use case, and we are making use of these 3 points to divide the circumference into 3 parts. Then utilise the trigonometric functions of sine and cosine to calculate the requisite coordinates and plug them back into the function. 153 | 154 | ![](img/35.png) 155 | 156 | This is how it looks with 3 points, 4 points, 5 points, 6 points and so on. These shapes are all generated with `clip-path`. 157 | 158 | ![](img/36.png) 159 | 160 | When the number of points gets sufficiently large, the polygon essentially becomes a circle. 161 | 162 | ![](img/37.png) 163 | 164 | We can also utilise such mathematical functions to draw different types of curves. 165 | 166 | ![](img/38.png) 167 | 168 | Lissajous curves were investigated during the 19th century, and is relatively well-known. 169 | 170 | ![](img/39.png) 171 | 172 | It is made up of a system of parametric equations and I discovered these curves work really well with `clip-path`. 173 | 174 | ![](img/40.png) 175 | 176 | The `polygon()` function can take in an optional `fill-rule` parameter. Its default value is `nonzero`, but we can change it to a value of `evenodd` and when applied to this star-shape, it will clip off the intersecting sections like so. 177 | 178 | ![](img/41.png) 179 | 180 | And we can make use of such behaviour to generate all kinds of different shapes. When I first realised this was possible, I was very intruigued by the results. Some of these shapes resemble undersea creatures to me, or even creatures from outer space. These are just a small sampling of what is possible with trigonometric functions. 181 | 182 | ![](img/42.png) 183 | 184 | Another technique we can use is by setting the `box-shadow` property to `inset`, together with `border-radius`. Here, we have a crescent-shaped moon. 185 | 186 | ![](img/43.png) 187 | 188 | But if I use elements of varying heights and widths, as well as different border-radius values and box-shadows, we end up with shapes that resemble brush strokes. It is possible to combine multiple brush stroke shapes to achieve your desired effect. 189 | 190 | Now, we’ve covered numerous techniques for creating different shapes with CSS. But how can we use these shapes? The simplest method is to just render them as tiles on a surface. 191 | 192 | ![](img/44.png) 193 | 194 | We can also use CSS grid to lay the shapes out. Grid is a 2-dimensional layout system. What we’re trying to achieve here is combine related shapes to form new ones. 195 | 196 | ![](img/45.png) 197 | 198 | CSS is inherently tied to the DOM, so we do need to match the number of elements to the size of the grid we want. 199 | 200 | ![](img/46.png) 201 | 202 | For example, if I wanted a 5x5 grid, I would need 25 elements, then lay them out with CSS grid. 203 | 204 | ![](img/47.png) 205 | 206 | I’m starting off with a simple rule here. Here I have 2 straight lines, rotated 45 deg in the clockwise and anti-clockwise directions. My rule is to randomly select one of those lines and put them in the grid. 207 | 208 | ![](img/48.png) 209 | 210 | Even though this is a simple rule, because adjacent lines could potentially be joined up, we end up with a maze effect. And this is a pattern that has been around for a long time. And we are using CSS to rotate the lines as well. 211 | 212 | ![](img/49.png) 213 | 214 | Another rule I have is for quarter circles. Again, I randomly choose one of these 4 quarter-circles and place them into the grid. Now when the adjacent shapes are combined, we are able to get a variety to interesting patterns. Here I’m using border-radius to draw these quarter-circles, but you can also use `clip-path` or `radial-gradient()` to draw these shapes as well. 215 | 216 | ![](img/50.png) 217 | 218 | Now the next question is, how can we dynamically generate such patterns. Because CSS does not possess the logic necessary to do something like that. I could utilise the concept of a dice, where if the result is 1, I use a particular set of values, if the result is 2, show a different set of values and so on. 219 | 220 | But we can also make use of Javascript, and I think it’s inevitable that Javascript is involved. 221 | 222 | ![](img/51.png) 223 | 224 | So I would like to talk a bit about css-doodle. This is a tool I wrote 2 years ago to solve this problem I had, in order to make use of some random functions and other useful things to generate these patterns. 225 | 226 | ![](img/52.png) 227 | 228 | If I were to use css-doodle to generate and draw these shapes, I can dynamically modify these values to create patterns of a different scale, this being an 8x8 grid now. 229 | 230 | CSS is very dependent on HTML, and this tool allows me to focus on just the CSS. The rules for this pattern are not too complicated, and this code generates some CSS. The `@rand()` function has a range of `500ms`, if I change the value to `5000ms`, the range will update accordingly from 1ms to 5000ms. 231 | 232 | `@pick()` will randomly pick a value from this matrix. This was inspired from the Logo programming language, not sure if any of you have played with it in the past, as it has a `pick` function as well. 233 | 234 | ![](img/53.png) 235 | 236 | Let’s take a look at another 5x5 grid. 237 | 238 | One of the more interesting grid properties is `grid-auto-flow`. One of the speakers mentioned this earlier, and what it can do is, if you have some grid items that are of different heights and widths, this property can arrange the grid items to fill up any empty spaces, where possible. Hence we get an effect like this. 239 | 240 | ![](img/54.png) 241 | 242 | At this point, we can add more elements to the grid, by adding a pseudo-element to every grid item. We can spruce up these pseudo-elements with different background colours, and give them a range of sizes from between 10% and 90%. 243 | 244 | ![](img/52.png) 245 | 246 | Oh, and I forgot to mention something earlier, let’s go back to this slide. This is stuff within the CSS grid, but I’m not sure if any of you have experience with GLSL (OpenGL Shading Language), or shaders in general. If you have, this might be more familiar to you. 247 | 248 | And these styles are mapped onto each grid cell, like how shaders are mapped to every pixel [❓18.32], it’s a similar concept, but the performance is probably not as good. 249 | 250 | ![](img/55.png) 251 | 252 | Back here, let’s say I have a pseudo-element like this one, I would apply these styles to each and every grid item to get an effect like the one we see here. This pattern here is just the right amount of complicated. And the effect is quite pretty, making use of the properties in CSS grid. 253 | 254 | ![](img/56.png) 255 | 256 | Now, let’s take a look at Properties. Grid is a very basic technique to generate patterns. You could randomly put stuff into a grid and discover all sorts of unique patterns. It’s a pretty convenient technique. 257 | 258 | ![](img/57.png) 259 | 260 | First up, `border-style`. 261 | 262 | ![](img/58.png) 263 | 264 | There are lots of values for `border-style`, these 4 being the most commonly used. 265 | 266 | ![](img/59.png) 267 | 268 | These border styles can be used for decorative purposes. 269 | 270 | ![](img/60.png) 271 | 272 | For example, rotating them with transforms. Basically what I’ve done here is rotate and scale up the patterns from the previous slide. 273 | 274 | ![](img/61.png) 275 | 276 | If you think this is too thick, you can modify the `border-width`. 277 | 278 | ![](img/62.png) 279 | 280 | Or change the `border-color` to red and purple, which is kind of ugly right now. 281 | 282 | ![](img/63.png) 283 | 284 | Because the colour is too bright, we can modify the `opacity` values, just do these randomly. 285 | 286 | ![](img/64.png) 287 | 288 | We can also randomly modify the values on the `@grid` function. Now we can also use the `gap` property and give the pattern a bit more breathing room. 289 | 290 | ![](img/65.png) 291 | 292 | There are still improvements to be made to this design. These lines are aligned too neatly, let’s give them a bit more variety with some transforms. 293 | 294 | ![](img/66.png) 295 | 296 | `@row()` will pass the value of each existing row to every grid cell, if we do something like this, we get a skewed effect. 297 | 298 | ![](img/67.png) 299 | 300 | 301 | This results in gaps between the lines so I can use a `@sin` function, increase the value here, to even things out, and this gives us a better result. 302 | 303 | ![](img/68.png) 304 | 305 | The effect we are seeing here is the result of some random values of `border-top` and `border-left`. This pattern here kind of resembles the window patterns found in ancient homes. 306 | 307 | ![](img/69.png) 308 | 309 | Let’s use the `dotted` value here. This keyboard of mine has issues and will repeat keystrokes sometimes. 310 | 311 | ![](img/70.png) 312 | 313 | This pattern uses `border-style: dotted`. We can increase the size value here, and we are actually putting the dots on a circular path. 314 | 315 | ![](img/71.png) 316 | 317 | Even though I’m only using 30 divs, it seems like I’m generating a lot more circles than that. 318 | 319 | ![](img/72.png) 320 | 321 | Now, let’s look at `border-image`. I find that this property is less used. I’ve only started playing around with it last year. Of course, I haven’t managed to dive really deep into it yet. 322 | 323 | ![](img/73.png) 324 | 325 | What I found interesting is that it generates symmetric patterns. 326 | 327 | ![](img/74.png) 328 | 329 | This is the code for the patterns in the previous slide. 330 | 331 | ![](img/75.png) 332 | 333 | Let’s change some values here. Increase the rotation to `10deg` makes the effect much thicker. 334 | 335 | ![](img/76.png) 336 | 337 | Just change the values around, it’s up to you, really. We end up with rather nice results. 338 | 339 | ![](img/77.png) 340 | 341 | Or we could also make use of the other possible values for `border-image`. Here I’ve combined a number of different values and as you can see, there is symmetry in all the resultant patterns. 342 | 343 | ![](img/78.png) 344 | 345 | And then, gradients. I really like gradients in CSS. Because CSS only allows us 2 pseudo-elements, there is no way to generate more. 346 | 347 | ![](img/79.png) 348 | 349 | 350 | But with gradients, because there is no limit to how many you can use, we can use them to generate more “elements” in the design. 351 | 352 | ![](img/80.png) 353 | 354 | This is a rather straightforward design. On this single div, we can generate 100 lines, using `linear-gradient()`. 355 | 356 | ![](img/81.png) 357 | 358 | Or maybe circles, with `radial-gradient()`. Even though I only have 1 div, I can generate unlimited gradients to make up for this short-coming. 359 | 360 | ![](img/82.png) 361 | 362 | Because we can draw many different shapes with gradients, we can apply them all to a single div, and end up with very interesting results. 363 | 364 | ![](img/83.png) 365 | 366 | Another pattern I like makes use of `mix-blend-mode`. Here I’m using 500 gradients per div. With 20 divs, that makes 10000 gradients. 367 | 368 | ![](img/84.png) 369 | 370 | This is how it originally looks. I merely zoomed in on the pattern. 371 | 372 | ![](img/85.png) 373 | 374 | By the end result of this code has a sci-fi feel to it. I’m not exactly sure of the consituent parts of this design, but just playing around with the different values in the various functions seems to generate very pleasant results. 375 | 376 | ![](img/86.png) 377 | 378 | Here we have a single gradient. Let’s add more gradients to the mix. And apply a `background-blend-mode` property. This is pretty useful when using multiple gradients. The gradients will blend together, but it’s quite tricky to control the colours. 379 | 380 | ![](img/87.png) 381 | 382 | If we further increase the number of gradients, this is the end result. But the colours are really hard to control. We’ll just have to experiment then. 383 | 384 | ![](img/88.png) 385 | 386 | This current design is red, but if we change the value to `11`, colour is very different. 387 | 388 | ![](img/89.png) 389 | 390 | We can also change the angle of the `linear-gradient`, give it a range of `-60deg` to `60deg`. It’s just the colour is hard to deal with. 391 | 392 | ![](img/90.png) 393 | 394 | Since colour is the problem, I will make use of the `hue-rotate` filter to make tweaks, as the colours are not very nice. 395 | 396 | ![](img/91.png) 397 | 398 | Without the filter, it’s a red, blue colour, but with the filter it looks slightly better. This effect is done with multiple conic gradients. 399 | 400 | ![](img/92.png) 401 | 402 | We can make more changes to the function values and end up with a completely different effect. I personally just like how it looks. There are a lot more effects we can achieve with gradients. 403 | 404 | ![](img/93.png) 405 | 406 | This pattern is made up of a combination of lines and dots generated via `linear-gradient()` and `radial-gradient()` respectively. 407 | 408 | ![](img/94.png) 409 | 410 | You could also achieve something like this. The lines here are made up of multiple linear gradients, and the shapes are created with `clip-path`. 411 | 412 | ![](img/95.png) 413 | 414 | Box shadow is one of my favourite properties. 415 | 416 | ![](img/96.png) 417 | 418 | Box shadow and gradients are similar in that there is no limit to the number of shapes you can generate with them. Some people make use of `box-shadow` to create pixel art. 419 | 420 | ![](img/97.png) 421 | 422 | So this is a relatively small creation, I think it looks rather pretty. 423 | 424 | ![](img/98.png) 425 | 426 | And there isn’t a lot of code involved. It’s the culmination of numerous box shadows, and we can try to add more of them. We can also modify the values in the `box-shadow` property to adjust the position of the shapes. 427 | 428 | ![](img/99.png) 429 | 430 | Another effect I’m quite fond of is done using `box-shadow` with `filter`. There isn’t much code involved here. I’m creating 100 box shadows on this element and applying a filter effect. 431 | 432 | ![](img/100.png) 433 | 434 | If we get rid of the filter, it looks like this. 435 | 436 | ![](img/101.png) 437 | 438 | As we change the values for contrast, the effect starts to morph and change accordingly. Using the value of `5` seems to create the most pleasant end result. 439 | 440 | ![](img/102.png) 441 | 442 | These patterns look like what you would see under a microscope. 443 | 444 | ![](img/103.png) 445 | 446 | `text-shadow` operates in a similar fashion. 447 | 448 | ![](img/104.png) 449 | 450 | It’s just that we would use this property for text. Because we are making use of text, then we also have the option of using Unicode symbols. 451 | 452 | ![](img/105.png) 453 | 454 | This is what happens if we use the character `x`. 455 | 456 | ![](img/106.png) 457 | 458 | We can apply different colours and sizes to `text-shadow` and sort of combine them together like so. 459 | 460 | ![](img/107.png) 461 | 462 | Now, this effect is made entirely with dots. The spread and distribution of the dots are all different, and when combined, we end up with such a design. 463 | 464 | ![](img/108.png) 465 | 466 | This feathery effect is made with parentheses. 467 | *Applause* 468 | Thank you, everyone. 469 | And you can also experiment with other symbols. 470 | 471 | ![](img/109.png) 472 | 473 | If you are not satisfied with the shape of parentheses, you can modify it with transforms. They originally look like this, but we can apply rotation and skew to end up with such a shape. 474 | 475 | ![](img/111.png) 476 | 477 | And that is how I made this particular design. 478 | *Applause* 479 | This sort of looks like some aquatic plants, I suppose. It’s made up of the previously created skewed parentheses and some dots. 480 | 481 | ![](img/112.png) 482 | 483 | We also have `text-decoration`. It does resemble the `border` property in that it too has dots and dashes. 484 | 485 | ![](img/113.png) 486 | 487 | But it also has something called `wavy`. 488 | 489 | ![](img/114.png) 490 | 491 | Finally we have something curvy to work with, so let’s see how we can make use of it. For now, all I need is to set the value to `wavy`, and we can adjust the length of the line by changing the value of `content`. 492 | 493 | ![](img/115.png) 494 | 495 | I’m actually hiding the actual text content, which is a straight line, and displaying the wavy text decoration. 496 | 497 | ![](img/116.png) 498 | 499 | Then, we can rotate multiple wavy lines at equal intervals, like so. 500 | 501 | ![](img/117.png) 502 | 503 | We can also add a `perspective` value, and you don’t see anything different yet. 504 | 505 | ![](img/118.png) 506 | 507 | But once we apply a rotation transformation, we will end up with something like this. Different values of `perspective` give us very different end results. 508 | 509 | ![](img/119.png) 510 | 511 | Now because it’s textual content, you can try other Unicode characters like `x` or `o` or any other characters for added effects. 512 | 513 | ![](img/120.png) 514 | 515 | Once we throw in some colour, we can get something like this. 516 | 517 | ![](img/121.png) 518 | 519 | And we can also animate the entire thing. 520 | *Applause* 521 | This animation involves animating the perspective value between 50px and [❓31.52] 522 | 523 | ![](img/122.png) 524 | 525 | Filters is the latest thing that I’m experimenting with. I use SVG filters quite a lot, because they work extremely well with CSS. Even though you may think this is not CSS, I think it doesn’t matter because I can create a lot of things with it. 526 | 527 | ![](img/123.png) 528 | 529 | This is the filter I use most often. It is fairly common, and involves adding noise as a texture. 530 | 531 | ![](img/124.png) 532 | 533 | Here is a conic gradient. Once we add in this filter, the gradient transforms. These parameter values are really fascinating, we only need to tweak them a little bit to get some spectacular effects. You can play around with them yourself as well. 534 | 535 | ![](img/125.png) 536 | 537 | We can also randomise the `seed` value and end up with a different effect every time. 538 | 539 | ![](img/126.png) 540 | 541 | This is an effect achieved by adding radial gradients to the previous mix. Looks rather pretty. 542 | 543 | ![](img/127.png) 544 | 545 | And by further tweaking the parameter values on the filter, we get something like this. I worked on this a while back, and I had never seen such an effect before, and I think it looks quite nice. It looks like the terrain of an alien planet. 546 | 547 | ![](img/128.png) 548 | 549 | SVG filters can be used to create clouds. 550 | 551 | ![](img/130.png) 552 | 553 | This is not complicated as it only involves the addition of a `box-shadow`. You can see how it looks like without the filter, but once the filter is applied, we get clouds. 554 | 555 | ![](img/132.png) 556 | 557 | This is also done with `box-shadow` and SVG filters, specifically inset box shadows. So it appears to expand inward instead. 558 | 559 | ![](img/133.png) 560 | 561 | Here, I’d like to mention animations as well. If we want to animate upwards of hundreds or thousands of elements, it’s going to be quite janky. A handful is fine, but thousands of elements won’t perform well. 562 | 563 | ![](img/134.png) 564 | 565 | This is a demo I made a while back. Even though it looks like there are a lot of dots, maybe a few thousand, in actuality, there are only 50 divs involved. The trick here is to apply gradients to the divs, since gradients are unlimited. Say we apply 100 gradients on each div, with 50 divs that works out to be 5000 dots. And this animation performs quite well. If we do animations and the CPU fan starts spinning up, that’s not really a good sign. 566 | 567 | ![](img/135.png) 568 | 569 | Let’s look at a different example. Even though it seems like there are many lines here, it’s actually just 15 divs. 570 | 571 | ![](img/136.png) 572 | 573 | Here’s how 1 div looks like. Increasing the number of divs gives us such an effect, and each div has 100 lines made with linear gradients. I also discovered that SVG filters work well with animations. 574 | 575 | ![](img/137.png) 576 | 577 | If I apply this filter to the previous animation, we end up with a wave-style animation. 578 | 579 | ![](img/138.png) 580 | 581 | Tweaking the `base-frequency` can give us many different effects as well. It’s really up to you. This parameter is quite fascinating. 582 | 583 | ![](img/139.png) 584 | 585 | There is another SVG filter that cannot be found in CSS, which is the Gaussian blur. CSS has a blur filter, but it is directionless. With SVG, we can determine if the filter is horizontal or vertical. 586 | 587 | ![](img/140.png) 588 | 589 | Changing the standard deviation value makes for some interesting effects as well. 590 | 591 | ![](img/141.png) 592 | 593 | And I also want to talk about CSS fractals. 594 | 595 | ![](img/142.png) 596 | 597 | Most designs nowadays use `rem` values, and use of `em` values seem to be less common. But I find that `em` values are interesting because if you have nested elements. The font-size of every element is calculated based on the font-size of it's parent element up the tree. Such nested recursion is a good characteristic we can make use of. 598 | 599 | ![](img/143.png) 600 | 601 | CSS is used to manipulate the DOM, which is a tree structure, and we can easily target individual nodes with CSS selectors. If our markup resembles that of a tree structure, the syntax of CSS selectors allows us to formulate a DSL (domain specific language) for styling. 602 | 603 | ![](img/144.png) 604 | 605 | This is a simple tree structure. Each element has 2 children nested within it. CSS makes it relatively simple to apply recursive styling without having to write a lot of code. 606 | 607 | ![](img/145.png) 608 | 609 | I've also added some new functionality to css-doodle. Let's add a third-dimension…I apologise, this is an experimental feature, the browser has stalled… 610 | 611 | ![](img/146.png) 612 | 613 | Alright, this is a type of recursive structure. I've added additional styling on each and every element, in this case, I've applied `box-shadow`. And the dots are made with `radial-gradient`. The end result is pretty good. But the performance isn't all that great. This was just an experiment. 614 | 615 | ![](img/147.png) 616 | 617 | The last thing I want to touch on is Houdini, because it presents us with numerous possibilities in the future. 618 | 619 | ![](img/148.png) 620 | 621 | Some of these things have already been mentioned previously so I will just skip over. 622 | 623 | ![](img/150.png) 624 | 625 | The unique thing about custom-defined properties is that you could put any values in there. Even Javascript. 626 | 627 | ![](img/151.png) 628 | 629 | Of course, we could go one step further, by creating our own *little language*. 630 | 631 | ![](img/152.png) 632 | 633 | Here I have an `--L-system`, and I've written the logic within the custom property. 634 | 635 | ![](img/153.png) 636 | 637 | Or I could also recreate the Logo programming language style syntax within the custom property. These values are the logic behind my styles. Houdini has been around for quite some time, and I hope everyone who is interested can explore what's possible, and make your own interesting creations. 638 | 639 | ![](img/154.png) 640 | 641 | After a lot of experimentation, you may come to the realisation that a lot of these CSS techniques can be translated to other domains, and conversely, techniques from outside of CSS can be applied to CSS as well. Which is why I would like to encourage everyone to broaden their horizons and experiment with all types of tools and techniques, like processing, for example. 642 | 643 | I feel that this is akin to music, where different musical instruments produce sounds of varying musicality, as well as different styles of playing. But what you really need to understand is the nature of music and how to use it to express yourself. That's an important lesson to learn. 644 | 645 | I really could go deeper into each topic I mentioned, but because there isn't enough time, I will be wrapping up here. I hope that this talk has inspired you in some way. 646 | Thank you very much. 647 | 648 | --- 649 | 650 | *I would like to thank Yuan Chuan for reviewing this translation, and for giving such an inspiring talk. 651 | I am not a professional translator, so my best effort here may be insufficient in expressing the full nuance of this talk. But hopefully, whatever you can glean from this will inspire you as much as it has me. 652 | If you are a native Chinese speaker and want to make edits to the translation, please [submit a pull request](https://github.com/huijing/xlat-generative-art-with-css). 653 | —Hui Jing* --------------------------------------------------------------------------------