antwankakki / FabricView

A new canvas drawing library for Android. Aims to be the Fabric.js for Android. Supports text, images, and hand/stylus drawing input. The library has a website and API docs, check it out
http://antwankakki.github.io/FabricView/
Apache License 2.0
1.04k stars 184 forks source link

getRotation has effect? #8

Closed eling13 closed 8 years ago

eling13 commented 8 years ago

1、Interactive Modes, Like ROTATE_MODE, it can rotate the canvas or bitmap?? for example, i want to rotate the Text which has been chosen, can it work?

2、If i want to put a pic or text on somewhere i touch, how can i do? how can i get the touchEvent x,y coordinate?

antwankakki commented 8 years ago
  1. Thats the plan and thats why there are TODO's next to them in the source code, again, this is a very premature alpha build.
  2. You can implement an OnTouchListener in your activity. and then set the fabricView's on touch listener to be that. and in your activity's onTouchEvent, you can intercept the MotionEvent (http://developer.android.com/reference/android/view/MotionEvent.html) and get the touch coordinates from there. after that you can draw a pic on it by calling the fabricView.drawImage method with the coordinates you got earlier.
eling13 commented 8 years ago

Thanks for replying. yes,It is a big work for a full funciton library. I appreciate it and keep watching on it. I will try the method you said, but the TouchEvent Interactive must be better packaged into the library,not in the activity. :)

antwankakki commented 8 years ago

No problem! and will take that into consideration of the library's design :+1:

eling13 commented 8 years ago

I got a problem.... why I get the mFabricView.getCanvasBitmap(),and I save it to the SD Card,and then I get the bitmap and found that its background is black, it's not the note line background(I set it note mode)... I save it using the jpeg format

antwankakki commented 8 years ago

I am at school right now. I am suspecting its due to the background being ignored and set to transparent and then when you are saving it as jpeg its changing the transparency to black.

eling13 commented 8 years ago

Thanks for your reply. I look at your source code,and found that in the @Overrinde onDraw the drawBackground api does not uses the var mBackgroundColor even thought it was been set to white...
If you don't use canvas.drawColor(mBackgroundColor); to fill the canvas, it will be a transparent as default, I insert canvas.drawColor(mBackgroundColor); ,and then saving it as jpeg ,Its background is Notebook_pager ,that's very good,

eling13 commented 8 years ago

public void drawBackground(Canvas canvas, int backgroundMode) { canvas.drawColor(mBackgroundColor); // So, I just insert this code before judging the backgroundMode .... }

public void setBackgroundColor(int mBackgroundColor) { this.mBackgroundColor = mBackgroundColor; invalidate();// I put in } I also found that the setBackgroundColor ,you lack of the invalidate(); api. So,It won't redraw the canvas immediately or never.

antwankakki commented 8 years ago

Sweet! Thanks for the notes :) do you wanna do a pull request or should I just add these to the library?

eling13 commented 8 years ago

yes to add to the library, :)

antwankakki commented 8 years ago

Done! Thanks for your contribution :)