Skip to content

Instantly share code, notes, and snippets.

{ Screen Scaling for Device }
function GetScreenScale: Single;
var
ScreenService: IFMXScreenService;
begin
Result := 1;
if TPlatformServices.Current.SupportsPlatformService (IFMXScreenService, IInterface(ScreenService)) then
begin
Result := ScreenService.GetScreenScale;
end;
{ Where AVP is the TViewport3D or self on a TForm3D }
var tmpsp: TPoint3D := ScreenHelper.CalculateScreenPosition(AVP.Context,
TPoint3D.Zero, Layer3D1.Scale.Point, Layer3D1.RotationAngle.Point, Layer3D1.Position.Point);
Circle1.Position.X := tmpsp.X - Circle1.Width / 2;
Circle1.Position.Y := tmpsp.Y - Circle1.Width / 2;
{ FIX: TPaintBox offset position }
tmpsp.X := tmpsp.X - PaintBox1.Position.X;
tmpsp.Y := tmpsp.Y - PaintBox1.Position.Y;
tmpr := RectF(tmpsp.X -FSize, tmpsp.Y -FSize, tmpsp.X +FSize, tmpsp.Y +FSize);
{ ABMP is a TBitmap }
{ Obtains device scaling }
function GetScreenScale: Single;
var
ScreenService: IFMXScreenService;
begin
Result := 1;
if TPlatformServices.Current.SupportsPlatformService (IFMXScreenService, IInterface(ScreenService)) then
begin
Result := ScreenService.GetScreenScale;
end;
var tmpsp: TPoint3D := TPoint3D.Zero;
// Obtain the screen coordinate by using the WorldToScreen method
tmpsp := self.Context.WorldToScreen(TProjection.Camera, Layer3D1.Position.Point);
writeln('2D Position: ' + tmpsp.X.ToString + ', ' + tmpsp.Y.ToString);
# A docker-compose must always start by the version tag.
# We use '3' because it's the last version at this time.
version: '3'
# You should know that docker-composes works with services.
# 1 service = 1 container.
# For example, a service maybe, a server, a client, a database...
# We use the keyword 'services' to start to create services.
services:
# As we said at the beginning, we want to create: a server and a client.
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="%package%"
android:versionCode="%versionCode%"
android:versionName="%versionName%"
android:installLocation="%installLocation%">
<uses-sdk android:minSdkVersion="%minSdkVersion%" android:targetSdkVersion="33" />
<%uses-permission%>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
procedure TFrmMain.FormCreate(Sender: TObject);
begin
{$IFDEF IOS}
if NotificationCenter1.AuthorizationStatus <> TAuthorizationStatus.Authorized then begin
NotificationCenter1.RequestPermission;
end;
{$ENDIF}
{$IFDEF ANDROID}
{ TErrorTodo }
constructor TErrorTodo.Create(ErrorMessage: string);
begin
self.ErrorMessage := ErrorMessage;
end;
function TErrorTodo.GetSelf: TObject;
begin
Result := Self;
ITodo = interface
end;
TErrorTodo = class(TInterfacedObject, ITodo)
public
[JSONMarshalled(True)][JSONName('error_message')]
ErrorMessage: string;
constructor Create(ErrorMessage: string);
function GetSelf: TObject;
{ TPosthocProgSettings }
class function TTodoProgSettings.GetDefaultSettingsFilename: string;
begin
Result := TPath.Combine(GetSettingsFolder(), 'init.bin');
end;
class function TTodoProgSettings.GetSettingsFolder: string;
var