<?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 map() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=map%28%29</link>
      <pubDate>Sun, 08 Aug 2021 20:07:31 +0000</pubDate>
         <description>Tagged with map() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedmap%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <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>Descending curve function?</title>
      <link>https://forum.processing.org/two/discussion/24193/descending-curve-function</link>
      <pubDate>Thu, 21 Sep 2017 00:15:13 +0000</pubDate>
      <dc:creator>darinb</dc:creator>
      <guid isPermaLink="false">24193@/two/discussions</guid>
      <description><![CDATA[<p>My math skills have faded with my hair color, I'm afraid. I need a function that produces a downward curve. For example, I will send it integers from 255-0. This is for a fading effect, the numbers are transparency values. I want it to fade quickly at first then to fade more slowly as it gets closer to zero. Ideally I'd like some control over the steepness (or "curviness") of the curve.</p>

<p>Suggestions? :)</p>

<p>--Darin</p>
]]></description>
   </item>
   <item>
      <title>How to sincronize the audio in a way that fade out the image?</title>
      <link>https://forum.processing.org/two/discussion/23399/how-to-sincronize-the-audio-in-a-way-that-fade-out-the-image</link>
      <pubDate>Tue, 11 Jul 2017 00:26:50 +0000</pubDate>
      <dc:creator>valent_000</dc:creator>
      <guid isPermaLink="false">23399@/two/discussions</guid>
      <description><![CDATA[<p>hi everyone! Im new using processing, and i find myself stuck with this doubt, im looking for something that helps me to sincronize the audio and the image and fade out the image, all of that part is in the keyPressed part, i hope i make myself clear</p>

<pre><code>import ddf.minim.*;

PImage img1, img2;
int trans ;
int vol = 1;
float transparency = 255;
AudioPlayer latido;
AudioPlayer pip;
Minim minim;


void setup() {

  size(500, 500);
  background(0);
  trans = 255;
  vol = 1;
  pipi = 3;
  img1 = loadImage("cora.jpg");
  minim = new Minim(this);
  pip = minim.loadFile("pip.mp3");
  latido = minim.loadFile("latido.mp3");
  // the audio "latido" in loop
  latido.loop();
}

void draw() {
  //i combine the audio with the transparency of the image
  int vol = int(latido.mix.level()*500);
  println(vol);
  int trans = int(map(vol,-100,200,80,200));
  tint(trans,100);
  image(img1, -30, -300); 

  if (transparency &gt; 0) { transparency -= 10; }
  tint(0, transparency);
  image(img1, -30, -300);
}
_
**        void keyPressed(){
          //when you press any key the audio "latido" stop, and another audio(pip) starts and the image fade out with tthe last audio(here is my doubt)

          latido.pause();

          pip.setGain(-15);
          pip.play();
          pip.loop();

        }**_
</code></pre>
]]></description>
   </item>
   <item>
      <title>map() values from an array for a sine wave</title>
      <link>https://forum.processing.org/two/discussion/23377/map-values-from-an-array-for-a-sine-wave</link>
      <pubDate>Sun, 09 Jul 2017 16:34:49 +0000</pubDate>
      <dc:creator>Nuss</dc:creator>
      <guid isPermaLink="false">23377@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone,</p>

<p>the following code I draw a sine wave.</p>

<pre><code>    float xValue;
    float yValue[];
    float yScale[];


    void setup() {
      size(800, 400);
      background(0);
      noLoop();
      yValue = new float[width];
      yScale = new float[height];
      for (int i=0; i&lt;width; i++) {
        xValue = map(i, width,0, 0, 4*PI);
        yValue[i] = sin(xValue)*height/2+height/2;       //&lt;-- Currently I help myself by multiplication with height/2.
        //yScale[i] = map(yValue[i],199,201,0,height);  // &lt;-- I wanna use map() for rescaling the y values but There is always an error
      }
    }

    void draw() {
      background(0);
      stroke(255);
      strokeWeight(2);
      for (int i=0; i&lt;799; i++) { //&lt;-- The same problem here. Whenever I set the width as limit.
        line(i, yValue[i], i+1, yValue[i+1]);
        println("yValue:"+yValue[i]);
      }
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>How Does Mapping Function work?</title>
      <link>https://forum.processing.org/two/discussion/22471/how-does-mapping-function-work</link>
      <pubDate>Mon, 08 May 2017 20:33:53 +0000</pubDate>
      <dc:creator>p2b2</dc:creator>
      <guid isPermaLink="false">22471@/two/discussions</guid>
      <description><![CDATA[<p>Namaste all,</p>

<p>I wanted to know how does the map(); function actually works.</p>

<p>I did come across that for "variable2 = map(variable1, min1, max1, min2, max2);" we apply the formula "variable2 = min2+(max2-min2)*((variable1-min1)/(max1-min1))".</p>

<p>But how did we come to this?And does processing sole this by using matrices? If yes then how</p>

<p>Thanks a lot.</p>

<hr />
]]></description>
   </item>
   <item>
      <title>How to "project" or "map" 2D shapes or images on 3D terrain</title>
      <link>https://forum.processing.org/two/discussion/23133/how-to-project-or-map-2d-shapes-or-images-on-3d-terrain</link>
      <pubDate>Mon, 19 Jun 2017 14:30:16 +0000</pubDate>
      <dc:creator>datatrash</dc:creator>
      <guid isPermaLink="false">23133@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>a while ago I followed this Coding Challenge video by Daniel Shiffman to create a moving 3D terrain:</p>

<p><span class="VideoWrap"><span class="Video YouTube" id="youtube-IKB1hWWedMk"><span class="VideoPreview"><a href="http://youtube.com/watch?v=IKB1hWWedMk"><img src="http://img.youtube.com/vi/IKB1hWWedMk/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span></p>

<p>I now want to map a 2D shape onto the terrain. 
Unfortunately I am a complete noob to programming and have no idea how to do this so I would really appreciate some help.</p>

<p>Can someone please point me in the right direction? :)</p>

<p>Many thanks and best regards!</p>
]]></description>
   </item>
   <item>
      <title>NaN Problem</title>
      <link>https://forum.processing.org/two/discussion/22463/nan-problem</link>
      <pubDate>Mon, 08 May 2017 16:03:05 +0000</pubDate>
      <dc:creator>Bobba93</dc:creator>
      <guid isPermaLink="false">22463@/two/discussions</guid>
      <description><![CDATA[<p>Hey, I'm trying to make a data visualization with a dataset about central power stations, that I put here, but when I try to visualize there are few power station "ball". When I try to understand the problem with Println(longitude), it tells me "map(NaN, -180, 180, 0, 1000) called, which returns NaN (not a number)". I think that the code is right, and I don't understand the problem with the .csv. Thank You!</p>

<p><a href="https://docs.google.com/spreadsheets/d/1B6ezcmjntEI-nI6_miO6UQaOU78ZXnDep-qtyVUWmJ4/edit?usp=sharing" target="_blank" rel="nofollow">https://docs.google.com/spreadsheets/d/1B6ezcmjntEI-nI6_miO6UQaOU78ZXnDep-qtyVUWmJ4/edit?usp=sharing</a></p>

<pre><code>PImage mappa; 
Table dati;

void setup(){
  size(1000, 500); 
  mappa= loadImage("world.png"); 
  dati= loadTable("energydata.csv", "header"); 
}

void draw(){
image(mappa, 0, 0, width, height);


 for( int riga=0; riga &lt; dati.getRowCount(); riga++){
float lat= dati.getFloat(riga,0); 
float lon= dati.getFloat(riga,1); 
/*String nome = dati.getString(riga,2);
String stato = dati.getString(riga,3);
float potenza= dati.getFloat(riga,4);
String tipo= dati.getString(riga,5);


float la=map(lat, 90, -90, 0, height);
float lo=map(lon, -180,180,0,width);
println(lon);

fill(#4AF2A1,80);
noStroke();
ellipse(lo,la,10,10);

noLoop();  }}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Project Clock Help!</title>
      <link>https://forum.processing.org/two/discussion/22284/project-clock-help</link>
      <pubDate>Sat, 29 Apr 2017 13:30:12 +0000</pubDate>
      <dc:creator>prolly02</dc:creator>
      <guid isPermaLink="false">22284@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys! I need help on my clock project. Why is the hour hand not moving? Help!</p>

<pre><code>void setup() 
    {
      size(200, 200);
      stroke(255);

    }
    void draw()
    {
      background(34, 40, 20);
      fill(255, 255, 255);
      ellipse(width/2, height/2, width, height);

      pushMatrix();
      translate(width/2, height/2);
      rotate(radians(map(second(),0, 60, 0, 360)));
      fill(255, second()*2, second()*2);
      noStroke();
      rect(0, -50, 10, 10);
      popMatrix();

     pushMatrix();
     translate(width/2, height/2);
     rotate(radians(minute()*6));
     stroke(0);
     line(0, 0, 0, -50);
     popMatrix();

     pushMatrix();
     translate(width/2, height/2);
     rotate(radians(hour()*5));
     stroke(0);
     line(0, 0, 0, -50);
     popMatrix();
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>In Shaders, how to avoid 'scrubbing' effect</title>
      <link>https://forum.processing.org/two/discussion/21149/in-shaders-how-to-avoid-scrubbing-effect</link>
      <pubDate>Sat, 04 Mar 2017 16:10:45 +0000</pubDate>
      <dc:creator>aarondbaron</dc:creator>
      <guid isPermaLink="false">21149@/two/discussions</guid>
      <description><![CDATA[<p>In the penrose tile example for the shader (InfiniteTiles), one can see that there is a value</p>

<pre><code>tileShader.set("time", millis() / 1000.0);
</code></pre>

<p>If I try to modify this so that the tile will move at a speed according to my mouse,</p>

<pre><code>float t =millis() / 1000.0; 
float pctX = map (mouseX, 0, width, 0, 1);
tileShader.set("time", t*pctX);
</code></pre>

<p>the shader will do this 'scrubbing' effect where the entire image moves very quickly, but then once you stop moving the mouse, it will go at the speed you want.  Is there any way to avoid this scrubbing effect?  What I'm trying to accomplish are smooth increases in speed of the tile movement.</p>
]]></description>
   </item>
   <item>
      <title>Brand new to P5, relatively new to JS in general (earthquake data)</title>
      <link>https://forum.processing.org/two/discussion/22118/brand-new-to-p5-relatively-new-to-js-in-general-earthquake-data</link>
      <pubDate>Fri, 21 Apr 2017 04:08:01 +0000</pubDate>
      <dc:creator>spkellydev</dc:creator>
      <guid isPermaLink="false">22118@/two/discussions</guid>
      <description><![CDATA[<p>Hey P5 board;</p>

<p>I've been learning javascript over the last couple of months, teaching myself. I'm trying to expand how I think about javascript and learn how to interact with data. That led me to Schiffman's youtube videos and here I am!</p>

<p>Anyway, I'm hoping someone could help me figure out how to <strong>sort USGS earthquake data by time using a slider</strong>. Here's my<a rel="nofollow" href="https://gist.github.com/spkellydev/e65f95b414fda1abd82f67e5a1ddf625"> Gist of the code</a>, but below I'll include where I'm finding problems.</p>

<p>I can't figure out how to map the timestamps to something usable on the slider. Any help is welcome!</p>

<p>For starters, I'm not sure if I'm even mapping my slider correctly. Here's the** time function**:</p>

<pre><code>function timeSlider(min, max) {

    //ms
    //slider = createSlider(minMS, currentTime, maxMS);
    //day in ms
    min = 86400000;
    //30 days in ms
    max = min * 30;
    //get 30 days ago timestamp
    min = currentTime - max;

    max = currentTime;
    //map slider from 1 day in ms to 30 days in ms
    var sliderMinMS = map(minMS, 0, min, 0, currentTime);
    var sliderMaxMS = map(maxMS, 0, (max - min), 0, currentTime);
    return sliderMinMS, sliderMaxMS;
}
</code></pre>

<p>Here's the setup function:</p>

<pre><code>function setup() {
    createCanvas(1024, 512);
    translate(width / 2, height / 2);
    imageMode(CENTER);
    image(mapImg, 0, 0);

    timeSlider(minMS, maxMS);

    slider = createSlider(minMS, currentTime, maxMS);
    slider.size(900);
    slider.position(20, 450);

}
</code></pre>

<p>here's the draw function (is this the most efficient way to display the data?):</p>

<pre><code>function draw() {
    var cx = webMerX(clon);
    var cy = webMerY(clat);


    for (var i = 1; i &lt; earthquakes.length; i++) {
        data = earthquakes[i].split(/,/);

        date[i] = data[0];
        //convert quake time to ms
        var timeQuake = [];
        timeQuake = date[i].getTime();

        var lat = data[1];
        var lon = data[2];

        var mag = data[4];

        var x = webMerX(lon) - cx;
        var y = webMerY(lat) - cy;

        mag = sqrt(pow(10, mag));
        var magMax = sqrt(pow(10,10));

        var d = map(mag, 0, magMax, 0, 500);

        if(timeQuake[i] &lt;= slider.value()) {

            fill(255, 130, 100);
            stroke(255);
            ellipse(x, y, d, d);
        }
    }

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>change between colors over time</title>
      <link>https://forum.processing.org/two/discussion/20861/change-between-colors-over-time</link>
      <pubDate>Sat, 18 Feb 2017 13:05:02 +0000</pubDate>
      <dc:creator>mHoneycomb</dc:creator>
      <guid isPermaLink="false">20861@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to fade a fill, back and forth between two colors or cycle through three colors.
I was able to fade from one color to the next, but I don't know how to make it go back or cycle through three colors.</p>

<pre><code>float easing = 0.01;
float xRed = 62, xGreen = 20, xBlue = 173;
float yRed = 207, yGreen = 1, yBlue = 106;
float rDiff, gDiff, bDiff, avgDiff;

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

void draw() {
  background(0);

  rDiff = dist(0, xRed, 0, yRed);
  gDiff = dist(0, xGreen, 0, yGreen);
  bDiff = dist(0, xBlue, 0, yBlue);
  avgDiff = (rDiff + gDiff + bDiff) / 3;

  if(avgDiff &gt; 1) {
  xRed += (yRed - xRed) * easing;
  xGreen += (yGreen - xGreen) * easing;
  xBlue += (yBlue - xBlue) * easing;

  fill(xRed, xGreen, xBlue);      
  ellipse(width/2, height/2, 300, 300);
  }

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Converting a CSV data into a sound track?</title>
      <link>https://forum.processing.org/two/discussion/21090/converting-a-csv-data-into-a-sound-track</link>
      <pubDate>Wed, 01 Mar 2017 22:46:07 +0000</pubDate>
      <dc:creator>abeythomas</dc:creator>
      <guid isPermaLink="false">21090@/two/discussions</guid>
      <description><![CDATA[<p>Hello!</p>

<p>I'm trying convert a long CSV data into a sound track and I wrote this code, but I'm not able to generate a sound. 
It's just a beep.</p>

<p>It's CSV on meteor spotting and I got the values for longitude and latitude and I tried to map it down for tri values.</p>

<p>Please help me as I'm pretty new to Processing :)</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/076/OR7MPH6ZDQOK.png" alt="Screen Shot 2017-03-01 at 11.39.42 PM" title="Screen Shot 2017-03-01 at 11.39.42 PM" /></p>
]]></description>
   </item>
   <item>
      <title>3d and 2d coordinates</title>
      <link>https://forum.processing.org/two/discussion/20186/3d-and-2d-coordinates</link>
      <pubDate>Wed, 11 Jan 2017 02:34:41 +0000</pubDate>
      <dc:creator>djevazi</dc:creator>
      <guid isPermaLink="false">20186@/two/discussions</guid>
      <description><![CDATA[<p><img src="https://forum.processing.org/two/uploads/imageupload/156/EOCEA50VM4PL.jpg" alt="coords" title="coords" /></p>

<p>In 3d sketches null of coordinares begins here (green number "1"), how to make it begin there (green number "2"), like in 2d sketches? I realize that mouseX and mouseY not working properly because beginning of coordinates is not in the upper left corner.</p>
]]></description>
   </item>
   <item>
      <title>Exponential map() function?</title>
      <link>https://forum.processing.org/two/discussion/18417/exponential-map-function</link>
      <pubDate>Wed, 05 Oct 2016 13:28:24 +0000</pubDate>
      <dc:creator>hristod</dc:creator>
      <guid isPermaLink="false">18417@/two/discussions</guid>
      <description><![CDATA[<p>Is it possible to create a mapping of values that outputs a logarithmic (exponential) value instead of linear? I need to program something similar as a knob or slider, controlling a filter cutoff frequency... (that's exactly what I need it for :)</p>

<p>Cheers,
H.</p>
]]></description>
   </item>
   <item>
      <title>Problem with "translating" from processing to p5.js</title>
      <link>https://forum.processing.org/two/discussion/17903/problem-with-translating-from-processing-to-p5-js</link>
      <pubDate>Fri, 19 Aug 2016 08:03:33 +0000</pubDate>
      <dc:creator>torekndsen</dc:creator>
      <guid isPermaLink="false">17903@/two/discussions</guid>
      <description><![CDATA[<p>Hello guys, I need some help to get started with the p5.js libriary</p>

<p>The following code will display the clock, and color the text, using the current clock(ss/mm/hh) as a hex value. I first wrote the code in processing where it works. Now I want to execute it as p5 however, after changing the syntax to fit the p5 language, it dosen't work. I can't figure out why, tho I suspect the "var" instead of "string" to be an possible issue?</p>

<p>Can you guys explain why it dosen't work?</p>

<p>p5.js code:</p>

<pre><code>var s,m,h; 
function setup() {
  createCanvas(800,600);

}

function draw() {
 s = second();
 m = minute();
 h = hour(); 

background(30);
var s_ = nf(s,2);
var m_ = nf(m,2);
var h_ = nf(h,2);

var hex_ =  "FF" + s_+ m_+ h_;
var c = unhex(hex_);

fill(c);
textSize(30);
text("#",width/2-70,height/2); 
text(s_,width/2-40,height/2); 
text(m_,width/2,height/2); 
text(h_,width/2+40,height/2); 
}
</code></pre>

<p>Same programme, just written in processing and WORKS:</p>

<pre><code>int s, m, h; 

void setup(){
  size(800,600);   
}

void draw(){
 s = second(); 
 m = minute();
 h = hour(); 

background(200);
String s_ = nf(s,2);
String m_ = nf(m,2);
String h_ = nf(h,2);

String hex_ =  "FF" + s_+ m_+ h_;
int c = unhex(hex_);


fill(c);
textSize(30);
text("#",width/2-70,height/2); 
text(s_,width/2-40,height/2); 
text(m_,width/2,height/2); 
text(h_,width/2+40,height/2); 
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>map() Command with different intervals</title>
      <link>https://forum.processing.org/two/discussion/17706/map-command-with-different-intervals</link>
      <pubDate>Sun, 31 Jul 2016 16:24:11 +0000</pubDate>
      <dc:creator>omerpekin</dc:creator>
      <guid isPermaLink="false">17706@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>according to my understanding from the reference page of processing and also experimenting a bit, both lerp() and map() commands work always linearly.</p>

<p>What I mean about that is if I m mapping numbers between 1 and 100 to 1-2; 50 will be always 1.5</p>

<p>Is there a way -- rather a simple way to modify map() command so that is does not map numbers linearly but lets say with a hyperbolic curve?</p>

<p>Once you map values in grasshopper with a graph-mapper it lets you modify the curve. My aim is to understand and also use the map() command to generate different mapping methods.</p>

<p>If anyone did or knows how to edit the map() function like this, I would appreciate the help.</p>

<p>Best, 
Omer</p>
]]></description>
   </item>
   <item>
      <title>mapping error - arduino, very basic</title>
      <link>https://forum.processing.org/two/discussion/12274/mapping-error-arduino-very-basic</link>
      <pubDate>Thu, 27 Aug 2015 19:40:12 +0000</pubDate>
      <dc:creator>frawgpaw</dc:creator>
      <guid isPermaLink="false">12274@/two/discussions</guid>
      <description><![CDATA[<p>Hey yall - firstly thanks for any help.</p>

<p>I am trying to run the very basic "graph" tutorial off of an arduino. (<a href="https://www.arduino.cc/en/Tutorial/Graph" target="_blank" rel="nofollow">https://www.arduino.cc/en/Tutorial/Graph</a>). I have a simple circuit with a potentiometer.</p>

<p>When I run this processing code, I get the following error:</p>

<p>map(NaN, 0, 1023, 0, 300) called, which returns NaN (not a number)</p>

<p>Weird. But if I type "println(inByte)" after my map line, the console shows me changing potentiometer values just fine. No error. Also, I should say the pop-out window which is supposed to graph my moving values is black, and never shows any sort of graph. Thanks again for all your help -</p>
]]></description>
   </item>
   <item>
      <title>How ti invert grayscale (0-255) in this code ?</title>
      <link>https://forum.processing.org/two/discussion/17497/how-ti-invert-grayscale-0-255-in-this-code</link>
      <pubDate>Tue, 12 Jul 2016 11:50:03 +0000</pubDate>
      <dc:creator>Josip</dc:creator>
      <guid isPermaLink="false">17497@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone ! I have a LIDAR lite v2 and i used it to measure distances , i mount him on 2 servo motors wich rotates in Y and X and lidar scanning distance in that time. Now i have this program which communicate with arduino and creating point cloud from degrees of X servo degrees of Y servo and distances in cm .</p>

<p>Now the question is why a get small picture whatever i put in size() i get the same small picture and with this program DARKER the pixel is closer the object is. AND NOW the main question is how to invert grayscale , cause i want darker pixel farther.</p>

<p>Sorry for so many words and thank u.</p>

<p>This is the code in processing.</p>

<pre><code>import processing.serial.*;

float pcolor = 0; // point color value
float xVal = 0;  // x value
float yVal = 0;  // y value

Serial myPort;

void setup() {

  size(400,200);

  printArray(Serial.list()); 

  myPort = new Serial(this, Serial.list()[0], 57600);

  myPort.bufferUntil('\n');   
  background(0);
}

void draw() {
  stroke(pcolor);    
  point(xVal,yVal);
}

void serialEvent(Serial myPort) {

  String inString = myPort.readStringUntil('\n');  

  if (inString !=null) {
    inString = trim(inString);    

    float[] colors = float(split(inString, ","));    

    if (colors.length &gt;=3) {       
      xVal = colors[0];          
      yVal = colors[1];
      pcolor = map(colors[2], 0, 400, 0,255);
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>map() function</title>
      <link>https://forum.processing.org/two/discussion/17301/map-function</link>
      <pubDate>Sat, 25 Jun 2016 13:20:35 +0000</pubDate>
      <dc:creator>Emmos</dc:creator>
      <guid isPermaLink="false">17301@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I am trying to figure out how this map() function works... but I just don't get it.
Maybe you guys can help me out..</p>

<p>For example:</p>

<pre><code>float a;

void setup(){
  size(300, 300);
}

void draw(){
  a= 50;
  a=map(a, -100, 100, 0, 2000);
}
</code></pre>

<p>How big wil "A" be after the mapping and why?</p>
]]></description>
   </item>
   <item>
      <title>coordinates Data to pixels</title>
      <link>https://forum.processing.org/two/discussion/17038/coordinates-data-to-pixels</link>
      <pubDate>Wed, 08 Jun 2016 09:18:54 +0000</pubDate>
      <dc:creator>uness</dc:creator>
      <guid isPermaLink="false">17038@/two/discussions</guid>
      <description><![CDATA[<p>I try to get the longitude and latitude of the earth quack on the <a rel="nofollow" href="https://en.wikipedia.org/wiki/Iceland#/media/File:Map_of_Iceland.svg">map </a>but i get a weird values, can someone help me figure out what i'm doing wrong?</p>

<p>I get the following values, which are outside my canvas:</p>

<p>Example of the Json data:</p>
]]></description>
   </item>
   <item>
      <title>get actual width of scaled shape??</title>
      <link>https://forum.processing.org/two/discussion/16881/get-actual-width-of-scaled-shape</link>
      <pubDate>Sun, 29 May 2016 20:14:21 +0000</pubDate>
      <dc:creator>FFD8</dc:creator>
      <guid isPermaLink="false">16881@/two/discussions</guid>
      <description><![CDATA[<p>I'm building a small set of functions that mirror primitive shapes (rect, ellipse, line), however normalize their pixel values for sending via OSC to openFrameworks. I've set this up, so that one just puts an 'x' in front of the existing shape. Everything is going great and screenX, screenY are my best friends in making this possible.. but I'm running into strange bugs if using scale() before drawing one of these shapes... the x,y coords get corrected, but not my width/height. 
a sample from basic setup looks like this:</p>

<p><code>pushMatrix(); // only adjusts translate/scale within matrix
  translate(width/2, height/2); // suggestion to draw from center out 
  scale(.65);
  xrect(0,0,250,250);
  popMatrix();</code></p>

<p><code>void xrect(float x1, float y1, float w1, float h1) {
  rect(x1, y1, w1, h1);
  String shape = "rect";
  float x1out = map(screenX(x1, y1), 0, width, 0, 1);
  float y1out = map(screenY(x1, y1), 0, height, 0, 1);
  float w1out = map(w1, 0, width, 0, 1);
  float h1out = map(h1, 0, height, 0, 1);
  // .. OSC message w/ these values sent after this
}</code></p>

<p>perhaps i should just be grabbing the screenX of (x1+w1) to know where that xpoint is then check the distance between those points? Wondering if there's a better way to check for transformations and know if anything's being scaled.</p>
]]></description>
   </item>
   <item>
      <title>Scaling Data Points to Window</title>
      <link>https://forum.processing.org/two/discussion/16850/scaling-data-points-to-window</link>
      <pubDate>Fri, 27 May 2016 13:50:50 +0000</pubDate>
      <dc:creator>dailyinvention</dc:creator>
      <guid isPermaLink="false">16850@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I am currently trying to figure out the best way to tackle this and if you have any suggestions it would be most appreciated.  I have an array of JSON objects retturned from an HTTP request that contain numerical values.  These values can range from 100 to 100,000,000.  Do you know of possible ways of scaling these particular values as points to a window?  Would I have to get the highest possible value first to map it to the pixels of the window or are there other options?  How would this be accomplished?</p>

<p>Thanks in advance for any help.</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>im trying to map the screen size of a video, what am i missing?</title>
      <link>https://forum.processing.org/two/discussion/15248/im-trying-to-map-the-screen-size-of-a-video-what-am-i-missing</link>
      <pubDate>Wed, 02 Mar 2016 17:00:52 +0000</pubDate>
      <dc:creator>Jai</dc:creator>
      <guid isPermaLink="false">15248@/two/discussions</guid>
      <description><![CDATA[<pre><code>int x = 0;
int y = 0;
int valx;
int valy;

void setup() {
  size(200, 200);
  background(0);

}

void draw() {
valx = map(x, 0, 195, 0, 80);
valy = map(y, 0, 195, 0, 80);

  println("X" + " ", mouseX, "                          Y" + " ", mouseY);
}
</code></pre>

<p>i even try this and nothing</p>

<pre><code>valx = map(x, mouseX, mouseX, 0, 80);
valy = map(y, mouseY, mouseY, 0, 80); 
</code></pre>
]]></description>
   </item>
   <item>
      <title>New to processing!</title>
      <link>https://forum.processing.org/two/discussion/14477/new-to-processing</link>
      <pubDate>Fri, 15 Jan 2016 17:39:31 +0000</pubDate>
      <dc:creator>Euzhan</dc:creator>
      <guid isPermaLink="false">14477@/two/discussions</guid>
      <description><![CDATA[<p>New to processing! I constructed this code that imprints a square that moves every second and fills the screen as time goes on. I need the squares/screen to refresh every hour. Help!</p>

<p>void setup(){</p>

<p>size(590, 590);
  background (20);
}</p>

<p>void draw(){</p>

<p>int x = 10;</p>

<p>float s = map(second(),0,59,0,(width-x));
  float m = map(minute(),0,59,0,(height-x));</p>

<p>noStroke();
  rect(s, m, 10, 10);
}</p>
]]></description>
   </item>
   <item>
      <title>scrolling in a movie through mouseX</title>
      <link>https://forum.processing.org/two/discussion/13599/scrolling-in-a-movie-through-mousex</link>
      <pubDate>Sun, 22 Nov 2015 13:59:12 +0000</pubDate>
      <dc:creator>Tilia</dc:creator>
      <guid isPermaLink="false">13599@/two/discussions</guid>
      <description><![CDATA[<p>Hi people,</p>

<p>im very new to this and im quite sure it should be very easy to do this but i don't know how.
i want to load a video in processing an control the displaying of the frames of the video through the mouseX position.</p>

<p>that is my code:</p>

<pre><code>import processing.video.*;
Movie myMovie;

void setup() {
  frameRate(30);
  size(1244, 700);
  myMovie = new Movie(this, "Komp 1.mov");
  myMovie.play();    
}

void movieEvent(Movie myMovie) {
  myMovie.read();
}

void draw() {
  image(myMovie, 0,0);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>represent intersection of 2 circles</title>
      <link>https://forum.processing.org/two/discussion/13590/represent-intersection-of-2-circles</link>
      <pubDate>Sat, 21 Nov 2015 16:09:47 +0000</pubDate>
      <dc:creator>mxloizix</dc:creator>
      <guid isPermaLink="false">13590@/two/discussions</guid>
      <description><![CDATA[<p>Hi, this are my data<br />
name, value<br />
hal,500<br />
wos,1400<br />
interHalWos,300</p>

<p>I would like to represent <em>interHalWos</em>, the intersection between the two variable <em>wos</em> and <em>hal</em>, like on the image beside :</p>

<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Venn_A_intersect_B.svg/170px-Venn_A_intersect_B.svg.png" alt="" /></p>

<p>I have done this code below. But it doesnt work. in fact it seems to be more complex, because we might have to calc the coordinate of the two points at the intersection of the circles, and so to deal with area, whereas below I work with line ...</p>

<p>any suggestion ?</p>

<pre><code>Table myData;
float wos, hal, scopus;
float rA, rB, rC ;
float interHalWos, interHalScopus, interScopusWos;
float ax, ay, bx, by;

void setup() {
  myData = loadTable("data.csv", "header, tsv");
  size(400, 400);
  background(100);

  purcentCalcul();

  ax = width/2; 
  ay = height/2 ;
  strokeWeight(1);stroke(255);point(ax,ay);

  rA = map(hal, 0, 100, 0, width/4);
  rB = map(wos, 0, 100, 0, width/4);

  bx = ax + map(100-hal,0,100,0,rA+rB);
  println(bx);
  by = ay;

  circle("hal", ax,ay, color(0, 255, 0), rA);
  circle("wos", bx,by, color(255, 0, 0), rB);

}

void purcentCalcul() {
  TableRow findTotal = myData.findRow("total", "name");
  TableRow findWos = myData.findRow("wos", "name");
  TableRow findHal = myData.findRow("hal", "name");
  TableRow findInterhw = myData.findRow("interHalWos", "name");
  float sumHalWos = findWos.getInt("value") + findHal.getInt("value") - findInterhw.getInt("value");  
  wos = findWos.getInt("value") * 100 / sumHalWos;
  hal = findHal.getInt("value") * 100 / sumHalWos;
  interHalWos = findInterhw.getInt("value") * 100 /sumHalWos; 

  println("wos % : "+ wos +" hal % : "+hal+" inter % : "+interHalWos);
}

void circle(String name, float x, float y, color couleur, float radius) {
  noFill();
  stroke(couleur);
  strokeWeight(3);
  ellipse(x, y, 2*radius, 2*radius);
  textAlign(CENTER);
  fill(couleur);
  text(name, x, y-radius-10);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>noise walking line back and forth</title>
      <link>https://forum.processing.org/two/discussion/13260/noise-walking-line-back-and-forth</link>
      <pubDate>Sun, 25 Oct 2015 22:16:56 +0000</pubDate>
      <dc:creator>nnnoooaahhh</dc:creator>
      <guid isPermaLink="false">13260@/two/discussions</guid>
      <description><![CDATA[<p>trying to turn this circle into a line (point) that will walk back and forth across the screen.
This is where I'm at, knowing it's way off in a strange direction. Please help.</p>

<pre><code>color bgColor = color(0); // black
color drawColor = color(255, 255, 255, 255); // white
float t = 0;
float n = noise(t);
float x = map (n, 0,1,0,width);
float y = map (n, 0,1,0,height);

void setup() {
  size(900, 650);
  background(bgColor);
}

void draw () {

  ellipse (x, 31,14,14);

  t += 0.01;
}

  class Walker {
    float x,y;

    float tx,ty;

    Walker() {
      tx = 0;
      ty = 10000;
    }

    void step() {
      x = map(noise(tx), 0, 1, 0, width);
      y = map(noise(tx), 0, 1, 0, height);

      tx += 0.01;
      ty += 0.01;
    }
  }
</code></pre>
]]></description>
   </item>
   <item>
      <title>How do I get my bar graph to fit in the window?</title>
      <link>https://forum.processing.org/two/discussion/13317/how-do-i-get-my-bar-graph-to-fit-in-the-window</link>
      <pubDate>Thu, 29 Oct 2015 18:50:04 +0000</pubDate>
      <dc:creator>pierreb</dc:creator>
      <guid isPermaLink="false">13317@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to make a bar graph and my data has a very high range. I have 51 data points ranging in numbers from 40,000-75,000. Right now I believe the graph is starting at 0 so obviously it is impossible to see the tops of the bars. I'm not exactly sure how to phrase this, but is it possible to scale down the graph in a way that it fits in the view of the window?</p>

<pre><code>int[] data;

void setup() {
size(900,900);
String[] text = loadStrings("averages.txt");
println(text);
data = int(split(text[0], ","));
}

void draw() {
background(255);
fill(0);
stroke(255);

for(int i = 0; i &lt; data.length; i++) {
int multiplier = 2;
float rectWidth = width / data.length;
float ypos = height - (data[i] * multiplier);
rect((rectWidth * i), ypos, rectWidth, (data[i] * multiplier));
}
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Why does using `color` have such bad performance</title>
      <link>https://forum.processing.org/two/discussion/13114/why-does-using-color-have-such-bad-performance</link>
      <pubDate>Mon, 19 Oct 2015 13:31:29 +0000</pubDate>
      <dc:creator>nlooije</dc:creator>
      <guid isPermaLink="false">13114@/two/discussions</guid>
      <description><![CDATA[<p>I am using the following piece of code to set the color of each pixel:</p>

<p><code>colorMode(RGB,1);
 for (var x = 0; x &lt; nX; x++) {
     for (var y = 0; y &lt; nY; y++) {
       var id = getIdx(x,y);
       var v = vArray[id]; //range=[0,1]
       var c = color(v, 0, 1-v);
       set(x, y, c);
   }
 }
 updatePixels();</code></p>

<p>It is very straightforward; i get a value from an array <code>vArray</code> which is in the range <code>[0,1]</code>. A color <code>c</code> is is calculated using <code>color()</code> and pixel <code>[x,y]</code> is set to <code>c</code>.
Unfortunately, this has very bad performance compared to the rest of my code; <code>color()</code> takes approximately 60% of the CPU time. It is a huge bottleneck compared to the rest of the code which should be the bottleneck considering it is doing heavy work. If i move <code>color()</code> out of the loop  the code runs efficiently again.</p>

<p>Does anyone know why <code>color()</code> is so inefficient? How can I avoid this inefficiency, either by modifying the use of <code>color()</code> or perhaps by setting the pixel color in some other way?</p>
]]></description>
   </item>
   </channel>
</rss>