public static StencilTestNode Create() { var model = new StencilTestModel(); var vs = new VertexShader(vertexCode); var fs = new FragmentShader(fragmentCode); var provider = new ShaderArray(vs, fs); var map = new AttributeMap(); map.Add(inPosition, StencilTestModel.strPosition); var polygonModeState = new PolygonModeState(PolygonMode.Line); var lineWidthState = new LineWidthState(10); var builder = new RenderMethodBuilder(provider, map, polygonModeState, lineWidthState); var node = new StencilTestNode(model, builder); node.polygonModeState = polygonModeState; node.lineWidthState = lineWidthState; node.Initialize(); return(node); }
/// <summary> /// Read an extended state /// Note: I'm still not sure whether its worth to precompile the states, it /// might be enough to interprete the states each time they are used. /// </summary> private List <State> ReadExtendedState(PdfDictionary extGStateDict) { var extendedState = new List <State>(); foreach (var command in extGStateDict.Elements.Keys) { // mögliche Inhalte in den settings siehe in der PDF Reference 1.7, Kapitel 8.4.5, Seite 128, Tabelle 58 switch (command) { case PdfKeys.LW: { var lineWidth = new LineWidthState(); extendedState.Add(lineWidth); lineWidth.LineWidth = extGStateDict.Elements.GetReal(command); break; } case PdfKeys.ca: { var fillAlpha = new FillAlphaState(); extendedState.Add(fillAlpha); fillAlpha.Alpha = extGStateDict.Elements.GetReal(command); break; } case PdfKeys.CA: { var strokeAlpha = new StrokeAlphaState(); extendedState.Add(strokeAlpha); strokeAlpha.Alpha = extGStateDict.Elements.GetReal(command); break; } case PdfKeys.Font: { var font = new FontState(); extendedState.Add(font); var fontArray = extGStateDict.Elements.GetArray(command); var fontDict = fontArray.Elements.GetDictionary(0); font.FontDescriptor = FontManager.ReadFontDescriptor(fontDict); font.FontSize = fontArray.Elements.GetReal(1); break; } case PdfKeys.SMask: { var softMaskState = new SoftMaskState(); extendedState.Add(softMaskState); var smaskDict = extGStateDict.Elements.GetDictionary(command); if (smaskDict != null) { softMaskState.SoftMask = GetSoftMask(smaskDict); } break; } } } return(extendedState); }