Painfully elementary lazarus / 39-Graphics ---------------------------------------------------------------------- SillyOldDragon · 2012-11-20 18:16 I am having a problem with getting started in Graphics.  What I would love to see is this (as vanilla as possible). The screen is x pixels wide.  The screen is y pixels high. I want to put one red pixel at x=45 and y = 30 on a black background. Would someone be kind enough to answer with a full program that does just that.  (The calculations for what I really want to do I can handle in my sleep but it's the pieces that deal witht the screen that have lost me.) All of the Uses, Types, Vars and the picky forms of asssignment needed to do one pixel to a certain point have got me going in circles. I haven't programmed in Pascal in 25+ years and I am SO HAPPY to see it's still alive.  Thank you ---------------------------------------------------------------------- eny · 2012-11-20 18:51 Have a look at the painter class in here  http://wiki.lazarus.freepascal.org/Lazarus_Mazes_demo ---------------------------------------------------------------------- anis2505 · 2012-11-20 20:05 Hi, Here is 2 example to draw: 1) Drawing to the form directly 2) Drawing to a custom control using Bitmap http://www.4shared.com/zip/z-CRkzVM/lazGraphics.html Take a look to the Wiki everything is explained well on it http://wiki.lazarus.freepascal.org/Developing_with_Graphics Regards ---------------------------------------------------------------------- SillyOldDragon · 2013-01-10 02:53 Wharever the file was on 4share - it won't download.  Is there anything out there that (given a long time history with Turbo Pascal) will just not worry about portability or frills and just say "put red dot here"? I just need one VERY vanilla plain example.  "Program ..... to ..... end." . Windows XP  screen 1024x768  32 bit colors Thank you ---------------------------------------------------------------------- Blaazen · 2013-01-10 03:08 Ok, so start a new project and put TPaintBox on a form (it's on the Additional Palette) - it adds component PaintBox1. Replace all code with this: Code: [Select]unit Unit1;        {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls; type      { TForm1 }   TForm1 = class(TForm)     PaintBox1: TPaintBox;     procedure PaintBox1Paint(Sender: TObject);   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.PaintBox1Paint(Sender: TObject); begin   with PaintBox1.Canvas do     begin       Brush.Color:=clWhite;       FillRect(0, 0, Width, Height);       Pixels[10, 10]:=clRed;                  end; end; end. And go to object inspector, select tab Events and assign PaintBox1.OnPaint event to PaintBox1Paint method. Now hit F9 and it will run project. Hopefully, there should be a white rectangle with a red pixel at [10, 10]. ---------------------------------------------------------------------- User137 · 2013-01-10 08:45 My favorite so far was TImage. Things are drawn to image1.Picture.Bitmap.Canvas. Note that it is very different from image1.Canvas, which is doing nonpermament changes, like drawing on form or Picturebox, and sometimes this is bad. ---------------------------------------------------------------------- Leledumbo · 2013-01-10 11:43 I would go for Blaazen solution if what you need is to draw the "screen" frequently as TPaintBox is meant for that. TImage would be too slow as it's intended for static image. Well, doing it on an OpenGL canvas might be the fastest though but I guess you don't need that far.