Mioplanet Documentation Center
Resources and Help
HomeProductsMioScriptJavaScriptTechNotesPHP
   Home | MioScript | draw.ID.getPixel SEARCH    

  Functions
draw.ID.brushFrom.ID
draw.ID.copyFrom.ID
draw.ID.copyMode
draw.ID.ellipse
draw.ID.getPixel
draw.ID.height
draw.ID.isEgual.ID
draw.ID.line
draw.ID.load
draw.ID.paint
draw.ID.pixelFormat
draw.ID.polygon
draw.ID.rect
draw.ID.rotate.sourceID
draw.ID.save
draw.ID.setPixel
draw.ID.size
draw.ID.text.ex
draw.ID.text.ex.getWidth
draw.ID.width
draw.isEgual.X
draw.isEgual.Y
draw.mem.create
draw.mem.createFromFile
draw.mem.delete
draw.mem.exists
draw.mx.deform
draw.mx.effects

  MioScript Reference
> Statements
app...
browser...
dialog...
disk...
draw...
extern...
filename...
keyboard...
menu...
mio...
mouse...
num...
path...
pushButton...
reg...
RS232...
sci...
screen...
shortcut...
sound...
str...
system...
time...
var...
window...

Function
draw.ID.getPixel

Language: MioScript
Product: MioFactory


Syntax

draw.ID.getPixel(X1, Y1, X2, Y2, X3, Y3, X4, Y4, X5, Y5, X6, Y6)


Parameters

INTX1, Y1Coordinates of the first pixel to read
INTX2, Y2Optional.
Coordinates of the second pixel to read
INTX3, Y3Optional.
Coordinates of the third pixel to read
INTX4, Y4Optional.
Coordinates of the forth pixel to read
INTX5, Y5Optional.
Coordinates of the fifth pixel to read
INTX6, Y6Optional.
Coordinates of the sixth pixel to read


Return value

Color or Array of colors



Description

This function read the color of a list of pixels.
Up to 6 pixels can be read with one call.

This function can be used to create maps.
Create a bitmap and load an an image with areas drawn with different colors.
When the user click on the application window, check the color of the pixel at the mouse position in the map bitmap.
The color of the pixel in the map bitmap will determine where the user click and which feature to call.

This function is also useful to detect collisions when developing games or animations.

Notice
always use BMP file for your maps to avoid compression of the JPG format.

When you specify more than one coordinate, an array is returned.




MioScript Sample Code

// Create and load a map file (can be any BMP file).
// Show the color in the map file depending on
// where the user click.

event.load
    ...
    &myMap = loadImage("map.bmp")
    ...
event.end


event.mouse:click
    &color = draw.&myMap.getPixel(
        mouse.main.x(), mouse.main.y()
    )
    alert("Color: "&color)

event.end