draw

clearRect function doesn't clear the canvas

喜你入骨 提交于 2019-11-26 13:47:15
I'm using this script on the body onmousemove function: function lineDraw() { // Get the context and the canvas: var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); // Clear the last canvas context.clearRect(0, 0, canvas.width, canvas.height); // Draw the line: context.moveTo(0, 0); context.lineTo(event.clientX, event.clientY); context.stroke(); } It's supposed to clear the canvas each time I move the mouse around, and draw a new line, but it isn't working properly. I'm trying to solve it without using jQuery, mouse listeners or similar. Here is a demo:

How to draw in JPanel? (Swing/graphics Java)

前提是你 提交于 2019-11-26 13:06:23
I'm working on a project in which I am trying to make a paint program. So far I've used Netbeans to create a GUI and set up the program. As of right now I am able to call all the coordinated necessary to draw inside it but I am very confused with how to actually paint inside it. Towards the end of my code I have a failed attempt at drawing inside the panel. Can anyone explain/show how to use graphics in a example like this? All examples I have found make a class and extend it with JPanel but I don't know if I can do this since it was generated in netbeans. I need to draw inside a JPanel ,

How to draw free hand polygon in Google map V2 in Android?

我是研究僧i 提交于 2019-11-26 11:36:40
I want to draw a Free Hand Polygon on the Map in Google Map V2 . This task was possible with Overlay Map V1 but Google Map has removed that class from V2. (Per this Google Map V2 has Remove Overlay Class ). Good Example for Google Map V1 to draw free style polygon. In Map V2, we can draw a polygon programmatically with the help of Google Official Doc but what should a user do? I have found Unclear answer for Map V2 I started with simple Google Map & draw polygon to do this programmatically & it is working properly but now I am looking for how a user can draw? I don't want to draw based on the

How to use android canvas to draw a Rectangle with only topleft and topright corners round?

ⅰ亾dé卋堺 提交于 2019-11-26 10:32:38
问题 I found a function for rectangles with all 4 corners being round, but I want to have just the top 2 corners round. What can I do? canvas.drawRoundRect(new RectF(0, 100, 100, 300), 6, 6, paint); 回答1: You can draw that piece by piece using drawLine() and drawArc() functions from the Canvas . 回答2: Use a path. It has the advantage of working for APIs less than 21 (Arc is also limited thusly, which is why I quad). Which is a problem because not everybody has Lollipop yet. You can however specify a

Android: looking for a drawArc() method with inner & outer radius

百般思念 提交于 2019-11-26 10:15:17
问题 I have the following custom view: This I have achieved by using the Canvas\' drawArc() method. However, with this drawArc() method I cannot limit the arc\'s inner radius. What I\'d like to have is something like this: where there is only an outer ring left. What I need is an drawArc() function where I can set the inner radius of the arc. Anyone an idea how to do that? (BTW, overpainting the inner area doesn\'t work, because it needs to be transparent. Painting an inner circle with Color

How do I draw an arrowhead (in Android)?

假如想象 提交于 2019-11-26 09:45:15
问题 I\'m fairly new to Android and have been toying around with Canvas. I\'m attempting to draw an arrow but I\'m only having luck with drawing the shaft, none of the arrowhead is working. I have searched a bit and found a Java example, but Android doesn\'t have GeneralPath or AffineTransform . Right now my code looks like the following (the arrowhead looks nothing like an arrowhead): public class DrawableView extends View { Context mContext; private int centerX; private int centerY; private int

Write text on an image in C#

那年仲夏 提交于 2019-11-26 08:08:52
问题 I have the following problem. I want to make some graphics in bitmap image like bond form i can write a text in image but i will write more text in various positions Bitmap a = new Bitmap(@\"path\\picture.bmp\"); using(Graphics g = Graphics.FromImage(a)) { g.DrawString(....); // requires font, brush etc } How can I write text and save it, and write another text in saved image. 回答1: To draw multiple strings, call graphics.DrawString multiple times. You can specify the location of the drawn

draw polar graph in java

元气小坏坏 提交于 2019-11-26 07:49:56
问题 Does anyone know how I can get started to draw a polar graph in java and plot some points on this graph? I mean the circles and lines, I wish to do this with something like swing, and not use any library like Jfreechart Thanks 回答1: You might like to look at Lissajous curves; an example of a = 5, b = 4 (5:4) is shown below. Addendum: Once you see how to plot points in xy coordinates, then you should look at converting between polar and Cartesian coordinates. public class LissajousPanel extends

JFreechart draw arc on chart

雨燕双飞 提交于 2019-11-26 07:49:32
问题 I have 2 questions 1)I am trying to draw an arc on an XYplot using the shape annotation. I used the XYLine annotation to draw a line and I want the arc to start where the line ends. I am having some issues with the parameters.I want the arc to have a height of 17, width 44, and start at the point(3.0, 17) of the plot(this is where the line ends). But the code below does not work. Can someone please tell me what is wrong with the code? Arc2D.Double arc = new Arc2D.Double(3.0, 16.9, 44.0, 17.04

Can I draw rectangle in XML?

醉酒当歌 提交于 2019-11-26 07:24:33
问题 I wonder if I can draw rectangle in XML. I know how to draw using drawRect method programmatically. 回答1: Yes you can and here is one I made earlier: <?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/listview_background_shape"> <stroke android:width="2dp" android:color="#ff207d94" /> <padding android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp" /> <corners android:radius="5dp" /> <solid android