![]() If StartDrawing(ImageOutput(hShadow1)) Start drawing onto the new image, you can only draw on one image per time. Global hShadow1 = NewImageOrEnd(#PB_Any, 500, 15, 32|#PB_Image_Transparent) Create a new image of Width(500) and Height(100) or kill the application StopDrawing() Stop drawing, very important. Don't forget using StopDrawing!īox(0,0,500,100,0) Draw a black box onto the image, later when the image will be drawn, the opacity will be set. If StartDrawing(ImageOutput(hImageTrans)) Start drawing onto the new image, you can only draw on one image per time. ![]() Global hImageTrans = NewImageOrEnd(#PB_Any, 500, 100) Create a new image of Width(500) and Height(100) or kill the application ProcedureReturn hImage It was a success if it got here, returning the newly created imagehandle/result. If Not hImage The image is not successfully created.Įnd End the application at this point, discontinue execution. Protected hImage = CreateImage(Image,Width,Height,Depth) Attempt creating the new image. ![]() Procedure NewImageOrEnd(Image, Width, Height, Depth = 24) A procedure I'm using to instantly kill the application if a image files to be created. ProcedureReturn Random(Max-Min)+Min Calculating the random number using a minimum and maximum value and returning it as a quad (Procedure.q) Procedure.q RandomEx(Min.q,Max.q) PB's default 'Random' function does not allow a Minimum value. Protected TY = ((Height/2)-(TH/2)+MarginY) Calculate the center Y position of the text.ĭrawText(TX,TY,Text, Color) Eventually drawing the text. Protected TX = ((Width/2 )-(TW/2)+MarginX) Calculate the center X position of the text. Protected TH = TextHeight(Text) Get the height the text will be. Protected TW = TextWidth (Text) Get the width the text will be. Procedure DrawTextCentered(Text.s, Width, Height, MarginX, MarginY, Color) A procedure to draw text centered within a range, allowing you to set a negative/positive margin as well. Variable names, macrofy statements and keywords and you'll get realĬode: Simple example regarding drawing onto a screen handle. The code and use the macro's instead of the original names. You can replace all newlines with a colon (. Oh, and feel free to post something too, I'd be interested! ![]() The normal sourcecode is 146 lines long, this one (the code) is 29 lines! XD #See attached image for a preview of what's going to happen. M SCS:Select:EO#M:M SCE:EndSelect:EO#M:M RPT:Repeat:EO#M:M UTL:Until:EO#M:M FRV:ForEver:EO#M # PE:PS NOE(I,W,H,D=24):PT iH=CreateImage(I,W,H,D):SI Not iH:End:SE:PR iH:PE:M IIN:If Not:EO#M # M LF:LoadFont:EO#M:M DAI:DrawAlphaImage:EO#M:M LXY:LineXY:EO#M:M DMTR:DrawingMode(1):EO#M # Macro RGC:ResetGradientColors():EndMacro:M SGC:GradientColor:EO#M:M LGG:LinearGradient:EO#M # M PT:Protected:EO#M:M PR:ProcedureReturn:EO#M:M GL:Global:EO#M:M SI:If:EO#M:M SE:EndIf #ĮndMacro:M STO(I):StartDrawing(ImageOutput(I)):EO#M:M SD:StopDrawing():EO#M:M IID(I) # M PS:Procedure:EndMacro:M PE:EndProcedure:EndMacro:M R(N):Random(N):EO#M:#PA=#PB_Any # Code: Macro M:Macro:EndMacro:Macro EO:End:EndMacro:M EMS():ElapsedMilliseconds():EndMacro #
0 Comments
Leave a Reply. |