Direct2D (12) : 画刷之 ID2D1RadialGradientBrush
作者:互联网
Direct2D (12) : 画刷之 ID2D1RadialGradientBrush
uses Direct2D, D2D1; procedure TForm1.FormPaint(Sender: TObject); var cvs: TDirect2DCanvas; iBrush: ID2D1RadialGradientBrush; R: TRect; rRGBP: TD2D1RadialGradientBrushProperties; //结构包含:中心点、偏移点、横向半径、纵向半径 arrGradientStop: array[0..1] of TD2D1GradientStop; iGradientStops: ID2D1GradientStopCollection; begin cvs := TDirect2DCanvas.Create(Canvas, ClientRect); R := ClientRect; InflateRect(R, -ClientWidth div 6, -ClientHeight div 6); rRGBP.center := D2D1PointF(ClientWidth / 2, ClientHeight / 2); rRGBP.gradientOriginOffset := D2D1PointF(0, 0); rRGBP.radiusX := (R.Right - R.Left) / 2; rRGBP.radiusY := (R.Bottom - R.Top) / 2; arrGradientStop[0].position := 0.0; arrGradientStop[0].color := D2D1ColorF(clYellow); arrGradientStop[1].position := 1.0; arrGradientStop[1].color := D2D1ColorF(clRed); cvs.RenderTarget.CreateGradientStopCollection( @arrGradientStop[0], Length(arrGradientStop), D2D1_GAMMA_2_2, D2D1_EXTEND_MODE_CLAMP, iGradientStops ); cvs.RenderTarget.CreateRadialGradientBrush(rRGBP, nil, iGradientStops, iBrush); cvs.Brush.Handle := iBrush; cvs.Pen.Width := 0; cvs.BeginDraw; cvs.Ellipse(R); cvs.EndDraw; cvs.Free; end; procedure TForm1.FormResize(Sender: TObject); begin Repaint; end;
效果图:
posted on 2011-04-02 16:17 万一 阅读(1154) 评论(0) 编辑 收藏
标签:iGradientStops,12,画刷,ID2D1RadialGradientBrush,cvs,arrGradientStop,Direct2D,rRGBP 来源: https://blog.51cto.com/u_14617575/2745413