MCPcopy Create free account
hub / github.com/lxn/walk / GradientFillRectanglePixels

Method GradientFillRectanglePixels

canvas.go:533–567  ·  view source on GitHub ↗

GradientFillRectanglePixels draws a gradient filled rectangle in native pixels.

(color1, color2 Color, orientation Orientation, bounds Rectangle)

Source from the content-addressed store, hash-verified

531
532// GradientFillRectanglePixels draws a gradient filled rectangle in native pixels.
533func (c *Canvas) GradientFillRectanglePixels(color1, color2 Color, orientation Orientation, bounds Rectangle) error {
534 vertices := [2]win.TRIVERTEX{
535 {
536 X: int32(bounds.X),
537 Y: int32(bounds.Y),
538 Red: uint16(color1.R()) * 256,
539 Green: uint16(color1.G()) * 256,
540 Blue: uint16(color1.B()) * 256,
541 Alpha: 0,
542 }, {
543 X: int32(bounds.X + bounds.Width),
544 Y: int32(bounds.Y + bounds.Height),
545 Red: uint16(color2.R()) * 256,
546 Green: uint16(color2.G()) * 256,
547 Blue: uint16(color2.B()) * 256,
548 Alpha: 0,
549 },
550 }
551
552 indices := win.GRADIENT_RECT{
553 UpperLeft: 0,
554 LowerRight: 1,
555 }
556
557 var o uint32
558 if orientation == Vertical {
559 o = 1
560 }
561
562 if !win.GradientFill(c.hdc, &vertices[0], 2, unsafe.Pointer(&indices), 1, o) {
563 return newError("GradientFill failed")
564 }
565
566 return nil
567}
568
569// DrawText draws text at given location in 1/96" units.
570//

Callers 2

GradientFillRectangleMethod · 0.95
updateBackgroundMethod · 0.80

Calls 4

newErrorFunction · 0.85
RMethod · 0.80
GMethod · 0.80
BMethod · 0.80

Tested by

no test coverage detected