All Projects → FreHu → abap-turtle-graphics

FreHu / abap-turtle-graphics

Licence: Unlicense License
It's turtles all the way down

Programming Languages

ABAP
45 projects

Projects that are alternatives of or similar to abap-turtle-graphics

abaK
ABAP constants done right
Stars: ✭ 26 (+4%)
Mutual labels:  abap
vscode-abaplint
Visual Studio Code abaplint extension
Stars: ✭ 18 (-28%)
Mutual labels:  abap
cloud-abap-rap
This repository contains several examples how to develop with the ABAP RESTful Application Programming Model (RAP) in SAP BTP, ABAP environment.
Stars: ✭ 98 (+292%)
Mutual labels:  abap
abapGitServer
Git server implemented in ABAP
Stars: ✭ 56 (+124%)
Mutual labels:  abap
abap2xlsx
Generate your professional Excel spreadsheet from ABAP
Stars: ✭ 493 (+1872%)
Mutual labels:  abap
nwabap-ui5uploader
This module allows a developer to upload SAPUI5/OpenUI5 sources into a SAP NetWeaver ABAP system.
Stars: ✭ 15 (-40%)
Mutual labels:  abap
transpiler
ABAP to JS transpiler
Stars: ✭ 57 (+128%)
Mutual labels:  abap
ABAPFavorites
ABAP Favorites Eclipse Plugin
Stars: ✭ 23 (-8%)
Mutual labels:  abap
text2tab
TAB-delimited text parser for ABAP
Stars: ✭ 16 (-36%)
Mutual labels:  abap
bw toolbox
📊 🔨 📦 Collection of all tools for SAP BW useful for daily work
Stars: ✭ 24 (-4%)
Mutual labels:  abap
abap-adt-api
Abap Developer Tools client
Stars: ✭ 25 (+0%)
Mutual labels:  abap
ajson
Yet another json parser serializer for ABAP
Stars: ✭ 29 (+16%)
Mutual labels:  abap
teched2021-developer-keynote
SAP TechEd 2021 Developer Keynote: Improving Developers' Lives.
Stars: ✭ 23 (-8%)
Mutual labels:  abap
abap-openapi-client
ABAP OpenAPI Client and Server generator in ABAP
Stars: ✭ 44 (+76%)
Mutual labels:  abap
fundamental-tools
Web applications with ABAP, done simple.
Stars: ✭ 42 (+68%)
Mutual labels:  abap
SAP-ABAP-Development
SAP ABAP development, customization and enhancement guides
Stars: ✭ 51 (+104%)
Mutual labels:  abap
dotabap.github.io
dotabap.org homepage
Stars: ✭ 19 (-24%)
Mutual labels:  abap
eui
Easy UI in SAP
Stars: ✭ 34 (+36%)
Mutual labels:  abap
abap-odata-smoke-test
This ABAP Report performs simple smoke tests for activated ODATA services, providing basic automated testing for your ODATA endpoints.
Stars: ✭ 13 (-48%)
Mutual labels:  abap
xtt
ABAP template engine for Excel, Word, Html & Pdf
Stars: ✭ 21 (-16%)
Mutual labels:  abap

logo

abap package version

Announcement blog

Enterprise-grade turtle graphics library for abap intended for business-oriented children or bored adults.

The graphics are generated in the svg format.

Installation

Import the repository to your system using abapGit.

Usage example

Turtle

report turtle_demo_polygons.

initialization.

  parameters:
    bgcolor  type string default `#000000`,
    polygons type i,
    sides    type i.

at selection-screen output.

  if polygons <> 0 and sides <> 0.

    data(turtle) = zcl_turtle=>create( 
      height = 800 
      width  = 800 
      title  = |Polygons:{ polygons } Sides: { sides }| background_color = bgcolor ).

    turtle->goto( x = 400 y = 400 ).
    turtle->set_pen( value #(
            stroke_color = `#FF00FF`
            stroke_width = 2 ) ).

    data(current_polygon) = 0.
    while current_polygon < polygons.

      " draw a regular polygon
      data(current_polygon_side) = 0.
      data(side_length) = 50.
      while current_polygon_side < sides.
        turtle->forward( side_length ).
        turtle->right( 360 / sides ).
        current_polygon_side = current_polygon_side + 1.
      endwhile.

      " rotate before painting next polygon
      turtle->right( 360 / polygons ).

      current_polygon = current_polygon + 1.
    endwhile.

    zcl_turtle_output=>show( turtle ).

  endif.

You can also save the image using zcl_turtle_output=>download( turtle ).

image

see zcl_turtle_examples for more

Supported instructions

zcl_turtle

movement:

  • forward, back
  • left,right (rotate by x degrees)
  • pen up/down (only considered when moving, not when outputting svg directly)

styling:

  • style (css will be placed in the html document head in within <style></style> tags)

  • background color

  • stroke width

  • stroke color

  • fill color

zcl_turtle_svg

Generate svg primitives:

  • line
  • circle
  • polyline
  • polygon
  • text

Note that this only returns the svg string. Add these shapes to a turtle using turtle->append_svg.

Color schemes: A random color is used for each line. You can use turtle->set_color_scheme( ) to change the colors.

L-systems (or TurtleScript, if you will)

Wiki link

Define an initial state, a number of iterations and a set of replacement rules. These will be applied in each iteration. Finally, the symbols are translated into instructions and executed.

Supported operations:

  • movement
  • rotation
  • stack push/pop

See zcl_turtle_lsystem=>instruction_kind.

DATA(turtle) = zcl_turtle=>create( height = 800 width = 600 ).
turtle->goto( x = 200 y = 200 ).

DATA(parameters) = VALUE zcl_turtle_lsystem=>params(
  instructions = VALUE #(
    ( symbol = 'F' kind = zcl_turtle_lsystem=>instruction_kind-forward amount = 10 )
    ( symbol = '+' kind = zcl_turtle_lsystem=>instruction_kind-right amount = 90 )
    ( symbol = '-' kind = zcl_turtle_lsystem=>instruction_kind-left amount = 90 ) )
  num_iterations = 3
  initial_state = `F`
  rewrite_rules = VALUE #(
    ( from = `F` to = `F+F-F-F+F` )
  )
).

DATA(lsystem) = zcl_turtle_lsystem=>create(
  turtle = turtle
  parameters = parameters ).

lsystem->execute( ).
lsystem->show( ).

image

The stack can be used to generate plants or trees:

DATA(turtle) = zcl_turtle=>create( height = 800 width = 600 ).
turtle->goto( x = 300 y = 600 ).
turtle->set_angle( -90 ).

DATA(parameters) = VALUE zcl_turtle_lsystem=>params(
  instructions = VALUE #(
    ( symbol = `F` kind = zcl_turtle_lsystem=>instruction_kind-forward amount = 10 )
    ( symbol = `+` kind = zcl_turtle_lsystem=>instruction_kind-right amount = 25 )
    ( symbol = `-` kind = zcl_turtle_lsystem=>instruction_kind-left amount = 25 )
    ( symbol = `[` kind = zcl_turtle_lsystem=>instruction_kind-stack_push )
    ( symbol = `]` kind = zcl_turtle_lsystem=>instruction_kind-stack_pop )
  )
  num_iterations = 5
  initial_state = `F`
  rewrite_rules = VALUE #(
    ( from = `F` to = `F[+F]F[-F][F]` )
  )
).

DATA(lsystem) = zcl_turtle_lsystem=>create(
  turtle = turtle
  parameters = parameters ).

lsystem->execute( ).
zcl_turtle_output=>show( turtle ).

image

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].