1
0

section_audiovisual_elements.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from nicegui import ui
  2. from . import (
  3. audio_documentation,
  4. avatar_documentation,
  5. doc,
  6. icon_documentation,
  7. image_documentation,
  8. interactive_image_documentation,
  9. video_documentation,
  10. )
  11. doc.title('*Audiovisual* Elements')
  12. doc.intro(image_documentation)
  13. @doc.demo('Captions and Overlays', '''
  14. By nesting elements inside a `ui.image` you can create augmentations.
  15. Use [Quasar classes](https://quasar.dev/vue-components/img) for positioning and styling captions.
  16. To overlay an SVG, make the `viewBox` exactly the size of the image and provide `100%` width/height to match the actual rendered size.
  17. ''')
  18. def captions_and_overlays_demo():
  19. with ui.image('https://picsum.photos/id/29/640/360'):
  20. ui.label('Nice!').classes('absolute-bottom text-subtitle2 text-center')
  21. with ui.image('https://cdn.stocksnap.io/img-thumbs/960w/airplane-sky_DYPWDEEILG.jpg'):
  22. ui.html('''
  23. <svg viewBox="0 0 960 638" width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
  24. <circle cx="445" cy="300" r="100" fill="none" stroke="red" stroke-width="10" />
  25. </svg>
  26. ''').classes('w-full bg-transparent')
  27. doc.intro(interactive_image_documentation)
  28. doc.intro(audio_documentation)
  29. doc.intro(video_documentation)
  30. doc.intro(icon_documentation)
  31. doc.intro(avatar_documentation)
  32. @doc.demo('SVG', '''
  33. You can add Scalable Vector Graphics using the `ui.html` element.
  34. ''')
  35. def svg_demo():
  36. content = '''
  37. <svg viewBox="0 0 200 200" width="100" height="100" xmlns="http://www.w3.org/2000/svg">
  38. <circle cx="100" cy="100" r="78" fill="#ffde34" stroke="black" stroke-width="3" />
  39. <circle cx="80" cy="85" r="8" />
  40. <circle cx="120" cy="85" r="8" />
  41. <path d="m60,120 C75,150 125,150 140,120" style="fill:none; stroke:black; stroke-width:8; stroke-linecap:round" />
  42. </svg>'''
  43. ui.html(content)