VisibleAfter, VisibleBefore, VisibleFromTo

Object visible at time value

Value Summary

VisibleAfter, VisibleBefore, VisibleFromToLibrary wrapper for "TimeEnd, TimeBegin, VisibleAfterEnd, and VisibleBeforeBegin"Non-negative real number

Description

VisibleAfter = t0 renders an object invisible until the real time t0 has elapsed in an animation. Then the object becomes visible.

VisibleBefore = t1 renders an object visible until the time t1. Then the object becomes invisible.

VisibleFrom = t_0 .. t_1 renders an object invisible until the time t0. Then the object becomes visible. After the time t1 it becomes invisible again.

VisibleAfter, VisibleBefore, VisibleFromTo allow to implement animated visibility of objects. This also includes otherwise static objects, which become animated objects when one of these attributes is used.

The attributes VisibleBeforeBegin and VisibleAfterEnd control the visibility of objects outside the time range of their animation set by TimeBegin and TimeEnd. See TimeBegin, TimeEnd for details.

VisibleAfter, VisibleBefore, VisibleFromTo provide short cuts for suitable settings of the attributes TimeBegin, VisibleBeforeBegin, TimeEnd, VisibleAfterEnd that produce the desired visibility effects.

VisibleAfter = t0 is a short cut for setting the following attribute values:

TimeBegin = t0, VisibleBeforeBegin = FALSE,

TimeEnd = t0, VisibleAfterEnd = TRUE.

The resulting effect is that the corresponding object is invisible at the beginning of the animation. It becomes visible at the time t0, staying visible until the end of the animation.

The time t0 has to be a real numerical value giving the real time in seconds.

VisibleBefore = t1 is a short cut for setting the following attribute values:

TimeBegin = t1, VisibleBeforeBegin = TRUE,

TimeEnd = t1, VisibleAfterEnd = FALSE.

The resulting effect is that the corresponding object is visible at the beginning of the animation. At the time t1 it becomes invisible, staying invisible until the end of the animation.

The time t1 has to be a real numerical value giving the real time in seconds.

VisibleFromTo = t_0 .. t_1 is a short cut for setting the following attribute values:

TimeBegin = t0, VisibleBeforeBegin = FALSE,

TimeEnd = t1, VisibleAfterEnd = FALSE.

The resulting effect is that the corresponding object is visible only from the time t0 until the time t1.

    Note:   The attributes VisibleAfter = t0 and VisibleBefore = t1 should not be combined to create visibility for the time range between t0 and t1. (Conflicting values are set implicitly for VisibleBeforeBegin etc.) Use VisibleFromTo = t_0 .. t_1 instead.

Examples

Example 1

The following animation consists of 100 pieces of the graph of the function xsin(x). At the times t = 0.1, 0.2 etc., an additional piece of the function becomes visible until, finally, the whole graph is built up:

plot(plot::Function2d(x*sin(x), x = (i - 1)*PI/100 .. i*PI/100, 
                      VisibleAfter = i/10) $ i = 1..100)

Example 2

This example creates an animated "spider net". It consists of several lines which appear one after the other at the times given by VisibleAfter until the full net is visible at the end of the animation:

SpiderNet := 
proc(move, move1, rc, gc, bc)
  local r, lines, x, y, x1, y1;
begin
  r := 1.0:  
  lines := [FAIL $ 361]:
  for i from 0 to 360 do 
    thet := float(i*PI/180);
    x     := r * cos(move  * thet); 
    y     := r * sin(move  * thet); 
    x1    := r * cos(move1 * thet);
    y1    := r * sin(move1 * thet);
    lines[i+1] := 
      plot::Line2d([x, y] ,[x1, y1], 
                   Color = [abs(rc*sin(i*PI/360)), 
                            abs(gc*sin(i*PI/360 + PI/4)),  
                            abs(bc*sin(i*PI/360 + PI/2))],
                   VisibleAfter = i/36
      );
  end_for:
  plot::Group2d(op(lines), Name = "SpiderNet",
                Axes = None, Scaling = Constrained)
end_proc:
plot(SpiderNet(3, 7, 0.9, 0.1, 0.5))

delete SpiderNet:

Example 3

This example creates an animated "Maurer rose". Here the animation starts with the full object. During the animation the lines disappear at the times given by VisibleBefore:

MaurerRose := proc(n, b, rc, gc, bc)
  local lines, i, thet, r, x, y, x1, y1;
begin
  r := 1.0;
  lines := [FAIL $ 361]:
  b := float(b*PI/180);
  for i from 0 to 360 do 
    thet := float(i*PI/180); 
    x     := r * sin(n*thet)    * cos(thet); 
    y     := r * sin(n*thet)    * sin(thet); 
    x1    := r * sin(n*(thet+b))* cos(thet+b);
    y1    := r * sin(n*(thet+b))* sin(thet+b);
    lines[i+1] := 
      plot::Line2d([x, y], [x1, y1], 
                   Color = [abs(rc*sin(i*PI/360)), 
                           abs(gc*sin(i*PI/360 + PI/4)),  
                           abs(bc*sin(i*PI/360 + PI/2))],
                   VisibleBefore = i/36
      );
  end_for:
  plot::Group2d(op(lines), Name = "MaurerRose",
                Axes = None, Scaling = Constrained):
end_proc:
plot(MaurerRose(4, 120, 0.1, 0.5, 0.9)):

delete MaurerRose:

Example 4

This example creates an animated "Lissajous net". It is built up from lines that have a life span of only 2 seconds each, set by VisibleFromTo:

LissajousNet := proc(r, a, b, R, A, B, rc, gc, bc)
  local lines, i, thet;
begin
  lines := [FAIL $ 361]:
  for i from 0 to 360 do 
    thet := float(i*PI/180);
    x     := r * cos(a*thet); 
    y     := r * sin(b*thet); 
    x1    := R * cos(A*thet);
    y1    := R * sin(B*thet);
    lines[i+1] := 
      plot::Line2d([x, y], [x1, y1], 
                   Color = [abs(rc*sin(i*PI/360)), 
                            abs(gc*sin(i*PI/360 + PI/4)),  
                            abs(bc*sin(i*PI/360 + PI/2))],
                   VisibleFromTo = i/36 .. i/36 + 2
      );
  end_for:
  plot::Group2d(op(lines), Name = "LissajousNet",
                Axes = None, Scaling = Constrained):
end_proc:
plot(LissajousNet(2, 3, 4, 1, 6, 3, 0.7, 0.1, 0.99))

delete LissajousNet:

Example 5

Here is a 3D example of an animation. A "spider net" is built up with lines that have a life span of 4 seconds each:

SpiderNet3d := proc(a, b, c, rc, gc, bc)
  local r, lines, i, x, x1, y, y1, thet, z1, z; 
begin 
  r := 1.0:
  lines := [FAIL $ 361]:
  for i from 0 to 360 do 
    thet := float(i*PI/180);
    x     := r * cos(thet)*cos(thet);
    y     := r * sin(thet)*cos(thet);
    z     := r * sin(thet):
    x1    := r * cos(a*thet)*cos(a*thet);
    y1    := r * sin(b*thet)*cos(b*thet);
    z1    := r * sin(c*thet):
    lines[i+1] := 
      plot::Line3d([x,y,z],[x1,y1,z1], 
                   Color = [abs(rc*sin(i*PI/360)),
                            abs(gc*sin(i*PI/360 + PI/4)), 
                            abs(bc*sin(i*PI/360 + PI/2))],
                   VisibleFromTo = i/36 .. i/36 + 4
      );
  end_for:
  plot::Group3d(op(lines), Name = "SpiderNet3d"):
end_proc:
plot(SpiderNet3d(2, 1, 3, 0.99, 0.9, 0.1))

Algorithms

The last examples on this page are taken from the mathPAD Online Edition (http://www.mupad.com/mathpad/recreations.html) written by Prof. Mirek Majewski. See there for details about the mathematics behind the examples above.

Was this topic helpful?