Demo: add Matplot demos 31/14031/2
Calixte DENIZET [Fri, 14 Mar 2014 15:12:10 +0000 (16:12 +0100)]
Change-Id: I60e42534ecb981135dde2b87f1c72402c74768f5

scilab/modules/graphics/demos/2d_3d_plots/2d_3d_plots.dem.gateway.sce
scilab/modules/graphics/demos/graphics.dem.gateway.sce
scilab/modules/graphics/demos/matplot/classical.dem.sce [new file with mode: 0644]
scilab/modules/graphics/demos/matplot/classical_1.dem.sce [new file with mode: 0644]
scilab/modules/graphics/demos/matplot/java_image.dem.sce [new file with mode: 0644]
scilab/modules/graphics/demos/matplot/mandelbrot.dem.sce [new file with mode: 0644]
scilab/modules/graphics/demos/matplot/matplot.dem.gateway.sce [new file with mode: 0644]
scilab/modules/graphics/demos/matplot/puffin.png [new file with mode: 0644]

index e0e1007..e14d729 100644 (file)
@@ -21,7 +21,6 @@ subdemolist = [                                   ..
 "fplot3d"        , "fplot3d.dem.sce"         ; ..
 "plot3d1"        , "plot3d1.dem.sce"         ; ..
 "fplot3d1"       , "fplot3d1.dem.sce"        ; ..
-"Matplot1 (mandelbrot)"     , "mandelbrot.dem.sce"      ; ..
 "contour"        , "contour.dem.sce"         ; ..
 "fcontour"       , "fcontour.dem.sce"        ; ..
 "contourf"       , "contourf.dem.sce"        ; ..
index 31a8c84..94cdfe0 100644 (file)
@@ -21,9 +21,10 @@ function subdemolist = demo_gateway()
     _("bar histogram")               ,"bar/bar.dem.sce"; ..
     _("Datatips")                    ,"datatips/datatips.dem.gateway.sce"                   ; ..
     _("LaTeX/MathML")                ,"textrendering/textrendering.dem.gateway.sce"         ; ..
-       _("Lighting")                    ,"lighting/lighting.dem.gateway.sce"                   ; ..
+    _("Lighting")                    ,"lighting/lighting.dem.gateway.sce"                   ; ..
     _("Misc")                        ,"misc/misc.dem.sce"                                   ; ..
-    _("Colormap")                    ,"colormap/colormap.dem.sce"];
+    _("Colormap")                    ,"colormap/colormap.dem.sce"                           ; ..
+    _("Matplot")                    ,"matplot/matplot.dem.gateway.sce"];
 
     subdemolist(:,2) = demopath + subdemolist(:,2);
 endfunction
diff --git a/scilab/modules/graphics/demos/matplot/classical.dem.sce b/scilab/modules/graphics/demos/matplot/classical.dem.sce
new file mode 100644 (file)
index 0000000..8c36e61
--- /dev/null
@@ -0,0 +1,23 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET
+//
+// This file is released under the 3-clause BSD license. See COPYING-BSD.
+
+function demo_classical()
+    my_handle             = scf(100001);
+    clf(my_handle,"reset");
+    demo_viewCode("classical.dem.sce");
+
+    // DEMO START
+
+    my_plot_desc          = _("Classical Matplot");
+    my_handle.figure_name = my_plot_desc;
+
+    Matplot();
+
+    // DEMO END
+endfunction
+
+
+demo_classical();
+clear demo_classical;
diff --git a/scilab/modules/graphics/demos/matplot/classical_1.dem.sce b/scilab/modules/graphics/demos/matplot/classical_1.dem.sce
new file mode 100644 (file)
index 0000000..cf48b1f
--- /dev/null
@@ -0,0 +1,23 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET
+//
+// This file is released under the 3-clause BSD license. See COPYING-BSD.
+
+function demo_classical_1()
+    my_handle             = scf(100001);
+    clf(my_handle,"reset");
+    demo_viewCode("classical_1.dem.sce");
+
+    // DEMO START
+
+    my_plot_desc          = _("Classical Matplot1");
+    my_handle.figure_name = my_plot_desc;
+
+    Matplot1();
+
+    // DEMO END
+endfunction
+
+
+demo_classical_1();
+clear demo_classical_1;
\ No newline at end of file
diff --git a/scilab/modules/graphics/demos/matplot/java_image.dem.sce b/scilab/modules/graphics/demos/matplot/java_image.dem.sce
new file mode 100644 (file)
index 0000000..be32290
--- /dev/null
@@ -0,0 +1,36 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET
+//
+// This file is released under the 3-clause BSD license. See COPYING-BSD.
+
+function demo_java_image()
+    my_handle             = scf(100001);
+    clf(my_handle,"reset");
+    demo_viewCode("java_image.dem.sce");
+    demopath = get_absolute_file_path("java_image.dem.sce");
+
+    // DEMO START
+
+    my_plot_desc          = _("Java Image");
+    my_handle.figure_name = my_plot_desc;
+
+    jimport javax.imageio.ImageIO;
+    jimport java.net.URL;
+
+    bi = ImageIO.read(URL.new("file://" + demopath + "/puffin.png"));
+    w = bi.getWidth(jvoid);
+    h = bi.getHeight(jvoid);
+    data = bi.getRGB(0, 0, w, h, [], 0, w);
+    data = matrix(data, double(w), double(h));
+    data = uint32(data');
+
+    Matplot(data);
+    e = gce();
+    e.image_type="argb";
+
+    // DEMO END
+endfunction
+
+
+demo_java_image();
+clear demo_java_image;
\ No newline at end of file
diff --git a/scilab/modules/graphics/demos/matplot/mandelbrot.dem.sce b/scilab/modules/graphics/demos/matplot/mandelbrot.dem.sce
new file mode 100644 (file)
index 0000000..a265f89
--- /dev/null
@@ -0,0 +1,101 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Samuel GOUGEON
+//
+// This file is released under the 3-clause BSD license. See COPYING-BSD.
+
+function demo_mandelbrot()
+
+    my_handle             = scf(100001);
+    clf(my_handle,"reset");
+
+    // DEMO START
+
+    my_plot_desc          = "mandelbrot";
+    my_handle.figure_name = my_plot_desc;
+    function M = getMandelbrotPart(xmin, xmax, ymin, ymax, nbPix, nColors, maxIters)
+        // M : matrix of integers imaging the targetted local Mandelbrot area
+        // M(i,j) gives the number of iterations for which the iterated z(i,j)
+        //     suite crosses |z|>=2 (making this point out of the Mandelbrot set)
+        ndmin = 0;
+        Dx = abs(xmax - xmin);
+        Dy = abs(ymax - ymin);
+        dp = sqrt(Dx*Dy / nbPix);  // Area of a pixel
+        nx = round(Dx/dp);
+        ny = round(Dy/dp);
+        dx = abs(xmax - xmin)/(nx-1);
+        x  = linspace(xmin, xmax, nx);
+        y  = ymax:-dx:ymin;
+        ny = length(y);
+        c  = (ones(ny,1)*x) + %i*(y.'*ones(1,nx));
+        z  = c;  // Initial c Matrix
+        nd = ones(z)*%inf;  // nb iter for > 2
+        inC = 1:size(c,"*");
+        i = 1;
+        waitId = 0;
+        ifin = min(ndmin+nColors, maxIters);
+        while i<=ifin,
+            if waitId==0
+                waitId = waitbar(i/ifin,_("Computing in progress..."));
+            else
+                waitbar(i/ifin,waitId);
+            end
+            a = abs(z);
+            nd(inC(find(a>2)))=i;
+            tmp = find(a<=2);
+            z   = z(tmp);
+            inC = inC(tmp);
+            z   = z.*z+c(inC);
+            i = i+1;
+        end
+        close(waitId)
+        M = nd
+    endfunction
+    // ---------------------
+
+    nColors = 100;   // Number of colors
+    maxIters = 500;  // Maximal number of iterations
+    nbPix = 200000;  // Total number of pixel per image
+    // Targetted Mandelbrot area
+    xmin = -0.33;
+    xmax = 0.07;
+    ymin = 0.6;
+    ymax = 1.13;
+
+    // Generating the Mandelbrot local view
+    M = getMandelbrotPart(xmin, xmax, ymin, ymax, nbPix, nColors, maxIters);
+
+    // Scaling false colors
+    icol  = [color("black")  addcolor(rainbowcolormap(nColors))];
+    Mmin = min(M);
+    M = M - Mmin + 1;
+    M(find(M==%inf | M>nColors))=0;
+    A = icol(M+1);
+
+    clf
+    drawlater;
+    // colordef("black")  // Bug 11369 to be fixed
+
+    // Displaying the area
+    Matplot1(matrix(A,size(M)),[xmin ymin xmax ymax]);
+
+    // Post-tuning the graphics
+    ca = gca();
+    ca.isoview = "on";
+    ca.data_bounds = [xmin ymin ; xmax ymax];
+    ca.tight_limits = "on";
+    ca.axes_visible = ["on" "on" "off"];
+    ca.title.font_size = 2;
+    Ttxt = _("Matplot1(..) displays a matrix\n(value => color#), with SCALED AXES\n(here is a part of the Mandelbrot set)")
+    xtitle(justify(msprintf(Ttxt),"c"))
+    xlabel(_("Real part"))
+    ylabel(_("Imaginary part"))
+
+    drawnow()
+
+    demo_viewCode("mandelbrot.dem.sce");
+
+endfunction
+
+demo_mandelbrot();
+clear demo_mandelbrot;
+
diff --git a/scilab/modules/graphics/demos/matplot/matplot.dem.gateway.sce b/scilab/modules/graphics/demos/matplot/matplot.dem.gateway.sce
new file mode 100644 (file)
index 0000000..3017a80
--- /dev/null
@@ -0,0 +1,15 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Calixte DENIZET
+//
+// This file is released under the 3-clause BSD license. See COPYING-BSD.
+
+demopath = get_absolute_file_path("matplot.dem.gateway.sce");
+
+subdemolist = [                                   ..
+_("Classical Matplot")      , "classical.dem.sce"    ; ..
+_("Classical Matplot1")    , "classical_1.dem.sce"       ; ..
+_("Mandelbrot")    , "mandelbrot.dem.sce"       ; ..
+_("Java Image")    , "java_image.dem.sce"       ];
+
+subdemolist(:,2) = demopath + subdemolist(:,2);
+clear demopath;
\ No newline at end of file
diff --git a/scilab/modules/graphics/demos/matplot/puffin.png b/scilab/modules/graphics/demos/matplot/puffin.png
new file mode 100644 (file)
index 0000000..cf2e671
Binary files /dev/null and b/scilab/modules/graphics/demos/matplot/puffin.png differ