Skip to content

Instantly share code, notes, and snippets.

Toomas Vooglaid toomasv

Block or report user

Report or block toomasv

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View mget.red
Red [
Description: {Attempt to implement @GiuseppeChillemi's "path dialect"}
Date: 22-Jun-2019
Author: "Toomas Vooglaid"
]
system/lexer/pre-load: func [src][
chr: complement charset {/[ "#}
path: [some chr #"/" some chr]
mpath: [path change #"[" "/(" to #"]" change skip #")" any [#"/" mpath]]
@toomasv
toomasv / chess.red
Last active Jun 20, 2019
Play chess against yourself
View chess.red
Red [
Title: "Chess"
Author: "Toomas Vooglaid"
Date: 20-Jun-2019
]
glass: 0.0.0.216
chessboard: [origin 0x0 space 0x0]
repeat i 8 [loop 4 [append chessboard pick [[b w][w b]] even? i]]
@toomasv
toomasv / taiji.red
Created Jun 4, 2019
Yin yang flowing
View taiji.red
Red []
spiral: function [
start step /out /sweep /stop val
][
shape: copy []
stop: any [val 0]
i: 1
until [
repend shape [
quote 'arc
@toomasv
toomasv / each.red
Created May 18, 2019
Applies func(s) to elements of series
View each.red
Red [
Description: {Applies function or sequence of functions
to block or collected output of previous functions}
Date: 18-May-2019
Author: "Toomas Vooglaid"
]
each*: make op! function [fn [any-function! block!] block [series!]][
{Applies a function to as many elements of the block as it has arguments
or a sequence of functions to the block or collected output of the previous function.
Returns block with the collected result of last function}
@toomasv
toomasv / color-picker2.red
Last active May 9, 2019
Yet another color-picker
View color-picker2.red
Red [
Description: "Yet another color-picker"
Date: 9-May-2019
]
context [
colors: []
colors2: [pen off translate 260x280 []]
i: 9
j: 256 / (i - 1)
img: none
@toomasv
toomasv / color-picker.red
Last active May 8, 2019
Another color-picker
View color-picker.red
Red [
Description: "Another color-picker"
Date: 8-May-2019
]
context [
colors: []
i: 9
j: 256 / (i - 1)
collect/into [
repeat r i [repeat g i [repeat b i [
@toomasv
toomasv / of.red
Last active Apr 27, 2019
Funny `of` op!
View of.red
Red [
Date: 26-Apr-2019
Idea: [@nedzadarek @giesse]
Source: https://gitter.im/red/help?at=5cc295d3375bac747008989b
]
of: make op! function ['word 'value] [
either any [
attempt [out: reflect get value word]
attempt [out: reflect value word]
attempt [
@toomasv
toomasv / diagram.red
Created Apr 25, 2019
Toy diagramming tool
View diagram.red
Red [
Author: "Toomas Vooglaid"
Started: 2018-05-17
]
context [
pan: dat: typ: category: cat: cats: sers: num: y-unit: x-unit: x-unit2: x-scale: y-scale: n: sum: swapped: transp: none
series: make block! 30
categories: make block! 30
numbers: make block! 150
dia-type: "bar"
@toomasv
toomasv / pie.red
Created Apr 25, 2019
Baking a pie
View pie.red
Red [Needs: 'View]
system/view/auto-sync?: no
ctx: context copy/deep [
;ctx: self
sum: func [block /local out][
out: 0 forall block [out: out + either percent? block/1 [block/1 * 100][block/1]]
]
face-index: func [face][index? find face/parent/pane face]
@toomasv
toomasv / sectors.red
Created Apr 25, 2019
Playing with versions of pie sectors
View sectors.red
Red [Needs: 'View]
selection: 6
switch selection [
1 [
actor: [face/draw/9: either event/away? [100x100][120x120]]
view/no-wait/tight compose/only [
style sector: box 400x400 draw [
fill-pen 61.160.255 pen white line-width 2
arc 200x200 100x100 -90 110 closed
]
You can’t perform that action at this time.