header

 

More links

AutoHotkey | Android | Arduino | COMM140Fractals | Grammar Checkers | Knots | A Million Dots Activity |  Processing | Processing for Scratch Users | RedBubble | Tutorials | Weather | World Time Meeting Planner | Favicon Generator.

Home > Tutorials > Processing > Processing Examples > Evolution of Xanthoria 001 > Evolution of Xanthorrhoea 001_1

Evolution of Xanthorrhoea 001_1

 

2010-10-20_0546.png

Comments:

Having produced code that can draw a basic trunk the next step is to convert this into a procedure that can be passed variables of (height, width, start_x, start_y)

Once I have created a procedure I can call it many times to draw many grass trees.

processing code

// Author: Rupert Russell
// Title: xanthorrhoea 001.1
// Date: October 20, 2010

void setup() {
   size(300, 300);
   smooth();
}

void draw() {
   noLoop(); 
   
   // draw trunk
   int trunk_width = 25;
   float step = 0.7;
   int start_x = width /3;
   int start_y = height;
   float lean = 0.1;

   for (int counter = 0; counter < 150; counter ++){
  
     strokeWeight(random(0.2, 2));
     float rand_y = random(0.2, 5);
     float rand_x = random(10);
     line(start_x + rand_x + lean * counter , start_y - (step * counter) - rand_y , start_x + trunk_width + rand_x + lean * counter, start_y - (step * counter) - rand_y * 2 );
   }
}
code formatter

 


APA citation:
Russell, R. (2016, July 05, 07:26 am). Evolution of Xanthorrhoea 001_1.
     Retrieved April 26, 2024, from http://www.rupert.id.au/tutorials/processing/examples/xanthorrea001/001_1.php

Last refreshed: April 26 2024. 09:18.09 pm

rupert dot russell at acu dot edu dot au Support Wikipedia

Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.


325 visits since October 20, 2010