Lazarus

Programming => Graphics => Graphics and Multimedia => BGRABitmap and LazPaint => Topic started by: lainz on May 26, 2019, 02:50:41 am

Title: BGRAJSONStyles demo
Post by: lainz on May 26, 2019, 02:50:41 am
Hi, today I was looking in the forum to this topic https://forum.lazarus.freepascal.org/index.php/topic,45503.msg322025.html#msg322025

And I liked the idea of CSS and custom controls, so decided to play a bit with BGRABitmap and JSON, to make styling from text files easy to read and use.

Instead of CSS, I choose JSON, because FPC already has an easy to use JSON unit.

This is the project home:

https://github.com/bgrabitmap/BGRAJSONStyles

And attached how it looks like.

Here a sample file:

Code: Javascript  [Select]
  1. {
  2.     "width": "100%",
  3.     "height": "100%",
  4.     "border-width": "10",
  5.     "background-color": "rgba(128, 64, 72, 0.1)",
  6.     "border-color": "rgba(0,0,0,0.7)",
  7.     "border-x-radius": "20px",
  8.     "border-y-radius": "20px",
  9.     "border-top-left-style": "rounded",
  10.     "border-top-right-style": "rounded",
  11.     "border-bottom-left-style": "bevel",
  12.     "border-bottom-right-style": "square"
  13. }

Is just another BGRABitmap test, because I can't say if I will continue it or not, but to say that BGRA has something special, that is the bevel style, in CSS I looked that is harder to do and needs some tricks. Here with a simple setting works out of the box.
Title: Re: BGRAJSONStyles demo
Post by: circular on May 26, 2019, 01:12:46 pm
Quite nice indeed  :)

Yeah CSS is probably one of the next steps.
Title: Re: BGRAJSONStyles demo
Post by: nouzi on May 26, 2019, 02:11:15 pm
nice work  O:-)
work after change this line
Code: Pascal  [Select]
  1. ...
  2. s.LoadFromFile(FileName, TEncoding.UTF8)
  3. ..
  4.  

 to

Code: Pascal  [Select]
  1. ...
  2. s.LoadFromFile(FileName)
  3. ...
  4.  
Title: Re: BGRAJSONStyles demo
Post by: lainz on May 26, 2019, 06:37:07 pm
Thanks circular.

And nouzi, I'm using trunk for that I must add the last parameter.