protected override void Invoke_02(string command, params string[] arguments)
        {
            int c = 0;

            if (command == ScenarioWords.COMMAND_画像)
            {
                int index = int.Parse(arguments[c++]);

                if (index < 0 || this.Images.Length <= index)
                {
                    throw new DDError("Bad index: " + index);
                }

                this.ImageIndex    = index;
                this.ImageDrawSize = DDUtils.AdjustRectExterior(this.Images[index].GetSize().ToD2Size(), new D4Rect(0, 0, DDConsts.Screen_W, DDConsts.Screen_H)).Size;
                this.ImageLTStart  = new D2Point(DDConsts.Screen_W - this.ImageDrawSize.W, DDConsts.Screen_H - this.ImageDrawSize.H);
                //this.ImageLTEnd = new D2Point(0, 0); // 固定値なので更新しない。
            }
            else if (command == ScenarioWords.COMMAND_Slide)
            {
                double rate1 = double.Parse(arguments[c++]);
                double rate2 = double.Parse(arguments[c++]);

                rate1 = DoubleTools.ToRange(rate1, 0.0, 1.0);
                rate2 = DoubleTools.ToRange(rate2, 0.0, 1.0);

                this.CurrDrawPosRate = rate1;
                this.DestDrawPosRate = rate2;
            }
            else
            {
                throw new DDError();
            }
        }
Beispiel #2
0
        public static void SetCurtain(int frameMax, double destWhiteLevel, double startWhiteLevel)
        {
            frameMax        = IntTools.ToRange(frameMax, 0, 3600);      // 0 frame - 1 min
            destWhiteLevel  = DoubleTools.ToRange(destWhiteLevel, -1.0, 1.0);
            startWhiteLevel = DoubleTools.ToRange(startWhiteLevel, -1.0, 1.0);

            CurtainQueue.Clear();

            if (frameMax == 0)
            {
                CurtainQueue.Enqueue(destWhiteLevel);
            }
            for (int frmcnt = 0; frmcnt <= frameMax; frmcnt++)
            {
                double wl;

                if (frmcnt == 0)
                {
                    wl = startWhiteLevel;
                }
                else if (frmcnt == frameMax)
                {
                    wl = destWhiteLevel;
                }
                else
                {
                    wl = startWhiteLevel + (destWhiteLevel - startWhiteLevel) * ((double)frmcnt / frameMax);
                }

                CurtainQueue.Enqueue(wl);
            }
        }
Beispiel #3
0
        private void DrawSpectra(Canvas2 frameImg, SpectrumGraph0001 sg, ShadowSpectraData ss)
        {
            using (Graphics g = frameImg.GetGraphics(false))
            {
                int dr_l = 0;
                int dr_t = MARGIN_TB;
                int dr_w = frameImg.GetWidth();
                int dr_h = frameImg.GetHeight() - MARGIN_TB * 2;

                for (int index = 0; index < sg.Spectra.Length; index++)
                {
                    int x = index * (BAR_WIDTH + BAR_INTERVAL) + BAR_INTERVAL;
                    int w = BAR_WIDTH;

                    double v1 = ss.ShadowSpectra[index];
                    double v2 = sg.Spectra[index];

                    v1 *= 0.5;                     // 要調整
                    v2 *= 0.5;                     // 要調整

                    int h1 = DoubleTools.ToInt(v1 * dr_h);
                    int h2 = DoubleTools.ToInt(v2 * dr_h);

                    int y1 = dr_h - h1;
                    int y2 = dr_h - h2;

                    g.FillRectangle(new SolidBrush(Color.FromArgb(128, 255, 255, 255)),
                                    dr_l + x, dr_t + y1, w, h1);
                    g.FillRectangle(new SolidBrush(Color.White),
                                    dr_l + x, dr_t + y2, w, h2);
                }
            }
        }
Beispiel #4
0
        private void ExpandSpan(double rate)
        {
            long sec1 = DateTimeToSec.ToSec(long.Parse(this.DateTimeSt.Text));
            long sec2 = DateTimeToSec.ToSec(long.Parse(this.DateTimeEd.Text));

            long span = sec2 - sec1;

            span = Math.Max(span, 120);             // 2 min <=
            span = DoubleTools.ToLong(span * rate);
            sec1 = sec2 - span;

            long st = DateTimeToSec.ToDateTime(sec1);

            st = Math.Max(st, Ground.I.Period_DateTimeSt);

            sec1 = DateTimeToSec.ToSec(st);
            sec2 = sec1 + span;

            long ed = DateTimeToSec.ToDateTime(sec2);

            ed = Math.Min(ed, Ground.I.Period_DateTimeEd);

            this.DateTimeSt.Text = st.ToString();
            this.DateTimeEd.Text = ed.ToString();
        }
Beispiel #5
0
        private void DrawSpectra(Canvas2 frameImg, SpectrumGraph0001 sg, ShadowSpectraData ss)
        {
            using (Graphics g = frameImg.GetGraphics(false))
            {
                int dr_l = 10;
                int dr_t = 10;
                int dr_w = frameImg.GetWidth() - 20;
                int dr_h = frameImg.GetHeight() - 20;

                for (int index = 0; index < sg.Spectra.Length; index++)
                {
                    int x1 = (((index * 3 + 0) * dr_w) / (sg.Spectra.Length * 3 - 2));
                    int x2 = (((index * 3 + 1) * dr_w) / (sg.Spectra.Length * 3 - 2));
                    int w  = x2 - x1;

                    double v1 = ss.ShadowSpectra[index];
                    double v2 = sg.Spectra[index];

                    v1 /= 2.0;                     // 要調整
                    v2 /= 2.0;                     // 要調整

                    int h1 = DoubleTools.ToInt(v1 * dr_h);
                    int h2 = DoubleTools.ToInt(v2 * dr_h);

                    int y1 = dr_h - h1;
                    int y2 = dr_h - h2;

                    g.FillRectangle(new SolidBrush(Color.FromArgb(128, 255, 255, 255)),
                                    dr_l + x1, dr_t + y1, w, h1);
                    g.FillRectangle(new SolidBrush(Color.White),
                                    dr_l + x1, dr_t + y2, w, h2);
                }
            }
        }
Beispiel #6
0
        public void Perform()
        {
            DDUtils.SetMouseDispMode(false);
            DDEngine.FreezeInput(10);

            double x     = DDConsts.Screen_W / 2;
            double y     = DDConsts.Screen_H / 2;
            double speed = SPEED_DEF;

            for (; ;)
            {
                DDMouse.UpdateMove();

                x += DDMouse.MoveX * speed;
                y += DDMouse.MoveY * speed;

                DDUtils.ToRange(ref x, 0, DDConsts.Screen_W - 1);
                DDUtils.ToRange(ref y, 0, DDConsts.Screen_H - 1);

                int ix = DoubleTools.ToInt(x);
                int iy = DoubleTools.ToInt(y);

                if (DDKey.IsPound(DX.KEY_INPUT_Z))
                {
                    speed += SPEED_CHANGE_STEP;
                }

                if (DDKey.IsPound(DX.KEY_INPUT_X))
                {
                    speed -= SPEED_CHANGE_STEP;
                }

                DDUtils.ToRange(ref speed, SPEED_MIN, SPEED_MAX);

                if (DDMouse.L.GetInput() == -1)
                {
                    break;
                }

                DDCurtain.DrawCurtain();

                DDPrint.SetPrint(0, 0, 24);
                DDPrint.PrintLine("★マウスカーソルを奪う");
                DDPrint.PrintLine("X=" + x.ToString("F3"));
                DDPrint.PrintLine("Y=" + y.ToString("F3"));
                DDPrint.PrintLine("Speed=" + speed);
                DDPrint.PrintLine("左クリックでメニューに戻る。");
                DDPrint.PrintLine("Zキー:速度上げ");
                DDPrint.PrintLine("Xキー:速度下げ");

                DDDraw.SetBright(new I3Color(255, 128, 0));
                DDDraw.DrawRect(DDGround.GeneralResource.WhiteBox, ix, iy - CROSS_WH / 2, 1, CROSS_WH);
                DDDraw.DrawRect(DDGround.GeneralResource.WhiteBox, ix - CROSS_WH / 2, iy, CROSS_WH, 1);
                DDDraw.Reset();

                DDEngine.EachFrame();
            }
            DDUtils.SetMouseDispMode(true);
        }
Beispiel #7
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        public static void SetBlendAdd(double a)
        {
            int pal = DoubleTools.ToInt(a * 255.0);

            pal = IntTools.ToRange(pal, 0, 255);

            Extra.BlendAdd = pal;
        }
Beispiel #8
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        public static void SetAlpha(double a)
        {
            int pal = DoubleTools.ToInt(a * 255.0);

            pal = IntTools.ToRange(pal, 0, 255);

            Extra.A = pal;
        }
Beispiel #9
0
        public static void Report(double progressRate, BigInteger currentValue, string currValTrailer = "")
        {
            progressRate = DoubleTools.ToRange(progressRate, 0.0, 1.0);

            using (new MSection(Ground.MtxReport))
            {
                File.WriteAllText(Consts.ReportFile, progressRate.ToString("F9") + "\n" + ToExponentNotation(ToString(currentValue)) + currValTrailer, Encoding.ASCII);
            }
            Ground.EvReported.Set();
        }
Beispiel #10
0
        public static double MixVolume(double volume1, double volume2)         // (volume1, volume2): 0.0 - 1.0, ret: 0.0 - 1.0
        {
            volume1 = DoubleTools.ToRange(volume1, 0.0, 1.0);
            volume2 = DoubleTools.ToRange(volume2, 0.0, 1.0);

            double mixedVolume = volume1 * volume2 * 2.0;             // 0.0 - 2.0

            mixedVolume = DoubleTools.ToRange(mixedVolume, 0.0, 1.0);

            return(mixedVolume);
        }
Beispiel #11
0
            public static List <List <Room> > AllocateToOutlineParts(List <Room> rooms, List <LabeledOutline> outlineLabel)
            {
                //bin setting
                List <double> outlinePartAreas = new List <double>();

                foreach (LabeledOutline i in outlineLabel)
                {
                    outlinePartAreas.Add(i.DifferenceArea);
                }

                //stuff setting
                List <double> roomAreas = new List <double>();

                foreach (Room i in rooms)
                {
                    roomAreas.Add(i.Area);
                }


                //bin packing
                List <List <Room> > allocatedRoom = new List <List <Room> >();

                List <List <double> > allocatedAreas  = new List <List <double> >();
                List <List <int> >    allocatingIndex = new List <List <int> >();


                allocatedAreas = DoubleTools.BinPacker.PackToBins(roomAreas, outlinePartAreas, out allocatingIndex);

                //adjusting
                List <List <double> > adjustedArea = new List <List <double> >();

                for (int i = 0; i < allocatedAreas.Count; i++)
                {
                    adjustedArea.Add(DoubleTools.ScaleToNewSum(outlinePartAreas[i], allocatedAreas[i]));
                }


                //roomRenewal
                for (int i = 0; i < allocatingIndex.Count; i++)
                {
                    List <Room> allocatedAtPart = new List <Room>();

                    for (int j = 0; j < allocatingIndex[i].Count; j++)
                    {
                        Room thisIndexRoom = rooms[j];
                        thisIndexRoom.Area = adjustedArea[i][j];
                        allocatedAtPart.Add(thisIndexRoom);
                    }

                    allocatedRoom.Add(allocatedAtPart);
                }

                return(allocatedRoom);
            }
Beispiel #12
0
        public static double MixVolume(double volume1, double volume2)
        {
            volume1 = DoubleTools.ToRange(volume1, 0.0, 1.0);
            volume2 = DoubleTools.ToRange(volume2, 0.0, 1.0);

            double mixedVolume = volume1 * volume2 * 2.0;

            mixedVolume = DoubleTools.ToRange(mixedVolume, 0.0, 1.0);

            return(mixedVolume);
        }
Beispiel #13
0
		//
		//	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
		//
		public static void SetVolume(int handle, double volume)
		{
			volume = DoubleTools.ToRange(volume, 0.0, 1.0);

			int pal = DoubleTools.ToInt(volume * 255.0);

			if (pal < 0 || 255 < pal)
				throw new DDError(); // 2bs

			if (DX.ChangeVolumeSoundMem(pal, handle) != 0) // ? 失敗
				throw new DDError();
		}
Beispiel #14
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        public static void SetBright(double r, double g, double b)
        {
            int pR = DoubleTools.ToInt(r * 255.0);
            int pG = DoubleTools.ToInt(g * 255.0);
            int pB = DoubleTools.ToInt(b * 255.0);

            pR = IntTools.ToRange(pR, 0, 255);
            pG = IntTools.ToRange(pG, 0, 255);
            pB = IntTools.ToRange(pB, 0, 255);

            Extra.Bright = new I3Color(pR, pG, pB);
        }
Beispiel #15
0
        public void MakeVideo(WaveData wave, WorkingDir wd, Action <Canvas2> addImage)
        {
            int frameNum = DoubleTools.ToInt((wave.Length * 1.0 / wave.WavHz) * AudioPicMP4Props.FPS);

            foreach (AbstractVideoImageMaker videoImageMaker in this.VideoImageMakers)
            {
                videoImageMaker.FrameNum = frameNum;
                videoImageMaker.Wave     = wave;
                videoImageMaker.WD       = wd;

                // ----

                videoImageMaker.GetImage = EnumerableTools.Supplier(videoImageMaker.GetImageSequence());
            }
            for (int frame = 0; frame < frameNum; frame++)
            {
                Canvas2 frameImg = new Canvas2(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H);

                foreach (AbstractVideoImageMaker videoImageMaker in this.VideoImageMakers)
                {
                    videoImageMaker.FrameImg = frameImg;
                    videoImageMaker.Frame    = frame;
                    videoImageMaker.Rate     = frame * 1.0 / (frameNum - 1);
                    videoImageMaker.InvRate  = 1.0 - videoImageMaker.Rate;

                    {
                        Canvas2 currFrameImg = videoImageMaker.GetImage();

                        if (currFrameImg != null)
                        {
                            PictureUtils.Paste(frameImg, currFrameImg);
                        }
                    }

                    videoImageMaker.FrameImg = null;
                    videoImageMaker.Frame    = -1;
                    videoImageMaker.Rate     = -1.0;
                    videoImageMaker.InvRate  = -1.0;
                }
                addImage(frameImg);
            }
            foreach (AbstractVideoImageMaker videoImageMaker in this.VideoImageMakers)
            {
                videoImageMaker.FrameNum = -1;
                videoImageMaker.Wave     = null;
                videoImageMaker.WD       = null;

                // ----

                videoImageMaker.GetImage = null;
            }
        }
Beispiel #16
0
        private void EditMode()
        {
            DDEngine.FreezeInput();
            DDUtils.SetMouseDispMode(true);

            for (; ;)
            {
                int lastMouseX = DDMouse.X;
                int lastMouseY = DDMouse.Y;

                DDMouse.UpdatePos();

                if (DDKey.GetInput(DX.KEY_INPUT_E) == 1)
                {
                    break;
                }

                if (1 <= DDKey.GetInput(DX.KEY_INPUT_LSHIFT) || 1 <= DDKey.GetInput(DX.KEY_INPUT_RSHIFT))                 // シフト押下 -> 移動モード
                {
                    if (1 <= DDMouse.L.GetInput())
                    {
                        DDGround.Camera.X -= DDMouse.X - lastMouseX;
                        DDGround.Camera.Y -= DDMouse.Y - lastMouseY;

                        DDUtils.ToRange(ref DDGround.Camera.X, 0.0, this.Map.W * MapTile.WH - DDConsts.Screen_W);
                        DDUtils.ToRange(ref DDGround.Camera.Y, 0.0, this.Map.H * MapTile.WH - DDConsts.Screen_H);

                        DDGround.ICamera.X = DoubleTools.ToInt(DDGround.Camera.X);
                        DDGround.ICamera.Y = DoubleTools.ToInt(DDGround.Camera.Y);
                    }
                }
                else                 // 編集モード
                {
                    GameEdit.EachFrame();
                }

                DrawWall();

                if (GameEdit.DisplayTileFlag)
                {
                    DrawMap();
                }

                GameEdit.Draw();

                DDEngine.EachFrame();
            }
            DDEngine.FreezeInput();
            DDUtils.SetMouseDispMode(false);
        }
Beispiel #17
0
        /// <summary>
        /// PictureBox (pb) 上の座標から、pb.Image 上の座標に変換する。
        /// pb.SizeMode == PictureBoxSizeMode.Zoom であること。
        /// </summary>
        /// <param name="pb"></param>
        /// <param name="pbPt"></param>
        /// <param name="toRangeFlag"></param>
        /// <returns>null == 枠外 || 画像が設定されていない。</returns>
        public static XYPoint getPictureBoxPointToImagePoint(PictureBox pb, XYPoint pbPt, bool toRangeFlag = false)
        {
            Image img = pb.Image;

            if (img == null)
            {
                return(null);
            }

            double w        = (double)img.Width;
            double h        = (double)img.Height;
            double screen_w = (double)pb.Width;
            double screen_h = (double)pb.Height;

            Rect imgRect    = new Rect(w, h);
            Rect screenRect = new Rect(0, 0, screen_w, screen_h);

            imgRect.adjustInside(screenRect);

            double x = pbPt.x;
            double y = pbPt.y;

            x -= imgRect.l;
            y -= imgRect.t;
            x /= imgRect.w;
            y /= imgRect.h;

            if (toRangeFlag)
            {
                x = DoubleTools.toRange(x, 0.0, 1.0);
                y = DoubleTools.toRange(y, 0.0, 1.0);
            }
            else
            {
                if (DoubleTools.isRange(x, 0.0, 1.0) == false)
                {
                    return(null);
                }

                if (DoubleTools.isRange(y, 0.0, 1.0) == false)
                {
                    return(null);
                }
            }
            x *= img.Width;
            y *= img.Height;

            return(new XYPoint(x, y));
        }
Beispiel #18
0
        private void MS_Sort(int colidx)
        {
            SortOrder order = this.MainSheet.Columns[colidx].HeaderCell.SortGlyphDirection;

            if (order == SortOrder.Ascending)
            {
                order = SortOrder.Descending;
            }
            else
            {
                order = SortOrder.Ascending;
            }

            int orderSign = order == SortOrder.Ascending ? 1 : -1;

            if (colidx == 0)
            {
                this.MS_Sort((a, b) => StringTools.CompIgnoreCase(
                                 "" + a.Cells[0].Value,
                                 "" + b.Cells[0].Value
                                 )
                             * orderSign
                             );
            }
            else if (colidx == 1)
            {
                this.MS_Sort((a, b) => StringTools.Comp(
                                 "" + a.Cells[1].Value,
                                 "" + b.Cells[1].Value
                                 )
                             * orderSign
                             );
            }
            else             // colidx == 2
            {
                this.MS_Sort((a, b) => DoubleTools.Comp(
                                 DoubleTools.ToDouble("" + a.Cells[2].Value, 0.0, IntTools.IMAX, 0.0),
                                 DoubleTools.ToDouble("" + b.Cells[2].Value, 0.0, IntTools.IMAX, 0.0)
                                 )
                             * orderSign
                             );
            }
            this.MainSheet.Columns[0].HeaderCell.SortGlyphDirection = SortOrder.None;
            this.MainSheet.Columns[1].HeaderCell.SortGlyphDirection = SortOrder.None;
            this.MainSheet.Columns[2].HeaderCell.SortGlyphDirection = SortOrder.None;

            this.MainSheet.Columns[colidx].HeaderCell.SortGlyphDirection = order;
        }
Beispiel #19
0
        private static void SetBlend(int mode, double a)
        {
            a = DoubleTools.ToRange(a, 0.0, 1.0);

            int pal = DoubleTools.ToInt(a * 255.0);

            if (pal < 0 || 255 < pal)
            {
                throw new GameError();
            }

            if (DX.SetDrawBlendMode(mode, pal) != 0)             // ? 失敗
            {
                throw new GameError();
            }
        }
Beispiel #20
0
        private static void DrawWall()
        {
            DDUtils.Approach(ref WallBokashiRate, WallBokashiRateDest, 0.93);
            DDUtils.Approach(ref WallZRate, WallZRateDest, 0.9);

            // ---

            DDSubScreenUtils.ChangeDrawScreen(WorkScreen);
            DDDraw.DrawBegin(Ground.I.Picture.TitleWall, DDConsts.Screen_W / 2.0, DDConsts.Screen_H / 2.0);
            DDDraw.DrawZoom(WallZRate);
            DDDraw.DrawEnd();
            DX.GraphFilter(WorkScreen.GetHandle(), DX.DX_GRAPH_FILTER_GAUSS, 16, DoubleTools.ToInt(WallBokashiRate * 1000.0));             // 1
            DX.GraphFilter(WorkScreen.GetHandle(), DX.DX_GRAPH_FILTER_GAUSS, 16, DoubleTools.ToInt(WallBokashiRate * 1000.0));             // 2
            DDSubScreenUtils.RestoreDrawScreen();

            DDDraw.DrawSimple(DDPictureLoaders2.Wrapper(WorkScreen), 0, 0);
        }
Beispiel #21
0
        private void ChartMoveMove(Chart chart, int x, int y)
        {
            try
            {
                double aX = chart.ChartAreas[0].AxisX.PixelPositionToValue(x);
                double aY = chart.ChartAreas[0].AxisY.PixelPositionToValue(y);

                long ttSec = DoubleTools.ToLong(aX * 86400.0);
                long dt    = TTCommon.TTSecToDateTime(ttSec);

                this.TTip.SetToolTip(
                    chart,
                    DateTimeUnit.FromDateTime(dt).ToString() + "\n" + aY.ToString("F9")
                    );
            }
            catch
            { }
        }
Beispiel #22
0
        private void MChart_MouseMove(object sender, MouseEventArgs e)
        {
            int x = e.X;
            int y = e.Y;

            if (this.MCMM_LastX == x && this.MCMM_LastY == y)
            {
                return;
            }

            this.MCMM_LastX = x;
            this.MCMM_LastY = y;

            if (this.MChart.ChartAreas.Count == 0)             // ? 未表示
            {
                return;
            }

            if (Ground.I.GrphData == null)             // ? 未表示
            {
                return;
            }

            if (Ground.I.GrphData.Start == -1)             // ? 未表示
            {
                return;
            }

            try
            {
                double aX = this.MChart.ChartAreas[0].AxisX.PixelPositionToValue(x);
                double aY = this.MChart.ChartAreas[0].AxisY.PixelPositionToValue(y);

                long ttSec = DoubleTools.ToLong(aX * 86400.0);
                long dt    = TTCommon.TTSecToDateTime(ttSec);

                this.TTip.SetToolTip(
                    this.MChart,
                    DateTimeUnit.FromDateTime(dt).ToString() + "\n" + aY.ToString("F9")
                    );
            }
            catch
            { }
        }
Beispiel #23
0
        private static void SetBright(double cR, double cG, double cB)         // (cR, cG, cB): 0.0 - 1.0 == 暗~明
        {
            // 0 - 255 と間違えている etc.
            //
            if (cR < -0.5 || 1.5 < cR)
            {
                throw new GameError();
            }
            if (cG < -0.5 || 1.5 < cG)
            {
                throw new GameError();
            }
            if (cB < -0.5 || 1.5 < cB)
            {
                throw new GameError();
            }

            cR = DoubleTools.ToRange(cR, 0.0, 1.0);
            cG = DoubleTools.ToRange(cG, 0.0, 1.0);
            cB = DoubleTools.ToRange(cB, 0.0, 1.0);

            int palR = DoubleTools.ToInt(cR * 255.0);
            int palG = DoubleTools.ToInt(cG * 255.0);
            int palB = DoubleTools.ToInt(cB * 255.0);

            if (palR < 0 || 255 < palR)
            {
                throw new GameError();
            }
            if (palG < 0 || 255 < palG)
            {
                throw new GameError();
            }
            if (palB < 0 || 255 < palB)
            {
                throw new GameError();
            }

            if (DX.SetDrawBright(palR, palG, palB) != 0)             // ? 失敗
            {
                throw new GameError();
            }
        }
Beispiel #24
0
        public override IEnumerable <Canvas2> GetImageSequence()
        {
            ShadowSpectraData ss = new ShadowSpectraData();

            for (; ;)
            {
                this.Wave.SetWavPart(DoubleTools.ToInt((this.Frame * 1.0 / AudioPicMP4Props.FPS + AudioPicMP4Props.AUDIO_DELAY_SEC) * this.Wave.WavHz));
                SpectrumGraph0001 sg = new SpectrumGraph0001(hz => this.Wave.GetSpectrum(hz));
                ss.Projection(sg.Spectra);
                int w = sg.Spectra.Length * (BAR_WIDTH + BAR_INTERVAL) + BAR_INTERVAL;

                Canvas2 frameImg = new Canvas2(w, AudioPicMP4Props.VIDEO_H);

                PictureUtils.Fill(frameImg, Color.Transparent);

                this.DrawSpectra(frameImg, sg, ss);

                yield return(frameImg);
            }
        }
Beispiel #25
0
        private void Test01_a(string rFile, string wFile)
        {
            WaveData wave = new WaveData(rFile);

            using (CsvFileWriter writer = new CsvFileWriter(wFile))
            {
                for (double sec = 0.0; sec < wave.Length * 1.0 / wave.WavHz; sec += 0.1)
                {
                    Console.WriteLine("sec: " + sec);                     // test

                    wave.SetWavPart(DoubleTools.ToInt(sec * wave.WavHz));

                    for (int hz = 30; hz < 4200; hz += 10)
                    {
                        writer.WriteCell(wave.GetSpectrum(hz).ToString("F9"));
                    }
                    writer.EndRow();
                }
            }
        }
Beispiel #26
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        public static void DrawCurtain(double whiteLevel = -1.0)
        {
            if (whiteLevel == 0.0)
            {
                return;
            }

            whiteLevel = DoubleTools.ToRange(whiteLevel, -1.0, 1.0);

            if (whiteLevel < 0.0)
            {
                DDDraw.SetAlpha(-whiteLevel);
                DDDraw.SetBright(0.0, 0.0, 0.0);
            }
            else
            {
                DDDraw.SetAlpha(whiteLevel);
            }

            DDDraw.DrawRect(DDGround.GeneralResource.WhiteBox, 0, 0, DDConsts.Screen_W, DDConsts.Screen_H);
            DDDraw.Reset();
        }
Beispiel #27
0
        public override IEnumerable <Canvas2> GetImageSequence()
        {
            ShadowSpectraData ssL = new ShadowSpectraData();
            ShadowSpectraData ssR = new ShadowSpectraData();

            for (; ;)
            {
                this.Wave.SetWavPart(DoubleTools.ToInt((this.Frame * 1.0 / AudioPicMP4Props.FPS + AudioPicMP4Props.AUDIO_DELAY_SEC) * this.Wave.WavHz));
                SpectrumGraph0001 sgL = new SpectrumGraph0001(hz => this.Wave.GetSpectrum_L(hz))
                {
                    R1 = 0.5, R2 = 0.5
                };
                SpectrumGraph0001 sgR = new SpectrumGraph0001(hz => this.Wave.GetSpectrum_R(hz))
                {
                    R1 = 0.5, R2 = 0.5
                };
                ssL.Projection(sgL.Spectra);
                ssR.Projection(sgR.Spectra);
                int w = sgL.Spectra.Length * (BAR_WIDTH + BAR_INTERVAL) + BAR_INTERVAL;

                Canvas2 frameImg_L = new Canvas2(w, AudioPicMP4Props.VIDEO_H);
                Canvas2 frameImg_R = new Canvas2(w, AudioPicMP4Props.VIDEO_H);

                PictureUtils.Fill(frameImg_L, Color.Transparent);
                PictureUtils.Fill(frameImg_R, Color.Transparent);

                this.DrawSpectra(frameImg_L, sgL, ssL, Color.FromArgb(255, 255, 200), false);
                this.DrawSpectra(frameImg_R, sgR, ssR, Color.FromArgb(200, 255, 255), true);

                Canvas2 frameImg = new Canvas2(w * 2, AudioPicMP4Props.VIDEO_H);

                PictureUtils.Paste(frameImg, frameImg_L, 0, 0, w, AudioPicMP4Props.VIDEO_H);
                PictureUtils.Paste(frameImg, frameImg_R, w, 0, w, AudioPicMP4Props.VIDEO_H);

                yield return(frameImg);
            }
        }
Beispiel #28
0
        public static void MusicFade(int frameMax, double destVRate, double startVRate)
        {
            if (CurrDestMusic == null)
            {
                return;
            }

            frameMax   = IntTools.ToRange(frameMax, 1, 3600);           // 1 frame - 1 min
            destVRate  = DoubleTools.ToRange(destVRate, 0.0, 1.0);
            startVRate = DoubleTools.ToRange(startVRate, 0.0, 1.0);

            for (int frmcnt = 0; frmcnt <= frameMax; frmcnt++)
            {
                double vRate;

                if (frmcnt == 0)
                {
                    vRate = startVRate;
                }
                else if (frmcnt == frameMax)
                {
                    vRate = destVRate;
                }
                else
                {
                    vRate = startVRate + ((destVRate - startVRate) * frmcnt) / frameMax;
                }

                PlayList.Enqueue(CreatePI('V', CurrDestMusic, false, false, vRate));
            }
            CurrDestMusicVolumeRate = destVRate;

            if (destVRate == 0.0)             // ? フェード目標音量ゼロ -> 曲停止
            {
                MusicStop();
            }
        }
Beispiel #29
0
        public void Main01()
        {
            FileTools.Delete(W_DIR);
            FileTools.CreateDir(W_DIR);

            this.SpData = new SpectrumData(Path.Combine(R_DIR, "Spectrum.csv"));

            while (this.Frame < this.SpData.Rows.Length)
            {
                double[] row = this.SpData.Rows[this.Frame];

                DDCurtain.DrawCurtain();
                DDPrint.SetPrint(0, 20, 23);

                for (int index = 0; index < 45; index++)
                {
                    double lv = 0.0;

                    for (int c = 0; c < 2; c++)
                    {
                        lv += row[index * 2 + c];
                    }

                    int iLv = DoubleTools.ToInt(lv * 145.0);

                    for (int c = 0; c < iLv; c++)
                    {
                        DDPrint.Print("*");
                    }

                    DDPrint.PrintRet();
                }

                this.MG_EachFrame();
            }
        }
Beispiel #30
0
        //
        //	copied the source file by https://github.com/stackprobe/Factory/blob/master/SubTools/CopyLib.c
        //
        private static void DrawPic_Main(DDPicture picture, ILayoutInfo layout)
        {
            // app > @ enter DrawPic

            // < app

            if (Extra.A != -1)
            {
                SetBlend(DX.DX_BLENDMODE_ALPHA, Extra.A);
            }
            else if (Extra.BlendAdd != -1)
            {
                SetBlend(DX.DX_BLENDMODE_ADD, Extra.BlendAdd);
            }
            else if (Extra.BlendInv)
            {
                SetBlend(DX.DX_BLENDMODE_INVSRC, 255);
            }

            if (Extra.Mosaic)
            {
                DX.SetDrawMode(DX.DX_DRAWMODE_NEAREST);
            }
            if (Extra.Bright.R != -1)
            {
                SetBright(Extra.Bright.R, Extra.Bright.G, Extra.Bright.B);
            }

            {
                FreeInfo u = layout as FreeInfo;

                if (u != null)
                {
                    // ? 失敗
                    if (
                        Extra.IntPos ?
                        DX.DrawModiGraph(
                            DoubleTools.ToInt(u.LTX),
                            DoubleTools.ToInt(u.LTY),
                            DoubleTools.ToInt(u.RTX),
                            DoubleTools.ToInt(u.RTY),
                            DoubleTools.ToInt(u.RBX),
                            DoubleTools.ToInt(u.RBY),
                            DoubleTools.ToInt(u.LBX),
                            DoubleTools.ToInt(u.LBY),
                            picture.GetHandle(),
                            1
                            )
                        != 0
                                                :
                        DX.DrawModiGraphF(
                            (float)u.LTX,
                            (float)u.LTY,
                            (float)u.RTX,
                            (float)u.RTY,
                            (float)u.RBX,
                            (float)u.RBY,
                            (float)u.LBX,
                            (float)u.LBY,
                            picture.GetHandle(),
                            1
                            )
                        != 0
                        )
                    {
                        if (Extra.IgnoreError == false)
                        {
                            throw new DDError();
                        }
                    }
                    goto endDraw;
                }
            }

            {
                RectInfo u = layout as RectInfo;

                if (u != null)
                {
                    // ? 失敗
                    if (
                        Extra.IntPos ?
                        DX.DrawExtendGraph(
                            DoubleTools.ToInt(u.L),
                            DoubleTools.ToInt(u.T),
                            DoubleTools.ToInt(u.R),
                            DoubleTools.ToInt(u.B),
                            picture.GetHandle(),
                            1
                            )
                        != 0
                                                :
                        DX.DrawExtendGraphF(
                            (float)u.L,
                            (float)u.T,
                            (float)u.R,
                            (float)u.B,
                            picture.GetHandle(),
                            1
                            )
                        != 0
                        )
                    {
                        if (Extra.IgnoreError == false)
                        {
                            throw new DDError();
                        }
                    }
                    goto endDraw;
                }
            }

            {
                SimpleInfo u = layout as SimpleInfo;

                if (u != null)
                {
                    // ? 失敗
                    if (
                        Extra.IntPos ?
                        DX.DrawGraph(
                            DoubleTools.ToInt(u.X),
                            DoubleTools.ToInt(u.Y),
                            picture.GetHandle(),
                            1
                            )
                        != 0
                                                :
                        DX.DrawGraphF(
                            (float)u.X,
                            (float)u.Y,
                            picture.GetHandle(),
                            1
                            )
                        != 0
                        )
                    {
                        if (Extra.IgnoreError == false)
                        {
                            throw new DDError();
                        }
                    }
                    goto endDraw;
                }
            }

            throw new DDError();             // ? 不明なレイアウト
endDraw:

            if (Extra.A != -1 || Extra.BlendAdd != -1 || Extra.BlendInv)
            {
                ResetBlend();
            }
            if (Extra.Mosaic)
            {
                DX.SetDrawMode(DX.DX_DRAWMODE_BILINEAR);
            }
            if (Extra.Bright.R != -1)
            {
                ResetBright();
            }

            // app > @ leave DrawPic

            // < app
        }