{"id":358,"date":"2015-10-19T17:30:23","date_gmt":"2015-10-19T08:30:23","guid":{"rendered":"http:\/\/www.takaya-com.jp\/archives\/?p=358"},"modified":"2015-10-19T17:40:50","modified_gmt":"2015-10-19T08:40:50","slug":"svg_css3_transform_sp1","status":"publish","type":"post","link":"https:\/\/takaya-com.jp\/archives\/2015\/10\/svg_css3_transform_sp1\/","title":{"rendered":"JavaScript\u304b\u3089SVG\u306eCSS\u30fbStyle\u3092\u64cd\u4f5c\u3057\u3066X,Y,Z\u8ef8\u305d\u308c\u305e\u308c\u306b\u5bfe\u3057\u3066\u56de\u8ee2\u3055\u305b\u308b"},"content":{"rendered":"<p><!-- \u672c\u6587 --><\/p>\n<p>SVG\u3067\u751f\u6210\u3055\u308c\u305f3\u679a\u306e\u30d1\u30cd\u30eb\u3092JavaScript\u304b\u3089CSS\u306e\u30b9\u30bf\u30a4\u30eb\u5909\u5316\u3055\u305b\u308b\u3053\u3068\u3067\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3055\u305b\u307e\u3059\u3002<br \/>\n\u8907\u6570\u306esvg\u3092\u91cd\u306d\u3066\u63cf\u753b\u3059\u308b\u305f\u3081\u306b\u3001svg\u3092\u542b\u3080div\u306b\u5bfe\u3057\u3066 position:relative \u3092\u3001<br \/>\n\u3059\u3079\u3066\u306esvg\u306b position:absolute \u3092CSS\u304b\u3089\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\n<\/p>\n<p>  <!--more--><br \/>\n\u2193\u4ee5\u4e0b\u304c\u5b9f\u969b\u306e\u30bd\u30fc\u30b9\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u3002<\/p>\n<p>\u25bcJavaScript<\/p>\n<pre class=\"lang:js decode:true \" title=\"JavaScript\" >&lt;script&gt;\r\n\r\n\tvar degX =0;\r\n\tvar degY =0;\r\n\tvar degZ =0;\r\n\r\n\tvar svg_x = document.getElementById(\"group_x\");\r\n\tvar svg_y = document.getElementById(\"group_y\");\r\n\tvar svg_z = document.getElementById(\"group_z\");\r\n\r\n\tsetInterval(\"draw()\",16);\r\n\r\n\tfunction draw(){\r\n\t\tdegX=(degX+1+360)%360;\r\n\t\tdegY=(degY+1+360)%360;\r\n\t\tdegZ=(degZ+1+360)%360;\r\n\t\tx=\"rotateX(\"+degX+\"deg)\";\r\n\t\ty=\"rotateY(\"+degY+\"deg)\";\r\n\t\tz=\"rotateZ(\"+degZ+\"deg)\";\r\n\r\n\t\tsvg_x.style.webkitTransform = x;\r\n\t\tsvg_y.style.webkitTransform = y;\r\n\t\tsvg_z.style.webkitTransform = z;\r\n}\r\n\r\n&lt;\/script&gt;<\/pre>\n<p>\u25bcCSS<\/p>\n<pre class=\"lang:css decode:true \" title=\"CSS\" >\r\n<style>\r\n#container{\r\n\twidth:500px;\r\n\theight:500px;\r\n\tposition:relative;\r\n\tperspective:300px;\r\n}\r\n\r\nsvg{\r\n\ttransform-style: preserve-3d;\r\n\tposition:absolute;\r\n}\r\n.number{\r\n\tfont-size:200px;\r\n}\r\nrect{opacity:0.4;}\r\n#rect_1{fill:#00f;}\r\n#rect_2{fill:#f00;}\r\n#rect_3{fill:#ff0;}\r\nline{\r\n\tstroke:black;\r\n\tstroke-width:3;\r\n}\r\ntext{\r\n\theight:200;\r\n\twidth:200;\r\n\tfont-size:50px;\r\n}\r\n<\/style>\r\n<\/pre>\n<p>\u25bcHTML<\/p>\n<pre class=\"lang:xhtml decode:true \" title=\"XHTML\" >\r\n\t<div id=\"container\">\r\n\t\t<svg id=\"line\" viewBox=\"-200 -200 600 600\">\r\n\t    \t<line x1=\"0\" y1=\"0\" x2=\"200\" y2=\"0\" \/> \r\n\t    \t<line x1=\"0\" y1=\"100\" x2=\"200\" y2=\"100\" \/> \r\n\t    \t<line x1=\"0\" y1=\"200\" x2=\"200\" y2=\"200\" \/> \r\n\t    \t<line x1=\"0\" y1=\"0\" x2=\"0\" y2=\"200\" \/> \r\n\t    \t<line x1=\"100\" y1=\"0\" x2=\"100\" y2=\"200\" \/> \r\n\t    \t<line x1=\"200\" y1=\"0\" x2=\"200\" y2=\"200\" \/> \r\n\t\t<\/svg>\r\n\t\t<svg class=\"panel\" id=\"group_x\" viewBox=\"-200 -200 600 600\">\r\n\t\t\t<rect id=\"rect_1\" height=\"200\" width=\"200\" \/>\r\n\t        <text x=\"20\" y=\"80\">X<\/text>\r\n\t\t<\/svg>\r\n\t\t<svg class=\"panel\" id=\"group_y\" viewBox=\"-200 -200 600 600\">\r\n\t\t\t<rect id=\"rect_2\" height=\"200\" width=\"200\" \/>\r\n    \t    <text x=\"20\" y=\"80\">Y<\/text>\r\n\t\t<\/svg>\r\n\t\t<svg class=\"panel\" id=\"group_z\" viewBox=\"-200 -200 600 600\">\r\n\t\t\t<rect id=\"rect_3\" height=\"200\" width=\"200\" \/>\r\n    \t    <text x=\"20\" y=\"80\">Z<\/text>\r\n\t\t<\/svg>\r\n\t<\/div>\r\n<\/pre>\n<p><a href=\"http:\/\/www.takaya-com.jp\/archives\/demo\/svg_css3_transform_sp1\/\" target=\"_blank\">\u30c7\u30e2\u30da\u30fc\u30b8\u306f\u3001\u3053\u3061\u3089<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>SVG\u3067\u751f\u6210\u3055\u308c\u305f3\u679a\u306e\u30d1\u30cd\u30eb\u3092JavaScript\u304b\u3089CSS\u306e\u30b9\u30bf\u30a4\u30eb\u5909\u5316\u3055\u305b\u308b\u3053\u3068\u3067\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3055\u305b\u307e\u3059\u3002 \u8907\u6570\u306esvg\u3092\u91cd\u306d\u3066\u63cf\u753b\u3059\u308b\u305f\u3081\u306b\u3001svg\u3092\u542b\u3080div\u306b\u5bfe\u3057\u3066 position:relative \u3092\u3001  [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,3],"tags":[],"_links":{"self":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/358"}],"collection":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/comments?post=358"}],"version-history":[{"count":9,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/358\/revisions"}],"predecessor-version":[{"id":370,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/posts\/358\/revisions\/370"}],"wp:attachment":[{"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/media?parent=358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/categories?post=358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/takaya-com.jp\/archives\/wp-json\/wp\/v2\/tags?post=358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}