mirror of https://github.com/anoshenko/rui.git
Updated Animation.String method
This commit is contained in:
parent
5e3d37a6a0
commit
9b27cb4a55
55
animation.go
55
animation.go
|
@ -411,9 +411,60 @@ func (animation *animationData) String() string {
|
||||||
|
|
||||||
buffer.WriteString("animation {")
|
buffer.WriteString("animation {")
|
||||||
|
|
||||||
// TODO
|
for _, tag := range animation.AllTags() {
|
||||||
|
if tag != PropertyTag {
|
||||||
|
if value, ok := animation.properties[tag]; ok && value != nil {
|
||||||
|
buffer.WriteString("\n\t")
|
||||||
|
buffer.WriteString(tag)
|
||||||
|
buffer.WriteString(" = ")
|
||||||
|
writePropertyValue(buffer, tag, value, "\t")
|
||||||
|
buffer.WriteRune(',')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buffer.WriteString("}")
|
writeProperty := func(prop AnimatedProperty, indent string) {
|
||||||
|
buffer.WriteString(prop.Tag)
|
||||||
|
buffer.WriteString("{\n")
|
||||||
|
buffer.WriteString(indent)
|
||||||
|
buffer.WriteString("from = ")
|
||||||
|
writePropertyValue(buffer, "from", prop.From, indent)
|
||||||
|
buffer.WriteString(",\n")
|
||||||
|
buffer.WriteString(indent)
|
||||||
|
buffer.WriteString("to = ")
|
||||||
|
writePropertyValue(buffer, "to", prop.To, indent)
|
||||||
|
for key, value := range prop.KeyFrames {
|
||||||
|
buffer.WriteString(",\n")
|
||||||
|
buffer.WriteString(indent)
|
||||||
|
tag := strconv.Itoa(key) + "%"
|
||||||
|
buffer.WriteString(tag)
|
||||||
|
buffer.WriteString(" = ")
|
||||||
|
writePropertyValue(buffer, tag, value, indent)
|
||||||
|
}
|
||||||
|
buffer.WriteString("\n")
|
||||||
|
buffer.WriteString(indent[1:])
|
||||||
|
buffer.WriteString("}")
|
||||||
|
}
|
||||||
|
|
||||||
|
if props := animation.animatedProperties(); len(props) > 0 {
|
||||||
|
|
||||||
|
buffer.WriteString("\n\t")
|
||||||
|
buffer.WriteString(PropertyTag)
|
||||||
|
buffer.WriteString(" = ")
|
||||||
|
if len(props) > 1 {
|
||||||
|
buffer.WriteString("[\n")
|
||||||
|
for _, prop := range props {
|
||||||
|
buffer.WriteString("\t\t")
|
||||||
|
writeProperty(prop, "\t\t\t")
|
||||||
|
buffer.WriteString(",\n")
|
||||||
|
}
|
||||||
|
buffer.WriteString("\t]")
|
||||||
|
} else {
|
||||||
|
writeProperty(props[0], "\t\t")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.WriteString("\n}")
|
||||||
return buffer.String()
|
return buffer.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -605,8 +605,8 @@ func writePropertyValue(buffer *strings.Builder, tag string, value any, indent s
|
||||||
} else {
|
} else {
|
||||||
for _, ch := range text {
|
for _, ch := range text {
|
||||||
if (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') ||
|
if (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') ||
|
||||||
ch == '+' || ch == '-' || ch == '@' || ch == '/' || ch == '_' || ch == ':' ||
|
ch == '+' || ch == '-' || ch == '@' || ch == '/' || ch == '_' || ch == '.' ||
|
||||||
ch == '#' || ch == '%' || ch == 'π' || ch == '°' {
|
ch == ':' || ch == '#' || ch == '%' || ch == 'π' || ch == '°' {
|
||||||
} else {
|
} else {
|
||||||
simple = false
|
simple = false
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue