Page 5 of 5

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Sun May 17, 2015 2:51 am
by IdeasVacuum
Another font thing of interest. A few fonts (out of many) fail gSetFont()
Debug:

Code: Select all

ERROR: gSetFont() with FontName$ 'Sonic XBd BT Extra' failed
What I would like to do is to parse my list of font names and remove the ones that will fail, so that the list I present on the app window are all good to go. I have butchered a portion of code from gDrawing.pbi:

Code: Select all

Procedure ChkFontList()
;----------------------
;Unicode compile
Protected fs, *fontFamily, *font, *fontName
Protected iLen.i, sTmp.s

              ForEach gFontList()

                  iLen = Len(gFontList()\sFaceName)
                  sTmp = Space((iLen * 2) + 2)
                  PokeS(@sTmp,gFontList()\sFaceName,-1,#PB_Unicode)
                  *fontName = @sTmp

                       If GdipCreateFontFamilyFromName_(*fontName, 0, @*fontFamily)

                              DeleteElement(gFontList())
                       Else
                              GdipDeleteFontFamily_(*fontFamily)
                       EndIf
              Next
EndProcedure
Is this Procedure OK? It seems to work very well..........

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Sat May 23, 2015 11:41 pm
by IdeasVacuum
Me again

What is the GDI+ equiverlent to PB's FillArea()?

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Sun May 24, 2015 12:23 am
by netmaestro
GdipFillPolygon should do the trick. If you need a sample, just holler and I'll post one otherwise good luck.

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Sun May 24, 2015 4:42 am
by IdeasVacuum
..... thanks Netmaestro. I actually solved it by drawing Polys, they are 'auto filled' if gDrawingMode(#PB_2DDrawing_Default)

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Wed Jun 24, 2015 8:11 am
by [blendman]
Danilo wrote:What are external thoughts/wishes about 'gDrawing2'?

Thoughts/wishes about compatibility (OS, command set, ...), supported Operating Systems,
about coding style (procedural vs. object-oriented), feature requests, or anything else...?
I'm open to suggestions.

(Personal Message and Public Message accepted)
Hi

I would like to know if it's possible to draw stroke with brush image.
1) we draw on the canvas, with an image to use (like we use drawalphaimage())
2) between the "dots", it create the stroke (line), with a space we can change and define
3) the curve stroke we have get could be "smoothed" (it's not ok on my picture)
4) it could be great to have the pressure tablet (wacom or other) :)

Example of those features :
Image


Operating system
- is it possible to have an equivalent of gdrawing for linux (some features at least) ?

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Fri Jul 24, 2015 4:04 pm
by troff
this is a really neat library!

as i learn to use it, can anybody may be tell me how the following is done:

1.) i have a world of 0..1000 pixels
2.) the origin should be 500,500, so that one can draw negative values
3.) the coordinate system should be cartesian

how is this done?

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Fri Jul 24, 2015 4:38 pm
by IdeasVacuum
you can do that with PB's 2D Drawing command
SetOrigin(x, y)

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Fri Jul 24, 2015 4:47 pm
by Danilo
troff wrote:this is a really neat library!

as i learn to use it, can anybody may be tell me how the following is done:

1.) i have a world of 0..1000 pixels
2.) the origin should be 500,500, so that one can draw negative values
3.) the coordinate system should be cartesian

how is this done?
Use gSetOrigin(x.f,y.f)

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Fri Jul 24, 2015 5:34 pm
by troff
hi,

i tried that and it works the first time, but ever other time using like arc, line, ellipse etc gSetOrigin seems to get reset - all lines etc will start left, top corner.
how does one do the transforms/translations for something like that?
is there a way to set the coordinate system to x,y lower left and back if needed?

thanks so far

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Fri Jul 24, 2015 5:58 pm
by Danilo
gSetOrigin() only starts fresh after gStartDrawing(), so if you use

Code: Select all

if gStartDrawing(....)
    gSetOrigin( OutputWidth()*0.5, OutputHeight()*0.5 )
    ; drawing commands
    gStopDrawing()
EndIf
it should work for all used drawing commands (lines, arc, ..).

Using gStartTransform() + gStopTransform() is for push/pop the current transformations state,
for use with local transforms, and recursive transformations.

Unfortunately my (6-7 years old) Windows PC hardware died 3 days ago, so I currently have only the MacMini with OS X and
can't test anything Windows-related. Ordered a new Mac Pro immediately, but it will take another 3-4 work days for arrival,
and I guess it will take a week from now on to have Windows 10 running. I am sorry for that, the death of the old PC was predictable -
I just thought I use it as long as it still works. ;)

Moving x,y to lower left with having +y go up (like Mac), is probably possible using some Matrix transforms like
flipping/mirroring. Not easy without the ability to simply test it, sorry. Maybe you can show some simple code snippets
of what you are doing, or somebody who can actually test it is able to help you immediately.

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Sun Oct 11, 2015 7:11 am
by applePi
My first try with this lib, thanks Danilo
Image

Code: Select all

XIncludeFile "gDrawing.pbi"

    
    Global Dim poly.POINTF(3)
   ;the body
   poly(0)\X =110;      /* first vertex */
   poly(0)\Y = 114;
   poly(1)\X = 322;    /* second vertex */
   poly(1)\Y = 114;
   poly(2)\X = 322;    /* third vertex */
   poly(2)\Y = 148;
   poly(3)\X = poly(0)\x;      /*  close the polygon */
   poly(3)\Y = poly(0)\y  
   
   Global Dim poly2.POINTF(4)
   ;uppper propeller
   poly2(0)\x =255;           /* first vertex */
   poly2(0)\y = 35;
   poly2(1)\x = 388;    /* second vertex */
   poly2(1)\y = 71;
   poly2(2)\x = 490;    /* third vertex */
   poly2(2)\y = 51
   poly2(3)\x = 158
   poly2(3)\y = 55
   poly2(4)\x = poly2(0)\x    
   poly2(4)\y = poly2(0)\y;    /* close the polygon */
   
   Global Dim poly3.POINTF(4)
   ;rear propeller
   poly3(0)\x = 109;           /* first vertex */
   poly3(0)\y = 78;
   poly3(1)\x = 108;    /* second vertex */
   poly3(1)\y = 151;
   poly3(2)\x = 121;    /* third vertex */
   poly3(2)\y = 125
   poly3(3)\x = 97
   poly3(3)\y = 103
   poly3(4)\x = poly3(0)\x    
   poly3(4)\y = poly3(0)\y;   /* close the polygon */


Procedure Draw()
    
    gDrawingMode(#PB_2DDrawing_Default)
    
    gSetPenSize(1)
    
    gSetPenColor(RGBA(255,0,0,$FF))
    gSetPenPattern(4,RGBA(255,0,0,$FF),RGBA(255,200,0,$FF))
    ;rear chamber (with pattern)
    gPie(322,114,60,60,180,90)
    gSetPenColor(RGBA(255,255,0,$FF))
    ;yellow bottom chamber
    gPie(322,114,40,35,0,90)
    
    
    gPoly(poly(),RGBA(105,0,255,$FF))
    gPoly(poly2(),RGBA($00,$FF,$00,$FF))
    gPoly(poly3(),RGBA($00,$FF,$00,$FF))
    
    gSetPenSize(3)
    gSetPenColor(RGBA(255,215,0,$FF))
    gArc(322,110,40,55,-90,97); pilot front wind shield
    
    gCircle(322,148,12,RGBA($00,$FF,$00,$FF)) ; wheel
    gCircle(322,148,6,RGBA($00,$00,$00,$FF))
        
EndProcedure

If gInit()
    mainWin = OpenWindow(#PB_Any,0,0,800,600,"gDrawing: Helicopter for vacations",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
    img = CreateImage(#PB_Any,800,600,24)
    If gStartDrawing( ImageOutput(img) )
        gClear( RGBA($AA,$AA,$AA,$FF) )
        Draw()
        gStopDrawing()
      EndIf
      
      imgWin  = ImageGadget(#PB_Any,0,0,800,600,ImageID(img))
    
    Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
    gEnd()
EndIf

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Mon Dec 28, 2015 3:15 am
by IdeasVacuum
Would be good to save image files, especially those, such as gif, not supported by PB.

GdipCreateBitmapFromFile(filename.p-unicode, *bitmap)

GdipSaveImageToFile(image, filename.p-unicode, *clsidEncoder.CLSID, *encoderParams)

sRod code snippet

Re: [Windows] 2DDrawing commands with AntiAliasing through G

Posted: Wed Dec 30, 2015 5:32 pm
by Danilo
IdeasVacuum wrote:Would be good to save image files, especially those, such as gif, not supported by PB.
Sorry, I don't use Windows anymore, at least currently. Feel free to take over the project - it comes with all sources,
and I don't restrict the use in any way. All my codes and contributions are without any restrictions. It's 'Public Domain'.