My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* <p>Hello Gray-Scott is a very basic demonstration of the underlying
* reaction-diffusion simulation. This model can be used to produce
* a wide variety of patterns, both static and animated and is therefore
* well suited for being combined with other generative techniques.</p>
*
* <p><strong>usage:</strong></p>
* <ul>
* <li>click + drag mouse to draw dots used as simulation seed</li>
* <li>press any key to reset</li>
* </ul>
*/

/*
* Copyright (c) 2010 Karsten Schmidt
*
* This demo & library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* http://creativecommons.org/licenses/LGPL/2.1/
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

import toxi.sim.grayscott.*;
import toxi.math.*;

GrayScott gs;

void setup() {
size(256,256);
gs=new GrayScott(width,height,false);
gs.setCoefficients(0.023,0.074,0.095,0.03);
}

void draw() {
if (mousePressed) {
gs.setRect(mouseX, mouseY,20,20);
}
loadPixels();
for(int i=0; i<10; i++) gs.update(1);
for(int i=0; i<gs.v.length; i++) {
float cellValue=gs.v[i];
int col=255-(int)(min(255,cellValue*768));
pixels[i]=col<<16|col<<8|col|0xff000000;
}
updatePixels();
}

void keyPressed() {
gs.reset();
}

Change log

r439 by toxmeister on Feb 16, 2010   Diff
last minute testing, minor demo updates
(comments, imports etc.)
Go to: 
Project members, sign in to write a code review

Older revisions

r429 by toxmeister on Feb 16, 2010   Diff
adding more CA demos, updating all
other toxi.sim demos
r382 by toxmeister on Feb 6, 2010   Diff
adding getters/setters for GrayScott
params, adding HelloGrayScott
Processing demo
All revisions of this file

File info

Size: 1839 bytes, 61 lines
Powered by Google Project Hosting