paint

Undo for a paint program

╄→尐↘猪︶ㄣ 提交于 2020-02-12 09:20:26
问题 I am looking into how to write a paint program that supports undo and seeing that, most likely, a command pattern is what I want. Something still escapes me, though, and I'm hoping someone can provide a simple answer or confirmation. Basically, if I am to embody the ability to undo a command, for instance stamping a solid circle on the screen, does this mean I need to essentially copy the frame buffer that the circle covers into memory, into this command object? I don't see any other way of

Undo for a paint program

佐手、 提交于 2020-02-12 09:20:23
问题 I am looking into how to write a paint program that supports undo and seeing that, most likely, a command pattern is what I want. Something still escapes me, though, and I'm hoping someone can provide a simple answer or confirmation. Basically, if I am to embody the ability to undo a command, for instance stamping a solid circle on the screen, does this mean I need to essentially copy the frame buffer that the circle covers into memory, into this command object? I don't see any other way of

Continuous drawing in CGContext with drawRect

放肆的年华 提交于 2020-02-07 06:56:20
问题 My question might be answered somewhere but I just couldn't find solution after a long research. I need to draw visually shapes (curves, lines, rectangles etc.) on iPhone one on top of the previous. I did that using CGContext to draw over an image and it's working fine. However in my app the drawing view resizes on device rotation and the lines become blurred because of the different image size. That's why I subclassed UIView and to call setNeedsDisplay from touchesMoved and touchesEnded . In

Applet Flickers even after using using Double Buffering

荒凉一梦 提交于 2020-02-05 04:27:10
问题 I am trying to make a 2 player Pong Applet where the user controls the paddle using mouse. I have used the concept of Double Buffering , but the Applet still flickers !!! What is the mistake I am committing ? import java.awt.Color; import java.awt.Graphics; import java.awt.Image; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import java.util.Timer; import javax.swing.JApplet; public class Pong extends JApplet implements Runnable, MouseMotionListener { Ball ball;

Drawing with Transparent Paint on Android

这一生的挚爱 提交于 2020-01-24 04:37:21
问题 When I use Paint with Color.TRANSPARENT on a normal 2D canvas in Android, I don't get any results and my intention was to get rid of some of the contents on the canvas. I mean the contents that I want to dispose of don't disappear. This is the code for my Paint : mPointFillPaint = new Paint(); mPointFillPaint.setColor(Color.TRANSPARENT); mPointFillPaint.setAntiAlias(true); mPointFillPaint.setStyle(Paint.Style.FILL); mPointFillPaint.setStrokeJoin(Paint.Join.MITER); 回答1: The following Paint

Why will my image not move?

狂风中的少年 提交于 2020-01-22 03:42:29
问题 I am making a 2d top-down game where the player controls a cat. To do this, the person uses the WASD keys to move. I have Form1, GameManager, Cat, and Moveable classes. Form1 sends GameManager the cat imagelist and e.graphics (for the picturebox). GameManager has a timer and each tick checks to see if the cat has moved. Cat handles the move logic. When I run the program, the cat sprite shows up at its initial position, but does not move upon pressing a key. I can't figure out my issue, could

How do I immediately change the row color when the selected index of a DataGridViewComboBox changes?

ぃ、小莉子 提交于 2020-01-17 05:16:37
问题 I'm using Windows Forms and have a DataGridView with a DataGridViewComboBoxColumn that is bound to a data source. When the user chooses a different item from the combo box, I'd like to immediately change the row color to indicate this new selection. I've tested several events such as CellValueChanged and RowPrePaint, but these requires that the user clicks off the row after making the selection. It seems like the row doesn't update immediately. Instead, it updates after the user clicks off

DataGridView overrides my custom row painting

ε祈祈猫儿з 提交于 2020-01-17 04:55:09
问题 I'm following the example on MSDN for using the RowPrePaint event to custom paint my rows. http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.rowprepaint(v=vs.110).aspx I only want to custom paint some rows, not all. I also have an alternating row style applied. When I stepped through the debugger I was able to watch the program paint the row according to the example in MSDN (a subtle gradient), but as soon as the RowPrePaint event handler returned the program repainted

Android: Painting app with eraser not working

时间秒杀一切 提交于 2020-01-17 02:20:14
问题 I am working on a painting app, with undo/redo function and would like to add eraser function. Code for MainActivity case R.id.undoBtn: doodleView.onClickUndo(); break; case R.id.redoBtn: doodleView.onClickRedo(); break; case R.id.eraserBtn: Constants.mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); break; DrawView // Drawing Part private Bitmap mBitmap; private Paint mBitmapPaint; private Canvas mCanvas; private Path mPath; private int selectedColor = Color.BLACK; private

Android: Painting app with eraser not working

做~自己de王妃 提交于 2020-01-17 02:20:13
问题 I am working on a painting app, with undo/redo function and would like to add eraser function. Code for MainActivity case R.id.undoBtn: doodleView.onClickUndo(); break; case R.id.redoBtn: doodleView.onClickRedo(); break; case R.id.eraserBtn: Constants.mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); break; DrawView // Drawing Part private Bitmap mBitmap; private Paint mBitmapPaint; private Canvas mCanvas; private Path mPath; private int selectedColor = Color.BLACK; private