Skip to content

Instantly share code, notes, and snippets.

View dockimbel's full-sized avatar

Nenad Rakocevic dockimbel

View GitHub Profile
turtle: #()
win: layout [ panel [
tfield: base 500x500 white draw []
origin tfield/offset tlayer: base 500x500 255.255.255.255 draw [] ]
panel [
text "History" return history: text-list 200x350 data [] return
panel [ button "Save" [save request-file history/data]
button "Load" [commands: load request-file foreach cmd commands [process-cmd cmd]] ]
return status: text "" 200x25 ]
@dockimbel
dockimbel / dyn-board.red
Last active July 8, 2017 15:52
Dynamic View usage example: drawing a board of buttons
Red [
Title: "Dynamic View usage example"
Author: "Nenad Rakocevic"
Date: 08/07/2017
]
generate: function [board [pair!] sz [pair!] return: [block!]][
pane: make block! sz/x * sz/y
pos: 1x1
count: 1
@dockimbel
dockimbel / arity-of.red
Created April 24, 2017 02:51 — forked from greggirwin/arity-of.red
Red arity-of function
; We have other reflective functions (words-of, body-of, etc.), but
; this is a little higher level, sounded fun to do, and may prove
; useful as we write more Red tools. It also shows how to make your
; own typesets and use them when parsing.
arity-of: function [
"Returns the fixed-part arity of a function spec"
spec [any-function! block!]
/with refs [refinement! block!] "Count one or more refinements, and add their arity"
][
@dockimbel
dockimbel / load-any.red
Created March 22, 2017 07:31
Experimental generic loader for non-Red input text.
Red []
load-any: function [input [string!]][
out: make block! 100
junk: none
until [
result: load/trap/next input 'pos
either error? result/3 [
append any [junk junk: make string! 20] result/2/1
Red [
Author: "ifgem"
]
#do [
macro: context [
make-object-spec: function [words] [
spec: copy []
@dockimbel
dockimbel / heart-animation.red
Created January 10, 2017 05:16 — forked from DideC/heart-animation.red
Heart animation for Red (only). Now with a complete control panel to play with the animations parameters. Nice time eater ;-)
Red [
title: "Heart animation"
author: "Didier Cadieu"
notes: {
Traduction in Red/Rebol of Terebus Volodymyr javascript demo : http://codepen.io/tvolodimir/pen/wqKuJ
}
Needs: View
]
;*** Settings
@dockimbel
dockimbel / haiku.red
Created December 29, 2016 14:32 — forked from maximvl/haiku.red
Red [
description: {
Attempt to copy Haiku Editor
(http://forthsalon.appspot.com/haiku-editor)
}
]
map: func [s 'word body] [
bind body 'word
forall s [
@dockimbel
dockimbel / bmr-calc.red
Created October 30, 2016 04:48 — forked from greggirwin/bmr-calc.red
Reactive BMR calculator in Red
Red [
Title: "BMR (Basal Metabolic Rate) Calculator"
Author: "Gregg Irwin"
File: %bmr-calc.red
Needs: View
Comment: {
An experiment in reactivity and data modeling.
145 lines with blanks and comments removed.
Red []
#system [
#import [
"shell32.dll" stdcall [
ShellExecute: "ShellExecuteW" [
hwnd [integer!]
lpOperation [c-string!]
lpFile [c-string!]
lpParameters [integer!]
Red[
Title: "Raytracer"
Needs: 'View
Notes: "Simple raytracer based on 'Ray Tracing in One Weekend' by Peter Shirley"
]
vec3_dot: function [a[vector!] b[vector!]] [
reduce (a/1 * b/1) + (a/2 * b/2) + (a/3 * b/3)
]