{"id":1229,"date":"2015-03-01T00:01:00","date_gmt":"2015-03-01T08:01:00","guid":{"rendered":"http:\/\/c-for-dummies.com\/blog\/?p=1229"},"modified":"2015-03-08T08:00:51","modified_gmt":"2015-03-08T15:00:51","slug":"pattern-manipulation","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=1229","title":{"rendered":"Pattern Manipulation"},"content":{"rendered":"<p>You see them all the time, mostly as &#8220;busy&#8221; gizmos. They are animations that spin or dance to deceive you into believing that the software is really doing something. But they&#8217;re merely animations. In fact, they&#8217;re very simple animations that require practically effortless coding.<br \/>\n<!--more--><br \/>\nConsider the animation shown in Figure 1. It cycles through some basic shades of red. Your eye interprets the changing colors as movement, but nothing is really moving.<\/p>\n<div id=\"attachment_1232\" style=\"width: 267px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1232\" src=\"http:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2015\/03\/201503-color_animation.gif\" alt=\"Figure 1. A simple color animation.\" width=\"257\" height=\"101\" class=\"size-full wp-image-1232\" \/><p id=\"caption-attachment-1232\" class=\"wp-caption-text\">Figure 1. A simple color animation.<\/p><\/div>\n<p>The image consists of 8 color panels. Each panel is assigned a color value. That value is manipulated to create the animation. So the panels don&#8217;t move or change location, only their color value is manipulated. The animated process is done by using simple math.<\/p>\n<p>In Figure 2, you see a more basic example, which is actually output from this month&#8217;s Exercise:<\/p>\n<div id=\"attachment_1233\" style=\"width: 595px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1233\" src=\"http:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2015\/03\/201503-terminal_animation.gif\" alt=\"Figure 2. Output from this month&#039;s Exercise.\" width=\"585\" height=\"414\" class=\"size-full wp-image-1233\" \/><p id=\"caption-attachment-1233\" class=\"wp-caption-text\">Figure 2. Output from this month&#8217;s Exercise (animation speed reduced for readability).<\/p><\/div>\n<p>Your task is to write code that cycles through values 0 through 7 in order, changing each position by 1, over and over. Yep: That&#8217;s an infinite loop. So you&#8217;ll need to press Ctrl+C to end the program, but in this instance, creating an infinite loop is desirable.<\/p>\n<p>While many ways exist to accomplish this task, your directions are to use only one variable for all the numbers. A second variable can be added if you need a looping statement, although I&#8217;m only being kind by making that concession.<\/p>\n<p><a href=\"http:\/\/c-for-dummies.com\/blog\/?p=1241\">Click here<\/a> to review my solutions. I have two: one that uses two variables and another that uses only a single variable. Please try the exercise on your own before you peek at my solutions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It may look complex, but changing a pattern isn&#8217;t a big deal. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=1229\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1229","post","type-post","status-publish","format-standard","hentry","category-exercise"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1229","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1229"}],"version-history":[{"count":7,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1229\/revisions"}],"predecessor-version":[{"id":1273,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1229\/revisions\/1273"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1229"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1229"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1229"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}