Post by bluatigro on May 13, 2018 11:09:45 GMT
this is a drawing program
if you want more tools ask
if you want more tools ask
'' bluatrigro 13 may 2017
'' draw it 1.0 JB version
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
nomainwin
global mode , pixel , lijn , ellipse , box
global ellipsefill , boxfill , ox , oy , nx , ny
global file$ , size , winx , winy , color$ , backolor$
winx = WindowWidth
winy = WindowHeight
menu #m , "file" _
, "new" , [new] _
, "open" , [open] _
, "save" , [save] _
, "save as" , [saveAs] _
,|, "exit" , [quit]
menu #m , "tools" _
, "pixel" , [pixel] _
, "line" , [line] _
, "ellipse" , [ellipse] _
, "ellipse fill" , [ellipsefill] _
, "box" , [box] _
, "box fill" , [boxfill] _
,|, "size" , [size] _
,|, "color" , [color] _
, "backcolor" , [backcolor]
size = 1
pixel = 1
lijn = 2
ellipse = 3
ellipsefill = 4
box = 5
boxfill = 6
color$ = "black"
backcolor$ = "yellow"
mode = pixel
open "draw it 1.0" for graphics as #m
#m "trapclose [quit]"
#m "when mouseMove [move]"
#m "when leftButtonDown [leftdown]"
#m "when leftButtonMove [leftmove]"
#m "when leftButtonUp [leftup]"
#m "setfocus"
wait
[move]
nx = MouseX
ny = MouseY
wait
[leftmove]
nx = MouseX
ny = MouseY
#m "rule " ; _R2_NOTXORPEN
#m "color black"
select case mode
case lijn
#m "down"
#m "line " ; ox ; " " ; oy ; " " ; nx ; " " ; ny
#m "up"
#m "down"
#m "line " ; ox ; " " ; oy ; " " ; nx ; " " ; ny
#m "up"
case ellipse
#m "goto " ; ( ox + nx ) / 2 ; " " ; ( oy + ny ) / 2
#m "down"
#m "ellipse " ; nx - ox ; " " ; ny - oy
#m "up"
#m "goto " ; ( ox + nx ) / 2 ; " " ; ( oy + ny ) / 2
#m "down"
#m "ellipse " ; nx - ox ; " " ; ny - oy
#m "up"
case ellipsefill
#m "goto " ; ( ox + nx ) / 2 ; " " ; ( oy + ny ) / 2
#m "down"
#m "ellipse " ; nx - ox ; " " ; ny - oy
#m "up"
#m "goto " ; ( ox + nx ) / 2 ; " " ; ( oy + ny ) / 2
#m "down"
#m "ellipse " ; nx - ox ; " " ; ny - oy
#m "up"
case box
#m "goto " ; ox ; " " ; oy
#m "down"
#m "box " ; nx ; " " ; ny
#m "up"
#m "goto " ; ox ; " " ; oy
#m "down"
#m "box " ; nx ; " " ; ny
#m "up"
case boxfill
#m "goto " ; ox ; " " ; oy
#m "down"
#m "box " ; nx ; " " ; ny
#m "up"
#m "goto " ; ox ; " " ; oy
#m "down"
#m "box " ; nx ; " " ; ny
#m "up"
case else
#m "rule " ; _R2_COPYPEN
#m "color " ; color$
#m "size " ; size
#m "goto " ; nx ; " " ; ny
#m "down"
#m "set " ; nx ; " " ; ny
#m "up"
end select
wait
sub Pause ms
t = time$( "milliseconds" )
while time$( "milliseconds" ) < t + ms
wend
end sub
[leftdown]
ox = MouseX
oy = MouseY
wait
[leftup]
#m "rule " ; _R2_COPYPEN
#m "color " ; color$
#m "backcolor " ; backcolor$
#m "size " ; size
select case mode
case lijn
#m "down"
#m "line " ; ox ; " " ; oy ; " " ; nx ; " " ; ny
#m "up"
case ellipse
#m "goto " ; ( ox + nx ) / 2 ; " " ; ( oy + ny ) / 2
#m "down"
#m "ellipse " ; nx - ox ; " " ; ny - oy
#m "up"
case ellipsefill
#m "goto " ; ( ox + nx ) / 2 ; " " ; ( oy + ny ) / 2
#m "down"
#m "ellipsefilled " ; nx - ox ; " " ; ny - oy
#m "up"
case box
#m "goto " ; ox ; " " ; oy
#m "down"
#m "box " ; nx ; " " ; ny
#m "up"
case boxfill
#m "goto " ; ox ; " " ; oy
#m "down"
#m "boxfilled " ; nx ; " " ; ny
#m "up"
case else
end select
wait
[pixel]
mode = pixel
wait
[line]
mode = lijn
wait
[ellipse]
mode = ellipse
wait
[ellipsefill]
mode = ellipsefill
wait
[box]
mode = box
wait
[boxfill]
mode = boxfill
wait
[size]
s$ = str$( size )
prompt "size = " ; s$
size = val( s$ )
wait
[color]
prompt "Color = " ; color$
wait
[backcolor]
prompt "BackColor = " ; backcolor$
wait
[new]
file$ = DefaultDir$ + "\unnamed.bmp"
#m "fill white"
wait
[open]
filedialog "open bmp" , "*.bmp" , file$
loadbmp "drawing" , file$
#m "background drawing"
wait
[saveAs]
filedialog "save bmp" , "*.bmp" , file$
[save]
#m "getbmp drawing 0 0 " ; winx ; " " ; winy
bmpsave "drawing" , file$
wait
[quit]
close #m
end