chillerlan-QRCode-Common-MaskPatternTester.html 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Documentation</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <base href="../">
  8. <link rel="icon" href="images/favicon.ico"/>
  9. <link rel="stylesheet" href="css/normalize.css">
  10. <link rel="stylesheet" href="css/base.css">
  11. <link rel="preconnect" href="https://fonts.gstatic.com">
  12. <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600;700&display=swap" rel="stylesheet">
  13. <link href="https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap" rel="stylesheet">
  14. <link rel="stylesheet" href="css/template.css">
  15. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0/css/all.min.css" integrity="sha256-ybRkN9dBjhcS2qrW1z+hfCxq+1aBdwyQM5wlQoQVt/0=" crossorigin="anonymous" />
  16. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/themes/prism-okaidia.css">
  17. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.css">
  18. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.css">
  19. <script src="https://cdn.jsdelivr.net/npm/fuse.js@3.4.6"></script>
  20. <script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
  21. <script src="js/search.js"></script>
  22. <script defer src="js/searchIndex.js"></script>
  23. </head>
  24. <body id="top">
  25. <header class="phpdocumentor-header phpdocumentor-section">
  26. <h1 class="phpdocumentor-title"><a href="" class="phpdocumentor-title__link">Documentation</a></h1>
  27. <input class="phpdocumentor-header__menu-button" type="checkbox" id="menu-button" name="menu-button" />
  28. <label class="phpdocumentor-header__menu-icon" for="menu-button">
  29. <i class="fas fa-bars"></i>
  30. </label>
  31. <section data-search-form class="phpdocumentor-search">
  32. <label>
  33. <span class="visually-hidden">Search for</span>
  34. <svg class="phpdocumentor-search__icon" width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
  35. <circle cx="7.5" cy="7.5" r="6.5" stroke="currentColor" stroke-width="2"/>
  36. <line x1="12.4892" y1="12.2727" x2="19.1559" y2="18.9393" stroke="currentColor" stroke-width="3"/>
  37. </svg>
  38. <input type="search" class="phpdocumentor-field phpdocumentor-search__field" placeholder="Loading .." disabled />
  39. </label>
  40. </section>
  41. <nav class="phpdocumentor-topnav">
  42. <ul class="phpdocumentor-topnav__menu">
  43. </ul>
  44. </nav>
  45. </header>
  46. <main class="phpdocumentor">
  47. <div class="phpdocumentor-section">
  48. <input class="phpdocumentor-sidebar__menu-button" type="checkbox" id="sidebar-button" name="sidebar-button" />
  49. <label class="phpdocumentor-sidebar__menu-icon" for="sidebar-button">
  50. Menu
  51. </label>
  52. <aside class="phpdocumentor-column -four phpdocumentor-sidebar">
  53. <section class="phpdocumentor-sidebar__category">
  54. <h2 class="phpdocumentor-sidebar__category-header">Namespaces</h2>
  55. <h4 class="phpdocumentor-sidebar__root-namespace"><a href="namespaces/chillerlan.html">chillerlan</a></h4>
  56. <ul class="phpdocumentor-list">
  57. <li>
  58. <a href="namespaces/chillerlan-qrcode.html">QRCode</a>
  59. </li>
  60. <li>
  61. <a href="namespaces/chillerlan-qrcodetest.html">QRCodeTest</a>
  62. </li>
  63. </ul>
  64. </section>
  65. <section class="phpdocumentor-sidebar__category">
  66. <h2 class="phpdocumentor-sidebar__category-header">Packages</h2>
  67. <h4 class="phpdocumentor-sidebar__root-namespace"><a href="packages/Application.html">Application</a></h4>
  68. </section>
  69. <section class="phpdocumentor-sidebar__category">
  70. <h2 class="phpdocumentor-sidebar__category-header">Reports</h2>
  71. <h3 class="phpdocumentor-sidebar__root-package"><a href="reports/deprecated.html">Deprecated</a></h3>
  72. <h3 class="phpdocumentor-sidebar__root-package"><a href="reports/errors.html">Errors</a></h3>
  73. <h3 class="phpdocumentor-sidebar__root-package"><a href="reports/markers.html">Markers</a></h3>
  74. </section>
  75. <section class="phpdocumentor-sidebar__category">
  76. <h2 class="phpdocumentor-sidebar__category-header">Indices</h2>
  77. <h3 class="phpdocumentor-sidebar__root-package"><a href="indices/files.html">Files</a></h3>
  78. </section>
  79. </aside>
  80. <div class="phpdocumentor-column -eight phpdocumentor-content">
  81. <ul class="phpdocumentor-breadcrumbs">
  82. <li class="phpdocumentor-breadcrumb"><a href="namespaces/chillerlan.html">chillerlan</a></li>
  83. <li class="phpdocumentor-breadcrumb"><a href="namespaces/chillerlan-qrcode.html">QRCode</a></li>
  84. <li class="phpdocumentor-breadcrumb"><a href="namespaces/chillerlan-qrcode-common.html">Common</a></li>
  85. </ul>
  86. <article class="phpdocumentor-element -class">
  87. <h2 class="phpdocumentor-content__title">
  88. MaskPatternTester
  89. <div class="phpdocumentor-element__package">
  90. in package
  91. <ul class="phpdocumentor-breadcrumbs">
  92. <li class="phpdocumentor-breadcrumb"><a href="packages/Application.html">Application</a></li>
  93. </ul>
  94. </div>
  95. </h2>
  96. <aside class="phpdocumentor-element-found-in">
  97. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPatternTester.php"><a href="files/src-common-maskpatterntester.html"><abbr title="src/Common/MaskPatternTester.php">MaskPatternTester.php</abbr></a></abbr>
  98. :
  99. <span class="phpdocumentor-element-found-in__line">25</span>
  100. </aside>
  101. <p class="phpdocumentor-summary">Receives a QRData object and runs the mask pattern tests on it.</p>
  102. <section class="phpdocumentor-description"><p>ISO/IEC 18004:2000 Section 8.8.2 - Evaluation of masking results</p>
  103. </section>
  104. <h5 class="phpdocumentor-tag-list__heading" id="tags">
  105. Tags
  106. <a href="#tags" class="headerlink"><i class="fas fa-link"></i></a>
  107. </h5>
  108. <dl class="phpdocumentor-tag-list">
  109. <dt class="phpdocumentor-tag-list__entry">
  110. <span class="phpdocumentor-tag__name">see</span>
  111. </dt>
  112. <dd class="phpdocumentor-tag-list__definition">
  113. <span class="phpdocumentor-tag-link"><a href="http://www.thonky.com/qr-code-tutorial/data-masking"><abbr title="http://www.thonky.com/qr-code-tutorial/data-masking">http://www.thonky.com/qr-code-tutorial/data-masking</abbr></a></span>
  114. </dd>
  115. </dl>
  116. <h3 id="toc">
  117. Table of Contents
  118. <a href="#toc" class="headerlink"><i class="fas fa-link"></i></a>
  119. </h3>
  120. <dl class="phpdocumentor-table-of-contents">
  121. <dt class="phpdocumentor-table-of-contents__entry -property -private">
  122. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#property_qrData">$qrData</a>
  123. <span>
  124. &nbsp;: <a href="classes/chillerlan-QRCode-Data-QRData.html"><abbr title="\chillerlan\QRCode\Data\QRData">QRData</abbr></a> </span>
  125. </dt>
  126. <dd>The data interface that contains the data matrix to test</dd>
  127. <dt class="phpdocumentor-table-of-contents__entry -method -public">
  128. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#method___construct">__construct()</a>
  129. <span>
  130. &nbsp;: mixed </span>
  131. </dt>
  132. <dd>Receives the QRData object</dd>
  133. <dt class="phpdocumentor-table-of-contents__entry -method -public">
  134. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#method_getBestMaskPattern">getBestMaskPattern()</a>
  135. <span>
  136. &nbsp;: <a href="classes/chillerlan-QRCode-Common-MaskPattern.html"><abbr title="\chillerlan\QRCode\Common\MaskPattern">MaskPattern</abbr></a> </span>
  137. </dt>
  138. <dd>shoves a QRMatrix through the MaskPatternTester to find the lowest penalty mask pattern</dd>
  139. <dt class="phpdocumentor-table-of-contents__entry -method -public">
  140. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#method_testPattern">testPattern()</a>
  141. <span>
  142. &nbsp;: int </span>
  143. </dt>
  144. <dd>Returns the penalty for the given mask pattern</dd>
  145. <dt class="phpdocumentor-table-of-contents__entry -method -private">
  146. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#method_testLevel1">testLevel1()</a>
  147. <span>
  148. &nbsp;: int </span>
  149. </dt>
  150. <dd>Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and
  151. give penalty to them. Example: 00000 or 11111.</dd>
  152. <dt class="phpdocumentor-table-of-contents__entry -method -private">
  153. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#method_testLevel2">testLevel2()</a>
  154. <span>
  155. &nbsp;: int </span>
  156. </dt>
  157. <dd>Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give
  158. penalty to them. This is actually equivalent to the spec&#039;s rule, which is to find MxN blocks and give a
  159. penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block.</dd>
  160. <dt class="phpdocumentor-table-of-contents__entry -method -private">
  161. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#method_testLevel3">testLevel3()</a>
  162. <span>
  163. &nbsp;: int </span>
  164. </dt>
  165. <dd>Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4
  166. starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them. If we
  167. find patterns like 000010111010000, we give penalty once.</dd>
  168. <dt class="phpdocumentor-table-of-contents__entry -method -private">
  169. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#method_testLevel4">testLevel4()</a>
  170. <span>
  171. &nbsp;: float </span>
  172. </dt>
  173. <dd>Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give
  174. penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.</dd>
  175. </dl>
  176. <section class="phpdocumentor-properties">
  177. <h3 class="phpdocumentor-elements__header" id="properties">
  178. Properties
  179. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#properties" class="headerlink"><i class="fas fa-link"></i></a>
  180. </h3>
  181. <article
  182. class="
  183. phpdocumentor-element
  184. -property
  185. -private
  186. "
  187. >
  188. <h4 class="phpdocumentor-element__name" id="property_qrData">
  189. $qrData
  190. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#property_qrData" class="headerlink"><i class="fas fa-link"></i></a>
  191. <span class="phpdocumentor-element__modifiers">
  192. </span>
  193. </h4>
  194. <aside class="phpdocumentor-element-found-in">
  195. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPatternTester.php"><a href="files/src-common-maskpatterntester.html"><abbr title="src/Common/MaskPatternTester.php">MaskPatternTester.php</abbr></a></abbr>
  196. :
  197. <span class="phpdocumentor-element-found-in__line">30</span>
  198. </aside>
  199. <p class="phpdocumentor-summary">The data interface that contains the data matrix to test</p>
  200. <code class="phpdocumentor-code phpdocumentor-signature ">
  201. <span class="phpdocumentor-signature__visibility">private</span>
  202. <span class="phpdocumentor-signature__type"><a href="classes/chillerlan-QRCode-Data-QRData.html"><abbr title="\chillerlan\QRCode\Data\QRData">QRData</abbr></a></span>
  203. <span class="phpdocumentor-signature__name">$qrData</span>
  204. </code>
  205. <section class="phpdocumentor-description"></section>
  206. </article>
  207. </section>
  208. <section class="phpdocumentor-methods">
  209. <h3 class="phpdocumentor-elements__header" id="methods">
  210. Methods
  211. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#methods" class="headerlink"><i class="fas fa-link"></i></a>
  212. </h3>
  213. <article
  214. class="phpdocumentor-element
  215. -method
  216. -public
  217. "
  218. >
  219. <h4 class="phpdocumentor-element__name" id="method___construct">
  220. __construct()
  221. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#method___construct" class="headerlink"><i class="fas fa-link"></i></a>
  222. </h4>
  223. <aside class="phpdocumentor-element-found-in">
  224. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPatternTester.php"><a href="files/src-common-maskpatterntester.html"><abbr title="src/Common/MaskPatternTester.php">MaskPatternTester.php</abbr></a></abbr>
  225. :
  226. <span class="phpdocumentor-element-found-in__line">38</span>
  227. </aside>
  228. <p class="phpdocumentor-summary">Receives the QRData object</p>
  229. <code class="phpdocumentor-code phpdocumentor-signature ">
  230. <span class="phpdocumentor-signature__visibility">public</span>
  231. <span class="phpdocumentor-signature__name">__construct</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type"><a href="classes/chillerlan-QRCode-Data-QRData.html"><abbr title="\chillerlan\QRCode\Data\QRData">QRData</abbr></a>&nbsp;</span><span class="phpdocumentor-signature__argument__name">$qrData</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">mixed</span></code>
  232. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  233. <dl class="phpdocumentor-argument-list">
  234. <dt class="phpdocumentor-argument-list__entry">
  235. <span class="phpdocumentor-signature__argument__name">$qrData</span>
  236. : <span class="phpdocumentor-signature__argument__return-type"><a href="classes/chillerlan-QRCode-Data-QRData.html"><abbr title="\chillerlan\QRCode\Data\QRData">QRData</abbr></a></span>
  237. </dt>
  238. <dd class="phpdocumentor-argument-list__definition">
  239. <section class="phpdocumentor-description"></section>
  240. </dd>
  241. </dl>
  242. <h5 class="phpdocumentor-tag-list__heading" id="tags">
  243. Tags
  244. <a href="#tags" class="headerlink"><i class="fas fa-link"></i></a>
  245. </h5>
  246. <dl class="phpdocumentor-tag-list">
  247. <dt class="phpdocumentor-tag-list__entry">
  248. <span class="phpdocumentor-tag__name">see</span>
  249. </dt>
  250. <dd class="phpdocumentor-tag-list__definition">
  251. <span class="phpdocumentor-tag-link"><abbr title="\chillerlan\QRCode\QROptions::$maskPattern">QROptions::$maskPattern</abbr></span>
  252. </dd>
  253. <dt class="phpdocumentor-tag-list__entry">
  254. <span class="phpdocumentor-tag__name">see</span>
  255. </dt>
  256. <dd class="phpdocumentor-tag-list__definition">
  257. <span class="phpdocumentor-tag-link"><a href="classes/chillerlan-QRCode-Data-QRMatrix.html#property_maskPattern"><abbr title="\chillerlan\QRCode\Data\QRMatrix::$maskPattern">QRMatrix::$maskPattern</abbr></a></span>
  258. </dd>
  259. </dl>
  260. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  261. <span class="phpdocumentor-signature__response_type">mixed</span>
  262. &mdash;
  263. </article>
  264. <article
  265. class="phpdocumentor-element
  266. -method
  267. -public
  268. "
  269. >
  270. <h4 class="phpdocumentor-element__name" id="method_getBestMaskPattern">
  271. getBestMaskPattern()
  272. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#method_getBestMaskPattern" class="headerlink"><i class="fas fa-link"></i></a>
  273. </h4>
  274. <aside class="phpdocumentor-element-found-in">
  275. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPatternTester.php"><a href="files/src-common-maskpatterntester.html"><abbr title="src/Common/MaskPatternTester.php">MaskPatternTester.php</abbr></a></abbr>
  276. :
  277. <span class="phpdocumentor-element-found-in__line">47</span>
  278. </aside>
  279. <p class="phpdocumentor-summary">shoves a QRMatrix through the MaskPatternTester to find the lowest penalty mask pattern</p>
  280. <code class="phpdocumentor-code phpdocumentor-signature ">
  281. <span class="phpdocumentor-signature__visibility">public</span>
  282. <span class="phpdocumentor-signature__name">getBestMaskPattern</span><span>(</span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type"><a href="classes/chillerlan-QRCode-Common-MaskPattern.html"><abbr title="\chillerlan\QRCode\Common\MaskPattern">MaskPattern</abbr></a></span></code>
  283. <h5 class="phpdocumentor-tag-list__heading" id="tags">
  284. Tags
  285. <a href="#tags" class="headerlink"><i class="fas fa-link"></i></a>
  286. </h5>
  287. <dl class="phpdocumentor-tag-list">
  288. <dt class="phpdocumentor-tag-list__entry">
  289. <span class="phpdocumentor-tag__name">see</span>
  290. </dt>
  291. <dd class="phpdocumentor-tag-list__definition">
  292. <span class="phpdocumentor-tag-link"><abbr title="\chillerlan\QRCode\Data\MaskPatternTester">MaskPatternTester</abbr></span>
  293. </dd>
  294. </dl>
  295. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  296. <span class="phpdocumentor-signature__response_type"><a href="classes/chillerlan-QRCode-Common-MaskPattern.html"><abbr title="\chillerlan\QRCode\Common\MaskPattern">MaskPattern</abbr></a></span>
  297. &mdash;
  298. </article>
  299. <article
  300. class="phpdocumentor-element
  301. -method
  302. -public
  303. "
  304. >
  305. <h4 class="phpdocumentor-element__name" id="method_testPattern">
  306. testPattern()
  307. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#method_testPattern" class="headerlink"><i class="fas fa-link"></i></a>
  308. </h4>
  309. <aside class="phpdocumentor-element-found-in">
  310. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPatternTester.php"><a href="files/src-common-maskpatterntester.html"><abbr title="src/Common/MaskPatternTester.php">MaskPatternTester.php</abbr></a></abbr>
  311. :
  312. <span class="phpdocumentor-element-found-in__line">63</span>
  313. </aside>
  314. <p class="phpdocumentor-summary">Returns the penalty for the given mask pattern</p>
  315. <code class="phpdocumentor-code phpdocumentor-signature ">
  316. <span class="phpdocumentor-signature__visibility">public</span>
  317. <span class="phpdocumentor-signature__name">testPattern</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type"><a href="classes/chillerlan-QRCode-Common-MaskPattern.html"><abbr title="\chillerlan\QRCode\Common\MaskPattern">MaskPattern</abbr></a>&nbsp;</span><span class="phpdocumentor-signature__argument__name">$pattern</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">int</span></code>
  318. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  319. <dl class="phpdocumentor-argument-list">
  320. <dt class="phpdocumentor-argument-list__entry">
  321. <span class="phpdocumentor-signature__argument__name">$pattern</span>
  322. : <span class="phpdocumentor-signature__argument__return-type"><a href="classes/chillerlan-QRCode-Common-MaskPattern.html"><abbr title="\chillerlan\QRCode\Common\MaskPattern">MaskPattern</abbr></a></span>
  323. </dt>
  324. <dd class="phpdocumentor-argument-list__definition">
  325. <section class="phpdocumentor-description"></section>
  326. </dd>
  327. </dl>
  328. <h5 class="phpdocumentor-tag-list__heading" id="tags">
  329. Tags
  330. <a href="#tags" class="headerlink"><i class="fas fa-link"></i></a>
  331. </h5>
  332. <dl class="phpdocumentor-tag-list">
  333. <dt class="phpdocumentor-tag-list__entry">
  334. <span class="phpdocumentor-tag__name">see</span>
  335. </dt>
  336. <dd class="phpdocumentor-tag-list__definition">
  337. <span class="phpdocumentor-tag-link"><abbr title="\chillerlan\QRCode\QROptions::$maskPattern">QROptions::$maskPattern</abbr></span>
  338. </dd>
  339. <dt class="phpdocumentor-tag-list__entry">
  340. <span class="phpdocumentor-tag__name">see</span>
  341. </dt>
  342. <dd class="phpdocumentor-tag-list__definition">
  343. <span class="phpdocumentor-tag-link"><a href="classes/chillerlan-QRCode-Data-QRMatrix.html#property_maskPattern"><abbr title="\chillerlan\QRCode\Data\QRMatrix::$maskPattern">QRMatrix::$maskPattern</abbr></a></span>
  344. </dd>
  345. </dl>
  346. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  347. <span class="phpdocumentor-signature__response_type">int</span>
  348. &mdash;
  349. </article>
  350. <article
  351. class="phpdocumentor-element
  352. -method
  353. -private
  354. "
  355. >
  356. <h4 class="phpdocumentor-element__name" id="method_testLevel1">
  357. testLevel1()
  358. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#method_testLevel1" class="headerlink"><i class="fas fa-link"></i></a>
  359. </h4>
  360. <aside class="phpdocumentor-element-found-in">
  361. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPatternTester.php"><a href="files/src-common-maskpatterntester.html"><abbr title="src/Common/MaskPatternTester.php">MaskPatternTester.php</abbr></a></abbr>
  362. :
  363. <span class="phpdocumentor-element-found-in__line">78</span>
  364. </aside>
  365. <p class="phpdocumentor-summary">Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and
  366. give penalty to them. Example: 00000 or 11111.</p>
  367. <code class="phpdocumentor-code phpdocumentor-signature ">
  368. <span class="phpdocumentor-signature__visibility">private</span>
  369. <span class="phpdocumentor-signature__name">testLevel1</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;&nbsp;</span><span class="phpdocumentor-signature__argument__name">$m</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type">int&nbsp;</span><span class="phpdocumentor-signature__argument__name">$size</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">int</span></code>
  370. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  371. <dl class="phpdocumentor-argument-list">
  372. <dt class="phpdocumentor-argument-list__entry">
  373. <span class="phpdocumentor-signature__argument__name">$m</span>
  374. : <span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;</span>
  375. </dt>
  376. <dd class="phpdocumentor-argument-list__definition">
  377. <section class="phpdocumentor-description"></section>
  378. </dd>
  379. <dt class="phpdocumentor-argument-list__entry">
  380. <span class="phpdocumentor-signature__argument__name">$size</span>
  381. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  382. </dt>
  383. <dd class="phpdocumentor-argument-list__definition">
  384. <section class="phpdocumentor-description"></section>
  385. </dd>
  386. </dl>
  387. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  388. <span class="phpdocumentor-signature__response_type">int</span>
  389. &mdash;
  390. </article>
  391. <article
  392. class="phpdocumentor-element
  393. -method
  394. -private
  395. "
  396. >
  397. <h4 class="phpdocumentor-element__name" id="method_testLevel2">
  398. testLevel2()
  399. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#method_testLevel2" class="headerlink"><i class="fas fa-link"></i></a>
  400. </h4>
  401. <aside class="phpdocumentor-element-found-in">
  402. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPatternTester.php"><a href="files/src-common-maskpatterntester.html"><abbr title="src/Common/MaskPatternTester.php">MaskPatternTester.php</abbr></a></abbr>
  403. :
  404. <span class="phpdocumentor-element-found-in__line">119</span>
  405. </aside>
  406. <p class="phpdocumentor-summary">Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give
  407. penalty to them. This is actually equivalent to the spec&#039;s rule, which is to find MxN blocks and give a
  408. penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block.</p>
  409. <code class="phpdocumentor-code phpdocumentor-signature ">
  410. <span class="phpdocumentor-signature__visibility">private</span>
  411. <span class="phpdocumentor-signature__name">testLevel2</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;&nbsp;</span><span class="phpdocumentor-signature__argument__name">$m</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type">int&nbsp;</span><span class="phpdocumentor-signature__argument__name">$size</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">int</span></code>
  412. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  413. <dl class="phpdocumentor-argument-list">
  414. <dt class="phpdocumentor-argument-list__entry">
  415. <span class="phpdocumentor-signature__argument__name">$m</span>
  416. : <span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;</span>
  417. </dt>
  418. <dd class="phpdocumentor-argument-list__definition">
  419. <section class="phpdocumentor-description"></section>
  420. </dd>
  421. <dt class="phpdocumentor-argument-list__entry">
  422. <span class="phpdocumentor-signature__argument__name">$size</span>
  423. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  424. </dt>
  425. <dd class="phpdocumentor-argument-list__definition">
  426. <section class="phpdocumentor-description"></section>
  427. </dd>
  428. </dl>
  429. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  430. <span class="phpdocumentor-signature__response_type">int</span>
  431. &mdash;
  432. </article>
  433. <article
  434. class="phpdocumentor-element
  435. -method
  436. -private
  437. "
  438. >
  439. <h4 class="phpdocumentor-element__name" id="method_testLevel3">
  440. testLevel3()
  441. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#method_testLevel3" class="headerlink"><i class="fas fa-link"></i></a>
  442. </h4>
  443. <aside class="phpdocumentor-element-found-in">
  444. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPatternTester.php"><a href="files/src-common-maskpatterntester.html"><abbr title="src/Common/MaskPatternTester.php">MaskPatternTester.php</abbr></a></abbr>
  445. :
  446. <span class="phpdocumentor-element-found-in__line">152</span>
  447. </aside>
  448. <p class="phpdocumentor-summary">Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4
  449. starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them. If we
  450. find patterns like 000010111010000, we give penalty once.</p>
  451. <code class="phpdocumentor-code phpdocumentor-signature ">
  452. <span class="phpdocumentor-signature__visibility">private</span>
  453. <span class="phpdocumentor-signature__name">testLevel3</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;&nbsp;</span><span class="phpdocumentor-signature__argument__name">$m</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type">int&nbsp;</span><span class="phpdocumentor-signature__argument__name">$size</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">int</span></code>
  454. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  455. <dl class="phpdocumentor-argument-list">
  456. <dt class="phpdocumentor-argument-list__entry">
  457. <span class="phpdocumentor-signature__argument__name">$m</span>
  458. : <span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;</span>
  459. </dt>
  460. <dd class="phpdocumentor-argument-list__definition">
  461. <section class="phpdocumentor-description"></section>
  462. </dd>
  463. <dt class="phpdocumentor-argument-list__entry">
  464. <span class="phpdocumentor-signature__argument__name">$size</span>
  465. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  466. </dt>
  467. <dd class="phpdocumentor-argument-list__definition">
  468. <section class="phpdocumentor-description"></section>
  469. </dd>
  470. </dl>
  471. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  472. <span class="phpdocumentor-signature__response_type">int</span>
  473. &mdash;
  474. </article>
  475. <article
  476. class="phpdocumentor-element
  477. -method
  478. -private
  479. "
  480. >
  481. <h4 class="phpdocumentor-element__name" id="method_testLevel4">
  482. testLevel4()
  483. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#method_testLevel4" class="headerlink"><i class="fas fa-link"></i></a>
  484. </h4>
  485. <aside class="phpdocumentor-element-found-in">
  486. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPatternTester.php"><a href="files/src-common-maskpatterntester.html"><abbr title="src/Common/MaskPatternTester.php">MaskPatternTester.php</abbr></a></abbr>
  487. :
  488. <span class="phpdocumentor-element-found-in__line">194</span>
  489. </aside>
  490. <p class="phpdocumentor-summary">Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give
  491. penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.</p>
  492. <code class="phpdocumentor-code phpdocumentor-signature ">
  493. <span class="phpdocumentor-signature__visibility">private</span>
  494. <span class="phpdocumentor-signature__name">testLevel4</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;&nbsp;</span><span class="phpdocumentor-signature__argument__name">$m</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type">int&nbsp;</span><span class="phpdocumentor-signature__argument__name">$size</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">float</span></code>
  495. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  496. <dl class="phpdocumentor-argument-list">
  497. <dt class="phpdocumentor-argument-list__entry">
  498. <span class="phpdocumentor-signature__argument__name">$m</span>
  499. : <span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;</span>
  500. </dt>
  501. <dd class="phpdocumentor-argument-list__definition">
  502. <section class="phpdocumentor-description"></section>
  503. </dd>
  504. <dt class="phpdocumentor-argument-list__entry">
  505. <span class="phpdocumentor-signature__argument__name">$size</span>
  506. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  507. </dt>
  508. <dd class="phpdocumentor-argument-list__definition">
  509. <section class="phpdocumentor-description"></section>
  510. </dd>
  511. </dl>
  512. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  513. <span class="phpdocumentor-signature__response_type">float</span>
  514. &mdash;
  515. </article>
  516. </section>
  517. <script type="text/javascript">
  518. function loadExternalCodeSnippets(line) {
  519. Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach((pre) => {
  520. var src = pre.getAttribute('data-src').replace( /\\/g, '/');
  521. var extension = (src.match(/\.(\w+)$/) || [, ''])[1];
  522. var language = 'php';
  523. var code = document.createElement('code');
  524. code.className = 'language-' + language;
  525. pre.textContent = '';
  526. pre.setAttribute('data-line', line)
  527. code.textContent = 'Loading…';
  528. pre.appendChild(code);
  529. var xhr = new XMLHttpRequest();
  530. xhr.open('GET', src, true);
  531. xhr.onreadystatechange = function () {
  532. if (xhr.readyState == 4) {
  533. if (xhr.status < 400 && xhr.responseText) {
  534. code.textContent = xhr.responseText;
  535. Prism.highlightElement(code);
  536. }
  537. else if (xhr.status >= 400) {
  538. code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
  539. }
  540. else {
  541. code.textContent = '✖ Error: File does not exist, is empty or trying to view from localhost';
  542. }
  543. }
  544. };
  545. xhr.send(null);
  546. });
  547. }
  548. var modals = document.querySelectorAll("[data-modal]");
  549. modals.forEach(function (trigger) {
  550. trigger.addEventListener("click", function (event) {
  551. //event.preventDefault();
  552. const modal = document.getElementById(trigger.dataset.modal);
  553. modal.classList.add("phpdocumentor-modal__open");
  554. loadExternalCodeSnippets(trigger.dataset.line)
  555. const exits = modal.querySelectorAll("[data-exit-button]");
  556. exits.forEach(function (exit) {
  557. exit.addEventListener("click", function (event) {
  558. event.preventDefault();
  559. modal.classList.remove("phpdocumentor-modal__open");
  560. });
  561. });
  562. });
  563. });
  564. </script>
  565. </article>
  566. <section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
  567. <section class="phpdocumentor-search-results__dialog">
  568. <header class="phpdocumentor-search-results__header">
  569. <h2 class="phpdocumentor-search-results__title">Search results</h2>
  570. <button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
  571. </header>
  572. <section class="phpdocumentor-search-results__body">
  573. <ul class="phpdocumentor-search-results__entries"></ul>
  574. </section>
  575. </section>
  576. </section>
  577. </div>
  578. </div>
  579. <a href="classes/chillerlan-QRCode-Common-MaskPatternTester.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
  580. </main>
  581. <script>
  582. cssVars({});
  583. </script>
  584. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
  585. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
  586. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
  587. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
  588. </body>
  589. </html>