Instantly share code, notes, and snippets.

Toomas Vooglaid toomasv

View GitHub Profile
View drop-to-list.red
Red [
Author: "Toomas Vooglaid"
Date: 13-Feb-2019
Purpose: {Example of dragging words from area to text-list}
]
count-nl: func [face /local text n x][
n: 0 x: face/selected/x
text: copy face/text
while [all [
text: find/tail text #"^/"
View syntax.rtd
Red [
Author: "Toomas Vooglaid"
Date: 2019-01-14
Purpose: {Study of syntax highlighting}
]
skp: charset " ^/^-[]()/"
initial-size: 800x800
addr: func [s1 s2 style] bind [keep as-pair i: index? s1 (index? s2) - i keep style] :collect
rule: [any [s:
skp
View lcs.red
Red [
Purpose: "Longest Common Subsequence"
Partially-based-on: http://rosettacode.org/wiki/Longest_common_subsequence
Date: 8-Jan-2019
Last: 10-Jan-2019
]
lcs: function [s t][
case [ ; preliminary checks
s = t [return copy s]
any [empty? s empty? t] [return copy ""]
View levenshtein.red
Red [
Date: 6-Jan-2019
File: %levenshtein.red
]
lev: function [s t][
unless string? s [s: mold s]
unless string? t [t: mold t]
case [
s = t [return 0]
empty? s [return (length? t)]
View check.red
Red []
ctx: context [
char: charset {([{}])"} ;"
opens: charset "[("
closes: charset "])"
line: 1
stack: make block! 1000
mark: comm: none
instr: false
inmulti: 0
View thru.red
Red [
Author: "Toomas Vooglaid"
Date: 2018-12-11
Improvements: @9214
]
thru: make op! func [a b /local inc op cmp][
inc: pick [1% 1] percent? a
set [op cmp] reduce pick [[:+ :<][:- :>]] a < b
collect [until [keep a b cmp a: a op inc]]
]
View freehand-on-area.red
Red [
Author: "Toomas Vooglaid"
Date: 2018-12-09
Purpose: {Study of freehand drawing on area}
]
do load-thru https://tinyurl.com/ybmvx58e ; make-transparent
img: draw 200x200 [box 0x0 199x199]
img: make-transparent img 255
style: 'thin
view [
View explosions.red
Red [
Title: "Explosions in Red"
Date: 14-Nov-2018
Author: "Bohdan Lechnowsky"
Origin: http://respectech.com/red/explosions.red
Adaptation: "Toomas Vooglaid"
Notes: {
Derived from "Explosions in Python" from p.33 of "Wireframe" magazine (wfmag.cc) Issue 1.
Unlike the above program that requires Python to be installed, plus "Pygame Zero" (whatever
View math2.red
Red [
Author: "Toomas Vooglaid"
Date: 12-Nov-2018
Purpose: {Alternative math func with left-associative power op!s}
]
*r: make op! func [a b][a ** (1.0 / b)]
math2: function [
{Math with more-or-less correct operations ordering,
left-associative power-ops included}
View stick.red
Red [
Author: {Toomas Vooglaid}
Date: 2018-11-07
Purpose: {Study of stick}
]
pos: joint: bone: len: none
sel: "Move:"
mode: "Mode-1"
movs: make block! 20