<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with round() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=round%28%29</link>
      <pubDate>Sun, 08 Aug 2021 20:07:35 +0000</pubDate>
         <description>Tagged with round() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedround%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>How would I solve this problem? (print)</title>
      <link>https://forum.processing.org/two/discussion/26069/how-would-i-solve-this-problem-print</link>
      <pubDate>Mon, 22 Jan 2018 00:15:53 +0000</pubDate>
      <dc:creator>PopeyeTheSailorMan</dc:creator>
      <guid isPermaLink="false">26069@/two/discussions</guid>
      <description><![CDATA[<p>Given the width of the rink, w (always more than 2), how would I output the rink following these rules:</p>

<p>If the width of the rink is w characters across, then the rink’s length is 4w - 3 characters.</p>

<p>The characters to be used around the rink are Xs.</p>

<p>The red line is always in the centre of the rink, drawn across using Rs.</p>

<p>The blue lines are always (w - 1) / 2 in distance from the red line, drawn across using Bs.</p>

<p>The result of calculating (w - 1) / 2 should always be rounded to the nearest integer, such that 1.5 rounds up to 2, and 1.4 rounds down to 1, for example.</p>

<p>For reference, in the output below, the blue lines are 2 units away from the red line.</p>

<p>Input:</p>

<p><code>4</code></p>

<p>Output:</p>

<pre><code>XXXX
X  X
X  X
X  X
XBBX
X  X
XRRX
X  X
XBBX
X  X
X  X
X  X
XXXX
</code></pre>

<p>Code:</p>

<pre><code>void setup() {

  String[] w = loadStrings("file.txt");

  int rinkWidth = Integer.parseInt(w[0]);
  int rinkLength = 4 * rinkWidth - 3;

  printRink(rinkWidth, rinkLength);
}

void printRink(int rinkWidth, int rinkLength) {

  for (int i = 0; i &lt; rinkWidth - 1; i ++) {
    print("X");
  }

  for (int i = 0; i &lt; rinkLength; i ++) {
    print("X" + "\n");
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Set size in cm/mm?</title>
      <link>https://forum.processing.org/two/discussion/25832/set-size-in-cm-mm</link>
      <pubDate>Fri, 05 Jan 2018 12:31:01 +0000</pubDate>
      <dc:creator>roy_g_biv</dc:creator>
      <guid isPermaLink="false">25832@/two/discussions</guid>
      <description><![CDATA[<p>If I recall correctly all size parameters are in pixels. Is it possible, if one wants, to define them in terms of cm or mm? You would need the pixel density of the monitor, right? Is that possible to get in Processing?</p>

<p>As a side note, it is quite difficult to google solutions specific to Processing since the name is such a commonly used word. I suppose I should have done the site:processing.org thing..</p>
]]></description>
   </item>
   <item>
      <title>Why is the background going blue?</title>
      <link>https://forum.processing.org/two/discussion/25453/why-is-the-background-going-blue</link>
      <pubDate>Fri, 08 Dec 2017 10:29:51 +0000</pubDate>
      <dc:creator>Cap</dc:creator>
      <guid isPermaLink="false">25453@/two/discussions</guid>
      <description><![CDATA[<p>If I use background(mouseX), it goes from black to white as I move the mouse across x but at 255 it goes from black to bright blue instead?</p>
]]></description>
   </item>
   <item>
      <title>convert float string to string</title>
      <link>https://forum.processing.org/two/discussion/18679/convert-float-string-to-string</link>
      <pubDate>Mon, 24 Oct 2016 00:49:20 +0000</pubDate>
      <dc:creator>allcc</dc:creator>
      <guid isPermaLink="false">18679@/two/discussions</guid>
      <description><![CDATA[<p>I'm communicating with a microcontroller using the serial port using a demo I found and it works great. The issue is I do not want a floating point number to go to the microcontroller. Right now it does, using the code below.</p>

<p>What I would like to do is drop the decimal (or round off) "subtext[counter]" before sending via myPort.write. I have tried converting it to an int, but then myport.write doesn't like it. If there is a way to send an INT via myPort.write that would also be a good solution.</p>

<p>if(counter&lt;subtext.length){</p>

<p>pan = Float.valueOf(subtext[counter]);</p>

<p>pan = (pan + 0.01) * 11.2;</p>

<p>(subtext[counter]) = Float.toString(pan);</p>

<p>myPort.write(subtext[counter]);</p>
]]></description>
   </item>
   <item>
      <title>For loop - storing previous value</title>
      <link>https://forum.processing.org/two/discussion/15806/for-loop-storing-previous-value</link>
      <pubDate>Fri, 01 Apr 2016 18:47:25 +0000</pubDate>
      <dc:creator>rumlac</dc:creator>
      <guid isPermaLink="false">15806@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I am trying to solve how to do the following:</p>

<p>I have an array of numbers
I want to map each value in the array between 15 and 60
I want to draw a number of rects side by side where each rect represents a number in the array of numbers 
The width of each rect will be the mapped value of it's corresponding number in the array.</p>

<p>How do I solve the Y position of each rect? I assume I need to find a way of saving the accumulative width of each rect and then place the new rect at the position?</p>

<pre><code>float[] rectWidths = {12.5, 23.7, 22.9, 77.3, 62.1};

void setup() {
  size(500, 375);
}

void draw() {
  background(255);
  for (int i = 0; i&lt;rectWidths.length; i++) {
    rect(H, height/2, map(rectWidths[i], min(rectWidths), max(rectWidths), 15, 60), 20); //H needs to be the accumulative width of each rect
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>ControlP5 Slider with integer ticks</title>
      <link>https://forum.processing.org/two/discussion/14968/controlp5-slider-with-integer-ticks</link>
      <pubDate>Wed, 17 Feb 2016 07:57:37 +0000</pubDate>
      <dc:creator>atran</dc:creator>
      <guid isPermaLink="false">14968@/two/discussions</guid>
      <description><![CDATA[<p>Hi guys,</p>

<p>Is there anyway to make the tick amount integers? I have set the slider's min to 0 and max to 599. I then set the number of ticks to be 600. However, whenever it iterates it goes: 0, 1, 2, 3, 4, 5, 5.99, 7, 8, 9.99, 11, 12.000002, 13, instead of just integers. The 5.99 instead of 6 and 9.99 instead of 10 really throws off my animation. Same goes for the 12.0002. Is there anyway to combat this?</p>

<p>Thanks</p>
]]></description>
   </item>
   <item>
      <title>How to round a float to its second or third decimal?</title>
      <link>https://forum.processing.org/two/discussion/13586/how-to-round-a-float-to-its-second-or-third-decimal</link>
      <pubDate>Sat, 21 Nov 2015 12:14:20 +0000</pubDate>
      <dc:creator>kennyLiao</dc:creator>
      <guid isPermaLink="false">13586@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone,</p>

<p>We have <code>round()</code>, <code>ceil()</code>, <code>floor()</code>, they all round float to int. Do we have functions to round float with 5 or more decimal to its second or third decimal?</p>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>'snap to' pixel after applying transformations</title>
      <link>https://forum.processing.org/two/discussion/12469/snap-to-pixel-after-applying-transformations</link>
      <pubDate>Thu, 10 Sep 2015 22:34:32 +0000</pubDate>
      <dc:creator>jedierikb</dc:creator>
      <guid isPermaLink="false">12469@/two/discussions</guid>
      <description><![CDATA[<pre><code>//given these coordinates for a rectangle (which I will draw with rectmode CORNER)
float layerX = -50;
float layerY = -50;
float layerW = 100;
float layerH = 100;

//and these transformations
translate( 300, 0 );
scale( 12, 1.5 );
scale( .5, .5 );

//which project those coordinates here.
float sx = screenX( layerX, layerY );
float sy = screenY( layerX, layerY );
float sw = screenX( layerX+layerW, layerY+layerH );
float sh = screenY( layerX+layerW, layerY+layerH );

//(this spits out 0, -37.5, 600, 37.5)
println( sx, sy, sw, sh );

//how do I modify the transformation to 'snap' the transformed values to [0, -38, 600, 38], effectively snapping to the pixel (and widening the rectangle)?
</code></pre>
]]></description>
   </item>
   <item>
      <title>how to approximate values</title>
      <link>https://forum.processing.org/two/discussion/9850/how-to-approximate-values</link>
      <pubDate>Fri, 13 Mar 2015 23:34:02 +0000</pubDate>
      <dc:creator>plux</dc:creator>
      <guid isPermaLink="false">9850@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I have float values let's say range (-100.0, 300.0). I cast to int to do a first approximation but then what if I want to say that every value ranging from 50 to 55 must be  equal to 50 and from 55 to 60 equal to 60?  As I have to do this for all the range (400 int values) is there an easy way to do this other than check for every number if is is the first 5 digits or the second 5?</p>

<p>some examples
44 = 40
256 = 257
122 = 120
-43 = -40</p>

<p>thanks</p>
]]></description>
   </item>
   </channel>
</rss>