canvas

Convert canvas' mouse coords to geographic coords

落爺英雄遲暮 提交于 2021-02-19 06:10:51
问题 I'm trying to create a map with all the cities of Italy using Python-Tkinter and Canvas . I found a picture of a map of Italy with a few highlighted cities online and inserted it to my Canvas . After that I used a function to determine what are the canvas coordinates of the 2 highlighted cities using: import tkinter as tk class Map(): #Creator-Function def __init__(self,parent): self.canvas=tk.Canvas(width=995,height=971,bg='black') self.canvas.pack(expand=0,fill='none') self.gif=tk

Convert canvas' mouse coords to geographic coords

非 Y 不嫁゛ 提交于 2021-02-19 06:10:18
问题 I'm trying to create a map with all the cities of Italy using Python-Tkinter and Canvas . I found a picture of a map of Italy with a few highlighted cities online and inserted it to my Canvas . After that I used a function to determine what are the canvas coordinates of the 2 highlighted cities using: import tkinter as tk class Map(): #Creator-Function def __init__(self,parent): self.canvas=tk.Canvas(width=995,height=971,bg='black') self.canvas.pack(expand=0,fill='none') self.gif=tk

Fabric JS: How to Transform Fabric Image

僤鯓⒐⒋嵵緔 提交于 2021-02-19 04:41:06
问题 How Can I skew and Scale left or right a Fabric Image inside a Canvas using Fabric JS? I need it to follow the way this monitor is being displayed so I can paste it like it is being displayed on the screen 回答1: Please go through this link. You can set transform and skew as Fiddle var canvas = new fabric.Canvas('canvas'); fabric.Image.fromURL("https://www.google.co.in/images/srpr/logo11w.png", function(img) { img.set({transformMatrix: [1, .30, 0, 1, 0, 0],width:200,height:50,top:100,left:150})

Chrome extension screenshot partial image cropping for Retina Display

扶醉桌前 提交于 2021-02-19 02:53:48
问题 I made a chrome extension, which captures a single element (div) of a website. I used chrome.tabs > captureVisibleTab to make a screenshot. Then, with the coordinates (x/y) and sizes (width/height) of the element (div) I crop the screenshot. This works fine for me on non-retina displays. But not so on a Macbook with Retina display. For example, on www.247activemedia.com, we want to capture the header div with the logo (id="header"). On non-retina result is: On a Macbook with Retina display:

JS Proxying HTML5 canvas context

一世执手 提交于 2021-02-19 02:46:11
问题 I'm hoping to proxy the canvas API so I can test that abstracted methods do actually draw to the canvas, however I'm hitting issues where after proxing I get an error: 'strokeStyle' setter called on an object that does not implement interface CanvasRenderingContext2D This code is simplified but throws the same error: /** !NB: This snippet will probably only run in Firefox */ var canvas = document.createElement("canvas"); canvas.width = 100; canvas.height = 100; canvas.style.backgroundColor =

canvas drawtext with multiline

大憨熊 提交于 2021-02-19 02:19:32
问题 I am developing a image commenting application. I draw text in canvas with canvas.drawText(text, x, y, imgPaint); This appears in a single line. I need to break the line to multiline when the text crosses the canvas width Thanks in advance 回答1: You need to use StaticLayout : TextPaint mTextPaint=new TextPaint(); StaticLayout mTextLayout = new StaticLayout("my text\nNext line is very long text that does not definitely fit in a single line on an android device. This will show you how!",

toDataURL() of webgl canvas returning transparent image in iOS only

房东的猫 提交于 2021-02-18 22:43:24
问题 I have a canvas with webGL-drawings, created by Blend4Web framework. I tried to save image using toDataURL() : image= $('canvas')[0].toDataURL(); All platforms works perfect, except iOS (iphone & ipad) I know about webGL aspects: Canvas toDataURL() returns blank image only in Firefox, preserveDrawingBuffer is enabled. Also, I know about limitations in iOS: iOS HTML5 Canvas toDataURL, but canvas is small, even 100×500px images are blank (it is 0,05MP, limit is 3MP). I use toDataURL() to send

toDataURL() of webgl canvas returning transparent image in iOS only

一笑奈何 提交于 2021-02-18 22:41:51
问题 I have a canvas with webGL-drawings, created by Blend4Web framework. I tried to save image using toDataURL() : image= $('canvas')[0].toDataURL(); All platforms works perfect, except iOS (iphone & ipad) I know about webGL aspects: Canvas toDataURL() returns blank image only in Firefox, preserveDrawingBuffer is enabled. Also, I know about limitations in iOS: iOS HTML5 Canvas toDataURL, but canvas is small, even 100×500px images are blank (it is 0,05MP, limit is 3MP). I use toDataURL() to send

Why I cannot use Konva.Image() in Konva.Shape.fillPatternImage(imageObj)?

梦想与她 提交于 2021-02-18 18:11:04
问题 The following is an example from Konvajs library to load an image: var imageObj = new Image(); imageObj.onload = function() { var yoda = new Konva.Image({ x: 50, y: 50, image: imageObj, width: 106, height: 118 }); And here is my code var annotation = new Konva.Line({ points: this.contour, stroke: color, closed: true, strokeWidth: 1 }); var nativeImageObject = new Image(); nativeImageObject.onload = function() { var konvaImage = new Konva.Image({ image: nativeImageObject }); annotation

Why I cannot use Konva.Image() in Konva.Shape.fillPatternImage(imageObj)?

大憨熊 提交于 2021-02-18 18:04:09
问题 The following is an example from Konvajs library to load an image: var imageObj = new Image(); imageObj.onload = function() { var yoda = new Konva.Image({ x: 50, y: 50, image: imageObj, width: 106, height: 118 }); And here is my code var annotation = new Konva.Line({ points: this.contour, stroke: color, closed: true, strokeWidth: 1 }); var nativeImageObject = new Image(); nativeImageObject.onload = function() { var konvaImage = new Konva.Image({ image: nativeImageObject }); annotation