Jump to content

Cairo 2D graphics library build 2024-04-02 alpha


 Share

Recommended Posts

The functions are added but the created PDF is currently empty. When I found a way to create working PDFs I will post it.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Posted (edited)

This seems to work but you need libcairo-2.dll which can be found also on my OneDrive (x86 / x64 folders).

;Coded by UEZ build 2024-04-02 beta
#AutoIt3Wrapper_UseX64=n

#include "..\Cairo.au3"

Cairo_Example()

Func Cairo_Example()
    If Not Cairo_Init("libcairo-2.dll") Then
        ConsoleWrite(@error & @CRLF)
        Exit
    EndIf
    If FileExists("Example.pdf") Then FileDelete("Example.pdf")

    Local $MM_TO_PT = 72.0 / 25.4, $PAGE_WIDTH_A5 = 148, $PAGE_HEIGHT_A5 = 210, $PAGE_WIDTH_A4 = 210, $PAGE_HEIGHT_A4 = 297
    Local Const $pSurface = Cairo_PDF_Create("Example.pdf", $PAGE_WIDTH_A5 * $MM_TO_PT, $PAGE_HEIGHT_A5 * $MM_TO_PT)
    Cairo_PDF_RestrictToVersion($pSurface, $CAIRO_PDF_VERSION_1_4)
    Local Const $pContext = Cairo_Context_Create($pSurface)
    Cairo_Context_SetLineWidth($pContext, 6)
    Cairo_Context_PathAddRectangle($pContext, 12, 12, 232,70)
    Cairo_Context_PathBeginNewSub($pContext)
    Cairo_Context_PathAddArc($pContext, 64, 64, 40, 0, ACos(-1) * 2)
    Cairo_Context_PathBeginNewSub($pContext)
    Cairo_Context_PathAddArcNegative($pContext, 192, 64, 40, 0, -ACos(-1) * 2)

    Cairo_Context_SetFillRule($pContext, $CAIRO_FILL_RULE_EVEN_ODD)
    Cairo_Context_SetSourceRGB($pContext, 0, 0.7, 0)
    Cairo_Context_FillPreserve($pContext)
    Cairo_Context_SetSourceRGB($pContext, 0, 0, 0)
    Cairo_Context_Stroke($pContext)

    Cairo_Context_Translate($pContext, 0, 128)
    Cairo_Context_PathAddRectangle($pContext, 12, 12, 232,70)
    Cairo_Context_PathBeginNewSub($pContext)
    Cairo_Context_PathAddArc($pContext, 64, 64, 40, 0, ACos(-1) * 2)
    Cairo_Context_PathBeginNewSub($pContext)
    Cairo_Context_PathAddArcNegative($pContext, 192, 64, 40, 0, -ACos(-1) * 2)

    Cairo_Context_SetFillRule($pContext, $CAIRO_FILL_RULE_WINDING)
    Cairo_SetColor($pContext, 0, 0, 0.9)
    Cairo_Context_FillPreserve($pContext)
    Cairo_SetColor($pContext, 0, 0, 0)
    Cairo_Context_Stroke($pContext)

    Cairo_Context_PathClear($pContext)
    Cairo_Context_PathAddMoveTo($pContext, 40, 150)
    Cairo_Font_SelectFace($pContext)
    Cairo_Font_SetSize($pContext, 30)
    Cairo_Context_PathAddText($pContext, "PDF Example")
    Cairo_SetColor($pContext, 0.9, 0, 0, 1)
    Cairo_Context_FillPreserve($pContext)
    Cairo_SetColor($pContext, 0, 0, 0.1, 0.5)
    Cairo_Context_SetLineWidth($pContext, 1.5)
    Cairo_Context_Stroke($pContext)

    Cairo_Surface_Finish($pSurface)
    Cairo_Surface_Flush($pSurface)
    
    ConsoleWrite(Cairo_Surface_GetStatus($pSurface) & @CRLF)
    Cairo_Context_Destroy($pContext)
    Cairo_Surface_Destroy($pSurface)
    Cairo_Close()
    ConsoleWrite(FileGetSize("Example.pdf") & @CRLF)
EndFunc

 

I seems that the Cairo.dll / Cairo64.dll doesn't work properly with PDF creation...

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...