--macroScript MicroPaint category: "HowTo" ( global MicroPaint_CanvasRollout try (destroyDialog MicroPaint_CanvasRollout) catch() local isDrawing = false local bitmapX = bitmapY = 512 global theCanvasBitmap = bitmap bitmapX bitmapY color:white local currentPos = lastPos = [0,0] rollout MicroPaint_CanvasRollout "MicroPaint" ( bitmap theCanvas pos:[0,0] width:bitmapX height:bitmapY bitmap:theCanvasBitmap colorpicker inkColor height:16 modal:false color:black across:4 checkbutton airBrush "AirBrush"width:50 spinner AirBrushSpeed "Speed" range:[0.1,50,10] fieldwidth:30 spinner BrushSize "Size" range:[1,50,10] type:#integer fieldwidth:40 listbox BrushShape items:#("Circle","Box","Circle Smooth") pos:[bitmapX+5,0] width:90 dotNetControl f1 "Windows.Forms.PictureBox" align:#left height:bitmapY width:bitmapX pos:[bitmapX+100,0] fn paintBrush pos = ( case BrushShape.selection of ( 1: ( if distance pos currentPos <= BrushSize.value/2 do setPixels theCanvasBitmap pos #(inkColor.color) ) 2: setPixels theCanvasBitmap pos #(inkColor.color) 3: ( theFactor = (distance pos currentPos) / (BrushSize.value/2.0) if theFactor <= 1.0 do ( theFactor = sin ( 90.0 * theFactor) thePixels = getPixels theCanvasBitmap pos 1 if thePixels[1] != undefined do ( thePixels[1] = (thePixels[1] * theFactor) + (inkColor.color * (1.0 - theFactor)) setPixels theCanvasBitmap pos thePixels ) ) )--end case 3 )--end case )--end fn fn drawStroke lastPos pos = ( currentPos = lastPos deltaX = pos.x - lastPos.x deltaY = pos.y - lastPos.y maxSteps = amax #(abs(deltaX),abs(deltaY)) deltaStepX = deltaX / maxSteps deltaStepY = deltaY / maxSteps for i = 0 to maxSteps do ( if airBrush.checked then ( for b = 1 to (BrushSize.value / AirBrushSpeed.value) do paintBrush (currentPos + (random [-BrushSize.value/2,-BrushSize.value/2] [BrushSize.value/2,BrushSize.value/2] )) ) else for b = -BrushSize.value/2 to BrushSize.value/2 do for c = -BrushSize.value/2 to BrushSize.value/2 do paintBrush (currentPos + [c,b]) currentPos += [deltaStepX, deltaStepY] ) theCanvas.bitmap = theCanvasBitmap /* local grab_bmp1 grab_bmp1 = bitmap 512 512 color:white copy theCanvasBitmap grab_bmp1 grab_bmp1.filename ="D:\\Desktop\\123.png" save grab_bmp1 f1.ImageLocation="D:\\Desktop\\123.png" */ ) on MicroPaint_CanvasRollout lbuttondown pos do ( lastPos = pos isDrawing = true drawStroke lastPos pos ) on MicroPaint_CanvasRollout lbuttonup pos do isDrawing = false on MicroPaint_CanvasRollout mousemove pos do ( if isDrawing do drawStroke lastPos pos lastPos = pos ) ) createDialog MicroPaint_CanvasRollout (bitmapx+620) (bitmapy+30) ) /* clearlistener(); showProperties MicroPaint_CanvasRollout.f1 MicroPaint_CanvasRollout.f1.ImageLocation="D:\\Desktop\\123.png" show MicroPaint_CanvasRollout.theCanvas.bitmap -- MicroPaint_CanvasRollout.f1.image= (dotnetclass "System.Drawing.Graphics").FromImage */