paint

Java: Using graphics component within an ActionListener

ぐ巨炮叔叔 提交于 2019-11-30 21:09:35
问题 I have two separate class and driver files, and in the class file I create the paint method: public void paint(Graphics g){ g.drawLine(...... .... //along with all of my other draw commands } Further down in the code, I create a JButton and within this button's action listener I don't know how to use a Graphics object to create more graphics in the JFrame. Should I be adding something to my driver to make this happen, or is there a way to use these graphics within my action listener? Thank

Strange crash drawing on canvas on Android 4.0.3. A/libc: Fatal signal 11 (SIGSEGV)

江枫思渺然 提交于 2019-11-30 20:25:20
I'm using a low cost tablet with Android 4.0.3. Here the log: 06-11 23:36:04.653: D/SynopticElement(1583): Size changed to 200x200 06-11 23:36:04.693: D/dalvikvm(1583): GC_FOR_ALLOC freed 62K, 12% free 7275K/8199K, paused 33ms 06-11 23:36:04.713: D/SynopticElement(1583): Size changed to 190x190 06-11 23:36:04.733: D/dalvikvm(1583): GC_FOR_ALLOC freed 9K, 12% free 7583K/8583K, paused 22ms 06-11 23:36:04.743: A/libc(1583): Fatal signal 11 (SIGSEGV) at 0xc52c9d4c (code=1) Debugging my code: canvas.scale(getWidth(), getWidth()); //I'm drawing a custom component Paint frameBackgroundPainter = new

Soft Paint Bucket Fill: Colour Equality

落花浮王杯 提交于 2019-11-30 20:20:10
问题 I'm making a small app where children can fill preset illustrations with colours. I've succesfully implemented an MS-paint style paint bucket using the flood fill argorithm. However, near the edges of image elements pixels are left unfilled, because the lines are anti-aliased. This is because the current condition on whether to fill is colourAtCurrentPixel == colourToReplace , which doesn't work on the blended pixels at the lines. (the colours are RGB uints) I'd like to add a smoothing

Drawing with Winforms

我只是一个虾纸丫 提交于 2019-11-30 19:02:49
问题 I want to get myself a bit of WinForm Graphics knowledge, so I'm rewriting my small 2D editor from XNA to WinForm Graphics-only. Now, I made myself a new UserControl for the tileset, but as I've seen, the Paint method is only called at the initialization of the control. Since I want to permanently repaint my control (or at least via MouseOver event to save a bit of performance), I heard the Invalidate() method gets the Control to repaint itself, but that is way too unperformant. Is there any

Draw Lines perodically

谁说我不能喝 提交于 2019-11-30 18:04:35
问题 i am in situation where i want to draw lines one by one with some time period. I tried to do it by using thread.but it didnt work for me. The objective is i've 5 lines. the lines should be drawn one after one with 5seconds delay .Using Thread.sleep(5000) in onDraw() method but all the lines were drawn after 5seconds those were not drawn periodically...how can i draw lines periodically... code snippet:: public class PaintDemoActivity extends Activity { DragView drawView; /** Called when the

Adding shapes to JPanel on a button click

我是研究僧i 提交于 2019-11-30 17:45:57
问题 I have a Class Circle with a button and a Class with a jPanel what i want to do is when that button is clicked a circle will be drawn on the panel and each time i click that button and change x and y "some how not implemented here" i got a circle on the JPanel over and over . How to do that, or is there a way to do what i descriped regardless of my code but i want the class circle to extends Shape. public class Window{ private JFrame frame; private JPanel panel = new JPanel(); Circle c = new

WinAPI C++: Reprogramming Window Resize

坚强是说给别人听的谎言 提交于 2019-11-30 15:48:57
I have a window, and I want to implement the borders as resizing borders, like any other window. Taking in suggestions from comments and answers, I have rewritten my code. For WM_GETMINMAXINFO I have: MINMAXINFO *min_max = reinterpret_cast<MINMAXINFO *>(lparam); min_max->ptMinTrackSize.x = MINX; min_max->ptMinTrackSize.y = MINY; MINX and MINY are the minimum size I want the window to be. For WM_NCHITTEST I have: RECT wnd_rect; int x, y; GetWindowRect (window, &wnd_rect); x = GET_X_LPARAM (lparam) - wnd_rect.left; y = GET_Y_LPARAM (lparam) - wnd_rect.top; if (x >= BORDERWIDTH && x <= wnd_rect

How to draw a curved line between 2 points on canvas?

会有一股神秘感。 提交于 2019-11-30 15:17:23
I have tried a lot of different approaches from examples around the web, but I can't seem to get this to work. I am trying to make a method that draws a curved line between 2 points on a canvas. The curve should be defined by a radius parameter. Below is my current code. public OverlayBuilder drawCurvedArrow(int startX, int startY, int endX, int endY, int curveRadius, int padding, int color) { PointF mPoint1 = new PointF(startX, startY); PointF mPoint2 = new PointF(endX, endY); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(12);

Reduce Padding Around Text in WinForms Button

荒凉一梦 提交于 2019-11-30 12:38:01
I have an application that is going to be used on a touch screen system, and it contains a number of buttons that are fairly large (~100px square). Each button will have between 1 and 4 lines of text (typically one word per line). Due to the large amount of padding in the button, I'm having to reduce the size of the text so that it becomes almost unreadable, however if I was able to reduce the internal padding so that the text would paint right up to the border, then I wouldn't have a problem. I've attempted to reduce the padding of the control down to zero as follows, but it doesn't help.

How to draw smooth / rounded path?

此生再无相见时 提交于 2019-11-30 11:21:11
问题 I am creating Paths and adding multi lines in each path by using path.moveTo(x, y) and path.lineTo(x, y) . Then canvas.drawPath(path, paint) is drawing all paths. But there are 1-2 pixel space between lines in some paths. How can I remove these spaces? My code is something like that: paint = new Paint(); paint.setColor(Color.RED); paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setDither(false); paint.setStrokeWidth(3); paint.setAntiAlias(true); for (int i = 0; i < length; i++) { Path path