├── .babelrc ├── .gitignore ├── README.md ├── assets └── logo.png ├── design-catalogue ├── designs-core │ ├── animations │ │ └── Rotation.js │ ├── designs │ │ ├── AbstractPoly.js │ │ ├── Checks.js │ │ ├── Circles.js │ │ ├── DoublyTriangle.js │ │ ├── Sottsass.js │ │ ├── Star.js │ │ ├── WavePatternLines.js │ │ └── createDesign.js │ ├── renderer │ │ └── flush.js │ ├── src │ │ └── index.js │ └── utils │ │ └── index.js ├── public │ └── index.html ├── src │ ├── components │ │ ├── ErrorBoundary.js │ │ ├── Footer.js │ │ ├── Heading.js │ │ ├── Home.js │ │ ├── Info.js │ │ ├── Placeholders.js │ │ ├── Player.js │ │ └── details │ │ │ ├── ChecksDetails.js │ │ │ ├── CirclesDetails.js │ │ │ ├── DetailContainer.js │ │ │ └── StarFractalDetails.js │ ├── index.js │ ├── primitives │ │ ├── BackButton.js │ │ ├── Button.js │ │ ├── Canvas.js │ │ ├── DownloadButton.js │ │ └── Slider.js │ └── utils │ │ ├── designs.js │ │ ├── downloadDesign.js │ │ ├── globalStyles.js │ │ ├── hoc.js │ │ └── lazyLoad.js └── vendor │ ├── react-art.development.js │ ├── react-art.production.min.js │ ├── react-dom-server.browser.development.js │ ├── react-dom-server.browser.production.min.js │ ├── react-dom-test-utils.development.js │ ├── react-dom-test-utils.production.min.js │ ├── react-dom-unstable-native-dependencies.development.js │ ├── react-dom-unstable-native-dependencies.production.min.js │ ├── react-dom.development.js │ ├── react-dom.production.min.js │ ├── react-is.development.js │ ├── react-is.production.min.js │ ├── react-scheduler.development.js │ ├── react-scheduler.production.min.js │ ├── react-test-renderer-shallow.development.js │ ├── react-test-renderer-shallow.production.min.js │ ├── react-test-renderer.development.js │ ├── react-test-renderer.production.min.js │ ├── react.development.js │ └── react.production.min.js ├── package.json └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env", "react"], 3 | "plugins": [ 4 | "transform-object-rest-spread", 5 | "transform-class-properties" 6 | ] 7 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .cache 2 | .vscode 3 | dist 4 | node_modules 5 | build -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Generative-design 2 | 3 | > A collection of interactive generative designs. 4 | 5 |

6 | 7 |

8 | 9 | This repository contains a collection of generative design React components with which you can play and change parameters to transform the design. 10 | 11 | > **This project will continue to evolve as I add more designs** 12 | 13 | ## Designs 14 | 15 | All the designs can be found at [https://generative-design.surge.sh](https://generative-design.surge.sh) 16 | -------------------------------------------------------------------------------- /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nitin42/generative-designs/8c7e80363c8386474be3a0df56d5b2ec25e0f190/assets/logo.png -------------------------------------------------------------------------------- /design-catalogue/designs-core/animations/Rotation.js: -------------------------------------------------------------------------------- 1 | export function startRotation(objects, props) { 2 | objects.forEach(object => { 3 | this.TwoJS.bind('update', frames => { 4 | // This is called every 2N frames 5 | if (this.TwoJS.playing) { 6 | if (frames % 2 === 0) { 7 | if (object.scale > 0.9999) { 8 | object.scale = object.rotation = 0 9 | } 10 | 11 | const t = (1 - object.scale) * props.scaleOffset 12 | 13 | object.scale += t 14 | object.rotation += t * props.rotationOffset * Math.PI 15 | } 16 | } 17 | }) 18 | }) 19 | } 20 | -------------------------------------------------------------------------------- /design-catalogue/designs-core/designs/AbstractPoly.js: -------------------------------------------------------------------------------- 1 | import { createDesign } from './createDesign' 2 | import { startRotation } from '../animations/Rotation' 3 | 4 | function drawOddHex(instance, len, y) { 5 | let count = 0 6 | const renderedHex = [] 7 | 8 | for (let x = len + 25; x <= instance.width - 40; x += 50) { 9 | if (count % 2 === 0) { 10 | const poly = instance.makePolygon(x, y, 10, 6) 11 | poly.fill = 'pink' 12 | poly.stroke = 'pink' 13 | 14 | renderedHex.push(poly) 15 | } else { 16 | const poly = instance.makePolygon(x, y, 10, 6) 17 | poly.fill = '#86cece' 18 | poly.stroke = '#86cece' 19 | renderedHex.push(poly) 20 | } 21 | count++ 22 | } 23 | 24 | return renderedHex 25 | } 26 | 27 | function drawEvenHex(instance, len, y) { 28 | let count = 0 29 | const renderedHex = [] 30 | 31 | for (let x = len + 25; x <= instance.width - 70; x += 50) { 32 | if (count % 2 === 0) { 33 | const poly = instance.makePolygon(x, y, 10, 6) 34 | poly.fill = '#ea8e6c' 35 | poly.stroke = '#ea8e6c' 36 | 37 | renderedHex.push(poly) 38 | } else { 39 | const poly = instance.makePolygon(x, y, 10, 6) 40 | poly.fill = '#b8d9d0' 41 | poly.stroke = '#b8d9d0' 42 | 43 | renderedHex.push(poly) 44 | } 45 | count++ 46 | } 47 | 48 | return renderedHex 49 | } 50 | 51 | function drawPolygon(instance, props) { 52 | let renderedHex = [] 53 | 54 | for (let x = 30; x <= instance.height; x += 40) { 55 | renderedHex.push(drawOddHex(instance, 20, x)) 56 | x += 40 57 | renderedHex.push(drawEvenHex(instance, 45, x)) 58 | } 59 | 60 | return renderedHex 61 | } 62 | 63 | function sketch() { 64 | const polys = drawPolygon(this.TwoJS, this.props) 65 | 66 | polys.forEach(poly => startRotation.call(this, poly, this.props)) 67 | } 68 | 69 | const AbstractPoly = createDesign(sketch) 70 | 71 | AbstractPoly.defaultProps = { 72 | callback: ctrl => {}, 73 | scaleOffset: 0.0245, 74 | rotationOffset: 4, 75 | width: 480, 76 | height: 430 77 | } 78 | 79 | export { AbstractPoly } 80 | -------------------------------------------------------------------------------- /design-catalogue/designs-core/designs/Checks.js: -------------------------------------------------------------------------------- 1 | import { createDesign } from './createDesign' 2 | import { startRotation } from '../animations/Rotation' 3 | 4 | function drawChecks(instance, props) { 5 | const renderedLines = [] 6 | 7 | for (let x = -15; x <= instance.width; x += props.horizontalGap) { 8 | for (let y = -15; y <= instance.height; y += props.verticalGap) { 9 | const line = instance.makeLine(x, y, x + 50, y) 10 | line.stroke = '#babcc0' 11 | 12 | renderedLines.push(line) 13 | } 14 | } 15 | 16 | for (let x = -15; x <= instance.width; x += props.horizontalGap) { 17 | for (let y = -15; y <= instance.height; y += props.verticalGap) { 18 | const line = instance.makeLine(x, y, x, y + 50) 19 | line.stroke = '#babcc0' 20 | 21 | renderedLines.push(line) 22 | } 23 | } 24 | 25 | return renderedLines 26 | } 27 | 28 | function sketch() { 29 | const checks = drawChecks(this.TwoJS, this.props) 30 | startRotation.call(this, checks, this.props) 31 | } 32 | 33 | const Checks = createDesign(sketch) 34 | 35 | Checks.defaultProps = { 36 | callback: inst => {}, 37 | scaleOffset: 0.1, 38 | rotationOffset: 1.5, 39 | width: 300, 40 | height: 300, 41 | verticalGap: 20, 42 | horizontalGap: 20 43 | } 44 | 45 | Checks.displayName = 'Checks' 46 | 47 | export { Checks } 48 | -------------------------------------------------------------------------------- /design-catalogue/designs-core/designs/Circles.js: -------------------------------------------------------------------------------- 1 | import { createDesign } from './createDesign' 2 | import { startRotation } from '../animations/Rotation' 3 | 4 | import { random } from '../utils/index' 5 | 6 | const colors = { 7 | CIRCLE_ONE: '#ff4444', 8 | CIRCLE_TWO: '#000000', 9 | CIRCLE_THREE: '#b8bdc1' 10 | } 11 | 12 | function drawCircle(offset, color, instance) { 13 | const circles = [] 14 | 15 | for (let x = 20; x <= instance.width; x += 15) { 16 | const circle = instance.makeCircle(offset, x, random(0, 10)) 17 | circle.fill = color 18 | circle.noStroke() 19 | 20 | circles.push(circle) 21 | } 22 | 23 | return circles 24 | } 25 | 26 | function drawPattern(instance, props) { 27 | let renderedCircles = [] 28 | 29 | for (let x = 10; x <= instance.width; x += props.positionOffsetOne) { 30 | renderedCircles.push(drawCircle(x, colors.CIRCLE_ONE, instance)) 31 | x += props.positionOffsetTwo 32 | 33 | renderedCircles.push(drawCircle(x, colors.CIRCLE_TWO, instance)) 34 | x += props.positionOffsetThree 35 | 36 | renderedCircles.push(drawCircle(x, colors.CIRCLE_THREE, instance)) 37 | } 38 | 39 | return renderedCircles 40 | } 41 | 42 | function sketch() { 43 | const circles = drawPattern(this.TwoJS, this.props) 44 | 45 | circles.forEach(objects => { 46 | startRotation.call(this, objects, this.props) 47 | }) 48 | } 49 | 50 | const Circles = createDesign(sketch) 51 | 52 | Circles.defaultProps = { 53 | callback: ctrl => {}, 54 | scaleOffset: 0.0245, 55 | rotationOffset: 4, 56 | width: 400, 57 | height: 300, 58 | positionOffsetOne: 20, 59 | positionOffsetTwo: 30, 60 | positionOffsetThree: 40 61 | } 62 | 63 | export { Circles } 64 | -------------------------------------------------------------------------------- /design-catalogue/designs-core/designs/DoublyTriangle.js: -------------------------------------------------------------------------------- 1 | import { createDesign } from './createDesign' 2 | import { startRotation } from '../animations/Rotation' 3 | import { random } from '../utils/index' 4 | 5 | function drawTriangle(instance, props) { 6 | const triangles = [] 7 | 8 | for (let x = 0; x <= 120; x += 10) { 9 | for (let y = 0; y <= 120; y += 10) { 10 | const triangle = instance.makePolygon(x, y, random(0, 1.2), 3) 11 | triangle.fill = 'mistyrose' 12 | triangle.noStroke() 13 | const group = instance.makeGroup(triangle) 14 | group.scale = 2.7 15 | 16 | triangles.push(triangle) 17 | } 18 | } 19 | 20 | return triangles 21 | } 22 | 23 | function drawLines(instance, props) { 24 | const renderedLines = [] 25 | 26 | for (let y = 0; y <= 120; y += 5) { 27 | for (let x = 0; x <= 120; x += 5) { 28 | if (x % 10 == 0) { 29 | const x1 = random(x, x + 1) 30 | const x2 = random(x, x + 3) 31 | const y2 = random(y, y - 4) 32 | 33 | const lineUp = instance.makeLine(x1, y, x2, y2) 34 | lineUp.stroke = props.strokeUp 35 | lineUp.linewidth = 0.3 36 | 37 | const group = instance.makeGroup(lineUp) 38 | group.scale = 2.9 39 | 40 | renderedLines.push(lineUp) 41 | 42 | const lineUp2 = instance.makeLine(x1 + 10, y + 10, x2 + 10, y2 + 10) 43 | lineUp2.stroke = props.strokeUp 44 | lineUp2.linewidth = 0.3 45 | 46 | const group2 = instance.makeGroup(lineUp2) 47 | group2.scale = 2.9 48 | 49 | renderedLines.push(lineUp2) 50 | } else { 51 | const y1 = random(y, y + 2) 52 | const x2 = random(x, x + 3) 53 | const y2 = random(y, y + 3) 54 | const lineDown = instance.makeLine(x, y1, x2, y2) 55 | lineDown.stroke = props.strokeDown 56 | lineDown.linewidth = 0.3 57 | 58 | const group = instance.makeGroup(lineDown) 59 | group.scale = 2.9 60 | 61 | renderedLines.push(lineDown) 62 | 63 | const lineDown2 = instance.makeLine(x + 10, y1 + 10, x2 + 10, y2 + 10) 64 | lineDown2.stroke = props.strokeDown 65 | lineDown2.linewidth = 0.3 66 | 67 | const group2 = instance.makeGroup(lineDown2) 68 | group2.scale = 2.9 69 | 70 | renderedLines.push(lineDown2) 71 | } 72 | } 73 | } 74 | 75 | return renderedLines 76 | } 77 | 78 | function sketch() { 79 | const triangles = drawTriangle(this.TwoJS, this.props) 80 | const lines = drawLines(this.TwoJS, this.props) 81 | 82 | startRotation.call(this, triangles, this.props) 83 | startRotation.call(this, lines, this.props) 84 | } 85 | 86 | const DoublyTriangle = createDesign(sketch) 87 | 88 | DoublyTriangle.displayName = 'DoublyTriangle' 89 | 90 | DoublyTriangle.defaultProps = { 91 | callback: ctrl => {}, 92 | scaleOffset: 0.05, 93 | rotationOffset: 2, 94 | strokeUp: '#ffc0cb', 95 | strokeDown: '#c6e2ff', 96 | width: 300, 97 | height: 300 98 | } 99 | 100 | export { DoublyTriangle } 101 | -------------------------------------------------------------------------------- /design-catalogue/designs-core/designs/Sottsass.js: -------------------------------------------------------------------------------- 1 | import { createDesign } from './createDesign' 2 | import { random } from '../utils/index' 3 | import { startRotation } from '../animations/Rotation' 4 | 5 | function drawLines(instance, props) { 6 | const renderedLines = [] 7 | 8 | for (let y = 0; y <= 200; y += 5) { 9 | for (let x = 0; x <= 200; x += 5) { 10 | if (x % 10 == 0) { 11 | const lineUp = instance.makeLine( 12 | random(x, x + 1), 13 | y, 14 | random(x, x + 3), 15 | random(y, y - 4) 16 | ) 17 | lineUp.stroke = props.strokeUp 18 | lineUp.linewidth = 0.3 19 | 20 | const group = instance.makeGroup(lineUp) 21 | group.scale = 3 22 | 23 | renderedLines.push(lineUp) 24 | } else { 25 | const lineDown = instance.makeLine( 26 | x, 27 | random(y, y + 2), 28 | random(x, x + 3), 29 | random(y, y + 3) 30 | ) 31 | lineDown.stroke = props.strokeDown 32 | lineDown.linewidth = 0.3 33 | 34 | const group = instance.makeGroup(lineDown) 35 | group.scale = 3 36 | 37 | renderedLines.push(lineDown) 38 | } 39 | } 40 | } 41 | 42 | return renderedLines 43 | } 44 | 45 | function drawCircles(instance, props) { 46 | const renderedCircles = [] 47 | 48 | for (let y = 0; y <= 100; y += 4) { 49 | for (let x = 0; x <= 100; x += 4) { 50 | const circle = instance.makeCircle(x, y, random(0, 1.1)) 51 | circle.noStroke() 52 | circle.fill = '#ffd700' 53 | circle.opacity = 0.3 54 | circle.linewidth = 0.5 55 | 56 | const group = instance.makeGroup(circle) 57 | group.scale = 3 58 | 59 | renderedCircles.push(circle) 60 | } 61 | } 62 | 63 | return renderedCircles 64 | } 65 | 66 | function sketch() { 67 | const circles = drawCircles(this.TwoJS, this.props) 68 | const lines = drawLines(this.TwoJS, this.props) 69 | 70 | // Rotate lines and circles 71 | startRotation.call(this, circles, this.props) 72 | startRotation.call(this, lines, this.props) 73 | } 74 | 75 | const SottsassPattern = createDesign(sketch) 76 | 77 | SottsassPattern.defaultProps = { 78 | callback: () => {}, 79 | strokeUp: '#ffc0cb', 80 | strokeDown: '#c6e2ff', 81 | scaleOffset: 0.02, 82 | rotationOffset: 4, 83 | width: 300, 84 | height: 300 85 | } 86 | 87 | SottsassPattern.displayName = 'Sottsass Pattern' 88 | 89 | export { SottsassPattern } 90 | -------------------------------------------------------------------------------- /design-catalogue/designs-core/designs/Star.js: -------------------------------------------------------------------------------- 1 | import { createDesign } from './createDesign' 2 | 3 | // This is required for generating different stars 4 | function createSubStars(instance, x, y, radius, sides, props) { 5 | const star = instance.makeStar(x, y, radius, radius - 30, sides) 6 | 7 | star.fill = props.fill 8 | star.stroke = props.stroke 9 | 10 | if (radius > 12) { 11 | createSubStars( 12 | instance, 13 | x + radius / props.innerRadiusOffset, 14 | y, 15 | radius / props.innerRadiusOffset, 16 | sides, 17 | props 18 | ) 19 | createSubStars( 20 | instance, 21 | x - radius / props.innerRadiusOffset, 22 | y, 23 | radius / props.innerRadiusOffset, 24 | sides, 25 | props 26 | ) 27 | createSubStars( 28 | instance, 29 | x, 30 | y + radius / props.innerRadiusOffset, 31 | radius / props.innerRadiusOffset, 32 | sides, 33 | props 34 | ) 35 | createSubStars( 36 | instance, 37 | x, 38 | y - radius / props.innerRadiusOffset, 39 | radius / props.innerRadiusOffset, 40 | sides, 41 | props 42 | ) 43 | } 44 | } 45 | 46 | function createStar(instance, x, y, props) { 47 | const { length: radius, sides, stroke, fill } = props 48 | 49 | const star = instance.makeStar(x, y, radius, radius - 30, sides) 50 | 51 | star.fill = fill 52 | star.stroke = stroke 53 | 54 | if (radius > 12) { 55 | createSubStars( 56 | instance, 57 | x + radius / props.outerRadiusOffset, 58 | y, 59 | radius / props.outerRadiusOffset, 60 | sides, 61 | props 62 | ) 63 | createSubStars( 64 | instance, 65 | x - radius / props.outerRadiusOffset, 66 | y, 67 | radius / props.outerRadiusOffset, 68 | sides, 69 | props 70 | ) 71 | createSubStars( 72 | instance, 73 | x, 74 | y + radius / props.outerRadiusOffset, 75 | radius / props.outerRadiusOffset, 76 | sides, 77 | props 78 | ) 79 | createSubStars( 80 | instance, 81 | x, 82 | y - radius / props.outerRadiusOffset, 83 | radius / props.outerRadiusOffset, 84 | sides, 85 | props 86 | ) 87 | } 88 | } 89 | 90 | function drawStarFractal(instance, props) { 91 | createStar(instance, instance.width / 2, instance.height / 2, props) 92 | } 93 | 94 | function sketch() { 95 | drawStarFractal(this.TwoJS, this.props) 96 | } 97 | 98 | const StarFractal = createDesign(sketch) 99 | 100 | StarFractal.displayName = 'StarFractal' 101 | 102 | StarFractal.defaultProps = { 103 | // Length of the fractal 104 | length: 120, 105 | height: 400, 106 | width: 400, 107 | // Number of sides of star 108 | sides: 8, 109 | stroke: 'mistyrose', 110 | fill: 'pink', 111 | outerRadiusOffset: 2, 112 | innerRadiusOffset: 2, 113 | callback: instance => {} 114 | } 115 | 116 | export { StarFractal } 117 | -------------------------------------------------------------------------------- /design-catalogue/designs-core/designs/WavePatternLines.js: -------------------------------------------------------------------------------- 1 | import { startRotation } from '../animations/Rotation' 2 | import { createDesign } from './createDesign' 3 | 4 | // Draw wave line pattern 5 | function drawWavyLines(instance, props) { 6 | const renderedLines = [] 7 | 8 | for (let y = 20; y <= 90; y += 5) { 9 | for (let x = 20; x <= 80; x += 5) { 10 | if (x % 10 == 0) { 11 | const lineUp = instance.makeLine(x, y, x + 3, y - 3) 12 | lineUp.stroke = props.strokeUp 13 | lineUp.linewidth = 0.7 14 | 15 | const group = instance.makeGroup(lineUp) 16 | group.scale = props.scale 17 | 18 | renderedLines.push(lineUp) 19 | } else { 20 | const lineDown = instance.makeLine(x, y, x + 3, y + 3) 21 | lineDown.stroke = props.strokeDown 22 | lineDown.linewidth = 0.7 23 | 24 | const group = instance.makeGroup(lineDown) 25 | group.scale = props.scale 26 | 27 | renderedLines.push(lineDown) 28 | } 29 | } 30 | } 31 | 32 | return renderedLines 33 | } 34 | 35 | function sketch() { 36 | const renderedLines = drawWavyLines(this.TwoJS, this.props) 37 | startRotation.call(this, renderedLines, this.props) 38 | } 39 | 40 | const WavyLines = createDesign(sketch) 41 | 42 | WavyLines.defaultProps = { 43 | width: 260, 44 | height: 250, 45 | strokeUp: '#FFEBE1', 46 | strokeDown: 'pink', 47 | scaleOffset: 0.08, 48 | rotationOffset: 4, 49 | scale: 2.5, 50 | callback: instance => {} 51 | } 52 | 53 | WavyLines.displayName = 'WavyLines' 54 | 55 | export { WavyLines } 56 | -------------------------------------------------------------------------------- /design-catalogue/designs-core/designs/createDesign.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Two from 'two.js' 3 | import { css } from 'emotion' 4 | 5 | import { flush } from '../renderer/flush' 6 | 7 | // Takes a sketch function, and renders Two.js graphics 8 | export function createDesign(sketch) { 9 | return class extends React.Component { 10 | // Two.js instance 11 | TwoJS = null 12 | 13 | componentDidMount() { 14 | // Get the main container element 15 | const container = document.getElementById(this.props.id) 16 | 17 | // Two.js params 18 | const params = { width: this.props.width, height: this.props.height } 19 | 20 | // Append Two.js base to our container 21 | this.TwoJS = new Two(params).appendTo(container) 22 | 23 | // Do some extra work with the Two.js instance (play/pause the animations, create custom curves etc) 24 | this.props.callback(this.TwoJS) 25 | 26 | // Render the graphics 27 | flush.call(this, { shouldDequeue: false }, sketch) 28 | } 29 | 30 | componentDidUpdate() { 31 | // Clear the previously rendered Two.js objects, and start rendering from scratch (otherwise we end up with an array of old objects along with the new objects) 32 | flush.call(this, { shouldDequeue: true }, sketch) 33 | } 34 | 35 | render() { 36 | return ( 37 |
51 | ) 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /design-catalogue/designs-core/renderer/flush.js: -------------------------------------------------------------------------------- 1 | // Flush Two.js graphics 2 | // It takes a flag to determine whether to clear the current batch and restart, and a callback to perform work. 3 | export function flush({ shouldDequeue }, work) { 4 | // Clear the current batch of lines and restart from scratch 5 | if (shouldDequeue) { 6 | this.TwoJS && this.TwoJS.clear() 7 | } 8 | 9 | work.call(this) 10 | 11 | this.TwoJS.update() 12 | } 13 | -------------------------------------------------------------------------------- /design-catalogue/designs-core/src/index.js: -------------------------------------------------------------------------------- 1 | import { StarFractal } from '../designs/Star' 2 | import { WavyLines } from '../designs/WavePatternLines' 3 | import { Circles } from '../designs/Circles' 4 | import { SottsassPattern } from '../designs/Sottsass' 5 | import { DoublyTriangle } from '../designs/DoublyTriangle' 6 | import { Checks } from '../designs/Checks' 7 | import { AbstractPoly } from '../designs/AbstractPoly' 8 | import { createDesign } from '../designs/createDesign' 9 | 10 | import { startRotation } from '../animations/Rotation' 11 | 12 | // Generative designs 13 | export { 14 | StarFractal, 15 | WavyLines, 16 | Circles, 17 | SottsassPattern, 18 | DoublyTriangle, 19 | Checks, 20 | AbstractPoly, 21 | createDesign, 22 | startRotation 23 | } 24 | -------------------------------------------------------------------------------- /design-catalogue/designs-core/utils/index.js: -------------------------------------------------------------------------------- 1 | export const random = (max, min) => 2 | Math.floor(Math.random() * (max - min) + min) 3 | -------------------------------------------------------------------------------- /design-catalogue/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Generative Design 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /design-catalogue/src/components/ErrorBoundary.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export class ErrorBoundary extends React.Component { 4 | state = { hasError: false } 5 | 6 | componentDidCatch(error, info) { 7 | console.clear() 8 | this.setState({ hasError: true }) 9 | } 10 | 11 | render() { 12 | if (this.state.hasError) { 13 | return {this.props.fallbackUI} 14 | } 15 | return this.props.children 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /design-catalogue/src/components/Footer.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import styled from 'react-emotion' 3 | 4 | const StyledFooter = styled('footer')` 5 | display: flex; 6 | justify-content: center; 7 | font-size: 20px; 8 | ` 9 | 10 | const StyledLink = styled('a')` 11 | text-decoration: none; 12 | color: #4f4f4f; 13 | font-weight: bold; 14 | ` 15 | 16 | export const Footer = props => ( 17 | 18 |

19 | Made with ❤️ by{' '} 20 | 21 | Nitin Tulswani 22 | 23 |

24 |
25 | ) 26 | -------------------------------------------------------------------------------- /design-catalogue/src/components/Heading.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import styled, { css } from 'react-emotion' 3 | 4 | const Title = styled('h1')` 5 | font-size: 4em; 6 | display: inline-block; 7 | 8 | @media screen and (max-device-width: 480px) { 9 | font-size: 2.4em; 10 | } 11 | ` 12 | 13 | export const Heading = props => ( 14 |
15 | Generative Design 16 |
17 | ) 18 | -------------------------------------------------------------------------------- /design-catalogue/src/components/Home.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import styled, { css } from 'react-emotion' 3 | 4 | import { Heading } from './Heading' 5 | import { Footer } from './Footer' 6 | import { Player } from './Player' 7 | import { Info as InfoModal } from './Info' 8 | 9 | import { 10 | ChecksDesign, 11 | StarFractal, 12 | PolygonDesign, 13 | WavyLines, 14 | Circles, 15 | DoublyTriangle, 16 | SottsassPattern 17 | } from '../utils/lazyLoad' 18 | 19 | const Catalogue = styled('div')` 20 | display: grid; 21 | grid-template-columns: repeat(auto-fill, 300px); 22 | justify-content: center; 23 | grid-gap: 40px; 24 | margin-left: 20px; 25 | 26 | @media screen and (max-device-width: 480px) { 27 | grid-template-columns: 300px; 28 | grid-gap: 20px; 29 | margin-left: 5px; 30 | } 31 | ` 32 | 33 | const Info = props => ( 34 |
50 |

Hello 👋

51 |

52 | You will find a collection of generative designs on the home page. 53 | Interact with a design by clicking on the play icon. 54 |

55 |

Parameterization

56 |

57 | To be able to create a bridge between transformation and visualization, 58 | you can click on some of the designs to open the details page. On the 59 | details page, you will find a list of controls to change the parameters of 60 | the design. Optionally, you can also save the transformed design. 61 |

62 |

63 | The source code for all the designs is available on{' '} 64 | 72 | GitHub 73 | 74 | . 75 |

76 |

Have fun!

77 |
78 | ) 79 | 80 | export const Home = props => ( 81 | 82 | 83 | 84 | 85 | 86 | 87 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 |