Skip to content

Instantly share code, notes, and snippets.

@magmoro
Created February 22, 2009 09:17
Show Gist options
  • Save magmoro/68412 to your computer and use it in GitHub Desktop.
Save magmoro/68412 to your computer and use it in GitHub Desktop.
function vmlImage(props){
var left=(props.left||0)-1;
var top=(props.top||0)-1;
var width=props.width+1;
var height=props.height+1;
var rect=new Element('v:rect',{
styles:{
width: width,
height: height,
left: left,
top: top,
position: 'absolute',
clip: 'rect(1px '+width+'px '+height+'px 1px)'
},
stroked:false
}).adopt(
new Element('v:fill',{
src: props.src,
type: 'tile',
position: 1/width+','+1/height
})
);
return rect;
}
var myVmlImage=vmlImage({
src: 'homer-simpson.jpg',
width:500,
height:500,
left:10,
top:10
}).inject(document.body);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment