MCPcopy Create free account
hub / github.com/SolarLune/masterplan / Width

Method Width

contents.go:5222–5241  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5220}
5221
5222func (w *InternetContents) Width() int {
5223
5224 asrString := w.Card.Properties.Get("aspect ratio").AsString()
5225 split := strings.FieldsFunc(asrString, func(r rune) bool { return r == ':' || r == ' ' })
5226
5227 width, _ := strconv.Atoi(split[0])
5228 height, _ := strconv.Atoi(split[1])
5229
5230 asr := float64(height) / float64(width)
5231
5232 sizeString := w.Card.Properties.Get("size").AsString()
5233 s, _ := strconv.Atoi(sizeString[:len(sizeString)-1])
5234 size := float64(s)
5235
5236 fWidth := size * (1 / asr)
5237 if asr > 1 {
5238 fWidth = size
5239 }
5240 return int(math.Round(fWidth))
5241}
5242
5243func (w *InternetContents) Height() int {
5244

Callers 3

ReinitContextMethod · 0.95
ReceiveMessageMethod · 0.95
DefaultSizeMethod · 0.95

Calls 2

AsStringMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected