Skip to content

Instantly share code, notes, and snippets.

View dockimbel's full-sized avatar

Nenad Rakocevic dockimbel

View GitHub Profile
@greggirwin
greggirwin / analog-clock.red
Last active September 28, 2016 03:52
An analog clock for Red
Red [
Title: "Red O'clock"
Author: "Gregg Irwin"
]
degree-to-xy: func [rad "radius" deg "degrees"] [
as-pair (rad * sine deg) (rad * negate cosine deg)
]
sex-to-degree: func ["Sexagesimal to degrees" n] [n * 6]
Red [needs: view]
turtle: #()
win: layout [ panel [
tfield: base 500x500 white draw []
origin tfield/offset tlayer: base 500x500 255.255.255.255 draw [] ]
panel [
text "History" return history: text-list 200x350 data [] return
panel [ button "Save" [save request-file history/data]
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
][
Red [needs: view]
turtle: #()
win: layout [ tfield: base 500x500 white draw []
panel [
text "History" return history: text-list 180x350 data [] return
panel [ button "Save" [save request-file history/data]
button "Load" [commands: load request-file foreach cmd commands [process-cmd cmd]] ]
]
ralette-grammar: [
collect any [
['decompose [
'rgb keep ([
r: (color/1) / 255.0
g: (color/2) / 255.0
b: (color/3) / 255.0
]) |
'hsl keep ([
h: (color/1) / 255.0
Red [
Title: "Red GUI tour"
Purpose: {To showcase the current capabilities of Red GUI}
Author: "Rudolf W. MEIJER"
Version: 0.9.0
Date: "12-Dec-2015"
Needs: 'view
Rights: "Copyright (c) 2015 Rudolf W. MEIJER"
]
Red [
Title: "Sintezar PM-102 - Phase Manipulation Digital Sintesizer"
Name: 'PM-102
Version: 0.4.0
Needs: 'View
; Date: 25-11-2015
File: %pm-102.red
Author: "Boleslav Březovský"
; Email: [email protected]
]
Red []
random/seed 1337
; produces a series of chromosomes within [0, dna] of each supplied maximum
make-dna-strand: func[dna
/local dna-length result][
dna-length: length? dna
result: make block! dna-length
foreach chromosome dna [
Red [
Title: "Tile game"
Purpose: {An implementation in Red of the 4x4 sliding tile puzzle}
Author: "Rudolf W. MEIJER (meijeru)"
File: %tile-game.red
Needs: 'View
Usage: {
Click on any tile that is adjacent to the empty space
and it will shift to that space.
Try to obtain a given configuration, e.g. 1 to 15 in order.
Red []
forth: context [
prog: [1 2 3 4 5 6 7 8 '+ '+ '* 150 '+ '* '+ '* '*]
registers: ['eax 'ebx 'ecx 'edx]
register-taint: [] ; registers we've touched in this set
register-goop: [] ; registers we need to pop to use
register-sets: 0
next-register: head registers