コード例 #1
0
 internal HistoryData(int Capacity, IColorType Color)
 {
 	m_Color = Color.GetAsRGBA_Bytes();
     m_Capacity = Capacity;
     m_Data = new TwoSidedStack<double>();
     Reset();
 }
コード例 #2
0
		private int presetIndex; //For multiple materials

		public SliceSelectorWidget(string label, RGBA_Bytes accentColor, string tag = null, int presetIndex = 1)
			: base(FlowDirection.TopToBottom)
		{
			this.presetIndex = presetIndex;
			this.filterLabel = label;
			if (tag == null)
			{
				this.filterTag = label.ToLower();
			}
			else
			{
				this.filterTag = tag;
			}

			this.HAnchor = HAnchor.ParentLeftRight;
			this.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
			this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			GuiWidget accentBar = new GuiWidget(7, 5);
			accentBar.BackgroundColor = accentColor;
			accentBar.HAnchor = HAnchor.ParentLeftRight;


			TextWidget labelText = new TextWidget(LocalizedString.Get(label).ToUpper());
			labelText.TextColor = ActiveTheme.Instance.PrimaryTextColor;
			labelText.HAnchor = Agg.UI.HAnchor.ParentCenter;
			labelText.Margin = new BorderDouble(0, 3, 0, 6);

			this.AddChild(labelText);
			this.AddChild(GetPulldownContainer());
			this.AddChild(new VerticalSpacer());
			this.AddChild(accentBar);
		}
コード例 #3
0
		private void SetDisplayAttributes()
		{
			this.separatorLineColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 100);
			this.Margin = new BorderDouble(2, 4, 2, 0);

			// colors
			this.textImageButtonFactory.normalFillColor = RGBA_Bytes.Transparent;
			this.textImageButtonFactory.normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);
			this.textImageButtonFactory.normalTextColor = ActiveTheme.Instance.SecondaryTextColor;

			this.textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;

			this.textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
			this.textImageButtonFactory.hoverBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);

			this.textImageButtonFactory.disabledFillColor = RGBA_Bytes.Transparent;
			this.textImageButtonFactory.disabledBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 100);
			this.textImageButtonFactory.disabledTextColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 100);

			// other settings
			this.textImageButtonFactory.FixedHeight = TallButtonHeight;
			this.textImageButtonFactory.fontSize = 11;
			this.textImageButtonFactory.borderWidth = 1;

			this.linkButtonFactory.fontSize = 11;
		}
コード例 #4
0
		public ViewControls2D()
		{
			if (ActiveTheme.Instance.DisplayMode == ActiveTheme.ApplicationDisplayType.Touchscreen)
			{
				buttonHeight = 40;
			}
			else
			{
				buttonHeight = 20;
			}

			TextImageButtonFactory iconTextImageButtonFactory = new TextImageButtonFactory();
			iconTextImageButtonFactory.AllowThemeToAdjustImage = false;
			iconTextImageButtonFactory.checkedBorderColor = RGBA_Bytes.White;

			BackgroundColor = new RGBA_Bytes(0, 0, 0, 120);
			iconTextImageButtonFactory.FixedHeight = buttonHeight;
			iconTextImageButtonFactory.FixedWidth = buttonHeight;

			string translateIconPath = Path.Combine("ViewTransformControls", "translate.png");
			translateButton = iconTextImageButtonFactory.GenerateRadioButton("", translateIconPath);
			translateButton.Margin = new BorderDouble(3);
			AddChild(translateButton);

			string scaleIconPath = Path.Combine("ViewTransformControls", "scale.png");
			scaleButton = iconTextImageButtonFactory.GenerateRadioButton("", scaleIconPath);
			scaleButton.Margin = new BorderDouble(3);
			AddChild(scaleButton);

			Margin = new BorderDouble(5);
			HAnchor |= Agg.UI.HAnchor.ParentLeft;
			VAnchor = Agg.UI.VAnchor.ParentTop;
			translateButton.Checked = true;
		}
コード例 #5
0
		public static void DrawTo(Graphics2D graphics2D, Mesh meshToDraw, Vector2 offset, double scale, RGBA_Bytes silhouetteColor)
		{
			graphics2D.Rasterizer.gamma(new gamma_power(.3));
			PathStorage polygonProjected = new PathStorage();
			foreach (Face face in meshToDraw.Faces)
			{
				if (face.normal.z > 0)
				{
					polygonProjected.remove_all();
					bool first = true;
					foreach (FaceEdge faceEdge in face.FaceEdges())
					{
						Vector2 position = new Vector2(faceEdge.firstVertex.Position.x, faceEdge.firstVertex.Position.y);
						position += offset;
						position *= scale;
						if (first)
						{
							polygonProjected.MoveTo(position.x, position.y);
							first = false;
						}
						else
						{
							polygonProjected.LineTo(position.x, position.y);
						}
					}
					graphics2D.Render(polygonProjected, silhouetteColor);
				}
			}
			graphics2D.Rasterizer.gamma(new gamma_none());
		}
コード例 #6
0
ファイル: TextWidget.cs プロジェクト: jeske/agg-sharp
        public TextWidget(string text, double x = 0, double y = 0, double pointSize = 12, Justification justification = Justification.Left, RGBA_Bytes textColor = new RGBA_Bytes(), bool ellipsisIfClipped = true, bool underline = false, RGBA_Bytes backgroundColor = new RGBA_Bytes())
        {
            Selectable = false;
            DoubleBuffer = DoubleBufferDefault;
            AutoExpandBoundsToText = false;
            EllipsisIfClipped = ellipsisIfClipped; 
            OriginRelativeParent = new Vector2(x, y);
            this.textColor = textColor;
            if (this.textColor.Alpha0To255 == 0)
            {
                // we assume it is the default if alpha 0.  Also there is no reason to make a text color of this as it will draw nothing.
                this.textColor = RGBA_Bytes.Black;
            }
            if (backgroundColor.Alpha0To255 != 0)
            {
                BackgroundColor = backgroundColor;
            }

            base.Text = text;
            StyledTypeFace typeFaceStyle = new StyledTypeFace(LiberationSansFont.Instance, pointSize, underline);
            printer = new TypeFacePrinter(text, typeFaceStyle, justification: justification);

            LocalBounds = printer.LocalBounds;

            MinimumSize = new Vector2(LocalBounds.Width, LocalBounds.Height);
        }
コード例 #7
0
		private int extruderIndex; //For multiple materials

		public PresetSelectorWidget(string label, RGBA_Bytes accentColor, string tag, int extruderIndex)
			: base(FlowDirection.TopToBottom)
		{
			this.extruderIndex = extruderIndex;
			this.filterLabel = label;
			this.filterTag = (tag == null) ? label.ToLower() : tag;
			
			this.HAnchor = HAnchor.ParentLeftRight;
			this.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
			this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			GuiWidget accentBar = new GuiWidget(7, 5)
			{
				BackgroundColor = accentColor,
				HAnchor = HAnchor.ParentLeftRight
			};

			TextWidget labelText = new TextWidget(label.Localize().ToUpper())
			{
				TextColor = ActiveTheme.Instance.PrimaryTextColor,
				HAnchor = Agg.UI.HAnchor.ParentCenter,
				Margin = new BorderDouble(0, 3, 0, 6)
			};

			this.AddChild(labelText);
			this.AddChild(GetPulldownContainer());
			this.AddChild(new VerticalSpacer());
			this.AddChild(accentBar);
		}
コード例 #8
0
		public ControlButtonViewBase(string label,
									 double width,
									 double height,
									 double textHeight,
									 double borderWidth,
									 double borderRadius,
									 double padding,
									 RGBA_Bytes textColor,
									 RGBA_Bytes fillColor,
									 RGBA_Bytes borderColor)
			: base(width, height)
		{
			this.borderRadius = borderRadius;
			this.borderWidth = borderWidth;
			this.fillColor = fillColor;
			this.borderColor = borderColor;
			this.padding = padding;

			TextWidget buttonText = new TextWidget(label, textHeight);
			buttonText.VAnchor = VAnchor.ParentCenter;
			buttonText.HAnchor = HAnchor.ParentCenter;
			buttonText.TextColor = textColor;

			//this.AnchorAll();
			this.AddChild(buttonText);
		}
コード例 #9
0
        public PanelSeparator()
            : base(4, 1)
        {
            AddHandlers();

            defaultBackgroundColor = new RGBA_Bytes(200, 200, 200);
            hoverBackgroundColor = new RGBA_Bytes(100, 100, 100);
            
            Agg.Image.ImageBuffer arrowImage = new Agg.Image.ImageBuffer();
            ImageIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "Icons", "icon_arrow_left_16x16.png"), arrowImage);
            arrowIndicator = new ImageWidget(arrowImage);
            arrowIndicator.HAnchor = Agg.UI.HAnchor.ParentCenter;
            arrowIndicator.VAnchor = Agg.UI.VAnchor.ParentCenter;
            arrowIndicator.Visible = true;

            this.AddChild(arrowIndicator);

            this.Hidden = false;
            this.BackgroundColor = defaultBackgroundColor;
            this.VAnchor = VAnchor.ParentBottomTop;
            this.Margin = new BorderDouble(8, 0);
            this.Cursor = Cursors.Hand;

            SetDisplayState();
        }
コード例 #10
0
ファイル: aa_demo.cs プロジェクト: glocklueng/agg-sharp
		protected override void RenderSolidSingleScanLine(IImageByte destImage, IScanlineCache scanLineCache, RGBA_Bytes color)
		{
			int y = scanLineCache.y();
			int num_spans = scanLineCache.num_spans();
			ScanlineSpan scanlineSpan = scanLineCache.begin();

			byte[] ManagedCoversArray = scanLineCache.GetCovers();
			for (; ; )
			{
				int x = scanlineSpan.x;
				int num_pix = scanlineSpan.len;
				int coverIndex = scanlineSpan.cover_index;

				do
				{
					int a = (ManagedCoversArray[coverIndex++] * color.Alpha0To255) >> 8;
					m_square.draw(destImage.NewGraphics2D().Rasterizer, m_sl, destImage,
									new RGBA_Bytes(color.Red0To255, color.Green0To255, color.Blue0To255, a),
									x, y);
					++x;
				}
				while (--num_pix > 0);
				if (--num_spans == 0) break;
				scanlineSpan = scanLineCache.GetNextScanlineSpan();
			}
		}
コード例 #11
0
			internal HistoryData(int capacity, IColorType lineColor)
			{
				this.lineColor = lineColor.GetAsRGBA_Bytes();
				this.capacity = capacity;
				data = new List<double>();
				Reset();
			}
コード例 #12
0
		public SolidProgressControl(int width = 80, int height = 15)
			: base(width, height)
		{
			this.fillColor = ActiveTheme.Instance.PrimaryAccentColor;
			this.borderColor = ActiveTheme.Instance.PrimaryTextColor;

			this.AfterDraw += new DrawEventHandler(bar_Draw);
		}
コード例 #13
0
 public void CopyPixels(byte[] buffer, int bufferOffset, RGBA_Bytes sourceColor, int count)
 {
     do
     {
         buffer[bufferOffset++] = sourceColor.red;
     }
     while (--count != 0);
 }
コード例 #14
0
ファイル: WhiteToColor.cs プロジェクト: glocklueng/agg-sharp
		public static ImageBuffer CreateWhiteToColor(ImageBuffer normalImage, RGBA_Bytes color)
		{
			ImageBuffer destImage = new ImageBuffer(normalImage.Width, normalImage.Height, 32, new BlenderBGRA());

			DoWhiteToColor(destImage, normalImage, color);

			return destImage;
		}
コード例 #15
0
		public HeightValueDisplay(View3DWidget view3DWidget)
		{
			BackgroundColor = new RGBA_Bytes(RGBA_Bytes.White, 150);
			this.view3DWidget = view3DWidget;
			view3DWidget.meshViewerWidget.AddChild(this);
			VAnchor = VAnchor.FitToChildren;
			HAnchor = HAnchor.FitToChildren;

			MeshViewerToDrawWith.DrawAfter += new DrawEventHandler(MeshViewerToDrawWith_Draw);
		}
コード例 #16
0
		public RenderFeatureExtrusion(Vector3 start, Vector3 end, int extruderIndex, double travelSpeed, double totalExtrusionMm, double filamentDiameterMm, double layerHeight, RGBA_Bytes color)
			: base(start, end, extruderIndex, travelSpeed)
		{
			this.color = color;
            double fillamentRadius = filamentDiameterMm / 2;
			double areaSquareMm = (fillamentRadius * fillamentRadius) * Math.PI;

			this.extrusionVolumeMm3 = (float)(areaSquareMm * totalExtrusionMm);
			this.layerHeight = (float)layerHeight;
		}
コード例 #17
0
		public TextImageWidget(string label, RGBA_Bytes fillColor, RGBA_Bytes borderColor, RGBA_Bytes textColor, double borderWidth, BorderDouble margin, ImageBuffer image = null, double fontSize = 12, FlowDirection flowDirection = FlowDirection.LeftToRight, double height = 40, double width = 0, bool centerText = false, double imageSpacing = 0)
			: base()
		{
			this.image = image;
			this.fillColor = fillColor;
			this.borderColor = borderColor;
			this.borderWidth = borderWidth;
			this.Margin = new BorderDouble(0);
			this.Padding = new BorderDouble(0);

			TextWidget textWidget = new TextWidget(label, pointSize: fontSize);
			ImageWidget imageWidget;

			FlowLayoutWidget container = new FlowLayoutWidget(flowDirection);

			if (centerText)
			{
				// make sure the contents are centered
				GuiWidget leftSpace = new GuiWidget(0, 1);
				leftSpace.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
				container.AddChild(leftSpace);
			}

			if (image != null && image.Width > 0)
			{
				imageWidget = new ImageWidget(image);
				imageWidget.VAnchor = VAnchor.ParentCenter;
				imageWidget.Margin = new BorderDouble(right: imageSpacing);
				container.AddChild(imageWidget);
			}

			if (label != "")
			{
				textWidget.VAnchor = VAnchor.ParentCenter;
				textWidget.TextColor = textColor;
				textWidget.Padding = new BorderDouble(3, 0);
				container.AddChild(textWidget);
			}

			if (centerText)
			{
				GuiWidget rightSpace = new GuiWidget(0, 1);
				rightSpace.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
				container.AddChild(rightSpace);

				container.HAnchor = Agg.UI.HAnchor.ParentLeftRight | Agg.UI.HAnchor.FitToChildren;
			}
			container.VAnchor = Agg.UI.VAnchor.ParentCenter;

			container.MinimumSize = new Vector2(width, height);
			container.Margin = margin;
			this.AddChild(container);
			HAnchor = HAnchor.ParentLeftRight | HAnchor.FitToChildren;
			VAnchor = VAnchor.ParentCenter | Agg.UI.VAnchor.FitToChildren;
		}
コード例 #18
0
ファイル: Gray.cs プロジェクト: jeske/agg-sharp
 public void BlendPixel(byte[] pDestBuffer, int bufferOffset, RGBA_Bytes sourceColor)
 {
     int OneOverAlpha = base_mask - sourceColor.alpha;
     unchecked
     {
         int y = (sourceColor.red * 77) + (sourceColor.green * 151) + (sourceColor.blue * 28);
         int gray = (y>>8);
         gray = (byte)((((gray - (int)(pDestBuffer[bufferOffset])) * sourceColor.alpha) + ((int)(pDestBuffer[bufferOffset]) << base_shift)) >> base_shift);
         pDestBuffer[bufferOffset] = (byte)gray;
     }
 }
コード例 #19
0
ファイル: aa_demo.cs プロジェクト: glocklueng/agg-sharp
		public void draw(ScanlineRasterizer ras, IScanlineCache sl, IImageByte destImage, RGBA_Bytes color,
				  double x, double y)
		{
			ras.reset();
			ras.move_to_d(x * m_size, y * m_size);
			ras.line_to_d(x * m_size + m_size, y * m_size);
			ras.line_to_d(x * m_size + m_size, y * m_size + m_size);
			ras.line_to_d(x * m_size, y * m_size + m_size);
			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			scanlineRenderer.RenderSolid(destImage, ras, sl, color);
		}
コード例 #20
0
ファイル: FloodFiller.cs プロジェクト: glocklueng/agg-sharp
		public FloodFill(RGBA_Bytes fillColor, int tolerance0To255)
		{
			if (tolerance0To255 > 0)
			{
				fillRule = new ToleranceMatch(fillColor, tolerance0To255);
			}
			else
			{
				fillRule = new ExactMatch(fillColor);
			}
		}
コード例 #21
0
		public void RenderSolid(IImageByte destImage, IRasterizer rasterizer, IScanlineCache scanLine, RGBA_Bytes color)
		{
			if (rasterizer.rewind_scanlines())
			{
				scanLine.reset(rasterizer.min_x(), rasterizer.max_x());
				while (rasterizer.sweep_scanline(scanLine))
				{
					RenderSolidSingleScanLine(destImage, scanLine, color);
				}
			}
		}
コード例 #22
0
ファイル: gouraud_mesh.cs プロジェクト: glocklueng/agg-sharp
			public mesh_point(double x_, double y_,
					   double dx_, double dy_,
					   RGBA_Bytes c, RGBA_Bytes dc_)
			{
				x = (x_);
				y = (y_);
				dx = (dx_);
				dy = (dy_);
				color = (c);
				dc = (dc_);
			}
コード例 #23
0
ファイル: Gray.cs プロジェクト: jeske/agg-sharp
 public void CopyPixels(byte[] pDestBuffer, int bufferOffset, RGBA_Bytes sourceColor, int count)
 {
     do
     {
         int y = (sourceColor.red * 77) + (sourceColor.green * 151) + (sourceColor.blue * 28);
         int gray = (y >> 8);
         pDestBuffer[bufferOffset] = (byte)gray;
         bufferOffset += bytesBetweenPixelsInclusive;
     }
     while (--count != 0);
 }
コード例 #24
0
ファイル: SolidSlider.cs プロジェクト: broettge/MatterControl
		public SolidSlideView(SolidSlider sliderWidget)
		{
			sliderAttachedTo = sliderWidget;

			TrackHeight = 10;

			TextColor = RGBA_Bytes.Black;
			TrackColor = new RGBA_Bytes(220, 220, 220);
			ThumbColor = ActiveTheme.Instance.SecondaryAccentColor;

			sliderWidget.ValueChanged += new EventHandler(sliderWidget_ValueChanged);
		}
コード例 #25
0
		protected override void AddChildElements()
		{
			AltGroupBox temperatureGroupBox = new AltGroupBox(new TextWidget("Temperature".Localize(), pointSize: 18, textColor: ActiveTheme.Instance.SecondaryAccentColor));
			temperatureGroupBox.Margin = new BorderDouble(0);

			FlowLayoutWidget mainContainer = new FlowLayoutWidget(Agg.UI.FlowDirection.TopToBottom);
			mainContainer.HAnchor = HAnchor.ParentLeftRight;
			mainContainer.Margin = new BorderDouble(left: 0);

			TextWidget subheader = new TextWidget("Temporarily override target temperature", pointSize: 8, textColor: ActiveTheme.Instance.PrimaryTextColor);
			subheader.Margin = new BorderDouble(bottom: 6);
			mainContainer.AddChild(subheader);

			temperatureGroupBox.AddChild(mainContainer);
			RGBA_Bytes separatorLineColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 100);

			int numberOfHeatedExtruders = 1;
			if (!ActiveSliceSettings.Instance.ExtrudersShareTemperature)
			{
				numberOfHeatedExtruders = ActiveSliceSettings.Instance.ExtruderCount;
			}

			if (numberOfHeatedExtruders > 1)
			{
				for (int i = 0; i < numberOfHeatedExtruders; i++)
				{
					DisableableWidget extruderTemperatureControlWidget = new DisableableWidget();
					extruderTemperatureControlWidget.AddChild(new ExtruderTemperatureControlWidget(i));
					mainContainer.AddChild(extruderTemperatureControlWidget);
					mainContainer.AddChild(new HorizontalLine(separatorLineColor));
					ExtruderWidgetContainers.Add(extruderTemperatureControlWidget);
				}
			}
			else
			{
				DisableableWidget extruderTemperatureControlWidget = new DisableableWidget();
				extruderTemperatureControlWidget.AddChild(new ExtruderTemperatureControlWidget());
				mainContainer.AddChild(extruderTemperatureControlWidget);
				mainContainer.AddChild(new HorizontalLine(separatorLineColor));
				ExtruderWidgetContainers.Add(extruderTemperatureControlWidget);
			}

			BedTemperatureControlWidget = new DisableableWidget();
			BedTemperatureControlWidget.AddChild(new BedTemperatureControlWidget());

			if (ActiveSliceSettings.Instance.HasHeatedBed())
			{
				mainContainer.AddChild(BedTemperatureControlWidget);
			}

			this.AddChild(temperatureGroupBox);
		}
コード例 #26
0
			public WrappingTextWidget(string text, double pointSize = 12, Justification justification = Justification.Left, RGBA_Bytes textColor = new RGBA_Bytes(), bool ellipsisIfClipped = true, bool underline = false, RGBA_Bytes backgroundColor = new RGBA_Bytes())
			{
				unwrappedMessage = text;
				messageContainer = new TextWidget(text, 0, 0, pointSize, justification, textColor, ellipsisIfClipped, underline);
				this.BackgroundColor = backgroundColor;
				messageContainer.AutoExpandBoundsToText = true;
				messageContainer.HAnchor = HAnchor.ParentLeft;
				messageContainer.VAnchor = VAnchor.ParentBottom;
				this.HAnchor = HAnchor.ParentLeftRight;
				this.VAnchor = VAnchor.FitToChildren;

				AddChild(messageContainer);
			}
コード例 #27
0
		public SavePartsSheetFeedbackWindow(int totalParts, string firstPartName, RGBA_Bytes backgroundColor)
			: base(300, 500)
		{
			BackgroundColor = backgroundColor;
			string savePartSheetTitle = LocalizedString.Get("MatterControl");
			string savePartSheetTitleFull = LocalizedString.Get("Saving to Parts Sheet");
			Title = string.Format("{0} - {1}", savePartSheetTitle, savePartSheetTitleFull);
			this.totalParts = totalParts;

			feedback.Padding = new BorderDouble(5, 5);
			feedback.AnchorAll();
			AddChild(feedback);
		}
コード例 #28
0
        public ExportToSdCardFeedbackWindow(int totalParts, string firstPartName, RGBA_Bytes backgroundColor)
            : base(300, 500)
        {
            BackgroundColor = backgroundColor;
            Title = "MatterControl - Exporting to Folder";
            this.totalParts = totalParts;

            feedback.Padding = new BorderDouble(5, 5);
            feedback.AnchorAll();
            AddChild(feedback);

            nextLine = CreateNextLine("");
            feedback.AddChild(nextLine);
        }
コード例 #29
0
		public void pixel_high_res(ImageBuffer sourceImage, RGBA_Bytes[] destBuffer, int destBufferOffset, int x, int y)
		{
			int r, g, b, a;
			r = g = b = a = LineAABasics.line_subpixel_scale * LineAABasics.line_subpixel_scale / 2;

			int weight;
			int x_lr = x >> LineAABasics.line_subpixel_shift;
			int y_lr = y >> LineAABasics.line_subpixel_shift;

			x &= LineAABasics.line_subpixel_mask;
			y &= LineAABasics.line_subpixel_mask;
			int sourceOffset;
			byte[] ptr = sourceImage.GetPixelPointerXY(x_lr, y_lr, out sourceOffset);

			weight = (LineAABasics.line_subpixel_scale - x) *
					 (LineAABasics.line_subpixel_scale - y);
			r += weight * ptr[sourceOffset + ImageBuffer.OrderR];
			g += weight * ptr[sourceOffset + ImageBuffer.OrderG];
			b += weight * ptr[sourceOffset + ImageBuffer.OrderB];
			a += weight * ptr[sourceOffset + ImageBuffer.OrderA];

			sourceOffset += sourceImage.GetBytesBetweenPixelsInclusive();

			weight = x * (LineAABasics.line_subpixel_scale - y);
			r += weight * ptr[sourceOffset + ImageBuffer.OrderR];
			g += weight * ptr[sourceOffset + ImageBuffer.OrderG];
			b += weight * ptr[sourceOffset + ImageBuffer.OrderB];
			a += weight * ptr[sourceOffset + ImageBuffer.OrderA];

			ptr = sourceImage.GetPixelPointerXY(x_lr, y_lr + 1, out sourceOffset);

			weight = (LineAABasics.line_subpixel_scale - x) * y;
			r += weight * ptr[sourceOffset + ImageBuffer.OrderR];
			g += weight * ptr[sourceOffset + ImageBuffer.OrderG];
			b += weight * ptr[sourceOffset + ImageBuffer.OrderB];
			a += weight * ptr[sourceOffset + ImageBuffer.OrderA];

			sourceOffset += sourceImage.GetBytesBetweenPixelsInclusive();

			weight = x * y;
			r += weight * ptr[sourceOffset + ImageBuffer.OrderR];
			g += weight * ptr[sourceOffset + ImageBuffer.OrderG];
			b += weight * ptr[sourceOffset + ImageBuffer.OrderB];
			a += weight * ptr[sourceOffset + ImageBuffer.OrderA];

			destBuffer[destBufferOffset].red = (byte)(r >> LineAABasics.line_subpixel_shift * 2);
			destBuffer[destBufferOffset].green = (byte)(g >> LineAABasics.line_subpixel_shift * 2);
			destBuffer[destBufferOffset].blue = (byte)(b >> LineAABasics.line_subpixel_shift * 2);
			destBuffer[destBufferOffset].alpha = (byte)(a >> LineAABasics.line_subpixel_shift * 2);
		}
コード例 #30
0
		public ViewControlsToggle()
		{
			TextImageButtonFactory iconTextImageButtonFactory = new TextImageButtonFactory();
			iconTextImageButtonFactory.AllowThemeToAdjustImage = false;
			iconTextImageButtonFactory.checkedBorderColor = RGBA_Bytes.White;

			BackgroundColor = new RGBA_Bytes(0, 0, 0, 120);

			iconTextImageButtonFactory.FixedHeight = buttonHeight;
			iconTextImageButtonFactory.FixedWidth = buttonHeight;

			string select2dIconPath = Path.Combine("ViewTransformControls", "2d.png");
			twoDimensionButton = iconTextImageButtonFactory.GenerateRadioButton("", select2dIconPath);
			twoDimensionButton.Margin = new BorderDouble(3);
			AddChild(twoDimensionButton);

			string select3dIconPath = Path.Combine("ViewTransformControls", "3d.png");
			threeDimensionButton = iconTextImageButtonFactory.GenerateRadioButton("", select3dIconPath);
			threeDimensionButton.Margin = new BorderDouble(3);

			if (ActiveTheme.Instance.DisplayMode != ActiveTheme.ApplicationDisplayType.Touchscreen)
			{
				AddChild(threeDimensionButton);

				if (UserSettings.Instance.get("LayerViewDefault") == "3D Layer"
					&&
					(UserSettings.Instance.Fields.StartCountDurringExit == UserSettings.Instance.Fields.StartCount - 1
					|| userChangedTo3DThisRun)
					)
				{
					threeDimensionButton.Checked = true;
				}
				else
				{
					twoDimensionButton.Checked = true;
				}
			}
			else
			{
				twoDimensionButton.Checked = true;
			}

			threeDimensionButton.Click += (sender, e) =>
			{
				userChangedTo3DThisRun = true;
			};
			Margin = new BorderDouble(5, 5, 200, 5);
			HAnchor |= Agg.UI.HAnchor.ParentRight;
			VAnchor = Agg.UI.VAnchor.ParentTop;
		}
コード例 #31
0
ファイル: FontHinting.cs プロジェクト: asmboom/PixelFarm
        protected override void RenderSolidSingleScanLine(IImageByte destImage, IScanlineCache scanLineCache, RGBA_Bytes color)
        {
            int          y            = scanLineCache.y();
            int          num_spans    = scanLineCache.num_spans();
            ScanlineSpan scanlineSpan = scanLineCache.begin();

            byte[] ManagedCoversArray = scanLineCache.GetCovers();
            for (; ;)
            {
                int x          = scanlineSpan.x;
                int num_pix    = scanlineSpan.len;
                int coverIndex = scanlineSpan.cover_index;

                do
                {
                    int a = (ManagedCoversArray[coverIndex++] * color.Alpha0To255) >> 8;
                    m_square.draw(destImage.NewGraphics2D().Rasterizer, m_sl, destImage,
                                  new RGBA_Bytes(color.Red0To255, color.Green0To255, color.Blue0To255, a),
                                  x, y);
                    ++x;
                }while (--num_pix > 0);
                if (--num_spans == 0)
                {
                    break;
                }
                scanlineSpan = scanLineCache.GetNextScanlineSpan();
            }
        }
コード例 #32
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            if (graphics2D.DestImage != null)
            {
                ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

                IImageByte backBuffer = widgetsSubImage;

                int         distBetween    = backBuffer.GetBytesBetweenPixelsInclusive();
                ImageBuffer redImageBuffer = new ImageBuffer();
                redImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 2, 8);
                ImageBuffer greenImageBuffer = new ImageBuffer();
                greenImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 1, 8);
                ImageBuffer blueImageBuffer = new ImageBuffer();
                blueImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 0, 8);

                ImageClippingProxy clippingProxy      = new ImageClippingProxy(backBuffer);
                ImageClippingProxy clippingProxyRed   = new ImageClippingProxy(redImageBuffer);
                ImageClippingProxy clippingProxyGreen = new ImageClippingProxy(greenImageBuffer);
                ImageClippingProxy clippingProxyBlue  = new ImageClippingProxy(blueImageBuffer);

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

                Color clearColor = useBlackBackgroundCheckbox.Checked ? new Color(0, 0, 0) : new Color(255, 255, 255);
                clippingProxy.clear(clearColor);
                alphaSlider.View.BackgroundColor = clearColor;

                Color FillColor = useBlackBackgroundCheckbox.Checked ? new Color(255, 255, 255, (int)(alphaSlider.Value)) : new Color(0, 0, 0, (int)(alphaSlider.Value));

                VertexSource.Ellipse er = new MatterHackers.Agg.VertexSource.Ellipse(Width / 2 - 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100);
                ras.add_path(er);
                ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
                scanlineRenderer.RenderSolid(clippingProxyRed, ras, sl, FillColor);

                VertexSource.Ellipse eg = new MatterHackers.Agg.VertexSource.Ellipse(Width / 2 + 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100);
                ras.add_path(eg);
                scanlineRenderer.RenderSolid(clippingProxyGreen, ras, sl, FillColor);

                VertexSource.Ellipse eb = new MatterHackers.Agg.VertexSource.Ellipse(Width / 2, Height / 2 + 50, 100, 100, 100);
                ras.add_path(eb);
                scanlineRenderer.RenderSolid(clippingProxyBlue, ras, sl, FillColor);
            }
            else if (graphics2D.DestImageFloat != null)
            {
#if false
                IImageFloat backBuffer = graphics2D.DestImageFloat;

                int distBetween = backBuffer.GetFloatsBetweenPixelsInclusive();
                ImageBufferFloat redImageBuffer = new ImageBufferFloat();
                redImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 2, 8);
                ImageBufferFloat greenImageBuffer = new ImageBufferFloat();
                greenImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 1, 8);
                ImageBufferFloat blueImageBuffer = new ImageBufferFloat();
                blueImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 0, 8);

                ImageClippingProxy clippingProxy      = new ImageClippingProxy(backBuffer);
                ImageClippingProxy clippingProxyRed   = new ImageClippingProxy(redImageBuffer);
                ImageClippingProxy clippingProxyGreen = new ImageClippingProxy(greenImageBuffer);
                ImageClippingProxy clippingProxyBlue  = new ImageClippingProxy(blueImageBuffer);

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

                RGBA_Bytes clearColor = useBlackBackgroundCheckbox.Checked ? new RGBA_Bytes(0, 0, 0) : new RGBA_Bytes(255, 255, 255);
                clippingProxy.clear(clearColor);
                alphaSlider.View.BackGroundColor = clearColor;

                RGBA_Bytes FillColor = useBlackBackgroundCheckbox.Checked ? new RGBA_Bytes(255, 255, 255, (int)(alphaSlider.Value)) : new RGBA_Bytes(0, 0, 0, (int)(alphaSlider.Value));

                VertexSource.Ellipse er = new AGG.VertexSource.Ellipse(Width / 2 - 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100);
                ras.add_path(er);
                agg_renderer_scanline.Default.render_scanlines_aa_solid(clippingProxyRed, ras, sl, FillColor);

                VertexSource.Ellipse eg = new AGG.VertexSource.Ellipse(Width / 2 + 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100);
                ras.add_path(eg);
                agg_renderer_scanline.Default.render_scanlines_aa_solid(clippingProxyGreen, ras, sl, FillColor);

                VertexSource.Ellipse eb = new AGG.VertexSource.Ellipse(Width / 2, Height / 2 + 50, 100, 100, 100);
                ras.add_path(eb);
                agg_renderer_scanline.Default.render_scanlines_aa_solid(clippingProxyBlue, ras, sl, FillColor);
#endif
            }

            base.OnDraw(graphics2D);
        }
コード例 #33
0
        public TextEditPage()
            : base("Text Edit Widget")
        {
            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            BackgroundColor     = new RGBA_Bytes(210, 210, 255);
            topToBottom.Padding = new BorderDouble(20);

            topToBottom.AddChild(new TextWidget("testing underline jpqy", underline: true));
            topToBottom.AddChild(new TextWidget("testing1\ntest2\ntest3"));

            topToBottom.AddChild(new TextWidget("this is some multiline\ntext\nwith centering", justification: Justification.Center));

            int tabIndex = 0;

#if true
            InternalTextEditWidget internalMultiLine = new InternalTextEditWidget("line1\nline2\nline3", 12, true, tabIndex++);
            //InternalTextEditWidget internalMultiLine = new InternalTextEditWidget("Line 1 - Multi Line Text Control\nLine 2 - Multi Line Text Control\nLine 3 - Multi Line Text Control\n", 12, true);
            topToBottom.AddChild(internalMultiLine);
#endif
            // show some masking for passwords
            {
                FlowLayoutWidget leftToRight = new FlowLayoutWidget();
                leftToRight.Margin = new BorderDouble(3);
                TextEditWidget passwordeTextEdit = new TextEditWidget("Password", tabIndex: tabIndex++);
                //passwordeTextEdit.InternalTextEditWidget.MaskCharacter = '*';
                passwordeTextEdit.Margin = new BorderDouble(4, 0);
                leftToRight.AddChild(passwordeTextEdit);

                TextWidget description = new TextWidget("Content:");
                leftToRight.AddChild(description);

                TextWidget passwordContent = new TextWidget("Password");
                leftToRight.AddChild(passwordContent);

                passwordeTextEdit.TextChanged += (sender, e) =>
                {
                    passwordContent.Text = passwordeTextEdit.Text;
                };

                topToBottom.AddChild(leftToRight);
            }

            TextEditWidget singleLineTextEdit = new TextEditWidget("Single Line Edit Text Control", tabIndex: tabIndex++);
            topToBottom.AddChild(singleLineTextEdit);

            TextEditWidget multiLineTextConrol = new TextEditWidget("Line 1 - Multi Line Text Control\nLine 2 - Multi Line Text Control\nLine 3 - Multi Line Text Control\n", tabIndex: tabIndex++);
            multiLineTextConrol.Multiline = true;
            topToBottom.AddChild(multiLineTextConrol);

            TextEditWidget longTextWidget = new TextEditWidget("This is some really long text.", pixelWidth: 100, tabIndex: tabIndex++);
            topToBottom.AddChild(longTextWidget);

            topToBottom.AddChild(new TextWidget("Integer Text Control:"));
            topToBottom.AddChild(new NumberEdit(512102416, tabIndex: tabIndex++));

            topToBottom.AddChild(new TextWidget("Floating Point Text Control:"));
            topToBottom.AddChild(new NumberEdit(512102416, allowNegatives: true, allowDecimals: true, tabIndex: tabIndex++));

            TextWidget paddingAdjustText = new TextWidget("Padding: 0");
            paddingAdjustText.AutoExpandBoundsToText = true;
            topToBottom.AddChild(paddingAdjustText);

            TextEditWidget paddingAdjustTextEdit = new TextEditWidget("Edit With Padding", tabIndex: tabIndex++);
            GuiWidget      paddingAroundTextEdit = new GuiWidget(100, 16);
            topToBottom.AddChild(paddingAroundTextEdit);
            paddingAroundTextEdit.AddChild(paddingAdjustTextEdit);
            paddingAdjustText.SetBoundsToEncloseChildren();

            //AddChild(new TextEditWidget("Multiline Edit Text Widget line 1\nline 2\nline 3", 200, 400, 200, 80, multiLine: true));
            AddChild(topToBottom);

            foreach (GuiWidget child in topToBottom.Children)
            {
                //child.Padding = new BorderDouble(4);
                child.HAnchor         = UI.HAnchor.ParentCenter;
                child.BackgroundColor = RGBA_Bytes.White;
                //child.Margin = new BorderDouble(3);
                if (child is TextWidget)
                {
                    child.BackgroundColor = new RGBA_Bytes(255, 200, 200);
                }
            }

            Slider textPaddingSlider = new Slider(new Vector2(), 200, 0, 10);
            topToBottom.AddChild(textPaddingSlider);
            textPaddingSlider.ValueChanged += (sender, e) =>
            {
                double padding = ((Slider)sender).Value;
                paddingAdjustText.Padding = new BorderDouble(padding);

                paddingAroundTextEdit.Padding = new BorderDouble(padding);
                paddingAroundTextEdit.SetBoundsToEncloseChildren();
                ((Slider)sender).Parent.SetBoundsToEncloseChildren();
            };

            topToBottom.HAnchor = UI.HAnchor.ParentCenter;
            topToBottom.VAnchor = UI.VAnchor.ParentCenter;
        }
コード例 #34
0
ファイル: FontHinting.cs プロジェクト: asmboom/PixelFarm
        public void draw(ScanlineRasterizer ras, IScanlineCache sl, IImageByte destImage, RGBA_Bytes color,
                         double x, double y)
        {
            ras.reset();
            ras.move_to_d(x * m_size, y * m_size);
            ras.line_to_d(x * m_size + m_size, y * m_size);
            ras.line_to_d(x * m_size + m_size, y * m_size + m_size);
            ras.line_to_d(x * m_size, y * m_size + m_size);
            ScanlineRenderer scanlineRenderer = new ScanlineRenderer();

            scanlineRenderer.render_scanlines_aa_solid(destImage, ras, sl, color);
        }
コード例 #35
0
            public void generate(int cols, int rows,
                                 double cell_w, double cell_h,
                                 double start_x, double start_y)
            {
                m_cols    = cols;
                m_rows    = rows;
                m_cell_w  = cell_w;
                m_cell_h  = cell_h;
                m_start_x = start_x;
                m_start_y = start_y;

                m_vertices.remove_all();
                for (int i = 0; i < m_rows; i++)
                {
                    double x = start_x;
                    for (int j = 0; j < m_cols; j++)
                    {
                        double     dx = random(-0.5, 0.5);
                        double     dy = random(-0.5, 0.5);
                        RGBA_Bytes c  = new RGBA_Bytes(rand.Next() & 0xFF, rand.Next() & 0xFF, rand.Next() & 0xFF);
                        RGBA_Bytes dc = new RGBA_Bytes(rand.Next() & 1, rand.Next() & 1, rand.Next() & 1);
                        m_vertices.add(new mesh_point(x, start_y, dx, dy, c, dc));
                        x += cell_w;
                    }
                    start_y += cell_h;
                }



                //  4---3
                //  |t2/|
                //  | / |
                //  |/t1|
                //  1---2
                m_triangles.remove_all();
                m_edges.remove_all();
                for (int i = 0; i < m_rows - 1; i++)
                {
                    for (int j = 0; j < m_cols - 1; j++)
                    {
                        int p1 = i * m_cols + j;
                        int p2 = p1 + 1;
                        int p3 = p2 + m_cols;
                        int p4 = p1 + m_cols;
                        m_triangles.add(new mesh_triangle((int)p1, (int)p2, (int)p3));
                        m_triangles.add(new mesh_triangle((int)p3, (int)p4, (int)p1));

                        int curr_cell = i * (m_cols - 1) + j;
                        int left_cell = j != 0 ? (int)(curr_cell - 1) : -1;
                        int bott_cell = i != 0 ? (int)(curr_cell - (m_cols - 1)) : -1;

                        int curr_t1 = curr_cell * 2;
                        int curr_t2 = curr_t1 + 1;

                        int left_t1 = (left_cell >= 0) ? left_cell * 2 : -1;
                        int left_t2 = (left_cell >= 0) ? left_t1 + 1 : -1;

                        int bott_t1 = (bott_cell >= 0) ? bott_cell * 2 : -1;
                        int bott_t2 = (bott_cell >= 0) ? bott_t1 + 1 : -1;

                        m_edges.add(new mesh_edge((int)p1, (int)p2, curr_t1, bott_t2));
                        m_edges.add(new mesh_edge((int)p1, (int)p3, curr_t2, curr_t1));
                        m_edges.add(new mesh_edge((int)p1, (int)p4, left_t1, curr_t2));

                        if (j == m_cols - 2) // Last column
                        {
                            m_edges.add(new mesh_edge((int)p2, (int)p3, curr_t1, -1));
                        }

                        if (i == m_rows - 2) // Last row
                        {
                            m_edges.add(new mesh_edge((int)p3, (int)p4, curr_t2, -1));
                        }
                    }
                }
            }