Dynamic HTML: Filters and Transitions
Dynamic HTML: Filters and Transitions
<html><head><style type=“text/css”>
h2{width:100%;}</style></head>
<body>
<h2 style=“filter:glow()”>Glow</h2>
<h2 style=“filter:blur()”>Blur</h2>
<h2 style=“filter:flipv()”>FlipV</h2>
<h2 style=“filter:fliph()”>Fliph</h2>
<h2 style=“filter:flipvfliph()”>FlipVandFlipH</h2>
<h2 style=“filter:shadow()”>Shadow</h2>
<h2 style=“filter:dopshadow()”>drop
Shadow</h2></body></html>
Chroma Filter
• chroma filter applies transparency effects
dynamically
– Without using a graphics editor to hard-code
transparency into the image
• onchange
– Fires when the value of a form changes
<html><head><title>Chroma Filter</title>
<script type=”text/javascript”>
function changecolor(theColor)
{
if (thecolor ){
chromaImg.filters(“chroma” ).color= theColor;
chromaImg.filters(“chroma” ).enabled= true;
}
else
chromaImg.filters(“chroma” ).enabled= false;
}
</script>
</head>
<body>
<h1> Chroma Filter </h1><img id =”chromaImg” src=”trans.gif” style=”position: absolute;
filter:chroma” alt =”Transparent Image” />
<form action = “ “>
<select onchange=”changecolor(this.value)”>
<option value= “ “>None</option>
<option value= “#00FFFF “>Cyan</option>
<option value= “ #FFFF00“>Yellow</option>
<option value= “#FF00FF “>Magenta</option>
<option value=”#000000” selected=”selected”>Black</option>
</select></form></body></html>
Output
Flip Filters: flipv and fliph
• flipv and fliph filters mirror text or images
vertically and horizontally, respectively
• <html xmlns=http://www.w3.org/1999/xhtml>
<head>
<title>Chroma Filter</title>
<script type=”text/css”>
body { background-color: #CCFFCC}
table { font-size : 3em;
font-family :Arial, sans serif;
background-color: #FFCCCC;
border-style: ridge;
border-collapse: collapse }
td { border-style: grove;
padding: 1ex }
</style>
</head>
<body>
<table>
<tr>
<td style=”filter:flipv fliph”>Text</td>
• <td style=”filter:flipv”>Text </td>
</tr>
</table>
</body>
</html>
Output
Transparency with the chroma Filter
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 300px;
height: 100px;
background-color: yellow;
box-shadow: 10px 10px 5px #888888;
}
</style>
</head>
<body>
<div></div>
</body></html>
Objectives
• To use filters to achieve special effects.
• To combine filters to achieve an even greater
variety of special effects.
• To be able to create animated visual transitions
between Web pages.
• To be able to modify filters dynamically, using
DHTML