added "scale" affine transformation for graphics pipeline - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/examples/fractals.lua
diff options
context:
space:
mode:
authorfrancesco-ST <francesco.abbate@st.com>2010年12月28日 13:36:33 +0100
committerfrancesco-ST <francesco.abbate@st.com>2010年12月28日 13:36:33 +0100
commit45ae5dceb38d665e446960618cb8c1cda5f5afc5 (patch)
treee596adfbe330b99d6a0b6b7cd684510b5a10680e /examples/fractals.lua
parent6d4c09d61a370c79ed8b41282ed7ad13a0d7f989 (diff)
downloadgsl-shell-45ae5dceb38d665e446960618cb8c1cda5f5afc5.tar.gz
added "scale" affine transformation for graphics pipeline
Added a specific error code. Documentation and fractal example updated.
Diffstat (limited to 'examples/fractals.lua')
-rw-r--r--examples/fractals.lua 45
1 files changed, 11 insertions, 34 deletions
diff --git a/examples/fractals.lua b/examples/fractals.lua
index 9f32717f..168ef83e 100644
--- a/examples/fractals.lua
+++ b/examples/fractals.lua
@@ -67,36 +67,16 @@ end
demo2 = function(n) return levyc(n and n or 6) end
-function get_box_gener()
- local pbox = {}
-
- local function get(ll)
- local b = pbox[ll]
- if not b then
- b = rect(0, 0, ll, ll)
- pbox[ll] = b
- end
- return b
- end
-
- local function count()
- local c = 0
- for k, v in pairs(pbox) do c = c+1 end
- return c
- end
- return get, count
-end
-
function demo3()
local rdsd = sqrt(2)/2
+ local ubox = rect(0, 0, 1, 1)
local cf
- local get_box, box_count = get_box_gener()
-
local function pitag_tree(pl, x, y, th, ll, depth)
- local box = get_box(ll)
local col = cf(depth)
- pl:add(box, col, {}, {{'translate', x= x, y= y}, {'rotate', angle= th}})
+ pl:add(ubox, col, {}, {{'translate', x= x, y= y},
+ {'rotate', angle= th},
+ {'scale', ll}})
if depth > 0 then
x, y = x - ll*sin(th), y + ll*cos(th)
pitag_tree(pl, x, y, th + pi/4, ll*rdsd, depth-1)
@@ -113,7 +93,6 @@ function demo3()
pitag_tree(pl, 0, 0, 0, 1, depth)
pl:show()
- print('number of used rectangles:', box_count())
return pl
end
@@ -188,17 +167,16 @@ function demo3ter(n)
end
function demo4(n)
+ local ubox = rect(0, 0, 1, 1)
n = n and n or 10
local col, coln
- local get_box, box_count = get_box_gener()
-
local function pitag_tree(pl, x, y, th, ll, depth)
if depth == 0 then
- local box = get_box(ll)
- local tr = {{'translate', x= x, y= y}, {'rotate', angle= th}}
- pl:add(box, col, {}, tr)
- pl:add(box, coln, {{'stroke', width= 2.5*ll}}, tr)
+ local tr = {{'translate', x= x, y= y}, {'rotate', angle= th},
+ {'scale', ll}}
+ pl:add(ubox, col, {}, tr)
+ pl:add(ubox, coln, {{'stroke', width= 2.5*ll}}, tr)
end
if depth > 0 then
x, y = x - ll*sin(th), y + ll*cos(th)
@@ -212,16 +190,15 @@ function demo4(n)
local cfgen = color_function('darkgreen', 1)
local pl = plot()
- pl.units = false
pl.sync = false
pl:show()
for k=0, n do
col, coln = cfgen(k/n), cfgen((k+1)/n)
pitag_tree(pl, 0, 0, 0, 1, k)
- pl:flush()
+ pl:flush()
end
- print('number of used rectangles:', box_count())
+
return pl
end
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月21日 19:36:12 +0000

AltStyle によって変換されたページ (->オリジナル) /