Created
May 30, 2010 12:46
-
-
Save dom96/419000 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var surf = newScreenSurface(800, 600) | |
var r: TRect = (0, 0, 900, 900) | |
# Draw the shapes | |
surf.fillRect(r, colWhite) | |
surf.drawLineAA((100, 170), (400, 471), colTan) | |
surf.drawLine((100, 170), (400, 471), colRed) | |
surf.drawEllipse(200, 300, 200, 30, colSeaGreen) | |
surf.drawHorLine(1, 300, 400, colViolet) | |
# Check if the ellipse is the size it's suppose to be. | |
surf.drawVerLine(200, 300 - 30 + 1, 60, colViolet) # ^^ | i suppose it is | |
surf.drawEllipse(400, 300, 300, 300, colOrange) | |
surf.drawEllipse(5, 5, 5, 5, colGreen) | |
surf.drawHorLine(5, 5, 900, colRed) | |
surf.drawVerLine(5, 60, 800, colRed) | |
surf.drawCircle((600, 500), 60, colRed) | |
#surf.drawText((300, 300), "TEST", colMidnightBlue) | |
#var textSize = textBounds("TEST") | |
#surf.drawText((300, 300 + textSize.height), $textSize.width & ", " & | |
# $textSize.height, colDarkGreen) | |
var mouseStartX = 0 | |
var mouseStartY = 0 | |
withEvents(surf, event): | |
case event.kind: | |
of SDL.QUITEV: | |
break | |
of SDL.KEYDOWN: | |
if event.sym == SDL.K_LEFT: | |
echo(event.sym) | |
surf.drawHorLine(395, 300, 5, colPaleGoldenRod) | |
echo("Drawing") | |
else: | |
echo(event.sym) | |
of SDL.MOUSEBUTTONDOWN: | |
# button.x/y is F* UP! | |
echo("MOUSEDOWN ", event.x) | |
mouseStartX = event.x | |
mouseStartY = event.y | |
of SDL.MOUSEBUTTONUP: | |
echo("MOUSEUP ", mouseStartX) | |
if mouseStartX != 0 and mouseStartY != 0: | |
echo(mouseStartX, "->", int(event.x)) | |
surf.drawLineAA((mouseStartX, MouseStartY), | |
(int(event.x), int(event.y)), colPaleGoldenRod) | |
mouseStartX = 0 | |
mouseStartY = 0 | |
else: | |
#echo(event.theType) | |
SDL.UpdateRect(surf.s, int32(0), int32(0), int32(800), int32(600)) | |
surf.writeToBMP("test.bmp") | |
SDL.Quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment