Skip to content

Instantly share code, notes, and snippets.

View greggirwin's full-sized avatar

Gregg Irwin greggirwin

  • Redlake Technologies
View GitHub Profile
@greggirwin
greggirwin / requesters.red
Last active February 6, 2020 21:41
Red requesters (alert, confirm, prompt, etc.)
Red [
author: ["Gregg Irwin"]
notes: {
Experimental requesters, for design discussion. Not just about the
implementation, but about modal vs modeless dialogs. I think there's
value in the simple, modal approach, but we probably want to provide
more advanced options. e.g. document/sheet modal, and mobile standard
approaches.
TBD: Determine if we want to build everything on inner funcs that are
@greggirwin
greggirwin / chess.red
Last active December 8, 2017 03:14
Edward DeJong's Chess Challenge in Red
Red [
title: "Edward de Jong's Chess Challenge"
author: ["Gregg Irwin"]
]
; This may prove useful as more logic is added. Right now it's not a big win.
array: function [
"Makes and initializes a block of of values (NONE by default)"
size [integer! block!] "Size or block of sizes for each dimension"
/initial "Specify an initial value for elements"
@greggirwin
greggirwin / dyn-tab-panel.red
Created December 11, 2017 21:39
Red dynamic tab panels
Red [needs: view]
detail-tab: first layout/only [panel [text "hello"]]
toggle-detail: function [state [logic!]][
either state [
insert at tabs/data 2 "Detail"
insert at tabs/pane 2 detail-tab
][
remove at tabs/data 2
@greggirwin
greggirwin / map-slider-to-range.red
Last active December 12, 2017 22:00
Map slider values to other ranges in Red
Red []
linear-interpolate: func [
src-min [number!]
src-max [number!]
dest-min [number!]
dest-max [number!]
value [number!]
][
add dest-min ((value - src-min) / (src-max - src-min) * (dest-max - dest-min))
@greggirwin
greggirwin / toomasv-color-picker.red
Created January 11, 2018 18:15
Mod of @toomasv's color picker
; The original is at https://gist.github.com/toomasv/19e45ce2cbd7dc213548400fcdec1f8b
context [
colors: exclude sort extract load help-string tuple! 2 [glass]
lay: copy [
style color: base 70x70 font [size: 8] wrap top on-down [
write-clipboard form face/extra
tx/data: rejoin [
"Color '" face/extra "' (" get face/extra ") copied to clipboard!"
]
@greggirwin
greggirwin / sets.red
Created January 12, 2018 23:16
Red set operation mezzanines (unique, intersect, etc.)
Red [
Title: "Red set-related functions"
Author: "Gregg Irwin"
File: %sets.red
Tabs: 4
Rights: "Copyright (C) 2013 All Mankind. All rights reserved."
License: {
Distributed under the Boost Software License, Version 1.0.
See https://github.com/dockimbel/Red/blob/master/BSL-License.txt
}
@greggirwin
greggirwin / include-example.red
Last active February 3, 2018 19:31
Red #include example
Red []
#include %include-me.red
print incl-int
print mold incl-str
img: load/as incl-img 'png
view [image img]
@greggirwin
greggirwin / typed-multiple-dispatch.red
Created February 18, 2018 19:25
Typed multiple dispatch in Red, per CLOS and PMD chat.
Red []
collect-values: func [
"Collect values in a block, by datatype or custom parse rule"
block [block!]
rule "Datatype, prototype value, or parse rule"
/deep "Include nested blocks"
][
rule: switch/default type?/word rule [
datatype! block! typeset! [rule] ; Blocks and typesets (e.g. any-word!) work directly as rules.
@greggirwin
greggirwin / draw-red-logo.red
Created February 22, 2018 23:20
Draw commands for Red logos.
Red []
view [
base 200x336 white draw [
pen #eeac29
fill-pen #eeac29 polygon 100x2 100x65 72x49
fill-pen #bc822d polygon 100x2 100x65 128x49
pen #d41c18
fill-pen #d41c18 polygon 100x84 100x146 37x109 64x63
@greggirwin
greggirwin / gui-droppper.red
Created March 9, 2018 07:23
Show how to drop loose faces and generate a layout from them.
Red [
Purpose: "Show how to drop faces to make a GUI and save it."
]
spec: copy []
btn-pos: 700x10
n: 0