snipt

Ctrl+h for KB shortcuts

Java

Create Rectangle

void setup() { 
createRect(50,50,100,100,20, 5, 100); 
}
 
//parameterizedfunction 
void createRect(int xpos, int ypos, int wdth, int ht, int strokeCol, 
int strokeWt, int fillCol) { 
stroke(strokeCol); 
strokeWeight(strokeWt); 
fill(fillCol); 
rect (xpos, ypos, wdth, ht); 
} 
https://snipt.net/embed/f81940003711d997efca35502e045892/
/raw/f81940003711d997efca35502e045892/
f81940003711d997efca35502e045892
java
Java
13
2019-06-27T07:19:10
True
False
False
/api/public/snipt/1233/
create-rectangle
<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> <a href="#L-7"> 7</a> <a href="#L-8"> 8</a> <a href="#L-9"> 9</a> <a href="#L-10">10</a> <a href="#L-11">11</a> <a href="#L-12">12</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">void</span> <span class="nf">setup</span><span class="o">()</span> <span class="o">{</span> </span><span id="L-2"><a name="L-2"></a><span class="n">createRect</span><span class="o">(</span><span class="mi">50</span><span class="o">,</span><span class="mi">50</span><span class="o">,</span><span class="mi">100</span><span class="o">,</span><span class="mi">100</span><span class="o">,</span><span class="mi">20</span><span class="o">,</span> <span class="mi">5</span><span class="o">,</span> <span class="mi">100</span><span class="o">);</span> </span><span id="L-3"><a name="L-3"></a><span class="o">}</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="c1">//parameterizedfunction </span> </span><span id="L-6"><a name="L-6"></a><span class="kt">void</span> <span class="nf">createRect</span><span class="o">(</span><span class="kt">int</span> <span class="n">xpos</span><span class="o">,</span> <span class="kt">int</span> <span class="n">ypos</span><span class="o">,</span> <span class="kt">int</span> <span class="n">wdth</span><span class="o">,</span> <span class="kt">int</span> <span class="n">ht</span><span class="o">,</span> <span class="kt">int</span> <span class="n">strokeCol</span><span class="o">,</span> </span><span id="L-7"><a name="L-7"></a><span class="kt">int</span> <span class="n">strokeWt</span><span class="o">,</span> <span class="kt">int</span> <span class="n">fillCol</span><span class="o">)</span> <span class="o">{</span> </span><span id="L-8"><a name="L-8"></a><span class="n">stroke</span><span class="o">(</span><span class="n">strokeCol</span><span class="o">);</span> </span><span id="L-9"><a name="L-9"></a><span class="n">strokeWeight</span><span class="o">(</span><span class="n">strokeWt</span><span class="o">);</span> </span><span id="L-10"><a name="L-10"></a><span class="n">fill</span><span class="o">(</span><span class="n">fillCol</span><span class="o">);</span> </span><span id="L-11"><a name="L-11"></a><span class="n">rect</span> <span class="o">(</span><span class="n">xpos</span><span class="o">,</span> <span class="n">ypos</span><span class="o">,</span> <span class="n">wdth</span><span class="o">,</span> <span class="n">ht</span><span class="o">);</span> </span><span id="L-12"><a name="L-12"></a><span class="o">}</span> </span></pre></div> </td></tr></table>
2d, java, processing