Skip to content

Instantly share code, notes, and snippets.

View greggirwin's full-sized avatar

Gregg Irwin greggirwin

  • Redlake Technologies
View GitHub Profile
@toomasv
toomasv / shooting.red
Last active August 14, 2019 19:58
Parametrized curve
Red [
Title: "Shooting"
Description: "Exercise with parametrized curve"
Date: 2019-08-10
Author: "Toomas Vooglaid"
Licence: "Public domain"
Usage: {
To load and orient the weapon - drag point.
To relocate the target - drag target.
To relocate weapon - ctrl-drag it (cannon relocates horizontally on dragging).
@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)
]
@toomasv
toomasv / rays.red
Last active August 2, 2019 19:22
Ray-casting exercise
Red [
Description: {Ray casting exercise}
Needs: View
Date: 25-July-2019
Inspiration: https://github.com/krisajenkins/elm-rays
Tutorial: https://ncase.me/sight-and-light/
Redporter: "Toomas Vooglaid"
Licence: "Public domain"
]
; To change into plain light instead of radial
Red [
Title: {Request a date}
Purpose: {To enter a date using a calendar display}
Author: "Rudolf W. MEIJER"
File: %request-date.red
Notes: {Inspired by the corresponding Rebgui facility}
Language: 'English
Tabs: 4
] ; end prologue
@toomasv
toomasv / color-picker2.red
Last active May 9, 2019 18:28
Yet another color-picker
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
@dander
dander / find-pattern.red
Last active December 14, 2019 08:46
Searches Red source files for a parse pattern
Red [
Title: "Find pattern"
Description: "Searches Red source files for a parse pattern"
]
allow: func [any][yes]
get-files: function [
"recursively collects the full file paths for all the files in the given directory"
dir [file!] /filter "only collect files where the predicate evaluates to true" pred [function!]
Red[]
dist-to-color: func [dist][
to tuple! reduce [dist * 256 dist * 256 dist * 256]
]
distance: func [start end /local diff][
diff: end - start
absolute square-root diff/x * diff/x + (diff/y * diff/y)
]
@toomasv
toomasv / layout-demo.red
Created March 20, 2019 14:01
Layout adjustment demo
Red []
context [
env: self
canvas: none
tab-pan: drawing-panel-tab: animations: none
info-panel: edit-options-panel: options-panel: drawing-panel: figs-panel: anim-panel: none
layer: layer1: drawing: selection-layer: grid-layer: drawing-layer: edit-layer: none
win: layout/options compose/deep [;
title "Drawing pad"
size 540x465
@burque505
burque505 / ahk-com4.red
Last active March 16, 2019 18:37
Automate Word with AutoHotkey module and red-lang
; You will need AutoHotkey.dll for this to work.
; It can be downloaded from https://github.com/HotKeyIt/ahkdll (source)
; or http://hotkeyit.github.io/v2/ for binaries (v1 on same page)
; Only tested with v1 - you will of course need MS Word on your machine.
; Use 32-bit AutoHotkey dll only!
; If red can't find it in your script directory, please put
; the dll in SysWOW64. (By all means try including it in your script
; directory first, if you like.)
@toomasv
toomasv / play.red
Last active March 6, 2019 20:27
Play beeps
Red [
Needs: View
Author: "Gregg Irwin"
Porter: "Toomas Vooglaid"
Source: https://gitter.im/red/red/gui-branch?at=5c7f0f2e86e34a126f92a7be
Port-date: 6-Mar-2019
]
#system [
#import [
"kernel32.dll" stdcall [