element_path.erl 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. -module(element_path).
  2. -author('Konstantin Zakablukovsky').
  3. -include("nitro.hrl").
  4. -compile(export_all).
  5. render_element(Record) ->
  6. wf_tags:emit_tag(<<"path">>, nitro:render(Record#path.body),
  7. lists:append([
  8. [
  9. {<<"id">>, Record#path.id},
  10. {<<"class">>, Record#path.class},
  11. {<<"style">>, Record#path.style},
  12. {<<"d">>, Record#path.d},
  13. {<<"pathLength">>, Record#path.pathLength},
  14. {<<"transform">>, Record#path.transform},
  15. {<<"externalResourcesRequired">>, Record#path.externalResourcesRequired}
  16. ],
  17. svg_conditional_processing(Record),
  18. svg_core(Record),
  19. svg_graphical_event(Record),
  20. svg_presentation(Record),
  21. Record#path.data_fields,
  22. Record#path.aria_states
  23. ])).
  24. %% Common SVG attributes
  25. svg_conditional_processing(Record)-> [
  26. {<<"requiredExtensions">>, Record#path.requiredExtensions},
  27. {<<"requiredFeatures">>, Record#path.requiredFeatures},
  28. {<<"systemLanguage">>, Record#path.systemLanguage}
  29. ].
  30. svg_core(Record)-> [
  31. {<<"xml:base">>, Record#path.xmlbase},
  32. {<<"xml:lang">>, Record#path.xmllang},
  33. {<<"xml:space">>, Record#path.xmlspace}
  34. ].
  35. svg_graphical_event(Record)-> [
  36. {<<"onactivate">>, Record#path.onactivate},
  37. {<<"onclick">>, Record#path.onclick},
  38. {<<"onfocusin">>, Record#path.onfocusin},
  39. {<<"onfocusout">>, Record#path.onfocusout},
  40. {<<"onload">>, Record#path.onload_graphical},
  41. {<<"onmousedown">>, Record#path.onmousedown},
  42. {<<"onmousemove">>, Record#path.onmousemove},
  43. {<<"onmouseout">>, Record#path.onmouseout},
  44. {<<"onmouseover">>, Record#path.onmouseover},
  45. {<<"onmouseup">>, Record#path.onmouseup}
  46. ].
  47. svg_presentation(Record)-> [
  48. {<<"alignment-baseline">>, Record#path.alignment_baseline},
  49. {<<"baseline-shift">>, Record#path.baseline_shift},
  50. {<<"clip">>, Record#path.clip},
  51. {<<"clip-path">>, Record#path.clip_path},
  52. {<<"clip-rule">>, Record#path.clip_rule},
  53. {<<"color">>, Record#path.color},
  54. {<<"color-interpolation">>, Record#path.color_interpolation},
  55. {<<"color-interpolation-filters">>, Record#path.color_interpolation_filters},
  56. {<<"color-profile">>, Record#path.color_profile},
  57. {<<"color-rendering">>, Record#path.color_rendering},
  58. {<<"cursor">>, Record#path.cursor},
  59. {<<"direction">>, Record#path.direction},
  60. {<<"display">>, Record#path.display},
  61. {<<"dominant-baseline">>, Record#path.dominant_baseline},
  62. {<<"enable-background">>, Record#path.enable_background},
  63. {<<"fill">>, Record#path.fill},
  64. {<<"fill-opacity">>, Record#path.fill_opacity},
  65. {<<"fill-rule">>, Record#path.fill_rule},
  66. {<<"filter">>, Record#path.filter},
  67. {<<"flood-color">>, Record#path.flood_color},
  68. {<<"flood-opacity">>, Record#path.flood_opacity},
  69. {<<"font-family">>, Record#path.font_family},
  70. {<<"font-size">>, Record#path.font_size},
  71. {<<"font-size-adjust">>, Record#path.font_size_adjust},
  72. {<<"font-stretch">>, Record#path.font_stretch},
  73. {<<"font-style">>, Record#path.font_style},
  74. {<<"font-variant">>, Record#path.font_variant},
  75. {<<"font-weight">>, Record#path.font_weight},
  76. {<<"glyph-orientation-horizontal">>, Record#path.glyph_orientation_horizontal},
  77. {<<"glyph-orientation-vertical">>, Record#path.glyph_orientation_vertical},
  78. {<<"image-rendering">>, Record#path.image_rendering},
  79. {<<"kerning">>, Record#path.kerning},
  80. {<<"letter-spacing">>, Record#path.letter_spacing},
  81. {<<"lighting-color">>, Record#path.lighting_color},
  82. {<<"marker-end">>, Record#path.marker_end},
  83. {<<"marker-mid">>, Record#path.marker_mid},
  84. {<<"marker-start">>, Record#path.marker_start},
  85. {<<"mask">>, Record#path.mask},
  86. {<<"opacity">>, Record#path.opacity},
  87. {<<"overflow">>, Record#path.overflow},
  88. {<<"pointer-events">>, Record#path.pointer_events},
  89. {<<"shape-rendering">>, Record#path.shape_rendering},
  90. {<<"stop-color">>, Record#path.stop_color},
  91. {<<"stop-opacity">>, Record#path.stop_opacity},
  92. {<<"stroke">>, Record#path.stroke},
  93. {<<"stroke-dasharray">>, Record#path.stroke_dasharray},
  94. {<<"stroke-dashoffset">>, Record#path.stroke_dashoffset},
  95. {<<"stroke-linecap">>, Record#path.stroke_linecap},
  96. {<<"stroke-linejoin">>, Record#path.stroke_linejoin},
  97. {<<"stroke-miterlimit">>, Record#path.stroke_miterlimit},
  98. {<<"stroke-opacity">>, Record#path.stroke_opacity},
  99. {<<"stroke-width">>, Record#path.stroke_width},
  100. {<<"text-anchor">>, Record#path.text_anchor},
  101. {<<"text-decoration">>, Record#path.text_decoration},
  102. {<<"text-rendering">>, Record#path.text_rendering},
  103. {<<"unicode-bidi">>, Record#path.unicode_bidi},
  104. {<<"visibility">>, Record#path.visibility},
  105. {<<"word-spacing">>, Record#path.word_spacing},
  106. {<<"writing-mode">>, Record#path.writing_mode}
  107. ].