admin管理员组文章数量:1023053
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
1 Answer
Reset to default 6With 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.
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
1 Answer
Reset to default 6With 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.
本文标签: javascriptcanvas library for drawing imagesStack Overflow
版权声明:本文标题:javascript - canvas library for drawing images - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745559884a2156099.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论