summaryrefslogtreecommitdiff
path: root/modules/gui/demos/uicontrol_image.dem.sce
blob: ac4d5cdc6d757388de98d4fa46c7af99de65e357 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2012 - Digiteo - Vincent Couvert
//
// This file is released under the 3-clause BSD license. See COPYING-BSD.

demo_plot3d = scf(100002);

// Display image with default size (centered in figure)
f = gcf();
figSize = f.axes_size;
imageWidth = 181;
imageHeight = 144;
h = uicontrol("Parent", f, ..
"Style", "image", ..
"Position", [(figSize(1)-imageWidth)/2 (figSize(2)-imageHeight)/2 imageWidth imageHeight], ..
"String", SCI + "/modules/demo_tools/images/logo_scilab.png");

demo_viewCode(SCI+ "/modules/gui/demos/uicontrol_image.dem.sce");

// Play with image size
scales = [1:.01:2 2:-0.01:1];
for k=scales
    if ~is_handle_valid(h) then
        break
    end
    scaledImageWidth = int(imageWidth * k);
    scaledImageHeight = int(imageHeight * k);
    scaleXY = [scaledImageWidth/imageWidth scaledImageHeight/imageHeight];
    set(h, "Position", [(figSize(1)-scaledImageWidth)/2 (figSize(2)-scaledImageHeight)/2 scaledImageWidth scaledImageHeight]);
    set(h, "Value", scaleXY);
    sleep(10);
end

// Play with image shear
xShear = [0:.01:1 1:-0.01:0];
yShear = xShear;
for k=1:size(xShear, "*")
    if ~is_handle_valid(h) then
        break
    end
    valueProp = [1 1 xShear(k) yShear(k)];
    set(h, "Value", valueProp);
    sleep(10);
end

// Play with rotation
for k=0:180
    if ~is_handle_valid(h) then
        break
    end
    valueProp = [1 1 0 0 k];
    set(h, "Value", valueProp);
    sleep(10);
end