Upgrade to Pro — share decks privately, control downloads, hide ads and more …

知っておくと得をする(かもしれない)
 SVGの基礎とviewBox

Naoki Matsuda
February 28, 2021

知っておくと得をする(かもしれない)
 SVGの基礎とviewBox

CSSの transform-box プロパティの挙動をよりよく知るためのSVGの座標系の説明です。

実際のスライドはアニメーションが多用されているので、詳しくはこちらのアーカイブ動画をご覧ください。
https://www.youtube.com/watch?v=nxiTyhe42gU

Naoki Matsuda

February 28, 2021
Tweet

More Decks by Naoki Matsuda

Other Decks in Design

Transcript

  1. XMLจॻͰ͋Δ จࣈ৘ใΛ಺แ ը૾ͷத਎ΛΞΫηγϒϧʹͰ͖Δ <circle cx="20" …> <title> Duck’s eye </title>

    </circle> ͢΂͕ͯཁૉʢDOMʣ CSS΍Web Fonts΋ద༻Ͱ͖Δ <circle> <path> <path> ࠶ར༻ੑ SVG Sprites΋͜ͷํ๏
  2. Standalone SVG HTML CSS SVG ֎෦ϑΝΠϧΛը૾ͱͯ͠දࣔͤ͞Δ HTML <svg> </svg> inline

    SVG HTMLͷதʹɺSVGίʔυΛ௚઀ॻ͘ HTML಺ʹSVGίʔυΛ௚઀ؚΊΔ͜ͱ͕Ͱ͖Δ CSS HTML
  3. Ξχϝʔγϣϯ࣮૷ํ๏͕๛෋ JavaScript ͳΜͰ΋Ͱ͖Δ var tl = new TimelineMax(); tl.fromTo('#obj', 3,

    {y: '0'}, {y: ’10', repeat: -1, yoyo: true}, '-=2') SMIL ཁૉ͚ͩͰΞχϝʔγϣϯ <circle cx="20" …> <animate attributeName="cx" from="100" to="100" dur="5s" … /> </circle> CSS Animations CSSͷΞχϝʔγϣϯ΋࢖͑Δ @keyframes stroke-anime { 0% { stroke-dashoffset: 800; fill: transparent; } 100% { stroke-dashoffset: 0; fill: rgba(#fff, .7); } }
  4. ίετύϑΥʔϚϯε ଱ٱੑ σβΠϯ ಠࣗੑ Custom Fields 3 6 3 4

    σʔλͱ૬ੑྑ͠ ίετύϑΥʔϚϯε ଱ٱੑ σβΠϯ ಠࣗੑ ࡏݿ
  5. <svg width="142" height="142" viewBox="0 0 142 142" xmlns="http://www.w3.org/2000/svg"> <script> window.alert("

    !!!!!!!! "); </script> <rect width="142" height="142" fill="#C4C4C4"/> </svg>
  6. <?php function permit_mimes( $mimes ) { $mimes['svg'] = 'image/svg+xml'; return

    $mimes; } add_filter('upload_mimes', 'permit_mimes'); ?>
  7. <?php function permit_mimes( $mimes ) { $mimes['svg'] = 'image/svg+xml'; return

    $mimes; } add_filter('upload_mimes', 'permit_mimes'); ?>
  8. HTML <img> HTML <object> <embed> <iframe> CSS bacground HTML5 inline

    SVG top-level
 document embedded
 document static image document animated image document font document Web Fonts mask, pattern … resource document https://svgwg.org/specs/integration/#referencing-modes
  9. $chart_point_data = [ 'ui-design' => ['380 186', '380 122', '380

    58' ], 'prototyping' => ['448 235', '508 216', '569 196'], 'share' => ['422 314', '460 367', '497 419'], 'design-system' => ['339 314', '301 367', '264 419'], 'extensibility' => ['313 235', '253 216', '192 196'] ];
  10. $chart_point_data = [ 'ui-design' => ['380 186', '380 122', '380

    58' ], 'prototyping' => ['448 235', '508 216', '569 196'], 'share' => ['422 314', '460 367', '497 419'], 'design-system' => ['339 314', '301 367', '264 419'], 'extensibility' => ['313 235', '253 216', '192 196'] ]; Protoyping Extension Design System Share UI 1 1 0 0 0
  11. <polygon points="380 186 448 235 422 314 339 314 313

    235" fill="#e506b1" opacity="0.6"> <animate attributeName="points" begin="indefinite" dur="1s" to=" 380 122 508 216 422 314 339 314 313 235" repeatCount="0" fill="freeze" calcMode="spline" keyTimes="0;1" keySplines="0.25 0.1 0.25 1.0" class="- animated"></animate> </polygon> 1 1 0 0 0
  12. 1 2 3 200 ............................... 2 3 200 1 ...............................

    viewBox="0 0 200 200" <line x1="0" y1="0" x2="200" y2="100" stroke="#fff" /> 0,0 200,100
  13. WP
 ZoomUp Lorem ipsum dolor sit amet, consectetur adipiscing elit,

    sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  14. #arm { transform-origin: 283px 196px; } ňpxʯ͕͍͍ͭͯΔ͕ɺ
 SVGͷ࠲ඪܥͷར༻୯Ґѻ͍ width: 50px;

    height: 50px; Ͱ΋ɺ transform-origin: 283px 196px; ϏϡʔϙʔτͷαΠζͱ͸ແؔ܎
  15. rect { transform-origin: 150px 150px; transform: rotate(360deg) } rect {

    transform-box: fill-box; transform-origin: 50% 50%; transform: rotate(360deg) } =
  16. rect { transform-origin: 150px 150px; transform: rotate(360deg) } rect {

    transform-box: fill-box; transform-origin: 50% 50%; transform: rotate(360deg) } =