Ejemplo n.º 1
0
        public override Frame transition_frame(Frame from_frame, Frame to_frame)
        {
            Frame  frame = new Frame(from_frame.width, from_frame.height);
            double prog0 = this.progress;
            double prog1 = this.progress;

            if (this.in_out == false)
            {
                prog0 = 1.0 - prog0;
            }
            else
            {
                prog1 = 1.0 - prog1;
            }

            int src_x, src_y, ovr_x, ovr_y;

            // TODO: Improve src_x/y so that it moves at the same speed as ovr_x/y with the midpoint
            if (direction == ObscuredWipeTransitionDirection.North)
            {
                src_x = 0;
                src_y = (int)(prog1 * frame.height);
                ovr_x = 0;
                ovr_y = (int)(frame.height - prog0 * (this.obs_frame.height + 2 * frame.height));
            }
            else if (direction == ObscuredWipeTransitionDirection.South)
            {
                src_x = 0;
                src_y = (int)(prog0 * frame.height);
                ovr_x = 0;
                ovr_y = (int)(frame.height - prog1 * (this.obs_frame.height + 2 * frame.height));
            }
            else if (direction == ObscuredWipeTransitionDirection.East)
            {
                src_x = (int)(prog0 * frame.width);
                src_y = 0;
                ovr_x = (int)(frame.width - prog1 * (this.obs_frame.width + 2 * frame.width));
                ovr_y = 0;
            }
            else
            {
                src_x = (int)(prog1 * frame.width);
                src_y = 0;
                ovr_x = (int)(frame.width - prog0 * (this.obs_frame.width + 2 * frame.width));
                ovr_y = 0;
            }

            if (this.direction == ObscuredWipeTransitionDirection.East || this.direction == ObscuredWipeTransitionDirection.South)
            {
                Frame tmpFrame = from_frame;
                from_frame = to_frame;
                to_frame   = tmpFrame;
            }

            Frame.copy_rect(frame, 0, 0, from_frame, 0, 0, from_frame.width, from_frame.height, DMDBlendMode.DMDBlendModeCopy);
            Frame.copy_rect(frame, src_x, src_y, to_frame, src_x, src_y, from_frame.width - src_x, from_frame.height - src_y, DMDBlendMode.DMDBlendModeCopy);
            Frame.copy_rect(frame, ovr_x, ovr_y, obs_frame, 0, 0, this.obs_frame.width, this.obs_frame.height, this.composite_op);

            return(frame);
        }
Ejemplo n.º 2
0
        public override Frame next_frame()
        {
            this.tick += 1;

            if ((this.tick % 6) != 0)
            {
                return(this.buffer);
            }

            Frame.copy_rect(this.buffer, 0, 0, this.frame, this.origin.First, this.origin.Second, this.buffer.width, this.buffer.height);
            if (this.bounce && (this.origin.First + this.buffer.width + this.translate.First > this.frame.width) ||
                this.origin.First + this.translate.First < 0)
            {
                this.translate = new Pair <int, int>(this.translate.First * -1, this.translate.Second);
            }

            if (this.bounce && (this.origin.Second + this.buffer.height + this.translate.Second > this.frame.height) ||
                (this.origin.Second + this.translate.Second < 0))
            {
                this.translate = new Pair <int, int>(this.translate.First, this.translate.Second * -1);
            }

            this.origin = new Pair <int, int>(this.origin.First + this.translate.First, this.origin.Second + this.translate.Second);
            return(this.buffer);
        }
Ejemplo n.º 3
0
        public override Frame transition_frame(Frame from_frame, Frame to_frame)
        {
            Frame  frame = new Frame(from_frame.width, from_frame.height);
            int    dst_x = 0;
            int    dst_y = 0;
            int    width, height;
            double prog = this.progress;

            if (this.in_out == false)
            {
                prog = 1.0 - prog;
            }

            if (this.direction == ExpandTransitionDirection.Vertical)
            {
                dst_x = 0;
                dst_y = Convert.ToInt32((frame.height / 2 - prog * (frame.height / 2)));

                width  = frame.width;
                height = Convert.ToInt32(prog * frame.height);
            }
            else
            {
                dst_x = Convert.ToInt32((frame.width / 2 - prog * (frame.width / 2)));
                dst_y = 0;

                width  = Convert.ToInt32(prog * frame.width);
                height = frame.height;
            }
            Frame.copy_rect(frame, dst_x, dst_y, to_frame, dst_x, dst_y, width, height, DMDBlendMode.DMDBlendModeCopy);
            return(frame);
        }
Ejemplo n.º 4
0
        public Frame subframe(int x, int y, int width, int height)
        {
            // Generates a new frame based on a sub rectangle of this frame
            Frame subframe = new Frame(width, height);

            Frame.copy_rect(subframe, 0, 0, this, x, y, width, height, DMDBlendMode.DMDBlendModeCopy);
            return(subframe);
        }
Ejemplo n.º 5
0
        public override Frame transition_frame(Frame from_frame, Frame to_frame)
        {
            Frame frame  = new Frame(from_frame.width, from_frame.height);
            int   dst_x  = 0;
            int   dst_y  = 0;
            int   dst_x1 = 0;
            int   dst_y1 = 0;

            double prog  = this.progress;
            double prog1 = this.progress;

            if (this.in_out == true)
            {
                prog = 1.0 - prog;
            }
            else
            {
                prog1 = 1.0 - prog1;
            }

            if (direction == PushTransitionDirection.North)
            {
                dst_x  = 0;
                dst_y  = (int)(prog * frame.height);
                dst_x1 = 0;
                dst_y1 = (int)(-prog1 * frame.height);
            }
            else if (direction == PushTransitionDirection.South)
            {
                dst_x  = 0;
                dst_y  = (int)(-prog * frame.height);
                dst_x1 = 0;
                dst_y1 = (int)(prog1 * frame.height);
            }
            else if (direction == PushTransitionDirection.East)
            {
                dst_x  = (int)(-prog * frame.width);
                dst_y  = 0;
                dst_x1 = (int)(prog1 * frame.width);
                dst_y1 = 0;
            }
            else if (direction == PushTransitionDirection.West)
            {
                dst_x  = (int)(prog * frame.width);
                dst_y  = 0;
                dst_x1 = (int)(-prog1 * frame.width);
                dst_y1 = 0;
            }
            Frame.copy_rect(frame, dst_x, dst_y, to_frame, 0, 0, from_frame.width, from_frame.height, DMDBlendMode.DMDBlendModeCopy);
            Frame.copy_rect(frame, dst_x1, dst_y1, from_frame, 0, 0, from_frame.width, from_frame.height, DMDBlendMode.DMDBlendModeCopy);

            return(frame);
        }
Ejemplo n.º 6
0
        public override Frame transition_frame(Frame from_frame, Frame to_frame)
        {
            Frame  frame = new Frame(from_frame.width, from_frame.height);
            double prog0 = this.progress;
            double prog1 = this.progress;

            int src_x = 0;
            int src_y = 0;

            if (this.in_out == false)
            {
                prog0 = 1.0 - prog0;
            }
            else
            {
                prog1 = 1.0 - prog1;
            }

            if (this.direction == WipeTransitionDirection.North)
            {
                src_x = 0;
                src_y = (int)(prog1 * frame.height);
            }
            else if (this.direction == WipeTransitionDirection.South)
            {
                src_x = 0;
                src_y = (int)(prog0 * frame.height);
            }
            else if (this.direction == WipeTransitionDirection.East)
            {
                src_x = (int)(prog0 * frame.width);
                src_y = 0;
            }
            else if (this.direction == WipeTransitionDirection.East)
            {
                src_x = (int)(prog1 * frame.width);
                src_y = 0;
            }
            if (this.direction == WipeTransitionDirection.East || this.direction == WipeTransitionDirection.South)
            {
                Frame tmpFrame = from_frame;
                from_frame = to_frame;
                to_frame   = tmpFrame;
            }
            Frame.copy_rect(frame, 0, 0, from_frame, 0, 0, from_frame.width, from_frame.height, DMDBlendMode.DMDBlendModeCopy);
            Frame.copy_rect(frame, src_x, src_y, to_frame, src_x, src_y, from_frame.width, from_frame.height, DMDBlendMode.DMDBlendModeCopy);

            return(frame);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Composites the next frame of this layer onto the given target buffer.
        /// Called by DisplayController.update()
        /// Generally subclasses should not override this method. Implement next_frame() instead
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public virtual Frame composite_next(Frame target)
        {
            Frame src = next_frame();

            if (src != null)
            {
                if (transition != null)
                {
                    src = this.transition.next_frame(target, src);
                }
                // src not all zeroes
                // Target = all zeros here
                Frame.copy_rect(target, (int)(this.target_x + this.target_x_offset), (int)(this.target_y + this.target_y_offset), src, 0, 0, src.width, src.height, this.composite_op);
            }
            return(src);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Uses this fonts characters to draw the given string at the given position
        /// </summary>
        public void draw(Frame frame, string text, int x, int y)
        {
            foreach (char ch in text)
            {
                int char_offset = (int)ch - (int)' ';
                if (char_offset < 0 || char_offset >= 96)
                {
                    continue;
                }

                int char_x = this.char_size * (char_offset % 10);
                int char_y = this.char_size * (char_offset / 10);
                int width  = this.char_widths[(int)char_offset];
                Frame.copy_rect(frame, x, y, this.bitmap, char_x, char_y, width, this.char_size, this.composite_op);
                x += width + this.tracking;
            }
        }
Ejemplo n.º 9
0
        public override Frame transition_frame(Frame from_frame, Frame to_frame)
        {
            // Calculate the frame index
            int index = 0;

            if (this.in_out == true)
            {
                index = (int)(this.progress * (frames.Count - 1));
            }
            else
            {
                index = (int)((1.0 - this.progress) * (frames.Count - 1));
            }

            // Subtract the respective reference frame from each of the input frames
            from_frame = from_frame.copy();
            Frame.copy_rect(from_frame, 0, 0, this.frames[index], 0, 0, this.width, this.height, DMDBlendMode.DMDBlendModeSubtract);
            to_frame = to_frame.copy();
            Frame.copy_rect(to_frame, 0, 0, this.frames[frames.Count - (index + 1)], 0, 0, this.width, this.height, DMDBlendMode.DMDBlendModeSubtract);
            // Add the results together
            Frame.copy_rect(from_frame, 0, 0, to_frame, 0, 0, this.width, this.height, DMDBlendMode.DMDBlendModeAdd);
            return(from_frame);
        }