User Tools

Site Tools


en:pixel

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:pixel [2016/01/01 22:41]
127.0.0.1 external edit
en:pixel [2020/05/27 10:02] (current)
admin
Line 1: Line 1:
 ===== Pixel (Function) ===== ===== Pixel (Function) =====
 ==== Format ==== ==== Format ====
-**pixel** (//x_expr////y_expr// )+**pixel** ([[numericexpressions|x_position]][[numericexpressions|y_position]] )
  
 returns //rgb_expr// returns //rgb_expr//
  
 ==== Description ==== ==== Description ====
-Returns the [[RGB|RGB]] value of the pixel at the //x_expr// and //y_expr// coordinate. If the pixels has not been set since the last [[clg|Clg]] command or was drawn with the color CLEAR a -1 will be returned.+Returns the [[RGB|RGB]] value of the pixel at the [[numericexpressions|x_position]] and [[numericexpressions|y_position]] coordinate. If the pixels has not been set since the last [[clg|Clg]] command or was drawn with the color CLEAR a -1 will be returned. 
 + 
 +==== Sample Program ==== 
 + 
 +The following sample program shows how to use the binary and operation and integer division to extract the red, blue, and green values from the number returned by pixel. 
 + 
 +<code> 
 +color red 
 +rect 0,0,100,100 
 + 
 +color rgb(100,50,150) 
 +rect 100,100,100,100 
 + 
 +color white 
 +rect 200,200,100,100 
 + 
 +while true 
 + c = pixel(mousex, mousey) 
 + r = (c & 0xff0000) \ 0x10000 
 + g = (c & 0xff00) \ 0x100 
 + b = (c & 0xff) 
 + print r,g,b 
 + pause .5 
 +end while 
 +</code>
  
 ==== See Also ==== ==== See Also ====
Line 13: Line 37:
 ==== History ====  ==== History ==== 
 |0.9.5m|New To Version| |0.9.5m|New To Version|
 +|2.0.0.4|Added example|
  
en/pixel.1451713302.txt.gz · Last modified: 2020/02/28 10:46 (external edit)