MCPcopy Create free account
hub / github.com/cogentcore/core / TestBackgroundImage

Function TestBackgroundImage

paint/background_test.go:30–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28}
29
30func TestBackgroundImage(t *testing.T) {
31 img, _, err := imagex.Open("test.png")
32 assert.NoError(t, err)
33 RunTest(t, "background-image", 1260, 200, func(pc *Context) {
34 pabg := colors.Uniform(colors.White)
35 st := styles.NewStyle()
36 st.Background = img
37 st.ComputeActualBackground(pabg)
38 st.ToDots()
39
40 sz := st.BoxSpace().Size().Add(math32.Vec2(200, 100))
41
42 test := func(of styles.ObjectFits, pos math32.Vector2) {
43 st.ObjectFit = of
44 pc.DrawStandardBox(st, pos, sz, pabg)
45 }
46
47 test(styles.FitFill, math32.Vec2(0, 0))
48 test(styles.FitContain, math32.Vec2(220, 0))
49 test(styles.FitCover, math32.Vec2(440, 0))
50 test(styles.FitScaleDown, math32.Vec2(660, 0))
51 test(styles.FitNone, math32.Vec2(880, 0))
52 })
53}
54
55func TestObjectFit(t *testing.T) {
56 img, _, err := imagex.Open("test.png")

Callers

nothing calls this directly

Calls 12

ToDotsMethod · 0.95
BoxSpaceMethod · 0.95
OpenFunction · 0.92
UniformFunction · 0.92
NewStyleFunction · 0.92
Vec2Function · 0.92
RunTestFunction · 0.85
DrawStandardBoxMethod · 0.80
AddMethod · 0.65
SizeMethod · 0.65
testFunction · 0.50

Tested by

no test coverage detected