Merge branch 'master' of git://factorcode.org/git/factor

db4
Slava Pestov 2009-05-13 19:39:33 -05:00
commit edeeabb9a1
5 changed files with 18 additions and 8 deletions

View File

@ -43,6 +43,11 @@ HELP: push-growing-circular
{ "elt" object } { "circular" circular } }
{ $description "Pushes an element onto a " { $link growing-circular } " object." } ;
HELP: rotate-circular
{ $values
{ "circular" circular } }
{ $description "Advances the start index of a circular object by one." } ;
ARTICLE: "circular" "Circular sequences"
"The " { $vocab-link "circular" } " vocabulary implements the " { $link "sequence-protocol" } " to allow an arbitrary start index and wrap-around indexing." $nl
"Creating a new circular object:"
@ -51,6 +56,7 @@ ARTICLE: "circular" "Circular sequences"
{ $subsection <growing-circular> }
"Changing the start index:"
{ $subsection change-circular-start }
{ $subsection rotate-circular }
"Pushing new elements:"
{ $subsection push-circular }
{ $subsection push-growing-circular } ;

View File

@ -12,6 +12,7 @@ circular strings ;
[ CHAR: e ] [ "test" <circular> 5 swap nth-unsafe ] unit-test
[ [ 1 2 3 ] ] [ { 1 2 3 } <circular> [ ] like ] unit-test
[ [ 2 3 1 ] ] [ { 1 2 3 } <circular> [ rotate-circular ] keep [ ] like ] unit-test
[ [ 2 3 1 ] ] [ { 1 2 3 } <circular> 1 over change-circular-start [ ] like ] unit-test
[ [ 3 1 2 ] ] [ { 1 2 3 } <circular> 1 over change-circular-start 1 over change-circular-start [ ] like ] unit-test
[ [ 3 1 2 ] ] [ { 1 2 3 } <circular> -100 over change-circular-start [ ] like ] unit-test

View File

@ -27,6 +27,9 @@ M: circular virtual-seq seq>> ;
#! change start to (start + n) mod length
circular-wrap (>>start) ;
: rotate-circular ( circular -- )
[ start>> 1 + ] keep circular-wrap (>>start) ;
: push-circular ( elt circular -- )
[ set-first ] [ 1 swap change-circular-start ] bi ;

View File

@ -12,12 +12,12 @@ M: game-world draw*
swap >>tick-slice draw-world ;
M: game-world begin-world
open-game-input
dup [ tick-length ] [ ] bi <game-loop> [ >>game-loop ] keep start-loop
drop
open-game-input ;
M: game-world end-world
close-game-input
[ [ stop-loop ] when* f ] change-game-loop
drop ;
M: game-world end-world
[ [ stop-loop ] when* f ] change-game-loop
close-game-input
drop ;

View File

@ -8,10 +8,10 @@ varying vec3 direction;
void main()
{
vec4 v = vec4(gl_Vertex.xy, 1.0, 1.0);
vec4 v = vec4(gl_Vertex.xy, -1.0, 1.0);
gl_Position = v;
vec4 p = (gl_ProjectionMatrixInverse * v) * vec4(1,1,-1,1);
vec4 p = gl_ProjectionMatrixInverse * v;
float s = sin(sky_theta), c = cos(sky_theta);
direction = mat3(1, 0, 0, 0, c, s, 0, -s, c)