Toggle navigation
Sign Up
Log In
Explore
Works
Folders
Tools
Collections
Artists
Groups
Groups
Topics
Tasks
Tasks
Jobs
Teams
Jobs
Recommendation
More Effects...
JS
/* Copyright (c) 2014 Mikhail Chernov (http://codepen.io/mikkamikka) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ var boundsx,boundsy, mouse = { down: false, button:1, x:0, y:0, px:0,py:0 }; var ic = 0x1000000; var random_color = '#0'; function Params() { this.iterations= 2; this.theta= 18; this.thetaRandomness= 0; this.angle= 0; this.scale= 4; this.scaleRandomness= 0; this.constantWidth= true; this.deltarota =30; } function Colors() { this.background = "#000000"; this.general = "#111faa"; this.random= true; this.alpha= 0.8; } function Rules() { this.axiom = 'F'; this.mainRule = 'FF-[-F+F+F]+[+F-F-F]'; this.Rule2 = ''; } var rules = new Rules(); var params = new Params(); var colors = new Colors(); var clear = { clear: function(){ canvas.width = canvas.width;}}; window.addEventListener('mousemove', function (event) { mouse.x = event.clientX; mouse.y = event.clientY; }); window.onmousemove = function(e) { mouse.px = mouse.x; mouse.py = mouse.y; mouse.x = e.clientX - window.innerWidth/2; mouse.y = -(e.clientY - window.innerHeight/2); if (mouse.down) { } e.preventDefault(); }; window.onmousedown = function(e){ mouse.down = true; mouse.px = mouse.x; mouse.py = mouse.y; mouse.x = e.clientX - window.innerWidth/2; mouse.y = -(e.clientY - window.innerHeight/2); public_color = getRandomColor(); } window.onmouseup = function(e){ mouse.down = false; } window.onload = function(){ } function drawLine(x,y, x0,y0, color, width) { ctx.beginPath(); ctx.moveTo(x,y); ctx.lineTo(x0,y0); ctx.strokeStyle = color; if (params.constantWidth) ctx.lineWidth = 1; else ctx.lineWidth = width; ctx.stroke(); } function getRandomColor() { var r = ~~( 255 * Math.random()); var g = ~~( 255 * Math.random()); var b = ~~( 255 * Math.random() ); var a = colors.alpha; return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; } function GetAxiomTree() { var Waxiom = rules.axiom; var newf = rules.mainRule; var newb = 'bb'; var newx = rules.Rule2; var level = params.iterations; while (level > 0) { var m = Waxiom.length; var T = ''; for (var j=0; j < m; j++) { var a = Waxiom[j]; if (a == 'F'){T += newf;} else if (a == 'b'){T += newb;} else if (a == 'X'){T += newx;} else T += a; } Waxiom = T; level--; } return Waxiom; } function DrawTheTree(geom, x_init, y_init, z_init){ var geometry = geom; var Wrule = GetAxiomTree(); var n = Wrule.length; var stackX = []; var stackY = []; var stackZ = []; var stackA = []; var stackV = []; var stackAxis = []; var theta = params.theta * Math.PI / 180; var scale = params.scale; var angle = params.angle * Math.PI / 180; var x0 = x_init; var y0 = y_init; var z0 = z_init ; var x; var y; var z; var rota = 0, rota2 = 0, deltarota = 18 * Math.PI/180; var newbranch = false; var axis_x = new THREE.Vector3( 1, 0, 0 ); var axis_y = new THREE.Vector3( 0, 1, 0 ); var axis_z = new THREE.Vector3( 0, 0, 1 ); var zero = new THREE.Vector3( 0, 0, 0 ); var axis_delta = new THREE.Vector3(), prev_startpoint = new THREE.Vector3(); var startpoint = new THREE.Vector3(x0,y0,z0), endpoint = new THREE.Vector3(); var bush_mark; var vector_delta = new THREE.Vector3(scale, scale, 0); for (var j=0; j
CSS
html, body { width: 100%; height: 100%; margin: 0px; } #gui { right: 0; position: fixed; top: 0; z-index:10; }
HTML
Join Effecthub.com
Working with Global Gaming Artists and Developers!
Login
Sign Up
Or Login with Your Email Address:
Email
Password
Remember
Or Sign Up with Your Email Address:
Your Email
This field must contain a valid email
Set Password
Password should be at least 1 character
Stay informed via email