audiovisual_elements.py 2.5 KB

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