private static Canvas2 BlurOnce(Canvas2 canvas, int phase) { int w = canvas.GetWidth(); int h = canvas.GetHeight(); Canvas2 dest = new Canvas2(w, h); using (Graphics g = dest.GetGraphics()) { g.DrawImage(canvas.GetImage(), 0, 0); for (int count = 0; count < 8; count++) { int direction = (count + phase) % 8; int xa = DIRECTIONS[direction, 0]; int ya = DIRECTIONS[direction, 1]; g.DrawImage( canvas.GetImage(), new Rectangle(xa, ya, w, h), 0, 0, w, h, GraphicsUnit.Pixel, GetIA_Alpha(1.0 / (2.0 + count)) ); } } return(dest); }
public PictureData(Canvas2 discJacket, int frame_w, int frame_h) { if (discJacket == null) { throw new Exception("discJacket is null"); } // g.DrawImage で「縮小」すると座標を整数にキャストしたようになるで、常に拡大されるように frame_wh より少し小さくする。 { int targ_w = frame_w - MARGIN; int targ_h = frame_h - MARGIN; int w = targ_w; int h = (int)(discJacket.GetHeight() * targ_w * 1.0 / discJacket.GetWidth()); if (targ_h < h) { w = (int)(discJacket.GetWidth() * targ_h * 1.0 / discJacket.GetHeight()); h = targ_h; } discJacket = PictureUtils.Expand(discJacket, w, h); } this.DiscJacket = discJacket; this.BluredDiscJacket = PictureUtils.Blur(discJacket, BLUR_DEPTH); PictureUtils.Filter_Color(this.BluredDiscJacket, Color.Black, WALL_DARKNESS_RATE); this.MarginedDiscJacket = PictureUtils.PutMargin(discJacket, MARGIN, MARGIN); this.Frame = new Canvas2(frame_w, frame_h); }
public static void Paste(Canvas2 dest, Canvas2 src) { using (Graphics g = dest.GetGraphics(false)) { g.DrawImage(src.GetImage(), 0, 0, dest.GetWidth(), dest.GetHeight()); } }
public static void Paste(Canvas2 dest, Canvas2 src, double l, double t, double w, double h) { #if true const double MARGIN = 10; if (w < src.GetWidth() + MARGIN || h < src.GetHeight() + MARGIN) { src = Expand(src, (int)(w * 0.99), (int)(h * 0.99)); } using (Graphics g = dest.GetGraphics()) { g.DrawImage(src.GetImage(), (float)l, (float)t, (float)w, (float)h); } #else // 試していない。 using (Graphics g = dest.GetGraphics()) { g.DrawImage( src.GetImage(), new PointF[] { new PointF((float)l, (float)t), new PointF((float)(l + w), (float)t), new PointF((float)l, (float)(t + h)), } ); } #endif }
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); } } }
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); } } }
public static void Fill(Canvas2 canvas, Color color) { using (Graphics g = canvas.GetGraphics()) { g.FillRectangle(new SolidBrush(color), 0, 0, canvas.GetWidth(), canvas.GetHeight()); } }
void Canvas2_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); Canvas2.CaptureMouse(); //_last = e.GetPosition(canvas); _last = e.GetPosition(this); isDragged = true; }
private double R2; // def: 0.1 public Background0001(string discJacketFile, double r1 = 0.2, double r2 = 0.1) { this.DiscJacket = new Canvas2(discJacketFile); this.BluredDiscJacket = PictureUtils.Blur(this.DiscJacket, 5); // 要調整 this.MarginedDiscJacket = PictureUtils.PutMargin(this.DiscJacket); this.R1 = r1; this.R2 = r2; }
public void LevelCompelte() { LevelComplete.SetActive(false); Canvas1.SetActive(false); Canvas2.SetActive(true); GameManager._instance.DesTroyer = true; GameManager._instance.DestroyerLevel(); }
public static Canvas2 Blur(Canvas2 canvas, int depth) { for (int count = 0; count < depth; count++) { canvas = BlurOnce(canvas, count); } return(canvas); }
public static Canvas2 Expand(Canvas2 canvas, int w, int h) { Canvas2 dest = new Canvas2(w, h); using (Graphics g = dest.GetGraphics()) { g.DrawImage(canvas.GetImage(), 0, 0, w, h); } return(dest); }
public static Canvas2 PutMargin(Canvas2 canvas, int xMargin, int yMargin) { Canvas2 dest = new Canvas2(canvas.GetWidth() + xMargin * 2, canvas.GetHeight() + yMargin * 2); using (Graphics g = dest.GetGraphics(false)) { g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, dest.GetWidth(), dest.GetHeight()); g.DrawImage(canvas.GetImage(), xMargin, yMargin, canvas.GetWidth(), canvas.GetHeight()); } return(dest); }
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; } }
private void Draw(int index) { Canvas2 discJacket = this.DiscJackets[index]; double rate = this.LeftToRight ? this.Rate : this.InvRate; double l = this.DrawPos1.X + (this.DrawPos2.X - this.DrawPos1.X) * rate; double t = this.DrawPos1.Y + (this.DrawPos2.Y - this.DrawPos1.Y) * rate; double w = this.DrawSize.W; double h = this.DrawSize.H; PictureUtils.Paste(this.FrameImg, discJacket, l, t, w, h); }
private void Awake() { //AudioListener.pause = false; // DontDestroyOnLoad(this.gameObject); //PlayerPrefs.DeleteAll(); if (_instance == null) { _instance = this; } Canvas1.SetActive(false); Canvas2.SetActive(true); GetCup(); }
public static Canvas2 PutMargin(Canvas2 canvas) { const int MARGIN = 10; Canvas2 dest = new Canvas2(canvas.GetWidth() + MARGIN * 2, canvas.GetHeight() + MARGIN * 2); using (Graphics g = dest.GetGraphics(false)) { g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, dest.GetWidth(), dest.GetHeight()); g.DrawImage(canvas.GetImage(), MARGIN, MARGIN, canvas.GetWidth(), canvas.GetHeight()); } return(dest); }
public static void Filter_Color(Canvas2 canvas, Color color, double a) { Canvas2 maskImg = new Canvas2(canvas.GetWidth(), canvas.GetHeight()); using (Graphics g = maskImg.GetGraphics(false)) { g.FillRectangle(new SolidBrush(color), 0, 0, maskImg.GetWidth(), maskImg.GetHeight()); } using (Graphics g = canvas.GetGraphics()) { g.DrawImage( maskImg.GetImage(), new Rectangle(0, 0, canvas.GetWidth(), canvas.GetHeight()), 0, 0, maskImg.GetWidth(), maskImg.GetHeight(), GraphicsUnit.Pixel, GetIA_Alpha(a) ); } }
private void OnTimedEvent(Object source, ElapsedEventArgs e) { Canvas2.Dispatcher.Invoke(() => { if (DateTime.Now - lastWeatherCall > TimeSpan.FromMinutes(5)) { weather.Update().Wait(); lastWeatherCall = DateTime.Now; } Canvas2.percentages[0] = 1 - storage.GetPercentFree() / 100.0; Canvas2.percentages[1] = 1 - processor.GetUtilizationPercent() / 100.0; Canvas2.percentages[2] = 1 - memory.GetUtilizationPercent() / 100.0; Canvas2.percentages[3] = battery.GetBatteryPercentage() / 100.0; Canvas2.temperature = Math.Round((weather.temperature * 9 / 5.0) + 32); Canvas2.pressure = Math.Round(weather.pressure); Canvas2.humidity = Math.Round(weather.humidity); Canvas2.InvalidateVisual(); }); }
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); } }
public static void Filter(Canvas2 canvas, Color color, double a) { int w = canvas.GetWidth(); int h = canvas.GetHeight(); Canvas2 mask = new Canvas2(w, h); using (Graphics g = mask.GetGraphics(false)) { g.FillRectangle(new SolidBrush(color), 0, 0, w, h); } using (Graphics g = canvas.GetGraphics()) { g.DrawImage( mask.GetImage(), new Rectangle(0, 0, w, h), 0, 0, w, h, GraphicsUnit.Pixel, GetIA_Alpha(a) ); } }
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); } }
// map public void LoadMapLevel() { //set the first check instance flag PlayerPrefs.SetInt("First", 10); DestroyFlagOutMap(); PlayerPrefs.SetInt("CheckFlag", 1); ScrollSnapRect._instance.Setpage(); //UIManager._instance.CountFlag++; //banner destroy //Demo._instance.hideBanner(); // UIManager._instance.CountBigBannerShow = 0; //// if (Saving) { PlayerPrefsX.SetVector3("PosFlag", UIManager._instance.posSaveDiamond); // Debug.Log(UIManager._instance.CountFlag); Saving = false; } MenuScripts._instance.levelTextToPlay.text = "Play level: " + PlayerPrefs.GetInt("ValueMaxLevel"); //SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().name); ScrollSnapRect._instance.CheckScroll = true; GetLevel(); diamondText.text = "" + PlayerPrefs.GetInt("DiamondTotal"); ChangeColorCamera._instance.SwitchColor(9); ChangeColorCamera._instance.zoomIn = true; UIManager._instance.GameOverShownPanel.SetActive(false); GameManager._instance.DesTroyer = true; GameManager._instance.DestroyerLevel(); Canvas1.SetActive(false); Canvas2.SetActive(true); DisableEverything(); }
private void AdjustJacketSize(string wdJacketFile, string wFile) { // memo: バイニリア補間(DX_DRAWMODE_BILINEAR)で綺麗に縮小できるのはアルゴリズム上2分の1サイズまでなので、 // らしい。--https://dxlib.xsrv.jp/cgi/patiobbs/patio.cgi?mode=view&no=4676 // -> ジャケットサイズの上限を画面サイズの2倍弱にする。 Ground.I.Logger.Info("ジャケット画像のサイズを矯正します。"); Canvas2 canvas = new Canvas2(wdJacketFile); Ground.I.Logger.Info("ジャケット_W.1 = " + canvas.GetWidth()); Ground.I.Logger.Info("ジャケット_H.1 = " + canvas.GetHeight()); if (canvas.GetWidth() < Consts.JACKET_W_MIN) { throw new Exception("ジャケット画像の「幅」が小さすぎます。"); } if (canvas.GetHeight() < Consts.JACKET_H_MIN) { throw new Exception("ジャケット画像の「高さ」が小さすぎます。"); } if ( Consts.JACKET_W_MAX < canvas.GetWidth() || Consts.JACKET_H_MAX < canvas.GetHeight() ) { double xr_w = Consts.JACKET_W_MAX / canvas.GetWidth(); double xr_h = Consts.JACKET_H_MAX / canvas.GetHeight(); if (xr_w < xr_h) // ? 高さより幅の方をより小さくする。-> 幅に合わせる。 { Ground.I.Logger.Info("幅(の上限値)に合わせる!"); this.Batch( Consts.ImgTools_FILE + " /rf " + wdJacketFile + " /wf " + wFile + " /EW " + Consts.JACKET_W_MAX, ProcMain.SelfDir ); } else // 高さに合わせる。 { Ground.I.Logger.Info("高さ(の上限値)に合わせる!"); this.Batch( Consts.ImgTools_FILE + " /rf " + wdJacketFile + " /wf " + wFile + " /EH " + Consts.JACKET_H_MAX, ProcMain.SelfDir ); } } else // サイズ変更不要 { Ground.I.Logger.Info("サイズ変更不要!"); this.Batch( Consts.ImgTools_FILE + " /rf " + wdJacketFile + " /wf " + wFile, ProcMain.SelfDir ); } // 確認のため canvas = new Canvas2(wFile); Ground.I.Logger.Info("ジャケット_W.2 = " + canvas.GetWidth()); Ground.I.Logger.Info("ジャケット_H.2 = " + canvas.GetHeight()); }
public void DrawTo(PictureData picture, int frame, int frameNum) { double sec = frame * 1.0 / VideoData.FPS; this.Wave.SetWavPart((int)((sec + AUDIO_DELAY_SEC) * this.Wave.WavHz)); List <double> spectra = new List <double>(); int hz = 10; for (int c = 1; c <= 9; c++) { for (int d = 0; d < 10; d++) { double spectrum = 0.0; for (int i = 0; i < c; i++) { spectrum = Math.Max(spectrum, this.Wave.GetSpectrum(hz)); hz += 10; } spectrum /= 30.0; // 要調整 spectrum = Vf(spectrum); spectra.Add(spectrum); } } for (int i = 0; i < spectra.Count; i++) { double v = this.ShadowSpectra[i]; v -= 0.01; v = Math.Max(v, spectra[i]); this.ShadowSpectra[i] = v; } Canvas2 dest = new Canvas2(picture.GetFrame().GetWidth(), picture.GetFrame().GetHeight()); using (Graphics g = dest.GetGraphics(false)) { g.FillRectangle(new SolidBrush(Color.FromArgb(64, 0, 0, 0)), 0, 0, dest.GetWidth(), dest.GetHeight()); int dr_l = 10; int dr_t = 10; int dr_w = dest.GetWidth() - 20; int dr_h = dest.GetHeight() - 20; for (int i = 0; i < spectra.Count; i++) { int x1 = (((i * 3 + 0) * dr_w) / (spectra.Count * 3 - 2)); int x2 = (((i * 3 + 1) * dr_w) / (spectra.Count * 3 - 2)); int w = x2 - x1; double v1 = this.ShadowSpectra[i]; double v2 = spectra[i]; 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); } } using (Graphics g = picture.GetFrame().GetGraphics(false)) { g.DrawImage(dest.GetImage(), 0, 0); } }
public static void Paste(Canvas2 dest, Canvas2 src, D4Rect rect) { Paste(dest, src, rect.L, rect.T, rect.W, rect.H); }
private IEnumerator DeactiveCanvas2() { yield return(new WaitForSeconds(0.05f)); Canvas2.SetActive(false); }
public void MakeVideo(WaveData wave, WorkingDir wd, Action <Canvas2> addImage) { this.DiscJacket = new Canvas2(this.DiscJacketFile); this.BluredDiscJacket = PictureUtils.Blur(this.DiscJacket, 5); // 要調整 this.MarginedDiscJacket = PictureUtils.PutMargin(this.DiscJacket); ShadowSpectraData ss = new ShadowSpectraData(); FadeInOutData f1 = new FadeInOutData() { MaxValue = 20 }; FadeInOutData f2 = new FadeInOutData(); f1.Rate = 1.0; int frameNum = DoubleTools.ToInt((wave.Length * 1.0 / wave.WavHz) * AudioPicMP4Props.FPS); for (int frame = 0; frame < frameNum; frame++) { if (frame == 2 * AudioPicMP4Props.FPS) { f1.TargetRate = 0.0; } if (frame == frameNum - 10 - f2.MaxValue) { f2.TargetRate = 1.0; } f1.Approach(); f2.Approach(); double rate = frame * 1.0 / (frameNum - 1); double invRate = 1.0 - rate; double r1 = 1.0 + 0.2 * rate; double r2 = 1.0 + 0.1 * invRate; D4Rect wallRect; D4Rect frntRect; { D2Size size = Utils.TangentSize( new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), new D2Size(this.DiscJacket.GetWidth(), this.DiscJacket.GetHeight()), false ); size.W *= r1; size.H *= r1; wallRect = Utils.Centering(new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), size); } { D2Size size = Utils.TangentSize( new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), new D2Size(this.DiscJacket.GetWidth(), this.DiscJacket.GetHeight()), true ); size.W *= r2; size.H *= r2; // マージン分 size.W *= this.MarginedDiscJacket.GetWidth() * 1.0 / this.DiscJacket.GetWidth(); size.H *= this.MarginedDiscJacket.GetHeight() * 1.0 / this.DiscJacket.GetHeight(); frntRect = Utils.Centering(new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), size); } Canvas2 frameImg = new Canvas2(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H); PictureUtils.Paste(frameImg, this.BluredDiscJacket, wallRect); PictureUtils.Filter(frameImg, Color.Black, 0.5); // 要調整 PictureUtils.Paste(frameImg, this.MarginedDiscJacket, frntRect); PictureUtils.Filter(frameImg, Color.Black, 0.1); // 要調整 PictureUtils.Filter(frameImg, Color.Black, f1.Rate); // 背景カーテン wave.SetWavPart(DoubleTools.ToInt((frame * 1.0 / AudioPicMP4Props.FPS + AudioPicMP4Props.AUDIO_DELAY_SEC) * wave.WavHz)); SpectrumGraph0001 sg = new SpectrumGraph0001(hz => wave.GetSpectrum(hz)); ss.Projection(sg.Spectra); this.DrawSpectra(frameImg, sg, ss); PictureUtils.Filter(frameImg, Color.Black, f2.Rate); // 前景カーテン addImage(frameImg); } }
private void Rec_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (!IsDragging) { return; } // Get the position on Canvas2 DraggedItem.SetValue(Canvas.LeftProperty, (Double)DraggedItem.GetValue(Canvas.LeftProperty) - (Double)Canvas2.GetValue(Canvas.LeftProperty)); DraggedItem.SetValue(Canvas.TopProperty, (Double)DraggedItem.GetValue(Canvas.TopProperty) - (Double)Canvas2.GetValue(Canvas.TopProperty)); // Item is on Canvas2 or not if ((Double)DraggedItem.GetValue(Canvas.LeftProperty) > 0 && (Double)DraggedItem.GetValue(Canvas.TopProperty) > 0) { IsInArea = true; } else { IsInArea = false; } // Position is legal or not if (IsInArea && (IsEmpty || IsAnchored)) { // Add to Canvas2 if (IsEmpty) { IsEmpty = false; DraggedItem.AnchorPointType = Anchors.AnchorType_FirstBlock; } else { DraggedItem.AnchorPointType = AnchorIndex; } RootCanvas.Children.Remove(DraggedItem); Canvas2.Children.Add(DraggedItem); Console.WriteLine(DateTime.Now.ToString() + " : Move <" + DraggedItem.Name + "> to <Canvas2>"); NewCanvasList.Add(DraggedItem); Console.WriteLine(DateTime.Now.ToString() + " : Add <" + DraggedItem.Name + "> to List"); // If is not anchored at the right anchor point if (AnchorIndex != (Define.AnchorNum - 1)) { // Update anchor point Anchor[1].X = (Double)DraggedItem.GetValue(Canvas.LeftProperty) + (Double)Canvas2.GetValue(Canvas.LeftProperty); Anchor[1].Y = (Double)DraggedItem.GetValue(Canvas.TopProperty) + (Double)Canvas2.GetValue(Canvas.TopProperty) + DraggedItem.Height + Anchors.VerticalMargin; Anchor[0].X = Anchor[1].X - Anchors.Indent; Anchor[0].Y = Anchor[1].Y; Anchor[2].X = Anchor[1].X + Anchors.Indent; Anchor[2].Y = Anchor[1].Y; Anchor[3].X = (Double)DraggedItem.GetValue(Canvas.LeftProperty) + (Double)Canvas2.GetValue(Canvas.LeftProperty) + DraggedItem.Width + Anchors.HorizontalMargin; Anchor[3].Y = (Double)DraggedItem.GetValue(Canvas.TopProperty) + (Double)Canvas2.GetValue(Canvas.TopProperty); Console.WriteLine(DateTime.Now.ToString() + " : Update anchor points"); } } else { // Delete illegal item Console.WriteLine(DateTime.Now.ToString() + " : Illegal placement. Delete <" + DraggedItem.Name + ">"); RootCanvas.Children.Remove(DraggedItem); DraggedItem = null; } IsDragging = false; // Update log Console.WriteLine(DateTime.Now.ToString() + " : Finish dragging"); }
private void MakeMovie_Main() { this.DiscJacket = new Canvas2(this.DiscJacketFile); this.BluredDiscJacket = PictureUtils.Blur(this.DiscJacket, 5); // 要調整 this.MarginedDiscJacket = PictureUtils.PutMargin(this.DiscJacket); { string wavFile = this.WD.GetPath("audio.wav"); string masterWavFile = this.WD.GetPath("audio2.wav"); FFmpegConv.MakeWavFile(this.SourceMediaFile, wavFile); if (this.MasterFlag && MasterUtils.Mastering(wavFile, masterWavFile)) { this.Wave = new WaveData(masterWavFile); this.FFmpeg.Audio.PutAudioFile(masterWavFile); } else { this.Wave = new WaveData(wavFile); this.FFmpeg.Audio.PutAudioFile(this.SourceMediaFile); } } ShadowSpectraData ss = new ShadowSpectraData(); FadeInOutData f1 = new FadeInOutData() { MaxValue = 20 }; FadeInOutData f2 = new FadeInOutData(); f1.Rate = 1.0; int frameNum = DoubleTools.ToInt((this.Wave.Length * 1.0 / this.Wave.WavHz) * AudioPicMP4Props.FPS); for (int frame = 0; frame < frameNum; frame++) { if (frame == 2 * AudioPicMP4Props.FPS) { f1.TargetRate = 0.0; } if (frame == frameNum - 10 - f2.MaxValue) { f2.TargetRate = 1.0; } f1.Approach(); f2.Approach(); double rate = frame * 1.0 / (frameNum - 1); double invRate = 1.0 - rate; double r1 = 1.0 + 0.2 * rate; double r2 = 1.0 + 0.1 * invRate; D4Rect wallRect; D4Rect frntRect; { D2Size size = Utils.TangentSize( new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), new D2Size(this.DiscJacket.GetWidth(), this.DiscJacket.GetHeight()), false ); size.W *= r1; size.H *= r1; wallRect = Utils.Centering(new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), size); } { D2Size size = Utils.TangentSize( new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), new D2Size(this.DiscJacket.GetWidth(), this.DiscJacket.GetHeight()), true ); size.W *= r2; size.H *= r2; // マージン分 size.W *= this.MarginedDiscJacket.GetWidth() * 1.0 / this.DiscJacket.GetWidth(); size.H *= this.MarginedDiscJacket.GetHeight() * 1.0 / this.DiscJacket.GetHeight(); frntRect = Utils.Centering(new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), size); } Canvas2 frameImg = new Canvas2(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H); PictureUtils.Paste(frameImg, this.BluredDiscJacket, wallRect); PictureUtils.Filter(frameImg, Color.Black, 0.5); // 要調整 PictureUtils.Paste(frameImg, this.MarginedDiscJacket, frntRect); PictureUtils.Filter(frameImg, Color.Black, 0.1); // 要調整 PictureUtils.Filter(frameImg, Color.Black, f1.Rate); // 背景カーテン this.Wave.SetWavPart(DoubleTools.ToInt((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); this.DrawSpectra(frameImg, sg, ss); PictureUtils.Filter(frameImg, Color.Black, f2.Rate); // 前景カーテン frameImg.Save(this.FFmpeg.GetImageFile(frame), ImageFormat.Jpeg, AudioPicMP4Props.JPEG_QUALITY); GC.Collect(); } this.FFmpeg.MakeMovie(); File.Copy(this.FFmpeg.GetMovieFile(), this.DestMP4File); }