Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

qow 12: how to draw an egg on a canvas?

Posted on 2002-04-01
11
Medium Priority
?
865 Views
Last Modified: 2010-05-18
hi experts,

i am starting a new quest: qow = question of the week :-)
each week i will introduce a new simple? question.

now qow 12
(one week later, i was absend)

the first working solution will get the points (a graded).

sorry, top 15 experts, you are not allowed to solve this
q, only other can solve this question :-(

well the question is:
how to draw an egg on a canvas??

a little sample is needed

let see

meikl ;-)
0
Comment
Question by:kretzschmar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +4
11 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 6909982
hehe very seasonal meikl :)
 
er poached egg on toast :

var
r : trect;
begin
r.Left := 5;
r.top := 5;
r.Right := 110;
r.Bottom := 105;
form1.canvas.FrameRect(r);
form1.canvas.Ellipse(10,10,100,100);
form1.Canvas.Brush.Color := clYellow;
form1.canvas.Ellipse(30,30,80,80);
end;
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6910240
Whay not red ? :o)
0
 
LVL 17

Expert Comment

by:inthe
ID: 6910350
er what do you feed your chickens? <G>
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:DrDelphi
ID: 6910353
with form1.canvas do
 begin
  Brush.Color := clYellow;
  Brush.Style := bsDiagCross;
  Ellipse(0,0,210,350);
  MoveTo(13,90);
  Lineto(210,210);
  MoveTo(6,120);
  Lineto(206,240);
  Brush.Color := clBlue;
  Brush.Style := bsSolid;
  FloodFill(14,94,ClBlack,fsBorder);
  Brush.Style := bsClear;
  Font.Size:=12;
  TextOut(220,0,'HAPPY EASTER!!');
 end;


Good luck!!
0
 
LVL 3

Expert Comment

by:tongalite
ID: 6910823
Hi,

he he he.... this is as simple as it gets

it's fun!
t.
procedure TForm1.EggButtonClick(Sender: TObject);

var
   x,y:integer;

begin
     x:=10; //Pos
     y:=10; //Pos
     image1. canvas.brush.color:=random(256*256*256);//color random
     image1.canvas.ellipse(x,y,x+(200), y+(120)); //ellipse size
      //Image1 = Transparent:=False
    end;
end.
0
 
LVL 6

Expert Comment

by:zebada
ID: 6911897
// _________________________________________________________________________
procedure TForm1.eggTop(l,t,r,b: integer);
var
  half: integer;
begin
  half := t+(b-t) div 2;
  form1.Canvas.Arc(l,t,r,b,l,half,r,half);
end;

// _________________________________________________________________________
procedure TForm1.eggBottom(l,t,r,b: integer);
var
  half: integer;
begin
  half := t+(b-t) div 2;
  form1.Canvas.Arc(l,t,r,b,r,half,l,half);
end;

// _________________________________________________________________________
procedure TForm1.egg(l,t,r,b: integer; egginess: integer);
var
  stretch: integer;
begin
  stretch := (egginess*(b-t)) div 100;
  EggTop(l,t+stretch,r,b);
  EggBottom(l,t,r,b+stretch);
  form1.Canvas.Brush.Color := clBlue;
  form1.Canvas.FloodFill((r-l) div 2,(b-t) div 2,form1.Canvas.Pen.Color,fsBorder);
end;

// _________________________________________________________________________
procedure TForm1.Button1Click(Sender: TObject);
begin
  // Left, top, width, height, egginess
  egg(50,50,300,400,20);
end;

0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6911992
//hehe very seasonal meikl :)

inthe, how I know the traditional Eastern Egg is red :P
0
 
LVL 1

Accepted Solution

by:
MBo earned 100 total points
ID: 6912213
procedure TForm1.Button2Click(Sender: TObject);
var
rgn:hRgn;
pts:array[0..6] of TPoint;
x1,y,x2,deltax,deltay:integer;
begin
x1:=100; x2:=400; y:=200; deltax:=5; deltay:=100;
Canvas.brush.Color:=clRed;
//Canvas.Pen.Color:=clRed; //for canvas.floodfill
pts[0].x:=x1;            pts[0].y:=y;
pts[1].x:=x1+deltax;     pts[1].y:=y-deltay;
pts[2].x:=x2-deltax;     pts[2].y:=y-2*deltay;
pts[3].x:=x2;            pts[3].y:=y;
pts[4].x:=x2-deltax;     pts[4].y:=y+2*deltay;
pts[5].x:=x1+deltax;     pts[5].y:=y+deltay;
pts[6].x:=x1;            pts[6].y:=y;

//simple and slow
//Canvas.PolyBezier(pts);
//Canvas.FloodFill(x1+100,y,clRed,fsBorder);

//faster
BeginPath(canvas.Handle);
PolyBezier(canvas.Handle,pts,7);
EndPath(canvas.Handle);
rgn:=PathToRegion(Canvas.Handle);
FillRgn(Canvas.handle,Rgn,Canvas.Brush.Handle);
DeleteObject(rgn);

end;
0
 
LVL 27

Author Comment

by:kretzschmar
ID: 6912425
perfect :-))

as all know an egg isn't a ellipse or an egg on toast,
even there are some happy pictures, spcially from drdelphi :-))

well next week a new ?simple q?

thanks to all for participating on this quest

meikl ;-)
0
 
LVL 27

Author Comment

by:kretzschmar
ID: 6912432
for zabada,

i post an additional q for you,
for your also correct egg

meikl ;-)
0
 
LVL 27

Author Comment

by:kretzschmar
ID: 6915263
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question