<!--
###########################################################################################
This is a JSFiddle example of "Cacatoo". This HTML page does not contain the code itself,
but determines where the grids, graphs, buttons, etc are placed. The real code is in the
Javascript Tab. I recommend enabling "Tabs (Columns)" under the settings in the top-right.
###########################################################################################
-->
<html>
<script src="https://bramvandijk88.github.io/cacatoo/scripts/cacatoo.js"></script>
<script src="https://bramvandijk88.github.io/cacatoo/scripts/all.js"></script> <!-- Dependencies
<link rel="stylesheet" href="style.css"> <!-- Set style sheet -->
<head>
<title>Cacatoo examples</title>
</head>
<script>
/*-------------------------End user-defined code ---------------------*/
</script>
<body onload="cacatoo()">
<div class="header" id="header">
<h2>Cacatoo (example project)</h2>
</div>
<div class="content" id="canvas_holder"> </div>
<div class="content" id="graph_holder"> </div>
<div class="content" id="form_holder"></div>
<div class="footer" id="footer"></div>
</body>
</html>
/*-----------------------Start user-defined code ---------------------*/
let sim;
function cacatoo() {
let config = {
title: "Turing patterns",
description: "Reaction-diffusion system with short-range activation and long-range inhibition",
maxtime: 100000,
ncol: 100,
nrow: 100, // dimensions of the grid to build
wrap: [true, true], // Wrap boundary [COLS, ROWS]
scale: 3, // scale of the grid (nxn pixels per grid cell
show_gridname: true,
graph_interval: 1,
graph_update: 5
}
sim = new Simulation(config)
sim.makeGridmodel("turing")
sim.turing.colourViridis("activator", 100)
sim.createDisplay_continuous({model:"turing", property:"activator", label:"Activator density", // Createa a display for a continuous variable (ODE state for external resources)
minval:0, maxval:100})
// A self-replicating turing, which also produces a second molecule which inhibits the turing
let Turing = function (a, b, i, d) {
return function (n, p) {
return [
a * p[0] - i * p[1] - d * p[0] * p[0], // p[0] is the activating molecule
b * p[0] - i * p[1] - d * p[1] * p[1] // p[1] is the inhibiting molecule, which inhibits both but is produced by the activating molecule,
]
}
}
// Configuration object with initial states, parameters, and diffusion rates
let ode_config = {
ode_name: "turingeq",
init_states: [0, 0], // p[0] and p[1]
parameters: [0.5, 0.5, 0.5, 0.05], // a,b,i,d
diffusion_rates: [0.1, 0.2]
} // resources diffuse through exteral environment, but internal resources stay...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.