FAQ Database Discussion Community


Drawing/Moving/Deleting strokes on HTML5 Canvas

javascript,cordova,canvas,html5-canvas,drawing
I am developing a drawing app using HTML5 Cordova. I need to implement drawing ,move strokes, delete ink strokes on HTML5 Canvas. I am exploring best ways to achieve the following: 1) Draw a stroke 2) Select a stroke and move it 3) Select a stroke and delete it. It...

Highcharts - Diagonal line X/Y axis

javascript,charts,highcharts,drawing
Is there any way of showing a 1:1 diagonal line in Highcharts? I am looking for a line which X and Y values always match. I know how to render a line in Highcharts using the renderer, however, I don't want an independent line but one that reacts to the...

Drawing a moving line in a transparent panel in C#

c#,drawing,transparency
There seems to be a million questions out there on this, yet I can't find one that will work. So, I guess it's time for question 1,000,001. I have a custom control with a PictureBox and a Panel. The Panel is the child of PictureBox with a transparent background. This...

Coordinates not corresponding

java,android,canvas,drawing
I'm pretty new to Android and I'm really struggling trying to understand what is going on in my application. I'm trying to build a small game in which a circle appears on the screen, in a random position and it disappears as soon as the user clicks on it. Then...

How to draw an animated path with multiple colors in ios?

ios,swift,animation,drawing
I need to draw something like the following image in my iOS app, except that the arc may contains more colors: I know how to draw it, but I'm looking for a way to animate the drawing of the path. There is a similar question here, except that the circle...

self updating drawings C#

c#,winforms,drawing
I am trying to make an external map for a computer game. Therefore I have made a Forms Application with a picture box, that contains my map image. Now I want to draw little squares onto the map using GDI. I allready got that working using Graphics.DrawRectangle. Now I want...

Customize a ProgressBar to become a Thermometer

android,drawing,draw,android-custom-view,android-progressbar
How to customize a ProgressBar to look like a Thermometer ? with the possibility to change color. My suggestion was to rotate the progressBar 90° to become vertical then have it overlay an image of an empty Thermometer but it's bad and messy solution. I Think the best will be...

Getting a line that has the coordinates defined by the mouse location

c#,graphics,drawing,line,mouse
I'm trying to make a little graphics program that has a circle of diameter 100 on the screen and from the center of it, a line is coming out of it that is always attached to the mouse pointer until such time that the user does a click, and then...

why won't my circle loop work in python

python,loops,drawing,turtle-graphics
import turtle import time import random n = int(input("how many circles do you want? ")) radius = int(input("Radius?")) turtle.forward(radius) turtle.left(90) for circle in range(num, 0, -1):90 (num..1) turtle.begin_fill() turtle.color(random.random(),random.random(), random.random()) turtle.circle(radius * circle / num) turtle.end_fill() turtle.left(90) turtle.forward(radius / num) turtle.right(90) ...

Drawing on canvas with opacity (dots in line) javascript

javascript,html5,canvas,drawing
I have that drawing logic: Draw = function(canvas, ctx, mousePosition) { var grad = ctx.createLinearGradient(0, 0, canvas[0].width, 0); grad.addColorStop(0, currentLineColor); grad.addColorStop(1, currentLineColor); ctx.lineWidth = currentLineWidth; ctx.strokeStyle = grad; ctx.lineCap = 'round'; ctx.lineJoin = 'round'; ctx.globalAlpha = 0.4; ctx.beginPath(); ctx.moveTo(lastMousePosition.x, lastMousePosition.y); ctx.lineTo(mousePosition.x, mousePosition.y); ctx.stroke(); }; When i set the globalAlpha to...

Drawing a line with a pixmap brush in Qt?

c++,qt,drawing,qpixmap
For some time I'm developing a simple drawing and painting app with Qt/C++. Currently I'm using QPainter::drawLine() to draw, and it works fine. What I want to do is drawing with pixmap brushes, which in a way I can do. I can draw with single color filled pixmaps using QPainterPath...

iOS swift - how to draw an ellipse with touch event

ios,swift,drawing,ellipse
currently I am trying to port my old windows phone app to iphone. The UI looks like this: I want to know how to do the following: Draw a solid ellipse on a specific position, e.g. at position x = 0, y = 0; The ellipse change its color upon...

Is it possible to rotate a drawing half-way its definition?

c#,drawing,rotatetransform
I'm doing some draws that are repetitive, and each of them gives lot of work. What i need to do is rotate the drawing half-way its definition, something like this: using (Graphics g = Graphics.FromImage(bmp)) { //define area do pictureBox e preenche a branco Brush brush = new SolidBrush(Color.White); Rectangle...

How to understand use-cases in specific scenerio

drawing,uml,modeling,use-case
I am drawing a diagram of use-case using ArgoUML, I have a scenario in which user can update status but after sign in to the application , in that sense i need to extends update status after sign in or make it a new separate usecase or generalize it. Thank...

saving drawing to sdcard from a custom view android

android,bitmap,drawing,android-canvas,android-custom-view
I'm working an app which is can draw on a custom view. I want to save the drawing with a button. I tried the other solution on the other threads but nothing. please give me an example with my method below. actually, it's not my method. it's from https://github.com/msiuts/FingerPaint Custom...

Undo/Redo for iOS Painting App

ios,drawing,opengl-es-2.0,paint,undo-redo
I have been doing research on what the best way to achieve undo/redo functionality is for a painting app. I am using OpenGL ES 2.0 on iOS. The most popular approach seems to be to save a list of commands and VBOs to re-generate the painting to its previous state...

Rotate a individual rectangle and ALL its contents

c#,drawing,rotatetransform
I'm using the method posted here Using a matrix to rotate rectangles individually (I hope this is not a repost, if it is maybe i'm doing something wrong) I'm using the perfectly defined RotateRectangle method as follows public void RotateRectangle(Graphics g, Rectangle r, float angle) { using (Matrix m =...

How to move panels up/down on keysDown event in c#

c#,winforms,drawing,panel
I've 4 panels, having same Y and different X, that are created at the program start on a picturebox. When I click on a panel, it sets the focus and is ready to get a keysDown event so i.e. if I click on up arrow key the panel moves up....

Draw String to centre of elipse using C#

c#,drawing
I have simple code, which can draw elipse. I want draw number to center of this elipse, how can I do this? Code for draw elipse is: Point point = p.PointToClient(Cursor.Position); float radius = 13.0f; float x = point.X - radius; float y = point.Y - radius; float width =...

How to draw smooth movement on surface

android,canvas,drawing,surfaceview
I am trying to achieve smooth movement of a drawn object. Here I draw circle which by itselfe move in Hypotrochoid path. I am setting delay in 16 ms to get 60 frames per second and position every frame. However my circle still does not move smooth. Main Activity Handler...

Drawing function but only on a certain screen/page (actionscript3)

actionscript-3,flash,actionscript,drawing
How do I make a drawing function to function only on one page/screen of an app? For example, the drawing function should only happens on page 15. What should I do in order for the "drawing"/drawing function to not be stuck on the screen when it goes to other pages?...

How can I calculate where to start my line based on the stroke cap?

android,drawing,ondraw,stroke
I'm trying to draw a line, but I need to take the width of the stroke cap into account so I don't overflow the container. I have code that looks like this... private void initialize() { this.paint = new Paint(); this.paint.setColor(Color.BLACK); this.paint.setStyle(Paint.Style.STROKE); this.paint.setStrokeCap(Paint.Cap.ROUND); this.paint.setStrokeWidth(1); } public void setStrokeWidth(float strokeWidth) {...

Why am I getting a QWidget error?

python,graphics,drawing,pyqt4
I have recently found this person's code that I could possibly be able to use for my project but I'm still pretty new to Python so I'm having a really rough time understanding the code and the error that keeps occurring even though the code is exactly the same as...

How to draw a rectangle using a char parameter in C++?

c++,parameters,char,drawing
I want to draw and fill a rectangle using C++. The function parameter passed in must be a char, not an int. In my header file the drawing function is this: void draw(char); My rectangle.cpp file is this: void rectangle::draw(char ) { for(height=0;height<=height;height++) { for(width=1;width<=width;width++) { cout<<'*'; } } }...

Matrix (?) to Rectangle and vise versa

c#,geometry,drawing
I'm currently working with files that define rectangular shapes in a way that I'm unfamiliar with. Someone told me it might be a matrix, but knowing that doesn't particularly help me with my problem, converting it to points and back. For example, I have these values: 0.95, -0.28, -0.28, -0.95,...

C# Win.Form - graphics disappear after load

c#,winforms,graphics,user-controls,drawing
I'm drawing on a User Control to show the time between two dates. My problem is when the applications starts running or every time I Refresh() the User Control all graphics disappears until the Form is resized. Observing how the Form behaves when it refreshes, the User Control is shown...

wxPython Draw A Triangle

python,wxpython,drawing
I understand that this is a very simple question, but how do you draw a triangle using wxpython? A simple example would be much appreciated. I tried using dc.DrawPolygon(self, points, xoffset, yoffset, fillStyle), but I didn't know what to pass in for fillstyle. All my efforts resulted in odd error...

Drawing canvas animation for pie on time h:m:s

javascript,jquery,canvas,drawing
How to draw a pie canvas by set time in inputs H:M:S? I have fiddle, but it works on the percentage. Please help make animation process on set time values. Thanks. function animate(current) { context.clearRect(0, 0, canvas.width, canvas.height); context.beginPath(); context.arc(x, y, radius, -(quart), ((circ) * current) - quart, false); context.stroke();...

Bitmap from Drawing not render outside of Load_Form

c#,.net,bitmap,drawing,system.drawing
I'm trying to render bitmap created from drawing to screen but only render after minimize and maximize again. I follow these steps: Using Bitmaps for Persistent Graphics in C# But only can render bitmap in screen outside of Load_Form. If I put the code: using System.Drawing; ... Graphics graphicsObj; myBitmap...

Qt - Draw on canvas

qt,drawing,qt5
I am trying to write a program using Qt5 that allows users to draw on canvas like paint. I know that the program has to handle events such as mousePressEvent(), mouseReleaseEvent(), and mouseMoveEvent(). But I am not able to figure out how to use them. Can you guys give me...

update NSView automatically with the function swift

swift,drawing,updates,nsview
I have a custom NSView with some drawing: class ViewController: NSViewController { @IBOutlet weak var mainView: LineDrawer! var time = NSTimer() override func viewDidLoad() { super.viewDidLoad() self.view.needsDisplay = true // Do any additional setup after loading the view. } override var representedObject: AnyObject? { didSet { // Update the view,...

How can I draw with pen width of 0 (invisible not cosmetic)?

c++,qt,drawing
I want to draw shapes with a border of various widths. If I set width = 0 though, I expect (imagine) that here will be no border... yet I read that the border 0 is very thin ("cosmetic") border. How can I draw my shapes with invisible border ? int...

GradientPaint Working Strangely

java,swing,drawing,gradient
While playing around with Java's painting tools, I came across the java.awt.GradientPaint class, which allows for gradient coloring when drawing shapes. I decided to play around with it, drawing filled-in rectangles with a red-to-green gradient on a JPanel, and immediately noticed something strange. When I began drawing a rectangle, it...

Why cant i paint on the panel

java,swing,jpanel,awt,drawing
I have made three panels south, east and north, i am trying to draw a circle on the north panel but i just cant figure out why it is not drawing.Here is my code: What i want is a small application that draws circles of different sizes and colours chosen...

how can i draw straight line using UIBezierPath in ios

ios,xcode,drawing
i am trying to draw straight line on my view....i can draw line on my finger path with that code but the line that drawn that is not straight ...it seems like it drwan with pencil....so how can i make it straight.. @implementation View { UIBezierPath *path; // (3) }...

HTML, Canvas Path2D alternative.

canvas,drawing,mobile-safari
I draw some graphics on my website using Path2d. Nothing complicated, just two triangles. But MobileSafari fails to create Path2D() object. Is there any workaround for it ? or any library to do that ? Thanks....

iOS - Fill bezierPath with multiple colors based on percentage

ios,drawing,uibezierpath
I drawed a UIBezierPath in Objective-C and fill it with a red color. Now, I want to fill the path with multiple colors based on percentage. For example: I want to fill the path with 20% green color and the remaining 80% with red color, on top of each other...

performance loading images game class

java,performance,variables,drawing
I'm trying to decide between several ways of drawing images for objects in a game. I want objects to have their own draw() method, but I'm afraid that I may cause unnecessary copies of the image or some other drop in efficiency, noticeable or not. The first way loads the...

wxPython DrawRectangle Not Filled with Black Background

python,wxpython,drawing
I am using python 2.7 and the most up to date version of wxpython for it (3.0). I am trying to draw a rectangle that is not filled. When I run the code below, it draws a red rectangle with the proper thickness, but the inside is white and not...

How to check if text overflows a rectangle in Tkinter?

python-3.x,tkinter,drawing
I drawn a rectangle in Tkinter. Then I wrote text inside the rectangle. But when I unzoom in my canvas, the text is getting bigger and it overflows the rectangle. So I want to check if the text overflows the rectangle in order to resize this text or totally remove...

Text drawing “bold”

c#,drawing
So I'm writing a program that generates a chart and saves it to PNG. From what I've read, if I were drawing to a window, it doesn't behave this way, but I'm not doing that. The problem is that when I pass the brush I use to draw the label...

Errors in bitmap creation in Java

java,bitmap,drawing,bmp
I'm trying to create a bitmap from a 2d array of pixel values. I've found some code on the internet (taken from http://forum.codecall.net/topic/62457-creating-a-bmp-image-in-java/): import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class BMP { private final static int BMP_CODE = 19778; byte [] bytes; public void saveBMP(String filename, int...

Java: Drawing single dots at specified (x,y) coordinates?

java,graphics,drawing
I am working on science research and am getting strange results from my code, and as a visual learner I thought it efficient to print my data to screen as it is analysed to try and see where the code is going wrong. For reference, I am analyzing a nonlinear...

OpenCV: how to draw continously with a mouse?

python,python-2.7,opencv,drawing,mouse
I modified a simple program taken from OpenCV documentation. I simply want to draw using the mouse pointer continuously. For the moment I succeeded to draw, but not in a continuous way unless if I move too slowly the mouse cursor. Code: import cv2 import numpy as np drawing=False #...

Drawing fractal flames

drawing,fractals,flame
Let me start off with the link to the PDF I've been reading to kickstart me into drawing fractal flames. http://flam3.com/flame_draves.pdf Following Draves' pseudo code I had no trouble drawing Sierpinski's Gasket using the three provided functions: F0(x, y) = ( x/2 , y/2 ) F1(x, y) = ( x+1/2...

Clear NSView programmatically in swift

osx,cocoa,swift,drawing,nsview
I have a NSView connected to a custom class.There's some drawing on that view: class LineDrawer: NSView { var linear = NSBezierPath() var storage = NSUserDefaults.standardUserDefaults() override func drawRect(dirtyRect: NSRect) { var color = NSColor() if let newLoadedData = storage.objectForKey("color") as? NSData { if let currentColor = NSUnarchiver.unarchiveObjectWithData(newLoadedData) as? NSColor...

Clipping a graphic in memory before drawing on form

c#,drawing,gdi+,widescreen
I'm trying to use the following code to copy a portion of the screen to a new location on my Windows form. private void Form1_Paint(object sender, PaintEventArgs e) { var srcPoint = new Point(0,0); var dstPoint = new Point(Screen.PrimaryScreen.Bounds.Width/2, Screen.PrimaryScreen.Bounds.Height/2); var copySize = new Size(100, 100); e.Graphics.CopyFromScreen(srcPoint, dstPoint, copySize, CopyPixelOperation.SourceCopy);...

How to draw and save 3D model in Qt from an array of 3d points?

c++,qt,opengl,3d,drawing
In my program I have an array of points with X; Y; Z coordinates. I need to be able to draw 3d model according to coordinates from this points and save it in file. And I'm stuck. Task seems to be not that difficult, it looks like I just need...

libGDX - TextureRegion drawing weird when scaled

java,libgdx,drawing,textures,texture-packing
Having a weird issue. I have a Texture with four frames of a sprite Animation. Each frame is loaded as a TextureRegion. Most of the time the Animation play without any issues, but occasionally it will draw too much of the Texture in one frame. Here's an example of what...

C#: Save image error

c#,image,drawing
i am trying to save a new image, but then C# give me an error like the following image the error refer to the following code string oldfilename = valid.getStringBeforeAnyChar(fi.Name, '.'); //"1" string newfilename = FolderDir + "\\" + subfolderoutput + "\\" + oldfilename + Copyright + fi.Extension; //"C:\\Users\\RHIT !...

Get coordinates of a drawing point from Chart Values in TextBoxes?

c#,.net,winforms,charts,drawing
In the designer I have two TextBoxes. And also a Chart control. I want that when I type in the first textBox the number 120 and in the second one type the number 1 it will draw a point on the chart in 120,1 but I mean 120 and 1...

Numpy-compatible image drawing library

python,image,numpy,drawing
I need to overplot general coordinate grids on images in python. I can compute the pixel coordinates of the grid lines, so I just need a module capable of drawing them as dashed lines on top of an image. The image comes in the form of a numpy array, so...

change alpha of a UIImage then use as colorWithPatternImage

xcode6,drawing,alpha,uigraphicscontext
I have a drawing app that I use preexisting .png images to draw certain textured colors into a UIImageView. //basic drawing stuff - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { ctr = 0; pts[0] = [touch locationInView:self.tempImage]; lastPoint = [touch locationInView:tempImage]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches...

FillEllipse Error

c#,exception,graphics,drawing,ellipse
I get a JIT compiling error running this code void draw(PaintEventArgs e) { Graphics gr =this.CreateGraphics(); Pen pen = new Pen(Color.Black, 5); int x = 50; int y = 50; int width = 100; int height = 100; gr.DrawEllipse(pen, x, y, width, height); gr.Dispose(); SolidBrush brush = new SolidBrush(Color.White); gr.FillEllipse(brush,...

Drawing by Windows GDI inside of Qt

qt,drawing,gdi,qgraphicsview
I am trying to use Windows GDI inside of QGraphicsView paintEvent but have noticed some drawing issues, for example the drawing disappear or blinking when I resize window or minimize and maximize. When I use Qt instead of GDI its working perfectly. Here is the code: [UPDATED CODE] #include "CustomView.h"...

Fill image with texture/pattern

javascript,canvas,html5-canvas,drawing,mask
I'm looking for a solution to change the texture/pattern for a product. At this moment i have: A .png picture of a couch with a transparent background A .png picture of a texture With the following code: <canvas id="a" width="800" height="500">Canvas not supported on your browser</canvas> var width = $(window).width();...

How to draw a simple rounded rect in swift (rounded corners)

ios,swift,drawing
I managed to draw a rect :-) But I don't know how to draw a rounded rect. Can someone help me out with the following code how to round the rect ?: let canvas = UIGraphicsGetCurrentContext() rec = CGRectMake(0, 0, 40, 40); //var maskPath = UIBezierPath(roundedRect: rec, byRoundingCorners: .BottomLeft |...

Masking circle segments in swift

swift,drawing,circle,masking
I'm creating a simple player app. There is a circle, that shows a progress of playing a song. What is the best way to draw this circle in Swift and make a mask? I assume I can draw a 2 circles putting the width stroke to the thickness I want...

How can I toggle shapes on and off screen in Java Swing?

java,swing,graphics,drawing,jtogglebutton
Okay so I am trying to build a program using swing in which I have to to be able to draw an oval and rectangle in the bottom right corner of the screen. I am currently trying to use a prior program in which the program starts and stops a...

Java encountering unknown errors in Eclipse- won't draw objects

java,eclipse,swing,jpanel,drawing
I've been trying to modify an old Java program of mine into a digital logic simulator, but after a certain point it stopped drawing the objects I initialized. It'll draw the white background but that's it. Pardon some of the irregularities, I'm eventually going to make it do a lot...

How to draw text of multiple sizes aligned on line with TextRenderer? [duplicate]

c#,winforms,drawing,gdi,text-rendering
This question already has an answer here: How do I get the position of the text baseline in a Label and a NumericUpDown? 2 answers I have an array of classes that contains some text and a font. I want to draw all the text aligned on line independently...

wxPython Paint Damaged, Clipped area

python,wxpython,drawing,wx
I have the following simple code (click the pink box and you can move it around with your mouse while holding down the left mouse button). import wx class AppPanel(wx.Panel): def __init__(self, parent, id): wx.Panel.__init__(self, parent, id) p = MovablePanel(self, -1) self.i = 0 self.Bind(wx.EVT_PAINT, self.OnPaint, self) def OnPaint(self, event):...