mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
703 lines
107 KiB
HTML
703 lines
107 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.6"/>
|
|
<title>ArduinoLibs: Bitmap.cpp Source File</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(function() { searchBox.OnSelectItem(0); });
|
|
</script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td style="padding-left: 0.5em;">
|
|
<div id="projectname">ArduinoLibs
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.6 -->
|
|
<script type="text/javascript">
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
</script>
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
|
<li><a href="pages.html"><span>Related Pages</span></a></li>
|
|
<li><a href="modules.html"><span>Modules</span></a></li>
|
|
<li><a href="annotated.html"><span>Classes</span></a></li>
|
|
<li class="current"><a href="files.html"><span>Files</span></a></li>
|
|
<li>
|
|
<div id="MSearchBox" class="MSearchBoxInactive">
|
|
<span class="left">
|
|
<img id="MSearchSelect" src="search/mag_sel.png"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
alt=""/>
|
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
|
</span><span class="right">
|
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
|
|
</span>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div id="navrow2" class="tabs2">
|
|
<ul class="tablist">
|
|
<li><a href="files.html"><span>File List</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark"> </span>Pages</a></div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div id="nav-path" class="navpath">
|
|
<ul>
|
|
<li class="navelem"><a class="el" href="dir_bc0718b08fb2015b8e59c47b2805f60c.html">libraries</a></li><li class="navelem"><a class="el" href="dir_6591a2127a29f6cea3994dcb5b0596d1.html">DMD</a></li> </ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">Bitmap.cpp</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">/*</span></div>
|
|
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment"> * Copyright (C) 2012 Southern Storm Software, Pty Ltd.</span></div>
|
|
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"> *</span></div>
|
|
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining a</span></div>
|
|
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"> * copy of this software and associated documentation files (the "Software"),</span></div>
|
|
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"> * to deal in the Software without restriction, including without limitation</span></div>
|
|
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment"> * the rights to use, copy, modify, merge, publish, distribute, sublicense,</span></div>
|
|
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"> * and/or sell copies of the Software, and to permit persons to whom the</span></div>
|
|
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment"> * Software is furnished to do so, subject to the following conditions:</span></div>
|
|
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"> *</span></div>
|
|
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"> * The above copyright notice and this permission notice shall be included</span></div>
|
|
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"> * in all copies or substantial portions of the Software.</span></div>
|
|
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment"> *</span></div>
|
|
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS</span></div>
|
|
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment"> * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span></div>
|
|
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span></div>
|
|
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment"> * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span></div>
|
|
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING</span></div>
|
|
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="comment"> * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER</span></div>
|
|
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="comment"> * DEALINGS IN THE SOFTWARE.</span></div>
|
|
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="comment"> */</span></div>
|
|
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span> </div>
|
|
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="preprocessor">#include "Bitmap.h"</span></div>
|
|
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="preprocessor">#include <WString.h></span></div>
|
|
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="preprocessor">#include <string.h></span></div>
|
|
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="preprocessor">#include <stdlib.h></span></div>
|
|
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span> </div>
|
|
<div class="line"><a name="l00088"></a><span class="lineno"><a class="line" href="classBitmap.html#a40526748415c8bbc58a8510d636c20f4"> 88</a></span> <a class="code" href="classBitmap.html#a40526748415c8bbc58a8510d636c20f4">Bitmap::Bitmap</a>(<span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height)</div>
|
|
<div class="line"><a name="l00089"></a><span class="lineno"> 89</span>  : _width(width)</div>
|
|
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span>  , _height(height)</div>
|
|
<div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  , _stride((width + 7) / 8)</div>
|
|
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  , fb(0)</div>
|
|
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  , _font(0)</div>
|
|
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  , _textColor(White)</div>
|
|
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span> {</div>
|
|
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  <span class="comment">// Allocate memory for the framebuffer and clear it (1 = pixel off).</span></div>
|
|
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size = _stride * _height;</div>
|
|
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span>  fb = (uint8_t *)malloc(size);</div>
|
|
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span>  <span class="keywordflow">if</span> (fb)</div>
|
|
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span>  memset(fb, 0xFF, size);</div>
|
|
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span> }</div>
|
|
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span> </div>
|
|
<div class="line"><a name="l00106"></a><span class="lineno"><a class="line" href="classBitmap.html#a72d2a301ec1eb1c8d0f3d64823659a8e"> 106</a></span> <a class="code" href="classBitmap.html#a72d2a301ec1eb1c8d0f3d64823659a8e">Bitmap::~Bitmap</a>()</div>
|
|
<div class="line"><a name="l00107"></a><span class="lineno"> 107</span> {</div>
|
|
<div class="line"><a name="l00108"></a><span class="lineno"> 108</span>  <span class="keywordflow">if</span> (fb)</div>
|
|
<div class="line"><a name="l00109"></a><span class="lineno"> 109</span>  free(fb);</div>
|
|
<div class="line"><a name="l00110"></a><span class="lineno"> 110</span> }</div>
|
|
<div class="line"><a name="l00111"></a><span class="lineno"> 111</span> </div>
|
|
<div class="line"><a name="l00174"></a><span class="lineno"><a class="line" href="classBitmap.html#a839dc8fab05a5ebf7a6b2e61436b2fa1"> 174</a></span> <span class="keywordtype">void</span> <a class="code" href="classBitmap.html#a839dc8fab05a5ebf7a6b2e61436b2fa1">Bitmap::clear</a>(<a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> color)</div>
|
|
<div class="line"><a name="l00175"></a><span class="lineno"> 175</span> {</div>
|
|
<div class="line"><a name="l00176"></a><span class="lineno"> 176</span>  <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> size = _stride * _height;</div>
|
|
<div class="line"><a name="l00177"></a><span class="lineno"> 177</span>  <span class="keywordflow">if</span> (color == <a class="code" href="classBitmap.html#a2c7faeeb89d3624b5bbca58871785adc">Black</a>)</div>
|
|
<div class="line"><a name="l00178"></a><span class="lineno"> 178</span>  memset(fb, 0xFF, size);</div>
|
|
<div class="line"><a name="l00179"></a><span class="lineno"> 179</span>  <span class="keywordflow">else</span></div>
|
|
<div class="line"><a name="l00180"></a><span class="lineno"> 180</span>  memset(fb, 0x00, size);</div>
|
|
<div class="line"><a name="l00181"></a><span class="lineno"> 181</span> }</div>
|
|
<div class="line"><a name="l00182"></a><span class="lineno"> 182</span> </div>
|
|
<div class="line"><a name="l00191"></a><span class="lineno"><a class="line" href="classBitmap.html#a35aa38b377d509d6c4f061a0b988d203"> 191</a></span> <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Bitmap::Color</a> <a class="code" href="classBitmap.html#a35aa38b377d509d6c4f061a0b988d203">Bitmap::pixel</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y)<span class="keyword"> const</span></div>
|
|
<div class="line"><a name="l00192"></a><span class="lineno"> 192</span> <span class="keyword"></span>{</div>
|
|
<div class="line"><a name="l00193"></a><span class="lineno"> 193</span>  <span class="keywordflow">if</span> (((<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)x) >= ((<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)_width) ||</div>
|
|
<div class="line"><a name="l00194"></a><span class="lineno"> 194</span>  ((<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)y) >= ((<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)_height))</div>
|
|
<div class="line"><a name="l00195"></a><span class="lineno"> 195</span>  <span class="keywordflow">return</span> <a class="code" href="classBitmap.html#a2c7faeeb89d3624b5bbca58871785adc">Black</a>;</div>
|
|
<div class="line"><a name="l00196"></a><span class="lineno"> 196</span>  uint8_t *ptr = fb + y * _stride + (x >> 3);</div>
|
|
<div class="line"><a name="l00197"></a><span class="lineno"> 197</span>  <span class="keywordflow">if</span> (*ptr & ((uint8_t)0x80) >> (x & 0x07))</div>
|
|
<div class="line"><a name="l00198"></a><span class="lineno"> 198</span>  <span class="keywordflow">return</span> <a class="code" href="classBitmap.html#a2c7faeeb89d3624b5bbca58871785adc">Black</a>;</div>
|
|
<div class="line"><a name="l00199"></a><span class="lineno"> 199</span>  <span class="keywordflow">else</span></div>
|
|
<div class="line"><a name="l00200"></a><span class="lineno"> 200</span>  <span class="keywordflow">return</span> <a class="code" href="classBitmap.html#a39b6754cfe50a457bbfdb1980fd87eb7">White</a>;</div>
|
|
<div class="line"><a name="l00201"></a><span class="lineno"> 201</span> }</div>
|
|
<div class="line"><a name="l00202"></a><span class="lineno"> 202</span> </div>
|
|
<div class="line"><a name="l00208"></a><span class="lineno"><a class="line" href="classBitmap.html#aac994b75418e7d37ec66829437329114"> 208</a></span> <span class="keywordtype">void</span> <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">Bitmap::setPixel</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> color)</div>
|
|
<div class="line"><a name="l00209"></a><span class="lineno"> 209</span> {</div>
|
|
<div class="line"><a name="l00210"></a><span class="lineno"> 210</span>  <span class="keywordflow">if</span> (((<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)x) >= ((<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)_width) ||</div>
|
|
<div class="line"><a name="l00211"></a><span class="lineno"> 211</span>  ((<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)y) >= ((<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>)_height))</div>
|
|
<div class="line"><a name="l00212"></a><span class="lineno"> 212</span>  <span class="keywordflow">return</span>; <span class="comment">// Pixel is off-screen.</span></div>
|
|
<div class="line"><a name="l00213"></a><span class="lineno"> 213</span>  uint8_t *ptr = fb + y * _stride + (x >> 3);</div>
|
|
<div class="line"><a name="l00214"></a><span class="lineno"> 214</span>  <span class="keywordflow">if</span> (color)</div>
|
|
<div class="line"><a name="l00215"></a><span class="lineno"> 215</span>  *ptr &= ~(((uint8_t)0x80) >> (x & 0x07));</div>
|
|
<div class="line"><a name="l00216"></a><span class="lineno"> 216</span>  <span class="keywordflow">else</span></div>
|
|
<div class="line"><a name="l00217"></a><span class="lineno"> 217</span>  *ptr |= (((uint8_t)0x80) >> (x & 0x07));</div>
|
|
<div class="line"><a name="l00218"></a><span class="lineno"> 218</span> }</div>
|
|
<div class="line"><a name="l00219"></a><span class="lineno"> 219</span> </div>
|
|
<div class="line"><a name="l00225"></a><span class="lineno"><a class="line" href="classBitmap.html#aa0a84f3694e343d68e7021552c69f767"> 225</a></span> <span class="keywordtype">void</span> <a class="code" href="classBitmap.html#aa0a84f3694e343d68e7021552c69f767">Bitmap::drawLine</a>(<span class="keywordtype">int</span> x1, <span class="keywordtype">int</span> y1, <span class="keywordtype">int</span> x2, <span class="keywordtype">int</span> y2, <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> color)</div>
|
|
<div class="line"><a name="l00226"></a><span class="lineno"> 226</span> {</div>
|
|
<div class="line"><a name="l00227"></a><span class="lineno"> 227</span>  <span class="comment">// Midpoint line scan-conversion algorithm from "Computer Graphics:</span></div>
|
|
<div class="line"><a name="l00228"></a><span class="lineno"> 228</span>  <span class="comment">// Principles and Practice", Second Edition, Foley, van Dam, et al.</span></div>
|
|
<div class="line"><a name="l00229"></a><span class="lineno"> 229</span>  <span class="keywordtype">int</span> dx = x2 - x1;</div>
|
|
<div class="line"><a name="l00230"></a><span class="lineno"> 230</span>  <span class="keywordtype">int</span> dy = y2 - y1;</div>
|
|
<div class="line"><a name="l00231"></a><span class="lineno"> 231</span>  <span class="keywordtype">int</span> xstep, ystep;</div>
|
|
<div class="line"><a name="l00232"></a><span class="lineno"> 232</span>  <span class="keywordtype">int</span> d, incrE, incrNE;</div>
|
|
<div class="line"><a name="l00233"></a><span class="lineno"> 233</span>  <span class="keywordflow">if</span> (dx < 0) {</div>
|
|
<div class="line"><a name="l00234"></a><span class="lineno"> 234</span>  xstep = -1;</div>
|
|
<div class="line"><a name="l00235"></a><span class="lineno"> 235</span>  dx = -dx;</div>
|
|
<div class="line"><a name="l00236"></a><span class="lineno"> 236</span>  } <span class="keywordflow">else</span> {</div>
|
|
<div class="line"><a name="l00237"></a><span class="lineno"> 237</span>  xstep = 1;</div>
|
|
<div class="line"><a name="l00238"></a><span class="lineno"> 238</span>  }</div>
|
|
<div class="line"><a name="l00239"></a><span class="lineno"> 239</span>  <span class="keywordflow">if</span> (dy < 0) {</div>
|
|
<div class="line"><a name="l00240"></a><span class="lineno"> 240</span>  ystep = -1;</div>
|
|
<div class="line"><a name="l00241"></a><span class="lineno"> 241</span>  dy = -dy;</div>
|
|
<div class="line"><a name="l00242"></a><span class="lineno"> 242</span>  } <span class="keywordflow">else</span> {</div>
|
|
<div class="line"><a name="l00243"></a><span class="lineno"> 243</span>  ystep = 1;</div>
|
|
<div class="line"><a name="l00244"></a><span class="lineno"> 244</span>  }</div>
|
|
<div class="line"><a name="l00245"></a><span class="lineno"> 245</span>  <span class="keywordflow">if</span> (dx >= dy) {</div>
|
|
<div class="line"><a name="l00246"></a><span class="lineno"> 246</span>  d = 2 * dy - dx;</div>
|
|
<div class="line"><a name="l00247"></a><span class="lineno"> 247</span>  incrE = 2 * dy;</div>
|
|
<div class="line"><a name="l00248"></a><span class="lineno"> 248</span>  incrNE = 2 * (dy - dx);</div>
|
|
<div class="line"><a name="l00249"></a><span class="lineno"> 249</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(x1, y1, color);</div>
|
|
<div class="line"><a name="l00250"></a><span class="lineno"> 250</span>  <span class="keywordflow">while</span> (x1 != x2) {</div>
|
|
<div class="line"><a name="l00251"></a><span class="lineno"> 251</span>  <span class="keywordflow">if</span> (d <= 0) {</div>
|
|
<div class="line"><a name="l00252"></a><span class="lineno"> 252</span>  d += incrE;</div>
|
|
<div class="line"><a name="l00253"></a><span class="lineno"> 253</span>  } <span class="keywordflow">else</span> {</div>
|
|
<div class="line"><a name="l00254"></a><span class="lineno"> 254</span>  d += incrNE;</div>
|
|
<div class="line"><a name="l00255"></a><span class="lineno"> 255</span>  y1 += ystep;</div>
|
|
<div class="line"><a name="l00256"></a><span class="lineno"> 256</span>  }</div>
|
|
<div class="line"><a name="l00257"></a><span class="lineno"> 257</span>  x1 += xstep;</div>
|
|
<div class="line"><a name="l00258"></a><span class="lineno"> 258</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(x1, y1, color);</div>
|
|
<div class="line"><a name="l00259"></a><span class="lineno"> 259</span>  }</div>
|
|
<div class="line"><a name="l00260"></a><span class="lineno"> 260</span>  } <span class="keywordflow">else</span> {</div>
|
|
<div class="line"><a name="l00261"></a><span class="lineno"> 261</span>  d = 2 * dx - dy;</div>
|
|
<div class="line"><a name="l00262"></a><span class="lineno"> 262</span>  incrE = 2 * dx;</div>
|
|
<div class="line"><a name="l00263"></a><span class="lineno"> 263</span>  incrNE = 2 * (dx - dy);</div>
|
|
<div class="line"><a name="l00264"></a><span class="lineno"> 264</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(x1, y1, color);</div>
|
|
<div class="line"><a name="l00265"></a><span class="lineno"> 265</span>  <span class="keywordflow">while</span> (y1 != y2) {</div>
|
|
<div class="line"><a name="l00266"></a><span class="lineno"> 266</span>  <span class="keywordflow">if</span> (d <= 0) {</div>
|
|
<div class="line"><a name="l00267"></a><span class="lineno"> 267</span>  d += incrE;</div>
|
|
<div class="line"><a name="l00268"></a><span class="lineno"> 268</span>  } <span class="keywordflow">else</span> {</div>
|
|
<div class="line"><a name="l00269"></a><span class="lineno"> 269</span>  d += incrNE;</div>
|
|
<div class="line"><a name="l00270"></a><span class="lineno"> 270</span>  x1 += xstep;</div>
|
|
<div class="line"><a name="l00271"></a><span class="lineno"> 271</span>  }</div>
|
|
<div class="line"><a name="l00272"></a><span class="lineno"> 272</span>  y1 += ystep;</div>
|
|
<div class="line"><a name="l00273"></a><span class="lineno"> 273</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(x1, y1, color);</div>
|
|
<div class="line"><a name="l00274"></a><span class="lineno"> 274</span>  }</div>
|
|
<div class="line"><a name="l00275"></a><span class="lineno"> 275</span>  }</div>
|
|
<div class="line"><a name="l00276"></a><span class="lineno"> 276</span> }</div>
|
|
<div class="line"><a name="l00277"></a><span class="lineno"> 277</span> </div>
|
|
<div class="line"><a name="l00286"></a><span class="lineno"><a class="line" href="classBitmap.html#aac61e3f7f625db568e37d88b52b3b2fc"> 286</a></span> <span class="keywordtype">void</span> <a class="code" href="classBitmap.html#aac61e3f7f625db568e37d88b52b3b2fc">Bitmap::drawRect</a>(<span class="keywordtype">int</span> x1, <span class="keywordtype">int</span> y1, <span class="keywordtype">int</span> x2, <span class="keywordtype">int</span> y2, <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> borderColor, <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> fillColor)</div>
|
|
<div class="line"><a name="l00287"></a><span class="lineno"> 287</span> {</div>
|
|
<div class="line"><a name="l00288"></a><span class="lineno"> 288</span>  <span class="keywordtype">int</span> temp;</div>
|
|
<div class="line"><a name="l00289"></a><span class="lineno"> 289</span>  <span class="keywordflow">if</span> (x1 > x2) {</div>
|
|
<div class="line"><a name="l00290"></a><span class="lineno"> 290</span>  temp = x1;</div>
|
|
<div class="line"><a name="l00291"></a><span class="lineno"> 291</span>  x1 = x2;</div>
|
|
<div class="line"><a name="l00292"></a><span class="lineno"> 292</span>  x2 = temp;</div>
|
|
<div class="line"><a name="l00293"></a><span class="lineno"> 293</span>  }</div>
|
|
<div class="line"><a name="l00294"></a><span class="lineno"> 294</span>  <span class="keywordflow">if</span> (y1 > y2) {</div>
|
|
<div class="line"><a name="l00295"></a><span class="lineno"> 295</span>  temp = y1;</div>
|
|
<div class="line"><a name="l00296"></a><span class="lineno"> 296</span>  y1 = y2;</div>
|
|
<div class="line"><a name="l00297"></a><span class="lineno"> 297</span>  y2 = temp;</div>
|
|
<div class="line"><a name="l00298"></a><span class="lineno"> 298</span>  }</div>
|
|
<div class="line"><a name="l00299"></a><span class="lineno"> 299</span>  <span class="keywordflow">if</span> (fillColor == borderColor) {</div>
|
|
<div class="line"><a name="l00300"></a><span class="lineno"> 300</span>  <a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">fill</a>(x1, y1, x2 - x1 + 1, y2 - y1 + 1, fillColor);</div>
|
|
<div class="line"><a name="l00301"></a><span class="lineno"> 301</span>  } <span class="keywordflow">else</span> {</div>
|
|
<div class="line"><a name="l00302"></a><span class="lineno"> 302</span>  <a class="code" href="classBitmap.html#aa0a84f3694e343d68e7021552c69f767">drawLine</a>(x1, y1, x2, y1, borderColor);</div>
|
|
<div class="line"><a name="l00303"></a><span class="lineno"> 303</span>  <span class="keywordflow">if</span> (y1 < y2)</div>
|
|
<div class="line"><a name="l00304"></a><span class="lineno"> 304</span>  <a class="code" href="classBitmap.html#aa0a84f3694e343d68e7021552c69f767">drawLine</a>(x2, y1 + 1, x2, y2, borderColor);</div>
|
|
<div class="line"><a name="l00305"></a><span class="lineno"> 305</span>  <span class="keywordflow">if</span> (x1 < x2)</div>
|
|
<div class="line"><a name="l00306"></a><span class="lineno"> 306</span>  <a class="code" href="classBitmap.html#aa0a84f3694e343d68e7021552c69f767">drawLine</a>(x2 - 1, y2, x1, y2, borderColor);</div>
|
|
<div class="line"><a name="l00307"></a><span class="lineno"> 307</span>  <span class="keywordflow">if</span> (y1 < (y2 - 1))</div>
|
|
<div class="line"><a name="l00308"></a><span class="lineno"> 308</span>  <a class="code" href="classBitmap.html#aa0a84f3694e343d68e7021552c69f767">drawLine</a>(x1, y2 - 1, x1, y1 + 1, borderColor);</div>
|
|
<div class="line"><a name="l00309"></a><span class="lineno"> 309</span>  <span class="keywordflow">if</span> (fillColor != <a class="code" href="classBitmap.html#aa89170263dc1f51f6366c1907119715e">NoFill</a>)</div>
|
|
<div class="line"><a name="l00310"></a><span class="lineno"> 310</span>  <a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">fill</a>(x1 + 1, y1 + 1, x2 - x1 - 1, y2 - y1 - 1, fillColor);</div>
|
|
<div class="line"><a name="l00311"></a><span class="lineno"> 311</span>  }</div>
|
|
<div class="line"><a name="l00312"></a><span class="lineno"> 312</span> }</div>
|
|
<div class="line"><a name="l00313"></a><span class="lineno"> 313</span> </div>
|
|
<div class="line"><a name="l00334"></a><span class="lineno"><a class="line" href="classBitmap.html#a933763a4f3cba79fbcf97ae6d0a864aa"> 334</a></span> <span class="keywordtype">void</span> <a class="code" href="classBitmap.html#a933763a4f3cba79fbcf97ae6d0a864aa">Bitmap::drawCircle</a>(<span class="keywordtype">int</span> centerX, <span class="keywordtype">int</span> centerY, <span class="keywordtype">int</span> radius, <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> borderColor, <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> fillColor)</div>
|
|
<div class="line"><a name="l00335"></a><span class="lineno"> 335</span> {</div>
|
|
<div class="line"><a name="l00336"></a><span class="lineno"> 336</span>  <span class="comment">// Midpoint circle scan-conversion algorithm using second-order</span></div>
|
|
<div class="line"><a name="l00337"></a><span class="lineno"> 337</span>  <span class="comment">// differences from "Computer Graphics: Principles and Practice",</span></div>
|
|
<div class="line"><a name="l00338"></a><span class="lineno"> 338</span>  <span class="comment">// Second Edition, Foley, van Dam, et al.</span></div>
|
|
<div class="line"><a name="l00339"></a><span class="lineno"> 339</span>  <span class="keywordflow">if</span> (radius < 0)</div>
|
|
<div class="line"><a name="l00340"></a><span class="lineno"> 340</span>  radius = -radius;</div>
|
|
<div class="line"><a name="l00341"></a><span class="lineno"> 341</span>  <span class="keywordtype">int</span> x = 0;</div>
|
|
<div class="line"><a name="l00342"></a><span class="lineno"> 342</span>  <span class="keywordtype">int</span> y = radius;</div>
|
|
<div class="line"><a name="l00343"></a><span class="lineno"> 343</span>  <span class="keywordtype">int</span> d = 1 - radius;</div>
|
|
<div class="line"><a name="l00344"></a><span class="lineno"> 344</span>  <span class="keywordtype">int</span> deltaE = 3;</div>
|
|
<div class="line"><a name="l00345"></a><span class="lineno"> 345</span>  <span class="keywordtype">int</span> deltaSE = 5 - 2 * radius;</div>
|
|
<div class="line"><a name="l00346"></a><span class="lineno"> 346</span>  drawCirclePoints(centerX, centerY, radius, x, y, borderColor, fillColor);</div>
|
|
<div class="line"><a name="l00347"></a><span class="lineno"> 347</span>  <span class="keywordflow">while</span> (y > x) {</div>
|
|
<div class="line"><a name="l00348"></a><span class="lineno"> 348</span>  <span class="keywordflow">if</span> (d < 0) {</div>
|
|
<div class="line"><a name="l00349"></a><span class="lineno"> 349</span>  d += deltaE;</div>
|
|
<div class="line"><a name="l00350"></a><span class="lineno"> 350</span>  deltaE += 2;</div>
|
|
<div class="line"><a name="l00351"></a><span class="lineno"> 351</span>  deltaSE += 2;</div>
|
|
<div class="line"><a name="l00352"></a><span class="lineno"> 352</span>  } <span class="keywordflow">else</span> {</div>
|
|
<div class="line"><a name="l00353"></a><span class="lineno"> 353</span>  d += deltaSE;</div>
|
|
<div class="line"><a name="l00354"></a><span class="lineno"> 354</span>  deltaE += 2;</div>
|
|
<div class="line"><a name="l00355"></a><span class="lineno"> 355</span>  deltaSE += 4;</div>
|
|
<div class="line"><a name="l00356"></a><span class="lineno"> 356</span>  --y;</div>
|
|
<div class="line"><a name="l00357"></a><span class="lineno"> 357</span>  }</div>
|
|
<div class="line"><a name="l00358"></a><span class="lineno"> 358</span>  ++x;</div>
|
|
<div class="line"><a name="l00359"></a><span class="lineno"> 359</span>  drawCirclePoints(centerX, centerY, radius, x, y, borderColor, fillColor);</div>
|
|
<div class="line"><a name="l00360"></a><span class="lineno"> 360</span>  }</div>
|
|
<div class="line"><a name="l00361"></a><span class="lineno"> 361</span> }</div>
|
|
<div class="line"><a name="l00362"></a><span class="lineno"> 362</span> </div>
|
|
<div class="line"><a name="l00388"></a><span class="lineno"><a class="line" href="classBitmap.html#a491e9c0bb20ddf5a5eb4933077c8ed72"> 388</a></span> <span class="keywordtype">void</span> <a class="code" href="classBitmap.html#a491e9c0bb20ddf5a5eb4933077c8ed72">Bitmap::drawBitmap</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keyword">const</span> <a class="code" href="classBitmap.html">Bitmap</a> &bitmap, <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> color)</div>
|
|
<div class="line"><a name="l00389"></a><span class="lineno"> 389</span> {</div>
|
|
<div class="line"><a name="l00390"></a><span class="lineno"> 390</span>  <span class="keywordtype">int</span> w = bitmap.<a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">width</a>();</div>
|
|
<div class="line"><a name="l00391"></a><span class="lineno"> 391</span>  <span class="keywordtype">int</span> s = bitmap.<a class="code" href="classBitmap.html#af30df263729385ea2330effe3c80a1bc">stride</a>();</div>
|
|
<div class="line"><a name="l00392"></a><span class="lineno"> 392</span>  <span class="keywordtype">int</span> h = bitmap.<a class="code" href="classBitmap.html#adcd4e3dc7594421e647b0f52da9a41a3">height</a>();</div>
|
|
<div class="line"><a name="l00393"></a><span class="lineno"> 393</span>  <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> invColor = !color;</div>
|
|
<div class="line"><a name="l00394"></a><span class="lineno"> 394</span>  <span class="keywordflow">for</span> (uint8_t by = 0; by < h; ++by) {</div>
|
|
<div class="line"><a name="l00395"></a><span class="lineno"> 395</span>  <span class="keyword">const</span> uint8_t *line = bitmap.<a class="code" href="classBitmap.html#a5eeed27c176eb6e4a2c39ea83444e27d">data</a>() + by * s;</div>
|
|
<div class="line"><a name="l00396"></a><span class="lineno"> 396</span>  uint8_t mask = 0x80;</div>
|
|
<div class="line"><a name="l00397"></a><span class="lineno"> 397</span>  uint8_t value = *line++;</div>
|
|
<div class="line"><a name="l00398"></a><span class="lineno"> 398</span>  <span class="keywordflow">for</span> (uint8_t bx = 0; bx < w; ++bx) {</div>
|
|
<div class="line"><a name="l00399"></a><span class="lineno"> 399</span>  <span class="keywordflow">if</span> (value & mask)</div>
|
|
<div class="line"><a name="l00400"></a><span class="lineno"> 400</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(x + bx, y + by, invColor);</div>
|
|
<div class="line"><a name="l00401"></a><span class="lineno"> 401</span>  <span class="keywordflow">else</span></div>
|
|
<div class="line"><a name="l00402"></a><span class="lineno"> 402</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(x + bx, y + by, color);</div>
|
|
<div class="line"><a name="l00403"></a><span class="lineno"> 403</span>  mask >>= 1;</div>
|
|
<div class="line"><a name="l00404"></a><span class="lineno"> 404</span>  <span class="keywordflow">if</span> (!mask) {</div>
|
|
<div class="line"><a name="l00405"></a><span class="lineno"> 405</span>  mask = 0x80;</div>
|
|
<div class="line"><a name="l00406"></a><span class="lineno"> 406</span>  value = *line++;</div>
|
|
<div class="line"><a name="l00407"></a><span class="lineno"> 407</span>  }</div>
|
|
<div class="line"><a name="l00408"></a><span class="lineno"> 408</span>  }</div>
|
|
<div class="line"><a name="l00409"></a><span class="lineno"> 409</span>  }</div>
|
|
<div class="line"><a name="l00410"></a><span class="lineno"> 410</span> }</div>
|
|
<div class="line"><a name="l00411"></a><span class="lineno"> 411</span> </div>
|
|
<div class="line"><a name="l00425"></a><span class="lineno"><a class="line" href="classBitmap.html#a5e4f23e8f14e193410b5f071149401e4"> 425</a></span> <span class="keywordtype">void</span> <a class="code" href="classBitmap.html#a491e9c0bb20ddf5a5eb4933077c8ed72">Bitmap::drawBitmap</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <a class="code" href="classBitmap.html#a2fcc98fd7580932b218134126a29ce43">Bitmap::ProgMem</a> bitmap, <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> color)</div>
|
|
<div class="line"><a name="l00426"></a><span class="lineno"> 426</span> {</div>
|
|
<div class="line"><a name="l00427"></a><span class="lineno"> 427</span>  uint8_t w = pgm_read_byte(bitmap);</div>
|
|
<div class="line"><a name="l00428"></a><span class="lineno"> 428</span>  uint8_t s = (w + 7) >> 3;</div>
|
|
<div class="line"><a name="l00429"></a><span class="lineno"> 429</span>  uint8_t h = pgm_read_byte(bitmap + 1);</div>
|
|
<div class="line"><a name="l00430"></a><span class="lineno"> 430</span>  <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> invColor = !color;</div>
|
|
<div class="line"><a name="l00431"></a><span class="lineno"> 431</span>  <span class="keywordflow">for</span> (uint8_t by = 0; by < h; ++by) {</div>
|
|
<div class="line"><a name="l00432"></a><span class="lineno"> 432</span>  <span class="keyword">const</span> uint8_t *line = ((<span class="keyword">const</span> uint8_t *)bitmap) + 2 + by * s;</div>
|
|
<div class="line"><a name="l00433"></a><span class="lineno"> 433</span>  uint8_t mask = 0x80;</div>
|
|
<div class="line"><a name="l00434"></a><span class="lineno"> 434</span>  uint8_t value = pgm_read_byte(line);</div>
|
|
<div class="line"><a name="l00435"></a><span class="lineno"> 435</span>  <span class="keywordflow">for</span> (uint8_t bx = 0; bx < w; ++bx) {</div>
|
|
<div class="line"><a name="l00436"></a><span class="lineno"> 436</span>  <span class="keywordflow">if</span> (value & mask)</div>
|
|
<div class="line"><a name="l00437"></a><span class="lineno"> 437</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(x + bx, y + by, color);</div>
|
|
<div class="line"><a name="l00438"></a><span class="lineno"> 438</span>  <span class="keywordflow">else</span></div>
|
|
<div class="line"><a name="l00439"></a><span class="lineno"> 439</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(x + bx, y + by, invColor);</div>
|
|
<div class="line"><a name="l00440"></a><span class="lineno"> 440</span>  mask >>= 1;</div>
|
|
<div class="line"><a name="l00441"></a><span class="lineno"> 441</span>  <span class="keywordflow">if</span> (!mask) {</div>
|
|
<div class="line"><a name="l00442"></a><span class="lineno"> 442</span>  mask = 0x80;</div>
|
|
<div class="line"><a name="l00443"></a><span class="lineno"> 443</span>  ++line;</div>
|
|
<div class="line"><a name="l00444"></a><span class="lineno"> 444</span>  value = pgm_read_byte(line);</div>
|
|
<div class="line"><a name="l00445"></a><span class="lineno"> 445</span>  }</div>
|
|
<div class="line"><a name="l00446"></a><span class="lineno"> 446</span>  }</div>
|
|
<div class="line"><a name="l00447"></a><span class="lineno"> 447</span>  }</div>
|
|
<div class="line"><a name="l00448"></a><span class="lineno"> 448</span> }</div>
|
|
<div class="line"><a name="l00449"></a><span class="lineno"> 449</span> </div>
|
|
<div class="line"><a name="l00509"></a><span class="lineno"> 509</span> <span class="preprocessor">#define fontIsFixed(font) (pgm_read_byte((font)) == 0 && \</span></div>
|
|
<div class="line"><a name="l00510"></a><span class="lineno"> 510</span> <span class="preprocessor"> pgm_read_byte((font) + 1) == 0)</span></div>
|
|
<div class="line"><a name="l00511"></a><span class="lineno"> 511</span> <span class="preprocessor"></span><span class="preprocessor">#define fontWidth(font) (pgm_read_byte((font) + 2))</span></div>
|
|
<div class="line"><a name="l00512"></a><span class="lineno"> 512</span> <span class="preprocessor"></span><span class="preprocessor">#define fontHeight(font) (pgm_read_byte((font) + 3))</span></div>
|
|
<div class="line"><a name="l00513"></a><span class="lineno"> 513</span> <span class="preprocessor"></span><span class="preprocessor">#define fontFirstChar(font) (pgm_read_byte((font) + 4))</span></div>
|
|
<div class="line"><a name="l00514"></a><span class="lineno"> 514</span> <span class="preprocessor"></span><span class="preprocessor">#define fontCharCount(font) (pgm_read_byte((font) + 5))</span></div>
|
|
<div class="line"><a name="l00515"></a><span class="lineno"> 515</span> <span class="preprocessor"></span></div>
|
|
<div class="line"><a name="l00526"></a><span class="lineno"><a class="line" href="classBitmap.html#a3e9bcbfb584d5020bd6f0a313ee275f0"> 526</a></span> <span class="keywordtype">void</span> <a class="code" href="classBitmap.html#a3e9bcbfb584d5020bd6f0a313ee275f0">Bitmap::drawText</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keyword">const</span> <span class="keywordtype">char</span> *str, <span class="keywordtype">int</span> len)</div>
|
|
<div class="line"><a name="l00527"></a><span class="lineno"> 527</span> {</div>
|
|
<div class="line"><a name="l00528"></a><span class="lineno"> 528</span>  <span class="keywordflow">if</span> (!_font)</div>
|
|
<div class="line"><a name="l00529"></a><span class="lineno"> 529</span>  <span class="keywordflow">return</span>;</div>
|
|
<div class="line"><a name="l00530"></a><span class="lineno"> 530</span>  uint8_t <a class="code" href="classBitmap.html#adcd4e3dc7594421e647b0f52da9a41a3">height</a> = fontHeight(_font);</div>
|
|
<div class="line"><a name="l00531"></a><span class="lineno"> 531</span>  <span class="keywordflow">if</span> (len < 0)</div>
|
|
<div class="line"><a name="l00532"></a><span class="lineno"> 532</span>  len = strlen(str);</div>
|
|
<div class="line"><a name="l00533"></a><span class="lineno"> 533</span>  <span class="keywordflow">while</span> (len-- > 0) {</div>
|
|
<div class="line"><a name="l00534"></a><span class="lineno"> 534</span>  x += <a class="code" href="classBitmap.html#a1a11f29863ee7f36a3b15c91963102bd">drawChar</a>(x, y, *str++);</div>
|
|
<div class="line"><a name="l00535"></a><span class="lineno"> 535</span>  <span class="keywordflow">if</span> (len > 0) {</div>
|
|
<div class="line"><a name="l00536"></a><span class="lineno"> 536</span>  <a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">fill</a>(x, y, 1, height, !_textColor);</div>
|
|
<div class="line"><a name="l00537"></a><span class="lineno"> 537</span>  ++x;</div>
|
|
<div class="line"><a name="l00538"></a><span class="lineno"> 538</span>  }</div>
|
|
<div class="line"><a name="l00539"></a><span class="lineno"> 539</span>  <span class="keywordflow">if</span> (x >= _width)</div>
|
|
<div class="line"><a name="l00540"></a><span class="lineno"> 540</span>  <span class="keywordflow">break</span>;</div>
|
|
<div class="line"><a name="l00541"></a><span class="lineno"> 541</span>  }</div>
|
|
<div class="line"><a name="l00542"></a><span class="lineno"> 542</span> }</div>
|
|
<div class="line"><a name="l00543"></a><span class="lineno"> 543</span> </div>
|
|
<div class="line"><a name="l00555"></a><span class="lineno"><a class="line" href="classBitmap.html#a802f5d6bd19a3727670e61e7a88a0cac"> 555</a></span> <span class="keywordtype">void</span> <a class="code" href="classBitmap.html#a3e9bcbfb584d5020bd6f0a313ee275f0">Bitmap::drawText</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keyword">const</span> String &str, <span class="keywordtype">int</span> start, <span class="keywordtype">int</span> len)</div>
|
|
<div class="line"><a name="l00556"></a><span class="lineno"> 556</span> {</div>
|
|
<div class="line"><a name="l00557"></a><span class="lineno"> 557</span>  <span class="keywordflow">if</span> (!_font)</div>
|
|
<div class="line"><a name="l00558"></a><span class="lineno"> 558</span>  <span class="keywordflow">return</span>;</div>
|
|
<div class="line"><a name="l00559"></a><span class="lineno"> 559</span>  uint8_t <a class="code" href="classBitmap.html#adcd4e3dc7594421e647b0f52da9a41a3">height</a> = fontHeight(_font);</div>
|
|
<div class="line"><a name="l00560"></a><span class="lineno"> 560</span>  <span class="keywordflow">if</span> (len < 0)</div>
|
|
<div class="line"><a name="l00561"></a><span class="lineno"> 561</span>  len = str.length() - start;</div>
|
|
<div class="line"><a name="l00562"></a><span class="lineno"> 562</span>  <span class="keywordflow">while</span> (len-- > 0) {</div>
|
|
<div class="line"><a name="l00563"></a><span class="lineno"> 563</span>  x += <a class="code" href="classBitmap.html#a1a11f29863ee7f36a3b15c91963102bd">drawChar</a>(x, y, str[start++]);</div>
|
|
<div class="line"><a name="l00564"></a><span class="lineno"> 564</span>  <span class="keywordflow">if</span> (len > 0) {</div>
|
|
<div class="line"><a name="l00565"></a><span class="lineno"> 565</span>  <a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">fill</a>(x, y, 1, height, !_textColor);</div>
|
|
<div class="line"><a name="l00566"></a><span class="lineno"> 566</span>  ++x;</div>
|
|
<div class="line"><a name="l00567"></a><span class="lineno"> 567</span>  }</div>
|
|
<div class="line"><a name="l00568"></a><span class="lineno"> 568</span>  <span class="keywordflow">if</span> (x >= _width)</div>
|
|
<div class="line"><a name="l00569"></a><span class="lineno"> 569</span>  <span class="keywordflow">break</span>;</div>
|
|
<div class="line"><a name="l00570"></a><span class="lineno"> 570</span>  }</div>
|
|
<div class="line"><a name="l00571"></a><span class="lineno"> 571</span> }</div>
|
|
<div class="line"><a name="l00572"></a><span class="lineno"> 572</span> </div>
|
|
<div class="line"><a name="l00585"></a><span class="lineno"><a class="line" href="classBitmap.html#a1a11f29863ee7f36a3b15c91963102bd"> 585</a></span> <span class="keywordtype">int</span> <a class="code" href="classBitmap.html#a1a11f29863ee7f36a3b15c91963102bd">Bitmap::drawChar</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">char</span> ch)</div>
|
|
<div class="line"><a name="l00586"></a><span class="lineno"> 586</span> {</div>
|
|
<div class="line"><a name="l00587"></a><span class="lineno"> 587</span>  uint8_t <a class="code" href="classBitmap.html#adcd4e3dc7594421e647b0f52da9a41a3">height</a> = fontHeight(_font);</div>
|
|
<div class="line"><a name="l00588"></a><span class="lineno"> 588</span>  <span class="keywordflow">if</span> (ch == <span class="charliteral">' '</span>) {</div>
|
|
<div class="line"><a name="l00589"></a><span class="lineno"> 589</span>  <span class="comment">// Font may not have space, or it is zero-width. Calculate</span></div>
|
|
<div class="line"><a name="l00590"></a><span class="lineno"> 590</span>  <span class="comment">// the real size and fill the space.</span></div>
|
|
<div class="line"><a name="l00591"></a><span class="lineno"> 591</span>  <span class="keywordtype">int</span> spaceWidth = <a class="code" href="classBitmap.html#a9b79ac13077ca865e4515510297780bd">charWidth</a>(<span class="charliteral">'n'</span>);</div>
|
|
<div class="line"><a name="l00592"></a><span class="lineno"> 592</span>  <a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">fill</a>(x, y, spaceWidth, height, !_textColor);</div>
|
|
<div class="line"><a name="l00593"></a><span class="lineno"> 593</span>  <span class="keywordflow">return</span> spaceWidth;</div>
|
|
<div class="line"><a name="l00594"></a><span class="lineno"> 594</span>  }</div>
|
|
<div class="line"><a name="l00595"></a><span class="lineno"> 595</span>  uint8_t first = fontFirstChar(_font);</div>
|
|
<div class="line"><a name="l00596"></a><span class="lineno"> 596</span>  uint8_t count = fontCharCount(_font);</div>
|
|
<div class="line"><a name="l00597"></a><span class="lineno"> 597</span>  uint8_t index = (uint8_t)ch;</div>
|
|
<div class="line"><a name="l00598"></a><span class="lineno"> 598</span>  <span class="keywordflow">if</span> (index < first || index >= (first + count))</div>
|
|
<div class="line"><a name="l00599"></a><span class="lineno"> 599</span>  <span class="keywordflow">return</span> 0;</div>
|
|
<div class="line"><a name="l00600"></a><span class="lineno"> 600</span>  index -= first;</div>
|
|
<div class="line"><a name="l00601"></a><span class="lineno"> 601</span>  uint8_t heightBytes = (height + 7) >> 3;;</div>
|
|
<div class="line"><a name="l00602"></a><span class="lineno"> 602</span>  uint8_t <a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">width</a>;</div>
|
|
<div class="line"><a name="l00603"></a><span class="lineno"> 603</span>  <span class="keyword">const</span> uint8_t *image;</div>
|
|
<div class="line"><a name="l00604"></a><span class="lineno"> 604</span>  <span class="keywordflow">if</span> (fontIsFixed(_font)) {</div>
|
|
<div class="line"><a name="l00605"></a><span class="lineno"> 605</span>  <span class="comment">// Fixed-width font.</span></div>
|
|
<div class="line"><a name="l00606"></a><span class="lineno"> 606</span>  width = fontWidth(_font);</div>
|
|
<div class="line"><a name="l00607"></a><span class="lineno"> 607</span>  image = ((<span class="keyword">const</span> uint8_t *)_font) + 6 + index * heightBytes * <a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">width</a>;</div>
|
|
<div class="line"><a name="l00608"></a><span class="lineno"> 608</span>  } <span class="keywordflow">else</span> {</div>
|
|
<div class="line"><a name="l00609"></a><span class="lineno"> 609</span>  <span class="comment">// Variable-width font.</span></div>
|
|
<div class="line"><a name="l00610"></a><span class="lineno"> 610</span>  width = pgm_read_byte(_font + 6 + index);</div>
|
|
<div class="line"><a name="l00611"></a><span class="lineno"> 611</span>  image = ((<span class="keyword">const</span> uint8_t *)_font) + 6 + count;</div>
|
|
<div class="line"><a name="l00612"></a><span class="lineno"> 612</span>  <span class="keywordflow">for</span> (uint8_t temp = 0; temp < index; ++temp) {</div>
|
|
<div class="line"><a name="l00613"></a><span class="lineno"> 613</span>  <span class="comment">// Scan through all previous characters to find the starting</span></div>
|
|
<div class="line"><a name="l00614"></a><span class="lineno"> 614</span>  <span class="comment">// location for this one.</span></div>
|
|
<div class="line"><a name="l00615"></a><span class="lineno"> 615</span>  image += pgm_read_byte(_font + 6 + temp) * heightBytes;</div>
|
|
<div class="line"><a name="l00616"></a><span class="lineno"> 616</span>  }</div>
|
|
<div class="line"><a name="l00617"></a><span class="lineno"> 617</span>  }</div>
|
|
<div class="line"><a name="l00618"></a><span class="lineno"> 618</span>  <span class="keywordflow">if</span> ((x + width) <= 0 || (y + height) <= 0)</div>
|
|
<div class="line"><a name="l00619"></a><span class="lineno"> 619</span>  <span class="keywordflow">return</span> <a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">width</a>; <span class="comment">// Character is off the top or left of the screen.</span></div>
|
|
<div class="line"><a name="l00620"></a><span class="lineno"> 620</span>  <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> invColor = !_textColor;</div>
|
|
<div class="line"><a name="l00621"></a><span class="lineno"> 621</span>  <span class="keywordflow">for</span> (uint8_t cx = 0; cx < <a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">width</a>; ++cx) {</div>
|
|
<div class="line"><a name="l00622"></a><span class="lineno"> 622</span>  <span class="keywordflow">for</span> (uint8_t cy = 0; cy < heightBytes; ++cy) {</div>
|
|
<div class="line"><a name="l00623"></a><span class="lineno"> 623</span>  uint8_t value = pgm_read_byte(image + cy * width + cx);</div>
|
|
<div class="line"><a name="l00624"></a><span class="lineno"> 624</span>  <span class="keywordtype">int</span> posn;</div>
|
|
<div class="line"><a name="l00625"></a><span class="lineno"> 625</span>  <span class="keywordflow">if</span> (heightBytes > 1 && cy == (heightBytes - 1))</div>
|
|
<div class="line"><a name="l00626"></a><span class="lineno"> 626</span>  posn = height - 8;</div>
|
|
<div class="line"><a name="l00627"></a><span class="lineno"> 627</span>  <span class="keywordflow">else</span></div>
|
|
<div class="line"><a name="l00628"></a><span class="lineno"> 628</span>  posn = cy * 8;</div>
|
|
<div class="line"><a name="l00629"></a><span class="lineno"> 629</span>  <span class="keywordflow">for</span> (uint8_t bit = 0; bit < 8; ++bit) {</div>
|
|
<div class="line"><a name="l00630"></a><span class="lineno"> 630</span>  <span class="keywordflow">if</span> ((posn + bit) >= (cy * 8) && (posn + bit) <= height) {</div>
|
|
<div class="line"><a name="l00631"></a><span class="lineno"> 631</span>  <span class="keywordflow">if</span> (value & 0x01)</div>
|
|
<div class="line"><a name="l00632"></a><span class="lineno"> 632</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(x + cx, y + posn + bit, _textColor);</div>
|
|
<div class="line"><a name="l00633"></a><span class="lineno"> 633</span>  <span class="keywordflow">else</span></div>
|
|
<div class="line"><a name="l00634"></a><span class="lineno"> 634</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(x + cx, y + posn + bit, invColor);</div>
|
|
<div class="line"><a name="l00635"></a><span class="lineno"> 635</span>  }</div>
|
|
<div class="line"><a name="l00636"></a><span class="lineno"> 636</span>  value >>= 1;</div>
|
|
<div class="line"><a name="l00637"></a><span class="lineno"> 637</span>  }</div>
|
|
<div class="line"><a name="l00638"></a><span class="lineno"> 638</span>  }</div>
|
|
<div class="line"><a name="l00639"></a><span class="lineno"> 639</span>  }</div>
|
|
<div class="line"><a name="l00640"></a><span class="lineno"> 640</span>  <span class="keywordflow">return</span> <a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">width</a>;</div>
|
|
<div class="line"><a name="l00641"></a><span class="lineno"> 641</span> }</div>
|
|
<div class="line"><a name="l00642"></a><span class="lineno"> 642</span> </div>
|
|
<div class="line"><a name="l00650"></a><span class="lineno"><a class="line" href="classBitmap.html#a9b79ac13077ca865e4515510297780bd"> 650</a></span> <span class="keywordtype">int</span> <a class="code" href="classBitmap.html#a9b79ac13077ca865e4515510297780bd">Bitmap::charWidth</a>(<span class="keywordtype">char</span> ch)<span class="keyword"> const</span></div>
|
|
<div class="line"><a name="l00651"></a><span class="lineno"> 651</span> <span class="keyword"></span>{</div>
|
|
<div class="line"><a name="l00652"></a><span class="lineno"> 652</span>  uint8_t index = (uint8_t)ch;</div>
|
|
<div class="line"><a name="l00653"></a><span class="lineno"> 653</span>  <span class="keywordflow">if</span> (!_font)</div>
|
|
<div class="line"><a name="l00654"></a><span class="lineno"> 654</span>  <span class="keywordflow">return</span> 0;</div>
|
|
<div class="line"><a name="l00655"></a><span class="lineno"> 655</span>  uint8_t first = fontFirstChar(_font);</div>
|
|
<div class="line"><a name="l00656"></a><span class="lineno"> 656</span>  uint8_t count = fontCharCount(_font);</div>
|
|
<div class="line"><a name="l00657"></a><span class="lineno"> 657</span>  <span class="keywordflow">if</span> (index == <span class="charliteral">' '</span>)</div>
|
|
<div class="line"><a name="l00658"></a><span class="lineno"> 658</span>  index = <span class="charliteral">'n'</span>; <span class="comment">// In case the font does not contain space.</span></div>
|
|
<div class="line"><a name="l00659"></a><span class="lineno"> 659</span>  <span class="keywordflow">if</span> (index < first || index >= (first + count))</div>
|
|
<div class="line"><a name="l00660"></a><span class="lineno"> 660</span>  <span class="keywordflow">return</span> 0;</div>
|
|
<div class="line"><a name="l00661"></a><span class="lineno"> 661</span>  <span class="keywordflow">if</span> (fontIsFixed(_font))</div>
|
|
<div class="line"><a name="l00662"></a><span class="lineno"> 662</span>  <span class="keywordflow">return</span> fontWidth(_font);</div>
|
|
<div class="line"><a name="l00663"></a><span class="lineno"> 663</span>  <span class="keywordflow">else</span></div>
|
|
<div class="line"><a name="l00664"></a><span class="lineno"> 664</span>  <span class="keywordflow">return</span> pgm_read_byte(_font + 6 + (index - first));</div>
|
|
<div class="line"><a name="l00665"></a><span class="lineno"> 665</span> }</div>
|
|
<div class="line"><a name="l00666"></a><span class="lineno"> 666</span> </div>
|
|
<div class="line"><a name="l00675"></a><span class="lineno"><a class="line" href="classBitmap.html#a0f7607b1c7867987f4500d490a666e8a"> 675</a></span> <span class="keywordtype">int</span> <a class="code" href="classBitmap.html#a0f7607b1c7867987f4500d490a666e8a">Bitmap::textWidth</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *str, <span class="keywordtype">int</span> len)<span class="keyword"> const</span></div>
|
|
<div class="line"><a name="l00676"></a><span class="lineno"> 676</span> <span class="keyword"></span>{</div>
|
|
<div class="line"><a name="l00677"></a><span class="lineno"> 677</span>  <span class="keywordtype">int</span> <a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">width</a> = 0;</div>
|
|
<div class="line"><a name="l00678"></a><span class="lineno"> 678</span>  <span class="keywordflow">if</span> (len < 0)</div>
|
|
<div class="line"><a name="l00679"></a><span class="lineno"> 679</span>  len = strlen(str);</div>
|
|
<div class="line"><a name="l00680"></a><span class="lineno"> 680</span>  <span class="keywordflow">while</span> (len-- > 0) {</div>
|
|
<div class="line"><a name="l00681"></a><span class="lineno"> 681</span>  width += <a class="code" href="classBitmap.html#a9b79ac13077ca865e4515510297780bd">charWidth</a>(*str++);</div>
|
|
<div class="line"><a name="l00682"></a><span class="lineno"> 682</span>  <span class="keywordflow">if</span> (len > 0)</div>
|
|
<div class="line"><a name="l00683"></a><span class="lineno"> 683</span>  ++<a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">width</a>;</div>
|
|
<div class="line"><a name="l00684"></a><span class="lineno"> 684</span>  }</div>
|
|
<div class="line"><a name="l00685"></a><span class="lineno"> 685</span>  <span class="keywordflow">return</span> <a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">width</a>;</div>
|
|
<div class="line"><a name="l00686"></a><span class="lineno"> 686</span> }</div>
|
|
<div class="line"><a name="l00687"></a><span class="lineno"> 687</span> </div>
|
|
<div class="line"><a name="l00697"></a><span class="lineno"><a class="line" href="classBitmap.html#a8ca70aa0f8f722a228358bffe794e925"> 697</a></span> <span class="keywordtype">int</span> <a class="code" href="classBitmap.html#a0f7607b1c7867987f4500d490a666e8a">Bitmap::textWidth</a>(<span class="keyword">const</span> String &str, <span class="keywordtype">int</span> start, <span class="keywordtype">int</span> len)<span class="keyword"> const</span></div>
|
|
<div class="line"><a name="l00698"></a><span class="lineno"> 698</span> <span class="keyword"></span>{</div>
|
|
<div class="line"><a name="l00699"></a><span class="lineno"> 699</span>  <span class="keywordtype">int</span> <a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">width</a> = 0;</div>
|
|
<div class="line"><a name="l00700"></a><span class="lineno"> 700</span>  <span class="keywordflow">if</span> (len < 0)</div>
|
|
<div class="line"><a name="l00701"></a><span class="lineno"> 701</span>  len = str.length() - start;</div>
|
|
<div class="line"><a name="l00702"></a><span class="lineno"> 702</span>  <span class="keywordflow">while</span> (len-- > 0) {</div>
|
|
<div class="line"><a name="l00703"></a><span class="lineno"> 703</span>  width += <a class="code" href="classBitmap.html#a9b79ac13077ca865e4515510297780bd">charWidth</a>(str[start++]);</div>
|
|
<div class="line"><a name="l00704"></a><span class="lineno"> 704</span>  <span class="keywordflow">if</span> (len > 0)</div>
|
|
<div class="line"><a name="l00705"></a><span class="lineno"> 705</span>  ++<a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">width</a>;</div>
|
|
<div class="line"><a name="l00706"></a><span class="lineno"> 706</span>  }</div>
|
|
<div class="line"><a name="l00707"></a><span class="lineno"> 707</span>  <span class="keywordflow">return</span> <a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">width</a>;</div>
|
|
<div class="line"><a name="l00708"></a><span class="lineno"> 708</span> }</div>
|
|
<div class="line"><a name="l00709"></a><span class="lineno"> 709</span> </div>
|
|
<div class="line"><a name="l00716"></a><span class="lineno"><a class="line" href="classBitmap.html#a628bb694fcfe6eab619a4f1e152d41c4"> 716</a></span> <span class="keywordtype">int</span> <a class="code" href="classBitmap.html#a628bb694fcfe6eab619a4f1e152d41c4">Bitmap::textHeight</a>()<span class="keyword"> const</span></div>
|
|
<div class="line"><a name="l00717"></a><span class="lineno"> 717</span> <span class="keyword"></span>{</div>
|
|
<div class="line"><a name="l00718"></a><span class="lineno"> 718</span>  <span class="keywordflow">if</span> (_font)</div>
|
|
<div class="line"><a name="l00719"></a><span class="lineno"> 719</span>  <span class="keywordflow">return</span> fontHeight(_font);</div>
|
|
<div class="line"><a name="l00720"></a><span class="lineno"> 720</span>  <span class="keywordflow">else</span></div>
|
|
<div class="line"><a name="l00721"></a><span class="lineno"> 721</span>  <span class="keywordflow">return</span> 0;</div>
|
|
<div class="line"><a name="l00722"></a><span class="lineno"> 722</span> }</div>
|
|
<div class="line"><a name="l00723"></a><span class="lineno"> 723</span> </div>
|
|
<div class="line"><a name="l00738"></a><span class="lineno"><a class="line" href="classBitmap.html#ab22fe1f3871934987a670b559f67c67c"> 738</a></span> <span class="keywordtype">void</span> <a class="code" href="classBitmap.html#ab22fe1f3871934987a670b559f67c67c">Bitmap::copy</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height, <a class="code" href="classBitmap.html">Bitmap</a> *dest, <span class="keywordtype">int</span> destX, <span class="keywordtype">int</span> destY)</div>
|
|
<div class="line"><a name="l00739"></a><span class="lineno"> 739</span> {</div>
|
|
<div class="line"><a name="l00740"></a><span class="lineno"> 740</span>  <span class="keywordflow">if</span> (dest == <span class="keyword">this</span>) {</div>
|
|
<div class="line"><a name="l00741"></a><span class="lineno"> 741</span>  <span class="comment">// Copying to within the same bitmap, so copy in a direction</span></div>
|
|
<div class="line"><a name="l00742"></a><span class="lineno"> 742</span>  <span class="comment">// that will prevent problems with overlap.</span></div>
|
|
<div class="line"><a name="l00743"></a><span class="lineno"> 743</span>  blit(x, y, x + width - 1, y + height - 1, destX, destY);</div>
|
|
<div class="line"><a name="l00744"></a><span class="lineno"> 744</span>  } <span class="keywordflow">else</span> {</div>
|
|
<div class="line"><a name="l00745"></a><span class="lineno"> 745</span>  <span class="comment">// Copying to a different bitmap.</span></div>
|
|
<div class="line"><a name="l00746"></a><span class="lineno"> 746</span>  <span class="keywordflow">while</span> (height > 0) {</div>
|
|
<div class="line"><a name="l00747"></a><span class="lineno"> 747</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> tempx = 0; tempx < <a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">width</a>; ++tempx)</div>
|
|
<div class="line"><a name="l00748"></a><span class="lineno"> 748</span>  dest-><a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(destX + tempx, destY, <a class="code" href="classBitmap.html#a35aa38b377d509d6c4f061a0b988d203">pixel</a>(x + tempx, y));</div>
|
|
<div class="line"><a name="l00749"></a><span class="lineno"> 749</span>  ++y;</div>
|
|
<div class="line"><a name="l00750"></a><span class="lineno"> 750</span>  ++destY;</div>
|
|
<div class="line"><a name="l00751"></a><span class="lineno"> 751</span>  --<a class="code" href="classBitmap.html#adcd4e3dc7594421e647b0f52da9a41a3">height</a>;</div>
|
|
<div class="line"><a name="l00752"></a><span class="lineno"> 752</span>  }</div>
|
|
<div class="line"><a name="l00753"></a><span class="lineno"> 753</span>  }</div>
|
|
<div class="line"><a name="l00754"></a><span class="lineno"> 754</span> }</div>
|
|
<div class="line"><a name="l00755"></a><span class="lineno"> 755</span> </div>
|
|
<div class="line"><a name="l00762"></a><span class="lineno"><a class="line" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2"> 762</a></span> <span class="keywordtype">void</span> <a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">Bitmap::fill</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height, <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> color)</div>
|
|
<div class="line"><a name="l00763"></a><span class="lineno"> 763</span> {</div>
|
|
<div class="line"><a name="l00764"></a><span class="lineno"> 764</span>  <span class="keywordflow">while</span> (height > 0) {</div>
|
|
<div class="line"><a name="l00765"></a><span class="lineno"> 765</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> temp = 0; temp < <a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">width</a>; ++temp)</div>
|
|
<div class="line"><a name="l00766"></a><span class="lineno"> 766</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(x + temp, y, color);</div>
|
|
<div class="line"><a name="l00767"></a><span class="lineno"> 767</span>  ++y;</div>
|
|
<div class="line"><a name="l00768"></a><span class="lineno"> 768</span>  --<a class="code" href="classBitmap.html#adcd4e3dc7594421e647b0f52da9a41a3">height</a>;</div>
|
|
<div class="line"><a name="l00769"></a><span class="lineno"> 769</span>  }</div>
|
|
<div class="line"><a name="l00770"></a><span class="lineno"> 770</span> }</div>
|
|
<div class="line"><a name="l00771"></a><span class="lineno"> 771</span> </div>
|
|
<div class="line"><a name="l00785"></a><span class="lineno"><a class="line" href="classBitmap.html#ac661adab340858b541a2fe44e6303f56"> 785</a></span> <span class="keywordtype">void</span> <a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">Bitmap::fill</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height, <a class="code" href="classBitmap.html#a2fcc98fd7580932b218134126a29ce43">Bitmap::ProgMem</a> pattern, <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> color)</div>
|
|
<div class="line"><a name="l00786"></a><span class="lineno"> 786</span> {</div>
|
|
<div class="line"><a name="l00787"></a><span class="lineno"> 787</span>  uint8_t w = pgm_read_byte(pattern);</div>
|
|
<div class="line"><a name="l00788"></a><span class="lineno"> 788</span>  uint8_t s = (w + 7) >> 3;</div>
|
|
<div class="line"><a name="l00789"></a><span class="lineno"> 789</span>  uint8_t h = pgm_read_byte(pattern + 1);</div>
|
|
<div class="line"><a name="l00790"></a><span class="lineno"> 790</span>  <span class="keywordflow">if</span> (!w || !h)</div>
|
|
<div class="line"><a name="l00791"></a><span class="lineno"> 791</span>  <span class="keywordflow">return</span>;</div>
|
|
<div class="line"><a name="l00792"></a><span class="lineno"> 792</span>  <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> invColor = !color;</div>
|
|
<div class="line"><a name="l00793"></a><span class="lineno"> 793</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> tempy = 0; tempy < <a class="code" href="classBitmap.html#adcd4e3dc7594421e647b0f52da9a41a3">height</a>; ++tempy) {</div>
|
|
<div class="line"><a name="l00794"></a><span class="lineno"> 794</span>  <span class="keyword">const</span> uint8_t *startLine = ((<span class="keyword">const</span> uint8_t *)pattern) + 2 + (tempy % h) * s;</div>
|
|
<div class="line"><a name="l00795"></a><span class="lineno"> 795</span>  <span class="keyword">const</span> uint8_t *line = startLine;</div>
|
|
<div class="line"><a name="l00796"></a><span class="lineno"> 796</span>  uint8_t mask = 0x80;</div>
|
|
<div class="line"><a name="l00797"></a><span class="lineno"> 797</span>  uint8_t value = pgm_read_byte(line++);</div>
|
|
<div class="line"><a name="l00798"></a><span class="lineno"> 798</span>  <span class="keywordtype">int</span> bit = 0;</div>
|
|
<div class="line"><a name="l00799"></a><span class="lineno"> 799</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> tempx = 0; tempx < <a class="code" href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">width</a>; ++tempx) {</div>
|
|
<div class="line"><a name="l00800"></a><span class="lineno"> 800</span>  <span class="keywordflow">if</span> (value & mask)</div>
|
|
<div class="line"><a name="l00801"></a><span class="lineno"> 801</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(x + tempx, y + tempy, color);</div>
|
|
<div class="line"><a name="l00802"></a><span class="lineno"> 802</span>  <span class="keywordflow">else</span></div>
|
|
<div class="line"><a name="l00803"></a><span class="lineno"> 803</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(x + tempx, y + tempy, invColor);</div>
|
|
<div class="line"><a name="l00804"></a><span class="lineno"> 804</span>  <span class="keywordflow">if</span> (++bit >= w) {</div>
|
|
<div class="line"><a name="l00805"></a><span class="lineno"> 805</span>  mask = 0x80;</div>
|
|
<div class="line"><a name="l00806"></a><span class="lineno"> 806</span>  line = startLine;</div>
|
|
<div class="line"><a name="l00807"></a><span class="lineno"> 807</span>  value = pgm_read_byte(line++);</div>
|
|
<div class="line"><a name="l00808"></a><span class="lineno"> 808</span>  bit = 0;</div>
|
|
<div class="line"><a name="l00809"></a><span class="lineno"> 809</span>  } <span class="keywordflow">else</span> {</div>
|
|
<div class="line"><a name="l00810"></a><span class="lineno"> 810</span>  mask >>= 1;</div>
|
|
<div class="line"><a name="l00811"></a><span class="lineno"> 811</span>  <span class="keywordflow">if</span> (!mask) {</div>
|
|
<div class="line"><a name="l00812"></a><span class="lineno"> 812</span>  mask = 0x80;</div>
|
|
<div class="line"><a name="l00813"></a><span class="lineno"> 813</span>  value = pgm_read_byte(line++);</div>
|
|
<div class="line"><a name="l00814"></a><span class="lineno"> 814</span>  }</div>
|
|
<div class="line"><a name="l00815"></a><span class="lineno"> 815</span>  }</div>
|
|
<div class="line"><a name="l00816"></a><span class="lineno"> 816</span>  }</div>
|
|
<div class="line"><a name="l00817"></a><span class="lineno"> 817</span>  }</div>
|
|
<div class="line"><a name="l00818"></a><span class="lineno"> 818</span> }</div>
|
|
<div class="line"><a name="l00819"></a><span class="lineno"> 819</span> </div>
|
|
<div class="line"><a name="l00841"></a><span class="lineno"><a class="line" href="classBitmap.html#af79ad4432297ff453fddc55625fec485"> 841</a></span> <span class="keywordtype">void</span> <a class="code" href="classBitmap.html#ae08eb6f9086f9923d8dc83a469ae4c4a">Bitmap::scroll</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height, <span class="keywordtype">int</span> dx, <span class="keywordtype">int</span> dy, <a class="code" href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Color</a> fillColor)</div>
|
|
<div class="line"><a name="l00842"></a><span class="lineno"> 842</span> {</div>
|
|
<div class="line"><a name="l00843"></a><span class="lineno"> 843</span>  <span class="comment">// Bail out if no scrolling at all.</span></div>
|
|
<div class="line"><a name="l00844"></a><span class="lineno"> 844</span>  <span class="keywordflow">if</span> (!dx && !dy)</div>
|
|
<div class="line"><a name="l00845"></a><span class="lineno"> 845</span>  <span class="keywordflow">return</span>;</div>
|
|
<div class="line"><a name="l00846"></a><span class="lineno"> 846</span> </div>
|
|
<div class="line"><a name="l00847"></a><span class="lineno"> 847</span>  <span class="comment">// Clamp the scroll region to the extents of the bitmap.</span></div>
|
|
<div class="line"><a name="l00848"></a><span class="lineno"> 848</span>  <span class="keywordflow">if</span> (x < 0) {</div>
|
|
<div class="line"><a name="l00849"></a><span class="lineno"> 849</span>  width += x;</div>
|
|
<div class="line"><a name="l00850"></a><span class="lineno"> 850</span>  x = 0;</div>
|
|
<div class="line"><a name="l00851"></a><span class="lineno"> 851</span>  }</div>
|
|
<div class="line"><a name="l00852"></a><span class="lineno"> 852</span>  <span class="keywordflow">if</span> (y < 0) {</div>
|
|
<div class="line"><a name="l00853"></a><span class="lineno"> 853</span>  height += y;</div>
|
|
<div class="line"><a name="l00854"></a><span class="lineno"> 854</span>  y = 0;</div>
|
|
<div class="line"><a name="l00855"></a><span class="lineno"> 855</span>  }</div>
|
|
<div class="line"><a name="l00856"></a><span class="lineno"> 856</span>  <span class="keywordflow">if</span> ((x + width) > _width)</div>
|
|
<div class="line"><a name="l00857"></a><span class="lineno"> 857</span>  width = _width - x;</div>
|
|
<div class="line"><a name="l00858"></a><span class="lineno"> 858</span>  <span class="keywordflow">if</span> ((y + height) > _height)</div>
|
|
<div class="line"><a name="l00859"></a><span class="lineno"> 859</span>  height = _height - y;</div>
|
|
<div class="line"><a name="l00860"></a><span class="lineno"> 860</span>  <span class="keywordflow">if</span> (width <= 0 || height <= 0)</div>
|
|
<div class="line"><a name="l00861"></a><span class="lineno"> 861</span>  <span class="keywordflow">return</span>;</div>
|
|
<div class="line"><a name="l00862"></a><span class="lineno"> 862</span> </div>
|
|
<div class="line"><a name="l00863"></a><span class="lineno"> 863</span>  <span class="comment">// Scroll the region in the specified direction.</span></div>
|
|
<div class="line"><a name="l00864"></a><span class="lineno"> 864</span>  <span class="keywordflow">if</span> (dy < 0) {</div>
|
|
<div class="line"><a name="l00865"></a><span class="lineno"> 865</span>  <span class="keywordflow">if</span> (dx < 0)</div>
|
|
<div class="line"><a name="l00866"></a><span class="lineno"> 866</span>  blit(x - dx, y - dy, x + width - 1 + dx, y + height - 1 + dy, x, y);</div>
|
|
<div class="line"><a name="l00867"></a><span class="lineno"> 867</span>  <span class="keywordflow">else</span></div>
|
|
<div class="line"><a name="l00868"></a><span class="lineno"> 868</span>  blit(x, y - dy, x + width - 1 - dx, y + height - 1 + dy, x + dx, y);</div>
|
|
<div class="line"><a name="l00869"></a><span class="lineno"> 869</span>  } <span class="keywordflow">else</span> {</div>
|
|
<div class="line"><a name="l00870"></a><span class="lineno"> 870</span>  <span class="keywordflow">if</span> (dx < 0)</div>
|
|
<div class="line"><a name="l00871"></a><span class="lineno"> 871</span>  blit(x - dx, y, x + width - 1 + dx, y + height - 1 - dy, x, y + dy);</div>
|
|
<div class="line"><a name="l00872"></a><span class="lineno"> 872</span>  <span class="keywordflow">else</span></div>
|
|
<div class="line"><a name="l00873"></a><span class="lineno"> 873</span>  blit(x, y, x + width - 1 - dx, y + height - 1 - dy, x + dx, y + dy);</div>
|
|
<div class="line"><a name="l00874"></a><span class="lineno"> 874</span>  }</div>
|
|
<div class="line"><a name="l00875"></a><span class="lineno"> 875</span> </div>
|
|
<div class="line"><a name="l00876"></a><span class="lineno"> 876</span>  <span class="comment">// Fill the pixels that were uncovered by the scroll.</span></div>
|
|
<div class="line"><a name="l00877"></a><span class="lineno"> 877</span>  <span class="keywordflow">if</span> (dy < 0) {</div>
|
|
<div class="line"><a name="l00878"></a><span class="lineno"> 878</span>  <a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">fill</a>(x, y + height + dy, width, -dy, fillColor);</div>
|
|
<div class="line"><a name="l00879"></a><span class="lineno"> 879</span>  <span class="keywordflow">if</span> (dx < 0)</div>
|
|
<div class="line"><a name="l00880"></a><span class="lineno"> 880</span>  <a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">fill</a>(x + width + dx, y, -dx, height + dy, fillColor);</div>
|
|
<div class="line"><a name="l00881"></a><span class="lineno"> 881</span>  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dx > 0)</div>
|
|
<div class="line"><a name="l00882"></a><span class="lineno"> 882</span>  <a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">fill</a>(x, y, dx, height + dy, fillColor);</div>
|
|
<div class="line"><a name="l00883"></a><span class="lineno"> 883</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dy > 0) {</div>
|
|
<div class="line"><a name="l00884"></a><span class="lineno"> 884</span>  <a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">fill</a>(x, y, width, -dy, fillColor);</div>
|
|
<div class="line"><a name="l00885"></a><span class="lineno"> 885</span>  <span class="keywordflow">if</span> (dx < 0)</div>
|
|
<div class="line"><a name="l00886"></a><span class="lineno"> 886</span>  <a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">fill</a>(x + width + dx, y + dy, -dx, height - dy, fillColor);</div>
|
|
<div class="line"><a name="l00887"></a><span class="lineno"> 887</span>  <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dx > 0)</div>
|
|
<div class="line"><a name="l00888"></a><span class="lineno"> 888</span>  <a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">fill</a>(x, y + dy, dx, height - dy, fillColor);</div>
|
|
<div class="line"><a name="l00889"></a><span class="lineno"> 889</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dx < 0) {</div>
|
|
<div class="line"><a name="l00890"></a><span class="lineno"> 890</span>  <a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">fill</a>(x + width + dx, y, -dx, height, fillColor);</div>
|
|
<div class="line"><a name="l00891"></a><span class="lineno"> 891</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dx > 0) {</div>
|
|
<div class="line"><a name="l00892"></a><span class="lineno"> 892</span>  <a class="code" href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">fill</a>(x, y, dx, height, fillColor);</div>
|
|
<div class="line"><a name="l00893"></a><span class="lineno"> 893</span>  }</div>
|
|
<div class="line"><a name="l00894"></a><span class="lineno"> 894</span> }</div>
|
|
<div class="line"><a name="l00895"></a><span class="lineno"> 895</span> </div>
|
|
<div class="line"><a name="l00902"></a><span class="lineno"><a class="line" href="classBitmap.html#a6d85556bcc9fac91d33f0f6f7a6430dd"> 902</a></span> <span class="keywordtype">void</span> <a class="code" href="classBitmap.html#a6d85556bcc9fac91d33f0f6f7a6430dd">Bitmap::invert</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, <span class="keywordtype">int</span> width, <span class="keywordtype">int</span> height)</div>
|
|
<div class="line"><a name="l00903"></a><span class="lineno"> 903</span> {</div>
|
|
<div class="line"><a name="l00904"></a><span class="lineno"> 904</span>  <span class="keywordflow">while</span> (height > 0) {</div>
|
|
<div class="line"><a name="l00905"></a><span class="lineno"> 905</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> tempx = x + width - 1; tempx >= x; --tempx)</div>
|
|
<div class="line"><a name="l00906"></a><span class="lineno"> 906</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(tempx, y, !<a class="code" href="classBitmap.html#a35aa38b377d509d6c4f061a0b988d203">pixel</a>(tempx, y));</div>
|
|
<div class="line"><a name="l00907"></a><span class="lineno"> 907</span>  --<a class="code" href="classBitmap.html#adcd4e3dc7594421e647b0f52da9a41a3">height</a>;</div>
|
|
<div class="line"><a name="l00908"></a><span class="lineno"> 908</span>  ++y;</div>
|
|
<div class="line"><a name="l00909"></a><span class="lineno"> 909</span>  }</div>
|
|
<div class="line"><a name="l00910"></a><span class="lineno"> 910</span> }</div>
|
|
<div class="line"><a name="l00911"></a><span class="lineno"> 911</span> </div>
|
|
<div class="line"><a name="l00912"></a><span class="lineno"> 912</span> <span class="keywordtype">void</span> Bitmap::blit(<span class="keywordtype">int</span> x1, <span class="keywordtype">int</span> y1, <span class="keywordtype">int</span> x2, <span class="keywordtype">int</span> y2, <span class="keywordtype">int</span> x3, <span class="keywordtype">int</span> y3)</div>
|
|
<div class="line"><a name="l00913"></a><span class="lineno"> 913</span> {</div>
|
|
<div class="line"><a name="l00914"></a><span class="lineno"> 914</span>  <span class="keywordflow">if</span> (y3 < y1 || (y1 == y3 && x3 <= x1)) {</div>
|
|
<div class="line"><a name="l00915"></a><span class="lineno"> 915</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> tempy = y1; tempy <= y2; ++tempy) {</div>
|
|
<div class="line"><a name="l00916"></a><span class="lineno"> 916</span>  <span class="keywordtype">int</span> y = y1 - tempy + y3;</div>
|
|
<div class="line"><a name="l00917"></a><span class="lineno"> 917</span>  <span class="keywordtype">int</span> x = x3 - x1;</div>
|
|
<div class="line"><a name="l00918"></a><span class="lineno"> 918</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> tempx = x1; tempx <= x2; ++tempx)</div>
|
|
<div class="line"><a name="l00919"></a><span class="lineno"> 919</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(x + tempx, y, <a class="code" href="classBitmap.html#a35aa38b377d509d6c4f061a0b988d203">pixel</a>(tempx, tempy));</div>
|
|
<div class="line"><a name="l00920"></a><span class="lineno"> 920</span>  }</div>
|
|
<div class="line"><a name="l00921"></a><span class="lineno"> 921</span>  } <span class="keywordflow">else</span> {</div>
|
|
<div class="line"><a name="l00922"></a><span class="lineno"> 922</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> tempy = y2; tempy >= y1; --tempy) {</div>
|
|
<div class="line"><a name="l00923"></a><span class="lineno"> 923</span>  <span class="keywordtype">int</span> y = y1 - tempy + y3;</div>
|
|
<div class="line"><a name="l00924"></a><span class="lineno"> 924</span>  <span class="keywordtype">int</span> x = x3 - x1;</div>
|
|
<div class="line"><a name="l00925"></a><span class="lineno"> 925</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> tempx = x2; tempx >= x1; --tempx)</div>
|
|
<div class="line"><a name="l00926"></a><span class="lineno"> 926</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(x + tempx, y, <a class="code" href="classBitmap.html#a35aa38b377d509d6c4f061a0b988d203">pixel</a>(tempx, tempy));</div>
|
|
<div class="line"><a name="l00927"></a><span class="lineno"> 927</span>  }</div>
|
|
<div class="line"><a name="l00928"></a><span class="lineno"> 928</span>  }</div>
|
|
<div class="line"><a name="l00929"></a><span class="lineno"> 929</span> }</div>
|
|
<div class="line"><a name="l00930"></a><span class="lineno"> 930</span> </div>
|
|
<div class="line"><a name="l00931"></a><span class="lineno"> 931</span> <span class="keywordtype">void</span> Bitmap::drawCirclePoints(<span class="keywordtype">int</span> centerX, <span class="keywordtype">int</span> centerY, <span class="keywordtype">int</span> radius, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y, Color borderColor, Color fillColor)</div>
|
|
<div class="line"><a name="l00932"></a><span class="lineno"> 932</span> {</div>
|
|
<div class="line"><a name="l00933"></a><span class="lineno"> 933</span>  <span class="keywordflow">if</span> (x != y) {</div>
|
|
<div class="line"><a name="l00934"></a><span class="lineno"> 934</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(centerX + x, centerY + y, borderColor);</div>
|
|
<div class="line"><a name="l00935"></a><span class="lineno"> 935</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(centerX + y, centerY + x, borderColor);</div>
|
|
<div class="line"><a name="l00936"></a><span class="lineno"> 936</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(centerX + y, centerY - x, borderColor);</div>
|
|
<div class="line"><a name="l00937"></a><span class="lineno"> 937</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(centerX + x, centerY - y, borderColor);</div>
|
|
<div class="line"><a name="l00938"></a><span class="lineno"> 938</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(centerX - x, centerY - y, borderColor);</div>
|
|
<div class="line"><a name="l00939"></a><span class="lineno"> 939</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(centerX - y, centerY - x, borderColor);</div>
|
|
<div class="line"><a name="l00940"></a><span class="lineno"> 940</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(centerX - y, centerY + x, borderColor);</div>
|
|
<div class="line"><a name="l00941"></a><span class="lineno"> 941</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(centerX - x, centerY + y, borderColor);</div>
|
|
<div class="line"><a name="l00942"></a><span class="lineno"> 942</span>  <span class="keywordflow">if</span> (fillColor != <a class="code" href="classBitmap.html#aa89170263dc1f51f6366c1907119715e">NoFill</a>) {</div>
|
|
<div class="line"><a name="l00943"></a><span class="lineno"> 943</span>  <span class="keywordflow">if</span> (radius > 1) {</div>
|
|
<div class="line"><a name="l00944"></a><span class="lineno"> 944</span>  <a class="code" href="classBitmap.html#aa0a84f3694e343d68e7021552c69f767">drawLine</a>(centerX - x + 1, centerY + y, centerX + x - 1, centerY + y, fillColor);</div>
|
|
<div class="line"><a name="l00945"></a><span class="lineno"> 945</span>  <a class="code" href="classBitmap.html#aa0a84f3694e343d68e7021552c69f767">drawLine</a>(centerX - y + 1, centerY + x, centerX + y - 1, centerY + x, fillColor);</div>
|
|
<div class="line"><a name="l00946"></a><span class="lineno"> 946</span>  <a class="code" href="classBitmap.html#aa0a84f3694e343d68e7021552c69f767">drawLine</a>(centerX - x + 1, centerY - y, centerX + x - 1, centerY - y, fillColor);</div>
|
|
<div class="line"><a name="l00947"></a><span class="lineno"> 947</span>  <a class="code" href="classBitmap.html#aa0a84f3694e343d68e7021552c69f767">drawLine</a>(centerX - y + 1, centerY - x, centerX + y - 1, centerY - x, fillColor);</div>
|
|
<div class="line"><a name="l00948"></a><span class="lineno"> 948</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (radius == 1) {</div>
|
|
<div class="line"><a name="l00949"></a><span class="lineno"> 949</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(centerX, centerY, fillColor);</div>
|
|
<div class="line"><a name="l00950"></a><span class="lineno"> 950</span>  }</div>
|
|
<div class="line"><a name="l00951"></a><span class="lineno"> 951</span>  }</div>
|
|
<div class="line"><a name="l00952"></a><span class="lineno"> 952</span>  } <span class="keywordflow">else</span> {</div>
|
|
<div class="line"><a name="l00953"></a><span class="lineno"> 953</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(centerX + x, centerY + y, borderColor);</div>
|
|
<div class="line"><a name="l00954"></a><span class="lineno"> 954</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(centerX + y, centerY - x, borderColor);</div>
|
|
<div class="line"><a name="l00955"></a><span class="lineno"> 955</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(centerX - x, centerY - y, borderColor);</div>
|
|
<div class="line"><a name="l00956"></a><span class="lineno"> 956</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(centerX - y, centerY + x, borderColor);</div>
|
|
<div class="line"><a name="l00957"></a><span class="lineno"> 957</span>  <span class="keywordflow">if</span> (fillColor != <a class="code" href="classBitmap.html#aa89170263dc1f51f6366c1907119715e">NoFill</a>) {</div>
|
|
<div class="line"><a name="l00958"></a><span class="lineno"> 958</span>  <span class="keywordflow">if</span> (radius > 1) {</div>
|
|
<div class="line"><a name="l00959"></a><span class="lineno"> 959</span>  <a class="code" href="classBitmap.html#aa0a84f3694e343d68e7021552c69f767">drawLine</a>(centerX - x + 1, centerY + y, centerX + x - 1, centerY + y, fillColor);</div>
|
|
<div class="line"><a name="l00960"></a><span class="lineno"> 960</span>  <a class="code" href="classBitmap.html#aa0a84f3694e343d68e7021552c69f767">drawLine</a>(centerX - x + 1, centerY - y, centerX + x - 1, centerY - y, fillColor);</div>
|
|
<div class="line"><a name="l00961"></a><span class="lineno"> 961</span>  } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (radius == 1) {</div>
|
|
<div class="line"><a name="l00962"></a><span class="lineno"> 962</span>  <a class="code" href="classBitmap.html#aac994b75418e7d37ec66829437329114">setPixel</a>(centerX, centerY, fillColor);</div>
|
|
<div class="line"><a name="l00963"></a><span class="lineno"> 963</span>  }</div>
|
|
<div class="line"><a name="l00964"></a><span class="lineno"> 964</span>  }</div>
|
|
<div class="line"><a name="l00965"></a><span class="lineno"> 965</span>  }</div>
|
|
<div class="line"><a name="l00966"></a><span class="lineno"> 966</span> }</div>
|
|
<div class="ttc" id="classBitmap_html_a76c3b49e535761f07c553e7336daf523"><div class="ttname"><a href="classBitmap.html#a76c3b49e535761f07c553e7336daf523">Bitmap::width</a></div><div class="ttdeci">int width() const </div><div class="ttdoc">Returns the width of the bitmap in pixels. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8h_source.html#l00048">Bitmap.h:48</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_ab22fe1f3871934987a670b559f67c67c"><div class="ttname"><a href="classBitmap.html#ab22fe1f3871934987a670b559f67c67c">Bitmap::copy</a></div><div class="ttdeci">void copy(int x, int y, int width, int height, Bitmap *dest, int destX, int destY)</div><div class="ttdoc">Copies the width x height pixels starting at top-left corner (x, y) to (destX, destY) in the bitmap d...</div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00738">Bitmap.cpp:738</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_ae08eb6f9086f9923d8dc83a469ae4c4a"><div class="ttname"><a href="classBitmap.html#ae08eb6f9086f9923d8dc83a469ae4c4a">Bitmap::scroll</a></div><div class="ttdeci">void scroll(int dx, int dy, Color fillColor=Black)</div><div class="ttdoc">Scrolls the entire contents of the bitmap by dx and dy. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8h_source.html#l00135">Bitmap.h:135</a></div></div>
|
|
<div class="ttc" id="classBitmap_html"><div class="ttname"><a href="classBitmap.html">Bitmap</a></div><div class="ttdoc">Represents a monochrome bitmap within main memory. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8h_source.html#l00032">Bitmap.h:32</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_aac61e3f7f625db568e37d88b52b3b2fc"><div class="ttname"><a href="classBitmap.html#aac61e3f7f625db568e37d88b52b3b2fc">Bitmap::drawRect</a></div><div class="ttdeci">void drawRect(int x1, int y1, int x2, int y2, Color borderColor=White, Color fillColor=NoFill)</div><div class="ttdoc">Draws a rectangle from (x1, y1) to (x2, y2), with the outline in borderColor and the interior filled ...</div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00286">Bitmap.cpp:286</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_aac994b75418e7d37ec66829437329114"><div class="ttname"><a href="classBitmap.html#aac994b75418e7d37ec66829437329114">Bitmap::setPixel</a></div><div class="ttdeci">void setPixel(int x, int y, Color color)</div><div class="ttdoc">Sets the pixel at (x, y) to color. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00208">Bitmap.cpp:208</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_aa0a84f3694e343d68e7021552c69f767"><div class="ttname"><a href="classBitmap.html#aa0a84f3694e343d68e7021552c69f767">Bitmap::drawLine</a></div><div class="ttdeci">void drawLine(int x1, int y1, int x2, int y2, Color color=White)</div><div class="ttdoc">Draws a line from (x1, y1) to (x2, y2) in color. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00225">Bitmap.cpp:225</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a491e9c0bb20ddf5a5eb4933077c8ed72"><div class="ttname"><a href="classBitmap.html#a491e9c0bb20ddf5a5eb4933077c8ed72">Bitmap::drawBitmap</a></div><div class="ttdeci">void drawBitmap(int x, int y, const Bitmap &bitmap, Color color=White)</div><div class="ttdoc">Draws bitmap at (x, y) in color. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00388">Bitmap.cpp:388</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a933763a4f3cba79fbcf97ae6d0a864aa"><div class="ttname"><a href="classBitmap.html#a933763a4f3cba79fbcf97ae6d0a864aa">Bitmap::drawCircle</a></div><div class="ttdeci">void drawCircle(int centerX, int centerY, int radius, Color borderColor=White, Color fillColor=NoFill)</div><div class="ttdoc">Draws a circle with a specific center (centerX, centerY) and radius, with the outline in borderColor ...</div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00334">Bitmap.cpp:334</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a1a11f29863ee7f36a3b15c91963102bd"><div class="ttname"><a href="classBitmap.html#a1a11f29863ee7f36a3b15c91963102bd">Bitmap::drawChar</a></div><div class="ttdeci">int drawChar(int x, int y, char ch)</div><div class="ttdoc">Draws a single character ch at (x, y). </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00585">Bitmap.cpp:585</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a2fcc98fd7580932b218134126a29ce43"><div class="ttname"><a href="classBitmap.html#a2fcc98fd7580932b218134126a29ce43">Bitmap::ProgMem</a></div><div class="ttdeci">PGM_VOID_P ProgMem</div><div class="ttdoc">Type that represents a bitmap within program memory. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8h_source.html#l00041">Bitmap.h:41</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a88d386944a7017aa776a177b10d8b2ba"><div class="ttname"><a href="classBitmap.html#a88d386944a7017aa776a177b10d8b2ba">Bitmap::Color</a></div><div class="ttdeci">uint8_t Color</div><div class="ttdoc">Type that represents the color of a pixel in a bitmap. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8h_source.html#l00040">Bitmap.h:40</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_adcd4e3dc7594421e647b0f52da9a41a3"><div class="ttname"><a href="classBitmap.html#adcd4e3dc7594421e647b0f52da9a41a3">Bitmap::height</a></div><div class="ttdeci">int height() const </div><div class="ttdoc">Returns the height of the bitmap in pixels. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8h_source.html#l00049">Bitmap.h:49</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_aa89170263dc1f51f6366c1907119715e"><div class="ttname"><a href="classBitmap.html#aa89170263dc1f51f6366c1907119715e">Bitmap::NoFill</a></div><div class="ttdeci">static const Color NoFill</div><div class="ttdoc">Special color value that is used with drawRect() and drawCircle() to indicate that the interior of th...</div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8h_source.html#l00046">Bitmap.h:46</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a0f7607b1c7867987f4500d490a666e8a"><div class="ttname"><a href="classBitmap.html#a0f7607b1c7867987f4500d490a666e8a">Bitmap::textWidth</a></div><div class="ttdeci">int textWidth(const char *str, int len=-1) const </div><div class="ttdoc">Returns the width in pixels of the len characters of str in the current font(), including inter-chara...</div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00675">Bitmap.cpp:675</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a99da820f9280aace6b512801d5a5e2b2"><div class="ttname"><a href="classBitmap.html#a99da820f9280aace6b512801d5a5e2b2">Bitmap::fill</a></div><div class="ttdeci">void fill(int x, int y, int width, int height, Color color)</div><div class="ttdoc">Fills the width x height pixels starting at top-left corner (x, y) with color. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00762">Bitmap.cpp:762</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a5eeed27c176eb6e4a2c39ea83444e27d"><div class="ttname"><a href="classBitmap.html#a5eeed27c176eb6e4a2c39ea83444e27d">Bitmap::data</a></div><div class="ttdeci">uint8_t * data()</div><div class="ttdoc">Returns a pointer to the start of the bitmap's data buffer. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8h_source.html#l00053">Bitmap.h:53</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a628bb694fcfe6eab619a4f1e152d41c4"><div class="ttname"><a href="classBitmap.html#a628bb694fcfe6eab619a4f1e152d41c4">Bitmap::textHeight</a></div><div class="ttdeci">int textHeight() const </div><div class="ttdoc">Returns the height in pixels of the current text drawing font(); or zero if font() is not set...</div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00716">Bitmap.cpp:716</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a9b79ac13077ca865e4515510297780bd"><div class="ttname"><a href="classBitmap.html#a9b79ac13077ca865e4515510297780bd">Bitmap::charWidth</a></div><div class="ttdeci">int charWidth(char ch) const </div><div class="ttdoc">Returns the width in pixels of ch in the current font(). </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00650">Bitmap.cpp:650</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a40526748415c8bbc58a8510d636c20f4"><div class="ttname"><a href="classBitmap.html#a40526748415c8bbc58a8510d636c20f4">Bitmap::Bitmap</a></div><div class="ttdeci">Bitmap(int width, int height)</div><div class="ttdoc">Constructs a new in-memory bitmap that is width x height pixels in size. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00088">Bitmap.cpp:88</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a39b6754cfe50a457bbfdb1980fd87eb7"><div class="ttname"><a href="classBitmap.html#a39b6754cfe50a457bbfdb1980fd87eb7">Bitmap::White</a></div><div class="ttdeci">static const Color White</div><div class="ttdoc">Color value corresponding to "white". If the bitmap is displayed on a LED array, then it may have a d...</div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8h_source.html#l00045">Bitmap.h:45</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_af30df263729385ea2330effe3c80a1bc"><div class="ttname"><a href="classBitmap.html#af30df263729385ea2330effe3c80a1bc">Bitmap::stride</a></div><div class="ttdeci">int stride() const </div><div class="ttdoc">Returns the number of bytes in each line of the bitmap's data() buffer. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8h_source.html#l00050">Bitmap.h:50</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a2c7faeeb89d3624b5bbca58871785adc"><div class="ttname"><a href="classBitmap.html#a2c7faeeb89d3624b5bbca58871785adc">Bitmap::Black</a></div><div class="ttdeci">static const Color Black</div><div class="ttdoc">Color value corresponding to "black". </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8h_source.html#l00044">Bitmap.h:44</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a839dc8fab05a5ebf7a6b2e61436b2fa1"><div class="ttname"><a href="classBitmap.html#a839dc8fab05a5ebf7a6b2e61436b2fa1">Bitmap::clear</a></div><div class="ttdeci">void clear(Color color=Black)</div><div class="ttdoc">Clears the entire bitmap to the specified color. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00174">Bitmap.cpp:174</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a6d85556bcc9fac91d33f0f6f7a6430dd"><div class="ttname"><a href="classBitmap.html#a6d85556bcc9fac91d33f0f6f7a6430dd">Bitmap::invert</a></div><div class="ttdeci">void invert(int x, int y, int width, int height)</div><div class="ttdoc">Inverts the width x height pixels starting at top-left corner (x, y). </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00902">Bitmap.cpp:902</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a3e9bcbfb584d5020bd6f0a313ee275f0"><div class="ttname"><a href="classBitmap.html#a3e9bcbfb584d5020bd6f0a313ee275f0">Bitmap::drawText</a></div><div class="ttdeci">void drawText(int x, int y, const char *str, int len=-1)</div><div class="ttdoc">Draws the len characters of str at (x, y). </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00526">Bitmap.cpp:526</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a72d2a301ec1eb1c8d0f3d64823659a8e"><div class="ttname"><a href="classBitmap.html#a72d2a301ec1eb1c8d0f3d64823659a8e">Bitmap::~Bitmap</a></div><div class="ttdeci">~Bitmap()</div><div class="ttdoc">Destroys this bitmap. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00106">Bitmap.cpp:106</a></div></div>
|
|
<div class="ttc" id="classBitmap_html_a35aa38b377d509d6c4f061a0b988d203"><div class="ttname"><a href="classBitmap.html#a35aa38b377d509d6c4f061a0b988d203">Bitmap::pixel</a></div><div class="ttdeci">Color pixel(int x, int y) const </div><div class="ttdoc">Returns the color of the pixel at (x, y); either Black or White. </div><div class="ttdef"><b>Definition:</b> <a href="Bitmap_8cpp_source.html#l00191">Bitmap.cpp:191</a></div></div>
|
|
</div><!-- fragment --></div><!-- contents -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated on Fri Nov 3 2017 10:48:52 for ArduinoLibs by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.6
|
|
</small></address>
|
|
</body>
|
|
</html>
|