Libraryless. Click here for Pure Java version (17746L/133K).
!7 concept ColorName { S color, name, comment; } module ColorNames > DynCRUD<ColorName> { *() { super(ColorName); } start { onConceptsChangeAndNow(r { setModuleName("Names Of Colors (" + countConcepts(ColorName) + ")") }); } // API void addColorName(Color color, S name, S comment) { uniq_sync(ColorName, color := colorToHex(color), +name, +comment); } S getClosestColorName(Color color) { ret pairA(getClosestColor(color)); } Pair<S, Double> getClosestColor(Color color) { new Lowest<S> best; for (ColorName cn) best.put(cn.name, colorDiff(color, colorFromHex(cn.color))); ret pair(best!, best.score()); } }
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1020194 |
Snippet name: | Names Of Colors |
Eternal ID of this version: | #1020194/9 |
Text MD5: | daaa9385bd0f78cf024370d9a661e3d4 |
Transpilation MD5: | ac981d1f83cf012c344cfe7f74adc891 |
Author: | stefan |
Category: | javax / stefan's os / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-12-13 17:34:42 |
Source code size: | 706 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 313 / 1701 |
Version history: | 8 change(s) |
Referenced in: | [show references] |