void Clear(Color color) { if (!isWireframe) { currentDrawingSession.Clear(color); } else { currentDrawingSession.Clear(Colors.White); } }
public async Task SetCanvas(double width, double height, IRandomAccessStream randomAccessStream) { CanvasVisibility = Visibility.Visible; canvasControl.Height = height; canvasControl.Width = width; canvasBitmap = await CanvasBitmap.LoadAsync(canvasControl, randomAccessStream); //CanvasDevice device = CanvasDevice.GetSharedDevice(); //CanvasRenderTarget offscreen = new CanvasRenderTarget(device, (float)width/2,(float)height/2,96); if (PictureCompression.UsePictureCompression) { ScaleEffect effect = new ScaleEffect() { Source = canvasBitmap, Scale = new Vector2((float)(160 / width)) }; CanvasDevice device = CanvasDevice.GetSharedDevice(); CanvasRenderTarget offscreen = new CanvasRenderTarget(device, (float)160, (float)(height * 160 / width), 96); using (CanvasDrawingSession ds = offscreen.CreateDrawingSession()) { ds.Clear(Colors.Black); ds.DrawImage(effect); } canvasControl.Height = offscreen.Size.Height; canvasControl.Width = offscreen.Size.Width; canvasBitmap = offscreen; } canvasControl.Invalidate(); ASCIIText = string.Empty; BitmapImage = new BitmapImage(); }
public void ProcessFrame(ProcessVideoFrameContext context) { using (CanvasBitmap input = CanvasBitmap.CreateFromDirect3D11Surface(canvasDevice, context.InputFrame.Direct3DSurface)) using (CanvasRenderTarget output = CanvasRenderTarget.CreateFromDirect3D11Surface(canvasDevice, context.OutputFrame.Direct3DSurface)) using (CanvasDrawingSession ds = output.CreateDrawingSession()) { TimeSpan time = context.InputFrame.RelativeTime.HasValue ? context.InputFrame.RelativeTime.Value : new TimeSpan(); ds.Clear(Colors.Black); for (uint i = 0; i < numColumns; i++) { for (uint j = 0; j < numRows; j++) { crops[i, j].Source = input; float scale = Rescale((float)(Math.Cos(time.TotalSeconds * 2f + 0.2f * (i + j))), 0.6f, 0.95f); float rotation = (float)time.TotalSeconds * 1.5f + 0.2f * (i + j); Vector2 centerPoint = new Vector2((i + 0.5f) * pixelsPerTile, (j + 0.5f) * pixelsPerTile); transforms[i, j].TransformMatrix = Matrix3x2.CreateRotation(rotation, centerPoint) * Matrix3x2.CreateScale(scale, centerPoint); ds.DrawImage(transforms[i, j]); } } } }
private void ClearCanvas(CanvasRenderTarget crt, Color?color = null) { using (CanvasDrawingSession canvasDrawSession = crt.CreateDrawingSession()) { canvasDrawSession.Clear(color ?? Colors.White); } }
private async void InvertImage(object sender, RoutedEventArgs e) { CanvasDevice device = CanvasDevice.GetSharedDevice(); CanvasRenderTarget target = new CanvasRenderTarget(device, _clickData.Image.PixelWidth, _clickData.Image.PixelHeight, 96); using (CanvasDrawingSession session = target.CreateDrawingSession()) using (var stream = new MemoryStream(_clickData.Data).AsRandomAccessStream()) { session.Clear(Colors.Transparent); session.DrawImage(new InvertEffect { Source = await CanvasBitmap.LoadAsync(device, stream) as ICanvasImage }); } using (var stream = new InMemoryRandomAccessStream()) { await target.SaveAsync(stream, CanvasBitmapFileFormat.Jpeg); var bytes = new byte[stream.Size]; await stream.AsStream().ReadAsync(bytes, 0, bytes.Length); var bitmap = new BitmapImage(); stream.Seek(0); await bitmap.SetSourceAsync(stream); Images[Images.IndexOf(_clickData)].Data = bytes; Images[Images.IndexOf(_clickData)].Image = bitmap; } }
//初始化杂项渲染目标 public static void InitializeOther() { //下杂项渲染目标 (从灰白网格到当前图层) using (CanvasDrawingSession ds = App.Model.SecondBottomRenderTarget.CreateDrawingSession()) { ICanvasImage ci = App.GrayWhiteGrid; //由下向上渲染的图片接口 for (int i = App.Model.Layers.Count - 1; i >= App.Model.Index; i--) //自下而上渲染 { ci = App.Render(App.Model.Layers[i], ci); //渲染 } ds.DrawImage(ci); } //上杂项渲染目标 (从当前图层的的上一层到顶层) using (CanvasDrawingSession ds = App.Model.SecondTopRenderTarget.CreateDrawingSession()) { ds.Clear(Colors.Transparent); ICanvasImage ci = App.Model.NullRenderTarget; //当前图层索引不在0,即并不在第一层 if (App.Model.Index > 0) { for (int i = 0; i < App.Model.Index; i++) //自上而下渲染 { ci = App.Render(App.Model.Layers[i], ci); //渲染 } ds.DrawImage(ci); } } }
public static void Render() { using (CanvasDrawingSession ds = App.Model.SecondSourceRenderTarget.CreateDrawingSession()) { ds.Clear(Colors.Transparent); //左上右下的位置 float LineL = 0; float LineT = 0; float LineR = App.Model.Width; float LineB = App.Model.Height; //线循环 for (float X = LineL; X < LineR; X += App.Setting.GridsSpace) { float xx = LineL + X; ds.DrawLine(xx, LineT, xx, LineB, App.Model.GridsColor); } for (float Y = LineT; Y < LineB; Y += App.Setting.GridsSpace) { float yy = LineT + Y; ds.DrawLine(LineL, yy, LineR, yy, App.Model.GridsColor); } } App.Model.isReRender = true; //重新渲染 App.Model.Refresh++; //画布刷新 }
private async Task Save_InkedImagetoStream(IRandomAccessStream stream) { //var file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(((BitmapImage)backImage.Source).UriSource); CanvasDevice device = CanvasDevice.GetSharedDevice(); CanvasBitmap image; using (var imgStream = await BACK_IMAGE.OpenAsync(FileAccessMode.ReadWrite)) { image = await CanvasBitmap.LoadAsync(device, imgStream); } //var image = await CanvasBitmap.LoadAsync(device, file.Path); //var image = new CanvasBitmap(); using (var renderTarget = new CanvasRenderTarget(device, (int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight, image.Dpi)) { using (CanvasDrawingSession ds = renderTarget.CreateDrawingSession()) { ds.Clear(Colors.White); if (image != null) { ds.DrawImage(image, new Rect(0, 0, (int)inkCanvas.ActualWidth, (int)inkCanvas.ActualHeight)); } ds.DrawInk(inkCanvas.InkPresenter.StrokeContainer.GetStrokes()); } await renderTarget.SaveAsync(stream, CanvasBitmapFileFormat.Png); } }
/// <summary> /// TODO: need to dispose CanvasRenderTarget. /// </summary> /// <param name="canvasDevice"></param> /// <param name="canvasBitmap"></param> private void CreateClipInMemory(CanvasDevice canvasDevice, CanvasBitmap canvasBitmap) { CanvasRenderTarget rendertarget = null; QueryPerformanceCounter(out long counter); var currentTime = TimeSpan.FromMilliseconds(1000f * counter / performanceFrequency); try { rendertarget = new CanvasRenderTarget(canvasDevice, canvasBitmap.SizeInPixels.Width, canvasBitmap.SizeInPixels.Height, canvasBitmap.Dpi, canvasBitmap.Format, canvasBitmap.AlphaMode); using (CanvasDrawingSession ds = rendertarget.CreateDrawingSession()) { ds.Clear(Colors.Transparent); ds.DrawImage(canvasBitmap); } mediaComposition.Clips.Add(MediaClip.CreateFromSurface(rendertarget, currentTime - _timeSpan)); } catch { } finally { _timeSpan = currentTime; } }
private void DrawBackground(CanvasDrawingSession ds, Matrix3x2 transform) { const int levelUpTime = 60; // After levelling up we flash the screen white for a bit Color normalColor = Colors.Blue; Color levelUpFlashColor = Colors.White; var flashAmount = Math.Min(1, (leveledUpTimer / (float)levelUpTime)); ds.Clear(InterpolateColors(normalColor, levelUpFlashColor, flashAmount)); var topLeft = Vector2.Transform(new Vector2(0, 0), transform); var bottomRight = Vector2.Transform(new Vector2(1, 1), transform); var middle = (bottomRight.X - topLeft.X) / 2 + topLeft.X; // and display some text to let the player know what happened if (leveledUpTimer < levelUpTime * 2) { ds.DrawText("Level Up!", middle, 0, Colors.White, levelUpFormat); } // Draw some lines to show where the top / bottom of the play area is. var topLine = topLeft.Y - Letter.TextFormat.FontSize; var bottomLine = bottomRight.Y + Letter.TextFormat.FontSize; Color lineColor = levelUpFlashColor; lineColor.A = 128; ds.DrawLine(0, topLine, bottomRight.X, topLine, lineColor, 3); ds.DrawLine(0, bottomLine, bottomRight.X, bottomLine, lineColor, 3); }
void ClearInkSurface() { using (CanvasDrawingSession ds = renderTarget.CreateDrawingSession()) { ds.Clear(Colors.Transparent); } }
public static void Apply() { if (App.Model.SecondCanvasImage != null) { //Undo:撤销 Undo undo = new Undo(); undo.TargeInstantiation(App.Model.Index, App.Model.CurrentRenderTarget); App.UndoAdd(undo); using (CanvasDrawingSession ds = App.Model.CurrentRenderTarget.CreateDrawingSession()) { //如果有选区:扣掉选区 if (App.Model.isAnimated == true) { ds.DrawImage(App.Model.MaskRenderTarget, 0, 0, App.Model.MainRenderTarget.Bounds, 1, CanvasImageInterpolation.Linear, CanvasComposite.DestinationOut); } //如果没有选区:全部擦除掉 else { ds.Clear(Colors.Transparent); } ds.DrawImage(App.Model.SecondCanvasImage); } App.Model.Layers[App.Model.Index].SetWriteableBitmap(App.Model.VirtualControl);//刷新缩略图 } }
public void DrawChart() { float useHeight = (float)chartGrid.ActualHeight; float useWidth = (float)drawingCanvas.ActualWidth; if (Results == null || Results.Length <= 0 || useHeight == 0 || useWidth == 0) { return; } CanvasDevice device = CanvasDevice.GetSharedDevice(); _offscreenBackGround = new CanvasRenderTarget(device, useWidth, useHeight, 96); using (CanvasDrawingSession ds = _offscreenBackGround.CreateDrawingSession()) { ds.Clear(Colors.LightGray); var tickOffsetX = useWidth / Results.Length; var currentOffsetX = 0.0; for (int i = 0; i < Results.Length; i++) { ds.FillRectangle(new Rect(new Point(currentOffsetX, 0), new Size(tickOffsetX, useHeight)), Results[i] ? TrueColor : FalseColor); currentOffsetX += tickOffsetX; } } //forces re-draw drawingCanvas.Invalidate(); }
private CanvasRenderTarget GetDrawings() { CanvasDevice device = CanvasDevice.GetSharedDevice(); CanvasRenderTarget target = new CanvasRenderTarget(device, (float)_canvasControl.ActualWidth, (float)_canvasControl.ActualHeight, 96); using (CanvasDrawingSession graphics = target.CreateDrawingSession()) { graphics.Clear(Colors.Transparent); if (_bitmap != null) { graphics.DrawImage(_bitmap, GetBitmapRect()); } if (_strokes != null && _strokes.Any()) { var list = _strokes.ToList(); list.Reverse(); list.ForEach((d) => { d.Draw(graphics); }); } if (_currentStroke != null) { _currentStroke.Draw(graphics); } } return(target); }
public void updateRepresentation() { if (boundingbox.Height > 0 && boundingbox.Width > 0) { CanvasDevice device = CanvasDevice.GetSharedDevice(); represent = new CanvasRenderTarget(device, (int)boundingbox.Width, (int)boundingbox.Height, 96); using (CanvasDrawingSession g2d = represent.CreateDrawingSession()) { g2d.Clear(Colors.LightGray); g2d.Antialiasing = CanvasAntialiasing.Antialiased; int xpos = 0; int ypos = 0; for (int y = 0; y < colormatrix.Length; y++) { for (int x = 0; x < colormatrix[y].Length; x++) { xpos = matrixPos.X + x * (pixSize + spacing); ypos = matrixPos.Y + y * (pixSize + spacing); colormatrix[x][y].pickRect = new Rect(xpos, ypos, pixSize, pixSize); if (colorpalette.Count >= 1) { colormatrix[x][y].color = colorpalette.Pop(); } colormatrix[x][y].draw(g2d); } } selectedField.pickRect = new Rect(matrixPos.X, ypos + pixSize + spacing, xpos - pixSize, pixSize + spacing); selectedField.draw(g2d); } } }
private CanvasBitmap _image; //底图 private CanvasRenderTarget GetDrawings(bool edit) { double w, h; //画布大小 if (edit) //编辑状态 { w = MyCanvas.ActualWidth; h = MyCanvas.ActualHeight; } else { Rect des = GetImageDrawingRect(); w = (_image.Size.Width / des.Width) * MyCanvas.Width; h = (_image.Size.Height / des.Height) * MyCanvas.Height; } var scale = edit ? 1 : w / MyCanvas.Width; //缩放比例 CanvasDevice device = CanvasDevice.GetSharedDevice(); CanvasRenderTarget target = new CanvasRenderTarget(device, (float)w, (float)h, 96); using (CanvasDrawingSession graphics = target.CreateDrawingSession()) { graphics.Clear(_back_color); DrawBackImage(graphics, scale); } return(target); }
//Merge Visual:合并可见 private void LayerMergeVisualButton_Click(object sender, RoutedEventArgs e) { App.Model.isCanUndo = false;//关闭撤销 //更新撤销类 Undo undo = new Undo(); undo.CollectionInstantiation(App.Model.Index, App.Model.Layers); App.UndoAdd(undo); //新建渲染目标=>层 CanvasRenderTarget crt = new CanvasRenderTarget(App.Model.VirtualControl, App.Model.Width, App.Model.Height); using (CanvasDrawingSession ds = crt.CreateDrawingSession()) { ds.Clear(Colors.Transparent); ICanvasImage ci = App.Model.NullRenderTarget; for (int i = App.Model.Layers.Count - 1; i >= 0; i--) //自下而上渲染 { ci = App.Render(App.Model.Layers[i], ci); //渲染 } ds.DrawImage(ci); } //删掉所有可视图层 for (int i = App.Model.Layers.Count - 1; i >= 0; i--)//自下而上 { Layer L = App.Model.Layers[i]; if (L.Visual == true) { App.Model.Layers.Remove(L); } } //插入与索引 Layer l = new Layer { Name = App.resourceLoader.GetString("/Layer/NameMerge_"), Visual = true, Opacity = 100, CanvasRenderTarget = crt, }; if (App.Model.isLowView) { l.LowView(); } else { l.SquareView(); } l.SetWriteableBitmap(App.Model.VirtualControl);//刷新缩略图 App.Model.Layers.Insert(0, l); App.Model.Index = 0; App.Model.isCanUndo = true; //打开撤销 App.Model.LayersCount = App.Model.Layers.Count; //Undo:撤销 Jugde(); //判断 }
private void RenderInfo(Size size, CanvasDrawingSession session, string text) { session.Clear(Colors.DarkRed); session.DrawText(text, new Vector2((float)size.Width / 2.0f, (float)size.Height / 2.0f), Colors.DarkRed ); }
public void Run(IBackgroundTaskInstance taskInstance) { // // TODO: Insert code to perform background work // // If you start any asynchronous methods here, prevent the task // from closing prematurely by using BackgroundTaskDeferral as // described in http://aka.ms/backgroundtaskdeferral // _deferral = taskInstance.GetDeferral(); Init().Wait(); CanvasTextFormat txtFmt1 = new CanvasTextFormat { FontSize = 28, FontFamily = "Old English Five", LineSpacingMode = CanvasLineSpacingMode.Proportional, LineSpacingBaseline = 0.8f }; CanvasTextFormat txtFmt2 = new CanvasTextFormat { FontSize = 18, FontFamily = "Segoe UI Emoji", LineSpacingMode = CanvasLineSpacingMode.Proportional, LineSpacingBaseline = 0.8f }; //display on spi if (_displaySpi.State == SSD1603.States.Ready) { //draw using (CanvasDrawingSession ds = _displaySpi.Render.CreateDrawingSession()) { ds.Clear(SSD1603.BackgroundColor); ds.DrawText("Hello", 0, 0, SSD1603.ForeColor, txtFmt1); } _displaySpi.Display(); } //display on i2c if (_displayI2c.State == SSD1603.States.Ready) { //draw using (CanvasDrawingSession ds = _displayI2c.Render.CreateDrawingSession()) { ds.Antialiasing = CanvasAntialiasing.Aliased; ds.TextAntialiasing = CanvasTextAntialiasing.Aliased; //REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "Astronaut III" /t REG_SZ /d "astronautiii.ttf" ds.Clear(SSD1603.BackgroundColor); ds.DrawText("\U0001F600\U00002603\U0001F341\U0001F50D", 0, 0, SSD1603.ForeColor, txtFmt2); } _displayI2c.Display(); } }
public void Clear() { using (CanvasDrawingSession ds = Render.CreateDrawingSession()) { ds.Clear(Color.FromArgb(0xFF, 0, 0, 0)); } Array.Clear(_buffer, 0, _buffer.Length); DisplayBuffer(); }
IDrawingUI _wall_paperUI; // 墙纸 #endregion #region methods /// <summary> /// 获取绘图结果 /// </summary> /// <param name="edit">是否编辑状态,编辑状态需要绘制编辑工具</param> /// <returns></returns> private CanvasRenderTarget GetDrawings(bool edit) { double w, h; //画布大小 if (edit) //编辑状态 { w = MainCanvas.ActualWidth; h = MainCanvas.ActualHeight; } else //最终生成图片 有一定的scale { Rect des = GetImageDrawingRect(); w = (_image.Size.Width / des.Width) * MainCanvas.Width; h = (_image.Size.Height / des.Height) * MainCanvas.Height; } var scale = edit ? 1 : w / MainCanvas.Width; //缩放比例 CanvasDevice device = CanvasDevice.GetSharedDevice(); CanvasRenderTarget target = new CanvasRenderTarget(device, (float)w, (float)h, 96); using (CanvasDrawingSession graphics = target.CreateDrawingSession()) { //绘制背景 graphics.Clear(_back_color); //绘制底图 DrawBackImage(graphics, scale); //绘制涂鸦 if (_doodleUIs != null && _doodleUIs.Count > 0) { var list = _doodleUIs.ToList(); list.Reverse(); list.ForEach((d) => { d.Draw(graphics, (float)scale); }); } if (_current_editing_doodleUI != null) { _current_editing_doodleUI.Draw(graphics, (float)scale); //正在涂鸦对象 在上面 } //绘制贴图 if (_wall_paperUI != null) { _wall_paperUI.Draw(graphics, (float)scale); } //绘制Tag if (_tagsUIs != null) { _tagsUIs.ForEach((t) => { t.Draw(graphics, (float)scale); }); } //绘制Crop裁剪工具 if (_cropUI != null && edit) { _cropUI.Draw(graphics, (float)scale); } } return(target); }
public static void Render() { using (CanvasDrawingSession ds = App.Model.SecondSourceRenderTarget.CreateDrawingSession()) { ds.Clear(App.Model.FillColor); if (App.Setting.FillMode == 0) //填充模式 { if (App.Model.isAnimated == true) //如果选区存在,就扣掉选区 { ds.DrawImage(App.Model.MaskRenderTarget, 0, 0, App.Model.MaskRenderTarget.Bounds, 1, CanvasImageInterpolation.Linear, CanvasComposite.DestinationIn); } } else if (App.Setting.FillMode == 1) //描边模式 { if (App.Model.isAnimated == true) //如果选区存在,就描边 { ds.DrawImage(new LuminanceToAlphaEffect //亮度转不透明度 { Source = new EdgeDetectionEffect //边缘检测 { Amount = 1, Source = App.Model.MaskRenderTarget }, }, 0, 0, App.Model.MaskRenderTarget.Bounds, 1, CanvasImageInterpolation.Linear, CanvasComposite.DestinationIn); } else { ds.DrawImage(new LuminanceToAlphaEffect //亮度转不透明度 { Source = new EdgeDetectionEffect //边缘检测 { Amount = 1, Source = App.GrayWhiteGrid, }, }, 0, 0, App.Model.MaskRenderTarget.Bounds, 1, CanvasImageInterpolation.Linear, CanvasComposite.DestinationIn); } } else if (App.Setting.FillMode == 2) //杂色模式 { ds.DrawImage(new TurbulenceEffect //画柏林噪声 { Octaves = 4, Size = new Vector2(App.Model.Width, App.Model.Height) }, 0, 0, App.Model.MaskRenderTarget.Bounds, 1, CanvasImageInterpolation.Linear, CanvasComposite.DestinationIn); if (App.Model.isAnimated == true)//如果选区存在,就扣掉选区 { ds.DrawImage(App.Model.MaskRenderTarget, 0, 0, App.Model.MaskRenderTarget.Bounds, 1, CanvasImageInterpolation.Linear, CanvasComposite.DestinationIn); } } } App.Model.isReRender = true; //重新渲染 App.Model.Refresh++; //画布刷新 }
public LayerRender(LayerCanvas paint) { Sessions = new CanvasDrawingSession[paint.Canvas.Length]; for (int i = 0, loopTo = Sessions.Length - 1; i <= loopTo; i++) { Sessions[i] = paint.Canvas[i].CreateDrawingSession(); } ForegroundSession = paint.Foreground.CreateDrawingSession(); ForegroundSession.Clear(Colors.Transparent); }
public void Clear(Color color) { UpdateDrawingSessionWithFlags(0); _drawingSession.Clear(color); _matrixSaves.Clear(); _flagSaves.Clear(); _clipSaves.Clear(); }
public void ProcessFrame(ProcessVideoFrameContext context) { bool skipMaskPred = false; if (context.InputFrame.IsDiscontinuous) { streamStartDelta = TimeSpan.FromTicks(DateTime.Now.Ticks) - context.InputFrame.SystemRelativeTime.Value; } else { if ((TimeSpan.FromTicks(DateTime.Now.Ticks) - context.InputFrame.SystemRelativeTime.Value - streamStartDelta) > TimeSpan.FromMilliseconds(maxDelay)) { skipMaskPred = true; } } if (!skipMaskPred) { frameCount++; features["0"] = context.InputFrame; var resTask = _learningModel.EvaluateFeaturesAsync(features, string.Empty).AsTask(); var startTime = DateTime.Now.Ticks; resTask.Wait(); Debug.WriteLine("delta {0}", TimeSpan.FromTicks(DateTime.Now.Ticks - startTime)); } using (CanvasBitmap inputBitmap = CanvasBitmap.CreateFromDirect3D11Surface(canvasDevice, context.InputFrame.Direct3DSurface)) using (CanvasBitmap inputMask = CanvasBitmap.CreateFromDirect3D11Surface(canvasDevice, output.Direct3DSurface)) using (CanvasRenderTarget renderTarget = CanvasRenderTarget.CreateFromDirect3D11Surface(canvasDevice, context.OutputFrame.Direct3DSurface)) using (CanvasDrawingSession ds = renderTarget.CreateDrawingSession()) { ds.Clear(Colors.Green); var addAlpha = new ColorMatrixEffect() { Source = inputMask, ColorMatrix = RToAlpha }; var resize = new ScaleEffect() { Source = addAlpha, Scale = new Vector2(((float)inputBitmap.SizeInPixels.Width / inputMask.SizeInPixels.Width), ((float)inputBitmap.SizeInPixels.Height / inputMask.SizeInPixels.Height)) }; var blend = new AlphaMaskEffect() { Source = inputBitmap, AlphaMask = resize }; ds.DrawImage(blend); ds.DrawText(String.Format("FPS: {0:f1}", currentFPS), fpsLabelOffset, fpsLabelColor); } }
private void CanvasControl_Draw(Microsoft.Graphics.Canvas.UI.Xaml.CanvasControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasDrawEventArgs args) { CanvasDrawingSession ds = args.DrawingSession; ds.Clear(Colors.White); if (canvasBitmap != null) { //ds.DrawRectangle(10, 10, 100, 100, Colors.Red); ds.DrawImage(canvasBitmap); } }
public void Draw(CanvasDrawingSession ds, Size screenSize) { ds.Clear(Colors.Black); ds.Transform = Matrix3x2.CreateTranslation((float)screenSize.Width / 2, (float)screenSize.Height / 2); for (int i = 0; i < stars.Count; i++) { stars[i].Update(); stars[i].Draw(ds); } }
private void Draw(CanvasDrawingSession ds) { ds.Antialiasing = CanvasAntialiasing.Aliased; ds.TextAntialiasing = CanvasTextAntialiasing.Auto; ds.Clear(Colors.Transparent); var renderer = _context.Editor.Renderers[0]; var container = _context.Editor.Project.CurrentContainer; if (container.Template != null) { DrawBackground( ds, container.Template.Background, container.Width, container.Height); renderer.Draw( ds, container.Template, container.Properties, null); } DrawBackground( ds, container.Background, container.Width, container.Height); renderer.Draw( ds, container, container.Properties, null); if (container.WorkingLayer != null) { renderer.Draw( ds, container.WorkingLayer, container.Properties, null); } if (container.HelperLayer != null) { renderer.Draw( ds, container.HelperLayer, container.Properties, null); } }
public void Rendar(CanvasBitmap canvasBitmap) { if (renderTarget != null) { using (CanvasDrawingSession ds = renderTarget.CreateDrawingSession()) { ds.Clear(Colors.Black); ds.DrawImage(canvasBitmap, -ClipImage.X.Value, -ClipImage.Y.Value); } } }
public void Clear() { using (CanvasDrawingSession ds = this.Render.CreateDrawingSession()) { ds.Clear(Color.FromArgb(0xFF, 0, 0, 0)); } Array.Clear(this._buffer, 0, this._buffer.Length); Array.Clear(this.DisplayBuffer, 0, this.DisplayBuffer.Length); this.DisplayBufferFunc(); }
private void DrawBackground(CanvasDrawingSession ds, Matrix3x2 transform) { const int levelUpTime = 60; // After levelling up we flash the screen white for a bit Color normalColor = Colors.Blue; Color levelUpFlashColor = Colors.White; var flashAmount = Math.Min(1, (leveledUpTimer / (float)levelUpTime)); ds.Clear(InterpolateColors(normalColor, levelUpFlashColor, flashAmount)); var topLeft = Vector2.Transform(new Vector2(0, 0), transform); var bottomRight = Vector2.Transform(new Vector2(1, 1), transform); var middle = (bottomRight.X - topLeft.X) / 2 + topLeft.X; // and display some text to let the player know what happened if (leveledUpTimer < levelUpTime * 2) { ds.DrawText("Level Up!", middle, 0, Colors.White, levelUpFormat); } // Draw some lines to show where the top / bottom of the play area is. var topLine = topLeft.Y - Letter.TextFormat.FontSize; var bottomLine = bottomRight.Y + Letter.TextFormat.FontSize; Color lineColor = levelUpFlashColor; lineColor.A = 128; ds.DrawLine(0, topLine, bottomRight.X, topLine, lineColor, 3); ds.DrawLine(0, bottomLine, bottomRight.X, bottomLine, lineColor, 3); }