canvas

GIF animation on canvas with frame control

不想你离开。 提交于 2021-01-28 10:42:02
问题 I have some frames within gif and i want to play them on canvas with collision detection. Is there someway how to extract frames from gif with javascript? 回答1: The short answer is that JavaScript has no simple way of controlling the current frame of an Animated GIF. The long answer is that there are sort-of ways to do what you want with just JS, but they are very much convoluted hacks. Example of hackish way: Create a canvas and don't add it to the DOM (so this won't be seen by anyone). In a

GIF animation on canvas with frame control

ぐ巨炮叔叔 提交于 2021-01-28 10:40:44
问题 I have some frames within gif and i want to play them on canvas with collision detection. Is there someway how to extract frames from gif with javascript? 回答1: The short answer is that JavaScript has no simple way of controlling the current frame of an Animated GIF. The long answer is that there are sort-of ways to do what you want with just JS, but they are very much convoluted hacks. Example of hackish way: Create a canvas and don't add it to the DOM (so this won't be seen by anyone). In a

How could we load a local image on a canvas?

时间秒杀一切 提交于 2021-01-28 08:01:04
问题 Hello and thank you for your time reading this question: I was trying to do an excercise to learn React, and because of I recently did a code in JS to load a file from local, an image, into a canvas, and then when user clicks on it circles are drawn; I tryed to do the same in React. Here is the JS excercise: https://codereview.stackexchange.com/questions/186526/read-an-image-file-into-a-canvas-and-display-click-coordinates I have created a canvas in Canvas' component's render(), and after

JS: Alter Color for specific image in HTML Canvas

江枫思渺然 提交于 2021-01-28 07:31:55
问题 Let say I got the sprite to the left and I want to apply a red filter over the image before drawing it in a canvas so it looks like the sprite to the right. http://puu.sh/6dQ0E.png Is there a way to do that? It could be done in two steps, but I don't know if it's possible to draw the geometric figure that has the exact same shape than the image. (Ex: Drawing a rectangle over it won't match.) Note: I want the filter to only be applied to this image, not the whole canvas. 回答1: You can combine 2

How to put an html element over a fabric.js element

我是研究僧i 提交于 2021-01-28 05:22:45
问题 I want to put a button over a fabric.js element which is inside of a fabric.Group. How do I get the top-left corner coords relative to the canvas container of a fabric element and then set it to the button?. jsfiddle: https://jsfiddle.net/d9sp16yc/2/ I've tried things like this or this but I don't get the results that I want. The button gets slightly moved to right or left / bottom or top. Another thing is that the setSize function is scaling the group when the window gets resized (just to

Optimizing pixi grid viewport

人盡茶涼 提交于 2021-01-28 05:21:43
问题 I am using pixi.js to create an interactive grid. This grid is composed of PIXI Graphics rectangles. I am now creating a layout of 25000 rectangles and the browser is having a hard time to process it (code sandbox below) This is my setup : setup() { // making a 30 x 13 grid of tiles for (let i = 0; i < 25000; i++) { let square = new PIXI.Graphics(); square.beginFill(0xF2F2F2); square.drawRect(0, 0, 25, 25); square.endFill(); // Opt-in to interactivity square.interactive = true; square

Blurry pixel paint on scaled canvas drawBitmap on Samsung devices

雨燕双飞 提交于 2021-01-28 05:20:36
问题 Some users encountered blurry pixels issue on Samsung devices. I don't have any Samsung device to check, but there is no problems with phones I have. I can't understand what is different on Samsung and why there is no issue with other devices! It will be very nice if someone could help me to understand! Thank you! How it looks on samsung My code: protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.save(); canvas.translate(imagePosition.getX(), imagePosition.getY()); canvas

How to stop the event bubble in easljs?

拥有回忆 提交于 2021-01-28 05:13:15
问题 I have a mousedown event listener on stage and a mousedown event listener on a shape.when I click on the shape, the mousedown event listener on stage will also fire? How to solve this? var stage = new createjs.Stage("test"); stage.addEventListener('stagemousedown',mouseDown); var shape = new createjs.Shape(); shape.graphics.beginStroke("#000").setStrokeStyle(8,"round").drawRect(0, 0, 100, 100); shape.addEventListener('mousedown',smouseDown); stage.addChild(shape); 回答1: The stagemousedown

Python Tkinter canvas class inheritance

守給你的承諾、 提交于 2021-01-28 03:34:55
问题 Using Tkinter 8.6, Python 3.7.3: A friendly user here instructed me on how to have an image act like a button by the way of creating an Imgbutton class that is a subclass of Tkinter Canvas . I have some questions regarding this code, here is the simplified version of it: #!/usr/local/bin/python3 import tkinter as tk from PIL import Image, ImageTk class Imgbutton(tk.Canvas): def __init__(self, master=None, image=None, command=None, **kw): super(Imgbutton, self).__init__(master=master, **kw)

RectF use dp or px?

China☆狼群 提交于 2021-01-28 01:54:18
问题 In Canvas, drawing an rectangle with RectF, need set top and left in dp or px? Integer padding = 10; Integer width = 100; // It is dp or px? Integer height = 50; RectF position = new RectF(); position.top = 0 + padding; position.bottom = position.top + height; position.left = 0 + padding; position.right = position.left + width; http://developer.android.com/intl/es/reference/android/graphics/RectF.html It does not indicate if the values are represented in px or dp. 回答1: As has already been