paint

Android canvas - Draw a hole

橙三吉。 提交于 2019-12-19 09:07:47
问题 Is it possible to realize the following picture in Android with canvas? I want to have a hole and not only a Circle over the red layer which is yellow colored. I tried this (and failed) with the following Code in my onDraw() -Method: canvas.drawBitmap(yellow, 0, 0, paint); canvas.drawBitmap(red, 0, 200, paint); Paint p = new Paint(); p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); canvas.drawCircle(300, 300, radius, p); But when I use this code, it makes a hole through both

Threading a paint method

空扰寡人 提交于 2019-12-19 03:49:10
问题 I was wondering how I would thread the following code, or just a method in general: public void run (){ public void paint(Graphics g) { g.fillRect(20, 20, 20, 20); for (int i = 20; i < 1000; i++) { g.fillRect(20, i, 20, 20); Thread.sleep(10); } } } I find that I am unable to make a thread of this code because I get an illegal start of expression error, which is fair but I do not see a way around it. 回答1: Its hard to tell what you are doing, but seems like you are trying to override paint() of

Android: is Paint.breakText(…) inaccurate?

陌路散爱 提交于 2019-12-19 03:25:18
问题 I have a View which draws a rectangle with a line of text inside of it. The view uses break text to ensure that no text extends outside of the rectangle; it ignores any text that does. This works fine for some characters, but often Strings made up of 'l's and 'f's extend outside of the rectangle. So, I'm in need of a sanity check here: Is there some obvious flaw in my below code, or is it possible that Paint.breakText(...) is inaccurate? public void onDraw(Canvas canvas) { int MARGIN = 1; int

How to get height of text with fixed width and get text length which fits in a frame?

霸气de小男生 提交于 2019-12-18 11:59:38
问题 well, I've managed to fit all my questions in the title. I need to break a long text in to columns/frames and layout them in to view. I've been digging for solutions for a couple of days now, but I can't find any examples or clear documentation on how to complete any of my tasks. I've seen a some mentions of StaticLayout, but I don't know how to use it properly. As for text height I've tried TextPaint's getTextBounds method, but it doesn't have width limit and it looks like it measures only

Efficient Line Smoothing and/or Simplification

此生再无相见时 提交于 2019-12-18 11:08:35
问题 I am creating a painting application in Actionscript (although my question is not Actionscript related). The basic idea is to start painting when the mouse is pressed and tracking the mouse movements. What I want to achieve is: reduce mouse "noise" and create more smoother looking lines. Right now, ( 1 ) is problematic because I get thousands of mouse movements within a few seconds. Due to ( 1 ) the line can look jaggy. What current idea: when the user finishes drawing the line, I store all

Java: Paint a histogram via fillRect()

女生的网名这么多〃 提交于 2019-12-18 09:45:51
问题 I like to make a histogram. With drawLine() , it's not really a problem for me, but when I try to do it with fillRect() the rectangles are going from top to bottom. I would like to paint the histogram looking similar to my histogram with drawLine() . Here is my code: public void paint(Graphics g) { super.paint(g); int height = getHeight(); int width = getWidth(); int x =10; haufigkeit=model.getMap(); for(int i = 1; i <= 45; i++) { int y; y = haufigkeit.get(i); Color color = new Color(0, 0,

Multiple problems regarding Java paint program while painting

岁酱吖の 提交于 2019-12-18 09:44:20
问题 I have a Java paint program, and I've got two problems to do with it. Both problems are relatively simple, and just regard how the mouse input is handled and how the image uses colors. Here's a photo of the app: So here's my first problem: As you can see, by the look of the app, there's a spray of dots on the paint area. Each of those dots is a mouseclick. The program does not recognize when a user is holding down the mouse button, so you have to click individually. This is obviously

Prevent WPF window flicker

夙愿已清 提交于 2019-12-18 08:53:26
问题 I've got a borderless WPF window that needs to be able to hide one of its controls and shrink the window at the same time. The problem is that it looks terrible. Here's what I am doing now: private void btnShowHideTopBar_Click(object sender, RoutedEventArgs e) { if (commandTopHide == true) { txtblkShowHideTopBar.Text = "Show Top Bar"; commandTopHide = false; myWindow.Left = 1100; myWindow.Width = 180; RSide.Width = new GridLength(0, GridUnitType.Pixel); } else if (commandTopHide == false) {

Writing a paint program à la MS Paint - how to interpolate between mouse move events?

我们两清 提交于 2019-12-17 23:47:33
问题 I want to write a paint program in the style of MS Paint. For painting things on screen when the user moves the mouse, I have to wait for mouse move events and draw on the screen whenever I receive one. Apparently, mose move events are not sent very often, so I have to interpolate the mouse movement by drawing a line between the current mouse position and the previous one. In pseudocode, this looks something like this: var positionOld = null def handleMouseMove(positionNew): if mouse.button

Writing a paint program à la MS Paint - how to interpolate between mouse move events?

一世执手 提交于 2019-12-17 23:47:26
问题 I want to write a paint program in the style of MS Paint. For painting things on screen when the user moves the mouse, I have to wait for mouse move events and draw on the screen whenever I receive one. Apparently, mose move events are not sent very often, so I have to interpolate the mouse movement by drawing a line between the current mouse position and the previous one. In pseudocode, this looks something like this: var positionOld = null def handleMouseMove(positionNew): if mouse.button