<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">So, it’s a very simple almost one-to-one translation of that C code block to Swift.<div class="">You have to make sure to <font face="Menlo" class="">import&nbsp;CCairo</font>&nbsp;at the beginning of the file, and change the variable declarations to use <font face="Menlo" class="">let</font>&nbsp;instead of the C declaration.</div><div class=""><br class=""></div><div class="">This works for me, as is.<br class=""><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">import CCairo</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">let surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 240, 80)</font></div><div class=""><font face="Menlo" class="">let cr = cairo_create (surface);</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">cairo_select_font_face(cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD)</font></div><div class=""><font face="Menlo" class="">cairo_set_font_size(cr, 32.0)</font></div><div class=""><font face="Menlo" class="">cairo_set_source_rgb(cr, 0.0, 0.0, 1.0)</font></div><div class=""><font face="Menlo" class="">cairo_move_to(cr, 10.0, 50.0)</font></div><div class=""><font face="Menlo" class="">cairo_show_text(cr, "Hello, world")</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">cairo_destroy(cr)</font></div><div class=""><font face="Menlo" class="">cairo_surface_write_to_png(surface, "hello.png")</font></div><div class=""><font face="Menlo" class="">cairo_surface_destroy(surface)</font></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Dec 11, 2015, at 3:21 PM, Gage Morgan &lt;<a href="mailto:gagemorgan@outlook.com" class="">gagemorgan@outlook.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">

<div class="">
<div class="">Do so here in a few. Want a bug report for that?<br class="">
<br class="">
<div class="acompli_signature">Sent from <a href="https://aka.ms/qtex0l" class="">Outlook Mobile</a></div>
<br class="">
</div>
<br class="">
<br class="">
<br class="">
<div class="gmail_quote">On Fri, Dec 11, 2015 at 12:08 PM -0800, "Harlan Haskins"
<span dir="ltr" class="">&lt;<a href="mailto:harlan@harlanhaskins.com" target="_blank" class="">harlan@harlanhaskins.com</a>&gt;</span> wrote:<br class="">
<br class="">
</div>
<div class="" style="word-wrap:break-word">Mind sending your CCairo modulemap?
<div class=""><br class="">
</div>
<div class="">I’d love to help you get this translated to Swift.</div>
<div class=""><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On Dec 11, 2015, at 2:44 PM, Gage Morgan via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div>
<br class="x_Apple-interchange-newline">
<div class="">
<div class="">
<div class="">I want to call PNG surfaces from Swift, as well as use cairo_line_to() and cairo_move_to() in Swift. Thing is, I need an example of cairo used in Swift so I can apply it to the rest of cairo.&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">My goal is to generate an executable that outputs *.png images using swift.&nbsp;</div>
<div class=""><br class="">
</div>
<div class="">Thanks for the support,</div>
<div class="">--MGage--<br class="">
<br class="">
<div class="x_acompli_signature">Sent from <a href="https://aka.ms/qtex0l" class="">
Outlook Mobile</a></div>
<br class="">
</div>
<br class="">
<br class="">
<br class="">
<div class="x_gmail_quote">On Thu, Dec 10, 2015 at 10:40 PM -0800, "Jason Dusek" <span dir="ltr" class="">
&lt;<a href="mailto:jason.dusek@gmail.com" target="_blank" class="">jason.dusek@gmail.com</a>&gt;</span> wrote:<br class="">
<br class="">
</div>
<div class="">
<div dir="ltr" class="">When you say, output to Swift, do you mean, call it from Swift? Return the PNG or surface to Swift?</div>
<br class="">
<div class="x_x_gmail_quote">
<div dir="ltr" class="">On Thu, 10 Dec 2015 at 22:39 Gage Morgan via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class="">
</div>
<blockquote class="x_x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div class="">
<div dir="ltr" class="">So, if I had this code written in C:
<div class=""><br class="">
</div>
<div class="">
<pre class="" style="font-family:mono; margin-left:124.281px; margin-right:124.281px; border:1px solid rgb(197,197,246); padding:0.5em; font-size:inherit; background-color:rgb(219,219,247)"><code class="">int
main (int argc, char *argv[])
{
        cairo_surface_t *surface =
            cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 80);
        cairo_t *cr =
            cairo_create (surface);

        cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
        cairo_set_font_size (cr, 32.0);
        cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
        cairo_move_to (cr, 10.0, 50.0);
        cairo_show_text (cr, "Hello, world");

        cairo_destroy (cr);
        cairo_surface_write_to_png (surface, "hello.png");
        cairo_surface_destroy (surface);
        return 0;
}</code></pre>
</div>
<div class=""><br class="">
</div>
<div class="">how would I output to Swift? If I can get one or two examples, I'll be closer to finished with using Cairo in Swift.</div>
<div class=""><br class="">
</div>
</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=kKLYQ91ZFOe6ryzRU3CXyiq4yOweT6LjPwa6z8Qwa5fRJQvehCW7UCK-2BbJEgYqk9ymhv1Wllv6abHreSdhPig42FLfYVbgr7JKJ7hY1Q7iq3tkkkIpLj1sxjm0TOLD4CC06I9rFJKGqidW9EjUhQCrGd33ergA7MqltYs6YCP9DldpA78aN2AZ7es5uc68BVL57Z7AvFLHnyE3-2BiYRej3Eg-2BkjZ9JyB4s-2F4sOp6rJ8M-3D" alt="" width="1" height="1" border="0" class="" style="min-height:1px!important; width:1px!important; border-width:0!important; margin-top:0!important; margin-bottom:0!important; margin-right:0!important; margin-left:0!important; padding-top:0!important; padding-bottom:0!important; padding-right:0!important; padding-left:0!important">
</div>
_______________________________________________<br class="">
swift-users mailing list<br class="">
<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="">
</blockquote>
</div>
</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=z0Ft8gvIaLt1zLwfkl4og6osLD9N8tlWJY1PY2zqWLUkHnPRqf22JfuLA5kPDXFPz8S7wT7SESan5AK-2BA-2F8xvy8No6VDuVOQrToOpIS1jKsflmvk861zymvyZDLaeAmh2bGY5Av42mn-2FxzfrwFx-2F7gO8nRl5f8mR4dSLpnAQIV-2FG-2FG9l5eYt5k5bLM4UlqqyInn9oqnAGfMS-2FStYfLW9ElxFJF6nrTW-2FSbOo3A-2BW6B0-3D" alt="" width="1" height="1" border="0" class="" style="height:1px!important; width:1px!important; border-width:0!important; margin-top:0!important; margin-bottom:0!important; margin-right:0!important; margin-left:0!important; padding-top:0!important; padding-bottom:0!important; padding-right:0!important; padding-left:0!important">
</div>
_______________________________________________<br class="">
swift-users mailing list<br class="">
<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>

</div></blockquote></div><br class=""></div></div></body></html>