Gamestudio Links
Zorro Links
Newest Posts
What are you working on?
by rayp. 12/14/19 13:36
Bmap creation - wrong Alpha values
by txesmi. 12/13/19 14:58
A9
by preacherX. 12/11/19 11:01
Error Message 010: invalid stops
by Volker. 12/11/19 08:25
AssetFix & Assets.csv
by MatPed. 12/11/19 07:03
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
7 registered members (Dooley, aventador, Zheka, anufriyev, AndrewAMD, 2 invisible), 713 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
timW, PabloMF, deepscreener, wzschultz, Alit
18342 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Painting #478261
09/26/19 09:07
09/26/19 09:07
Joined: Jul 2007
Posts: 540
Turkey, izmir
Emre Offline OP
User
Emre  Offline OP
User

Joined: Jul 2007
Posts: 540
Turkey, izmir
Hi guys, i'm trying to paint texture/bmap.

this is the code i use:

Code

#include <acknex.h>
#include <windows.h>
#include <default.c>



BMAP* paint_map="#512x512x24";

PANEL* paint_pan =
{
	bmap=paint_map;
	flags=SHOW;
}

var brush_size=32;

function main()
{
	fps_max=75;
	video_set(512,512,32,2);
	
	mouse_mode=3;
	mouse_pointer=2;
	bmap_fill(paint_map,vector(255,255,255),100);
	
	var pic_width=bmap_width(paint_map);
	var pic_height=bmap_height(paint_map);
	var pixel;
	var format;
	var px,py;


	while(1)
	{
		
		if(mouse_left)
		{	
			format = bmap_lock(paint_map, 888);
					
			int i=0;
			for(i=0;i<brush_size; i++)
			{
				int j=0;
				
				for(j=0;j<360;j++)//circle
				{
					
					
					pixel = pixel_for_vec(vector(0,255,0),100,format);
					px=clamp(mouse_pos.x+i*cos(j),1,pic_width-1);
					py=clamp(mouse_pos.y+i*sin(j),1,pic_height-1);
					
					pixel_to_bmap(paint_map, px,py, pixel);
					
				}
				
			}
		}
		bmap_unlock(paint_map);
		
		wait(1);
	}

}




i need soft brush and pressure option, as in image editing programs.. Any help would be great.

[Linked Image]

Re: Painting [Re: Emre] #478268
09/26/19 22:01
09/26/19 22:01
Joined: Jun 2007
Posts: 1,275
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,275
Hiporope and its pain
Hi,
here you go
Code
void col_lerp(COLOR *_cT, COLOR *_c0, COLOR *_c1, var _factor, var _gamma) {
	_cT->red   = pow(pow(_c0->red, _gamma) * (1 - _factor)   + pow(_c1->red, _gamma) * _factor,   1.0 / _gamma);
	_cT->green = pow(pow(_c0->green, _gamma) * (1 - _factor) + pow(_c1->green, _gamma) * _factor, 1.0 / _gamma);
	_cT->blue  = pow(pow(_c0->blue, _gamma) * (1 - _factor)  + pow(_c1->blue, _gamma) * _factor,  1.0 / _gamma);
}

void bmap_paint_circle (
	BMAP *_bmp,      
	int _posX,         
	int _posY,         
	var _radiusInt,  
	var _radiusExt, 
	COLOR *_color, 
	var _alpha) 
	{
		var _g = _radiusExt - _radiusInt;
		if (_g == 0)
			_g = 0.001;
		int _x0 = maxv(-_radiusExt, -_posX);
		int _xL = minv(_radiusExt, bmap_width(_bmp) - _posX);
		int _y = maxv(-_radiusExt, -_posY);
		int _yL = minv(_radiusExt, bmap_height(_bmp) - _posY);
		var _frt = bmap_lock(_bmp, 0);
		for (; _y<_yL; _y+=1) {
			int _x = _x0;
			for (; _x<_xL; _x+=1) {
				var _r = sqrt(_y * _y + _x * _x);
				if (_r > _radiusExt)
					continue;
				var _f = (1 - maxv(_r - _radiusInt, 0) / _g) * _alpha / 100;
				var _p = pixel_for_bmap(_bmp, _posX + _x, _posY + _y);
				COLOR _c;
				pixel_to_vec(&_c, NULL, _frt, _p);
				col_lerp(&_c, &_c, _color, _f, 2.2);
//				vec_lerp(&_c, &_c, _color, _f);
				_p = pixel_for_vec(&_c, 100, _frt);
				pixel_to_bmap(_bmp, _posX + _x, _posY + _y, _p);
			}
		}
		bmap_unlock(_bmp);
	}


Salud!

Re: Painting [Re: txesmi] #478271
09/27/19 03:45
09/27/19 03:45
Joined: Jul 2007
Posts: 540
Turkey, izmir
Emre Offline OP
User
Emre  Offline OP
User

Joined: Jul 2007
Posts: 540
Turkey, izmir
This is awesome! Thank you very much, txesmi!

Re: Painting [Re: Emre] #478280
09/27/19 14:49
09/27/19 14:49
Joined: Jun 2007
Posts: 1,275
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,275
Hiporope and its pain
You are welcome laugh


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1