themes and styles
This commit is contained in:
@@ -205,3 +205,30 @@ func (t *StyleTable) AddDerived(baseID StyleID, override StyleOverride) StyleID
|
||||
t.styles[id] = derived
|
||||
return id
|
||||
}
|
||||
|
||||
// AddStyle stores a fully resolved style as a new StyleID.
|
||||
// It defensively copies slice fields.
|
||||
func (t *StyleTable) AddStyle(s Style) StyleID {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
|
||||
id := t.nextID
|
||||
t.nextID++
|
||||
|
||||
if s.StrokeDashes != nil {
|
||||
cp := make([]float64, len(s.StrokeDashes))
|
||||
copy(cp, s.StrokeDashes)
|
||||
s.StrokeDashes = cp
|
||||
}
|
||||
|
||||
t.styles[id] = s
|
||||
return id
|
||||
}
|
||||
|
||||
// Count returns the number of styles stored in the table.
|
||||
// Intended for tests/diagnostics.
|
||||
func (t *StyleTable) Count() int {
|
||||
t.mu.RLock()
|
||||
defer t.mu.RUnlock()
|
||||
return len(t.styles)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user