Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Processingjs and the Draw Function

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 08-11-2013, 08:35 AM PM User | #1 Pollen New to the CF scene   Join Date: Aug 2013 Posts: 1 Thanks: 1 Thanked 0 Times in 0 Posts Processingjs and the Draw Function I'd like this piece of code to draw numShape number of triangles, but it just keeps drawing one triangle at a time and looping forever. This is probably pretty basic, any help is appreciated! Code: ```if (typeShape=="Triangle"||typeShape=="triangle") { var triangleWidth = 30; var triangleHeight = 30; var triangleoneX = random(canvasWidth-triangleWidth); var triangleoneY = random(canvasHeight-triangleHeight); var triangletwoX = triangleoneX+(0.5*triangleWidth); var triangletwoY = triangleoneY-triangleHeight; var trianglethreeX = triangleoneX+triangleWidth; var trianglethreeY = triangleoneY; for(i = 0;i < numShape; i = i + 1) { triangle(triangleoneX,triangleoneY,triangletwoX,triangletwoY,trianglethreeX,trianglethreeY); } }```
 08-12-2013, 01:33 AM PM User | #2 Brandnew Regular Coder   Join Date: Aug 2012 Posts: 113 Thanks: 0 Thanked 24 Times in 24 Posts hi Pollen, i think your loop is calling your function triangle multiple times, however your values aren't changing. You get the random variables from the function and these same variables are being called repeatedly, thus you only see the same triangle (however i could be wrong about this but when i fiddled with your code i just saw the same values repeating). You may want to change the structure of your calls...i worked up a small function since i don't know what your triangle function looks like...maybe this might help to bring your code in the right direction and create multiple different triangles (keep in mind this is simple and thus not guarantee that the randomness will not call the same values twice) Code: ```

``` __________________ 1 Corinthians 15:3-4 / Ephesians 2:8-9 - What or Who are you living for?
 Users who have thanked Brandnew for this post: Pollen (08-12-2013)

 Bookmarks

 Tags processingjs

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 02:21 PM.