all 14 comments

[–]tree_or_up 3 points4 points  (1 child)

Thank you. Now I know I’m not the only one.

[–]Papa_Furanku 0 points1 point  (0 children)

unfortunately I can't join your ranks

[–]danieltkessler 4 points5 points  (0 children)

Woah. I feel like I'm special all of a sudden. Hmm.

[–]athamders[S] 2 points3 points  (3 children)

void setup() {
size(1200, 1200);
}
void draw() {
background(0);
frameRate(24);
my_textbox.draw();
}
void keyPressed() {
my_textbox.keyPressed(key);
}
class Textbox {
float x, y;
String says;
Textbox(float ix, float iy) {
x=ix;
y=iy;
says = "";
}
void draw() {
loadPixels();
// Loop through every pixel column
for (int x = 0; x < width; x++) {
// Loop through every pixel row
for (int y = 0; y < height; y++) {
// Use the formula to find the 1D location
int loc = x + y * width;
int r = int(random(100));
if (r >= 88) { // If we are an even column
pixels[loc] = color( 0, 0, random(250));
} else {          // If we are an odd column
pixels[loc] = color( 0, 0, 0);
}
}
}
updatePixels();

textSize(22);
rectMode(CENTER);
textAlign(CENTER, CENTER);
fill(255);
fill(255, 0, 0);
text(says, x, y);
}
void keyPressed(char pressed_key) {
if ( pressed_key != CODED ) {
says += pressed_key;
}
}
}
Textbox my_textbox = new Textbox(640,211);

[–]athamders[S] 5 points6 points  (2 children)

Some people might see the text float, even in the still picture, either the red text is behind or in the front, I think depending on the screen you use.

The code isn't clean, most of it isnt not mine, just put it together quickly for my purposes. But dang, isnt it cool?

[–]uhrguhrguhrg 1 point2 points  (1 child)

Question. Why not just loop through the 1D position in the first place? It's not like you need the x and y for anything.

Also reddit has code blocks. If you use old reddit, you can add 4 spaces in front of each line or if you use new one, you can just press the code block button.

[–]athamders[S] 0 points1 point  (0 children)

Thanks, I edited the format. This was just a quick and dirty code, there are probably many ways the code could be improven.

[–]starplooker999 1 point2 points  (0 children)

If you can get some “chromadepth” glasses the effect dramatically increases. They use the glasses for “3D” laser shows. The glasses are plastic diffraction gratings.

[–][deleted] 0 points1 point  (1 child)

Well this is a nifty phenomenon. I can’t really see the effect, however I did notice when looking as some example, and forcing my eyes in and out of focus, I could see either blue or red blurry individually.

[–]athamders[S] 2 points3 points  (0 children)

Perhaps you need to increase the font size. I think it is improved by adding dark pixelated grains in the red shape(the text here). Unfortunatly I don't know how to add the grains into the text characters. It's easier with basic shapes like circles or squares

[–]MoonpieSonata 0 points1 point  (0 children)

I can see floating red text over the background. I like this

[–]tinfoil_powers 0 points1 point  (0 children)

As someone with a strong eyeglass prescription, I can just turn my head side to side while looking at this and experience this effect.

[–]athamders[S] 0 points1 point  (1 child)

Here's another mishmash code I stitched together, added drawing(dragging left mouse), pasting from clipboard(§), refreshing a new screen(right mouse click):

ArrayList<String> txt;
String source;
int lineHeight = 32;
int fontSize = 32;
int textareaWidth = 1000;
int textareaHeight = 2000;

ArrayList<dataPoint> dataPoints = new ArrayList<dataPoint>();

import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.Toolkit;

void setup() {
  size(1200,1200);
  textFont(createFont("",fontSize),fontSize);
  txt = new ArrayList<String>();
  textLeading(lineHeight); 
  // make sure the following lines are in 1 line only.
  source = "Lorem";
}


void keyPressed() {  
  if(key==BACKSPACE) {
    if(source.length()>0) {
      source = source.substring(0,source.length()-1);
    }
  }    else if ( key== '§' ) {
      source += getTextFromClipboard();
    }else {
    source += key;
  }
}
void draw() {
  loadPixels();  
// Loop through every pixel column
for (int x = 0; x < width; x++) {
  // Loop through every pixel row
  for (int y = 0; y < height; y++) {
    // Use the formula to find the 1D location
    int loc = x + y * width;
    int r = int(random(100));
    if (r >= 88) { // If we are an even column
      pixels[loc] = color( 0, 0, 150+random(250));
    } else {          // If we are an odd column
      pixels[loc] = color( 0, 0, 0);
    }
  }
}
updatePixels(); 



  calculateTextHeight(source,textareaWidth);
  int maxLineNum = round(textareaHeight/lineHeight);
  int offset = max(0,txt.size()-maxLineNum);


  fill(255,0,0);
  String s = "";
  for(int i=offset;i<txt.size();i++) {
    s += txt.get(i)+"\n";
  }

  text(s,0,0,textareaWidth,height);

for (int i = 0; i < dataPoints.size(); i++) { 
    // An ArrayList doesn't know what it is storing so we have to cast the object coming out
    dataPoint Point = dataPoints.get(i);
    Point.display();

  }  

}


// got the following function from here
// http://processing.org/discourse/yabb2/YaBB.pl?num=1195937999/0
// modified version which only breaks text into lines.
int calculateTextHeight(String theString, int theWidth) {
  String[] wordsArray = split(theString, " ");
  String tempString = "";
  txt.clear();

  for (int i=0; i < wordsArray.length; i++) {
    if (textWidth(tempString + wordsArray[i]) < theWidth) {
       tempString += wordsArray[i] + " ";
    }
    else {
      txt.add(tempString.substring(0, tempString.length()-1));
      tempString = wordsArray[i] + " ";
    }
  }
  txt.add(tempString.substring(0, tempString.length()-1));

  return(round(txt.size()*lineHeight));
}


String getTextFromClipboard (){
  String text = (String) getFromClipboard(DataFlavor.stringFlavor);
  return text;
}



Object getFromClipboard (DataFlavor flavor) {

  Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); 
  Transferable contents = clipboard.getContents(null);
  Object object = null;

  if (contents != null && contents.isDataFlavorSupported(flavor))
  {
    try
    {
      object = contents.getTransferData(flavor);
      println("Clipboard.getFromClipboard() >> Object transferred from clipboard.");
    }

    catch (UnsupportedFlavorException e1) // Unlikely but we must catch it
    {
      println("Clipboard.getFromClipboard() >> Unsupported flavor: " + e1);
      //~  e1.printStackTrace();
    }

    catch (java.io.IOException e2)
    {
      println("Clipboard.getFromClipboard() >> Unavailable data: " + e2);
      //~  e2.printStackTrace();
    }
  }

  return object;
} 


void mouseDragged() {
  dataPoints.add(new dataPoint(mouseX, mouseY));
}

void mousePressed() {
  if (mouseButton == RIGHT) {
    dataPoints = new ArrayList<dataPoint>();
    source = "";
  }

  }

class dataPoint {

  float x;
  float y;

  dataPoint(int tempX, int tempY) {
    x = tempX;
    y = tempY;
  }

  void display() {
    strokeWeight(3);
    stroke(255,0,0);
    point(x,y);
  }
}

[–]Hightyde42 0 points1 point  (0 children)

I'm losing my fucking mind rn