Filters and Transitions
Filters and Transitions
184
Internet Systems
185
Internet Systems
186
Internet Systems
Example:
<IMG SRC = “pic.jpg”
STYLE = “filter: invert”>
To get the effect, this filter must be used with the position property.
You should also include padding to give room for the shadow to
move out beyond the text.
187
Internet Systems
Example:
<BODY>
<P STYLE = "position: absolute;
padding: 10;
font-size = 2em;
filter: shadow( direction = 0,
color = gray )">
M M M</P>
<P STYLE = "position: absolute; top: 50;
padding: 10;
font-size = 2em;
filter: shadow( direction = 90,
color = gray )">
M M M</P>
</BODY>
188
Internet Systems
189
Internet Systems
Example:
<HTML>
<HEAD>
<TITLE>alpha Filter</TITLE>
<SCRIPT>
function start()
{
pic.filters( "alpha" ).finishopacity = 0;
}
</SCRIPT>
</HEAD>
<BODY ONLOAD = "start()">
<DIV ID = "pic"
STYLE = "position: absolute;
filter: alpha( style = 1,
opacity = 100)">
<IMG SRC = "Bars.bmp">
</BODY>
</HTML>
190
Internet Systems
Parameters:
color: the color of the aura
strength: the strength of the aura
When the strength is set high, the effect is often clipped by the
border of the element.
Padding overcomes this.
Parameters:
strength: how much out of focus the text or image is
add: if true, a copy of the original image is superimposed on
the blurred one (which gives something like a shadow effect)
direction: the direction in which the rendering of the
element is smudged – one of eight equally spaced clockwise
offsets from the vertical (in degrees), just as with the shadow
filter.
191
Internet Systems
Parameters:
freq: the frequency of the sine wave
phase: the phase shift of the sine wave
strength: the amplitude of the sine wave
add: if true, superimposes the filtered effect on the original
image – useful only with images
192
Internet Systems
Parameters:
offx / offy: the offset in number of pixels
color: the color of the drop shadow.
Example:
<IMG SRC = “pic.gif” STYLE = “…
filter: dropShadow( offsetx = 50,
offsety = 75, color = black)”>
193
Internet Systems
Example:
document.body.filters( "light" ).addPoint(
200, 125, 300, 255, 255, 255, 100)
194
Internet Systems
Example:
document.body.filters( "light" ).addCone(
100, 300, 200, 200, 0,
255, 255, 255, 100, 30)
195
Internet Systems
Example:
A typical absolute move would be
document.body.filters( "light" ).moveLight(
1, 400, 100, 100, 1)
A typical relative move would be
document.body.filters( "light" ).moveLight(
0,200,0,-100,0)
196
Internet Systems
Example:
The following creates a white-light point source with 100%
strength at (x,y,z) = (200,125,300) when the body successfully
loads.
<HTML>
<HEAD>
<TITLE>Light Point</TITLE>
<SCRIPT LANGUAGE = "JavaScript">
function start()
{
document.body.filters( "light" ).addPoint(
200, 125, 300, 255, 255, 255, 100 )
}
function changeLight()
{
document.body.filters( "light" ).moveLight(
0, 200, 0, -100, 0 )
}
</SCRIPT>
</HEAD>
<BODY BACKGROUND = "Bars.bmp" ONLOAD = "start()"
STYLE = "filter: light"
ONCLICK = "changeLight()">
</BODY>
</HTML>
197
Internet Systems
198
Internet Systems
Example:
The following, when the file is loaded, creates two white-light cone
sources, both with 100% strength and 30o spread.
The first source is at (x,y,z) = (100,300,200), directed at
(x,y) = (200,0) on the page
The second is at (400,300,200), directed at (300,0).
When the body is clicked, the target of the first is moved (with absolute
positioning) to (100,100), and that of the second to (400,100).
The heights of both sources go down to 100.
<HTML>
<HEAD>
<TITLE>Light</TITLE>
<SCRIPT LANGUAGE = "JavaScript">
function start()
{
document.body.filters( "light" ).addCone(
100,300,200, 200,0, 255,255,255, 100, 30)
document.body.filters( "light" ).addCone(
400,300,200, 300,0, 255,255,255, 100, 30)
}
function changeLight()
{
document.body.filters( "light" ).moveLight(
0, 100, 100, 100, 1)
document.body.filters( "light" ).moveLight(
1, 400, 100, 100, 1)
}
</SCRIPT>
</HEAD>
<BODY BACKGROUND = "Bars.bmp" ONLOAD = "start()"
STYLE = "filter: light"
ONCLICK = "changeLight()">
</BODY>
</HTML>
199
Internet Systems
200
Internet Systems
Transitions
Explorer 5’s transitions allow many scriptable PowerPoint-like effects.
201
Internet Systems
Example:
The following causes a P element with content TEXT to fade out over
one second, then fade in over one second, then repeat indefinitely.
<HTML>
<HEAD>
<TITLE>Fading Text</TITLE>
<SCRIPT LANGUAGE = "JavaScript">
var direction = true;
function fade()
{
text.filters( "blendTrans" ).apply();
text.style.visibility =
direction ? "hidden" : "visible";
text.filters( "blendTrans" ).play();
direction = ! direction;
}
</SCRIPT>
</HEAD>
<BODY ONLOAD = "fade()">
<P ID = "text" ONFILTERCHANGE = "fade()"
STYLE = "width: 300;
filter: blendTrans( duration = 1 )">
TEXT</P>
</BODY>
</HTML>
202
Internet Systems
For example,
6 (wipe right) grows the pattern from left to right, and
16 (split) starts with a horizontal line through the middle of the
element, which spreads up and down.
See Figure 17.4, pp. 592-596, of the text for all 24 patterns and
examples of the effects of some.
203