GithubHelp home page GithubHelp logo

jujuadams / clean-shapes Goto Github PK

View Code? Open in Web Editor NEW
36.0 4.0 5.0 907 KB

Antialiased primitives library for GameMaker Studio 2023.1

License: MIT License

Game Maker Language 82.27% GLSL 17.73%
gamemaker gamemaker-studio-2 gms2 primitive shape rectangle circle polyline linestrip line

clean-shapes's People

Contributors

bakumoe avatar jujuadams avatar xordev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

clean-shapes's Issues

Rendering on iPhone SE 2nd Ed. broken (upstream)

Also tested on v2023.6; rendered results are broken for the test project.
Using latest runtime, built with Xcode 15.1.
Target device is iPhone SE 2nd generation, with iOS 16.1.2.

Attached is the result on iOS:
image0

And the expected result rendered on PC:
screenshot_1120 2024-01-12

Add offset to border of shape

Offset value for borders with positive numbers moving outwards and negative numbers moving inwards of the shape.

image

example:
.Border(thickness, offset, color, alpha)

CleanConvex wonkiness

Here's another thing I noticed

  • Border thickness is super inconsistent
  • Shape can break

Higher rounding and border thickness worsen the effects

CleanConvex wonky2

Code for the above gif:

var _x = 100, _y = 200, _size = 50, _offset = sin(current_time / 500);
CleanConvex([_x - _size, _y - _size,    _x + _size + (_offset * _size), _y - _size - (_offset * _size),    _x + _size, _y + _size,    _x - _size, _y + _size]).Blend(c_orange, 1.0).Border(10, c_red, 1.0).Rounding(0).Draw();
_x += _size * 3;
CleanConvex([_x - _size, _y - _size,    _x + _size + (_offset * _size), _y - _size - (_offset * _size),    _x + _size, _y + _size,    _x - _size, _y + _size]).Blend(c_orange, 1.0).Border(30, c_red, 1.0).Rounding(0).Draw();
_x += _size * 3;
CleanConvex([_x - _size, _y - _size,    _x + _size + (_offset * _size), _y - _size - (_offset * _size),    _x + _size, _y + _size,    _x - _size, _y + _size]).Blend(c_orange, 1.0).Border(10, c_red, 1.0).Rounding(30).Draw();
_x += _size * 3;
CleanConvex([_x - _size, _y - _size,    _x + _size + (_offset * _size), _y - _size - (_offset * _size),    _x + _size, _y + _size,    _x - _size, _y + _size]).Blend(c_orange, 1.0).Border(30, c_red, 1.0).Rounding(30).Draw();

Unintuitive to draw a border-only ellipse

Minor note on CleanShapes, I have to do this to get a border-only ellipse:

    CleanEllipse(focused_node.x, focused_node.y, 120, 80)
        .Blend(c_black, 0)
        .Border(5, focused_color, 1)
        .Draw();

If you remove that Blend it just draws a solid ellipse (using the border color), which isn't what I'd expect. Not sure if this is a bug/fixable, just mentioning it

Add toggleable vertex ordering fix

Triangles and convex polygons require that their coordinate be defined in a clockwise fashion. Clean Shapes should support an "autofix" behaviour that solves this problem for the user.

Defining less colours than segments on a CleanSpline with .BlendExt throws error

I mentioned this in the pull request, the spline test room was crashing due to it.

Assuming x1, y1, etc. are set, the following code would compile:

CleanSpline([x1, y1, x2, y2, x3, y3, x4, y4, x5, y5], 6) // more segments than colours
.BlendExt([c_white, 1.0, c_yellow, 1.0, c_fuchsia, 1.0, c_aqua, 1.0, c_lime, 1.0])
.Draw();

But this would throw an ungraceful error:

CleanSpline([x1, y1, x2, y2, x3, y3, x4, y4, x5, y5], 5) // same amount or less segments than colours
.BlendExt([c_white, 1.0, c_yellow, 1.0, c_fuchsia, 1.0, c_aqua, 1.0, c_lime, 1.0])
.Draw();
___________________________________________
############################################################################################
ERROR in
action number 1
of Draw Event
for object oTestSpline:

Push :: Execution Error - Variable Index [10] out of range [10] - -15.argument0(91,10)
 at gml_Script_anon___CleanClassSpline_gml_GlobalScript_CleanSpline_5301___CleanClassSpline_gml_GlobalScript_CleanSpline (line 201) -             var _colour = merge_colour(_inputArray[_int], _inputArray[_int + 2], _frac);
############################################################################################
gml_Script_anon___CleanClassSpline_gml_GlobalScript_CleanSpline_5301___CleanClassSpline_gml_GlobalScript_CleanSpline (line 201)
gml_Object_oTestSpline_Draw_0 (line 1) - CleanSpline([x1, y1, x2, y2, x3, y3, x4, y4, x5, y5], 5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.