Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - loudar

Pages: [1] 2 3 ... 5
1
Programs / Image functions: Convert Cartesian to Polar coordinates
« on: October 15, 2021, 03:16:20 pm »
I wrote this function as part of Vedit, the image editor made in QB64, but I wanted to share it because I can't recall seeing one like it here. I used the Wiki example for modifying image data in memory and adapted it to read the pixel data, then write them back into a new image with a bit of math for the new x and y coordinates.

Enjoy!

Code: QB64: [Select]
  1. SUB RectangleToPolar (Image AS LONG)
  2.     IF R < 0 OR R > 1 OR G < 0 OR G > 1 OR B < 0 OR B > 1 OR _PIXELSIZE(Image) <> 4 THEN EXIT SUB
  3.     DIM Buffer AS _MEM: Buffer = _MEMIMAGE(Image) 'Get a memory reference to our image
  4.  
  5.     maxx = _WIDTH(Image)
  6.     maxy = _HEIGHT(Image)
  7.     mx = maxx / 2
  8.     my = maxy / 2
  9.  
  10.     DIM O AS _OFFSET, O_Last AS _OFFSET
  11.     O = Buffer.OFFSET 'We start at this offset
  12.     O_Last = Buffer.OFFSET + maxx * maxy * 4 'We stop when we get to this offset
  13.     DIM imgPoints(maxy, maxx, 0 TO 3) AS _UNSIGNED _BYTE
  14.     DIM p, maxp AS _UNSIGNED _INTEGER64
  15.     maxp = maxx * maxy
  16.     'use on error free code ONLY!
  17.     DO
  18.         p = p + 1
  19.         y = FIX((p / maxp) * maxy)
  20.         x = p - (FIX((p / maxp) * maxy) * maxx)
  21.         imgPoints(y, x, 0) = _MEMGET(Buffer, O, _UNSIGNED _BYTE)
  22.         imgPoints(y, x, 1) = _MEMGET(Buffer, O + 1, _UNSIGNED _BYTE)
  23.         imgPoints(y, x, 2) = _MEMGET(Buffer, O + 2, _UNSIGNED _BYTE)
  24.         imgPoints(y, x, 3) = _MEMGET(Buffer, O + 3, _UNSIGNED _BYTE)
  25.         O = O + 4
  26.     LOOP UNTIL O = O_Last
  27.     'create new image
  28.     DIM newImg AS LONG
  29.     newImg = _NEWIMAGE(maxx, maxy, 32)
  30.     prevDest& = _DEST
  31.     _DEST newImg
  32.     COLOR _RGBA(0, 0, 0, 255), _RGBA(0, 0, 0, 0)
  33.     CLS
  34.     scaley = (maxx / 2 / _PI)
  35.     IF scaley > maxy THEN scaley = maxy / 2
  36.     y = -1: DO: y = y + 1
  37.         yfactor = (1 - (y / (maxy))) * scaley
  38.         x = -1: DO: x = x + 1
  39.             PSET (mx - (yfactor * SIN(2 * _PI * (1 - (x / maxx)))), my - (yfactor * COS(2 * _PI * (1 - (x / maxx))))), _RGBA(imgPoints(y, x, 2), imgPoints(y, x, 1), imgPoints(y, x, 0), imgPoints(y, x, 3))
  40.         LOOP UNTIL x = maxx
  41.     LOOP UNTIL y = maxy
  42.     _DEST Image
  43.     COLOR _RGBA(0, 0, 0, 255), _RGBA(0, 0, 0, 0)
  44.     CLS
  45.     _PUTIMAGE (0, 0)-(maxx, maxy), newImg, Image
  46.     _FREEIMAGE newImg
  47.     ERASE imgPoints
  48.     DIM imgPoints(0, 0, 0) AS _UNSIGNED _BYTE
  49.     _DEST prevDest&
  50.     'turn checking back on when done!
  51.     _MEMFREE Buffer

2
Programs / Re: Particle emitter designer
« on: September 30, 2021, 07:00:35 pm »
The "opensave" library probably causes an issue, since that uses Windows things, I believe. As I haven't done an own file explorer, that will be the only supported platform for now. The .bas file you should be able to open in your IDE though 👀

I think I started the first bits of code for this about a year back. The UI framework was inspired by the ease of HTML, I wanted to capture that and put it into a QB64-native desktop variant. So I designed all the elements I wanted and I am still continuously expanding that library as I go.
As for the particle routines, that was a piece of code I also started a year ago, but only wrote that for a little 2D "game" which never became anything. Now I relived it to make it modifiable with the UI and maybe use the emitters I create in a Level design tool that is yet to be written 8)
As for putting those pieces of code together, it took me one day. Writing all the aspects...months!

3
Programs / Re: Particle emitter designer
« on: September 30, 2021, 03:48:04 am »
Good news, Pete! Scrolling on the sliders is now implemented, as well as the fullscreen toggle.

Also added the option "extra" (how much particles deviate from their path) and "wind influence" (self explanatory)!

Also a little side note/question: The dropdown menus seem to be expanded randomly sometimes and I can't figure out why for ages now, so if anybody wants to have a look...

4
Programs / Re: Particle emitter designer
« on: September 29, 2021, 12:10:42 pm »
Since maximizing isn't the same as proper fullscreen, I will add the option anyway ;D

5
Programs / Re: Particle emitter designer
« on: September 29, 2021, 11:31:54 am »
Good that you remind me of _FULLSCREEN! I will add a checkbox to toggle that ;)

6
Programs / Re: Particle emitter designer
« on: September 29, 2021, 02:39:02 am »
Since the window is resizable, you could just maximize the window and everything should work as expected. The UI updates itself automatically. I'll set a minimum depending on your screen size for the initial size though!

7
Programs / Re: Particle emitter designer
« on: September 28, 2021, 08:46:07 pm »
I think the overlapping might be because your window is too small ;D If you resize it, they should move outwards, because I aligned the left column to the left side and the right one to the right side.
You could, if you want to, tinker with the placement in the internal/.tui files, documentation is in the GitHub repository linked above!

8
Programs / Particle emitter designer
« on: September 28, 2021, 03:29:56 pm »
This program creates an emitter that works within a framework I wrote some time ago!

The UI is utilizing my self-written universal menu framework which you can find here: https://github.com/Targon-Industries/um.
The particle system stems from a game I started and I might want to expand with this and more tools to come.

To try it out yourself, download the .zip below, extract it and run the program, should work fine. Please don't hesitate to report bugs! 8) You can also save/load emitter files, if you want to share them.

Newest version
 


 
unknown.png

9
Programs / Re: Image editor in QB64.
« on: August 07, 2021, 06:25:35 pm »
@TempodiBasic Bug should be fixed now in the repository!

10
Programs / Re: Image editor in QB64.
« on: August 07, 2021, 06:17:35 pm »
Hey @TempodiBasic!

Thanks for the notice, I am aware of this problem, just didn't come around to fix it yet. If you happen to be in this screen, click the button in the top left corner.

Why this bug occurs: When "bypassing" the "New"-button in the start menu via the settings, you eventually don't create a new file. Since many things in the main window are dependent on a file being existent/certain variables having proper values, it's not displaying it correctly. Creating a new file or opening one solves this. I'll fix this now that someone noticed ;D

11
Programs / Re: Better way to moving 'sprites'
« on: August 07, 2021, 12:34:26 pm »
There are many ways in which you could "improve" this, though that's always subjective of course.

For me, I like having my sprites as images within a folder, then load them and be able to just play with them how I want. That removes code from the program and generalizes the drawing part a lot.
I wrote some functions in QB64 that can do that in my latest Gamejam participation: https://github.com/loudar/Gamejam-2021-07-24

There are many options how you can tweak this, it totally depends on your coding style and your end goal ;D

12
QB64 Discussion / Re: Why dont we collab?
« on: August 05, 2021, 05:00:09 pm »
Hey!

I've thought about this because I've had the same question as you. I don't think it's because people don't *want* to. But often times, when just wanting to try out some code, what you have to do to get it into your IDE is more work than in other IDEs. Something like a library importer and a public library on the website would be absolutely amazing (and I'm willing to help with that if needed). QB64 has TCP support, so automatic network stuff would be possible...

13
Maybe with this? http://www.qb64.org/wiki/CSRLIN
Can't say if it'll work for console though.

14
Works super well in the image editor! Great work again.

15
Programs / Image editor in QB64.
« on: August 02, 2021, 08:03:49 am »
About a year ago, @STxAxTIC mentioned that he would love to see someone make an image editor in QB64.
Today, I can finally show the first very rough version of this.
There is a lot more that is going to be added and changed about this though. Image processing, different colors for vector layers and painting, and so on. Lots of optimization to do and probably hidden bugs to find.

Since I think I now have a good framework to build upon, I want to be able to you bunch involved in this. If anybody has interesting image processing functions, ideas how to optimize the program or literally anything else, please don't hesitate to share! For now this has only be me with help from the code of some of you (Thanks to @luke @SpriggsySpriggs and @SMcNeill here), but I'd also love this to become a community thing maybe (?).

If you happen to make an improvement, feel free to create a pull request on the repository and I'll look through it and try to keep everything organized. This here will also stay the main thread for the project.

Source code and all other files: https://github.com/Targon-Industries/Vedit

Screenshot 2021-08-02 134928.png

Pages: [1] 2 3 ... 5