brush

I need an algorithm for rendering soft paint brush strokes.

I have an array of mouse points, a stroke width, and a softness. I can draw soft circles and soft lines. Which algorithm should I use for drawing my array of points? I want crossed lines to look nice as well as end points. ...

Convert string to Brushes/Brush name in C#

I have a configuration file where a developer can specify a text color by passing in a string: <text value="Hello, World" color="Red"/> Rather than have a gigantic switch statement look for all of the possible colors, it'd be nice to just use the properties in the class System.Drawing.Brushes instead so internally I can say something...

Disposing a static brush

Hi, I'm writing a biorhythm app. To test it i have a form with a Button and a PictureBox. When I click on the button i do myPictureBox.Image = GetBiorhythm2(); Which runs ok for the first time, but on the second click it causes the following exception: System.ArgumentException: Parameter is not valid. at System.Drawing.Graphics.Ch...

How do I implement a custom Brush in WPF?

Where can I find out enough info about how Brushes work to implement my own System.Windows.Media.Brush? I can handle all of the freezable baggage, but it's not really obvious what I need to override to get it to work. Yeah, so I didn't mean that I want to use a predefined brush. I want to extend System.Windows.Media.Brush, which is ...

WPF - How can I make a brush that paints graph-paper-like squares?

How might I create a brush that paints a regular, repeated grid of 1-unit thick lines spaced evenly in both the horizontal and vertical axes? Imagine graph paper, if you will. Ideally the solution would allow control over the brushes used for the lines and the background (the regions within the squares). In this way the background cou...

Creating a WPF ValueConverter for a Brush

On the Nerd Plus Art blog today, there was a post about creating WPF Resources for arrows, which the author uses frequently. I have a side project that has Back and Forward buttons, so I thought that the Left and Right arrows would work great on those buttons. I added the LeftArrow and RightArrow Geometries to my application's resources...

What is the best way to pick a random brush from the Brushes collection in C#?

What is the best way to pick a random brush from the System.Drawing.Brushes collection in C#? ...

Convert System.Windows.Media.Brush to System.Drawing.Brush

How can I convert a System.Windows.Media.Brush to System.Drawing.Brush? I'm trying to get the color of a system.windows.media.brush formatted to a System.Drawing.Color object. The below solution doesn't work because it requires a solidcolorbrush object, whereas the object i need converting from is a system.windows.media.brush object: ...

Line with different solid colors, solidcolorbrush with gradient stops but without the gradients

In Silverlight (version 3 preview), I want to create a Line with different solid colors, so no gradients between colors. Basically I want to do the following: <Line X1="0" X2="500" StrokeThickness="10"> <Line.Stroke> <LinearGradientBrush> <GradientStop Color="Blue" Offset="0.5" /> <GradientStop Color="Red" Offset="1"/> </LinearGr...

CreatePatternBrush / Ellipse not working on WinMobile device but on emulator

To draw a circular part of a bitmap on the screen, I use a PatternBrush created from the bitmap to fill an ellipse. I use P/Invoke to the native functions because there seems to be a bug in CF2.0 if you use the managed functions (see here for more details: http://social.msdn.microsoft.com/forums/en-US/netfxcompact/thread/e831ea2f-039a-4b...

How do I combine brushes in WPF?

I have two brushes. I don't know wath type of brushes they are. They can be ImageBrushes, SolidBrushes or VisualBrushes. I have each in a variable of the "Brush" type. I need to combine two brushes. How do I do it? I tried this. But It didn't work. Here are Back and Front the brushes that need to me combined. Border Bd = new B...

Creating a custom fill brush in XAML

How do I create the following shape in XAML? <Ellipse Height="100" Width="100"> <Ellipse.Fill> ??? </Ellipse.Fill> </Ellipse> LinearGradientBrush can't be transformed in this way? RadialGradientBrush is not suitable either. Any ideas? ...

C# Drawing, Strange Behaviour

Hi, the following code is fairly straight forward - it fills a design surface with randomnly selected pixels - nothing special (ignore the XXXXXXX's in the 2nd method for now). private void PaintBackground() { Random rnd = new Random(); Bitmap b = new Bitmap(this.Width, this.Height); for (int vertical = 0; vertical < this.H...

WPF 'magic' negating brush?

Hello! I have a gradient that changes its colors, I want the text inside it should always be visible. I rather doing it dynamically if there is any out-the-box resource; I want a 'magic brush' that negates the color. Any experiments? ...

Qt Qbrush issue

What is the difference in the following code, QGraphicsScene * scence = new QGraphicsScene(); QBrush *brush = new QBrush((QColor(60,20,20))); scence->setBackgroundBrush(*brush); QGraphicsView *view = new QGraphicsView(); view->setScene(scence); //view->setBackgroundBrush(*brush); //view->setCacheMode(QGraphicsView:...

Visual C++ program for paint brush code using openGL

hi!I want the code/program for paint brush in Visual C++ using open gl.It must include square,rectangle,triangle,circle,pencil,eraser and it must have buttons. ...

compare a brush and color

if (backBrush == SystemColors.ActiveCaption) This fails. Says you can't compare a brush and a color. How do I find the color of the brush? ...

Is there a MergedGradientBrush in wpf?

Suppose I had two brushes. One that was a linear gradient brush that was from Dark to light One was a radial brush that went from Dark to light. How could I merge the brushes so that when I apply them, I can apply both at once. EG Check this: 1) http://www.codeproject.com/KB/vista/WindowsVistaRenderer/VistaRenderer4.gif 2) http://www....

WPF - Relative transform on brush results in jagged lines.

After applying a relative rotate transform (of 45 degrees) on a brush in WPF, I am left with extremely jagged lines. Has anyone else experienced this? Did you find a solution? ...

OpenGL equivalent of GDI's HatchBrush or PatternBrush?

I have a VB6 application (please don't laugh) which does a lot of drawing via BitBlt and the standard VB6 drawing functions. I am running up against performance issues (yes, I do the regular tricks like drawing to memory). So, I decided to investigate other ways of drawing, and have come upon OpenGL. I've been doing some experimenting...