paint
Android Paint stroke width positioning
No you can’t; the stroke is always centered. The only things you can control are: stroke miter stroke cap stroke join stroke width You must manually account for the stroke width when defining your drawing paths.
Implementing smooth sketching and drawing on the element
I made something like this a while ago and turned it into a jquery plugin. have a look over here, if it’s what you’re after I’ll post a more detailed answer and dig out the simplified jquery version from my archives: http://jsfiddle.net/95tft/ EDIT OK, sorry I couldn’t do this yesterday: Originally the code above was … Read more
How to draw smooth / rounded path?
Maybe this will create what you want paint.setColor(color); // set the color paint.setStrokeWidth(size); // set the size paint.setDither(true); // set the dither to true paint.setStyle(Paint.Style.STROKE); // set to STOKE paint.setStrokeJoin(Paint.Join.ROUND); // set the join to round you want paint.setStrokeCap(Paint.Cap.ROUND); // set the paint cap to round too paint.setPathEffect(new CornerPathEffect(10) ); // set the path effect … Read more
setShadowLayer Android API differences
setShadowLayer() is only supported on text when hardware acceleration is on. Hardware acceleration is on by default when targetSdk=14 or higher. An easy workaround is to put your View in a software layer: myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null).
Is there already a canvas drawing directive for AngularJS out there?
Ok I did one and it is actually pretty easy: app.directive(“drawing”, function(){ return { restrict: “A”, link: function(scope, element){ var ctx = element[0].getContext(‘2d’); // variable that decides if something should be drawn on mousemove var drawing = false; // the last coordinates before the current move var lastX; var lastY; element.bind(‘mousedown’, function(event){ if(event.offsetX!==undefined){ lastX = … Read more
Drawing a filled rectangle with a border in android
Try paint.setStyle(Paint.Style.FILL) and paint.setStyle(Paint.Style.STROKE). Paint paint = new Paint(); Rect r = new Rect(10, 10, 200, 100); @Override public void onDraw(Canvas canvas) { // fill paint.setStyle(Paint.Style.FILL); paint.setColor(Color.MAGENTA); canvas.drawRect(r, paint); // border paint.setStyle(Paint.Style.STROKE); paint.setColor(Color.BLACK); canvas.drawRect(r, paint); }
How do I draw bold text on a Bitmap?
Use the setTypeface method on your Paint object to set the font to something with the bold style turned on. paint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));