Forum Replies Created
-
AuthorPosts
-
If you want to make color lighter or darker, you can multiply it with float:
Local darkerPink:=Color.Pink * .8
Local lighter:=Color.FromHex("#554488") * 1.2
Nice!
One note about converting Color into UInt:
Monkey123Function RGBA:UInt( c:Color )Return UInt(c.a*255) Shl 24 | UInt(c.b*255) Shl 16 | UInt(c.g*255) Shl 8 | UInt(c.r*255)EndThere is an ABGR format! I suppose, it’s a native opengl format.
That’s why if you write color as $FF0000FF you’ll get Red color but you can expect Blue here.
mojo.Image uses Pixmap with premultiplied alpha.
If you’ll save such pixmap then you’ll get artifacts on next loading image – alpha will be premultiplied twice here.
I think this is the reason.
PNG loader itself works well.
@abakobo try to just resave pixmap without touching pixelFormat and alpha:
Monkey12Local pix:=Pixmap.Load( srcPath ) 'format=none, calcAlpha=falsepix.Save( destPath )it is an artefacts-free for me.
Actually, we can to omit where condition, and then we can pass any instance with method Clicked() as a button – thanks to geteric type T.
I still hope that the best way is to use pure monkey2’s path..
But I didn’t use mobile targets yet.
You can write own Function GetPrefsFile:String( file:String,author:String="defValue",name:String="defValue" ) that will use sdl prefs or what you want else, and you can change single place if needed to make changes for a whole project.
And to link with my code:
Const AppPrefs:=Preferences.Get( GetPrefsFile( "app.json" ) )
I tried it just for testing because we talk about Nulls here.
And I can live with that too.
What happen if we compare ‘default null’ first class function with keyword Null?
The answer is – first class function is null until have no assigned values.
Example app:
Monkey12345678910111213141516171819202122232425Namespace myapp#Import "<std>"Using std..Function Main()Local f:Bool()If f=Null Print "#1: func is null"f+=FuncIf f=Null Print "#2: func is null"f-=FuncIf f=Null Print "#3: func is null"EndFunction Func:Bool()Return TrueEndOutput:
Monkey12#1: func is null#3: func is nullAlso I found that mx2cc allow us to write weird code:
Monkey1f-=Null ' or +=NullIs this Null value will generate anonimous new instance or simple will do nothing?
I think the answer is the second case – do nothing. If we have empty / null f and write f+=Null then f still is null.
Yes, I like what you said in the latest post.
And some changes to docs for these methods where you explain that Null is context specific. Maybe even to create own docs page for Null and place references here from other pages.
What happen if we compare ‘default null’ first class function with keyword Null?
If GetValue ( "test",Null )=Null
Genarally, .Contains () is our big friend.
You’re probably right, although it does allow the above ‘magic’ to work. Ditto other tricks like non-intrusive ref counting, eg: ‘_refs[obj]+=1’ will ‘just work’.
There is an default (t) in c#, don’t know is it possible/ okay for monkey.
With that mechanism we can write
GetValue <T>:T ( key:String,value:T=default (T) )
And it can also create default first class function for us.
Almost, you’re definitely supposed to be allowed to chain functions together, although ‘f=f+F2’ should work too, will fix!
I’m not sure that f=f1+f2 is a good idea.
If f1 returns 5 and f2 returns 10 then f1+f2 should return 15. But in our case we get resulting value of the last call only.
But operator += is used as ‘subscription’ operator for a long time and it’s behavior is quite expected.
A null function value is a NOP function (ie: it doesn’t do anything and returns ‘null’) but is still a normal, valid function (just like a null int, ie: 0, is a normal int)
Returning ‘null’-values of different types can be very insidious.
For example, С# have method bool TryGetValue( key, out value ) to avoid returning unexisting values, and indexing operator throw an exception if key not found (msdn).
IMO, for monkey2 will be good at least to improve docs for Map::Get() method and Map::[ ] operator, where would be explained that *you always get ‘default-null’ value here*. And very important to use Map::Contains() if you want to know has map a key of not.
Have Int(0) isn’t the same as have no value at all.
Just to pay attention on it.
As an idea – to make standalon app or special dialog in ted2go to customize themes.
Dreams…
I am thinking about adding new Tab named Examples where would be collected all links to bananas/samples – kind of project tree view.
Wow.
Thanks to all patrons!
-
AuthorPosts