Skip to content

Instantly share code, notes, and snippets.

View viniciusfbb's full-sized avatar

Vinícius Felipe Botelho Barbosa viniciusfbb

View GitHub Profile
@viniciusfbb
viniciusfbb / SkiaClipCircle.pas
Last active June 21, 2024 11:50
Draw semi-transparent rectangle + circle clipping one minor circle on the center, so that you create a hole in the drawing, and can see what it behind the control
// 1. Enable Skia on your project (right click on project > Enable Skia);
// 2. Add one TImage as the background;
// 3. Add one TSkPaintBox in front of the TImage and add the follow code on the TSkPaintBox.OnDraw event:
uses
System.Math;
procedure TForm1.SkPaintBox1Draw(ASender: TObject; const ACanvas: ISkCanvas;
const ADest: TRectF; const AOpacity: Single);
var
@viniciusfbb
viniciusfbb / ResizeImage.pas
Last active June 21, 2024 11:49
Resizing image using Skia4Delphi
function GetResizedImage(const AImage: ISkImage; ATargetWidth, ATargetHeight: Integer;
ASamplingOptions: TSkSamplingOptions; AProgressive: Boolean = True): ISkImage;
function MakeResized(const AImage: ISkImage; ANewWidth, ANewHeight: Integer): ISkImage;
var
LSurface: ISkSurface;
begin
LSurface := TSkSurface.MakeRaster(ANewWidth, ANewHeight);
LSurface.Canvas.Clear(0);
LSurface.Canvas.Scale(ANewWidth / AImage.Width, ANewHeight / AImage.Height);
@viniciusfbb
viniciusfbb / fmx.svg
Created May 19, 2023 02:56
Firemonkey Artwork #delphi
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@viniciusfbb
viniciusfbb / Skia.TextShadow.pas
Created January 22, 2023 14:07
Text shadow example using the Skia4Delphi library
uses
Skia, Skia.FMX.Graphics;
procedure TForm1.SkPaintBox1Draw(ASender: TObject; const ACanvas: ISkCanvas;
const ADest: TRectF; const AOpacity: Single);
var
LTextLayout: TSkTextLayout;
LPaint: ISkPaint;
begin
LTextLayout := TSkTextLayout.Create;
@viniciusfbb
viniciusfbb / KeyName.pas
Created November 28, 2022 15:04
Delphi FMX key name, used in OnKeyDown/OnKeyUp
function KeyName(const AKey: Word): string;
begin
case AKey of
1: Result := 'vkLButton';
2: Result := 'vkRButton';
3: Result := 'vkCancel';
4: Result := 'vkMButton';
5: Result := 'vkXButton1';
6: Result := 'vkXButton2';
8: Result := 'vkBack';
@viniciusfbb
viniciusfbb / CheckInPath.fmx
Created November 21, 2022 12:35
Check if the mouse is in path with Skia4Delphi
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 480
ClientWidth = 580
FormFactor.Width = 320
FormFactor.Height = 480
FormFactor.Devices = [Desktop]
OnCreate = FormCreate
@viniciusfbb
viniciusfbb / SimpleResize.pas
Created November 7, 2022 17:41
Simple example resizing an image using Skia4Delphi
uses
System.UITypes, Skia;
function GetResizedImage(const AImage: ISkImage; const ANewWidth, ANewHeight: Integer): ISkImage;
var
LSurface: ISkSurface;
begin
LSurface := TSkSurface.MakeRaster(ANewWidth, ANewHeight);
LSurface.Canvas.Clear(TAlphaColors.Null);
LSurface.Canvas.Scale(ANewWidth / AImage.Width, ANewHeight / AImage.Height);
@viniciusfbb
viniciusfbb / Skia.Vcl.SvgRotating.dfm
Created November 1, 2022 03:45
Skia4Delphi example of TSkSvg control rotating in VCL
This file has been truncated, but you can view the full file.
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 442
ClientWidth = 628
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
@viniciusfbb
viniciusfbb / Skia.Sample.DropShadow.dfm
Last active September 18, 2022 03:18
Simple sample to drop shadow in image with skia4delphi
object Form2: TForm2
Left = 0
Top = 0
Caption = 'Form2'
ClientHeight = 442
ClientWidth = 628
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
@viniciusfbb
viniciusfbb / Sample.Form.Controls.TSkPaintBox.pas
Last active September 15, 2022 20:19
Signature to SVG with Skia4Delphi
{************************************************************************}
{ }
{ Skia4Delphi }
{ }
{ Copyright (c) 2011-2022 Google LLC. }
{ Copyright (c) 2021-2022 Skia4Delphi Project. }
{ }
{ Use of this source code is governed by a BSD-style license that can be }
{ found in the LICENSE file. }
{ }