Git Product home page Git Product logo

creative-coding-growth's Introduction

Creative Coding: Growth

This is the code for a creative coding hack session based on the theme of "Growth", as in a time lapse of a plant growing. We'll meet in person, or remotely if you can't make it and see what we each can come up with in a defined period of time. This code is using the 2d canvas. If you're just beginning with this type of coding you can read up on it a bit:

Getting started

  1. Fork this repo and create new branch.
  2. Copy john-doe and replace with your name, or multiple copies e.g. jane-doe-1, jane-doe-2
  3. Create and modify the code only in your user directory.
  4. Once we're done I'll merge everything into master and share out the results.

Navigate the code:

I kept things simple without any preprocessors. Include your js files through <script> tags. Everything is done in a very OOP style. In the john-doe file I separated out each object into its own file. Some included code you should be aware of is the Vector2 class from Three.js, which is an object of the following structure with some convenience methods on it to make it easier to work with:

>> var v = new THREE.Vector2(1,5);
{
	x:1,
	y:5
}

>> v.length();
5.0990195135927845

I have some color utilities in common/colors.js and some random number generators in common/random.js.

new Scene()

This is the basic scene graph with some utilities to start up the loop. Manually start your objects in the constructor and add them to the update loop. This object is created automatically at the bottom of the script on document ready. Most likely you won't add much code here, just the commands to start and update your objects.

Useful Public properties:
  • scene.ratio - the device pixel ratio, for retina displays
  • scene.$canvas - a jQuery wrapped canvas
  • scene.canvas - the canvas element
  • scene.context - the context for the canvas, what you do all the drawing with
  • scene.currentTime - the current time in unix epoch time in milliseconds
  • scene.showStats - a switch to show or hide the stats
  • scene.width - the width if the canvas in pixels (will be double the screen width on retina)
  • scene.height - the height if the canvas in pixels (will be double the screen height on retina)
  • scene.left - the left offset of the canvas (0 in this setup)
  • scene.top - the left top of the canvas (0 in this setup)

GrowthManager()

A simple manager for loading up multiple Growth objects. Every object created gets a reference to the scene.

Growth()

A simple growth entity.

Properties:
  • growth.scene - A reference to the main scene
  • growth.color - The color as a style designation, e.g. "hsl(133,50%,50%)"
  • growth.base - The base vector
  • growth.lines - An array of vectors making up the growth line

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.