From 0929a5a9e8baaf5c37688dea36de70e4ca82b879 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Sun, 3 Aug 2008 01:12:45 -0500 Subject: [PATCH 1/5] Add cfdg.models.spirales --- extra/cfdg/models/spirales/spirales.factor | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 extra/cfdg/models/spirales/spirales.factor diff --git a/extra/cfdg/models/spirales/spirales.factor b/extra/cfdg/models/spirales/spirales.factor new file mode 100644 index 0000000000..5f01d6a48f --- /dev/null +++ b/extra/cfdg/models/spirales/spirales.factor @@ -0,0 +1,41 @@ + +USING: namespaces sequences math random-weighted cfdg ; + +IN: spirales + +DEFER: line + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: block ( -- ) + [ + [ circle ] do + [ 0.3 s 60 flip line ] do + ] + recursive ; + +: a1 ( -- ) + [ + [ 0.95 s 2 x 12 r 0.5 b 10 hue 1.5 sat a1 ] do + [ block ] do + ] + recursive ; + +: line ( -- ) + -0.3 a + [ 0 rotate a1 ] do + [ 120 rotate a1 ] do + [ 240 rotate a1 ] do ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +: run ( -- ) + [ -1 b ] >background + { -20 40 -20 40 } viewport set + [ line ] >start-shape + 0.03 >threshold + cfdg-window ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +MAIN: run \ No newline at end of file From 9d1f741893862e28b09505fc039ddab3f6ae70be Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Mon, 4 Aug 2008 11:01:55 -0500 Subject: [PATCH 2/5] html.streams: Use color objects --- extra/html/streams/streams.factor | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/extra/html/streams/streams.factor b/extra/html/streams/streams.factor index eae13f53ad..76719b6ffa 100755 --- a/extra/html/streams/streams.factor +++ b/extra/html/streams/streams.factor @@ -1,9 +1,11 @@ ! Copyright (C) 2004, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: generic assocs help http io io.styles io.files continuations -io.streams.string kernel math math.order math.parser namespaces -quotations assocs sequences strings words html.elements -xml.entities sbufs continuations destructors accessors ; + +USING: combinators generic assocs help http io io.styles io.files + continuations io.streams.string kernel math math.order math.parser + namespaces quotations assocs sequences strings words html.elements + xml.entities sbufs continuations destructors accessors arrays ; + IN: html.streams GENERIC: browser-link-href ( presented -- href ) @@ -47,9 +49,9 @@ TUPLE: html-sub-stream < html-stream style parent ; ] [ call ] if* ] [ call ] if* ; inline -: hex-color, ( triplet -- ) - 3 head-slice - [ 255 * >fixnum >hex 2 CHAR: 0 pad-left % ] each ; +: hex-color, ( color -- ) + { [ red>> ] [ green>> ] [ blue>> ] } cleave 3array + [ 255 * >fixnum >hex 2 CHAR: 0 pad-left % ] each ; : fg-css, ( color -- ) "color: #" % hex-color, "; " % ; From 5cd794f9037a1bf0c892793fd6ba885c2889a48a Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Mon, 4 Aug 2008 11:02:17 -0500 Subject: [PATCH 3/5] html.streams.tests: Update tests for color objects --- extra/html/streams/streams-tests.factor | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/extra/html/streams/streams-tests.factor b/extra/html/streams/streams-tests.factor index 14f1621346..948c998e13 100644 --- a/extra/html/streams/streams-tests.factor +++ b/extra/html/streams/streams-tests.factor @@ -1,6 +1,8 @@ + USING: html.streams html.streams.private -io io.streams.string io.styles kernel -namespaces tools.test xml.writer sbufs sequences inspector ; + io io.streams.string io.styles kernel + namespaces tools.test xml.writer sbufs sequences inspector colors ; + IN: html.streams.tests : make-html-string @@ -52,7 +54,7 @@ M: funky browser-link-href [ [ "car" - H{ { foreground { 1 0 1 1 } } } + H{ { foreground T{ rgba f 1 0 1 1 } } } format ] make-html-string ] unit-test @@ -60,7 +62,7 @@ M: funky browser-link-href [ "
cdr
" ] [ [ - H{ { page-color { 1 0 1 1 } } } + H{ { page-color T{ rgba f 1 0 1 1 } } } [ "cdr" write ] with-nesting ] make-html-string ] unit-test From 481a1e2153745654243a844eeb969711901f751a Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Mon, 4 Aug 2008 11:03:18 -0500 Subject: [PATCH 4/5] Add demos tag for cfdg.models.spirales --- extra/cfdg/models/spirales/tags.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 extra/cfdg/models/spirales/tags.txt diff --git a/extra/cfdg/models/spirales/tags.txt b/extra/cfdg/models/spirales/tags.txt new file mode 100644 index 0000000000..cb5fc203e1 --- /dev/null +++ b/extra/cfdg/models/spirales/tags.txt @@ -0,0 +1 @@ +demos From ed6ec2c8a84887bcaf9b8d5e9d8d3af33bbc20d4 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Mon, 4 Aug 2008 11:03:53 -0500 Subject: [PATCH 5/5] Minor changes to cfdg.models.spirales --- extra/cfdg/models/spirales/spirales.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/cfdg/models/spirales/spirales.factor b/extra/cfdg/models/spirales/spirales.factor index 5f01d6a48f..60e4384fe0 100644 --- a/extra/cfdg/models/spirales/spirales.factor +++ b/extra/cfdg/models/spirales/spirales.factor @@ -1,7 +1,7 @@ USING: namespaces sequences math random-weighted cfdg ; -IN: spirales +IN: cfdg.models.spirales DEFER: line