Skip to content

Instantly share code, notes, and snippets.

View greggirwin's full-sized avatar

Gregg Irwin greggirwin

  • Redlake Technologies
View GitHub Profile
divisible?: func [a b] [0 = remainder a b]
; This doesn't work like R3 in how negative widths work.
forskip: func [
"Evaluates a block at regular intervals in a series."
'word [word!] "Word referring to the series to traverse (modified)"
width [integer!] "Interval size (width of each skip)"
body [block!] "Body to evaluate at each position"
/local orig result op
][
@greggirwin
greggirwin / split.red
Last active June 2, 2016 03:55
An updated `split` function for Red
map-each: function [
"Evaluates body for each value(s) in a series, returning all results."
'word [word! block!] "Word, or words, to set on each iteration"
data [series! map!]
body [block!]
] [
collect [
foreach :word data [
if not unset? set/any 'tmp do body [keep/only :tmp]
]
@greggirwin
greggirwin / bubbles.red
Last active June 17, 2016 23:23
Animated bubbles
Red [
Title: "Bubbles"
Author: [REBOL version "Gabriele Santilli" Red port "Gregg Irwin"]
File: %bubbles.red
Tabs: 4
Needs: View
]
system/view/auto-sync?: no
@greggirwin
greggirwin / analog-clock-2.red
Last active June 17, 2016 23:24
Analog clock, refined, with informational comments
Red [
Title: "Red O'clock"
Author: "Gregg Irwin"
File: %analog-clock.red
Tabs: 4
Needs: View
Purpose: {
- Introduce some basic Red concepts, like functions and datatypes
- Show how the DRAW block and timer events work in the View system
}
@greggirwin
greggirwin / calculator.red
Created June 19, 2016 00:04
Red Calculator
Red [
Title: "Calculator"
File: %calculator.r
Version: 0.0.1
;Date: 18-Jun-2016
Author: [
REBOL version ["Jeff Kreis" "Allen Kamp" "Carl Sassenrath"]
Red port "Gregg Irwin"
]
Purpose: "Simple numeric calculator."
@greggirwin
greggirwin / resize-image-2.red
Last active June 19, 2016 22:59
Red enhanced and annotated image resizing demo
Red [
Title: "Draw Image Resizing Test"
Author: [REBOL version "Carl Sassenrath" Red port "Gregg Irwin"]
Version: 0.0.1
Needs: View
]
;ii Red is very flexible, allowing you to structure your code in
;ii many different ways. While it's almost never a good idea to
;ii write "clever" code, it can be very powerful to write code
@greggirwin
greggirwin / resize-image-3.red
Created June 20, 2016 14:08
Red interactive image resize demo, now with draggable image
Red [
Title: "Draw Image Resizing Test"
Author: [REBOL version "Carl Sassenrath" Red port "Gregg Irwin"]
Version: 0.0.1
Needs: View
]
;ii Red is very flexible, allowing you to structure your code in
;ii many different ways. While it's almost never a good idea to
;ii write "clever" code, it can be very powerful to write code
@greggirwin
greggirwin / bubbles-fast.red
Last active June 20, 2016 23:37
Fast bubbles in Red (move mouse over to make it go faster)
Red [
Title: "Bubbles"
Author: [REBOL version "Gabriele Santilli" Red port "Gregg Irwin"]
File: %bubbles.red
Tabs: 4
Needs: View
]
system/view/auto-sync?: no
@greggirwin
greggirwin / bubbles-2.red
Created June 21, 2016 06:15
Bubbles with code meant more for reading than minimum size
Red [
Title: "Bubbles 2: The Sequel"
Author: [REBOL version "Gabriele Santilli" Red port "Gregg Irwin"]
File: %bubbles-2.red
Tabs: 4
Needs: View
]
system/view/auto-sync?: no ; We'll call SHOW when we want to update the UI
@greggirwin
greggirwin / sign.reds
Created June 22, 2016 16:04
Red/System SIGN? function
sign?*: func [
check? [logic!]
return: [red-integer!]
/local
i [red-integer!]
f [red-float!]
res [red-logic!]
ret [integer!]
][
#typecheck -sign?- ;-- `sign?` would be replaced by lexer