 |
|
BaselScript |
Beschreibung
Draw circle
▀ ▀ ▀ ▀ JAVA ▀ ▀ ▀ ▀
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;
public class CircleView extends View {
public CircleView(Context context) {
super(context);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
float centerX = getWidth() / 2f;
float centerY = getHeight() / 2f;
float radius = 100f; // Adjust the radius as needed
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setStyle(Paint.Style.FILL);
canvas.drawCircle(centerX, centerY, radius, paint);
}
}
▀ ▀ ▀ ▀ KOTLIN ▀ ▀ ▀ ▀
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.view.View
class CircleView(context: Context) : View(context) {
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
val centerX = width / 2.toFloat()
val centerY = height / 2.toFloat()
val radius = 100f // Adjust the radius as needed
val paint = Paint()
paint.color = Color.RED
paint.style = Paint.Style.FILL
canvas.drawCircle(centerX, centerY, radius, paint)
}
}
▀ ▀ ▀ ▀ PYTHON ▀ ▀ ▀ ▀
import matplotlib.pyplot as plt
import numpy as np
# Create a figure and axis
fig, ax = plt.subplots()
# Define the center and radius of the circle
center = (0, 0)
radius = 1
# Create a circle patch
circle = plt.Circle(center, radius, fill=False, color=`blue`)
# Add the circle to the axis
ax.add_patch(circle)
# Set axis limits to fit the circle
ax.set_xlim(-1.5, 1.5)
ax.set_ylim(-1.5, 1.5)
# Set aspect ratio to be equal
ax.set_aspect(`equal`
▀ ▀ ▀ ▀ DELPHI ▀ ▀ ▀ ▀
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
procedure PaintBox1Paint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.PaintBox1Paint(Sender: TObject);
var
centerX, centerY, radius: Integer;
begin
// Calculate the center coordinates
centerX := PaintBox1.Width div 2;
centerY := PaintBox1.Height div 2;
// Set the radius
radius := 100;
// Draw a red circle
PaintBox1.Canvas.Brush.Color := clRed;
PaintBox1.Canvas.Pen.Color := clRed;
PaintBox1.Canvas.Ellipse(centerX - radius, centerY - radius, centerX + radius, centerY + radius);
end;
end.
▀ ▀ ▀ ▀ BASEL SCRIPT ▀ ▀ ▀ ▀
scene =1 name="draw circle" mode=graphic bgcolor=gray
// start script
section init
clear canvas=1
draw tile=circle name=circle1 color=yellow radius=100 stroke_width=10 filling=1 gravity=center_screen
draw canvas=1
end section
end scene 1