Skip to content

Making canvas fill the size of the parent #1126

Closed Answered by kkoreilly
runrc asked this question in Q&A
Discussion options

You must be logged in to vote

This should work:

b := core.NewBody("Test")
c := core.NewCanvas(b)
c.Styler(func(s *styles.Style) {
  s.Grow.Set(1, 1) // << this makes it take up the entire space
})
c.SetDraw(func(pc *paint.Context) {
  pc.MoveTo(0, 0)
  pc.LineTo(1, 1)
  pc.StrokeStyle.Color = colors.Scheme.Error.Base
  pc.Stroke()
})
b.RunMainWindow()

Depending on your use case, you might also be interested in our data plots.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by runrc
Comment options

You must be logged in to vote
1 reply
@kkoreilly
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants