Recent

Author Topic: BGRAJSONStyles demo  (Read 492 times)

lainz

  • Hero Member
  • *****
  • Posts: 3312
    • Lainz
BGRAJSONStyles demo
« 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.

circular

  • Hero Member
  • *****
  • Posts: 3052
    • Personal webpage
Re: BGRAJSONStyles demo
« Reply #1 on: May 26, 2019, 01:12:46 pm »
Quite nice indeed  :)

Yeah CSS is probably one of the next steps.
Conscience is the debugger of the mind

nouzi

  • Full Member
  • ***
  • Posts: 142
Re: BGRAJSONStyles demo
« Reply #2 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.  
« Last Edit: May 26, 2019, 02:17:29 pm by nouzi »
my english is  bad
Lazarus 2.0 free pascal 3.0.4
Lazarus trunk  free pascal trunk 
System : windows 7 64bit

lainz

  • Hero Member
  • *****
  • Posts: 3312
    • Lainz
Re: BGRAJSONStyles demo
« Reply #3 on: May 26, 2019, 06:37:07 pm »
Thanks circular.

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