Author Topic: GdiPlus Texture Rotating  (Read 2683 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
GdiPlus Texture Rotating
« on: February 22, 2016, 04:27:05 AM »
Hello,

Code: [Select]
include "gdip.inc"
window 640,480,1
setframes 60
hdc = GetBufferDC()

% Unitpixel          = 2
% WrapModeTile       = 0
% WrapModeTileFlipX  = 1
% WrapModeTileFlipy  = 2
% WrapModeTileFlipXY = 3
% WrapModeClamp      = 4
% FillModeAlternate  = 0
% MatrixOrderPrepend = 0
% MatrixOrderAppend  = 1

Extern Lib "gdiplus.dll"
! GdipRotateTextureTransform
! GdipResetTextureTransform
! GdipLoadImageFromFile
! GdipCreateTexture             
! GdipScaleTextureTransform       
! GdipTranslateTextureTransform   
! GdipFillRectangleI
! GdipDisposeImage
! GdipDeleteBrush
End Extern

single angle
sys image, texBrush
wchar pm = "png/pm.png"

GdipLoadImageFromFile pm, &image
GdipCreateTexture image, WrapModeTile, &texBrush

while Key(27)=0
cls 0, 0, 250

GdipScaleTextureTransform texBrush, 1.5, 2.0, MatrixOrderPrepend
GdipRotateTextureTransform texBrush, angle, MatrixOrderAppend 
GdipFillRectangleI hdc, texBrush, 0, 0, 640, 480
GdipResetTextureTransform texBrush

angle +=1
if angle >=360 then angle =-angle
sync()
wend
GdipDisposeImage image
GdipDeleteBrush  texBrush
winEnd

.

Peter

  • Guest
Re: GdiPlus Texture Rotating
« Reply #1 on: February 22, 2016, 12:26:58 PM »
DrawString: a bit text.
Code: [Select]
include "gdip.inc"
window 640,480,1
hdc = GetBufferDC()

%UnitPixel = 2
%UnitPoint = 3   

Type RectF
   single x
   single y
   single w
   single h
End Type

Extern Lib "gdiplus.dll"
! GdipCreateFontFamilyFromName
! GdipCreateSolidFill
! GdipDrawString
! GdipCreateFont
! GdipDeleteFont
! GdipDeleteBrush
! GdipDeleteFontFamily
End Extern

wstring font

Sub SetFontEx(wstring fontname)
    font = fontname
end sub   

Sub DrawString(single x, y, size, wstring txt)
    RECTF fRect = {x, y, ScrW, ScrH}
    sys pFont, pFontFamily, pBrush
    GdipCreateFontFamilyFromName font, NULL, &pFontFamily
    GdipCreateFont pFontFamily, size, FontStyleRegular, UnitPoint, &pFont
    GdipCreateSolidFill 0xFFFFFFFF, &pBrush
    GdipDrawString hdc, txt, Len(txt), pFont, fRect, NULL, pBrush
    GdipDeleteFont  pFont
    GdipDeleteBrush pBrush
    GdipDeleteFontFamily pFontFamily
End Sub

SetFontEx "david"
DrawString 100,100,24,"Hello GdiPlus World"
SetFontEx "georgia"
DrawString 100,124,24,"Hello GdiPlus World"
SetFontEx "gisha"
DrawString 100,158,24,"Hello GdiPlus World"
SetFontEx "impact"
DrawString 100,186,24,"Hello GdiPlus World"
setfontEx "wingdings"
DrawString 100,300,24,"OOOOOOOOOOOO"

for i=0 to 640 step 40
    DrawString i,0x0,40,"w"
    DrawString i,430,40,"w"

next

waitkey
winEnd

JRS

  • Guest
Re: GdiPlus Texture Rotating
« Reply #2 on: February 22, 2016, 06:41:53 PM »
Hi Peter,

Thanks for all the code posts, I review them often. We now have more room on the new server so attaching screen shots would enhance the work your presenting. More people will try something they see the final results. Count on people being lazy for the most part.

« Last Edit: February 22, 2016, 10:01:32 PM by John »

Peter

  • Guest
Re: GdiPlus Texture Rotating
« Reply #3 on: February 24, 2016, 10:30:44 AM »
Hello,

GdiPlus Mystery.

Code: [Select]
include "gdip.inc"
window 1024,768,1
setframes 100

sys x,y
single i, a

while Key(27)=0
cls 0,0,0
for i=0 to 360 step .5
    x = sin(i+a)*50 - cos(i-a)*i
    y = cos(i+a)*50 + sin(i-a)*i
    color 255,mod(i,128)+127,mod(i,64)+127,mod(i,32)+127 
    FillCircle x+xMouse()-50,y+yMouse()-50, sin(i)*10
 next 
a +=.03
if a >=360 then a=-a
Sync()
wend
winEnd

.
« Last Edit: February 24, 2016, 11:01:22 AM by Peter »

Peter

  • Guest
Re: GdiPlus Texture Rotating
« Reply #4 on: February 24, 2016, 10:56:56 AM »
Hello,

Gdiplus CreatePath
Code: [Select]
include "gdip.inc"
Window 640,480,1
SetFrames 60
hdc = GetBufferDC()

%UnitPixel = 2
%FillModeAlternate = 0

Extern Lib "gdiplus.dll"
! GdipCreatePath
! GdipDrawPath
! GdipAddPathEllipseI
! GdipCreatePen1
! GdipDeletePen
! GdipDeletePath
End Extern

sys iPen, iEllipsePath

GdipCreatePath FillModeAlternate, &iEllipsePath
GdipAddPathEllipseI iEllipsePath, 100,  50, 200, 100
GdipAddPathEllipseI iEllipsePath, 150, 100, 200, 150
GdipAddPathEllipseI iEllipsePath, 200, 150, 200, 200
GdipAddPathEllipseI iEllipsePath, 300, 250, 100, 180
GdipAddPathEllipseI iEllipsePath, 350, 350, 100, 140

GdipCreatePen1 0xFFFFAAFF, 3.0, UnitPixel, &iPen
GdipDrawPath hdc, iPen, iEllipsePath

GdipDeletePath iEllipsePath
GdipDeletePen  iPen

WaitKey()
WinEnd
« Last Edit: February 24, 2016, 02:17:48 PM by Peter »