paint

Paint foreign component (i.e. belonging to a different frame's content pane) in another component

本秂侑毒 提交于 2019-12-06 14:06:44
问题 Hallo all. I want to paint a foreign component (i.e. belonging to a different frame's content pane), lets call it frame B, inside a component in frame A. The problem is that when I paint the component it is painted also in the content pane of the frame A, also it flickers or all gets ugly when the frame is re-sized (i.e. painted few times inside the component, some blue squares are appearing, etc.). The issue becomes more visible if I try to, for example, scale or translate the foreign

How to save an image-file on server through Java applet?

与世无争的帅哥 提交于 2019-12-06 14:05:26
问题 I have a paint application that runs as a Java applet. I need to save the contents of the canvas on server machine in any image-format typically PNG. Please help! 回答1: You might be interested by the code I wrote for Processing, which is basically Java code. Re: save to web --- image export. Earlier in the thread I explain some precautions to be taken with such application (to avoid flooding a server from a malicious user) and I give the corresponding PHP code. 回答2: You need to do two things:

Android Scratch card app

拜拜、爱过 提交于 2019-12-06 13:47:09
问题 I am doing a small project for college and wondering if someone can tell me how I would go about doing a scratch card app. This app should have one image overlaying another. The one on top should allow the user to remove the image depending on where they rub on the image and thus part of the image that was removed revealing the image underneath. Pretty much like a scratch card. Any help would be great! This is the code im using at the moment . public class workinggraphics extends Activity { /

How to save draw paint with custom view android?

微笑、不失礼 提交于 2019-12-06 12:16:17
I am using following code . and i am getting problem when saving images .i am able to save bitmap but when save bimap it saves also i erased paint also with black color public class FingerPaint extends GraphicsActivity implements ColorPickerDialog.OnColorChangedListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new MyView(this)); mPaint = new Paint(); mPaint.setAntiAlias(true); mPaint.setDither(true); mPaint.setColor(0xFFFF0000); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint

Draw horizontal or vertical line using touch in iOS

主宰稳场 提交于 2019-12-06 11:43:47
问题 I am working on a project where I want that if user touch move in horizontal direction then horizontal line should draw and of user touch move in vertical direction then vertical line should draw. Kindly suggest some solution using Swift. I tried below. But this is drawing free line. override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { super.touchesBegan(touches, with: event) let touch: AnyObject? = touches.first let lastPoint = touch!.previousLocation(in: holderView)

How do I let multiple Threads paint onto an AWT component?

為{幸葍}努か 提交于 2019-12-06 09:59:48
EDIT: solved, look below for my solution. first of all, this is my very first question here, so if I make any mistakes, please tell me. I am trying to write a Mandelbrot Fractal Program in Java, for training purposes. The ideal for all the functionality I want to have is the Fractalizer ( http://www.fractalizer.de/en/ ), but for now, I will be happy with a program that draws the Mandelbrot Set on the screen (instead of, for example, writing it to an image file). Of course, I want the program to be fast, so I thought that I could split the calculation into multiple threads to utilize my multi

Paint method java - Rectangle with outline

风格不统一 提交于 2019-12-06 09:12:40
I want to create a wall with a blue line outline and black filling. I have only a blue wall now and I tried a couple of the Graphics methods but wasn't working. public void paint(Graphics g) { g.setColor(Color.blue); g.fillRect(x, y, size, size); } First, override paintComponent , not paint . Second, there's no need to re-invent the wheel like that. Instead, use an existing Swing component (e.g. JPanel ), import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing

Java Swing: Clearing custom painting from a JPanel overlayed with other JPanels in a JLayeredPane

谁说胖子不能爱 提交于 2019-12-06 08:54:10
I've got a JLayeredPane containing three JPanels, two of which overlap, that I'm painting shapes to. One of the two JPanels that overlap needs to have every shape drawn to it cleared without affecting the shapes drawn to the JPanel under it disappear from the screen. Currently I'm using something like this: Graphics g = pane2.getGraphics(); g.clearRect (0, 0, 1000, 1000); But this not only clears everything painted to pane2 but also pane1, which is under it. So my question is: Is there any way to clear everything painted to one JPanel without affecting anything painted to a JPanel under it? I

Qt catch pressed key

被刻印的时光 ゝ 提交于 2019-12-06 07:46:04
i think of to write primitive snake. i have window where program paints random lines. but i can't think up how to catch pressed key to change direction of painted line. class QUpdatingPathIte : public QGraphicsPathItem { void advance(int phase) { if (phase == 0) return; int x,y; int w,a,s,d; char c; // // HOW TO MAKE THIS HERE? (i had done early in console application) // but i can't do this in GUI , what should i do? scanf("%c",&c); if (c=='w') { x=-20; y=0; } else if (c=='s') { x=20; y=0; } else if (c=='a') { x=0; y=-20; } else if(c=='d') { x=0; y=20; } QPainterPath p = path(); p.lineTo(x, y

Android Paint PorterDuff.Mode.CLEAR drawing black color on my view

岁酱吖の 提交于 2019-12-06 07:06:42
I want to implement eraser for my painting app . I am able to erase with the following code paint.setColor(0x00000000); paint.setAlpha(0x00); But after erasing when you start painting again it does not paint properly so any idea to erase paint please suggest. Try the below code. paint.setAlpha(0xFF);//transperent color paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));//clear the draw Also have a look at the sample FingerPaint.java in the api demos under the folder graphics. setAlpha(int a) Helper to setColor(), that only assigns the color's alpha value, leaving its r,g,b values