[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft-devel] [GSoC] [Doubt] Bitmap rendering

From: k kushal
Subject: Re: [ft-devel] [GSoC] [Doubt] Bitmap rendering
Date: Fri, 23 Jun 2017 17:30:40 +0000

On Fri, 23 Jun 2017 at 10:55 PM, Arvinder Bhathal <address@hidden> wrote:
> I wanted to know if anyone knew how to display the pixel grid
> (like the one in ftgrid) on webpage. (Arvinder ?)

If the goal is just to have a grid of some size with pixel-level
control, then a canvas of the appropriate size would do.
  // create a blank canvas
  <canvas id="canvas" width="100" height ="100"></canvas>
  In JS:
  var canvas = document.getElementById('canvas');
  var ctx = canvas.getContext('2d');
  // get a pixel from the canvas
  var pixel= ctx.getImageData(x-coord, y-coord, 1, 1);
  // pixelData is an array of unsigned 8-bit integers representing
pixel data in RGBA order. If 'pixel' was more than a single pixel, the
data would be ordered row by row
  var pixelData =;
  // make the pixel black
  pixelData[0] = 0;
  pixelData[1] = 0;
  pixelData[2] = 0;
  // write the pixel back to the canvas
  ctx.putImageData(pixel, x-coord, y-coord);

Is this any help? I think I may have missed the goal of what you
wanted from the grid since the resulting image from all the above
could just be done in C.
Do we get visible grid (the lines) using this ?
If so, the computation for the resultant image we want could be done in C and put it in here. 
And also, no need of GIF(s). We can give the same transition effect using canvas. 
( All this is just for the lines ) :) 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]