Can I draw with anti-aliasing on canvas?
I need my circles and line have smooth edges.
Anti-aliasing is the smoothing of jagged edges in digital images by averaging the colors of the pixels at a boundary. The letter on the left is aliased. The letter on the right has had anti-aliasing applied to make the edges appear smoother.
<canvas>: The Graphics Canvas element. Use the HTML <canvas> element with either the canvas scripting API or the WebGL API to draw graphics and animations.
Element used for canvas graphics is <canvas>. The HTML canvas element is used to draw graphics, on the fly, via scripting (usually JavaScript).
Drawing operations want Paint
. In this Paint
you set Paint.setFlags(Paint.ANTI_ALIAS_FLAG)
Check this out. It fairly uses smooth edges.. http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.html
The paint properties needed to get anti-aliasing is :
mPaint = new Paint(); mPaint.setAntiAlias(true);
For drawing use:
mPath = new Path(); mPath.reset(); mPath.moveTo(x, y);//can be used where to trigger the path
onDraw method should contain:
canvas.drawPath(mPath, mPaint);
Declare the mPath and mPaint as global.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With