Browse Source

Added 'GetWidth' and 'GetHeight' in bgrascript.pas

lainz 11 years ago
parent
commit
7174dbe743
3 changed files with 41 additions and 11 deletions
  1. 21 1
      bgrascript.pas
  2. BIN
      test/test_bgrascript/file.png
  3. 20 10
      test/test_bgrascript/umain.lfm

+ 21 - 1
bgrascript.pas

@@ -23,6 +23,11 @@ procedure SynCompletionList(itemlist: TStrings);
 begin
 begin
   with itemlist do
   with itemlist do
   begin
   begin
+    {Assign key values}
+    Add('let key "value"');
+    {Read Values}
+    Add('GetWidth width');
+    Add('GetHeight height');
     {TFPCustomImage override}
     {TFPCustomImage override}
     Add('SetSize 320,240');
     Add('SetSize 320,240');
     {Loading functions}
     {Loading functions}
@@ -116,7 +121,7 @@ begin
       list[i] := variables.Values[list[i]];
       list[i] := variables.Values[list[i]];
 
 
   case LowerCase(list[0]) of
   case LowerCase(list[0]) of
-    {Assign values to variable names}
+    {Assign key values}
     'let':
     'let':
     begin
     begin
       Result := ParamCheck(passed, 3);
       Result := ParamCheck(passed, 3);
@@ -124,6 +129,21 @@ begin
         variables.Add(list[1] + '=' + list[2]);
         variables.Add(list[1] + '=' + list[2]);
     end;
     end;
 
 
+    {Read values}
+    'getwidth':
+    begin
+      Result := ParamCheck(passed, 2);
+      if Result then
+        variables.Add(list[1] + '=' + IntToStr(bitmap.Width));
+    end;
+
+    'getheight':
+    begin
+      Result := ParamCheck(passed, 2);
+      if Result then
+        variables.Add(list[1] + '=' + IntToStr(bitmap.Height));
+    end;
+
     {TFPCustomImage override}
     {TFPCustomImage override}
     'setsize':
     'setsize':
     begin
     begin

BIN
test/test_bgrascript/file.png


+ 20 - 10
test/test_bgrascript/umain.lfm

@@ -461,40 +461,50 @@ object Form1: TForm1
       ''
       ''
       '// "store some values"'
       '// "store some values"'
       'let oneh 100'
       'let oneh 100'
+      'let drawmode "dmDrawWithTransparency"'
+      'let blendmode "boTransparent"'
+      'let filename "file.png"'
+      'let color1 "rgba(250,250,250,1)"'
+      'let color2 "rgba(255,255,255,1)"'
+      'GetWidth width'
+      'GetHeight height'
       ''
       ''
       '// "Draw rectangles, lines and bitmap"'
       '// "Draw rectangles, lines and bitmap"'
-      'Rectangle 0,0,oneh,oneh,"rgba(0,0,0,0.6)","rgba(250,250,250,1)","dmDrawWithTransparency"'
-      'Rectangle 20,20,80,80,"rgba(0,0,0,0.4)","rgba(255,255,255,1)","dmDrawWithTransparency"'
+      'Rectangle 0,0,oneh,oneh,"rgba(0,0,0,0.6)",color1,drawmode'
+      'Rectangle 20,20,80,80,"rgba(0,0,0,0.4)",color2,drawmode'
       'SetHorizLine 0,10,98,"rgba(0,0,0,.3)"'
       'SetHorizLine 0,10,98,"rgba(0,0,0,.3)"'
       'SetVertLine 90,1,98,"rgba(0,0,0,.3)"'
       'SetVertLine 90,1,98,"rgba(0,0,0,.3)"'
-      'BlendBitmap 26,26,"test.png","boTransparent"'
+      'BlendBitmap 26,26,"test.png",blendmode'
       ''
       ''
       '// "Save and weird things step 1"'
       '// "Save and weird things step 1"'
-      'SaveToFile "file.png"'
+      'SaveToFile filename'
       'Negative'
       'Negative'
-      'BlendBitmap 0,oneh,"file.png","boTransparent"'
+      'BlendBitmap 0,oneh,filename,blendmode'
       ''
       ''
       '// "Save and weird things step 2"'
       '// "Save and weird things step 2"'
-      'SaveToFile "file.png"'
+      'SaveToFile filename'
       'Negative'
       'Negative'
       'FilterFastBlur 3,"False"'
       'FilterFastBlur 3,"False"'
-      'BlendBitmap oneh,0,"file.png","boTransparent"'
+      'BlendBitmap oneh,0,filename,blendmode'
       ''
       ''
       '// "Flip the world and save it"'
       '// "Flip the world and save it"'
       'VerticalFlip 0,0,100,100'
       'VerticalFlip 0,0,100,100'
       'HorizontalFlip 100,100,200,200'
       'HorizontalFlip 100,100,200,200'
       'VerticalFlip 100,0,200,100'
       'VerticalFlip 100,0,200,100'
       'HorizontalFlip 100,0,200,100'
       'HorizontalFlip 100,0,200,100'
-      'SaveToFile "file.png"'
+      'SaveToFile filename'
       ''
       ''
       '// "Weird things level 3"'
       '// "Weird things level 3"'
       'DrawCheckers 200,0,300,300,"rgba(100,100,100,255)","rgba(0,0,0,0)"'
       'DrawCheckers 200,0,300,300,"rgba(100,100,100,255)","rgba(0,0,0,0)"'
       'InplaceGrayscaleRect 0,0,100,100'
       'InplaceGrayscaleRect 0,0,100,100'
       'FilterSmooth "False"'
       'FilterSmooth "False"'
-      'ApplyBitmapMask "file.png",100,100,200,200,0,100'
+      'ApplyBitmapMask filename,100,100,200,200,0,100'
+      ''
+      'DrawHorizLine 0,0,width,"rgba(0,0,0,1)"'
+      'DrawVertLine 0,0,height,"rgba(0,0,0,1)"'
       ''
       ''
       '// "Save this in your hard disk (again)"'
       '// "Save this in your hard disk (again)"'
-      'SaveToFile "file.png"    '
+      'SaveToFile filename      '
     )
     )
     VisibleSpecialChars = [vscSpace, vscTabAtLast]
     VisibleSpecialChars = [vscSpace, vscTabAtLast]
     SelectedColor.FrameEdges = sfeAround
     SelectedColor.FrameEdges = sfeAround