not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.5 KiB

  1. clearScreen ('black')
  2. center = { 'x': window.innerWidth / 2,
  3. 'y': window.innerHeight / 2 }
  4. class Mandala:
  5. def __init__(self, text, freq=1, dist=0, \
  6. font_size=32, color='black', \
  7. font='"Noto Mono", "Noto Emoji"', offset=0):
  8. self.text = text
  9. rad = 360/freq * (Math.PI/180)
  10. for i in range(freq):
  11. angle = i * rad - offset
  12. pos = { 'x': Math.cos(angle - Math.PI/2) * dist,
  13. 'y': Math.sin(angle - Math.PI/2) * dist }
  14. self.place(pos, angle, font_size, font, color)
  15. def place(self, pos, rad, font_size, font, color):
  16. el = document.createElement('span')
  17. el.innerHTML = self.text
  18. el.style['text-shadow'] = '0 0 10px white'
  19. el.style['color'] = color
  20. el.style['font-size'] = font_size + 'px'
  21. el.style['font-family'] = font
  22. el.style['position'] = 'absolute'
  23. el.style.transform = 'rotate(' + rad + 'rad)'
  24. document.body.appendChild(el)
  25. style = window.getComputedStyle(el)
  26. offset_x = int(style.width) / 2
  27. offset_y = int(style.height) / 2
  28. el.style.top = center.y + pos.y - offset_y + 'px'
  29. el.style.left = center.x + pos.x - offset_x + 'px'
  30. if __name__=='__main__':
  31. Mandala ('🌺', 20, 295, 90, 'pink')
  32. Mandala ('🍎', 22, 220, 60, 'red')
  33. Mandala ('🐜', 20, 160, 50, 'orange')
  34. Mandala ('🐌', 10, 110, 30, 'green')
  35. Mandala ('Azúcar', 6, 70, 18, 'yellow')
  36. Mandala ('Somos', 2, 20, 30, 'blue')