javascript - Create rotated rectangle out of an image -
is there way slice image pieces (45deg rotated rectangles).
here's code found on internet has animation , creates rectangles of image. (version:5) http://plnkr.co/edit/8tcvpyweskirfengntd6?p=preview
i tried create rotated rectangles prob when use transform:rotate(45deg)
out of piece first applies background rotates it.
edit1: trying sth creating div rotated contains div who's rotated other way
<div style="overflow:hidden;transform:rotate(45deg)"> <div class="tilepiece" style="transform:rotate(-45deg);background-image:url('img.jpg');background-position:xx xx"></div> ... </div>
(version:6) http://plnkr.co/edit/8tcvpyweskirfengntd6?p=preview
maybe hint css using background image , tiles on . http://codepen.io/gc-nomade/pen/fahme/
idea set white background rotated tiles giving each different delay in transition. in codepen , used sass generate associate css in loop
$n : 24 ; div:hover span{@for $i 0 through $n { @if $i > 0 { &:nth-child(#{$i}) { background:white; transition: 0s #{$i/3}s; } } } }
wich gives 24 rules bth-child incremented , transition delay incremented . firt 3 looks :
div:hover span:nth-child(1) { background: white; transition: 0s 0.33333s; } div:hover span:nth-child(2) { background: white; transition: 0s 0.66667s; } div:hover span:nth-child(3) { background: white; transition: 0s 1s; } /* , on untill 24*/
to switch image another, need imbricate 2 elements reverse initial rotation. can set transition on both state , last tiles fade on hover , first show on mouse out : http://codepen.io/gc-nomade/pen/zrond/
you can add scissor or slide effect http://codepen.io/gc-nomade/pen/vtzle/
Comments
Post a Comment