1
0

audiovisual_elements.py 1.8 KB

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