Jump to content

Some Graphical Examples using GDI+ Vol. I


UEZ
 Share

Recommended Posts

Do you mean the distance between the squares independent of number of squares?

UEZ

yes. if i set it to have 10 squares and change the delay between squares spawing to 20 it gives me 10 squares.

set the delay to 30 and i get 6

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

yes. if i set it to have 10 squares and change the delay between squares spawing to 20 it gives me 10 squares.

set the delay to 30 and i get 6

The dependency between $k and Step x is following:

Step x should always < than $k

If you want to create e.g. 11 squares than

  • short distance: k$ = 22 and Step 2
  • for medium distance: $k = 99 and Step 9
  • for long distance: $k = 275 and Step 25
  • for extra long distance: k$ = 1089 and Step 99
Amount of squares = $k / x where k is the length. The higher k is the longer takes the flight.

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Added Mesmerizing Squares Screensaver code to my 1st post.

It is modified from Rotating Squares code packed into screensaver code.

Just compile it, rename it to .scr and copy it to %windir%\System32. Select screensaver...

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Added Mesmerizing Squares Screensaver code to my 1st post.

It is modified from Rotating Squares code packed into screensaver code.

Just compile it, rename it to .scr and copy it to %windir%\System32. Select screensaver...

UEZ

very nicely done

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

very nicely done

Thank you very much for your comment :)

Btw, I didn't check it on dual monitor and I found out in my office that it is NOT working properly on dual monitor.

I updated the code. See my 1st post! It is jerking on very high resolutions because whole screen is being cleaned every frame...

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

its very nice, but.....

why no options for that screen saver?

heres mine and has lots of options.

http://www.mediafire.com/?sharekey=bfb7d7a...04e75f6e8ebb871

i got the number of squares to work, better gui, more options.

how do I;

1: change expansion rate

2: use ini file

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

its very nice, but.....

why no options for that screen saver?

heres mine and has lots of options.

http://www.mediafire.com/?sharekey=bfb7d7a...04e75f6e8ebb871

i got the number of squares to work, better gui, more options.

how do I;

1: change expansion rate

2: use ini file

I was too lazy for doing the config section :)

Btw, your ss is not working on my notebook (Vista x32), no small preview, nothing happens when I press the preview button (only black screen) and the window freezes where I selected the screensaver when I pressed ESC -> I've to kill rundll32.exe.

EDIT:

OK, I got it. it is not designed to work as a real screensaver when you rename it to .scr, copy it to system32 folder and select the screensaver from control panel.

Change the code from:

For $j = 1 To $squares step $dlyoÝ÷ Ù«ewµç»hjëh×6  For $j = $squares To 1 step -$dly

to draw from back to front :lmao:

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I was too lazy for doing the config section :)

Btw, your ss is not working on my notebook (Vista x32), no small preview, nothing happens when I press the preview button (only black screen) and the window freezes where I selected the screensaver when I pressed ESC -> I've to kill rundll32.exe.

EDIT:

OK, I got it. it is not designed to work as a real screensaver when you rename it to .scr, copy it to system32 folder and select the screensaver from control panel.

Change the code from:

For $j = 1 To $squares step $dly

to  For $j = $squares To 1 step -$dly

to draw from back to front :lmao:

UEZ

i dont know why it didnt work. i updated it (three times) last night. gonna update it (again) with that code. wonder what it would look like.....

http://www.mediafire.com/?nxnmr2gmzmm

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

Added another GDI+ example Sinus Scroller :)

Have a look on my 1st post! (#06 Sinus Scroller)

Do you like the examples? Which one is your favorite?

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 2 weeks later...

This is only an information that I updated, modified and added some of the examples since my last post from 2009.01.30.

If you are interested in my GDI+ stuff just go to my 1st post and have a look on it (more details on change log).

If not, just ignore this post.

THANKS for all your feedback.

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

@UEZ,

This is great stuff. Nice and interesting examples.

I like the sinus scroller the most.

You've got my 5 stars.

GreenCan

Contributions

CheckUpdate - SelfUpdating script ------- Self updating script

Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple

MsgBox with CountDown ------------------- MsgBox with visual countdown

Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView

Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV)

USB Drive Tools ------------------------------ Tool to help you with your USB drive management

Input Period udf ------------------------------ GUI for a period input

Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette

Excel Chart UDF ----------------------------- Collaboration project with water 

GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm

TaskListAllDetailed --------------------------- List All Scheduled Tasks

Computer Info --------------------------------- A collection of information for helpdesk

Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only)

Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format

Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane

Oracle SQL Report Generator -------------  Oracle Report generator using SQL

SQLite Report Generator -------------------  SQLite Report generator using SQL

SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field

DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access

Animated animals ----------------------------- Fun: Moving animated objects

Perforated image in GUI --------------------- Fun: Perforate your image with image objects

UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ

Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool

Visual Image effect (GUI) -------------------- Visually apply effects on an image

 

 

 

Link to comment
Share on other sites

My shinning GDI+ example is in the latest version of Limitars LMP. I owe you many thanks for i learned a lot from your examples.

Your're welcome :)

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

My shinning GDI+ example is in the latest version of Limitars LMP. I owe you many thanks for i learned a lot from your examples.

Show me your example please! :)

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

@UEZ,

This is great stuff. Nice and interesting examples.

I like the sinus scroller the most.

You've got my 5 stars.

GreenCan

Thanks GreenCan for your feedback :)

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

@youknowwho4eva: nice but the code is too long.

I tried to compact your code (not speed optimized):

#include <GUIConstantsEx.au3>
#include <GDIplus.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <Bass.au3>
#include <BassConstants.au3>
$userdll = DllOpen("user32.dll")
$bass_dll = DllOpen("BASS.dll")
Global Const $width = 200
Global Const $height = 230
Global $title = "LMP Visualization"
$file = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)")
_BASS_Init($bass_dll, 0, -1, 44100, 0, "")
$MusicHandle = _BASS_StreamCreateFile($bass_dll, False, $file, 0, 0, 0)
If @error Then
    MsgBox(0, "Error", "Could not load audio file" & @CR & "Error = " & @error)
    Exit
EndIf
Opt("GUIOnEventMode", 1)
$hwnd = GUICreate($title, $width, $height, -1, -1, Default, $WS_EX_TOOLWINDOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState()

_GDIPlus_Startup()
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
_GDIPlus_GraphicsClear($backbuffer)
$pen1 = _GDIPlus_PenCreate(0, 1)
$pen2 = _GDIPlus_PenCreate(0, 1)

$song_length = _BASS_ChannelGetLength($bass_dll, $MusicHandle, $BASS_POS_BYTE)
_BASS_ChannelPlay($bass_dll, $MusicHandle, 1)

Do
    $current = _BASS_ChannelGetPosition($bass_dll, $MusicHandle, $BASS_POS_BYTE)
    $percent = Round(($current / $song_length) * 100, 0)
    $levels = _BASS_ChannelGetLevel($bass_dll, $MusicHandle)
    $RightChLvl = Round(_LoWord($levels) / $height * 2.5, 0)
    $LeftChLvl = Round(_HiWord($levels) / $height * 2.5, 0)
    _GDIPlus_GraphicsClear($backbuffer)
    For $l = 0 To $leftChLvl
        $r = (-(Cos(1 * $l / 2^7) + 1) / 2) * 256
        $g = ((Cos(4 * $l / 2^8) + 1) / 2) * 256
        $b = (-(Cos(1 * $l / 2^8) + 1) / 2) * 256
        _GDIPlus_PenSetColor($pen1, "0xEF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))
        _GDIPlus_GraphicsDrawLine($backbuffer, $width / 5, $height - $l, $width / 5 + 30, $height - $l, $pen1)
    Next
    For $l = 0 To $RightChLvl
        $r = (-(Cos(1 * $l / 2^7) + 1) / 2) * 256
        $g = ((Cos(4 * $l / 2^8) + 1) / 2) * 256
        $b = (-(Cos(1 * $l / 2^8) + 1) / 2) * 256
        _GDIPlus_PenSetColor($pen2, "0xEF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))
        _GDIPlus_GraphicsDrawLine($backbuffer, 3 * $width / 5, $height - $l, 3 * $width / 5 + 30, $height - $l, $pen2)
    Next
    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)
    Sleep(50)
Until False

Func close()
    _BASS_Free($bass_dll)
    _GDIPlus_PenDispose($pen1)
    _GDIPlus_PenDispose($pen2)
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_GraphicsDispose($backbuffer)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>close

I hope it helps you :)

Regards,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Sorry, I couldn't remember how to make it scrollable like that. That definatly is much smaller. You shoulda seen the way I had it before, it was over 3000 lines lol. I couldn't think of how to do it differently, the way you did it is much better. I wanna kick myself for not thinking of it. Well the cosin stuff I would have never thought of, But I could do it with less math probably. My computer is quick so it has no problem, But maybe putting some steps on the for loops would speed it up for slower systems. I was also thinking this could easily be done with an image and a black line covering up the image. But I wanted to try and learn some more of the GDI+ stuff. I plan on making more that better utilize the GDI+.

Giggity

Link to comment
Share on other sites

Sorry, I couldn't remember how to make it scrollable like that. That definatly is much smaller. You shoulda seen the way I had it before, it was over 3000 lines lol. I couldn't think of how to do it differently, the way you did it is much better. I wanna kick myself for not thinking of it. Well the cosin stuff I would have never thought of, But I could do it with less math probably. My computer is quick so it has no problem, But maybe putting some steps on the for loops would speed it up for slower systems. I was also thinking this could easily be done with an image and a black line covering up the image. But I wanted to try and learn some more of the GDI+ stuff. I plan on making more that better utilize the GDI+.

We are here to exchange knowledge and to learn more techniques :) , so don't frustrate... :)

Nobody is perfect.

Regards,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I got an idea...

Here a small modifcation:

#include <GUIConstantsEx.au3>
#include <GDIplus.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <Bass.au3>
#include <BassConstants.au3>
$userdll = DllOpen("user32.dll")
$bass_dll = DllOpen("BASS.dll")
Global Const $width = 200
Global Const $height = 230
Global $title = "LMP Visualization"
$file = FileOpenDialog("Open...", "", "MP3 Files (*.mp3)")
_BASS_Init($bass_dll, 0, -1, 44100, 0, "")
$MusicHandle = _BASS_StreamCreateFile($bass_dll, False, $file, 0, 0, 0)
If @error Then
    MsgBox(0, "Error", "Could not load audio file" & @CR & "Error = " & @error)
    Exit
EndIf
Opt("GUIOnEventMode", 1)
$hwnd = GUICreate($title, $width, $height, -1, -1, Default, $WS_EX_TOOLWINDOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState()

_GDIPlus_Startup()
$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
_GDIPlus_GraphicsClear($backbuffer)
$pen1 = _GDIPlus_PenCreate(0, 1)
$pen_size = 4
$pen2 = _GDIPlus_PenCreate(0, $pen_size)

$song_length = _BASS_ChannelGetLength($bass_dll, $MusicHandle, $BASS_POS_BYTE)
_BASS_ChannelPlay($bass_dll, $MusicHandle, 1)
$current = _BASS_ChannelGetPosition($bass_dll, $MusicHandle, $BASS_POS_BYTE)
$percent = Round(($current / $song_length) * 100, 0)

$max_l = 0
$max_r = 0
$fall_speed = 5
$fire_up = 10
Do
    $levels = _BASS_ChannelGetLevel($bass_dll, $MusicHandle)
    $LeftChLvl = Round(_HiWord($levels) / $height * 2.0, 0)
    $RightChLvl = Round(_LoWord($levels) / $height * 2.0, 0)
    If $max_l <= $LeftChLvl Then
        $max_l = $LeftChLvl + $fire_up
    Else
        If $max_l > $LeftChLvl + $pen_size + 1 Then $max_l -= $fall_speed
    EndIf
    If $max_r <= $RightChLvl Then
        $max_r = $RightChLvl + $fire_up
    Else
        If $max_r > $RightChLvl + $pen_size + 1 Then $max_r -= $fall_speed
    EndIf
    _GDIPlus_GraphicsClear($backbuffer, 0x5F000000)
    _GDIPlus_PenSetColor($pen2, 0xEF7F7F7F)
    For $l = 0 To $leftChLvl
        $r = (-(Cos(1 * $l / 2^7) + 1) / 2) * 256
        $g = ((Cos(4 * $l / 2^8) + 1) / 2) * 256
        $b = (-(Cos(1 * $l / 2^8) + 1) / 2) * 256
        _GDIPlus_PenSetColor($pen1, "0xEF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))
        _GDIPlus_GraphicsDrawLine($backbuffer, $width / 5, $height - $l, $width / 5 + 30, $height - $l, $pen1)
    Next
    For $l = 0 To $RightChLvl
        $r = (-(Cos(1 * $l / 2^7) + 1) / 2) * 256
        $g = ((Cos(4 * $l / 2^8) + 1) / 2) * 256
        $b = (-(Cos(1 * $l / 2^8) + 1) / 2) * 256
        _GDIPlus_PenSetColor($pen1, "0xEF" & Hex($r, 2) & Hex($g, 2) & Hex($b, 2))
        _GDIPlus_GraphicsDrawLine($backbuffer, 3 * $width / 5, $height - $l, 3 * $width / 5 + 30, $height - $l, $pen1)
    Next
    _GDIPlus_GraphicsDrawLine($backbuffer, $width / 5, $height - $max_l, $width / 5 + 30, $height - $max_l, $pen2)
    _GDIPlus_GraphicsDrawLine($backbuffer, 3 * $width / 5, $height - $max_r, 3 * $width / 5 + 30, $height - $max_r, $pen2)
    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)
    Sleep(15)
Until False

Func close()
    _BASS_Free($bass_dll)
    _GDIPlus_PenDispose($pen1)
    _GDIPlus_PenDispose($pen2)
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_GraphicsDispose($backbuffer)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>close

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...