<commit_before>var system;

var gui;
var params = {
  num_segments: 5,
  wave_amplitude: 50,
  wave_frequency: 3
};
var guiNumSegments, guiWaveAmplitude, guiWaveFrequency;

function setup() {
  createCanvas(500, 500);
  P5JsSettings.init();

  gui = new dat.gui.GUI();
  guiNumSegments = gui.add(params, "num_segments").min(1).max(200).step(1);
  guiWaveAmplitude = gui.add(params, "wave_amplitude").min(-200).max(200).step(10);
  guiWaveFrequency = gui.add(params, "wave_frequency").min(0.5).max(5).step(0.25);
  addGuiListeners();
  
  colorMode(HSB);
  initSystem();
  frameRate(1);
  noLoop();
}

function draw(){
  background(0, 0, 20);
  system.tick();
  system.draw();
}
 
function initSystem(){
  var rect = new Rect(0.1 * width, 0.1 * height, 
                            0.8 * width, 0.8 * height);
  system = new System(rect, params);
  draw();
}

function addGuiListeners(){
  guiNumSegments.onFinishChange(function(value) {
    initSystem();
  });
  guiWaveAmplitude.onFinishChange(function(value) {
    initSystem();
  });
  guiWaveFrequency.onFinishChange(function(value) {
    initSystem();
  });
}


<commit_msg>p5js/meandering-river - Add screenshot capability<commit_after>var system;
var canvas;

var gui;
var params = {
  num_segments: 5,
  wave_amplitude: 50,
  wave_frequency: 3
};
var guiNumSegments, guiWaveAmplitude, guiWaveFrequency;

function setup() {
  canvas = createCanvas(500, 500);
  P5JsSettings.init();

  gui = new dat.gui.GUI();
  guiNumSegments = gui.add(params, "num_segments").min(1).max(200).step(1);
  guiWaveAmplitude = gui.add(params, "wave_amplitude").min(-200).max(200).step(10);
  guiWaveFrequency = gui.add(params, "wave_frequency").min(0.5).max(5).step(0.25);
  addGuiListeners();
  
  colorMode(HSB);
  initSystem();
  frameRate(1);
  noLoop();
}

function draw(){
  background(0, 0, 20);
  system.tick();
  system.draw();
}
 
function initSystem(){
  var rect = new Rect(0.1 * width, 0.1 * height, 
                            0.8 * width, 0.8 * height);
  system = new System(rect, params);
  draw();
}

function addGuiListeners(){
  guiNumSegments.onFinishChange(function(value) {
    initSystem();
  });
  guiWaveAmplitude.onFinishChange(function(value) {
    initSystem();
  });
  guiWaveFrequency.onFinishChange(function(value) {
    initSystem();
  });
}

function keyTyped(){
  if (key == 'p'){
    saveCanvas(canvas, 'screenshot', 'png');
  }
}



{'fraction_non_alphanumeric': 0.16452014956377234, 'fraction_numerical': 0.03614457831325301, 'mean_word_length': 3.954732510288066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6060114', 'n_tokens_mistral': 966, 'n_tokens_neox': 873, 'n_words': 156}