POINT
n = POINT (x [, y])
Returns the color of the pixel at x
,y
.
If the y-argument is not specified, x
specifies the
following info-code:
- 0: returns the current graphics cursor X-position
- 1: returns the current graphics cursor Y-position
Example 1: Get color
print point(100,100) ' Output: -2038815
Example 2: Get graphics cursor position
point(0)
x = point(1)
y = print "Initial position: "; x, y ' Output: 0,0
line STEP 50,50 STEP 50,50
point(0)
x = point(1)
y = print "Position after STEP: "; x, y ' Output: 100,100
Example 3
This demonstrates saving a screen section and redrawing it at different places on screen, a tiling and a moving across the screen.
' POINT demo.bas SmallBASIC 0.12.2 [B+=MGA] 2016-03-07
for objects = 1 to 300
if rnd > 0.5 then
circle rnd*xmax\1, rnd*ymax\1, rnd*50\1, rnd*5, rnd*16/1
else
rect rnd*xmax\1, rnd*ymax\1 step rnd*50\1, rnd*50\1, rnd*16/1
end if
next
at 0, ymax - 2*txth("Q") : print " press any..."
showpage
pause
350
xw = 250
yh = 0, 0, xw, yh
bottle cls
for y = 0 to ymax step yh
for x = 0 to xmax step xw
pour x, y, xw, yhshowpage
next
next
at 0, ymax - 2*txth("Q"): print " press any..."
showpage
pause
cls
for x = 0 to xmax step 25
cls
ymax\2 - yh\2, xw, yh
pour x, showpage
delay 10
next
at 0, ymax - 2*txth("Q") : print "done, press any... "
showpage
pause
sub bottle(xleft, ytop, xwidth, yheight)
local x, y
dim screensection(xwidth, yheight)
for y = ytop to (ytop + yheight - 1)
for x = xleft to (xleft + xwidth - 1)
POINT(x, y)
screensection(x, y) = next
next
end
sub pour(xoff, yoff, xwidth, yheight)
local x, y
for y = 0 to yheight
for x = 0 to xwidth
colr = screensection(x, y)pset x + xoff, y + yoff, colr
next
next
end
Example 4: Get graphics cursor and color
' Note: POINT(x, y) returns the color of the pixel at x,y. But it's
' also possible to use POINT(0) and POINT(1) to return the current
' X,Y graphics position...:
' Draw a little circle at the current graphics x,y position:
Sub show_point
Local x = Point(0) ' This is where the last graphics command left us...
Local y = Point(1)
Local c
Point(x, y) ' Now we know also the color of that point...
c = Circle x, y, 3 Color c FILLED ' (CIRCLE does not change current X,Y)
End Sub
' Draw a box and show the corners with a circle:
Line 50, 50, 360, 50 Color 15: show_point
Line STEP 0, +40 Color 14: show_point
Line STEP -(360 - 50), 0 Color 15: show_point
Line STEP 0, -40 Color 14: show_point
Showpage
' Print text inside the box and change its colors:
Point(0) + 45
x = Point(1) + 8
y = "That's the POINT !"
text = Txtw(text) - 6
x_dot = x + Txth(text) - 5
y_dot = y + For b = 7 To 1 Step -1 ' b = Background color
Xor (16 - b) ' c = Reversed Foreground color
c = b Color c, b: At x, y: Print "That's the POINT !"
Circle x_dot, y_dot, 3 Color c FILLED ' Print a point under '!'
Paint x - 2, y - 2, b ' Paint the rest of the box
Pause 1
Showpage
Next
Pause
Code samples using POINT
002 numeric variables.bas
003 conditional branching.bas
006 arrays+.bas
3d block lettes.bas
3d rotating cube with message.bas
3d_torus.bas
3dtorus.bas
7gables.bas
anball 1.0.bas
anomail.bas
Another center finder.bas
another look at trig functions.bas
arc_ui.bas
ascii 3d.bas
Balleta 2-11-15.bas
betrayal: crows ii.bas
bezier_pen.bas
biorythms.bas
blackbox.bas
Blackbox.bas
btn 21.bas
checkers.bas
checkers.bas
chess.bas
chess.bas
circumscribe triangle.bas
conrec-sb-v01.bas
coordplot.bas
dataminmax.bas
Graphics
ARC
CHART
CIRCLE
COLOR
DRAW
DRAWPOLY
IMAGE
LINE
PAINT
PEN
PLOT
POINT
PSET
RECT
RGB
RGBF
SHOWPAGE
TEXTHEIGHT
TEXTWIDTH
TXTH
TXTW
VIEW
WINDOW
XMAX
XPOS
YMAX
YPOS
If there is insufficient information on this page and you wish learn more about POINT,
please send an email to smallbasic@gmail.com. You can help to improve information about
POINT by submitting a pull request,
click View Source for details. Note, an offline language reference text file is also available - see the Download section.