Re: CairoGraphics

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: CairoGraphics

Ken Treis
Hi Damien,

Yes it definitely works -- at least for me, on Mac OS X. Recent VMs  
from John McIntosh have the plugin already, though on the mac it only  
searches for libraries in a few select places and it doesn't accept  
absolute paths. Hopefully this will be resolved soon; for now I've  
symlinked the library into my  Squeak VM's plugins folder.

On Linux you may have to compile a VM yourself to get the plugin; I  
know it's in the VM source tree.

For a quick demo, try:

> |image cr backgroundGradient textGradient|
> image := CRImageSurface format: CRFormat argb32 extent: 300@200.
> cr := image context.
> backgroundGradient := CRLinearGradient from: 0@0 to: 150@200.
> backgroundGradient addStopAt: 0 color: Color white.
> backgroundGradient addStopAt: 1 color: Color lightGray.
> cr
> source: backgroundGradient;
> paint.
> cr moveTo: 30@100.
> cr
> selectFontFace: 'Sans';
> fontSize: 40.
> cr textPath: 'Hello, World!'.
> cr
> source: Color green;
> strokePreserve.
> textGradient := CRLinearGradient from: 0@50 to: 300@50.
> textGradient addStopAt: 0 color: Color blue alpha: 0.2.
> textGradient addStopAt: 1 color: Color blue alpha: 0.8.
> cr
> source: textGradient;
> fill.
> image writeToPng: '/Users/kdt/Desktop/hello.png'.
This isn't anything super exciting to look at, but if you've got the  
IA32ABI plugin and have set up CRLibrary class>>libraryPath to point  
to the Cairo library, you should be able to see the output (attached).  
I'll try to post a more impressive demo soon.


Ken

On Sep 25, 2009, at 2:08 AM, Damien Cassou wrote:

> Hi Ken,
>
> I'm going to have 4 students working during 4 months on Smalltalk. I
> would like to get a Cairo working implementation. What about
> yours/Travis'? What can we do with it? Can we draw something in Pharo?
> Does it work?
>
> Thank you
>
> --
> Damien Cassou
> http://damiencassou.seasidehosting.st
>
> "Lambdas are relegated to relative obscurity until Java makes them
> popular by not having them." James Iry
--
Ken Treis
Miriam Technologies, Inc.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

hello.png (17K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: CairoGraphics

Stéphane Ducasse
cool


On Sep 25, 2009, at 7:19 PM, Ken Treis wrote:

> Hi Damien,
>
> Yes it definitely works -- at least for me, on Mac OS X. Recent VMs  
> from John McIntosh have the plugin already, though on the mac it  
> only searches for libraries in a few select places and it doesn't  
> accept absolute paths. Hopefully this will be resolved soon; for now  
> I've symlinked the library into my  Squeak VM's plugins folder.
>
> On Linux you may have to compile a VM yourself to get the plugin; I  
> know it's in the VM source tree.
>
> For a quick demo, try:
>
>> |image cr backgroundGradient textGradient|
>> image := CRImageSurface format: CRFormat argb32 extent: 300@200.
>> cr := image context.
>> backgroundGradient := CRLinearGradient from: 0@0 to: 150@200.
>> backgroundGradient addStopAt: 0 color: Color white.
>> backgroundGradient addStopAt: 1 color: Color lightGray.
>> cr
>> source: backgroundGradient;
>> paint.
>> cr moveTo: 30@100.
>> cr
>> selectFontFace: 'Sans';
>> fontSize: 40.
>> cr textPath: 'Hello, World!'.
>> cr
>> source: Color green;
>> strokePreserve.
>> textGradient := CRLinearGradient from: 0@50 to: 300@50.
>> textGradient addStopAt: 0 color: Color blue alpha: 0.2.
>> textGradient addStopAt: 1 color: Color blue alpha: 0.8.
>> cr
>> source: textGradient;
>> fill.
>> image writeToPng: '/Users/kdt/Desktop/hello.png'.
>
> This isn't anything super exciting to look at, but if you've got the  
> IA32ABI plugin and have set up CRLibrary class>>libraryPath to point  
> to the Cairo library, you should be able to see the output  
> (attached). I'll try to post a more impressive demo soon.
>
>
> Ken
>
> On Sep 25, 2009, at 2:08 AM, Damien Cassou wrote:
>
>> Hi Ken,
>>
>> I'm going to have 4 students working during 4 months on Smalltalk. I
>> would like to get a Cairo working implementation. What about
>> yours/Travis'? What can we do with it? Can we draw something in  
>> Pharo?
>> Does it work?
>>
>> Thank you
>>
>> --
>> Damien Cassou
>> http://damiencassou.seasidehosting.st
>>
>> "Lambdas are relegated to relative obscurity until Java makes them
>> popular by not having them." James Iry
>
> --
> Ken Treis
> Miriam Technologies, Inc.
> <hello.png>_______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: CairoGraphics

Ken Treis
On Sep 25, 2009, at 10:57 AM, Stéphane Ducasse wrote:

> cool

For anyone who's been playing with this, I just posted another new  
revision of Alien that fixes the platform sizes to match C platform  
sizes. Not sure what I was thinking in the first go-around. Anyhow, if  
you load Alien-Core-kdt.58 in Pharo, you'll need to re-initialize Alien:

        Alien initialize

In other news, I've got CairoGraphics mostly working in GemStone  
(2.3.1) now too, running on top of an "Alien Lite" that provides  
support for the types of function calls I need to make. If anyone is  
interested in this, email me directly and I'll send you the code once  
I've worked out the remaining major bugs.


Ken

>
>
> On Sep 25, 2009, at 7:19 PM, Ken Treis wrote:
>
>> Hi Damien,
>>
>> Yes it definitely works -- at least for me, on Mac OS X. Recent VMs
>> from John McIntosh have the plugin already, though on the mac it
>> only searches for libraries in a few select places and it doesn't
>> accept absolute paths. Hopefully this will be resolved soon; for now
>> I've symlinked the library into my  Squeak VM's plugins folder.
>>
>> On Linux you may have to compile a VM yourself to get the plugin; I
>> know it's in the VM source tree.
>>
>> For a quick demo, try:
>>
>>> |image cr backgroundGradient textGradient|
>>> image := CRImageSurface format: CRFormat argb32 extent: 300@200.
>>> cr := image context.
>>> backgroundGradient := CRLinearGradient from: 0@0 to: 150@200.
>>> backgroundGradient addStopAt: 0 color: Color white.
>>> backgroundGradient addStopAt: 1 color: Color lightGray.
>>> cr
>>> source: backgroundGradient;
>>> paint.
>>> cr moveTo: 30@100.
>>> cr
>>> selectFontFace: 'Sans';
>>> fontSize: 40.
>>> cr textPath: 'Hello, World!'.
>>> cr
>>> source: Color green;
>>> strokePreserve.
>>> textGradient := CRLinearGradient from: 0@50 to: 300@50.
>>> textGradient addStopAt: 0 color: Color blue alpha: 0.2.
>>> textGradient addStopAt: 1 color: Color blue alpha: 0.8.
>>> cr
>>> source: textGradient;
>>> fill.
>>> image writeToPng: '/Users/kdt/Desktop/hello.png'.
>>
>> This isn't anything super exciting to look at, but if you've got the
>> IA32ABI plugin and have set up CRLibrary class>>libraryPath to point
>> to the Cairo library, you should be able to see the output
>> (attached). I'll try to post a more impressive demo soon.
>>
>>
>> Ken
>>
>> On Sep 25, 2009, at 2:08 AM, Damien Cassou wrote:
>>
>>> Hi Ken,
>>>
>>> I'm going to have 4 students working during 4 months on Smalltalk. I
>>> would like to get a Cairo working implementation. What about
>>> yours/Travis'? What can we do with it? Can we draw something in
>>> Pharo?
>>> Does it work?
>>>
>>> Thank you
>>>
>>> --
>>> Damien Cassou
>>> http://damiencassou.seasidehosting.st
>>>
>>> "Lambdas are relegated to relative obscurity until Java makes them
>>> popular by not having them." James Iry
>>
>> --
>> Ken Treis
>> Miriam Technologies, Inc.
>> <hello.png>_______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

--
Ken Treis
Miriam Technologies, Inc.


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: CairoGraphics

Fernando olivero
Hi Ken,

good improvements to Alien!

Are you are using Installer to load Alien? Would be better to put the  
Alien>>#initialize into a post Install method, does Installer have  
that? The AlienLoader does that, so your fixes should work.

What stuff is in Alien and not in "Alien Lite"?

Fernando


Il giorno Sep 26, 2009, alle ore 1:59 AM, Ken Treis ha scritto:

> On Sep 25, 2009, at 10:57 AM, Stéphane Ducasse wrote:
>
>> cool
>
> For anyone who's been playing with this, I just posted another new
> revision of Alien that fixes the platform sizes to match C platform
> sizes. Not sure what I was thinking in the first go-around. Anyhow, if
> you load Alien-Core-kdt.58 in Pharo, you'll need to re-initialize  
> Alien:
>
> Alien initialize
>
> In other news, I've got CairoGraphics mostly working in GemStone
> (2.3.1) now too, running on top of an "Alien Lite" that provides
> support for the types of function calls I need to make. If anyone is
> interested in this, email me directly and I'll send you the code once
> I've worked out the remaining major bugs.
>
>
> Ken
>
>>
>>
>> On Sep 25, 2009, at 7:19 PM, Ken Treis wrote:
>>
>>> Hi Damien,
>>>
>>> Yes it definitely works -- at least for me, on Mac OS X. Recent VMs
>>> from John McIntosh have the plugin already, though on the mac it
>>> only searches for libraries in a few select places and it doesn't
>>> accept absolute paths. Hopefully this will be resolved soon; for now
>>> I've symlinked the library into my  Squeak VM's plugins folder.
>>>
>>> On Linux you may have to compile a VM yourself to get the plugin; I
>>> know it's in the VM source tree.
>>>
>>> For a quick demo, try:
>>>
>>>> |image cr backgroundGradient textGradient|
>>>> image := CRImageSurface format: CRFormat argb32 extent: 300@200.
>>>> cr := image context.
>>>> backgroundGradient := CRLinearGradient from: 0@0 to: 150@200.
>>>> backgroundGradient addStopAt: 0 color: Color white.
>>>> backgroundGradient addStopAt: 1 color: Color lightGray.
>>>> cr
>>>> source: backgroundGradient;
>>>> paint.
>>>> cr moveTo: 30@100.
>>>> cr
>>>> selectFontFace: 'Sans';
>>>> fontSize: 40.
>>>> cr textPath: 'Hello, World!'.
>>>> cr
>>>> source: Color green;
>>>> strokePreserve.
>>>> textGradient := CRLinearGradient from: 0@50 to: 300@50.
>>>> textGradient addStopAt: 0 color: Color blue alpha: 0.2.
>>>> textGradient addStopAt: 1 color: Color blue alpha: 0.8.
>>>> cr
>>>> source: textGradient;
>>>> fill.
>>>> image writeToPng: '/Users/kdt/Desktop/hello.png'.
>>>
>>> This isn't anything super exciting to look at, but if you've got the
>>> IA32ABI plugin and have set up CRLibrary class>>libraryPath to point
>>> to the Cairo library, you should be able to see the output
>>> (attached). I'll try to post a more impressive demo soon.
>>>
>>>
>>> Ken
>>>
>>> On Sep 25, 2009, at 2:08 AM, Damien Cassou wrote:
>>>
>>>> Hi Ken,
>>>>
>>>> I'm going to have 4 students working during 4 months on  
>>>> Smalltalk. I
>>>> would like to get a Cairo working implementation. What about
>>>> yours/Travis'? What can we do with it? Can we draw something in
>>>> Pharo?
>>>> Does it work?
>>>>
>>>> Thank you
>>>>
>>>> --
>>>> Damien Cassou
>>>> http://damiencassou.seasidehosting.st
>>>>
>>>> "Lambdas are relegated to relative obscurity until Java makes them
>>>> popular by not having them." James Iry
>>>
>>> --
>>> Ken Treis
>>> Miriam Technologies, Inc.
>>> <hello.png>_______________________________________________
>>> Pharo-project mailing list
>>> [hidden email]
>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
> --
> Ken Treis
> Miriam Technologies, Inc.
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: CairoGraphics

Ken Treis
On Sep 26, 2009, at 3:21 AM, Fernando olivero wrote:

> Hi Ken,
>
> good improvements to Alien!

Thanks!

> Are you are using Installer to load Alien? Would be better to put the
> Alien>>#initialize into a post Install method, does Installer have
> that? The AlienLoader does that, so your fixes should work.

I'm not using Installer -- I suppose I should, but I'm currently just  
loading it from Monticello. For platform-specific sizes, I didn't do  
anything fancy because I think long-term this needs to be done by a  
primitive, perhaps at image startup.

> What stuff is in Alien and not in "Alien Lite"?

By "Alien Lite", I mean my little library of GemStone "UserActions"  
that implement just the bare minimum parts of Alien that I needed to  
get CairoGraphics working there. Maybe I should have called it "Alien  
Gaunt" or something.

It assumes all floats are double-precision, only supports integral and  
double return values, and has a ceiling on the number of integral and  
double arguments that can be passed to a function [1]. Also, "Alien  
Lite" has no mechanism for automatic freeing of Cairo handles when  
Smalltalk objects are collected. Oh, and it doesn't support callbacks  
yet either.

It's enough to make CairoGraphics work, but probably wouldn't be very  
useful for anything else at this point. I'm told that GemStone 3.0 is  
going to have a real FFI, so at that point it might make sense to  
create an Alien-ish layer on top of that.


Ken

[1] On x86_64, the first 6 integral arguments and the first 8 floating-
point arguments are passed in registers, with other values passed on  
the stack. None of the functions I'm using in CairoGraphics have blown  
over that limit, so I haven't implemented the stack allocation portion  
and thus there's a limit on the total number of each type of argument  
supported.

>
> Fernando
>
>
> Il giorno Sep 26, 2009, alle ore 1:59 AM, Ken Treis ha scritto:
>
>> On Sep 25, 2009, at 10:57 AM, Stéphane Ducasse wrote:
>>
>>> cool
>>
>> For anyone who's been playing with this, I just posted another new
>> revision of Alien that fixes the platform sizes to match C platform
>> sizes. Not sure what I was thinking in the first go-around. Anyhow,  
>> if
>> you load Alien-Core-kdt.58 in Pharo, you'll need to re-initialize
>> Alien:
>>
>> Alien initialize
>>
>> In other news, I've got CairoGraphics mostly working in GemStone
>> (2.3.1) now too, running on top of an "Alien Lite" that provides
>> support for the types of function calls I need to make. If anyone is
>> interested in this, email me directly and I'll send you the code once
>> I've worked out the remaining major bugs.
>>
>>
>> Ken
>>
>>>
>>>
>>> On Sep 25, 2009, at 7:19 PM, Ken Treis wrote:
>>>
>>>> Hi Damien,
>>>>
>>>> Yes it definitely works -- at least for me, on Mac OS X. Recent VMs
>>>> from John McIntosh have the plugin already, though on the mac it
>>>> only searches for libraries in a few select places and it doesn't
>>>> accept absolute paths. Hopefully this will be resolved soon; for  
>>>> now
>>>> I've symlinked the library into my  Squeak VM's plugins folder.
>>>>
>>>> On Linux you may have to compile a VM yourself to get the plugin; I
>>>> know it's in the VM source tree.
>>>>
>>>> For a quick demo, try:
>>>>
>>>>> |image cr backgroundGradient textGradient|
>>>>> image := CRImageSurface format: CRFormat argb32 extent: 300@200.
>>>>> cr := image context.
>>>>> backgroundGradient := CRLinearGradient from: 0@0 to: 150@200.
>>>>> backgroundGradient addStopAt: 0 color: Color white.
>>>>> backgroundGradient addStopAt: 1 color: Color lightGray.
>>>>> cr
>>>>> source: backgroundGradient;
>>>>> paint.
>>>>> cr moveTo: 30@100.
>>>>> cr
>>>>> selectFontFace: 'Sans';
>>>>> fontSize: 40.
>>>>> cr textPath: 'Hello, World!'.
>>>>> cr
>>>>> source: Color green;
>>>>> strokePreserve.
>>>>> textGradient := CRLinearGradient from: 0@50 to: 300@50.
>>>>> textGradient addStopAt: 0 color: Color blue alpha: 0.2.
>>>>> textGradient addStopAt: 1 color: Color blue alpha: 0.8.
>>>>> cr
>>>>> source: textGradient;
>>>>> fill.
>>>>> image writeToPng: '/Users/kdt/Desktop/hello.png'.
>>>>
>>>> This isn't anything super exciting to look at, but if you've got  
>>>> the
>>>> IA32ABI plugin and have set up CRLibrary class>>libraryPath to  
>>>> point
>>>> to the Cairo library, you should be able to see the output
>>>> (attached). I'll try to post a more impressive demo soon.
>>>>
>>>>
>>>> Ken
>>>>
>>>> On Sep 25, 2009, at 2:08 AM, Damien Cassou wrote:
>>>>
>>>>> Hi Ken,
>>>>>
>>>>> I'm going to have 4 students working during 4 months on
>>>>> Smalltalk. I
>>>>> would like to get a Cairo working implementation. What about
>>>>> yours/Travis'? What can we do with it? Can we draw something in
>>>>> Pharo?
>>>>> Does it work?
>>>>>
>>>>> Thank you
>>>>>
>>>>> --
>>>>> Damien Cassou
>>>>> http://damiencassou.seasidehosting.st
>>>>>
>>>>> "Lambdas are relegated to relative obscurity until Java makes them
>>>>> popular by not having them." James Iry
>>>>
>>>> --
>>>> Ken Treis
>>>> Miriam Technologies, Inc.
>>>> <hello.png>_______________________________________________
>>>> Pharo-project mailing list
>>>> [hidden email]
>>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>>
>>>
>>> _______________________________________________
>>> Pharo-project mailing list
>>> [hidden email]
>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>> --
>> Ken Treis
>> Miriam Technologies, Inc.
>>
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

--
Ken Treis
Miriam Technologies, Inc.


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project