admin管理员组文章数量:1026989
I need to simulate the effect of skewing an image, like Photoshop, using Javascript. Do you guys know how to do that in Javascript?
What kind of geometry calculation is applied to the <canvas>
context? I can't use CSS for this, because it has to be modified dynamically.
I need to simulate the effect of skewing an image, like Photoshop, using Javascript. Do you guys know how to do that in Javascript?
What kind of geometry calculation is applied to the <canvas>
context? I can't use CSS for this, because it has to be modified dynamically.
- This can be done with CSS3 alone. – Madara's Ghost Commented Jul 16, 2012 at 19:24
- this cannot be done with CSS because it has to be modified on the fly by javascript. I said that on the question. Thanks anyway. – Duck Commented Jul 16, 2012 at 20:43
3 Answers
Reset to default 2This is possible with CSS3 alone:
img {
-webkit-transform: skew(45deg);
}
Live Example
Note, I only used webkit, but it's the same for all other modern browsers.
CSS transform: skew();
will do this for you with no Javascript.
Demo: http://jsfiddle/ThinkingStiff/MtWBy/
Output
CSS
#original {
margin: 55px 10px 0 10px;
}
#vertical {
margin: 30px 20px 0 0;
transform: skew( 0, -30deg );
-ms-transform: skew( 0, -30deg );
-moz-transform: skew( 0, -30deg );
-o-transform: skew( 0, -30deg );
-webkit-transform: skew( 0, -30deg );
}
#horizontal {
margin: 55px 0 0 0;
transform: skew( -30deg, 0 );
-ms-transform: skew( -30deg, 0 );
-moz-transform: skew( -30deg, 0 );
-o-transform: skew( -30deg, 0 );
-webkit-transform: skew( -30deg, 0 );
}
.image {
background-image: url( 'http://placekitten./100' );
border: 1px solid black;
display: inline-block;
height: 100px;
margin-right: 20px;
vertical-align: top;
width: 100px;
}
HTML
<div id="original" class="image"></div>
<div id="vertical" class="image"></div>
<div id="horizontal" class="image"></div>
I found the solution: http://www.w3schools./html5/playcanvas.asp?filename=playcanvas_transformb&preval=1,0,0,1,0,0
I need to simulate the effect of skewing an image, like Photoshop, using Javascript. Do you guys know how to do that in Javascript?
What kind of geometry calculation is applied to the <canvas>
context? I can't use CSS for this, because it has to be modified dynamically.
I need to simulate the effect of skewing an image, like Photoshop, using Javascript. Do you guys know how to do that in Javascript?
What kind of geometry calculation is applied to the <canvas>
context? I can't use CSS for this, because it has to be modified dynamically.
- This can be done with CSS3 alone. – Madara's Ghost Commented Jul 16, 2012 at 19:24
- this cannot be done with CSS because it has to be modified on the fly by javascript. I said that on the question. Thanks anyway. – Duck Commented Jul 16, 2012 at 20:43
3 Answers
Reset to default 2This is possible with CSS3 alone:
img {
-webkit-transform: skew(45deg);
}
Live Example
Note, I only used webkit, but it's the same for all other modern browsers.
CSS transform: skew();
will do this for you with no Javascript.
Demo: http://jsfiddle/ThinkingStiff/MtWBy/
Output
CSS
#original {
margin: 55px 10px 0 10px;
}
#vertical {
margin: 30px 20px 0 0;
transform: skew( 0, -30deg );
-ms-transform: skew( 0, -30deg );
-moz-transform: skew( 0, -30deg );
-o-transform: skew( 0, -30deg );
-webkit-transform: skew( 0, -30deg );
}
#horizontal {
margin: 55px 0 0 0;
transform: skew( -30deg, 0 );
-ms-transform: skew( -30deg, 0 );
-moz-transform: skew( -30deg, 0 );
-o-transform: skew( -30deg, 0 );
-webkit-transform: skew( -30deg, 0 );
}
.image {
background-image: url( 'http://placekitten./100' );
border: 1px solid black;
display: inline-block;
height: 100px;
margin-right: 20px;
vertical-align: top;
width: 100px;
}
HTML
<div id="original" class="image"></div>
<div id="vertical" class="image"></div>
<div id="horizontal" class="image"></div>
I found the solution: http://www.w3schools./html5/playcanvas.asp?filename=playcanvas_transformb&preval=1,0,0,1,0,0
本文标签: javascriptHTML 5 Skew codeStack Overflow
版权声明:本文标题:javascript - HTML 5 Skew code - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745660589a2161864.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论