Skip to content

Commit 096ba74

Browse files
committed
Add temporary workaround for issue #32
Clojure code hightlight is now disabled, but the indentind is shown.
1 parent 352299a commit 096ba74

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

_posts/2018-03-04-verlet-integration.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This code uses the [Quil library](https://github.com/quil/quil) to render points
3434
and lines. In the `main-` function, the `sketch` macro from the Quil library is
3535
used to bind the physics domain to the UI.
3636

37-
```clojure
37+
```Clojure
3838
(defn -main []
3939
(quil/sketch
4040
:host -main
@@ -55,7 +55,7 @@ The sketch macro basically asks the developer to configure which 'handler
5555
functions' it should call when certain events occur. For instance:
5656

5757
- a key is pressed -> call `key-pressed`
58-
- the mouse is pressed -> call `mouse-press`
58+
- the mouse is pressed -> call `mouse-pressed`
5959
- the state of your program has to be updated -> call `update-state`
6060
- it's time to draw the new state -> call `draw`
6161
- etc.
@@ -69,7 +69,7 @@ Because I configured Quil to run in functional mode `(quil-mw/fun-mode)`, Quil:
6969

7070
The handler function signatures therefore look like this:
7171

72-
```clojure
72+
```Clojure
7373
(defn draw [state] ...)
7474
(defn update-state [state] ...)
7575
(defn key-pressed [state event] ...)
@@ -81,7 +81,7 @@ The handler function signatures therefore look like this:
8181
What does a snapshot of this world state look like? `key-pressed` gives some
8282
hints:
8383

84-
```clojure
84+
```Clojure
8585
(defn key-pressed
8686
[state event]
8787
(let [raw-key (:raw-key event)
@@ -99,7 +99,7 @@ hints:
9999
So on pressing a key, a certain world is loaded. Let's look into the 'sticks'
100100
world:
101101

102-
```clojure
102+
```Clojure
103103
{:points {:p0 {:x 10 :y 1 :oldx 0 :oldy 0}
104104
:p1 {:x 100 :y 100 :oldx 100 :oldy 100}
105105
:p2 {:x 0 :y 500 :oldx 0 :oldy 525}
@@ -128,7 +128,7 @@ Stick length. The simulation loop boils down to:
128128

129129
In code:
130130

131-
```clojure
131+
```Clojure
132132
(defn update-state
133133
[state]
134134
(->> state
@@ -145,7 +145,7 @@ This code can be read like this: 'with `state`, first `update-points`, then
145145
Points are the main abstraction in this code. I decided to use a record to name
146146
them:
147147

148-
```clojure
148+
```Clojure
149149
(defrecord Point [x y oldx oldy pinned])
150150
```
151151

@@ -157,7 +157,7 @@ A pinned Point can be unpinned by clicking it with the mouse pointer.
157157
The `update-point` function calculates the velocity of the Point and adds some
158158
gravity in the mix:
159159

160-
```clojure
160+
```Clojure
161161
(defn update-point
162162
[{:keys [x y oldx oldy pinned] :as point}]
163163
(if pinned
@@ -179,7 +179,7 @@ values in a data structure without explicitly querying the data structure. So
179179
instead of getting each and every value out of Point and binding it to a 'new'
180180
name...
181181

182-
```clojure
182+
```Clojure
183183
(let [x (:x point)
184184
y (:y point)
185185
oldx (:oldx point)
@@ -208,7 +208,7 @@ already moving and reacting to gravity in the simulation.
208208
It's time for Points to meet the harsh reality of life. Walls are harder than
209209
Points and therefore Points should bounce off of them:
210210

211-
```clojure
211+
```Clojure
212212
(defn hit-floor? [y] (> y height))
213213
(defn hit-ceiling? [y] (< y 0))
214214
(defn hit-left-wall? [x] (< x 0))
@@ -276,7 +276,7 @@ Instead of trying to calculate the solution that satisfies all Stick constraints
276276
at once, this code simply looks at one Stick at a time and 'solves' the
277277
constraint problem by repeatedly solving Stick constraints in isolation.
278278

279-
```clojure
279+
```Clojure
280280
(defn apply-stick-constraint
281281
[{length :length :as stick}
282282
{p0x :x p0y :y oldp0x :oldx oldp0y :oldy pinp0 :pinned :as p0}
@@ -336,7 +336,7 @@ is perceived to behave naturally.
336336

337337
Finally, the Points and Sticks have to be drawn on screen:
338338

339-
```clojure
339+
```Clojure
340340
(defn draw
341341
[state]
342342
(quil/background 255)

0 commit comments

Comments
 (0)