Skip to content

Instantly share code, notes, and snippets.

@toomasv
toomasv / zooming.red
Last active September 5, 2019 16:32
Zooming function
Red [
Date: 4-Sep-2019
Description: {Mouse sensitive zooming function}
Author: "Toomas Vooglaid"
Licence: "Public domain"
]
zooming: function [face event][
;face's draw-block needs to have matrix defined
mx: face/draw/matrix
@toomasv
toomasv / fly.red
Last active August 28, 2019 08:53
Spider and fly
Red [
Date: 28-July-2019
Notes: {Click on window to add flies}
]
bb: [] fc: target: none
web: load %web.png
set-step: func [face][as-pair
face/extra/speed * (cosine face/extra/dir)
face/extra/speed * (sine face/extra/dir)
]
Rebol [
Title: "Build"
Author: ["Ladislav Mecir" "Brian Hawley"]
File: %build.r
Date: 2-May-2006/13:36:38+2:00
History: [
7/apr/2003/19:02 {using INSERT and ONLY keywords}
30/Oct/2004/12:55 {intermediate version - alpha}
31/Oct/2004/9:49 {intermediate - word - insert/only, :word - insert}
4/Nov/2004/6:55 {word - insert and evaluate, :word - insert/only}
@greggirwin
greggirwin / inject.red
Last active May 14, 2020 10:59
INJECT func experiment. Alternative to REDUCE or COMPOSE.
Red [
name: 'inject
file: %inject.red
author: "Gregg Irwin"
notes: {
Red version of Ladislav Mecir's R2 `build` func. I can't find his on
the net, to link to, but can post his original if desired. His point
was that `compose` isn't always easy to use, when parens are part of
block you're composing, or how your blocks are structured, whether you
can use `/only` with `compose`. e.g.
@yvern
yvern / fun.red
Last active September 30, 2018 06:20
Functional constructs experiments in Red
->: make op! :function ; arrow-style lambdas: [x]->[x + 1]
id: ["Identity function, one in, same out" x]->[x]
;--------------------------------------------------------------------------------------
cmp: ["Gets a block! of words! or blcoks! that represent a function! and composes it in the usual way"
fs [any-block!]]->[ [x]-> compose/deep/only [take reduce append (reduce fs) [x] ]
]
@giesse
giesse / profile-gab.red
Last active November 20, 2021 19:13
profile function for Red (two variants)
Red []
e.g.: :comment
; ideally not exported on the global context
delta-time*: function [code count] [
start: now/precise
loop count code
difference now/precise start
]
@toomasv
toomasv / date-picker.red
Last active May 17, 2019 09:59
To pick a date...
Red [
Started: 2018-05-16
Date: 2019-01-25
Needs: View
;%range.red ;https://gist.github.com/toomasv/0e3244375afbedce89b3719c8be7eac0
;TinyURL https://tinyurl.com/y7bt2nqy
File: %date-picker.red
]
context [
y: d: none
@toomasv
toomasv / rtbox.red
Last active September 19, 2021 09:16
Red [
Author: "Toomas Vooglaid"
Started: 2018-05-01
Purpose: "First steps into rich-text box"
]
ctx: context [
env: self
start: end: 1
diff: 0
dbl: no
@toomasv
toomasv / graph.red
Last active July 11, 2018 02:22
Toy graph DSL
Red [
Author: "Toomas Vooglaid"
Date: 2017-12-31
History: [
2017-12-28 {First draft}
2018-01-20 {Added arrows, subtree moving, elementary interactive editing}
2018-01-24 {Edges formatting}
2018-02-01 {Added differnt edge-ends, layout orientations, improved options-handling}
2018-02-03 {Implemented stepped (orthogonal) edges, improved star layout}
2018-02-06 {Added directions `across` (default: perpendicular to the step-away direction) and `away` (in the step-away direction).
@toomasv
toomasv / range.red
Last active June 19, 2021 14:41
Range function for multiple datatypes
Red [
Author: "Toomas Vooglaid"
Date: 26-11-2017
]
range: function [val1 val2 /step stp /limit /enbase ebase /debase dbase /unicode][
stp+?: none
stp: any [stp either any [percent? val1 percent? val2] [1%][1]]
if any [all [block? stp zero? stp/3] zero? stp] [return none]
case [
debase [