canvas

Canvas DrawImage() poor quality [duplicate]

半城伤御伤魂 提交于 2021-02-04 13:20:15
问题 This question already has answers here : Html5 canvas drawImage: how to apply antialiasing (6 answers) Closed 5 years ago . I have a problem with Html5 canvas i draw an image but its quality becomes very poor after i draw it with canvas it becomes this my code is here <script type="text/javascript"> $canvasWidth = $('#canvas').width; $canvasHeight = $('#canvas').height; var alpha = 0.0; var canvas = document.getElementById('canvas'); var ctx = canvas.getContext('2d'); function draw(){ var

Why the canvas widget into Tkinter with Python 3 is slow?

拥有回忆 提交于 2021-01-29 21:01:51
问题 I've just started to use the Tkinter module with Python(3.2), so I decided to rewrite my old program(I used curses module) with this module. The program is a Game of Life simulator. The algorithm I've implemented works so quickly without the user interface. This is my program(it is a fast experiment, I never used the canvas widget): #!/usr/bin/python3 import gol import Tkinter as tk class Application(tk.Frame): def __init__(self): self.root = tk.Tk() self.root.wm_title('Canvas Experiments')

How can I implement word wrap and carriage returns in canvas fillText?

假如想象 提交于 2021-01-29 20:38:08
问题 I'm trying to display textarea information that has been stored in a MariaDB. I don't have a problem storing the text information. What I'm having a problem with is transition the formatting from the text area to the canvas I want it displayed in. The goal is to have a user fill in the notes in a textarea and then have those displayed in the separate canvas report. Right now, I can get the wordwrap working successfully using this code I have stored in a wordWrap.js file: function wrapText (c,

Creating canvas on top of SurfaceView android

前提是你 提交于 2021-01-29 20:08:49
问题 I am trying to create canvas like the below image on the top SurfaceView using which i will open the camera This rectangular canvas should support every screen size in android and should be at center_vertical and center_horizontal of the screen with rest of the screen as translucent black as displayed in the image. I am very new with Canvas and have tried this: Java: package com.example.cameraapplication; import android.content.Context; import android.graphics.Canvas; import android.graphics

HTML5 Cut out circle from previous drawn strokes

*爱你&永不变心* 提交于 2021-01-29 18:03:21
问题 How can you cut out a circle on a previous drawn canvas in html5? I tried filling it transparent, and of course it did not work, I can fill it with a color but I really need it to be cut out of the canvas revealing the layer beneath. This is what I tried. context.beginPath(); context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false); context.fillStyle = "rgba(0, 0, 0, 0)"; context.fill(); and context.beginPath(); context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false); context

I get invalid type error when trying to call readPixels

拟墨画扇 提交于 2021-01-29 16:56:22
问题 context.readPixels(0, 0, context.drawingBufferWidth, context.drawingBufferHeight, context.RGBA, context.FLOAT, pixels); This is the code. I get this error in the console: WebGL: INVALID_ENUM: readPixels: invalid type But this works perfectly fine: context.readPixels(0, 0, context.drawingBufferWidth, context.drawingBufferHeight, context.RGBA, context.UNSIGNED_BYTE, pixels); Float or int is supposed to be supported, but only unsigned_byte works. There's no resource online on how to correctly

How create a line with borders in HTML5 canvas properly

a 夏天 提交于 2021-01-29 16:26:40
问题 I want to draw a path of lines with borders in html, to render the streets in a map, but I could not find any standard way to do that, so I resourced to draw two superposed lines, the first one thicker than the second. The first attempt actually worked well: <!DOCTYPE html> <html> <body> <canvas id="myCanvas" width="1000" height="1000" style="border:1px solid #000000;"> Your browser does not support the HTML5 canvas tag. </canvas> <script> var c=document.getElementById("myCanvas"); var ctx=c

size/coordinates of wrapped text object in tkinter Canvas

家住魔仙堡 提交于 2021-01-29 12:32:50
问题 How do I get coordinates of a wrapped text object in Tkinter Canvas? I know I can use canvas.bbox(text_object) but it will give me only box coordinates. But if the text is wrapped I need to get coordinates of last char in the last line. I want to put a polygon under text so as to make background color for text only. I got this using canvas.bbox(text_object) I want it to be like this : 回答1: You can use canvas.find_overlapping(x, y, x+1, y+1) to find the boundaries of your text: import tkinter

Attaching event to self (canvas) tkinter

 ̄綄美尐妖づ 提交于 2021-01-29 08:06:09
问题 i have created a class in python that extends the tkinter canvas. I am trying to attach an event to this canvas to handle click's within the class. It functions if i attach the event outside of the class itself but when binding within the class the click event only occur's once and then proceeds not to do anything at all only performing the first click: class myCanvas(Canvas): def callback(event): print('clicked at', event.x, event.y) def __init__(self, parent, **kwargs): Canvas.__init__(self

Attaching event to self (canvas) tkinter

廉价感情. 提交于 2021-01-29 08:00:26
问题 i have created a class in python that extends the tkinter canvas. I am trying to attach an event to this canvas to handle click's within the class. It functions if i attach the event outside of the class itself but when binding within the class the click event only occur's once and then proceeds not to do anything at all only performing the first click: class myCanvas(Canvas): def callback(event): print('clicked at', event.x, event.y) def __init__(self, parent, **kwargs): Canvas.__init__(self