drawing

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

.NET GDI+: Drawing lines with rounded corners

≡放荡痞女 提交于 2019-12-20 02:41:49
问题 Given an array of points, it is easy to draw a line based on these, e.g. using the GraphicsPath class. For instance, the following array of points... [0]: (0,0) [1]: (100,0) [2]: (0,100) [3]: (100,100) ...describes a line that resembles a Z. But here comes the challenge; I need to draw rounded corners with a radius of e.g. 10 pixels. By corners I mean the points in the line that aren't start or end points. In this case there are two corners at (0,100) and (100,0) . I've played around with

Add rounded corners to custom view

限于喜欢 提交于 2019-12-20 01:08:54
问题 I'm quite new to Android and i'm trying to draw on a custom view (with canvas). I've got some lines & rects there. The point is, that i now want to give the whole view rounded corners, but that doesn't work well, as i'm drawing on the view and my drawings are above the rounded corners, which were added through the ressources. Is there a possibility to add rounded corners, that cover the whole view? Best regards and thank's for any help! 回答1: I am not sure of your requirements. But you can use

getChildDrawingOrder called/used erratically?

北城余情 提交于 2019-12-19 18:55:42
问题 I am creating an isometric map with simple tiles, and I’ve extended RelativeLayout to create a layout that holds these tiles. Really, just using a RelativeLayout as-is worked fine as long as my orientation matched the order in which the tiles were written to the XML file; all I’ve overwritten are the constructors, where I simply call super and setChildrenDrawingOrderEnabled(true); along with setting up some variables (height and width of the grid), and then getChildDrawingOrder itself. My

Drawing an image onto a Panel control gives artefacts when resizing

。_饼干妹妹 提交于 2019-12-19 17:46:30
问题 Currently I'm trying to do what I thought would be a simple task: Draw an image onto the full area of a Panel control in Windows Forms. (Please ignore for the moment that I could use the BackgroundImage property) The image to draw looks like this: I.e. a yellow box with an 1 pixel blue frame around. To draw, I'm using the Paint event of the Panel control: private void panel1_Paint(object sender, PaintEventArgs e) { e.Graphics.DrawImage(Resources.MyImage, panel1.ClientRectangle); } This looks

Drawing an image onto a Panel control gives artefacts when resizing

て烟熏妆下的殇ゞ 提交于 2019-12-19 17:46:20
问题 Currently I'm trying to do what I thought would be a simple task: Draw an image onto the full area of a Panel control in Windows Forms. (Please ignore for the moment that I could use the BackgroundImage property) The image to draw looks like this: I.e. a yellow box with an 1 pixel blue frame around. To draw, I'm using the Paint event of the Panel control: private void panel1_Paint(object sender, PaintEventArgs e) { e.Graphics.DrawImage(Resources.MyImage, panel1.ClientRectangle); } This looks

Custom Font not working on Android

北城余情 提交于 2019-12-19 11:24:19
问题 I am doing the below. All I get is the basic font, not my custom symbol font. Any ideas? Paint pnt = new Paint(); // SymbolNo is 38. Returns string "&" which is correct in normal font. String symbolText = Character.toString((char)SymbolNo); // Should adopt a symbol font and draw symbol to screen instead. But I just see "&" Typeface tf = Typeface.createFromAsset(m_context.getAssets(), "fonts/myFont.TTF" ); pnt.setTypeface(tf); m_canvas.drawText(symbolText,x, y, pnt); my font is in assets/fonts

Drawing a blinking caret in Winforms

﹥>﹥吖頭↗ 提交于 2019-12-19 10:45:14
问题 I'm developing a custom control, which most resembles a text area. I am drawing text, which works correctly, and accepting input which also works.. But I (the user) am left guessing where the caret is while I type, since I'm doing everything manually. How do I draw a blinking caret to show where I am currently typing? Is there a standard way to do this? 回答1: I think that, annoyingly, there is no managed API for Carets. You must, therefore, either PInvoke to the Win32 functions for carets, or,

How to create Emgu Image from System.Drawing.Image?

独自空忆成欢 提交于 2019-12-19 10:16:17
问题 I have a source that gives me a jpeg in memory stream (Bytes). I can convert it to System.Drawing.Image but I don't know how to convert it to Emgu Image. Maybe a direct conversion to Emgu Image is possible ? I'm working in C# under VS2010. Thanks. SW 回答1: You can first convert System.Drawing.Image object to a Bitmap and then create an Emgu.CV.Image with that bitmap. The code is as follows: System.Drawing.Image image; Bitmap bmpImage = new Bitmap(image); Emgu.CV.Image = new Emgu.CV.Image<Bgr,

Bug in geometry Hit-Testing

心不动则不痛 提交于 2019-12-19 07:36:45
问题 I have a DrawingVisual element that rappresents a path which geometry is described by this syntax: "m106,59.3c0-1.98,0,0-4.95,0.989-3.96,0.989-13.8,3.96-20.8,4.95-6.92,0-14.8-3.96-17.8-3.96-1.98,2.97,3.96,10.9,7.91,13.8,2.97,1.98,9.89,3.96,14.8,3.96,4.95-0.989,10.9-2.97,13.8-6.92,2.97-2.97,5.93-10.9,6.92-12.9z" To render the visual i use MyCanvas class, that provides hit-testing functionality: public class MyCanvas : Panel { public List<Visual> Visuals = new List<Visual>(); private List