Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I worked out a solution using two generated images. The first one <code>imgText</code> contains only text (white) in front of black background. The second one <code>imgMask</code>functions as mask and therefore contains the screen line pattern. It's fine to generate the first (text image) only once within the <code>setup()</code> part; because your type doesn't change/move or transform. The mask image has to be updated every frame if you want to achieve the effect of "scanning" lines. This happens every <code>draw()</code> loop through the shift of the <code>offset</code> parameter. </p> <p>The rest is pretty basic; clear the background every frame and draw the inverted version of <code>imgText</code> before you display the actual masked image. </p> <pre><code> PImage imgText; PImage imgMask; PFont font; int barHeight = 20; float offset = 0; float offsetTick = 0.3; void setup () { size (320, 240); noStroke (); smooth (); font = createFont ("Helvetica-Bold.vlw", 18); // Create new image containing only // the white text infront of an empty // black sketch background background (0); fill (255); textFont (font); textAlign (CENTER); text ("Text goes here", width/2, height/2); imgText = createImage (width, height, ARGB); copySketchIntoImage (imgText); // Create empty mask image imgMask = createImage (width, height, ARGB); } void draw () { // Move the scan lines further down // by increasing offset offset += offsetTick; if (offset &gt; barHeight * 2) { offset = 0; } // Update the text mask image updateMask (offset); imgText.mask (imgMask); // Draw the inverted background+text background (255); fill (0); text ("Text goes here", width/2, height/2); // Display the masked version of the // text image above the inverted background image (imgText, 0, 0); } void updateMask (float theOffset) { background (0); fill (255); for (float i=theOffset - barHeight; i &lt; height; i += barHeight * 2) { rect (0, i, width, barHeight); } copySketchIntoImage (imgMask); } // Method to copy all sketch pixels // into an existing PImage. void copySketchIntoImage (PImage theDestImage) { loadPixels (); theDestImage.loadPixels (); for (int i=0; i &lt; pixels.length; i++) { theDestImage.pixels[i] = pixels[i]; } theDestImage.updatePixels (); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload