DrawingView | android上的一个涂鸦控件。可以设置画笔的粗细,颜色,撤销上一笔涂鸦,提供保存图片的接口。 | Canvas library
kandi X-RAY | DrawingView Summary
kandi X-RAY | DrawingView Summary
DrawingView
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Click the image
- Saves the image to the disk
- Undo last path
- Save bitmap to file
- Initializes the activity
- Loads the image into memory
- Initializes the pen
- Initialize views
- Helper method to set the transparent color
- Sets the background color
- Gets the pen color
- Handle touch event
- Initializes this sprite
- Performs a measure on the bitmap
- On draw
- Gets the pen size
DrawingView Key Features
DrawingView Examples and Code Snippets
Community Discussions
Trending Discussions on DrawingView
QUESTION
I´m making a macro that does some actions in Catia v5, I got all the code written by recording it, and it works wonders! But, now i want to be able to just run the code on another catproduct, catpart, etc. But without having to manually change the file name on the code.
CODE:
...ANSWER
Answered 2021-Aug-19 at 19:48Use the Name
or FullName
properties of the Document object.
QUESTION
Creating a drawing app in Studio,Facing null pointer exception as try to access my UI elements As I am using View Binding Rather than normal data binding . Here is the code.
...ANSWER
Answered 2021-Aug-01 at 05:23You're calling findViewById on the Activity, not the dialog. So its searching for that view in the Activity's view tree. Use var smallbtn=dialog.findViewById(R.id.ib_small_brush)
and it should work.
QUESTION
to sum up I am trying to change the src of ImageButtons inside my dialog_colors.xml file from MainActivity. However whatever I do I couldnt manage to change it. I tried the same code with ImageButtons inside my activity_main.xml but it doesnt work for buttons inside dialog_colors.xml file.
activity_main.xlm
...ANSWER
Answered 2021-Jul-24 at 13:34I found a solution to define an attribute in the MainActivity.kt
through activity_main.xml
to content_main.xml
(included layout). The key word here is DataBinding
. The project is completely reproducible and I provide first Kotlin
and at the very end the JAVA
files.
KOTLIN:
To enable DataBinding
you need to go to your build.gradle(Module)
and add following code:
QUESTION
In the code below, I'm trying to replace a sticker with an imageView
keeping the same [Width, Height, TranslateX, TranslateY, and Rotation] of the sticker to give it to the imageView
:
ANSWER
Answered 2021-May-15 at 12:11Perhaps, you have to obtain correct translation values by re-calculating the transform matrix that is compatible to the View's transform.
QUESTION
I am studying Kotlin as my second language and I have been having some troubles. What I want to do : My exercise is to change the color of the balls on the screen when I click on a button. The answer given by my professor is not sufficient and is not executing. I know that it would be easier if a could call the Balls.draw() method but I can not because the canvas is not explicitly defined. I have tried so many other codes but nothing changes.
There is all my files:
Activity_main.xml :
...ANSWER
Answered 2021-Apr-10 at 10:51Your main problem is that you set drawingView.b1.paint.color
in your MainActivity, but in Balls.kt.draw() you set it back to paint.color = color
Then, you should invalidate() the view when you make changes to it.
Meanwhile I refactored your code a little bit, I post it below. The only change in activity_main.xml was that I deleted the Buttons onClick attribute.
QUESTION
Here is the full code of the finger paint app:
DrawingView: https://pastebin.com/4t8SUTDJ
MainActivity: https://pastebin.com/rU4nQwUS
MainActivity XML: https://pastebin.com/GLJjRty2
Stroke: https://pastebin.com/ihs03rEW
...ANSWER
Answered 2021-Jan-09 at 12:36If you are using the same object in the list it will point to the same reference. Changing an object will affect all items in the list.
In your case, all paths inside mUserList
will have the same mNativePath
.
If you want to keep references to all Paths, then you should initiate a new Stroke
object when adding to the mUserList
.
Here is a simplified example to understand better why is this happening:
QUESTION
I Have a image and i want to make a 8 dot on image, that dot are move when touch dot and drag to screen, is this possible to make that type of touch and movable dots on image?
Show above image on 8 point , i want to result like this image and also that point are move when you touch that point and move on image and also want that point x,y coordinate .
i tried below code but its show dots are not in proper form , and all dots move at the same time.
...ANSWER
Answered 2020-Dec-21 at 12:02Create a custom
ImageView
which extends theandroidx.appcompat.widget.AppCompatImageView
class, which implements anOnTouchListener
with anArrayList
which will keep track of theDot
s.You override
onDraw(Canvas canvas)
of the customImageView
and iterate through theArrayList
ofDot
s and draw eachDot
in the list usingcanvas.drawCircle(float cx, float cy, float radius, @NonNull Paint paint)
.Whenever
MotionEvent.ACTION_DOWN
is fired you check if the touch was inside an existing dot.If it was you set that
Dot
to a global variable i.e.touchedDot
, when the users movesOnTouchListener
firesMotionEvent.ACTION_MOVE
which you then check iftouchedDot != null
and if so simply change itsx
andy
to match the events viatouchedDot.x = event.getX()
andtouchedDot.y = event.getY()
and then callinvalidate()
which will call theImageView
sonDraw
method and the dot will be moved as the users finger moves. When the user lifts their finger either from a touch or a move,MotionEvent.ACTION_UP
is fired, there you simply check iftouchedDot == null
and if so you then create a newDot
at thex
andy
they touched in, otherwise you settouchedDot = null
to reset it for the next move or touch event.
Here is an example I created using Picasso to load the image into the custom ImageView
:
build.gradle:
QUESTION
I am developing an App for iOS. Latest versions of everything.
I'm adding some touch input - basically the ability to draw some shapes and highlight things. I have a UIScrollView which contains a UIView onto which other objects are drawn or placed. The UIView has a subview - a custom UIView which is the drawing canvas that covered its entirety.
I am catching the TouchesBegan/Moved/Cancelled/Ended routines in that canvas. Drawing, recording points, redrawing, varying line thickness on pressure, colours etc is working fine.
The weird thing is that I always get the -Began message, then immediately a -Moved message with a huge jump. Then things seem to settle down to smooth tracking with points received every 8-10ms.
Here is an example: First - the call to TouchesBegan, in which I record the first point.
...ANSWER
Answered 2020-Nov-16 at 00:44As you can see from the GitHub link in the comments:
https://github.com/xamarin/xamarin-macios/issues/10072
the problem is likely inherent in iOS.
So the source code and solution outlined in Addendum #2 above will solve this problem thoroughly.
So I think this one is closed.
QUESTION
Currently, I am able to have a separate PKCanvasView
and a PKToolPicker
that is shown when a button is tapped on. However, the tool is not being transferred between the picker and the canvas view. Does anyone have any idea how to link the two such that when I change the tool in the picker, the tool is updated in the canvas view as well? I've attached my code below. Thank you!
ANSWER
Answered 2020-Sep-23 at 05:42Solved it!
QUESTION
I am working on a paint tool for android and have attempted to implement a 'fill with color' tool. Where a user is able to fill a particular area with color depending on what they have selected. I have found examples of Flood Fill for Java but cant see anything similar for Kotlin.
I have tried the following - https://developer.android.com/reference/kotlin/android/graphics/Path.FillType
But have not had too much luck since it instead uses the surrounding colour and not what colour the user has selected.
EDIT:
A snippet of the code I am working with:
...ANSWER
Answered 2020-Sep-19 at 18:24This is kind of a complicated subject - if you want to draw a Path
with a particular fill and colour, you need to create a Paint
and use setColor
(and setStyle
to make it Paint.Style.FILL
.
But Path
s are for vector graphics, they're all defined lines and curves. Unless you're creating the shapes that the user can fill in as paths in the first place, you'll have trouble defining one to fit an arbitrary area.
I'm guessing you're actually using bitmaps, like a normal paint program, and you want to tap on a pixel and have that change colour, and also recursively change the colour of surrounding pixels if they meet a certain threshold. So you'll have to get the Canvas
's Bitmap
, and work out how to move through the pixels, changing them as you go (e.g. with Bitmap.setPixel()
)
There are a lot of algorithms for doing this, you'll just need to pick one and implement it. You probably don't want to use Path
s to do it though!
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install DrawingView
You can use DrawingView like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the DrawingView component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page