Doodling with Cairo...

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

Doodling with Cairo...

Stew MacLean

Hi,

 

I’ve been experimenting with the various Cairo bits and pieces trying to figure out how to get a nice looking tree/UI – some interesting stuff! (thanks for the previous pointers, everyone).

 

One of which is the Gizmo – which on first impression I wondered what’s with all these pink rectangles?

 

But delving deeper it looks like a pretty cool open ended framework – I’ve been experimenting with nesting and it sort of works, but not sure if I’m configuring it correctly.

 

The Cairo Wrapper Kit is a piece of art, but I’m struggling to get my head around it – wrapper hell?

 

Anyway, I was wondering where the “Doodle Layout Algorithm” came from? – all I can find are references to a constraint based object visualization system from the mid 90’s.

 

BTW, I know Smalltalk is generally self documenting code, but some “big picture” class/package documentation with these lovely experiments would make them a lot more accessible!

 

Cheers,

 

Stewart

 

 

Gizmo>>layoutFromIndex: index

            "** The Doodle Layout Algorithm **

1) Use desiredLayoutBlock to find out what we want as our bounds inside the availableExtent given to us. Store this in @desired.

2) Figure out what extent we want to offer our children based on our @desired bounds. Store this in @offered.

            @desired may contain a width/height of BlockClosure. In this case, we offer the

            available space for that dimension to our children

3) Offer the @offered space to each child, storing their @requested space

4) Keep a record of the @maximum extent that our children reach inside us so that we can decide how to clip correctly.

5) <pluggable> Use our child layout algorithm to position and size the @requested space as the @bounds of the child

6) Return our @desired bounds to our parent as a requested space replacing any BlockClosure with details from our children's @maximum extent.

."

 

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Doodling with Cairo...

Michael Lucas-Smith-2
Hi Stewart,

Gizmo was just something Travis Griggs and I made to experiment with CairoGraphics. We wanted to see how it would perform, what kinds of issues we might run in to using Cairo resources in widgets, that sort of thing.

The doodle layout algorithm is a variant of the CSS layout algorithm, significantly simplified, by me as a way to avoid having to do a full on layout algorithm but still get the majority of what we needed to experimenting. This approach to layout is not the future for the UI, we have other plans there using a constraint based solver that has been proven in production code both in Smalltalk and in other languages.

As an experiment, it was a complete success - we sold ourselves on the idea that Cairo was completely viable for our customers to use for this kind of work (ie: custom widgets) and potentially for doing the core widgets too. Some of the people in the community have gone even further, making graphics contexts that use CairoGraphics and whole suits of widgets. It's inspiring and very cool.

So, you've stumbled upon some of the humble beginnings - I frankly didn't realise we'd put that stuff in the open repository, I thought we'd left it in our private repository. Have fun with it if you want.. somewhere in there is my fancy clock that moves the numbers instead of the clock hands and also a Dr. Who animation.

Cheers,
Michael

On 10/01/2008, at 2:34 AM, Stewart MacLean <[hidden email]> wrote:

Hi,

 

I’ve been experimenting with the various Cairo bits and pieces trying to figure out how to get a nice looking tree/UI – some interesting stuff! (thanks for the previous pointers, everyone).

 

One of which is the Gizmo – which on first impression I wondered what’s with all these pink rectangles?

 

But delving deeper it looks like a pretty cool open ended framework – I’ve been experimenting with nesting and it sort of works, but not sure if I’m configuring it correctly.

 

The Cairo Wrapper Kit is a piece of art, but I’m struggling to get my head around it – wrapper hell?

 

Anyway, I was wondering where the “Doodle Layout Algorithm” came from? – all I can find are references to a constraint based object visualization system from the mid 90’s.

 

BTW, I know Smalltalk is generally self documenting code, but some “big picture” class/package documentation with these lovely experiments would make them a lot more accessible!

 

Cheers,

 

Stewart

 

 

Gizmo>>layoutFromIndex: index

            "** The Doodle Layout Algorithm **

1) Use desiredLayoutBlock to find out what we want as our bounds inside the availableExtent given to us. Store this in @desired.

2) Figure out what extent we want to offer our children based on our @desired bounds. Store this in @offered.

            @desired may contain a width/height of BlockClosure. In this case, we offer the

            available space for that dimension to our children

3) Offer the @offered space to each child, storing their @requested space

4) Keep a record of the @maximum extent that our children reach inside us so that we can decide how to clip correctly.

5) <pluggable> Use our child layout algorithm to position and size the @requested space as the @bounds of the child

6) Return our @desired bounds to our parent as a requested space replacing any BlockClosure with details from our children's @maximum extent.

."

 

 

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Doodling with Cairo...

Stew MacLean

Hi Michael,

 

Thanks for making Gizmo available – I’ve discovered the clocks, and have experimented with nesting them – quite funky seeing the Dr Who, alongside yours and Travis’ clock in one window.

 

I was wondering whether you could provide a few more details on “we have other plans there using a constraint based solver that has been proven in production code both in Smalltalk and in other languages.”? Sounds interesting…

 

Yeah, it is inspiring what people have done with Cairo in VW. I’ve been working through various examples/frameworks etc trying to get my head around it all. I’m now trying to apply it to develop my own cool looking UI. A lot of work, but experiments etc such as yours and others are a great help – thanks.

 

Cheers,

Stewart

 

-----Original Message-----
From: Michael Lucas-Smith [mailto:[hidden email]]
Sent: 24 July 2013 10:31 p.m.
To: [hidden email]
Cc: [hidden email]
Subject: Re: [vwnc] Doodling with Cairo...

 

Hi Stewart,

 

Gizmo was just something Travis Griggs and I made to experiment with CairoGraphics. We wanted to see how it would perform, what kinds of issues we might run in to using Cairo resources in widgets, that sort of thing.

 

The doodle layout algorithm is a variant of the CSS layout algorithm, significantly simplified, by me as a way to avoid having to do a full on layout algorithm but still get the majority of what we needed to experimenting. This approach to layout is not the future for the UI, we have other plans there using a constraint based solver that has been proven in production code both in Smalltalk and in other languages.

 

As an experiment, it was a complete success - we sold ourselves on the idea that Cairo was completely viable for our customers to use for this kind of work (ie: custom widgets) and potentially for doing the core widgets too. Some of the people in the community have gone even further, making graphics contexts that use CairoGraphics and whole suits of widgets. It's inspiring and very cool.

 

So, you've stumbled upon some of the humble beginnings - I frankly didn't realise we'd put that stuff in the open repository, I thought we'd left it in our private repository. Have fun with it if you want.. somewhere in there is my fancy clock that moves the numbers instead of the clock hands and also a Dr. Who animation.

 

Cheers,

Michael

 

On 10/01/2008, at 2:34 AM, Stewart MacLean <[hidden email]> wrote:



Hi,

 

I’ve been experimenting with the various Cairo bits and pieces trying to figure out how to get a nice looking tree/UI – some interesting stuff! (thanks for the previous pointers, everyone).

 

One of which is the Gizmo – which on first impression I wondered what’s with all these pink rectangles?

 

But delving deeper it looks like a pretty cool open ended framework – I’ve been experimenting with nesting and it sort of works, but not sure if I’m configuring it correctly.

 

The Cairo Wrapper Kit is a piece of art, but I’m struggling to get my head around it – wrapper hell?

 

Anyway, I was wondering where the “Doodle Layout Algorithm” came from? – all I can find are references to a constraint based object visualization system from the mid 90’s.

 

BTW, I know Smalltalk is generally self documenting code, but some “big picture” class/package documentation with these lovely experiments would make them a lot more accessible!

 

Cheers,

 

Stewart

 

 

Gizmo>>layoutFromIndex: index

          "** The Doodle Layout Algorithm **

1) Use desiredLayoutBlock to find out what we want as our bounds inside the availableExtent given to us. Store this in @desired.

2) Figure out what extent we want to offer our children based on our @desired bounds. Store this in @offered.

          @desired may contain a width/height of BlockClosure. In this case, we offer the

          available space for that dimension to our children

3) Offer the @offered space to each child, storing their @requested space

4) Keep a record of the @maximum extent that our children reach inside us so that we can decide how to clip correctly.

5) <pluggable> Use our child layout algorithm to position and size the @requested space as the @bounds of the child

6) Return our @desired bounds to our parent as a requested space replacing any BlockClosure with details from our children's @maximum extent.

."

 

 

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Doodling with Cairo...

Michael Lucas-Smith-2

On 11/01/2008, at 12:46 AM, Stewart MacLean <[hidden email]> wrote:

Hi Michael,

 

Thanks for making Gizmo available – I’ve discovered the clocks, and have experimented with nesting them – quite funky seeing the Dr Who, alongside yours and Travis’ clock in one window.


I had a lot of fun making those clocks. I wanted to do some drawing that couldn't be easily done with our existing graphics framework. The area that let us down the most in Cairo was fonts, for obvious reasons. I'm not going to rehash that discussion, we've got mail archives for a reason.

 

I was wondering whether you could provide a few more details on “we have other plans there using a constraint based solver that has been proven in production code both in Smalltalk and in other languages.”? Sounds interesting…

 


Sorry nothing to report on that at the moment.


Yeah, it is inspiring what people have done with Cairo in VW. I’ve been working through various examples/frameworks etc trying to get my head around it all. I’m now trying to apply it to develop my own cool looking UI. A lot of work, but experiments etc such as yours and others are a great help – thanks.


Not a problem.

Cheers,
Michael

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Doodling with Cairo...

Joachim Geidel
In reply to this post by Stew MacLean

Am 09.01.2008 um 16:34 schrieb Stewart MacLean <[hidden email]>:

The Cairo Wrapper Kit is a piece of art, but I’m struggling to get my head around it – wrapper hell?


Stewart,

if you meant the package "CairoGraphics-Wrappers", then it's my fault. :-)  

It was an experiment with the purpose to answer two questions: 
1) Is it possible to provide a framework which makes it easy to render an existing widget with Cairo without rewriting it from scratch? 
2) How difficult is it to move the VisualWorks widgets to Cairo?
The idea was to wrap an arbitrary VisualComponent in a CairoWrapper, and use a CairoGraphicsContext for redirecting the rendering messages to a CairoContext. 

There's a VWNC thread with the subject "Wrapping Cairo" from September 2007 and a thread "Cairofying VisualWorks" from October 2007 (http://forum.world.st/Cairofying-VisualWorks-td1409333.html) where you can find more details.

The packages are probably not compatible with recent versions of VisualWorks (7.6 and later) and CairoGraphics, as it was just an experiment and I never adapted it to later versions of VW.

Cheers
Joachim


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Doodling with Cairo...

Joachim Geidel

Am 27.07.2013 um 18:31 schrieb Joachim Geidel <[hidden email]>:

Am 09.01.2008 um 16:34 schrieb Stewart MacLean <[hidden email]>:

The Cairo Wrapper Kit is a piece of art, but I’m struggling to get my head around it – wrapper hell?


Stewart,

if you meant the package "CairoGraphics-Wrappers", then it's my fault. :-)  

Hmm, the "piece of art" bit can't possibly have anything to do with CairoGraphics-Wrappers - you were probably talking about Chris Thorgrimsson's Cairo Graphics Kit (http://cairocreations.wordpress.com/, http://esug.org/data/ESUG2011/Slides/24-Wednesday/07-24-ESUG-Cairo_Graphics_Kit.pdf), weren't you?

Cheers,
Joachim


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Doodling with Cairo...

Stew MacLean

Hi Joachim,

 

Yes, I was talking about the Cairo Graphics Kit – sorry for the confusion.

 

In actual fact, I’ve got started by using your package in conjunction with the rounded rectangle code that Randy Coulman kindly pointed me too. Please see below.

 

I’m now trying to figure out how to adapt GF/ST to display the sexy rectangles.

 

Thanks for making your experiment available and the references to the threads in your previous message.

 

Cheers,

 

Stewart

 

displayButtonRoundedCornersOn: aGraphicsContext

            "self example: #displayButtonRoundedCornersOn:"

 

            CairoButton new

                        text: 'OverDrive Is Delicous';

                        setExtent;

                        drawOn: aGraphicsContext cairoContext

 

 

-----Original Message-----
From: Joachim Geidel [mailto:[hidden email]]
Sent: 29 July 2013 4:10 a.m.
To: [hidden email]
Cc: VW NC
Subject: Re: [vwnc] Doodling with Cairo...

 

 

Am 27.07.2013 um 18:31 schrieb Joachim Geidel <[hidden email]>:

 

Am 09.01.2008 um 16:34 schrieb Stewart MacLean <[hidden email]>:

The Cairo Wrapper Kit is a piece of art, but I’m struggling to get my head around it – wrapper hell?

 

Stewart,

 

if you meant the package "CairoGraphics-Wrappers", then it's my fault. :-)  

 

Hmm, the "piece of art" bit can't possibly have anything to do with CairoGraphics-Wrappers - you were probably talking about Chris Thorgrimsson's Cairo Graphics Kit (http://cairocreations.wordpress.com/, http://esug.org/data/ESUG2011/Slides/24-Wednesday/07-24-ESUG-Cairo_Graphics_Kit.pdf), weren't you?

 

Cheers,

Joachim

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Doodling with Cairo...

Henrik Sperre Johansen
<base href="x-msg://359/">For ideas/inspiration, here's the package I hacked together:


To install;
GFPen useCairoPen.
To revert: 
GFPen useDefaultPen.

Doesn't work with zooming, as I didn't need that, and the implemented "primitive" set on GFScalingPen is incomplete, just covering my use cases.

There's one feature not already in GF/ST; using gradients as colors, like this:

myGO fillColor: (self gradientFor: someBounds)

A sample gradientFor:,  filling myGO with an orange -> red gradient from top to bottom, called with new displayBounds whenever GO changes extent:
#gradientFor: aRectangle
| gradient |
gradient := CairoGraphics.LinearGradient
from:  0@0 to: 0 @ aRectangle height .
gradient
addStopAt: 0
colorValue: (ColorValue white blendWith: ColorValue orange );
addStopAt: 0.3
colorValue: ColorValue orange;
addStopAt: 0.5
colorValue: (ColorValue orange blendWith: ColorValue red);
addStopAt: 1
colorValue: ColorValue  red.
^gradient

Cheers,
Henry

On Jul 30, 2013, at 10:49 , Stewart MacLean <[hidden email]> wrote:

Hi Joachim,
 
Yes, I was talking about the Cairo Graphics Kit – sorry for the confusion.
 
In actual fact, I’ve got started by using your package in conjunction with the rounded rectangle code that Randy Coulman kindly pointed me too. Please see below.
 
I’m now trying to figure out how to adapt GF/ST to display the sexy rectangles.
 
Thanks for making your experiment available and the references to the threads in your previous message.
 
Cheers,
 
Stewart
 
displayButtonRoundedCornersOn: aGraphicsContext
            "self example: #displayButtonRoundedCornersOn:"
 
            CairoButton new
                        text: 'OverDrive Is Delicous';
                        setExtent;
                        drawOn: aGraphicsContext cairoContext
 
<image001.jpg>
 
-----Original Message-----
From: Joachim Geidel [mailto:joachim.geidel@onlinehome.de] 
Sent: 29 July 2013 4:10 a.m.
To: [hidden email]
Cc: VW NC
Subject: Re: [vwnc] Doodling with Cairo...
 
 
Am 27.07.2013 um 18:31 schrieb Joachim Geidel <[hidden email]>:
 
Am 09.01.2008 um 16:34 schrieb Stewart MacLean <[hidden email]>:
The Cairo Wrapper Kit is a piece of art, but I’m struggling to get my head around it – wrapper hell?
 
Stewart,
 
if you meant the package "CairoGraphics-Wrappers", then it's my fault. :-)  
 
Hmm, the "piece of art" bit can't possibly have anything to do with CairoGraphics-Wrappers - you were probably talking about Chris Thorgrimsson's Cairo Graphics Kit (http://cairocreations.wordpress.com/, http://esug.org/data/ESUG2011/Slides/24-Wednesday/07-24-ESUG-Cairo_Graphics_Kit.pdf), weren't you?
 
Cheers,
Joachim
 
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Doodling with Cairo...

Randy Coulman
Henrik,

This is a bit of a mind-bending trick, but comes in handy sometimes. You can create your gradient in a unit rectangle and then scale the gradient based on your bounds.

So, in your example, you can create your gradient from 0@0 to 0@1, and then later, you can do this:

gradient modifyMatrix: [:m | m scale: aRectangle extent reciprocal]

What you have is fine for that context (and less confusing), but if you have a common gradient that you want to use in a number of different-sized rectangles, this trick works pretty well. And no, I'm not sure I completely understand how it works :-).


Randy

On Tue, Jul 30, 2013 at 8:06 AM, Henrik Johansen <[hidden email]> wrote:
For ideas/inspiration, here's the package I hacked together:


To install;
GFPen useCairoPen.
To revert: 
GFPen useDefaultPen.

Doesn't work with zooming, as I didn't need that, and the implemented "primitive" set on GFScalingPen is incomplete, just covering my use cases.

There's one feature not already in GF/ST; using gradients as colors, like this:

myGO fillColor: (self gradientFor: someBounds)

A sample gradientFor:,  filling myGO with an orange -> red gradient from top to bottom, called with new displayBounds whenever GO changes extent:
#gradientFor: aRectangle
| gradient |
gradient := CairoGraphics.LinearGradient
from:  0@0 to: 0 @ aRectangle height .
gradient
addStopAt: 0
colorValue: (ColorValue white blendWith: ColorValue orange );
addStopAt: 0.3
colorValue: ColorValue orange;
addStopAt: 0.5
colorValue: (ColorValue orange blendWith: ColorValue red);
addStopAt: 1
colorValue: ColorValue  red.
^gradient

Cheers,
Henry

On Jul 30, 2013, at 10:49 , Stewart MacLean <[hidden email]> wrote:

Hi Joachim,
 
Yes, I was talking about the Cairo Graphics Kit – sorry for the confusion.
 
In actual fact, I’ve got started by using your package in conjunction with the rounded rectangle code that Randy Coulman kindly pointed me too. Please see below.
 
I’m now trying to figure out how to adapt GF/ST to display the sexy rectangles.
 
Thanks for making your experiment available and the references to the threads in your previous message.
 
Cheers,
 
Stewart
 
displayButtonRoundedCornersOn: aGraphicsContext
            "self example: #displayButtonRoundedCornersOn:"
 
            CairoButton new
                        text: 'OverDrive Is Delicous';
                        setExtent;
                        drawOn: aGraphicsContext cairoContext
 
<image001.jpg>
 
-----Original Message-----
From: Joachim Geidel [mailto:[hidden email]onlinehome.de] 
Sent: 29 July 2013 4:10 a.m.
To: [hidden email]
Cc: VW NC
Subject: Re: [vwnc] Doodling with Cairo...
 
 
Am 27.07.2013 um 18:31 schrieb Joachim Geidel <[hidden email]>:
 
Am 09.01.2008 um 16:34 schrieb Stewart MacLean <[hidden email]>:
The Cairo Wrapper Kit is a piece of art, but I’m struggling to get my head around it – wrapper hell?
 
Stewart,
 
if you meant the package "CairoGraphics-Wrappers", then it's my fault. :-)  
 
Hmm, the "piece of art" bit can't possibly have anything to do with CairoGraphics-Wrappers - you were probably talking about Chris Thorgrimsson's Cairo Graphics Kit (http://cairocreations.wordpress.com/, http://esug.org/data/ESUG2011/Slides/24-Wednesday/07-24-ESUG-Cairo_Graphics_Kit.pdf), weren't you?
 
Cheers,
Joachim
 
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc




--
Randy Coulman
Email: [hidden email]
Home: http://randycoulman.com
Twitter: @randycoulman      GitHub: randycoulman

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Doodling with Cairo...

Henrik Sperre Johansen
On 30.07.2013 19:50, Randy Coulman wrote:
Henrik,

This is a bit of a mind-bending trick, but comes in handy sometimes. You can create your gradient in a unit rectangle and then scale the gradient based on your bounds.

So, in your example, you can create your gradient from 0@0 to 0@1, and then later, you can do this:

gradient modifyMatrix: [:m | m scale: aRectangle extent reciprocal]

What you have is fine for that context (and less confusing), but if you have a common gradient that you want to use in a number of different-sized rectangles, this trick works pretty well. And no, I'm not sure I completely understand how it works :-).

Yeah, in this case the gradient wasn't use elsewhere, otherwise a refactoring
gradientFor: someBounds
    ^self myGradient modifyMatrix: [m m scale: someBounds ]

myGradient
    ^(CairoGraphics.LinearGradient from:  0@0 to: 0 @ 1)        
addStopAt: 0 colorValue: (ColorValue white blendWith: ColorValue orange );
addStopAt: 0.3 colorValue: ColorValue orange;
addStopAt: 0.5 colorValue: (ColorValue orange blendWith: ColorValue red);
addStopAt: 1 colorValue: ColorValue  red;
                yourself
would make sense.

Not sure if this is what you meant, but at least in my case, both shapes and gradients were pretty much static, so I'd rather take the hit of an extra gradient instance/object + proper update methods where needed, than use a single gradient instance (whose stops can be edited centrally affecting display of all users), and which has to be scaled to new bounds for each object during the draw loop.

Cheers,
Henry

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Doodling with Cairo...

Stew MacLean
In reply to this post by Henrik Sperre Johansen
<base href="x-msg://359/">

Resending as didn’t appear on list… I’ve also subsequently tried your code and the improvement is fantastic!

 

Hi Henrik,

 

Thank you, thank you!

 

I’ve been digging into the GF/ST Framework (please see clunky object model below – deleted as message didn’t appear on vwnc list) and had figured that GFScalingPen was what I should reimplement, but was wilting at the prospect of all those primitives (Cairo details are still a mystery to me, and I don’t have much spare time to delve into it).

 

I was going to tackle it within the various GFGraphicObject subclasses that I needed, but this is a way better approach. I should be able to expand on your “primitive set” as required, given your kick start.

 

From what I understand, zooming should be possible using matrix transformations, but hey I’m getting ahead of myself!

 

Thanks again,

 

Cheers,

 

Stewart

 

 

 

-----Original Message-----
From: Henrik Johansen [mailto:[hidden email]]
Sent:
31 July 2013 3:06 a.m.
To: [hidden email]
Cc: [hidden email]
Subject: Re: [vwnc] Doodling with
Cairo...

 

For ideas/inspiration, here's the package I hacked together:

 

 

To install;

GFPen useCairoPen.

To revert: 

GFPen useDefaultPen.

 

Doesn't work with zooming, as I didn't need that, and the implemented "primitive" set on GFScalingPen is incomplete, just covering my use cases.

 

There's one feature not already in GF/ST; using gradients as colors, like this:

 

myGO fillColor: (self gradientFor: someBounds)

 

A sample gradientFor:,  filling myGO with an orange -> red gradient from top to bottom, called with new displayBounds whenever GO changes extent:

#gradientFor: aRectangle

         

          | gradient |

          gradient := CairoGraphics.LinearGradient

                      from:  0@0 to: 0 @ aRectangle height .

          gradient

                      addStopAt: 0

                                  colorValue: (ColorValue white blendWith: ColorValue orange );

                      addStopAt: 0.3

                                  colorValue: ColorValue orange;

          addStopAt: 0.5

                                  colorValue: (ColorValue orange blendWith: ColorValue red);

                      addStopAt: 1

                                  colorValue: ColorValue  red.

          ^gradient

 

Cheers,

Henry

 

On Jul 30, 2013, at 10:49 , Stewart MacLean <[hidden email]> wrote:



Hi Joachim,

 

Yes, I was talking about the Cairo Graphics Kit – sorry for the confusion.

 

In actual fact, I’ve got started by using your package in conjunction with the rounded rectangle code that Randy Coulman kindly pointed me too. Please see below.

 

I’m now trying to figure out how to adapt GF/ST to display the sexy rectangles.

 

Thanks for making your experiment available and the references to the threads in your previous message.

 

Cheers,

 

Stewart

 

displayButtonRoundedCornersOn: aGraphicsContext

            "self example: #displayButtonRoundedCornersOn:"

 

            CairoButton new

                        text: 'OverDrive Is Delicous';

                        setExtent;

                        drawOn: aGraphicsContext cairoContext

 

<image001.jpg>

 

-----Original Message-----
From: Joachim Geidel [mailto:joachim.geidel@onlinehome.de] 
Sent: 
29 July 2013 4:10 a.m.
To: [hidden email]
Cc: VW NC
Subject: Re: [vwnc] Doodling with
Cairo...

 

 

Am 27.07.2013 um 18:31 schrieb Joachim Geidel <[hidden email]>:

 

Am 09.01.2008 um 16:34 schrieb Stewart MacLean <[hidden email]>:

The Cairo Wrapper Kit is a piece of art, but I’m struggling to get my head around it – wrapper hell?

 

Stewart,

 

if you meant the package "CairoGraphics-Wrappers", then it's my fault. :-)  

 

Hmm, the "piece of art" bit can't possibly have anything to do with CairoGraphics-Wrappers - you were probably talking about Chris Thorgrimsson's Cairo Graphics Kit (http://cairocreations.wordpress.com/, http://esug.org/data/ESUG2011/Slides/24-Wednesday/07-24-ESUG-Cairo_Graphics_Kit.pdf), weren't you?

 

Cheers,

Joachim

 

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

 


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Doodling with Cairo...

Henrik Sperre Johansen

On Aug 3, 2013, at 8:25 , Stewart MacLean <[hidden email]> wrote:

<base href="x-msg://359/">

Resending as didn’t appear on list… I’ve also subsequently tried your code and the improvement is fantastic!

 

Hi Henrik,

 

Thank you, thank you!

 

I’ve been digging into the GF/ST Framework (please see clunky object model below – deleted as message didn’t appear on vwnc list) and had figured that GFScalingPen was what I should reimplement, but was wilting at the prospect of all those primitives (Cairo details are still a mystery to me, and I don’t have much spare time to delve into it).

 

I was going to tackle it within the various GFGraphicObject subclasses that I needed, but this is a way better approach. I should be able to expand on your “primitive set” as required, given your kick start.

 

From what I understand, zooming should be possible using matrix transformations, but hey I’m getting ahead of myself!

 

Thanks again,

 

Cheers,

 

Stewart


Good to hear!

There's some time since I touched the code, but there's some other leftovers you might run into that causes head scratching:
- A performance experiment where the Pen draws using a single context instead of creating new ones for each primitive call (cairoDrawOne/New, switched between in cairoDraw:)
IIRC, I had problems with context initialization that were never really resolved, which is why it's set to the slower version. 

- Double buffering
I had trouble getting the scratch to function correctly.
If you look at GFPen >> #displayPolicy there's a commented out "& false" in the test there, so I eventually ended up with something that worked good enough for my needs.
In case more problems hit though, I left it in so I could easily disable it :P 

GroupGO caching on the other hand, is right out.

And a small confession that's sure to make some people frown;
It does no translation from VW to Cairo coordinate system. 
So shapes drawn by cairo will be 1/2 a pixel off where legacy applications would expect them to be. (except in the cases where primitive hasn't been reimplemented)

Cheers,
Henry

PS. That object model looks pretty familiar; core GF/ST classes in the mid, a few domain GO's at the top, and a custom drawing pane ( for specifying a custom default controller, in our case). 

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc