그래픽을 렌더링하는 데 도움이되는 자바 스크립트 라이브러리가 있는지 알고 싶습니다. Google을 검색했지만 도구를 찾지 못했습니다. 캔버스에 Gauss 커브를 만들고 싶습니다.Html5 Canvas Javascript libraries?
0
A
답변
2
15 초가 걸렸습니다. 그것이 당신이 원하는 것을 얻을 때까지 그걸 가지고 놀아 라.
$(document).ready(drawGaussian);
var canvasContext;
var points;
var noise = 0;
function drawGaussian()
{
canvasContext = document.getElementById("gaussian-canvas").getContext("2d");
document.getElementById("gaussian-canvas").onclick = cycleNoise;
cycleNoise();
}
function cycleNoise()
{
canvasContext.clearRect(0, 0, 400, 400);
var m = Math.random() > .4
var amount = Math.round(Math.random() * 20000);
var size = Math.round(Math.random() * 3)+1;
document.getElementById("particles").innerHTML = amount;
document.getElementById("size").innerHTML = size;
switch(noise)
{
case 0:
drawGaussianField(amount, size, 200, 200, 400, 100, m);
document.getElementById("type").innerHTML = (m ? "Monochromatic" : "Chromatic") + " Field";
break;
case 1:
drawGaussianCurves(amount, size, 200, 200, 400, 150, m);
document.getElementById("type").innerHTML = (m ? "Monochromatic" : "Chromatic") + " Curves";
break;
case 2:
drawGaussianDiamond(amount, size, 200, 200, 400, 130, m);
document.getElementById("type").innerHTML = (m ? "Monochromatic" : "Chromatic") + " Diamond";
break;
case 3:
drawGaussianOval(amount, size, 200, 200, 300, 300, m);
document.getElementById("type").innerHTML = (m ? "Monochromatic" : "Chromatic") + " Circle";
break;
case 4:
drawGaussianBurst(amount, size, 200, 200, 120, 120, m);
document.getElementById("type").innerHTML = (m ? "Monochromatic" : "Chromatic") + " Burst";
break;
}
noise++;
if(noise > 4) noise = 0;
}
function drawGaussianField(amount, thickness, x, y, width, height, monochromatic)
{
for(i = 0; i < amount; i++)
{
points = getGaussianPoints();
setColor(monochromatic);
canvasContext.fillRect(x + ((width*.5) * points[3]), y + ((height*.5) * points[2]), thickness, thickness);
}
}
function drawGaussianCurves(amount, thickness, x, y, width, height, monochromatic){
for(i = 0; i < amount; i++)
{
points = getGaussianPoints();
setColor(monochromatic);
canvasContext.fillRect(x + ((width*.5) * points[0]), y + ((height*.5) * points[2]), thickness, thickness);
}
}
function drawGaussianDiamond(amount, thickness, x, y, width, height, monochromatic){
for(i = 0; i < amount; i++)
{
points = getGaussianPoints();
setColor(monochromatic);
canvasContext.fillRect(x + ((width*.5) * points[0]), y + ((height*.5) * points[3]), thickness, thickness);
}
}
function drawGaussianOval(amount, thickness, x, y, width, height, monochromatic){
for(i = 0; i < amount; i++)
{
points = getGaussianPoints();
setColor(monochromatic);
canvasContext.fillRect(x + ((width*.5) * points[0]), y + ((height*.5) * points[1]), thickness, thickness);
}
}
function drawGaussianBurst(amount, thickness, x, y, width, height, monochromatic){
for(i = 0; i < amount; i++)
{
points = getGaussianPoints();
setColor(monochromatic);
canvasContext.fillRect(x + ((width*.5) * points[2]), y + ((height*.5) * points[3]), thickness, thickness);
}
}
function setColor(val){
if(val)
{
canvasContext.fillStyle = '#ffffff';
}
else
{
canvasContext.fillStyle = "#"+Math.floor(Math.random()*16777215).toString(16);
}
}
function getGaussianPoints(){
var x1, x2, w, y1, y2;
do {
x1 = 2.0 * Math.random() - 1.0;
x2 = 2.0 * Math.random() - 1.0;
w = x1 * x1 + x2 * x2;
} while (w >= 1.0);
w = Math.sqrt((-2.0 * Math.log(w))/w);
y1 = x1 * w;
y2 = x2 * w;
return [x1, x2, y1, y2];
}
2
2
Here 내가 사용하고 KineticJS library 추천 한 자바 스크립트 라이브러리
+0
고마워 ... 나는 안드로이드에 대한 developping 그래서 rapahel 큰 없습니다;)하지만 감사합니다! – Delarn
3
라파엘, 종이 및 처리 사이에 잡지 스매싱에서 좋은 비교가 paper.js 더 완전한 사람 중 하나입니다. 적극적으로 유지 관리되고 정기적으로 업데이트됩니다.
1
Paper.js는 HTML5 캔버스에 매우 적합합니다. 이전에 언급했듯이 SVG 또는 VML 기반의 라이브러리는 안드로이드 장치에서 작동하지 않기 때문에 피해야합니다.
관련 문제
- 1. Html5, JavaScript, Canvas Animations?
- 2. JavaScript/HTML5 Canvas - 이미지 배열로드
- 3. HTML5 Canvas 내에서 마우스 커서 숨기기 Javascript
- 4. Javascript : Collision Detection Help (HTML5 Canvas)
- 5. HTML5 Canvas rendering oddly
- 6. HTML5 canvas "reset"fillStyle
- 7. HTML5, Canvas 및 FireFox
- 8. HTML5 Canvas line drawing
- 9. HTML5 Canvas, shadowColor & shadowBlur
- 10. android의 html5 canvas
- 11. Canvas HTML5 inheritance
- 12. Html5 canvas text interactive?
- 13. HTML5 canvas getPixel
- 14. HTML5 Canvas, GUI
- 15. HTML5 Canvas 대신 Spritely?
- 16. HTML5 Canvas and manipulating
- 17. HTML5 Canvas flashing text?
- 18. HTML5 Canvas with wordpress
- 19. HTML5 canvas lineWidth가 무시됩니다.
- 20. HTML5 - Canvas Shape Stroke
- 21. HTML5 clicable canvas element?
- 22. HTML5 move Canvas 객체
- 23. HTML5 Canvas 이미지 작업
- 24. JQuery, Canvas, Range, Html5
- 25. HTML5 "Canvas is null"
- 26. Like HTML5 Canvas
- 27. HTML5 Canvas Tooltips
- 28. HTML5 Canvas Elements styling?
- 29. HTML5 Canvas - 다른 획
- 30. HTML5 canvas 클릭 및 드래그
20 분 이내에 중복 질문이나 투표 질문으로 마감 될 것으로 예상됩니다. 지금까지 어떤 도구를 찾았습니까? –
그만한 가치가있는 곳은 html5 캔버스 자습서입니다 ... "라이브러리"가 없습니다 – Delarn
https://www.google.com/search?q=canvas+libraries -> [첫 번째 검색 결과] (http : /javascript.open-libraries.com/utilities/drawing/10-best-javascript-drawing-and-canvas-libraries/). –