`prev Menu next`

ASK PIXEL

`ASK PIXEL VALUE (x,y) a
` assigns the color index of the color at the point(x,y) to a numeric variable a.
If no color index matches the color at the point, -1 is assigned.

`ASK PIXEL SIZE (x1 , y1 ; x2 , y2) a,b
` assigns the numbers of horizontal and vertical pixels of the rectangle of which diagonal vertices is (x1, y1) and (x2, y2) to numeric variables a, b.
The vertices or sides of the rectangle are counted in.

Let M be a 2-dimensional array.
`ASK PIXEL ARRAY (x,y) M
` assigns the color index of each pixel on the rectangle of which the left-top vertex is (x,y) and the width is the number of first dimension of M and the height is the number of second dimension of M to M.
If no color index matches the color at the point, -1 is assigned.
[Reference] MAT PLOT CELLS
Example.

    100 DIM M(501,501)
    110 ASK PIXEL SIZE(-0.5,0.5; 0.5,-0.5) A,B
    120 MAT M=ZER(A,B)
    130 ASK PIXEL ARRAY (-0.5,0.5) M
    140 GET POINT: X,Y
    150 MAT PLOT CELLS, IN X-1,Y+1;X+1,Y-1 :M

This program shall obtain the color indices of the pixels on the interior of the square of side length 1 and of center the origin, and draw the square enlarged two times around the point indicated by a mouse click.

Note.
When we assign different colors to the same color index using SET COLOR MIX, former colors become those with no color index.
As PLOT TEXT (LABEL, LETTERS) employs some colors other than designated, we change the COLOR MODE to NATIVE when we capture letters.