{"id":4053373,"name":"github.com/jphsd/texture","ecosystem":"go","description":"Package texture contains functions that can be combined to create image textures.\n\nHere's a simple example that creates a Perlin value field and renders it to an image:\n\nFields are interfaces that support returning a value for any given point in the field.\n\nThree types of texture field are supported:\n\nAll fields provide an Eval2(x, y float64) function which takes any x and y and\nreturns either a value, vector or color.\nIf a field type doesn't support the entire 2D plane, then it must return 0,\n{0, ..., 0}, or image/color.Black for values of x and y not supported.\n\nA texture is a tree made up of field nodes and leaves.\n\nA field is considered a leaf if it is not dependent on any other fields.\nExamples of leaves are the gradient fields LinearGradient, RadialGradient and ConicGradient.\n\nAny field that relies on another field or fields is considered a node.\nExamples of nodes are the filter fields like AbsFilter, ClipFilter and InvertFilter.\nAll of these require at least one source field in order to operate.\n\nTextures are built from the leaves upward until a root node has been created.\nThis node can then be passed to a function that will realize it, such as NewTextureRGBA which generates\nan image.RGBA by repeatedly calling the root's ColorField Eval2 function for each image pixel.\n\n1D leaves vary only in one dimension, typically x.\n\nDifferent rotations, scalings and offsets can be obtained using Transform.\n\nAs the name suggests, these return a single value independent of the location within the field.\n\nThis field defines a gradient going from left to right using a Wave starting at 0 and repeating as\na function of the wave's wave length (lambda).\n\n2D leaves vary in x and y.\n\nDifferent rotations, scalings and offsets can be obtained using Transform.\n\nA collection of leaves for generating triangles, squares and hexagonal chequer boards.\nThe size of the cells is determined by the scale value.\n\nThe triangle and square boards are colored -1 and 1, whereas the hexagonal board is colored -1, 0 and 1.\n\nThis field defines a gradient that rotates around {0,0} using a Wave starting at 0 and mapping x\nto theta / (2 * Pi).\n\nThe image field uses the underlying image to figure the color value to return for any given location.\nSupported interpolations are NearestInterp, LinearInterp, CubicInterp, P3Interp and P5Interp.\n\nThis field provides Perlin noise (aka gradient noise) using the supplied seed.\nThe field repeats over [256,256]. See Perlin93.\n\nThis field defines a gradient that extends from {0,0} using a Wave starting at 0 and mapping to the\nabsolute distance from {0,0}.\n\nThis field is defined by a graphics2d.Shape.\nLocations within the shape return 1 and all others -1.\n\nLike the heading says, these are 2D field generator experiments, your mileage may vary.\n\nFilters are nodes that do something with the value supplied by their source.\nThey map values in [-1,1] to another in [-1,1].\nSome filters take A and B parameters, in which case the value filtered is A*value+B\n\nThe expressive range of the texture package is due to the ability to combine multiple source\nfields together using some heuristic.\n\nConvert between F, VF and CF fields\n\nTransformers affect the value of x and y used when a field's Evals method is called.\nThey map (x, y) to (x', y').\n\nThis transformer applies an affine transform graphics2d.Aff3 to input coordinates allowing for translations,\nrotations, scalings and shearings.\nWhen something other than a gradient in x is required, the affine transform can be used to move, scale and rotate\nit to the desired location.\n\nTiler transforms allow finite areas to be replicated across the infinite plane.\nUseful for creating repeating patterns and images.\n\nThe relection transforms take a line defined by two points as the location of a mirror.\nPoints on the positive side of the line remain unchanged while those on the negative are remapped.\n\nThe warp transforms provide generalized image warping functionality not provided by the preceding.\nThey rely on a function WarpFunc to map points from one domain to the other.\n\nThe displace transforms use two fields to perturb the location returned from a third field.\nThe degree of perturbation is controlled by a scaling factor.\nThe second version of each transform allows a generalized affine transform to be supplied rather than just\na fixed scaling.\n\nDistort provides a self referential transform that samples the field three times, once each for the x and y\ndisplacements and once with the new x' and y'.\n\nThese transforms apply a resolution filter to x and y.\nNote that pixelate does not perform true pixelation in terms of averaging values over the desired resolution.\n\nThese transforms replace y with a fixed value when performing Eval2(x, y).\nStrip also implements the Wave interface and can be used in gradient leaves.\n\nThree type of fractal nodel are available, Fractal, VariableFractal and IFS.\n\nFractal nodes are a combination of both combiner and transformer nodes.\nEach location is evaluated for each octave, with an affine transform being applied between evaluations to x and y,\nand the resulting values then combined using an OctaveCombiner.\n\nTwo OctaveCombiner are provided\n\nIFS, or Iterated Fractal Systems Barnsley88, take a series of contractive affine transformations and apply them\nrepeatedely to some depth (akin to octaves above).\n\nAny type that implements Wave can be used to drive a gradient field.\nThis interface defines two methods - Eval(x float64) which returns a value in [-1, 1],\nand Lambda() which returns the wave length of the wave.\n\nThree types are defined as starting points and allow a variety of waveforms to be generated:\n\nAll of them utilize the non-linear functions provided in graphics2d.\nFor convenience these are wrapped in NonLinear, primarily so that the output is mapped from\n[0,1] to [-1,1], and so that the slope name can be captured for JSON marshalling.\n\nNLWave takes a slice of wave lengths and a slice of slopes, together with flags that indicate\nif slopes should be mirrored, and whether only a single cycle shold be generated.\n\nDCWave takes a slice of one or two wave lengths and a slice of one or two slopes, together with\na flag that indicate if only a single cycle shold be generated.\n\nIf only one wave length is provided, then it is used for both the rising and falling halves of the wave.\nIf only one slope type is provided, then it is used for both the rising and falling halves of the wave.\nHence, providing only one wave length and slope type is equivalent to mirroring.\n\nWhen once is set, values less than 0 or greater than the wave length are returned as -1.\n\nACWave takes a slice of one, two or four wave lengths and a slice of one, two or four slopes, together\nwith a flag that indicate if only a single cycle shold be generated. Note this waveform starts at 0, unlike\nthe other two which both start at -1.\n\nIf only one wave length is provided, then it is used for all quadrants of the wave.\nIf only one slope type is provided, then it is used for all quadrants of the wave.\nIf only two wave lengths are provided, then they are used for both halves of the wave.\nIf only two slope types are provided, then they are used for both halves of the wave.\n\nWhen once is set, values less than 0 or greater than the wave length are returned as 0.\n\nTextures are realized by calling the root node's Eval2(x, y) method.\nImage wrappers are provided that perform this step lazily and in a cacheable fashion.\nThe wrapper is responsible for defining the image bounds, the texture offset and step values.\nThese images can then be passed to image/draw.Draw, graphics2d.RenderShape or to\ngraphics2d.NewFilledPen as source images.\n\nCaching determines whether a value is evaluated once and cached, or always evaluated.\nIf a particular texture subgraph is expensive to compute, it may be better to evaluate it's domain\nonce and cache it in an image that can then be referenced through an Image node.\n\nThe 2D graphics packages in other languages, such as Java and SVG, have a notion of a gradient fill\nor paint.\nGo, however, doesn't since it's golang.org/x/image/vector.Draw takes an image.\nTo address this texture has some utility functions that use simple gradient textures to create the same\neffect.\n\nThe gradients are all value fields and mapped to either image/color.Gray16 or image/color.RGBA.\nIn the latter case, by using github.com/jphsd/graphics2d/image.Colorizer.","homepage":"https://github.com/jphsd/texture","licenses":"Apache-2.0","normalized_licenses":["Apache-2.0"],"repository_url":"https://github.com/jphsd/texture","keywords_array":[],"namespace":"github.com/jphsd","versions_count":13,"first_release_published_at":"2022-10-05T04:05:08.000Z","latest_release_published_at":"2024-01-10T05:35:51.000Z","latest_release_number":"v0.0.0-20240110053551-4982ab182aff","last_synced_at":"2026-03-27T08:34:33.119Z","created_at":"2022-04-12T10:22:21.423Z","updated_at":"2026-03-27T08:34:33.119Z","registry_url":"https://pkg.go.dev/github.com/jphsd/texture","install_command":"go get github.com/jphsd/texture","documentation_url":"https://pkg.go.dev/github.com/jphsd/texture#section-documentation","metadata":{},"repo_metadata":{"uuid":"382418215","full_name":"jphsd/texture","owner":"jphsd","description":"Procedural texture generation package.","archived":false,"fork":false,"pushed_at":"2023-03-01T17:36:31.000Z","size":23170,"stargazers_count":17,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-03-02T10:49:51.515Z","etag":null,"topics":["bryce-3d","pcg","pcgen","procedural-generation","texture","texture-synthesis"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"logo_url":null,"metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-02T17:29:44.000Z","updated_at":"2023-03-02T10:49:51.516Z","dependencies_parsed_at":"2022-07-07T23:29:06.066Z","dependency_job_id":null,"html_url":"https://github.com/jphsd/texture","commit_stats":null,"repository_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jphsd%2Ftexture","tags_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jphsd%2Ftexture/tags","manifests_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jphsd%2Ftexture/manifests","owner_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jphsd","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":108921946,"host_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"http://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names"}},"repo_metadata_updated_at":"2023-03-21T19:25:58.254Z","dependent_packages_count":0,"downloads":null,"downloads_period":null,"dependent_repos_count":0,"rankings":{"downloads":null,"dependent_repos_count":9.345852080216646,"dependent_packages_count":6.999148183520997,"stargazers_count":4.610134034838059,"forks_count":7.012503408949347,"average":6.9919094268812625},"purl":"pkg:golang/github.com/jphsd/texture","advisories":[],"docker_usage_url":"https://docker.ecosyste.ms/usage/go/github.com/jphsd/texture","docker_dependents_count":null,"docker_downloads_count":null,"usage_url":"https://repos.ecosyste.ms/usage/go/github.com/jphsd/texture","dependent_repositories_url":"https://repos.ecosyste.ms/api/v1/usage/go/github.com/jphsd/texture/dependencies","status":null,"funding_links":[],"critical":null,"issue_metadata":{"last_synced_at":"2023-05-18T20:30:48.957Z","issues_count":0,"pull_requests_count":8,"avg_time_to_close_issue":null,"avg_time_to_close_pull_request":669.375,"issues_closed_count":0,"pull_requests_closed_count":8,"pull_request_authors_count":2,"issue_authors_count":0,"avg_comments_per_issue":null,"avg_comments_per_pull_request":0.0,"merged_pull_requests_count":8,"bot_issues_count":0,"bot_pull_requests_count":1,"past_year_issues_count":0,"past_year_pull_requests_count":1,"past_year_avg_time_to_close_issue":null,"past_year_avg_time_to_close_pull_request":4652.0,"past_year_issues_closed_count":0,"past_year_pull_requests_closed_count":1,"past_year_pull_request_authors_count":1,"past_year_issue_authors_count":0,"past_year_avg_comments_per_issue":null,"past_year_avg_comments_per_pull_request":0.0,"past_year_bot_issues_count":0,"past_year_bot_pull_requests_count":1,"past_year_merged_pull_requests_count":1},"versions_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Fjphsd%2Ftexture/versions","version_numbers_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Fjphsd%2Ftexture/version_numbers","dependent_packages_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Fjphsd%2Ftexture/dependent_packages","related_packages_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Fjphsd%2Ftexture/related_packages","codemeta_url":"https://packages.ecosyste.ms/api/v1/registries/proxy.golang.org/packages/github.com%2Fjphsd%2Ftexture/codemeta","maintainers":[]}