AutoHotkey | Android | Arduino | COMM140 | Fractals | 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
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.
// 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 ); } }
APA citation:
Russell, R. (2016, July 05, 07:26 am). Evolution of Xanthorrhoea 001_1.
Retrieved November 25, 2024, from http://www.rupert.id.au/tutorials/processing/examples/xanthorrea001/001_1.php
Last refreshed: November 25 2024. 05:03.25 pm
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.