|
Post by bluatigro on Apr 8, 2018 2:03:17 GMT -5
i been working on this for some time draw it : a simple draw program whit gdi api bruhs and pen rem : it is not good jet if anyone can help its good
|
|
|
Post by bluatigro on Apr 13, 2018 1:01:03 GMT -5
update : draw it whit draw mode [ _R2_* ] i don't know from every draw.mode exactly what it does experiment and see paint does not have this option i got al native LB graphics stuf [ except pie and piefilled ] build in [ extra : triangle ] Attachments:draw_it_v2.bas (7.96 KB)
|
|
|
Post by bluatigro on Jan 15, 2019 8:37:24 GMT -5
update : now you can draw your own sprites
'' bluatigro 15 jan 2019 WindowWidth = DisplayWidth WindowHeight = DisplayHeight nomainwin global mode , pixel , lijn , ellipse , cellipse , box global remove , text , text$ , font$ , cellipsefill global ellipsefill , boxfill , ox , oy , nx , ny , fill global file$ , size , winx , winy , color$ , backolor$ global text , text$ , font$ , triangle , tel , shadow$ global sprx , spry winx = WindowWidth winy = WindowHeight sprx = 64 spry = 64 menu #m , "file" _ , "new" , [new] _ , "open" , [open] _ , "save" , [save] _ , "save as" , [saveAs] _ ,|, "exit" , [quit] menu #m , "tools" _ , "fill" , [fill] _ , "pixel" , [pixel] _ , "line" , [line] _ , "rect ellipse" , [ellipse] _ , "rect ellipse fill" , [ellipsefill] _ , "c ellipse" , [cellipse] _ , "c ellipse fill" , [cellipsefill] _ , "box" , [box] _ , "box fill" , [boxfill] _ , "triangle" , [triangle] _ ,|, "remove" , [remove] _ ,|, "font" , [font] _ , "text" , [text] _ ,|, "size" , [size] _ ,|, "color" , [color] _ , "backcolor" , [backcolor] _ , "shadow color" , [shadow] size = 1 pixel = 1 lijn = 2 ellipse = 3 ellipsefill = 4 box = 5 boxfill = 6 remove = 7 color$ = "red" backcolor$ = "yellow" shadow$ = "black" font$ = " 30 bold" text$ = "type text here" text = 8 triangle = 9 cellipse = 10 cellipsefill = 11 mode = pixel open "draw it sprite" 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 white" #m "size 1" 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 , 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 cellipse , cellipsefill #m "goto " ; ox ; " " ; oy #m "down" #m "ellipse " ; ( nx - ox ) * 2 ; " " ; ( ny - oy ) * 2 #m "up" #m "goto " ; ox ; " " ; oy #m "down" #m "ellipse " ; ( nx - ox ) * 2 ; " " ; ( ny - oy ) * 2 #m "up" case box , 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 pixel #m "rule " ; _R2_COPYPEN #m "color black" #m "size " ; size #m "goto " ; nx ; " " ; ny - spry #m "down" #m "set " ; nx ; " " ; ny - spry #m "up" #m "color " ; color$ #m "size " ; size #m "goto " ; nx ; " " ; ny #m "down" #m "set " ; nx ; " " ; ny #m "up" case else ''remove #m "rule " ; _R2_COPYPEN #m "color white" #m "size " ; size #m "goto " ; nx ; " " ; ny - spry #m "down" #m "set " ; nx ; " " ; ny - spry #m "up" #m "color black" #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 if mode = triangle then x( tel ) = ox y( tel ) = oy tel = tel + 1 end if wait [leftup] #m "rule " ; _R2_COPYPEN #m "size " ; size select case mode case fill #m "color " ; shadow$ #m "backcolor " ; shadow$ #m "goto 0 0" #m "down" #m "boxfilled " ; sprx ; " " ; spry #m "up" #m "color " ; color$ #m "backcolor " ; color$ #m "goto 0 " ; spry #m "down" #m "boxfilled " ; sprx ; " " ; spry * 2 #m "up" case lijn #m "color " ; shadow$ #m "down" #m "line " ; ox ; " " ; oy - spry _ ; " " ; nx ; " " ; ny - spry #m "up" #m "color " ; color$ #m "backcolor " ; backcolor$ #m "down" #m "line " ; ox ; " " ; oy ; " " ; nx ; " " ; ny #m "up" case ellipse #m "color " ; shadow$ #m "goto " ; ( ox + nx ) / 2 _ ; " " ; ( oy + ny ) / 2 - spry #m "down" #m "ellipse " ; nx - ox ; " " ; ny - oy #m "up" #m "color " ; color$ #m "backcolor " ; backcolor$ #m "goto " ; ( ox + nx ) / 2 ; " " ; ( oy + ny ) / 2 #m "down" #m "ellipse " ; nx - ox ; " " ; ny - oy #m "up" case ellipsefill #m "color " ; shadow$ #m "backcolor " ; shadow$ #m "goto " ; ( ox + nx ) / 2 _ ; " " ; ( oy + ny ) / 2 - spry #m "down" #m "ellipsefilled " ; nx - ox ; " " ; ny - oy #m "up" #m "color " ; color$ #m "backcolor " ; backcolor$ #m "goto " ; ( ox + nx ) / 2 ; " " ; ( oy + ny ) / 2 #m "down" #m "ellipsefilled " ; nx - ox ; " " ; ny - oy #m "up" case cellipse #m "color " ; shadow$ #m "goto " ; ox ; " " ; oy - spry #m "down" #m "ellipse " ; ( nx - ox ) * 2 ; " " ; ( ny - oy ) * 2 #m "up" #m "color " ; color$ #m "backcolor " ; backcolor$ #m "goto " ; ox ; " " ; oy #m "down" #m "ellipse " ; ( nx - ox ) * 2 ; " " ; ( ny - oy ) * 2 #m "up" case cellipsefill #m "color " ; shadow$ #m "backcolor " ; shadow$ #m "goto " ; ox ; " " ; oy - spry #m "down" #m "ellipsefilled " ; ( nx - ox ) * 2 ; " " ; ( ny - oy ) * 2 #m "up" #m "color " ; color$ #m "backcolor " ; backcolor$ #m "goto " ; ox ; " " ; oy #m "down" #m "ellipsefilled " ; ( nx - ox ) * 2 ; " " ; ( ny - oy ) * 2 #m "up" case box #m "color " ; shadow$ #m "goto " ; ox ; " " ; oy - spry #m "down" #m "box " ; nx ; " " ; ny - spry #m "up" #m "color " ; color$ #m "goto " ; ox ; " " ; oy #m "down" #m "box " ; nx ; " " ; ny #m "up" case boxfill #m "color " ; shadow$ #m "backcolor " ; shadow$ #m "goto " ; ox ; " " ; oy #m "down" #m "boxfilled " ; nx ; " " ; ny #m "up" #m "color " ; color$ #m "backcolor " ; backcolor$ #m "goto " ; ox ; " " ; oy #m "down" #m "boxfilled " ; nx ; " " ; ny #m "up" case text #m "goto " ; ox ; " " ; oy #m "color " ; color$ #m "backcolor black" #m "down" #m "\" ; text$ #m "up" #m "goto " ; ox ; " " ; oy - spry #m "color " ; shadow$ #m "backcolor white" #m "down" #m "\" ; text$ #m "up" case triangle if tel = 3 then tel = 0 call tri x(0),y(0),x(1),y(1),x(2),y(2),color$ call tri x(0),y(0)-spry _ ,x(1),y(1)-spry,x(2),y(2)-spry,shadow$ end if case else end select wait sub swap byref a , byref b h = a a = b b = a end sub sub tri x1 , y1 , x2 , y2 , x3 , y3 , kl$ #m "color "; kl$ if y1 = y2 then y1 = y1 - 1e-10 if y2 = y3 then y3 = y3 + 1e-10 if y1 > y3 then call swap y1 , y3 call swap x1 , x3 end if if y1 > y2 then call swap y1 , y2 call swap x1 , x2 end if if y2 > y3 then call swap y2 , y3 call swap x2 , x3 end if for i = y1 to y3 a = x1 + ( x3 - x1 ) * (i-y1) / ( y3 - y1 ) if i < y2 then b = x1 + ( x2 - x1 ) * (i-y1) / ( y2 - y1 ) else b = x2 + ( x3 - x2 ) * (i-y2) / ( y3 - y2 ) end if #m "down" #m "line " ; a ; " " ; i ; " " ; b ; " " ; i #m "up" next i end sub [pixel] mode = pixel wait [line] mode = lijn wait [ellipse] mode = ellipse wait [ellipsefill] mode = ellipsefill wait [cellipse] mode = cellipse wait [cellipsefill] mode = cellipsefill wait [box] mode = box wait [boxfill] mode = boxfill wait [font] fontdialog font$ , font$ #m "font " ; font$ wait [text] prompt "text = " ; text$ mode = text wait [triangle] tel = 0 mode = triangle wait [remove] mode = remove wait [size] s$ = str$( size ) prompt "size = " ; s$ size = val( s$ ) #m "size " ; size wait [color] colordialog color$ , color$ wait [backcolor] colordialog backcolor$ , backcolor$ wait [shadow] colordialog shadow$ , shadow$ wait [new] file$ = DefaultDir$ + "\unnamed.bmp" #m "fill white" [x] x$ = str$( sprx ) prompt "X size ?" ; x$ sprx = val( x$ ) if sprx > winx then goto [x] [y] y$ = str$( spry ) prompt "Y size ?" ; y$ spry = val( y$ ) if spry > winy / 2 then goto [y] #m "goto " ; 0 ; " " ; spry + 1 #m "color black" #m "backcolor black" #m "down" #m "boxfilled " ; sprx ; " " ; spry * 2 #m "up" wait [open] filedialog "open bmp" , "*.bmp" , file$ loadbmp "bmp" , file$ #m "background bmp" wait [saveAs] filedialog "save bmp" , "*.bmp" , file$ [save] #m "getbmp bmp 0 0 " ; sprx ; " " ; spry * 2 bmpsave "bmp" , file$ wait [quit] close #m end
|
|