Ooops
January 20, 2021, 11:07:26 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Algorithms
»
[bb] Any Zoom Level Line by skn3 [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] Any Zoom Level Line by skn3 [ 1+ years ago ] (Read 1731 times)
BlitzBot
Jr. Member
Posts: 1
[bb] Any Zoom Level Line by skn3 [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:43 AM »
Title :
Any Zoom Level Line
Author :
skn3
Posted :
1+ years ago
Description :
A function to draw a line at a variable Zoom. What this means is . Say you are making an art app. And you were at 4X zoomed in, with this you can quickly draw a line at 4X zoom.
[update]
I just fixed some flaot --> int and int --> float rounding up/down errors. Not that its majorly complicated, but a line in any zoom, will be 99% accurate now.
Code :
Code: BlitzBasic
Graphics
640
,
480
,
32
,
2
Global
angle#=
0
While
KeyDown
(
1
)
=
False
SetBuffer
BackBuffer
(
)
Cls
Color
255
,
255
,
255
drawline
(
200
,
200
,
MouseX
(
)
,
MouseY
(
)
,
33
)
Flip
Wend
Function
DrawLine
(
StartX,StartY,EndX,EndY,Scale
)
StartX=StartX/Scale*Scale
StartY=StartY/Scale*Scale
EndX=EndX/Scale*Scale
EndY=EndY/Scale*Scale
If
StartX<EndX
Then
Xmode=
True
Else
Xmode=
False
End If
If
StartY<EndY
Then
Ymode=
True
Else
Ymode=
False
End If
width#=
Abs
(
startX-EndX
)
height#=
Abs
(
StartY-EndY
)
If
width#>height#
Then
loops=width#
If
XMode=
False
Then
xstep#=-
1
Else
xstep#=
1
End If
If
Ymode=
False
Then
ystep#=-
(
height#/width#
)
Else
ystep#=
(
height#/width#
)
End If
Else
loops=height#
If
XMode=
False
Then
xstep#=-
(
width#/height#
)
Else
xstep#=
(
width#/height#
)
End If
If
Ymode=
False
Then
ystep#=-
1
Else
ystep#=
1
End If
End If
drawX#=startX
drawY#=startY
loops=
Ceil
(
loops/scale
)
+
1
For
i=
1
To
loops
getX#=drawX#/scale
getY#=drawY#/scale
intX=
Int
(
getX#
)
*scale
intY=
Int
(
GetY#
)
*scale
Rect
IntX,IntY,scale,scale
drawX#=drawX#+
(
xstep#*scale
)
drawY#=drawY#+
(
ystep#*scale
)
Next
End Function
Comments :
none...
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Algorithms
»
[bb] Any Zoom Level Line by skn3 [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal