Cairo__GraphicsContext.st
changeset 10 dd5fece7c8d2
parent 8 ccb6c1e6201e
child 11 fdc697f4f190
equal deleted inserted replaced
9:36bf6c3b50d4 10:dd5fece7c8d2
    46 	^0
    46 	^0
    47 
    47 
    48     "Modified: / 10-09-2008 / 18:19:53 / Jan Vrany <vranyj1@fel.cvut.cz>"
    48     "Modified: / 10-09-2008 / 18:19:53 / Jan Vrany <vranyj1@fel.cvut.cz>"
    49 ! !
    49 ! !
    50 
    50 
       
    51 !GraphicsContext class methodsFor:'examples'!
       
    52 
       
    53 rectangleOnTranscript
       
    54 
       
    55     "
       
    56         Cairo::GraphicsContext rectangleOnTranscript
       
    57     "
       
    58 
       
    59 
       
    60     | gc |
       
    61     gc := Transcript cairo.
       
    62     gc paint: Color black.
       
    63     gc moveToX: 30 y: 50.
       
    64     gc paint: (Color red alpha: 0.5).
       
    65     gc rectangleX: 10 y: 15 width: 150 height: 60.
       
    66     gc fill.
       
    67     gc paint: (Color red alpha: 0.75).
       
    68     gc rectangleX: 10 y: 15 width: 150 height: 60.
       
    69     gc stroke.
       
    70 
       
    71     "Created: / 23-04-2009 / 17:33:57 / Jan Vrany <vranyj1@fel.cvut.cz>"
       
    72 ! !
       
    73 
    51 !GraphicsContext class methodsFor:'primitives'!
    74 !GraphicsContext class methodsFor:'primitives'!
    52 
    75 
    53 primAppendPath: cr path: path 
    76 primAppendPath: cr path: path 
    54 
    77 
    55 	<cdecl: void "cairo_append_path" ( Cairo::GraphicsContext Cairo::Path ) >
    78 	<cdecl: void "cairo_append_path" ( Cairo::GraphicsContext Cairo::Path ) >
   896 
   919 
   897     ^self 
   920     ^self 
   898         paintRed:   (aColor red / 100) asDouble
   921         paintRed:   (aColor red / 100) asDouble
   899         green:      (aColor green / 100) asDouble
   922         green:      (aColor green / 100) asDouble
   900         blue:       (aColor blue / 100) asDouble
   923         blue:       (aColor blue / 100) asDouble
   901         alpha:      aColor alpha
   924         alpha:      aColor alpha asDouble
   902 
   925 
   903     "Created: / 10-07-2008 / 11:18:13 / Jan Vrany <vranyj1@fel.cvut.cz>"
   926     "Created: / 10-07-2008 / 11:18:13 / Jan Vrany <vranyj1@fel.cvut.cz>"
       
   927     "Modified: / 23-04-2009 / 17:31:33 / Jan Vrany <vranyj1@fel.cvut.cz>"
   904 !
   928 !
   905 
   929 
   906 surface
   930 surface
   907 
   931 
   908     surface ifNil:[surface := self class primGetTarget: self].
   932     surface ifNil:[surface := self class primGetTarget: self].
   910 
   934 
   911     "Created: / 10-07-2008 / 10:33:59 / Jan Vrany <vranyj1@fel.cvut.cz>"
   935     "Created: / 10-07-2008 / 10:33:59 / Jan Vrany <vranyj1@fel.cvut.cz>"
   912     "Modified: / 10-09-2008 / 20:53:00 / Jan Vrany <vranyj1@fel.cvut.cz>"
   936     "Modified: / 10-09-2008 / 20:53:00 / Jan Vrany <vranyj1@fel.cvut.cz>"
   913 ! !
   937 ! !
   914 
   938 
       
   939 !GraphicsContext methodsFor:'cairo - font'!
       
   940 
       
   941 fontFaceFamily: family slant: slant weight: weight
       
   942 
       
   943     ^self class primSelectFontFace: self
       
   944         family: family asString
       
   945         slant: slant asInteger
       
   946         weight: weight asInteger
       
   947 
       
   948     "Created: / 23-04-2009 / 17:23:54 / Jan Vrany <vranyj1@fel.cvut.cz>"
       
   949 !
       
   950 
       
   951 fontSize: sz
       
   952 
       
   953     ^self class primSetFontSize: self size: sz
       
   954 
       
   955     "Created: / 23-04-2009 / 17:24:33 / Jan Vrany <vranyj1@fel.cvut.cz>"
       
   956 ! !
       
   957 
   915 !GraphicsContext methodsFor:'cairo - paints'!
   958 !GraphicsContext methodsFor:'cairo - paints'!
   916 
   959 
   917 paintRed: red green: green blue: blue alpha: alpha
   960 paintRed: red green: green blue: blue alpha: alpha
   918 
   961 
   919     ^self class 
   962     ^self class 
   921 
   964 
   922     "Created: / 10-07-2008 / 11:10:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
   965     "Created: / 10-07-2008 / 11:10:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
   923 ! !
   966 ! !
   924 
   967 
   925 !GraphicsContext methodsFor:'cairo - paths'!
   968 !GraphicsContext methodsFor:'cairo - paths'!
       
   969 
       
   970 moveToX: x y: y
       
   971 
       
   972     ^self class primMoveTo: self x: x asFloat y: y asFloat
       
   973 
       
   974     "Created: / 23-04-2009 / 17:21:00 / Jan Vrany <vranyj1@fel.cvut.cz>"
       
   975 !
   926 
   976 
   927 rectangleX: x y: y width: width height: height 
   977 rectangleX: x y: y width: width height: height 
   928 
   978 
   929     ^self class 
   979     ^self class 
   930         primRectangle: self 
   980         primRectangle: self 
   932         y: y asDouble 
   982         y: y asDouble 
   933         width: width asDouble 
   983         width: width asDouble 
   934         height: height asDouble
   984         height: height asDouble
   935 
   985 
   936     "Created: / 10-07-2008 / 09:41:50 / Jan Vrany <vranyj1@fel.cvut.cz>"
   986     "Created: / 10-07-2008 / 09:41:50 / Jan Vrany <vranyj1@fel.cvut.cz>"
       
   987 !
       
   988 
       
   989 showText: aString
       
   990 
       
   991     ^self class primShowText: self utf8: aString utf8Encoded
       
   992 
       
   993     "Created: / 23-04-2009 / 17:25:20 / Jan Vrany <vranyj1@fel.cvut.cz>"
   937 ! !
   994 ! !
   938 
   995 
   939 !GraphicsContext methodsFor:'cairo - stroke & fill'!
   996 !GraphicsContext methodsFor:'cairo - stroke & fill'!
   940 
   997 
   941 fill
   998 fill