Click here to Skip to main content
15,899,937 members
Home / Discussions / Graphics
   

Graphics

 
AnswerRe: USB WEBCAMs Pin
jon-martin.com21-Jul-09 2:17
jon-martin.com21-Jul-09 2:17 
QuestionMetal Circle with GDI+ Pin
Leslie Sanford10-Jun-09 19:42
Leslie Sanford10-Jun-09 19:42 
AnswerRe: Metal Circle with GDI+ Pin
Luc Pattyn11-Jun-09 6:25
sitebuilderLuc Pattyn11-Jun-09 6:25 
GeneralRe: Metal Circle with GDI+ Pin
Leslie Sanford11-Jun-09 10:14
Leslie Sanford11-Jun-09 10:14 
GeneralRe: Metal Circle with GDI+ Pin
Luc Pattyn11-Jun-09 10:19
sitebuilderLuc Pattyn11-Jun-09 10:19 
GeneralRe: Metal Circle with GDI+ Pin
Luc Pattyn12-Jun-09 3:42
sitebuilderLuc Pattyn12-Jun-09 3:42 
GeneralRe: Metal Circle with GDI+ Pin
Leslie Sanford13-Jun-09 8:41
Leslie Sanford13-Jun-09 8:41 
GeneralRe: Metal Circle with GDI+ Pin
Luc Pattyn14-Jun-09 7:25
sitebuilderLuc Pattyn14-Jun-09 7:25 
Hi Leslie,

I combined your and my techniques, and now have a metallic circular brush that can be reused since it scales with the Graphics:
PathGradientBrush brush;

private void makeCircularMetalBrush() {
    List<PointF> points=new List<PointF>();
    List<Color> colors=new List<Color>();
    int darkest=80;
    int lightest=255;

    double rplus=1.03;
    for (int i=0; i<360; i+=5) {
        double angle=(i+45)*Math.PI/180;
        double cos=Math.Cos(angle);
        double sin=Math.Sin(angle);
        points.Add(new PointF((float)(rplus*cos), (float)(rplus*sin)));
        angle=i*Math.PI/180;
        cos=Math.Cos(angle);
        int c=darkest+(int)((lightest-darkest)*cos*cos);
        colors.Add(Color.FromArgb(c, c, c));
    }
    brush = new PathGradientBrush(points.ToArray());
    brush.SurroundColors = colors.ToArray();
    brush.CenterColor = Color.White;
}

private void pan_Paint(object sender, PaintEventArgs e) {
    Graphics g=e.Graphics;
    int cx=pan.Width/2;
    int cy=pan.Height/2;
    int r=cx;
    if (r>cy) r=cy;
    r-=20;  // margin
    g.TranslateTransform(cx, cy);
    g.ScaleTransform(r, r);
    g.FillEllipse(brush, new RectangleF(-1, -1, 2, 2));
}


As a result metallic painting has become much cheaper now.

BTW: for larger shapes (e.g. the surrounding rectangle) another brush would be required, since its characteristic points would fall inside the new shape, and whatever is beyond the brush shape would be painted white.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.

GeneralRe: Metal Circle with GDI+ Pin
Leslie Sanford23-Jun-09 14:27
Leslie Sanford23-Jun-09 14:27 
GeneralRe: Metal Circle with GDI+ Pin
Luc Pattyn23-Jun-09 14:33
sitebuilderLuc Pattyn23-Jun-09 14:33 
GeneralRe: Metal Circle with GDI+ Pin
Luc Pattyn26-Jun-09 6:48
sitebuilderLuc Pattyn26-Jun-09 6:48 
GeneralRe: Metal Circle with GDI+ Pin
Henry Minute16-Jun-09 11:12
Henry Minute16-Jun-09 11:12 
QuestionWeb Cam URL Pin
Dinker Batra9-Jun-09 21:15
Dinker Batra9-Jun-09 21:15 
Questionhow can I load a image into memory? Pin
transoft8-Jun-09 4:38
transoft8-Jun-09 4:38 
QuestionCreating an Emboss/Bevelled effect for Circles and Rectangles [modified] Pin
Leslie Sanford7-Jun-09 19:56
Leslie Sanford7-Jun-09 19:56 
AnswerRe: Creating an Emboss/Bevelled effect for Circles and Rectangles Pin
Tim Craig8-Jun-09 14:38
Tim Craig8-Jun-09 14:38 
GeneralRe: Creating an Emboss/Bevelled effect for Circles and Rectangles Pin
Leslie Sanford8-Jun-09 15:37
Leslie Sanford8-Jun-09 15:37 
GeneralRe: Creating an Emboss/Bevelled effect for Circles and Rectangles Pin
Tim Craig8-Jun-09 19:09
Tim Craig8-Jun-09 19:09 
GeneralRe: Creating an Emboss/Bevelled effect for Circles and Rectangles Pin
Leslie Sanford8-Jun-09 19:52
Leslie Sanford8-Jun-09 19:52 
GeneralRe: Creating an Emboss/Bevelled effect for Circles and Rectangles Pin
Tim Craig9-Jun-09 15:05
Tim Craig9-Jun-09 15:05 
QuestionGLX rendering context problem Pin
sheeri manik2-Jun-09 15:08
sheeri manik2-Jun-09 15:08 
QuestionDxText for Offline VideoWatermarking Pin
anki12326-May-09 21:24
anki12326-May-09 21:24 
QuestionObject transform problem! Pin
Avion8525-May-09 13:30
Avion8525-May-09 13:30 
AnswerRe: Object transform problem! Pin
Baltoro4-Jun-09 7:44
Baltoro4-Jun-09 7:44 
Question3D Model seems to be all... 2Dish [Solved] Pin
Anthony Mushrow24-May-09 16:24
professionalAnthony Mushrow24-May-09 16:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.