HSV>RGB color conversion, much other stuff
parent
96293991ec
commit
96a5afc718
43
README.txt
43
README.txt
|
@ -103,9 +103,6 @@ a list. Note that it uses 'call' to execute the given quotation:
|
|||
: each ( list quotation -- )
|
||||
#! Push each element of a proper list in turn, and apply a
|
||||
#! quotation to each element.
|
||||
#!
|
||||
#! In order to compile, the quotation must consume one more
|
||||
#! value than it produces.
|
||||
over [
|
||||
>r uncons r> tuck >r >r call r> r> each
|
||||
] [
|
||||
|
@ -223,3 +220,43 @@ The 'with-stream' word is implemented by pushing a new namespace on the
|
|||
namestack, setting the 'stdio' variable therein, and execution the given
|
||||
quotation.
|
||||
|
||||
* Continuations
|
||||
|
||||
A continuation is a quotation that restores execution to the point where
|
||||
it was captured. Continuations are captured using the callcc0 and
|
||||
callcc1 words in the 'continuations' vocabulary.
|
||||
|
||||
The word names are abbreviations for 'call with current continuation';
|
||||
the 0 or 1 refers to the arity of the continuation.
|
||||
|
||||
Consider the phrase 'call with current continuation':
|
||||
|
||||
- 'call' -- it calls a quotation given as a parameter...
|
||||
- 'with' -- with a value on the stack....
|
||||
- 'current continuation' -- that is a quotation that can be called
|
||||
to restore execution at the current point.
|
||||
|
||||
A continuation can either have arity 0 or 1. This refers to the number
|
||||
of parameters the quotation transfers from the caller stack to the
|
||||
restored point.
|
||||
|
||||
Three very simple examples:
|
||||
|
||||
[ call ] callcc0 "Hello world." print
|
||||
^
|
||||
------- captured continuation restores here.
|
||||
==> Hello world.
|
||||
|
||||
[ "my-c" set ] callcc0 "Hello world." print
|
||||
^
|
||||
-------- captured continuation restores here.
|
||||
==> Hello world.
|
||||
|
||||
"my-c" get call
|
||||
==> Hello world.
|
||||
|
||||
Continuations are an advanced feature and are used in the implementation
|
||||
of error handling, multi-tasking, co-routines, and generators.
|
||||
|
||||
(This is for my editor. It can be removed.
|
||||
:tabSize=4:indentSize=4:noTabs=true:)
|
||||
|
|
|
@ -4,43 +4,23 @@ FFI:
|
|||
- command line parsing cleanup
|
||||
- > 1 ( ) inside word def
|
||||
|
||||
- when* compilation
|
||||
- when* compilation in jvm
|
||||
- compile word twice; no more 'cannot compile' error!
|
||||
- doc comments in assoc, image, inferior
|
||||
- styles - could use some cleanup
|
||||
- list - trim down
|
||||
- move quadratic and simpson to contrib
|
||||
- init-assembler called twice
|
||||
- compiler: drop literal peephole optimization
|
||||
- compiling when*
|
||||
- compiling unless*
|
||||
- getenv/setenv: if literal arg, compile as a load/store
|
||||
- inline words
|
||||
|
||||
[error] SideKick$BufferChangeHandler: We have cplusplus.xml (/home/slava/jEdit/modes/) but got event for DefaultInputHandler.java (/home/slava/jEdit/org/gjt/sp/jedit/gui/)
|
||||
[error] SideKick$BufferChangeHandler: We have cplusplus.xml (/home/slava/jEdit/modes/) but got event for DefaultInputHandler.java (/home/slava/jEdit/org/gjt/sp/jedit/gui/)
|
||||
|
||||
[error] AWT-EventQueue-0: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 98
|
||||
[error] AWT-EventQueue-0: at org.gjt.sp.jedit.Buffer.getLineOfOffset(Buffer.java:882)
|
||||
[error] AWT-EventQueue-0: at errorlist.DefaultErrorSource$DefaultError.getLineNumber(Unknown Source)
|
||||
[error] AWT-EventQueue-0: at errorlist.DefaultErrorSource.getLineErrors(Unknown Source)
|
||||
[error] AWT-EventQueue-0: at errorlist.ErrorOverview.paintComponent(Unknown Source)
|
||||
|
||||
[error] EditBus: Exception while sending message on EditBus:
|
||||
[error] EditBus: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 98
|
||||
[error] EditBus: at org.gjt.sp.jedit.Buffer.getLineOfOffset(Buffer.java:882)
|
||||
[error] EditBus: at errorlist.DefaultErrorSource$DefaultError.getLineNumber(Unknown Source)
|
||||
[error] EditBus: at errorlist.ErrorList$ErrorCellRenderer.getTreeCellRendererComponent(Unknown Source)
|
||||
[error] EditBus: at javax.swing.plaf.basic.BasicTreeUI$NodeDimensionsHandler.getNodeDimensions(BasicTreeUI.java:2751)
|
||||
|
||||
[error] EditBus: Exception while sending message on EditBus:
|
||||
[error] EditBus: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 98
|
||||
[error] EditBus: at org.gjt.sp.jedit.Buffer.getLineOfOffset(Buffer.java:882)
|
||||
[error] EditBus: at errorlist.DefaultErrorSource$DefaultError.getLineNumber(Unknown Source)
|
||||
[error] EditBus: at errorlist.ErrorList$ErrorCellRenderer.getTreeCellRendererComponent(Unknown Source)
|
||||
[error] EditBus: at javax.swing.plaf.basic.BasicTreeUI$NodeDimensionsHandler.getNodeDimensions(BasicTreeUI.java:2751)
|
||||
[error] EditBus: at javax.swing.tree.AbstractLayoutCache.getNodeDimensions(AbstractLayoutCache.java:475)
|
||||
|
||||
- perhaps /i should work with all numbers
|
||||
- profiler is inaccurate: wrong word on cs
|
||||
- buffer change handler in sidekick is screwed
|
||||
|
|
|
@ -148,5 +148,5 @@ USE: unparser
|
|||
"Factor" "realname" set
|
||||
"factorbot" "nick" set
|
||||
"irc.freenode.net" 6667 <client> [
|
||||
[ "#factor" ] irc
|
||||
[ "#concatenative" ] irc
|
||||
] with-stream ;
|
||||
|
|
|
@ -160,6 +160,8 @@ cpu "x86" = [
|
|||
"/library/sdl/sdl.factor"
|
||||
"/library/sdl/sdl-video.factor"
|
||||
"/library/sdl/sdl-event.factor"
|
||||
"/library/sdl/sdl-gfx.factor"
|
||||
"/library/sdl/hsv.factor"
|
||||
] [
|
||||
dup print
|
||||
run-resource
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
! Contains definition of the hsv>rgb word for converting
|
||||
! Hue/Saturation/Value color values to RGB.
|
||||
|
||||
! This thing is GPL, hsv->rgb is a translation to Common Lisp of a
|
||||
! function found in color_sys.py in Python 2.3.0
|
||||
|
||||
! Translated to Factor by Slava Pestov.
|
||||
|
||||
IN: sdl
|
||||
USE: combinators
|
||||
USE: kernel
|
||||
USE: lists
|
||||
USE: math
|
||||
USE: namespaces
|
||||
USE: stack
|
||||
|
||||
: f_ ( h s v i -- f ) >r transp >r 2dup r> 6 * r> - ;
|
||||
: p ( v s x -- v p x ) >r dupd neg succ * r> ;
|
||||
: q ( v s f -- q ) * neg succ * ;
|
||||
: t_ ( v s f -- t_ ) neg succ * neg succ * ;
|
||||
|
||||
: mod-cond ( p list -- )
|
||||
#! Call p mod q'th entry of the list of quotations, where
|
||||
#! q is the length of the list. The value q remains on the
|
||||
#! stack.
|
||||
[ dupd length mod ] keep nth call ;
|
||||
|
||||
: hsv>rgb ( h s v -- r g b )
|
||||
pick 6 * >fixnum [
|
||||
[ f_ t_ p swap ( v p t ) ]
|
||||
[ f_ q p -rot ( q v p ) ]
|
||||
[ f_ t_ p swapd ( p v t ) ]
|
||||
[ f_ q p rot ( p q v ) ]
|
||||
[ f_ t_ p transp ( t p v ) ]
|
||||
[ f_ q p ( v p q ) ]
|
||||
] mod-cond ;
|
|
@ -45,7 +45,7 @@ typedef unsigned short CHAR;
|
|||
typedef unsigned char BYTE;
|
||||
|
||||
/* Memory heap size */
|
||||
#define DEFAULT_ARENA (5 * 1024 * 1024)
|
||||
#define DEFAULT_ARENA (64 * 1024 * 1024)
|
||||
#define COMPILE_ZONE_SIZE (5 * 1024 * 1024)
|
||||
|
||||
#define STACK_SIZE 16384
|
||||
|
|
Loading…
Reference in New Issue