Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <link href="https://fonts.googleapis.com/css?family=Bungee+Hairline" rel="stylesheet">


  <div id = "holder">

  <h1> Painting With L Systems </h1>
  <h2>Create your own brush strokes by setting the Chaos and Relativity dials. Press 'GENERATE' to see the L-system brush you created.  </h2>
 <canvas id="canvasGenerate" width = "400px" height="400px"></canvas>
    <div id = "controls"></div>
</div>

  <div class="row">

<h1> A Triptych of L Systems </h1>
<div id = "gridToo">
 <canvas id="canvas" width="200" height="500"></canvas>
    <canvas id="canvasTwo" width="200" height="500"></canvas>
      

 <canvas id="canvasThree" width="300" height="500"></canvas>
   <!-- <div id="textresult"></div> -->
 </div>




              
            
!

CSS

              
                @color1: rgba(1, 22, 39, 1);
@color2: rgba(247, 23, 53, 1);
@color3: rgba(65, 234, 212, 1);
@color4: rgba(253, 255, 252, 1);
@color5: rgba(255, 159, 28, 1);
@color6: #FEF5E9;
@colorCanvas: #FFFFF8;
@color7: #FEFE91;
// @bgColor: rgb(49, 59, 74, .9);
@bgColor: rgba(0, 1, 13, .9);



body{
	background-color: @bgColor;
	color: lighten(@color3, 30%);
	padding-left: 50px;
  font-size: 16px;
}

#holder{
  display: grid;
  width: 90vw;
  grid-template-columns: 70vw 30vw;
}

#gridToo{
  display: grid;
  width: 90vw;
  grid-template-columns: 30vw 30vw 30vw;
}
#canvasGenerate{
  border: 1px inset rgba(68, 68, 68, .2);
  margin: auto;
  // height: 40vh;
  width: 40vw;
  
}
#canvasThree{
  // border: 1px inset rgba(68, 68, 68, .2);
  margin: auto;
}
h2{
	font-size: 16px;
	width:60%;
}

button {
  background: #315D7F;
  width: 180px;
  height: 90px;
  padding: 4px 0;
  margin: 1em;
  // position: absolute;
  // left: 80%;
  // top: 50%;
  // transform: translateX(-50%) translateY(-50%);
  border-radius: 3px;
  // color: #444;

}
//   p {
//    	font-family: 'Roboto'; 
// 	  text-align: center;
//   	text-transform: uppercase;
//     color: #FFF;
//     user-select: none;
//   }
  
//   &:hover {
//     cursor: pointer;
//   }
  
//   &:after {
//     content: "";
//     display: block;
//     position: absolute;
//     width: 100%;
//     height: 10%;
//     border-radius: 50%;
//     background-color: darken(#f1c40f, 20%);
//     opacity: 0.4;
//     bottom: -30px;
//   }



              
            
!

JS

              
                var slider;
var sliderTwo;
var generaterOne;
var generatorTwo ;
var c;
var x;
var y;
var sliderTitle;
var sliderTwoTitle;
var dials;
function setup (){
    c = createCanvas(x, y);
    x= windowWidth;
    y= windowHeight;
    textFont('Bungee Hairline');
  slider = createSlider(60, 65, 60);
  sliderTwo = createSlider(60, 65, 60);
  var grabber = select('#controls')

// dials = createP('DIALS');
// dials.parent(grabber)
  sliderTwoTitle =  createP('RELATIVITY');
  sliderTwoTitle.style('font-family', 'Bungee Hairline');
  sliderTwoTitle.parent(grabber)
  slider.parent(grabber)
  slider.size(150, 50);
sliderTwo.size(150, 50);
    sliderTitle = createP('CHAOS');
  sliderTitle.style('font-family', 'Bungee Hairline');
  sliderTitle.parent(grabber)

  sliderTwo.parent(grabber)

button = createButton('GENERATE');
button.class('btn btn-navy btn-border-rev-o');


button.mousePressed(reGenerate);  
button.mousePressed(re_draw);  
button.parent(grabber)
button.style('font-family', 'Bungee Hairline')
  // translate(width / 2, height / 2);

function re_draw(){
  redraw();
}
//generate your own

 var canvas = document.getElementById('canvasGenerate')
 var ctx = canvas.getContext("2d");
 ctx.strokeStyle = '#F8FA9D';
 var newWidth = 1.8;
  var newHeight = .3;
function reGenerate (){
  // redraw();
  
    newWidth = newWidth * 1.1618
  newHeight = newHeight *Math.PI
  ctx.translate(canvas.width /newWidth, canvas.height/newHeight)
  // ctx.translate(canvas.width /newWidth, canvas.height/Math.PI)
  ctx.rotate(Math.PI);
generatorOne = slider.value();
generatorTwo = -1*sliderTwo.value();
console.log(slider.value())

var tree = new LSystem({
  axiom: 'X',
  productions: {
    // 'X': 'F-[[X]+X]+F[+FX]-X+F-[[X]+X]+F',
    'X': 'F-[[X]+X]-X+F-[[X]+X]+F',
    
    'F': 'FFF'
    // 'F': 'F-[[X]+X]+F'
    
  },
  finals: {
    'F': () => {
      ctx.beginPath()
      ctx.moveTo(0, 0)
      ctx.lineTo(0, 25 / (tree.iterations + 5))
      ctx.stroke()
      ctx.translate(0, 25 / (tree.iterations + 5))
    },
    '+': () => { ctx.rotate((Math.PI / 180) *generatorTwo ) },
    '-': () => { ctx.rotate((Math.PI / 180) *generaterOne ) },
      // '+': () => { ctx.rotate((Math.PI / 90) * -60) },
    // '-': () => { ctx.rotate((Math.PI / 90) * 60) },
    '[': () => { ctx.save() },
    ']': () => { ctx.restore() }
  }
})

// Run the 5 iterations of the L-System
tree.iterate(5);
tree.final(); 
}
}

/* Start Tryptic One */

//1.a
 var newCanvas =document.getElementById('canvas')
 var ctx = newCanvas.getContext("2d");
 ctx.strokeStyle = '#30875F';

var tree = new LSystem({
  axiom: 'X',
  productions: {
    'X': 'F-[[X]+X]+F[+FX]-X',
    'F': 'FF'
  },
  finals: {
    'F': () => {
      ctx.beginPath()
      ctx.moveTo(0, 0)
      ctx.lineTo(0, 25 / (tree.iterations + 1))
      ctx.stroke()
      ctx.translate(0, 25 / (tree.iterations + 1))
    },
    '+': () => { ctx.rotate((Math.PI / 180) * -60) },
    '-': () => { ctx.rotate((Math.PI / 180) * 60) },
    '[': () => { ctx.save() },
    ']': () => { ctx.restore() }
  }
})

// Run the 5 iterations of the L-System
tree.iterate(5);
// Output the new string/word into the text field
// document.getElementById('textresult').innerHTML = tree.getString();
tree.final();

// 1.b
 var canvasTwo = document.getElementById('canvas')
 var ctxTwo = canvasTwo.getContext("2d");
 ctxTwo.strokeStyle = '#771427';
var tree = new LSystem({
  axiom: 'X',
  productions: {
    'X': 'F-[[X]+X]+F[+FX]-X',
    'F': 'FF'
  },
  finals: {
    'F': () => {
      ctx.beginPath()
      ctx.moveTo(0, 0)
      ctx.lineTo(0, 25 / (tree.iterations + 1))
      ctx.stroke()
      ctx.translate(0, 25 / (tree.iterations + 1))
    },
    '+': () => { ctx.rotate((Math.PI / 180) * -60) },
    '-': () => { ctx.rotate((Math.PI / 180) * 60) },
    '[': () => { ctx.save() },
    ']': () => { ctx.restore() }
  }
})

tree.iterate(5);
tree.final();

//1.c
 var ctx = document.getElementById('canvasTwo').getContext("2d");
 ctx.strokeStyle = '#2C7BD6';
var tree = new LSystem({
  axiom: 'X',
  productions: {
    'X': 'F-[[X]+X]+F[+FX]-X',
    'F': 'FF'
  },
  finals: {
    'F': () => {
      ctx.beginPath()
      ctx.moveTo(0, 0)
      ctx.lineTo(0, 25 / (tree.iterations + 1))
      ctx.stroke()
      ctx.translate(0, 25 / (tree.iterations + 1))
    },
    '+': () => { ctx.rotate((Math.PI / 180) * 60) },
    '-': () => { ctx.rotate((Math.PI / 180) * -60) },
    '[': () => { ctx.save() },
    ']': () => { ctx.restore() }
  }
})

tree.iterate(5);
tree.final();

//1.d
 var ctx = document.getElementById('canvas').getContext("2d");
 ctx.strokeStyle = '#B42D33';
var tree = new LSystem({
  axiom: 'X',
  productions: {
    'X': 'F-[[X]+X]+F[+FX]-X',
    'F': 'FF'
  },
  finals: {
    'F': () => {
      ctx.beginPath()
      ctx.moveTo(0, 0)
      ctx.lineTo(0, 25 / (tree.iterations + 1))
      ctx.stroke()
      ctx.translate(0, 25 / (tree.iterations + 1))
    },
    '+': () => { ctx.rotate((Math.PI / 180) * -60) },
    '-': () => { ctx.rotate((Math.PI / 180) * 60) },
    '[': () => { ctx.save() },
    ']': () => { ctx.restore() }
  }
})

tree.iterate(5);
tree.final();

//2.a
 var ctx = document.getElementById('canvasTwo').getContext("2d");
 ctx.strokeStyle = '#D3F6FA';

// ctx.translate(canvas.width / 3.5, canvas.height / 1.5);
ctx.rotate(Math.PI);

var tree = new LSystem({
  axiom: 'X',
  productions: {
    'X': 'F-[[X]+X]+F[+FX]-X',
    'F': 'FF'
  },
  finals: {
    'F': () => {
      ctx.beginPath()
      ctx.moveTo(0, 0)
      ctx.lineTo(0, 25 / (tree.iterations + 1))
      ctx.stroke()
      ctx.translate(0, 25 / (tree.iterations + 1))
    },
    '+': () => { ctx.rotate((Math.PI / 180) * -30) },
    '-': () => { ctx.rotate((Math.PI / 180) * 30) },
    // '-': () => { ctx.rotate((Math.PI / 180) * 30) },
    
    '[': () => { ctx.save() },
    ']': () => { ctx.restore() }
  }
})
tree.iterate(4);
tree.final();

// 2.b
 var ctx = document.getElementById('canvasTwo').getContext("2d");
 ctx.strokeStyle = '#E39E2F';
var tree = new LSystem({
  axiom: 'X',
  productions: {
    'X': 'F-[[X]+X]+F[+FX]-X',
    'F': 'FF'
  },
  finals: {
    'F': () => {
      ctx.beginPath()
      ctx.moveTo(0, 0)
      ctx.lineTo(0, 25 / (tree.iterations + 1))
      ctx.stroke()
      ctx.translate(0, 25 / (tree.iterations + 1))
    },
    '+': () => { ctx.rotate((Math.PI / 180) * -60) },
    '-': () => { ctx.rotate((Math.PI / 180) * 60) },
    '[': () => { ctx.save() },
    ']': () => { ctx.restore() }
  }
})

tree.iterate(5);
tree.final();

// 3.a
 var ctx = document.getElementById('canvasThree').getContext("2d");
 ctx.strokeStyle = '#F54E65';
var tree = new LSystem({
  axiom: 'X',
  productions: {
    'X': 'F-[[X]+X]+F[+FX]-X',
    'F': 'FF'
  },
  finals: {
    'F': () => {
      ctx.beginPath()
      ctx.moveTo(0, 0)
      ctx.lineTo(0, 25 / (tree.iterations + 1))
      ctx.stroke()
      ctx.translate(0, 25 / (tree.iterations + 1))
    },
    '+': () => { ctx.rotate((Math.PI / 180) * -60) },
    '-': () => { ctx.rotate((Math.PI / 180) * 60) },
    '[': () => { ctx.save() },
    ']': () => { ctx.restore() }
  }
})

tree.iterate(5);
tree.final();

//3.b
var ctx = document.getElementById('canvasThree').getContext("2d");
 ctx.strokeStyle = '#CAFBE5';

var tree = new LSystem({
  axiom: 'X',
  productions: {
    'X': 'F-[[X]+X]+F[+FX]-X',
    'F': 'FF'
  },
  finals: {
    'F': () => {
      ctx.beginPath()
      ctx.moveTo(0, 0)
      ctx.lineTo(0, 25 / (tree.iterations + 1))
      ctx.stroke()
      ctx.translate(0, 25 / (tree.iterations + 1))
    },
    '+': () => { ctx.rotate((Math.PI / 90) * 60) },
    '-': () => { ctx.rotate((Math.PI / 90) * -60) },
    '[': () => { ctx.save() },
    ']': () => { ctx.restore() }
  }
})

tree.iterate(7);
tree.final();

var ctx = document.getElementById('canvasThree').getContext("2d");
 ctx.strokeStyle = '#D3F6FA';

var tree = new LSystem({
  axiom: 'X',
  productions: {
    'X': 'F-[[X]+X]+F[+FX]-X',
    'F': 'FF'
  },
  finals: {
    'F': () => {
      ctx.beginPath()
      ctx.moveTo(0, 0)
      ctx.lineTo(0, 25 / (tree.iterations + 1))
      ctx.stroke()
      ctx.translate(0, 25 / (tree.iterations + 1))
    },
    '+': () => { ctx.rotate((Math.PI / 90) * -60) },
    '-': () => { ctx.rotate((Math.PI / 90) * 60) },
    '[': () => { ctx.save() },
    ']': () => { ctx.restore() }
  }
})

tree.iterate(7);
tree.final();

              
            
!
999px

Console