Пример #1
0
        public Subtitle(Danmaku danmaku, Display display, float offset = 0)
        {
            Danmaku = danmaku;
            Display = display;
            Offset  = offset;

            Start          = SetStart();
            End            = SetEnd();
            Color          = SetColor();
            Position       = SetPosition();
            StartMarkup    = SetStartMarkup();
            EndMarkup      = SetEndMarkup();
            ColorMarkup    = SetColorMarkup();
            BorderMarkup   = SetBorderMarkup();
            FontSizeMarkup = SetFontSizeMarkup();
            StyleMarkup    = SetStyleMarkup();
            LayerMarkup    = SetLayerMarkup();
            ContentMarkup  = SetContentMarkup();
            Text           = SetText();
        }
Пример #2
0
        public void Create(long avid, long cid, Config subtitleConfig, string assFile)
        {
            // 弹幕转换
            var biliDanmakus = DanmakuProtobuf.GetAllDanmakuProto(avid, cid);

            // 按弹幕出现顺序排序
            biliDanmakus.Sort((x, y) => { return(x.Progress.CompareTo(y.Progress)); });

            var danmakus = new List <Danmaku>();

            foreach (var biliDanmaku in biliDanmakus)
            {
                var danmaku = new Danmaku
                {
                    // biliDanmaku.Progress单位是毫秒,所以除以1000,单位变为秒
                    Start     = biliDanmaku.Progress / 1000.0f,
                    Style     = mapping[biliDanmaku.Mode],
                    Color     = (int)biliDanmaku.Color,
                    Commenter = biliDanmaku.MidHash,
                    Content   = biliDanmaku.Content,
                    SizeRatio = 1.0f * biliDanmaku.Fontsize / normalFontSize
                };

                danmakus.Add(danmaku);
            }

            // 弹幕预处理
            Producer producer = new Producer(config, danmakus);

            producer.StartHandle();

            // 字幕生成
            var keepedDanmakus = producer.KeepedDanmakus;
            var studio         = new Studio(subtitleConfig, keepedDanmakus);

            studio.StartHandle();
            studio.CreateAssFile(assFile);
        }
Пример #3
0
        public ScrollDisplay(Config config, Danmaku danmaku) : base()
        {
            //Console.WriteLine("ScrollDisplay constructor.");

            Config    = config;
            Danmaku   = danmaku;
            LineIndex = 0;

            IsScaled  = SetIsScaled();
            FontSize  = SetFontSize();
            MaxLength = SetMaxLength();
            Width     = SetWidth();
            Height    = SetHeight();

            Horizontal = SetHorizontal();
            Vertical   = SetVertical();

            Distance = SetDistance();
            Speed    = SetSpeed();

            Duration = SetDuration();
            Leave    = SetLeave();
        }
Пример #4
0
 public BottomDisplay(Config config, Danmaku danmaku) : base(config, danmaku)
 {
     //Console.WriteLine("BottomDisplay constructor.");
 }