create random roulette for draw game lazarus / 21-General ---------------------------------------------------------------------- Ericktux · 2021-12-25 16:23 good morning brothers and merry christmas to all of you, I am thinking of creating a raffle program that has a rotating random wheel, someone knows how I can create a wheel similar to the image that I attach. ---------------------------------------------------------------------- speter · 2021-12-26 00:03 To get rotated text use: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Font.Orientation := 10*degree; Have a look at the attached project. You'll need to work on it a bit, but it should give you a start. In particular, note that the position specified with (canvas.)textout is near the text's top-left... You can use textwidth() &/or textextent() to workout the text's (unrotated?) size on the canvas. cheers S. ---------------------------------------------------------------------- Roland57 · 2021-12-26 07:23 Hello! Merry Christmas to you. Cairo is handy for that kind of things. Here is an example. ---------------------------------------------------------------------- 440bx · 2021-12-26 09:01 I would be quite nice (and also more impressive) if the numbers acted as if they were rotating on a pin on their center of gravity, that way the numbers would not be fixed and always have their base horizontal making them easier to read. IOW, the number that ends at the top of the wheel would not be upside down nor would the rest of the numbers be at an angle.  (21st century... gotta put a gyroscope in those wheels ) ---------------------------------------------------------------------- Roland57 · 2021-12-26 20:50 Cairo roulette V2. ---------------------------------------------------------------------- Fred vS · 2021-12-26 21:52 Quote from: Roland57 on December 26, 2021, 09:50:53 pmCairo roulette V2.  Hello Roland! Excellent, I did not know that Cairo works for Linux too. Tested on Debian 11 and the png-files are created, ou-of-the-box. I dont know Cairo but is it possible to have the result to screen too for X and Windows? Fre;D ---------------------------------------------------------------------- Roland57 · 2021-12-26 22:25 Quote from: Fred vS on December 26, 2021, 10:52:05 pmI dont know Cairo but is it possible to have the result to screen too for X and Windows? Hello Fred. Yes, it is certainly possible. There is a package with many examples which allows to use Cairo in Lazarus. (And, by the way, for MSEide, there is also an example using Cairo. The impressive and beautiful example named repazdemo. But this is another story.) In that case (for the roulette game), if it were my project, I would use Cairo in a console program to made all the images needed, and after I would load the images in my application. ---------------------------------------------------------------------- Fred vS · 2021-12-26 22:45 Quote from: Roland57 on December 26, 2021, 11:25:17 pmQuote from: Fred vS on December 26, 2021, 10:52:05 pmI dont know Cairo but is it possible to have the result to screen too for X and Windows? Hello Fred. Yes, it is certainly possible. There is a package with many examples which allows to use Cairo in Lazarus. (And, by the way, for MSEide, there is also an example using Cairo. The impressive and beautiful example named repazdemo. But this is another story.) In that case (for the roulette game), if it were my project, I would use Cairo in a console program to made all the images needed, and after I would load the images in my application. OK, time to discover and explore Cairo and his treasures... Thanks for the tips and happy new all. Fre;D ---------------------------------------------------------------------- Ericktux · 2021-12-27 03:54 Thank you very much friend "roland57" for sharing your knowledge, I have joined the file "roulette.pas" to my project and when starting the file "roulette.png" is generated. My question is, how can I make it turn like a game roulette and show the chosen item, i'm new to this image topic and cairo, will you have some example project please.  PS: I attach an example image ---------------------------------------------------------------------- Roland57 · 2021-12-27 05:25 Quote from: Ericktux on December 27, 2021, 04:54:13 amwill you have some example project please.  Unfortunately no, but there are many animation examples here and there. If it were my project, my next step would be to modify the little program I provided to you, in order to create all the images that I need. If you don't see what I mean, you could apply to the GIF animation that you attached the following ImageMagick command: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i convert roulette.gif %02d.png ---------------------------------------------------------------------- Roland57 · 2021-12-29 17:20 Hello! Here is a quick demo project. It is 1° a modified version of roulette3.pas, which accepts an angle as parameter; 2° a script to call roulette3 with values for 0 to 350 (step 10); a Lazarus project using BGRABitmap. The pictures are already generated, so you just have to compile and run the Lazarus project. Hum, the file is too big. So you will have only 9 pictures instead of 36. The program should still work, and you will see the idea. It will be easy to generate all the pictures by yourself. Regards. Roland P.-S. Remade the package with smaller pictures (and without Lazarus standard icon).  P.-P.-S. Attachment deleted. Please see updated package in the next message. ---------------------------------------------------------------------- Ericktux · 2021-12-29 20:13 wow  sounds great my friend thank you so much I'm going to try it ---------------------------------------------------------------------- Roland57 · 2021-12-30 18:08 Hello! Here is another demo, more complete, using a timer. The previous demo with a TSpinEdit is included. Along the way I realized that it was a mistake not to have generated the images in the correct order. Then you had to break your head to get the number corresponding to the image.  So I retouched the frame generator (roulette3), in order to generate the images in the most handy order. Regards. Roland ---------------------------------------------------------------------- sysrpl · 2021-12-31 04:01 At the 20 second mark of the video attached to this pascal git repository, you will find a good example of both the wheel and animation you are trying to recreate. https://github.com/sysrpl/Codebot.Animator