public override void OnDraw(Graphics2D graphics2D) { GameImageSequence menuBackground = (GameImageSequence)DataAssetCache.Instance.GetAsset(typeof(GameImageSequence), "CreditsScreen"); graphics2D.Render(menuBackground.GetImageByIndex(0), 0, 0); base.OnDraw(graphics2D); }
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()); }
public override void OnDraw(Graphics2D graphics2D) { graphics2D.Rectangle(LocalBounds, RGBA_Bytes.Black); RoundedRect boundsRect = new RoundedRect(dragBar.BoundsRelativeToParent, 0); graphics2D.Render(boundsRect, DragBarColor); base.OnDraw(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { GameImageSequence background = (GameImageSequence)DataAssetCache.Instance.GetAsset(typeof(GameImageSequence), "GameBackground"); graphics2D.Render(background.GetImageByIndex(0), 0, 0); m_Playfield.Draw(graphics2D); base.OnDraw(graphics2D); }
private void DrawBorder(Graphics2D graphics2D) { if (borderColor.Alpha0To255 > 0) { RectangleDouble boarderRectangle = LocalBounds; RoundedRect rectBorder = new RoundedRect(boarderRectangle, 0); graphics2D.Render(new Stroke(rectBorder, borderWidth), borderColor); } }
public override void OnDraw(Graphics2D graphics2D) { RectangleDouble Bounds = LocalBounds; RoundedRect rectBorder = new RoundedRect(Bounds, this.borderRadius); graphics2D.Render(rectBorder, borderColor); RectangleDouble insideBounds = Bounds; insideBounds.Inflate(-this.borderWidth); RoundedRect rectInside = new RoundedRect(insideBounds, Math.Max(this.borderRadius - this.borderWidth, 0)); graphics2D.Render(rectInside, this.fillColor); base.OnDraw(graphics2D); }
public FloodFillDemo() { BackgroundColor = RGBA_Bytes.White; imageToFillOn = new ImageBuffer(400, 300, 32, new BlenderBGRA()); Graphics2D imageToFillGraphics = imageToFillOn.NewGraphics2D(); imageToFillGraphics.Clear(RGBA_Bytes.White); imageToFillGraphics.DrawString("Click to fill", 20, 30); imageToFillGraphics.Circle(new Vector2(200, 150), 35, RGBA_Bytes.Black); imageToFillGraphics.Circle(new Vector2(200, 150), 30, RGBA_Bytes.Green); imageToFillGraphics.Rectangle(20, 50, 210, 280, RGBA_Bytes.Black); imageToFillGraphics.Rectangle(imageToFillOn.GetBounds(), RGBA_Bytes.Blue); Random rand = new Random(); for (int i = 0; i < 20; i++) { Ellipse elipse = new Ellipse(rand.Next(imageToFillOn.Width), rand.Next(imageToFillOn.Height), rand.Next(10, 60), rand.Next(10, 60)); Stroke outline = new Stroke(elipse); imageToFillGraphics.Render(outline, RGBA_Bytes.Black); } m_slider1 = new Slider(new Vector2(80, 10), 510); m_slider2 = new Slider(new Vector2(80, 10 + 20), 510); m_slider1.ValueChanged += new EventHandler(NeedsRedraw); m_slider2.ValueChanged += new EventHandler(NeedsRedraw); AddChild(m_slider1); AddChild(m_slider2); m_slider1.Text = "Pixel size={0:F3}"; m_slider1.SetRange(8, 100); m_slider1.NumTicks = 23; m_slider1.Value = 32; m_slider2.Text = "gamma={0:F3}"; m_slider2.SetRange(0.0, 3.0); m_slider2.Value = 1.0; }
public override void OnDraw(Graphics2D graphics2D) { byte alpha = (byte)(alphaSlider.Value * 255); for (int i = 0; i < lionShape.NumPaths; i++) { lionShape.Colors[i].Alpha0To255 = alpha; } Affine transform = Affine.NewIdentity(); transform *= Affine.NewTranslation(-lionShape.Center.x, -lionShape.Center.y); transform *= Affine.NewScaling(lionScale, lionScale); transform *= Affine.NewRotation(angle + Math.PI); transform *= Affine.NewSkewing(skewX / 1000.0, skewY / 1000.0); transform *= Affine.NewTranslation(Width / 2, Height / 2); // This code renders the lion: VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(lionShape.Path, transform); graphics2D.Render(transformedPathStorage, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths); base.OnDraw(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { byte alpha = (byte)(alphaSlider.Value * 255); for (int i = 0; i < lionShape.NumPaths; i++) { lionShape.Colors[i].Alpha0To255 = alpha; } Affine transform = Affine.NewIdentity(); transform *= Affine.NewTranslation(-lionShape.Center.x, -lionShape.Center.y); transform *= Affine.NewScaling(lionScale, lionScale); transform *= Affine.NewRotation(angle + Math.PI); transform *= Affine.NewSkewing(skewX / 1000.0, skewY / 1000.0); transform *= Affine.NewTranslation(Width / 2, Height / 2); // This code renders the lion: VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(lionShape.Path, transform); graphics2D.Render(transformedPathStorage, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths); base.OnDraw(graphics2D); }
private void Initialize(ImageBuffer sourceImage, RectangleInt boundsToCopyFrom) { if (sourceImage == this) { throw new Exception("We do not create a temp buffer for this to work. You must have a source distinct from the dest."); } Deallocate(); Allocate(boundsToCopyFrom.Width, boundsToCopyFrom.Height, boundsToCopyFrom.Width * sourceImage.BitDepth / 8, sourceImage.BitDepth); SetRecieveBlender(sourceImage.GetRecieveBlender()); if (width != 0 && height != 0) { RectangleInt DestRect = new RectangleInt(0, 0, boundsToCopyFrom.Width, boundsToCopyFrom.Height); RectangleInt AbsoluteSourceRect = boundsToCopyFrom; // The first thing we need to do is make sure the frame is cleared. LBB [3/15/2004] MatterHackers.Agg.Graphics2D graphics2D = NewGraphics2D(); graphics2D.Clear(new RGBA_Bytes(0, 0, 0, 0)); int x = -boundsToCopyFrom.Left - (int)sourceImage.OriginOffset.x; int y = -boundsToCopyFrom.Bottom - (int)sourceImage.OriginOffset.y; graphics2D.Render(sourceImage, x, y, 0, 1, 1); } }
public override void OnDraw(Graphics2D graphics2D) { base.OnDraw(graphics2D); RectangleDouble Bounds = LocalBounds; RoundedRect borderRect = new RoundedRect(this.LocalBounds, 0); Stroke strokeRect = new Stroke(borderRect, borderWidth); graphics2D.Render(strokeRect, borderColor); }
public override void OnDraw(Graphics2D graphics2D) { // get the bounds of all the points var bounds = RectangleDouble.ZeroIntersection; foreach (var poly in Polygons) { foreach (var point in poly) { bounds.ExpandToInclude(point); } } // prep for scaling var transform = Affine.NewTranslation(-bounds.Left, -bounds.Bottom); // scale to window var scale = Math.Min(Width / bounds.Width, Height / bounds.Height); transform *= Affine.NewScaling(scale); // scale for boarder transform *= Affine.NewScaling(.9); // move for boarder transform *= Affine.NewTranslation(Width / 20, Height / 20); // draw all the triangles var index = 0; foreach (var poly in Polygons) { var numPoints = poly.Count; if (numPoints > 2) { var first = true; var vertexStorage = new VertexStorage(); for (int i = 0; i < numPoints; i++) { var p0 = poly[i]; if (first) { vertexStorage.MoveTo(p0); first = false; } else { vertexStorage.LineTo(p0); } } graphics2D.Render(new VertexSourceApplyTransform(vertexStorage, transform), 0, 0, colors[index].WithAlpha(190)); } else if (numPoints > 1) { var p0 = poly[numPoints - 1]; var p1 = poly[numPoints - 2]; graphics2D.Line(transform.Transform(p0), transform.Transform(p1), colors[index]); } index++; } base.OnDraw(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { if (borderColor.Alpha0To255 > 0) { RectangleDouble borderRectangle = LocalBounds; if (borderWidth > 0) { if (borderWidth == 1) { graphics2D.Rectangle(borderRectangle, borderColor); } else { //boarderRectangle.Inflate(-borderWidth / 2); RoundedRect rectBorder = new RoundedRect(borderRectangle, this.borderRadius); graphics2D.Render(new Stroke(rectBorder, borderWidth), borderColor); } } } if (this.fillColor.Alpha0To255 > 0) { RectangleDouble insideBounds = LocalBounds; insideBounds.Inflate(-this.borderWidth); RoundedRect rectInside = new RoundedRect(insideBounds, Math.Max(this.borderRadius - this.borderWidth, 0)); graphics2D.Render(rectInside, this.fillColor); } base.OnDraw(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { if (loadedGCode != null) { Affine transform = TotalTransform; CreateGrid(transform); double gridLineWidths = 0.2 * layerScale; Stroke stroke = new Stroke(grid, gridLineWidths); if (RenderGrid) { graphics2D.Render(stroke, new RGBA_Bytes(190, 190, 190, 255)); } RenderType renderType = RenderType.Extrusions; if (RenderMoves) { renderType |= RenderType.Moves; } if (RenderRetractions) { renderType |= RenderType.Retractions; } if (RenderSpeeds) { renderType |= RenderType.SpeedColors; } if (SimulateExtrusion) { renderType |= RenderType.SimulateExtrusion; } gCodeRenderer.Render(graphics2D, activeLayerIndex, transform, layerScale, renderType, FeatureToStartOnRatio0To1, FeatureToEndOnRatio0To1); } base.OnDraw(graphics2D); }
private double PrintTopOfPage(ImageBuffer plateInventoryImage, Graphics2D plateGraphics) { plateGraphics.Clear(RGBA_Bytes.White); double currentlyPrintingHeightPixels = plateInventoryImage.Height - PageMarginMM.Top * PixelPerMM; string logoPathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "PartSheetLogo.png"); if(File.Exists(logoPathAndFile)) { ImageBuffer logoImage = new ImageBuffer(); ImageIO.LoadImageData(logoPathAndFile, logoImage); currentlyPrintingHeightPixels -= logoImage.Height; plateGraphics.Render(logoImage, (plateInventoryImage.Width - logoImage.Width) / 2, currentlyPrintingHeightPixels); } currentlyPrintingHeightPixels -= PartPaddingPixels; double underlineHeightMM = 1; RectangleDouble lineBounds = new RectangleDouble(0, 0, plateInventoryImage.Width - PageMarginPixels.Left * 2, underlineHeightMM * PixelPerMM); lineBounds.Offset(PageMarginPixels.Left, currentlyPrintingHeightPixels - lineBounds.Height); plateGraphics.FillRectangle(lineBounds, RGBA_Bytes.Black); return currentlyPrintingHeightPixels - (lineBounds.Height + PartPaddingPixels); }
public override void OnDraw(Graphics2D graphics2D) { graphics2D.Render(imageToFillOn, imageOffset); base.OnDraw(graphics2D); }
public void DrawTo(Graphics2D graphics2D, Mesh meshToDraw, RGBA_Bytes partColorIn, double minZ, double maxZ) { RGBA_Floats partColor = partColorIn.GetAsRGBA_Floats(); graphics2D.Rasterizer.gamma(new gamma_power(.3)); RenderPoint[] points = new RenderPoint[3] { new RenderPoint(), new RenderPoint(), new RenderPoint() }; foreach (Face face in meshToDraw.Faces) { int i = 0; Vector3 normal = Vector3.TransformVector(face.normal, trackballTumbleWidget.ModelviewMatrix).GetNormal(); if (normal.z > 0) { foreach (FaceEdge faceEdge in face.FaceEdges()) { points[i].position = trackballTumbleWidget.GetScreenPosition(faceEdge.firstVertex.Position); Vector3 transformedPosition = Vector3.TransformPosition(faceEdge.firstVertex.Position, trackballTumbleWidget.ModelviewMatrix); points[i].z = transformedPosition.z; i++; } RGBA_Floats polyDrawColor = new RGBA_Floats(); double L = Vector3.Dot(lightNormal, normal); if (L > 0.0f) { polyDrawColor = partColor * lightIllumination * L; } polyDrawColor = RGBA_Floats.ComponentMax(polyDrawColor, partColor * ambiantIllumination); for (i = 0; i < 3; i++) { double ratio = (points[i].z - minZ) / (maxZ - minZ); int ratioInt16 = (int)(ratio * 65536); points[i].color = new RGBA_Bytes(polyDrawColor.Red0To255, ratioInt16 >> 8, ratioInt16 & 0xFF); } #if true scanline_unpacked_8 sl = new scanline_unpacked_8(); ScanlineRasterizer ras = new ScanlineRasterizer(); render_gouraud(graphics2D.DestImage, sl, ras, points); #else IRecieveBlenderByte oldBlender = graphics2D.DestImage.GetRecieveBlender(); graphics2D.DestImage.SetRecieveBlender(new BlenderZBuffer()); graphics2D.Render(polygonProjected, renderColor); graphics2D.DestImage.SetRecieveBlender(oldBlender); #endif byte[] buffer = graphics2D.DestImage.GetBuffer(); int pixels = graphics2D.DestImage.Width * graphics2D.DestImage.Height; for (int pixelIndex = 0; pixelIndex < pixels; pixelIndex++) { buffer[pixelIndex * 4 + ImageBuffer.OrderR] = buffer[pixelIndex * 4 + ImageBuffer.OrderR]; buffer[pixelIndex * 4 + ImageBuffer.OrderG] = buffer[pixelIndex * 4 + ImageBuffer.OrderR]; buffer[pixelIndex * 4 + ImageBuffer.OrderB] = buffer[pixelIndex * 4 + ImageBuffer.OrderR]; } } } }
public static void Main(string[] args) { // first we will show how to use the simple drawing functions in graphics 2D { ImageBuffer simpleImage = new ImageBuffer(640, 480, 32, new BlenderBGRA()); Graphics2D simpleImageGraphics2D = simpleImage.NewGraphics2D(); // clear the image to white simpleImageGraphics2D.Clear(Color.White); // draw a circle simpleImageGraphics2D.Circle(50, 50, 30, Color.Blue); // draw a line simpleImageGraphics2D.Line(10, 100, 520, 50, new Color(20, 200, 200)); // draw a filled box simpleImageGraphics2D.FillRectangle(60, 260, 200, 280, Color.Yellow); // and an outline around it simpleImageGraphics2D.Rectangle(60, 260, 200, 280, Color.Magenta); // draw some text simpleImageGraphics2D.DrawString("A Simple Example", 300, 400, 20); // and save this image out ImageTgaIO.Save(simpleImage, "SimpleDrawAndSave.tga"); } // now we will we will show how to use the render function to draw more complex things { ImageBuffer lessSimpleImage = new ImageBuffer(640, 480, 32, new BlenderBGRA()); Graphics2D lessSimpleImageGraphics2D = lessSimpleImage.NewGraphics2D(); // clear the image to white lessSimpleImageGraphics2D.Clear(Color.White); // draw a circle Ellipse ellipseTest = new Ellipse(0, 0, 100, 50); for (double angleDegrees = 0; angleDegrees < 180; angleDegrees += 22.5) { VertexSourceApplyTransform rotatedTransform = new VertexSourceApplyTransform(ellipseTest, Affine.NewRotation(MathHelper.DegreesToRadians(angleDegrees))); VertexSourceApplyTransform rotatedAndTranslatedTransform = new VertexSourceApplyTransform(rotatedTransform, Affine.NewTranslation(lessSimpleImage.Width / 2, 150)); lessSimpleImageGraphics2D.Render(rotatedAndTranslatedTransform, Color.Yellow); Stroke ellipseOutline = new Stroke(rotatedAndTranslatedTransform, 3); lessSimpleImageGraphics2D.Render(ellipseOutline, Color.Blue); } // and a little polygon VertexStorage littlePoly = new VertexStorage(); littlePoly.MoveTo(50, 50); littlePoly.LineTo(150, 50); littlePoly.LineTo(200, 200); littlePoly.LineTo(50, 150); littlePoly.LineTo(50, 50); lessSimpleImageGraphics2D.Render(littlePoly, Color.Cyan); // draw some text TypeFacePrinter textPrinter = new TypeFacePrinter("Printing from a printer", 30, justification: Justification.Center); IVertexSource translatedText = new VertexSourceApplyTransform(textPrinter, Affine.NewTranslation(new Vector2(lessSimpleImage.Width / 2, lessSimpleImage.Height / 4 * 3))); lessSimpleImageGraphics2D.Render(translatedText, Color.Red); Stroke strokedText = new Stroke(translatedText); lessSimpleImageGraphics2D.Render(strokedText, Color.Black); IVertexSource rotatedText = new VertexSourceApplyTransform(textPrinter, Affine.NewRotation(MathHelper.DegreesToRadians(90))); IVertexSource rotatedTranslatedText = new VertexSourceApplyTransform(rotatedText, Affine.NewTranslation(new Vector2(40, lessSimpleImage.Height / 2))); lessSimpleImageGraphics2D.Render(rotatedTranslatedText, Color.Black); // and save this image out ImageTgaIO.Save(lessSimpleImage, "LessSimpleDrawAndSave.tga"); } }
public override void OnDraw(Graphics2D graphics2D) { if (this.queueDataView.EditMode) { selectionCheckBoxContainer.Visible = true; actionButtonContainer.Visible = false; } else { selectionCheckBoxContainer.Visible = false; } base.OnDraw(graphics2D); RectangleDouble Bounds = LocalBounds; RoundedRect rectBorder = new RoundedRect(Bounds, 0); if (this.isActivePrint && !this.queueDataView.EditMode) { this.BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor; SetTextColors(RGBA_Bytes.White); this.viewButton.BackgroundColor = RGBA_Bytes.White; this.viewButtonLabel.TextColor = ActiveTheme.Instance.SecondaryAccentColor; //Draw interior border graphics2D.Render(new Stroke(rectBorder, 3), ActiveTheme.Instance.SecondaryAccentColor); } else if (this.isSelectedItem) { this.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor; this.partLabel.TextColor = RGBA_Bytes.White; this.partStatus.TextColor = RGBA_Bytes.White; this.selectionCheckBox.TextColor = RGBA_Bytes.White; this.viewButton.BackgroundColor = RGBA_Bytes.White; this.viewButtonLabel.TextColor = ActiveTheme.Instance.SecondaryAccentColor; } else if (this.IsHoverItem) { this.BackgroundColor = RGBA_Bytes.White; this.partLabel.TextColor = RGBA_Bytes.Black; this.selectionCheckBox.TextColor = RGBA_Bytes.Black; this.partStatus.TextColor = RGBA_Bytes.Black; this.viewButton.BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor; this.viewButtonLabel.TextColor = RGBA_Bytes.White; //Draw interior border graphics2D.Render(new Stroke(rectBorder, 3), ActiveTheme.Instance.SecondaryAccentColor); } else { this.BackgroundColor = new RGBA_Bytes(255, 255, 255, 255); SetTextColors(RGBA_Bytes.Black); this.selectionCheckBox.TextColor = RGBA_Bytes.Black; this.partStatus.TextColor = RGBA_Bytes.Black; this.viewButton.BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor; this.viewButtonLabel.TextColor = RGBA_Bytes.White; } }
public override void OnDraw(Graphics2D graphics2D) { base.OnDraw(graphics2D); RectangleDouble boarderRectangle = LocalBounds; RoundedRect rectBorder = new RoundedRect(boarderRectangle, 0); graphics2D.Render(new Stroke(rectBorder, 1), new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200)); }
public override void Render(Graphics2D graphics2D, Affine transform, double layerScale, RenderType renderType) { if ((renderType & RenderType.Extrusions) == RenderType.Extrusions) { double extrusionLineWidths = 0.2 * layerScale; RGBA_Bytes extrusionColor = RGBA_Bytes.Black; //extrusionColor = color; PathStorage pathStorage = new PathStorage(); VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(pathStorage, transform); Stroke stroke = new Stroke(transformedPathStorage, extrusionLineWidths); stroke.line_cap(LineCap.Round); stroke.line_join(LineJoin.Round); pathStorage.Add(start.x, start.y, ShapePath.FlagsAndCommand.CommandMoveTo); pathStorage.Add(end.x, end.y, ShapePath.FlagsAndCommand.CommandLineTo); graphics2D.Render(stroke, 0, extrusionColor); } }
public override void OnDraw(Graphics2D graphics2D) { if (this.isHoverItem) { //buttonContainer.Visible = true; } else { //buttonContainer.Visible = false; } base.OnDraw(graphics2D); if (this.isSelectedItem) { this.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor; this.partLabel.TextColor = RGBA_Bytes.White; this.selectionCheckBox.TextColor = RGBA_Bytes.White; //RectangleDouble Bounds = LocalBounds; //RoundedRect rectBorder = new RoundedRect(Bounds, 0); //graphics2D.Render(new Stroke(rectBorder, 3), RGBA_Bytes.White); } else if (this.isHoverItem) { RectangleDouble Bounds = LocalBounds; RoundedRect rectBorder = new RoundedRect(Bounds, 0); this.BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor; this.partLabel.TextColor = RGBA_Bytes.White; this.selectionCheckBox.TextColor = RGBA_Bytes.White; graphics2D.Render(new Stroke(rectBorder, 3), ActiveTheme.Instance.PrimaryAccentColor); } else { this.BackgroundColor = new RGBA_Bytes(255, 255, 255, 255); this.partLabel.TextColor = RGBA_Bytes.Black; } }
private void CreateAndRenderCombined(Graphics2D graphics2D, IVertexSource ps1, IVertexSource ps2) { PathStorage combined = null; switch (m_operation.SelectedIndex) { case 1: combined = CombinePaths(ps1, ps2, ClipType.ctUnion); break; case 2: combined = CombinePaths(ps1, ps2, ClipType.ctIntersection); break; case 3: combined = CombinePaths(ps1, ps2, ClipType.ctXor); break; case 4: combined = CombinePaths(ps1, ps2, ClipType.ctDifference); break; case 5: combined = CombinePaths(ps2, ps1, ClipType.ctDifference); break; } if (combined != null) { graphics2D.Render(combined, new RGBA_Floats(0.5, 0.0, 0, 0.5).GetAsRGBA_Bytes()); } }
public override void OnDraw(Graphics2D graphics2D) { base.OnDraw(graphics2D); if (this.isActivePrint) { //RectangleDouble Bounds = LocalBounds; //RoundedRect rectBorder = new RoundedRect(Bounds, 0); this.BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor; SetTextColors(RGBA_Bytes.White); //graphics2D.Render(new Stroke(rectBorder, 4), ActiveTheme.Instance.SecondaryAccentColor); } else if (this.isHoverItem) { RectangleDouble Bounds = LocalBounds; RoundedRect rectBorder = new RoundedRect(Bounds, 0); this.BackgroundColor = RGBA_Bytes.White; SetTextColors(RGBA_Bytes.Black); graphics2D.Render(new Stroke(rectBorder, 3), ActiveTheme.Instance.SecondaryAccentColor); } else { this.BackgroundColor = RGBA_Bytes.White; SetTextColors(RGBA_Bytes.Black); } }
public void Draw(Graphics2D currentRenderer) { foreach (Rock aRock in m_RockList) { aRock.Draw(currentRenderer); } foreach (Player aPlayer in m_PlayerList) { aPlayer.DrawBullets(currentRenderer); } foreach (SequenceEntity aSequenceEntity in m_SequenceEntityList) { aSequenceEntity.Draw(currentRenderer); } foreach (Player aPlayer in m_PlayerList) { aPlayer.Draw(currentRenderer); } GameImageSequence hud = (GameImageSequence)DataAssetCache.Instance.GetAsset(typeof(GameImageSequence), (m_PlayerList.Count).ToString() + "PlayerHUD"); currentRenderer.Render(hud.GetImageByIndex(0), 400, 300); foreach (Player aPlayer in m_PlayerList) { aPlayer.DrawScore(currentRenderer); } #if false Gl.glMatrixMode(Gl.GL_PROJECTION); // Select The Projection Matrix Gl.glLoadIdentity(); // Reset The Projection Matrix Glu.gluPerspective(45, Entity.GameWidth / (double)Entity.GameHeight, 0.1, 100); // Calculate The Aspect Ratio Of The Window Gl.glMatrixMode(Gl.GL_MODELVIEW); // Select The Modelview Matrix float scale = .08f; Gl.glLoadIdentity(); // Reset The Current Modelview Matrix Gl.glLightf(Gl.GL_LIGHT0, Gl.GL_CONSTANT_ATTENUATION, 0.0f); Gl.glLightf(Gl.GL_LIGHT0, Gl.GL_LINEAR_ATTENUATION, 0.0f); Gl.glLightf(Gl.GL_LIGHT0, Gl.GL_QUADRATIC_ATTENUATION, 0.0002f); float[] position = new float[] { -10.5f, 10.0f, 20.0f, 1.0f }; Gl.glScalef(scale, scale, scale); Gl.glTranslatef(0, 0, -160); // Move Left 1.5 Units And Into The Screen 6.0 Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, position); Gl.glTranslatef((float)m_Player.Position.x - 200, (float)m_Player.Position.y - 200, 0); Gl.glRotatef((float)((m_Player.m_Rotation - Math.PI / 2) / Math.PI * 180), 0, 0, 1); // Rotate The Triangle On The Y axis ( NEW ) Gl.glShadeModel(Gl.GL_FLAT); Gl.glClearDepth(1); // Depth Buffer Setup Gl.glEnable(Gl.GL_DEPTH_TEST); // Enables Depth Testing Gl.glDepthFunc(Gl.GL_LEQUAL); // The Type Of Depth Testing To Do Gl.glDisable(Gl.GL_CULL_FACE); #endif #if USE_GLSL String[] vertexSource = System.IO.File.ReadAllLines("..\\..\\GameData\\marble.vert"); vertexSource = new string[] { "void main(void) { gl_Position = ftransform(); } " }; vertexSource = new string[] { "varying vec3 normal, lightDir, eyeVec; void main() { normal = gl_NormalMatrix * gl_Normal; vec3 vVertex = vec3(gl_ModelViewMatrix * gl_Vertex); lightDir = vec3(gl_LightSource[0].position.xyz - vVertex); eyeVec = -vVertex; gl_Position = ftransform(); }" }; int vertexShader = Gl.glCreateShader(Gl.GL_VERTEX_SHADER); Gl.glShaderSource(vertexShader, vertexSource.Length, vertexSource, null); Gl.glCompileShader(vertexShader); int goodCompile; Gl.glGetShaderiv(vertexShader, Gl.GL_COMPILE_STATUS, out goodCompile); String[] fragmentSource = System.IO.File.ReadAllLines("..\\..\\GameData\\marble.frag"); fragmentSource = new string[] { "void main(void) { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); }" }; fragmentSource = new string[] { "varying vec3 normal, lightDir, eyeVec; void main (void) { vec4 final_color = (gl_FrontLightModelProduct.sceneColor * gl_FrontMaterial.ambient) + (gl_LightSource[0].ambient * gl_FrontMaterial.ambient); vec3 N = normalize(normal); vec3 L = normalize(lightDir); float lambertTerm = dot(N,L); if(lambertTerm > 0.0) { final_color += gl_LightSource[0].diffuse * gl_FrontMaterial.diffuse * lambertTerm; vec3 E = normalize(eyeVec); vec3 R = reflect(-L, N); float specular = pow( max(dot(R, E), 0.0), gl_FrontMaterial.shininess ); final_color += gl_LightSource[0].specular * gl_FrontMaterial.specular * specular; } gl_FragColor = final_color; }" }; int fragmentShader = Gl.glCreateShader(Gl.GL_FRAGMENT_SHADER); Gl.glShaderSource(fragmentShader, fragmentSource.Length, fragmentSource, null); Gl.glCompileShader(fragmentShader); Gl.glGetShaderiv(fragmentShader, Gl.GL_COMPILE_STATUS, out goodCompile); int shaderProgram; shaderProgram = Gl.glCreateProgram(); Gl.glAttachShader(shaderProgram, fragmentShader); Gl.glAttachShader(shaderProgram, vertexShader); Gl.glLinkProgram(shaderProgram); Gl.glGetProgramiv(shaderProgram, Gl.GL_LINK_STATUS, out goodCompile); System.Text.StringBuilder infoLog = new System.Text.StringBuilder(); int length; Gl.glGetShaderInfoLog(shaderProgram, 500, out length, infoLog); Gl.glUseProgram(shaderProgram); #endif //m_Ship.Render(); #if USE_GLSL Gl.glUseProgram(0); Gl.glDetachShader(shaderProgram, fragmentShader); Gl.glDetachShader(shaderProgram, vertexShader); Gl.glDeleteShader(fragmentShader); Gl.glDeleteShader(vertexShader); Gl.glDeleteProgram(shaderProgram); #endif }
private void render_gpc(Graphics2D graphics2D) { switch (m_polygons.SelectedIndex) { case 0: { //------------------------------------ // Two simple paths // PathStorage ps1 = new PathStorage(); PathStorage ps2 = new PathStorage(); double x = m_x - Width / 2 + 100; double y = m_y - Height / 2 + 100; ps1.MoveTo(x + 140, y + 145); ps1.LineTo(x + 225, y + 44); ps1.LineTo(x + 296, y + 219); ps1.ClosePolygon(); ps1.LineTo(x + 226, y + 289); ps1.LineTo(x + 82, y + 292); ps1.MoveTo(x + 220, y + 222); ps1.LineTo(x + 363, y + 249); ps1.LineTo(x + 265, y + 331); ps1.MoveTo(x + 242, y + 243); ps1.LineTo(x + 268, y + 309); ps1.LineTo(x + 325, y + 261); ps1.MoveTo(x + 259, y + 259); ps1.LineTo(x + 273, y + 288); ps1.LineTo(x + 298, y + 266); ps2.MoveTo(100 + 32, 100 + 77); ps2.LineTo(100 + 473, 100 + 263); ps2.LineTo(100 + 351, 100 + 290); ps2.LineTo(100 + 354, 100 + 374); graphics2D.Render(ps1, new RGBA_Floats(0, 0, 0, 0.1).GetAsRGBA_Bytes()); graphics2D.Render(ps2, new RGBA_Floats(0, 0.6, 0, 0.1).GetAsRGBA_Bytes()); CreateAndRenderCombined(graphics2D, ps1, ps2); } break; case 1: { //------------------------------------ // Closed stroke // PathStorage ps1 = new PathStorage(); PathStorage ps2 = new PathStorage(); Stroke stroke = new Stroke(ps2); stroke.width(10.0); double x = m_x - Width / 2 + 100; double y = m_y - Height / 2 + 100; ps1.MoveTo(x + 140, y + 145); ps1.LineTo(x + 225, y + 44); ps1.LineTo(x + 296, y + 219); ps1.ClosePolygon(); ps1.LineTo(x + 226, y + 289); ps1.LineTo(x + 82, y + 292); ps1.MoveTo(x + 220 - 50, y + 222); ps1.LineTo(x + 265 - 50, y + 331); ps1.LineTo(x + 363 - 50, y + 249); ps1.close_polygon(ShapePath.FlagsAndCommand.FlagCCW); ps2.MoveTo(100 + 32, 100 + 77); ps2.LineTo(100 + 473, 100 + 263); ps2.LineTo(100 + 351, 100 + 290); ps2.LineTo(100 + 354, 100 + 374); ps2.ClosePolygon(); graphics2D.Render(ps1, new RGBA_Floats(0, 0, 0, 0.1).GetAsRGBA_Bytes()); graphics2D.Render(stroke, new RGBA_Floats(0, 0.6, 0, 0.1).GetAsRGBA_Bytes()); CreateAndRenderCombined(graphics2D, ps1, stroke); } break; case 2: { //------------------------------------ // Great Britain and Arrows // PathStorage gb_poly = new PathStorage(); PathStorage arrows = new PathStorage(); GreatBritanPathStorage.Make(gb_poly); make_arrows(arrows); Affine mtx1 = Affine.NewIdentity(); Affine mtx2 = Affine.NewIdentity(); mtx1 *= Affine.NewTranslation(-1150, -1150); mtx1 *= Affine.NewScaling(2.0); mtx2 = mtx1; mtx2 *= Affine.NewTranslation(m_x - Width / 2, m_y - Height / 2); VertexSourceApplyTransform trans_gb_poly = new VertexSourceApplyTransform(gb_poly, mtx1); VertexSourceApplyTransform trans_arrows = new VertexSourceApplyTransform(arrows, mtx2); graphics2D.Render(trans_gb_poly, new RGBA_Floats(0.5, 0.5, 0, 0.1).GetAsRGBA_Bytes()); Stroke stroke_gb_poly = new Stroke(trans_gb_poly); stroke_gb_poly.Width = 0.1; graphics2D.Render(stroke_gb_poly, new RGBA_Floats(0, 0, 0).GetAsRGBA_Bytes()); graphics2D.Render(trans_arrows, new RGBA_Floats(0.0, 0.5, 0.5, 0.1).GetAsRGBA_Bytes()); CreateAndRenderCombined(graphics2D, trans_gb_poly, trans_arrows); } break; case 3: { //------------------------------------ // Great Britain and a Spiral // spiral sp = new spiral(m_x, m_y, 10, 150, 30, 0.0); Stroke stroke = new Stroke(sp); stroke.width(15.0); PathStorage gb_poly = new PathStorage(); GreatBritanPathStorage.Make(gb_poly); Affine mtx = Affine.NewIdentity();; mtx *= Affine.NewTranslation(-1150, -1150); mtx *= Affine.NewScaling(2.0); VertexSourceApplyTransform trans_gb_poly = new VertexSourceApplyTransform(gb_poly, mtx); graphics2D.Render(trans_gb_poly, new RGBA_Floats(0.5, 0.5, 0, 0.1).GetAsRGBA_Bytes()); Stroke stroke_gb_poly = new Stroke(trans_gb_poly); stroke_gb_poly.width(0.1); graphics2D.Render(stroke_gb_poly, new RGBA_Floats(0, 0, 0).GetAsRGBA_Bytes()); graphics2D.Render(stroke, new RGBA_Floats(0.0, 0.5, 0.5, 0.1).GetAsRGBA_Bytes()); CreateAndRenderCombined(graphics2D, trans_gb_poly, stroke); } break; case 4: { //------------------------------------ // Spiral and glyph // spiral sp = new spiral(m_x, m_y, 10, 150, 30, 0.0); Stroke stroke = new Stroke(sp); stroke.width(15.0); PathStorage glyph = new PathStorage(); glyph.MoveTo(28.47, 6.45); glyph.curve3(21.58, 1.12, 19.82, 0.29); glyph.curve3(17.19, -0.93, 14.21, -0.93); glyph.curve3(9.57, -0.93, 6.57, 2.25); glyph.curve3(3.56, 5.42, 3.56, 10.60); glyph.curve3(3.56, 13.87, 5.03, 16.26); glyph.curve3(7.03, 19.58, 11.99, 22.51); glyph.curve3(16.94, 25.44, 28.47, 29.64); glyph.LineTo(28.47, 31.40); glyph.curve3(28.47, 38.09, 26.34, 40.58); glyph.curve3(24.22, 43.07, 20.17, 43.07); glyph.curve3(17.09, 43.07, 15.28, 41.41); glyph.curve3(13.43, 39.75, 13.43, 37.60); glyph.LineTo(13.53, 34.77); glyph.curve3(13.53, 32.52, 12.38, 31.30); glyph.curve3(11.23, 30.08, 9.38, 30.08); glyph.curve3(7.57, 30.08, 6.42, 31.35); glyph.curve3(5.27, 32.62, 5.27, 34.81); glyph.curve3(5.27, 39.01, 9.57, 42.53); glyph.curve3(13.87, 46.04, 21.63, 46.04); glyph.curve3(27.59, 46.04, 31.40, 44.04); glyph.curve3(34.28, 42.53, 35.64, 39.31); glyph.curve3(36.52, 37.21, 36.52, 30.71); glyph.LineTo(36.52, 15.53); glyph.curve3(36.52, 9.13, 36.77, 7.69); glyph.curve3(37.01, 6.25, 37.57, 5.76); glyph.curve3(38.13, 5.27, 38.87, 5.27); glyph.curve3(39.65, 5.27, 40.23, 5.62); glyph.curve3(41.26, 6.25, 44.19, 9.18); glyph.LineTo(44.19, 6.45); glyph.curve3(38.72, -0.88, 33.74, -0.88); glyph.curve3(31.35, -0.88, 29.93, 0.78); glyph.curve3(28.52, 2.44, 28.47, 6.45); glyph.ClosePolygon(); glyph.MoveTo(28.47, 9.62); glyph.LineTo(28.47, 26.66); glyph.curve3(21.09, 23.73, 18.95, 22.51); glyph.curve3(15.09, 20.36, 13.43, 18.02); glyph.curve3(11.77, 15.67, 11.77, 12.89); glyph.curve3(11.77, 9.38, 13.87, 7.06); glyph.curve3(15.97, 4.74, 18.70, 4.74); glyph.curve3(22.41, 4.74, 28.47, 9.62); glyph.ClosePolygon(); Affine mtx = Affine.NewIdentity(); mtx *= Affine.NewScaling(4.0); mtx *= Affine.NewTranslation(220, 200); VertexSourceApplyTransform trans = new VertexSourceApplyTransform(glyph, mtx); FlattenCurves curve = new FlattenCurves(trans); CreateAndRenderCombined(graphics2D, stroke, curve); graphics2D.Render(stroke, new RGBA_Floats(0, 0, 0, 0.1).GetAsRGBA_Bytes()); graphics2D.Render(curve, new RGBA_Floats(0, 0.6, 0, 0.1).GetAsRGBA_Bytes()); } break; } }
public override void OnDraw(Graphics2D graphics2D) { graphics2D.Render(image, 0, 0); base.OnDraw(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { graphics2D.Render(imageToFillOn, imageOffset); base.OnDraw(graphics2D); }
protected override void DoDraw(Graphics2D destRenderer) { int playerSequenceIndex = GetPlayerIndex(); GameImageSequence playerShip = (GameImageSequence)DataAssetCache.Instance.GetAsset(typeof(GameImageSequence), "Player" + (playerSequenceIndex + 1).ToString() + "Ship"); destRenderer.Render(playerShip.GetImageByRatio(m_Rotation / (2 * Math.PI)), m_Position.x, m_Position.y); }
private void render_gpc(Graphics2D graphics2D) { switch (m_polygons.SelectedIndex) { case 0: { //------------------------------------ // Two simple paths // PathStorage ps1 = new PathStorage(); PathStorage ps2 = new PathStorage(); double x = m_x - Width / 2 + 100; double y = m_y - Height / 2 + 100; ps1.MoveTo(x + 140, y + 145); ps1.LineTo(x + 225, y + 44); ps1.LineTo(x + 296, y + 219); ps1.ClosePolygon(); ps1.LineTo(x + 226, y + 289); ps1.LineTo(x + 82, y + 292); ps1.MoveTo(x + 220, y + 222); ps1.LineTo(x + 363, y + 249); ps1.LineTo(x + 265, y + 331); ps1.MoveTo(x + 242, y + 243); ps1.LineTo(x + 268, y + 309); ps1.LineTo(x + 325, y + 261); ps1.MoveTo(x + 259, y + 259); ps1.LineTo(x + 273, y + 288); ps1.LineTo(x + 298, y + 266); ps2.MoveTo(100 + 32, 100 + 77); ps2.LineTo(100 + 473, 100 + 263); ps2.LineTo(100 + 351, 100 + 290); ps2.LineTo(100 + 354, 100 + 374); graphics2D.Render(ps1, new RGBA_Floats(0, 0, 0, 0.1).GetAsRGBA_Bytes()); graphics2D.Render(ps2, new RGBA_Floats(0, 0.6, 0, 0.1).GetAsRGBA_Bytes()); CreateAndRenderCombined(graphics2D, ps1, ps2); } break; case 1: { //------------------------------------ // Closed stroke // PathStorage ps1 = new PathStorage(); PathStorage ps2 = new PathStorage(); Stroke stroke = new Stroke(ps2); stroke.width(10.0); double x = m_x - Width / 2 + 100; double y = m_y - Height / 2 + 100; ps1.MoveTo(x + 140, y + 145); ps1.LineTo(x + 225, y + 44); ps1.LineTo(x + 296, y + 219); ps1.ClosePolygon(); ps1.LineTo(x + 226, y + 289); ps1.LineTo(x + 82, y + 292); ps1.MoveTo(x + 220 - 50, y + 222); ps1.LineTo(x + 265 - 50, y + 331); ps1.LineTo(x + 363 - 50, y + 249); ps1.close_polygon(ShapePath.FlagsAndCommand.FlagCCW); ps2.MoveTo(100 + 32, 100 + 77); ps2.LineTo(100 + 473, 100 + 263); ps2.LineTo(100 + 351, 100 + 290); ps2.LineTo(100 + 354, 100 + 374); ps2.ClosePolygon(); graphics2D.Render(ps1, new RGBA_Floats(0, 0, 0, 0.1).GetAsRGBA_Bytes()); graphics2D.Render(stroke, new RGBA_Floats(0, 0.6, 0, 0.1).GetAsRGBA_Bytes()); CreateAndRenderCombined(graphics2D, ps1, stroke); } break; case 2: { //------------------------------------ // Great Britain and Arrows // PathStorage gb_poly = new PathStorage(); PathStorage arrows = new PathStorage(); GreatBritanPathStorage.Make(gb_poly); make_arrows(arrows); Affine mtx1 = Affine.NewIdentity(); Affine mtx2 = Affine.NewIdentity(); mtx1 *= Affine.NewTranslation(-1150, -1150); mtx1 *= Affine.NewScaling(2.0); mtx2 = mtx1; mtx2 *= Affine.NewTranslation(m_x - Width / 2, m_y - Height / 2); VertexSourceApplyTransform trans_gb_poly = new VertexSourceApplyTransform(gb_poly, mtx1); VertexSourceApplyTransform trans_arrows = new VertexSourceApplyTransform(arrows, mtx2); graphics2D.Render(trans_gb_poly, new RGBA_Floats(0.5, 0.5, 0, 0.1).GetAsRGBA_Bytes()); Stroke stroke_gb_poly = new Stroke(trans_gb_poly); stroke_gb_poly.Width = 0.1; graphics2D.Render(stroke_gb_poly, new RGBA_Floats(0, 0, 0).GetAsRGBA_Bytes()); graphics2D.Render(trans_arrows, new RGBA_Floats(0.0, 0.5, 0.5, 0.1).GetAsRGBA_Bytes()); CreateAndRenderCombined(graphics2D, trans_gb_poly, trans_arrows); } break; case 3: { //------------------------------------ // Great Britain and a Spiral // spiral sp = new spiral(m_x, m_y, 10, 150, 30, 0.0); Stroke stroke = new Stroke(sp); stroke.width(15.0); PathStorage gb_poly = new PathStorage(); GreatBritanPathStorage.Make(gb_poly); Affine mtx = Affine.NewIdentity(); ; mtx *= Affine.NewTranslation(-1150, -1150); mtx *= Affine.NewScaling(2.0); VertexSourceApplyTransform trans_gb_poly = new VertexSourceApplyTransform(gb_poly, mtx); graphics2D.Render(trans_gb_poly, new RGBA_Floats(0.5, 0.5, 0, 0.1).GetAsRGBA_Bytes()); Stroke stroke_gb_poly = new Stroke(trans_gb_poly); stroke_gb_poly.width(0.1); graphics2D.Render(stroke_gb_poly, new RGBA_Floats(0, 0, 0).GetAsRGBA_Bytes()); graphics2D.Render(stroke, new RGBA_Floats(0.0, 0.5, 0.5, 0.1).GetAsRGBA_Bytes()); CreateAndRenderCombined(graphics2D, trans_gb_poly, stroke); } break; case 4: { //------------------------------------ // Spiral and glyph // spiral sp = new spiral(m_x, m_y, 10, 150, 30, 0.0); Stroke stroke = new Stroke(sp); stroke.width(15.0); PathStorage glyph = new PathStorage(); glyph.MoveTo(28.47, 6.45); glyph.curve3(21.58, 1.12, 19.82, 0.29); glyph.curve3(17.19, -0.93, 14.21, -0.93); glyph.curve3(9.57, -0.93, 6.57, 2.25); glyph.curve3(3.56, 5.42, 3.56, 10.60); glyph.curve3(3.56, 13.87, 5.03, 16.26); glyph.curve3(7.03, 19.58, 11.99, 22.51); glyph.curve3(16.94, 25.44, 28.47, 29.64); glyph.LineTo(28.47, 31.40); glyph.curve3(28.47, 38.09, 26.34, 40.58); glyph.curve3(24.22, 43.07, 20.17, 43.07); glyph.curve3(17.09, 43.07, 15.28, 41.41); glyph.curve3(13.43, 39.75, 13.43, 37.60); glyph.LineTo(13.53, 34.77); glyph.curve3(13.53, 32.52, 12.38, 31.30); glyph.curve3(11.23, 30.08, 9.38, 30.08); glyph.curve3(7.57, 30.08, 6.42, 31.35); glyph.curve3(5.27, 32.62, 5.27, 34.81); glyph.curve3(5.27, 39.01, 9.57, 42.53); glyph.curve3(13.87, 46.04, 21.63, 46.04); glyph.curve3(27.59, 46.04, 31.40, 44.04); glyph.curve3(34.28, 42.53, 35.64, 39.31); glyph.curve3(36.52, 37.21, 36.52, 30.71); glyph.LineTo(36.52, 15.53); glyph.curve3(36.52, 9.13, 36.77, 7.69); glyph.curve3(37.01, 6.25, 37.57, 5.76); glyph.curve3(38.13, 5.27, 38.87, 5.27); glyph.curve3(39.65, 5.27, 40.23, 5.62); glyph.curve3(41.26, 6.25, 44.19, 9.18); glyph.LineTo(44.19, 6.45); glyph.curve3(38.72, -0.88, 33.74, -0.88); glyph.curve3(31.35, -0.88, 29.93, 0.78); glyph.curve3(28.52, 2.44, 28.47, 6.45); glyph.ClosePolygon(); glyph.MoveTo(28.47, 9.62); glyph.LineTo(28.47, 26.66); glyph.curve3(21.09, 23.73, 18.95, 22.51); glyph.curve3(15.09, 20.36, 13.43, 18.02); glyph.curve3(11.77, 15.67, 11.77, 12.89); glyph.curve3(11.77, 9.38, 13.87, 7.06); glyph.curve3(15.97, 4.74, 18.70, 4.74); glyph.curve3(22.41, 4.74, 28.47, 9.62); glyph.ClosePolygon(); Affine mtx = Affine.NewIdentity(); mtx *= Affine.NewScaling(4.0); mtx *= Affine.NewTranslation(220, 200); VertexSourceApplyTransform trans = new VertexSourceApplyTransform(glyph, mtx); FlattenCurves curve = new FlattenCurves(trans); CreateAndRenderCombined(graphics2D, stroke, curve); graphics2D.Render(stroke, new RGBA_Floats(0, 0, 0, 0.1).GetAsRGBA_Bytes()); graphics2D.Render(curve, new RGBA_Floats(0, 0.6, 0, 0.1).GetAsRGBA_Bytes()); } break; } }
internal void DrawBullets(Graphics2D destRenderer) { int playerSequenceIndex = GetPlayerIndex(); GameImageSequence bulletImage = (GameImageSequence)DataAssetCache.Instance.GetAsset(typeof(GameImageSequence), "Player" + (playerSequenceIndex + 1).ToString() + "Bullet"); foreach (Bullet aBullet in m_BulletList) { destRenderer.Render(bulletImage.GetImageByIndex(0), aBullet.Position.x, aBullet.Position.y, aBullet.Velocity.GetAngle0To2PI(), 1, 1); } }
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); if (orignialSize.x == 0) { orignialSize.x = WindowSize.x; orignialSize.y = WindowSize.y; } ImageBuffer destImageWithPreMultBlender = new ImageBuffer(); switch (widgetsSubImage.BitDepth) { case 24: destImageWithPreMultBlender.Attach(widgetsSubImage, new BlenderPreMultBGR()); break; case 32: destImageWithPreMultBlender.Attach(widgetsSubImage, new BlenderPreMultBGRA()); break; default: throw new Exception("Unknown bit depth"); } ImageClippingProxy clippingProxy_pre = new ImageClippingProxy(destImageWithPreMultBlender); clippingProxy_pre.clear(new RGBA_Floats(1.0, 1.0, 1.0)); Affine src_mtx = Affine.NewIdentity(); src_mtx *= Affine.NewTranslation(-orignialSize.x / 2 - 10, -orignialSize.y / 2 - 20 - 10); src_mtx *= Affine.NewRotation(drawAngle.Value * Math.PI / 180.0); src_mtx *= Affine.NewScaling(drawScale.Value); src_mtx *= Affine.NewTranslation(orignialSize.x / 2, orignialSize.y / 2 + 20); Affine img_mtx = Affine.NewIdentity(); img_mtx *= Affine.NewTranslation(-orignialSize.x / 2 + 10, -orignialSize.y / 2 + 20 + 10); img_mtx *= Affine.NewRotation(drawAngle.Value * Math.PI / 180.0); img_mtx *= Affine.NewScaling(drawScale.Value); img_mtx *= Affine.NewTranslation(orignialSize.x / 2, orignialSize.y / 2 + 20); img_mtx.invert(); MatterHackers.Agg.span_allocator sa = new span_allocator(); span_interpolator_linear interpolator = new span_interpolator_linear(img_mtx); span_image_filter sg; switch (sourceImage.BitDepth) { case 24: { ImageBufferAccessorClip source = new ImageBufferAccessorClip(sourceImage, RGBA_Floats.rgba_pre(0, 0, 0, 0).GetAsRGBA_Bytes()); sg = new span_image_filter_rgb_bilinear_clip(source, RGBA_Floats.rgba_pre(0, 0.4, 0, 0.5), interpolator); } break; case 32: { ImageBufferAccessorClip source = new ImageBufferAccessorClip(sourceImage, RGBA_Floats.rgba_pre(0, 0, 0, 0).GetAsRGBA_Bytes()); sg = new span_image_filter_rgba_bilinear_clip(source, RGBA_Floats.rgba_pre(0, 0.4, 0, 0.5), interpolator); } break; default: throw new Exception("Bad sourc depth"); } ScanlineRasterizer ras = new ScanlineRasterizer(); ras.SetVectorClipBox(0, 0, Width, Height); ScanlineCachePacked8 sl = new ScanlineCachePacked8(); //scanline_unpacked_8 sl = new scanline_unpacked_8(); double r = orignialSize.x; if (orignialSize.y - 60 < r) { r = orignialSize.y - 60; } VertexSource.Ellipse ell = new VertexSource.Ellipse(orignialSize.x / 2.0 + 10, orignialSize.y / 2.0 + 20 + 10, r / 2.0 + 16.0, r / 2.0 + 16.0, 200); VertexSourceApplyTransform tr = new VertexSourceApplyTransform(ell, src_mtx); ras.add_path(tr); //clippingProxy_pre.SetClippingBox(30, 0, (int)width(), (int)height()); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.GenerateAndRender(ras, sl, clippingProxy_pre, sa, sg); if (false) // this is test code to check different quality settings for scalling { Vector2 screenCenter = new Vector2(Width / 2, Height / 2); Vector2 deltaToMouse = mousePosition - screenCenter; double angleToMouse = Math.Atan2(deltaToMouse.y, deltaToMouse.x); double diagonalSize = Math.Sqrt(sourceImage.Width * sourceImage.Width + sourceImage.Height * sourceImage.Height); double distToMouse = deltaToMouse.Length; double scalling = distToMouse / diagonalSize; graphics2D.Render(sourceImage, Width / 2, Height / 2, angleToMouse - MathHelper.Tau / 8, scalling, scalling); } base.OnDraw(graphics2D); }
public void DrawScore(Graphics2D destRenderer) { int playerSequenceIndex = GetPlayerIndex(); GameImageSequence scoreSequence = (GameImageSequence)DataAssetCache.Instance.GetAsset(typeof(GameImageSequence), "ScoreNumbers"); string score = m_Score.ToString(); int x = 43; int y = 577; switch (playerSequenceIndex) { case 0: break; case 1: x = 700; break; case 2: x = 45; y = 5; break; case 3: x = 700; y = 5; break; default: break; } for (int i = 0; i < score.Length; i++) { int digit = (int)(score[i] - '0'); ImageBuffer numberImage = scoreSequence.GetImageByIndex(digit); destRenderer.Render(numberImage, x, y); x += numberImage.Width; } }
public override void OnDraw(Graphics2D graphics2D) { base.OnDraw(graphics2D); if (this.IsHoverItem) { RectangleDouble Bounds = LocalBounds; RoundedRect rectBorder = new RoundedRect(Bounds, 0); this.BackgroundColor = RGBA_Bytes.White; this.partLabel.TextColor = RGBA_Bytes.Black; graphics2D.Render(new Stroke(rectBorder, 3), ActiveTheme.Instance.SecondaryAccentColor); } else { this.BackgroundColor = new RGBA_Bytes(255, 255, 255, 255); this.partLabel.TextColor = RGBA_Bytes.Black; } }
public override void OnDraw(Graphics2D graphics2D) { RoundedRect rect = new RoundedRect(LocalBounds, 0); graphics2D.Render(rect, new RGBA_Bytes(OverlayColor, 220)); base.OnDraw(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { RectangleDouble borderRectangle = LocalBounds; RoundedRect rectBorder = new RoundedRect(borderRectangle, 0); graphics2D.Render(new Stroke(rectBorder, BorderWidth), BorderColor); base.OnDraw(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { base.OnDraw(graphics2D); RoundedRect rect = new RoundedRect(LocalBounds, 0); graphics2D.Render(rect, new RGBA_Bytes(OverlayColor, 50)); graphics2D.Render(new Stroke(rect, 3), OverlayColor); }
public override void OnDraw(Graphics2D graphics2D) { if (this.libraryDataView.EditMode && !this.IsViewHelperItem) { this.selectionCheckBox.Checked = this.IsSelectedItem; selectionCheckBoxContainer.Visible = true; rightButtonOverlay.Visible = false; } else { selectionCheckBoxContainer.Visible = false; } base.OnDraw(graphics2D); if (this.IsSelectedItem && !this.IsViewHelperItem) { this.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor; this.partLabel.TextColor = RGBA_Bytes.White; this.selectionCheckBox.TextColor = RGBA_Bytes.White; } else if (this.IsHoverItem) { RectangleDouble Bounds = LocalBounds; RoundedRect rectBorder = new RoundedRect(Bounds, 0); this.BackgroundColor = RGBA_Bytes.White; this.partLabel.TextColor = RGBA_Bytes.Black; this.selectionCheckBox.TextColor = RGBA_Bytes.Black; graphics2D.Render(new Stroke(rectBorder, 3), ActiveTheme.Instance.SecondaryAccentColor); } else { this.BackgroundColor = new RGBA_Bytes(255, 255, 255, 255); this.partLabel.TextColor = RGBA_Bytes.Black; this.selectionCheckBox.TextColor = RGBA_Bytes.Black; } }
public override void OnDraw(Graphics2D graphics2D) { //Trigger thumbnail generation if neeeded if (!thumbNailHasBeenCreated && !processingThumbnail) { if (SetImageFast()) { thumbNailHasBeenCreated = true; OnDoneRendering(); } else { Task.Run(() => LoadOrCreateThumbnail()); } } if (this.FirstWidgetUnderMouse) { RoundedRect rectBorder = new RoundedRect(this.LocalBounds, 0); //graphics2D.Render(rectBorder, this.HoverBackgroundColor); } graphics2D.Render(thumbnailImage, Width / 2 - thumbnailImage.Width / 2, Height / 2 - thumbnailImage.Height / 2); base.OnDraw(graphics2D); if (HoverBorderColor.Alpha0To255 > 0) { RectangleDouble Bounds = LocalBounds; RoundedRect borderRect = new RoundedRect(this.LocalBounds, this.borderRadius); Stroke strokeRect = new Stroke(borderRect, BorderWidth); graphics2D.Render(strokeRect, HoverBorderColor); } }