예제 #1
0
        void DrawAnswer(CairoContextEx gr, double x, double y)
        {
            ColorPalette palette = new ColorPalette(Translations);

            gr.Save();

            // A full sized square of paper
            gr.SetSourceColor(palette.Cairo(ColorPalette.Id.Yellow));
            gr.Rectangle(x, y, width, height);
            gr.Fill();
            gr.Stroke();

            // 3/4 of the whole size square of paper in the bottom right corner
            gr.SetSourceColor(palette.Cairo(ColorPalette.Id.Blue));
            double w = 3d / 4d * width;
            double h = 3d / 4d * height;

            gr.Rectangle(x + (width - w), y + (height - h), w, h);
            gr.Fill();
            gr.Stroke();

            // 3/4 square of paper in the top left corner
            gr.SetSourceColor(palette.Cairo(ColorPalette.Id.Green));
            gr.Rectangle(x, y, 3d / 4d * width, 3d / 4d * height);
            gr.Fill();
            gr.Stroke();

            // 1/4 square of paper in the top left corner
            gr.SetSourceColor(palette.Cairo(ColorPalette.Id.Red));
            gr.Rectangle(x, y, 1d / 4d * width, 1d / 4d * height);
            gr.Fill();
            gr.Stroke();

            gr.Restore();
        }
예제 #2
0
        private Color ColorForPortion(char portion)
        {
            if (portion == A)
            {
                return(palette.Cairo(1));
            }

            return(palette.Cairo(0));
        }
예제 #3
0
        private void DrawObject(CairoContextEx gr, int area_width, int area_height)
        {
            palette.Alpha = alpha;
            double x = DrawAreaX + 0.15, y = DrawAreaY + 0.1;

            gr.SetSourceColor(palette.Cairo(ColorPalette.Id.Black));
            double       pos_x = x, pos_y = y;
            const double figure_size   = 0.6;
            const double square_size   = figure_size / NUMCOLUMNS;
            const double center_square = square_size / 2;
            double       radius_square = .8 * (square_size - (LineWidth * 2)) / 2;

            gr.Rectangle(pos_x, pos_y, figure_size, figure_size);
            gr.Stroke();

            for (int line = 0; line < NUMCOLUMNS - 1; line++)             // Horizontal
            {
                pos_y += square_size;
                gr.MoveTo(pos_x, pos_y);
                gr.LineTo(pos_x + figure_size, pos_y);
                gr.Stroke();
            }

            pos_y = y;
            for (int column = 0; column < NUMCOLUMNS - 1; column++)             // Vertical
            {
                pos_x += square_size;
                gr.MoveTo(pos_x, pos_y);
                gr.LineTo(pos_x, pos_y + figure_size);
                gr.Stroke();
            }

            pos_y = y + center_square;
            pos_x = x + center_square;

            for (int i = 0, itcolor = 0; i < NUMCOLUMNS * NUMCOLUMNS && itcolor < palette.Count; i++)
            {
                int   dx, dy;
                Color color = palette.Cairo(itcolor);
                dx = (location_order[i]) % NUMCOLUMNS;
                dy = (location_order[i]) / NUMCOLUMNS;

                gr.Arc(pos_x + square_size * dx, pos_y + square_size * dy, radius_square, 0, 2 * Math.PI);
                gr.FillGradient(pos_x + square_size * dx, pos_y + square_size * dy, radius_square, radius_square, color);

                if (i == dotsPerColor[itcolor])
                {
                    itcolor++;
                }
            }
        }
예제 #4
0
        private void DrawObject(CairoContextEx gr)
        {
            double x = DrawAreaX + 0.125, y = DrawAreaY + 0.2;
            int    idx;

            palette.Alpha = alpha;

            for (int i = 0; i < colors_shown; i++)
            {
                idx      = color_order [i];
                gr.Color = palette.Cairo(idx);
                gr.MoveTo(x, y);
                gr.ShowPangoText(palette.Name(i));
                gr.Stroke();

                if (i == 2)
                {
                    y += 0.2;
                    x  = DrawAreaX + 0.125;
                }
                else
                {
                    x += 0.25;
                }
            }
        }
예제 #5
0
 private void DrawSquare(CairoContextEx gr, double x, double y, SquareColor [] colours, int index)
 {
     gr.Save();
     for (int column = 0; column < columns; column++)
     {
         for (int row = 0; row < rows; row++)
         {
             // if you want 2 schemes (primary or secundary colors)
             Color c = palette.Cairo(ColorPalette.Id.First + color_sheme * 3 + (int)colours[index + (columns * row) + column]);
             gr.Rectangle(x + row * rect_w, y + column * rect_h, rect_w, rect_h);
             gr.FillGradient(x + row * rect_w, y + column * rect_h, rect_w, rect_h, c);
         }
     }
     gr.Restore();
     for (int column = 0; column < columns; column++)
     {
         for (int row = 0; row < rows; row++)
         {
             gr.Rectangle(x + row * rect_w, y + column * rect_h, rect_w, rect_h);
             gr.Stroke();
         }
     }
 }
예제 #6
0
        protected override void Initialize()
        {
            ArrayListIndicesRandom random_indices = new ArrayListIndicesRandom(total_slices);
            Color clr;

            cp = new ColorPalette(Translations);

            Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces;

            cercle_colors    = new Color [total_slices];
            badcercle_colors = new Color [total_slices];
            for (int i = 0; i < total_slices; i++)
            {
                cercle_colors [i]    = cp.Cairo(i);
                badcercle_colors [i] = cp.Cairo(i);
            }

            // Correct answer
            random_indices.Initialize();
            clr = badcercle_colors [random_indices[0]];
            badcercle_colors [random_indices[0]] = badcercle_colors [random_indices[1]];
            badcercle_colors [random_indices[1]] = clr;

            // Create random color order for the session
            start_indices = new int [circles];
            for (int i = 0; i < circles; i++)
            {
                start_indices[i] = (random_indices[i]);
            }

            ans_pos = random.Next(circles);
            Answer.SetMultiOptionAnswer(ans_pos, Answer.GetFigureName(ans_pos));

            const double        text_offset = 0.04;
            const double        witdh_used  = 0.9;     // Total width used for drawing all the figures
            const double        margin      = 0.1 / circles / 2;
            const double        box_size    = witdh_used / circles;
            double              y;
            HorizontalContainer container;
            DrawableArea        drawable_area;

            Color [] colors;

            y = DrawAreaY + 0.1 + (radius / 2);

            container = new HorizontalContainer(0.05, y, witdh_used, box_size);
            AddWidget(container);

            circle_parameters = new CircleParameters [circles];
            for (int i = 0; i < circles; i++)
            {
                if (ans_pos == i)
                {
                    colors = badcercle_colors;
                }
                else
                {
                    colors = cercle_colors;
                }

                circle_parameters [i]      = new CircleParameters(colors);
                drawable_area              = new DrawableArea(box_size, box_size);
                drawable_area.SelectedArea = new Rectangle((box_size - box_size) / 2, 0, box_size, box_size);
                drawable_area.Data         = i;
                drawable_area.DataEx       = Answer.GetMultiOption(i);

                drawable_area.DrawEventHandler += delegate(object sender, DrawEventArgs e)
                {
                    int idx = (int)e.Data;
                    CircleParameters circle = circle_parameters [idx];
                    double           x1, y1;

                    x1 = y1 = radius + margin;

                    DrawCircle(e.Context, x1, y1, circle.Colors, start_indices [idx]);
                    e.Context.DrawTextCentered(e.Width / 2, box_size + text_offset,
                                               Answer.GetFigureName(idx));
                    e.Context.Stroke();
                };
                container.AddChild(drawable_area);
            }
        }