<commit_before>import processing.video.*;
import java.util.*;
import tuio.*;

TuioClient tuioClient;
Capture video;
PGraphics lensEffect;
PImage lensImage;
PImage lensImage2;
PGraphics imgtmp;

int lensDiameter = 300;  // Lens diameter
int magFactor = 20;  // Magnification factor
int lensCenterX = 300;
int lensCenterY = 300;
int[] lensArray;  // Height and width of lens
int[] buffer;

void setup() {
  size( 640, 480 );

  // TUIO setup
  /**noStroke();
   * fill(0);
   * loop();
   * hint(ENABLE_NATIVE_FONTS);
   * font = createFont("Arial", 18);
   * scale_factor = height/table_size;
   * tuioClient  = new TuioClient(this);
   **/

  background(0);
  video = new Capture( this, 640, 480, 15 );
  buffer = new int[video.width * video.height];
  lensArray = new int[video.width * video.height];
  initializeLensMatrix();

  loadPixels();  // load pixels into memory for manip
}

void initializeLensMatrix() {
  // Lens algorithm (transformation array)
  int m, a, b;
  int r = lensDiameter / 2;
  float s = sqrt(r*r - magFactor*magFactor);

  for (int y = 0; y < video.height; y++) {
    for (int x = 0; x < video.width; x++) {
      int distanceToCenterX = x - lensCenterX;
      int distanceToCenterY = y - lensCenterY;
      if(dist(x, y, lensCenterX, lensCenterY) >= r) {
        // point is outside the circle of the lens, so its pixel should not
        // be modified
        a = x;
        b = y;
      }
      else {
        // point is under the lens, so point it somewhere else
        float z = sqrt(r*r
              - pow(distanceToCenterX, 2) 
              - pow(distanceToCenterY, 2));
        println(magFactor / z);
        a = int(distanceToCenterX * magFactor / z + 0.5);
        b = int(distanceToCenterY * magFactor / z + 0.5);
        a += lensCenterX;
        b += lensCenterY;
        a = constrain(a, 0, video.width-1);
        b = constrain(b, 0, video.height-1);
      }

      lensArray[x + y * video.width] 
                    = a + b * video.width;
    }<commit_msg>Need to this test revision of lensing Should work<commit_after>import processing.video.*;
import java.util.*;
import tuio.*;

TuioClient tuioClient;
Capture video;
PGraphics lensEffect;
PImage lensImage;
PImage lensImage2;
PGraphics imgtmp;

int lensDiameter = 300;  // Lens diameter
int magFactor = 20;  // Magnification factor
int lensCenterX = 300;
int lensCenterY = 300;
int[] lensArray;  // Height and width of lens
int[] buffer;

void setup() {
  size( 640, 480 );

  // TUIO setup
  /**noStroke();
   * fill(0);
   * loop();
   * hint(ENABLE_NATIVE_FONTS);
   * font = createFont("Arial", 18);
   * scale_factor = height/table_size;
   * tuioClient  = new TuioClient(this);
   **/

  background(0);
  video = new Capture( this, 640, 480, 15 );
  buffer = new int[video.width * video.height];
  lensArray = new int[video.width * video.height];
  initializeLensMatrix();

  loadPixels();  // load pixels into memory for manip
}

void initializeLensMatrix() {
  // Lens algorithm (transformation array)
  int m, a, b;
  int r = lensDiameter / 2;
  float s = sqrt(r*r - magFactor*magFactor);

  for (int y = 0; y < video.height; y++) {
    for (int x = 0; x < video.width; x++) {
      int distanceToCenterX = x - lensCenterX;
      int distanceToCenterY = y - lensCenterY;
      if(dist(x, y, lensCenterX, lensCenterY) >= r) {
        // point is outside the circle of the lens, so its pixel should not
        // be modified
        a = x;
        b = y;
      }
      else {
        // point is under the lens, so point it somewhere else
        float z = sqrt(r*r
              - pow(distanceToCenterX, 2) 
              - pow(distanceToCenterY, 2));
        a = int(distanceToCenterX * magFactor / z + 0.5);
        b = int(distanceToCenterY * magFactor / z + 0.5);
        a += lensCenterX;
        b += lensCenterY;
        a = constrain(a, 0, video.width-1);
        b = constrain(b, 0, video.height-1);
      }

      lensArray[x + y * video.width] 
                    = a + b * video.width;
    }
{'fraction_non_alphanumeric': 0.12699203187250996, 'fraction_numerical': 0.02141434262948207, 'mean_word_length': 2.418723404255319, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '1851125', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1317, 'n_words': 402}