This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env fsharpi | |
#I "../../../.nuget/packages/hopac/0.3.21/lib/net45/" | |
#I "../../../.nuget/packages/hopac.extras/0.3.1/lib/net45" | |
#r "Hopac.Extras" | |
#r "Hopac.Platform" | |
#r "Hopac.Core" | |
#r "Hopac" | |
open System |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import typetraits | |
import strutils | |
import random | |
import sdl2 | |
import dadren.application | |
import dadren.scenes | |
import dadren.utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main.nim(8, 3) Error: cannot instantiate 'resize' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
method draw(self: VSplit[Color], display: var RendererPtr) = | |
let | |
mp = self.midpointW(self.ratio) | |
top = self.region.top | |
bottom = self.region.bottom | |
display.setDrawColor(255, 255, 255, 255) | |
for y in top..bottom: | |
display.drawPoint(mp, y) | |
self.backward.draw(display) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Region*[T: int|float] = object | |
left*, top*, right*, bottom*: T | |
proc width*[T](self: Region): T = self.right - self.left | |
proc height*[T](self: Region): T = self.bottom - self.top | |
proc midpointW*[T](self: Region[T], position: float): T = self.left + position * self.width[T]() | |
proc midpointH*[T](self: Region[T], position: float): T = self.top + position * self.height[T]() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import strutils | |
import random | |
import sdl2 | |
import dadren.application | |
import dadren.scenes | |
import dadren.utils | |
template `as` (a, b: untyped): untyped = ((b)a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
Region*[T: int|float] = object | |
left, top, right, bottom: T | |
# then | |
for node in self.bsp.leaves: | |
var r: Region[float] | |
r.left = node.left | |
r.top = node.top |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template `as` (a, b: untyped): untyped = ((b)a) | |
type | |
BSPNode[T] = ref object of RootObj | |
parent: BSPNode[T] | |
ParentNode[T] = ref object of BSPNode[T] | |
forward, backward: BSPNode[T] | |
position: float | |
Leaf[T]= ref object of BSPNode[T] | |
content: T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proc split[T](self: BSPTree[T], target: Leaf, parent: ParentNode[T]): Leaf[T] = | |
var mp: int | |
parent.backward = target | |
if (parent of VSplit[T]): | |
var casted = (VSplit[T])parent | |
mp = midpoint(casted, target) | |
casted.adjustSource(target, mp) | |
casted.forward = casted.newSibling(target, mp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template `isA` (a, b: untyped): untyped = | |
# this definition exists in the System module | |
compiles((b)a) | |
# test.nim(19, 16) Error: type mismatch: got (typedesc[Leaf[system.string]]) | |
# but expected one of: | |
# template isA(a, b: untyped): untyped |