├── .gitignore ├── LICENSE.md ├── README.md ├── node_modules └── .cache │ └── ava │ └── failing-tests.json ├── package.json ├── src ├── deltaphistar.js └── test.html ├── test ├── .DS_Store └── index.js └── versionHistory.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Mac 10 | .DS_Store 11 | 12 | # Diagnostic reports (https://nodejs.org/api/report.html) 13 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 14 | 15 | # Runtime data 16 | pids 17 | *.pid 18 | *.seed 19 | *.pid.lock 20 | 21 | # Directory for instrumented libs generated by jscoverage/JSCover 22 | lib-cov 23 | 24 | # Coverage directory used by tools like istanbul 25 | coverage 26 | *.lcov 27 | 28 | # nyc test coverage 29 | .nyc_output 30 | 31 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 32 | .grunt 33 | 34 | # Bower dependency directory (https://bower.io/) 35 | bower_components 36 | 37 | # node-waf configuration 38 | .lock-wscript 39 | 40 | # Compiled binary addons (https://nodejs.org/api/addons.html) 41 | build/Release 42 | 43 | # Dependency directories 44 | node_modules/ 45 | jspm_packages/ 46 | 47 | # TypeScript v1 declaration files 48 | typings/ 49 | 50 | # TypeScript cache 51 | *.tsbuildinfo 52 | 53 | # Optional npm cache directory 54 | .npm 55 | 56 | # Optional eslint cache 57 | .eslintcache 58 | 59 | # Microbundle cache 60 | .rpt2_cache/ 61 | .rts2_cache_cjs/ 62 | .rts2_cache_es/ 63 | .rts2_cache_umd/ 64 | 65 | # Optional REPL history 66 | .node_repl_history 67 | 68 | # Output of 'npm pack' 69 | *.tgz 70 | 71 | # Yarn Integrity file 72 | .yarn-integrity 73 | 74 | # dotenv environment variables file 75 | .env 76 | .env.test 77 | 78 | # parcel-bundler cache (https://parceljs.org/) 79 | .cache 80 | 81 | # Next.js build output 82 | .next 83 | 84 | # Nuxt.js build / generate output 85 | .nuxt 86 | dist 87 | 88 | # Gatsby files 89 | .cache/ 90 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 91 | # https://nextjs.org/blog/next-9-1#public-directory-support 92 | # public 93 | 94 | # vuepress build output 95 | .vuepress/dist 96 | 97 | # Serverless directories 98 | .serverless/ 99 | 100 | # FuseBox cache 101 | .fusebox/ 102 | 103 | # DynamoDB Local files 104 | .dynamodb/ 105 | 106 | # TernJS port file 107 | .tern-port 108 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # DPS CONTRAST (DELTA PHI STAR) LICENSE 2 | ***DPS Contrast***, also known as ***Delta Phi Star***, is a simple formula for predicting human visual perception of contrast between text and background. 3 | 4 | - **WHAT WHERE HOW** 5 | - Delta Phi Star predicts the contrast of text against the background for a given pair of colors. 6 | - Delta Phi Star emerged from the SAPC/APCA project developing new standards for better beat ability on the web. 7 | - Delta Phi Star takes in two $L^*$ (Lstar) values, and returns an $L^c$ (lightness contrast) value. 8 | 9 | - **UNIFORMITY:** 10 | - DPS Contrast is quasi-uniform for human perception of text against a background on a self-illuminated display 11 | - reasonably accurate within a defined range $L^c 45$ to $L^c 75$ and for positive polarity (dark text on a light background) 12 | - The perception curve is based on the output of SACMX-based mixed-mode high-spatial-frequency contrast matching data, using 13 | - hardware-calibrated standard-dynamic-range (SDR) sRGB displays 14 | - a typical office-type lighting environment with a nominal ambient illumination of 350 lux. 15 | 16 | - **LIMITATIONS:** 17 | - DPS Contrast becomes substantially less accurate at very high and very low contrasts 18 | - $L^c$ values lower than $L^c 45$ or higher than $L^c 75$ are generally higher than actual perception 19 | - as such $L^c$ values lower than $L^c 45$ or higher than $L^c 75$ should be derated 20 | - DPS Contrast is not polarity aware 21 | - and $L^c$ values for reverse polarity aka "dark mode" are generally lower 22 | - in dark mode, actual contrast is higher than the reported $L^c$ values between $L^c 40$ & $L^c 70$ 23 | - to approximate the polarity difference, add **$5$** to the $L^c$ value for dark mode results between $L^c 40$ & $L^c 70$ 24 | 25 | - **INITALISMS and ACRONYMS:** 26 | - APCA™: Accessible Perceptual Contrast Algorithm™ *(aye pea see aye)* 27 | - sometimes referred to as the Advanced Perceptual Contrast Algorithm 28 | - is a perceptual uniform model of text on a self-illuminated display 29 | - APCA-W3: APCA World Wide Web 30 | - specific apca version intended for WCAG guidelines 31 | - includes a version of APCA-RDG accessibility guidelines for visual readability 32 | - APCA-RDG: APCA Readability Design Guidelines 33 | - an independent set of design guidelines to promote effective readability and accessibility for visually readable content 34 | - DPS-C: Delta Phi Star™ Contrast *(dee pea ess)* 35 | - simplified quasi-uniform perceptual contrast model 36 | - SACAM™: SLuv Accessible Color Appearance Model™ *(say cam)* 37 | - color appearance model that is designed specifically for self-illuminated displays 38 | - features utilities to accommodate various visual impairments 39 | - SAPC™: SLuv Accessible Perceptual Contrast™ *(sap see)* 40 | - an earlier contrast appearance model that laid the foundation for APCA and SACAM 41 | - SACMX: Spatially Aware Contrast Matching eXperiment 42 | - a method of measuring the perceived suprathreshold contrast at high spatial frequencies 43 | 44 | - **COPYRIGHT and TRADEMARKS:** 45 | - this repo and all materials contained here in, are copyright © 2022 by Andrew Somers. All Rights Reserved. Use permitted as defined in this license agreement. 46 | - Nothing in this license agreement extends to nor permits the use of any trademarks shown anywhere in this repo, unless specifically stated. 47 | - The term "Delta Phi Star™" may be used to describe instantiations, integrations, applications, libraries, or frameworks which are using the materials in this repo, provided that such usage is unaltered except as may be needed to port to different languages. 48 | 49 | 50 | 51 | ## MODIFIED AFFERO GENERAL PUBLIC LICENSE 52 | Software and source code in this repo is licensed per the AGPL version three, pursuant to the following modifications and provisions as provided for in AGPL Section 7, and as enumerated below. 53 | 54 | ### *The followings provisions modify the terms of the AGPL, per section seven:* 55 | 56 | 1. **Attribution** 57 | - the use of any source code, other intellectual property, or other materials presented in this repo requires, at a minimum, attribution to the code author and a repo owner, Andrew Somers. 58 | - attribution to be placed with the attribution for other contributors. 59 | - within an attribution listing of only names without indication of what was contributed, the attribution shall be *"Andrew Somers"* 60 | - within an attribution listing which includes reference to the contributing material, the attribution shall convey *"Delta Phi Star Contrast by Andrew Somers"* in a form consistent with other contributors. 61 | 2. **As-Is, No Warranty Expressed Nor Implied** 62 | - the source code and other intellectual property in this repository is offered exclusively as-is, with no warranty whatsoever, neither expressed nor implied, including no obligation of providing support of any kind, including but not limited to technical, support, testing, evaluation, and integration. 63 | 3. **Limitations on Use and Safety Evaluation** 64 | - the owners of this repository accept no liability whatsoever for the use or misuse or inappropriate use of any of the materials herein. 65 | - the user(s) of any of the materials in this repository applications involving any level of human safety including but not limited to medical, clinical, transportation, aerospace, motor vehicle, military, and law-enforcement, shall except full liability for the use of the materials herein. 66 | - the user(s) of materials in this repository shall be solely responsible for any and all safety testing, evaluation, and certifications, as may be required or deemed necessary or prudent for their specific implementation or application. 67 | 4. **Fitness of Purpose and Hold Harmless** 68 | - no claim is made, nor is any assertion supported, regarding the fitness-of-purpose or fitness-of-use of any materials in this repository for any use or for any given application, integration, library, framework, or any other utilization of the materials in this repository. 69 | - the fitness of purpose, and/or fitness-of-use, of any materals in ths repository shall be determined soley by the user(s) of the materials, who shall accept any and all liabilities from the use, integration, implementation, distribution, and application of any of the materials including any underlying theories and guidelines. 70 | - users of any materials in this repository shall hold harmless the owners of this repository and the contributors to this repository of any and all liabilities stemming from any use misuse or inappropriate use of the materials here in. 71 | 5. **Support Limitations** 72 | - outside of any written contract for support, there is no guarantee or warranty providing for any specific level of support, support requests shall be handled on an available time and resources basis, at the sole discretion of the owners and contributors to this repository and related repositories. 73 | - limited support is offered here in the issues and discussion sections, and at the other SAPC-APCA repos, on an as–available basis, and provided as is and without any form of client/vendor expectation. 74 | - the contributors to this repository have sole discretion as too the level, volume, and degree of support offered at any given time. 75 | 76 | 77 | ```text 78 | GNU AFFERO GENERAL PUBLIC LICENSE 79 | Version 3, 19 November 2007 80 | 81 | Copyright (C) 2007 Free Software Foundation, Inc. 82 | Everyone is permitted to copy and distribute verbatim copies 83 | of this license document, but changing it is not allowed. 84 | 85 | Preamble 86 | 87 | The GNU Affero General Public License is a free, copyleft license for 88 | software and other kinds of works, specifically designed to ensure 89 | cooperation with the community in the case of network server software. 90 | 91 | The licenses for most software and other practical works are designed 92 | to take away your freedom to share and change the works. By contrast, 93 | our General Public Licenses are intended to guarantee your freedom to 94 | share and change all versions of a program--to make sure it remains free 95 | software for all its users. 96 | 97 | When we speak of free software, we are referring to freedom, not 98 | price. Our General Public Licenses are designed to make sure that you 99 | have the freedom to distribute copies of free software (and charge for 100 | them if you wish), that you receive source code or can get it if you 101 | want it, that you can change the software or use pieces of it in new 102 | free programs, and that you know you can do these things. 103 | 104 | Developers that use our General Public Licenses protect your rights 105 | with two steps: (1) assert copyright on the software, and (2) offer 106 | you this License which gives you legal permission to copy, distribute 107 | and/or modify the software. 108 | 109 | A secondary benefit of defending all users' freedom is that 110 | improvements made in alternate versions of the program, if they 111 | receive widespread use, become available for other developers to 112 | incorporate. Many developers of free software are heartened and 113 | encouraged by the resulting cooperation. However, in the case of 114 | software used on network servers, this result may fail to come about. 115 | The GNU General Public License permits making a modified version and 116 | letting the public access it on a server without ever releasing its 117 | source code to the public. 118 | 119 | The GNU Affero General Public License is designed specifically to 120 | ensure that, in such cases, the modified source code becomes available 121 | to the community. It requires the operator of a network server to 122 | provide the source code of the modified version running there to the 123 | users of that server. Therefore, public use of a modified version, on 124 | a publicly accessible server, gives the public access to the source 125 | code of the modified version. 126 | 127 | An older license, called the Affero General Public License and 128 | published by Affero, was designed to accomplish similar goals. This is 129 | a different license, not a version of the Affero GPL, but Affero has 130 | released a new version of the Affero GPL which permits relicensing under 131 | this license. 132 | 133 | The precise terms and conditions for copying, distribution and 134 | modification follow. 135 | 136 | TERMS AND CONDITIONS 137 | 138 | 0. Definitions. 139 | 140 | "This License" refers to version 3 of the GNU Affero General Public License. 141 | 142 | "Copyright" also means copyright-like laws that apply to other kinds of 143 | works, such as semiconductor masks. 144 | 145 | "The Program" refers to any copyrightable work licensed under this 146 | License. Each licensee is addressed as "you". "Licensees" and 147 | "recipients" may be individuals or organizations. 148 | 149 | To "modify" a work means to copy from or adapt all or part of the work 150 | in a fashion requiring copyright permission, other than the making of an 151 | exact copy. The resulting work is called a "modified version" of the 152 | earlier work or a work "based on" the earlier work. 153 | 154 | A "covered work" means either the unmodified Program or a work based 155 | on the Program. 156 | 157 | To "propagate" a work means to do anything with it that, without 158 | permission, would make you directly or secondarily liable for 159 | infringement under applicable copyright law, except executing it on a 160 | computer or modifying a private copy. Propagation includes copying, 161 | distribution (with or without modification), making available to the 162 | public, and in some countries other activities as well. 163 | 164 | To "convey" a work means any kind of propagation that enables other 165 | parties to make or receive copies. Mere interaction with a user through 166 | a computer network, with no transfer of a copy, is not conveying. 167 | 168 | An interactive user interface displays "Appropriate Legal Notices" 169 | to the extent that it includes a convenient and prominently visible 170 | feature that (1) displays an appropriate copyright notice, and (2) 171 | tells the user that there is no warranty for the work (except to the 172 | extent that warranties are provided), that licensees may convey the 173 | work under this License, and how to view a copy of this License. If 174 | the interface presents a list of user commands or options, such as a 175 | menu, a prominent item in the list meets this criterion. 176 | 177 | 1. Source Code. 178 | 179 | The "source code" for a work means the preferred form of the work 180 | for making modifications to it. "Object code" means any non-source 181 | form of a work. 182 | 183 | A "Standard Interface" means an interface that either is an official 184 | standard defined by a recognized standards body, or, in the case of 185 | interfaces specified for a particular programming language, one that 186 | is widely used among developers working in that language. 187 | 188 | The "System Libraries" of an executable work include anything, other 189 | than the work as a whole, that (a) is included in the normal form of 190 | packaging a Major Component, but which is not part of that Major 191 | Component, and (b) serves only to enable use of the work with that 192 | Major Component, or to implement a Standard Interface for which an 193 | implementation is available to the public in source code form. A 194 | "Major Component", in this context, means a major essential component 195 | (kernel, window system, and so on) of the specific operating system 196 | (if any) on which the executable work runs, or a compiler used to 197 | produce the work, or an object code interpreter used to run it. 198 | 199 | The "Corresponding Source" for a work in object code form means all 200 | the source code needed to generate, install, and (for an executable 201 | work) run the object code and to modify the work, including scripts to 202 | control those activities. However, it does not include the work's 203 | System Libraries, or general-purpose tools or generally available free 204 | programs which are used unmodified in performing those activities but 205 | which are not part of the work. For example, Corresponding Source 206 | includes interface definition files associated with source files for 207 | the work, and the source code for shared libraries and dynamically 208 | linked subprograms that the work is specifically designed to require, 209 | such as by intimate data communication or control flow between those 210 | subprograms and other parts of the work. 211 | 212 | The Corresponding Source need not include anything that users 213 | can regenerate automatically from other parts of the Corresponding 214 | Source. 215 | 216 | The Corresponding Source for a work in source code form is that 217 | same work. 218 | 219 | 2. Basic Permissions. 220 | 221 | All rights granted under this License are granted for the term of 222 | copyright on the Program, and are irrevocable provided the stated 223 | conditions are met. This License explicitly affirms your unlimited 224 | permission to run the unmodified Program. The output from running a 225 | covered work is covered by this License only if the output, given its 226 | content, constitutes a covered work. This License acknowledges your 227 | rights of fair use or other equivalent, as provided by copyright law. 228 | 229 | You may make, run and propagate covered works that you do not 230 | convey, without conditions so long as your license otherwise remains 231 | in force. You may convey covered works to others for the sole purpose 232 | of having them make modifications exclusively for you, or provide you 233 | with facilities for running those works, provided that you comply with 234 | the terms of this License in conveying all material for which you do 235 | not control copyright. Those thus making or running the covered works 236 | for you must do so exclusively on your behalf, under your direction 237 | and control, on terms that prohibit them from making any copies of 238 | your copyrighted material outside their relationship with you. 239 | 240 | Conveying under any other circumstances is permitted solely under 241 | the conditions stated below. Sublicensing is not allowed; section 10 242 | makes it unnecessary. 243 | 244 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 245 | 246 | No covered work shall be deemed part of an effective technological 247 | measure under any applicable law fulfilling obligations under article 248 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 249 | similar laws prohibiting or restricting circumvention of such 250 | measures. 251 | 252 | When you convey a covered work, you waive any legal power to forbid 253 | circumvention of technological measures to the extent such circumvention 254 | is effected by exercising rights under this License with respect to 255 | the covered work, and you disclaim any intention to limit operation or 256 | modification of the work as a means of enforcing, against the work's 257 | users, your or third parties' legal rights to forbid circumvention of 258 | technological measures. 259 | 260 | 4. Conveying Verbatim Copies. 261 | 262 | You may convey verbatim copies of the Program's source code as you 263 | receive it, in any medium, provided that you conspicuously and 264 | appropriately publish on each copy an appropriate copyright notice; 265 | keep intact all notices stating that this License and any 266 | non-permissive terms added in accord with section 7 apply to the code; 267 | keep intact all notices of the absence of any warranty; and give all 268 | recipients a copy of this License along with the Program. 269 | 270 | You may charge any price or no price for each copy that you convey, 271 | and you may offer support or warranty protection for a fee. 272 | 273 | 5. Conveying Modified Source Versions. 274 | 275 | You may convey a work based on the Program, or the modifications to 276 | produce it from the Program, in the form of source code under the 277 | terms of section 4, provided that you also meet all of these conditions: 278 | 279 | a) The work must carry prominent notices stating that you modified 280 | it, and giving a relevant date. 281 | 282 | b) The work must carry prominent notices stating that it is 283 | released under this License and any conditions added under section 284 | 7. This requirement modifies the requirement in section 4 to 285 | "keep intact all notices". 286 | 287 | c) You must license the entire work, as a whole, under this 288 | License to anyone who comes into possession of a copy. This 289 | License will therefore apply, along with any applicable section 7 290 | additional terms, to the whole of the work, and all its parts, 291 | regardless of how they are packaged. This License gives no 292 | permission to license the work in any other way, but it does not 293 | invalidate such permission if you have separately received it. 294 | 295 | d) If the work has interactive user interfaces, each must display 296 | Appropriate Legal Notices; however, if the Program has interactive 297 | interfaces that do not display Appropriate Legal Notices, your 298 | work need not make them do so. 299 | 300 | A compilation of a covered work with other separate and independent 301 | works, which are not by their nature extensions of the covered work, 302 | and which are not combined with it such as to form a larger program, 303 | in or on a volume of a storage or distribution medium, is called an 304 | "aggregate" if the compilation and its resulting copyright are not 305 | used to limit the access or legal rights of the compilation's users 306 | beyond what the individual works permit. Inclusion of a covered work 307 | in an aggregate does not cause this License to apply to the other 308 | parts of the aggregate. 309 | 310 | 6. Conveying Non-Source Forms. 311 | 312 | You may convey a covered work in object code form under the terms 313 | of sections 4 and 5, provided that you also convey the 314 | machine-readable Corresponding Source under the terms of this License, 315 | in one of these ways: 316 | 317 | a) Convey the object code in, or embodied in, a physical product 318 | (including a physical distribution medium), accompanied by the 319 | Corresponding Source fixed on a durable physical medium 320 | customarily used for software interchange. 321 | 322 | b) Convey the object code in, or embodied in, a physical product 323 | (including a physical distribution medium), accompanied by a 324 | written offer, valid for at least three years and valid for as 325 | long as you offer spare parts or customer support for that product 326 | model, to give anyone who possesses the object code either (1) a 327 | copy of the Corresponding Source for all the software in the 328 | product that is covered by this License, on a durable physical 329 | medium customarily used for software interchange, for a price no 330 | more than your reasonable cost of physically performing this 331 | conveying of source, or (2) access to copy the 332 | Corresponding Source from a network server at no charge. 333 | 334 | c) Convey individual copies of the object code with a copy of the 335 | written offer to provide the Corresponding Source. This 336 | alternative is allowed only occasionally and noncommercially, and 337 | only if you received the object code with such an offer, in accord 338 | with subsection 6b. 339 | 340 | d) Convey the object code by offering access from a designated 341 | place (gratis or for a charge), and offer equivalent access to the 342 | Corresponding Source in the same way through the same place at no 343 | further charge. You need not require recipients to copy the 344 | Corresponding Source along with the object code. If the place to 345 | copy the object code is a network server, the Corresponding Source 346 | may be on a different server (operated by you or a third party) 347 | that supports equivalent copying facilities, provided you maintain 348 | clear directions next to the object code saying where to find the 349 | Corresponding Source. Regardless of what server hosts the 350 | Corresponding Source, you remain obligated to ensure that it is 351 | available for as long as needed to satisfy these requirements. 352 | 353 | e) Convey the object code using peer-to-peer transmission, provided 354 | you inform other peers where the object code and Corresponding 355 | Source of the work are being offered to the general public at no 356 | charge under subsection 6d. 357 | 358 | A separable portion of the object code, whose source code is excluded 359 | from the Corresponding Source as a System Library, need not be 360 | included in conveying the object code work. 361 | 362 | A "User Product" is either (1) a "consumer product", which means any 363 | tangible personal property which is normally used for personal, family, 364 | or household purposes, or (2) anything designed or sold for incorporation 365 | into a dwelling. In determining whether a product is a consumer product, 366 | doubtful cases shall be resolved in favor of coverage. For a particular 367 | product received by a particular user, "normally used" refers to a 368 | typical or common use of that class of product, regardless of the status 369 | of the particular user or of the way in which the particular user 370 | actually uses, or expects or is expected to use, the product. A product 371 | is a consumer product regardless of whether the product has substantial 372 | commercial, industrial or non-consumer uses, unless such uses represent 373 | the only significant mode of use of the product. 374 | 375 | "Installation Information" for a User Product means any methods, 376 | procedures, authorization keys, or other information required to install 377 | and execute modified versions of a covered work in that User Product from 378 | a modified version of its Corresponding Source. The information must 379 | suffice to ensure that the continued functioning of the modified object 380 | code is in no case prevented or interfered with solely because 381 | modification has been made. 382 | 383 | If you convey an object code work under this section in, or with, or 384 | specifically for use in, a User Product, and the conveying occurs as 385 | part of a transaction in which the right of possession and use of the 386 | User Product is transferred to the recipient in perpetuity or for a 387 | fixed term (regardless of how the transaction is characterized), the 388 | Corresponding Source conveyed under this section must be accompanied 389 | by the Installation Information. But this requirement does not apply 390 | if neither you nor any third party retains the ability to install 391 | modified object code on the User Product (for example, the work has 392 | been installed in ROM). 393 | 394 | The requirement to provide Installation Information does not include a 395 | requirement to continue to provide support service, warranty, or updates 396 | for a work that has been modified or installed by the recipient, or for 397 | the User Product in which it has been modified or installed. Access to a 398 | network may be denied when the modification itself materially and 399 | adversely affects the operation of the network or violates the rules and 400 | protocols for communication across the network. 401 | 402 | Corresponding Source conveyed, and Installation Information provided, 403 | in accord with this section must be in a format that is publicly 404 | documented (and with an implementation available to the public in 405 | source code form), and must require no special password or key for 406 | unpacking, reading or copying. 407 | 408 | 7. Additional Terms. 409 | 410 | "Additional permissions" are terms that supplement the terms of this 411 | License by making exceptions from one or more of its conditions. 412 | Additional permissions that are applicable to the entire Program shall 413 | be treated as though they were included in this License, to the extent 414 | that they are valid under applicable law. If additional permissions 415 | apply only to part of the Program, that part may be used separately 416 | under those permissions, but the entire Program remains governed by 417 | this License without regard to the additional permissions. 418 | 419 | When you convey a copy of a covered work, you may at your option 420 | remove any additional permissions from that copy, or from any part of 421 | it. (Additional permissions may be written to require their own 422 | removal in certain cases when you modify the work.) You may place 423 | additional permissions on material, added by you to a covered work, 424 | for which you have or can give appropriate copyright permission. 425 | 426 | Notwithstanding any other provision of this License, for material you 427 | add to a covered work, you may (if authorized by the copyright holders of 428 | that material) supplement the terms of this License with terms: 429 | 430 | a) Disclaiming warranty or limiting liability differently from the 431 | terms of sections 15 and 16 of this License; or 432 | 433 | b) Requiring preservation of specified reasonable legal notices or 434 | author attributions in that material or in the Appropriate Legal 435 | Notices displayed by works containing it; or 436 | 437 | c) Prohibiting misrepresentation of the origin of that material, or 438 | requiring that modified versions of such material be marked in 439 | reasonable ways as different from the original version; or 440 | 441 | d) Limiting the use for publicity purposes of names of licensors or 442 | authors of the material; or 443 | 444 | e) Declining to grant rights under trademark law for use of some 445 | trade names, trademarks, or service marks; or 446 | 447 | f) Requiring indemnification of licensors and authors of that 448 | material by anyone who conveys the material (or modified versions of 449 | it) with contractual assumptions of liability to the recipient, for 450 | any liability that these contractual assumptions directly impose on 451 | those licensors and authors. 452 | 453 | All other non-permissive additional terms are considered "further 454 | restrictions" within the meaning of section 10. If the Program as you 455 | received it, or any part of it, contains a notice stating that it is 456 | governed by this License along with a term that is a further 457 | restriction, you may remove that term. If a license document contains 458 | a further restriction but permits relicensing or conveying under this 459 | License, you may add to a covered work material governed by the terms 460 | of that license document, provided that the further restriction does 461 | not survive such relicensing or conveying. 462 | 463 | If you add terms to a covered work in accord with this section, you 464 | must place, in the relevant source files, a statement of the 465 | additional terms that apply to those files, or a notice indicating 466 | where to find the applicable terms. 467 | 468 | Additional terms, permissive or non-permissive, may be stated in the 469 | form of a separately written license, or stated as exceptions; 470 | the above requirements apply either way. 471 | 472 | 8. Termination. 473 | 474 | You may not propagate or modify a covered work except as expressly 475 | provided under this License. Any attempt otherwise to propagate or 476 | modify it is void, and will automatically terminate your rights under 477 | this License (including any patent licenses granted under the third 478 | paragraph of section 11). 479 | 480 | However, if you cease all violation of this License, then your 481 | license from a particular copyright holder is reinstated (a) 482 | provisionally, unless and until the copyright holder explicitly and 483 | finally terminates your license, and (b) permanently, if the copyright 484 | holder fails to notify you of the violation by some reasonable means 485 | prior to 60 days after the cessation. 486 | 487 | Moreover, your license from a particular copyright holder is 488 | reinstated permanently if the copyright holder notifies you of the 489 | violation by some reasonable means, this is the first time you have 490 | received notice of violation of this License (for any work) from that 491 | copyright holder, and you cure the violation prior to 30 days after 492 | your receipt of the notice. 493 | 494 | Termination of your rights under this section does not terminate the 495 | licenses of parties who have received copies or rights from you under 496 | this License. If your rights have been terminated and not permanently 497 | reinstated, you do not qualify to receive new licenses for the same 498 | material under section 10. 499 | 500 | 9. Acceptance Not Required for Having Copies. 501 | 502 | You are not required to accept this License in order to receive or 503 | run a copy of the Program. Ancillary propagation of a covered work 504 | occurring solely as a consequence of using peer-to-peer transmission 505 | to receive a copy likewise does not require acceptance. However, 506 | nothing other than this License grants you permission to propagate or 507 | modify any covered work. These actions infringe copyright if you do 508 | not accept this License. Therefore, by modifying or propagating a 509 | covered work, you indicate your acceptance of this License to do so. 510 | 511 | 10. Automatic Licensing of Downstream Recipients. 512 | 513 | Each time you convey a covered work, the recipient automatically 514 | receives a license from the original licensors, to run, modify and 515 | propagate that work, subject to this License. You are not responsible 516 | for enforcing compliance by third parties with this License. 517 | 518 | An "entity transaction" is a transaction transferring control of an 519 | organization, or substantially all assets of one, or subdividing an 520 | organization, or merging organizations. If propagation of a covered 521 | work results from an entity transaction, each party to that 522 | transaction who receives a copy of the work also receives whatever 523 | licenses to the work the party's predecessor in interest had or could 524 | give under the previous paragraph, plus a right to possession of the 525 | Corresponding Source of the work from the predecessor in interest, if 526 | the predecessor has it or can get it with reasonable efforts. 527 | 528 | You may not impose any further restrictions on the exercise of the 529 | rights granted or affirmed under this License. For example, you may 530 | not impose a license fee, royalty, or other charge for exercise of 531 | rights granted under this License, and you may not initiate litigation 532 | (including a cross-claim or counterclaim in a lawsuit) alleging that 533 | any patent claim is infringed by making, using, selling, offering for 534 | sale, or importing the Program or any portion of it. 535 | 536 | 11. Patents. 537 | 538 | A "contributor" is a copyright holder who authorizes use under this 539 | License of the Program or a work on which the Program is based. The 540 | work thus licensed is called the contributor's "contributor version". 541 | 542 | A contributor's "essential patent claims" are all patent claims 543 | owned or controlled by the contributor, whether already acquired or 544 | hereafter acquired, that would be infringed by some manner, permitted 545 | by this License, of making, using, or selling its contributor version, 546 | but do not include claims that would be infringed only as a 547 | consequence of further modification of the contributor version. For 548 | purposes of this definition, "control" includes the right to grant 549 | patent sublicenses in a manner consistent with the requirements of 550 | this License. 551 | 552 | Each contributor grants you a non-exclusive, worldwide, royalty-free 553 | patent license under the contributor's essential patent claims, to 554 | make, use, sell, offer for sale, import and otherwise run, modify and 555 | propagate the contents of its contributor version. 556 | 557 | In the following three paragraphs, a "patent license" is any express 558 | agreement or commitment, however denominated, not to enforce a patent 559 | (such as an express permission to practice a patent or covenant not to 560 | sue for patent infringement). To "grant" such a patent license to a 561 | party means to make such an agreement or commitment not to enforce a 562 | patent against the party. 563 | 564 | If you convey a covered work, knowingly relying on a patent license, 565 | and the Corresponding Source of the work is not available for anyone 566 | to copy, free of charge and under the terms of this License, through a 567 | publicly available network server or other readily accessible means, 568 | then you must either (1) cause the Corresponding Source to be so 569 | available, or (2) arrange to deprive yourself of the benefit of the 570 | patent license for this particular work, or (3) arrange, in a manner 571 | consistent with the requirements of this License, to extend the patent 572 | license to downstream recipients. "Knowingly relying" means you have 573 | actual knowledge that, but for the patent license, your conveying the 574 | covered work in a country, or your recipient's use of the covered work 575 | in a country, would infringe one or more identifiable patents in that 576 | country that you have reason to believe are valid. 577 | 578 | If, pursuant to or in connection with a single transaction or 579 | arrangement, you convey, or propagate by procuring conveyance of, a 580 | covered work, and grant a patent license to some of the parties 581 | receiving the covered work authorizing them to use, propagate, modify 582 | or convey a specific copy of the covered work, then the patent license 583 | you grant is automatically extended to all recipients of the covered 584 | work and works based on it. 585 | 586 | A patent license is "discriminatory" if it does not include within 587 | the scope of its coverage, prohibits the exercise of, or is 588 | conditioned on the non-exercise of one or more of the rights that are 589 | specifically granted under this License. You may not convey a covered 590 | work if you are a party to an arrangement with a third party that is 591 | in the business of distributing software, under which you make payment 592 | to the third party based on the extent of your activity of conveying 593 | the work, and under which the third party grants, to any of the 594 | parties who would receive the covered work from you, a discriminatory 595 | patent license (a) in connection with copies of the covered work 596 | conveyed by you (or copies made from those copies), or (b) primarily 597 | for and in connection with specific products or compilations that 598 | contain the covered work, unless you entered into that arrangement, 599 | or that patent license was granted, prior to 28 March 2007. 600 | 601 | Nothing in this License shall be construed as excluding or limiting 602 | any implied license or other defenses to infringement that may 603 | otherwise be available to you under applicable patent law. 604 | 605 | 12. No Surrender of Others' Freedom. 606 | 607 | If conditions are imposed on you (whether by court order, agreement or 608 | otherwise) that contradict the conditions of this License, they do not 609 | excuse you from the conditions of this License. If you cannot convey a 610 | covered work so as to satisfy simultaneously your obligations under this 611 | License and any other pertinent obligations, then as a consequence you may 612 | not convey it at all. For example, if you agree to terms that obligate you 613 | to collect a royalty for further conveying from those to whom you convey 614 | the Program, the only way you could satisfy both those terms and this 615 | License would be to refrain entirely from conveying the Program. 616 | 617 | 13. Remote Network Interaction; Use with the GNU General Public License. 618 | 619 | Notwithstanding any other provision of this License, if you modify the 620 | Program, your modified version must prominently offer all users 621 | interacting with it remotely through a computer network (if your version 622 | supports such interaction) an opportunity to receive the Corresponding 623 | Source of your version by providing access to the Corresponding Source 624 | from a network server at no charge, through some standard or customary 625 | means of facilitating copying of software. This Corresponding Source 626 | shall include the Corresponding Source for any work covered by version 3 627 | of the GNU General Public License that is incorporated pursuant to the 628 | following paragraph. 629 | 630 | Notwithstanding any other provision of this License, you have 631 | permission to link or combine any covered work with a work licensed 632 | under version 3 of the GNU General Public License into a single 633 | combined work, and to convey the resulting work. The terms of this 634 | License will continue to apply to the part which is the covered work, 635 | but the work with which it is combined will remain governed by version 636 | 3 of the GNU General Public License. 637 | 638 | 14. Revised Versions of this License. 639 | 640 | The Free Software Foundation may publish revised and/or new versions of 641 | the GNU Affero General Public License from time to time. Such new versions 642 | will be similar in spirit to the present version, but may differ in detail to 643 | address new problems or concerns. 644 | 645 | Each version is given a distinguishing version number. If the 646 | Program specifies that a certain numbered version of the GNU Affero General 647 | Public License "or any later version" applies to it, you have the 648 | option of following the terms and conditions either of that numbered 649 | version or of any later version published by the Free Software 650 | Foundation. If the Program does not specify a version number of the 651 | GNU Affero General Public License, you may choose any version ever published 652 | by the Free Software Foundation. 653 | 654 | If the Program specifies that a proxy can decide which future 655 | versions of the GNU Affero General Public License can be used, that proxy's 656 | public statement of acceptance of a version permanently authorizes you 657 | to choose that version for the Program. 658 | 659 | Later license versions may give you additional or different 660 | permissions. However, no additional obligations are imposed on any 661 | author or copyright holder as a result of your choosing to follow a 662 | later version. 663 | 664 | 15. Disclaimer of Warranty. 665 | 666 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 667 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 668 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 669 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 670 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 671 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 672 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 673 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 674 | 675 | 16. Limitation of Liability. 676 | 677 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 678 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 679 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 680 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 681 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 682 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 683 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 684 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 685 | SUCH DAMAGES. 686 | 687 | 17. Interpretation of Sections 15 and 16. 688 | 689 | If the disclaimer of warranty and limitation of liability provided 690 | above cannot be given local legal effect according to their terms, 691 | reviewing courts shall apply local law that most closely approximates 692 | an absolute waiver of all civil liability in connection with the 693 | Program, unless a warranty or assumption of liability accompanies a 694 | copy of the Program in return for a fee. 695 | 696 | END OF TERMS AND CONDITIONS 697 | 698 | How to Apply These Terms to Your New Programs 699 | 700 | If you develop a new program, and you want it to be of the greatest 701 | possible use to the public, the best way to achieve this is to make it 702 | free software which everyone can redistribute and change under these terms. 703 | 704 | To do so, attach the following notices to the program. It is safest 705 | to attach them to the start of each source file to most effectively 706 | state the exclusion of warranty; and each file should have at least 707 | the "copyright" line and a pointer to where the full notice is found. 708 | 709 | 710 | Copyright (C) 711 | 712 | This program is free software: you can redistribute it and/or modify 713 | it under the terms of the GNU Affero General Public License as published 714 | by the Free Software Foundation, either version 3 of the License, or 715 | (at your option) any later version. 716 | 717 | This program is distributed in the hope that it will be useful, 718 | but WITHOUT ANY WARRANTY; without even the implied warranty of 719 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 720 | GNU Affero General Public License for more details. 721 | 722 | You should have received a copy of the GNU Affero General Public License 723 | along with this program. If not, see . 724 | 725 | Also add information on how to contact you by electronic and paper mail. 726 | 727 | If your software can interact with users remotely through a computer 728 | network, you should also make sure that it provides a way for users to 729 | get its source. For example, if your program is a web application, its 730 | interface could display a "Source" link that leads users to an archive 731 | of the code. There are many ways you could offer source, and different 732 | solutions will be better for different programs; see section 13 for the 733 | specific requirements. 734 | 735 | You should also get your employer (if you work as a programmer) or school, 736 | if any, to sign a "copyright disclaimer" for the program, if necessary. 737 | For more information on this, and how to apply and follow the GNU AGPL, see 738 | . 739 | 740 | ``` 741 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | version 5 |    6 | 7 | plain vanilla JS 8 |    9 | 10 | license 11 |    12 |

13 |

14 | 15 | last commit 16 |    17 | 18 | downloads 19 |    20 | 21 | twitter 22 |    23 |

24 | 25 | 26 | # 𝜟𝜱✴︎ _(delta phi star) DPS Contrast_ 27 | $𝜟𝜱✴︎$ or Delta Phi Star or DPS Contrast, is a method of determining perceptual lightness contrast developed by Andrew Somers (Myndex Research), and is a sibling of [APCA](https://github.com/Myndex/SAPC-APCA) and SAPC/SACAM. It is a simplified method using easily invertible standardized maths, however it lacks some useful properties such as polarity sensitivity. 28 | 29 | But In fact, $𝜟𝜱✴︎$ is intended for applications where a "general" simplifed perceptual contrast is desired, where polarity sensitivity is not needed or is more ambiguous. Nevertheless, polarity sensitivity can be emulated by adding $Lc\ 5$ to negative polarity situations. 30 | 31 | 𝜟𝜱✴︎ DPS Contrast was created on the path toward SACAM and APCA. 32 | 33 | **TUTORIAL:** create Lstar from the piecewise $sRGB$ → $Y$ and $L^*$ per the standard CIE math (see the [See Stars](https://github.com/Myndex/seestars) microlibrary), then: 34 | 35 | ```js 36 | deltaPhiStar = (Math.abs(bgLstar ** 1.618 - txLstar ** 1.618) ** 0.618) * 1.414 - 40 ; 37 | 38 | // ** is equiv to Math.pow 39 | ``` 40 | 41 | This mainly works for "Light Mode" but does not track dark mode as well as APCA. 42 | 43 | Also, while this is close to parity with light mode APCA for $Lc\ +45$ thru $Lc\ +75$. The very low and very high contrasts reported by 𝜟𝜱✴︎ higher than those reported by APCA. 44 | 45 | As the difference has a power curve exponent of $1/𝜱$ applied, the difference must be an absolute value. $𝜟𝜱✴︎$ returns a positive value always, and is symmetrical in regards to polarity (text and BG order do not affect results). 46 | 47 | 48 | 49 | 50 | ## DELTA PHI STAR CONTRAST FAQ 51 | ***DPS Contrast***, also known as ***Delta Phi Star 𝜟𝜱✴︎***, is a simple formula for predicting human visual perception of contrast between text and background on computer monitors and devices. 52 | 53 | - **WHO WHAT WHERE WHEN WHY HOW** 54 | - Delta Phi Star was developed by Andrew Somers, in the pursuit of better (and simpler) readability guidelines. 55 | - Delta Phi Star is a formula that predicts the contrast of text against the background for a given pair of colors. 56 | - Delta Phi Star emerged from the SAPC/APCA project developing new standards for better beat ability on the web. 57 | - To provide a simple, yet usefully accurate and perceptually uniform contrast metric. 58 | - Convert a color pair to D65 CIELAB, then send the $L^*$ (Lstar) values to DPS, and it returns an $L^c$ (lightness contrast) value. 59 | 60 | --- 61 | - **BASIC READABILITY GUIDELINES:** 62 | - Delta Phi Star Readability Guidelines are set as simple thresholds similar to WCAG 2.x 63 | - Linear interpolation is permitted intra-level. 64 | - These values are based on reference fonts such as Helvetica or Arial. 65 | - To use a 300 weight font, add $L^c\ 10$ to the contrast threshold needed for normal weight. 66 | - CSS `font-smoothing: antialiased` is prohibited for 300 weight fonts smaller than 36px and for 400 fonts which are smaller than 24px. 67 | - `font-smoothing: auto` should be used for small and thin fonts. 68 | 69 | - **_FOR PRIMARY CONTENT TEXT_** 70 | - $L^c\ 75$ permits a minimum font size of: 71 | - 16px normal or 12px bold 72 | - $L^c\ 60$ permits a minimum font size of: 73 | - 24px normal or 16px bold 74 | - $L^c\ 45$ permits a minimum font size of: 75 | - 42px normal or 24px bold 76 | - **_FOR SECONDARY CONTENT, "SPOT" READABLE TEXT_** 77 | - _subtract_ $L^c\ 15$ from the above values. 78 | - at $L^c\ 90$ (which calculates as $L^c\ 75$ _after_ subtracting $L^c\ 15$) 79 | - minimum font size is 11px for secondary content only. 80 | - secondary content includes things like "copyright" or "placeholder text" or other textual elements that are not directly related to the primary contact of the page or primary navigation. 81 | 82 | - **_FOR SEMANTIC NON-TEXT (icons and pictograms)_** 83 | - $L^c\ 60$ for thin outline icons or thin line drawings 84 | - $L^c\ 45$ for solid icons or bolder line drawings 85 | - **_FOR NON-SEMANTIC NON-TEXT (chart elements or button shapes)_** 86 | - $L^c\ 45$ for button outlines, thin chart lines, small pie pieces 87 | - $L^c\ 30$ for solid buttons, bar charts, large pie pieces 88 | 89 | 90 | - **VISUAL COMPARISON** 91 | While there isn't a tool up and running here, at [LeaVerou](https://github.com/LeaVerou)'s [color.js](https://github.com/LeaVerou/color.js) demo site, DeltaPhiStar's part of the demo for when to flip from black to white. In this demo you can compare a number of different contrast algorithms, including WCAG2, APCA, DeltaPhiStar, and others. 92 | 93 | [**_Black or White?_**](https://colorjs.io/apps/blackwhite/) at color.js 94 | 95 | Here's a screenshot of that demo comparing DeltaPhiStar to APCA, the boxes with a dashed border around them indicate where DeltaPhiStar is different than APCA, with DPS showing black text instead of white. 96 | 97 | This is largely attributable to the the following: 98 | - The difference in how sRGB colors are processed between APCA & DeltaPhiStar 99 | - DeltaPhiStar using the IEC _piecewise_ linearization and CIE conversion to $L^*$. 100 | - APCA uses an optimized conversion that compensates for gamma gain. 101 | - APCA is polarity sensitive, DeltaPhiStar is not. 102 | - as a result, near the flip point for black and white, DeltaPhiStar is slightly under reporting the actual contrast of negative polarity (White text). 103 | 104 | _click to enlarge_ 105 | Colors.js sample black and white flip test comparing APCA and delta phi star 106 | 107 | As you can see, DeltaPhiStar is not as accurate around the Extreme flip point, but otherwise in relatively decent agreement, and probably well suited for a simplified guideline. 108 | 109 | 110 | --- 111 | - **UNIFORMITY:** 112 | - DPS Contrast is quasi-uniform for human perception of text against a background on a self-illuminated display 113 | - reasonably accurate within a defined range $L^c 45$ to $L^c 75$ and for positive polarity (dark text on a light background) 114 | - The perception curve is based on the output of SACMX-based mixed-mode high-spatial-frequency contrast matching data, using 115 | - hardware-calibrated standard-dynamic-range (SDR) sRGB displays 116 | - a typical office lighting environment with a nominal ambient illumination of 350 lux. 117 | - proximal screen set at or close to white. 118 | 119 | - **DEPENDENCIES:** 120 | - DPS Contrast itself is a *single line of code*, but it's inputs require that a color has been reduced to a $CIE\ L^*$ value. 121 | - therefore, DPS contrast has a dependency for a library that can parse an sRGB color and convert it to D65 CIELAB. 122 | - depending on the application, it may be useful to add logic to determine the polarity of the text and background, and for negative polarity to add $5$ to the LC value (or alternately, offset $-35$ instead of $-40$ at the return). 123 | 124 | - **LIMITATIONS:** 125 | - DPS Contrast becomes substantially less accurate at very high and very low contrasts 126 | - $L^c$ values lower than $L^c 45$ or higher than $L^c 75$ are generally higher than actual perception 127 | - as such $L^c$ values lower than $L^c 45$ or higher than $L^c 75$ should be derated 128 | - otherwise, the range between 45 to 75 is the area of the thresholds most important for text, Arguably this is the only thing that's really necessary for use in defined guidelines such as those needed for WCAG. 129 | - DPS Contrast is not polarity aware 130 | - and $L^c$ values for reverse polarity aka "dark mode" are generally lower 131 | - in dark mode, actual contrast is higher than the reported $L^c$ values between $L^c 40$ & $L^c 70$ 132 | - to approximate the polarity difference, add **$5$** to the $L^c$ value for dark mode results between $L^c 40$ & $L^c 70$ 133 | 134 | - **INITALISMS and ACRONYMS:** 135 | - APCA™: Accessible Perceptual Contrast Algorithm™ *(aye pea see aye)* 136 | - sometimes referred to as the Advanced Perceptual Contrast Algorithm 137 | - is a perceptual uniform model of text on a self-illuminated display 138 | - APCA-W3: APCA World Wide Web version 139 | - specific APCA version intended for WCAG guidelines 140 | - includes a version of APCA-RDG accessibility guidelines for visual readability 141 | - APCA-RDG: APCA Readability Design Guidelines 142 | - an independent set of design guidelines to promote effective readability and accessibility for visually readable content 143 | - DPS-C: Delta Phi Star™ Contrast *(dee pea ess)* 144 | - simplified quasi-uniform perceptual contrast model 145 | - SACAM™: SLuv Accessible Color Appearance Model™ *(say cam)* 146 | - color appearance model that is designed specifically for self-illuminated displays 147 | - features utilities to accommodate various visual impairments 148 | - SAPC™: SLuv Accessible Perceptual Contrast™ *(sap see)* 149 | - an earlier contrast appearance model that laid the foundation for APCA and SACAM 150 | - SACMX: Spatially Aware Contrast Matching eXperiment 151 | - a method of measuring the perceived suprathreshold contrast at high spatial frequencies 152 | 153 | - **COPYRIGHT and TRADEMARKS:** 154 | - this repo and all materials contained here in, are copyright © 2022 by Andrew Somers. All Rights Reserved. Use permitted as defined in this license agreement. 155 | - Nothing in the license agreement extends to nor permits the use of any trademarks shown anywhere in this repo, unless specifically stated. 156 | - The term "Delta Phi Star™" may be used to describe instantiations, integrations, applications, libraries, or frameworks which are using the materials in this repo, provided that such usage is unaltered except as may be needed to port to different languages. 157 | 158 | - **PHI BONUS** 159 | ```math 160 | \begin{align} \phi = 5^{0.5} \times 0.5 + 0.5 \end{align} 161 | ``` 162 | 163 | -------------------------------------------------------------------------------- /node_modules/.cache/ava/failing-tests.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "deltaphistar", 3 | "version": "0.0.1", 4 | "type": "module", 5 | "description": "Delta Phi Star is a general purpose method of determining perceptual lightness contrast developed by Andrew Somers (Myndex Research), and is a sibling of APCA and SACAM. It is a simplified method using easily invertible standardized maths, however it lacks some useful APCA properties such as polarity sensitivity.", 6 | "main": "./src/deltaphistar.js", 7 | "keywords": [ 8 | "CSS", 9 | "HTML", 10 | "PDF", 11 | "RTF", 12 | "sRGB", 13 | "RGB", 14 | "P3", 15 | "displayP3", 16 | "Adobe RGB", 17 | "LCh", 18 | "Lstar", 19 | "color", 20 | "colour", 21 | "contrast", 22 | "lightness", 23 | "brightness", 24 | "luminance", 25 | "luminance contrast", 26 | "lightness contrast", 27 | "perceptual contrast", 28 | "visual contrast", 29 | "color contrast", 30 | "colour contrast", 31 | "text contrast", 32 | "APCA contrast", 33 | "A11y contrast", 34 | "constant contrast", 35 | "accessible contrast", 36 | "readability contrast", 37 | "readability", 38 | "accessibility", 39 | "contrast sensitivity", 40 | "spatial frequency", 41 | "spacial frequency", 42 | "design tools", 43 | "design systems", 44 | "design guidelines", 45 | "typography", 46 | "a11y", 47 | "W3C", 48 | "WCAG", 49 | "WCAG 2", 50 | "WCAG 3", 51 | "SACAM", 52 | "SAPC", 53 | "APCA" 54 | ], 55 | "author": "Andrew Somers", 56 | "license": "AGPL v3", 57 | "bugs": { 58 | "url": "https://github.com/Myndex/deltaphistar/issues" 59 | }, 60 | "forum": { 61 | "url": "https://github.com/Myndex/deltaphistar/discussion" 62 | }, 63 | "repository": { 64 | "type": "git", 65 | "url": "https://github.com/Myndex/deltaphistar.git" 66 | }, 67 | "homepage": "https://git.myndex.com", 68 | "scripts": { 69 | "test": "ava test/index.js" 70 | }, 71 | "devDependencies": { 72 | "ava": "^4.3.0" 73 | }, 74 | "dependencies": { 75 | "colorparsley": "^0.1.8", 76 | "seestars": "^0.0.1" 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/deltaphistar.js: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | ///// 3 | ///// DELTA PHI STAR - General purpose perceptual contrast 4 | ///// Beta 0.0.1 5 | ///// Copyright © 2022 by Andrew Somers. All Rights Reserved. 6 | ///// LICENSE: AGPL 3 LICENSE 7 | ///// CONTACT: Please use the ISSUES or DISCUSSIONS tab at: 8 | ///// https://github.com/Myndex/deltaphistar/ 9 | ///// 10 | /////////////////////////////////////////////////////////////////////////////// 11 | ///// 12 | ///// MINIMAL IMPORTS: 13 | ///// import { seestars } from 'seestars'; 14 | ///// 15 | ///// 16 | //////////////////////////////////////////////////////////////////////////////// 17 | 18 | ////////// DELTA PHI STAR 0.0.1 USAGE ////////////////////////////////////// 19 | /// 20 | /// ________________________________________________________________________ 21 | /// 22 | /// ********** QUICK START ********** 23 | /// 24 | /// let contrast = contrastDPS(foreground, background) 25 | /// 26 | /// // foreground, background are any sRGB color string 27 | /// 28 | //////////////////////////////////////////////////////////////////////////////// 29 | 30 | 31 | //////////////////////////////////////////////////////////////////////////////// 32 | /////////////////////////////////////////////////////////////////////////////// 33 | ///// BEGIN DELTA PHI STAR 0.0.1 BLOCK \//////////////////////////////// 34 | //// \////////////////////////////// 35 | /// \//////////////////////////// 36 | // \////////////////////////// 37 | 38 | 39 | ///// DEPENDENCIES ///// 40 | 41 | // The following imports are not needed for the main APCA function, 42 | // but are needed for the shortcut/alias calcAPCA(), and for the 43 | // future invertAPCA function, which examines hue. 44 | 45 | 46 | //// (add slash to line start for local test mode, remove before push) 47 | /* //// LOCAL TESTING SWITCH for using test.html 48 | // import { colorParsley } from'../../colorparsley/src/colorparsley.js'; 49 | import { seeStars } from'../../seestars/src/seestars.js'; 50 | /*/ //// TOGGLE 51 | // import { colorParsley } from 'colorparsley'; 52 | import { seeStars } from "seestars"; 53 | // */ //// END LOCAL TESTING SWITCH 54 | 55 | const phi = Math.pow(5, 0.5) * 0.5 + 0.5; // Math.phi can be used if Math.js 56 | 57 | export function contrastDPS (foreground, background) { 58 | // send it a text and a bg color string, returns a value 0-100 59 | let txLstar = seeStars(foreground); 60 | let bgLstar = seeStars(background); 61 | 62 | let contrast = Math.pow( Math.abs(Math.pow(bgLstar, phi) - 63 | Math.pow(txLstar,phi)), (1 / phi) ) * Math.SQRT2 - 40; 64 | 65 | return (contrast < 7.5) ? 0.0 : contrast ; 66 | 67 | } 68 | 69 | // (Math.pow(bgLstar,1.618) - Math.pow(txLstar,1.618))**0.618 // 70 | -------------------------------------------------------------------------------- /src/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 𝜟𝜱✴︎delta phi star TEST 4 | 5 | 6 |

𝜟𝜱✴︎delta phi star Script Test 0.0.1

7 | 8 |

Usage:

9 |
10 | 𝜟𝜱✴ = contrastDPS(color1, color2); 11 |
12 |
13 | 14 |
15 |
Enable Javascript
16 | 17 | 18 |

TESTING YOUR IMPLEMENTATION

19 | 20 |

If you've implemented the code and want a quick sanity check, Here are some keystone checks with no rounding. The first color is TEXT and the second color is BACKGROUND: 21 | 22 |

Test Values for 0.0.1 constants. 23 | 24 |

TEXT vs BKGND • EXPECTED RESULT for 0.0.1

25 |

 26 |     #000 & #9e9e9e 	 ∆Φ✴: 52.042324818974436
 27 |     #9e9e9e & #FFF 	 ∆Φ✴: 52.15817941439123
 28 |     #FFF & #888 	 ∆Φ✴: 63.155229570915864
 29 |     #888 & #000 	 ∆Φ✴: 40.15402173709839
 30 |     #000 & #aaa 	 ∆Φ✴: 58.397040139078555
 31 |     #aaa & #234 	 ∆Φ✴: 49.71988060967246
 32 |     #234 & #def 	 ∆Φ✴: 84.77424837874361
 33 |     #def & #123 	 ∆Φ✴: 88.70761679910729
 34 |     #123 & #444 	 ∆Φ✴: 0.0
 35 |     #444 & #777 	 ∆Φ✴: 11.029421871598664
 36 |     #777 & #a4a4a4 	 ∆Φ✴: 12.543444585172274
 37 |     #a4a4a4 & #fff 	 ∆Φ✴: 48.902933046054386
 38 |     #fff & #000 	 ∆Φ✴: 101.35051965850337
 39 |     #000 & #595959 	 ∆Φ✴: 13.468722550811329
 40 | 
 41 | Some APCA Lc  values for comparison:
 42 | 
 43 |     #888 vs #fff  APCA Lc 63.056469930209424
 44 |                      ∆Φ✴: 63.155229570915864
 45 | 
 46 |     #000 vs #aaa  APCA Lc 58.146262578561334
 47 |                      ∆Φ✴: 58.397040139078555
 48 |                      
 49 |     #123 vs #def  APCA Lc 91.66830811481631
 50 |                      ∆Φ✴: 88.70761679910729
 51 |                      
 52 |     #123 vs #444  APCA Lc  8.32326136957393
 53 |                      ∆Φ✴:  0.0
 54 |     
55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /test/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Myndex/deltaphistar/4b5fb4a5726937ce182e59e42756b65c141b2e96/test/.DS_Store -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | // Delta Phi Star Test Script for 0.0.1 2 | 3 | import test from 'ava'; 4 | 5 | import { contrastDPS } from '../src/deltaphistar.js'; 6 | 7 | console.log('BEGIN TESTS') 8 | 9 | test.todo("Testing Delta Phi Star calculations\n") 10 | 11 | let color = ['#000', '#9e9e9e', '#FFF', '#888','#000', '#aaa', '#234', '#def', '#123', '#444', '#777', '#a4a4a4','#fff', '#000', '#595959']; 12 | 13 | let colorLength = color.length - 1; 14 | 15 | let contrastResult = [ 52.042324818974436, 52.15817941439123, 63.155229570915864, 40.15402173709839, 58.397040139078555, 49.71988060967246, 84.77424837874364, 88.70761679910729, 0.0, 11.029421871598664, 12.543444585172253, 48.9029330460544, 101.35051965850337, 13.468722550811329, ]; 16 | 17 | 18 | for (let eye = 1, eyePlus; eye < colorLength; eye++) { 19 | 20 | eyePlus = eye + 1; 21 | test('Lc value for ' + color[eye] + ' and ' + color[eyePlus], (t) => { 22 | t.deepEqual(contrastResult[eye], contrastDPS(color[eye],color[eyePlus])); 23 | }); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /versionHistory.md: -------------------------------------------------------------------------------- 1 | # 𝜟𝜱✴︎ _(delta phi star)_ 2 | ```javascript 3 | let phiStarContrast = contrastDPS('colorString','colorString') ` 4 | ``` 5 | ## _Version History_ 6 | 7 | ### Current Version: **0.0.1** 8 | 9 | 0.0.1 - (Aug 9 2022) 10 | 11 | - Initial Beta Release 12 | 13 | 14 | --------------------------------------------------------------------------------