Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Do Mär 28, 2024 23:24

Foren-Übersicht » Sonstiges » Projekte
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 1 Beitrag ] 
Autor Nachricht
 Betreff des Beitrags: glVectorGraphics
BeitragVerfasst: Sa Aug 29, 2009 15:55 
Offline
DGL Member
Benutzeravatar

Registriert: Di Jul 01, 2003 18:59
Beiträge: 887
Wohnort: (The Netherlands)
Programmiersprache: fpc/delphi/java/c#
The NEW glVectorGraphics unit allows to draw 2D vector graphics with OpenGL.

Features:
- Allows drawing shapes defined by an path. This path needs to be constructed as an SVG path.
- Basic shapes:
* rectangle (allows rounded corners)
* elipse / circle
* line
- Each shape can be applied with a 'style' determining how it is drawn. (e.g. linewidth, linecolor, fill, fillrotation, etc)
- Fill Types:
* none
* solid (rgba color)
* linear (uses 0..n points with x pos and rgba color) (can be rotated also)
* circular (uses 0..n points with x pos and rgba color)
* bitmap (needs glbitmap unit) (can be rotated also)
* pattern (uses tiled 2D vector shapes as fill, can be a real slowdown)
- 2D Vector Fonts. Uses font outlines stored as svg paths. A tool converter is also in the project.
- Grouping (allows for making up a shape consisting of multiple paths / fills)
- native object-pascal unit so no need for third party dll or units (except glbitmap and dglopengl ofcourse)
- I tested it on delphi2009 only, but it should work on other delphi versions too and maybe compile with fpc too.
- Released under the MPL license.

Also i made a start for User Interface classes. So far only the button is working.

The test/example program currently shows the image below.

Currently it is only availble from my svn at: http://thuis.vanderhoning.net/svn_glvg/ ... ion-0.5.1a

Example usage:
Code:
  1.  
  2.   polyrect := TglvgRect.Create; //create an rectangle
  3.   polyrect.X:= 1.0; //position
  4.   polyrect.Y:= 1.0;
  5.   polyrect.Width:=100.0; //size
  6.   polyrect.Height:=200.0;
  7.   polyrect.Rx:=20.0; //rounded corner size
  8.   polyrect.Ry:=20.0;
  9.   polyrect.Style.Color.SetColor(1,0,0,1); //set solid color with individual rgba values
  10.   polyrect.Style.Color.a:=0.8; //it is also possible to set only the alpha value (transparency)
  11.   polyrect.Style.GradColorAngle:=90; //rotate the gradient color fill
  12.   polyrect.Style.NumGradColors := 2; //set the number of colors in the gradient color fill
  13.   polyrect.Style.GradColor[0].a :=1.0; //change the alpha for the first gradient color point (it takes over values from the solid color, so i change it here)
  14.   polyrect.Style.GradColor[0].SetColor('#FF0000'); //you can use web hex color codes
  15.   polyrect.Style.GradColor[1].SetColor('#00FF00');
  16.   polyrect.Style.FillType := glvgLinearGradient; //set the fill type to gradient
  17.   polyrect.Style.LineType := glvgSolid; //make the line style solid (basic line color is white)
  18.   polyrect.Polygon.Id:=7; //give it an id (need to automate that) , needed for stencil buffer filling
  19.   polyrect.Init; //init the rectange (makes an svg path from it)
  20.   polyrect.Polygon.Tesselate; //optianaly tesselate the object (does get auto called on first time rendering)
  21.  


Now rendering is easy:
Code:
  1.  
  2.   //rotate rounded rectangle
  3.   glrotatef(angle,0,0,1); //standard opengl rotate command
  4.   polyrect.Render; //draw the shape specified earlier.
  5.  


As i have not yet written a canvas class yet the alpha transparency has to be manualy set.
Code:
  1.  
  2.   // Set Alpha Blending with opengl commands
  3.   glEnable (GL_BLEND);
  4.   glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  5.  


Let me know what you think about it in the feedback thread: viewtopic.php?t=8646


Dateianhänge:
glvggrad2.jpg
glvggrad2.jpg [ 52.82 KiB | 12117-mal betrachtet ]

_________________
http://3das.noeska.com - create adventure games without programming
Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 1 Beitrag ] 
Foren-Übersicht » Sonstiges » Projekte


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 25 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.124s | 21 Queries | GZIP : On ]