Angle gradient in canvas

A context strokeStyle can be a gradient: // create a gradient gradient = ctx.createLinearGradient(xStart, yStart, xEnd, yEnd); gradient.addColorStop(0.0,”blue”); gradient.addColorStop(1.0,”purple”); // stroke using that gradient ctx.strokeStyle = gradient; Example code and a Demo using a gradient strokeStyle: http://jsfiddle.net/m1erickson/w46ps/ <!doctype html> <html> <head> <link rel=”stylesheet” type=”text/css” media=”all” href=”https://stackoverflow.com/questions/22223950/css/reset.css” /> <!– reset css –> <script type=”text/javascript” src=”http://code.jquery.com/jquery.min.js”></script> <style> … Read more

Determine angle of view of smartphone camera

The Camera.Parameters getHorizontalViewAngle() and getVerticalViewAngle() functions provide you with the base view angles. I say “base”, because these apply only to the Camera itself in an unzoomed state, and the values returned by these functions do not change even when the view angle itself does. Camera.Parameters p = camera.getParameters(); double thetaV = Math.toRadians(p.getVerticalViewAngle()); double thetaH … Read more

Rotating Image on A canvas in android

You can either rotate your bitmap when you draw it by using a matrix: Matrix matrix = new Matrix(); matrix.setRotate(angle, imageCenterX, imageCenterY); yourCanvas.drawBitmap(yourBitmap, matrix, null); You can also do it by rotating the canvas before drawing: yourCanvas.save(Canvas.MATRIX_SAVE_FLAG); //Saving the canvas and later restoring it so only this image will be rotated. yourCanvas.rotate(-angle); yourCanvas.drawBitmap(yourBitmap, left, top, … Read more