All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hyperscala.svg.attributes.Paint.scala Maven / Gradle / Ivy

package org.hyperscala.svg.attributes

import org.powerscala.Color
import org.hyperscala.svg.SVGTag
import org.hyperscala.persistence.ValuePersistence

/**
 * @author Matt Hicks 
 */
sealed trait Paint {
  def value: String
}

object Paint extends ValuePersistence[Paint] {
  val None = PaintNone
  val Current = PaintCurrent
  def Color(color: Color) = PaintColor(color)
  def IRI(iri: String) = PaintIRI(iri)
  def Ref(tag: SVGTag) = IRI("#%s".format(tag.identity))

  def fromString(s: String, name: String, clazz: Class[_]) = throw new UnsupportedOperationException("Paint reading not supported")

  def toString(t: Paint, name: String, clazz: Class[_]) = t.value
}

object PaintNone extends Paint {
  val value = "none"
}

object PaintCurrent extends Paint {
  val value = "currentColor"
}

case class PaintColor(color: Color) extends Paint {
  def value = color.hex.rgb
}

case class PaintIRI(iri: String) extends Paint {
  def value = "url(%s)".format(iri)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy