head 1.2; access; symbols; locks; strict; comment @ * @; 1.2 date 2005.12.10.14.03.33; author macslow; state Exp; branches; next 1.1; commitid 14eb439adf824567; 1.1 date 2005.09.30.10.04.11; author macslow; state Exp; branches; next ; commitid 5ce2433d0c934567; desc @@ 1.2 log @Added two new cairo-hacks/samples, made cairo-in-motion use cairomm-0.2.0 and added a slider controlling the "smoothness" (read: updates per second) of the animation @ text @// "cairo in motion" is a testbed for animated vector-drawing // using cairo within a gtk+-environment // // Copyright (C) 2005 Mirco Mueller // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #ifndef _CAIROSAMPLES_H_ #define _CAIROSAMPLES_H_ #include #include #include #include "sample-list-store.h" typedef struct _HandlePoint { double x; double y; } HandlePoint; class CairoSamples { public: CairoSamples (); ~CairoSamples (); typedef struct _Entry { std::string name; } Entry; enum Sample { CurveRectangle = 0, Clock, FillAndStroke, FillAndStroke2, Fontmania, Gradient, Image, ImagePattern, LibSVG, MovingArc, MovingArcNegative, MovingCairoLogo, MovingClip, MovingClipImage, MovingCurveTo, MovingGradient, MovingGradient2, MovingZini, OperatorAdd, OperatorAtop, OperatorAtopReverse, OperatorIn, OperatorInReverse, OperatorOut, OperatorOutReverse, OperatorOver, OperatorOverReverse, OperatorSaturate, OperatorXor, Path, PatternFill, SetLineCap, SetLineJoin, TextAlignCenter, Text, TextExtents, XxxClipRectangle, XxxDash, XxxLongLines, XxxMultiSegmentCaps, XxxSelfIntersect, NumberOfSamples }; enum DashStyle { DashOff = 0, Dotted, Dashed, DashDotDash, DashedFunky }; void do_animation_step (unsigned long ulMilliSeconds); void set_context (Cairo::Context* pCairoContext); void normalize_canvas (double fWidth, double fHeight) const; void set_bg_svg (std::string strSVGFileName); bool do_sample (Sample sample); void set_cap_style (Cairo::LineCap cairoCapStyle); void set_join_style (Cairo::LineJoin cairoJoinStyle); void set_dash_style (DashStyle dashStyle); void set_operator (Cairo::Operator cairoOperator); void set_extend_mode (Cairo::Extend cairoExtendMode); void set_filter_mode (Cairo::Filter cairoFilterMode); void set_line_width (double fLineWidth); void set_bg_color (Gdk::Color bgColor); void set_font_family (std::string strFontFamily); void set_font_size (double fFontSize); void set_font_weight (Cairo::FontWeight cairoFontWeight); void set_font_slant (Cairo::FontSlant cairoFontSlant); void set_some_text (std::string strSomeText); void set_image_file_name (std::string strFileName); void set_svg_file_name (std::string strFileName); void add_samples_to_list_store (SampleListStore* pSampleListStore); std::string get_sample_name (Sample sample); private: void update_var (double* pfValue, double fLowerLimit, double fUpperLimit, double* pfStep, double fGrow, double fShrink); HandlePoint get_center (); HandlePoint get_point1 (); HandlePoint get_point2 (); HandlePoint get_point3 (); HandlePoint get_point4 (); double get_radius (); double get_angle_1 (); double get_angle_2 (); void draw_background (); void draw_background (Gdk::Color color); void draw_handle (double fX, double fY); void draw_handle (HandlePoint* pPoint); bool sample_fallback (std::string strMessage); bool curve_rectangle (); bool clock (); bool fill_and_stroke (); bool fill_and_stroke2 (); bool fontmania (); bool gradient (); bool image (); bool image_pattern (); bool libsvg (); bool moving_arc (); bool moving_arc_negative (); bool moving_cairo_logo (); bool moving_clip (); bool moving_clip_image (); bool moving_curve_to (); bool moving_gradient (); bool moving_gradient2 (); bool moving_zini (); bool operator_add (); bool operator_atop (); bool operator_atop_reverse (); bool operator_in (); bool operator_in_reverse (); bool operator_out (); bool operator_out_reverse (); bool operator_over (); bool operator_over_reverse (); bool operator_saturate (); bool operator_xor (); bool path (); bool pattern_fill (); bool set_line_cap (); bool set_line_join (); bool text_align_center (); bool text (); bool text_extents (); bool xxx_clip_rectangle (); bool xxx_dash (); bool xxx_long_lines (); bool xxx_multi_segment_caps (); bool xxx_self_intersect (); protected: HandlePoint m_center; HandlePoint m_point1; HandlePoint m_point2; HandlePoint m_point3; HandlePoint m_point4; double m_fRadius; double m_fAngle1; double m_fAngle2; double m_centerXStep; double m_centerYStep; double m_point1XStep; double m_point1YStep; double m_point2XStep; double m_point2YStep; double m_point3XStep; double m_point3YStep; double m_point4XStep; double m_point4YStep; double m_fRadiusStep; double m_fAngle1Step; double m_fAngle2Step; Cairo::Context* m_pCairoContext; Cairo::LineCap m_cairoCapStyle; Cairo::LineJoin m_cairoJoinStyle; DashStyle m_dashStyle; Cairo::Operator m_cairoOperator; Cairo::Extend m_cairoExtendMode; Cairo::Filter m_cairoFilterMode; double m_fLineWidth; Gdk::Color m_bgColor; std::string m_strFontFamily; double m_fFontSize; Cairo::FontWeight m_cairoFontWeight; Cairo::FontSlant m_cairoFontSlant; std::string m_strSomeText; std::string m_strImageFileName; std::string m_strSvgFileName; std::vector m_sampleList; unsigned long m_ulMilliSeconds; }; #endif /*_CAIROSAMPLES_H_*/ @ 1.1 log @a little learning toy usable for testing out code-smidgens of cairo-effects @ text @d23 1 a23 1 #include d49 1 d65 1 d101 2 a102 2 void do_animation_step (); void set_context (cairo_t* pCairoContext); d104 4 a107 4 void set_bg_svg (std::string strSVGFileName) const; bool do_sample (Sample sample) const; void set_cap_style (cairo_line_cap_t cairoCapStyle); void set_join_style (cairo_line_join_t cairoJoinStyle); d109 3 a111 3 void set_operator (cairo_operator_t cairoOperator); void set_extend_mode (cairo_extend_t cairoExtendMode); void set_filter_mode (cairo_filter_t cairoFilterMode); d116 2 a117 2 void set_font_weight (cairo_font_weight_t cairoFontWeight); void set_font_slant (cairo_font_slant_t cairoFontSlant); d122 1 a122 1 std::string get_sample_name (Sample sample) const; d131 54 a184 52 HandlePoint get_center () const; HandlePoint get_point1 () const; HandlePoint get_point2 () const; HandlePoint get_point3 () const; HandlePoint get_point4 () const; double get_radius () const; double get_angle_1 () const; double get_angle_2 () const; void draw_background () const; void draw_background (Gdk::Color color) const; void draw_handle (double fX, double fY) const; void draw_handle (HandlePoint* pPoint) const; bool sample_not_found () const; bool curve_rectangle () const; bool fill_and_stroke () const; bool fill_and_stroke2 () const; bool fontmania () const; bool gradient () const; bool image () const; bool image_pattern () const; bool libsvg () const; bool moving_arc () const; bool moving_arc_negative () const; bool moving_cairo_logo () const; bool moving_clip () const; bool moving_clip_image () const; bool moving_curve_to () const; bool moving_gradient () const; bool moving_gradient2 () const; bool operator_add () const; bool operator_atop () const; bool operator_atop_reverse () const; bool operator_in () const; bool operator_in_reverse () const; bool operator_out () const; bool operator_out_reverse () const; bool operator_over () const; bool operator_over_reverse () const; bool operator_saturate () const; bool operator_xor () const; bool path () const; bool pattern_fill () const; bool set_line_cap () const; bool set_line_join () const; bool text_align_center () const; bool text () const; bool text_extents () const; bool xxx_clip_rectangle () const; bool xxx_dash () const; bool xxx_long_lines () const; bool xxx_multi_segment_caps () const; bool xxx_self_intersect () const; d208 3 a210 3 cairo_t* m_pCairoContext; cairo_line_cap_t m_cairoCapStyle; cairo_line_join_t m_cairoJoinStyle; d212 3 a214 3 cairo_operator_t m_cairoOperator; cairo_extend_t m_cairoExtendMode; cairo_filter_t m_cairoFilterMode; d219 2 a220 2 cairo_font_weight_t m_cairoFontWeight; cairo_font_slant_t m_cairoFontSlant; d225 1 @