chillerlan-QRCode-Common-MaskPattern.html 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365
  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. MaskPattern
  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/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  98. :
  99. <span class="phpdocumentor-element-found-in__line">24</span>
  100. </aside>
  101. <p class="phpdocumentor-summary">ISO/IEC 18004:2000 Section 8.8.1
  102. ISO/IEC 18004:2000 Section 8.8.2 - Evaluation of masking results</p>
  103. <h5 class="phpdocumentor-tag-list__heading" id="tags">
  104. Tags
  105. <a href="#tags" class="headerlink"><i class="fas fa-link"></i></a>
  106. </h5>
  107. <dl class="phpdocumentor-tag-list">
  108. <dt class="phpdocumentor-tag-list__entry">
  109. <span class="phpdocumentor-tag__name">see</span>
  110. </dt>
  111. <dd class="phpdocumentor-tag-list__definition">
  112. <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>
  113. </dd>
  114. </dl>
  115. <h3 id="toc">
  116. Table of Contents
  117. <a href="#toc" class="headerlink"><i class="fas fa-link"></i></a>
  118. </h3>
  119. <dl class="phpdocumentor-table-of-contents">
  120. <dt class="phpdocumentor-table-of-contents__entry -constant -public">
  121. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_000">PATTERN_000</a>
  122. <span>
  123. &nbsp;= 0b0 </span>
  124. </dt>
  125. <dd></dd>
  126. <dt class="phpdocumentor-table-of-contents__entry -constant -public">
  127. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_001">PATTERN_001</a>
  128. <span>
  129. &nbsp;= 0b1 </span>
  130. </dt>
  131. <dd></dd>
  132. <dt class="phpdocumentor-table-of-contents__entry -constant -public">
  133. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_010">PATTERN_010</a>
  134. <span>
  135. &nbsp;= 0b10 </span>
  136. </dt>
  137. <dd></dd>
  138. <dt class="phpdocumentor-table-of-contents__entry -constant -public">
  139. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_011">PATTERN_011</a>
  140. <span>
  141. &nbsp;= 0b11 </span>
  142. </dt>
  143. <dd></dd>
  144. <dt class="phpdocumentor-table-of-contents__entry -constant -public">
  145. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_100">PATTERN_100</a>
  146. <span>
  147. &nbsp;= 0b100 </span>
  148. </dt>
  149. <dd></dd>
  150. <dt class="phpdocumentor-table-of-contents__entry -constant -public">
  151. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_101">PATTERN_101</a>
  152. <span>
  153. &nbsp;= 0b101 </span>
  154. </dt>
  155. <dd></dd>
  156. <dt class="phpdocumentor-table-of-contents__entry -constant -public">
  157. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_110">PATTERN_110</a>
  158. <span>
  159. &nbsp;= 0b110 </span>
  160. </dt>
  161. <dd></dd>
  162. <dt class="phpdocumentor-table-of-contents__entry -constant -public">
  163. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_111">PATTERN_111</a>
  164. <span>
  165. &nbsp;= 0b111 </span>
  166. </dt>
  167. <dd></dd>
  168. <dt class="phpdocumentor-table-of-contents__entry -constant -public">
  169. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERNS">PATTERNS</a>
  170. <span>
  171. &nbsp;= [self::PATTERN_000, self::PATTERN_001, self::PATTERN_010, self::PATTERN_011, self::PATTERN_100, self::PATTERN_101, self::PATTERN_110, self::PATTERN_111] </span>
  172. </dt>
  173. <dd></dd>
  174. <dt class="phpdocumentor-table-of-contents__entry -property -private">
  175. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#property_maskPattern">$maskPattern</a>
  176. <span>
  177. &nbsp;: int </span>
  178. </dt>
  179. <dd>The current mask pattern value (0-7)</dd>
  180. <dt class="phpdocumentor-table-of-contents__entry -method -public">
  181. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method___construct">__construct()</a>
  182. <span>
  183. &nbsp;: mixed </span>
  184. </dt>
  185. <dd>MaskPattern constructor.</dd>
  186. <dt class="phpdocumentor-table-of-contents__entry -method -public">
  187. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_getBestPattern">getBestPattern()</a>
  188. <span>
  189. &nbsp;: self </span>
  190. </dt>
  191. <dd>Evaluates the matrix of the given data interface and returns a new mask pattern instance for the best result</dd>
  192. <dt class="phpdocumentor-table-of-contents__entry -method -public">
  193. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_getMask">getMask()</a>
  194. <span>
  195. &nbsp;: <abbr title="\Closure">Closure</abbr> </span>
  196. </dt>
  197. <dd>Returns a closure that applies the mask for the chosen mask pattern.</dd>
  198. <dt class="phpdocumentor-table-of-contents__entry -method -public">
  199. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_getPattern">getPattern()</a>
  200. <span>
  201. &nbsp;: int </span>
  202. </dt>
  203. <dd>Returns the current mask pattern</dd>
  204. <dt class="phpdocumentor-table-of-contents__entry -method -public">
  205. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_testRule1">testRule1()</a>
  206. <span>
  207. &nbsp;: int </span>
  208. </dt>
  209. <dd>Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and
  210. give penalty to them. Example: 00000 or 11111.</dd>
  211. <dt class="phpdocumentor-table-of-contents__entry -method -public">
  212. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_testRule2">testRule2()</a>
  213. <span>
  214. &nbsp;: int </span>
  215. </dt>
  216. <dd>Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give
  217. penalty to them. This is actually equivalent to the spec&#039;s rule, which is to find MxN blocks and give a
  218. penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block.</dd>
  219. <dt class="phpdocumentor-table-of-contents__entry -method -public">
  220. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_testRule3">testRule3()</a>
  221. <span>
  222. &nbsp;: int </span>
  223. </dt>
  224. <dd>Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4
  225. starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them. If we
  226. find patterns like 000010111010000, we give penalty once.</dd>
  227. <dt class="phpdocumentor-table-of-contents__entry -method -public">
  228. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_testRule4">testRule4()</a>
  229. <span>
  230. &nbsp;: int </span>
  231. </dt>
  232. <dd>Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give
  233. penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.</dd>
  234. <dt class="phpdocumentor-table-of-contents__entry -method -private">
  235. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_applyRule1">applyRule1()</a>
  236. <span>
  237. &nbsp;: int </span>
  238. </dt>
  239. <dd></dd>
  240. <dt class="phpdocumentor-table-of-contents__entry -method -private">
  241. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_isWhiteHorizontal">isWhiteHorizontal()</a>
  242. <span>
  243. &nbsp;: bool </span>
  244. </dt>
  245. <dd></dd>
  246. <dt class="phpdocumentor-table-of-contents__entry -method -private">
  247. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_isWhiteVertical">isWhiteVertical()</a>
  248. <span>
  249. &nbsp;: bool </span>
  250. </dt>
  251. <dd></dd>
  252. </dl>
  253. <section class="phpdocumentor-constants">
  254. <h3 class="phpdocumentor-elements__header" id="constants">
  255. Constants
  256. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constants" class="headerlink"><i class="fas fa-link"></i></a>
  257. </h3>
  258. <article class="phpdocumentor-element -constant -public ">
  259. <h4 class="phpdocumentor-element__name" id="constant_PATTERN_000">
  260. PATTERN_000
  261. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_000" class="headerlink"><i class="fas fa-link"></i></a>
  262. </h4>
  263. <aside class="phpdocumentor-element-found-in">
  264. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  265. :
  266. <span class="phpdocumentor-element-found-in__line">26</span>
  267. </aside>
  268. <code class="phpdocumentor-signature phpdocumentor-code ">
  269. <span class="phpdocumentor-signature__visibility">public</span>
  270. <span class="phpdocumentor-signature__type">mixed</span>
  271. <span class="phpdocumentor-signature__name">PATTERN_000</span>
  272. = <span class="phpdocumentor-signature__default-value">0b0</span>
  273. </code>
  274. <section class="phpdocumentor-description"></section>
  275. <section class="phpdocumentor-description"></section>
  276. </article>
  277. <article class="phpdocumentor-element -constant -public ">
  278. <h4 class="phpdocumentor-element__name" id="constant_PATTERN_001">
  279. PATTERN_001
  280. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_001" class="headerlink"><i class="fas fa-link"></i></a>
  281. </h4>
  282. <aside class="phpdocumentor-element-found-in">
  283. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  284. :
  285. <span class="phpdocumentor-element-found-in__line">27</span>
  286. </aside>
  287. <code class="phpdocumentor-signature phpdocumentor-code ">
  288. <span class="phpdocumentor-signature__visibility">public</span>
  289. <span class="phpdocumentor-signature__type">mixed</span>
  290. <span class="phpdocumentor-signature__name">PATTERN_001</span>
  291. = <span class="phpdocumentor-signature__default-value">0b1</span>
  292. </code>
  293. <section class="phpdocumentor-description"></section>
  294. <section class="phpdocumentor-description"></section>
  295. </article>
  296. <article class="phpdocumentor-element -constant -public ">
  297. <h4 class="phpdocumentor-element__name" id="constant_PATTERN_010">
  298. PATTERN_010
  299. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_010" class="headerlink"><i class="fas fa-link"></i></a>
  300. </h4>
  301. <aside class="phpdocumentor-element-found-in">
  302. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  303. :
  304. <span class="phpdocumentor-element-found-in__line">28</span>
  305. </aside>
  306. <code class="phpdocumentor-signature phpdocumentor-code ">
  307. <span class="phpdocumentor-signature__visibility">public</span>
  308. <span class="phpdocumentor-signature__type">mixed</span>
  309. <span class="phpdocumentor-signature__name">PATTERN_010</span>
  310. = <span class="phpdocumentor-signature__default-value">0b10</span>
  311. </code>
  312. <section class="phpdocumentor-description"></section>
  313. <section class="phpdocumentor-description"></section>
  314. </article>
  315. <article class="phpdocumentor-element -constant -public ">
  316. <h4 class="phpdocumentor-element__name" id="constant_PATTERN_011">
  317. PATTERN_011
  318. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_011" class="headerlink"><i class="fas fa-link"></i></a>
  319. </h4>
  320. <aside class="phpdocumentor-element-found-in">
  321. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  322. :
  323. <span class="phpdocumentor-element-found-in__line">29</span>
  324. </aside>
  325. <code class="phpdocumentor-signature phpdocumentor-code ">
  326. <span class="phpdocumentor-signature__visibility">public</span>
  327. <span class="phpdocumentor-signature__type">mixed</span>
  328. <span class="phpdocumentor-signature__name">PATTERN_011</span>
  329. = <span class="phpdocumentor-signature__default-value">0b11</span>
  330. </code>
  331. <section class="phpdocumentor-description"></section>
  332. <section class="phpdocumentor-description"></section>
  333. </article>
  334. <article class="phpdocumentor-element -constant -public ">
  335. <h4 class="phpdocumentor-element__name" id="constant_PATTERN_100">
  336. PATTERN_100
  337. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_100" class="headerlink"><i class="fas fa-link"></i></a>
  338. </h4>
  339. <aside class="phpdocumentor-element-found-in">
  340. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  341. :
  342. <span class="phpdocumentor-element-found-in__line">30</span>
  343. </aside>
  344. <code class="phpdocumentor-signature phpdocumentor-code ">
  345. <span class="phpdocumentor-signature__visibility">public</span>
  346. <span class="phpdocumentor-signature__type">mixed</span>
  347. <span class="phpdocumentor-signature__name">PATTERN_100</span>
  348. = <span class="phpdocumentor-signature__default-value">0b100</span>
  349. </code>
  350. <section class="phpdocumentor-description"></section>
  351. <section class="phpdocumentor-description"></section>
  352. </article>
  353. <article class="phpdocumentor-element -constant -public ">
  354. <h4 class="phpdocumentor-element__name" id="constant_PATTERN_101">
  355. PATTERN_101
  356. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_101" class="headerlink"><i class="fas fa-link"></i></a>
  357. </h4>
  358. <aside class="phpdocumentor-element-found-in">
  359. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  360. :
  361. <span class="phpdocumentor-element-found-in__line">31</span>
  362. </aside>
  363. <code class="phpdocumentor-signature phpdocumentor-code ">
  364. <span class="phpdocumentor-signature__visibility">public</span>
  365. <span class="phpdocumentor-signature__type">mixed</span>
  366. <span class="phpdocumentor-signature__name">PATTERN_101</span>
  367. = <span class="phpdocumentor-signature__default-value">0b101</span>
  368. </code>
  369. <section class="phpdocumentor-description"></section>
  370. <section class="phpdocumentor-description"></section>
  371. </article>
  372. <article class="phpdocumentor-element -constant -public ">
  373. <h4 class="phpdocumentor-element__name" id="constant_PATTERN_110">
  374. PATTERN_110
  375. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_110" class="headerlink"><i class="fas fa-link"></i></a>
  376. </h4>
  377. <aside class="phpdocumentor-element-found-in">
  378. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  379. :
  380. <span class="phpdocumentor-element-found-in__line">32</span>
  381. </aside>
  382. <code class="phpdocumentor-signature phpdocumentor-code ">
  383. <span class="phpdocumentor-signature__visibility">public</span>
  384. <span class="phpdocumentor-signature__type">mixed</span>
  385. <span class="phpdocumentor-signature__name">PATTERN_110</span>
  386. = <span class="phpdocumentor-signature__default-value">0b110</span>
  387. </code>
  388. <section class="phpdocumentor-description"></section>
  389. <section class="phpdocumentor-description"></section>
  390. </article>
  391. <article class="phpdocumentor-element -constant -public ">
  392. <h4 class="phpdocumentor-element__name" id="constant_PATTERN_111">
  393. PATTERN_111
  394. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERN_111" class="headerlink"><i class="fas fa-link"></i></a>
  395. </h4>
  396. <aside class="phpdocumentor-element-found-in">
  397. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  398. :
  399. <span class="phpdocumentor-element-found-in__line">33</span>
  400. </aside>
  401. <code class="phpdocumentor-signature phpdocumentor-code ">
  402. <span class="phpdocumentor-signature__visibility">public</span>
  403. <span class="phpdocumentor-signature__type">mixed</span>
  404. <span class="phpdocumentor-signature__name">PATTERN_111</span>
  405. = <span class="phpdocumentor-signature__default-value">0b111</span>
  406. </code>
  407. <section class="phpdocumentor-description"></section>
  408. <section class="phpdocumentor-description"></section>
  409. </article>
  410. <article class="phpdocumentor-element -constant -public ">
  411. <h4 class="phpdocumentor-element__name" id="constant_PATTERNS">
  412. PATTERNS
  413. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#constant_PATTERNS" class="headerlink"><i class="fas fa-link"></i></a>
  414. </h4>
  415. <aside class="phpdocumentor-element-found-in">
  416. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  417. :
  418. <span class="phpdocumentor-element-found-in__line">38</span>
  419. </aside>
  420. <code class="phpdocumentor-signature phpdocumentor-code ">
  421. <span class="phpdocumentor-signature__visibility">public</span>
  422. <span class="phpdocumentor-signature__type">array&lt;string|int, int&gt;</span>
  423. <span class="phpdocumentor-signature__name">PATTERNS</span>
  424. = <span class="phpdocumentor-signature__default-value">[self::PATTERN_000, self::PATTERN_001, self::PATTERN_010, self::PATTERN_011, self::PATTERN_100, self::PATTERN_101, self::PATTERN_110, self::PATTERN_111]</span>
  425. </code>
  426. </article>
  427. </section>
  428. <section class="phpdocumentor-properties">
  429. <h3 class="phpdocumentor-elements__header" id="properties">
  430. Properties
  431. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#properties" class="headerlink"><i class="fas fa-link"></i></a>
  432. </h3>
  433. <article
  434. class="
  435. phpdocumentor-element
  436. -property
  437. -private
  438. "
  439. >
  440. <h4 class="phpdocumentor-element__name" id="property_maskPattern">
  441. $maskPattern
  442. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#property_maskPattern" class="headerlink"><i class="fas fa-link"></i></a>
  443. <span class="phpdocumentor-element__modifiers">
  444. </span>
  445. </h4>
  446. <aside class="phpdocumentor-element-found-in">
  447. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  448. :
  449. <span class="phpdocumentor-element-found-in__line">52</span>
  450. </aside>
  451. <p class="phpdocumentor-summary">The current mask pattern value (0-7)</p>
  452. <code class="phpdocumentor-code phpdocumentor-signature ">
  453. <span class="phpdocumentor-signature__visibility">private</span>
  454. <span class="phpdocumentor-signature__type">int</span>
  455. <span class="phpdocumentor-signature__name">$maskPattern</span>
  456. </code>
  457. <section class="phpdocumentor-description"></section>
  458. </article>
  459. </section>
  460. <section class="phpdocumentor-methods">
  461. <h3 class="phpdocumentor-elements__header" id="methods">
  462. Methods
  463. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#methods" class="headerlink"><i class="fas fa-link"></i></a>
  464. </h3>
  465. <article
  466. class="phpdocumentor-element
  467. -method
  468. -public
  469. "
  470. >
  471. <h4 class="phpdocumentor-element__name" id="method___construct">
  472. __construct()
  473. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method___construct" class="headerlink"><i class="fas fa-link"></i></a>
  474. </h4>
  475. <aside class="phpdocumentor-element-found-in">
  476. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  477. :
  478. <span class="phpdocumentor-element-found-in__line">59</span>
  479. </aside>
  480. <p class="phpdocumentor-summary">MaskPattern constructor.</p>
  481. <code class="phpdocumentor-code phpdocumentor-signature ">
  482. <span class="phpdocumentor-signature__visibility">public</span>
  483. <span class="phpdocumentor-signature__name">__construct</span><span>(</span><span class="phpdocumentor-signature__argument"><span class="phpdocumentor-signature__argument__return-type">int&nbsp;</span><span class="phpdocumentor-signature__argument__name">$maskPattern</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">mixed</span></code>
  484. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  485. <dl class="phpdocumentor-argument-list">
  486. <dt class="phpdocumentor-argument-list__entry">
  487. <span class="phpdocumentor-signature__argument__name">$maskPattern</span>
  488. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  489. </dt>
  490. <dd class="phpdocumentor-argument-list__definition">
  491. <section class="phpdocumentor-description"></section>
  492. </dd>
  493. </dl>
  494. <h5 class="phpdocumentor-tag-list__heading" id="tags">
  495. Tags
  496. <a href="#tags" class="headerlink"><i class="fas fa-link"></i></a>
  497. </h5>
  498. <dl class="phpdocumentor-tag-list">
  499. <dt class="phpdocumentor-tag-list__entry">
  500. <span class="phpdocumentor-tag__name">throws</span>
  501. </dt>
  502. <dd class="phpdocumentor-tag-list__definition">
  503. <span class="phpdocumentor-tag-link"><a href="classes/chillerlan-QRCode-QRCodeException.html"><abbr title="\chillerlan\QRCode\QRCodeException">QRCodeException</abbr></a></span>
  504. </dd>
  505. </dl>
  506. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  507. <span class="phpdocumentor-signature__response_type">mixed</span>
  508. &mdash;
  509. </article>
  510. <article
  511. class="phpdocumentor-element
  512. -method
  513. -public
  514. -static "
  515. >
  516. <h4 class="phpdocumentor-element__name" id="method_getBestPattern">
  517. getBestPattern()
  518. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_getBestPattern" class="headerlink"><i class="fas fa-link"></i></a>
  519. </h4>
  520. <aside class="phpdocumentor-element-found-in">
  521. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  522. :
  523. <span class="phpdocumentor-element-found-in__line">106</span>
  524. </aside>
  525. <p class="phpdocumentor-summary">Evaluates the matrix of the given data interface and returns a new mask pattern instance for the best result</p>
  526. <code class="phpdocumentor-code phpdocumentor-signature ">
  527. <span class="phpdocumentor-signature__visibility">public</span>
  528. <span class="phpdocumentor-signature__static">static</span> <span class="phpdocumentor-signature__name">getBestPattern</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">$dataInterface</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">self</span></code>
  529. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  530. <dl class="phpdocumentor-argument-list">
  531. <dt class="phpdocumentor-argument-list__entry">
  532. <span class="phpdocumentor-signature__argument__name">$dataInterface</span>
  533. : <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>
  534. </dt>
  535. <dd class="phpdocumentor-argument-list__definition">
  536. <section class="phpdocumentor-description"></section>
  537. </dd>
  538. </dl>
  539. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  540. <span class="phpdocumentor-signature__response_type">self</span>
  541. &mdash;
  542. </article>
  543. <article
  544. class="phpdocumentor-element
  545. -method
  546. -public
  547. "
  548. >
  549. <h4 class="phpdocumentor-element__name" id="method_getMask">
  550. getMask()
  551. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_getMask" class="headerlink"><i class="fas fa-link"></i></a>
  552. </h4>
  553. <aside class="phpdocumentor-element-found-in">
  554. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  555. :
  556. <span class="phpdocumentor-element-found-in__line">89</span>
  557. </aside>
  558. <p class="phpdocumentor-summary">Returns a closure that applies the mask for the chosen mask pattern.</p>
  559. <code class="phpdocumentor-code phpdocumentor-signature ">
  560. <span class="phpdocumentor-signature__visibility">public</span>
  561. <span class="phpdocumentor-signature__name">getMask</span><span>(</span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type"><abbr title="\Closure">Closure</abbr></span></code>
  562. <section class="phpdocumentor-description"><p>Encapsulates data masks for the data bits in a QR code, per ISO 18004:2006 6.8. Implementations
  563. of this class can un-mask a raw BitMatrix. For simplicity, they will unmask the entire BitMatrix,
  564. including areas used for finder patterns, timing patterns, etc. These areas should be unused
  565. after the point they are unmasked anyway.</p>
  566. <p>Note that the diagram in section 6.8.1 is misleading since it indicates that i is column position
  567. and j is row position. In fact, as the text says, i is row position and j is column position.</p>
  568. </section>
  569. <h5 class="phpdocumentor-tag-list__heading" id="tags">
  570. Tags
  571. <a href="#tags" class="headerlink"><i class="fas fa-link"></i></a>
  572. </h5>
  573. <dl class="phpdocumentor-tag-list">
  574. <dt class="phpdocumentor-tag-list__entry">
  575. <span class="phpdocumentor-tag__name">see</span>
  576. </dt>
  577. <dd class="phpdocumentor-tag-list__definition">
  578. <span class="phpdocumentor-tag-link"><a href="https://www.thonky.com/qr-code-tutorial/mask-patterns"><abbr title="https://www.thonky.com/qr-code-tutorial/mask-patterns">https://www.thonky.com/qr-code-tutorial/mask-patterns</abbr></a></span>
  579. </dd>
  580. <dt class="phpdocumentor-tag-list__entry">
  581. <span class="phpdocumentor-tag__name">see</span>
  582. </dt>
  583. <dd class="phpdocumentor-tag-list__definition">
  584. <span class="phpdocumentor-tag-link"><a href="https://github.com/zxing/zxing/blob/e9e2bd280bcaeabd59d0f955798384fe6c018a6c/core/src/main/java/com/google/zxing/qrcode/decoder/DataMask.java#L32-L117"><abbr title="https://github.com/zxing/zxing/blob/e9e2bd280bcaeabd59d0f955798384fe6c018a6c/core/src/main/java/com/google/zxing/qrcode/decoder/DataMask.java#L32-L117">https://github.com/zxing/zxing/blob/e9e2bd280bcaeabd59d0f955798384fe6c018a6c/core/src/main/java/com/google/zxing/qrcode/decoder/DataMask.java#L32-L117</abbr></a></span>
  585. </dd>
  586. </dl>
  587. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  588. <span class="phpdocumentor-signature__response_type"><abbr title="\Closure">Closure</abbr></span>
  589. &mdash;
  590. </article>
  591. <article
  592. class="phpdocumentor-element
  593. -method
  594. -public
  595. "
  596. >
  597. <h4 class="phpdocumentor-element__name" id="method_getPattern">
  598. getPattern()
  599. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_getPattern" class="headerlink"><i class="fas fa-link"></i></a>
  600. </h4>
  601. <aside class="phpdocumentor-element-found-in">
  602. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  603. :
  604. <span class="phpdocumentor-element-found-in__line">71</span>
  605. </aside>
  606. <p class="phpdocumentor-summary">Returns the current mask pattern</p>
  607. <code class="phpdocumentor-code phpdocumentor-signature ">
  608. <span class="phpdocumentor-signature__visibility">public</span>
  609. <span class="phpdocumentor-signature__name">getPattern</span><span>(</span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">int</span></code>
  610. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  611. <span class="phpdocumentor-signature__response_type">int</span>
  612. &mdash;
  613. </article>
  614. <article
  615. class="phpdocumentor-element
  616. -method
  617. -public
  618. -static "
  619. >
  620. <h4 class="phpdocumentor-element__name" id="method_testRule1">
  621. testRule1()
  622. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_testRule1" class="headerlink"><i class="fas fa-link"></i></a>
  623. </h4>
  624. <aside class="phpdocumentor-element-found-in">
  625. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  626. :
  627. <span class="phpdocumentor-element-found-in__line">127</span>
  628. </aside>
  629. <p class="phpdocumentor-summary">Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and
  630. give penalty to them. Example: 00000 or 11111.</p>
  631. <code class="phpdocumentor-code phpdocumentor-signature ">
  632. <span class="phpdocumentor-signature__visibility">public</span>
  633. <span class="phpdocumentor-signature__static">static</span> <span class="phpdocumentor-signature__name">testRule1</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">$matrix</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">$height</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">$width</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">int</span></code>
  634. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  635. <dl class="phpdocumentor-argument-list">
  636. <dt class="phpdocumentor-argument-list__entry">
  637. <span class="phpdocumentor-signature__argument__name">$matrix</span>
  638. : <span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;</span>
  639. </dt>
  640. <dd class="phpdocumentor-argument-list__definition">
  641. <section class="phpdocumentor-description"></section>
  642. </dd>
  643. <dt class="phpdocumentor-argument-list__entry">
  644. <span class="phpdocumentor-signature__argument__name">$height</span>
  645. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  646. </dt>
  647. <dd class="phpdocumentor-argument-list__definition">
  648. <section class="phpdocumentor-description"></section>
  649. </dd>
  650. <dt class="phpdocumentor-argument-list__entry">
  651. <span class="phpdocumentor-signature__argument__name">$width</span>
  652. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  653. </dt>
  654. <dd class="phpdocumentor-argument-list__definition">
  655. <section class="phpdocumentor-description"></section>
  656. </dd>
  657. </dl>
  658. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  659. <span class="phpdocumentor-signature__response_type">int</span>
  660. &mdash;
  661. </article>
  662. <article
  663. class="phpdocumentor-element
  664. -method
  665. -public
  666. -static "
  667. >
  668. <h4 class="phpdocumentor-element__name" id="method_testRule2">
  669. testRule2()
  670. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_testRule2" class="headerlink"><i class="fas fa-link"></i></a>
  671. </h4>
  672. <aside class="phpdocumentor-element-found-in">
  673. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  674. :
  675. <span class="phpdocumentor-element-found-in__line">169</span>
  676. </aside>
  677. <p class="phpdocumentor-summary">Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give
  678. penalty to them. This is actually equivalent to the spec&#039;s rule, which is to find MxN blocks and give a
  679. penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block.</p>
  680. <code class="phpdocumentor-code phpdocumentor-signature ">
  681. <span class="phpdocumentor-signature__visibility">public</span>
  682. <span class="phpdocumentor-signature__static">static</span> <span class="phpdocumentor-signature__name">testRule2</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">$matrix</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">$height</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">$width</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">int</span></code>
  683. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  684. <dl class="phpdocumentor-argument-list">
  685. <dt class="phpdocumentor-argument-list__entry">
  686. <span class="phpdocumentor-signature__argument__name">$matrix</span>
  687. : <span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;</span>
  688. </dt>
  689. <dd class="phpdocumentor-argument-list__definition">
  690. <section class="phpdocumentor-description"></section>
  691. </dd>
  692. <dt class="phpdocumentor-argument-list__entry">
  693. <span class="phpdocumentor-signature__argument__name">$height</span>
  694. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  695. </dt>
  696. <dd class="phpdocumentor-argument-list__definition">
  697. <section class="phpdocumentor-description"></section>
  698. </dd>
  699. <dt class="phpdocumentor-argument-list__entry">
  700. <span class="phpdocumentor-signature__argument__name">$width</span>
  701. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  702. </dt>
  703. <dd class="phpdocumentor-argument-list__definition">
  704. <section class="phpdocumentor-description"></section>
  705. </dd>
  706. </dl>
  707. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  708. <span class="phpdocumentor-signature__response_type">int</span>
  709. &mdash;
  710. </article>
  711. <article
  712. class="phpdocumentor-element
  713. -method
  714. -public
  715. -static "
  716. >
  717. <h4 class="phpdocumentor-element__name" id="method_testRule3">
  718. testRule3()
  719. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_testRule3" class="headerlink"><i class="fas fa-link"></i></a>
  720. </h4>
  721. <aside class="phpdocumentor-element-found-in">
  722. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  723. :
  724. <span class="phpdocumentor-element-found-in__line">202</span>
  725. </aside>
  726. <p class="phpdocumentor-summary">Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4
  727. starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them. If we
  728. find patterns like 000010111010000, we give penalty once.</p>
  729. <code class="phpdocumentor-code phpdocumentor-signature ">
  730. <span class="phpdocumentor-signature__visibility">public</span>
  731. <span class="phpdocumentor-signature__static">static</span> <span class="phpdocumentor-signature__name">testRule3</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">$matrix</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">$height</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">$width</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">int</span></code>
  732. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  733. <dl class="phpdocumentor-argument-list">
  734. <dt class="phpdocumentor-argument-list__entry">
  735. <span class="phpdocumentor-signature__argument__name">$matrix</span>
  736. : <span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;</span>
  737. </dt>
  738. <dd class="phpdocumentor-argument-list__definition">
  739. <section class="phpdocumentor-description"></section>
  740. </dd>
  741. <dt class="phpdocumentor-argument-list__entry">
  742. <span class="phpdocumentor-signature__argument__name">$height</span>
  743. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  744. </dt>
  745. <dd class="phpdocumentor-argument-list__definition">
  746. <section class="phpdocumentor-description"></section>
  747. </dd>
  748. <dt class="phpdocumentor-argument-list__entry">
  749. <span class="phpdocumentor-signature__argument__name">$width</span>
  750. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  751. </dt>
  752. <dd class="phpdocumentor-argument-list__definition">
  753. <section class="phpdocumentor-description"></section>
  754. </dd>
  755. </dl>
  756. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  757. <span class="phpdocumentor-signature__response_type">int</span>
  758. &mdash;
  759. </article>
  760. <article
  761. class="phpdocumentor-element
  762. -method
  763. -public
  764. -static "
  765. >
  766. <h4 class="phpdocumentor-element__name" id="method_testRule4">
  767. testRule4()
  768. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_testRule4" class="headerlink"><i class="fas fa-link"></i></a>
  769. </h4>
  770. <aside class="phpdocumentor-element-found-in">
  771. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  772. :
  773. <span class="phpdocumentor-element-found-in__line">282</span>
  774. </aside>
  775. <p class="phpdocumentor-summary">Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give
  776. penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.</p>
  777. <code class="phpdocumentor-code phpdocumentor-signature ">
  778. <span class="phpdocumentor-signature__visibility">public</span>
  779. <span class="phpdocumentor-signature__static">static</span> <span class="phpdocumentor-signature__name">testRule4</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">$matrix</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">$height</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">$width</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">int</span></code>
  780. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  781. <dl class="phpdocumentor-argument-list">
  782. <dt class="phpdocumentor-argument-list__entry">
  783. <span class="phpdocumentor-signature__argument__name">$matrix</span>
  784. : <span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;</span>
  785. </dt>
  786. <dd class="phpdocumentor-argument-list__definition">
  787. <section class="phpdocumentor-description"></section>
  788. </dd>
  789. <dt class="phpdocumentor-argument-list__entry">
  790. <span class="phpdocumentor-signature__argument__name">$height</span>
  791. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  792. </dt>
  793. <dd class="phpdocumentor-argument-list__definition">
  794. <section class="phpdocumentor-description"></section>
  795. </dd>
  796. <dt class="phpdocumentor-argument-list__entry">
  797. <span class="phpdocumentor-signature__argument__name">$width</span>
  798. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  799. </dt>
  800. <dd class="phpdocumentor-argument-list__definition">
  801. <section class="phpdocumentor-description"></section>
  802. </dd>
  803. </dl>
  804. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  805. <span class="phpdocumentor-signature__response_type">int</span>
  806. &mdash;
  807. </article>
  808. <article
  809. class="phpdocumentor-element
  810. -method
  811. -private
  812. -static "
  813. >
  814. <h4 class="phpdocumentor-element__name" id="method_applyRule1">
  815. applyRule1()
  816. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_applyRule1" class="headerlink"><i class="fas fa-link"></i></a>
  817. </h4>
  818. <aside class="phpdocumentor-element-found-in">
  819. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  820. :
  821. <span class="phpdocumentor-element-found-in__line">131</span>
  822. </aside>
  823. <code class="phpdocumentor-code phpdocumentor-signature ">
  824. <span class="phpdocumentor-signature__visibility">private</span>
  825. <span class="phpdocumentor-signature__static">static</span> <span class="phpdocumentor-signature__name">applyRule1</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">$matrix</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">$height</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">$width</span></span><span class="phpdocumentor-signature__argument"><span>, </span><span class="phpdocumentor-signature__argument__return-type">bool&nbsp;</span><span class="phpdocumentor-signature__argument__name">$isHorizontal</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">int</span></code>
  826. <section class="phpdocumentor-description"></section>
  827. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  828. <dl class="phpdocumentor-argument-list">
  829. <dt class="phpdocumentor-argument-list__entry">
  830. <span class="phpdocumentor-signature__argument__name">$matrix</span>
  831. : <span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;</span>
  832. </dt>
  833. <dd class="phpdocumentor-argument-list__definition">
  834. <section class="phpdocumentor-description"></section>
  835. </dd>
  836. <dt class="phpdocumentor-argument-list__entry">
  837. <span class="phpdocumentor-signature__argument__name">$height</span>
  838. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  839. </dt>
  840. <dd class="phpdocumentor-argument-list__definition">
  841. <section class="phpdocumentor-description"></section>
  842. </dd>
  843. <dt class="phpdocumentor-argument-list__entry">
  844. <span class="phpdocumentor-signature__argument__name">$width</span>
  845. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  846. </dt>
  847. <dd class="phpdocumentor-argument-list__definition">
  848. <section class="phpdocumentor-description"></section>
  849. </dd>
  850. <dt class="phpdocumentor-argument-list__entry">
  851. <span class="phpdocumentor-signature__argument__name">$isHorizontal</span>
  852. : <span class="phpdocumentor-signature__argument__return-type">bool</span>
  853. </dt>
  854. <dd class="phpdocumentor-argument-list__definition">
  855. <section class="phpdocumentor-description"></section>
  856. </dd>
  857. </dl>
  858. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  859. <span class="phpdocumentor-signature__response_type">int</span>
  860. &mdash;
  861. </article>
  862. <article
  863. class="phpdocumentor-element
  864. -method
  865. -private
  866. -static "
  867. >
  868. <h4 class="phpdocumentor-element__name" id="method_isWhiteHorizontal">
  869. isWhiteHorizontal()
  870. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_isWhiteHorizontal" class="headerlink"><i class="fas fa-link"></i></a>
  871. </h4>
  872. <aside class="phpdocumentor-element-found-in">
  873. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  874. :
  875. <span class="phpdocumentor-element-found-in__line">248</span>
  876. </aside>
  877. <code class="phpdocumentor-code phpdocumentor-signature ">
  878. <span class="phpdocumentor-signature__visibility">private</span>
  879. <span class="phpdocumentor-signature__static">static</span> <span class="phpdocumentor-signature__name">isWhiteHorizontal</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">$row</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">$width</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">$from</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">$to</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">bool</span></code>
  880. <section class="phpdocumentor-description"></section>
  881. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  882. <dl class="phpdocumentor-argument-list">
  883. <dt class="phpdocumentor-argument-list__entry">
  884. <span class="phpdocumentor-signature__argument__name">$row</span>
  885. : <span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;</span>
  886. </dt>
  887. <dd class="phpdocumentor-argument-list__definition">
  888. <section class="phpdocumentor-description"></section>
  889. </dd>
  890. <dt class="phpdocumentor-argument-list__entry">
  891. <span class="phpdocumentor-signature__argument__name">$width</span>
  892. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  893. </dt>
  894. <dd class="phpdocumentor-argument-list__definition">
  895. <section class="phpdocumentor-description"></section>
  896. </dd>
  897. <dt class="phpdocumentor-argument-list__entry">
  898. <span class="phpdocumentor-signature__argument__name">$from</span>
  899. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  900. </dt>
  901. <dd class="phpdocumentor-argument-list__definition">
  902. <section class="phpdocumentor-description"></section>
  903. </dd>
  904. <dt class="phpdocumentor-argument-list__entry">
  905. <span class="phpdocumentor-signature__argument__name">$to</span>
  906. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  907. </dt>
  908. <dd class="phpdocumentor-argument-list__definition">
  909. <section class="phpdocumentor-description"></section>
  910. </dd>
  911. </dl>
  912. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  913. <span class="phpdocumentor-signature__response_type">bool</span>
  914. &mdash;
  915. </article>
  916. <article
  917. class="phpdocumentor-element
  918. -method
  919. -private
  920. -static "
  921. >
  922. <h4 class="phpdocumentor-element__name" id="method_isWhiteVertical">
  923. isWhiteVertical()
  924. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#method_isWhiteVertical" class="headerlink"><i class="fas fa-link"></i></a>
  925. </h4>
  926. <aside class="phpdocumentor-element-found-in">
  927. <abbr class="phpdocumentor-element-found-in__file" title="src/Common/MaskPattern.php"><a href="files/src-common-maskpattern.html"><abbr title="src/Common/MaskPattern.php">MaskPattern.php</abbr></a></abbr>
  928. :
  929. <span class="phpdocumentor-element-found-in__line">263</span>
  930. </aside>
  931. <code class="phpdocumentor-code phpdocumentor-signature ">
  932. <span class="phpdocumentor-signature__visibility">private</span>
  933. <span class="phpdocumentor-signature__static">static</span> <span class="phpdocumentor-signature__name">isWhiteVertical</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">$matrix</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">$height</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">$x</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">$from</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">$to</span></span><span>)</span><span> : </span><span class="phpdocumentor-signature__response_type">bool</span></code>
  934. <section class="phpdocumentor-description"></section>
  935. <h5 class="phpdocumentor-argument-list__heading">Parameters</h5>
  936. <dl class="phpdocumentor-argument-list">
  937. <dt class="phpdocumentor-argument-list__entry">
  938. <span class="phpdocumentor-signature__argument__name">$matrix</span>
  939. : <span class="phpdocumentor-signature__argument__return-type">array&lt;string|int, mixed&gt;</span>
  940. </dt>
  941. <dd class="phpdocumentor-argument-list__definition">
  942. <section class="phpdocumentor-description"></section>
  943. </dd>
  944. <dt class="phpdocumentor-argument-list__entry">
  945. <span class="phpdocumentor-signature__argument__name">$height</span>
  946. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  947. </dt>
  948. <dd class="phpdocumentor-argument-list__definition">
  949. <section class="phpdocumentor-description"></section>
  950. </dd>
  951. <dt class="phpdocumentor-argument-list__entry">
  952. <span class="phpdocumentor-signature__argument__name">$x</span>
  953. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  954. </dt>
  955. <dd class="phpdocumentor-argument-list__definition">
  956. <section class="phpdocumentor-description"></section>
  957. </dd>
  958. <dt class="phpdocumentor-argument-list__entry">
  959. <span class="phpdocumentor-signature__argument__name">$from</span>
  960. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  961. </dt>
  962. <dd class="phpdocumentor-argument-list__definition">
  963. <section class="phpdocumentor-description"></section>
  964. </dd>
  965. <dt class="phpdocumentor-argument-list__entry">
  966. <span class="phpdocumentor-signature__argument__name">$to</span>
  967. : <span class="phpdocumentor-signature__argument__return-type">int</span>
  968. </dt>
  969. <dd class="phpdocumentor-argument-list__definition">
  970. <section class="phpdocumentor-description"></section>
  971. </dd>
  972. </dl>
  973. <h5 class="phpdocumentor-return-value__heading">Return values</h5>
  974. <span class="phpdocumentor-signature__response_type">bool</span>
  975. &mdash;
  976. </article>
  977. </section>
  978. <script type="text/javascript">
  979. function loadExternalCodeSnippets(line) {
  980. Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach((pre) => {
  981. var src = pre.getAttribute('data-src').replace( /\\/g, '/');
  982. var extension = (src.match(/\.(\w+)$/) || [, ''])[1];
  983. var language = 'php';
  984. var code = document.createElement('code');
  985. code.className = 'language-' + language;
  986. pre.textContent = '';
  987. pre.setAttribute('data-line', line)
  988. code.textContent = 'Loading…';
  989. pre.appendChild(code);
  990. var xhr = new XMLHttpRequest();
  991. xhr.open('GET', src, true);
  992. xhr.onreadystatechange = function () {
  993. if (xhr.readyState == 4) {
  994. if (xhr.status < 400 && xhr.responseText) {
  995. code.textContent = xhr.responseText;
  996. Prism.highlightElement(code);
  997. }
  998. else if (xhr.status >= 400) {
  999. code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText;
  1000. }
  1001. else {
  1002. code.textContent = '✖ Error: File does not exist, is empty or trying to view from localhost';
  1003. }
  1004. }
  1005. };
  1006. xhr.send(null);
  1007. });
  1008. }
  1009. var modals = document.querySelectorAll("[data-modal]");
  1010. modals.forEach(function (trigger) {
  1011. trigger.addEventListener("click", function (event) {
  1012. //event.preventDefault();
  1013. const modal = document.getElementById(trigger.dataset.modal);
  1014. modal.classList.add("phpdocumentor-modal__open");
  1015. loadExternalCodeSnippets(trigger.dataset.line)
  1016. const exits = modal.querySelectorAll("[data-exit-button]");
  1017. exits.forEach(function (exit) {
  1018. exit.addEventListener("click", function (event) {
  1019. event.preventDefault();
  1020. modal.classList.remove("phpdocumentor-modal__open");
  1021. });
  1022. });
  1023. });
  1024. });
  1025. </script>
  1026. </article>
  1027. <section data-search-results class="phpdocumentor-search-results phpdocumentor-search-results--hidden">
  1028. <section class="phpdocumentor-search-results__dialog">
  1029. <header class="phpdocumentor-search-results__header">
  1030. <h2 class="phpdocumentor-search-results__title">Search results</h2>
  1031. <button class="phpdocumentor-search-results__close"><i class="fas fa-times"></i></button>
  1032. </header>
  1033. <section class="phpdocumentor-search-results__body">
  1034. <ul class="phpdocumentor-search-results__entries"></ul>
  1035. </section>
  1036. </section>
  1037. </section>
  1038. </div>
  1039. </div>
  1040. <a href="classes/chillerlan-QRCode-Common-MaskPattern.html#top" class="phpdocumentor-back-to-top"><i class="fas fa-chevron-circle-up"></i></a>
  1041. </main>
  1042. <script>
  1043. cssVars({});
  1044. </script>
  1045. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
  1046. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>
  1047. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-numbers/prism-line-numbers.min.js"></script>
  1048. <script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/plugins/line-highlight/prism-line-highlight.min.js"></script>
  1049. </body>
  1050. </html>