Skip to content

Commit 464083a

Browse files
committed
update readme
1 parent 48a79e7 commit 464083a

File tree

8 files changed

+269
-162
lines changed

8 files changed

+269
-162
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ val animatedBox =
2828
)
2929
```
3030

31-
[Badge-SonatypeReleases]: https://img.shields.io/nexus/r/https/oss.sonatype.org/io.github.kitlangton/animus_2.13.svg "Sonatype Releases"
32-
[Badge-SonatypeSnapshots]: https://img.shields.io/nexus/s/https/oss.sonatype.org/io.github.kitlangton/animus_2.13.svg "Sonatype Snapshots"
33-
[Link-SonatypeSnapshots]: https://oss.sonatype.org/content/repositories/snapshots/io/github/kitlangton/animus_2.13/ "Sonatype Snapshots"
34-
[Link-SonatypeReleases]: https://oss.sonatype.org/content/repositories/releases/io/github/kitlangton/animus_2.13/ "Sonatype Releases"
31+
[Badge-SonatypeReleases]: https://img.shields.io/nexus/r/https/oss.sonatype.org/io.github.kitlangton/animus_3.svg "Sonatype Releases"
32+
[Badge-SonatypeSnapshots]: https://img.shields.io/nexus/s/https/oss.sonatype.org/io.github.kitlangton/animus_3.svg "Sonatype Snapshots"
33+
[Link-SonatypeSnapshots]: https://oss.sonatype.org/content/repositories/snapshots/io/github/kitlangton/animus_3/ "Sonatype Snapshots"
34+
[Link-SonatypeReleases]: https://oss.sonatype.org/content/repositories/releases/io/github/kitlangton/animus_3/ "Sonatype Releases"

example/src/main/scala/example/Main.scala

Lines changed: 177 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -12,60 +12,6 @@ def periodic[A](min: Int, max: Int, value: => A): Signal[A] =
1212
false
1313
).startWith(value)
1414

15-
final case class Origin(
16-
x: Double,
17-
y: Double
18-
) derives VectorArithmetic
19-
20-
final case class Rect(
21-
origin: Origin,
22-
width: Double,
23-
height: Double,
24-
red: Double = scala.util.Random.nextDouble(),
25-
green: Double = scala.util.Random.nextDouble(),
26-
blue: Double = scala.util.Random.nextDouble()
27-
28-
// rotation: Double = 0
29-
) derives VectorArithmetic:
30-
def x: Double = origin.x
31-
def y: Double = origin.y
32-
33-
final case class RectView(
34-
styles: String = "bg-red-600"
35-
) extends View:
36-
def windowWidth = org.scalajs.dom.window.innerHeight
37-
38-
def randomRect = Rect(
39-
Origin(0, 0),
40-
10,
41-
// scala.util.Random.nextDouble() * 80,
42-
scala.util.Random.nextDouble() * windowWidth
43-
// 0 // scala.util.Random.nextDouble() * 30 - 15
44-
)
45-
46-
val rectSignal = periodic(500, 1000, randomRect).spring
47-
48-
def body =
49-
div(
50-
top <-- rectSignal.map(_.y).px,
51-
left <-- rectSignal.map(_.x).px,
52-
width <-- rectSignal.map(_.width).px,
53-
height <-- rectSignal.map(_.height).px,
54-
background <-- rectSignal.map { r =>
55-
s"rgb(${r.red * 255},${r.red * 255},${r.red * 255})"
56-
},
57-
opacity(0.15)
58-
// transform <-- rectSignal.map { r =>
59-
// s"rotate(${r.rotation}deg)"
60-
// }
61-
)
62-
63-
trait View:
64-
def body: HtmlElement
65-
66-
object View:
67-
given Conversion[View, HtmlElement] = _.body
68-
6915
object Main:
7016
def main(args: Array[String]): Unit =
7117
documentEvents(_.onDomContentLoaded).foreach { _ =>
@@ -91,55 +37,199 @@ object Main:
9137
.toSignal(0.0)
9238

9339
val animusText = div(
94-
cls("flex"),
40+
cls(
41+
"flex text-6xl tracking-widest"
42+
),
43+
fontFamily("Bebas Neue"),
9544
List("A", "N", "I", "M", "U", "S").map { letter =>
9645
div(
9746
cls("text-6xl relative"),
47+
fontSize("80px"),
9848
letter,
9949
top <-- wobble.px,
10050
left <-- wobble.px,
10151
styleProp("filter") <-- wobble.spring.map { w =>
10252
s"blur(${w}px)"
53+
},
54+
transform <-- wobble.spring.map { w =>
55+
s"rotate(${w * 5 - 5}deg)"
10356
}
10457
)
10558
}
10659
)
10760

108-
def body =
109-
div(
110-
cls("bg-neutral-900"),
61+
final case class Todo(title: String)
62+
63+
val todos = Vector(
64+
Todo("Learn Scala 3"),
65+
Todo("Learn Laminar"),
66+
Todo("Learn Animus"),
67+
Todo("Build something cool"),
68+
Todo("Profit!"),
69+
Todo("Question the morality of your success"),
70+
Todo("Donate all your profits in a fit of guilt"),
71+
Todo("Start a new project in search of purpose and redemption"),
72+
Todo("Fail repeatedly, questioning your competence"),
73+
Todo("Descend into isolation and existential crisis"),
74+
Todo("Reread 'Notes from Underground', find frightening parallels"),
75+
Todo("Attempt to connect with others but fail due to technology alienation"),
76+
Todo("Fall into a pit of despair"),
77+
Todo("Encounter a stranger who challenges your perspective"),
78+
Todo("Engage in philosophical debates with the stranger"),
79+
Todo("Become absorbed in the works of Nietzsche"),
80+
Todo("Decide to write a manifesto"),
81+
Todo("Lose yourself in the process, alienating friends and family"),
82+
Todo("Eventually finish and publish the manifesto"),
83+
Todo("It is met with heavy criticism and misunderstanding"),
84+
Todo("Feel crushed and spiraling deeper into solitude"),
85+
Todo("Attempt to find comfort in stoicism"),
86+
Todo("Only find more questions, not answers"),
87+
Todo("Confront your mortality and the impermanence of all things"),
88+
Todo("Decide to reinvent yourself and re-learn compassion"),
89+
Todo("Stumble upon an old machine you'd created"),
90+
Todo("Discard it, reflecting on the naivety of your past ambitions"),
91+
Todo("Volunteer at a local shelter in search of humility"),
92+
Todo("Conduct philosophical talks at the shelter"),
93+
Todo("Slowly start to regain faith in humanity"),
94+
Todo("Write a book about your transformation"),
95+
Todo("Your book touches many people, becomes a success"),
96+
Todo("Feel a sense of satisfaction but also emptiness"),
97+
Todo("Realize you still have lots to learn"),
98+
Todo("Commit to lifelong learning"),
99+
Todo("Inspire others with your journey"),
100+
Todo("Reflect on the futility of ambition"),
101+
Todo("Accept the fluidity and ambiguity of life"),
102+
Todo("Find peace in solitude and simplicity"),
103+
Todo("Live out your days quietly, introspectively"),
104+
Todo("Pass on, leaving behind a complex legacy"),
105+
Todo("Silence"),
106+
Todo("Silence"),
107+
Todo("Silence"),
108+
Todo("The horrid buzzing af a colossal, metallic wasp"),
109+
Todo("SCREAMING ENDLESS SCREAMING"),
110+
Todo("Transition into the ethereal, leaving earthly existence behind"),
111+
Todo("Experience the sensation of floating in a vast, tranquil emptiness"),
112+
Todo("Realize consciousness still persists, even in the void"),
113+
Todo("Recognize the void itself is an embodiment of your consciousness"),
114+
Todo("Start to perceive a faint shimmer in the distance"),
115+
Todo("Move towards it, feeling an inexplicable pull"),
116+
Todo("Emerge in a new world, reincarnated as a curious child"),
117+
Todo("Experience a life filled with learning and exploration"),
118+
Todo("Develop an interest in computers and technology"),
119+
Todo("Stumble upon an old book about programming in your teens"),
120+
Todo("Intrigued, you spend countless hours studying it"),
121+
Todo("Discover the power of creating and manipulating software"),
122+
Todo("Specialize in computer science, focusing on programming languages"),
123+
Todo("Start from the basics - 'Hello World' in Python"),
124+
Todo("Gradually move on to more complex tasks"),
125+
Todo("Descend into the world of Java, understanding OOP"),
126+
Todo("Eventually, you come across a peculiar language - Scala"),
127+
Todo("Dive deep into Scala 2, mesmerized by its elegance and power"),
128+
Todo("As your understanding grows, you prepare to take on a new challenge"),
129+
Todo("And so begins your journey to Learn Scala 3")
130+
)
131+
132+
// start at the given index, then take the next 3 elements, rotating back to the start
133+
def rotate[A](start: Int, take: Int, as: Vector[A]): Vector[A] =
134+
val size = as.size
135+
val i = start % size
136+
val j = (i + take) % size
137+
if j < i then as.slice(i, size) ++ as.slice(0, j)
138+
else as.slice(i, j)
139+
140+
val todosSignal =
141+
EventStream
142+
.periodic(1000)
143+
.toSignal(0)
144+
.map(rotate(_, 3, todos))
145+
.map(_.zipWithIndex)
146+
147+
val colors = List("text-neutral-200", "text-neutral-400", "text-neutral-600")
148+
149+
def todosView = div(
150+
cls("flex flex-col mt-32 text-3xl tracking-widest"),
151+
fontFamily("Bebas Neue"),
152+
children <-- todosSignal.splitTransition(_._1) { (_, value, signal, t) =>
111153
div(
112-
cls("z-10 relative font-bold overflow-hidden text-6xl text-neutral-100 h-screen flex flex-col"),
113-
cls("tracking-wider flex-col p-4 sm:p-24"),
114-
animusText,
154+
cls("transition-colors duration-300"),
155+
cls <-- signal.map { value =>
156+
colors(value._2 % colors.size)
157+
},
115158
div(
116-
cls("text-lg mt-4 items-center max-w-lg"),
159+
cls("flex space-x-2 py-2 "),
117160
div(
118-
cls("items-center flex flex-wrap"),
119-
"is a",
120-
children <-- article.splitOneTransition(identity) { (_, string, _, t) =>
161+
cls("flex-wrap flex space-x-2"),
162+
transformOrigin("left"),
163+
transform <-- signal
164+
.map { value =>
165+
value._2 match
166+
case 0 => 1.0
167+
case 1 => 0.9
168+
case _ => 0.8
169+
}
170+
.spring
171+
.map { s =>
172+
s"scale(${s})"
173+
},
174+
styleProp("filter") <-- signal
175+
.map { value =>
176+
value._2 match
177+
case 0 => 0.0
178+
case 1 => 0.5
179+
case _ => 1
180+
}
181+
.spring
182+
.map { s =>
183+
s"blur(${s}px)"
184+
},
185+
value._1.title.split(" ").map { word =>
121186
div(
122-
string,
123-
t.width
187+
word,
188+
cls("relative"),
189+
top <-- wobble.px,
190+
left <-- wobble.px,
191+
transform <-- wobble.spring.map(w => s"rotate(${w * 3 - 3}deg)")
124192
)
125-
},
126-
adjectiveOne.body,
127-
div(s"and"),
128-
AdjectiveView().body
129-
),
130-
div(s"spring animation library for Scala.js.")
131-
)
132-
),
193+
}
194+
)
195+
),
196+
t.opacity,
197+
t.height,
198+
t.blur
199+
)
200+
}
201+
)
202+
203+
def body =
204+
div(
205+
fontFamily("Playfair Display"),
206+
cls("z-10 relative font-bold text-neutral-100 h-screen flex flex-col"),
207+
cls("tracking-wider flex-col p-14 sm:p-24 overflow-x-hidden"),
208+
animusText,
133209
div(
134-
cls("w-full flex justify-center items-center"),
135-
cls("fixed inset-0"),
136-
transform := "translateZ(0)",
137-
List.fill(200)(
138-
RectView("bg-neutral-800")
139-
)
210+
cls("text-lg mt-4 items-center max-w-lg italic"),
211+
div(
212+
cls("items-center flex whitespace-nowrap"),
213+
"is a",
214+
children <-- article.splitOneTransition(identity) { (_, string, _, t) =>
215+
div(
216+
string,
217+
t.width
218+
)
219+
},
220+
adjectiveOne.body,
221+
div(s"and"),
222+
AdjectiveView().body
223+
),
224+
div(s"spring animation library for Scala.js.")
140225
)
226+
// todosView
141227
)
142228

229+
////////////////
230+
// ADJECTIVES //
231+
////////////////
232+
143233
lazy val adjectives = Array(
144234
"aesthetic",
145235
"pulchritudinous",
@@ -185,9 +275,13 @@ object Main:
185275

186276
def body =
187277
div(
188-
cls(s"flex flex-col my-[8px] mx-2 overflow-hidden"),
278+
cls(s"flex flex-col my-[8px] mx-2 overflow-hidden not-italic"),
279+
// skew
280+
transform("skewX(-15deg)"),
281+
fontFamily("Bebas Neue"),
282+
fontSize("24px"),
189283
div(
190-
cls("flex whitespace-nowrap text-neutral-900 bg-neutral-300 px-2"),
284+
cls("flex whitespace-nowrap text-neutral-900 bg-neutral-300 px-1.5 py-1 relative top-1"),
191285
children <-- adjective.splitOneTransition(identity) { (_, string, _, t) =>
192286
div(
193287
string,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package example
2+
3+
import com.raquo.laminar.api.L.*
4+
5+
trait View:
6+
def body: HtmlElement
7+
8+
object View:
9+
given Conversion[View, HtmlElement] = _.body

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Animus</title>
77
</head>
8-
<body id="app">
8+
<body id="app" class="bg-neutral-900">
99
<script type="module" src="/main.js"></script>
1010
</body>
1111
</html>

0 commit comments

Comments
 (0)