Permalink
Browse files

Created `macros` module for internal Macro functionality.

Created `NamedValues` trait to allow Macro generation of field name to values.
Updated `Color` to extend `NameValues` to retain color names for preset names.
  • Loading branch information...
darkfrog26 committed Aug 23, 2017
1 parent 20b4ff8 commit 01a57374e4e7cb07d0cc00cbbcdd974de4e6864c
@@ -32,16 +32,30 @@ val scalaCheckVersion = "1.13.5"

lazy val root = project.in(file("."))
.aggregate(
coreJS, coreJVM, spatialJS, spatialJVM, stream, communicationJS, communicationJVM, dom, client, server,
serverUndertow, canvasJS, canvasJVM, hypertext, optimizer, appJS, appJVM, templateJS, templateJVM, exampleJS,
exampleJVM
macrosJS, macrosJVM, coreJS, coreJVM, spatialJS, spatialJVM, stream, communicationJS, communicationJVM, dom, client,
server, serverUndertow, canvasJS, canvasJVM, hypertext, optimizer, appJS, appJVM, templateJS, templateJVM,
exampleJS, exampleJVM
)
.settings(
resolvers += "Artima Maven Repository" at "http://repo.artima.com/releases",
publish := {},
publishLocal := {}
)

lazy val macros = crossProject.in(file("macros"))
.settings(
name := "youi-macros",
description := "Dependency for internal Macro functionality",
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scalactic" %%% "scalactic" % scalacticVersion,
"org.scalatest" %%% "scalatest" % scalaTestVersion % "test"
)
)

lazy val macrosJS = macros.js
lazy val macrosJVM = macros.jvm

lazy val core = crossProject.in(file("core"))
.settings(
name := "youi-core",
@@ -71,6 +85,7 @@ lazy val core = crossProject.in(file("core"))
"org.scala-js" %%% "scalajs-dom" % scalaJSDOM
)
)
.dependsOn(macros)

lazy val coreJS = core.js
lazy val coreJVM = core.jvm
@@ -71,149 +71,149 @@ class Color private(val value: Long) extends AnyVal {
def withBrightness(brightness: Double): Color = Color.fromHSB(hue, saturation, brightness)
}

object Color {
def Clear: Color = fromLong(0x00000000)
def AliceBlue: Color = fromLong(0xF0F8FFFF)
def AntiqueWhite: Color = fromLong(0xFAEBD7FF)
def Aqua: Color = fromLong(0x00FFFFFF)
def Aquamarine: Color = fromLong(0x7FFFD4FF)
def Azure: Color = fromLong(0xF0FFFFFF)
def Beige: Color = fromLong(0xF5F5DCFF)
def Bisque: Color = fromLong(0xFFE4C4FF)
def Black: Color = fromLong(0x000000FF)
def BlanchedAlmond: Color = fromLong(0xFFEBCDFF)
def Blue: Color = fromLong(0x0000FFFF)
def BlueViolet: Color = fromLong(0x8A2BE2FF)
def Brown: Color = fromLong(0xA52A2AFF)
def BurlyWood: Color = fromLong(0xDEB887FF)
def CadetBlue: Color = fromLong(0x5F9EA0FF)
def Chartreuse: Color = fromLong(0x7FFF00FF)
def Chocolate: Color = fromLong(0xD2691EFF)
def Coral: Color = fromLong(0xFF7F50FF)
def CornflowerBlue: Color = fromLong(0x6495EDFF)
def Cornsilk: Color = fromLong(0xFFF8DCFF)
def Crimson: Color = fromLong(0xDC143CFF)
def Cyan: Color = fromLong(0x00FFFFFF)
def DarkBlue: Color = fromLong(0x00008BFF)
def DarkCyan: Color = fromLong(0x008B8BFF)
def DarkGoldenRod: Color = fromLong(0xB8860BFF)
def DarkGray: Color = fromLong(0xA9A9A9FF)
def DarkGreen: Color = fromLong(0x006400FF)
def DarkKhaki: Color = fromLong(0xBDB76BFF)
def DarkMagenta: Color = fromLong(0x8B008BFF)
def DarkOliveGreen: Color = fromLong(0x556B2FFF)
def DarkOrange: Color = fromLong(0xFF8C00FF)
def DarkOrchid: Color = fromLong(0x9932CCFF)
def DarkRed: Color = fromLong(0x8B0000FF)
def DarkSalmon: Color = fromLong(0xE9967AFF)
def DarkSeaGreen: Color = fromLong(0x8FBC8FFF)
def DarkSlateBlue: Color = fromLong(0x483D8BFF)
def DarkSlateGray: Color = fromLong(0x2F4F4FFF)
def DarkTurquoise: Color = fromLong(0x00CED1FF)
def DarkViolet: Color = fromLong(0x9400D3FF)
def DeepPink: Color = fromLong(0xFF1493FF)
def DeepSkyBlue: Color = fromLong(0x00BFFFFF)
def DimGray: Color = fromLong(0x696969FF)
def DodgerBlue: Color = fromLong(0x1E90FFFF)
def FireBrick: Color = fromLong(0xB22222FF)
def FloralWhite: Color = fromLong(0xFFFAF0FF)
def ForestGreen: Color = fromLong(0x228B22FF)
def Fuchsia: Color = fromLong(0xFF00FFFF)
def Gainsboro: Color = fromLong(0xDCDCDCFF)
def GhostWhite: Color = fromLong(0xF8F8FFFF)
def Gold: Color = fromLong(0xFFD700FF)
def GoldenRod: Color = fromLong(0xDAA520FF)
def Gray: Color = fromLong(0x808080FF)
def Green: Color = fromLong(0x008000FF)
def GreenYellow: Color = fromLong(0xADFF2FFF)
def HoneyDew: Color = fromLong(0xF0FFF0FF)
def HotPink: Color = fromLong(0xFF69B4FF)
def IndianRed: Color = fromLong(0xCD5C5CFF)
def Indigo: Color = fromLong(0x4B0082FF)
def Ivory: Color = fromLong(0xFFFFF0FF)
def Khaki: Color = fromLong(0xF0E68CFF)
def Lavender: Color = fromLong(0xE6E6FAFF)
def LavenderBlush: Color = fromLong(0xFFF0F5FF)
def LawnGreen: Color = fromLong(0x7CFC00FF)
def LemonChiffon: Color = fromLong(0xFFFACDFF)
def LightBlue: Color = fromLong(0xADD8E6FF)
def LightCoral: Color = fromLong(0xF08080FF)
def LightCyan: Color = fromLong(0xE0FFFFFF)
def LightGoldenRodYellow: Color = fromLong(0xFAFAD2FF)
def LightGray: Color = fromLong(0xD3D3D3FF)
def LightGreen: Color = fromLong(0x90EE90FF)
def LightPink: Color = fromLong(0xFFB6C1FF)
def LightSalmon: Color = fromLong(0xFFA07AFF)
def LightSeaGreen: Color = fromLong(0x20B2AAFF)
def LightSkyBlue: Color = fromLong(0x87CEFAFF)
def LightSlateGray: Color = fromLong(0x778899FF)
def LightSteelBlue: Color = fromLong(0xB0C4DEFF)
def LightYellow: Color = fromLong(0xFFFFE0FF)
def Lime: Color = fromLong(0x00FF00FF)
def LimeGreen: Color = fromLong(0x32CD32FF)
def Linen: Color = fromLong(0xFAF0E6FF)
def Magenta: Color = fromLong(0xFF00FFFF)
def Maroon: Color = fromLong(0x800000FF)
def MediumAquaMarine: Color = fromLong(0x66CDAAFF)
def MediumBlue: Color = fromLong(0x0000CDFF)
def MediumOrchid: Color = fromLong(0xBA55D3FF)
def MediumPurple: Color = fromLong(0x9370DBFF)
def MediumSeaGreen: Color = fromLong(0x3CB371FF)
def MediumSlateBlue: Color = fromLong(0x7B68EEFF)
def MediumSpringGreen: Color = fromLong(0x00FA9AFF)
def MediumTurquoise: Color = fromLong(0x48D1CCFF)
def MediumVioletRed: Color = fromLong(0xC71585FF)
def MidnightBlue: Color = fromLong(0x191970FF)
def MintCream: Color = fromLong(0xF5FFFAFF)
def MistyRose: Color = fromLong(0xFFE4E1FF)
def Moccasin: Color = fromLong(0xFFE4B5FF)
def NavajoWhite: Color = fromLong(0xFFDEADFF)
def Navy: Color = fromLong(0x000080FF)
def OldLace: Color = fromLong(0xFDF5E6FF)
def Olive: Color = fromLong(0x808000FF)
def OliveDrab: Color = fromLong(0x6B8E23FF)
def Orange: Color = fromLong(0xFFA500FF)
def OrangeRed: Color = fromLong(0xFF4500FF)
def Orchid: Color = fromLong(0xDA70D6FF)
def PaleGoldenRod: Color = fromLong(0xEEE8AAFF)
def PaleGreen: Color = fromLong(0x98FB98FF)
def PaleTurquoise: Color = fromLong(0xAFEEEEFF)
def PaleVioletRed: Color = fromLong(0xDB7093FF)
def PapayaWhip: Color = fromLong(0xFFEFD5FF)
def PeachPuff: Color = fromLong(0xFFDAB9FF)
def Peru: Color = fromLong(0xCD853FFF)
def Pink: Color = fromLong(0xFFC0CBFF)
def Plum: Color = fromLong(0xDDA0DDFF)
def PowderBlue: Color = fromLong(0xB0E0E6FF)
def Purple: Color = fromLong(0x800080FF)
def RebeccaPurple: Color = fromLong(0x663399FF)
def Red: Color = fromLong(0xFF0000FF)
def RosyBrown: Color = fromLong(0xBC8F8FFF)
def RoyalBlue: Color = fromLong(0x4169E1FF)
def SaddleBrown: Color = fromLong(0x8B4513FF)
def Salmon: Color = fromLong(0xFA8072FF)
def SandyBrown: Color = fromLong(0xF4A460FF)
def SeaGreen: Color = fromLong(0x2E8B57FF)
def SeaShell: Color = fromLong(0xFFF5EEFF)
def Sienna: Color = fromLong(0xA0522DFF)
def Silver: Color = fromLong(0xC0C0C0FF)
def SkyBlue: Color = fromLong(0x87CEEBFF)
def SlateBlue: Color = fromLong(0x6A5ACDFF)
def SlateGray: Color = fromLong(0x708090FF)
def Snow: Color = fromLong(0xFFFAFAFF)
def SpringGreen: Color = fromLong(0x00FF7FFF)
def SteelBlue: Color = fromLong(0x4682B4FF)
def Tan: Color = fromLong(0xD2B48CFF)
def Teal: Color = fromLong(0x008080FF)
def Thistle: Color = fromLong(0xD8BFD8FF)
def Tomato: Color = fromLong(0xFF6347FF)
def Turquoise: Color = fromLong(0x40E0D0FF)
def Violet: Color = fromLong(0xEE82EEFF)
def Wheat: Color = fromLong(0xF5DEB3FF)
def White: Color = fromLong(0xFFFFFFFF)
def WhiteSmoke: Color = fromLong(0xF5F5F5FF)
def Yellow: Color = fromLong(0xFFFF00FF)
def YellowGreen: Color = fromLong(0x9ACD32FF)
object Color extends NamedValues[Color] {
val Clear: Color = named(fromLong(0x00000000))
val AliceBlue: Color = named(fromLong(0xF0F8FFFF))
val AntiqueWhite: Color = named(fromLong(0xFAEBD7FF))
val Aqua: Color = named(fromLong(0x00FFFFFF))
val Aquamarine: Color = named(fromLong(0x7FFFD4FF))
val Azure: Color = named(fromLong(0xF0FFFFFF))
val Beige: Color = named(fromLong(0xF5F5DCFF))
val Bisque: Color = named(fromLong(0xFFE4C4FF))
val Black: Color = named(fromLong(0x000000FF))
val BlanchedAlmond: Color = named(fromLong(0xFFEBCDFF))
val Blue: Color = named(fromLong(0x0000FFFF))
val BlueViolet: Color = named(fromLong(0x8A2BE2FF))
val Brown: Color = named(fromLong(0xA52A2AFF))
val BurlyWood: Color = named(fromLong(0xDEB887FF))
val CadetBlue: Color = named(fromLong(0x5F9EA0FF))
val Chartreuse: Color = named(fromLong(0x7FFF00FF))
val Chocolate: Color = named(fromLong(0xD2691EFF))
val Coral: Color = named(fromLong(0xFF7F50FF))
val CornflowerBlue: Color = named(fromLong(0x6495EDFF))
val Cornsilk: Color = named(fromLong(0xFFF8DCFF))
val Crimson: Color = named(fromLong(0xDC143CFF))
val Cyan: Color = named(fromLong(0x00FFFFFF))
val DarkBlue: Color = named(fromLong(0x00008BFF))
val DarkCyan: Color = named(fromLong(0x008B8BFF))
val DarkGoldenRod: Color = named(fromLong(0xB8860BFF))
val DarkGray: Color = named(fromLong(0xA9A9A9FF))
val DarkGreen: Color = named(fromLong(0x006400FF))
val DarkKhaki: Color = named(fromLong(0xBDB76BFF))
val DarkMagenta: Color = named(fromLong(0x8B008BFF))
val DarkOliveGreen: Color = named(fromLong(0x556B2FFF))
val DarkOrange: Color = named(fromLong(0xFF8C00FF))
val DarkOrchid: Color = named(fromLong(0x9932CCFF))
val DarkRed: Color = named(fromLong(0x8B0000FF))
val DarkSalmon: Color = named(fromLong(0xE9967AFF))
val DarkSeaGreen: Color = named(fromLong(0x8FBC8FFF))
val DarkSlateBlue: Color = named(fromLong(0x483D8BFF))
val DarkSlateGray: Color = named(fromLong(0x2F4F4FFF))
val DarkTurquoise: Color = named(fromLong(0x00CED1FF))
val DarkViolet: Color = named(fromLong(0x9400D3FF))
val DeepPink: Color = named(fromLong(0xFF1493FF))
val DeepSkyBlue: Color = named(fromLong(0x00BFFFFF))
val DimGray: Color = named(fromLong(0x696969FF))
val DodgerBlue: Color = named(fromLong(0x1E90FFFF))
val FireBrick: Color = named(fromLong(0xB22222FF))
val FloralWhite: Color = named(fromLong(0xFFFAF0FF))
val ForestGreen: Color = named(fromLong(0x228B22FF))
val Fuchsia: Color = named(fromLong(0xFF00FFFF))
val Gainsboro: Color = named(fromLong(0xDCDCDCFF))
val GhostWhite: Color = named(fromLong(0xF8F8FFFF))
val Gold: Color = named(fromLong(0xFFD700FF))
val GoldenRod: Color = named(fromLong(0xDAA520FF))
val Gray: Color = named(fromLong(0x808080FF))
val Green: Color = named(fromLong(0x008000FF))
val GreenYellow: Color = named(fromLong(0xADFF2FFF))
val HoneyDew: Color = named(fromLong(0xF0FFF0FF))
val HotPink: Color = named(fromLong(0xFF69B4FF))
val IndianRed: Color = named(fromLong(0xCD5C5CFF))
val Indigo: Color = named(fromLong(0x4B0082FF))
val Ivory: Color = named(fromLong(0xFFFFF0FF))
val Khaki: Color = named(fromLong(0xF0E68CFF))
val Lavender: Color = named(fromLong(0xE6E6FAFF))
val LavenderBlush: Color = named(fromLong(0xFFF0F5FF))
val LawnGreen: Color = named(fromLong(0x7CFC00FF))
val LemonChiffon: Color = named(fromLong(0xFFFACDFF))
val LightBlue: Color = named(fromLong(0xADD8E6FF))
val LightCoral: Color = named(fromLong(0xF08080FF))
val LightCyan: Color = named(fromLong(0xE0FFFFFF))
val LightGoldenRodYellow: Color = named(fromLong(0xFAFAD2FF))
val LightGray: Color = named(fromLong(0xD3D3D3FF))
val LightGreen: Color = named(fromLong(0x90EE90FF))
val LightPink: Color = named(fromLong(0xFFB6C1FF))
val LightSalmon: Color = named(fromLong(0xFFA07AFF))
val LightSeaGreen: Color = named(fromLong(0x20B2AAFF))
val LightSkyBlue: Color = named(fromLong(0x87CEFAFF))
val LightSlateGray: Color = named(fromLong(0x778899FF))
val LightSteelBlue: Color = named(fromLong(0xB0C4DEFF))
val LightYellow: Color = named(fromLong(0xFFFFE0FF))
val Lime: Color = named(fromLong(0x00FF00FF))
val LimeGreen: Color = named(fromLong(0x32CD32FF))
val Linen: Color = named(fromLong(0xFAF0E6FF))
val Magenta: Color = named(fromLong(0xFF00FFFF))
val Maroon: Color = named(fromLong(0x800000FF))
val MediumAquaMarine: Color = named(fromLong(0x66CDAAFF))
val MediumBlue: Color = named(fromLong(0x0000CDFF))
val MediumOrchid: Color = named(fromLong(0xBA55D3FF))
val MediumPurple: Color = named(fromLong(0x9370DBFF))
val MediumSeaGreen: Color = named(fromLong(0x3CB371FF))
val MediumSlateBlue: Color = named(fromLong(0x7B68EEFF))
val MediumSpringGreen: Color = named(fromLong(0x00FA9AFF))
val MediumTurquoise: Color = named(fromLong(0x48D1CCFF))
val MediumVioletRed: Color = named(fromLong(0xC71585FF))
val MidnightBlue: Color = named(fromLong(0x191970FF))
val MintCream: Color = named(fromLong(0xF5FFFAFF))
val MistyRose: Color = named(fromLong(0xFFE4E1FF))
val Moccasin: Color = named(fromLong(0xFFE4B5FF))
val NavajoWhite: Color = named(fromLong(0xFFDEADFF))
val Navy: Color = named(fromLong(0x000080FF))
val OldLace: Color = named(fromLong(0xFDF5E6FF))
val Olive: Color = named(fromLong(0x808000FF))
val OliveDrab: Color = named(fromLong(0x6B8E23FF))
val Orange: Color = named(fromLong(0xFFA500FF))
val OrangeRed: Color = named(fromLong(0xFF4500FF))
val Orchid: Color = named(fromLong(0xDA70D6FF))
val PaleGoldenRod: Color = named(fromLong(0xEEE8AAFF))
val PaleGreen: Color = named(fromLong(0x98FB98FF))
val PaleTurquoise: Color = named(fromLong(0xAFEEEEFF))
val PaleVioletRed: Color = named(fromLong(0xDB7093FF))
val PapayaWhip: Color = named(fromLong(0xFFEFD5FF))
val PeachPuff: Color = named(fromLong(0xFFDAB9FF))
val Peru: Color = named(fromLong(0xCD853FFF))
val Pink: Color = named(fromLong(0xFFC0CBFF))
val Plum: Color = named(fromLong(0xDDA0DDFF))
val PowderBlue: Color = named(fromLong(0xB0E0E6FF))
val Purple: Color = named(fromLong(0x800080FF))
val RebeccaPurple: Color = named(fromLong(0x663399FF))
val Red: Color = named(fromLong(0xFF0000FF))
val RosyBrown: Color = named(fromLong(0xBC8F8FFF))
val RoyalBlue: Color = named(fromLong(0x4169E1FF))
val SaddleBrown: Color = named(fromLong(0x8B4513FF))
val Salmon: Color = named(fromLong(0xFA8072FF))
val SandyBrown: Color = named(fromLong(0xF4A460FF))
val SeaGreen: Color = named(fromLong(0x2E8B57FF))
val SeaShell: Color = named(fromLong(0xFFF5EEFF))
val Sienna: Color = named(fromLong(0xA0522DFF))
val Silver: Color = named(fromLong(0xC0C0C0FF))
val SkyBlue: Color = named(fromLong(0x87CEEBFF))
val SlateBlue: Color = named(fromLong(0x6A5ACDFF))
val SlateGray: Color = named(fromLong(0x708090FF))
val Snow: Color = named(fromLong(0xFFFAFAFF))
val SpringGreen: Color = named(fromLong(0x00FF7FFF))
val SteelBlue: Color = named(fromLong(0x4682B4FF))
val Tan: Color = named(fromLong(0xD2B48CFF))
val Teal: Color = named(fromLong(0x008080FF))
val Thistle: Color = named(fromLong(0xD8BFD8FF))
val Tomato: Color = named(fromLong(0xFF6347FF))
val Turquoise: Color = named(fromLong(0x40E0D0FF))
val Violet: Color = named(fromLong(0xEE82EEFF))
val Wheat: Color = named(fromLong(0xF5DEB3FF))
val White: Color = named(fromLong(0xFFFFFFFF))
val WhiteSmoke: Color = named(fromLong(0xF5F5F5FF))
val Yellow: Color = named(fromLong(0xFFFF00FF))
val YellowGreen: Color = named(fromLong(0x9ACD32FF))

private def hexify(value: Double): String = hexify(math.floor(value * 255.0).toInt)
private def hexify(value: Int): String = f"$value%02x"
@@ -36,4 +36,4 @@ object Macros {
case _ => c.abort(c.enclosingPosition, "Bad usage of url interpolation.")
}
}
}
}
@@ -92,5 +92,9 @@ class ColorSpec extends WordSpec with Matchers {
c.saturation should be(1.0)
c.brightness should be(0.7490196078431373)
}
"get a color by name" in {
Color.getByName("green") should be(Some(Color.Green))
Color.getByName("blanched almond") should be(Some(Color.BlanchedAlmond))
}
}
}
@@ -33,6 +33,7 @@ object ClientExampleApplication extends JSApp with ExampleApplication with Clien
val imageEditor = ImageEditorExample

val dataTransfer = DataTransferExample
val selection = hypertext.SelectionExample

val htmlHello = hypertext.HelloWorld
val htmlAnimation = hypertext.AnimationExample
Oops, something went wrong.

0 comments on commit 01a5737

Please sign in to comment.