private void LcdScreen_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { if (isLoaded) { args.DrawingSession.Clear(Color.FromArgb(255, 220, 220, 220)); visualizer.Draw(sender, args, gameStateMachine.StateCode); args.DrawingSession.DrawText("Score: " + score.ToString().PadLeft(9, '0'), new System.Numerics.Vector2(0f, 0f), Color.FromArgb(255, 0, 0, 0)); args.DrawingSession.DrawText("Chances Left: " + chancesLeft.ToString(), new System.Numerics.Vector2(0f, 50f), Color.FromArgb(255, 0, 0, 0)); if (playerMessage != null) { args.DrawingSession.DrawText(playerMessage, new System.Numerics.Vector2(0f, 100f), Color.FromArgb((byte)messageFadeOpacity, 0, 0, 0)); } if (playerMessageRow2 != null) { args.DrawingSession.DrawText(playerMessageRow2, new System.Numerics.Vector2(0f, 120f), Color.FromArgb((byte)messageFadeOpacity, 0, 0, 0)); } } }
public void Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args, StateMachine.GameStateCodes gameState) { double screenWidth = sender.Size.Width; double screenHeight = sender.Size.Height; double hStride = System.Math.Floor(screenWidth / 6d); double vStride = System.Math.Floor(screenHeight / 7d); double hLeftover = screenWidth - (6d * hStride); double vLeftover = screenHeight - (7d * vStride); float hMargin = (float)System.Math.Floor(hLeftover / 2d); float vMargin = (float)System.Math.Floor(vLeftover / 2d); for (int i = 0; i < World.Globals.LocationCount; i++) { Arrangements.TileCoordinate coord = tileCoordinateHolder.TileCoordinateFor(i); float x = hMargin + (float)(coord.Column * hStride); float y = vMargin + (float)(coord.Row * vStride); var r = new Windows.Foundation.Rect(x, y, (float)hStride, (float)vStride); CanvasBitmap bitmap = bitmapHolder.BitmapForLocation(i); args.DrawingSession.DrawImage(bitmap, r); if (gameItemHolder.IsBerryAt(i) || gameState == StateMachine.GameStateCodes.StartingUp) { CanvasBitmap berryBitmap = bitmapHolder.BerryBitmap(); args.DrawingSession.DrawImage(berryBitmap, r); } if (gameItemHolder.IsBugAt(i) || gameState == StateMachine.GameStateCodes.StartingUp) { CanvasBitmap bugBitmap = bitmapHolder.BugBitmap(); args.DrawingSession.DrawImage(bugBitmap, r); } if (gameItemHolder.IsPlayerAt(i) || gameState == StateMachine.GameStateCodes.StartingUp) { if (blinkStateOn) { CanvasBitmap playerBitmap; playerBitmap = bitmapHolder.PlayerIdleBitmap(picking); args.DrawingSession.DrawImage(playerBitmap, r); } } } // draw message here // fade it during the update function }
private void prologControl_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { var textDisplay = GenerateTextDisplay(sender, (float)sender.Size.Width, (float)sender.Size.Height); var blurEffect = new GaussianBlurEffect() { Source = textDisplay, BlurAmount = 10 }; mTextOpacityBrush.StartPoint = mBlurOpacityBrush.StartPoint = new Vector2(0, 0); mTextOpacityBrush.EndPoint = mBlurOpacityBrush.EndPoint = new Vector2(0, (float)sender.Size.Height); var ds = args.DrawingSession; //using (ds.CreateLayer(mBlurOpacityBrush)) //{ // ds.DrawImage(blurEffect); //} using (ds.CreateLayer(mTextOpacityBrush)) { ds.DrawImage(textDisplay); } }
private async void CanvasAnimatedControl_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { if (SharedMethods.isRunnnig) { var curDistance = SharedMethods.RoundTripDistance(tourLocations, tourOrder); if (curDistance < bestTourDistance) { bestTourDistance = curDistance; tourOrder.CopyTo(bestTourOrder, 0); } currentIteration++; UpdateUI(); tourOrder = LexicographicOrder.Lexicography(tourOrder); if (currentIteration >= totalIterations) { SharedMethods.isRunnnig = false; } else { SharedMethods.DrawPath(args.DrawingSession, tourLocations, tourOrder, Color.FromArgb(85, 255, 255, 255), 2f); SharedMethods.DrawPath(args.DrawingSession, tourLocations, bestTourOrder, Color.FromArgb(85, 255, 255, 255), 4f); } } else { if (currentIteration > 0) { SharedMethods.DrawPath(args.DrawingSession, tourLocations, bestTourOrder, Color.FromArgb(85, 255, 255, 255), 4f); } await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { startBtn.Visibility = Visibility.Visible; stopBtn.Visibility = Visibility.Collapsed; }); sender.Paused = true; } }
private void Canvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { }
private void Canvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { var opacityMask = CreateOpacityMask(sender, 800, 800); var bytes = opacityMask.GetPixelBytes(); var bmp = CanvasBitmap.CreateFromBytes(sender.Device, bytes, 800, 800, Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized); var brush = new CanvasImageBrush(sender, bmp); using (var layer = args.DrawingSession.CreateLayer(brush)) { args.DrawingSession.FillRectangle(new Rect(100, 0, 500, 350), Colors.BlueViolet); } Canvas.Paused = true; }
private void Canvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { buildGameTwo.DrawGame(args.DrawingSession); }
private void CanvasAnimatedControl_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { if (Machine.Painter.Canvas != null) { args.DrawingSession.Clear(Windows.UI.Colors.Transparent); Machine.Painter.Draw(args.DrawingSession); } this.DrawingSession = args.DrawingSession; }
private void canvas_Draw_1(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { double canvas_width = this.canvas.Size.Width; double canvas_height = this.canvas.Size.Height; // https://microsoft.github.io/Win2D/html/P_Microsoft_Graphics_Canvas_CanvasDrawingSession_Transform.htm args.DrawingSession.Transform = Matrix3x2.CreateTranslation(new Vector2((float)(canvas_width / 2 - map.map_width / 2), (float)(canvas_height / 2 - map.map_height / 2))); map.Draw(sender, args); for (int index = 0; index < this.players.Length; index++) { this.players[index].Draw(sender, args, index); } //args.DrawingSession.DrawText("Hello, World!", 100, 100, Colors.Black); //args.DrawingSession.DrawCircle(125, 125, 100, Colors.Green); //args.DrawingSession.DrawLine(0, 0, 50, 200, Colors.Red); }
private void OnDraw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { if (_lineSpectrum != null && _audioProvider.IsPlaying) { _lineSpectrum.CreateSpectrumLine(sender, args.DrawingSession); } }
private void Canvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { var opacityMask = CreateOpacityMask(sender, 800, 800); var brush = new CanvasImageBrush(sender, opacityMask); using (var layer = args.DrawingSession.CreateLayer(brush)) { args.DrawingSession.FillRectangle(new Rect(100, 0, 500, 350), Colors.BlueViolet); } Canvas.Paused = true; }
private void DrawCanvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { Core mainCore = Core.MainCore; if (mainCore != null && !mainCore.Running) { return; } var session = args.DrawingSession; session.FillCircle(mainCore.Ball.Position, 20, Colors.Red); session.FillCircle((float)sender.Size.Width, (float)sender.Size.Height, 20, Colors.Red); session.DrawLine(new Vector2(200, 200), mainCore.Ball.Position / 10, Colors.Blue); session.DrawText( mainCore.Ball.Position.X.ToString() + "\n" + mainCore.Ball.Position.Y.ToString() + "\n" + mainCore.Ball.Acceleration.X.ToString() + "\n" + mainCore.Ball.Acceleration.Y.ToString() + "\n" + mainCore.Ball.Speed.X.ToString() + "\n" + mainCore.Ball.Speed.Y.ToString() + "\n" + sender.Size.Width + "\n" + sender.Size.Width , 100, 100, Colors.Red); }
private void canvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { lock (_points) { double height = sender.Size.Height; foreach (var point in _points) { args.DrawingSession.DrawLine( point.X * _barWidth, Convert.ToSingle(height), point.X * _barWidth, Convert.ToSingle(height) - point.Y, Colors.Green, 1); } } }
private void CanvasAnimatedControl_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { //args.DrawingSession.DrawImage(image: new CanvasBitmap(), x: 100, y: 100); }
private async void CanvasAnimatedControl_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { if (SharedMethods.isRunnnig) { ga.NewGenration(); UpdateUI(); count++; SharedMethods.DrawPath(args.DrawingSession, SharedMethods.Locations, ga.BestGenes, Color.FromArgb(85, 255, 255, 255), 4f); SharedMethods.DrawPath(args.DrawingSession, SharedMethods.Locations, ga.Population[elitism].Genes, Color.FromArgb(85, 255, 255, 255), 2f); } else { if (count > 0) { SharedMethods.DrawPath(args.DrawingSession, tourLocations, ga.BestGenes, Color.FromArgb(85, 255, 255, 255), 4f); } await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { startBtn.Visibility = Visibility.Visible; stopBtn.Visibility = Visibility.Collapsed; }); sender.Paused = true; } }
public void Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { args.DrawingSession.FillRectangle(pos_x, pos_y, tile_width, tile_height, Color.FromArgb(255, 0, 0, 0)); args.DrawingSession.DrawRectangle(pos_x, pos_y, tile_width, tile_height, Color.FromArgb(255, 0, 253, 255)); }
public void Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { for (int ix = 0; ix < width; ix++) { for (int iy = 0; iy < height; iy++) { tiles[ix, iy].Draw(sender, args); } } }
private void canvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { var options = CanvasSpriteOptions.ClampToSourceRect; using (var sb = args.DrawingSession.CreateSpriteBatch(CanvasSpriteSortMode.None, CanvasImageInterpolation.NearestNeighbor, options)) { Vector4 tint = Vector4.One; var column = mWidth / 64; if (mWidth % 64 > 0) { column++; } var row = mHeight / 64; if (mHeight % 64 > 0) { row++; } for (var y = 0; y < row; y++) { for (var x = 0; x < column; x++) { mMapTiles.Draw(sb, 47, mMapTiles.SpriteSize * new Vector2(x, y), tint); } } mCharacterTiles.Draw(sb, 5, new Vector2(mCharacterTiles.SpriteSize.X * 2, mCharacterTiles.SpriteSize.Y / 2 * 2), Vector4.One); mCharacterTiles.Draw(sb, 8, new Vector2(mCharacterTiles.SpriteSize.X * 1, mCharacterTiles.SpriteSize.Y / 2 * 5), Vector4.One); mCharacterTiles.Draw(sb, 8, new Vector2(mCharacterTiles.SpriteSize.X * 2, mCharacterTiles.SpriteSize.Y / 2 * 5), Vector4.One); mCharacterTiles.Draw(sb, 12, new Vector2(mCharacterTiles.SpriteSize.X * 3, mCharacterTiles.SpriteSize.Y / 2 * 5), Vector4.One); mCharacterTiles.Draw(sb, 10, new Vector2(mCharacterTiles.SpriteSize.X * 1, mCharacterTiles.SpriteSize.Y / 2 * 8), Vector4.One); mCharacterTiles.Draw(sb, 14, new Vector2(mCharacterTiles.SpriteSize.X * 2, mCharacterTiles.SpriteSize.Y / 2 * 8), Vector4.One); mCharacterTiles.Draw(sb, 18, new Vector2(mCharacterTiles.SpriteSize.X * 3, mCharacterTiles.SpriteSize.Y / 2 * 8), Vector4.One); mCharacterTiles.Draw(sb, 11, new Vector2(mCharacterTiles.SpriteSize.X * 1, mCharacterTiles.SpriteSize.Y / 2 * 10), Vector4.One); mCharacterTiles.Draw(sb, 15, new Vector2(mCharacterTiles.SpriteSize.X * 2, mCharacterTiles.SpriteSize.Y / 2 * 10), Vector4.One); mCharacterTiles.Draw(sb, 19, new Vector2(mCharacterTiles.SpriteSize.X * 3, mCharacterTiles.SpriteSize.Y / 2 * 10), Vector4.One); mCharacterTiles.Draw(sb, 9, new Vector2(mCharacterTiles.SpriteSize.X * 2, mCharacterTiles.SpriteSize.Y / 2 * 13), Vector4.One); mCharacterTiles.Draw(sb, 23, new Vector2(mCharacterTiles.SpriteSize.X * 2, mCharacterTiles.SpriteSize.Y / 2 * 16), Vector4.One); mCharacterTiles.Draw(sb, 22, new Vector2(mCharacterTiles.SpriteSize.X * 2, mCharacterTiles.SpriteSize.Y / 2 * 19), Vector4.One); mCharacterTiles.Draw(sb, 26, new Vector2(mCharacterTiles.SpriteSize.X * 2, mCharacterTiles.SpriteSize.Y / 2 * 22), Vector4.One); mCharacterTiles.Draw(sb, 25, new Vector2(mCharacterTiles.SpriteSize.X * 2, mCharacterTiles.SpriteSize.Y / 2 * 25), Vector4.One); mCharacterTiles.Draw(sb, 16, new Vector2(mCharacterTiles.SpriteSize.X * 2, mCharacterTiles.SpriteSize.Y / 2 * 28), Vector4.One); mCharacterTiles.Draw(sb, 17, new Vector2(mCharacterTiles.SpriteSize.X * 2, mCharacterTiles.SpriteSize.Y / 2 * 30), Vector4.One); int ahnTile; if (mYOffset % 2 == 0) { ahnTile = 20; } else { ahnTile = 21; } mCharacterTiles.Draw(sb, ahnTile, new Vector2(mCharacterTiles.SpriteSize.X * 27, mYOffset), Vector4.One); } var text = "이 게임의 끝마무리에 공헌한 인물"; var titlelText = new CanvasTextFormat() { FontSize = 30, FontFamily = "Segoe UI", FontWeight = FontWeights.Bold, HorizontalAlignment = CanvasHorizontalAlignment.Center }; var textLayout = new CanvasTextLayout(sender, text, titlelText, (float)sender.Size.Width, (float)sender.Size.Height); args.DrawingSession.DrawTextLayout(textLayout, 0, 0, new CanvasSolidColorBrush(sender, Color.FromArgb(0xff, 0x55, 0xff, 0xff))); var descText = new CanvasTextFormat() { FontSize = 30, FontFamily = "Segoe UI" }; args.DrawingSession.DrawTextLayout(new CanvasTextLayout(sender, $"이름은 {mPlayerName}. 바로 당신이다.", descText, (float)sender.Size.Width, (float)sender.Size.Height), 400, 70, new CanvasSolidColorBrush(sender, Color.FromArgb(0xff, 0x55, 0xff, 0x55))); args.DrawingSession.DrawTextLayout(new CanvasTextLayout(sender, "히드라, 노티스 동굴의 보스였다.", descText, (float)sender.Size.Width, (float)sender.Size.Height), 400, 166, new CanvasSolidColorBrush(sender, Color.FromArgb(0xff, 0x55, 0xff, 0x55))); args.DrawingSession.DrawTextLayout(new CanvasTextLayout(sender, "거대 드래곤, 락업 동굴의 보스였다.", descText, (float)sender.Size.Width, (float)sender.Size.Height), 400, 292, new CanvasSolidColorBrush(sender, Color.FromArgb(0xff, 0x55, 0xff, 0x55))); args.DrawingSession.DrawTextLayout(new CanvasTextLayout(sender, "미노타우루스, 여기서 두 번 등장하는 생물이다.", descText, (float)sender.Size.Width, (float)sender.Size.Height), 400, 420, new CanvasSolidColorBrush(sender, Color.FromArgb(0xff, 0x55, 0xff, 0x55))); args.DrawingSession.DrawTextLayout(new CanvasTextLayout(sender, "기갑 독사, 던전 오브 이블을 지키던 기계 생물.", descText, (float)sender.Size.Width, (float)sender.Size.Height), 400, 516, new CanvasSolidColorBrush(sender, Color.FromArgb(0xff, 0x55, 0xff, 0x55))); args.DrawingSession.DrawTextLayout(new CanvasTextLayout(sender, "검은 기사, 네크로만서 쪽의 제 2인자 이다.", descText, (float)sender.Size.Width, (float)sender.Size.Height), 400, 612, new CanvasSolidColorBrush(sender, Color.FromArgb(0xff, 0x55, 0xff, 0x55))); args.DrawingSession.DrawTextLayout(new CanvasTextLayout(sender, "아키몽크, 네크로만서의 왼팔 역할의 실력자.", descText, (float)sender.Size.Width, (float)sender.Size.Height), 400, 708, new CanvasSolidColorBrush(sender, Color.FromArgb(0xff, 0x55, 0xff, 0x55))); args.DrawingSession.DrawTextLayout(new CanvasTextLayout(sender, "아키메이지, 네크로만서의 오른팔인 마법사.", descText, (float)sender.Size.Width, (float)sender.Size.Height), 400, 804, new CanvasSolidColorBrush(sender, Color.FromArgb(0xff, 0x55, 0xff, 0x55))); args.DrawingSession.DrawTextLayout(new CanvasTextLayout(sender, "네오-네크로만서, 바로 당신의 목표였던 그자.", descText, (float)sender.Size.Width, (float)sender.Size.Height), 400, 932, new CanvasSolidColorBrush(sender, Color.FromArgb(0xff, 0x55, 0xff, 0x55))); //var ds = args.DrawingSession; //using (ds.CreateLayer(0)) //{ // ds.DrawImage(GenerateTextDisplay(sender, (float)sender.Size.Width, (float)sender.Size.Height)); //} }
/// <summary> /// Draws each frame of the Canvas /// </summary> private void CanvasAnimatedControl_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { if (Storage.Settings.ExpensiveRender) { if (!initailized) { // If not initialized take one from to initialize fftInitialize(); } else { using (var cpb = new CanvasPathBuilder(args.DrawingSession)) { // Start curve at 0 cpb.BeginFigure(0, height); // Initialize render points Vector2 p0; Vector2 p1; Vector2 p2; Vector2 p3; Vector2 p4; Vector2 p5; Vector2 p6; Vector2 p7; Vector2 p8; // Set render points if (_audioIn) { average = averageSmoother.Smooth(AudioManager.AudioInAverage); p0 = new Vector2(Point0, height - Adjust(smoother1.Smooth(AudioManager.AudioInSpec1)) * height); p1 = new Vector2(Point1, height - Adjust(smoother2.Smooth(AudioManager.AudioInSpec2)) * height); p2 = new Vector2(Point2, height - Adjust(smoother3.Smooth(AudioManager.AudioInSpec3)) * height); p3 = new Vector2(Point3, height - Adjust(smoother4.Smooth(AudioManager.AudioInSpec4)) * height); p4 = new Vector2(Point4, height - Adjust(smoother5.Smooth(AudioManager.AudioInSpec5)) * height); p5 = new Vector2(Point5, height - Adjust(smoother6.Smooth(AudioManager.AudioInSpec6)) * height); p6 = new Vector2(Point6, height - Adjust(smoother7.Smooth(AudioManager.AudioInSpec7)) * height); p7 = new Vector2(Point7, height - Adjust(smoother8.Smooth(AudioManager.AudioInSpec8)) * height); p8 = new Vector2(Point8, height - Adjust(smoother9.Smooth(AudioManager.AudioInSpec9)) * height); } else { average = averageSmoother.Smooth(AudioManager.AudioOutAverage); p0 = new Vector2(Point0, height - Adjust(smoother1.Smooth(AudioManager.AudioOutSpec1)) * height); p1 = new Vector2(Point1, height - Adjust(smoother2.Smooth(AudioManager.AudioOutSpec2)) * height); p2 = new Vector2(Point2, height - Adjust(smoother3.Smooth(AudioManager.AudioOutSpec3)) * height); p3 = new Vector2(Point3, height - Adjust(smoother4.Smooth(AudioManager.AudioOutSpec4)) * height); p4 = new Vector2(Point4, height - Adjust(smoother5.Smooth(AudioManager.AudioOutSpec5)) * height); p5 = new Vector2(Point5, height - Adjust(smoother6.Smooth(AudioManager.AudioOutSpec6)) * height); p6 = new Vector2(Point6, height - Adjust(smoother7.Smooth(AudioManager.AudioOutSpec7)) * height); p7 = new Vector2(Point7, height - Adjust(smoother8.Smooth(AudioManager.AudioOutSpec8)) * height); p8 = new Vector2(Point8, height - Adjust(smoother9.Smooth(AudioManager.AudioOutSpec9)) * height); } // Render points cpb.AddLine(p0); cpb.AddCubicBezier(GetC1(p0), GetC2(p1), p1); cpb.AddCubicBezier(GetC1(p1), GetC2(p2), p2); cpb.AddCubicBezier(GetC1(p2), GetC2(p3), p3); cpb.AddCubicBezier(GetC1(p3), GetC2(p4), p4); cpb.AddCubicBezier(GetC1(p4), GetC2(p5), p5); cpb.AddCubicBezier(GetC1(p5), GetC2(p6), p6); cpb.AddCubicBezier(GetC1(p6), GetC2(p7), p7); cpb.AddCubicBezier(GetC1(p7), GetC2(p8), p8); cpb.AddLine(new Vector2(p8.X, height)); cpb.EndFigure(CanvasFigureLoop.Closed); // Render CanvasLinearGradientBrush gradient = new CanvasLinearGradientBrush(sender, TransparentBlurple, Blurple) { EndPoint = new Vector2(0, height + 48), StartPoint = new Vector2(0, -12) }; var path = CanvasGeometry.CreatePath(cpb); //args.DrawingSession.DrawGeometry(path, Blurple, 1); args.DrawingSession.FillGeometry(path, gradient); } } } }
private void DrawWaveformCanvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { float xAxis = 0.0f; for (int i = 0; i < waveformFloatData.Count; i++) { if (i == 0) { continue; } Vector2 point1 = new Vector2(xAxis, waveformFloatData[i - 1]); Vector2 point2 = new Vector2(xAxis, waveformFloatData[i]); args.DrawingSession.DrawLine(point1, point2, Colors.Red, 1f); xAxis += 0.3f; } waveformFloatData.Clear(); }
private void canvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { if (useRenderTarget) { args.DrawingSession.DrawImage(scrollerTarget, scrollPos); } else { args.DrawingSession.DrawTextLayout(scroller_layout, scrollPos, Colors.White); } if (showW2DFpsCounter) { DrawfpsCounter.Draw(args.DrawingSession); } if (showW2DUpdCounter) { UpdatefpsCounter.Draw(args.DrawingSession); } }
private void canvasControl_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { var time = DateTime.Now; var session = args.DrawingSession; session.Clear(Colors.Transparent); var width = 36f; var radius = width * 0.45f; var xCenter = (float)width / 2; var yCenter = (float)width / 2; session.DrawEllipse(xCenter, yCenter, radius, radius, Colors.Black, 2f); session.FillCircle(xCenter, yCenter, radius, Colors.BlueViolet); session.DrawEllipse(xCenter, yCenter, 1, 1, Colors.Black, 2f); var secAngl = (time.Second + (time.Millisecond / 1000f)) * 6f; var minAngl = (time.Minute * 6f) + secAngl / 60f; var hourAngl = (time.Hour % 12 * 30f) + minAngl / 12f; Action <float, double, float> drawline = (angle, length, lineWidth) => { var radAng = (Math.PI / 180) * angle; var x = xCenter + (Math.Cos(radAng) * length); var y = yCenter + (Math.Sin(radAng) * length); session.DrawLine(xCenter, yCenter, (int)x, (int)y, Colors.Black, lineWidth); }; drawline(secAngl - 90, radius * 0.8, 1); drawline(minAngl - 90, radius * 0.9, 2); drawline(hourAngl - 90, radius * 0.5, 2.5f); canvasControl.Invalidate(); }
private void CanvasAnimatedControl_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { if (_inited) { var commandList = _drawForCanvas.GetCanvasImage(sender, 1, 1); args.DrawingSession.DrawImage(commandList); } }
private void DanmuCanvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { cl.Dispose(); cl = new CanvasCommandList(sender); using (var clds = cl.CreateDrawingSession()) { for (int i = 0; i < onDrawList.Count; i++) { clds.DrawText(onDrawList[i].Text, onDrawList[i].position.X + 2, onDrawList[i].position.Y + 1, Colors.Black); clds.DrawText(onDrawList[i].Text, onDrawList[i].position, onDrawList[i].color); } } args.DrawingSession.DrawImage(cl); }
public void Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args, int player) { // because we cant test with xbox controllers right now and only have keyboards to work with only two players will be implemented // this code will have to be changed once we are ready to test with an xbox, but for now this will allow us to set up the functionality // for the rest of the game. Players also dont start moving until input is given. In the real game they should start moving in a random // direction immediately, but for testing purposes I'm leaving that out so there is no random element to deal with when testing counter++; if (counter >= 15) { counter = 0; if (death0 == false) { if (player == 0) { if (dKeyDown) { tile_x++; } if (aKeyDown) { tile_x--; } if (sKeyDown) { tile_y++; } if (wKeyDown) { tile_y--; } if (tile_x == 20 || tile_x == -1 || tile_y == -1 || tile_y == 20) { death0 = true; } } } if (death1 == false) { if (player == 1) { if (rightKeyDown) { tile_x++; } if (leftKeyDown) { tile_x--; } if (downKeyDown) { tile_y++; } if (upKeyDown) { tile_y--; } if (tile_x == 20 || tile_x == -1 || tile_y == -1 || tile_y == 20) { death1 = true; } } } ///* // up = I // left = j // down = k // right = L // */ //if (death2 == false) //{ // if (player == 2) // { // if (lKeyDown) { tile_x++; } // if (jKeyDown) { tile_x--; } // if (kKeyDown) { tile_y++; } // if (iKeyDown) { tile_y--; } // if (tile_x == 20 || tile_x == -1 || tile_y == -1 || tile_y == 20) { death2 = true; } // } //} ///* // up = T // left = F // down = G // right = H // */ //if (death3 == false) //{ // if (player == 3) // { // if (hKeyDown) { tile_x++; } // if (fKeyDown) { tile_x--; } // if (gKeyDown) { tile_y++; } // if (tKeyDown) { tile_y--; } // if (tile_x == 20 || tile_x == -1 || tile_y == -1 || tile_y == 20) { death3 = true; } // } //} } map.TileToPos(tile_x, tile_y, out pos_x, out pos_y); if (player == 0) { args.DrawingSession.FillRectangle(pos_x - width / 2, pos_y - height / 2, width, height, Color.FromArgb(255, 0, 253, 255)); args.DrawingSession.DrawRectangle(pos_x - width / 2, pos_y - height / 2, width, width, Color.FromArgb(255, 0, 253, 255)); } if (player == 1) { args.DrawingSession.FillRectangle(pos_x - width / 2, pos_y - height / 2, width, height, Color.FromArgb(255, 255, 0, 0)); args.DrawingSession.DrawRectangle(pos_x - width / 2, pos_y - height / 2, width, width, Color.FromArgb(255, 255, 0, 0)); } if (player == 2) { args.DrawingSession.FillRectangle(pos_x - width / 2, pos_y - height / 2, width, height, Color.FromArgb(255, 255, 0, 208)); args.DrawingSession.DrawRectangle(pos_x - width / 2, pos_y - height / 2, width, width, Color.FromArgb(255, 255, 0, 208)); } if (player == 3) { args.DrawingSession.FillRectangle(pos_x - width / 2, pos_y - height / 2, width, height, Color.FromArgb(255, 246, 255, 0)); args.DrawingSession.DrawRectangle(pos_x - width / 2, pos_y - height / 2, width, width, Color.FromArgb(255, 246, 255, 0)); } }
private void CanvasAnimatedControl_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { args.DrawingSession.DrawEllipse(155, 115, 80, 30, Colors.Black, 3); args.DrawingSession.DrawText("Hello, world!", 100, 100, Colors.Yellow); }
private void CanvasAnimatedControl_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { using (var cpb = new CanvasPathBuilder(args.DrawingSession)) { cpb.BeginFigure(0, height); average = averageSmoother.Smooth(AudioManager.AudioAverage); Vector2 p0 = new Vector2(Point0, height - Adjust(smoother1.Smooth(AudioManager.AudioSpec1)) * height); Vector2 p1 = new Vector2(Point1, height - Adjust(smoother2.Smooth(AudioManager.AudioSpec2)) * height); Vector2 p2 = new Vector2(Point2, height - Adjust(smoother3.Smooth(AudioManager.AudioSpec3)) * height); Vector2 p3 = new Vector2(Point3, height - Adjust(smoother4.Smooth(AudioManager.AudioSpec4)) * height); Vector2 p4 = new Vector2(Point4, height - Adjust(smoother5.Smooth(AudioManager.AudioSpec5)) * height); Vector2 p5 = new Vector2(Point5, height - Adjust(smoother6.Smooth(AudioManager.AudioSpec6)) * height); Vector2 p6 = new Vector2(Point6, height - Adjust(smoother7.Smooth(AudioManager.AudioSpec7)) * height); Vector2 p7 = new Vector2(Point7, height - Adjust(smoother8.Smooth(AudioManager.AudioSpec8)) * height); Vector2 p8 = new Vector2(Point8, height - Adjust(smoother9.Smooth(AudioManager.AudioSpec9)) * height); cpb.AddLine(p0); cpb.AddCubicBezier(GetC1(p0), GetC2(p1), p1); cpb.AddCubicBezier(GetC1(p1), GetC2(p2), p2); cpb.AddCubicBezier(GetC1(p2), GetC2(p3), p3); cpb.AddCubicBezier(GetC1(p3), GetC2(p4), p4); cpb.AddCubicBezier(GetC1(p4), GetC2(p5), p5); cpb.AddCubicBezier(GetC1(p5), GetC2(p6), p6); cpb.AddCubicBezier(GetC1(p6), GetC2(p7), p7); cpb.AddCubicBezier(GetC1(p7), GetC2(p8), p8); cpb.AddLine(new Vector2(p8.X, height)); cpb.EndFigure(CanvasFigureLoop.Closed); CanvasLinearGradientBrush gradient = new CanvasLinearGradientBrush(sender, TransparentBlurple, Blurple) { EndPoint = new Vector2(0, height + 48), StartPoint = new Vector2(0, -12) }; var path = CanvasGeometry.CreatePath(cpb); //args.DrawingSession.DrawGeometry(path, Blurple, 1); args.DrawingSession.FillGeometry(path, gradient); } }
private void Canvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { Si.DrawGame(args.DrawingSession); /*//if (Window.Current.CoreWindow.GetKeyState(VirtualKey.Space).HasFlag(CoreVirtualKeyStates.Down)) * if (Window.Current.CoreWindow.GetAsyncKeyState(VirtualKey.Space) == * Windows.UI.Core.CoreVirtualKeyStates.Down) * { * Lasers laser = new Lasers(0, 0, LaserImage); * laser.ShootLaser(LaserImage, Si.ship); * laser.Image(args.DrawingSession); * laser.Update(LaserImage); * }*/ }
private void CanvasAnimatedControl_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { foreach (var line in segments) { args.DrawingSession.DrawLine(line.StartPoint, line.EndPoint, brush, 3f); } }
private void canvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { //Draw Black Background Rect rect = new Rect(); rect.X = 0; rect.Y = 0; rect.Width = 600; rect.Height = 400; args.DrawingSession.DrawRectangle(rect, snake.foregroundColor); args.DrawingSession.FillRectangle(rect, snake.backgroundColor); if (gameIsRunning) { Rect scoreBoard = new Rect(); scoreBoard.X = 401; scoreBoard.Y = 0; scoreBoard.Width = 199; scoreBoard.Height = 400; args.DrawingSession.DrawRectangle(scoreBoard, snake.foregroundColor); args.DrawingSession.FillRectangle(scoreBoard, snake.foregroundColor); Rect playerScoreRec = new Rect(); playerScoreRec.X = 441; playerScoreRec.Y = 181; playerScoreRec.Width = 160; playerScoreRec.Height = 40; CanvasTextFormat textFormatOfScoreText = new CanvasTextFormat() { FontFamily = "Courier New", FontSize = 72 }; args.DrawingSession.DrawText($"{snake.playerScore}", playerScoreRec, snake.backgroundColor, textFormatOfScoreText); //Draw Game snake.drawGame(args.DrawingSession); } else if (gameOver) { Rect locOfGameOverText = new Rect(); locOfGameOverText.X = 200; locOfGameOverText.Y = 125; locOfGameOverText.Width = 200; locOfGameOverText.Height = 200; CanvasTextFormat textFormatOfGameOverText = new CanvasTextFormat() { FontFamily = "Courier New", FontSize = 72 }; args.DrawingSession.DrawText("GAME OVER", locOfGameOverText, Colors.White, textFormatOfGameOverText); } else if (startPageDisplaying) { Rect titleRec = new Rect(); titleRec.X = 25; titleRec.Y = 20; titleRec.Width = 400; titleRec.Height = 100; Rect selectionText = new Rect(); selectionText.X = 60; selectionText.Y = 200; selectionText.Width = 400; selectionText.Height = 200; Rect imageRec = new Rect(); imageRec.X = 300; imageRec.Y = 40; imageRec.Width = 216; imageRec.Height = 216; CanvasTextFormat textFormatOfTitleText = new CanvasTextFormat() { FontFamily = "Courier New", FontSize = 72 }; CanvasTextFormat textFormatOfSelectionText = new CanvasTextFormat() { FontFamily = "Courier New", FontSize = 44 }; string selectionString = "PLAY!!!\nSETTINGS!!!\nHOW TO PLAY???\nCREDITS!!!\n"; args.DrawingSession.DrawText("SNAKE!!!", titleRec, Colors.White, textFormatOfTitleText); args.DrawingSession.DrawText(selectionString, selectionText, Colors.White, textFormatOfSelectionText); menuSelector.draw(args.DrawingSession); } else if (settingsPageDisplaying) { Rect SettingsTitleRec = new Rect(); SettingsTitleRec.X = 25; SettingsTitleRec.Y = 10; SettingsTitleRec.Width = 200; SettingsTitleRec.Height = 50; Rect selectionTextColor = new Rect(); selectionTextColor.X = 60; selectionTextColor.Y = 100; selectionTextColor.Width = 400; selectionTextColor.Height = 200; Rect selectionTextMusic = new Rect(); selectionTextMusic.X = 380; selectionTextMusic.Y = 100; selectionTextMusic.Width = 400; selectionTextMusic.Height = 200; Rect ExitSign = new Rect(); ExitSign.X = 25; ExitSign.Y = 340; ExitSign.Width = 550; ExitSign.Height = 200; Rect instructions = new Rect(); instructions.X = 25; instructions.Y = 55; instructions.Width = 550; instructions.Height = 60; string select_Colors = "DARK ORANGE \n\nGREEN \n\nCYAN \n\nHOT PINK\n\n"; string select_Music = "SONG 1\n\nSONG 2\n\nSONG 3\n\n"; CanvasTextFormat SettingsFormatOfTitleText = new CanvasTextFormat() { FontFamily = "Courier New", FontSize = 25 }; args.DrawingSession.DrawText("SETTINGS!!!", SettingsTitleRec, Colors.White, SettingsFormatOfTitleText); args.DrawingSession.DrawText(select_Colors, selectionTextColor, Colors.White, SettingsFormatOfTitleText); args.DrawingSession.DrawText(select_Music, selectionTextMusic, Colors.White, SettingsFormatOfTitleText); args.DrawingSession.DrawText("PRESS ENTER OR X TO GO TO START MENU", ExitSign, Colors.White, SettingsFormatOfTitleText); menuSelector_Settings.draw(args.DrawingSession); args.DrawingSession.DrawText("HIT LEFT AND RIGHT TO SWITCH COLUMNS", instructions, Colors.White, SettingsFormatOfTitleText); } else if (scoreScreen) { Rect scoreScreenRec = new Rect(); scoreScreenRec.X = 20; scoreScreenRec.Y = 20; scoreScreenRec.Width = 570; scoreScreenRec.Height = 570; CanvasTextFormat scoreScreenFormat = new CanvasTextFormat() { FontFamily = "Courier New", FontSize = 30 }; string scoreScreenText = "GAMING HEROS\n\nMARIO ....... 59\nYOSHI ....... 49\nLINK ........ 39\n\n" + "YOU ......... " + snake.playerScore + "\n\n"; if (snake.playerScore > 59) { scoreScreenText += "YOU'RE A TRUE GAMING HERO!!!\n\n"; } else { scoreScreenText += "YOU SUCK! GET BETTER, SCRUB!\n\n"; } scoreScreenText += "PRESS ENTER OR X TO GO TO START\n"; args.DrawingSession.DrawText(scoreScreenText, scoreScreenRec, Colors.White, scoreScreenFormat); } else if (howToPlayDisplaying) { Rect howToPlayRect = new Rect(); howToPlayRect.X = 25; howToPlayRect.Y = 25; howToPlayRect.Width = 550; howToPlayRect.Height = 300; CanvasTextFormat rectFormat = new CanvasTextFormat() { FontFamily = "Courier New", FontSize = 24 }; args.DrawingSession.DrawText("HOW TO PLAY XBOX/WINDOWS:\n\n" + "D-PAD UP/UP ARROW = GO UP\n" + "D-PAD DOWN/DOWN ARROW = GO DOWN\n" + "D-PAD LEFT/LEFT ARROW = GO LEFT\n" + "D-PAD RIGHT/RIGHT ARROW = GO RIGHT\n" + "ENTER = SELECT/BACK/ADVANCE\n" + "A BUTTON = SELECT\n" + "X BUTTON = BACK\n\n" + "PRESS ENTER OR X TO GO TO START MENU", howToPlayRect, Colors.White, rectFormat); } else if (loading) { Rect locOfLoadText = new Rect(); locOfLoadText.X = 125; locOfLoadText.Y = 150; locOfLoadText.Width = 400; locOfLoadText.Height = 200; CanvasTextFormat textFormatOfLoadText = new CanvasTextFormat() { FontFamily = "Courier New", FontSize = 56, FontStyle = Windows.UI.Text.FontStyle.Italic }; args.DrawingSession.DrawText("LOADING...", locOfLoadText, Colors.White, textFormatOfLoadText); } else if (credits) { Rect creditsRec = new Rect(); creditsRec.Y = 20; creditsRec.X = 20; creditsRec.Width = 600; creditsRec.Height = 400; CanvasTextFormat textFormatOfCredits = new CanvasTextFormat() { FontFamily = "Courier New", FontSize = 32 }; string creditsString = "THE CREW:\n\nALEX ROSATI (SUPER COOL)\nAVIAN CALADO (SLEEPY)\nPETER SCHUBERT (COOL)\nNISARG" + " PATEL (COOL) \n\nPRESS ENTER OR X TO GO BACK"; args.DrawingSession.DrawText(creditsString, creditsRec, Colors.White, textFormatOfCredits); } }