Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Autobuild

  • Loading branch information...
commit 5696b61cdc6144510baa328b6931fe1aedd13a36 1 parent a0f7bcb
@o3builder o3builder authored
Showing with 40 additions and 16 deletions.
  1. +40 −16 example/nodecanvas.js
  2. BIN  lib/o3-canvas/o3-lin32.node
View
56 example/nodecanvas.js
@@ -16,11 +16,9 @@
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-var canvasFactory = require('../lib/o3-canvas')
-
-function drawtocontext(ctx)
+var canvasFactory = require('../index.js')
+function oldtestshapes(ctx)
{
- ctx.clearRect(0,0,300,300)
ctx.fillStyle = "rgb(200,0,0)";
ctx.fillRect (10, 10, 55, 50);
@@ -40,18 +38,41 @@ function drawtocontext(ctx)
ctx.fill();
ctx.stroke();
-
- ctx.strokeStyle= "rgb(255,128,0)";
- ctx.beginPath();
- ctx.moveTo(75,25);
- ctx.quadraticCurveTo(25,25,25,62.5);
- ctx.quadraticCurveTo(25,100,50,100);
- ctx.quadraticCurveTo(50,120,30,125);
- ctx.quadraticCurveTo(60,120,65,100);
- ctx.quadraticCurveTo(125,100,125,62.5);
- ctx.quadraticCurveTo(125,25,75,25);
- ctx.stroke();
+}
+function drawtocontext(ctx)
+{
+ ctx.fillStyle = "rgb(200,200,200)";
+ ctx.fillRect(0,0,300,300);
+
+ ctx.strokeStyle= "rgb(0,0,0)";
+ for (var i = 0;i<10;i++)
+ {
+ ctx.save();
+
+ var color = Math.floor(200+Math.random()*55);
+
+ ctx.fillStyle = "rgba(255,255,"+color+",0.4)";
+
+ ctx.translate(50+Math.random()*200, Math.random()*200);
+ var sx = Math.random()+ 0.5;
+ var sy = sx;
+ if (Math.random()<0.5) sx = -sx;
+ ctx.scale(sx,sy);
+ //ctx.lineWidth = 4;
+ ctx.beginPath();
+ ctx.moveTo(75,25);
+ ctx.quadraticCurveTo(25,25,25,62.5);
+ ctx.quadraticCurveTo(25,100,50,100);
+ ctx.quadraticCurveTo(50,120,30,125);
+ ctx.quadraticCurveTo(60,120,65,100);
+ ctx.quadraticCurveTo(125,100,125,62.5);
+ ctx.quadraticCurveTo(125,25,75,25);
+
+ ctx.fill();
+ ctx.stroke();
+ ctx.restore();
+ };
}
/*
function draw()
@@ -67,8 +88,11 @@ http.createServer(function (req, res) {
var ctx = canvasFactory(300,300, "argb");
drawtocontext(ctx);
var buf = ctx.pngBuffer();
+ var buf2 = ctx.jpgBuffer();
res.writeHead(200, {'Content-Type': 'text/html'});
- res.end('<img alt="Embedded Image" src="data:image/png;base64,'+buf.toBase64()+'">');
+ res.end('<img alt="Embedded Image" src="data:image/png;base64,'+buf.toBase64()+'"><br>'
+ +'<img alt="Embedded Image" src="data:image/png;base64,'+buf2.toBase64()+'">'
+ );
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');
View
BIN  lib/o3-canvas/o3-lin32.node
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.