Menu
  • HOME
  • TAGS

Java unwanted border on JPanel when drawing

java,graphics,draw

You need to call setResizeable(false) on your frame before you call pack(). Calling pack() will size the frame to fit its components. Making the frame non-resizeable afterwards will give it thinner borders, which will increase the amount of space inside the frame.

draw-function with fold and and add-line?

recursion,scheme,draw

You don't say specifically which language you are using, but this looks suspicious: (fold empty-image (add-line ...)) In Racket the way to use fold is: (foldl f base l) Here f is a function. In your code you have empty-image. You need to define define a function say f, that...

Libgdx shader, render and draw confusion

opengl,libgdx,shader,render,draw

The problem here is, that you never set the Shader back to the default Shader, so your Spritebatch always uses the "solid white" Shader. As the javadock of the setShader(ShaderProgram shader)sais you can reset the Shader by calling setShader(null). Another possibility would be to use another Texture for the solid...

How can I create a Line with different colors in android

android,colors,android-studio,draw

Use GradientDrawable. GradientDrawable rainbow = new GradientDrawable(Orientation.LEFT_RIGHT, new int[] {Color.RED, Color.MAGENTA, Color.BLUE, Color.CYAN, Color.GREEN, Color.YELLOW, Color.RED}); The docs tell you how to set shape, interpolation between colors, position of colors, etc....

How to draw the spectrogram from data the stft?

java,draw,drawrect

The Java SE libraries do not cover this sort of thing. You need to: identify a 3rd-party Java library that provides scientific graphing, identify a non-Java application that you can run to generate an image that you can embed in your Java app's output; e.g. run it using Runtime.exec(...), or...

Draw color to every pixel in picturebox

c#,draw,picturebox,progress

Each time your timer ticks you want to draw another pixel with (different?) color, right? What you need to do is declare current x and y coordinates outside of timer1_Tick method and increase their values accordingly every time you draw something. To immediately see the results you should also call...

How to activate the method to draw from a button?

android,onclick,draw,activation

You call invalidate() on the view you want to redraw

libGDX draw a text using a decals to 3d facing camera

java,text,3d,libgdx,draw

I wouldn't try the Decal method because it's not set up for text. SpriteBatch is already set up for text. (The Decal method could theoretically perform better because you wouldn't need a separate draw call for each string of text. However, you would have to roll your own version of...

Draw Circle onTouch on a Canvas Image Bitmap

android,touch,android-canvas,draw,android-bitmap

You have to extend ImageView and override onTouchEvent() and onDraw() methods. public class MyImageView extends ImageView { private float lastX; private float lastY; ... public MyImageView(Context context) { super(context); } public MyImageView(Context context, AttributeSet attrs) { super(context, attrs); } public MyImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle);...

Drawing a simple image in R

r,image,plot,draw

Here is the way to print in an image file: #set up png png(filename = "ACE.png", width = 5, height = 15, units = "cm", pointsize = 12, res = 300) par(bg = "transparent", usr = c(0, 51, 0, 451)) #make the plot window a certain size? plot(x=NULL, y=NULL ,...

Drawing a cone surface in general equation in Matlab [duplicate]

matlab,plot,draw

In case somebody else was looking for this: my question was duplicate of http://stackoverflow.com/a/15100406/3179989...

Use a progressbar inside a custom view?

android,progress-bar,draw,android-custom-view

You may want to consider extending ViewGroup in your Gamecontroller_View instead of View. From the documentation: A ViewGroup is a special view that can contain other views (called children.) The view group is the base class for layouts and views containers. ...

Draw a line every N words using iTextSharp

position,itextsharp,line,word,draw

Please take a look at the Every25Words examples. In that example, I read a text file into a String with the readFile() method. I then split the text into words based on the occurrence of spaces, and I add each word one by one: public void createPdf(String dest) throws IOException,...

Delphi: Can't Draw On Panel's Canvas

image,delphi,canvas,draw

Looking at your whole class I asume you desire to controll which image is being shown at which time based on certain condition. Right? If that is the case first thing that you need is for your class to have a field for storing the image data. In your example...

Draw Image At Cursor Position Visual Basic

vb.net,draw,paint,cursor-position

Use the MouseDown() event of the Form and draw at the location specified by "e.X" and "e.Y". You can use the Timer() control to get a one second delay. Here's a quick example: Public Class Form1 Private WithEvents Tmr As New System.Windows.Forms.Timer Private Sub Form1_Load(sender As Object, e As EventArgs)...

Canvas draw text verticaly

java,android,text,android-canvas,draw

First, you need Paint Paint paint = new Paint(); // your paint settings such as stroke thickness and such Then, rotate your canvas canvas.rotate(yourTextAngle, originX, originY); Then, you draw your text canvas.drawText("Your text", originX, originY, paint); The text should be drawn vertically based on the angle you supplied. Then if...

BufferedImage Sometimes Doesn't render

java,swing,awt,draw,bufferedimage

I had to modify most of the code to get something to work. I'm assuming that this is what you want. Here are the changes I made. I added a main method that called SwingUtilities invokeLater to put the Swing components on the Event Dispatch thread. I split the code...

g.FillRectangle only working one time

c#,draw,tabcontrol

You need to change the position of the second rectangle so it starts in the same position as the first: //tab is selected System.Drawing.SolidBrush lightBlue = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(239, 242, 247)); g.FillRectangle(lightBlue, tabRectangle); // I can't get this working.. System.Drawing.SolidBrush sele = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(65, 95, 155)); g.FillRectangle(sele, new System.Drawing.Rectangle( tabRectangle.X,tabRectangle.Y, 5,...

How to draw the trajectory ( tracking path ) of an moving object in an image - Opencv?

image,opencv,draw

cv::Mat imageToDraw; //this is your image to draw, don't forget to load it std::vector<cv::Point> pointsInLast20Frames; //fill this vector with points, they should be ordered cv::Scalar color(0, 0, 255); //red for(int i = 0; i < pointsInLast20Frames.size() - 1; ++i) { cv::line(imageToDraw, pointsInLast20Frames[i], pointsInLast20Frames[i+1], color); } ...

Draw triangle by the intersect of 3 circles

javascript,canvas,draw

Finding the intersection points which are on the circumference of all three circles Here's how to do it: Define 3 circles: var A={x:0,y:0,r:200,color:"rgba(52, 152, 219,0.5)"}; var B={x:0,y:400,r:250,color:"rgba(46, 204, 113,0.5)"}; var C={x:300,y:200,r:280,color:"rgba(241, 196, 15,0.5)"}; Calculate the intersection points of the 3 circles vs each other (AB,BC,CA): var intersections=[]; var AB=circleIntersections(A,B); //...

My repaint in JFrame is not working

java,swing,draw,keylistener,repaint

The KeyListener shouldn't be working since a JComponent by default cannot get program focus, a necessary requirement for a KeyListener to work. One solution is to make it focusable via setFocusable(true) and then call requestFocusInWindow() on it. Better to use Key Bindings (tutorial link). Note that you should be overriding...

sqrt-based filled ellipse pixel drawing function

vb.net,lua,draw,pixels,ellipse

Here's what I came up with for my CPU renderer in the past. It's very efficient and very simple too. It relies on the mathematical definition of the ellipse, so the ellipse is drawn centered at x,y and has the width and height defined from the center, not from the...

Drawing on a panel but when adding it through another frame, nothing draws

java,user-interface,panel,draw

There are 2 separate issues here. (1) Simplest answer is - you need to call 'getGraphics' from within your action method. Not from the constructor. E.g. public void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { Graphics2D doo = (Graphics2D) jPanel2.getGraphics(); ... doo.setFont(...); doo.drawString(...); } (2) This would yield visible drawings, but they'll disappear whenever...

As3: Draw overlapping rectangles to a sprite and apply alpha

actionscript-3,graphics,sprite,draw

I suspect that the graphics object does not support this kind of functionality for parts of its data. If both boxes are individual DisplayObjects, you can set the .blendMode of the DisplayObjectContainer to BlendMode.LAYER, which gives the desired result. Here's some example code that refactors the drawing of a rectangle...

How can I optimize this bottleneck Draw call?

c#,optimization,xna,draw,xna-4.0

You could always render each building to a texture and cache it while it's on screen. That way you only draw the windows once for each building. you will draw the entire building in one call after it's been cached, saving you from building it piece by piece every frame....

Click is registered but not drawn in canvas android

android,performance,canvas,draw

Idea To solve this answer is taken from Android FingerPaint sample does not draw dot? My Code : private boolean mDrawPoint; @Override public boolean onTouchEvent(MotionEvent event) { int maskedAction = event.getActionMasked(); Log.d("onTouchEvent"); switch (maskedAction) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_POINTER_DOWN: { mDrawPoint = true; paths = new HashMap<Integer, Path>(); cor.setStrokeWidth(brushSize); for...

Drawing with timer is not working

java,swing,timer,awt,draw

Never start a Timer inside of paintComponent. This method is for drawing and drawing only and nothing, I mean absolutely nothing else. You should start your Timer elsewhere, perhaps in the class's constructor, and have it change fields of your class, and then call repaint(). The paintComponent method should then...

Styling Android Spinner

android,styles,spinner,draw

I found a solution what I want to do as below. <Spinner android:id="@+id/genderBox" android:layout_width="match_parent" android:layout_height="30dp" android:background="@drawable/my_spinner" /> and make a xml file in drawable folder and paste following code <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape> <solid android:color="@android:color/white" /> <stroke android:width="1dp" android:color="#d2d2d2" /> <padding...

Draw a circle in a Canvas using changing-variable(animation)

java,android,variables,canvas,draw

private float width = getWindowManager().getDefaultDisplay().getWidth() height = getWindowManager().getDefaultDisplay().getHeight(); //Ns permet de savoir la resolution instead of this: float width = this.getWidth() height = this.getHeight();//Ns permet de savoir la resolution ...

Add white rectangle above a screenshot in a Graphics object (java) [duplicate]

java,graphics,draw

Here's the rough idea: BufferedImage image = ImageIO.read(file); int whiteSpaceHeight = 20; BufferedImage result = new BufferedImage(image.getWidth(), image.getHeight()+whiteSpaceHeight, image.getType()); Graphics graphics = result.getGraphics(); graphics.drawImage(image, 0, whiteSpaceHeight, null); graphics.drawString(textToAdd, 0, whiteSpaceHeight/2); ...

c# Draw Textbox onclick

c#,textbox,draw

You should examine OnClick event on your Form or Panel. Then you should get x and y parameters and, finally, use method panel1.Controls.Add(yourTextBox); But seriously, this is googleable question, so, please, avoid asking such on StackOverflow.

canvas rectangles get drawn then disappear javascript

javascript,canvas,draw

It looks like your rects are being drawn and then the image (which loads asynchronously) is eventually loaded and then drawn on top of the rects--making them disappear. Put the if(theSection.allHotSpots.length > 0 inside the onload so the image doesn't later clobber the rects....

Draw an ellipse sqrt-based function

vb.net,plot,lua,draw,ellipse

Ok, I managed to find a solution for the filled ellipse by checking if the pixel from the second half is gonna be drawn in the x-range of the first half of the ellipse. function drawellipse(xc, yc, w, h, dofill) --trouble with the size, 1 pixel to large on x...

pygame drawing a filled rectangle overwrite border, but only sometimes?

python,pygame,draw,rect,class-variables

Okay, I figured it out. The Rect argument in the draw function is relative to the position of the image. Since I had set its rect to its location on the screen, it was drawing the rectangle way offset from the corner. It worked on my first one only because...

How to draw in the screen AndroidStudio? [closed]

android,screen,draw

here is a code that could help you. import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.media.MediaPlayer; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.widget.Button; public class rodando extends ActionBarActivity...

isssue in redo undo opration in my paintview android

android,drawing,android-canvas,draw

Try removing canvas.drawBitmap(canvasBitmap, 0, 0, canvasPaint); and replace with canvas.drawColor(canvasPaint); If that works then the additional paths you see are on this background bitmap. Second issue, create a new storage class: public class ColoredPath{ private int color; private Path path; //simple getters and setters here } Store like this: public...

how to draw a text on a circle in SWIFT

swift,text,drawing,draw

By using this library : https://github.com/javenisme/CurvaView var arctext : CoreTextArcView = CoreTextArcView(frame: CGRectMake(50, 50, 200, 200), font: UIFont.systemFontOfSize(15), text: "Hello this is radious arc with text", radius: 85, arcSize: 130.0, color: UIColor.redColor()) arctext.backgroundColor = UIColor.clearColor() self.view.addSubview(arctext) Remove arc for one file like as follows (set -fno-objc-arc to that library's .m...

Can't draw a triangle with OpenGL ES 2.0 on android

java,android,opengl-es,geometry,draw

Clear the background before drawing the triangle ;) public void onDrawFrame(GL10 unused) { // Redraw background color GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); mTriangle.draw(); } ...

How to set timer in View class?

android,multithreading,timer,draw

But it is showing this exception IllegalThreadStateException. It caused by non-runnable or non-threading class. A class that extends View has not thread on it, so that you get IllegalThreadStateException. Is there any other way to implement timer in this screen? Java provided a Timer class to be used for...

AndroidScript - DrawArc equivalent?

javascript,android,android-canvas,draw,android-scripting

Here is a good answer posted by Schnee Wittchen on another forum:- You may use the DrawArc method of the image object. I found it a little bit tricky as it behaves different to the normal explanation, but anyway it is usable. Syntax: img.DrawArc( x1, y1, x2, y2 ,startangle, sweepangle...

Does the draw order affects objects position in depth? (images included)

c++,opengl,shader,draw

I have cloned the repository you have linked to see if the issue was located somewhere else. In your most recent version the Object3D::draw function looks like this: glBindVertexArray(this->vaoID); glUseProgram(shader.getProgramID()); glUniformMatrix4fv(this->currentshader.getUniformID_Model(), 1, GL_TRUE, this->currentMatrix.getMatrix()); // PPmat é matriz identidade glDrawElements(GL_TRIANGLES, 40, GL_UNSIGNED_INT, (GLvoid*)0); glBindVertexArray(0); glUseProgram(0); glClear( GL_DEPTH_BUFFER_BIT); <<< clears the...

QRubberBand, how to draw on it

c++,qt,draw,rubber

It is not drawing on rubber band but it does what you need : void MyButton::mouseMoveEvent(QMouseEvent *event) { rubberBand->setGeometry(QRect(mypoint, event->pos()).normalized());//Area Bounding QToolTip::showText( event->globalPos(), QString("%1,%2") .arg(rubberBand->size().width()) .arg(rubberBand->size().height()),this ); } QToolTip is shown near the cursor. It dynamically changes and shows actual information about size of rubber band. Result (black area is...

Draw circle from main Activity or change view

java,android,view,android-activity,draw

To draw a circle using paint , you need to create a custom view like this private class CircleView extends View{ Paint paint = new Paint(); public CircleView(Context context) { super(context); } @Override public void onDraw(Canvas canvas) { paint.setColor(Color.GREEN); // set your own position and radius canvas.drawCircle(100,200,100,paint); } } And,...

What to use for drawing in Android - View or SurfaceView?

android,view,android-canvas,draw,surfaceview

If you want to use Canvas, you are increasingly better off with a custom View, rather than a SurfaceView. The simple reason is that Canvas rendering on a View can be hardware accelerated, while Canvas rendering on a SurfaceView's surface is always done in software (still true as of Android...

Pygame draw interactively

python,pygame,mouse,draw,interactive

You are filling white the entire screen every tick. So after you actually draw the screen become blank again on the next tick. Just move screen.fill(white) out of main cycle: import pygame windowSize = (500,500) white = (255,255,255) black = (0,0,0) pygame.init() screen = pygame.display.set_mode(windowSize) running = 1 screen.fill(white) while...

How to fill in area with certain color

colors,draw,pixel,area

As Kenogu Labz mentions in another answer, your problem is that the your Color match is exact but the colors around the edges of the image are antialiased or being degraded by the source image codec (a common problem with lossy image compression systems such as JPEG). Instead of performing...

Erase or delete a line drawn on a TImage Canvas

delphi,canvas,line,draw,erase

If you do not have areas filled with color, you can do all drawing with Pen.Mode set to pmXOR. It will give some odd points where lines cross (for example where the red line crosses the blue circle), but when you re-draw the red line - it will disappear. Just...

Processing: Trying to animate the drawing of lines without draw function

java,animation,twitter,processing,draw

Processing uses double buffering, which means that when you draw "to the screen", you're actually drawing to an off-screen buffer. Since your code is not in the draw() function, this happens before the frame is even visible. Then when the frame becomes visible, it takes the entire off-screen buffer, and...

libgdx won't draw sprite or animation

java,android,libgdx,draw

Your keyframes are kept in an array called bullets, but when you call the Animation constructor you pass something called 'aims' as the second argument. You should try instead passing 'bullets', as in: bulletAnimation = new Animation(0.06f,bullets); You shouldn't have a problem with using a Sprite[] as the Sprite class...

How to use a SurfaceView from an Adapter (Android)

android,draw,surfaceview,android-adapter,baseadapter

Overriding draw() probably isn't what you want. If you want to draw on the View, override onDraw(). If you want to draw on the Surface, that's usually done from a separate thread. (The SurfaceView has two parts; the surface part is a completely separate layer that is drawn behind the...

How to draw a rectangle around multiline text

java,pdf,itext,draw

It sounds as if you are missing only a single piece of the puzzle to meet your requirement. That piece is called getYLine(). Please take a look at the DrawRectangleAroundText example. This example draws the same paragraph twice. The first time, it adds a rectangle that probably looks like the...

How can I center Graphics.drawString() in Java?

java,text,draw,centering,graphics2d

I used the answer on this question. The code I used looks something like this: /** * Draw a String centered in the middle of a Rectangle. * * @param g The Graphics instance. * @param text The String to draw. * @param rect The Rectangle to center the text...

Cant Override UIView.Draw Method

c#,ios,uiview,xamarin,draw

The problem is that you create a program with the Unified API (see "using CoreImage" at the top). In Unified API, we no longer use PointF, SizeF or RectangleF, as those are 32-bit structures, so they do not work on 32/64 bit modes. In Unified, you need to use "CGRect"...

Clearing Graphics from a Window in Python

python,text,graphics,window,draw

EDIT: Apparantly, you're using Calico graphics, which is built on IronPython not Cython and does not have access to the tkinter bindings. The underlying implementation is Gtk, not tkinter, and that's the place to look if you're trying to extend the functionality (though it looks perfectly sufficient as is). The...

Draw text on screen

ios,text,draw

So, I am using this solution now. Thanks to InkGolem for the small hint. This code writes the string "textOnScreen" to the position x=75 and y=35 with yellow colour. UILabel *uiLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 20, 15)]; uiLabel.text = @"textOnScreen"; uiLabel.frame=CGRectMake(75, 35, 160, 20); uiLabel.font=[UIFont boldSystemFontOfSize:25.0]; uiLabel.textColor=[UIColor yellowColor]; uiLabel.backgroundColor=[UIColor...

Javascript bmi calculator pointer position

javascript,draw

Seeing how I myself am very new to javascript and I'm not really sure how you image is constructed (if it's all a big box or several lesser boxes), I'll just give you my point of view. Assuming you have four seperate boxes and we take the green one as...

How can i separete the letter in string when drawing

java,draw,drawstring

You can draw each character seperately. By retrieving the FontMetrics currently used by the Graphics object, you can measure the width of each character, so you can advance using this width and a given seperation. public static void drawString(Graphics g, String string, int x, int y, int seperation) { FontMetrics...

getGraphics from panel returns null

java,swing,graphics,nullpointerexception,draw

You are using the Graphics object wrong. Instead of calling write from wherever you call it, instead override paintComponent. You could do something like: private int xx; private int yy; private Color c; @Override protected void paintComponent(Graphics g) { super.paintComponent(g); if(c != null) { int width=panel.getWidth()/x; int height=panel.getHeight()/y; g.setColor(c); g.drawRect(xx*width,...

How to move axes to center of chart in Maxima draw

plot,center,draw,axis,maxima

Right. You'll use something like the following, with symmetric ranges for x and y. load(draw)$ draw2d( user_preamble="set zeroaxis linetype 5; set xtics axis; set ytics axis; set border 0;", explicit(sin(x),x,-%pi, %pi))$ ...

How to draw a circle with asterisk? function in Ruby [closed]

c++,ruby,draw,asterisk,circle

Here is an equivalent C++ code #include <iostream> int main() { double r = 7.0; double r_in = r - 0.4; double r_out = r + 0.4; for ( double y = r; y >= -r; --y ) { for ( double x = -r; x < r_out; x +=...

Android Canvas drawLine not drawing on MainActivity

java,android,android-activity,canvas,draw

you can display the bitmap like that: canvas.drawBitmap(bmp, positionX, positionY, paint); in your case you can try somthing like this: canvas.drawBitmap(bitmap, 0, 0, null); but you need to use a diffrent canvas for it. The canvas wich let you draw stuff on your screen will be passed to your onDraw()...

Java Graphics clear arc

java,graphics,draw,paintcomponent

Try it out: import java.awt.Graphics2D; import java.awt.geom.Area; import java.awt.geom.Ellipse2D; import java.awt.geom.RoundRectangle2D; // and other stuffes you should have already imported @Override public void paintComponent(Graphics g) { super.paintComponent(g); Area area = new Area( new RoundRectangle2D.Double(0, 0, 200, 200, 50, 50)); area.subtract(new Area(new Ellipse2D.Double(75, 50, 50, 50))); g.setColor(Color.RED); ((Graphics2D) g).fill(area); } Link...

HTML CANVAS not working

javascript,html5,canvas,draw

The code seems ok to me. I added a call to the init function. As LJ_1102 stated: The offset issue is a CSS issue. The width and height attributes set the width and height of the bitmap itself. The CSS width and height attributes set the element width and height....

Customize a ProgressBar to become a Thermometer

android,drawing,draw,android-custom-view,android-progressbar

First I would provide 2 setters, one for color and one for the temperature value, normalized from 0 ... 1, where 0 means no visible bar, and 1 means a fully visible bar. public void setColor(int color) { mColor = color; invalidate(); // important, this triggers onDraw } public void...

Arc doesn't shows on wpf canvas?

c#,wpf,canvas,draw

You have to set Canvas.Left and Canvas.Top on the Ellipse, not on the Canvas. in cnv_MouseLeftButtonDown change Canvas.SetTop(cnv, p.Y); Canvas.SetLeft(cnv, p.X); to Canvas.SetTop(ellipse, p.Y); Canvas.SetLeft(ellipse, p.X); Another bug is cnv_MouseMove, where the expression ellipse.Width = p.X - Canvas.GetLeft(ellipse); tries to assign a negative width to the Ellipse when the mouse...

Create Custom UIVview, circle with two color

ios,objective-c,uiview,draw

Subclass UIView and implement the drawRect: method. Here is code to draw a circle to get you started: - (void)drawRect:(CGRect)rect { CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextAddEllipseInRect(ctx, rect); CGContextSetFillColor(ctx, CGColorGetComponents([[UIColor blueColor] CGColor])); CGContextFillPath(ctx); } also, take a look at how to draw part of a circle...

Libgdx blending contrast issue in render();

libgdx,rendering,draw,alphablending

The blend function you're using for the spotlight takes the current pixel brightness and multiplies it by (1+alpha). So if you darken to 0.7 of brightness (using a darkener alpha of 0.3), you want the spotlight to multiply the brightness by 1/0.7 = 1.429 so you should use a spotlight...

Drawing with Transparent Paint on Android

android,canvas,2d,draw,paint

Pleas try t use the following Paint. I may Help.! mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setColor(Color.TRANSPARENT); mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT)); mPaint.setAntiAlias(true); ...

Javascript drawing board with columns of alternating colors using ctx

javascript,draw

You should divide your x value by the increment (10) and check its modulo 2 : function draw() { var canvas = document.getElementById('canvas'); var ctx = canvas.getContext('2d'); for (var y = 0; y < 100; y += 10) { for (var x = 0; x < 100; x += 10)...

Draw circle and X spots inside an image by list of x,y coordinates.Asp C#

c#,asp.net,image,coordinates,draw

Finally I made it.As DrCopyPaste said you must load image, draw and save it.Draw green circle and red X with the following code. Bitmap bitMapIm = new System.Drawing.Bitmap(Server.MapPath(@"images\court.jpg")); Graphics graphicIm = Graphics.FromImage(bitMapIm); Pen penGreen = new Pen(Color.Green, 3); Pen penRed = new Pen(Color.Red, 3); for (int i = 0; i...

Rebin data and update imshow plot

python,numpy,matplotlib,draw,imshow

You seem to be missing the limits on the y value in the histogram redraw in update_data. The high index and low index are also the wrong way around. The following looks more promising, Z, xedges, yedges = np.histogram2d(x[high_index:low_index],y[high_index:low_index], bins=150) (although I'm not sure it's exactly what you want) EDIT:...

C# Draw multiple Lines

c#,line,draw

I would make a Line class having start and end point of the line in struct Point and make list of that class instead of having four arrays. public class MyLine { public Point StartPoint {get; set;} public Point EndPoint {get; set;} public void DrawLine() { //Draw line code goes...

Arc or circle not perfectly round after drawing on screen

android,draw,circle

seems that arc drawing routine is somewhat broken, run my code and wait till angle is < 270 degs or less: class V extends View implements Runnable { private Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private RectF mRect = new RectF(); private float mStartAngle; private float mAngle; private Xfermode mClearMmode =...

How to correctly position a “X” in a rectangle?

c#,position,draw,square

It seems like the issue is where you are using your MidpointRounding.AwayFromZero It seems to me that if the sum you have to calculate the position you want to draw the 'X' gives the result 6.6, you want to have it in position 6, not position 7, so realistically you...

How to draw a animated line appearing in canvas html5?

javascript,jquery,animation,html5-canvas,draw

var canvas = $("#paper")[0]; var c = canvas.getContext("2d"); var startX = 10; var startY = 10; var endX = 500; var endY = 10; var amount = 0; setInterval(function() { amount += 0.05; // change to alter duration if (amount > 1) amount = 1; c.clearRect(0, 0, canvas.width, canvas.height);...

drawing gradient over rectangle in swift

ios,swift,draw,gradient

You need to specify a clipping path right before drawing the gradient. In your case, create a rectangle path and call CGContextClip(context) CGContextAddRect(context, CGRect(...)) CGContextClip(context) CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0) The gradient will be clipped to the rectangle....

android draw rectangle with dimensions and modify them in runtime

android,runtime,draw,dimensions

I just know about the existence of the class enum, which solves the problem of design that I had. It's a much easier way of carrying it out. According to the example that I wrote in the wording of the question, this is the code using the class enum: static...

Class is not abstract and does not override abstract method

java,inheritance,abstract-class,draw

Both classes Rectangle and Ellipse need to override both of the abstract methods. To work around this, you have 3 options: Add the two methods Make each class that extends Shape abstract Have a single method that does the function of the classes that will extend Shape, and override that...

How do I draw things differently depending on the case in XNA?

c#,xna,draw

It sounds like your last example/choice is spot on. It even has a name, the Strategy pattern. In the class based version of this pattern, you would normally just pass in a new object every time (as in your example) but because this is in the Draw method, I would...

How to get all the coordinate points (X and Y) in ios

ios,xcode,draw,uibezierpath

The system sends touch events at a certain interval. If you move slow you get more, but going fast you get less of them. You can't get more if you move fast. But you also don't need more probably. You just have to draw the line between points, no matter...

How to draw a specific shape in CSS? [closed]

css,draw,shape,css-shapes

Try to break your shape up in smaller shapes. You could do something like this: Draw a square to serve as the main body for your shape Draw three triangles in different sizes to overlap the square in your background color. By hiding certain parts of your square you can...

Pygame.draw.arc() completion bug or just me?

python,python-2.7,pygame,draw

Solved thanks to /u/Mekire in this reddit post import pygame from pygame import gfxdraw RED = pygame.Color("red") WHITE = pygame.Color("white") def draw_arc(surface, center, radius, start_angle, stop_angle, color): x,y = center start_angle = int(start_angle%360) stop_angle = int(stop_angle%360) if start_angle == stop_angle: gfxdraw.circle(surface, x, y, radius, color) else: gfxdraw.arc(surface, x, y, radius,...

Understanding void draw() in processing

processing,draw

Most Processing sketches use a call to the background() function as the first line in the draw() function. This clears out anything drawn in previous frames. However, you want to keep the stuff drawn in previous frames, so you don't want to clear them out. The problem with this is...

Drawing a triangle with rounded bottom in CSS?

css,geometry,draw

So we create a circle and place it on top to make it look like how you want it, you get something like this: CSS: .triangle{ width: 0px; height: 0px; border-style: solid; border-width: 0 200px 200px 0; border-color: transparent #48a665 transparent transparent; } .triangle:after { content: ""; display: block; width:...

Drawing in a Gtk.DrawingArea

gtk,draw,pygobject,drawingarea

Adding DrawingAreas to a Grid is a bit problematic if hexpand and vexpand are not set. Additionally adding width_request and height_request is needed (or some other layout organization which forces the DrawingArea to have a size), otherwise the initial window size will be tiny or not visible. The following shows...

c draw function not drawing properly

c,draw

Typecast problem. M results in 0 when dy/dx is below one. Typecast them to floats to get a float as a result.

Character walks slow in my C# game

c#,performance,draw

Start with this: Player.Image = Image.FromFile("Rice-Boy-Walking-Down.gif"); (and the other load routines). On every tick? Seriously? Load them once during initialization, store them in variables, reuse the images. Ever played a computer game? They are not trashing your disc trying to load all graphics asset every frame. Disc access is slow....

How to draw custom rectangles in java

java,draw,drawrectangle,path-2d

The key is you want to visualize how the code is drawing the object. The original code starts at the top left corner and draws in a clockwise direction. First, you need to move your start point, this will be much easier if you start on a corner, not a...

Draw a fill rectangle dynamically on screen in C#

c#,screen,draw

This is an example that works for me. The crucial parts are: using the Paint event and its Graphics adding a Clear(BackgroundColor) or else I get the same artifacts you see for transparency the TransparencyKey property should be used. There is a certain choice of colors: Common colors may conflict...

DirectX cuts Vertex and only draws last call

c++,directx,draw,vertex

I got it fixed, here for others: Vertices getting cut: my near/far plane were to near to eachother. (they were 0.1f and 100.0f) Changed both values and now they work. DirectX only drawing last call: Had to apply material again for each model. So doing // Set coresponding input layout...

Leaflet-draw : Create editable layers

angularjs,draw,leaflet,geojson,angular-leaflet-directive

I modified your code and it seems that I have fixed the bugs for you. Here is my code. <!DOCTYPE html> <html ng-app="demoapp"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="http://tombatossals.github.io/angular-leaflet-directive/bower_components/angular/angular.min.js"></script> <script src="http://tombatossals.github.io/angular-leaflet-directive/bower_components/leaflet/dist/leaflet.js"></script> <script...