public void rewind(int pathId)
 {
     currentChar   = 0;
     currentOffset = new Vector2(0, 0);
     if (text != null && text.Length > 0)
     {
         currentGlyph = typeFaceStyle.GetGlyphForCharacter(text[currentChar]);
         if (currentGlyph != null)
         {
             currentGlyph.rewind(0);
         }
     }
 }
Exemple #2
0
        public IEnumerable <VertexData> Vertices()
        {
            if (text != null && text.Length > 0)
            {
                Vector2 currentOffset = new Vector2(0, 0);

                currentOffset = GetBaseline(currentOffset);

                string[] lines = text.Split('\n');
                foreach (string line in lines)
                {
                    currentOffset = GetXPositionForLineBasedOnJustification(currentOffset, line);

                    for (int currentChar = 0; currentChar < line.Length; currentChar++)
                    {
                        IVertexSource currentGlyph = typeFaceStyle.GetGlyphForCharacter(line[currentChar]);

                        if (currentGlyph != null)
                        {
                            foreach (VertexData vertexData in currentGlyph.Vertices())
                            {
                                if (vertexData.command != ShapePath.FlagsAndCommand.CommandStop)
                                {
                                    VertexData offsetVertex = new VertexData(vertexData.command, vertexData.position + currentOffset + Origin);
                                    yield return(offsetVertex);
                                }
                            }
                        }

                        // get the advance for the next character
                        if (currentChar < line.Length - 1)
                        {
                            // pass the next char so the typeFaceStyle can do kerning if it needs to.
                            currentOffset.x += typeFaceStyle.GetAdvanceForCharacter(line[currentChar], line[currentChar + 1]);
                        }
                        else
                        {
                            currentOffset.x += typeFaceStyle.GetAdvanceForCharacter(line[currentChar]);
                        }
                    }

                    // before we go onto the next line we need to move down a line
                    currentOffset.x  = 0;
                    currentOffset.y -= typeFaceStyle.EmSizeInPixels;
                }
            }

            VertexData endVertex = new VertexData(ShapePath.FlagsAndCommand.CommandStop, Vector2.Zero);

            yield return(endVertex);
        }
Exemple #3
0
		public blur()
		{
			m_rbuf2 = new ImageBuffer();
			m_shape_bounds = new RectangleDouble();
			m_method = new RadioButtonGroup(new Vector2(10.0, 10.0), new Vector2(130.0, 60.0));
			m_radius = new Slider(new Vector2(130 + 10.0, 10.0 + 4.0), new Vector2(290, 8.0));
			m_shadow_ctrl = new PolygonEditWidget(4);
			m_channel_r = new CheckBox(10.0, 80.0, "Red");
			m_channel_g = new CheckBox(10.0, 95.0, "Green");
			m_channel_b = new CheckBox(10.0, 110.0, "Blue");
			m_FlattenCurves = new CheckBox(10, 315, "Convert And Flatten Curves");
			m_FlattenCurves.Checked = true;

			AddChild(m_method);
			m_method.AddRadioButton("Stack Blur");
			m_method.AddRadioButton("Recursive Blur");
			m_method.AddRadioButton("Channels");
			m_method.SelectedIndex = 1;

			AddChild(m_radius);
			m_radius.SetRange(0.0, 40.0);
			m_radius.Value = 15.0;
			m_radius.Text = "Blur Radius={0:F2}";

			AddChild(m_shadow_ctrl);

			AddChild(m_channel_r);
			AddChild(m_channel_g);
			AddChild(m_channel_b);
			AddChild(m_FlattenCurves);
			m_channel_g.Checked = true;

			m_sl = new ScanlineCachePacked8();

			StyledTypeFace typeFaceForLargeA = new StyledTypeFace(LiberationSansFont.Instance, 300, flatenCurves: false);
			m_path = typeFaceForLargeA.GetGlyphForCharacter('a');

			Affine shape_mtx = Affine.NewIdentity();
			shape_mtx *= Affine.NewTranslation(150, 100);
			m_path = new VertexSourceApplyTransform(m_path, shape_mtx);
			m_shape = new FlattenCurves(m_path);

			bounding_rect.bounding_rect_single(m_shape, 0, ref m_shape_bounds);

			m_shadow_ctrl.SetXN(0, m_shape_bounds.Left);
			m_shadow_ctrl.SetYN(0, m_shape_bounds.Bottom);
			m_shadow_ctrl.SetXN(1, m_shape_bounds.Right);
			m_shadow_ctrl.SetYN(1, m_shape_bounds.Bottom);
			m_shadow_ctrl.SetXN(2, m_shape_bounds.Right);
			m_shadow_ctrl.SetYN(2, m_shape_bounds.Top);
			m_shadow_ctrl.SetXN(3, m_shape_bounds.Left);
			m_shadow_ctrl.SetYN(3, m_shape_bounds.Top);
			m_shadow_ctrl.line_color(new RGBA_Floats(0, 0.3, 0.5, 0.3));
		}
Exemple #4
0
		public override void OnDraw(Graphics2D graphics2D)
		{
			GammaLookUpTable gamma = new GammaLookUpTable(gammaSlider.Value);
			IRecieveBlenderByte NormalBlender = new BlenderBGR();
			IRecieveBlenderByte GammaBlender = new BlenderGammaBGR(gamma);
			ImageBuffer rasterNormal = new ImageBuffer();
			rasterNormal.Attach(graphics2D.DestImage, NormalBlender);
			ImageBuffer rasterGamma = new ImageBuffer();
			rasterGamma.Attach(graphics2D.DestImage, GammaBlender);
			ImageClippingProxy clippingProxyNormal = new ImageClippingProxy(rasterNormal);
			ImageClippingProxy clippingProxyGamma = new ImageClippingProxy(rasterGamma);

			clippingProxyNormal.clear(new RGBA_Floats(1, 1, 1));

			ScanlineRasterizer ras = new ScanlineRasterizer();
			scanline_unpacked_8 sl = new scanline_unpacked_8();

			int size_mul = (int)pixelSizeSlider.Value;

			renderer_enlarged ren_en = new renderer_enlarged(size_mul);

			StyledTypeFace type = new StyledTypeFace(LiberationSansFont.Instance, 12);
			IVertexSource character = type.GetGlyphForCharacter('E');
			character.rewind(0);
			ras.reset();
			ras.add_path(character);
			ren_en.RenderSolid(clippingProxyGamma, ras, sl, RGBA_Bytes.Black);

			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			scanlineRenderer.RenderSolid(clippingProxyGamma, ras, sl, RGBA_Bytes.Black);

			ras.gamma(new gamma_none());

			PathStorage ps = new PathStorage();
			Stroke pg = new Stroke(ps);
			pg.width(2);

			DrawBigA(graphics2D);

			base.OnDraw(graphics2D);
		}