I'm searching how to set own bitmap like stylus of my path which I draw on canvas. This is exactly implemented in Sketchbook and it is perfect. Which classes I must use? Can you recommend me some solution, please?
Related
I don't know alot about graphics and drawings but I am trying to do something on canvas, and that is using vector graphics instead of bitmap to draw path on canvas with finger , I cant find any documentation or tutorials to understand how to do that, but I know that this implementation is used by some drawing apps.
According to my searching I deduced that using vector graphics will never show pixels on the edges of the path even if you zoomed.
Please suggest any thing that might help me use vector graphics and attach it to canvas to draw, thanks.
If you just want to draw with the finger :
Assuming you have a custom View that covers the drawing area ...
On onTouch handler on ACTION_DOWN create a new Path object with origin at touch point, on ACTION_MOVE you add new segments to the Path and call invalidate().
On onDraw you draw the Path on the Canvas.
I m working on canvas. Here I just want to draw some geometric figures on canvas which may be resized according to the touch_move positions. By figures , I just meant triangle,rectangle,circle and some polygons. Is there a way to achieve this? . I haven't seen such apps which can draw these figures over canvas. So this seems to be complicated.. Thanks in advance
See this link.
If your application does not require a significant amount of processing or frame-rate speed (perhaps for a chess game, a snake game, or another slowly-animated application), then you should consider creating a custom View component and drawing with a Canvas in View.onDraw(). The most convenient aspect of doing so is that the Android framework will provide you with a pre-defined Canvas to which you will place your drawing calls.
I'm sure you can find some open-sourced out-of-the-box solutions for this if you tried a little.
If you actually want to learn something you should read the tutorials of per example;
-Custom Views
-OpenGL
After doing the tutorials, you'll have 2 ways to draw basic shapes, a triangle and a circle I believe, already done.
easy now.
What I want eventually:
I want to have 2 bitmaps overlayed on a view. Same bitmaps with the one above have higher brightness than the below one.
Now when the user strokes(with touch event (like paint brush)) on the upper bitmap, I want those parts of the upper bitmap to go invisible.
For those who are familiar with adobe photoshop perhaps this will make more sense:
I want to draw a mask on an image being display so that only the unmasked parts remain visible. But the mask can be drawn from a brush with variable hardness/size.
How do I achieve this functionality? Direct me in in the line where I should research or give sample code.
Also, is it possible to draw strokes on an imageview with a brush which has variable hardness? I know that I can drawPath and drawArc on a canvas, but I do not know how to achieve the different brush strokes/styles.
Please pardon me if I haven't phrased my question right, or wasn't able to find similar duplicates.
You can use FrameLayout to overlay one image over other in Android and for Custom Masking search FingerPaint on google.
I think the best way is to do your own off-screen compositing, then render the composited image using an ImageView or perhaps a subclass with custom interaction. See this sample code for an example of how to do such compositing using the Porter-Duff transfer modes.
I have been searching all evening for some way to implement an eraser function for my drawing app. The most common answer is to simply paint the background color or image in, but this solution will not work for my application because I am implementing multiple layers (Gimp/Photoshop style).
The user should be able to draw a line with the brush tools provided in as many layers as they like (the onDraw method of my drawingview draws layer0...layerX on top of each other). Then if they choose the eraser tool it should cause any area of the current layer that they trace over to become transparent.
I cannot seem to find an appropriate class/function built in and am unsure how I could write it myself. I tried to do something like
Paint paint = new Paint();
paint.setAlpha(0);
and then use that Paint object to draw with, but that only draws an 'invisible' line.
I also attempted to use
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
but that just seemed to draw as normal and without effect. I'm probably using it incorrectly, but the Android documentation does not contain a clear description of what it does. I just happened to see it in some examples about modifying bitmaps.
I can supply code as needed, I am just not sure what would be helpful to solve my problem. Being pointed in the right direction would be the biggest help as I have not been successful with Google.
You can find the implementation of eraser function, create new canvas, brush function and save function, on this link :
create android drawing interface
it's have very good tutorial for making drawing app on android using motion event.
Not sure how to do this, or what the right terms are for describing this, but here goes:
I want to make a closing circle animation in my android app, much like the end of this video. I'm guessing what I need to do is somehow draw a black circle but instead of filling the inside of the circle fill the outside. How exactly would I do that, given the tools I have with Android's Canvas class?
Have you tried using clipPath to achieve this?
I was working on the same kind of thing and achieved it by using clipPath of canvas.