graphics

Can we have two canvases in an activity ? (OR) Having a canvas outside the onDraw() is not working

天大地大妈咪最大 提交于 2019-12-20 06:25:26
问题 @Override protected void onDraw(Canvas canvas) { // Draw graphic objects ..... } public void displayCalc(){ //Do some calculation & display results near these graphic objects String result = String.valueOf(value); //Do some calculation //Display Calculated values Canvas c =new Canvas(); Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL); paint.setAntiAlias(true); paint.setColor(Color.WHITE); c.drawText(result,200,300,paint); } But if i have the same thing in the function onDraw it

Clearing the graphics of a transparent panel C#

跟風遠走 提交于 2019-12-20 06:09:46
问题 I have a WebBrowser control with a transparent panel over the top of it, what I am trying to do is draw a rectangle on the transparent panel around the element in the page that the mouse is hovering over. So far I have everything working except the panel is not being cleared before drawing the next rectangle so I end up with rectangles everywhere. heres the code Im using. paneGraphics = drawingPane.CreateGraphics(); Rectangle inspectorRectangle; inspectorRectangle = controller.inspectElement(

on delphi/android how to draw a TbitmapSurface on a Canvas?

落爺英雄遲暮 提交于 2019-12-20 06:07:08
问题 Under delphi (and under firemonkey/android), What is the most fastest way to draw on a Tcanvas a TbitmapSurface ? I try to use TTexture like MyTexture.Assign(aBitmapSurface) and later do TCustomCanvasGpu(Canvas).DrawTexture but MyTexture.Assign(aBitmapSurface) have 2 main drawbacks : it's must be done inside the main thread (i don't know why else we have black screen) it's relatively slow operation 回答1: I do not use/code for Android so read with extreme prejudice. As Delphi uses VCL so I

How do you resize a Bitmap under .NET CF 2.0

余生颓废 提交于 2019-12-20 05:42:38
问题 I have a Bitmap that I want to enlarge programatically to ~1.5x or 2x to its original size. Is there an easy way to do that under .NET CF 2.0? 回答1: One "normal" way would be to create a new Bitmap of the desired size, create a Graphics for it and then draw the old image onto it with Graphics.DrawImage(Point, Rectangle) . Are any of those calls not available on the Compact Framework? EDIT: Here's a short but complete app which works on the desktop: using System; using System.Drawing; class

Is there any easy way to draw a circle onto a JPanel?

做~自己de王妃 提交于 2019-12-20 05:23:29
问题 I'm having trouble using the drawOval(x,y,width,height) method, which assumes that the x and y values represent the coordinates of the "upper left corner of the oval to be drawn" (javadoc) I want the x and y values to represent the center-point of a circle. How do I do this? Thanks 回答1: A simple solution, if you have the width/height declared in advance, would be to use the drawOval method as follows: drawOval( x - (width/2), y - (height/2), width, height); This will ensure that (x, y) is at

extracting scale matrix from modelview matrix

半城伤御伤魂 提交于 2019-12-20 04:36:58
问题 how do we extract scale matrix from model view matrix? Right now I am taking length of each coloumn, but it fails when the scale is negative. here is my code: float xs = matrix[0][0] * matrix[0][1] * matrix[0][2] * matrix[0][3] < 0 ? -1 : 1; float ys = matrix[1][0] * matrix[1][1] * matrix[1][2] * matrix[1][3] < 0 ? -1 : 1; float zs = matrix[2][0] * matrix[2][1] * matrix[2][2] * matrix[2][3] < 0 ? -1 : 1; glm::vec3 new_scale; new_scale.x = xs* glm::sqrt( matrix[0][0] * matrix[0][0] + matrix[0]

How to prevent Graphical stutter when scrolling a large zoomed out picture

六月ゝ 毕业季﹏ 提交于 2019-12-20 04:31:52
问题 I have a large tiff picture (5.9 Mb , 13k X 16k reolution) that the user loads into a scrollable panel that he then can zoom in/out of, scroll and mark points, regions etc on. for the scrollable double buffered panel I am using a modification of Bob Powell's awesome ZoomPicBox The panel displays only the part of the picture currently in view. The stutter occurs when scrolling the image when zoomed out (even if the interpolationMode is set to low) Is there anything that can be done about it

As3: Draw overlapping rectangles to a sprite and apply alpha

五迷三道 提交于 2019-12-20 04:18:26
问题 I need to draw independet rectangles to a sprite. But the overlapping areas will get visible if I apply alpha to my sprite (the sprite will be fade in and out): var spBox:Sprite = new Sprite(); this.addChild(spBox); spBox.graphics.beginFill(0x123456) spBox.graphics.drawRect(100, 100, 50, 50); spBox.graphics.endFill(); spBox.graphics.beginFill(0x123456) spBox.graphics.drawRect(125, 125, 50, 50); spBox.graphics.endFill(); Is there a way to compine/flatten/merge the rectangles of my sprite? I

Scaling Picturebox does not change image at all

为君一笑 提交于 2019-12-20 03:53:33
问题 I'm using a picturebox to create a visual of an instance of my truss class. I'm creating the visual by drawing directly onto the picture box in the paint event. The method looks like this private void pictureBox1_Paint(object sender, PaintEventArgs e) { if (isDraw) { //Preparing to draw Graphics g = e.Graphics; g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.Bicubic; RunEntry entry = this.passedHistory.SelectedItem as RunEntry; AnsFile objToDraw = entry

Clicking on a JPanel to draw shapes

…衆ロ難τιáo~ 提交于 2019-12-20 03:30:19
问题 I have a JFrame containing 3 JPanels; Options, menu, canvas. In options there are a number of JButtons representing shapes. The aim is to click on the JButton of a shape e.g. rectangle, then click anywhere on the canvas and the shape will be drawn there. For some reason, the shape does not always get drawn, it is only drawn when I click somewhere in the top left area of the canvas. Also the shape seems to randomly change size depending on where I click. Here are some of my code snippets, it's