Advertisement
Guest User

Untitled

a guest
May 26th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. const artist = 'M1248 761h-48v72h-48v-72h-48v83h-48v113h-48V784h-48v82h-48v24h-48v-18h-48V767h-48v77h-48v-48h-48v85h-48v-65h-48v17h-48v-72h-48v83h-48v113h-48V784h-48v82h-48v24h-48v-18h-48v-56h-48v28H96v-48H48v85H0V85h48V0h48v48h48v84h48v-22h48V87h48V62h48v21h48v35h48V48h48v110h48v-32h48v20h48V85h48V0h48v48h48v84h48v-22h48V87h48V62h48v21h48v35h48V48h48v110h48v-32h48v32h48V87h48v71h48v603h-48v129h-48V761z';
  2. const product = 'M48 796V0h48v796H48zm96 20V132h48v684h-48zm96 74V87h48v803h-48zm96-106V83h48v701h-48zm96 60V48h48v796h-48zm96-11V126h48v707h-48zm96 48V85h48v796h-48zm96-37V48h48v796h-48zm96 28V110h48v762h-48zm96-6V62h48v804h-48zm96 91V118h48v839h-48zm96-196V158h48v603h-48zm96 23V83h48v701h-48zm96 60V48h48v796h-48z';
  3. const productMobile = 'M0 425V41.56h28.52V425H0zm57.04-50.61V39.64h28.52v334.75H57.04zm57.03 28.65V22.92h28.52v380.12h-28.52zm57.04-5.25V60.17h28.52v337.62h-28.52zm57.04 22.92V40.59h28.52v380.12h-28.52zm57.04-17.67V22.92h28.51v380.12H285.2zm57.03 13.37V52.53h28.52V416.4h-28.52zm57.04-2.87V29.61h28.52v383.93h-28.52z';
  4. const artistMobile = 'M428.44 39.64H457v334.75h-28.56v39.15h-28.56v11.47H371.3v-8.6h-28.56v-50.14h-28.56v36.77h-28.56v-22.92h-28.57v40.59H228.5v-31.04h-28.56v8.12h-28.56V363.4H142.8v39.64h-28.56V457H85.69v-82.61H57.13v39.15H28.55v11.47H0V41.55h28.56V29.6h28.57v10.03h28.56v16.7h28.56V22.93h28.56v52.53h28.56V60.17h28.57v9.55h28.56V40.59h28.56V0h28.56v22.92h28.57v40.11h28.56v-10.5h28.56V41.55h28.56V29.6h28.57v10.03z';
  5.  
  6. function transformOne( data ) {
  7. const regexNewLine = /[a-zA-Z]/g;
  8. const regexSpace = /-/g;
  9. const regexDoubleSpace = /\s{2}(?=(-|\d))/g;
  10. const regexFix = /\d+/g;
  11.  
  12. const out = d
  13. .replace(regexNewLine, `\n$& `)
  14. .replace(regexSpace, ` $&`)
  15. .replace(regexDoubleSpace, ` `)
  16. .replace(regexFix, (match) => {
  17. return match / 1344;
  18. });
  19.  
  20. return out
  21. }
  22.  
  23. function transformTwo( data, width, height ) {
  24.  
  25. const regexNewLine = /[a-zA-Z]/g;
  26. const regexSpace = /-/g;
  27. const regexDoubleSpace = /\s{2}(?=(-|\d))/g;
  28.  
  29. const out = data
  30. .replace(regexNewLine, `\n$& `)
  31. .replace(regexSpace, ` $&`)
  32. .replace(regexDoubleSpace, ` `)
  33. .split(/\n/)
  34. .filter(Boolean)
  35. .map(action => action.trim())
  36. .map(action => action.split(' '))
  37. .map(action => {
  38. switch (action[0]){
  39. case 'M':
  40. case 'm':
  41. return [
  42. action[0],
  43. action[1] / width,
  44. action[2] / height,
  45. ]
  46. case 'V':
  47. case 'v':
  48. return [
  49. action[0],
  50. action[1] / height,
  51. ]
  52. case 'H':
  53. case 'h':
  54. return [
  55. action[0],
  56. action[1] / width,
  57. ]
  58. case 'Z':
  59. case 'z':
  60. return [
  61. action[0],
  62. ]
  63. default:
  64. return action;
  65. }
  66.  
  67. })
  68. .map(action => action.join(' '))
  69. .join(' ')
  70. ;
  71.  
  72. return out;
  73. }
  74.  
  75. console.log( transformTwo( productMobile, 457, 457 ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement