canvas

WPF - How to get canvas position on mouse click independently of the resolution and resizing

我与影子孤独终老i 提交于 2021-02-05 11:11:56
问题 I found a lot on this subject for HTML 5 JavaScript (like so), but I have found nothing over WPF. I have a canvas that we are creating for selecting points over a image in that canvas. The canvas element in XAML is very simple: <Canvas x:Name="Cnv" Grid.Column="1" Grid.Row="1" /> We are getting the coordinates from mouse click like so: Point p = Mouse.GetPosition(Cnv); Then, we draw something on that point: ellipse = new Ellipse(); ellipse.Fill = Brushes.Transparent; ellipse.Width = 20;

WPF - How to get canvas position on mouse click independently of the resolution and resizing

三世轮回 提交于 2021-02-05 11:11:03
问题 I found a lot on this subject for HTML 5 JavaScript (like so), but I have found nothing over WPF. I have a canvas that we are creating for selecting points over a image in that canvas. The canvas element in XAML is very simple: <Canvas x:Name="Cnv" Grid.Column="1" Grid.Row="1" /> We are getting the coordinates from mouse click like so: Point p = Mouse.GetPosition(Cnv); Then, we draw something on that point: ellipse = new Ellipse(); ellipse.Fill = Brushes.Transparent; ellipse.Width = 20;

WPF - How to get canvas position on mouse click independently of the resolution and resizing

天涯浪子 提交于 2021-02-05 11:10:14
问题 I found a lot on this subject for HTML 5 JavaScript (like so), but I have found nothing over WPF. I have a canvas that we are creating for selecting points over a image in that canvas. The canvas element in XAML is very simple: <Canvas x:Name="Cnv" Grid.Column="1" Grid.Row="1" /> We are getting the coordinates from mouse click like so: Point p = Mouse.GetPosition(Cnv); Then, we draw something on that point: ellipse = new Ellipse(); ellipse.Fill = Brushes.Transparent; ellipse.Width = 20;

Will rendering images outside an HTML5 canvas hurt performance?

六眼飞鱼酱① 提交于 2021-02-05 09:31:58
问题 I'm building a 2D platformer game and I'll have a bunch of the level off the screen. Will it hurt performance to render these, or should I develop some form of 2D occlusion culling to avoid rendering this? Furthermore, how much of a performance hit would this cause? 回答1: The rendering engine should throw out render calls to areas outside the canvas, but I would still recommend not trying to draw to those areas to begin with just to reduce the overall overhead of performing unnecessary logic.

Radius Line Appears on Moving Arc

≯℡__Kan透↙ 提交于 2021-02-05 07:56:27
问题 I was trying to create these shapes moving, the shape is made up of a semicircle and a symmetric upper arc & lower arc. They should be just the shape in front but now there are line like a tail dragging behind when they move. The output shape with unknown tail It seems like these lines are from the moveTo part of upper and lower arcs, but I can't figure out how to solve it. Where should I change to get rid of it? function Fish(x, y, dx, dy, radius){ this.x = x; this.y = y; this.dx = dx; this

Blurry svg in canvas

主宰稳场 提交于 2021-02-05 06:35:05
问题 Why SVG doesn't scale correctly in canvas (it is all pixelated and blurry) ? What am I doing wrong ? All I want is the SVG image to keep it's aspect ratio whatever the canvas size, and alose not have it becoming blurry. var canvas = document.getElementById("screen"), ctx = canvas.getContext("2d"); var img = new Image(); img.src = "http://imgh.us/perso.svg"; img.onload = function() { ctx.drawImage(img, 0, 0); } * { margin: 0; padding: 0; box-sizing: border-box; } html, body { width: 100%;

How i make movable perticuler dots on image with x y position in android?

泪湿孤枕 提交于 2021-02-04 21:14:34
问题 I Have a image and i want to make a 8 dot on image, that dot are move when touch dot and drag to screen, is this possible to make that type of touch and movable dots on image? Show above image on 8 point , i want to result like this image and also that point are move when you touch that point and move on image and also want that point x,y coordinate . i tried below code but its show dots are not in proper form , and all dots move at the same time. class DrawingView extends View { Bitmap

How i make movable perticuler dots on image with x y position in android?

筅森魡賤 提交于 2021-02-04 21:13:32
问题 I Have a image and i want to make a 8 dot on image, that dot are move when touch dot and drag to screen, is this possible to make that type of touch and movable dots on image? Show above image on 8 point , i want to result like this image and also that point are move when you touch that point and move on image and also want that point x,y coordinate . i tried below code but its show dots are not in proper form , and all dots move at the same time. class DrawingView extends View { Bitmap

What is the getCSSCanvasContext() method of an HTML5 element?

二次信任 提交于 2021-02-04 14:40:12
问题 What is the getCSSCanvasContext() method? I saw it in Chrome’s debuging console, but I cannot find any decent documentation for it. Does it mean we can draw using canvas commands on any element? 回答1: The method is implemented in WebKit (meaning you can also use it in Safari) and returns an object that lets you draw into a CSS image. See this blog post for an example: In the latest nightlies, you can try out a new feature: the ability to specify named image buffers in CSS and then to draw into

get clicks through html canvas

寵の児 提交于 2021-02-04 14:26:48
问题 I'm seeing a lot of questions about how to get the html5 canvas element to receive mouse clicks, I'm using the canvas as an overlay and the mouse clicks aren't going through to the elements below. I'm loading an image into the canvas, and I thought that might be the problem but I've also tried it with an empty canvas and I get the same result. Here is an example: with the image: http://www.1luckypixel.com/paranormal/canvas_test.html the link goes to google but it's not registering. It's my