canvas

Why function returns wrong color in canvas?

折月煮酒 提交于 2019-12-24 23:37:26
问题 My canvas color is 50 255 50 155. When I do a code: function getClickedAreaColor(x, y) { var data = ctx.getImageData(x, y, 1, 1).data, color = []; for (var i = 0; i < data.length; i++) { color.push(data[i]); } return color; } It returns 49 255 49 155 Why is that? 回答1: There is a note in the specs for the getImageData method for such situations: Due to the lossy nature of converting to and from premultiplied alpha color values, pixels that have just been set using putImageData() might be

Drawing video on canvas

試著忘記壹切 提交于 2019-12-24 23:16:51
问题 I'm trying to draw a video from video element on canvas. I wrote the following JS code: $(function () { var video = $("#video"); video.bind("loadedmetadata", function () { var vw = this.videoWidth; var vh = this.videoHeight; var canvas = $('#canvas'); canvas.width(vw).height(vh); var context = canvas.getContext("2d"); video.addEventListener("play", function () { draw(video, context, vw, vh); }, false); }); }); function draw(video, context, vw, vh) { if (video.paused || video.ended) { return

The light component is behind Image in Unity

∥☆過路亽.° 提交于 2019-12-24 23:15:23
问题 I have two different canvases: one for the background and one for the game scene Principal canvas: Background canvas: I'm having this problem: If I put an object in the principal canvas, everything seems to works but If I add a light component to this object, I'll not see the light (it is like the background image is ahead the light): Without the background canvas: With the background canvas: Any idea why? (The problem is not the BGcanvas, the problem is the image component of the BGcanvas,

Canvas handling event, then passing through to iframe…?

天涯浪子 提交于 2019-12-24 22:46:13
问题 Despite searching all evening, I still haven't found a solution to this. I have the following layout in the DOM: <div class="kort_miðja_úti"> <iframe class="kort_miðja" frameborder="0" width="100%" height="100%" src="...."></iframe> <canvas class="kort_canvas"></canvas> </div> The canvas is in front, acting as a transparent overlayer on an interactive map from a different site. So when there's a mouse event, it gets it first. It needs to do things on the mouse events, then forward them on to

generating preview of BMP Image

泄露秘密 提交于 2019-12-24 22:15:41
问题 I am working on a Media up-loader which uploads images to Server. Before start upload file i want to show small thumbnail of Image. I used Loader class to load image selected by user & used Canvas to draw image on it. This works fine with images like jpg & png. But for bmp file loader class doesn't work. Is there anyway to load bmp image in Flex & Convert it to BitmapData ?? 回答1: I didn't test the example, but you could try this: Parsing and displaying BMP files via ActionScript And read the

paintbox doesnt paint from timer method c++ builder borland

﹥>﹥吖頭↗ 提交于 2019-12-24 22:01:14
问题 I am using Borland C++Builder 6. I have two methods of the form: void __fastcall FDisplay::PaintBox1Paint(TObject *Sender) void __fastcall FDisplay::TimerLabelsViewTimer(TObject *Sender) In the first method I draw the coordinate system. and in the second method I did: PaintBox1->Canvas->MoveTo(693,201); PaintBox1->Canvas->LineTo(770,187); and the line doesn't appear on the coordinate system. my second question, how can I erase the line and return to the base paint? Should I do this? PaintBox1

paper.js Stroke Drawing Inconsistently

≡放荡痞女 提交于 2019-12-24 21:48:41
问题 I am having trouble not only fixing this issue but also reproducing it. I have a web app with a lot going on but the problem I'm having with paper.js is that sometimes the stroke will draw way too large. Here is how it should look: But it draws like this: Anyone have any clues how this could be happening? It only shows up intermittently. Thanks! EDIT: I have figured out that the problem originates from that I dynamically size my <canvas> element to fit the screen on load with jQuery. I have

Connect elements with same class using canvas

▼魔方 西西 提交于 2019-12-24 21:33:07
问题 I'm working on a table that has sets of numbers. every set has one number with class 'exist' because the are present on the first column. What I'm trying to do is, to connect those numbers per column using canvas line. I manage to get their position using offset but don't know how to implement it. Hope you understand me. Thanks. Sample Result $('table tbody tr').each(function(k, x) { $(this).find('td:first-child .rw').each(function(t, u) { const n = $(this).text().trim(); var rw = Array.from

MooTools to jQuery with Canvas element

两盒软妹~` 提交于 2019-12-24 21:21:39
问题 I have found a JS Fiddle that provides a perfect solution for a project I am working on. Unfortunately the framework selected in the fiddle is MooTools. I am working in jQuery 1.9.1 and when I switch framework to jQuery the fiddle breaks. I have tried to change out a few of the things I thought might be causing the issue, but no luck. I'm hoping someone has enough familiarity with both frameworks that they could fork off a jQuery working version of this... http://jsfiddle.net/oskar/Aapn8/ I

How to add text into canvas

孤人 提交于 2019-12-24 21:18:45
问题 I have problem with canvas fillText function. I have this code : scene.shapes['shop1'] = new Shape(); var ps1 = scene.shapes['shop1'].points; // for convenience ps1[0] = new Point(1024, 66, 10); // left bottom ps1[1] = new Point(694, 66, 10); // right bottom ps1[2] = new Point(694, 466, 10); // right top ps1[3] = new Point(1024, 466, 10); // left top // Background scene.shapes['shop1'].polygons.push(new Polygon( [ps1[0], ps1[1], ps1[2], ps1[3] ], new Point(0, 0, 1), true /* double-sided */,