javascript - canvas library for drawing images - Stack Overflow

HTML5 canvas provides lots of flexibility to draw images using javascript. We need to generate javascri

HTML5 canvas provides lots of flexibility to draw images using javascript. We need to generate javascript code based on inputs from the user (say something like 10 balls of blue color, 5 squares of green color and of a certain size ...). Is there an library which provides appropriate Javascript API(s) so that it is easier to generate the canvas along with the javascript code for requirements listed above?

HTML5 canvas provides lots of flexibility to draw images using javascript. We need to generate javascript code based on inputs from the user (say something like 10 balls of blue color, 5 squares of green color and of a certain size ...). Is there an library which provides appropriate Javascript API(s) so that it is easier to generate the canvas along with the javascript code for requirements listed above?

Share Improve this question edited Oct 7, 2010 at 21:33 kangax 39.2k13 gold badges100 silver badges135 bronze badges asked Oct 7, 2010 at 10:46 user339108user339108 13.1k34 gold badges82 silver badges112 bronze badges 2
  • Java APIs? Do you mean JavaScript APIs? – Matt Ball Commented Oct 7, 2010 at 14:47
  • Yes (either Java or Javascript based) abstraction should be fine. I have used code.google./p/charts4j before and found it to tbe useful. – user339108 Commented Oct 8, 2010 at 11:37
Add a ment  | 

1 Answer 1

Reset to default 6

With Fabric.js it's quite trivial to draw simple shapes (circles, rectangles, etc.) on canvas. It also supports image importing and manipulation.

Displaying rectangle, for example is as easy as:

var canvas = new fabric.Canvas('id_of_canvas_element');

var rect = new fabric.Rect({
  top: 100,
  left: 100,
  width: 60,
  height: 70,
  fill: 'red'
});

canvas.add(rect);

Take a look at demos.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745559886a4633044.html

相关推荐

  • javascript - canvas library for drawing images - Stack Overflow

    HTML5 canvas provides lots of flexibility to draw images using javascript. We need to generate javascri

    19小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信