[DEMO] A screenshot of SDL + Cairo + Morph

Todd Fleming todd at flemingcnc.com
Sun Dec 4 17:05:27 PST 2005


Todd Fleming wrote:

> Brian Rice wrote:
>
>> That looks really good, idiomatically. Just a good example of  
>> emulating Logo with a flexible-enough syntax. :)
>>
>> Having to specify rgb so much is a little awkward. We do have named  
>> colors in colors.slate, but they do use floating point. Perhaps we  
>> can just do a simpler "Color Red" etc. for the simpler primary/ 
>> secondary palette with just integers, or just modify colors.slate 
>> for  the primaries and secondaries. (It was produced by running a 
>> quick  script over the X11 reference color set table, of course.)
>
>
> I'm looking at Colors.slate now; it looks good.  Cairo uses floating 
> point colors (notice that my example has "r: 1 g: 1 b: 1" instead of 
> "r: 255 g: 255 b: 255").
>
> Todd

This looks better now; I even changed the star body to MediumTurquoise :).

morph@(ContextMorph traits) paint: context
[
    inform: 'ContextMorph paint'.
   
    context `>> [
        sourceRGB: Colors Black.
        rectangle: (Rectangle origin: 0 , 0 extent: 640 , 480). fill.
       
        sourceRGB: Colors White.
        rectangle: (Rectangle origin: 50 , 50 extent: 300 , 300). fill.
       
        sourceRGB: Colors Red.
        rectangle: (Rectangle origin: 100 , 100 extent: 100 , 100). fill.
       
        sourceRGB: Colors Green alpha: 0.5.
        rectangle: (Rectangle origin: 150 , 150 extent: 100 , 100). fill.
       
        sourceRGB: Colors Blue alpha: 0.5.
        rectangle: (Rectangle origin: 200 , 200 extent: 100 , 100). fill.

        sourceRGB: Colors Red.
        rectangle: (Rectangle origin: 300 , 100 extent: 100 , 100). fill.
        lineWidth: 10. sourceRGB: Colors Blue.
        rectangle: (Rectangle origin: 300 , 100 extent: 100 , 100). stroke.

        lineWidth: 5. sourceRGB: Colors White.
        save.
        lineWidth: 10. sourceRGB: Colors Red.
        moveTo: 500, 100. lineTo: 600, 200. stroke.
        restore.
        moveTo: 500, 100. lineTo: 600, 200. stroke.
       
        sourceRGB: Colors Red.
        moveTo: 500, 400. lineTo: 550, 300. lineTo: 600, 400.
        lineTo: 500, 325. lineTo: 600, 325. closePath. stroke.
        sourceRGB: Colors MediumTurquoise.
        moveTo: 500, 400. lineTo: 550, 300. lineTo: 600, 400.
        lineTo: 500, 325. lineTo: 600, 325. fill.
    ].
].

Todd




More information about the Slate mailing list