Пример #1
0
        public MovieClipSnapshot copyWith(MovieClipDataSnapshotModifier modifier, float duration)
        {
            D.assert(duration > 0);
            Dictionary <string, MovieClipObject> updatedDictionary = new Dictionary <string, MovieClipObject>();
            float newTimestamp = timestamp + duration;

            foreach (var entry in objects)
            {
                var obj = entry.Value;
                if (obj.deathTime == null || obj.deathTime > newTimestamp)
                {
                    updatedDictionary.Add(entry.Key, entry.Value);
                }
            }
            var snapshot = new MovieClipSnapshot(
                objects.ToDictionary(
                    entry => entry.Key,
                    entry => (MovieClipObject)entry.Value.Clone()
                    ),
                timestamp
                );

            snapshot._defaultDuration = duration;
            modifier(snapshot);
            snapshot._timestamp = newTimestamp;

            return(snapshot);
        }
Пример #2
0
 public static void createBasicObject(
     this MovieClipSnapshot snapshot,
     string id,
     Widget child,
     AppearAnimation animation = AppearAnimation.none,
     int layer        = 0,
     Offset position  = null,
     Offset pivot     = null,
     Size scale       = null,
     float rotation   = 0,
     float opacity    = 1,
     float delay      = 0,
     float appearTime = MovieClipSnapshot.kDefaultAppearTime)
 {
     snapshot.createObject(new BasicMovieClipObject(id, child, layer),
                           position: position,
                           pivot: pivot,
                           scale: scale,
                           rotation: rotation,
                           opacity: opacity,
                           delay: delay,
                           animation: animation,
                           appearTime: appearTime
                           );
 }
Пример #3
0
 public static bool animateFloatListObject(
     this MovieClipSnapshot snapshot,
     string id,
     PropertyModifier <List <float> > modifier,
     float delay    = 0,
     float?duration = null,
     PropertyModifier <List <float> > from = null,
     Curve curve = null
     )
 {
     return(snapshot.animateTo <List <float> >(
                id,
                paramName: "progress",
                target: progress => {
         var ret = progress.ToList();
         modifier(ret);
         return ret;
     },
                delay: delay,
                duration: duration,
                from: from != null ? (PropertyProvider <List <float> >)(progress => {
         var ret = progress.ToList();
         from(ret);
         return ret;
     }) : null,
                curve: curve
                ));
 }
Пример #4
0
 public static void createText(
     this MovieClipSnapshot snapshot,
     string id, string text,
     TextStyle style           = null,
     AppearAnimation animation = AppearAnimation.none,
     int layer        = 0,
     Offset position  = null,
     Offset pivot     = null,
     Size scale       = null,
     float rotation   = 0,
     float opacity    = 1,
     float delay      = 0,
     float appearTime = MovieClipSnapshot.kDefaultAppearTime)
 {
     snapshot.createObject(new MovieClipTextObject(
                               id, text, style, layer: layer),
                           position: position,
                           pivot: pivot,
                           scale: scale,
                           rotation: rotation,
                           opacity: opacity,
                           delay: delay,
                           animation: animation,
                           appearTime: appearTime);
 }
Пример #5
0
        private void instantiateFrames(List <MovieClipDataFrame> frames)
        {
            MovieClipSnapshot snapshot = new MovieClipSnapshot(0);

            snapshots.Clear();
            _duration = 0;
            foreach (var frame in frames)
            {
                snapshot = frame.applyTo(snapshot);
                snapshots.Add(snapshot);
                _duration += frame.duration;
            }
        }
Пример #6
0
 public static void createTypingEffect(
     this MovieClipSnapshot snapshot,
     string id,
     string text,
     TextStyle style          = null,
     Color color              = null,
     TextAlign textAlign      = TextAlign.left,
     int?maxLines             = null,
     float?maxWidth           = null,
     float?maxHeight          = null,
     float?minWidth           = null,
     float?minHeight          = null,
     EdgeInsets padding       = null,
     BoxDecoration decoration = null,
     int layer        = 0,
     Offset position  = null,
     Offset pivot     = null,
     Size scale       = null,
     float rotation   = 0,
     float opacity    = 1,
     float delay      = 0,
     float appearTime = MovieClipSnapshot.kDefaultAppearTime)
 {
     snapshot.createTypingEffect(
         id: id,
         texts: new List <string> {
         text
     },
         style: style,
         color: color,
         textAlign: textAlign,
         maxLines: maxLines,
         maxWidth: maxWidth,
         maxHeight: maxHeight,
         minWidth: minWidth,
         minHeight: minHeight,
         padding: padding ?? EdgeInsets.all(10),
         decoration: decoration ?? new BoxDecoration(),
         layer: layer,
         position: position,
         pivot: pivot ?? new Offset(0, 0.5f),
         scale: scale,
         rotation: rotation,
         opacity: opacity,
         delay: delay,
         appearTime: appearTime
         );
 }
Пример #7
0
 public static void createTextBox(
     this MovieClipSnapshot snapshot,
     string id,
     string text,
     TextStyle style           = null,
     Color color               = null,
     TextAlign textAlign       = TextAlign.center,
     int?maxLines              = null,
     float?maxWidth            = null,
     float?maxHeight           = null,
     float?minWidth            = null,
     float?minHeight           = null,
     EdgeInsets padding        = null,
     BoxDecoration decoration  = null,
     AppearAnimation animation = AppearAnimation.none,
     int layer        = 0,
     Offset position  = null,
     Offset pivot     = null,
     Size scale       = null,
     float rotation   = 0,
     float opacity    = 1,
     float delay      = 0,
     float appearTime = MovieClipSnapshot.kDefaultAppearTime)
 {
     snapshot.createObject(new MovieClipTextBoxObject(id,
                                                      text,
                                                      style,
                                                      color: color,
                                                      textAlign: textAlign,
                                                      maxLines: maxLines,
                                                      maxWidth: maxWidth,
                                                      maxHeight: maxHeight,
                                                      minWidth: minWidth,
                                                      minHeight: minHeight,
                                                      padding: padding ?? EdgeInsets.all(10),
                                                      decoration: decoration,
                                                      layer: layer
                                                      ),
                           position: position,
                           pivot: pivot,
                           scale: scale,
                           rotation: rotation,
                           opacity: opacity,
                           delay: delay,
                           animation: animation,
                           appearTime: appearTime
                           );
 }
Пример #8
0
 public static bool animateTyping(
     this MovieClipSnapshot snapshot,
     string id,
     int index      = 0,
     float target   = 1,
     float delay    = 0,
     float?duration = null,
     Curve curve    = null
     )
 {
     return(snapshot.animateFloatListObject(
                id,
                progress => { progress[index] = target; },
                delay: delay,
                duration: duration,
                curve: curve
                ));
 }
Пример #9
0
 public static void createBasicObjectWithTitle(
     this MovieClipSnapshot snapshot,
     string id,
     string title,
     Widget child,
     float titleDistance       = 25,
     Alignment alignment       = null,
     TextStyle style           = null,
     AppearAnimation animation = AppearAnimation.none,
     int layer        = 0,
     Offset position  = null,
     Offset pivot     = null,
     Size scale       = null,
     float rotation   = 0,
     float opacity    = 1,
     float delay      = 0,
     float appearTime = MovieClipSnapshot.kDefaultAppearTime)
 {
     snapshot.createBasicObject(
         id: id,
         child: new Stack(children: new List <Widget> {
         new Padding(
             child: child,
             padding: EdgeInsets.all(titleDistance)
             ),
         Positioned.fill(
             new Align(
                 child: new Text(title, style: style ?? new TextStyle(fontWeight: FontWeight.bold)),
                 alignment: alignment ?? Alignment.topCenter
                 )
             )
     }),
         animation: animation,
         layer: layer,
         position: position,
         pivot: pivot,
         scale: scale,
         rotation: rotation,
         opacity: opacity,
         delay: delay,
         appearTime: appearTime
         );
 }
Пример #10
0
 public MovieClipSnapshot applyTo(MovieClipSnapshot snapshot)
 {
     return(snapshot.copyWith(modifier, duration));
 }