Skip to content

Instantly share code, notes, and snippets.

@adicirstei
adicirstei / happy-place.clj
Created May 28, 2019 11:42
Tarbell's Happy Place made with Clojure2D
(ns happy-place
(:require [clojure2d.core :refer :all]
[clojure2d.color :as c]
[fastmath.random :as r]
[fastmath.core :as m]
[fastmath.vector :as v]))
(def dim 900)
(def agents 128)
@adicirstei
adicirstei / beads.clj
Last active April 23, 2019 21:07
Beads on vector fields source
(ns gen-art.beads
(:require [clojure2d.core :refer :all]
[fastmath.core :as m]
[fastmath.random :as r]
[fastmath.fields :as f]
[fastmath.vector :as v]
[clojure2d.color :as c]
[clojure2d.extra.utils :as ut]
[clojure2d.pixels :as p])
(:import [fastmath.vector Vec2]) )
@adicirstei
adicirstei / boids.clj
Last active February 24, 2019 19:56
Paper.js [boids example](http://paperjs.org/examples/tadpoles/)
(ns gen-art.boids
(:require [clojure2d.core :refer :all]
[fastmath.core :as m]
[fastmath.random :as r]
[fastmath.fields :as f]
[fastmath.vector :as v]
[clojure2d.color :as c]
[clojure2d.pixels :as p])
(:import [fastmath.vector Vec2]))
@adicirstei
adicirstei / dejong.clj
Created February 7, 2019 14:56
Peter de Jong attractor
(ns attractors.dejong
(:require [clojure2d.core :refer :all]
[clojure2d.pixels :as p]
[clojure2d.color :as c]
[fastmath.core :as m]
[fastmath.vector :as v]
[fastmath.random :as r]))
;(set! *warn-on-reflection* true)
@adicirstei
adicirstei / Main.hs
Last active July 5, 2018 11:25
Gloss with JuicyPixels trying to make a match
module Main where
import Codec.Picture
import Control.Monad.ST
import Control.Monad.Primitive
import qualified Codec.Picture.Types as M
import Graphics.Gloss
import Graphics.Gloss.Data.ViewPort(ViewPort)
import Graphics.Gloss.Juicy (fromImageRGBA8)
@adicirstei
adicirstei / Exception.elm
Created November 29, 2016 15:32
Elm run-time exceptions
import Html exposing (beginnerProgram, div, span, button, text)
import Html.Events exposing (onClick)
type Msg
= Increment Int
| Decrement Int
type alias Model =
{ action : Int -> Msg
@adicirstei
adicirstei / design.fsx
Created October 13, 2016 09:36
How do I design this?
/// My function types
type Backward<'Core> = 'Core -> 'Core
type InputCore = {
backward : Backward<InputCore>
x : float
}
type TanhCore = {
backward : Backward<TanhCore>
@adicirstei
adicirstei / BTrees.elm
Last active July 20, 2016 12:12
Ninety-nine Elm Problems
type Tree a =
Empty
| Node a (Tree a) (Tree a)
mirror : Tree a -> Tree a
mirror t =
case t of
Empty -> Empty
Node v l r -> Node v (mirror r) (mirror l)
@adicirstei
adicirstei / Rx-WinForm.fsx
Created February 29, 2016 14:46
Rx-flavor reactive WinForm
#I "packages/Rx-Linq/lib/net45"
#I "packages/Rx-Interfaces/lib/net45"
#I "packages/Rx-Core/lib/net45"
#I "packages/FSharp.Control.Reactive/lib/net40"
#r "FSharp.Control.Reactive.dll"
#r "System.Reactive.Core.dll"
#r "System.Reactive.Interfaces.dll"
#r "System.Reactive.Linq.dll"
@adicirstei
adicirstei / WinForm.fsx
Last active April 4, 2022 17:17
Fully reactive UI in F# with observables
open System
open System.Windows.Forms
open System.Drawing
type Action =
| Increment
| Decrement
let form = new Form(Width= 400, Height = 300, Visible = true, Text = "Hello World")