snipt

Ctrl+h for KB shortcuts

Java

Comment Toggle

1
2
3
4
5
//* 
background(img); 
/*/ 
background(255); 
//*/
https://snipt.net/embed/b6c6df9f77f685f3788f71fe24581623/
/raw/b6c6df9f77f685f3788f71fe24581623/
b6c6df9f77f685f3788f71fe24581623
java
Java
5
2019-07-13T17:56:43
True
False
False
Aug 01, 2013 at 08:06 AM
/api/public/snipt/71179/
comment-toggle
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">//* </span> </span><span id="L-2"><a name="L-2"></a><span class="n">background</span><span class="o">(</span><span class="n">img</span><span class="o">);</span> </span><span id="L-3"><a name="L-3"></a><span class="cm">/*/ </span> </span><span id="L-4"><a name="L-4"></a><span class="cm">background(255); </span> </span><span id="L-5"><a name="L-5"></a><span class="cm">//*/</span> </span></pre></div> </td></tr></table>

Java

Loop Through All Values of Luminance

int dmod = frameCount%510;
int col = dmod<255?dmod:510-dmod;
https://snipt.net/embed/1401a9bebbf0fc3b97bc401abdc003ad/
/raw/1401a9bebbf0fc3b97bc401abdc003ad/
1401a9bebbf0fc3b97bc401abdc003ad
java
Java
2
2019-07-12T19:28:37
True
False
False
Aug 01, 2013 at 07:40 AM
/api/public/snipt/71174/
loop-through-all-values-of-luminance
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kt">int</span> <span class="n">dmod</span> <span class="o">=</span> <span class="n">frameCount</span><span class="o">%</span><span class="mi">510</span><span class="o">;</span> </span><span id="L-2"><a name="L-2"></a><span class="kt">int</span> <span class="n">col</span> <span class="o">=</span> <span class="n">dmod</span><span class="o">&lt;</span><span class="mi">255</span><span class="o">?</span><span class="n">dmod</span><span class="o">:</span><span class="mi">510</span><span class="o">-</span><span class="n">dmod</span><span class="o">;</span> </span></pre></div> </td></tr></table>
color, processing

Java

Drawing Vertex Shapes with End and Start Being Equal

1
2
3
for (int i=0; i<NUMSEGMENTS+1; i++) {
  drawVertex(i==NUMSEGMENTS?0:i, DIAM_FIXED);
}
https://snipt.net/embed/edc3e587313ce9cb8be8d4fb7d1c5549/
/raw/edc3e587313ce9cb8be8d4fb7d1c5549/
edc3e587313ce9cb8be8d4fb7d1c5549
java
Java
3
2019-07-13T11:41:46
True
False
False
Aug 01, 2013 at 07:25 AM
/api/public/snipt/71171/
drawing-vertex-shapes-with-end-and-start-being-equal
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">for</span> <span class="o">(</span><span class="kt">int</span> <span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="o">;</span> <span class="n">i</span><span class="o">&lt;</span><span class="n">NUMSEGMENTS</span><span class="o">+</span><span class="mi">1</span><span class="o">;</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span> </span><span id="L-2"><a name="L-2"></a> <span class="n">drawVertex</span><span class="o">(</span><span class="n">i</span><span class="o">==</span><span class="n">NUMSEGMENTS</span><span class="o">?</span><span class="mi">0</span><span class="o">:</span><span class="n">i</span><span class="o">,</span> <span class="n">DIAM_FIXED</span><span class="o">);</span> </span><span id="L-3"><a name="L-3"></a><span class="o">}</span> </span></pre></div> </td></tr></table>
processing

Java

Scroll Through Elements in Array (1 line)

currentImage = ++currentImage%images.length;
https://snipt.net/embed/3efb3b99a7b4f8f79d5d3ef0dcae6056/
/raw/3efb3b99a7b4f8f79d5d3ef0dcae6056/
3efb3b99a7b4f8f79d5d3ef0dcae6056
java
Java
1
2019-07-15T02:05:11
True
False
False
Aug 01, 2013 at 07:23 AM
/api/public/snipt/71170/
scroll-through-elements-in-array-1-line
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="n">currentImage</span> <span class="o">=</span> <span class="o">++</span><span class="n">currentImage</span><span class="o">%</span><span class="n">images</span><span class="o">.</span><span class="na">length</span><span class="o">;</span> </span></pre></div> </td></tr></table>
processing

Java

timestamp

1
2
3
4
5
6
import java.util.Calendar;

String timestamp() {
  Calendar now = Calendar.getInstance();
  return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now);
}
https://snipt.net/embed/d799f1c68f91125301c8ea0c06945eeb/
/raw/d799f1c68f91125301c8ea0c06945eeb/
d799f1c68f91125301c8ea0c06945eeb
java
Java
6
2019-07-21T04:01:51
True
False
False
Jul 15, 2013 at 01:01 PM
/api/public/snipt/67826/
timestamp-1
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="kn">import</span> <span class="nn">java.util.Calendar</span><span class="o">;</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="n">String</span> <span class="nf">timestamp</span><span class="o">()</span> <span class="o">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="n">Calendar</span> <span class="n">now</span> <span class="o">=</span> <span class="n">Calendar</span><span class="o">.</span><span class="na">getInstance</span><span class="o">();</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">return</span> <span class="n">String</span><span class="o">.</span><span class="na">format</span><span class="o">(</span><span class="s">&quot;%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS&quot;</span><span class="o">,</span> <span class="n">now</span><span class="o">);</span> </span><span id="L-6"><a name="L-6"></a><span class="o">}</span> </span></pre></div> </td></tr></table>
calendar, time