Skip to content

Instantly share code, notes, and snippets.

View SimonDanisch's full-sized avatar
🏠
Working from home

Simon SimonDanisch

🏠
Working from home
View GitHub Profile
creation isbits type immutable type mutable type array gpu array (device) local memory
pass to device yes, copy no ptrs, copy copy no by reference no
on device yes may contain device ptr no no no yes
using GLVisualize, GeometryTypes, Colors
using GLAbstraction
using Reactive
window = glscreen()
timesignal = bounce(linspace(0f0,1f0,360))
description = """
Animated 2D particles in 3D space with glow.
"""
# Modular pass manager:
context = ExecutionContext()
# adds a predefined function from Sugar as a pass.
# this one takes care of e.g.:
# * turning Expr(:invoke, args...) into Expr(:call, args...)
# * removes apply_type
# * turn all functions into GlobalRef
# * etc
using Gtk, GLWindow, GLAbstraction, Reactive, GeometryTypes, Colors, GLVisualize
using GtkReactive
using Gtk.GConstants, ModernGL
mutable struct GtkContext <: GLWindow.AbstractContext
window::Gtk.GLArea
framebuffer::GLWindow.GLFramebuffer
end
function make_context_current(screen::Screen)
function getop(op)
op == :inc && return +
op == :dec && return -
eval(Base, op)
end
function eval_instr(instr, vars)
lhs, op, rhs = split(instr, " ")
slhs = Symbol(lhs)
val1 = get!(vars, slhs, 0)
val2 = parse(Int, rhs)
using GeometryTypes, Makie
include("noise.jl") #https://gist.github.com/SimonDanisch/89779b923d77a4ecdf61246cbe24611b#file-noise4-jl
# inspired by https://github.com/rougier/alien-life
resolution = (1000, 1000)
scene = Scene(resolution = resolution)
n = 60_000
#=
# Perlin noise ported from: https://github.com/caseman/noise
# with the license:
Copyright (c) 2008 Casey Duncan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
function find_jl_files(dir, files = String[])
for file in readdir(dir)
path = joinpath(dir, file)
if endswith(path, ".jl")
push!(files, path)
elseif isdir(path)
find_jl_files(path, files)
end
end
files
#https://github.com/hughsk/moire-1/b
using GeometryTypes
using MakiE, Colors
struct Ring
movement::Float32
radius::Float32
speed::Float32
spin::Vec2f0
using CLArrays
Wx = CLArray(rand(100))
y = CLArray(rand(100))
b = CLArray(rand(100))
σ(x) = 1 / (1 + exp(-x))
# this will get fused to a single kernel call:
y .= σ.(Wx .+ b)