<rss version="2.0">
  <channel>
    <title>PaintCode on Mark Alldritt</title>
    <link>https://Alldritt.micro.blog/categories/paintcode/</link>
    <description></description>
    
    <language>en</language>
    
    <lastBuildDate>Thu, 02 Mar 2017 13:59:10 -0700</lastBuildDate>
    
    <item>
      <title>Animated Record Button with PaintCode</title>
      <link>https://Alldritt.micro.blog/2017/03/02/animated-record-button.html</link>
      <pubDate>Thu, 02 Mar 2017 13:59:10 -0700</pubDate>
      
      <guid>http://Alldritt.micro.blog/2017/03/02/animated-record-button.html</guid>
      <description>&lt;p&gt;Here is an example of how to use &lt;a href=&#34;https://www.paintcodeapp.com&#34;&gt;PaintCode&lt;/a&gt; to create an animated button.&lt;/p&gt;
&lt;p&gt;The code for this project is available on &lt;a href=&#34;https://github.com/alldritt/RecordButton&#34;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;##Background&lt;/p&gt;
&lt;p&gt;I wanted to create a record/stop button for a project I&amp;rsquo;m working on that mirrored the appearance of the record/stop button found in Apple&amp;rsquo;s iOS Camera Video recorder and Voice Recorder applications.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://markalldritt.com/wp-content/uploads/2017/03/VoiceRecorder.gif&#34; alt=&#34;Voice Recorder&#34;&gt;&lt;/p&gt;
&lt;p&gt;##PaintCode Design&lt;/p&gt;
&lt;p&gt;PaintCode makes creating simple designs like this very simple.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://markalldritt.com/wp-content/uploads/2017/03/PaintCode.gif&#34; alt=&#34;PaintCode&#34;&gt;&lt;/p&gt;
&lt;p&gt;I have a square canvas in which there are two concentric circles.  The outer circle is the button&amp;rsquo;s frame (white), and the inner circle is the tappable button (red).&lt;/p&gt;
&lt;p&gt;Using PaintCode&amp;rsquo;s expressions I have two parameters:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;isPressed, a boolean, controls the color used to draw the inner circle&lt;/li&gt;
&lt;li&gt;isRecording, a fraction (0.0-&amp;gt;1.0) controls the transition of the inner circle from a circle to a smaller rounded square&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;##The Code&lt;/p&gt;
&lt;p&gt;When the button is tapped, isPressed is set to true until the tap ends.  When the tap ends, the value of isRecording is animated from 0.0 -&amp;gt; 1.0 or 1.0 to 0.0 depending on the state of the button.  That&amp;rsquo;s it.&lt;/p&gt;
&lt;p&gt;Here is the result:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;http://markalldritt.com/wp-content/uploads/2017/03/RecordButton.gif&#34; alt=&#34;RecordButton&#34;&gt;&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>