Skip to content

Instantly share code, notes, and snippets.

@hinjolicious
hinjolicious / increment.red
Created June 17, 2026 13:49
Increment/decrement ++ / -- Incr Decr set-val
Red []
; pass by reference
incr: func ['x][set x (get x) + 1]
decr: func ['x][set x (get x) - 1]
increment: :incr
decrement: :decr
++: :incr
--: :decr
set-val: function ['var val][set var :val]
@hinjolicious
hinjolicious / for-loop.red
Last active June 20, 2026 16:36
Custom structure to allow a c-style for-loop in Red
Red [
; custom structure to allow a c-style for-loop in Red
]
; do-for loop:
; usage:
; do for [cond][while][step][
; body
; ]
@hinjolicious
hinjolicious / colors.red
Created June 17, 2026 13:54
Color conversion utility based on Processing
Red []
; Color conversion utility based on Processing
; Collaborator: Gemini AI
hsb-to-rgb: func [
"Converts p5.js HSB values (H: 0-360, S: 0-100, B: 0-100) to a Red tuple!"
h [number!] ; hue 0-360
s [number!] ; saturation 0-255
b [number!] ; brightness 0-255
/local c x m r g b-val
@hinjolicious
hinjolicious / pipe-map.red
Last active June 21, 2026 03:20
Pipelining - Mapping Library for Red
Red [
title: "Piping (Pipelining) and Mapping for Red"
author: "hinjolicious"
resource: "Gemini AI"
]
#include %dev.red
; == PIPE / PIPELINING
@hinjolicious
hinjolicious / filter.red
Created June 20, 2026 16:21
FILTER - Filter a list based on a condition
Red [
title: "FILTER - Filter a list based on a condition"
author: "hinjolicious"
usage: {
a: [1 2 3 4 5 6 7 8 9 10]
print mold filter a [[x] x % 2 = 0]
a: [[1 2] [3 6] [5 6] [7 14] [9 10]]
print mold filter a [[x y] (x * 2) = y]
print mold a || [[x y] (x * 2) = y]
@hinjolicious
hinjolicious / mandelbrot-interactive.red
Last active June 26, 2026 19:03
Interactive Mandelbrot Set (Red/System)
Red [
Title: "Mandelbrot (Optimized)"
Author: "hinjolicious"
Note: {
* Adapted from Red's showcase code.
* Added interactivity: zoom/un-zoom, changing colors, smooth colors, etc.
* Assistance from Gemini AI
}
Needs: 'View
Tabs: 4
@hinjolicious
hinjolicious / nfunc.red
Last active August 7, 2026 05:03
Named-Arguments Functions Factory with Refinements Support
; + this support both positional and named args + refinements
; + type validation working properly accodring to the function definition
; + better error information
; note: a collab with Red/Sensei
nfunc: func [spc bdy /local groups pos-names][
groups: collect [
current: copy []
stop: false
parse spc [
@hinjolicious
hinjolicious / plasma-test.red
Last active August 15, 2026 07:24
Red's Draw vs Direct Pixel Performance
Red [
Title: "Red's Draw vs Direct Pixel Performance"
Needs: 'View
]
system/view/auto-sync?: off ; <-- TO MAKE PIXEL MANIPULATION ON IMAGE FASTER!!!
w: 80
h: 80
blk: copy []
@hinjolicious
hinjolicious / tooltip.red
Created August 16, 2026 02:59
A simple tooltip for buttons, field, etc.
Red [ title: "A simple tooltip for buttons, field, etc." ]
__tooltip: context [
get-absolute-offset: function [face][
offset-adjust: [ 6x6 8x31 6x26 8x51 ]
adjust-index: 1
adjustment: 0
results: face/offset
target: face/parent
until [