<?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 tochararray() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=tochararray%28%29</link>
      <pubDate>Sun, 08 Aug 2021 19:20:04 +0000</pubDate>
         <description>Tagged with tochararray() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedtochararray%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Int(str), where str is a single-digit number, gives the utf char code instead of the number as int</title>
      <link>https://forum.processing.org/two/discussion/26850/int-str-where-str-is-a-single-digit-number-gives-the-utf-char-code-instead-of-the-number-as-int</link>
      <pubDate>Wed, 14 Mar 2018 21:08:41 +0000</pubDate>
      <dc:creator>samuset</dc:creator>
      <guid isPermaLink="false">26850@/two/discussions</guid>
      <description><![CDATA[<pre><code>String pi = "31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170";

int x;

void draw () {
  for (int i = 0; i &lt; pi.length(); i++) {
    x = int(pi.charAt(i));
    println(x);
  }
}
</code></pre>

<p>And this prints numbers around 48-58 as x in the log. I'm dumbfounded as to why it wouldn't give me the right characters from the String pi. Thank you for your help in advance.</p>

<p>Edit: I realized the <code>int(pi.charAt(i))</code> is not working, as this results in the utf-8 character code of the given number from 0 to 9, which are 48-57. Of course, I can work around this, but would still be best to see how this should be done properly.</p>
]]></description>
   </item>
   <item>
      <title>How to link a letter of a string to a shape?</title>
      <link>https://forum.processing.org/two/discussion/24389/how-to-link-a-letter-of-a-string-to-a-shape</link>
      <pubDate>Thu, 05 Oct 2017 00:16:31 +0000</pubDate>
      <dc:creator>rolomogno</dc:creator>
      <guid isPermaLink="false">24389@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
I would like to link the letters of a string to some shapes, for example:</p>

<p>link letter "a" to an ellipse
link letter "b" to a rectangle
link letter "c" to a triangle</p>

<p>so if the string is "abc" I will have "ellipse, rect and triangle" on the screen;
so if the string is "bca" I will have "rectangle, triangle and ellipse" on the screen;
so if the string is "cab" I will have "triangle, ellipse and rectangle" on the screen;
... and so on.</p>

<p>Could you help me?</p>

<p>Thank you very much.</p>
]]></description>
   </item>
   <item>
      <title>retrieving elements from a list randomly</title>
      <link>https://forum.processing.org/two/discussion/20529/retrieving-elements-from-a-list-randomly</link>
      <pubDate>Sun, 29 Jan 2017 10:09:40 +0000</pubDate>
      <dc:creator>Chrisir</dc:creator>
      <guid isPermaLink="false">20529@/two/discussions</guid>
      <description><![CDATA[<p>hello all,</p>

<p>obviously an old problem. It occurs in different forms.</p>

<p>E.g. in a scrabble game we have to hand out letters to the players. But they are not distributed evenly over the Alphabet, so there are not as many Qs than Es in the game (reflecting the distribution of letters in normal English texts).</p>

<p>Let's therefore assume, I make a char array, where this distribution is reflected, so it's</p>

<p><code>EEEEEEEEEQAAAAAAMMOO</code> or so.</p>

<p>Now retrieving elements from this list randomly:</p>

<p>When I retrieved a letter I can't retrieve it again. I can replace it with a character that is a stop sign like #.</p>

<p><code>EEEEE#EEEQAAAAAAMMOO</code></p>

<p>But then when retrieving a letter later in the game, most slots hold #-signs.</p>

<p><code>##E################O#</code></p>

<p>So a typical random like</p>

<p><code>randomNumberIndex = int(random(listOfLetters.length()));</code> would most times fail, so I would have to repeat it until hitting a letter. Bad.</p>

<p>But what is the most efficient way of solving this? An ArrayList and then shorten the ArrayList ?</p>

<p>Thanks!</p>

<p>Best, Chrisir   ;-)</p>
]]></description>
   </item>
   <item>
      <title>Is it really not possible to determine the precise height of a text?</title>
      <link>https://forum.processing.org/two/discussion/19869/is-it-really-not-possible-to-determine-the-precise-height-of-a-text</link>
      <pubDate>Wed, 21 Dec 2016 14:43:20 +0000</pubDate>
      <dc:creator>Patakk</dc:creator>
      <guid isPermaLink="false">19869@/two/discussions</guid>
      <description><![CDATA[<p>I want to be able to draw the exact bounding box of a text. The width is not a problem, I can use the <em>textWidth()</em> function and give it the string I'm rendering, but when it comes to its height, I'm clueless. Yes, functions <em>textAscent()</em> and <em>textDescent()</em> are available and their sum gives me the maximum height of the font in general, but what I need is the height of a particular string or a character which is potentially smaller in height..</p>

<p>Is there a workaround that'll give me what I want??</p>

<p>Cheers</p>
]]></description>
   </item>
   <item>
      <title>Splitting strings by characters</title>
      <link>https://forum.processing.org/two/discussion/20199/splitting-strings-by-characters</link>
      <pubDate>Wed, 11 Jan 2017 18:40:20 +0000</pubDate>
      <dc:creator>Nekios</dc:creator>
      <guid isPermaLink="false">20199@/two/discussions</guid>
      <description><![CDATA[<p>I want to write a function which take strings as input and returns an array of characters consisting of the characters in the order they originally appear in the string. For example, explode( "Dirk" ) should return the array {'D', 'i', 'r', 'k'}. However, I cannot get it to work.</p>

<p><code>char[] explode(String s) {
  String theString = s;
  char[] c = new char[theString.length()];
  for (int i = 0; i &lt; theString.length(); i++) {
    c[i] = theString.charAt(i);
    return c[i];
  }
}</code></p>

<p>I also want to write a function that behaves like the above one in reverse. Taking an array of characters as input and returns a String consisting of all the characters in the array glued together. For example, returning ("Dirk") after inputting the array {'D', 'i', 'r', 'k'}.</p>
]]></description>
   </item>
   <item>
      <title>Reverse a word with a function</title>
      <link>https://forum.processing.org/two/discussion/19072/reverse-a-word-with-a-function</link>
      <pubDate>Wed, 16 Nov 2016 18:04:02 +0000</pubDate>
      <dc:creator>Lugi5000</dc:creator>
      <guid isPermaLink="false">19072@/two/discussions</guid>
      <description><![CDATA[<p>Hello!</p>

<p>I want to make a program that includes a function. The function should reverse a word. For example if I type in Hello, it should end up with olleH. My question is how the code would look like for this program.</p>

<p>Thank you in advance, Lugi5000</p>
]]></description>
   </item>
   <item>
      <title>character within a string</title>
      <link>https://forum.processing.org/two/discussion/15525/character-within-a-string</link>
      <pubDate>Wed, 16 Mar 2016 18:32:01 +0000</pubDate>
      <dc:creator>jeffmarc</dc:creator>
      <guid isPermaLink="false">15525@/two/discussions</guid>
      <description><![CDATA[<p>string [] name={"name1","name2","name3"};</p>

<p>how do i address characters in string?
name[0][4] should be 1 name[1][4] should be 2 
what is the proper syntax, this worked in C</p>
]]></description>
   </item>
   <item>
      <title>Image to Keyboard</title>
      <link>https://forum.processing.org/two/discussion/13905/image-to-keyboard</link>
      <pubDate>Fri, 11 Dec 2015 22:12:01 +0000</pubDate>
      <dc:creator>nakwonseo</dc:creator>
      <guid isPermaLink="false">13905@/two/discussions</guid>
      <description><![CDATA[<p>I have a tiny question. If someone could help, I'd appreciate it a lot.</p>

<p>When I click play, I want the image to be at the stage when the mouse is at the right side of the screen. And as the user is typing, the image goes from high tot left (pixelated to clear image). How to connect the image to keyboard?</p>

<p>//variables for message function
String message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vel quam fermentum, blandit nulla vel, adipiscing sapien. Pellentesque nunc lectus, vestibulum a sollicitudin ac, vulputate vitae libero. Duis ut consectetur quam, ullamcorper faucibus est. Quisque quis dui ante. Vivamus ullamcorper, felis et feugiat faucibus, augue odio lacinia est, et tristique neque ligula eget mi. Morbi et nulla leo. Integer semper nibh erat, ac rutrum ante hendrerit id.";
float textleft = 50, texttop = 50;
float charw = 8, charh = 13;
int lettersPerLine = 90;
float xmargin = 400, ymargin = 750;
int progress = 0;
int[] asciivalues; //use this line to convert string to int[]</p>

<p>PImage img;
int grid = 5;</p>

<p>import processing.video.*;
Capture cam;</p>

<p>void setup() {
  size(displayWidth, displayHeight);
  textFont(createFont("Courier", 14), 14);</p>

<p>asciivalues = int( message.toCharArray() ); //use this line to convert string to int[]</p>

<p>cam = new Capture(this, width, height, 30);
  cam.start();</p>

<p>img = loadImage("01.png");
  img = cam;
  background(0);
  smooth();</p>

<p>}</p>

<p>float getXPosition(int index) {
  return index%lettersPerLine * charw + xmargin;
}
float getYPosition(int index) {
  return int(index/lettersPerLine) * charh + ymargin;</p>

<p>}</p>

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

<p>// background(255);</p>

<p>timer(120);</p>

<p>picture();
  pix();
  message();
  //rect(0, -180, width, height);</p>

<p>}</p>

<p>//message to be typed function
void message() {</p>

<p>for (int i = 0; i &lt; message.length (); i++) {
    fill(0);
    if (progress &gt;= i) fill(100);
    if (progress == i) fill(255, 0, 0);
    textSize(14);
    text(message.charAt(i), getXPosition(i), getYPosition(i));
  }</p>

<p>}</p>

<p>void keyPressed() {
  if (int(key) &gt;= int(' ') &amp;&amp; int(key) &lt;= int('z')) {
    if (progress &lt; message.length() &amp;&amp; key == asciivalues[progress]) {
      progress++;
      int percentDone = floor(float(progress) / float(message.length())*100);
      println(percentDone);
    }
  }
}</p>

<p>//timer function
void timer(int interval) {</p>

<p>String time = "Time";
  int t;</p>

<p>//background(255);
  t = interval - int(millis()/1000);
  time = nf(t, 2);
  if (t &lt; 0) {
    time = "";
    textSize(100);
    fill(255, 0, 0);
    noStroke();
    text("STOP", width/2.5, height/1.12);
    message = "";
  }
  text(time, width<em>0.15, height</em>0.9);
}</p>

<p>//image function</p>

<p>void picture() {
  if (cam.available()) {
    cam.read();
  }
  image(cam, 0, -180);
  //filter(GRAY);
  //filter(INVERT);
  //filter(THRESHOLD, 0.50);
}
void mousePressed() {
  image(cam, 0, 0);
  filter(GRAY);
  //filter(THRESHOLD, 0.50);</p>

<p>saveFrame("/Users/aminatayyub/Desktop/DC_Final/text_perc_cam_eurika_/data/01.png");
  cam.stop();</p>

<p>}</p>

<p>//pixel to image function
void pix() {</p>

<p>grid = mouseX+1;
  // Pick a random point</p>

<p>for (int x = 1; x &lt; width; x+=grid) {
    for (int y = 0; y &lt; height; y+=grid ) {
      int loc = x + y*img.width;</p>

<pre><code>  // Look up the RGB color in the source image
  img.loadPixels();
  float r = red(img.pixels[loc]);
  float g = green(img.pixels[loc]);
  float b = blue(img.pixels[loc]);
  float gray = brightness(img.pixels[loc]);

  noStroke();

  // Draw an ellipse at that location with that color
  fill(r, g, b, 100);
  fill(gray);
  rect(x, y, grid, grid);
}
</code></pre>

<p>}</p>

<p>}</p>
]]></description>
   </item>
   <item>
      <title>Separating Characters</title>
      <link>https://forum.processing.org/two/discussion/13797/separating-characters</link>
      <pubDate>Sun, 06 Dec 2015 00:19:53 +0000</pubDate>
      <dc:creator>chooj</dc:creator>
      <guid isPermaLink="false">13797@/two/discussions</guid>
      <description><![CDATA[<p>How can I separate characters within a string to be objects of an array?</p>

<p>For example:</p>

<p>for (int i = 0; i &lt; string.length; i++) {
   character[i] = ______________;
}</p>
]]></description>
   </item>
   <item>
      <title>How to make sketch look through string + make a println showing number of occurrences of each vowel?</title>
      <link>https://forum.processing.org/two/discussion/13750/how-to-make-sketch-look-through-string-make-a-println-showing-number-of-occurrences-of-each-vowel</link>
      <pubDate>Wed, 02 Dec 2015 21:11:41 +0000</pubDate>
      <dc:creator>TheTurtle413</dc:creator>
      <guid isPermaLink="false">13750@/two/discussions</guid>
      <description><![CDATA[<p>I need to make the sketch search through the string "The unusually quick brown fox jumps over the lazy family dog repeatedly." and make a (println) output report showing the number of occurrences for each vowel (a,e,i,o,u). I made some code, but I got stuck. For example, the println showed 9 for the vowel a even though the vowel a occurs four times in the string. What am I doing wrong? Thanks.</p>

<pre>String sentence = "The unusually quick brown fox jumps over the lazy family dog repeatedly.";
println(sentence.indexOf("a"));
println(sentence.indexOf("e"));
println(sentence.indexOf("i"));
println(sentence.indexOf("o"));
println(sentence.indexOf("u"));
noLoop();</pre>
]]></description>
   </item>
   <item>
      <title>Replacing an array of strings with integer</title>
      <link>https://forum.processing.org/two/discussion/13178/replacing-an-array-of-strings-with-integer</link>
      <pubDate>Thu, 22 Oct 2015 16:12:49 +0000</pubDate>
      <dc:creator>yousufalin</dc:creator>
      <guid isPermaLink="false">13178@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I have an array of Strings, {a,b,c,b,a,d,a,c,a}. I wanted to sort and replace them with integers, and change it as {0,1,2,1,0,3,0,2,0}</p>

<p>As the first step I tried removing the repeating elements from the array and made another array of strings {a,b,c,d}. 
Then I used a for loop and assigned values for these strings as {0,1,2,3}.</p>

<p>Now I wanted to replace the individual members in the first array of strings, where "a" is replaced with "0", "b" with "1", "c " with "2" and "d" with "3", and make an array {0,1,2,1,0,3,0,2,0}</p>

<pre><code>String [] name = {"a", "b", "c", "b", "a", "d", "a", "c", "a"};

IntDict sortedName;
IntDict finalNameList;


void setup() {
  size(600, 600);
  smooth();

  sortedName = new IntDict();
  finalNameList = new IntDict();


  for (int i=0; i&lt;name.length; i++) {
    finalNameList.increment(name[i]);
  }

  String [] names = sortedName.keyArray(); //// sorted array of strings {a,b,c,d}

  for (int i=0; i&lt;names.length; i++) {
    finalNameList.set(names[i], i);
  }

  int [] values = finalNameList.valueArray(); ///// assigned values for a,b,c,d-- 0,1,2,3


  ////// now i wanted to replace the strings in the first array, name with the integers

  for (int i =0; i&lt;name.length; i++) {
    name[i]= name[i].replaceAll(names[i], i-names.length);

    println(name[i]);
  }
}


void draw() {

  background(125);
}
</code></pre>

<p>would be great if someone can help me with this. 
many thanks in advance :)</p>
]]></description>
   </item>
   <item>
      <title>Difficulty with nested loop and text</title>
      <link>https://forum.processing.org/two/discussion/11801/difficulty-with-nested-loop-and-text</link>
      <pubDate>Wed, 22 Jul 2015 19:51:27 +0000</pubDate>
      <dc:creator>rumlac</dc:creator>
      <guid isPermaLink="false">11801@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I am trying to figure out how to do the following:</p>

<ul>
<li>Check first character in a string</li>
<li>Check what that character is.</li>
<li>Add 1 to counter (could use an array to store the frequency of each character)</li>
<li>Move on to the next character in the string</li>
<li>and so on..</li>
</ul>

<p>Essentially I am trying to figure out a way of counting the frequency of each different character in a string.</p>

<p>I was able to do this using if/else statements for each letter of the alphabet but ideally I would like a better way of doing this.</p>

<p>Heres what I have so far:</p>

<pre><code>      String yourString = msg;
      char[] allChars = new char[yourString.length()];
      for (int i = 0; i &lt; yourString.length (); i++) {
        allChars[i] = yourString.charAt(i);
        String character = str(allChars[i]);

        for (counter=0; counter &lt; alpha.length; counter++) {
          if (character.equals(alpha[counter]) == true ) {
            count[counter] = count[counter]+1;
          }
        }
      println("The number of A is" + count[0]);
      }
</code></pre>

<p>alpha is a character array containing the individual letters of the alphabet
count is an array where I am trying to store the values i.e:</p>

<ul>
<li>count[0] would equal the number of times the letter A appears in the string</li>
<li>count[1] would equal the number of times the letter B appears in the string</li>
</ul>

<p>Any help would be great! thanks!</p>
]]></description>
   </item>
   <item>
      <title>How can  I change the format of the numbers from 1,9 (one point nine) to 1.9)?</title>
      <link>https://forum.processing.org/two/discussion/11106/how-can-i-change-the-format-of-the-numbers-from-1-9-one-point-nine-to-1-9</link>
      <pubDate>Mon, 01 Jun 2015 19:55:30 +0000</pubDate>
      <dc:creator>Mino32</dc:creator>
      <guid isPermaLink="false">11106@/two/discussions</guid>
      <description><![CDATA[<p>I want to change the format of the numbers with decimals because it is confusing when i have thousands (1,900) and decimals.</p>
]]></description>
   </item>
   <item>
      <title>almacenar caracteres en un array con número de repetición</title>
      <link>https://forum.processing.org/two/discussion/10159/almacenar-caracteres-en-un-array-con-numero-de-repeticion</link>
      <pubDate>Fri, 03 Apr 2015 07:48:09 +0000</pubDate>
      <dc:creator>lilispi</dc:creator>
      <guid isPermaLink="false">10159@/two/discussions</guid>
      <description><![CDATA[<p>Hola ojala me puedan ayudar.
Estoy leyendo un archivo.txt con datos los cuales almaceno en un array. Ahora deseo leer el archivo y contar las veces que se repite cada carácter y al final imprimir la lista de caracteres con el numero de veces que este re repite. Alguien me puede decir como podría hacerlo.</p>

<pre><code>String[] lines;
String dato[];
int index = 0;

void setup() {
  size(200, 200);
  background(0);
  lines = loadStrings("abra.txt");

  if (index &lt; lines.length) {
    dato = split(lines[index], ',');
    index=index+1;
    println(dato);
  }

  int []charFreqs = new int[256];
  for(char c: dato.toCharArray){
    charFreqs[c]++;
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>characters in an array with repetition number</title>
      <link>https://forum.processing.org/two/discussion/10202/characters-in-an-array-with-repetition-number</link>
      <pubDate>Mon, 06 Apr 2015 04:51:10 +0000</pubDate>
      <dc:creator>lilispi</dc:creator>
      <guid isPermaLink="false">10202@/two/discussions</guid>
      <description><![CDATA[<p>Hello! i need help. I'm reading a file.txt which data store them in an array. Now I want to read the file and count how many times each character is repeated and finally print the list of characters with the number of times this re repeats. Someone can tell me how could.</p>
]]></description>
   </item>
   <item>
      <title>println if a string contains a certain character only once</title>
      <link>https://forum.processing.org/two/discussion/8066/println-if-a-string-contains-a-certain-character-only-once</link>
      <pubDate>Tue, 11 Nov 2014 07:03:16 +0000</pubDate>
      <dc:creator>anderssonx</dc:creator>
      <guid isPermaLink="false">8066@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to code a program to check a string for a certain character and if it's found once (but not less or more than one)in the string i want to print a line to the command box.</p>

<p>How can i achieve this?</p>
]]></description>
   </item>
   </channel>
</rss>