TriGradient

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

TriGradient

Post by AUGE_OHR »

hi,

under c:\MiniGUI\SAMPLES\Advanced\FillTriangle\FillTriangle.prg i found TriGradient.
but it is "without Parameter" and fill hole Form
TriGradient.jpg
TriGradient.jpg (12.54 KiB) Viewed 2722 times
i need it for 3 Points

Code: Select all

GraGradient(::oPS, {X1,Y1}, {{X2,Y2}, {X3,Y3}}, aColors, GRA_GRADIENT_TRIANGLE)
XBDTL_TriGradient.JPG
XBDTL_TriGradient.JPG (119.85 KiB) Viewed 2722 times
so how to modify "C" Code of c:\MiniGUI\SAMPLES\Advanced\FillTriangle\FillTriangle.prg :idea:
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: TriGradient

Post by AUGE_OHR »

hi,

i got "Delaunay Triangulation" working under HMG. :D

Point with different Color ( Value )
XBDTL_001.jpg
XBDTL_001.jpg (77.7 KiB) Viewed 2688 times
calculate "Delaunay Triangulation"
XBDTL_002.jpg
XBDTL_002.jpg (162.43 KiB) Viewed 2688 times
draw Gradient Color given by Point Color
XBDTL_003.jpg
XBDTL_003.jpg (86.73 KiB) Viewed 2688 times
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: TriGradient

Post by AUGE_OHR »

hi,

i search for Set of Colors exclude WHITE & BLACK

i have now 12 "strong" Colors

Code: Select all

FUNCTION GET_RGB_COLOR()
LOCAL aRet := {}

   AADD(aRet,{255,000,000})     // Red
   AADD(aRet,{255,128,000})     // Red-Yellow
   AADD(aRet,{255,255,000})     // Yello
   AADD(aRet,{128,255,000})     // Yello-Green
   AADD(aRet,{000,255,000})     // Green
   AADD(aRet,{000,255,128})     // Green-Cyan
   AADD(aRet,{000,255,255})     // Cyan
   AADD(aRet,{000,128,255})     // Cyan-Blue
   AADD(aRet,{000,000,255})     // Blue
   AADD(aRet,{128,000,255})     // Blue-Pink
   AADD(aRet,{255,000,255})     // Pink
   AADD(aRet,{255,000,128})     // Pink-Red

RETURN aRet
but that is not enough to make it "nice" so i try

Code: Select all

   aColor := NumColor2RGB( hb_RandomInt( 255*255*255 ) )
XBDTL_16M_Colors.JPG
XBDTL_16M_Colors.JPG (131.87 KiB) Viewed 2637 times
this are "too much" Colors ... :roll:

i like "strong" Color while some 16M Color have "light" Touch ... to much "white" :?:
so how to get more "strong" Colors :idea:
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: TriGradient

Post by AUGE_OHR »

hi,

here is "C"-Source for TriGradient
DLT_HB_FUNC.ZIP
(2.62 KiB) Downloaded 142 times
MiniGUI Extended Version use 4 Points ( Rect ).
for HMG i add 3 x Array {x,y,R,G,B} and 4th are {0,0,0,0,0}

Code: Select all

   hDC := BeginPaint(nHwnd, @pps )
   FillGradientEx( hDC ,{1024,0,250,0,0},{1024,768,0,250,0},{0,768,0,0,250})
   EndPaint(nHwnd, pps )
for Triangle Gradient i need 3 Points

Code: Select all

METHOD DrawTriangleGradient(cForm, aPos, aPos2, aPos3, aColors1, aColors2, aColors3) CLASS DemoForm
LOCAL lRet
LOCAL nHwnd, nHDC 

   nHwnd := GetformHandle( cForm )
   IF EMPTY(nHwnd)
     RETURN .F.
   ENDIF
   nHDC := GetDC( nHwnd )
   lRet := GRAGRADIENTEX( nHDC ,{aPos [1],aPos [2],aColors1[1],aColors1[2],aColors1[3]} ,;
                                         {aPos2[1],aPos2[2],aColors2[1],aColors2[2],aColors2[3]} ,;
                                         {aPos3[1],aPos3[2],aColors3[1],aColors3[2],aColors3[3]} )
   ReleaseDC( nHwnd, nHDC )

RETURN lRet
have fun
Jimmy
User avatar
Steed
Posts: 433
Joined: Sat Dec 12, 2009 3:40 pm

Re: TriGradient

Post by Steed »

beatifull
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: TriGradient

Post by AUGE_OHR »

hi,

this was made with Code from my Xbase++ App.
for 1000 Points it have to make about 2.000.000 "Circle" to find nearest 2 Points for Triangle.

so the Question is how to "speed up" ... does someone have a CUDA*** Sample how to use with harbour / HMG :?:
*** calculate on Grafic Card from NVidea
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: TriGradient

Post by AUGE_OHR »

hi,

have test Source under 64 Bit and it is much faster than 32 Bit App :o
it use big Array and many Calculation ( Triangle )

for 1000 Point with about 2.000.000 Calculation it need 90 Sec. under 32 Bit App but only 45 Sec. when run 64 Bit App :D
see also this Thread http://www.hmgforum.com/viewtopic.php?f=5&t=6516

---

Source use CLASS Code but it is NOT the usual way how i "mix" HMG Syntax with CLASS Code
i simple was to lasy to re-write existing Xbase++ CLASS to Function.
HBDLT.ZIP
(15.32 KiB) Downloaded 140 times
have fun
Jimmy
Post Reply