colors.ts 930 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { Color, HSL } from "three";
  2. const offset = {
  3. hover: {
  4. h: -0.012,
  5. s: 0,
  6. l: 0.07,
  7. },
  8. press: {
  9. h: 0.002,
  10. s: 0.104,
  11. l: 0.207,
  12. },
  13. disable: {
  14. h: -0.0189,
  15. s: 0,
  16. l: -0.15,
  17. },
  18. select: {
  19. h: -0.0189,
  20. s: 0,
  21. l: -0.15,
  22. },
  23. };
  24. type keys = keyof typeof offset | 'pub';
  25. export const getMouseColors = (color16: string) => {
  26. let theme = new Color(color16);
  27. // if (theme.r === theme.g && theme.g === theme.b && theme.g === 0) {
  28. // theme = new Color(themeColor)
  29. // }
  30. const themeHSL = theme.getHSL({} as HSL);
  31. const temp = new Color();
  32. const colors = Object.entries(offset).reduce((t, [k, o]) => {
  33. t[k as keys] = '#' + temp
  34. .setHSL(themeHSL.h + o.h, themeHSL.s + o.s, themeHSL.l + o.l)
  35. .getHexString();
  36. return t;
  37. }, {} as Record<keys, string>);
  38. colors.pub = color16
  39. return {
  40. theme: '#' + theme.getHexString(),
  41. ...colors
  42. };
  43. }