Click here to Skip to main content
15,891,013 members
Everything / Drawing

Drawing

drawing

Great Reads

by honey the codewitch
Explore techniques for drawing using GFX
by honey the codewitch
Use an ILI9341 display efficiently from an ESP32 without the Arduino framework. Load JPEGs.
by Garvit Arya
It is a JavaScript based application for drawing basic free-hand shapes, logos and drawings.
by Swagat Parida
Steps to create a simple drawing app using HTML5 Canvas

Latest Articles

by Minh Danh Nguyen (ToughDev)
This is a cheap 320×240 2.8″ TFT LCD module that uses the ILI9320 controller for the display and the XPT2046.
by honey the codewitch
Use GFX effectively with e-paper/e-ink displays
by honey the codewitch
Explore techniques for drawing using GFX
by honey the codewitch
Explore the inner workings of a highly capable IoT display driver for the ESP32

All Articles

Sort by Updated

Drawing 

12 Sep 2023 by NoviceCoder871987
I ran into a weird issue with custom drawing the listview control. I drew the grid lines in response to CDDS_POSTPAINT notification. All working okay so far. However, when scrolling vertically, the lines will be messed up and will not be drawn at...
9 Sep 2023 by Richard MacCutchan
See About Custom Draw - Win32 apps | Microsoft Learn[^] for custom drawing in Report mode.
7 May 2023 by Minh Danh Nguyen (ToughDev)
This is a cheap 320×240 2.8″ TFT LCD module that uses the ILI9320 controller for the display and the XPT2046.
1 Feb 2023 by OriginalGriff
You can draw a line: I know that because your other questions indicate it. You can draw a hexagon: you have said so. So ... draw a line. Use one of the end points as the center of the hexagon and offset the other six points you need from that:...
31 Jan 2023 by moshaveran
I want to draw a line that has a hexagon at the end. with mouse move event. I can draw a circle or a square, but not a hexagon! What I have tried: I want draw a line that have a hexagon at the end
13 Dec 2022 by pitwi
Hi! A view weeks ago I changed to Java and so far everything's fine - except drawing (with Swing). The code below works - except the part that draws a graphics. What's wrong? package Test2GUI; import java.time.format.*; import...
7 Dec 2022 by pitwi
Hi! A view weeks ago I changed from Visual Studio C# to Java and now I've tried my first project with Swing and WindowBuilder. So far so good and everything works fine - except drawing that line. There's no error message but also no line. Neither...
7 Dec 2022 by Richard MacCutchan
See Line2D Java Example - Computer Notes[^]
7 Feb 2022 by Member 12617947
I have a rich text box that get scroll position with the code below Private Declare Auto Function RtfScroll _ Lib "user32.dll" Alias "SendMessage" ( _ ByVal hWnd As IntPtr, _ ByVal Msg As Integer,...
7 Feb 2022 by CHill60
There are some articles here on CP that can guide you into building your own Custom Control WinForms Custom Container Control[^] Writing Your Custom Control: Step by Step[^] There is also this article...
18 Jun 2021 by honey the codewitch
Use GFX effectively with e-paper/e-ink displays
3 Jun 2021 by honey the codewitch
Explore techniques for drawing using GFX
6 May 2021 by honey the codewitch
Explore the inner workings of a highly capable IoT display driver for the ESP32
4 May 2021 by honey the codewitch
Use an ILI9341 display efficiently from an ESP32 without the Arduino framework. Load JPEGs.
25 Apr 2021 by honey the codewitch
Explore the basic drawing functionality provided by the GFX IoT library
20 Apr 2021 by JR212
Hi, How Can I see if 2 or more circels intersect or touching each other? What I have tried: When using rectangle and the upper left corner touch the lower right corner the circles aren't really touching. but intersect return true
20 Apr 2021 by OriginalGriff
Don't even check the rectangle: get the value of the distance between circle centres and compare that to the sum of the diameters. If it's less then they overlap, if it's equal then they touch, if it's greater they are separate. And it's easy to...
20 Apr 2021 by Patrice T
Not really a programming question, more like geometry. Quote: How Can I see if 2 or more circels intersect or touching each other? Each circle is inside a rectangle, if both rectangle don't touch, circles don't touch. if rectangles touch, you...
19 Oct 2020 by Member 14846576
I'm making a strategy game in C# (nothing too wild, no animations or action). I managed to draw a section of the map and allow the user to scroll it, using DrawImage and specify a region of the map image to draw: RectangleF srcRect = new...
19 Oct 2020 by OriginalGriff
You can try setting the form DoubleBuffered property to true: Control.DoubleBuffered Property (System.Windows.Forms) | Microsoft Docs[^] and see if that improves it, but the best solution is not to use a PictureBox at all. Instead, put a Panel on...
19 Sep 2020 by Patrice T
your code is very simple minded, and it is bad. Quote: i use Timer which redraws the digits every 100 milliseconds. A simple test can divide by 10 the workload of redraw: if (LastTime != NewTime) { redrawClock(); LastTime = NewTime; } ...
19 Sep 2020 by Avtem
So i'm trying to create a digit clock using only WinAPI with C++ (see the screenshot)[^] Function drawDash() is called 7 times to draw one digit. i use Timer which redraws the digits every 100 milliseconds. Everything looks fine, but for...
19 Sep 2020 by Rick York
Since you are using C++, I recommend writing a class to handle this for you. Here's one possibility : template class handleobj { public: handleobj( T h ) { m_handle = h; } virtual ~handleobj() { if(...
19 Sep 2020 by KarstenK
Your problem is here:FillRgn(hdc, hrgnClip, CreateSolidBrush(color)); in creating a brush and NOT deleting it. Asign it to a var use it and than delete it later, or if the color is constant you need to create it only once. Your error case is...
19 Sep 2020 by Richard MacCutchan
The only thing I can see that may be an issue is the following: FillRgn(hdc, hrgnClip, CreateSolidBrush(color)); DeleteObject(SelectObject(hdc, GetStockObject(WHITE_BRUSH))); Are you certain that DeleteObject is actually deleting the solid brush?
8 Sep 2020 by Mineodo68
UPDATE : Quote: The WinForms implementation of Form only permits a solid colour to be used as the transparency key. It's not possible to have varying levels of transparency. Hello, I'm actually working with Windows Forms and GDI+. I've got my...
8 Sep 2020 by Gerry Schmitz
.net - C# Create Gradient Image - Stack Overflow[^] This is a mod of the above (changed one of gradient colors and the file type). The point is you can save a transparent gradient; you just have to think more about how you apply your other...
22 Oct 2019 by Member 14630688
I have a text file with cordinates of spline. I want a code to convert those cordinates into dxf file. What I have tried: I have less knowledge about points to dxf
22 Oct 2019 by MadMyche
I hve no need for a spline to DXF convertor so I am not going to go out and write one. However I did minimal research (wikipedia) and found that they can be simple text files, and they have a published reference guide to the structure (see references below). What I would probably do first is to...
21 Oct 2019 by KarstenK
Than you need to acquire the knowledge. I used my search engine to find the dxf format in the wikipedia. Read it to understand the format and follow some links. When you understand it, you may write some converter code. It is simple text readable format, so simple things shouldnt be too hard. ...
18 Sep 2019 by Member 14596963
Draw two circles with the mouse on picturebox. When lowering the mouse, the center of the circle is set, and when released, its radius set. The coordinates of the center of the circles and their radii are displayed on the form (in Cartesian CS). Determine the mutual arrangement of circles...
18 Sep 2019 by OriginalGriff
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you. So we need you to do the...
30 Aug 2019 by Member 13482508
I made this function to sort the rectangle so that it will draw. private Rectangle SortedRect(Point P, Size S) { if (S.Width
30 Aug 2019 by kursatdemir58
Hello, I ve been googling for hours. Please help me! Im having trouble with real time rectangle drawing, Let's say 1st second I want to draw y1 to positive heigth, in 2nd second y1 to negative heigth. But DrawRectangle doesn't except negative values and doesn't draw. I show in drtail in picture...
23 May 2019 by Member 14430889
Dear All: i am new, i just start to learn draw shape with vs2012 c++ and Gdiplus about 5 weeks, i create a simple project to test, but when i draw polygon finish, i cannot delete any polygon which i selected from canvas, it not so easy like to delete a rectangle or a ellipse, only delete the...
23 May 2019 by Richard MacCutchan
You should do all your painting/drawing to the screen in the function that handles the WM_PAINT message. Each time this function is called it should redraw all the shapes. When a shape is deleted you just remove it from the list of items to draw, and then call InvalidateRect to force a repaint...
30 Aug 2018 by Samira Radwan
I have created a method to switch between 2 colors every X time. I called this method on the class constructor (the class extends View) The method: private void setCircleAnimation(){ final int color1 = Color.parseColor("#3399ff"); final int color2 = Color.parseColor("#84c1ff"); ...
30 Aug 2018 by Samira Radwan
Hi all, I have java class extends view. I draw a simple circle on canvas. The requirements is to make this circle blink or flash. I have tried many things and searched alot with no luck. It's pretty easy to make textView or image blink by adding animation, but the circle I have to draw then make...
30 Aug 2018 by Gerry Schmitz
Blinking or "strobing" can cause epileptic fits in certain individuals and is therefore not recommended. It's grouped in with "web sites that suck". ("Rotating" is better IMO).
3 Aug 2018 by Member 12533122
Hello people. I am drawing rect in my application on button click. but i want draw it on start of application. as i am drawing on OninitDialog function it will not drawing anything on it. so how can i draw it on starting application? What I have tried: void XYZ::OnBnClickedOk() { CRect rc;...
3 Aug 2018 by KarstenK
Another solution is to use PostMessage for a WM_PAINT message which triggers the painting of your control. Best is to use InvalidateRect for the control before. Tip: Create the pens only once, as class members or as static objects to improve performance.
3 Aug 2018 by Richard MacCutchan
If you draw objects outside of the function that responds to the WM_PAINT message, then it will not work. As soon as the dialog is shown it will erase the background and redraw all controls in the resource. You should add the rectangle into your resource settings.
1 Aug 2018 by Member 12533122
Hello people, i am doing drawings on dialof in MFC vc++. i am drawing lines as per the different inputs i am getting from the serial. now i want to clear the drawings when i get another input. What I have tried: CClientDC dc(GetDlgItem(IDC_STATICDISPLAY)); CPen lDot(PS_DASH, 2, RGB(255,...
1 Aug 2018 by KarstenK
If the control is completly owner drawn that you should use FillRect with your bckground color at first draw call. And I would suggest that you store the Windows-handle of the control and other constant objects (like the pen) as member variables to improve performance.
1 Aug 2018 by Rick York
GetDlgItem(IDC_STATICDISPLAY)-...
4 May 2018 by Wendelius
There's a very nice conversation at c# - Fastest API for rendering text in Windows Forms? - Stack Overflow[^]
4 May 2018 by creizlein
I have a custom control that used a lot of Label controls inside, and i started experiencing performance issues when drawing/redrawing the screen So i decided to remove them as they look overwhelming and just draw the texts I needed I started using Graphics.DrawString method, which was SUPER...
11 Dec 2017 by Member 12137971
How do I draw an arc that goes from 0 degrees to 180, and his perimiter is 20mm? The picture with an explanation[^] What I have tried: Graphics g = Graphics.FromImage(bmp); g.PageUnit = GraphicsUnit.Millimeter; Rectangle r = new Rectangle(0, 0, (int)(Math.Round((40 / 25.4) / (float)Math.PI *...
11 Dec 2017 by alywaly
I would use the graphics DrawArc method and call this from overridden OnPaint(PaintEventArgs e) private void MyDrawArc(PaintEventArgs e) { // Create pen.d Pen pen = new Pen(Color.Black, 22); // coordinates int x = 100; int y =...
20 Oct 2017 by NoviceCoder871987
I have a weird issue with Dialog box on Windows XP it doesn't draw correctly, The listview doesn't redraw unless i do some thing that forces repaints like clicking on the size boarders then the listview show. But if i move the application somewhere on screen it goes hidden again. This picture...
20 Oct 2017 by NoviceCoder871987
Issue is fixed by using SetParent on listview and the parent set is the main dialog and when switching between tabs using SetParent to return the parent of listview to the sub dialog so the code still hide it with ShowWindow. Now the Listview always show on top. No flickering. Very good.
3 Sep 2017 by BillWoodruff
using System.Drawing; using System.Windows.Forms; namespace PathStuff { public static class PathExtensions { public static void MakeHole(this Control cntrl, Rectangle xrect) { var region = new Region(cntrl.ClientRectangle); region.Exclude(xrect);...
1 Sep 2017 by newbie1992
hello morning everyone anyone know how to crop (make a rectangular hole in) a control? i try to crop a square in the middle of the panel for an example if the size of my panel was Panel myPanel = new Panel() { Size = new Size(300, 800), Location = new Point(0,0); BackColor =...
31 Aug 2017 by Graeme_Grant
[moved from comments - thanks for the suggestion RickZeeland] Is the hole suppose to show objects behind it? Like a transparent hole? Something like this: Making Transparent Controls - No Flickering[^][^]???
31 Aug 2017 by RickZeeland
In addition to the nice article mentioned by Graeme (which deserves points really) Making Transparent Controls - No Flickering[^] , the following: If you want to "punch a hole", this article might be of interest: Phil Wright : Component Factory: .NET2, Transparent controls[^] Also using...
19 May 2017 by Meriç Kıranoğlu
I have a windows application. [^] When I click on Calculate, I make some calculations using those textboxes. with those calculations, I obtain some values and write them on a datagridview [^] At this point, I need to draw some lines using those values which are basically coordinates of my...
19 May 2017 by Meriç Kıranoğlu
Ok, somehow I managed to draw the lines. I'm leaving my solution here in case of anyone else needs it :) Pen myPen = new Pen(Color.Black); private void pictureBoxDraw_Paint(object sender, PaintEventArgs e) { myPen.Width = 2; if (binary > 0) ...
19 May 2017 by OriginalGriff
Look at the error message - it's not complaining about the draw, but about the format of the data you are trying to convert to a number. That's what a FormatException is there for! Most likely, the value in that specific cell is not what you think it is: it's not an integer! So extract the...
4 May 2017 by Toni_s
Hi all. I have a question about how to play animation without to use too much memory. I want to load in every Timer Tick only one frame directly from the disk, without to load all frames into memory in a variable. I have make one function for this, but if i called it slows down in every frame a...
12 Apr 2017 by Member 13113452
Okay so in the "What have you tried?" is the code I currently have. I was wondering if anyone could help me make it so a text box appears and when you paste a processing.js code it outputs a drawing. If that makes sense. Basically, fill(255, 255, 0); ellipse(200, 200, 200,...
12 Apr 2017 by Nick_3141592654
Your question isn't very clear. It seems that you want to create a web page containing a text box and a Canvas. You want a user to be able to type some text that happens to be javascript code into the text box, and for that JS code to execute. It also happens to be the case that the JS of...
14 Dec 2016 by Sruthi Suresh
AM drawing multiple rectangles in my windows form and is saved to a rectangle list at run time.how do i move these rectangles with mouse and then save it to the rectangle list at run time so that the user can place these rectangles as they wishWhat I have tried:i tried to locate the...
14 Dec 2016 by Ralf Meier
to complete the Solution from CPallini a Little bit :If you do a MouseDown on your Form you have to look it the actual MousePosition is at a coordinate-range of one of your rectangles.If Yes you should memorize the actual MousePosition relative to the Rectangle-Postion.If you now move...
14 Dec 2016 by CPallini
"It didn't worked" is not pretty informative. Please elaborate.Anyway, I suppose you are missing a conversion from Screen to Client coordinates (or the opposite). Have a loook at Mouse Events in Windows Forms[^] and at Control.PointToClient Method (Point) (System.Windows.Forms)[^] (for sample...
12 Dec 2016 by Patrice T
As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.When you just ask for the solution, it is like trying to learn to drive...
12 Dec 2016 by Member 12898887
Hi, I'd like to print a given binary tree horizontally in C WITH LINKS between nodes.I've done it without links , when i tried to do it with links it really got messed up... So if anyone can give me the solution that will be very helpful.Thanx...PS: More explanations in the images...
8 Dec 2016 by PZero1992
Hello,I am trying to make the background of a combobox hatched. I just want to have the Textbox part of the box hatched, not the button or the dropdown list.I have written the following code, and it works quite well, despite the fact, that it is hatched only for like 100ms and then the...
8 Dec 2016 by Richard MacCutchan
You are using the wrong paint method, see Control.OnPaintBackground Method (PaintEventArgs) (System.Windows.Forms)[^].
7 Dec 2016 by Dave Kreskowiak
It would seem kind of obvious to just check to make sure the height is greater than 0 before drawing the rectangle.
3 Dec 2016 by Alper_Baysal
I am using the SimplePerfChart in my program. I am reading data from PLC and draw a line in a chart according to my data. But now i have to draw to seperate line on a single chart area (for example minimum and maximum values ) but i can't do it.Sorry for my english. It isn't my native...
3 Dec 2016 by Alper_Baysal
You are right i am talking about that project. I did that at the same time i posted this question.
2 Dec 2016 by Richard MacCutchan
Assuming you are talking about Simple Performance Chart[^] then you need to post your question in the forum at the end of the article.
15 Oct 2016 by BurkusCat
Hi there,I am using the Google Location Services API on Android to periodically save a latitude/longitude they were at. I am trying to create a polygon around these points to create a route of where they have been. I want the route to take into the location accuracy for each of the points, so...
20 Jun 2016 by The Zakies
we will build an outline line around the drawn lines so we would test the mouse click on this outline to know which line is selected. and we would in the coming update build a select function inside the move tool
7 Jun 2016 by The Zakies
[tut4] how to draw lines & to draw different types on end shapes like rectangle and circle using C#
10 May 2016 by farhad baghyari
Hi i am a mechanical engineering student.(so i don't know too much about programming)I wanna make a program that draws curves with rational Bezier (I should write the code myself and not using formGraphics.DrawBezier). I've recently started learning c# and i am so new to it. I've searched alot...
10 May 2016 by OriginalGriff
That's pretty simple to start with: the mouse capture stuff is trivial.Add a Panel to a form - call it "myDrawing" - and handle two events for the Panel: Paint, and MouseClick.Add a list to your form class:private List points = new List();Now, in the MouseClick handler, add...
18 Apr 2016 by Ryan Scott White
Draw rectangles in a C# console window with this drop-in class
28 Mar 2016 by quguimin
as the title says, the program runs on the win32 platform;like the powerpoint file demonstration,the teacher could use mouse drawing,if the (graphics)lines are useless,they could be selected and deleted;anyone could help me analyse the tech-point or API using? thank you !What I have...
28 Mar 2016 by Serkan Onat
You can take Diagram Editor[^] as an example and extend its functionality based on the provided base classesOr DrawCLI sample (in Visual Studio Samples Pack) can be another example as a startup projectBut these two projects are based on MFC ,if use of MFC is a problem then you can easily...
27 Mar 2016 by Richard MacCutchan
You can use Windows GDI[^] to draw lines, curves etc. See Win32 Programming - FunctionX[^] for some useful tutorials.
6 Mar 2016 by Jakub Szymanowski
The article presents idea and implementation of Fourier Transform (DFT and FFT algorithms) in Digital Signal Processing.
3 Mar 2016 by The Zakies
Tutorial 2 (how to interactively add multiple shapes GDI using linked lists)
18 Jan 2016 by Sergey Alexandrovich Kryukov
cmbay asked:…So the question is, is it possible to bind the Background of my control to its' container's background without explicitly identifying the container.It can be done by binding using RelativeSource. Please see:RelativeSource Class (System.Windows.Data)[^],C# Corner:...
17 Jan 2016 by cmbay
I am creating a WPF Custom Control Template and I would like one of the GeometryDrawing Brushs to use the Background Brush of the control's container. For example if I put this control on a Window I would like this particular Brush to use the Window's Background Brush. Like wise if the control...
19 Dec 2015 by Swagat Parida
Steps to create a simple drawing app using HTML5 Canvas
11 Dec 2015 by CHill60
Have a look at this CP article Professional C# - Graphics with GDI+[^]There is also a reference zone[^] here on CPOr there always the M$ documentation[^]
11 Dec 2015 by Umut Comlekcioglu
Hello everyone,I'm developing Puzzle Game for my little brother. I wanna drawing Puzzle Piece like below. http://postimg.org/image/q5j410d3p/[^]I can't use Bitmap or Picturebox. So I need to draw it with Graphics Path but I don't know too much about Graphics Path.Anyone can help...
28 Oct 2015 by Ziya1995
1. OnRender doesn't render in the code 1 because the visual MyImage is not added into a visual tree. But it renders when you add it into the visual tree of Canvas.Source:WPF: InvalidateVisual doesn't draw by OnRender.[^]2. Even if it renders on the surface of Canvas, it will not render...
28 Oct 2015 by Ziya1995
OnRender doesn't get called until a visual gets added into a visual tree.If the goal is to get the image without adding the visual to the visual tree, you can use VisualCollection/DrawingVisual.Code: public partial class MainWindow : Window { public MainWindow() ...
26 Oct 2015 by Ziya1995
Goal:1. Create Canvas.2. Create MyImage : Image.3. Draw MyImage by OnRender.4. Set MyImage source to ImageBrush source.5. Set ImageBrush to Canvas.Background.Problem: The canvas gets drawn empty instead of what OnRender should draw.Question: How to make it draw what is set to...
26 Oct 2015 by Ziya1995
Goal: To use OnRender to draw into ImageBrush by RenderTargetBitmap.Problem: It doesn't draw.Question: How to do it using OnRender without adding Control as child to Canvas.Children?Notes:1. It works, if to add Control as child to Canvas.Children. You can do by turning the comment...
10 Oct 2015 by webmaster442
Windows Forms does not support svg or eps by default. You can use wmf or emf formats. They are both vector graphics. Just convert your image, set up image as resouce and assign it to a picturebox.
9 Oct 2015 by Umesh AP
Hi All, What is the Best way to display and print company logo on windows form. Container may be PictureBox, Panel or anything else. I am trying to use vector format images (.svg, .eps etc) for better clarity.
6 Oct 2015 by Member 4385570
https://msdn.microsoft.com/en-us/library/k0fsyd4e(v=vs.110).aspx
5 Oct 2015 by Umesh AP
Hi All, I have Panel on windows form containing labels for displaying information and 2 PictureBox controls. One for Company logo & other for captured photo) When i print them either on Printer or just save in PDF format, both images looking very blur. I want to improve quality of images. So...
10 Sep 2015 by LiQuick
How do I scale a WPF GeometryDrawing where the GeometryDrawing path points are effectively changed? What I want to do is that I have a DrawingGroup of GeometryDrawings and I want to resize one of these GeometryDrawings. I know I can put this Geometrydrawing in a separate DrawingGroup and use...
9 Sep 2015 by Patrick70__
The set of points can be quite large and it indicates the coordinates (kind of a photoshop ruler). It doesn't have to be too time-consuming and can be updated in case of zoom/pan. Furthermore I might have to add the number of the coordinate in same points.ThanxPatrick
31 Aug 2015 by DanBecause
I can't say I entirely understand what you mean by "really change the pathpoints", but the Transform property on the Geometry will scale the Geometry before it is rendered and the Geometry will be rendered as though it were the scaled size (not a zoomed version of the original size). So, for...