ViewShadow

Description of the View's shadow

Create from source

func NewInsetViewShadow(offsetX, offsetY, blurRadius, spreadRadius SizeUnit, color Color) ViewShadow

Create the new inset shadow for a view. Arguments: offsetX, offsetY - x and y offset of the shadow blurRadius - the blur radius of the shadow spreadRadius - the spread radius of the shadow color - the color of the shadow

func NewShadowWithParams(params Params) ViewShadow

Create the new shadow for a view.

func NewTextShadow(offsetX, offsetY, blurRadius SizeUnit, color Color) ViewShadow

Create the new text shadow. Arguments: offsetX, offsetY - x and y offset of the shadow blurRadius - the blur radius of the shadow color - the color of the shadow

func NewViewShadow(offsetX, offsetY, blurRadius, spreadRadius SizeUnit, color Color) ViewShadow

Create the new shadow for a view. Arguments: offsetX, offsetY - x and y offset of the shadow blurRadius - the blur radius of the shadow spreadRadius - the spread radius of the shadow color - the color of the shadow

Create from resource

View {
    shadow = _{
        blur = 2px,
        color = #FF5C0700,
        inset = false,
        spread-radius = 0px,
        x-offset = 3px,
        y-offset = 5px,
    },
}

Interface description

Inherit methods from Properties, fmt.Stringer

Properties

"blur"

Determines the radius of the blur effect. The larger this value, the bigger the blur, so the shadow becomes bigger and lighter. Negative values are not allowed

Constant: BlurRadius

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

GridLayout {
    width = 100%,
    height = 100%,
    cell-vertical-align = center,
    cell-horizontal-align = center,
    content = Button {
        content = "Decline",
        shadow = _{
            blur = 1em,
            color = black,
            spread-radius = 0.5em,
        },
    },
}
view := rui.NewGridLayout(session, rui.Params{
    rui.Width:               rui.Percent(100),
    rui.Height:              rui.Percent(100),
    rui.CellVerticalAlign:   rui.CenterAlign,
    rui.CellHorizontalAlign: rui.CenterAlign,
    rui.Content: rui.NewButton(session, rui.Params{
        rui.Content: "Decline",
        rui.Shadow:  rui.NewViewShadow(rui.Px(0), rui.Px(0), rui.Em(1), rui.Em(0.5), rui.Black),
    }),
})

"color"

Color property of the shadow

Constant: ColorTag

Types: Color, string

Internal type is Color, other types converted to it during assignment

See Color description for more details

Examples

GridLayout {
    width = 100%,
    height = 100%,
    cell-vertical-align = center,
    cell-horizontal-align = center,
    content = Button {
        content = "Decline",
        shadow = _{
            blur = 1em,
            color = black,
            spread-radius = 0.5em,
        },
    },
}
view := rui.NewGridLayout(session, rui.Params{
    rui.Width:               rui.Percent(100),
    rui.Height:              rui.Percent(100),
    rui.CellVerticalAlign:   rui.CenterAlign,
    rui.CellHorizontalAlign: rui.CenterAlign,
    rui.Content: rui.NewButton(session, rui.Params{
        rui.Content: "Decline",
        rui.Shadow:  rui.NewViewShadow(rui.Px(0), rui.Px(0), rui.Em(1), rui.Em(0.5), rui.Black),
    }),
})

"inset"

Controls whether to draw shadow inside the frame or outside. Inset shadows are drawn inside the border(even transparent ones), above the background, but below content

Constant: Inset

Types: bool, int, string

Values

bool int string Description
true 1 "true", "yes", "on", "1" Drop shadow inside the frame(as if the content was depressed inside the box)
false 0 "false", "no", "off", "0" Shadow is assumed to be a drop shadow(as if the box were raised above the content)

Examples

GridLayout {
    width = 100%,
    height = 100%,
    cell-vertical-align = center,
    cell-horizontal-align = center,
    content = Button {
        content = "Decline",
        shadow = [
            _{
                blur = 0.3em,
                color = black,
                spread-radius = 0.1em,
            },
            _{
                inset = true,
                blur = 0.3em,
                color = black,
                spread-radius = 0.1em,
            },
        ]
    },
}
view := rui.NewGridLayout(session, rui.Params{
    rui.Width:               rui.Percent(100),
    rui.Height:              rui.Percent(100),
    rui.CellVerticalAlign:   rui.CenterAlign,
    rui.CellHorizontalAlign: rui.CenterAlign,
    rui.Content: rui.NewButton(session, rui.Params{
        rui.Content: "Decline",
        rui.Shadow: []rui.ViewShadow{
            rui.NewViewShadow(rui.Px(0), rui.Px(0), rui.Em(0.3), rui.Em(0.1), rui.Black),
            rui.NewInsetViewShadow(rui.Px(0), rui.Px(0), rui.Em(0.3), rui.Em(0.1), rui.Black),
        },
    }),
})

"spread-radius"

Positive values will cause the shadow to expand and grow bigger, negative values will cause the shadow to shrink

Constant: SpreadRadius

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

GridLayout {
    width = 100%,
    height = 100%,
    cell-vertical-align = center,
    cell-horizontal-align = center,
    content = Button {
        content = "Decline",
        shadow = _{
            blur = 1em,
            color = black,
            spread-radius = 0.5em,
        },
    },
}
view := rui.NewGridLayout(session, rui.Params{
    rui.Width:               rui.Percent(100),
    rui.Height:              rui.Percent(100),
    rui.CellVerticalAlign:   rui.CenterAlign,
    rui.CellHorizontalAlign: rui.CenterAlign,
    rui.Content: rui.NewButton(session, rui.Params{
        rui.Content: "Decline",
        rui.Shadow:  rui.NewViewShadow(rui.Px(0), rui.Px(0), rui.Em(1), rui.Em(0.5), rui.Black),
    }),
})

"x-offset"

Determines the shadow horizontal offset. Negative values place the shadow to the left of the element

Constant: XOffset

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

GridLayout {
    width = 100%,
    height = 100%,
    cell-vertical-align = center,
    cell-horizontal-align = center,
    background-color = lightsalmon,
    content = Button {
        content = "Decline",
        shadow = _{
            x-offset = 0.5em,
            y-offset = 1em,
            blur = 0.2em,
            color = salmon,
            spread-radius = 0.1em,
        },
    },
}
view := rui.NewGridLayout(session, rui.Params{
    rui.Width:               rui.Percent(100),
    rui.Height:              rui.Percent(100),
    rui.CellVerticalAlign:   rui.CenterAlign,
    rui.CellHorizontalAlign: rui.CenterAlign,
    rui.BackgroundColor:     rui.LightSalmon,
    rui.Content: rui.NewButton(session, rui.Params{
        rui.Content: "Decline",
        rui.Shadow: []rui.ViewShadow{
            rui.NewViewShadow(rui.Em(0.5), rui.Em(1), rui.Em(0.2), rui.Em(0.1), rui.Salmon),
        },
    }),
})

"y-offset"

Determines the shadow vertical offset. Negative values place the shadow above the element

Constant: YOffset

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

GridLayout {
    width = 100%,
    height = 100%,
    cell-vertical-align = center,
    cell-horizontal-align = center,
    background-color = lightsalmon,
    content = Button {
        content = "Decline",
        shadow = _{
            x-offset = 0.5em,
            y-offset = 1em,
            blur = 0.2em,
            color = salmon,
            spread-radius = 0.1em,
        },
    },
}
view := rui.NewGridLayout(session, rui.Params{
    rui.Width:               rui.Percent(100),
    rui.Height:              rui.Percent(100),
    rui.CellVerticalAlign:   rui.CenterAlign,
    rui.CellHorizontalAlign: rui.CenterAlign,
    rui.BackgroundColor:     rui.LightSalmon,
    rui.Content: rui.NewButton(session, rui.Params{
        rui.Content: "Decline",
        rui.Shadow: []rui.ViewShadow{
            rui.NewViewShadow(rui.Em(0.5), rui.Em(1), rui.Em(0.2), rui.Em(0.1), rui.Salmon),
        },
    }),
})