canvas

Unable to draw correctly on canvas after zooming in/out ( Scaling)

我的梦境 提交于 2021-02-10 07:38:19
问题 I am unable to draw correctly after scaling. The aim is to allow users to draw rectangles on the image. I am using canvas to display the image and then draw rectangles on image, this is working fine. But now I am trying to add zoom in and zoom out functionality. I need to move the rectangle after zooming in/out , I am able to do so correctly. I have 3 arrays where I am saving the rectangle coordinates: drawItems : Initial rectangle coordinates on draw currentItems : Coordinates after scaling

Drawing a png image on a tkinter canvas python

与世无争的帅哥 提交于 2021-02-09 10:58:30
问题 I am trying to create a simple game using tkinter in python 3.5 using the canvas widget. For this game I am need to be able to use a transparent (png) image. Here is my code: from PIL import ImageTk from tkinter import Tk, Canvas root = Tk() im = ImageTk.PhotoImage(file="test.png") canvas = Canvas(root, width=900, height=900) canvas.pack() canvasImage = canvas.create_image(0, 0, image=im, anchor="nw") root.mainloop() The problem is that, despite getting no errors i can't load an image with a

Drawing a png image on a tkinter canvas python

白昼怎懂夜的黑 提交于 2021-02-09 10:58:13
问题 I am trying to create a simple game using tkinter in python 3.5 using the canvas widget. For this game I am need to be able to use a transparent (png) image. Here is my code: from PIL import ImageTk from tkinter import Tk, Canvas root = Tk() im = ImageTk.PhotoImage(file="test.png") canvas = Canvas(root, width=900, height=900) canvas.pack() canvasImage = canvas.create_image(0, 0, image=im, anchor="nw") root.mainloop() The problem is that, despite getting no errors i can't load an image with a

How to load and draw emojis on canvas efficiently?

你说的曾经没有我的故事 提交于 2021-02-08 21:47:30
问题 I would like to print an emoji on html canvas. It can be done using images, but it is cumbersome. Is there a better way? const canvas = document.querySelector("#canvas"); const contex = canvas.getContext("2d"); var img = new Image(); img.src = "emoji.jpg"; img.addEventListener( "load", () => { context.drawImage(img, 0, 0, 200, 200); } ); img.src = "img.jpg"; #canvas { background: red; } <canvas id="canvas"></canvas> Edit: Okey, I think my question is misunderstood. I am able to draw emoji as

How to load and draw emojis on canvas efficiently?

随声附和 提交于 2021-02-08 21:47:11
问题 I would like to print an emoji on html canvas. It can be done using images, but it is cumbersome. Is there a better way? const canvas = document.querySelector("#canvas"); const contex = canvas.getContext("2d"); var img = new Image(); img.src = "emoji.jpg"; img.addEventListener( "load", () => { context.drawImage(img, 0, 0, 200, 200); } ); img.src = "img.jpg"; #canvas { background: red; } <canvas id="canvas"></canvas> Edit: Okey, I think my question is misunderstood. I am able to draw emoji as

html2canvas and flashcanvas on IE8 not working

不羁岁月 提交于 2021-02-08 19:46:15
问题 I use html2canvas library to make a png image of a table. It works on Chrome, Firefox and Safari. The code is as follows: $('#myTable').html2canvas ({ onrendered : function(canvas) { var img = canvas.toDataURL('image/png'); var newWin = window.open('', '_blank','width=500,height=400'); var htmlPage = ""; htmlPage += "<html>"; htmlPage += "<head>"; ... htmlPage += "</head>"; htmlPage += "<body>"; ... htmlPage += "<img src='"+img+"' width='400px'/>"; ... htmlPage += "</body>"; htmlPage += "<

Rendering text to a kivy canvas

情到浓时终转凉″ 提交于 2021-02-08 14:17:29
问题 I am trying to draw my own graphic within a kivy 'canvas'. For now I have a red or green rectangle which changes colour once per second, but I want to add a changing text label. After a little searching it appears that there isn't a "Text" Instruction which can be added to the canvas. I have found a few references to using a Label() widget as well as the canvas Instructions, but this does not seem ideal, and also I can't seem to get it to render more than once. Here's my object as it stands

Exponential Graph Animation P5js Canvas

寵の児 提交于 2021-02-08 11:02:18
问题 I am trying to animate a growing exponential graph using P5js. I have successfully plotted the graph itself, but the "rulers/scales" on the sides won't work. I want the "window" to scale according to the X and Y axis, just like this example: Animation I am trying to replicate this animation I want the graph to "grow" and the rulers/scales on the sides to represent the growth, X is time and Y the multiplier (big text in the middle). As seen on the animation I linked, X and Y values move

Exponential Graph Animation P5js Canvas

一世执手 提交于 2021-02-08 10:59:45
问题 I am trying to animate a growing exponential graph using P5js. I have successfully plotted the graph itself, but the "rulers/scales" on the sides won't work. I want the "window" to scale according to the X and Y axis, just like this example: Animation I am trying to replicate this animation I want the graph to "grow" and the rulers/scales on the sides to represent the growth, X is time and Y the multiplier (big text in the middle). As seen on the animation I linked, X and Y values move

C# WPF drawing grid

梦想与她 提交于 2021-02-08 10:44:23
问题 I wanna make a drawing grid like this: Can anyone help me please? I have this right now: <Canvas> <Canvas.Background> <DrawingBrush TileMode="Tile" Viewport="0 0 40 40" ViewportUnits="Absolute" Opacity="0.5"> <DrawingBrush.Drawing> <GeometryDrawing> <GeometryDrawing.Geometry> <RectangleGeometry Rect="0,0,50,50"/> </GeometryDrawing.Geometry> <GeometryDrawing.Pen> <Pen Brush="#FF323232" Thickness="0.25"/> </GeometryDrawing.Pen> </GeometryDrawing> </DrawingBrush.Drawing> </DrawingBrush> </Canvas