Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I once had to do something similar for a small little project I was working on for fun.</p> <p>I do not see why you would need to create a thread for each letter to create a transition between two words unless I'm not understanding what you are pretending to do correctly.</p> <p>Check and study the following code, see if its any help:</p> <pre><code>static class Program { static void Main() { TextTranstition transition = new TextTranstition(); transition.TransitionFinished += TransitionTicked; transition.TransitionTicked += TransitionTicked; transition.StartTransition("AmazingWordTransition", "MyNewWordAppearing", 100); Thread.CurrentThread.Join(); Console.ReadKey(); } public static void TransitionTicked(object sender, TranstitionEventArgs e) { Console.Clear(); Console.Write(e.TransitionText); } } public class TranstitionEventArgs : EventArgs { private readonly string transitionText; public string TransitionText { get { return this.transitionText; } } public TranstitionEventArgs(string transitionText) { this.transitionText = transitionText; } } public class TextTranstition { private struct StartInfo { public StartInfo(string initialText, string finalText, int timeStep) { this.initialText = initialText; this.finalText = finalText; this.timeStep = timeStep; } private readonly string initialText; public string InitialText { get { return this.initialText; } } private readonly string finalText; public string FinalText { get { return this.finalText; } } private readonly int timeStep; public int TimeStep { get { return this.timeStep; } } } public EventHandler&lt;TranstitionEventArgs&gt; TransitionFinished; public EventHandler&lt;TranstitionEventArgs&gt; TransitionTicked; public void StartTransition(string initialText, string finalText, int timeStep) { StartInfo startInfo = new StartInfo(initialText, finalText, timeStep); Thread t = new Thread(startTransition); t.Start(startInfo); } private void startTransition(object info) { StartInfo startInfo = (StartInfo)info; string initialText = startInfo.InitialText; string finalText = startInfo.FinalText; if (initialText.Length &lt; finalText.Length) { initialText = initialText.PadRight(finalText.Length); } if (TransitionTicked != null) TransitionTicked(this, new TranstitionEventArgs(initialText)); while ((initialText = transition(initialText, finalText)) != finalText) { Thread.Sleep(startInfo.TimeStep); if (TransitionTicked != null) TransitionTicked(this, new TranstitionEventArgs(initialText)); } if (TransitionFinished != null) TransitionFinished(this, new TranstitionEventArgs(finalText)); } private string transition(string initialText, string finalText) { StringBuilder b = new StringBuilder(finalText.Length); for (int i = 0; i &lt; finalText.Length; i++) { char c = initialText[i]; int charCode = (int)c; if (c != finalText[i]) { if (charCode == 122 || charCode==32) charCode = 65; else if (charCode == 90) charCode = 97; else { charCode += 1; } } b.Append((char)charCode); } return b.ToString(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload