Modernize gfx#6
Merged
Merged
Conversation
…ax.X / r.Min.Y < r.Max.Y in both DrawPalettedImage and DrawPalettedLayer
…IntFilledRectangle
…ltiplied-alpha blend
… cmp.Ordered constraints
…nc-backed implementation
…y instead of partially black
…hout gaps and right/bottom edge pixels aren't skipped
… images index Pix correctly
004a9b7 to
4c18041
Compare
…et, and re-embed README snippets
…stem renders instead of falling back to the background
… instead of looking up the color at world origin
… coordinates return 0 / no-op instead of panicking
…ose a column or row to int() truncation
…TPClient(nil) no-op, and TileServer.DrawTile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modernization pass though the
gfxpackage, extracted HTTP related code into its own package (gfxhttp).Will hopefully address what is asked for in #5
Important
This package is just something I've made for fun.
Breaking API changes
(require code edits at call sites)Removed from root
gfx— moved to newgfxhttpsubpackage:gfx.HTTP(type)gfx.HTTPClient(var)gfx.Get,gfx.GetPNG,gfx.GetImage,gfx.GetTilesetgfx.GeoTileServer(type)gfx.GTS(constructor)gfx.GeoTileServer.{GetImage, DrawTile, DrawNeighbors, DrawTileAndNeighbors}gfx.GeoTile.GetImage(method on still-presentGeoTile)Replacement:
import "github.com/peterhellberg/gfx/gfxhttp"Renamed:
gfx.DrawCicleFast → gfx.DrawCircleFast(typo fix; no alias kept)Signature changes:
gfx.SortSlice(slice any, less func(i, j int) bool)→gfx.SortSlice[S ~[]E, E any](s S, cmp func(a, b E) int).cmp.Compare-style int(matches
slices.SortFunc).gfx.Sign,gfx.Clamp,gfx.Lerpare now generic on newgfx.Numeric/gfx.Signedconstraints (orcmp.OrderedforClamp).Float64 callers keep working via type inference.
gfx.Lerp(0, 2, 0.1)(untyped int literals) now infersT = intand returns
0. Pass float literals orgfx.Lerp[float64](...).f := gfx.Sign) now needs toinstantiate (
f := gfx.Sign[float64]).Module floor:
go.modraised fromgo 1.17togo 1.25. Consumers must use Go 1.25 or newer.Changes
go: Bump versions to current supported versions1.25.xand1.26.xrand: Replaced the deprecated rand.Seed call with a package-level*rand.Randpalette: Palette.Random now callsgfx.RandIntninstead ofrand.Intndraw: Replaced them.X != w / m.Y != htermination withr.Min.X < r.Max.X / r.Min.Y < r.Max.Yin bothDrawPalettedImageandDrawPalettedLayerdraw: RenamedDrawCicleFast→DrawCircleFastgfx: Replaceinterface{}withanydraw_int: Removed bare return statements in DrawIntRectangle and DrawIntFilledRectangleimage: Replaced the per-pixelDrawColorOverpath with an inline premultiplied-alpha blendgfx: Moved HTTP related code into newgfxhttppackagegfxhttp: Threadcontext.Contextthrough all requestsmath: MakeSign,Clamp, andLerpgeneric via newNumeric,Signed, andcmp.Orderedconstraintssort: ReplaceSortSlicereflection wrapper with genericslices.SortFunc-backed implementationlicense: Update copyright yeardoc: Update copyright yearexamples: Update examplesblock: Color every vertex inBlock.Trianglesso faces render uniformly instead of partially blacktriangle: RoundTriangle.BoundsMaxup so adjacent triangles meet without gaps and right/bottom edge pixels aren't skippedpaletted: HonorRect.MininPaletted.PixOffsetso non-origin Paletted images index Pix correctlygfx: Drop legacy// +builddirectives now thatgo.modis on Go 1.25examples: Usegfx.Vand keyedSignedDistanceliterals to satisfy go vet, and re-embed README snippetsgfx: Modernize counted for loops to range-over-int (go fix)examples/gfx-example-animation: Slice 5 palette colors so the flower stem renders instead of falling back to the backgrounddraw: Use the triangle's first vertex color inDrawTrianglesWireframeinstead of looking up the color at world originpaletted: Bounds-checkColorIndexAtandSetColorIndexso out-of-range coordinates return 0 / no-op instead of panickingblock: RoundBlock.DrawBoundsMaxup so fractionalRectedges don't lose a column or row toint()truncationgfxhttp: Add tests for rawGetresponse,GetImagedecode path,WithHTTPClient(nil)no-op, andTileServer.DrawTiledoc: ListWithHeaderalongside the othergfxhttpoptionsgfx: Drop!tinygobuild constraints from files whose imports TinyGo now supports (hopefully)